Netcode Overhaul
Rewrote netcode to be more stable and functional. Packet-server mode has been restrategized and will now be the default netmode when playing with 3+ non-LAN players. TryRunTics has been cleaned up with older tick control behavior removed to account for the rewritten renderer. The main thread is now more consistent when playing online to prevent potential slow downs and lock ups. Load barriers are better accounted for to prevent spikes on level transition. Improvements to chat and lobby systems including a force start game button. Added a suite of new host options such as kicking and controlling who can pause the game. Max players increased from 8 to 16 since the new code can now handle it. Note: Demo functionality is untested. This will be rewritten at a later time alongside improvements to GZDoom's playback features (e.g. freecam mode).
This commit is contained in:
parent
abfd91e8f1
commit
94be307225
45 changed files with 3119 additions and 2669 deletions
159
src/ct_chat.cpp
159
src/ct_chat.cpp
|
|
@ -55,6 +55,7 @@ enum
|
|||
EXTERN_CVAR (Bool, sb_cooperative_enable)
|
||||
EXTERN_CVAR (Bool, sb_deathmatch_enable)
|
||||
EXTERN_CVAR (Bool, sb_teamdeathmatch_enable)
|
||||
EXTERN_CVAR (Int, cl_showchat)
|
||||
|
||||
int active_con_scaletext();
|
||||
|
||||
|
|
@ -73,8 +74,16 @@ static void CT_BackSpace ();
|
|||
static void ShoveChatStr (const char *str, uint8_t who);
|
||||
static bool DoSubstitution (FString &out, const char *in);
|
||||
|
||||
static TArray<uint8_t> ChatQueue;
|
||||
constexpr int MessageLimit = 2; // Clamp the amount of messages you can send in a brief period
|
||||
constexpr uint64_t MessageThrottleTime = 1000u; // Time in ms that spam messages will be tracked.
|
||||
constexpr uint64_t SpamCoolDown = 3000u;
|
||||
|
||||
static TArray<uint8_t> ChatQueue;
|
||||
static uint64_t ChatThrottle = 0u;
|
||||
static int ChatSpamCount = 0;
|
||||
static uint64_t ChatCoolDown = 0u; // Spam limiter
|
||||
|
||||
CVAR (Int, net_chatslowmode, 0, CVAR_SERVERINFO | CVAR_NOSAVE)
|
||||
CVAR (String, chatmacro1, "I'm ready to kick butt!", CVAR_ARCHIVE)
|
||||
CVAR (String, chatmacro2, "I'm OK.", CVAR_ARCHIVE)
|
||||
CVAR (String, chatmacro3, "I'm not looking too good!", CVAR_ARCHIVE)
|
||||
|
|
@ -265,7 +274,7 @@ void CT_Drawer (void)
|
|||
}
|
||||
}
|
||||
|
||||
FStringf prompt("%s ", GStrings.GetString("TXT_SAY"));
|
||||
FStringf prompt("%s ", chatmodeon == 2 && deathmatch && teamplay ? GStrings.GetString("TXT_SAYTEAM") : GStrings.GetString("TXT_SAY"));
|
||||
int x, scalex, y, promptwidth;
|
||||
|
||||
y = (viewactive || gamestate != GS_LEVEL) ? -displayfont->GetHeight()-2 : -displayfont->GetHeight() - 22;
|
||||
|
|
@ -365,6 +374,24 @@ static void ShoveChatStr (const char *str, uint8_t who)
|
|||
if (str == NULL || str[0] == '\0')
|
||||
return;
|
||||
|
||||
if (netgame)
|
||||
{
|
||||
const uint64_t time = I_msTime();
|
||||
if (time >= ChatThrottle)
|
||||
{
|
||||
ChatSpamCount = 0;
|
||||
}
|
||||
else if (++ChatSpamCount >= MessageLimit)
|
||||
{
|
||||
ChatSpamCount = 0;
|
||||
ChatCoolDown = time + SpamCoolDown;
|
||||
}
|
||||
|
||||
ChatThrottle = time + MessageThrottleTime;
|
||||
if (net_chatslowmode > 0)
|
||||
ChatCoolDown = max<uint64_t>(time + net_chatslowmode * 1000, ChatCoolDown);
|
||||
}
|
||||
|
||||
FString substBuff;
|
||||
|
||||
if (str[0] == '/' &&
|
||||
|
|
@ -508,13 +535,40 @@ static bool DoSubstitution (FString &out, const char *in)
|
|||
|
||||
CCMD (messagemode)
|
||||
{
|
||||
if (menuactive == MENU_Off)
|
||||
if (menuactive != MENU_Off)
|
||||
return;
|
||||
|
||||
const uint64_t time = I_msTime();
|
||||
if (ChatCoolDown > time)
|
||||
{
|
||||
buttonMap.ResetButtonStates();
|
||||
chatmodeon = 1;
|
||||
C_HideConsole ();
|
||||
CT_ClearChatMessage ();
|
||||
Printf("You must wait %d more seconds before being able to chat again\n", int((ChatCoolDown - time) * 0.001));
|
||||
return;
|
||||
}
|
||||
|
||||
if (multiplayer && deathmatch)
|
||||
{
|
||||
if (cl_showchat < CHAT_GLOBAL)
|
||||
{
|
||||
Printf("Global chat is currently disabled\n");
|
||||
return;
|
||||
}
|
||||
|
||||
chatmodeon = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cl_showchat < CHAT_TEAM_ONLY)
|
||||
{
|
||||
Printf("Team chat is currently disabled\n");
|
||||
return;
|
||||
}
|
||||
|
||||
chatmodeon = 2;
|
||||
}
|
||||
|
||||
buttonMap.ResetButtonStates();
|
||||
C_HideConsole ();
|
||||
CT_ClearChatMessage ();
|
||||
}
|
||||
|
||||
CCMD (say)
|
||||
|
|
@ -522,22 +576,75 @@ CCMD (say)
|
|||
if (argv.argc() == 1)
|
||||
{
|
||||
Printf ("Usage: say <message>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint64_t time = I_msTime();
|
||||
if (ChatCoolDown > time)
|
||||
{
|
||||
Printf("You must wait %d more seconds before being able to chat again\n", int((ChatCoolDown - time) * 0.001));
|
||||
return;
|
||||
}
|
||||
|
||||
// If not in a DM lobby, route it to team chat instead (helps improve chat
|
||||
// filtering).
|
||||
if (multiplayer && deathmatch)
|
||||
{
|
||||
if (cl_showchat < CHAT_GLOBAL)
|
||||
{
|
||||
Printf("Global chat is currently disabled\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShoveChatStr(argv[1], 0);
|
||||
}
|
||||
}
|
||||
else if (cl_showchat < CHAT_TEAM_ONLY)
|
||||
{
|
||||
Printf("Team chat is currently disabled\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShoveChatStr (argv[1], 0);
|
||||
ShoveChatStr(argv[1], 1);
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (messagemode2)
|
||||
{
|
||||
if (menuactive == MENU_Off)
|
||||
if (menuactive != MENU_Off)
|
||||
return;
|
||||
|
||||
const uint64_t time = I_msTime();
|
||||
if (ChatCoolDown > time)
|
||||
{
|
||||
buttonMap.ResetButtonStates();
|
||||
chatmodeon = 2;
|
||||
C_HideConsole ();
|
||||
CT_ClearChatMessage ();
|
||||
Printf("You must wait %d more seconds before being able to chat again\n", int((ChatCoolDown - time) * 0.001));
|
||||
return;
|
||||
}
|
||||
|
||||
if (multiplayer && deathmatch && !teamplay)
|
||||
{
|
||||
if (cl_showchat < CHAT_GLOBAL)
|
||||
{
|
||||
Printf("Global chat is currently disabled\n");
|
||||
return;
|
||||
}
|
||||
|
||||
chatmodeon = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cl_showchat < CHAT_TEAM_ONLY)
|
||||
{
|
||||
Printf("Team chat is currently disabled\n");
|
||||
return;
|
||||
}
|
||||
|
||||
chatmodeon = 2;
|
||||
}
|
||||
|
||||
buttonMap.ResetButtonStates();
|
||||
C_HideConsole();
|
||||
CT_ClearChatMessage();
|
||||
}
|
||||
|
||||
CCMD (say_team)
|
||||
|
|
@ -545,6 +652,32 @@ CCMD (say_team)
|
|||
if (argv.argc() == 1)
|
||||
{
|
||||
Printf ("Usage: say_team <message>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint64_t time = I_msTime();
|
||||
if (ChatCoolDown > time)
|
||||
{
|
||||
Printf("You must wait %d more seconds before being able to chat again\n", int((ChatCoolDown - time) * 0.001));
|
||||
return;
|
||||
}
|
||||
|
||||
// If in a DM lobby, route it to global chat instead (helps
|
||||
// improve chat filtering).
|
||||
if (multiplayer && deathmatch && !teamplay)
|
||||
{
|
||||
if (cl_showchat < CHAT_GLOBAL)
|
||||
{
|
||||
Printf("Global chat is currently disabled\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShoveChatStr(argv[1], 0);
|
||||
}
|
||||
}
|
||||
else if (cl_showchat < CHAT_TEAM_ONLY)
|
||||
{
|
||||
Printf("Team chat is currently disabled\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue