diff --git a/source/sw/src/cheats.cpp b/source/sw/src/cheats.cpp index f36d3c62c..b821a460f 100644 --- a/source/sw/src/cheats.cpp +++ b/source/sw/src/cheats.cpp @@ -175,6 +175,35 @@ void WeaponCheat(PLAYERp pp, const char *) p->WpnAmmo[i] = DamageData[i].max_ammo; } + p->WpnShotgunAuto = 50; + p->WpnRocketHeat = 5; + p->WpnRocketNuke = 1; + + PlayerUpdateWeapon(p, u->WeaponNum); + } +} + +void AmmoCheat(PLAYERp pp, const char *) +{ + PLAYERp p; + short pnum; + unsigned int i; + USERp u; + + TRAVERSE_CONNECT(pnum) + { + p = &Player[pnum]; + u = User[p->PlayerSprite]; + + p->WpnShotgunAuto = 50; + p->WpnRocketHeat = 5; + p->WpnRocketNuke = 1; + + for (i = 0; i < SIZ(p->WpnAmmo); i++) + { + p->WpnAmmo[i] = DamageData[i].max_ammo; + } + PlayerUpdateWeapon(p, u->WeaponNum); } } @@ -269,6 +298,55 @@ void ItemCheat(PLAYERp pp, const char *cheat_string) PlayerUpdateKeys(pp); } +void InventoryCheat(PLAYERp pp, const char *cheat_string) +{ + // + // Get all ITEMS + // + PLAYERp p; + short pnum; + short inv; + int i; + + PutStringInfo(pp, "INVENTORY"); + + TRAVERSE_CONNECT(pnum) + { + p = &Player[pnum]; + + p->WpnShotgunAuto = 50; + p->WpnRocketHeat = 5; + p->WpnRocketNuke = 1; + p->Armor = 100; + + for (inv = 0; inv < MAX_INVENTORY; inv++) + { + p->InventoryPercent[inv] = 100; + //p->InventoryAmount[inv] = 1; + p->InventoryAmount[inv] = InventoryData[inv].MaxInv; + //PlayerUpdateInventory(p, inv); + } + + PlayerUpdateInventory(p, p->InventoryNum); + //p->InventoryNum = 0; + } + +} + +void ArmorCheat(PLAYERp pp, const char *cheat_string) +{ + short pnum; + const char *str = nullptr; + + TRAVERSE_CONNECT(pnum) + { + if (User[Player[pnum].PlayerSprite]->Health < pp->MaxHealth) + str = "ARMOR"; + Player[pnum].Armor = 100; + } + if (str) PutStringInfo(pp, GStrings(str)); +} + void HealCheat(PLAYERp pp, const char *cheat_string) { short pnum; diff --git a/source/sw/src/cheats.h b/source/sw/src/cheats.h index 45301b49f..d9c6f2bfe 100644 --- a/source/sw/src/cheats.h +++ b/source/sw/src/cheats.h @@ -13,11 +13,14 @@ void PrevCheat(PLAYERp pp, const char *); void MapCheat(PLAYERp pp, const char *); void LocCheat(PLAYERp pp, const char *); void GunsCheat(PLAYERp pp, const char *cheat_string); +void AmmoCheat(PLAYERp pp, const char *); void WeaponCheat(PLAYERp pp, const char *); void GodCheat(PLAYERp pp, const char *); void ClipCheat(PLAYERp pp, const char *); void WarpCheat(PLAYERp pp, const char *cheat_string); void ItemCheat(PLAYERp pp, const char *cheat_string); +void InventoryCheat(PLAYERp pp, const char *cheat_string); +void ArmorCheat(PLAYERp pp, const char *cheat_string); void HealCheat(PLAYERp pp, const char *cheat_string); void SortKeyCheat(PLAYERp pp, const char *sKey); void KeysCheat(PLAYERp pp, const char *cheat_string); diff --git a/source/sw/src/osdcmds.cpp b/source/sw/src/osdcmds.cpp index e4e7c1df5..a927c3e9e 100644 --- a/source/sw/src/osdcmds.cpp +++ b/source/sw/src/osdcmds.cpp @@ -103,50 +103,6 @@ static int osdcmd_map(osdcmdptr_t parm) return OSDCMD_OK; } - -// demo [] -// -// To profile a demo ("timedemo mode"), can be given in the range 0-8, -// which will start to replay it as fast as possible, rendering frames -// for each gametic. -// -// Notes: -// * The demos should be recorded with demorec_diffs set to 0, so that the -// game state updates are actually computed. -// * Currently, the profiling can only be aborted on SDL 1.2 builds by -// pressing any key. -// * With greater than 1, interpolation should be calculated properly, -// though this has not been verified by looking at the frames. -// * When testing whether a change in the source has an effect on performance, -// the variance of the run times MUST be taken into account (that is, the -// replaying must be performed multiple times for the old and new versions, -// etc.) -static int osdcmd_demo(osdcmdptr_t parm) -{ - if (numplayers > 1) - { - OSD_Printf("Command not allowed in multiplayer\n"); - return OSDCMD_OK; - } - - if (g_player[myconnectindex].ps->gm & MODE_GAME) - { - OSD_Printf("demo: Must not be in a game.\n"); - return OSDCMD_OK; - } - - if (parm->numparms != 1 && parm->numparms != 2) - return OSDCMD_SHOWHELP; - - { - int32_t prof = parm->numparms==2 ? Batoi(parm->parms[1]) : -1; - - Demo_SetFirst(parm->parms[0]); - Demo_PlayFirst(clamp(prof, -1, 8)+1, 0); - } - - return OSDCMD_OK; -} #endif static int osdcmd_activatecheat(osdcmdptr_t parm) @@ -188,6 +144,19 @@ int osdcmd_restartmap(osdcmdptr_t UNUSED(parm)) return OSDCMD_OK; } +int osdcmd_levelwarp(osdcmdptr_t parm) +{ + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + + char cheatcode[9] = "swtrek##"; + + for (int i = 0; i < 2; i++) + cheatcode[6+i] = parm->parms[0][i]; + + WarpCheat(Player, cheatcode); + return OSDCMD_OK; +} + #if 0 static int osdcmd_spawn(osdcmdptr_t parm) { @@ -282,112 +251,12 @@ static int osdcmd_spawn(osdcmdptr_t parm) return OSDCMD_OK; } - -static int osdcmd_setvar(osdcmdptr_t parm) -{ - if (numplayers > 1) - { - OSD_Printf("Command not allowed in multiplayer\n"); - return OSDCMD_OK; - } - - if (parm->numparms != 2) - return OSDCMD_SHOWHELP; - - int i = hash_find(&h_gamevars, parm->parms[1]); - int const newValue = (i == -1) ? Batol(parm->parms[1]) : Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex); - - if ((i = hash_find(&h_gamevars, parm->parms[0])) >= 0) - { - Gv_SetVar(i, newValue, g_player[myconnectindex].ps->i, myconnectindex); - - OSD_Printf("Variable \"%s\" now has value %d (input: %d)\n", aGameVars[i].szLabel, - Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex), newValue); - } - else - { - OSD_Printf("setvar: \"%s\" is not a game variable!\n", parm->parms[0]); - return OSDCMD_SHOWHELP; - } - - return OSDCMD_OK; -} - -static int osdcmd_addlogvar(osdcmdptr_t parm) -{ - if (numplayers > 1) - { - OSD_Printf("Command not allowed in multiplayer\n"); - return OSDCMD_OK; - } - - if (parm->numparms != 1) - return OSDCMD_SHOWHELP; - - int const i = hash_find(&h_gamevars, parm->parms[0]); - - if (i >= 0) - OSD_Printf("Variable \"%s\" has value %d, default %d\n", parm->parms[0], Gv_GetVar(i, g_player[screenpeek].ps->i, screenpeek), (int)aGameVars[i].defaultValue); - else - { - OSD_Printf("addlogvar: %s is not a game variable!\n", parm->parms[0]); - return OSDCMD_SHOWHELP; - } - - return OSDCMD_OK; -} - -static int osdcmd_setactorvar(osdcmdptr_t parm) -{ - if (numplayers > 1) - { - OSD_Printf("Command not allowed in multiplayer\n"); - return OSDCMD_OK; - } - - if (parm->numparms != 3) - return OSDCMD_SHOWHELP; - - int16_t const spriteNum = Batol(parm->parms[0]); - - if ((unsigned)spriteNum >= MAXSPRITES) - { - OSD_Printf("setactorvar: Invalid sprite number!\n"); - return OSDCMD_OK; - } - - // get value to set - int i = hash_find(&h_gamevars, parm->parms[2]); - int const newValue = (i >= 0) ? Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex) : Batol(parm->parms[2]); - - if ((i = hash_find(&h_gamevars, parm->parms[1])) >= 0) - { - Gv_SetVar(i, newValue, spriteNum, myconnectindex); - - OSD_Printf("Variable \"%s\" for sprite %d value is now %d (input: %d)\n", aGameVars[i].szLabel, spriteNum, - Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex), newValue); - } - else - { - OSD_Printf("setactorvar: %s is not a game variable!\n", parm->parms[1]); - return OSDCMD_SHOWHELP; - } - - return OSDCMD_OK; -} #endif static int osdcmd_give(osdcmdptr_t parm) { int32_t i; -// if (numplayers != 1 || (g_player[myconnectindex].ps->gm & MODE_GAME) == 0 || -// g_player[myconnectindex].ps->dead_flag != 0) -// { -// OSD_Printf("give: Cannot give while dead or not in a single-player game.\n"); -// return OSDCMD_OK; -// } - if (parm->numparms != 1) return OSDCMD_SHOWHELP; if (!Bstrcasecmp(parm->parms[0], "all")) @@ -407,141 +276,27 @@ static int osdcmd_give(osdcmdptr_t parm) } else if (!Bstrcasecmp(parm->parms[0], "ammo")) { -// for (i=MAX_WEAPONS-(VOLUMEONE?6:1)-1; i>=PISTOL_WEAPON; i--) -// P_AddAmmo(g_player[myconnectindex].ps,i,g_player[myconnectindex].ps->max_ammo_amount[i]); + AmmoCheat(Player, ""); return OSDCMD_OK; } else if (!Bstrcasecmp(parm->parms[0], "armor")) { -// g_player[myconnectindex].ps->inv_amount[GET_SHIELD] = 100; + ArmorCheat(Player, ""); // this cheat did not exist before return OSDCMD_OK; } else if (!Bstrcasecmp(parm->parms[0], "keys")) { - KeysCheat(Player,"swkeys"); + KeysCheat(Player, "swkeys"); return OSDCMD_OK; } else if (!Bstrcasecmp(parm->parms[0], "inventory")) { - ItemCheat(Player, "swgimme"); + InventoryCheat(Player, ""); // this cheat did not exist before return OSDCMD_OK; } return OSDCMD_SHOWHELP; } -#if 0 -void onvideomodechange(int32_t newmode) -{ - uint8_t palid; - - // XXX? -// if (!newmode || g_player[screenpeek].ps->palette < BASEPALCOUNT) -// palid = g_player[screenpeek].ps->palette; -// else -// palid = BASEPAL; - -#ifdef POLYMER - if (videoGetRenderMode() == REND_POLYMER) - { - int32_t i = 0; - - while (i < MAXSPRITES) - { - if (actor[i].lightptr) - { - polymer_deletelight(actor[i].lightId); - actor[i].lightptr = NULL; - actor[i].lightId = -1; - } - i++; - } - } -#endif - - videoSetPalette(0, palid, 0); - g_restorePalette = -1; - g_crosshairSum = -1; -} -#endif - -#if 0 -static int osdcmd_dumpmapstate(osdfuncparm_t const * const) -{ - // this command takes no parameters - - DumpMapStateHistory(); - - return OSDCMD_OK; -} - -static int osdcmd_printtimes(osdcmdptr_t UNUSED(parm)) -{ - UNREFERENCED_CONST_PARAMETER(parm); - - char buf[32]; - int32_t maxlen = 0; - int32_t haveev=0, haveac=0; - static char const s_event_[] = "EVENT_"; - int constexpr strlen_event_ = ARRAY_SIZE(s_event_) - 1; - - for (auto & EventName : EventNames) - { - int const len = Bstrlen(EventName+strlen_event_); - Bassert(len < ARRAY_SSIZE(buf)); - maxlen = max(len, maxlen); - } - - for (int i=0; i: gives requested item", osdcmd_give); @@ -550,14 +305,9 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip); - -// OSD_RegisterFunction("printtimes", "printtimes: prints VM timing statistics", osdcmd_printtimes); + OSD_RegisterFunction("levelwarp", "levelwarp : warp to level", osdcmd_levelwarp); OSD_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap); -// OSD_RegisterFunction("addlogvar","addlogvar : prints the value of a gamevar", osdcmd_addlogvar); -// OSD_RegisterFunction("setvar","setvar : sets the value of a gamevar", osdcmd_setvar); -// OSD_RegisterFunction("setvarvar","setvarvar : sets the value of to ", osdcmd_setvar); -// OSD_RegisterFunction("setactorvar","setactorvar : sets the value of 's to ", osdcmd_setactorvar); // OSD_RegisterFunction("spawn","spawn [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);