Break cheat code stuff out of game.c and into cheats.c/h. Remove unnecessary header includes from several modules (all relevant headers are already pulled in by duke3d.h).

git-svn-id: https://svn.eduke32.com/eduke32@5611 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-02-07 02:38:03 +00:00
parent 463f5b5faa
commit 51bc13a9d7
18 changed files with 805 additions and 823 deletions

View file

@ -230,7 +230,7 @@ MAPSTER32_TARGET:=$(MAPSTER32)$(EXESUFFIX)
COMMON_OBJS=rev COMMON_OBJS=rev
COMMON_EDITOR_OBJS=m32common m32def m32exec m32vars rev COMMON_EDITOR_OBJS=m32common m32def m32exec m32vars rev
DUKE3D_OBJS=game global actors gamedef gameexec gamevars player premap sector anim animsounds common config demo input menus namesdyn net savegame rts osdfuncs osdcmds grpscan sounds soundsdyn DUKE3D_OBJS=game global actors gamedef gameexec gamevars player premap sector anim animsounds common config demo input menus namesdyn net savegame rts osdfuncs osdcmds grpscan sounds soundsdyn cheats
DUKE3D_EDITOR_OBJS=astub common grpscan sounds_mapster32 DUKE3D_EDITOR_OBJS=astub common grpscan sounds_mapster32
ifneq ($(USE_LIBVPX),0) ifneq ($(USE_LIBVPX),0)

View file

@ -40,6 +40,7 @@ $(DUKE3D_OBJ)/game.$o: $(DUKE3D_SRC)/game.c $(game_defs_dep) $(MACT_ROOT)/scripl
$(DUKE3D_OBJ)/actors.$o: $(DUKE3D_SRC)/actors.c $(duke3d_h) $(DUKE3D_OBJ)/actors.$o: $(DUKE3D_SRC)/actors.c $(duke3d_h)
$(DUKE3D_OBJ)/anim.$o: $(DUKE3D_SRC)/anim.c $(duke3d_h) $(DUKE3D_SRC)/input.h $(MACT_ROOT)/animlib.h $(DUKE3D_SRC)/animvpx.h $(DUKE3D_SRC)/animsounds.h $(DUKE3D_OBJ)/anim.$o: $(DUKE3D_SRC)/anim.c $(duke3d_h) $(DUKE3D_SRC)/input.h $(MACT_ROOT)/animlib.h $(DUKE3D_SRC)/animvpx.h $(DUKE3D_SRC)/animsounds.h
$(DUKE3D_OBJ)/animsounds.$o: $(DUKE3D_SRC)/animsounds.c $(DUKE3D_SRC)/animsounds.h $(DUKE3D_OBJ)/animsounds.$o: $(DUKE3D_SRC)/animsounds.c $(DUKE3D_SRC)/animsounds.h
$(DUKE3D_OBJ)/cheats.$o: $(DUKE3D_SRC)/cheats.c
$(DUKE3D_OBJ)/demo.$o: $(DUKE3D_SRC)/demo.c $(duke3d_h) $(DUKE3D_SRC)/input.h $(DUKE3D_OBJ)/demo.$o: $(DUKE3D_SRC)/demo.c $(duke3d_h) $(DUKE3D_SRC)/input.h
$(DUKE3D_OBJ)/gamedef.$o: $(DUKE3D_SRC)/gamedef.c $(duke3d_h) $(gamedef_h) $(DUKE3D_SRC)/savegame.h $(DUKE3D_OBJ)/gamedef.$o: $(DUKE3D_SRC)/gamedef.c $(duke3d_h) $(gamedef_h) $(DUKE3D_SRC)/savegame.h
$(DUKE3D_OBJ)/gameexec.$o: $(DUKE3D_SRC)/gameexec.c $(DUKE3D_SRC)/gamestructures.c $(duke3d_h) $(gamedef_h) $(DUKE3D_OBJ)/gameexec.$o: $(DUKE3D_SRC)/gameexec.c $(DUKE3D_SRC)/gamestructures.c $(duke3d_h) $(gamedef_h)

View file

@ -195,6 +195,7 @@ DUKE3D_OBJS=$(DUKE3D_OBJ)\game.$o \
$(DUKE3D_OBJ)\anim.$o \ $(DUKE3D_OBJ)\anim.$o \
$(DUKE3D_OBJ)\animsounds.$o \ $(DUKE3D_OBJ)\animsounds.$o \
$(DUKE3D_OBJ)\animvpx.$o \ $(DUKE3D_OBJ)\animvpx.$o \
$(DUKE3D_OBJ)\cheats.$o \
$(DUKE3D_OBJ)\common.$o \ $(DUKE3D_OBJ)\common.$o \
$(DUKE3D_OBJ)\demo.$o \ $(DUKE3D_OBJ)\demo.$o \
$(DUKE3D_OBJ)\gamedef.$o \ $(DUKE3D_OBJ)\gamedef.$o \

View file

@ -173,6 +173,7 @@
<ClInclude Include="source\anim.h" /> <ClInclude Include="source\anim.h" />
<ClInclude Include="source\animsounds.h" /> <ClInclude Include="source\animsounds.h" />
<ClInclude Include="source\animvpx.h" /> <ClInclude Include="source\animvpx.h" />
<ClInclude Include="source\cheats.h" />
<ClInclude Include="source\common_game.h" /> <ClInclude Include="source\common_game.h" />
<ClInclude Include="source\demo.h" /> <ClInclude Include="source\demo.h" />
<ClInclude Include="source\events_defs.h" /> <ClInclude Include="source\events_defs.h" />
@ -304,6 +305,7 @@
<ClCompile Include="source\animsounds.c" /> <ClCompile Include="source\animsounds.c" />
<ClCompile Include="source\animvpx.c" /> <ClCompile Include="source\animvpx.c" />
<ClCompile Include="source\astub.c" /> <ClCompile Include="source\astub.c" />
<ClCompile Include="source\cheats.c" />
<ClCompile Include="source\config.c" /> <ClCompile Include="source\config.c" />
<ClCompile Include="source\common.c" /> <ClCompile Include="source\common.c" />
<ClCompile Include="source\demo.c" /> <ClCompile Include="source\demo.c" />
@ -347,7 +349,6 @@
<ClCompile Include="source\startgtk.game.c" /> <ClCompile Include="source\startgtk.game.c" />
<ClCompile Include="source\startwin.game.c" /> <ClCompile Include="source\startwin.game.c" />
<ClCompile Include="source\winbits.c" /> <ClCompile Include="source\winbits.c" />
<ClCompile Include="source\wrapper.c" />
<ClCompile Include="source\jaudiolib\src\driver_directsound.c" /> <ClCompile Include="source\jaudiolib\src\driver_directsound.c" />
<ClCompile Include="source\jaudiolib\src\driver_nosound.c" /> <ClCompile Include="source\jaudiolib\src\driver_nosound.c" />
<ClCompile Include="source\jaudiolib\src\driver_sdl.c" /> <ClCompile Include="source\jaudiolib\src\driver_sdl.c" />

View file

@ -507,7 +507,12 @@
<ClInclude Include="source\mpu401.h"> <ClInclude Include="source\mpu401.h">
<Filter>eduke32\headers</Filter> <Filter>eduke32\headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="source\_midi.h" /> <ClInclude Include="source\_midi.h">
<Filter>eduke32\headers</Filter>
</ClInclude>
<ClInclude Include="source\cheats.h">
<Filter>eduke32\headers</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="build\src\a-c.c"> <ClCompile Include="build\src\a-c.c">
@ -681,9 +686,6 @@
<ClCompile Include="source\winbits.c"> <ClCompile Include="source\winbits.c">
<Filter>eduke32\source</Filter> <Filter>eduke32\source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\wrapper.c">
<Filter>eduke32\source</Filter>
</ClCompile>
<ClCompile Include="source\jaudiolib\src\driver_directsound.c"> <ClCompile Include="source\jaudiolib\src\driver_directsound.c">
<Filter>jaudiolib\source</Filter> <Filter>jaudiolib\source</Filter>
</ClCompile> </ClCompile>
@ -894,6 +896,9 @@
<ClCompile Include="build\src\md4.c"> <ClCompile Include="build\src\md4.c">
<Filter>build\source</Filter> <Filter>build\source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\cheats.c">
<Filter>eduke32\source</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Makefile.msvc"> <None Include="Makefile.msvc">

