diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7038619ec..3eed80064 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4129,6 +4129,7 @@ static void Handle_MapQueueSend(UINT16 newmapnum, UINT8 newgametype, boolean new static char *buf_p = buf; UINT8 flags = 0; + boolean doclear = (newgametype == ROUNDQUEUE_CLEAR); CONS_Debug(DBG_GAMELOGIC, "Map queue: mapnum=%d newgametype=%d newencoremode=%d\n", newmapnum, newgametype, newencoremode); @@ -4149,9 +4150,16 @@ static void Handle_MapQueueSend(UINT16 newmapnum, UINT8 newgametype, boolean new } WRITEUINT8(buf_p, roundqueue.size); - SendNetXCmd(XD_MAPQUEUE, buf, buf_p - buf); + if (doclear == true) + { + memset(&roundqueue, 0, sizeof(struct roundqueue)); + } + else + { + G_MapIntoRoundQueue(newmapnum, newgametype, newencoremode, false); + } - G_MapIntoRoundQueue(newmapnum, newgametype, newencoremode, false); + SendNetXCmd(XD_MAPQUEUE, buf, buf_p - buf); } static void Command_QueueMap_f(void) @@ -4160,6 +4168,7 @@ static void Command_QueueMap_f(void) size_t option_force; size_t option_gametype; size_t option_encore; + size_t option_clear; boolean usingcheats; boolean ischeating; @@ -4184,6 +4193,29 @@ static void Command_QueueMap_f(void) return; } + usingcheats = CV_CheatsEnabled(); + ischeating = (!(netgame || multiplayer) || !K_CanChangeRules(false)); + + option_clear = COM_CheckParm("-clear"); + + if (option_clear) + { + if (ischeating && !usingcheats) + { + CONS_Printf(M_GetText("Cheats must be enabled.\n")); + return; + } + + if (roundqueue.size == 0) + { + CONS_Printf(M_GetText("Round queue is already empty!\n")); + return; + } + + Handle_MapQueueSend(0, ROUNDQUEUE_CLEAR, false); + return; + } + if (roundqueue.size >= ROUNDQUEUE_MAX) { CONS_Printf(M_GetText("Round queue is currently full.\n")); @@ -4194,16 +4226,13 @@ static void Command_QueueMap_f(void) option_gametype = COM_CheckPartialParm("-g"); option_encore = COM_CheckPartialParm("-e"); - usingcheats = CV_CheatsEnabled(); - ischeating = (!(netgame || multiplayer)); - if (!( first_option = COM_FirstOption() )) first_option = COM_Argc(); if (first_option < 2) { /* I'm going over the fucking lines and I DON'T CAREEEEE */ - CONS_Printf("queuemap [-gametype ] [-force]:\n"); + CONS_Printf("queuemap [-gametype ] [-force] / [-clear]:\n"); CONS_Printf(M_GetText( "Queue up a map by its name, or by its number (though why would you).\n" "All parameters are case-insensitive and may be abbreviated.\n")); @@ -4221,7 +4250,7 @@ static void Command_QueueMap_f(void) return; } - if (!K_CanChangeRules(false) || (/*newmapnum != 1 &&*/ M_MapLocked(newmapnum))) + if ((/*newmapnum != 1 &&*/ M_MapLocked(newmapnum))) { ischeating = true; } @@ -4292,6 +4321,7 @@ static void Got_RequestMapQueuecmd(UINT8 **cp, INT32 playernum) UINT8 flags, setgametype; boolean setencore; UINT16 mapnumber; + boolean doclear = false; flags = READUINT8(*cp); @@ -4310,6 +4340,17 @@ static void Got_RequestMapQueuecmd(UINT8 **cp, INT32 playernum) } if (roundqueue.size >= ROUNDQUEUE_MAX) + doclear = (setgametype == ROUNDQUEUE_CLEAR); + + if (doclear == true) + { + if (roundqueue.size == 0) + { + CONS_Alert(CONS_ERROR, "queuemap: Queue is already empty!\n"); + return; + } + } + else if (roundqueue.size >= ROUNDQUEUE_MAX) { CONS_Alert(CONS_ERROR, "queuemap: Unable to add map beyond %u\n", roundqueue.size); return; @@ -4325,6 +4366,7 @@ static void Got_MapQueuecmd(UINT8 **cp, INT32 playernum) { UINT8 flags, setgametype, queueposition; boolean setencore; + boolean doclear = false; flags = READUINT8(*cp); @@ -4342,7 +4384,9 @@ static void Got_MapQueuecmd(UINT8 **cp, INT32 playernum) return; } - if (queueposition >= ROUNDQUEUE_MAX) + doclear = (setgametype == ROUNDQUEUE_CLEAR); + + if (doclear == false && queueposition >= ROUNDQUEUE_MAX) { CONS_Alert(CONS_ERROR, "queuemap: Unable to add map beyond %u\n", roundqueue.size); return; @@ -4351,18 +4395,28 @@ static void Got_MapQueuecmd(UINT8 **cp, INT32 playernum) if (server) return; - while (roundqueue.size <= queueposition) + if (doclear == true) { - memset(&roundqueue.entries[roundqueue.size], 0, sizeof(roundentry_t)); - roundqueue.size++; + memset(&roundqueue, 0, sizeof(struct roundqueue)); } + else + { + while (roundqueue.size <= queueposition) + { + memset(&roundqueue.entries[roundqueue.size], 0, sizeof(roundentry_t)); + roundqueue.size++; + } - G_MapSlipIntoRoundQueue(queueposition, 0, setgametype, setencore, false); + G_MapSlipIntoRoundQueue(queueposition, 0, setgametype, setencore, false); + } if (!IsPlayerAdmin(playernum)) return; - CONS_Printf("queuemap: A map was successfully added to the round queue (position %u)\n", queueposition); + if (doclear) + CONS_Printf("queuemap: The round queue was cleared.\n"); + else + CONS_Printf("queuemap: A map was added to the round queue (pos. %u)\n", queueposition+1); } static void Command_Pause(void) diff --git a/src/g_game.h b/src/g_game.h index ab6d73653..c8177c91f 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -54,6 +54,7 @@ typedef enum } nextmapspecial_t; #define ROUNDQUEUE_MAX 10 // sane max? maybe make dynamically allocated later +#define ROUNDQUEUE_CLEAR UINT16_MAX // lives in gametype field of packets struct roundentry_t {