diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c7d10f46d..84b46fe4d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1444,8 +1444,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_connectawaittime); CV_RegisterVar(&cv_serverinfoscreen); - + // player restat + CV_RegisterVar(&cv_allowrestat); COM_AddCommand("restat", Command_Restat); COM_AddCommand("restat2", Command_Restat2); COM_AddCommand("restat3", Command_Restat3); @@ -1458,48 +1459,13 @@ static void RestatForPlayer(UINT32 ssplayer) int speed; int weight; - if (!cv_restat_allow.value) + if (!cv_allowrestat.value) { - CONS_Printf("This command has been disabled by the server host."); + CONS_Printf("This command has been disabled by the server host.\n"); return; } - if (COM_Argc() > 1) - { - if (fasticmp(COM_Argv(1), "random")) - { - player->randomrestat = !player->randomrestat; - if (player->randomrestat) - { - CONS_Printf("Random restat is now enabled."); - player->kartspeedrestat = 0; - player->kartweightrestat = 0; - } - else - { - CONS_Printf("Random restat is now disabled."); - } - - WeaponPref_Send(ssplayer); - return; - } - else if (fasticmp(COM_Argv(1), "off")) - { - player->kartspeedrestat = 0; - player->kartweightrestat = 0; - player->randomrestat = false; - WeaponPref_Send(ssplayer); - return; - } - else - { - CONS_Printf( - "Usage: \"restat \"\n" - "Alternatively: \"restat random\" to toggle using random stats each round.\n" - "or \"restat off\" to use your skin's default stats.\n"); - } - } - else if (COM_Argc() > 2) + if (COM_Argc() > 2) { if (sscanf(COM_Argv(1), " %d", &speed) == 0 || sscanf(COM_Argv(2), " %d", &weight) == 0) @@ -1520,12 +1486,47 @@ static void RestatForPlayer(UINT32 ssplayer) player->kartweightrestat = weight; player->randomrestat = false; - CONS_Printf("You will be \130 %d speed, %d weight\140 for the next race.", speed, weight); - CONS_Printf("Use \135restat off\140 to return to your skin's default stats."); + CONS_Printf("You will be %d speed, %d weight for the next race.\n", speed, weight); + CONS_Printf("Use \"restat off\" to return to your skin's default stats.\n"); WeaponPref_Send(ssplayer); return; } + else if (COM_Argc() > 1) + { + if (fasticmp(COM_Argv(1), "random")) + { + player->randomrestat = !player->randomrestat; + if (player->randomrestat) + { + CONS_Printf("Random restat is now enabled.\n"); + } + else + { + CONS_Printf("Random restat is now disabled.\n"); + } + + WeaponPref_Send(ssplayer); + return; + } + else if (fasticmp(COM_Argv(1), "off")) + { + player->kartspeedrestat = 0; + player->kartweightrestat = 0; + player->randomrestat = false; + WeaponPref_Send(ssplayer); + + CONS_Printf("Now using skin default stats.\n"); + return; + } + else + { + CONS_Printf( + "Usage: \"restat \"\n" + "Alternatively: \"restat random\" to toggle the use of random stats each round.\n" + "or \"restat off\" to use your skin's default stats.\n"); + } + } else { CONS_Printf( diff --git a/src/g_game.c b/src/g_game.c index c1ae55bc7..2dfce20f6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -494,7 +494,7 @@ consvar_t cv_deadzonestyle[MAXSPLITSCREENPLAYERS] = { }; // allows players to use restat (server toggle) -consvar_t cv_restat_allow = CVAR_INIT ("restat_allow", "Yes", CV_NETVAR, CV_YesNo, NULL); +consvar_t cv_allowrestat = CVAR_INIT ("allowrestat", "Yes", CV_NETVAR, CV_YesNo, NULL); // now automatically allocated in D_RegisterClientCommands // so that it doesn't have to be updated depending on the value of MAXPLAYERS @@ -2739,6 +2739,9 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) UINT8 kartspeed; UINT8 kartweight; + UINT8 kartspeedrestat; + UINT8 kartweightrestat; + boolean randomrestat; boolean followerready; INT32 followerskin; @@ -2836,6 +2839,10 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) kartspeed = players[player].kartspeed; kartweight = players[player].kartweight; + kartspeedrestat = players[player].kartspeedrestat; + kartweightrestat = players[player].kartweightrestat; + randomrestat = players[player].randomrestat; + followerready = players[player].followerready; followercolor = players[player].followercolor; followerskin = players[player].followerskin; @@ -2902,16 +2909,24 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) laptime[i] = 0; } - if (players[player].randomrestat) + // might cause issues with weponpref sync? + if (!cv_allowrestat.value) { - kartspeed = P_RandomRange(1, 9); - kartweight = P_RandomRange(1, 9); + kartspeedrestat = 0; + kartweightrestat = 0; + randomrestat = false; } - else if (players[player].kartspeedrestat != 0 && - players[player].kartweightrestat != 0) + + if (randomrestat) { - kartspeed = players[player].kartspeedrestat; - kartweight = players[player].kartweightrestat; + kartspeedrestat = P_RandomRange(1, 9); + kartweightrestat = P_RandomRange(1, 9); + } + + if (kartspeedrestat != 0 && kartweightrestat != 0) + { + kartspeed = kartspeedrestat; + kartweight = kartweightrestat; } else { @@ -3041,6 +3056,10 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) p->voice_id = voice; p->kartspeed = kartspeed; p->kartweight = kartweight; + + p->kartspeedrestat = kartspeedrestat; + p->kartweightrestat = kartweightrestat; + p->randomrestat = randomrestat; // p->charflags = charflags; memcpy(players[player].availabilities, availabilities, sizeof(availabilities)); diff --git a/src/g_game.h b/src/g_game.h index 17f093a10..27244a282 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -96,7 +96,7 @@ extern consvar_t cv_resetspecialmusic; extern consvar_t cv_resume; -extern consvar_t cv_restat_allow; +extern consvar_t cv_allowrestat; void weaponPrefChange(void); void weaponPrefChange2(void);