Trying to edit the Great General Points from Barb Combat mod

draco963

Prince
Joined
Jan 26, 2007
Messages
451
Location
Ottawa
OK, so Thomas SG very kindly updated TheLopez's original mod, and it now works in BtS, which is great. My problem is, I am trying to port in the iUpgradeCost modifier for buildings that was developed in the CCCP, as I really like a Civ III style Leonardo's workshop.

So, I was able to isolate all the changed DLL files in the CCCP where that tag showed up, and started bringing it into Thomas's update GGfBC mod. CodeBlocks gave all sorts of errors when I tried to compile it though, so I did a little digging.

Turns out that the changed DLL files Thomas included in the updated GGfBC mod are hugely different from the BtS originals, and when I try to compile a DLL using just those (without my changes) the compile fails, citing many, mnay errors in CvGame.cpp.

So, I'm attaching those files, and I hope someone can clear up what's wrong for me, because I am in way over my head, and I haven't got a clue what's going on...

In particular, I should note that CvUnit.cpp is way bigger, and CvGame.cpp & CvPlayer.cpp are way smaller, than the BtS v3.17 originals.

View attachment C++ source (changed files only).rar

And here's a copy of what CodeBlocks tells me:
Spoiler :
||=== CvGameCoreDLL, Final Release Win32 ===|
CvGame.cpp|327|error C2039: 'clearSigns' : is not a member of 'CvDLLEngineIFaceBase'|
CvGame.cpp|629|error C2660: 'CvTeam::declareWar' : function does not take 3 arguments|
CvGame.cpp|2216|error C2660: 'CvPlayer::updateCitySight' : function does not take 2 arguments|
CvGame.cpp|6552|error C2660: 'CvTeam::declareWar' : function does not take 3 arguments|
CvGame.cpp|7205|error C2660: 'CvTeam::declareWar' : function does not take 3 arguments|
CvGame.cpp|7223|error C2660: 'CvPlayer::acquireCity' : function does not take 4 arguments|
CvGame.cpp|8650|error C2660: 'CvPlayerAI::AI_diploVote' : function does not take 3 arguments|
CvGame.cpp|8699|error C2065: 'NO_PLAYER_VOTE_CHECKED' : undeclared identifier|
CvGame.cpp|8703|error C2678: binary '==' : no operator found which takes a left-hand operand of type 'PlayerVoteTypes' (or there is no acceptable conversion)|
CvGame.cpp|8703|error C3861: 'NO_PLAYER_VOTE_CHECKED': identifier not found, even with argument-dependent lookup|
||=== Build finished: 10 errors, 0 warnings ===|


Thanks!!!
 
I hope someone is able to make more sense of this now that I have more information...

I was able to integrate the changes in six of the seven DLL source files into the BtS originals, except for CvUnit.cpp... That one has me totally stumped. The reason being:

This is what is written into the changed DLL (lines 1052-1209 in the previously uploaded file):
Spoiler :
void CvUnit::resolveCombat(CvUnit* pDefender, CvPlot* pPlot, CvBattleDefinition& kBattle)
{
CombatDetails cdAttackerDetails;
CombatDetails cdDefenderDetails;

int iAttackerStrength = currCombatStr(NULL, NULL, &cdAttackerDetails);
int iAttackerFirepower = currFirepower(NULL, NULL);
int iDefenderStrength;
int iAttackerDamage;
int iDefenderDamage;
int iDefenderOdds;

getDefenderCombatValues(*pDefender, pPlot, iAttackerStrength, iAttackerFirepower, iDefenderOdds, iDefenderStrength, iAttackerDamage, iDefenderDamage, &cdDefenderDetails);
int iAttackerKillOdds = iDefenderOdds * (100 - withdrawalProbability()) / 100;

if (isHuman() || pDefender->isHuman())
{
//Added ST
CyArgsList pyArgsCD;
pyArgsCD.add(gDLL->getPythonIFace()->makePythonObject(&cdAttackerDetails));
pyArgsCD.add(gDLL->getPythonIFace()->makePythonObject(&cdDefenderDetails));
pyArgsCD.add(getCombatOdds(this, pDefender));
gDLL->getEventReporterIFace()->genericEvent("combatLogCalc", pyArgsCD.makeFunctionArgs());
}

collateralCombat(pPlot, pDefender);

while (true)
{
if (GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("COMBAT_DIE_SIDES"), "Combat") < iDefenderOdds)
{
if (getCombatFirstStrikes() == 0)
{
if (getDamage() + iAttackerDamage >= maxHitPoints() && GC.getGameINLINE().getSorenRandNum(100, "Withdrawal") < withdrawalProbability())
{
flankingStrikeCombat(pPlot, iAttackerStrength, iAttackerFirepower, iAttackerKillOdds, iDefenderDamage, pDefender);

// < Great Generals From Barbarian Combat Start >

bool xpFromCombat = true;

if(pDefender->isBarbarian() && !GC.getGameINLINE().isGreatGeneralFromBarbarianCombat())
{
xpFromCombat = false;
}

if(pDefender->isAnimal() && !GC.getGameINLINE().isGreatGeneralFromAnimalCombat())
{
xpFromCombat = false;
}

changeExperience(GC.getDefineINT("EXPERIENCE_FROM_WITHDRAWL"), pDefender->maxXPValue(), xpFromCombat, pPlot->getOwnerINLINE() == getOwnerINLINE(), true);
// < Great Generals From Barbarian Combat End >
//changeExperience(GC.getDefineINT("EXPERIENCE_FROM_WITHDRAWL"), pDefender->maxXPValue(), true, pPlot->getOwnerINLINE() == getOwnerINLINE(), !pDefender->isBarbarian());
break;
}

changeDamage(iAttackerDamage, pDefender->getOwnerINLINE());

if (pDefender->getCombatFirstStrikes() > 0 && pDefender->isRanged())
{
kBattle.addFirstStrikes(BATTLE_UNIT_DEFENDER, 1);
kBattle.addDamage(BATTLE_UNIT_ATTACKER, BATTLE_TIME_RANGED, iAttackerDamage);
}

cdAttackerDetails.iCurrHitPoints = currHitPoints();

if (isHuman() || pDefender->isHuman())
{
CyArgsList pyArgs;
pyArgs.add(gDLL->getPythonIFace()->makePythonObject(&cdAttackerDetails));
pyArgs.add(gDLL->getPythonIFace()->makePythonObject(&cdDefenderDetails));
pyArgs.add(1);
pyArgs.add(iAttackerDamage);
gDLL->getEventReporterIFace()->genericEvent("combatLogHit", pyArgs.makeFunctionArgs());
}
}
}
else
{
if (pDefender->getCombatFirstStrikes() == 0)
{
if (std::min(GC.getMAX_HIT_POINTS(), pDefender->getDamage() + iDefenderDamage) > combatLimit())
{
changeExperience(GC.getDefineINT("EXPERIENCE_FROM_WITHDRAWL"), pDefender->maxXPValue(), true, pPlot->getOwnerINLINE() == getOwnerINLINE(), !pDefender->isBarbarian());
pDefender->setDamage(combatLimit(), getOwnerINLINE());
break;
}

pDefender->changeDamage(iDefenderDamage, getOwnerINLINE());

if (getCombatFirstStrikes() > 0 && isRanged())
{
kBattle.addFirstStrikes(BATTLE_UNIT_ATTACKER, 1);
kBattle.addDamage(BATTLE_UNIT_DEFENDER, BATTLE_TIME_RANGED, iDefenderDamage);
}

cdDefenderDetails.iCurrHitPoints=pDefender->currHitPoints();

if (isHuman() || pDefender->isHuman())
{
CyArgsList pyArgs;
pyArgs.add(gDLL->getPythonIFace()->makePythonObject(&cdAttackerDetails));
pyArgs.add(gDLL->getPythonIFace()->makePythonObject(&cdDefenderDetails));
pyArgs.add(0);
pyArgs.add(iDefenderDamage);
gDLL->getEventReporterIFace()->genericEvent("combatLogHit", pyArgs.makeFunctionArgs());
}
}
}

if (getCombatFirstStrikes() > 0)
{
changeCombatFirstStrikes(-1);
}

if (pDefender->getCombatFirstStrikes() > 0)
{
pDefender->changeCombatFirstStrikes(-1);
}

if (isDead() || pDefender->isDead())
{
// < Great Generals From Barbarian Combat Start >
bool xpFromCombat = true;

if(pDefender->isBarbarian() && !GC.getGameINLINE().isGreatGeneralFromBarbarianCombat())
{
xpFromCombat = false;
}

if(pDefender->isAnimal() && !GC.getGameINLINE().isGreatGeneralFromAnimalCombat())
{
xpFromCombat = false;
}

if (isDead())
{
int iExperience = defenseXPValue();
iExperience = ((iExperience * iAttackerStrength) / iDefenderStrength);
iExperience = range(iExperience, GC.getDefineINT("MIN_EXPERIENCE_PER_COMBAT"), GC.getDefineINT("MAX_EXPERIENCE_PER_COMBAT"));
pDefender->changeExperience(iExperience, maxXPValue(), xpFromCombat, pPlot->getOwnerINLINE() == pDefender->getOwnerINLINE(), true);
}
else
{
flankingStrikeCombat(pPlot, iAttackerStrength, iAttackerFirepower, iAttackerKillOdds, iDefenderDamage, pDefender);

int iExperience = pDefender->attackXPValue();
iExperience = ((iExperience * iDefenderStrength) / iAttackerStrength);
iExperience = range(iExperience, GC.getDefineINT("MIN_EXPERIENCE_PER_COMBAT"), GC.getDefineINT("MAX_EXPERIENCE_PER_COMBAT"));
changeExperience(iExperience, pDefender->maxXPValue(), xpFromCombat, pPlot->getOwnerINLINE() == getOwnerINLINE(), true);
}
// < Great Generals From Barbarian Combat End >

break;
}
}
}

This one argument, CvUnit::resolveCombat contains both the changes made to accomodate the Great Generals from Barbarians mod. But the BtS version of CvUnit.cpp has no such argument. In the changed file, the previous three arguments (updateAirStrike, resolveAirCombat & updateAirCombat) don't exist in the BtS version, and the argument following (updateCombat) occurs much sooner in the BtS than the changed file (about where the Air arguments start in the changed file).

So, I have absolutely no idea how to reconcile this... Please, please, please someone save me!! :cry:
 
I'm not exactly sure what you mean, partly because of your use of the term "argument" where I believe you mean "function." Note that it doesn't much matter where a particular function is defined in a given file; it'll work whether it's listed first or last so long as the prototype is in the headers.

Anyhow, in the unmodified BTS 3.17 sources the CvUnit::resolveCombat() function begins on line 1052, right between CvUnit::updateAirCombat() and CvUnitUpdateCombat(); it's the same position and ordering as in the RAR file you posted above...
 
Dresden, thanks for the reply, and the corrction to my grammer.

And if the CvUnit::resolveCombat() function begins on line 1085, then there is something seriously wrong with my unmodified BtS DLL files, cause it's not there...

Where could I go to d/l a clean copy of the BtS v3.17 SDK? I've already re-installed BtS twice, so I'm seriously confused...

Some more details: my CvUnit.cpp file is 295 kB, and was last modified on 28/06/2007. If that's the commercial copy, then everyone else's should be the same...

Thanks again.
 
I can't tell you the exact 3.17 release date, but the thread here on CFC "announcing" it was started 18 June 2008, so yours is definitely too new. I'd have guessed it was from Solver's Unofficial Patch given the date, but the file size is too small and that version has CvUnit::resolveCombat() right on line 1052. :confused:

Here are the stats of the various versions from what I know:
  • The Original 3.17 CvUnit.cpp is 302 KB (309,684 bytes) and last modified 1 May 2008
  • The Solver 0.19 Unofficial Patch CvUnit.cpp is 302 KB (310,098 bytes) and last modified 27 June 2008
  • The 0.19.1 Unofficial Patch CvUnit.cpp is 303 KB (310,744 bytes) and last modified 18 August 2008

Anyhow, attached is a clean copy of the original "official" 3.17 sources. Note that after you download it I might remove the attachment since it's big and sucks up a good deal of my attachment quota ;)
 

Attachments

  • Source_317_Official.rar
    5.4 MB · Views: 58
Now THAT'S better!!! :D:king::goodjob:

Thank-you Dresden, so much! I don't know what was wrong with my "originals", but they definately don't match yours. Haven't been able to compare more than three so far, gotta get to work, but it's looking very good. I'll write back tonight, but I'm sure this will solve all my problems.

Now that I've got this, I'll keep the rar incase I need to start fresh again. Go ahead and delete it, with my thanks. ;)
 
Figured out what was wrong with my originals Dresden. Turns out, for whatever starnge reason, the BtS v3.17 patch was not installing to the correct directory, but was instead making a new dir for itself two levels up the directory tree... Odd as heck, but it does explain my problems.

Thanks again for your help!
 
Top Bottom