View file

@ -1,6 +1,6 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/* /*
Copyright (C) 2010 EDuke32 developers and contributors Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32. This file is part of EDuke32.
@ -23,9 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define actors_c_ #define actors_c_
#include "duke3d.h" #include "duke3d.h"
#include "actors.h"
#include "gamedef.h"
#include "gameexec.h"
#if KRANDDEBUG #if KRANDDEBUG
# define ACTOR_STATIC # define ACTOR_STATIC

View file

@ -0,0 +1,681 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "duke3d.h"
#include "osdcmds.h"
#include "cheats.h"
// KEEPINSYNC game.h: enum cheatindex_t
char CheatStrings [][MAXCHEATLEN] =
{
"cornholio", // 0
"stuff", // 1
"scotty###", // 2
"coords", // 3
"view", // 4
"time", // 5
"unlock", // 6
"cashman", // 7
"items", // 8
"rate", // 9
"skill#", // 10
"beta", // 11
"hyper", // 12
"monsters", // 13
"<RESERVED>", // 14
"<RESERVED>", // 15
"todd", // 16
"showmap", // 17
"kroz", // 18
"allen", // 19
"clip", // 20
"weapons", // 21
"inventory", // 22
"keys", // 23
"debug", // 24
"<RESERVED>", // 25
"cgs", // 26
};
const uint32_t CheatFunctionFlags [] =
{
1 << CHEATFUNC_GOD,
1 << CHEATFUNC_GIVEEVERYTHING,
1 << CHEATFUNC_WARP,
1 << CHEATFUNC_COORDS,
1 << CHEATFUNC_VIEW,
0,
1 << CHEATFUNC_UNLOCK,
1 << CHEATFUNC_CASHMAN,
1 << CHEATFUNC_GIVEALLITEMS,
1 << CHEATFUNC_FRAMERATE,
1 << CHEATFUNC_SKILL,
1 << CHEATFUNC_QUOTEBETA,
1 << CHEATFUNC_HYPER,
1 << CHEATFUNC_MONSTERS,
0,
0,
1 << CHEATFUNC_QUOTETODD,
1 << CHEATFUNC_SHOWMAP,
1 << CHEATFUNC_GOD,
1 << CHEATFUNC_QUOTEALLEN,
1 << CHEATFUNC_CLIP,
1 << CHEATFUNC_GIVEWEAPONS,
1 << CHEATFUNC_GIVEINVENTORY,
1 << CHEATFUNC_GIVEKEYS,
1 << CHEATFUNC_DEBUG,
0,
(1 << CHEATFUNC_GOD) | (1 << CHEATFUNC_GIVEEVERYTHING),
};
// KEEPINSYNC game.h: enum CheatCodeFunctions
// KEEPINSYNC menus.c: MenuEntry_t ME_CheatCodes[]
const uint8_t CheatFunctionIDs [] =
{
CHEAT_CASHMAN,
CHEAT_CORNHOLIO,
CHEAT_STUFF,
CHEAT_WEAPONS,
CHEAT_ITEMS,
CHEAT_INVENTORY,
CHEAT_KEYS,
CHEAT_HYPER,
CHEAT_VIEW,
CHEAT_SHOWMAP,
CHEAT_UNLOCK,
CHEAT_CLIP,
CHEAT_SCOTTY,
CHEAT_SKILL,
CHEAT_MONSTERS,
CHEAT_RATE,
CHEAT_BETA,
CHEAT_TODD,
CHEAT_ALLEN,
CHEAT_COORDS,
CHEAT_DEBUG,
};
char const * const g_NAMMattCheatQuote = "Matt Saettler. matts@saettler.com";
void G_SetupCheats(void)
{
// KEEPINSYNC: NAM_WW2GI_CHEATS
if (WW2GI)
{
#if 0
// WWII GI's original cheat prefix temporarily disabled because W conflicts with WSAD movement
CheatKeys[0] = CheatKeys[1] = sc_W;
#else
CheatKeys[0] = sc_G;
CheatKeys[1] = sc_I;
#endif
Bstrcpy(CheatStrings[0], "2god");
Bstrcpy(CheatStrings[1], "2blood");
Bstrcpy(CheatStrings[2], "2level###");
Bstrcpy(CheatStrings[3], "2coords");
Bstrcpy(CheatStrings[4], "2view");
Bstrcpy(CheatStrings[5], "<RESERVED>");
Bstrcpy(CheatStrings[7], "<RESERVED>");
Bstrcpy(CheatStrings[8], "<RESERVED>");
Bstrcpy(CheatStrings[9], "2rate");
Bstrcpy(CheatStrings[10], "2skill");
Bstrcpy(CheatStrings[11], "<RESERVED>");
Bstrcpy(CheatStrings[12], "<RESERVED>");
Bstrcpy(CheatStrings[13], "<RESERVED>");
Bstrcpy(CheatStrings[16], "2matt");
Bstrcpy(CheatStrings[17], "2showmap");
Bstrcpy(CheatStrings[18], "2ryan");
Bstrcpy(CheatStrings[19], "<RESERVED>");
Bstrcpy(CheatStrings[20], "2clip");
Bstrcpy(CheatStrings[21], "2weapons");
Bstrcpy(CheatStrings[22], "2inventory");
Bstrcpy(CheatStrings[23], "<RESERVED>");
Bstrcpy(CheatStrings[24], "2debug");
Bstrcpy(CheatStrings[26], "2cgs");
Bstrcpy(GametypeNames[0], "GI Match (Spawn)");
Bstrcpy(GametypeNames[2], "GI Match (No Spawn)");
}
else if (NAM)
{
CheatKeys[0] = sc_N;
CheatKeys[1] = sc_V;
Bstrcpy(CheatStrings[0], "acaleb");
Bstrcpy(CheatStrings[1], "ablood");
Bstrcpy(CheatStrings[2], "alevel###");
Bstrcpy(CheatStrings[3], "acoords");
Bstrcpy(CheatStrings[4], "aview");
Bstrcpy(CheatStrings[5], "<RESERVED>");
Bstrcpy(CheatStrings[7], "<RESERVED>");
Bstrcpy(CheatStrings[8], "<RESERVED>");
Bstrcpy(CheatStrings[9], "arate");
Bstrcpy(CheatStrings[10], "askill");
Bstrcpy(CheatStrings[11], "<RESERVED>");
Bstrcpy(CheatStrings[12], "ahyper");
Bstrcpy(CheatStrings[13], "<RESERVED>");
Bstrcpy(CheatStrings[16], "amatt");
Bstrcpy(CheatStrings[17], "ashowmap");
Bstrcpy(CheatStrings[18], "agod");
Bstrcpy(CheatStrings[19], "<RESERVED>");
Bstrcpy(CheatStrings[20], "aclip");
Bstrcpy(CheatStrings[21], "aweapons");
Bstrcpy(CheatStrings[22], "ainventory");
Bstrcpy(CheatStrings[23], "<RESERVED>");
Bstrcpy(CheatStrings[24], "adebug");
Bstrcpy(CheatStrings[26], "acgs");
Bstrcpy(GametypeNames[0], "GruntMatch (Spawn)");
Bstrcpy(GametypeNames[2], "GruntMatch (No Spawn)");
}
}
static void doinvcheat(int32_t invidx, int32_t defaultnum, int32_t event)
{
defaultnum = VM_OnEventWithReturn(event, g_player[myconnectindex].ps->i, myconnectindex, defaultnum);
if (defaultnum >= 0)
g_player[myconnectindex].ps->inv_amount[invidx] = defaultnum;
}
static void G_CheatGetInv(void)
{
doinvcheat(GET_STEROIDS, 400, EVENT_CHEATGETSTEROIDS);
doinvcheat(GET_HEATS, 1200, EVENT_CHEATGETHEAT);
doinvcheat(GET_BOOTS, 200, EVENT_CHEATGETBOOT);
doinvcheat(GET_SHIELD, 100, EVENT_CHEATGETSHIELD);
doinvcheat(GET_SCUBA, 6400, EVENT_CHEATGETSCUBA);
doinvcheat(GET_HOLODUKE, 2400, EVENT_CHEATGETHOLODUKE);
doinvcheat(GET_JETPACK, 1600, EVENT_CHEATGETJETPACK);
doinvcheat(GET_FIRSTAID, g_player[myconnectindex].ps->max_player_health, EVENT_CHEATGETFIRSTAID);
}
static void end_cheat(void)
{
g_player[myconnectindex].ps->cheat_phase = 0;
KB_FlushKeyboardQueue();
}
static int32_t cheatbuflen;
static int8_t cheatbuf[MAXCHEATLEN];
void G_DoCheats(void)
{
int32_t ch, i, j, k=0, weapon;
static int32_t vol1inited=0;
char consolecheat = 0; // JBF 20030914
if (osdcmd_cheatsinfo_stat.cheatnum != -1)
{
if (ud.player_skill == 4)
{
P_DoQuote(QUOTE_CHEATS_DISABLED, g_player[myconnectindex].ps);
osdcmd_cheatsinfo_stat.cheatnum = -1;
return;
}
// JBF 20030914
k = osdcmd_cheatsinfo_stat.cheatnum;
osdcmd_cheatsinfo_stat.cheatnum = -1;
consolecheat = 1;
}
if (VOLUMEONE && !vol1inited)
{
// change "scotty###" to "scotty##"
uint32_t const warpend = Bstrlen(CheatStrings[2]);
if (strcmp(&CheatStrings[2][warpend-3], "###") == 0)
CheatStrings[2][warpend-1] = '\0';
Bstrcpy(CheatStrings[6], "<RESERVED>");
vol1inited = 1;
}
if (consolecheat && numplayers < 2 && ud.recstat == 0)
goto FOUNDCHEAT;
if (g_player[myconnectindex].ps->gm & (MODE_TYPE|MODE_MENU))
return;
if (g_player[myconnectindex].ps->cheat_phase == 1)
{
while (KB_KeyWaiting())
{
ch = Btolower(KB_GetCh());
if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')))
{
g_player[myconnectindex].ps->cheat_phase = 0;
// P_DoQuote(QUOTE_46,g_player[myconnectindex].ps);
return;
}
cheatbuf[cheatbuflen++] = (int8_t) ch;
// This assertion is not obvious, but it should hold because of the
// cheat string matching logic below.
Bassert(cheatbuflen < (signed)sizeof(cheatbuf));
cheatbuf[cheatbuflen] = 0;
// KB_ClearKeysDown();
for (k=0; k < NUMCHEATCODES; k++)
{
for (j = 0; j<cheatbuflen; j++)
{
if (cheatbuf[j] == CheatStrings[k][j] || (CheatStrings[k][j] == '#' && ch >= '0' && ch <= '9'))
{
if (CheatStrings[k][j+1] == 0) goto FOUNDCHEAT;
if (j == cheatbuflen-1) return;
}
else break;
}
}
g_player[myconnectindex].ps->cheat_phase = 0;
return;
FOUNDCHEAT:
i = VM_OnEventWithReturn(EVENT_ACTIVATECHEAT, g_player[myconnectindex].ps->i, myconnectindex, k);
if (k != CHEAT_COMEGETSOME) // Users are not allowed to interfere with TX's debugging cheat.
k = i;
{
switch (k)
{
case CHEAT_WEAPONS:
j = 0;
if (VOLUMEONE)
j = 6;
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++)
{
P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
g_player[myconnectindex].ps->gotweapon |= (1<<weapon);
}
P_DoQuote(QUOTE_CHEAT_ALL_WEAPONS, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_INVENTORY:
G_CheatGetInv();
P_DoQuote(QUOTE_CHEAT_ALL_INV, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_KEYS:
g_player[myconnectindex].ps->got_access = 7;
KB_FlushKeyboardQueue();
P_DoQuote(QUOTE_CHEAT_ALL_KEYS, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_DEBUG:
g_Debug = 1-g_Debug;
G_DumpDebugInfo();
Bsprintf(tempbuf, "Gamevars dumped to log");
G_AddUserQuote(tempbuf);
Bsprintf(tempbuf, "Map dumped to debug.map");
G_AddUserQuote(tempbuf);
end_cheat();
break;
case CHEAT_CLIP:
ud.noclip = !ud.noclip;
P_DoQuote(QUOTE_CHEAT_NOCLIP-!ud.noclip, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_RESERVED2:
g_player[myconnectindex].ps->player_par = 0;
g_player[myconnectindex].ps->gm = MODE_EOL;
end_cheat();
return;
case CHEAT_ALLEN:
P_DoQuote(QUOTE_CHEAT_ALLEN, g_player[myconnectindex].ps);
g_player[myconnectindex].ps->cheat_phase = 0;
KB_ClearKeyDown(sc_N);
return;
case CHEAT_CORNHOLIO:
case CHEAT_KROZ:
case CHEAT_COMEGETSOME:
{
const int32_t pi = g_player[myconnectindex].ps->i;
ud.god = 1-ud.god;
if (ud.god)
{
pus = 1;
pub = 1;
sprite[pi].cstat = 257;
actor[pi].t_data[0] = 0;
actor[pi].t_data[1] = 0;
actor[pi].t_data[2] = 0;
actor[pi].t_data[3] = 0;
actor[pi].t_data[4] = 0;
actor[pi].t_data[5] = 0;
sprite[pi].hitag = 0;
sprite[pi].lotag = 0;
sprite[pi].pal = g_player[myconnectindex].ps->palookup;
if (k != CHEAT_COMEGETSOME)
{
P_DoQuote(QUOTE_CHEAT_GODMODE_ON, g_player[myconnectindex].ps);
}
else
{
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "Come Get Some!");
S_PlaySound(DUKE_GETWEAPON2);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
G_CheatGetInv();
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++)
g_player[myconnectindex].ps->gotweapon |= (1<<weapon);
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++)
P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
g_player[myconnectindex].ps->got_access = 7;
}
}
else
{
sprite[pi].extra = g_player[myconnectindex].ps->max_player_health;
actor[pi].extra = -1;
g_player[myconnectindex].ps->last_extra = g_player[myconnectindex].ps->max_player_health;
P_DoQuote(QUOTE_CHEAT_GODMODE_OFF, g_player[myconnectindex].ps);
}
sprite[pi].extra = g_player[myconnectindex].ps->max_player_health;
actor[pi].extra = 0;
if (k != CHEAT_COMEGETSOME)
g_player[myconnectindex].ps->dead_flag = 0;
end_cheat();
return;
}
case CHEAT_STUFF:
j = 0;
if (VOLUMEONE)
j = 6;
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++)
g_player[myconnectindex].ps->gotweapon |= (1<<weapon);
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++)
P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
G_CheatGetInv();
g_player[myconnectindex].ps->got_access = 7;
P_DoQuote(QUOTE_CHEAT_EVERYTHING, g_player[myconnectindex].ps);
// P_DoQuote(QUOTE_21,g_player[myconnectindex].ps);
g_player[myconnectindex].ps->inven_icon = ICON_FIRSTAID;
end_cheat();
return;
case CHEAT_SCOTTY:
case CHEAT_SKILL:
if (k == CHEAT_SCOTTY)
{
i = Bstrlen(CheatStrings[k])-3+VOLUMEONE;
if (!consolecheat)
{
// JBF 20030914
int16_t volnume, levnume;
if (VOLUMEALL)
{
volnume = cheatbuf[i] - '0';
levnume = (cheatbuf[i+1] - '0')*10+(cheatbuf[i+2]-'0');
}
else
{
volnume = cheatbuf[i] - '0';
levnume = cheatbuf[i+1] - '0';
}
volnume--;
levnume--;
if ((VOLUMEONE && volnume > 0) || volnume > g_numVolumes-1 ||
levnume >= MAXLEVELS || MapInfo[volnume *MAXLEVELS+levnume].filename == NULL)
{
end_cheat();
return;
}
ud.m_volume_number = ud.volume_number = volnume;
ud.m_level_number = ud.level_number = levnume;
}
else
{
// JBF 20030914
ud.m_volume_number = ud.volume_number = osdcmd_cheatsinfo_stat.volume;
ud.m_level_number = ud.level_number = osdcmd_cheatsinfo_stat.level;
}
}
else
{
if (!consolecheat)
{
i = Bstrlen(CheatStrings[k])-1;
ud.m_player_skill = ud.player_skill = cheatbuf[i] - '1';
}
else
{
ud.m_player_skill = ud.player_skill = osdcmd_cheatsinfo_stat.volume;
}
}
/*if (numplayers > 1 && g_netServer)
Net_NewGame(ud.m_volume_number,ud.m_level_number);
else*/ g_player[myconnectindex].ps->gm |= MODE_RESTART;
end_cheat();
return;
case CHEAT_COORDS:
#ifdef USE_OPENGL
if (++ud.coords >= 3) ud.coords = 0;
#else
if (++ud.coords >= 2) ud.coords = 0;
#endif
end_cheat();
return;
case CHEAT_VIEW:
if (g_player[myconnectindex].ps->over_shoulder_on)
g_player[myconnectindex].ps->over_shoulder_on = 0;
else
{
g_player[myconnectindex].ps->over_shoulder_on = 1;
CAMERADIST = 0;
CAMERACLOCK = totalclock;
}
// P_DoQuote(QUOTE_CHEATS_DISABLED,g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_TIME:
// P_DoQuote(QUOTE_21,g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_UNLOCK:
if (VOLUMEONE) return;
for (i=numsectors-1; i>=0; i--) //Unlock
{
j = sector[i].lotag;
if (j == -1 || j == 32767) continue;
if ((j & 0x7fff) > 2)
{
if (j&(0xffff-16384))
sector[i].lotag &= (0xffff-16384);
G_OperateSectors(i, g_player[myconnectindex].ps->i);
}
}
G_OperateForceFields(g_player[myconnectindex].ps->i, -1);
P_DoQuote(QUOTE_CHEAT_UNLOCK, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_CASHMAN:
ud.cashman = 1-ud.cashman;
KB_ClearKeyDown(sc_N);
g_player[myconnectindex].ps->cheat_phase = 0;
return;
case CHEAT_ITEMS:
G_CheatGetInv();
g_player[myconnectindex].ps->got_access = 7;
P_DoQuote(QUOTE_CHEAT_EVERYTHING, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_SHOWMAP: // SHOW ALL OF THE MAP TOGGLE;
ud.showallmap = !ud.showallmap;
for (i=0; i<(MAXSECTORS>>3); i++)
show2dsector[i] = ud.showallmap*255;
P_DoQuote(ud.showallmap ? QUOTE_SHOW_MAP_ON : QUOTE_SHOW_MAP_OFF,
g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_TODD:
if (NAM)
{
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], g_NAMMattCheatQuote);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
}
else
{
P_DoQuote(QUOTE_CHEAT_TODD, g_player[myconnectindex].ps);
}
end_cheat();
return;
case CHEAT_RATE:
if (ud.tickrate++ > 2)
ud.tickrate = 0;
end_cheat();
return;
case CHEAT_BETA:
P_DoQuote(QUOTE_CHEAT_BETA, g_player[myconnectindex].ps);
KB_ClearKeyDown(sc_H);
end_cheat();
return;
case CHEAT_HYPER:
g_player[myconnectindex].ps->inv_amount[GET_STEROIDS] = 399;
g_player[myconnectindex].ps->inv_amount[GET_HEATS] = 1200;
P_DoQuote(QUOTE_CHEAT_STEROIDS, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_MONSTERS:
{
const char *s [] ={ "On", "Off", "On (2)" };
if (++g_noEnemies == 3)
g_noEnemies = 0;
Bsprintf(ScriptQuotes[QUOTE_RESERVED4], "Monsters: %s", s[g_noEnemies]);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
end_cheat();
return;
}
case CHEAT_RESERVED:
case CHEAT_RESERVED3:
ud.eog = 1;
g_player[myconnectindex].ps->player_par = 0;
g_player[myconnectindex].ps->gm |= MODE_EOL;
KB_FlushKeyboardQueue();
return;
default:
end_cheat();
return;
}
}
}
}
else
{
if (KB_KeyPressed((uint8_t) CheatKeys[0]))
{
if (g_player[myconnectindex].ps->cheat_phase >= 0 && numplayers < 2 && ud.recstat == 0)
{
if (CheatKeys[0] == CheatKeys[1])
KB_ClearKeyDown((uint8_t) CheatKeys[0]);
g_player[myconnectindex].ps->cheat_phase = -1;
}
}
if (KB_KeyPressed((uint8_t) CheatKeys[1]))
{
if (g_player[myconnectindex].ps->cheat_phase == -1)
{
if (ud.player_skill == 4)
{
P_DoQuote(QUOTE_CHEATS_DISABLED, g_player[myconnectindex].ps);
g_player[myconnectindex].ps->cheat_phase = 0;
}
else
{
g_player[myconnectindex].ps->cheat_phase = 1;
// P_DoQuote(QUOTE_25,g_player[myconnectindex].ps);
cheatbuflen = 0;
}
KB_FlushKeyboardQueue();
}
else if (g_player[myconnectindex].ps->cheat_phase != 0)
{
g_player[myconnectindex].ps->cheat_phase = 0;
KB_ClearKeyDown((uint8_t) CheatKeys[0]);
KB_ClearKeyDown((uint8_t) CheatKeys[1]);
}
}
}
}

