Where/how do you add new read, write, reset values if no examples present?

Kailric

Jack of All Trades
Joined
Mar 25, 2008
Messages
3,100
Location
Marooned, Y'isrumgone
I am wanting to add new combat modifiers based on several factors including a Apostolic Palace Vote.. but there are no read, write, reset values for any of the votes... so where/how do I add these to the game so that my global variables are saved?

Edit: I searched for examples but only find ones where there are existing values for related types. Is there any mods that have done this that I can check them out?
 
What you're running into is the fact that Info classes, like CvVoteInfo, don't save their values. The reason for this is that they should never change within a particular release of a mod. They are read straight out of the XML files every time a mod is loaded.

I don't know what exactly it is you're trying to achieve, but assuming that each individual player can have these modifiers, I would store the values on the Player. For example, something like:

CvPlayer.h
Code:
public:
int getVoteCombatModifier();
void changeVoteCombatModifier(int iChange);

protected:
int m_iVoteCombatModifier;

CvPlayer.cpp
Code:
public:
int CvPlayer::getVoteModifier()
{
  return m_iVoteCombatModifier;
}

void CvPlayer::changeVoteModifier(int iChange)
{
  m_iChangeVoteModifier += iChange;
}

...and do all the standard saving you would do for a Player variable. (You will also need to write the code that actually applies the combat modifier in the combat calculations. I'm not sure where that is exactly in the code.)
 
Hey, thanks. The main thing I was wanting to know was if values for one info class could be saved under another. Seemed logical that it could but sense I was going to be away from my computer for a while I figured I'd ask and maybe save myself some trouble of figuring it out the old fashion way.

The code for the combat modifiers is already in place and everything works fine.. just I know that computers only do what you tell them to and I haven't told it to save those variables.

But thanks for the heads up... I'll add the code and see how it goes :goodjob:
 
Ok, i added the code as you said to Cvplayer.* and that file compiled ok, but I also need to use those variables in Cvgame.cpp. So I am getting these errors like this here.. how do I fix this?

error C3861: 'isVoteisSanctionedOnly': identifier not found, even with argument-dependent lookup

Some of the code:
Code:
else if (kVote.isVoteSanctionHolywar())
{

			
            if (isVoteisSanctionedOnly())
            {
                setVoteisSanctionedOnly(true);
            }

setVoteOutcome(kData, NO_PLAYER_VOTE);
}

So how do I make it so I can "find" those identifier while using other files besides Cvplayer? Are these variables "global" or are they stuck to a Player?

Edit: hmm... wouldn't it be better to assign those variables to the Global.* so it called from anywhere? If thats what the CvGlobal.* files are for?
 
Just looks like you have a typo. Eliminate the second 'is' in isVoteSanctionHolyWar.

That "is" should be there.. just the way I done it to differentiate between the variable and the function or something like that. I fixed the problem though. Adding the variable to CvPlayer made it so I would have to add/modify the variable to every civilization each time I used the variable.. if not then one CIv would say one thing then another something else, so instead I added it to CvGame.cpp. Now to call the variable I just use this for example:
Code:
 if ((GC.getGameINLINE().isVoteisSanctionedOnly()) || (GC.getGameINLINE().isVoteHolywarisDeclared()))
 {
            return false;
 }

I didn't realize it but there was a very good example to go by in the code already. The No Nukes Resolution that appears with the UN wonder. I totally forgot about UN resolutions cause I was just working with the AP resolutions.

So now to check the variable I just use the GC.getGameINLINE(). I got that from the No Nukes example...

But, I don't know why that works so If any one could explain that .. it would be helpful.
 
Back
Top Bottom