messing with CvDeal.cpp

Afforess

The White Wizard
Joined
Jul 31, 2007
Messages
12,239
Location
Austin, Texas
I want to make it so Masters can end vassal agreements, and I have it partially working. Right now, Masters can end vassal agreements at will, but so can vassals. Here's the section of code I'm editing, with the change colored.

Code:
bool CvDeal::isCancelable(PlayerTypes eByPlayer, CvWString* pszReason)
{
    if (isUncancelableVassalDeal(eByPlayer, pszReason))
    {

       [COLOR=Red] return true;[/COLOR] (It was false)

    }

    int iTurns = turnsToCancel(eByPlayer);
    if (pszReason)
    {
        if (iTurns > 0)
        {
            *pszReason = gDLL->getText("TXT_KEY_MISC_DEAL_NO_CANCEL", iTurns);
        }
    }

    return (iTurns <= 0);
}

Now, I think I need to change it to something like this, but it brings up errors in codeblocks.

Code:
bool CvDeal::isCancelable(PlayerTypes eByPlayer, CvWString* pszReason)
{
    if (isUncancelableVassalDeal(eByPlayer, pszReason))
    {
/*************************************************************************************************/
/** Afforess  Realistic Diplomacy             08/13/09                                              */
/**                                                                                              */
/**                                                                                              */
/*************************************************************************************************/
        if (!(GET_TEAM(getTeam()).isAVassal()))
        {
            return false;
        }
        else
        {
            return true; 
        }
/*************************************************************************************************/
/** Afforess  Realistic Diplomacy                         END                                      */
/*************************************************************************************************/
    }

    int iTurns = turnsToCancel(eByPlayer);
    if (pszReason)
    {
        if (iTurns > 0)
        {
            *pszReason = gDLL->getText("TXT_KEY_MISC_DEAL_NO_CANCEL", iTurns);
        }
    }

    return (iTurns <= 0);
}


The errors codeblocks gives are:

CvDeal.cpp(1085) : error C2228: left of '.isAVassal' must have class/struct/union type
CvDeal.cpp(1085) : error C3861: 'getTeam': identifier not found, even with argument-dependent

Any idea what I'm doing wrong, and what the code should look like?
 
Firstly, GET_TEAM() returns a pointer.
GET_TEAM(x)->isAVassal() ;)

CvDeal has no function called "getTeam()". You've to take the ID of eByPlayer (I think).
You could use GET_PLAYER(eByPlayer)->getTeam().

The corrected line:
if (!(GET_TEAM(GET_PLAYER(eByPlayer)->getTeam())->isAVassal()))
 
The corrected line:
if (!(GET_TEAM(GET_PLAYER(eByPlayer)->getTeam())->isAVassal()))

This line does not work. I get several errors when I try to compile.

Here's the errors:
CvDeal.cpp(1085) : error C2819: type 'CvPlayerAI' does not have an overloaded member 'operator ->'
c:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\CvGameCoreDLL\CvPlayerAI.h(13) : see declaration of 'CvPlayerAI'
did you intend to use '.' instead?
CvDeal.cpp(1085) : error C2227: left of '->getTeam' must point to class/struct/union
type is 'CvPlayerAI'
did you intend to use '.' instead?
CvDeal.cpp(1085) : error C2227: left of '->isAVassal' must point to class/struct/union
After looking at the errors, I changed the line to:
Code:
if (!(GET_TEAM(GET_PLAYER(eByPlayer).getTeam()).isAVassal()))
and It compiled fine, but the code doesn't work as intended. The game seems to ignore it.
 
Yes, you're right. It's '.', not '->':wallbash:

Maybe you should fix the code of "isUncancelableVassalDeal" :confused:
 
In CvDeal, there is a function "isUncancelableVassalDeal".
I think you should change some return values of this function.
Maybe this could solve your problem.
But I'm not quite sure which values you have to change :(
 
First, I think you should check if the deal is an uncancelable vassal deal first, and only then have you extra logic. This would block non-vassals from canceling all deals. Otherwise the logic seems sounds. Add some logging statements to it to track what's going on or use a debug DLL and step through the code.
 
Top Bottom