Help with GameTextManager.cpp (again)

CaptainMidnight

Warlord
Joined
Apr 16, 2006
Messages
141
I've run a ground yet again with GamesTextManager.cpp, I really don't understand what's going on here and can't find any manuals or guides to help me out. Anyway, I extracted a 'Civic building class Commerce change' tag from Afforress's A New Dawn. It works great and so far the AI works too. But I can't get the game text to display properly and I rather not use the user unfriendly :

GameTextManager.cpp (Compiles fine and looks ok):
Code:
/*************************************************************************************************/
/** CMEDIT: Building Class Commerce Change (Original Code by Afforess)							**/
/** DATE: 27/04/2012																			**/
/*************************************************************************************************/
	iLast = 0;
	int iCount = 0;
	for (iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)
	{
		for (iJ = 0; iJ < NUM_COMMERCE_TYPES; iJ++)
		{
			BuildingTypes eBuilding;
			if (bPlayerContext && NO_PLAYER != GC.getGameINLINE().getActivePlayer())
			{
				eBuilding = (BuildingTypes)GC.getCivilizationInfo(GC.getGameINLINE().getActiveCivilizationType()).getCivilizationBuildings(iI);
			}
			else
			{
				eBuilding = (BuildingTypes)GC.getBuildingClassInfo((BuildingClassTypes)iI).getDefaultBuildingIndex();
			}

			if (eBuilding != NO_BUILDING && GC.getCivicInfo(eCivic).getBuildingClassCommerceChange(iI, iJ) != 0)
			{
				szFirstBuffer.Format(L"%s%s", NEWLINE, gDLL->getText("TXT_KEY_CIVIC_BUILDING_COMMERCE_CHANGE", GC.getCivicInfo(eCivic).getBuildingClassCommerceChange(iI, iJ), GC.getCommerceInfo((CommerceTypes)iJ).getChar()).c_str());
				CvWString szBuilding;
				szBuilding.Format(L"<link=literal>%s</link>", GC.getBuildingInfo(eBuilding).getDescription());
				setListHelp(szHelpText, szFirstBuffer, szBuilding, L", ", (GC.getCivicInfo(eCivic).getBuildingClassCommerceChange(iI, iJ) != iLast));
				if (iLast == GC.getCivicInfo(eCivic).getBuildingClassCommerceChange(iI, iJ)) iCount++;
				iLast = GC.getCivicInfo(eCivic).getBuildingClassCommerceChange(iI, iJ);
				if (iCount > 3) iCount = iLast = 0;
			}
		}
	}
/*************************************************************************************************/
/** COMMENT:																					**/	
/** CMEDIT: End																					**/	
/*************************************************************************************************/

The XML is like this:

Code:
<TEXT>
		<Tag>TXT_KEY_CIVIC_BUILDING_COMMERCE_CHANGE</Tag>
		<English>[ICON_BULLET]%D1_Change %F2 from[SPACE]</English>
		<French>[ICON_BULLET]%D1_Change %F2 :[SPACE]</French>
		<German>[ICON_BULLET]%D1_Change %F2 durch die Modernisierung[SPACE]</German>
		<Italian>[ICON_BULLET]%D1_Change %F2 da[SPACE]</Italian>
		<Spanish>[ICON_BULLET]%D1_Change %F2 por[SPACE]</Spanish>
	</TEXT>

But I just get a funny read out (see the attach screenie). It should display "+1 Gold, +1 Culture, +1 Beaker from Granary". I have tried different XML structures but to no avail. Am I missing something obvious?
 

Attachments

  • Pic.jpg
    Pic.jpg
    112.8 KB · Views: 94
The fix would be to keep track of more stuff to determine when the output should be adjusted.

The code is currently set up to only track when the amount of a commerce change changes. It does not pay attention to whether the type of commerce has changed, so a single building with multiple changes that are all of the same amount will cause issues like you see. See what happens if you make the changes 1, 2, 3, 4 instead of 1, 1, 1, 1 (it should work OK in that case).

I also suspect the code will have trouble in other cases, like it might have issues with multiple buildings with commerce changes but where the amount is the same (like all at +1) unless the type is also the same for all of them (all Research, for example). I have not checked closely enough to be sure, but I think it would be a problem.

The "more stuff" mentioned in the first line would be, at least, the type of commerce that the last change used. That would be the addition of an "iLastType" that is set up and used pretty much like the "iLast" value but store the commerce type (which is the value of iJ). The last argument of the setListHelp line would need to do the existing "iLast" check and also check the new "iLastType" to see if it matches the current value of iJ. There may be more changes necessary, but that should be a good start.
 
Top Bottom