Skip to content

Commit

Permalink
Fixed bug#1786091 - Crash when using the "give" cheat when not in-game.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij committed Dec 1, 2007
1 parent 31dce51 commit 9843c22
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
13 changes: 12 additions & 1 deletion doomsday/plugins/doom64tc/src/m_cheat.c
Expand Up @@ -721,13 +721,24 @@ DEFCC(CCmdCheatGive)
Con_Printf("Example: 'give arw' corresponds the cheat IDFA.\n");
return true;
}

if(argc == 3)
{
i = atoi(argv[2]);
if(i < 0 || i >= MAXPLAYERS || !players[i].plr->ingame)
if(i < 0 || i >= MAXPLAYERS)
return false;
plyr = &players[i];
}

if(G_GetGameState() != GS_LEVEL)
{
Con_Printf("Can only \"give\" when in a game!\n");
return true;
}

if(!plyr->plr->ingame)
return; // Can't give to a player who's not playing

strcpy(buf, argv[1]); // Stuff is the 2nd arg.
strlwr(buf);
for(i = 0; buf[i]; i++)
Expand Down
12 changes: 11 additions & 1 deletion doomsday/plugins/jdoom/src/m_cheat.c
Expand Up @@ -703,10 +703,20 @@ DEFCC(CCmdCheatGive)
if(argc == 3)
{
i = atoi(argv[2]);
if(i < 0 || i >= MAXPLAYERS || !players[i].plr->ingame)
if(i < 0 || i >= MAXPLAYERS)
return false;
plyr = &players[i];
}

if(G_GetGameState() != GS_LEVEL)
{
Con_Printf("Can only \"give\" when in a game!\n");
return true;
}

if(!plyr->plr->ingame)
return; // Can't give to a player who's not playing

strcpy(buf, argv[1]); // Stuff is the 2nd arg.
strlwr(buf);
for(i = 0; buf[i]; i++)
Expand Down
12 changes: 11 additions & 1 deletion doomsday/plugins/jheretic/src/m_cheat.c
Expand Up @@ -817,9 +817,19 @@ DEFCC(CCmdCheatGive)
if(argc == 3)
{
target = atoi(argv[2]);
if(target < 0 || target >= MAXPLAYERS || !players[target].plr->ingame)
if(target < 0 || target >= MAXPLAYERS)
return false;
}

if(G_GetGameState() != GS_LEVEL)
{
Con_Printf("Can only \"give\" when in a game!\n");
return true;
}

if(!players[target].plr->ingame)
return; // Can't give to a player who's not playing

if(argc != 2 && argc != 3)
tellUsage = true;
else if(!strnicmp(argv[1], "weapons", 1))
Expand Down
13 changes: 12 additions & 1 deletion doomsday/plugins/jhexen/src/m_cheat.c
Expand Up @@ -1149,13 +1149,24 @@ DEFCC(CCmdCheatGive)
Con_Printf(" 0-4 - weapon\n");
return true;
}

if(argc == 3)
{
i = atoi(argv[2]);
if(i < 0 || i >= MAXPLAYERS || !players[i].plr->ingame)
if(i < 0 || i >= MAXPLAYERS)
return false;
plyr = &players[i];
}

if(G_GetGameState() != GS_LEVEL)
{
Con_Printf("Can only \"give\" when in a game!\n");
return true;
}

if(!plyr->plr->ingame)
return; // Can't give to a player who's not playing

strcpy(buf, argv[1]); // Stuff is the 2nd arg.
strlwr(buf);
for(i = 0; buf[i]; i++)
Expand Down
13 changes: 12 additions & 1 deletion doomsday/plugins/wolftc/src/m_cheat.c
Expand Up @@ -693,13 +693,24 @@ DEFCC(CCmdCheatGive)
Con_Printf("Example: 'give arw' corresponds the cheat IDFA.\n");
return true;
}

if(argc == 3)
{
i = atoi(argv[2]);
if(i < 0 || i >= MAXPLAYERS || !players[i].plr->ingame)
if(i < 0 || i >= MAXPLAYERS)
return false;
plyr = &players[i];
}

if(G_GetGameState() != GS_LEVEL)
{
Con_Printf("Can only \"give\" when in a game!\n");
return true;
}

if(!plyr->plr->ingame)
return; // Can't give to a player who's not playing

strcpy(buf, argv[1]); // Stuff is the 2nd arg.
strlwr(buf);
for(i = 0; buf[i]; i++)
Expand Down

0 comments on commit 9843c22

Please sign in to comment.