Skip to content

Commit

Permalink
Add "clone wars!" and "clone wars!!" for more debug droids.
Browse files Browse the repository at this point in the history
clone wars = 10 droids
clone wars! = 40 droids
clone wars!! = 135 droids
  • Loading branch information
Cyp committed Jul 29, 2016
1 parent 0b9b7f7 commit 640f6c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/cheat.cpp
Expand Up @@ -37,7 +37,7 @@
struct CHEAT_ENTRY
{
const char *pName;
void (*function)(void); // pointer to void* function
void (*function)(); // pointer to void* function
};

bool Cheated = false;
Expand All @@ -46,7 +46,9 @@ static CHEAT_ENTRY cheatCodes[] =
{"templates", listTemplates}, // print templates
{"jsload", jsAutogame}, // load an AI script for selectedPlayer
{"jsdebug", jsShowDebug}, // show scripting states
{"clone wars", kf_CloneSelected}, // clone selected units
{"clone wars", []{ kf_CloneSelected(10); }}, // clone selected units
{"clone wars!", []{ kf_CloneSelected(40); }}, // clone selected units
{"clone wars!!", []{ kf_CloneSelected(135); }}, // clone selected units
{"noassert", kf_NoAssert}, // turn off asserts
{"count me", kf_ShowNumObjects}, // give a count of objects in the world
{"give all", kf_AllAvailable}, // give all
Expand Down
20 changes: 9 additions & 11 deletions src/keybind.cpp
Expand Up @@ -313,12 +313,11 @@ void kf_ToggleSensorDisplay(void)
/* Halves all the heights of the map tiles */
void kf_HalveHeights(void)
{
UDWORD i, j;
MAPTILE *psTile;

for (i = 0; i < mapWidth; i++)
for (int i = 0; i < mapWidth; ++i)
{
for (j = 0; j < mapHeight; j++)
for (int j = 0; j < mapHeight; ++j)
{
psTile = mapTile(i, j);
psTile->height /= 2;
Expand Down Expand Up @@ -378,10 +377,9 @@ void kf_DebugDroidInfo(void)
}
}

void kf_CloneSelected(void)
void kf_CloneSelected(int limit)
{
DROID_TEMPLATE *sTemplate = NULL;
const int limit = 10; // make 10 clones
const char *msg;
#ifndef DEBUG
// Bail out if we're running a _true_ multiplayer game (to prevent MP cheating)
Expand All @@ -407,14 +405,15 @@ void kf_CloneSelected(void)

if (!sTemplate)
{
debug(LOG_ERROR, "Cloning vat has been destoryed. We can't find the template for this droid: %s, id:%u, type:%d!", psDroid->aName, psDroid->id, psDroid->droidType);
debug(LOG_ERROR, "Cloning vat has been destroyed. We can't find the template for this droid: %s, id:%u, type:%d!", psDroid->aName, psDroid->id, psDroid->droidType);
return;
}

// create a new droid army
for (int i = 0; i < limit; i++)
{
DROID *psNewDroid = buildDroid(sTemplate, psDroid->pos.x + (i * 12), psDroid->pos.y + (i * 14), psDroid->player, false, NULL);
Vector2i pos = removeZ(psDroid->pos) + iSinCosR(40503 * i, iSqrt(50 * 50 * i)); // 40503 = 65536/φ
DROID *psNewDroid = buildDroid(sTemplate, pos.x, pos.y, psDroid->player, false, nullptr);
if (psNewDroid)
{
addDroid(psNewDroid, apsDroidLists);
Expand All @@ -424,12 +423,12 @@ void kf_CloneSelected(void)
psScrCBNewDroid = NULL;
triggerEventDroidBuilt(psNewDroid, NULL);
}
else
else if (!bMultiMessages)
{
debug(LOG_ERROR, "Cloning has failed for template:%s id:%d", getID(sTemplate), sTemplate->multiPlayerID);
}
}
sasprintf((char **)&msg, _("Player %u is cheating a new droid army of: %s."), selectedPlayer, psDroid->aName);
sasprintf((char **)&msg, _("Player %u is cheating a new droid army of: %d × %s."), selectedPlayer, limit, psDroid->aName);
sendTextMessage(msg, true);
Cheated = true;
audio_PlayTrack(ID_SOUND_NEXUS_LAUGH1);
Expand Down Expand Up @@ -1330,7 +1329,6 @@ void kf_ToggleGodMode(void)
if (godMode)
{
FEATURE *psFeat = apsFeatureLists[0];
int player;

godMode = false;
setRevealStatus(pastReveal);
Expand All @@ -1342,7 +1340,7 @@ void kf_ToggleGodMode(void)
}

// and the structures
for (player = 0; player < MAX_PLAYERS; ++player)
for (unsigned player = 0; player < MAX_PLAYERS; ++player)
{
if (player != selectedPlayer)
{
Expand Down
2 changes: 1 addition & 1 deletion src/keybind.h
Expand Up @@ -235,7 +235,7 @@ extern void kf_SpeedUp(void);
extern void kf_SlowDown(void);
extern void kf_NormalSpeed(void);

extern void kf_CloneSelected(void);
void kf_CloneSelected(int);
extern void kf_Reload(void);

#define SPIN_SCALING (360*DEG_1)
Expand Down

0 comments on commit 640f6c2

Please sign in to comment.