View file

@ -0,0 +1,91 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#pragma once
extern void G_DoCheats(void);
extern void G_SetupCheats(void);
extern char CheatStrings [][MAXCHEATLEN];
extern char const * const g_NAMMattCheatQuote;
// Cheats
// KEEPINSYNC game.c: char CheatStrings[][]
enum cheatindex_t
{
CHEAT_CORNHOLIO, // 0
CHEAT_STUFF,
CHEAT_SCOTTY,
CHEAT_COORDS,
CHEAT_VIEW,
CHEAT_TIME, // 5
CHEAT_UNLOCK,
CHEAT_CASHMAN,
CHEAT_ITEMS,
CHEAT_RATE,
CHEAT_SKILL, // 10
CHEAT_BETA,
CHEAT_HYPER,
CHEAT_MONSTERS,
CHEAT_RESERVED,
CHEAT_RESERVED2, // 15
CHEAT_TODD,
CHEAT_SHOWMAP,
CHEAT_KROZ,
CHEAT_ALLEN,
CHEAT_CLIP, // 20
CHEAT_WEAPONS,
CHEAT_INVENTORY,
CHEAT_KEYS,
CHEAT_DEBUG,
CHEAT_RESERVED3, // 25
CHEAT_COMEGETSOME,
NUMCHEATS,
};
// KEEPINSYNC game.c: uint8_t CheatFunctionIDs[]
// KEEPINSYNC menus.c: MenuEntry_t ME_CheatCodes[]
enum CheatCodeFunctions
{
CHEATFUNC_CASHMAN,
CHEATFUNC_GOD,
CHEATFUNC_GIVEEVERYTHING,
CHEATFUNC_GIVEWEAPONS,
CHEATFUNC_GIVEALLITEMS,
CHEATFUNC_GIVEINVENTORY,
CHEATFUNC_GIVEKEYS,
CHEATFUNC_HYPER,
CHEATFUNC_VIEW,
CHEATFUNC_SHOWMAP,
CHEATFUNC_UNLOCK,
CHEATFUNC_CLIP,
CHEATFUNC_WARP,
CHEATFUNC_SKILL,
CHEATFUNC_MONSTERS,
CHEATFUNC_FRAMERATE,
CHEATFUNC_QUOTEBETA,
CHEATFUNC_QUOTETODD,
CHEATFUNC_QUOTEALLEN,
CHEATFUNC_COORDS,
CHEATFUNC_DEBUG,
NUMCHEATFUNCS,
};

View file

@ -1,6 +1,6 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/* /*
Copyright (C) 2010 EDuke32 developers and contributors Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32. This file is part of EDuke32.

View file

@ -1,6 +1,6 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/* /*
Copyright (C) 2010 EDuke32 developers and contributors Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32. This file is part of EDuke32.
@ -23,44 +23,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define game_c_ #define game_c_
#include "duke3d.h" #include "duke3d.h"
#include "compat.h"
#include "baselayer.h"
#include "renderlayer.h" #include "renderlayer.h"
#include "scriplib.h"
#include "file_lib.h"
#include "gamedefs.h"
#include "keyboard.h"
#include "mouse.h" // JBF 20030809
#include "joystick.h"
#include "function.h"
#include "control.h"
#include "fx_man.h"
#include "sounds.h"
#include "config.h"
#include "osd.h"
#include "osdfuncs.h" #include "osdfuncs.h"
#include "osdcmds.h" #include "osdcmds.h"
#include "scriptfile.h"
#include "grpscan.h"
#include "gamedef.h"
#include "kplib.h"
#include "crc32.h" #include "crc32.h"
#include "hightile.h"
#include "control.h"
#include "lz4.h"
#include "net.h" #include "net.h"
#include "premap.h"
#include "gameexec.h"
#include "menus.h" #include "menus.h"
#include "savegame.h" #include "savegame.h"
#include "anim.h" #include "anim.h"
#include "demo.h" #include "demo.h"
#include "common.h"
#include "common_game.h"
#include "input.h" #include "input.h"
#include "compat.h"
#include "colmatch.h" #include "colmatch.h"
#include "cheats.h"
#ifdef __ANDROID__ #ifdef __ANDROID__
#include "android.h" #include "android.h"
@ -83,9 +58,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
# include "winlayer.h"
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <shellapi.h> # include <shellapi.h>
# define UPDATEINTERVAL 604800 // 1w # define UPDATEINTERVAL 604800 // 1w
# include "winbits.h" # include "winbits.h"
@ -123,7 +96,7 @@ char boardfilename[BMAX_PATH] = {0}, currentboardfilename[BMAX_PATH] = {0};
int32_t voting = -1; int32_t voting = -1;
int32_t vote_map = -1, vote_episode = -1; int32_t vote_map = -1, vote_episode = -1;
static int32_t g_Debug = 0; int32_t g_Debug = 0;
static int32_t g_noLogoAnim = 0; static int32_t g_noLogoAnim = 0;
static int32_t g_noLogo = 0; static int32_t g_noLogo = 0;
@ -4932,7 +4905,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
} }
} }
static void G_DumpDebugInfo(void) void G_DumpDebugInfo(void)
{ {
#if !defined LUNATIC #if !defined LUNATIC
int32_t i,j,x; int32_t i,j,x;
@ -8100,588 +8073,6 @@ skip:
#endif #endif
} }
// KEEPINSYNC game.h: enum cheatindex_t
char CheatStrings[][MAXCHEATLEN] =
{
"cornholio", // 0
"stuff", // 1
"scotty###", // 2
"coords", // 3
"view", // 4
"time", // 5
"unlock", // 6
"cashman", // 7
"items", // 8
"rate", // 9
"skill#", // 10
"beta", // 11
"hyper", // 12
"monsters", // 13
"<RESERVED>", // 14
"<RESERVED>", // 15
"todd", // 16
"showmap", // 17
"kroz", // 18
"allen", // 19
"clip", // 20
"weapons", // 21
"inventory", // 22
"keys", // 23
"debug", // 24
"<RESERVED>", // 25
"cgs", // 26
};
const uint32_t CheatFunctionFlags[] =
{
1 << CHEATFUNC_GOD,
1 << CHEATFUNC_GIVEEVERYTHING,
1 << CHEATFUNC_WARP,
1 << CHEATFUNC_COORDS,
1 << CHEATFUNC_VIEW,
0,
1 << CHEATFUNC_UNLOCK,
1 << CHEATFUNC_CASHMAN,
1 << CHEATFUNC_GIVEALLITEMS,
1 << CHEATFUNC_FRAMERATE,
1 << CHEATFUNC_SKILL,
1 << CHEATFUNC_QUOTEBETA,
1 << CHEATFUNC_HYPER,
1 << CHEATFUNC_MONSTERS,
0,
0,
1 << CHEATFUNC_QUOTETODD,
1 << CHEATFUNC_SHOWMAP,
1 << CHEATFUNC_GOD,
1 << CHEATFUNC_QUOTEALLEN,
1 << CHEATFUNC_CLIP,
1 << CHEATFUNC_GIVEWEAPONS,
1 << CHEATFUNC_GIVEINVENTORY,
1 << CHEATFUNC_GIVEKEYS,
1 << CHEATFUNC_DEBUG,
0,
(1 << CHEATFUNC_GOD) | (1 << CHEATFUNC_GIVEEVERYTHING),
};
// KEEPINSYNC game.h: enum CheatCodeFunctions
// KEEPINSYNC menus.c: MenuEntry_t ME_CheatCodes[]
const uint8_t CheatFunctionIDs[] =
{
CHEAT_CASHMAN,
CHEAT_CORNHOLIO,
CHEAT_STUFF,
CHEAT_WEAPONS,
CHEAT_ITEMS,
CHEAT_INVENTORY,
CHEAT_KEYS,
CHEAT_HYPER,
CHEAT_VIEW,
CHEAT_SHOWMAP,
CHEAT_UNLOCK,
CHEAT_CLIP,
CHEAT_SCOTTY,
CHEAT_SKILL,
CHEAT_MONSTERS,
CHEAT_RATE,
CHEAT_BETA,
CHEAT_TODD,
CHEAT_ALLEN,
CHEAT_COORDS,
CHEAT_DEBUG,
};
char const * const g_NAMMattCheatQuote = "Matt Saettler. matts@saettler.com";
static void doinvcheat(int32_t invidx, int32_t defaultnum, int32_t event)
{
defaultnum = VM_OnEventWithReturn(event, g_player[myconnectindex].ps->i, myconnectindex, defaultnum);
if (defaultnum >= 0)
g_player[myconnectindex].ps->inv_amount[invidx] = defaultnum;
}
static void G_CheatGetInv(void)
{
doinvcheat(GET_STEROIDS, 400, EVENT_CHEATGETSTEROIDS);
doinvcheat(GET_HEATS, 1200, EVENT_CHEATGETHEAT);
doinvcheat(GET_BOOTS, 200, EVENT_CHEATGETBOOT);
doinvcheat(GET_SHIELD, 100, EVENT_CHEATGETSHIELD);
doinvcheat(GET_SCUBA, 6400, EVENT_CHEATGETSCUBA);
doinvcheat(GET_HOLODUKE, 2400, EVENT_CHEATGETHOLODUKE);
doinvcheat(GET_JETPACK, 1600, EVENT_CHEATGETJETPACK);
doinvcheat(GET_FIRSTAID, g_player[myconnectindex].ps->max_player_health, EVENT_CHEATGETFIRSTAID);
}
static void end_cheat(void)
{
g_player[myconnectindex].ps->cheat_phase = 0;
KB_FlushKeyboardQueue();
}
static int32_t cheatbuflen;
static int8_t cheatbuf[MAXCHEATLEN];
GAME_STATIC void G_DoCheats(void)
{
int32_t ch, i, j, k=0, weapon;
static int32_t vol1inited=0;
char consolecheat = 0; // JBF 20030914
if (osdcmd_cheatsinfo_stat.cheatnum != -1)
{
if (ud.player_skill == 4)
{
P_DoQuote(QUOTE_CHEATS_DISABLED,g_player[myconnectindex].ps);
osdcmd_cheatsinfo_stat.cheatnum = -1;
return;
}
// JBF 20030914
k = osdcmd_cheatsinfo_stat.cheatnum;
osdcmd_cheatsinfo_stat.cheatnum = -1;
consolecheat = 1;
}
if (VOLUMEONE && !vol1inited)
{
// change "scotty###" to "scotty##"
uint32_t const warpend = Bstrlen(CheatStrings[2]);
if (strcmp(&CheatStrings[2][warpend-3], "###") == 0)
CheatStrings[2][warpend-1] = '\0';
Bstrcpy(CheatStrings[6],"<RESERVED>");
vol1inited = 1;
}
if (consolecheat && numplayers < 2 && ud.recstat == 0)
goto FOUNDCHEAT;
if (g_player[myconnectindex].ps->gm & (MODE_TYPE|MODE_MENU))
return;
if (g_player[myconnectindex].ps->cheat_phase == 1)
{
while (KB_KeyWaiting())
{
ch = Btolower(KB_GetCh());
if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')))
{
g_player[myconnectindex].ps->cheat_phase = 0;
// P_DoQuote(QUOTE_46,g_player[myconnectindex].ps);
return;
}
cheatbuf[cheatbuflen++] = (int8_t)ch;
// This assertion is not obvious, but it should hold because of the
// cheat string matching logic below.
Bassert(cheatbuflen < (signed)sizeof(cheatbuf));
cheatbuf[cheatbuflen] = 0;
// KB_ClearKeysDown();
for (k=0; k < NUMCHEATCODES; k++)
{
for (j = 0; j<cheatbuflen; j++)
{
if (cheatbuf[j] == CheatStrings[k][j] || (CheatStrings[k][j] == '#' && ch >= '0' && ch <= '9'))
{
if (CheatStrings[k][j+1] == 0) goto FOUNDCHEAT;
if (j == cheatbuflen-1) return;
}
else break;
}
}
g_player[myconnectindex].ps->cheat_phase = 0;
return;
FOUNDCHEAT:
i = VM_OnEventWithReturn(EVENT_ACTIVATECHEAT, g_player[myconnectindex].ps->i, myconnectindex, k);
if (k != CHEAT_COMEGETSOME) // Users are not allowed to interfere with TX's debugging cheat.
k = i;
{
switch (k)
{
case CHEAT_WEAPONS:
j = 0;
if (VOLUMEONE)
j = 6;
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++)
{
P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
g_player[myconnectindex].ps->gotweapon |= (1<<weapon);
}
P_DoQuote(QUOTE_CHEAT_ALL_WEAPONS, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_INVENTORY:
G_CheatGetInv();
P_DoQuote(QUOTE_CHEAT_ALL_INV, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_KEYS:
g_player[myconnectindex].ps->got_access = 7;
KB_FlushKeyboardQueue();
P_DoQuote(QUOTE_CHEAT_ALL_KEYS, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_DEBUG:
g_Debug = 1-g_Debug;
G_DumpDebugInfo();
Bsprintf(tempbuf,"Gamevars dumped to log");
G_AddUserQuote(tempbuf);
Bsprintf(tempbuf,"Map dumped to debug.map");
G_AddUserQuote(tempbuf);
end_cheat();
break;
case CHEAT_CLIP:
ud.noclip = !ud.noclip;
P_DoQuote(QUOTE_CHEAT_NOCLIP-!ud.noclip, g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_RESERVED2:
g_player[myconnectindex].ps->player_par = 0;
g_player[myconnectindex].ps->gm = MODE_EOL;
end_cheat();
return;
case CHEAT_ALLEN:
P_DoQuote(QUOTE_CHEAT_ALLEN,g_player[myconnectindex].ps);
g_player[myconnectindex].ps->cheat_phase = 0;
KB_ClearKeyDown(sc_N);
return;
case CHEAT_CORNHOLIO:
case CHEAT_KROZ:
case CHEAT_COMEGETSOME:
{
const int32_t pi = g_player[myconnectindex].ps->i;
ud.god = 1-ud.god;
if (ud.god)
{
pus = 1;
pub = 1;
sprite[pi].cstat = 257;
actor[pi].t_data[0] = 0;
actor[pi].t_data[1] = 0;
actor[pi].t_data[2] = 0;
actor[pi].t_data[3] = 0;
actor[pi].t_data[4] = 0;
actor[pi].t_data[5] = 0;
sprite[pi].hitag = 0;
sprite[pi].lotag = 0;
sprite[pi].pal = g_player[myconnectindex].ps->palookup;
if (k != CHEAT_COMEGETSOME)
{
P_DoQuote(QUOTE_CHEAT_GODMODE_ON, g_player[myconnectindex].ps);
}
else
{
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4],"Come Get Some!");
S_PlaySound(DUKE_GETWEAPON2);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
G_CheatGetInv();
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++)
g_player[myconnectindex].ps->gotweapon |= (1<<weapon);
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++)
P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
g_player[myconnectindex].ps->got_access = 7;
}
}
else
{
sprite[pi].extra = g_player[myconnectindex].ps->max_player_health;
actor[pi].extra = -1;
g_player[myconnectindex].ps->last_extra = g_player[myconnectindex].ps->max_player_health;
P_DoQuote(QUOTE_CHEAT_GODMODE_OFF, g_player[myconnectindex].ps);
}
sprite[pi].extra = g_player[myconnectindex].ps->max_player_health;
actor[pi].extra = 0;
if (k != CHEAT_COMEGETSOME)
g_player[myconnectindex].ps->dead_flag = 0;
end_cheat();
return;
}
case CHEAT_STUFF:
j = 0;
if (VOLUMEONE)
j = 6;
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++)
g_player[myconnectindex].ps->gotweapon |= (1<<weapon);
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++)
P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
G_CheatGetInv();
g_player[myconnectindex].ps->got_access = 7;
P_DoQuote(QUOTE_CHEAT_EVERYTHING, g_player[myconnectindex].ps);
// P_DoQuote(QUOTE_21,g_player[myconnectindex].ps);
g_player[myconnectindex].ps->inven_icon = ICON_FIRSTAID;
end_cheat();
return;
case CHEAT_SCOTTY:
case CHEAT_SKILL:
if (k == CHEAT_SCOTTY)
{
i = Bstrlen(CheatStrings[k])-3+VOLUMEONE;
if (!consolecheat)
{
// JBF 20030914
int16_t volnume,levnume;
if (VOLUMEALL)
{
volnume = cheatbuf[i] - '0';
levnume = (cheatbuf[i+1] - '0')*10+(cheatbuf[i+2]-'0');
}
else
{
volnume = cheatbuf[i] - '0';
levnume = cheatbuf[i+1] - '0';
}
volnume--;
levnume--;
if ((VOLUMEONE && volnume > 0) || volnume > g_numVolumes-1 ||
levnume >= MAXLEVELS || MapInfo[volnume *MAXLEVELS+levnume].filename == NULL)
{
end_cheat();
return;
}
ud.m_volume_number = ud.volume_number = volnume;
ud.m_level_number = ud.level_number = levnume;
}
else
{
// JBF 20030914
ud.m_volume_number = ud.volume_number = osdcmd_cheatsinfo_stat.volume;
ud.m_level_number = ud.level_number = osdcmd_cheatsinfo_stat.level;
}
}
else
{
if (!consolecheat)
{
i = Bstrlen(CheatStrings[k])-1;
ud.m_player_skill = ud.player_skill = cheatbuf[i] - '1';
}
else
{
ud.m_player_skill = ud.player_skill = osdcmd_cheatsinfo_stat.volume;
}
}
/*if (numplayers > 1 && g_netServer)
Net_NewGame(ud.m_volume_number,ud.m_level_number);
else*/ g_player[myconnectindex].ps->gm |= MODE_RESTART;
end_cheat();
return;
case CHEAT_COORDS:
#ifdef USE_OPENGL
if (++ud.coords >= 3) ud.coords = 0;
#else
if (++ud.coords >= 2) ud.coords = 0;
#endif
end_cheat();
return;
case CHEAT_VIEW:
if (g_player[myconnectindex].ps->over_shoulder_on)
g_player[myconnectindex].ps->over_shoulder_on = 0;
else
{
g_player[myconnectindex].ps->over_shoulder_on = 1;
CAMERADIST = 0;
CAMERACLOCK = totalclock;
}
// P_DoQuote(QUOTE_CHEATS_DISABLED,g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_TIME:
// P_DoQuote(QUOTE_21,g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_UNLOCK:
if (VOLUMEONE) return;
for (i=numsectors-1; i>=0; i--) //Unlock
{
j = sector[i].lotag;
if (j == -1 || j == 32767) continue;
if ((j & 0x7fff) > 2)
{
if (j&(0xffff-16384))
sector[i].lotag &= (0xffff-16384);
G_OperateSectors(i,g_player[myconnectindex].ps->i);
}
}
G_OperateForceFields(g_player[myconnectindex].ps->i,-1);
P_DoQuote(QUOTE_CHEAT_UNLOCK,g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_CASHMAN:
ud.cashman = 1-ud.cashman;
KB_ClearKeyDown(sc_N);
g_player[myconnectindex].ps->cheat_phase = 0;
return;
case CHEAT_ITEMS:
G_CheatGetInv();
g_player[myconnectindex].ps->got_access = 7;
P_DoQuote(QUOTE_CHEAT_EVERYTHING,g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_SHOWMAP: // SHOW ALL OF THE MAP TOGGLE;
ud.showallmap = !ud.showallmap;
for (i=0; i<(MAXSECTORS>>3); i++)
show2dsector[i] = ud.showallmap*255;
P_DoQuote(ud.showallmap ? QUOTE_SHOW_MAP_ON : QUOTE_SHOW_MAP_OFF,
g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_TODD:
if (NAM)
{
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], g_NAMMattCheatQuote);
P_DoQuote(QUOTE_RESERVED4,g_player[myconnectindex].ps);
}
else
{
P_DoQuote(QUOTE_CHEAT_TODD,g_player[myconnectindex].ps);
}
end_cheat();
return;
case CHEAT_RATE:
if (ud.tickrate++ > 2)
ud.tickrate = 0;
end_cheat();
return;
case CHEAT_BETA:
P_DoQuote(QUOTE_CHEAT_BETA,g_player[myconnectindex].ps);
KB_ClearKeyDown(sc_H);
end_cheat();
return;
case CHEAT_HYPER:
g_player[myconnectindex].ps->inv_amount[GET_STEROIDS] = 399;
g_player[myconnectindex].ps->inv_amount[GET_HEATS] = 1200;
P_DoQuote(QUOTE_CHEAT_STEROIDS,g_player[myconnectindex].ps);
end_cheat();
return;
case CHEAT_MONSTERS:
{
const char *s[] = { "On", "Off", "On (2)" };
if (++g_noEnemies == 3)
g_noEnemies = 0;
Bsprintf(ScriptQuotes[QUOTE_RESERVED4], "Monsters: %s", s[g_noEnemies]);
P_DoQuote(QUOTE_RESERVED4,g_player[myconnectindex].ps);
end_cheat();
return;
}
case CHEAT_RESERVED:
case CHEAT_RESERVED3:
ud.eog = 1;
g_player[myconnectindex].ps->player_par = 0;
g_player[myconnectindex].ps->gm |= MODE_EOL;
KB_FlushKeyboardQueue();
return;
default:
end_cheat();
return;
}
}
}
}
else
{
if (KB_KeyPressed((uint8_t)CheatKeys[0]))
{
if (g_player[myconnectindex].ps->cheat_phase >= 0 && numplayers < 2 && ud.recstat == 0)
{
if (CheatKeys[0] == CheatKeys[1])
KB_ClearKeyDown((uint8_t)CheatKeys[0]);
g_player[myconnectindex].ps->cheat_phase = -1;
}
}
if (KB_KeyPressed((uint8_t)CheatKeys[1]))
{
if (g_player[myconnectindex].ps->cheat_phase == -1)
{
if (ud.player_skill == 4)
{
P_DoQuote(QUOTE_CHEATS_DISABLED,g_player[myconnectindex].ps);
g_player[myconnectindex].ps->cheat_phase = 0;
}
else
{
g_player[myconnectindex].ps->cheat_phase = 1;
// P_DoQuote(QUOTE_25,g_player[myconnectindex].ps);
cheatbuflen = 0;
}
KB_FlushKeyboardQueue();
}
else if (g_player[myconnectindex].ps->cheat_phase != 0)
{
g_player[myconnectindex].ps->cheat_phase = 0;
KB_ClearKeyDown((uint8_t)CheatKeys[0]);
KB_ClearKeyDown((uint8_t)CheatKeys[1]);
}
}
}
}
void G_SetViewportShrink(int32_t dir) void G_SetViewportShrink(int32_t dir)
{ {
if (ud.screen_size == 8 && dir!=0 && (dir>0)==(int32_t)ud.statusbarmode) if (ud.screen_size == 8 && dir!=0 && (dir>0)==(int32_t)ud.statusbarmode)
@ -11595,76 +10986,7 @@ int32_t app_main(int32_t argc, char const * const * argv)
G_LoadGroups(!g_noAutoLoad && !ud.config.NoAutoLoad); G_LoadGroups(!g_noAutoLoad && !ud.config.NoAutoLoad);
// flushlogwindow = 1; // flushlogwindow = 1;
// KEEPINSYNC: NAM_WW2GI_CHEATS G_SetupCheats();
if (WW2GI)
{
#if 0
// WWII GI's original cheat prefix temporarily disabled because W conflicts with WSAD movement
CheatKeys[0] = CheatKeys[1] = sc_W;
#else
CheatKeys[0] = sc_G;
CheatKeys[1] = sc_I;
#endif
Bstrcpy(CheatStrings[0], "2god");
Bstrcpy(CheatStrings[1], "2blood");
Bstrcpy(CheatStrings[2], "2level###");
Bstrcpy(CheatStrings[3], "2coords");
Bstrcpy(CheatStrings[4], "2view");
Bstrcpy(CheatStrings[5], "<RESERVED>");
Bstrcpy(CheatStrings[7], "<RESERVED>");
Bstrcpy(CheatStrings[8], "<RESERVED>");
Bstrcpy(CheatStrings[9], "2rate");
Bstrcpy(CheatStrings[10], "2skill");
Bstrcpy(CheatStrings[11], "<RESERVED>");
Bstrcpy(CheatStrings[12], "<RESERVED>");
Bstrcpy(CheatStrings[13], "<RESERVED>");
Bstrcpy(CheatStrings[16], "2matt");
Bstrcpy(CheatStrings[17], "2showmap");
Bstrcpy(CheatStrings[18], "2ryan");
Bstrcpy(CheatStrings[19], "<RESERVED>");
Bstrcpy(CheatStrings[20], "2clip");
Bstrcpy(CheatStrings[21], "2weapons");
Bstrcpy(CheatStrings[22], "2inventory");
Bstrcpy(CheatStrings[23], "<RESERVED>");
Bstrcpy(CheatStrings[24], "2debug");
Bstrcpy(CheatStrings[26], "2cgs");
Bstrcpy(GametypeNames[0],"GI Match (Spawn)");
Bstrcpy(GametypeNames[2],"GI Match (No Spawn)");
}
else if (NAM)
{
CheatKeys[0] = sc_N;
CheatKeys[1] = sc_V;
Bstrcpy(CheatStrings[0], "acaleb");
Bstrcpy(CheatStrings[1], "ablood");
Bstrcpy(CheatStrings[2], "alevel###");
Bstrcpy(CheatStrings[3], "acoords");
Bstrcpy(CheatStrings[4], "aview");
Bstrcpy(CheatStrings[5], "<RESERVED>");
Bstrcpy(CheatStrings[7], "<RESERVED>");
Bstrcpy(CheatStrings[8], "<RESERVED>");
Bstrcpy(CheatStrings[9], "arate");
Bstrcpy(CheatStrings[10], "askill");
Bstrcpy(CheatStrings[11], "<RESERVED>");
Bstrcpy(CheatStrings[12], "ahyper");
Bstrcpy(CheatStrings[13], "<RESERVED>");
Bstrcpy(CheatStrings[16], "amatt");
Bstrcpy(CheatStrings[17], "ashowmap");
Bstrcpy(CheatStrings[18], "agod");
Bstrcpy(CheatStrings[19], "<RESERVED>");
Bstrcpy(CheatStrings[20], "aclip");
Bstrcpy(CheatStrings[21], "aweapons");
Bstrcpy(CheatStrings[22], "ainventory");
Bstrcpy(CheatStrings[23], "<RESERVED>");
Bstrcpy(CheatStrings[24], "adebug");
Bstrcpy(CheatStrings[26], "acgs");
Bstrcpy(GametypeNames[0],"GruntMatch (Spawn)");
Bstrcpy(GametypeNames[2],"GruntMatch (No Spawn)");
}
if (!usecwd) if (!usecwd)
G_CleanupSearchPaths(); G_CleanupSearchPaths();

View file

@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef game_h_ #ifndef game_h_
#define game_h_ #define game_h_
#include "premap.h" #include "premap.h" // XXX
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -263,9 +263,6 @@ extern const char *s_buildDate;
extern const char *g_rtsNamePtr; extern const char *g_rtsNamePtr;
extern char CheatStrings[][MAXCHEATLEN];
extern char const * const g_NAMMattCheatQuote;
extern char boardfilename[BMAX_PATH], currentboardfilename[BMAX_PATH]; extern char boardfilename[BMAX_PATH], currentboardfilename[BMAX_PATH];
extern char boardfilename[BMAX_PATH]; extern char boardfilename[BMAX_PATH];
@ -283,6 +280,7 @@ extern int32_t althud_numberpal;
extern int32_t althud_numbertile; extern int32_t althud_numbertile;
extern int32_t althud_shadows; extern int32_t althud_shadows;
extern int32_t g_Debug;
extern int32_t g_Shareware; extern int32_t g_Shareware;
#if !defined LUNATIC #if !defined LUNATIC
extern int32_t g_cameraClock; extern int32_t g_cameraClock;
@ -345,6 +343,7 @@ void A_SpawnRandomGlass(int32_t i,int32_t wallnum,int32_t n);
void A_SpawnWallGlass(int32_t i,int32_t wallnum,int32_t n); void A_SpawnWallGlass(int32_t i,int32_t wallnum,int32_t n);
void G_AddUserQuote(const char *daquote); void G_AddUserQuote(const char *daquote);
void G_BackToMenu(void); void G_BackToMenu(void);
void G_DumpDebugInfo(void);
const char* G_PrintYourTime(void); const char* G_PrintYourTime(void);
const char* G_PrintParTime(void); const char* G_PrintParTime(void);
@ -516,68 +515,6 @@ enum {
// left: ST 32767, 65534, 65535 // left: ST 32767, 65534, 65535
}; };
// Cheats
// KEEPINSYNC game.c: char CheatStrings[][]
enum cheatindex_t
{
CHEAT_CORNHOLIO, // 0
CHEAT_STUFF,
CHEAT_SCOTTY,
CHEAT_COORDS,
CHEAT_VIEW,
CHEAT_TIME, // 5
CHEAT_UNLOCK,
CHEAT_CASHMAN,
CHEAT_ITEMS,
CHEAT_RATE,
CHEAT_SKILL, // 10
CHEAT_BETA,
CHEAT_HYPER,
CHEAT_MONSTERS,
CHEAT_RESERVED,
CHEAT_RESERVED2, // 15
CHEAT_TODD,
CHEAT_SHOWMAP,
CHEAT_KROZ,
CHEAT_ALLEN,
CHEAT_CLIP, // 20
CHEAT_WEAPONS,
CHEAT_INVENTORY,
CHEAT_KEYS,
CHEAT_DEBUG,
CHEAT_RESERVED3, // 25
CHEAT_COMEGETSOME,
NUMCHEATS,
};
// KEEPINSYNC game.c: uint8_t CheatFunctionIDs[]
// KEEPINSYNC menus.c: MenuEntry_t ME_CheatCodes[]
enum CheatCodeFunctions
{
CHEATFUNC_CASHMAN,
CHEATFUNC_GOD,
CHEATFUNC_GIVEEVERYTHING,
CHEATFUNC_GIVEWEAPONS,
CHEATFUNC_GIVEALLITEMS,
CHEATFUNC_GIVEINVENTORY,
CHEATFUNC_GIVEKEYS,
CHEATFUNC_HYPER,
CHEATFUNC_VIEW,
CHEATFUNC_SHOWMAP,
CHEATFUNC_UNLOCK,
CHEATFUNC_CLIP,
CHEATFUNC_WARP,
CHEATFUNC_SKILL,
CHEATFUNC_MONSTERS,
CHEATFUNC_FRAMERATE,
CHEATFUNC_QUOTEBETA,
CHEATFUNC_QUOTETODD,
CHEATFUNC_QUOTEALLEN,
CHEATFUNC_COORDS,
CHEATFUNC_DEBUG,
NUMCHEATFUNCS,
};
# define G_ModDirSnprintf(buf, size, basename, ...) \ # define G_ModDirSnprintf(buf, size, basename, ...) \
( \ ( \

View file

@ -20,22 +20,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "compat.h"
#include <time.h>
#include <stdlib.h>
#include <math.h> // sqrt
#include "build.h"
#include "duke3d.h" #include "duke3d.h"
#include "gamedef.h" #include <time.h>
#include "gameexec.h" #include <math.h> // sqrt
#include "scriplib.h" #include "scriplib.h"
#include "savegame.h" #include "savegame.h"
#include "premap.h"
#include "osdcmds.h" #include "osdcmds.h"
#include "osd.h"
#include "menus.h" #include "menus.h"
#include "input.h" #include "input.h"
#include "anim.h" #include "anim.h"

View file

@ -1,6 +1,6 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/* /*
Copyright (C) 2010 EDuke32 developers and contributors Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32. This file is part of EDuke32.
@ -21,11 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "duke3d.h" #include "duke3d.h"
#include "common_game.h"
#include "gamevars.h"
#include "gamedef.h"
#include "osd.h"
#include "savegame.h"
#include "menus.h" #include "menus.h"
#define gamevars_c_ #define gamevars_c_

View file

@ -1,6 +1,6 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/* /*
Copyright (C) 2010 EDuke32 developers and contributors Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32. This file is part of EDuke32.
@ -20,23 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "compat.h"
#include "duke3d.h" #include "duke3d.h"
#include "renderlayer.h"
#include "net.h"
#include "player.h"
#include "mouse.h"
#include "joystick.h"
#include "osd.h"
#include "osdcmds.h" #include "osdcmds.h"
#include "gamedef.h"
#include "gameexec.h"
#include "savegame.h" #include "savegame.h"
#include "premap.h"
#include "demo.h" #include "demo.h"
#include "xxhash.h" #include "xxhash.h"
#include "common.h"
#include "common_game.h"
#include "input.h" #include "input.h"
#include "menus.h" #include "menus.h"

View file

@ -21,9 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "duke3d.h" #include "duke3d.h"
#include "common_game.h"
#include "osd.h"
#include "player.h"
#include "demo.h" #include "demo.h"
#include "enet/enet.h" #include "enet/enet.h"

View file

@ -1,6 +1,6 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/* /*
Copyright (C) 2010 EDuke32 developers and contributors Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32. This file is part of EDuke32.
@ -21,14 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "duke3d.h" #include "duke3d.h"
#include "game.h"
#include "common_game.h"
#include "osd.h"
#include "gamedef.h"
#include "premap.h"
#include "sounds.h"
#include "fx_man.h"
#include "gameexec.h"
#include "anim.h" #include "anim.h"
#include "menus.h" #include "menus.h"
#include "demo.h" #include "demo.h"

View file

@ -23,12 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define sector_c_ #define sector_c_
#include "duke3d.h" #include "duke3d.h"
#include "sector.h"
#include "gamedef.h"
#include "gameexec.h"
#include "premap.h"
#include "osd.h"
#include "common_game.h"
#include "input.h" #include "input.h"
// PRIMITIVE // PRIMITIVE

View file

@ -1,6 +1,6 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/* /*
Copyright (C) 2010 EDuke32 developers and contributors Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32. This file is part of EDuke32.
@ -27,20 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS
#endif #endif
#include <stdio.h>
#include <string.h>
#include "fx_man.h"
#include "music.h"
#include "duke3d.h" #include "duke3d.h"
#include "osd.h" #include "renderlayer.h" // for win_gethwnd()
#include "sounds.h"
#include "common_game.h"
#ifdef _WIN32
#include "winlayer.h"
#endif
#define DQSIZE 128 #define DQSIZE 128