Skip to content

Commit

Permalink
Fix power generation speed in multiplayer depending on game options d…
Browse files Browse the repository at this point in the history
…ifficulty level.

Basically, any player that changed the game difficulty level to help them beat the campaign would end up accidentally cheating 10% extra power in multiplayer...

This cause different clients to disagree on the game state, but that's normal.

Changelog: Fix each player's power generation speed in multiplayer depending on the their game options difficulty level.
  • Loading branch information
Cyp committed Nov 1, 2010
1 parent 1637e3e commit 8707a2a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "lib/framework/frame.h"

#include "lib/netplay/netplay.h"

#include "difficulty.h"
#include "intdisplay.h"
#include "mission.h"
Expand Down Expand Up @@ -132,7 +134,7 @@ static int32_t updateExtractedPower(STRUCTURE *psBuilding)
{
RES_EXTRACTOR *pResExtractor;
int32_t pointsToAdd, extractedPoints;
int32_t powmodifier;
int32_t powmodifier = NORMAL_POWER_MOD/10;

pResExtractor = (RES_EXTRACTOR *) psBuilding->pFunctionality;
extractedPoints = 0;
Expand All @@ -142,17 +144,14 @@ static int32_t updateExtractedPower(STRUCTURE *psBuilding)
{
int overflowDiff;
// Add modifier according to difficulty level
if (getDifficultyLevel() == DL_EASY)
{
powmodifier = EASY_POWER_MOD/10;
}
else if (getDifficultyLevel() == DL_HARD)
if (!NetPlay.bComms) // ignore multiplayer games
{
powmodifier = HARD_POWER_MOD/10;
}
else
{
powmodifier = NORMAL_POWER_MOD/10;
switch (getDifficultyLevel())
{
case DL_EASY: powmodifier = EASY_POWER_MOD/10; break;
case DL_HARD: powmodifier = HARD_POWER_MOD/10; break;
default: break;
}
}
// if the extractor hasn't been updated recently, now would be a good time.
if (pResExtractor->timeLastUpdated < 20 && gameTime >= 20)
Expand Down

0 comments on commit 8707a2a

Please sign in to comment.