Announcement

Collapse
No announcement yet.

PROJECT: ShowOnMap

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

  • FIrst attempt I redid it to be:

    Code:
    	MapPoint SpotFound(-1,-1);
    	CityInfluenceIterator it(point, GetVisionRadius());  //m_sizeIndex GetVisionRadius()
    	
    	sint32 s;
    	for(s = 0; s < rec->GetNumShowOnMap(); s++) {
    		const TerrainImprovementRecord *trec = g_theTerrainImprovementDB->Get(s);
    		for(it.Start(); !it.End(); it.Next()) {
    			if(point == it.Pos())
    				continue;
    
    			if(terrainutil_CanPlayerSpecialBuildAt(trec, m_owner, it.Pos())){
    				if (SpotFound.IsValid()){
    					Cell *ncell = g_theWorld->GetCell(it.Pos());   
    					Cell *ocell = g_theWorld->GetCell(SpotFound);
    				
    					if(ncell->GetNumDBImprovements() < ocell->GetNumDBImprovements()  
    					){
    						SpotFound = it.Pos(); 
    					}
    				} else {
    					SpotFound = it.Pos(); 
    				}
    			}
    		}
    		g_player[m_owner]->CreateSpecialImprovement(rec->GetShowOnMapIndex(s), SpotFound, 0);
    	}
    and nothing happened...off to double check
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment


    • Actually now you would need to use the debug version, but you can also use message boxes to get some pieces of information out of it. Well actually this is a dirty hack but works. To do this you can insert this little piece of code:

      Code:
      char[1024] buff;
      sprintf(buff, "This code is executed!");
      MessageBox(NULL, buff, buff, MB_OK)
      Alternatively the message box can also give out some values:

      Code:
      sprintf(buff, "Num of tilimps at old loc: %i, num of tileimps at new loc: %i", ocell->GetNumDBImprovements(), ncell->GetNumDBImprovements());
      Note the %i is the placeholder for an integer and %s for a string. You can use the help of MSVS to get to know more about the sprintf function.

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

      Comment


      • Code:
        	// How does the default constructor initialize MapPoint?
        	// Does the default constructor create a valid MapPoint?
        	// If not yes, how to create an invalid MapPoint?
        For some reason I put those questions into the code, E. And what did you do? You just removed without showing that you found the answers. However interestingly in your last post in this thread you show that you have found the answers.

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

        Comment


        • For bonus points, work out questions 2 and 3 for doughnut shape worlds.

          Comment


          • Originally posted by Fromafar
            For bonus points, work out questions 2 and 3 for doughnut shape worlds.
            Nice, Fromafar you are still here. Anyway, I should use a bool in that case, it would have been so nice...

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

            Comment

            Working...
            X