Troubles with Arrays and Arrays of Arrays...

What's wrong with this picture?

Code:
setTechExtraBuildingHealth(eIndex, getTechExtraBuildingHappiness(eIndex) + iChange);

Spoiler Hint :
Health is not Happiness
Check the other change() function to make sure it's not also broken. I don't think this is the only problem, but it's definitely one of them.
 
What's wrong with this picture?

Code:
setTechExtraBuildingHealth(eIndex, getTechExtraBuildingHappiness(eIndex) + iChange);
Spoiler Hint :
Health is not Happiness
Check the other change() function to make sure it's not also broken. I don't think this is the only problem, but it's definitely one of them.

Oh wow. That is a problem. And it looks like the only problem. As soon as I changed that, I got the correct XML value of healthiness from the building. I guess it was adding the health and the happiness together.
 
I believe you had the code to add the happiness first, and then the health code was using the happiness value as the "current" value, adding them together. So everything works perfectly now?
 
I believe you had the code to add the happiness first, and then the health code was using the happiness value as the "current" value, adding them together. So everything works perfectly now?

Yes. Only two major hurdles left, CvGameTextMgr, and the AI. I'll see if I can tackle them, and if I hit walls, I'll post here. Meanwhile, can you see if you can help me fix my infinite loop problem? It's a bigger priority than this.
 
I have a few questions.

First off, I'm not sure what to add in this function, to show the changes from each tech.

Code:
void CvGameTextMgr::setTechTradeHelp(CvWStringBuffer &szBuffer, TechTypes eTech, PlayerTypes eTradePlayer, bool bCivilopediaText, bool bPlayerContext, bool bStrategyText, bool bTreeInfo, TechTypes eFromTech)

I tried to use the TAB modcomp as an example, but I got hung up, here:

Code:
for (iI = 0; iI < GC.getNumBuildingInfos(); ++iI)
	{
	//	Building commerce changes
		buildBuildingTechCommerceChangeString(szBuffer, eTech, iI, true, bPlayerContext);
	//	Building yield changes
		buildBuildingTechYieldChangeString(szBuffer, eTech, iI, true, bPlayerContext);
	//	Building specialist count changes
		buildBuildingTechSpecialistChangeString(szBuffer, eTech, iI, true, bPlayerContext);
	//	Building commerce changes
		buildBuildingTechCommerceModifierString(szBuffer, eTech, iI, true, bPlayerContext);
	//	Building yield changes
		buildBuildingTechYieldModifierString(szBuffer, eTech, iI, true, bPlayerContext);
	//	Building happy changes
		[B]buildBuildingTechHappinessChangesString(szBuffer, eTech, iI, true, [/B]bPlayerContext);
	//	Building health changes
		[B]buildBuildingTechHealthChangesString(szBuffer, eTech, iI, true, [/B]bPlayerContext);
	}

I added the bolded item, and they are references to another function. That's all fine and dandy, but I need to add those functions. Using the TAB modcomp as an example is useless, because health and happiness is treated differently than commerce or yields...

Then, in

Code:
void CvGameTextMgr::setBuildingHelpActual(CvWStringBuffer &szBuffer, BuildingTypes eBuilding, bool bCivilopediaText, bool bStrategyText, bool bTechChooserText, CvCity* pCity, bool bActual)

I added this, but it seems to have no effect in game.

Code:
for (int iTech = 0; iTech < GC.getNumTechInfos(); iTech++)
	{
		if (kBuilding.getTechHealthChanges(iTech) != 0)
		{
			szFirstBuffer.Format(L"%s%s", NEWLINE, gDLL->getText("TXT_KEY_WITH", abs(kBuilding.getTechHealthChanges(iTech)), ((kBuilding.getTechHealthChanges(iTech) > 0) ? gDLL->getSymbolID(HEALTHY_CHAR): gDLL->getSymbolID(UNHEALTHY_CHAR))).c_str());
			szTempBuffer.Format(L"<link=literal>%s</link>", GC.getTechInfo((TechTypes)iTech).getDescription());
			setListHelp(szBuffer, szFirstBuffer, szTempBuffer, L", ", (kBuilding.getTechHealthChanges(iTech) != iLast));
			iLast = kBuilding.getTechHealthChanges(iTech);
		}

		if (kBuilding.getTechHappinessChanges(iTech) != 0)
		{
			szFirstBuffer.Format(L"%s%s", NEWLINE, gDLL->getText("TXT_KEY_WITH", abs(kBuilding.getTechHappinessChanges(iTech)), ((kBuilding.getTechHappinessChanges(iTech) > 0) ? gDLL->getSymbolID(HAPPY_CHAR) : gDLL->getSymbolID(UNHAPPY_CHAR))).c_str());
			szTempBuffer.Format(L"<link=literal>%s</link>", GC.getTechInfo((TechTypes)iTech).getDescription());
			setListHelp(szBuffer, szFirstBuffer, szTempBuffer, L", ", (kBuilding.getTechHappinessChanges(iTech) != iLast));
			iLast = kBuilding.getTechHappinessChanges(iTech);
		}
	}
 
