Skip to content

Commit 8707a2a

Browse files
committed
Fix power generation speed in multiplayer depending on game options difficulty 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.
1 parent 1637e3e commit 8707a2a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/power.c

+10-11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
#include "lib/framework/frame.h"
2828

29+
#include "lib/netplay/netplay.h"
30+
2931
#include "difficulty.h"
3032
#include "intdisplay.h"
3133
#include "mission.h"
@@ -132,7 +134,7 @@ static int32_t updateExtractedPower(STRUCTURE *psBuilding)
132134
{
133135
RES_EXTRACTOR *pResExtractor;
134136
int32_t pointsToAdd, extractedPoints;
135-
int32_t powmodifier;
137+
int32_t powmodifier = NORMAL_POWER_MOD/10;
136138

137139
pResExtractor = (RES_EXTRACTOR *) psBuilding->pFunctionality;
138140
extractedPoints = 0;
@@ -142,17 +144,14 @@ static int32_t updateExtractedPower(STRUCTURE *psBuilding)
142144
{
143145
int overflowDiff;
144146
// Add modifier according to difficulty level
145-
if (getDifficultyLevel() == DL_EASY)
146-
{
147-
powmodifier = EASY_POWER_MOD/10;
148-
}
149-
else if (getDifficultyLevel() == DL_HARD)
147+
if (!NetPlay.bComms) // ignore multiplayer games
150148
{
151-
powmodifier = HARD_POWER_MOD/10;
152-
}
153-
else
154-
{
155-
powmodifier = NORMAL_POWER_MOD/10;
149+
switch (getDifficultyLevel())
150+
{
151+
case DL_EASY: powmodifier = EASY_POWER_MOD/10; break;
152+
case DL_HARD: powmodifier = HARD_POWER_MOD/10; break;
153+
default: break;
154+
}
156155
}
157156
// if the extractor hasn't been updated recently, now would be a good time.
158157
if (pResExtractor->timeLastUpdated < 20 && gameTime >= 20)

0 commit comments

Comments
 (0)