Case Study: Adding new XML attributes and using them in the SDK

Weird. K, link up your entire mod and I'll check it out.
 
oki thx.
here you are.

http://forums.civfanatics.com/downloads.php?do=file&id=4593 (hope they don't delete it, I'll do it once we solved prb)

To the Stuff: pls dont' delete that file just for the time needed to Kael to download. The prb I've encountered could be suffered by anyone and if we don't find a way to solve it, it will get harder to dev mods. Thx.

The files you uploaded seemed to be compressed twice. Once into a zip and another time in an "ace" file? Could you upload a copy that is just zipped, I cant uncompress ace files.
 
Many thx for this tutorial. Lead me to my first own SDK mod. Thx Kael.

Edit 1: After the first immediate success with single value tags, I tried to add something more complicated with child tags. I was sure it should work, but it didn't. Civ kept crashing when loading the XML Files. Then (many hours later and after starting to try to connect mentally with the XML base code of CIV 4) I recognized, the game even crashed, if I only add the member variable's declaration in the header file and the initialisation of this pointer to a bool array in the constructor. Very strange ...

Eventually I decided to compile the whole project again by clearing my "Final Release" folder completely and oh wonder, it worked! So my tipp, if you run in a similar problem and you are tired of trying to compile and debug the source code by starring at it over and over again, try the same drastic meassure. Maybe and only maybe it's going to help.
 
So how does this schema thing work, anyhow? I insert the fields in the schema, and the insert the fields into the regular xml as normal, but then the game says the file is not according to the schema? When I placed the new field at the end of the entry, it loaded fine. Likewise in another instance, I placed the new field near the beginning of the entry in the schema and the game expected it sooner. And, one more time while adding an entry and it seems that it expected the new entry at the end of the file (but in the schema the space for the new entries are near the beginning).

Edit: I found some really weird behavior. While trying to edit Civ4BonusInfos.xml, the game prompted me for an entry "iAIObjective" which no search turns up anything in the XML (in the vanilla folder or the BtS folder) files _except_ in the schema. Anyone know anything about this?
 
Step 4 (optional): Making your adjustments show up on the diplo screen:

Thanks to Chalid for showing me where to do this. CvGameTextMgr.cpp controls the game text. Making the following addition to CvGameTextMgr::getAttitudeString will allow your attitude adjustments on the diplomacy screen.

CvGameTextMgr.cpp

I can't get this part working. Or, actually, I don't know which part doesn't work because I can't tell if attitude changes or not without seeing it in diplomacy screens. I added only Alignment thing but I don't know where's the problem: maybe something wrong with reading from xml, maybe something wrong with calculating attitudes, maybe something wrong with displaying it in diplomacy window. Could somebody help me with debuging please? ;) Changes I made (Everything is pretty much as in Kael's examples with some changes. I don't know, maybe the error is pretty obvious, but since it's my first try with SDK...):

CIV4CivilizationsSchema.xml
Spoiler :

<ElementType name="ArtDefineTag" content="textOnly"/>
<ElementType name="iAlignment" content="textOnly" dt:type="int"/>
<ElementType name="iWonderConstructRand" content="textOnly" dt:type="int"/>
.....
<ElementType name="LeaderHeadInfo" content="eltOnly">
<element type="Type"/>
<element type="Description"/>
<element type="Civilopedia"/>
<element type="ArtDefineTag"/>
<element type="iAlignment"/>
<element type="iWonderConstructRand"/>


CIV4LeaderHeadInfos.xml
Spoiler :

<ArtDefineTag>ART_DEF_LEADER_BRENNUS</ArtDefineTag>
<iAlignment>-20</iAlignment>
<iWonderConstructRand>0</iWonderConstructRand>
(different for each leader; range -100 to 100)


CvInfos.cpp
Spoiler :

CvLeaderHeadInfo::CvLeaderHeadInfo() :
m_iAlignment(0),
m_iWonderConstructRand(0),
.......
int CvLeaderHeadInfo::getSameReligionAttitudeChange() const
{
return m_iSameReligionAttitudeChange;
}
int CvLeaderHeadInfo::getAlignment() const
{
return m_iAlignment;
}

void CvLeaderHeadInfo::setAlignment(int i)
{
m_iAlignment = i;
}

int CvLeaderHeadInfo::getSameReligionAttitudeDivisor() const
{
return m_iSameReligionAttitudeDivisor;
}
.......

stream->Read(&m_iDifferentReligionAttitudeChangeLimit);
stream->Read(&m_iAlignment);
stream->Read(&m_iBonusTradeAttitudeDivisor);

.......

stream->Write(m_iDifferentReligionAttitudeChangeLimit);
stream->Write(m_iAlignment);
stream->Write(m_iBonusTradeAttitudeDivisor);

......

pXML->GetChildXmlValByName(&m_iDifferentReligionAttitudeChangeLimit, "iDifferentReligionAttitudeChangeLimit");
pXML->GetChildXmlValByName(&m_iAlignment, "iAlignment");
pXML->GetChildXmlValByName(&m_iBonusTradeAttitudeDivisor, "iBonusTradeAttitudeDivisor");


CvInfos.h
Spoiler :

DllExport int getDifferentReligionAttitudeChangeLimit() const;
DllExport int getAlignment() const;
DllExport void setAlignment(int i);

DllExport int getBonusTradeAttitudeDivisor() const;
......
int m_iDifferentReligionAttitudeChangeLimit;
int m_iAlignment;
int m_iBonusTradeAttitudeDivisor;


CvPlayerAI.cpp
Spoiler :

int CvPlayerAI::AI_getAlignmentAttitude(PlayerTypes ePlayer)
{
int iAttitude;
iAttitude = 0;

if (GC.getLeaderHeadInfo(getPersonalityType()).getAlignment() > 0)
{
if (GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() < 0)
{
iAttitude = -3;
}
if (GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() == 0)
{
iAttitude = 1;
}
if (GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() > 0)
{
iAttitude = 4;
}
}

else if (GC.getLeaderHeadInfo(getPersonalityType()).getAlignment() == 0)
{
if (GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() < -80)
{
iAttitude = -3;
}
if (GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() < 80 && GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() > -80)
{
iAttitude = 1;
}
if (GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() > 80)
{
iAttitude = -2;
}
}
else if (GC.getLeaderHeadInfo(getPersonalityType()).getAlignment() < 0)
{
if (GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() < 0)
{
iAttitude = 2;
}
else if (GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() == 0)
{
iAttitude = -1;
}
else if (GC.getLeaderHeadInfo(GET_PLAYER(ePlayer).getPersonalityType()).getAlignment() > 0)
{
iAttitude = -3;
}
}

return iAttitude;
}


......

iAttitude += AI_getRivalTradeAttitude(ePlayer);
iAttitude += AI_getAlignmentAttitude(ePlayer);


CvPlayerAI.h
Spoiler :

int AI_getDifferentReligionAttitude(PlayerTypes ePlayer);
int AI_getAlignmentAttitude(PlayerTypes ePlayer);
int AI_getBonusTradeAttitude(PlayerTypes ePlayer);


CvGameTextMgr.cpp
Spoiler :

iAttitudeChange = GET_PLAYER(ePlayer).AI_getAlignmentAttitude(eTargetPlayer);
if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
{
if (GC.getLeaderHeadInfo(GET_PLAYER(eTargetPlayer).getPersonalityType()).getAlignment() > 0)
{
szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_GOOD_ALIGNMENT", iAttitudeChange).GetCString());
szBuffer.append(NEWLINE);
szBuffer.append(szTempBuffer);
}
else if (GC.getLeaderHeadInfo(GET_PLAYER(eTargetPlayer).getPersonalityType()).getAlignment() < 0)
{
szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_EVIL_ALIGNMENT", iAttitudeChange).GetCString());
szBuffer.append(NEWLINE);
szBuffer.append(szTempBuffer);
}
else
{
szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_NEUTRAL_ALIGNMENT", iAttitudeChange).GetCString());
szBuffer.append(NEWLINE);
szBuffer.append(szTempBuffer);
}

}


(I added this into the loop for (iPass = 0; iPass < 2; iPass++) { near the end of it, after all the other similar iAttitudeChange things, just before the nested loop for (iI = 0; iI < NUM_MEMORY_TYPES; ++iI) { starts).

Note: I used szBuffer += NEWLINE + szTempBuffer; at first; but I got compile error: something about different variable types, I suppose += operation couldn't be done because szBuffer and NEWLINE are of different variable types or so. Then I tried szBuffer.append(NEWLINE); szBuffer.append(szTempBuffer); as in other similar instances, and it compiled without errors.


Civ4GameText_DiplomacyText_BTS.xml
Spoiler :


<TEXT>
<Tag>TXT_KEY_MISC_ATTITUDE_GOOD_ALIGNMENT</Tag>
<English>%D1: "You are good"</English>
</TEXT>
<TEXT>
<Tag>TXT_KEY_MISC_ATTITUDE_EVIL_ALIGNMENT</Tag>
<English>%D1: "You are evil"</English>
</TEXT>
<TEXT>
<Tag>TXT_KEY_MISC_ATTITUDE_NEUTRAL_ALIGNMENT</Tag>
<English>%D1: "You are neutral"</English>
</TEXT>



Compiles without any problems, game runs without any problems, just I don't see leader attitudes, like +2: "you are good". As a matter of fact, I see no attitudes at all, even +1: "years of peace.....". But when I declare war then I see both "you declared war" and "this war spoils our...". I did numerous testings with different civilizations and it's always the same. Though I never made more then like 20 - 30 turns, I think that's pretty much enough to get at least +1: "years of peace...". And if it's not, anyway I need to have that Alignment attitude kicking in as soon as 2 civs meet.
 
Very odd. I dont see any isues with the code you posted. Could you post your entire CvGameTextMgr::getAttitudeString function so I can check it out, that sounds to be where your issue is occuring.

BTW, please put code inside [ code ] [ /code ] (without the spaces) tags to make it easier to read.
 
I'm trying to add an attitude modifer based on if the other civ has researched a certain technology. I'm stumbling at part 3 of the tutorial in the opening post. Kael's examples use access to a bonus and civic choices - but what code would be used for a tech?
 
hey Kael, how are you?
It's been quite a long time since last time.
I was curious, have been able to solve my prob in the end?
the prb posted in this thread...

Hello to all of you :)
 
Very odd. I dont see any isues with the code you posted. Could you post your entire CvGameTextMgr::getAttitudeString function so I can check it out, that sounds to be where your issue is occuring.

Here:

Spoiler :
Code:
void CvGameTextMgr::getAttitudeString(CvWStringBuffer& szBuffer, PlayerTypes ePlayer, PlayerTypes eTargetPlayer)
{
	CvWString szTempBuffer;
	int iAttitudeChange;
	int iPass;
	int iI;
	CvPlayerAI& kPlayer = GET_PLAYER(ePlayer);
	TeamTypes eTeam = (TeamTypes) kPlayer.getTeam();
	CvTeamAI& kTeam = GET_TEAM(eTeam);
		
	szBuffer.append(gDLL->getText("TXT_KEY_ATTITUDE_TOWARDS", GC.getAttitudeInfo(GET_PLAYER(ePlayer).AI_getAttitude(eTargetPlayer)).getTextKeyWide(), GET_PLAYER(eTargetPlayer).getNameKey()));

	for (int iTeam = 0; iTeam < MAX_TEAMS; iTeam++)
	{
		CvTeam& kLoopTeam = GET_TEAM((TeamTypes)iTeam);
		if (kLoopTeam.isAlive())
		{
			if (NO_PLAYER != eTargetPlayer)
			{
				CvTeam& kTargetTeam = GET_TEAM(GET_PLAYER(eTargetPlayer).getTeam());
				if (kTargetTeam.isHasMet((TeamTypes)iTeam))
				{
					if (kTeam.isVassal((TeamTypes)iTeam))
					{
						szBuffer.append(NEWLINE);
						szBuffer.append(gDLL->getText("TXT_KEY_ATTITUDE_VASSAL_OF", kLoopTeam.getName().GetCString()));

						setVassalRevoltHelp(szBuffer, (TeamTypes)iTeam, kTeam.getID());
					}
					else if (kLoopTeam.isVassal(kTeam.getID()))
					{
						szBuffer.append(NEWLINE);
						szBuffer.append(gDLL->getText("TXT_KEY_ATTITUDE_MASTER_OF", kLoopTeam.getName().GetCString()));
					}
				}
			}
		}
	}

	for (iPass = 0; iPass < 2; iPass++)
	{
		iAttitudeChange = GET_PLAYER(ePlayer).AI_getAlignmentAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			if (GC.getLeaderHeadInfo(GET_PLAYER(eTargetPlayer).getPersonalityType()).getAlignment() > 0)
			{
				szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_GOOD_ALIGNMENT", iAttitudeChange).GetCString());
				szBuffer.append(NEWLINE);
				szBuffer.append(szTempBuffer);
			}
			else if (GC.getLeaderHeadInfo(GET_PLAYER(eTargetPlayer).getPersonalityType()).getAlignment() < 0)
			{
				szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_EVIL_ALIGNMENT", iAttitudeChange).GetCString());
				szBuffer.append(NEWLINE);
				szBuffer.append(szTempBuffer);
			}
			else
			{
				szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_NEUTRAL_ALIGNMENT" , iAttitudeChange).GetCString());
				szBuffer.append(NEWLINE);
				szBuffer.append(szTempBuffer);
			}

		}

		iAttitudeChange = kPlayer.AI_getCloseBordersAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_LAND_TARGET", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getWarAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_WAR", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getPeaceAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_PEACE", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getSameReligionAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_SAME_RELIGION", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getDifferentReligionAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_DIFFERENT_RELIGION", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getBonusTradeAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_BONUS_TRADE", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getOpenBordersAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_OPEN_BORDERS", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getDefensivePactAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_DEFENSIVE_PACT", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getRivalDefensivePactAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_RIVAL_DEFENSIVE_PACT", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getRivalVassalAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_RIVAL_VASSAL", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getShareWarAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_SHARE_WAR", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getFavoriteCivicAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_FAVORITE_CIVIC", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getTradeAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_TRADE", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = kPlayer.AI_getRivalTradeAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_RIVAL_TRADE", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = GET_PLAYER(ePlayer).AI_getColonyAttitude(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_FREEDOM", iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		iAttitudeChange = GET_PLAYER(ePlayer).AI_getAttitudeExtra(eTargetPlayer);
		if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
		{
			szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText(((iAttitudeChange > 0) ? "TXT_KEY_MISC_ATTITUDE_EXTRA_GOOD" : "TXT_KEY_MISC_ATTITUDE_EXTRA_BAD"), iAttitudeChange).GetCString());
			szBuffer.append(NEWLINE);
			szBuffer.append(szTempBuffer);
		}

		for (iI = 0; iI < NUM_MEMORY_TYPES; ++iI)
		{
			iAttitudeChange = kPlayer.AI_getMemoryAttitude(eTargetPlayer, ((MemoryTypes)iI));
			if ((iPass == 0) ? (iAttitudeChange > 0) : (iAttitudeChange < 0))
			{
				szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((iAttitudeChange > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText("TXT_KEY_MISC_ATTITUDE_MEMORY", iAttitudeChange, GC.getMemoryInfo((MemoryTypes)iI).getDescription()).GetCString());
				szBuffer.append(NEWLINE);
				szBuffer.append(szTempBuffer);
			}
		}
	}

	if (NO_PLAYER != eTargetPlayer)
	{
		int iWarWeariness = GET_PLAYER(eTargetPlayer).getModifiedWarWearinessPercentAnger(GET_TEAM(GET_PLAYER(eTargetPlayer).getTeam()).getWarWeariness(eTeam) * max(0, 100 + kTeam.getEnemyWarWearinessModifier()));
		if (iWarWeariness / 10000 > 0)
		{
			szBuffer.append(NEWLINE);
			szBuffer.append(gDLL->getText("TXT_KEY_WAR_WEAR_HELP", iWarWeariness / 10000));
		}
	}

}
 
do you think that my prb could be this:

when I make the final calculation of OilTotalConsumption I set it as Integer, but I've seen that in my function:

Code:
//get buildings oil consumption per turn
int CvCity::OilConsumptionPerBuildings()
{

	int iAirportCons = 0;
	int iDryDockCons = 0;
	int iHospitalCons = 0;
	int iHydroplantCons = 0;
	int iNuclearPlantCons = 0;
	int iRecyclingCenterCons = 0;

	int iTotalConsumption = 0;
// basic city consumptio BCC from Define INT
	int iBCC = 0;
//	int iMedCitiesConsumption = 0;
//	int iBigCitiesConsumption = 0;
//	int iEnormousCitiesConsumption = 0;


	if (hasActiveBuilding((BuildingTypes)GC.getInfoTypeForString("BUILDING_AIRPORT")))
	{
		iAirportCons = GC.getBuildingInfo(BuildingTypes (GC.getInfoTypeForString("BUILDING_AIRPORT"))).getOilConsumption();
	}
	return iAirportCons;

	if (hasActiveBuilding((BuildingTypes)GC.getInfoTypeForString("BUILDING_DRYDOCK")))
	{
		iDryDockCons = GC.getBuildingInfo(BuildingTypes (GC.getInfoTypeForString("BUILDING_DRYDOCK"))).getOilConsumption();
	}
	return iDryDockCons;

	if (hasActiveBuilding((BuildingTypes)GC.getInfoTypeForString("BUILDING_HOSPITAL")))
	{
		iHospitalCons = GC.getBuildingInfo(BuildingTypes (GC.getInfoTypeForString("BUILDING_HOSPITAL"))).getOilConsumption();
	}
	return iHospitalCons;

	if (hasActiveBuilding((BuildingTypes)GC.getInfoTypeForString("BUILDING_HYDROPLANT")))
	{
		iHydroplantCons = GC.getBuildingInfo(BuildingTypes (GC.getInfoTypeForString("BUILDING_HYDROPLANT"))).getOilConsumption();
	}
	return iHydroplantCons;

	if (hasActiveBuilding((BuildingTypes)GC.getInfoTypeForString("BUILDING_NUCLEAR_PLANT")))
	{
		iNuclearPlantCons = GC.getBuildingInfo(BuildingTypes (GC.getInfoTypeForString("BUILDING_NUCLEAR_PLANT"))).getOilConsumption();
	}
	return iNuclearPlantCons;

	if (hasActiveBuilding((BuildingTypes)GC.getInfoTypeForString("BUILDING_RECYCLING_CENTER")))
	{
		iRecyclingCenterCons = GC.getBuildingInfo(BuildingTypes (GC.getInfoTypeForString("BUILDING_RECYCLING_CENTER"))).getOilConsumption();
	}
	return iRecyclingCenterCons;

// let's go for population
	if ((getPopulation() >= 1) && (getPopulation() <= 5))
	{
		iBCC = (GC.getDefineINT("LITTLE_CITIES_CONSUMPTION"));
	}
	else if ((getPopulation() >= 6) && (getPopulation() <= 10))
	{
		iBCC = (GC.getDefineINT("MED_CITIES_CONSUMPTION"));
	}
	else if ((getPopulation() >= 11) && (getPopulation() <= 15))
	{
		iBCC = (GC.getDefineINT("BIG_CITIES_CONSUMPTION"));
	}
	else if (getPopulation() >= 16)
	{
		iBCC = (GC.getDefineINT("ENORMOUS_CITIES_CONSUMPTION"));
	}
	return iBCC;



	iTotalConsumption = ((iBCC * getPopulation()) + ((iBCC * iAirportCons) / 100) + ((iBCC * iDryDockCons) / 100) + ((iBCC * iHospitalCons) / 100) + ((iBCC * iHydroplantCons) / 100) + ((iBCC * iNuclearPlantCons) / 100) + ((iBCC * iRecyclingCenterCons) / 100));


	return iTotalConsumption;

}

I make the resoult divided by 100, so could happens that the resoult is a 0,xxx number.
Do you think compiler get this prb and stops it self?
 
I mean look here I set the XML file like this:
Code:
<BuildingClass>BUILDINGCLASS_RECYCLING_CENTER</BuildingClass>
			<Type>BUILDING_RECYCLING_CENTER</Type>
			<SpecialBuildingType>NONE</SpecialBuildingType>
			<Description>TXT_KEY_BUILDING_RECYCLING_CENTER</Description>
			<Civilopedia>TXT_KEY_BUILDING_RECYCLING_CENTER_PEDIA</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_RECYCLING_CENTER_STRATEGY</Strategy>
			<Advisor>ADVISOR_GROWTH</Advisor>
			<ArtDefineTag>ART_DEF_BUILDING_RECYCLING_CENTER</ArtDefineTag>
			<MovieDefineTag>NONE</MovieDefineTag>
			<HolyCity>NONE</HolyCity>
			<ReligionType>NONE</ReligionType>
			<StateReligion>NONE</StateReligion>
			<PrereqReligion>NONE</PrereqReligion>
			<GlobalReligionCommerce>NONE</GlobalReligionCommerce>
			<VictoryPrereq>NONE</VictoryPrereq>
			<FreeStartEra>NONE</FreeStartEra>
			<MaxStartEra>NONE</MaxStartEra>
			<ObsoleteTech>NONE</ObsoleteTech>
			<PrereqTech>TECH_ECOLOGY</PrereqTech>
			<TechTypes/>
			<Bonus>NONE</Bonus>
			<PrereqBonuses/>
			<ProductionTraits/>
			<HappinessTraits/>
			<PowerBonus>NONE</PowerBonus>
			<FreeBonus>NONE</FreeBonus>
			<iNumFreeBonuses>0</iNumFreeBonuses>
			<FreeBuilding>NONE</FreeBuilding>
			<FreePromotion>NONE</FreePromotion>
			<CivicOption>NONE</CivicOption>
			<GreatPeopleUnitClass>NONE</GreatPeopleUnitClass>
			<iGreatPeopleRateChange>0</iGreatPeopleRateChange>
			<iHurryAngerModifier>0</iHurryAngerModifier>
			<bBorderObstacle>0</bBorderObstacle>
			<bTeamShare>0</bTeamShare>
			<bWater>0</bWater>
			<bRiver>0</bRiver>
			<bPower>0</bPower>
			<bDirtyPower>0</bDirtyPower>
			<bAreaCleanPower>0</bAreaCleanPower>
			<bDiploVote>0</bDiploVote>
			<bForceTeamVoteEligible>0</bForceTeamVoteEligible>
			<bCapital>0</bCapital>
			<bGovernmentCenter>0</bGovernmentCenter>
			<bGoldenAge>0</bGoldenAge>
			<bMapCentering>0</bMapCentering>
			<bNoUnhappiness>0</bNoUnhappiness>
			<bNoUnhealthyPopulation>0</bNoUnhealthyPopulation>
			<bBuildingOnlyHealthy>1</bBuildingOnlyHealthy>
			<bNeverCapture>0</bNeverCapture>
			<bNukeImmune>0</bNukeImmune>
			<bPrereqReligion>0</bPrereqReligion>
			<bCenterInCity>0</bCenterInCity>
			<iAIWeight>0</iAIWeight>
			<iCost>300</iCost>
			<iHurryCostModifier>0</iHurryCostModifier>
			<iMinAreaSize>-1</iMinAreaSize>
			<iConquestProb>66</iConquestProb>
			<iCitiesPrereq>0</iCitiesPrereq>
			<iTeamsPrereq>0</iTeamsPrereq>
			<iLevelPrereq>0</iLevelPrereq>
			<iMinLatitude>0</iMinLatitude>
			<iMaxLatitude>90</iMaxLatitude>
			<iGreatPeopleRateModifier>0</iGreatPeopleRateModifier>
			<iGreatGeneralRateModifier>0</iGreatGeneralRateModifier>
			<iDomesticGreatGeneralRateModifier>0</iDomesticGreatGeneralRateModifier>
			<iGlobalGreatPeopleRateModifier>0</iGlobalGreatPeopleRateModifier>
			<iAnarchyModifier>0</iAnarchyModifier>
			<iGlobalHurryModifier>0</iGlobalHurryModifier>
			<iExperience>0</iExperience>
			<iGlobalExperience>0</iGlobalExperience>
			<iFoodKept>0</iFoodKept>
<!-- OIL CONSUMPTION -->
			<iOilConsumption>-40</iOilConsumption>
<!-- END -->			
			<iAirlift>0</iAirlift>
			<iAirModifier>0</iAirModifier>
			<iNukeModifier>0</iNukeModifier>
			<iNukeExplosionRand>0</iNukeExplosionRand>
			<iFreeSpecialist>0</iFreeSpecialist>
			<iAreaFreeSpecialist>0</iAreaFreeSpecialist>
			<iGlobalFreeSpecialist>0</iGlobalFreeSpecialist>
			<iMaintenanceModifier>0</iMaintenanceModifier>
			<iWarWearinessModifier>0</iWarWearinessModifier>
			<iGlobalWarWearinessModifier>0</iGlobalWarWearinessModifier>
			<iHealRateChange>0</iHealRateChange>
			<iHealth>0</iHealth>
			<iAreaHealth>0</iAreaHealth>
			<iGlobalHealth>0</iGlobalHealth>
			<iHappiness>0</iHappiness>
			<iAreaHappiness>0</iAreaHappiness>
			<iGlobalHappiness>0</iGlobalHappiness>
			<iStateReligionHappiness>0</iStateReligionHappiness>
			<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
			<iMilitaryProductionModifier>0</iMilitaryProductionModifier>
			<iSpaceProductionModifier>0</iSpaceProductionModifier>
			<iGlobalSpaceProductionModifier>0</iGlobalSpaceProductionModifier>
			<iTradeRoutes>0</iTradeRoutes>
			<iCoastalTradeRoutes>0</iCoastalTradeRoutes>
			<iGlobalTradeRoutes>0</iGlobalTradeRoutes>
			<iTradeRouteModifier>0</iTradeRouteModifier>
			<iGlobalPopulationChange>0</iGlobalPopulationChange>
			<iFreeTechs>0</iFreeTechs>
			<iDefense>0</iDefense>
			<iBombardDefense>0</iBombardDefense>
			<iAllCityDefense>0</iAllCityDefense>
			<iAsset>6</iAsset>
			<iPower>0</iPower>
			<fVisibilityPriority>1.0</fVisibilityPriority>
			<SeaPlotYieldChanges/>
			<GlobalSeaPlotYieldChanges/>
			<YieldChanges/>
			<CommerceChanges/>
			<ObsoleteSafeCommerceChanges/>
			<CommerceChangeDoubleTimes/>
			<CommerceModifiers/>
			<GlobalCommerceModifiers/>
			<SpecialistExtraCommerces/>
			<StateReligionCommerces/>
			<CommerceHappinesses/>
			<ReligionChanges/>
			<SpecialistCounts/>
			<FreeSpecialistCounts/>
			<CommerceFlexibles/>
			<CommerceChangeOriginalOwners/>
			<ConstructSound>AS2D_BUILD_RECYCLING_CENTER</ConstructSound>
			<BonusHealthChanges/>
			<BonusHappinessChanges/>
			<BonusProductionModifiers/>
			<UnitCombatFreeExperiences/>
			<DomainFreeExperiences/>
			<DomainProductionModifiers/>
			<BuildingHappinessChanges/>
			<PrereqBuildingClasses/>
			<BuildingClassNeededs/>
			<SpecialistYieldChanges/>
			<BonusYieldModifiers/>
			<Flavors>
				<Flavor>
					<FlavorType>FLAVOR_GROWTH</FlavorType>
					<iFlavor>10</iFlavor>
				</Flavor>
			</Flavors>
			<HotKey/>
			<bAltDown>0</bAltDown>
			<bShiftDown>0</bShiftDown>
			<bCtrlDown>0</bCtrlDown>
			<iHotKeyPriority>0</iHotKeyPriority>
		</BuildingInfo>

so here it would be for ex. iBCC = 30
30 * -40 = -120
-120/100 = - 1,2

2nd) I should probably give him all the buildings with a certain ammount of OIL Consumption or when it doens't find the value he cannot associate the absence with "0". Correct?

3rd) isn't there a faster way to loop throw the buildings and get all the building active OIL CONSUMPTION value?
 
so ladies and gentlemen I solved the prb:
if you want to add a new attribute to XML and get into .cpp you should add it after last int attribute you see.
In the example above

Code:
<Flavors>
				<Flavor>
					<FlavorType>FLAVOR_GROWTH</FlavorType>
					<iFlavor>10</iFlavor>
				</Flavor>
			</Flavors>
			<HotKey/>
			<bAltDown>0</bAltDown>
			<bShiftDown>0</bShiftDown>
			<bCtrlDown>0</bCtrlDown>
			<iHotKeyPriority>0</iHotKeyPriority>

[B][U]HERE[/U][/B]
		</BuildingInfo>

So it will load the MOD!
This idiot problem stopped me 1 year ago...
xxxxxing XML... (sorry)
 
Great to hear you have it worked out. I have inserted attributes at places other than the end of the object definition without issues so Im not sure why that fixed it for you, but either way at least its working! :D
 
oyur prb is with compiling or with XML load?

if the second remeber to add in your xmlschema file

Code:
<element type="iAlignment" [B]minOccurs="0"[/B]/>

or

insert your new attribute fro each Civ you find.

if you don't do this the game won't know what to do if the attribute is absent.
with minOccurs you tell it: "if you don't find it assign basic value = 0"
 
Top Bottom