- CCMD cleanup.

This commit is contained in:
Christoph Oelckers 2020-07-04 21:36:27 +02:00
parent 39185300e7
commit 7872b701ce
14 changed files with 320 additions and 531 deletions

View file

@ -10,6 +10,7 @@ set( PCH_SOURCES
src/animatesprites_r.cpp
src/animatesprites_d.cpp
src/bowling.cpp
src/ccmds.cpp
src/cheats.cpp
src/d_menu.cpp
src/dispatch.cpp
@ -45,7 +46,6 @@ set( PCH_SOURCES
src/zz_game.cpp
src/zz_global.cpp
src/zz_net.cpp
src/zz_osdcmds.cpp
src/zz_player.cpp
src/zz_premap.cpp
src/zz_savegame.cpp

View file

@ -2808,7 +2808,7 @@ void handle_se14(int i, bool checkstat, int RPG, int JIBS6)
}
if (s->xvel <= 64 && statstate)
stopsound(hittype[i].lastvx);
S_StopEnvSound(hittype[i].lastvx, i);
if ((sc->floorz - sc->ceilingz) < (108 << 8))
{

View file

@ -3870,7 +3870,7 @@ void moveeffectors_d(void) //STATNUM 3
x = ldist(&sprite[ps[p].i], &sprite[j]);
if (x < 768)
{
if (S_CheckSoundPlaying(DUKE_LONGTERM_PAIN) < 1)
if (S_CheckSoundPlaying(ps[p].i, DUKE_LONGTERM_PAIN) < 1)
spritesound(DUKE_LONGTERM_PAIN, ps[p].i);
spritesound(SHORT_CIRCUIT, ps[p].i);
sprite[ps[p].i].extra -= 8 + (krand() & 7);

View file

@ -0,0 +1,306 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "duke3d.h"
#include "osdcmds.h"
#include "savegame.h"
#include "sbar.h"
#include "mapinfo.h"
#include "cheathandler.h"
BEGIN_DUKE_NS
bool cheatGod(cheatseq_t*);
bool cheatClip(cheatseq_t*);
bool cheatWeapons(cheatseq_t* s);
bool cheatStuff(cheatseq_t* s);
bool cheatKeys(cheatseq_t* s);
bool cheatInventory(cheatseq_t* s);
static void dowarp(int volume, int level)
{
ud.m_monsters_off = ud.monsters_off = 0;
ud.m_respawn_items = 0;
ud.m_respawn_inventory = 0;
ud.multimode = 1;
ud.m_volume_number = volume;
m_level_number = level;
if (ps[myconnectindex].gm & MODE_GAME)
{
G_NewGame(ud.m_volume_number, m_level_number, ud.m_player_skill);
ps[myconnectindex].gm = MODE_RESTART;
}
else G_NewGame_EnterLevel();
}
static int ccmd_levelwarp(CCmdFuncPtr parm)
{
if (parm->numparms != 2)
return CCMD_SHOWHELP;
int e = atoi(parm->parms[0]);
int m = atoi(parm->parms[1]);
if (e == 0 || m == 0)
{
Printf(TEXTCOLOR_RED "Invalid level!: E%sL%s\n", parm->parms[0], parm->parms[1]);
return CCMD_OK;
}
dowarp(e - 1, m - 1);
return CCMD_OK;
}
static int ccmd_map(CCmdFuncPtr parm)
{
if (parm->numparms != 1)
{
return CCMD_SHOWHELP;
}
FString mapname = parm->parms[0];
if (!fileSystem.Lookup(mapname, "MAP"))
{
Printf(TEXTCOLOR_RED "map: file \"%s\" not found.\n", mapname.GetChars());
return CCMD_OK;
}
int volume, level;
// Check if the map is already defined.
for (int i = 0; i < 512; i++)
{
if (mapList[i].labelName.CompareNoCase(mapname) == 0)
{
volume = i / MAXLEVELS;
level = i % MAXLEVELS;
goto foundone;
}
}
if (VOLUMEONE)
{
Printf(TEXTCOLOR_RED "Cannot use user maps in shareware.\n");
return CCMD_OK;
}
// Treat as user map if not found in the list of regular maps.
boardfilename[0] = '/';
boardfilename[1] = 0;
volume = 0;
level = 7;
DefaultExtension(mapname, ".map");
strcat(boardfilename, mapname);
foundone:
if (numplayers > 1)
{
return CCMD_OK;
}
dowarp(volume, level);
return CCMD_OK;
}
static int ccmd_activatecheat(CCmdFuncPtr parm)
{
if (parm->numparms != 1)
return CCMD_SHOWHELP;
PlaybackCheat(parm->parms[0]);
return CCMD_OK;
}
static int ccmd_god(CCmdFuncPtr)
{
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
cheatGod(nullptr);
else
Printf("god: Not in a single-player game.\n");
return CCMD_OK;
}
static int ccmd_noclip(CCmdFuncPtr)
{
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
{
cheatClip(nullptr);
}
else
{
Printf("noclip: Not in a single-player game.\n");
}
return CCMD_OK;
}
int ccmd_restartmap(CCmdFuncPtr)
{
if (ps[myconnectindex].gm & MODE_GAME && ud.multimode == 1)
ps[myconnectindex].gm = MODE_RESTART;
return CCMD_OK;
}
static int ccmd_spawn(CCmdFuncPtr parm)
{
int x = 0, y = 0, z = 0;
unsigned int cstat = 0, picnum = 0;
unsigned int pal = 0;
int ang = 0;
int set = 0, idx;
if (numplayers > 1 || !(ps[myconnectindex].gm & MODE_GAME)) {
Printf("spawn: Can't spawn sprites in multiplayer games or demos\n");
return CCMD_OK;
}
switch (parm->numparms) {
case 7: // x,y,z
x = atol(parm->parms[4]);
y = atol(parm->parms[5]);
z = atol(parm->parms[6]);
set |= 8;
case 4: // ang
ang = atol(parm->parms[3]) & 2047; set |= 4;
case 3: // cstat
cstat = (unsigned short)atol(parm->parms[2]); set |= 2;
case 2: // pal
pal = (unsigned char)atol(parm->parms[1]); set |= 1;
case 1: // tile number
if (isdigit(parm->parms[0][0])) {
picnum = (unsigned short)atol(parm->parms[0]);
}
else {
int i, j;
for (j = 0; j < 2; j++) {
for (i = 0; i < labelcnt; i++) {
if (
(j == 0 && !strcmp(label + (i * MAXLABELLEN), parm->parms[0])) ||
(j == 1 && !stricmp(label + (i * MAXLABELLEN), parm->parms[0]))
) {
picnum = (unsigned short)labelcode[i];
break;
}
}
if (i < labelcnt) break;
}
if (i == labelcnt) {
Printf("spawn: Invalid tile label given\n");
return CCMD_OK;
}
}
if (picnum >= MAXTILES) {
Printf("spawn: Invalid tile number\n");
return CCMD_OK;
}
break;
default:
return CCMD_SHOWHELP;
}
idx = fi.spawn(ps[myconnectindex].i, (short)picnum);
if (set & 1) sprite[idx].pal = (char)pal;
if (set & 2) sprite[idx].cstat = (short)cstat;
if (set & 4) sprite[idx].ang = ang;
if (set & 8) {
if (setsprite(idx, x, y, z) < 0) {
Printf("spawn: Sprite can't be spawned into null space\n");
deletesprite(idx);
}
}
return CCMD_OK;
}
static int ccmd_give(CCmdFuncPtr parm)
{
if (numplayers != 1 || (ps[myconnectindex].gm & MODE_GAME) == 0 ||
ps[myconnectindex].dead_flag != 0)
{
Printf("give: Cannot give while dead or not in a single-player game.\n");
return CCMD_OK;
}
if (parm->numparms != 1) return CCMD_SHOWHELP;
cheatseq_t* cs = (cheatseq_t*)(intptr_t)1;
if (!stricmp(parm->parms[0], "all"))
{
cheatStuff(cs);
}
else if (!stricmp(parm->parms[0], "health"))
{
sprite[ps[myconnectindex].i].extra = max_player_health<<1;
}
else if (!stricmp(parm->parms[0], "weapons"))
{
cheatWeapons(cs);
}
else if (!stricmp(parm->parms[0], "ammo"))
{
int maxw = VOLUMEONE ? SHRINKER_WEAPON : MAX_WEAPONS;
for (int i = maxw; i >= PISTOL_WEAPON; i--)
addammo(i, &ps[myconnectindex], max_ammo_amount[i]);
}
else if (!stricmp(parm->parms[0], "armor"))
{
ps[myconnectindex].shield_amount = 100;
}
else if (!stricmp(parm->parms[0], "keys"))
{
cheatKeys(cs);
}
else if (!stricmp(parm->parms[0], "inventory"))
{
cheatInventory(cs);
}
else return CCMD_SHOWHELP;
return CCMD_OK;
}
int registerosdcommands(void)
{
C_RegisterFunction("map","map <mapname>: warp to the given map, identified by its name", ccmd_map);
C_RegisterFunction("levelwarp","levelwarp <e> <m>: warp to episode 'e' and map 'm'", ccmd_levelwarp);
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", ccmd_give);
C_RegisterFunction("god","god: toggles god mode", ccmd_god);
C_RegisterFunction("activatecheat","activatecheat <string>: activates a cheat code", ccmd_activatecheat);
C_RegisterFunction("noclip","noclip: toggles clipping mode", ccmd_noclip);
C_RegisterFunction("restartmap", "restartmap: restarts the current map", ccmd_restartmap);
C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",ccmd_spawn);
return 0;
}
END_DUKE_NS

View file

@ -1,110 +0,0 @@
//-------------------------------------------------------------------------
/*
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
BEGIN_DUKE_NS
#define MAXCHEATLEN 20
#define NUMCHEATCODES (int32_t)ARRAY_SIZE(CheatStrings)
extern void G_DoCheats(void);
extern void G_SetupCheats(void);
// 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_RAJOSEPH, // 25
CHEAT_RAMRBILL,
CHEAT_RATONY,
CHEAT_RAGARY,
CHEAT_RARHETT,
CHEAT_RAAARON, // 30
CHEAT_RANOCHEAT,
CHEAT_RAWOLESLAGLE,
CHEAT_RAMIKAEL,
CHEAT_RAGREG,
CHEAT_RANOAH, // 35
CHEAT_RAARIJIT,
CHEAT_RADONUT,
CHEAT_RAKFC,
CHEAT_RAVAN,
NUMCHEATS,
};
extern char CheatStrings[NUMCHEATS][MAXCHEATLEN];
// 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,
};
END_DUKE_NS

View file

@ -30,7 +30,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "duke3d.h"
#include "osdcmds.h"
#include "savegame.h"
#include "game.h"
#include "superfasthash.h"

View file

@ -229,7 +229,6 @@ void lotsofcolourglass(int spriteNum,int wallNum,int glassCnt);
void lotsofglass(int spriteNum,int wallnum,int glassCnt);
void G_BackToMenu(void);
void G_DumpDebugInfo(void);
const char* G_PrintYourTime(void);
const char* G_PrintParTime(void);

View file

@ -64,6 +64,11 @@ G_EXTERN actor_t actor[MAXSPRITES];
// actorinfo: tile-specific data THAT DOES NOT CHANGE during the course of a game
G_EXTERN ActorInfo actorinfo[MAXTILES];
G_EXTERN animwalltype animwall[MAXANIMWALLS];
enum
{
MAXLABELLEN = 64
};
extern char *label;
G_EXTERN char g_loadFromGroupOnly;
G_EXTERN char g_skillCnt;

View file

@ -1,48 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010 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.
*/
//-------------------------------------------------------------------------
#ifndef osdcmds_h_
#define osdcmds_h_
BEGIN_DUKE_NS
struct osdcmd_cheatsinfo {
int32_t cheatnum; // -1 = none, else = see DoCheats()
int32_t volume,level;
};
extern struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat;
int32_t registerosdcommands(void);
// key bindings stuff
typedef struct {
const char *name;
int32_t id;
} keydef_t;
extern const char *const ConsoleButtons[];
END_DUKE_NS
#endif // osdcmds_h_

View file

@ -1402,8 +1402,8 @@ int doincrements_d(struct player_struct* p)
p->jetpack_on = 0;
checkavailinven(p);
spritesound(DUKE_JETPACK_OFF, p->i);
stopsound(DUKE_JETPACK_IDLE);
stopsound(DUKE_JETPACK_ON);
S_StopEnvSound(DUKE_JETPACK_IDLE, p->i);
S_StopEnvSound(DUKE_JETPACK_ON, p->i);
}
}

View file

@ -348,7 +348,7 @@ int getanimationgoal(const int* animptr)
j = -1;
for (i = animatecnt - 1; i >= 0; i--)
if (animptr == (int*)animateptr[i])
if (animptr == animateptr[i])
{
j = i;
break;

View file

@ -1663,8 +1663,8 @@ void checksectors_d(int snum)
else if (sprite[p->i].extra < max_player_health)
sprite[p->i].extra = max_player_health;
}
else if (S_CheckSoundPlaying(FLUSH_TOILET) == 0)
spritesound(FLUSH_TOILET, p->i);
else if (S_CheckSoundPlaying(neartagsprite, FLUSH_TOILET) == 0)
spritesound(FLUSH_TOILET, neartagsprite);
return;
case NUKEBUTTON:

View file

@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "duke3d.h"
#include "compat.h"
#include "baselayer.h"
#include "osdcmds.h"
#include "net.h"
#include "savegame.h"
@ -59,6 +58,7 @@ BEGIN_DUKE_NS
void SetDispatcher();
void InitCheats();
void checkcommandline();
int registerosdcommands(void);
int16_t max_ammo_amount[MAX_WEAPONS];
@ -972,24 +972,6 @@ bool GameInterface::GenerateSavePic()
}
void G_DumpDebugInfo(void)
{
int32_t j,x;
// FILE * fp=fopen("condebug.log","w");
for (x=0; x<MAXSTATUS; x++)
{
j = headspritestat[x];
while (j >= 0)
{
buildprint("Sprite ", j, " (", TrackerCast(sprite[j].x), ",", TrackerCast(sprite[j].y), ",", TrackerCast(sprite[j].z),
") (picnum: ", TrackerCast(sprite[j].picnum), ")\n");
buildprint("\n");
j = nextspritestat[j];
}
}
}
static int G_MaybeTakeOnFloorPal(tspritetype *pSprite, int sectNum)
{
int const floorPal = sector[sectNum].floorpal;

View file

@ -1,344 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010 EDuke32 developers and contributors
Copyright (C) 2020 Raze 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 "ns.h" // Must come before everything else!
#include "duke3d.h"
#include "osdcmds.h"
#include "savegame.h"
#include "sbar.h"
#include "mapinfo.h"
#include "cheathandler.h"
BEGIN_DUKE_NS
bool cheatGod(cheatseq_t*);
bool cheatClip(cheatseq_t*);
bool cheatWeapons(cheatseq_t* s);
bool cheatStuff(cheatseq_t* s);
bool cheatKeys(cheatseq_t* s);
bool cheatInventory(cheatseq_t* s);
static int osdcmd_levelwarp(CCmdFuncPtr parm)
{
if (parm->numparms != 2)
return OSDCMD_SHOWHELP;
int e = atoi(parm->parms[0]);
int m = atoi(parm->parms[1]);
if (e == 0 || m == 0)
{
Printf(TEXTCOLOR_RED "Invalid level!: E%sL%s\n", parm->parms[0], parm->parms[1]);
return OSDCMD_OK;
}
ud.m_volume_number = e - 1;
m_level_number = m - 1;
ud.m_monsters_off = ud.monsters_off = 0;
ud.m_respawn_items = 0;
ud.m_respawn_inventory = 0;
ud.multimode = 1;
if (g_player[myconnectindex].ps->gm & MODE_GAME)
{
G_NewGame(ud.m_volume_number, m_level_number, ud.m_player_skill);
g_player[myconnectindex].ps->gm = MODE_RESTART;
}
else G_NewGame_EnterLevel();
return OSDCMD_OK;
}
static int osdcmd_map(CCmdFuncPtr parm)
{
if (parm->numparms != 1)
{
return OSDCMD_SHOWHELP;
}
FString mapname = parm->parms[0];
if (!fileSystem.Lookup(mapname, "MAP"))
{
Printf(TEXTCOLOR_RED "map: file \"%s\" not found.\n", mapname.GetChars());
return OSDCMD_OK;
}
// Check if the map is already defined.
for (int i = 0; i < 512; i++)
{
if (mapList[i].labelName.CompareNoCase(mapname) == 0)
{
ud.m_volume_number = i / MAXLEVELS;
m_level_number = i % MAXLEVELS;
goto foundone;
}
}
if (VOLUMEONE)
{
Printf(TEXTCOLOR_RED "Cannot use user maps in shareware.\n");
return OSDCMD_OK;
}
// Treat as user map
boardfilename[0] = '/';
boardfilename[1] = 0;
ud.m_volume_number = 0;
m_level_number = 7;
DefaultExtension(mapname, ".map");
strcat(boardfilename, mapname);
foundone:
if (numplayers > 1)
{
return OSDCMD_OK;
}
ud.m_monsters_off = ud.monsters_off = 0;
ud.m_respawn_items = 0;
ud.m_respawn_inventory = 0;
ud.multimode = 1;
if (g_player[myconnectindex].ps->gm & MODE_GAME)
{
G_NewGame(ud.m_volume_number, m_level_number, ud.m_player_skill);
g_player[myconnectindex].ps->gm = MODE_RESTART;
}
else G_NewGame_EnterLevel();
return OSDCMD_OK;
}
static int osdcmd_activatecheat(CCmdFuncPtr parm)
{
if (parm->numparms != 1)
return OSDCMD_SHOWHELP;
PlaybackCheat(parm->parms[0]);
return OSDCMD_OK;
}
static int osdcmd_god(CCmdFuncPtr)
{
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
cheatGod(nullptr);
else
Printf("god: Not in a single-player game.\n");
return OSDCMD_OK;
}
static int osdcmd_noclip(CCmdFuncPtr)
{
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
{
cheatClip(nullptr);
}
else
{
Printf("noclip: Not in a single-player game.\n");
}
return OSDCMD_OK;
}
int osdcmd_restartmap(CCmdFuncPtr UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
if (g_player[myconnectindex].ps->gm & MODE_GAME && ud.multimode == 1)
g_player[myconnectindex].ps->gm = MODE_RESTART;
return OSDCMD_OK;
}
static int osdcmd_spawn(CCmdFuncPtr parm)
{
int32_t picnum = 0;
uint16_t cstat=0;
char pal=0;
int16_t ang=0;
int16_t set=0, idx;
vec3_t vect;
if (numplayers > 1 || !(g_player[myconnectindex].ps->gm & MODE_GAME))
{
Printf("spawn: Can't spawn sprites in multiplayer games or demos\n");
return OSDCMD_OK;
}
switch (parm->numparms)
{
case 7: // x,y,z
vect.x = Batol(parm->parms[4]);
vect.y = Batol(parm->parms[5]);
vect.z = Batol(parm->parms[6]);
set |= 8;
fallthrough__;
case 4: // ang
ang = Batol(parm->parms[3]) & 2047;
set |= 4;
fallthrough__;
case 3: // cstat
cstat = (uint16_t)Batol(parm->parms[2]);
set |= 2;
fallthrough__;
case 2: // pal
pal = (uint8_t)Batol(parm->parms[1]);
set |= 1;
fallthrough__;
case 1: // tile number
if (isdigit(parm->parms[0][0]))
{
picnum = Batol(parm->parms[0]);
}
else
{
int32_t i;
int32_t j;
for (j=0; j<2; j++)
{
for (i=0; i<labelcnt; i++)
{
if ((j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) ||
(j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0])))
{
picnum = labelcode[i];
break;
}
}
if (i < labelcnt)
break;
}
if (i==labelcnt)
{
Printf("spawn: Invalid tile label given\n");
return OSDCMD_OK;
}
}
if ((uint32_t)picnum >= MAXUSERTILES)
{
Printf("spawn: Invalid tile number\n");
return OSDCMD_OK;
}
break;
default:
return OSDCMD_SHOWHELP;
}
idx = fi.spawn(g_player[myconnectindex].ps->i, picnum);
if (set & 1) sprite[idx].pal = (uint8_t)pal;
if (set & 2) sprite[idx].cstat = (int16_t)cstat;
if (set & 4) sprite[idx].ang = ang;
if (set & 8)
{
if (setsprite(idx, &vect) < 0)
{
Printf("spawn: Sprite can't be spawned into null space\n");
deletesprite(idx);
}
}
return OSDCMD_OK;
}
static int osdcmd_give(CCmdFuncPtr parm)
{
int32_t i;
if (numplayers != 1 || (g_player[myconnectindex].ps->gm & MODE_GAME) == 0 ||
g_player[myconnectindex].ps->dead_flag != 0)
{
Printf("give: Cannot give while dead or not in a single-player game.\n");
return OSDCMD_OK;
}
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
cheatseq_t* cs = (cheatseq_t*)(intptr_t)1;
if (!Bstrcasecmp(parm->parms[0], "all"))
{
cheatStuff(cs);
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "health"))
{
sprite[g_player[myconnectindex].ps->i].extra = max_player_health<<1;
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "weapons"))
{
cheatWeapons(cs);
return OSDCMD_OK;
}
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, max_ammo_amount[i]);
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "armor"))
{
g_player[myconnectindex].ps->inv_amount[GET_SHIELD] = 100;
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "keys"))
{
cheatKeys(cs);
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "inventory"))
{
cheatInventory(cs);
return OSDCMD_OK;
}
return OSDCMD_SHOWHELP;
}
int32_t registerosdcommands(void)
{
C_RegisterFunction("map","map <mapname>: loads the given map", osdcmd_map);
C_RegisterFunction("levelwarp","levelwarp <e> <m>: warp to episode 'e' and map 'm'", osdcmd_levelwarp);
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
C_RegisterFunction("god","god: toggles god mode", osdcmd_god);
C_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat);
C_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
C_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap);
C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
return 0;
}
END_DUKE_NS