gDLL->getInterfaceIFace()->addMessage

vincentz

Programmer
Joined
Feb 4, 2009
Messages
3,614
Location
Denmark
I've been trying everything but I cant get the text to show :(

Textfile
PHP:
	<TEXT>
		<Tag>TXT_KEY_GOT_RESEARCH_FROM_PROJECT</Tag>
		<English>Your projects have gathered research for %s1_TechName (%d2%%)</English>
		<French>Your projects have gathered research for %s1_TechName (%d2%%)</French>
		<German>Your projects have gathered research for %s1_TechName (%d2%%)</German>
		<Italian>Your projects have gathered research for %s1_TechName (%d2%%)</Italian>
		<Spanish>Your projects have gathered research for %s1_TechName (%d2%%)</Spanish>
	</TEXT>
Spoiler :

PHP:
void CvTeam::updateTechShare(TechTypes eTech)
{
	int iBestShare;
	int iCount;
	int iI;
	CvWString szBuffer;

	if (isHasTech(eTech))
	{
		return;
	}
	
	iBestShare = MAX_INT;

	for (iI = 0; iI < MAX_TEAMS; iI++)
	{
		if (isTechShare(iI))
		{
			iBestShare = std::min(iBestShare, (iI + 1));
		}
	}

	if (iBestShare != MAX_INT)
	{
		iCount = 0;

		for (iI = 0; iI < MAX_CIV_TEAMS; iI++)
		{
			if (GET_TEAM((TeamTypes)iI).isAlive())
			{
				if (GET_TEAM((TeamTypes)iI).isHasTech(eTech))
				{
					if (isHasMet((TeamTypes)iI))
					{
						FAssertMsg(iI != getID(), "iI is not expected to be equal with getID()");
						iCount++;
					}
				}
			}
		}
//Vincentz Techshare

			int newProjectResearch = getResearchCost(eTech) * GC.getGameINLINE().getSorenRandNum(10, "Project Tech Sharing") * iCount / (iBestShare * 10);
			
			changeResearchProgress(eTech, (newProjectResearch), NO_PLAYER);
			szBuffer = gDLL->getText("TXT_KEY_GOT_RESEARCH_FROM_PROJECT", GC.getTechInfo(eTech).getTextKeyWide(), newProjectResearch);
			gDLL->getInterfaceIFace()->addMessage(((PlayerTypes)iI), true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_PROJECT_COMPLETED", MESSAGE_TYPE_INFO, NULL, (ColorTypes)GC.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"));


	}
}

Something is wrong in this part, I just cant figure out what... Is it the (PlayerTypes)iI) part?
The compiler doesnt show any errors, the text just doesnt show when everything else is working ... :/
PHP:
		szBuffer = gDLL->getText("TXT_KEY_GOT_RESEARCH_FROM PROJECT", GC.getTechInfo(eTech).getTextKeyWide(), newProjectResearch);
			gDLL->getInterfaceIFace()->addMessage(((PlayerTypes)iI), true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_PROJECT_COMPLETED", MESSAGE_TYPE_INFO, NULL, (ColorTypes)GC.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"));
 
I believe the first argument of addMessage is the recipient. Looks like iI is MAX_CIV_TEAMS at that point, i.e. the barbarians. To check if that's the issue, you could try GC.getGame().getActivePlayer() -- in single-player that should always be the human player; or just (PlayerTypes)0.
(The correct recipients are probably all the members of "this" team.)
 
Just to follow up on this. Unfortunately it wasnt that simple, as it was in CvTeam.cpp, and it required a bit more, otherwise all the szbuffer from all the players was being put out to the addmessage.
The code for fixing this :

PHP:
	for (int iI = 0; iI < MAX_PLAYERS; iI++)
	{
		if (GET_PLAYER((PlayerTypes)iI).isAlive())
		{
			if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
			{
				CvWString szBuffer = gDLL->getText("TXT_KEY_GOT_RESEARCH_FROM_PROJECT", GC.getTechInfo(eTech).getTextKeyWide(), newProjectResearch, iCount, iBestShare, 
				(GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getResearchPercent()), (GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getNoTechTradeModifier()));

				gDLL->getInterfaceIFace()->addMessage(((PlayerTypes)iI), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_PROJECT_COMPLETED", MESSAGE_TYPE_INFO, NULL, (ColorTypes)GC.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"));
			}
		}
	}
 
Top Bottom