Problem with <GlobalBuildingExtraCommerces>

Thunderbrd

C2C War Dog
Joined
Jan 2, 2010
Messages
29,952
Location
Las Vegas
This is one of my wonders, so I can enhance it. Cahokia Mounds is supposed to provide +50% production speed of Tumulus and +2 Culture from Tumulus, although the bonus doesn't always seem to show up when the Tumulus is in the production queue. Do you think I should increase the culture bonus, or give it another new ability?

Well... Stonehenge grants a free monument to all cities which is fairly similar in strength to giving a free Tumulus in all cities. However, the +2 Culture from Tumulus is interesting... does that affect all cities? If it does, that might be effective enough actually... I have a feeling the benefit isn't utilizing the right tags somehow if that detail isn't showing up - she states she had already built the tumulus in that city.

This may end up being more of a bug in the tags used to give the +2 culture actually. I may need to look into that from the dll side.

The Culture bonus is supposed to affect all Tumulus in your civilization. If you wouldn't mind, could you take a look at both Cahokia Mounds and Serpent Mound? Cahokia is supposed to add +2 culture to Tumulus, and Serpent Mound adds +2 science to Tumulus. The tag responsible is our relatively new <GlobalBuildingExtraCommerces>. I've used it on several of my Wonders to add bonuses to particular buildings from a Wonder.

I can take a look at that tag, yes. But I can't promise much as I've yet to wrap my head around Commerce programming. The method utilized with them and yields is a little confusing for me to read.

As a separate issue/bug/problem, we also need to take a look at the free fire pit in every city... apparently it doesn't seem to be giving it, though it says it does, from controlled fire, or at least not everywhere. This is my wife's report... I haven't looked into it much to know exactly what the problem there is.

I'll take a look more later this afternoon. Apparently that tag is probably one of the issues - maybe just a text issue which would be fairly easy to resolve.

OK, so we have a serious problem here somewhere.

The benefits from those mounds listed under those tags aren't working at all it seems. I'm not seeing any effect indicated for them on the wonder (not in the help pops nor the pedia), nor on the tumulus once the wonder is built.

The tags were apparently designed by AIAndy and utilize a highly complex level of structure based vectors which may be just a notch past my ability to sort out. Just looking at the coding it seems alright... but either its simply not working to bring the data in correctly (which COULD be the way the tags are utilized in the XML) or there's problems with the text manager calling those benefits.

I'll post the issue in the bugs thread and keep taking a look at the problem but I warn it may be beyond my current capacity right now to solve due to the sheer complexity of working with not only the vector itself but the commerce system as well. Furthermore, this sort of one building affecting another on a global level is fairly complex as well and may be a bit tough for me to follow through the code. I could sort it out but it could take me a LONG time to do so. If it hasn't been addressed, I'll come back to it once my other projects are finished.

Reposting here to enlist some assistance.

The tag loads with this:
Spoiler :
Code:
m_aGlobalBuildingCommerceChanges.clear();
	if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"GlobalBuildingExtraCommerces"))
	{
		if (pXML->SkipToNextVal())
		{
			int iNumSibs = gDLL->getXMLIFace()->GetNumChildren(pXML->GetXML());

			if (0 < iNumSibs)
			{
				if (gDLL->getXMLIFace()->SetToChild(pXML->GetXML()))
				{
					for (int j = 0; j < iNumSibs; ++j)
					{
						if (pXML->GetChildXmlVal(szTextVal))
						{
							BuildingCommerceChange kChange;
							kChange.eBuildingClass = (BuildingClassTypes)pXML->FindInInfoClass(szTextVal);
							pXML->GetNextXmlVal(szTextVal);
							kChange.eCommerce = (CommerceTypes)pXML->FindInInfoClass(szTextVal);
							pXML->GetNextXmlVal(&kChange.iChange);
							m_aGlobalBuildingCommerceChanges.push_back(kChange);

							gDLL->getXMLIFace()->SetToParent(pXML->GetXML());

						}

						if (!gDLL->getXMLIFace()->NextSibling(pXML->GetXML()))
						{
							break;
						}

					}

					gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
				}
			}
		}

		gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
	}
and is displayed with at least this code:
Spoiler :
Code:
for (int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)
			{
				BuildingTypes eLoopBuilding;
				if (!bCivilopediaText && NO_PLAYER != GC.getGameINLINE().getActivePlayer())
				{
					eLoopBuilding = (BuildingTypes)GC.getCivilizationInfo(GC.getGameINLINE().getActiveCivilizationType()).getCivilizationBuildings(iI);
				}
				else
				{
					eLoopBuilding = (BuildingTypes)GC.getBuildingClassInfo((BuildingClassTypes)iI).getDefaultBuildingIndex();
				}
				
				if (eLoopBuilding != NO_BUILDING && kBuilding.getGlobalBuildingCommerceChange(iI, iJ) != 0)
				{
					szFirstBuffer.Format(L"%s%s", NEWLINE, gDLL->getText("TXT_KEY_CIVIC_BUILDING_COMMERCE_CHANGE", kBuilding.getGlobalBuildingCommerceChange(iI, iJ), GC.getCommerceInfo((CommerceTypes)iJ).getChar()).c_str());
					CvWString szBuilding;
					szBuilding.Format(L"<link=literal>%s</link>", GC.getBuildingInfo(eLoopBuilding).getDescription());
					setListHelp(szBuffer, szFirstBuffer, szBuilding, L", ", (kBuilding.getGlobalBuildingCommerceChange(iI, iJ) != iLast));
					if (iLast == kBuilding.getGlobalBuildingCommerceChange(iI, iJ)) iCount++;
					iLast = kBuilding.getGlobalBuildingCommerceChange(iI, iJ);
					if (iCount > 3) iCount = iLast = 0;
				}
			}
		}
I presume the text code is for the building with the tag, not the affected building and I believe the problem must be with the way the tag loads or possibly how it processes its benefits to the receiving buildings because they aren't showing those benefits received which should be a result of their calculated benefits along the process and shouldn't require any explicit coding to say its getting the bonus from elsewhere.

Again, as noted in the quotes, this COULD be in the way the xml is programmed, which I have not yet taken a look at. I thought it a bit funny that we were calling for the commerce type definition in the way its doing so there rather than relying on the usual method of values by slot... don't know if that has anything to do with it really. Just postulating here.
 
That is Koshling's work, not mine.
Both the XML and the help text generation look fine to me. Does it display the amount it adds to other buildings on the wonder itself?

I had a look at the processing code and there is a bug there:
Code:
for(int iCommerce = 0; iCommerce < NUM_COMMERCE_TYPES; iCommerce++ )
			{
				int iChange = kBuilding.getGlobalBuildingCommerceChange(iI, iCommerce);

				if ( iChange != 0 )
				{
					GET_PLAYER(getOwnerINLINE()).changeBuildingClassCommerceChange((BuildingClassTypes)iI, (CommerceTypes)iCommerce, iChange);
				}
			}
It does not work properly to remove the building like that.
It should be:
Code:
for(int iCommerce = 0; iCommerce < NUM_COMMERCE_TYPES; iCommerce++ )
			{
				int iCommerceChange = kBuilding.getGlobalBuildingCommerceChange(iI, iCommerce);

				if ( iCommerceChange != 0 )
				{
					GET_PLAYER(getOwnerINLINE()).changeBuildingClassCommerceChange((BuildingClassTypes)iI, (CommerceTypes)iCommerce, ICommerceChange * iChange);
				}
			}

It should still work though in the former version if you only add the wonder once and never remove it.

I don't think there is a help for that on the effected building though currently. Have you checked if it actually does something or have you only checked the help texts?
 
Not yet (sorta)... there's been this further conversation on the subject:

This is one of my wonders, so I can enhance it. Cahokia Mounds is supposed to provide +50% production speed of Tumulus and +2 Culture from Tumulus, although the bonus doesn't always seem to show up when the Tumulus is in the production queue. Do you think I should increase the culture bonus, or give it another new ability?

Well... Stonehenge grants a free monument to all cities which is fairly similar in strength to giving a free Tumulus in all cities. However, the +2 Culture from Tumulus is interesting... does that affect all cities? If it does, that might be effective enough actually... I have a feeling the benefit isn't utilizing the right tags somehow if that detail isn't showing up - she states she had already built the tumulus in that city.

This may end up being more of a bug in the tags used to give the +2 culture actually. I may need to look into that from the dll side.

The Culture bonus is supposed to affect all Tumulus in your civilization. If you wouldn't mind, could you take a look at both Cahokia Mounds and Serpent Mound? Cahokia is supposed to add +2 culture to Tumulus, and Serpent Mound adds +2 science to Tumulus. The tag responsible is our relatively new <GlobalBuildingExtraCommerces>. I've used it on several of my Wonders to add bonuses to particular buildings from a Wonder.

I can take a look at that tag, yes. But I can't promise much as I've yet to wrap my head around Commerce programming. The method utilized with them and yields is a little confusing for me to read.

As a separate issue/bug/problem, we also need to take a look at the free fire pit in every city... apparently it doesn't seem to be giving it, though it says it does, from controlled fire, or at least not everywhere. This is my wife's report... I haven't looked into it much to know exactly what the problem there is.

I'll take a look more later this afternoon. Apparently that tag is probably one of the issues - maybe just a text issue which would be fairly easy to resolve.

OK, so we have a serious problem here somewhere.

The benefits from those mounds listed under those tags aren't working at all it seems. I'm not seeing any effect indicated for them on the wonder (not in the help pops nor the pedia), nor on the tumulus once the wonder is built.

The tags were apparently designed by AIAndy and utilize a highly complex level of structure based vectors which may be just a notch past my ability to sort out. Just looking at the coding it seems alright... but either its simply not working to bring the data in correctly (which COULD be the way the tags are utilized in the XML) or there's problems with the text manager calling those benefits.

I'll post the issue in the bugs thread and keep taking a look at the problem but I warn it may be beyond my current capacity right now to solve due to the sheer complexity of working with not only the vector itself but the commerce system as well. Furthermore, this sort of one building affecting another on a global level is fairly complex as well and may be a bit tough for me to follow through the code. I could sort it out but it could take me a LONG time to do so. If it hasn't been addressed, I'll come back to it once my other projects are finished.

Okay, thanks for bringing it to our attention. I wasn't sure myself what was going on with the wonder, because the bonus appeared sometimes and didn't appear at other times. I've used that tag on a few other Wonders. I don't know if anyone else has reported a similar problem with any of my other Wonders that use it.

The fact that its appeared at any time is a bit odd and could be used to locate the problem. I don't see any condition for it to appear in my wife's game right now... So yeah, if anyone sees those modifiers, I'd like to know.

I'm just as concerned with the free firepit not being given to the cities when Controlled Fire is built too... ugh.

Here is a screenshot from my current game. I control both Cahokia Mounds and Serpent Mound, and Mexico City is showing the bonuses to Tumulus. Tumulus would never give a Science bonus under normal circumstances, and the Culture is more than what you would get from a normal Tumulus.

Ok, so it shows up in the build help. But does it ever show up in the building help when the tumulus is in the city already? Or in the pedia? Does the bonus show up in the build help on the Mounds themselves? We may just have a text generator problem.

A good way to test further to isolate if its just a text problem would be to note the base research and culture values the round before the tumulus is built and comparing that to the round after its built. (Pop changes, Property Buildings that may have come in or left during that round, and Trade changes could possibly throw that calculation so it might be worth noting those to make sure.) It'd be interesting to see if the building is actually giving the benefits according to the adjustment from the Mounds being in play.

Since we have even one help popup showing the values accurately, I'm compelled to think we have primarily a text based problem only. THAT might be a bit easier for me to resolve. (I say might because the text generation I posted in the bug thread I started on this used some fairly unusual methods that I'm unsure about - of course that may be part of the problem itself... code may have been copied and not quite adapted correctly.)

EDIT: Wait wait... I looked at your image again and noticed its ONLY SHOWING IN THE 'ACTUAL' calculation! WEIRD!!! That's not the value displaying directly for the building but the projected overall effect of that building being put into play. I KNOW there's a lot of issues with the actual calculation on many buildings and this may be one reason - missing real value displays perhaps? Still, that does suggest its actually calculating the values correctly and the problem is only in the text manager file! I'd still appreciate hearing results from any aforementioned test though.

Sorry, btw, to insinuate you as the developer there. I assumed based on the vector setup. And I'm not trying to point fingers either, just calling for help really ;).

Your code tweak is interesting and I'll try to include that.

I do think this is mostly a matter of the help texts missing something or not working where it should.
 
@T-brd:

I've added this to the SVN with my latest commit, so don't worry about it.

Thanks... as you know I'm not in a great position to have done that in a manner that could be committed any time soon so that's a big help there.

I don't think it covers every issue here though... I'll have to take a deeper look at the text manager on these matters.
 
Ok, so I more patiently reviewed your change on the building processing and I now suspect that it will actually fix the whole problem. From what I gather, that section doesn't just remove the building data but adds the building data as well. It's dependent on the value of iChange. If I change is -1 then its removing the building details, if its 1 then its adding the building details. So I think you found the crux of the problem and it'd be worth a quick load on the new svn to prove it.
 
Back
Top Bottom