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:
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:
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
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; }
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)); } //.... }
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
Comment