Announcement

Collapse
No announcement yet.

PROJECT: ShowOnMap

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #76
    Originally posted by E
    would SpotFound is a valid position be tested by if( SpotFound == 0) or just if(!SpotFound)? I thought MapPoint doesnt work like a sint32?
    Neither the first thing nor the second one. So of what type is SpotFound, were it is stored in the memory?

    Actually you have to give it an invalid value so that you can use it for testing. So what is the invalid value?

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

    Comment


    • #77
      you mean something like:

      Code:
      if(!g_theWorld->GetCell(SpotFound)) ||
      Formerly known as "E" on Apolyton

      See me at Civfanatics.com

      Comment


      • #78
        Originally posted by E
        you mean something like:

        Code:
        if(!g_theWorld->GetCell(SpotFound)) ||
        No, I don't mean this. Actually if SpotFound is invalid then GetCell will crash.

        Actually I asked you of what type SpotFound is and where it is stored in the memory here the two possibilities: On the stack or on the heap?

        And I asked you what the invalid value for such a thing is like a MapPoint. So all you have to do is to figure out, whether it is an object or just a pointer. If it is a pointer you have to initialize it with NULL, otherwise you have to look at the constructor of the MapPoint and figure out what are its parameters. You have to see whether there are any default parameters. And if these default parameters can be valid.

        Well that should be enough tasks for now. Oh and of course I want to see the answers posted here.

        And by the way if you can't figure these out, I expect that you ask for instance where you can find some of the answers if it isn't in your C++ book.

        -Martin
        Last edited by Martin Gühmann; April 28, 2006, 15:57.
        Civ2 military advisor: "No complaints, Sir!"

        Comment


        • #79
          dp

          -Martin
          Civ2 military advisor: "No complaints, Sir!"

          Comment


          • #80
            Originally posted by Martin Gühmann


            No, I don't mean this. Actually if SpotFound is invalid then GetCell will crash.

            Actually I asked you of what type SpotFound is and where it is stored in the memory here the two possibilities: On the stack or on the heap?

            And I asked you what the invalid value for such a thing is like a MapPoint. So all you have to do is to figure out, whether it is an object or just a pointer. If it is a pointer you have to initialize it with NULL, otherwise you have to look at the constructor of the MapPoint and figure out what are its parameters. You have to see whether there are any default parameters. And if these default parameters can be valid.

            Well that should be enough tasks for now. Oh and of course I want to see the answers posted here.

            And by the way if you can't figure these out, I expect that you ask for instance where you can find some of the answers if it isn't in your C++ book.

            -Martin
            I looked at MapPoint.cpp and didn't see anything. But what do you mean by type? you mean sint32 etc?
            stack vs heap? what are they.

            I'll check out my book later tonight but generally I'm real weak on terminology. I've been able to get things to work because I've been able to put bricks together even if I don't know they are called bricks. If you get my analogy.
            Formerly known as "E" on Apolyton

            See me at Civfanatics.com

            Comment


            • #81
              Originally posted by E
              I looked at MapPoint.cpp and didn't see anything.
              Actually it is full of all the stuff I asked you for. Well maybe you should have a look on the header file too.

              Originally posted by E
              But what do you mean by type?
              I thought of the type of SpotFound. It is a variable. And as every variable in C++ it has type. I just asked what it is its type.

              Originally posted by E
              you mean sint32 etc?
              That's a possibility. But in the case of SpotFound it isn't. It is something else.

              Originally posted by E
              stack vs heap? what are they.
              Stacks and heaps are certain kind of memories. The places where your objects are stored. The stack is automatic memory, this means you can put objects on it and they are deleted automaticly. Heap objects have to be deleted manually.

              On the stack you put objects and you can only remove the top most object, therefore it is automatic. But this way you can't use your object at a varity of places in your program.

              On the heap you can put objects everywhere (actually this is done automatically for you). Unfortunately access is slower, a memory address must be found first at which the object can be stored.

              However I could go much more into details here, but the main point of the heap is that you use pointers on the heap objects and don't use the objects themselves.

              Originally posted by E
              I'll check out my book later tonight but generally I'm real weak on terminology. I've been able to get things to work because I've been able to put bricks together even if I don't know they are called bricks. If you get my analogy.
              That's the problem, if you don't know what a constructor is then you don't know how a particular kind of object is initialized. And of course there are then much more things you don't understand.

              So here is a little task for you: Find the definitions for constructor, deconstructor and for the default values of the constructor. To answer these questions you have your book and of course the whole world wide web.

              -Martin
              Civ2 military advisor: "No complaints, Sir!"

              Comment


              • #82
                Code:
                		for(it.Start(); !it.End(); it.Next()) {
                			if(it.Pos() == pos) continue;
                
                			Cell *cell = GetCell(it.Pos());
                			Assert(cell);
                			if(!cell) continue;
                what does the assert do for this? is this a NULL check?

                or more like:

                Code:
                void Director::TradeActorDestroy(TradeRoute routeToDestroy)
                {
                	ListPos			pos, foundPos;
                	TradeActor		*tActor = NULL;
                
                	foundPos = pos = m_tradeActorList->GetHeadPosition();
                	for (uint32 i=0; iL(); i++) 
                	{
                		tActor = m_tradeActorList->GetNext(pos);
                		
                		Assert(tActor != NULL);
                		if(tActor->GetRouteID() == routeToDestroy)
                			break;
                		else
                			foundPos = pos;
                	}
                	if (foundPos) 
                	{
                		m_tradeActorList->DeleteAt(foundPos);
                		delete tActor;
                	}
                }
                Formerly known as "E" on Apolyton

                See me at Civfanatics.com

                Comment


                • #83
                  Originally posted by E
                  what does the assert do for this? is this a NULL check?
                  Yes this is a NULL check, but I doubt that this Assert will ever pop up. And for some reason I asked you of what type SpotFound is. There is a huge difference.

                  Anyway I gave you a little task and to find the answers at least for constructor and deconstructor can be found easily. I used google and within five minutes I got them. So actually it is just a copy and paste job.

                  -Martin
                  Civ2 military advisor: "No complaints, Sir!"

                  Comment


                  • #84
                    Originally posted by Martin Gühmann
                    Anyway I gave you a little task and to find the answers at least for constructor and deconstructor can be found easily. I used google and within five minutes I got them. So actually it is just a copy and paste job.
                    Actually I asked you for the answers of these question:

                    What is a constructor?
                    What is a deconstructor? (Actually deconstructor is the wrong term, but I leave it to you to find the right term.)

                    So were are the answers of these questions? This is a five minute job, just open google, look for c++ constructor and vola and than click on the "C++ Tutorial - Lesson 20: Copy Constructors" link and you are on a page with a tutorial and if you click on the link below you have the definition of constructor and a link to answer the second question. So what is so difficuilt about this?

                    But all you did was this:

                    Code:
                    if((!g_theWorld->GetCell(SpotFound)) ||
                    I already told you that this doesn't work and even crash if SpotFound is really an invalid map position, however it isn't and that's becuase you don't use the right constructor.

                    And by the way I told you several times that you should get the indentation right, and don't tell me it is the forum, I looked into the source code.

                    -Martin
                    Civ2 military advisor: "No complaints, Sir!"

                    Comment


                    • #85
                      I wasn't finished with that code. I'm still reading up on it in my c++ book. the other stuff i posted was stuff i worked on before but didn't commit.

                      as for constructor i went to this http://cplus.about.com/b/a/093572.htm and didn't see the definition. but to tell you they use a lot of terminology that i'm not familiar with and the examples don't look much like the ctp2 code so it takes me a while to figure it out.


                      A copy constructor is a special constructor that takes as its argument a reference to an object of the same class and creates a new object that is a copy. Learn about shallow and deep copies of objects.
                      Formerly known as "E" on Apolyton

                      See me at Civfanatics.com

                      Comment


                      • #86
                        why do i get nothing for deconstructor and a lot for destructor?
                        Formerly known as "E" on Apolyton

                        See me at Civfanatics.com

                        Comment


                        • #87
                          Originally posted by E
                          why do i get nothing for deconstructor and a lot for destructor?
                          Because of this (Well my fault):

                          Originally posted by Martin Gühmann
                          What is a deconstructor? (Actually deconstructor is the wrong term, but I leave it to you to find the right term.)
                          So and what is now the correct term? It shouldn't be too difficult.

                          And by the way there is a link to the definition of constructor in chapeter 20 of that tutorial.

                          -Martin
                          Last edited by Martin Gühmann; April 30, 2006, 14:38.
                          Civ2 military advisor: "No complaints, Sir!"

                          Comment


                          • #88
                            Martin,
                            I'm still working on the definitions but I was playing the new 568 build and it seems that the show on map was working fairly well, oddly and thats with this code if((!g_theWorld->GetCell(SpotFound)) ||

                            so it didn't crash but it created the improvement in various spots (N, NW, and SE observed). Well, except it did not create the pyramids but it might have to do with that zulu city already having the hanging gardens and it didn't create the light house in water.

                            I think one limit though is that the iterator is limited to the city radius when it should be the border the radius, it will give more options.

                            Other than that not sure how to get it working better so I'll get back to my reading.
                            Formerly known as "E" on Apolyton

                            See me at Civfanatics.com

                            Comment


                            • #89
                              Originally posted by E
                              I'm still working on the definitions but I was playing the new 568 build and it seems that the show on map was working fairly well, oddly and thats with this code if((!g_theWorld->GetCell(SpotFound)) ||
                              That's beacuase SpotFound isn't an invalid position on the map, to be precise it is the tile with the coordinates x = 0 and y = 0. Actually I told you to figure this out ion your own by looking on the default constructor.

                              With this in mind programming it like that does not represent the pseudo code I gave you.

                              But now if you manage to initialize SpotFound so that it is an invalid spot, this will crash.

                              Originally posted by E
                              so it didn't crash but it created the improvement in various spots (N, NW, and SE observed). Well, except it did not create the pyramids but it might have to do with that zulu city already having the hanging gardens and it didn't create the light house in water.
                              Well it could tried to create the pyramids at tile (0,0) or they are just hidden by the hanging gardens.

                              Originally posted by E
                              I think one limit though is that the iterator is limited to the city radius when it should be the border the radius, it will give more options.
                              Maybe you find something in const.txt for that.

                              Originally posted by E
                              Other than that not sure how to get it working better so I'll get back to my reading.
                              Well read first.

                              -Martin
                              Civ2 military advisor: "No complaints, Sir!"

                              Comment


                              • #90
                                Ok,
                                a constructor makes a basic onject. It has an address but isn't an object. Kind of like an empty shortcut

                                a destructor "~" kills the whole object.

                                how are these going to apply to my showonmap?
                                Formerly known as "E" on Apolyton

                                See me at Civfanatics.com

                                Comment

                                Working...
                                X