Skip to content

Commit

Permalink
Fixed "where" ccmd in jHeretic. Plus implemented it in jDoom.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij committed Aug 18, 2006
1 parent 6ebb9a6 commit 46abde3
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 8 deletions.
2 changes: 2 additions & 0 deletions doomsday/plugins/jdoom/src/d_console.c
Expand Up @@ -39,6 +39,7 @@ DEFCC(CCmdCheatWarp);
DEFCC(CCmdCheatReveal);
DEFCC(CCmdCheatGive);
DEFCC(CCmdCheatMassacre);
DEFCC(CCmdCheatWhere);
DEFCC(CCmdCheatExitLevel);
DEFCC(CCmdCheatSuicide);

Expand Down Expand Up @@ -200,6 +201,7 @@ ccmd_t gameCCmds[] = {
{"kill", CCmdCheatMassacre},
{"exitlevel", CCmdCheatExitLevel},
{"suicide", CCmdCheatSuicide},
{"where", CCmdCheatWhere},

{"doomfont", CCmdDoomFont},

Expand Down
37 changes: 37 additions & 0 deletions doomsday/plugins/jdoom/src/m_cheat.c
Expand Up @@ -492,6 +492,35 @@ void cht_PosFunc(player_t *plyr)
P_SetMessage(plyr, buf);
}

static void CheatDebugFunc(player_t *player, cheat_t * cheat)
{
char lumpName[9];
char textBuffer[256];
subsector_t *sub;

if(!player->plr->mo || !usergame)
return;

P_GetMapLumpName(gameepisode, gamemap, lumpName);
sprintf(textBuffer, "MAP [%s] X:%5d Y:%5d Z:%5d",
lumpName,
player->plr->mo->pos[VX] >> FRACBITS,
player->plr->mo->pos[VY] >> FRACBITS,
player->plr->mo->pos[VZ] >> FRACBITS);
P_SetMessage(player, textBuffer);

// Also print some information to the console.
Con_Message(textBuffer);
sub = player->plr->mo->subsector;
Con_Message("\nSubsector %i:\n", P_ToIndex(sub));
Con_Message(" Floorz:%d pic:%d\n", P_GetIntp(sub, DMU_FLOOR_HEIGHT),
P_GetIntp(sub, DMU_FLOOR_TEXTURE));
Con_Message(" Ceilingz:%d pic:%d\n", P_GetIntp(sub, DMU_CEILING_HEIGHT),
P_GetIntp(sub, DMU_CEILING_TEXTURE));
Con_Message("Player height:%x Player radius:%x\n",
player->plr->mo->height, player->plr->mo->radius);
}

/*
* This is the multipurpose cheat ccmd.
*/
Expand Down Expand Up @@ -759,6 +788,14 @@ DEFCC(CCmdCheatMassacre)
return true;
}

DEFCC(CCmdCheatWhere)
{
if(!can_cheat())
return false; // Can't cheat!
CheatDebugFunc(players + consoleplayer, NULL);
return true;
}

/*
* Exit the current level and goto the intermission.
*/
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/src/h_console.c
Expand Up @@ -182,6 +182,7 @@ ccmd_t gameCCmds[] = {
{"kill", CCmdCheatMassacre},
{"exitlevel", CCmdCheatExitLevel},
{"suicide", CCmdCheatSuicide},
{"where", CCmdCheatWhere},

{"hereticfont",CCmdHereticFont},

Expand All @@ -203,7 +204,6 @@ ccmd_t gameCCmds[] = {
{"invleft", CCmdInventory},
{"invright", CCmdInventory},
{"chicken", CCmdCheatPig},
{"where", CCmdCheatWhere},
{NULL}
};

Expand Down
34 changes: 32 additions & 2 deletions doomsday/plugins/jheretic/src/m_cheat.c
Expand Up @@ -692,6 +692,35 @@ static void CheatIDDQDFunc(player_t *player, Cheat_t * cheat)
P_SetMessage(player, TXT_CHEATIDDQD);
}

static void CheatDebugFunc(player_t *player, cheat_t * cheat)
{
char lumpName[9];
char textBuffer[256];
subsector_t *sub;

if(!player->plr->mo || !usergame)
return;

P_GetMapLumpName(gameepisode, gamemap, lumpName);
sprintf(textBuffer, "MAP [%s] X:%5d Y:%5d Z:%5d",
lumpName,
player->plr->mo->pos[VX] >> FRACBITS,
player->plr->mo->pos[VY] >> FRACBITS,
player->plr->mo->pos[VZ] >> FRACBITS);
P_SetMessage(player, textBuffer);

// Also print some information to the console.
Con_Message(textBuffer);
sub = player->plr->mo->subsector;
Con_Message("\nSubsector %i:\n", P_ToIndex(sub));
Con_Message(" Floorz:%d pic:%d\n", P_GetIntp(sub, DMU_FLOOR_HEIGHT),
P_GetIntp(sub, DMU_FLOOR_TEXTURE));
Con_Message(" Ceilingz:%d pic:%d\n", P_GetIntp(sub, DMU_CEILING_HEIGHT),
P_GetIntp(sub, DMU_CEILING_TEXTURE));
Con_Message("Player height:%x Player radius:%x\n",
player->plr->mo->height, player->plr->mo->radius);
}

// This is the multipurpose cheat ccmd.
DEFCC(CCmdCheat)
{
Expand Down Expand Up @@ -887,8 +916,9 @@ DEFCC(CCmdCheatMassacre)

DEFCC(CCmdCheatWhere)
{
/* if(!canCheat()) return false; // Can't cheat!
CheatDebugFunc(players+consoleplayer, NULL); */
if(!canCheat())
return false; // Can't cheat!
CheatDebugFunc(players+consoleplayer, NULL);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jhexen/src/hconsole.c
Expand Up @@ -174,6 +174,7 @@ ccmd_t gameCCmds[] = {
{"give", CCmdCheatGive},
{"kill", CCmdCheatMassacre},
{"suicide", CCmdCheatSuicide},
{"where", CCmdCheatWhere},

{"hexenfont", CCmdHexenFont},

Expand All @@ -197,7 +198,6 @@ ccmd_t gameCCmds[] = {
{"pig", CCmdCheatPig},
{"runscript", CCmdCheatRunScript},
{"scriptinfo", CCmdScriptInfo},
{"where", CCmdCheatWhere},
{"class", CCmdCheatShadowcaster},
#ifdef DEMOCAM
{"demomode", CCmdSetDemoMode},
Expand Down
11 changes: 7 additions & 4 deletions doomsday/plugins/jhexen/src/m_cheat.c
Expand Up @@ -926,14 +926,16 @@ static void CheatVersionFunc(player_t *player, cheat_t * cheat)

static void CheatDebugFunc(player_t *player, cheat_t * cheat)
{
char lumpName[9];
char textBuffer[256];
subsector_t *sub;

if(!player->plr->mo)
if(!player->plr->mo || !usergame)
return;

sprintf(textBuffer, "MAP %d (%d) X:%5d Y:%5d Z:%5d",
P_GetMapWarpTrans(gamemap), gamemap,
P_GetMapLumpName(gameepisode, gamemap, lumpName);
sprintf(textBuffer, "MAP [%s] X:%5d Y:%5d Z:%5d",
lumpName,
player->plr->mo->pos[VX] >> FRACBITS,
player->plr->mo->pos[VY] >> FRACBITS,
player->plr->mo->pos[VZ] >> FRACBITS);
Expand Down Expand Up @@ -1258,7 +1260,8 @@ DEFCC(CCmdCheatShadowcaster)

DEFCC(CCmdCheatWhere)
{
//if(!canCheat()) return false; // Can't cheat!
if(!canCheat())
return false; // Can't cheat!
CheatDebugFunc(players + consoleplayer, NULL);
return true;
}
Expand Down

0 comments on commit 46abde3

Please sign in to comment.