What are you trying to do? I have no idea what text you would want to add to the tech trade hover. :confused:
 
What are you trying to do? I have no idea what text you would want to add to the tech trade hover. :confused:

Set tech help calls set tech trade help. So anything I want to add to a tech display needs to be in set tech trade help.See for yourself:
Code:
void CvGameTextMgr::setTechHelp(CvWStringBuffer &szBuffer, TechTypes eTech, bool bCivilopediaText, bool bPlayerContext, bool bStrategyText, bool bTreeInfo, TechTypes eFromTech)
{
    setTechTradeHelp(szBuffer, eTech, NO_PLAYER, bCivilopediaText, bPlayerContext, bStrategyText, bTreeInfo, eFromTech);
}
 
Okay, so what do you want to add to the hover text here? If you describe what you want to add you'll be halfway to writing the code. Give an example. I'm happy to help when you get stuck, but I would be more willing if you did as much of the work as you could first. As I'm fond of saying, help me help you.
 
Okay, so what do you want to add to the hover text here? If you describe what you want to add you'll be halfway to writing the code. Give an example. I'm happy to help when you get stuck, but I would be more willing if you did as much of the work as you could first. As I'm fond of saying, help me help you.

So, here's an example:

Refrigeration:
allows +1 movement over water
Allows Supermarket
+1 :) with Zoo
+1 :health: with Zoo
 
Great. The next step is to write out in psuedocode how you would find all that information. Psuedocode is English writing that has the structure of code.

Code:
find largest element in list

set max to MIN_INT
for each element x in list
    if x > max
        set max to x
return max

Can you write out something like this for your hover text?
 
Great. The next step is to write out in psuedocode how you would find all that information. Psuedocode is English writing that has the structure of code.

That's what my CPS prof tells me too. Maybe I should listen to him. ;)
Code:
for (techcount; getnumtechinfos; techcount++)
     if techhealthchanges =! 0
          print "+ (:health: / :yuck: ) with techcount"
Like that?
 
This function is given a TechTypes for which to display information, so I wouldn't expect to see a loop over all techs. Instead, this is supposed to display the :health: and/or :) that the tech adds to buildings.

That's the plain English description. Now try your hand at the psuedocode for that.
 
Okay, sorry I left this thread hanging, so close to completion. I needed to release a new version, and that became all time consuming. However, I am ready to pick this up again. I understand what I am doing a bit more too...

However, I'm afraid CvGameTextMgr is one of the files I understand the least.

I need to add text for the techs that will affect the buildings, in SetTechHelp. I also need to add the text for the actual building hover too, in SetBuildingActualHelp...

I looked at the TAB modcomp for an example, but the way commerce is shown is vastly different to happiness and healthiness.

I guess I'm not sure how to write that example below into code.

After this, what else do I need to do, add AI code, and that's it?
 
The psuedocode goes something like this:

Code:
for each building
    if tech.getBuildingHappiness(building) != 0
        append "* <amount> with <building name>" to buffer
    if tech.getBuildingHealth(building) != 0
        append "* <amount> with <building name>" to buffer
 
I'm also trying to make an array, a Civic requirement or list for units, so that RevDCM can unhardcode the inquistor unit. I am trying to follow Xienwolf's guide, but I haven't even started on the actual SDK yet, because can't even get past the schema. It fails to load Unitinfos when I add the tags I thought I had added to the schema.

My Schema XML looks like so:
Code:
	<ElementType name="NotGameOption" content="textOnly"/>
	<ElementType name="ReqCivicOrs" content="eltOnly">
		<element type="CivicOption" minOccurs="0" maxOccurs="*"/>
	</ElementType>
...
		<element type="NotGameOption" minOccurs="0"/>
		<element type="ReqCivicOrs" minOccurs="0"/>
and my testing UnitInfos:
Code:
			<NotGameOption>NONE</NotGameOption>
			<ReqCivicOrs>
				<CivicOption>CIVIC_THEOCRACY</CivicOption>
				<CivicOption>NONE</CivicOption>
				<CivicOption>NONE</CivicOption>
			</ReqCivicOrs>

The NotGAmeOption tag is a tag I have just added which works, it's merely there for reference in placement. Where have I gone wrong? I can't even start working on it yet, until I can get the schema to work.
 
Did you include:

<ElementType name="CivicOption" content="textOnly"/>

No, but having added it I now get the same problem. Here is my modified code with textOnly added:


Ahh, got the order wrong, now it works.
Code:
	<ElementType name="NotGameOption" content="textOnly"/>
	<ElementType name="ReqCivicOrs" content="eltOnly">
		<element type="CivicOption" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="CivicOption" content="textOnly"/>
 
OK, well I'm still not sure if the schema is correct, but Civ4 loads up with that schema code, and I've placed in non functioning tags in UnitInfos, so I assume it's right.

So moving on. Following Xienwolf's tutorial on cloning an array, I have hit a snag. I'm not cloning an array, I'm creating a new one, so things are a bit different. Currently I'm at the assert stuff. I am using the PrereqAndTechs as an example and am here:

Code:
//phungus civic canTrain current spot
int CvUnitInfo::getReqCivicOrs(int i) const	
{
	FAssertMsg(i < GC.getNUM_CIVIC_OPTIONS(), "Index out of bounds");
	FAssertMsg(i > -1, "Index out of bounds");
	return m_piReqCivicOrs ? m_piReqCivicOrs[i] : -1;
}
//phungus -end

int CvUnitInfo::getPrereqAndTechs(int i) const	
{
	FAssertMsg(i < GC.getNUM_UNIT_AND_TECH_PREREQS(), "Index out of bounds");
	FAssertMsg(i > -1, "Index out of bounds");
	return m_piPrereqAndTechs ? m_piPrereqAndTechs[i] : -1;
}

Now the problem is that getNUM_UNIT_AND_TECH_PREREQS is a function that exists in CvGlobals, and CvGameCoreUtils. My assumption here is that this assert references an index set up there, to ensure something isn't going wrong with the array, and give the developer an assert if that occurs. I'd like a functioning assert, so I need this to work. But I can't find any reference to something like it in either files. I've written getNUM_CIVIC_OPTIONS as a placeholder, but that's obviously not going to work.

How do I proceed?
 
OK, well I'm still not sure if the schema is correct, but Civ4 loads up with that schema code, and I've placed in non functioning tags in UnitInfos, so I assume it's right.

So moving on. Following Xienwolf's tutorial on cloning an array, I have hit a snag. I'm not cloning an array, I'm creating a new one, so things are a bit different. Currently I'm at the assert stuff. I am using the PrereqAndTechs as an example and am here:

Code:
//phungus civic canTrain current spot
int CvUnitInfo::getReqCivicOrs(int i) const    
{
    FAssertMsg(i < GC.getNUM_CIVIC_OPTIONS(), "Index out of bounds");
    FAssertMsg(i > -1, "Index out of bounds");
    return m_piReqCivicOrs ? m_piReqCivicOrs[i] : -1;
}
//phungus -end

int CvUnitInfo::getPrereqAndTechs(int i) const    
{
    FAssertMsg(i < GC.getNUM_UNIT_AND_TECH_PREREQS(), "Index out of bounds");
    FAssertMsg(i > -1, "Index out of bounds");
    return m_piPrereqAndTechs ? m_piPrereqAndTechs[i] : -1;
}
Now the problem is that getNUM_UNIT_AND_TECH_PREREQS is a function that exists in CvGlobals, and CvGameCoreUtils. My assumption here is that this assert references an index set up there, to ensure something isn't going wrong with the array, and give the developer an assert if that occurs. I'd like a functioning assert, so I need this to work. But I can't find any reference to something like it in either files. I've written getNUM_CIVIC_OPTIONS as a placeholder, but that's obviously not going to work.

How do I proceed?
Just a stab in the dark here, but are you looking for "GC.getNumCivicInfos()"?
 
Just a stab in the dark here, but are you looking for "GC.getNumCivicInfos()"?

Common sense would dictate yes. It's certainly a good enough guess to throw it in there and move on, and come back to it if things don't work. Will try it, thank you.
 
Back
Top Bottom