mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-17 02:01:15 +00:00
Setup vote is a XCMD now
But now the rest of voting can get desynced easily now... this is increasingly getting more and more fucked.
This commit is contained in:
parent
116ef8065f
commit
58da420e30
4 changed files with 69 additions and 30 deletions
|
@ -46,6 +46,7 @@
|
|||
#include "m_cond.h"
|
||||
#include "m_anigif.h"
|
||||
#include "k_kart.h" // SRB2kart
|
||||
#include "y_inter.h"
|
||||
|
||||
#ifdef NETGAME_DEVMODE
|
||||
#define CV_RESTRICT CV_NETVAR
|
||||
|
@ -61,6 +62,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum);
|
|||
static void Got_WeaponPref(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Mapcmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum);
|
||||
#ifdef DELFILE
|
||||
static void Got_Delfilecmd(UINT8 **cp, INT32 playernum);
|
||||
|
@ -472,6 +474,7 @@ const char *netxcmdnames[MAXNETXCMD - 1] =
|
|||
"SETMOTD",
|
||||
"SUICIDE",
|
||||
"DEMOTED",
|
||||
"SETUPVOTE",
|
||||
#ifdef HAVE_BLUA
|
||||
"LUACMD",
|
||||
"LUAVAR"
|
||||
|
@ -501,6 +504,7 @@ void D_RegisterServerCommands(void)
|
|||
RegisterNetXCmd(XD_PAUSE, Got_Pause);
|
||||
RegisterNetXCmd(XD_SUICIDE, Got_Suicide);
|
||||
RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd);
|
||||
RegisterNetXCmd(XD_SETUPVOTE, Got_SetupVotecmd);
|
||||
#ifdef HAVE_BLUA
|
||||
RegisterNetXCmd(XD_LUACMD, Got_Luacmd);
|
||||
#endif
|
||||
|
@ -1942,6 +1946,38 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pultmode, boolean rese
|
|||
}
|
||||
}
|
||||
|
||||
void D_SetupVote(void)
|
||||
{
|
||||
XBOXSTATIC char buf[8];
|
||||
char *p;
|
||||
UINT16 maps[4];
|
||||
INT32 i;
|
||||
|
||||
p = buf;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
INT32 j;
|
||||
maps[i] = RandMap(G_TOLFlag(gametype), prevmap);
|
||||
|
||||
for (j = 0; j < 4; j++) // Compare with others to make sure you don't roll duplicates
|
||||
{
|
||||
INT32 loops = 0;
|
||||
if (j >= i)
|
||||
continue;
|
||||
while (maps[i] == maps[j] && loops < 4) // If this needs more than 4 loops, I think it's safe to assume it's not finding any suitable matches :V
|
||||
{
|
||||
maps[i] = RandMap(G_TOLFlag(gametype), prevmap);
|
||||
loops++;
|
||||
}
|
||||
}
|
||||
|
||||
WRITEUINT16(p, maps[i]);
|
||||
}
|
||||
|
||||
SendNetXCmd(XD_SETUPVOTE, buf, p - buf);
|
||||
}
|
||||
|
||||
// Warp to map code.
|
||||
// Called either from map <mapname> console command, or idclev cheat.
|
||||
//
|
||||
|
@ -4502,6 +4538,31 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum)
|
|||
G_ExitLevel();
|
||||
}
|
||||
|
||||
static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
if (playernum != serverplayer && !IsPlayerAdmin(playernum))
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]);
|
||||
if (server)
|
||||
{
|
||||
XBOXSTATIC UINT8 buf[2];
|
||||
|
||||
buf[0] = (UINT8)playernum;
|
||||
buf[1] = KICK_MSG_CON_FAIL;
|
||||
SendNetXCmd(XD_KICK, &buf, 2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
votelevels[i] = (INT16)READUINT16(*cp);
|
||||
|
||||
G_SetGamestate(GS_VOTING);
|
||||
Y_StartVote();
|
||||
}
|
||||
|
||||
/** Prints the number of the displayplayer.
|
||||
*
|
||||
* \todo Possibly remove this; it was useful for debugging at one point.
|
||||
|
|
|
@ -191,9 +191,10 @@ typedef enum
|
|||
XD_SETMOTD, // 19
|
||||
XD_SUICIDE, // 20
|
||||
XD_DEMOTED, // 21
|
||||
XD_SETUPVOTE, // 22
|
||||
#ifdef HAVE_BLUA
|
||||
XD_LUACMD, // 22
|
||||
XD_LUAVAR, // 23
|
||||
XD_LUACMD, // 23
|
||||
XD_LUAVAR, // 24
|
||||
#endif
|
||||
MAXNETXCMD
|
||||
} netxcmd_t;
|
||||
|
@ -248,6 +249,7 @@ void Command_ExitGame_f(void);
|
|||
void Command_Retry_f(void);
|
||||
void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore
|
||||
void D_MapChange(INT32 pmapnum, INT32 pgametype, boolean pultmode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pfromlevelselect);
|
||||
void D_SetupVote(void);
|
||||
void ObjectPlace_OnChange(void);
|
||||
boolean IsPlayerAdmin(INT32 playernum);
|
||||
void SetAdminPlayer(INT32 playernum);
|
||||
|
|
31
src/g_game.c
31
src/g_game.c
|
@ -3089,7 +3089,7 @@ INT16 G_TOLFlag(INT32 pgametype)
|
|||
* has those flags.
|
||||
* \author Graue <graue@oceanbase.org>
|
||||
*/
|
||||
static INT16 RandMap(INT16 tolflags, INT16 pprevmap)
|
||||
INT16 RandMap(INT16 tolflags, INT16 pprevmap)
|
||||
{
|
||||
INT16 *okmaps = Z_Malloc(NUMMAPS * sizeof(INT16), PU_STATIC, NULL);
|
||||
INT32 numokmaps = 0;
|
||||
|
@ -3239,28 +3239,6 @@ static void G_DoCompleted(void)
|
|||
nextmap = prevmap;
|
||||
else if (cv_advancemap.value == 2) // Go to random map.
|
||||
nextmap = RandMap(G_TOLFlag(gametype), prevmap);
|
||||
else if (cv_advancemap.value == 3)
|
||||
{
|
||||
INT32 j;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
INT32 k;
|
||||
votelevels[j] = RandMap(G_TOLFlag(gametype), prevmap);
|
||||
for (k = 0; k < 4; k++) // Compare with others to make sure you don't roll multiple :V
|
||||
{
|
||||
INT32 loopcount = 0;
|
||||
if (j == k)
|
||||
continue;
|
||||
while (votelevels[j] == votelevels[k] && loopcount < 4) // If this needs more than 4 loops, I think it's safe to assume it's not finding anything :VVV
|
||||
{
|
||||
votelevels[j] = RandMap(G_TOLFlag(gametype), prevmap);
|
||||
loopcount++;
|
||||
}
|
||||
}
|
||||
if (votelevels[j] < NUMMAPS && !mapheaderinfo[votelevels[j]])
|
||||
P_AllocMapHeader(votelevels[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We are committed to this map now.
|
||||
|
@ -3385,11 +3363,8 @@ static void G_DoContinued(void)
|
|||
//
|
||||
static void G_DoStartVote(void)
|
||||
{
|
||||
I_Assert(netgame || multiplayer);
|
||||
|
||||
G_SetGamestate(GS_VOTING);
|
||||
Y_StartVote();
|
||||
|
||||
if (server)
|
||||
D_SetupVote();
|
||||
gameaction = ga_nothing;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,5 +219,6 @@ FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics);
|
|||
|
||||
// Don't split up TOL handling
|
||||
INT16 G_TOLFlag(INT32 pgametype);
|
||||
INT16 RandMap(INT16 tolflags, INT16 pprevmap);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue