[SDK Debugging] CvCity.cpp - Error C2065 & Error C2039 - Any Suggestions?

doronron

King
Joined
Nov 16, 2003
Messages
906
Location
Home or Work...
I am currently attempting to merge TheLopez's M.A.D. Nukes, TheLopez's Localized Starting Techs, and monteczuma's Influence Driven War into a BtS v3.02 DLL. I have several debug errors to work through, but I need some help -- I haven't written or debugged any program code that wasn't HTML or XML in years.

So, the first error I have is:

* Error C2065: 'bNewValue': undeclared identifier

Code:
void CvCity::setNumRealBuilding(BuildingTypes eIndex, int iNewValue)
{
	setNumRealBuildingTimed(eIndex, iNewValue, true, getOwnerINLINE(), GC.getGameINLINE().getGameTurnYear());

	// < M.A.D. Nukes Start >

	if(bNewValue && GC.getBuildingInfo(eIndex).enablesMAD() && GC.getGameINLINE().isMADNukesEnabled())

	{
		GET_PLAYER(getOwnerINLINE()).setMADNukesEnabled(iNewValue);

	}

	// < M.A.D. Nukes End   >

When i change this to 'iNewValue':

Code:
void CvCity::setNumRealBuilding(BuildingTypes eIndex, int iNewValue)
{
	setNumRealBuildingTimed(eIndex, iNewValue, true, getOwnerINLINE(), GC.getGameINLINE().getGameTurnYear());

	// < M.A.D. Nukes Start >

	if([b]iNewValue[/b] && GC.getBuildingInfo(eIndex).enablesMAD() && GC.getGameINLINE().isMADNukesEnabled())

	{

GET_PLAYER(getOwnerINLINE()).setMADNukesEnabled(iNewValue);

	}

	// < M.A.D. Nukes End   >

This resolves the error. Was this correct?

Also, the next CvCity.cpp error was:

* Error C2039: 'isAllowsNukes': is not a member of CvBuildingInfo'

Code:
			     if (GC.getBuildingInfo(eIndex).isAllowsNukes())

				{

					GC.getGameINLINE().makeNukesValid(true);

				}

When I change the code to:

Code:
				if (GC.getBuildingInfo(eIndex).[b]enablesMAD[/b]())

				{

					GC.getGameINLINE().[b]isMADNukesEnabled()[/b];

				}

This resolves the bug and continues the compile. Was this correct?
 
Code:
void CvCity::setNumRealBuilding(BuildingTypes eIndex, int iNewValue)
{
	setNumRealBuildingTimed(eIndex, iNewValue, true, getOwnerINLINE(), GC.getGameINLINE().getGameTurnYear());

	// < M.A.D. Nukes Start >

	if([b]iNewValue[/b] && GC.getBuildingInfo(eIndex).enablesMAD() && GC.getGameINLINE().isMADNukesEnabled())

	{

GET_PLAYER(getOwnerINLINE()).setMADNukesEnabled(iNewValue);

	}

	// < M.A.D. Nukes End   >

While the above will probably work something like this would probably be a bit more accurate:

Code:
void CvCity::setNumRealBuilding(BuildingTypes eIndex, int iNewValue)
{
	setNumRealBuildingTimed(eIndex, iNewValue, true, getOwnerINLINE(), GC.getGameINLINE().getGameTurnYear());

	// < M.A.D. Nukes Start >

	if([b]iNewValue > 0[/b] && GC.getBuildingInfo(eIndex).enablesMAD() && GC.getGameINLINE().isMADNukesEnabled())

	{

GET_PLAYER(getOwnerINLINE()).setMADNukesEnabled([b]true[/b]);

	}

	// < M.A.D. Nukes End   >

I'd need more information about the surrounding code to answer your second question with any kind of accuracy.
 
Hmm. Could you explain why would that works better -- what I am missing? I'm trying to learn this as I go, really, but I want to get this to work.

I'm not entirely certain how much of the code you need to see, so attached is the modified source files I'm working on along with the old WL 2.08 sources that the code was pulled from. One thing I noticed while placing the MAD code into BtS was that there were a lot of code pertaining to Nukes in BtS that wasn't replaced by TheLopez's stuff (which makes me think it was implemented in v3.02).

Here are the sources.
 
Hmm. Could you explain why would that works better -- what I am missing? I'm trying to learn this as I go, really, but I want to get this to work.

I'm not entirely certain how much of the code you need to see, so attached is the modified source files I'm working on along with the old WL 2.08 sources that the code was pulled from. One thing I noticed while placing the MAD code into BtS was that there were a lot of code pertaining to Nukes in BtS that wasn't replaced by TheLopez's stuff (which makes me think it was implemented in v3.02).

Here are the sources.

It doesn’t necessarily work better per say, but it's more accurate. In C/C++ "if(iNewValue)" will evaluate to true when iNewValue is non-zero and false when iNewValue is equal to zero. Now it appears that the code you were trying to port in from the MAD mod was that from "CvCity::setHasRealBuilding" - which, if I'm not mistaken was replaced by "CvCity::setNumRealBuilding" which takes an int as its second parameter rather than a bool. I'm assuming that the game will set iNewValue to 0 if the building doesn't exist and some value greater than zero if it does exist. Your code would technically function improperly if, say, the game passed a value of -1 to iNewValue to indicate the building does not exist.

I may take a look at the code you posted later tonight.
 
OK, that makes sense. I did notice that a good chunk of the functions used were changed for others, with variables being switched from Boolean to Integer, so I figured on running into some problems. Just kind of surprised at all the extra nuke code in the files. I wonder how much of it pertains to the new guided missile & tactical nuke features. The Sources zip includes all of the affected *.cpp and *.h files, by the way, as I suspect I will end up asking questions on bugs in every one of them.

Thank you for your help.
 
* Error C2039: 'isAllowsNukes': is not a member of CvBuildingInfo'

Code:
			     if (GC.getBuildingInfo(eIndex).isAllowsNukes())

				{

					GC.getGameINLINE().makeNukesValid(true);

				}

You should not be getting a compile time error here unless you specifically removed isAllowsNukes from CvBuildingInfo. I'll assume for the moment that isn't the case, in which case - you are starting your merge process with the latest Vanilla version of the SDK and attempting to apply all of the code changes (and ONLY the code changes), as indicated in the MAD mod's code by "// < M.A.D. Nukes Start >", to that version of the SDK, correct?
 
I am removing 'IsAllowsNukes' as it was part of the required changes according to TheLopez's original code as compared to the stock v2.08 Warlords sources.

If I put it back in, would the new code that continues to call it conflict with the MAD Nukes code?
 
I am removing 'IsAllowsNukes' as it was part of the required changes according to TheLopez's original code as compared to the stock v2.08 Warlords sources.

If I put it back in, would the new code that continues to call it conflict with the MAD Nukes code?

I have no idea. I don't have the stock warlords code unfortunately.
 
Back
Top Bottom