68
68
#include " GameLogic/ExperienceTracker.h"
69
69
#include " GameLogic/GameLogic.h"
70
70
#include " GameLogic/Module/BodyModule.h"
71
+ #include " GameLogic/Module/ProductionUpdate.h"
71
72
#include " GameLogic/Object.h"
72
73
#include " GameLogic/PartitionManager.h"
73
74
#include " GameLogic/ScriptEngine.h"
@@ -123,7 +124,65 @@ void printObjects(Object *obj, void *userData)
123
124
TheScriptEngine->AppendDebugMessage (line, FALSE );
124
125
}
125
126
126
- #endif
127
+ #endif // defined(RTS_DEBUG)
128
+
129
+
130
+ #if defined(RTS_DEBUG) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
131
+
132
+ void giveAllSciences (Player* player)
133
+ {
134
+ // cheese festival: do NOT imitate this code. it is for debug purposes only.
135
+ std::vector<AsciiString> v = TheScienceStore->friend_getScienceNames ();
136
+ for (size_t i = 0 ; i < v.size (); ++i)
137
+ {
138
+ ScienceType st = TheScienceStore->getScienceFromInternalName (v[i]);
139
+ if (st != SCIENCE_INVALID && TheScienceStore->isScienceGrantable (st))
140
+ {
141
+ player->grantScience (st);
142
+ }
143
+ }
144
+ }
145
+
146
+ void objectUnderConstruction (Object* obj, void *underConstruction)
147
+ {
148
+ if (obj->testStatus (OBJECT_STATUS_UNDER_CONSTRUCTION))
149
+ {
150
+ *(Bool*)underConstruction = true ;
151
+ return ;
152
+ }
153
+
154
+ ProductionUpdateInterface *pui = ProductionUpdate::getProductionUpdateInterfaceFromObject (obj);
155
+ if (pui != NULL && pui->getProductionCount () > 0 )
156
+ {
157
+ *(Bool*)underConstruction = true ;
158
+ return ;
159
+ }
160
+ }
161
+
162
+ Bool hasThingsInProduction (Player* player)
163
+ {
164
+ Bool hasThingInProduction = false ;
165
+ player->iterateObjects ( objectUnderConstruction, &hasThingInProduction );
166
+ return hasThingInProduction;
167
+ }
168
+
169
+ Bool hasThingsInProduction (PlayerType playerType)
170
+ {
171
+ for (Int n = 0 ; n < ThePlayerList->getPlayerCount (); ++n)
172
+ {
173
+ Player* player = ThePlayerList->getNthPlayer (n);
174
+ if (player->getPlayerType () == playerType)
175
+ {
176
+ if (hasThingsInProduction (player))
177
+ return true ;
178
+ }
179
+ }
180
+ return false ;
181
+ }
182
+
183
+ #endif // defined(RTS_DEBUG) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
184
+
185
+
127
186
static Bool isSystemMessage ( const GameMessage *msg );
128
187
129
188
enum { DROPPED_MAX_PARTICLE_COUNT = 1000 };
@@ -4119,10 +4178,17 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
4119
4178
case GameMessage::MSG_META_DEMO_REMOVE_PREREQ:
4120
4179
{
4121
4180
// Doesn't make a valid network message
4122
- Player *localPlayer = ThePlayerList->getLocalPlayer ();
4123
- localPlayer->toggleIgnorePrereqs ();
4181
+ // TheSuperHackers @info In multiplayer, all clients need to enable this cheat at the same time, otherwise game will mismatch
4182
+ Bool enable = !ThePlayerList->getLocalPlayer ()->ignoresPrereqs ();
4183
+
4184
+ for (Int n = 0 ; n < ThePlayerList->getPlayerCount (); ++n)
4185
+ {
4186
+ Player* player = ThePlayerList->getNthPlayer (n);
4187
+ if (player->getPlayerType () == PLAYER_HUMAN)
4188
+ player->enableIgnorePrereqs (enable);
4189
+ }
4124
4190
4125
- if (localPlayer-> ignoresPrereqs () )
4191
+ if (enable )
4126
4192
TheInGameUI->messageNoFormat ( TheGameText->FETCH_OR_SUBSTITUTE (" GUI:DebugIgnorePrereqOn" , L" Ignore Prerequisites is ON" ) );
4127
4193
else
4128
4194
TheInGameUI->messageNoFormat ( TheGameText->FETCH_OR_SUBSTITUTE (" GUI:DebugIgnorePrereqOff" , L" Ignore Prerequisites is OFF" ) );
@@ -4136,15 +4202,25 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
4136
4202
case GameMessage::MSG_META_DEMO_INSTANT_BUILD:
4137
4203
{
4138
4204
// Doesn't make a valid network message
4139
- Player *localPlayer = ThePlayerList->getLocalPlayer ();
4140
- localPlayer->toggleInstantBuild ();
4205
+ // TheSuperHackers @info In multiplayer, all clients need to enable this cheat at the same time, otherwise game will mismatch
4206
+ if (!TheGameLogic->isInMultiplayerGame () || !hasThingsInProduction (PLAYER_HUMAN))
4207
+ {
4208
+ Bool enable = !ThePlayerList->getLocalPlayer ()->buildsInstantly ();
4141
4209
4142
- if (localPlayer->buildsInstantly ())
4143
- TheInGameUI->messageNoFormat ( TheGameText->FETCH_OR_SUBSTITUTE (" GUI:DebugInstantBuildOn" , L" Instant Build is ON" ) );
4144
- else
4145
- TheInGameUI->messageNoFormat ( TheGameText->FETCH_OR_SUBSTITUTE (" GUI:DebugInstantBuildOff" , L" Instant Build is OFF" ) );
4210
+ for (Int n = 0 ; n < ThePlayerList->getPlayerCount (); ++n)
4211
+ {
4212
+ Player* player = ThePlayerList->getNthPlayer (n);
4213
+ if (player->getPlayerType () == PLAYER_HUMAN)
4214
+ player->enableInstantBuild (enable);
4215
+ }
4146
4216
4147
- disp = DESTROY_MESSAGE;
4217
+ if (enable)
4218
+ TheInGameUI->messageNoFormat ( TheGameText->FETCH_OR_SUBSTITUTE (" GUI:DebugInstantBuildOn" , L" Instant Build is ON" ) );
4219
+ else
4220
+ TheInGameUI->messageNoFormat ( TheGameText->FETCH_OR_SUBSTITUTE (" GUI:DebugInstantBuildOff" , L" Instant Build is OFF" ) );
4221
+
4222
+ disp = DESTROY_MESSAGE;
4223
+ }
4148
4224
break ;
4149
4225
}
4150
4226
@@ -4153,10 +4229,17 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
4153
4229
case GameMessage::MSG_META_DEMO_FREE_BUILD:
4154
4230
{
4155
4231
// Doesn't make a valid network message
4156
- Player *localPlayer = ThePlayerList->getLocalPlayer ();
4157
- localPlayer->toggleFreeBuild ();
4232
+ // TheSuperHackers @info In multiplayer, all clients need to enable this cheat at the same time, otherwise game will mismatch
4233
+ Bool enable = !ThePlayerList->getLocalPlayer ()->buildsForFree ();
4234
+
4235
+ for (Int n = 0 ; n < ThePlayerList->getPlayerCount (); ++n)
4236
+ {
4237
+ Player* player = ThePlayerList->getNthPlayer (n);
4238
+ if (player->getPlayerType () == PLAYER_HUMAN)
4239
+ player->enableFreeBuild (enable);
4240
+ }
4158
4241
4159
- if (localPlayer-> buildsForFree () )
4242
+ if (enable )
4160
4243
TheInGameUI->messageNoFormat ( TheGameText->FETCH_OR_SUBSTITUTE (" GUI:DebugFreeBuildOn" , L" Free Build is ON" ) );
4161
4244
else
4162
4245
TheInGameUI->messageNoFormat ( TheGameText->FETCH_OR_SUBSTITUTE (" GUI:DebugFreeBuildOff" , L" Free Build is OFF" ) );
@@ -4352,20 +4435,14 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
4352
4435
// -----------------------------------------------------------------------------------------
4353
4436
case GameMessage::MSG_META_DEMO_GIVE_ALL_SCIENCES:
4354
4437
{
4355
- Player *player = ThePlayerList-> getLocalPlayer ();
4356
- if (player )
4438
+ // TheSuperHackers @info In multiplayer, all clients need to enable this cheat at the same time, otherwise game will mismatch
4439
+ for (Int n = 0 ; n < ThePlayerList-> getPlayerCount (); ++n )
4357
4440
{
4358
- // cheese festival: do NOT imitate this code. it is for debug purposes only.
4359
- std::vector<AsciiString> v = TheScienceStore->friend_getScienceNames ();
4360
- for (size_t i = 0 ; i < v.size (); ++i)
4361
- {
4362
- ScienceType st = TheScienceStore->getScienceFromInternalName (v[i]);
4363
- if (st != SCIENCE_INVALID && TheScienceStore->isScienceGrantable (st))
4364
- {
4365
- player->grantScience (st);
4366
- }
4367
- }
4441
+ Player* player = ThePlayerList->getNthPlayer (n);
4442
+ if (player->getPlayerType () == PLAYER_HUMAN)
4443
+ giveAllSciences (player);
4368
4444
}
4445
+
4369
4446
TheInGameUI->messageNoFormat ( TheGameText->FETCH_OR_SUBSTITUTE (" GUI:DebugGiveAllSciences" , L" Granting all sciences!" ) );
4370
4447
disp = DESTROY_MESSAGE;
4371
4448
break ;
0 commit comments