Announcement

Collapse
No announcement yet.

DEBUG: The only one ConstructionTile used bug

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

  • DEBUG: The only one ConstructionTile used bug

    If you ever played around with the ContructionTiles flags in tileimp.txt then you noticed that unlike in CTP1 only one of the three ContructionTiles is used instead of three. While I was trying to fix it I found another bug, the PercentComplete function in TerrImproveData.cpp:

    Code:
    sint32 TerrainImprovementData::PercentComplete() const
    {
    	sint32 totalTurns, turnsDone;
    
    	MapPoint p = m_point;
    	//Function replaced by Martin Gühmann
    	//Original function always returns 10 instead of the total production turns.
    //	totalTurns = terrainutil_GetTimeToBuild(p, m_type, m_transformType);
    	totalTurns = terrainutil_GetProductionTime(m_type, p, m_transformType);
    	turnsDone = totalTurns - m_turnsToComplete;
    	if (totalTurns == 0) return 100;
    	return (turnsDone * 100) / totalTurns;
    }
    I noticed that the total production time of a terrain improvement should be returned here. But terrainutil_GetTimeToBuild just returns 10, no matter what you put into the function. From What I understand the terrainutil_GetProductionTime should do the same. And it looks now with the change the function PercentComplete function does work.

    Here is the actual fuction I modified, I added another argument to the parameter list in terrainutil.h and in tiledraw.cpp:

    Code:
    void TiledMap::DrawPartiallyConstructedImprovement(aui_Surface *surface, uint32 env, sint32 type, sint32 x, sint32 y, uint16 index, BOOL fog, sint32 percentComplete)
    //Added sint32 percentComplete by Martin Gühmann
    {
    //....
    	const TerrainImprovementRecord *rec = g_theTerrainImprovementDB->Get(type);
    /*	//MG: Origianal code outcommented and replaced by the code below
    	if(index >= rec->GetNumConstructionTiles()) {
    		if(rec->GetNumConstructionTiles() < 1) {
    			data = m_tileSet->GetImprovementData(1);
    		} else {
    			data = m_tileSet->GetImprovementData((uint16) rec->GetConstructionTiles(rec->GetNumConstructionTiles() - 1));
    		}
    	} else {
    		data =  m_tileSet->GetImprovementData((uint16) rec->GetConstructionTiles(index));
    	}*/
    	if(rec->GetNumConstructionTiles() < 1) {
    		data = m_tileSet->GetImprovementData(1);
    	}
    //	else if(rec->GetNumConstructionTiles() < 2) {
    //		data = m_tileSet->GetImprovementData((uint16) rec->GetConstructionTiles(rec->GetNumConstructionTiles() - 1));
    //	} 
    	else {
    		uint16 ctIndex = (uint16)floor((rec->GetNumConstructionTiles() * percentComplete)/100 );
    		data = m_tileSet->GetImprovementData((uint16) rec->GetConstructionTiles(ctIndex));
    	//	Original code:
    	//	data = m_tileSet->GetImprovementData((uint16) rec->GetConstructionTiles(index));
    	}
    //....
    }
    The TileImprovement graphic for unfinished tileimps is now determined on the number of CunstructionTiles in tileimp.txt and the completion state of the improvement. Unfortunatly while I was steting this code in the debug build I got much more Assertion failure messages then before. I think I have tested my last modification and the rush build fix with it but I am not sure at 100%.

    And there is another problem, the improvement graphic is only updated when the improvement is in the vision range of a unit and then only when the unit is moved or you enabled GodMode via the Cheat Editor. If it is just in your city radius the graphic isn't updated.

    If you like to test these files yourself download the attachment. It includes:

    TerrImprovementData.cpp
    tiledraw.cpp
    tiledmap.h

    They aren't in an directory structure so you have to put them on your own into the according directories.

    TerrImprovementData.cpp goes into the ..\ctp2_code\gs\gameobj\ folder.
    And the other two files go into the ..\ctp2_code\gfx\tilesys\ folder.

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

  • #2
    Re: The only one ConstructionTile used bug

    Originally posted by Martin Gühmann
    Unfortunatly while I was steting this code in the debug build I got much more Assertion failure messages then before. I think I have tested my last modification and the rush build fix with it but I am not sure at 100%.
    I figuered out why I got more debug assertions: I switched to GoodMod of course without its slic files, so finally we have also to test the game on mods.

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

    Comment


    • #3
      Hi Martin,
      You mention you can only see the partially constructed improvement if a unit can see it and not if it is just within your city radius. Is this also true of any ordinary improvement you own? For instance, if someone comes and pillages a tile improvement in your city radius, do you not see it? Do you think that this is a problem?

      Comment


      • #4
        No it is just a problem of not finished tile improvements that their graphics are only updated when you enable good mode or one of your units is moving near the not finished tile improvement.

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

        Comment


        • #5
          I guess I meant whether or not you think we should change the display behaviour of title improvements. This is controlled by tiledraw.cpp, we can change it if you think it appropriate.

          Comment


          • #6
            I already changed the display behaviour for unfinished tile improvements, because this way it comes closer to the CTP1 display behaviour of unfinished tile improvements. The problem is that I don't know where the part of the function is located were the unfinished tile improvements are updated. For finished improvements there is no need to update them every turn, because they don't change their graphics every or every second turn like for the unfinished tile improvemnts. So I think the problem is that this draw function isn't recalled every turn. Of course the is no need for it, as long as nothing changes. I guess the programmers just forgot the construction tiles, because they give them all the same graphics.

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

            Comment

            Working...
            X