Skip to content

Commit

Permalink
CHANGELOG: Fix rearming pads to actually repair units
Browse files Browse the repository at this point in the history
refs ticket:1581
fixes ticket:2313
fixes ticket:2234

Fix rearming pads so they actually rearm at the speed they're intended to. Also make rearming upgrades affect rearming pad repair speed. Replaces REARM_PAD.currentPtsAdded with REARM_PAD.timeLastUpdated, but savefiles should still be compatible.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8865 4a71c877-e1ca-e34f-864e-861f7616d084
(cherry picked from commit 75569d1)

Conflicts:

	src/game.c
	src/structure.c
(cherry picked from commit 6421c81)
  • Loading branch information
buginator authored and cybersphinx committed Nov 15, 2010
1 parent c17f420 commit 81b29af
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/structure.c
Expand Up @@ -3580,6 +3580,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure)
else if (structureMode == REF_REARM_PAD)
{
REARM_PAD *psReArmPad = &psStructure->pFunctionality->rearmPad;
UDWORD pointsAlreadyAdded;

psDroid = (DROID *)psChosenObj;
ASSERT_OR_RETURN( , psDroid != NULL, "invalid droid pointer");
Expand Down Expand Up @@ -3643,7 +3644,8 @@ static void aiUpdateStructure(STRUCTURE *psStructure)
// Make sure it's a rearmable weapon (and so we don't divide by zero)
if (psDroid->sMove.iAttackRuns[i] > 0 && asWeaponStats[psDroid->asWeaps[i].nStat].numRounds > 0)
{
// Written this way to prevent rounding errors - do not "simplify"
// Do not "simplify" this formula.
// It is written this way to prevent rounding errors.
int ammoToAddThisTime =
pointsToAdd*getNumAttackRuns(psDroid,i)/pointsRequired -
pointsAlreadyAdded*getNumAttackRuns(psDroid,i)/pointsRequired;
Expand All @@ -3670,15 +3672,16 @@ static void aiUpdateStructure(STRUCTURE *psStructure)
/* do repairing */
if (psDroid->body < psDroid->originalBody)
{
// Written this way to prevent rounding errors - do not "simplify"
pointsToAdd = VTOL_REPAIR_FACTOR * (100+asReArmUpgrade[psStructure->player].modifier) * (gameTime % (1<<16))
/ (GAME_TICKS_PER_SEC * 100);
pointsToAdd -= VTOL_REPAIR_FACTOR * (100+asReArmUpgrade[psStructure->player].modifier) * (psReArmPad->timeLastUpdated % (1<<16))
/ (GAME_TICKS_PER_SEC * 100);
// Do not "simplify" this formula.
// It is written this way to prevent rounding errors.
pointsToAdd = VTOL_REPAIR_FACTOR * (100+asReArmUpgrade[psStructure->player].modifier) * (gameTime -
psReArmPad->timeStarted) / (GAME_TICKS_PER_SEC * 100);
pointsAlreadyAdded = VTOL_REPAIR_FACTOR * (100+asReArmUpgrade[psStructure->player].modifier) * (psReArmPad->timeLastUpdated -
psReArmPad->timeStarted) / (GAME_TICKS_PER_SEC * 100);

if (pointsToAdd > 0)
if ((pointsToAdd - pointsAlreadyAdded) > 0)
{
psDroid->body += pointsToAdd;
psDroid->body += (pointsToAdd - pointsAlreadyAdded);
}
if (psDroid->body >= psDroid->originalBody)
{
Expand Down

0 comments on commit 81b29af

Please sign in to comment.