Questions on the DLL

I assume that these buttons are the new widgets you added, right?
If so - make sure you added the proper code (CvDLLWidgetData:: parseHelp? a new popup definition?).

If everything is defined properly, and the python code seems fine, try adding a breakpoint in the C++ code when debugging, in the function(s) that should be called when the button is pressed.

Another thing - in the widgets enum itself - make sure you added your widgets at the end (right before NUM_WIDGET_TYPES), or else there might be problems (I had them when I added widgets). Probably a conflict with the definitions in the exe.
 
I assume that these buttons are the new widgets you added, right?
...
Another thing - in the widgets enum itself - make sure you added your widgets at the end (right before NUM_WIDGET_TYPES), or else there might be problems (I had them when I added widgets). Probably a conflict with the definitions in the exe.

Actually the buttons weren't the widgets I added, but I did as you suggested and moved the widgets to the end, and now it works. Thanks :)

I have another question, though. Does CvPlayer::changeCommerceRateModifier add commerce (like +2:gold:) or add a percentage of commerce (like +50%:science:)? If it does the latter, what function adds commerce like the former example?
 
I have another question, though. Does CvPlayer::changeCommerceRateModifier add commerce (like +2:gold:) or add a percentage of commerce (like +50%:science:)? If it does the latter, what function adds commerce like the former example?

All the functions which end with 'Modifier' relate to percentage. So the latter.

I'm not sure what you want the function to do - to add a +2:gold: to a player? to each one of the player's cities?
I don't know if there's anything like it - you could probably add if it doesn't exist (something along the lines of getExtraCommerce and changeExtraCommerce).
 
All the functions which end with 'Modifier' relate to percentage. So the latter.

I'm not sure what you want the function to do - to add a +2:gold: to a player? to each one of the player's cities?
I don't know if there's anything like it - you could probably add if it doesn't exist (something along the lines of getExtraCommerce and changeExtraCommerce).

I want it to add commerce to each city. I assumed if there was a function to add a percentage of commerce to a city, there would be one to add commerce. Are you saying there isn't?
 
There are functions that update the specialists and their commerce, but I couldn't find one unrelated to specialists (although I must admit I didn't look that hard).

I guess there should be something else - for example for the shrine income - but I don't know where it is.
Look for the code which calculates the commerce (CvCity::updateCommerce, I think) and see what affects it.
 
There has to be a function somewhere that adds commerce to a city from a building (like +2:culture: or something). Since I need this to apply in all cities, could I somehow loop this to affect all the player's cities (and even cities built in the future possibly, depending on how difficult this would be)? Then I would have to add it under CvTeam::ProcessTech(), correct?
 
There has to be a function somewhere that adds commerce to a city from a building (like +2:culture: or something). Since I need this to apply in all cities, could I somehow loop this to affect all the player's cities (and even cities built in the future possibly, depending on how difficult this would be)? Then I would have to add it under CvTeam::ProcessTech(), correct?

There is no function 'changeCommerce' or even 'changeBuildingCommerce'.
The update for the buildings commerce (which is returned by CvCity::getBuildingCommerce()) is done in CvCity::updateBuildingCommerce() which calls CvCity::getBuildingCommerceByBuilding(), so the actual calculation is done in the city itself for the actual buildings.

I suggest you add an 'extraCommerce' member to CvCity, and update this in processTech() (just don't forget to add this to read() and write()).

Alternatively you could use a hack and add a fake free building which adds the commerce you want. Personally, I don't like these tricks, but I've seen people use them.
 
There is no function 'changeCommerce' or even 'changeBuildingCommerce'.
The update for the buildings commerce (which is returned by CvCity::getBuildingCommerce()) is done in CvCity::updateBuildingCommerce() which calls CvCity::getBuildingCommerceByBuilding(), so the actual calculation is done in the city itself for the actual buildings.

I suggest you add an 'extraCommerce' member to CvCity, and update this in processTech() (just don't forget to add this to read() and write()).

I added the following three functions in CvCity.cpp: CvCity::updateTechCommerce(), CvCity::getTechCommerce(), and CvCity::getTechCommerceByTech(). However, when I try to call updateTechCommerce in CvTeam::ProcessTech, it cannot find it. I looked and CvCity.h is not included. I tried including it, but it still cannot find updateTechCommerce. What else do I need to do?
 
CvTeam.cpp already includes CvGameCoreDLL.h, which includes CvCity.h.

I'm guessing that you added the function to the 'protected' part of the class, which means other classes cannot access this function.
Try moving it to the 'public' section of the class, and if that doesn't work - post the exact compiler error message.
 
I checked and the function was already in the public part of CvCity. Here is the error message as requested:

Spoiler :
CvTeam.cpp(5360) : error C3861: 'updateTechCommerce': identifier not found, even with argument-dependent lookup
 
I always get that error when I forget the (arguments) in my function call. Like if I put updateTechCommerce; isntead of updateTechCommerce(eTech);

Also if you make a change to a header file you must do a full recompile, don't worry abut that if you're using Danny Deamonic's makefile, as his makefile checks for header changes for you, but the old makefiles required you to do that manually.
 
I shouldn't need any arguments, though. Here is the declaration of my function in CvCity.h:

Code:
void updateTechCommerce();

and here is my use in CvTeam.cpp:

Code:
for ( iI = 0; iI < NUM_COMMERCE_TYPES; iI++ )
{
	if (GC.getTechInfo(eTech).getCommerceChange(iI))
	{
		updateTechCommerce()
	}
}

That's all I should need, right?
 
YOu are forgetting a ;

Also the function is in CvCity, so you need to call a valid city pointer to call that function on.

Also the way I'd assume that function works, it would seem it should have an argument (a specific tech passed into it), but I don't know your code.
 
YOu are forgetting a ;

Also the function is in CvCity, so you need to call a valid city pointer to call that function on.

Also the way I'd assume that function works, it would seem it should have an argument (a specific tech passed into it), but I don't know your code.

It appears I forgot to copy the ;

What do you mean I need to call a valid city pointer?
 
You said you put your function in CvCity, so you need to call it on a CvCity object, and Civ4 uses pointers for citys, plots, and units, and references for players. Ie your call should be made like

pCity->updateTechCommerce();

And you will need to define the city somehow (most likely loop through all the cities for the players in the team and call this function on all these cities).
 
Try something like that (didn't compile it myself, so you probably need to make some changes):

Code:
	for (iI = 0; iI < MAX_PLAYERS; iI++)
	{
		if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
		{
			CvCity* pLoopCity;
			int iLoop;
			for (pLoopCity = GET_PLAYER((PlayerTypes)iI).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iI).nextCity(&iLoop))
			{
				pLoopCity->updateTechCommerce();
			}

		}
	}
 
Basically, just make sure you are calling a valid CvCity object though:

Try something like that (didn't compile it myself, so you probably need to make some changes):

Code:
	for (iI = 0; iI < MAX_PLAYERS; iI++)
	{
		if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
		{
			[b]CvCity* pLoopCity = NULL;[/b]
			int iLoop;
			for (pLoopCity = GET_PLAYER((PlayerTypes)iI).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iI).nextCity(&iLoop))
			{
				[b]if(pLoopCity)[/b]
				{
					pLoopCity->updateTechCommerce();
				}
			}

		}
	}

I also still don't understand how your updateTechCommerce() function works without a tech as an argument. I really think you should reevalute that code and consider setting it up so that the tech type is passed as an argument Ie make it CvCity::updateTechCommerce(TechTypes eTech)
 
I tried that code and got the same error as before, except with firstcity and nextcity. Do I need a pointer for these as well?
 
I edited the code just after I wrote it, maybe you copied it before I edited it.
(I added 'GET_PLAYER((PlayerTypes)iI).' before firstCity and nextCity)
 
Back
Top Bottom