mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-04 04:36:21 +00:00
Refactor XD_GIVEITEM into CHEAT_GIVEITEM
This commit is contained in:
parent
1300ec5d56
commit
8893666b53
3 changed files with 41 additions and 48 deletions
|
|
@ -83,7 +83,6 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum);
|
|||
static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_PickVotecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_GiveItemcmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Pause(UINT8 **cp, INT32 playernum);
|
||||
|
|
@ -619,14 +618,13 @@ const char *netxcmdnames[MAXNETXCMD - 1] =
|
|||
"ACCEPTPARTYINVITE", // XD_ACCEPTPARTYINVITE
|
||||
"LEAVEPARTY", // XD_LEAVEPARTY
|
||||
"CANCELPARTYINVITE", // XD_CANCELPARTYINVITE
|
||||
"GIVEITEM", // XD_GIVEITEM
|
||||
"CHEAT", // XD_CHEAT
|
||||
"ADDBOT", // XD_ADDBOT
|
||||
"DISCORD", // XD_DISCORD
|
||||
"PLAYSOUND", // XD_PLAYSOUND
|
||||
"SCHEDULETASK", // XD_SCHEDULETASK
|
||||
"SCHEDULECLEAR", // XD_SCHEDULECLEAR
|
||||
"AUTOMATE", // XD_AUTOMATE
|
||||
"CHEAT", // XD_CHEAT
|
||||
};
|
||||
|
||||
// =========================================================================
|
||||
|
|
@ -673,8 +671,6 @@ void D_RegisterServerCommands(void)
|
|||
RegisterNetXCmd(XD_MODIFYVOTE, Got_ModifyVotecmd);
|
||||
RegisterNetXCmd(XD_PICKVOTE, Got_PickVotecmd);
|
||||
|
||||
RegisterNetXCmd(XD_GIVEITEM, Got_GiveItemcmd);
|
||||
|
||||
RegisterNetXCmd(XD_SCHEDULETASK, Got_ScheduleTaskcmd);
|
||||
RegisterNetXCmd(XD_SCHEDULECLEAR, Got_ScheduleClearcmd);
|
||||
RegisterNetXCmd(XD_AUTOMATE, Got_Automatecmd);
|
||||
|
|
@ -2068,6 +2064,11 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...)
|
|||
case CHEAT_DEVMODE:
|
||||
COPY(WRITEUINT32, UINT32);
|
||||
break;
|
||||
|
||||
case CHEAT_GIVEITEM:
|
||||
COPY(WRITESINT8, int);
|
||||
COPY(WRITEUINT8, unsigned int);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef COPY
|
||||
|
|
@ -5388,41 +5389,6 @@ static void Got_PickVotecmd(UINT8 **cp, INT32 playernum)
|
|||
Y_SetupVoteFinish(pick, level);
|
||||
}
|
||||
|
||||
static void Got_GiveItemcmd(UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
int item;
|
||||
int amt;
|
||||
|
||||
item = READSINT8 (*cp);
|
||||
amt = READUINT8 (*cp);
|
||||
|
||||
if (
|
||||
( !CV_CheatsEnabled() ) ||
|
||||
( item < KITEM_SAD || item >= NUMKARTITEMS )
|
||||
)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING,
|
||||
M_GetText ("Illegal give item received from %s\n"),
|
||||
player_names[playernum]);
|
||||
if (server)
|
||||
SendKick(playernum, KICK_MSG_CON_FAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
K_StripItems(&players[playernum]);
|
||||
players[playernum].itemroulette = 0;
|
||||
|
||||
players[playernum].itemtype = item;
|
||||
players[playernum].itemamount = amt;
|
||||
|
||||
CV_CheaterWarning(
|
||||
playernum,
|
||||
(amt != 1) // FIXME: we should have actual KITEM_ name array
|
||||
? va("kartgiveitem %s %d", cv_kartdebugitem.PossibleValue[item+1].strvalue, amt)
|
||||
: va("kartgiveitem %s", cv_kartdebugitem.PossibleValue[item+1].strvalue)
|
||||
);
|
||||
}
|
||||
|
||||
static void Got_ScheduleTaskcmd(UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
char command[MAXTEXTCMD];
|
||||
|
|
@ -5682,6 +5648,35 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum)
|
|||
break;
|
||||
}
|
||||
|
||||
case CHEAT_GIVEITEM: {
|
||||
SINT8 item = READSINT8(*cp);
|
||||
UINT8 amt = READUINT8(*cp);
|
||||
|
||||
item = max(item, KITEM_SAD);
|
||||
item = min(item, NUMKARTITEMS - 1);
|
||||
|
||||
K_StripItems(player);
|
||||
|
||||
// Cancel roulette if rolling
|
||||
player->itemroulette = 0;
|
||||
|
||||
player->itemtype = item;
|
||||
player->itemamount = amt;
|
||||
|
||||
if (amt == 0)
|
||||
{
|
||||
CV_CheaterWarning(playernum, "delete my items");
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: we should have actual KITEM_ name array
|
||||
const char *itemname = cv_kartdebugitem.PossibleValue[1 + item].strvalue;
|
||||
|
||||
CV_CheaterWarning(playernum, va("give item %s x%d", itemname, amt));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NUMBER_OF_CHEATS:
|
||||
break;
|
||||
}
|
||||
|
|
@ -5843,8 +5838,6 @@ static void Command_Archivetest_f(void)
|
|||
*/
|
||||
static void Command_KartGiveItem_f(void)
|
||||
{
|
||||
char buf[2];
|
||||
|
||||
int ac;
|
||||
const char *name;
|
||||
int item;
|
||||
|
|
@ -5886,14 +5879,14 @@ static void Command_KartGiveItem_f(void)
|
|||
|
||||
if (item < NUMKARTITEMS)
|
||||
{
|
||||
buf[0] = item;
|
||||
INT32 amt;
|
||||
|
||||
if (ac > 2)
|
||||
buf[1] = atoi(COM_Argv(2));
|
||||
amt = atoi(COM_Argv(2));
|
||||
else
|
||||
buf[1] = 1;/* default to one quantity */
|
||||
amt = 1;/* default to one quantity */
|
||||
|
||||
SendNetXCmd(XD_GIVEITEM, buf, 2);
|
||||
D_Cheat(consoleplayer, CHEAT_GIVEITEM, item, amt);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -196,14 +196,13 @@ typedef enum
|
|||
XD_ACCEPTPARTYINVITE, // 29
|
||||
XD_LEAVEPARTY, // 30
|
||||
XD_CANCELPARTYINVITE, // 31
|
||||
XD_GIVEITEM, // 32
|
||||
XD_CHEAT, // 32
|
||||
XD_ADDBOT, // 33
|
||||
XD_DISCORD, // 34
|
||||
XD_PLAYSOUND, // 35
|
||||
XD_SCHEDULETASK, // 36
|
||||
XD_SCHEDULECLEAR, // 37
|
||||
XD_AUTOMATE, // 38
|
||||
XD_CHEAT, // 39
|
||||
|
||||
MAXNETXCMD
|
||||
} netxcmd_t;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ typedef enum {
|
|||
CHEAT_HURT,
|
||||
CHEAT_RELATIVE_TELEPORT,
|
||||
CHEAT_DEVMODE,
|
||||
CHEAT_GIVEITEM,
|
||||
|
||||
NUMBER_OF_CHEATS
|
||||
} cheat_t;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue