implement allowing to load addons and gamestate only instead of joining server

really messy, needs some cleanup, not sure if this is good at all
This commit is contained in:
Alug committed 2026-01-27 18:06:22 +01:00
1 parent c4581bd9a6
commit 3e476d7658
3 files changed
+99 -30

No files matched your search

+45 -17
View File
@@ -100,6 +100,10 @@ static int map_icon_request_count; // current count of icon requests sent
static UINT8 *map_icon_data;
static patch_t *map_icon;
// if true, signals the game to only load addons AND gamestate
// instead of fully joining a server
boolean addonsonly = false;
plrinfo playerinfo[MAXPLAYERS] = {};
SINT8 joinnode = 0; // used for CL_VIEWSERVER
@@ -1438,6 +1442,7 @@ static void CL_DrawConnectionStatus(void)
// Buttons
V_DrawFill(8, BASEVIDHEIGHT - 14, BASEVIDWIDTH - 16, 12, 239);
V_DrawThinString(16, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sESC%s] = Abort", "\x82", "\x80"));
V_DrawCenteredThinString(BASEVIDWIDTH/2, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sSPACE%s] = Load Addons", "\x82", "\x80"));
V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sENTER%s] = Join", "\x82", "\x80"));
}
else if (filedownload.current != -1)
@@ -2579,7 +2584,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
return true;
}
cl_mode = (cv_serverinfoscreen.value) ? CL_VIEWSERVER : CL_CHECKFILES;
cl_mode = (cv_serverinfoscreen.value && !addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES;
}
else
{
@@ -2600,6 +2605,17 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
return true;
}
static void FreeMapIcon(void)
{
if (map_icon != NULL)
Patch_Free(map_icon);
map_icon = NULL;
if (map_icon_data != NULL)
Z_Free(map_icon_data);
map_icon_data = NULL;
map_icon_request_count = 0;
}
/** Called by CL_ConnectToServer
*
* \param tmpsave The name of the gamestate file???
@@ -2624,7 +2640,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
case CL_ASKFULLFILELIST:
if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved
cl_mode = (cv_serverinfoscreen.value) ? CL_VIEWSERVER : CL_CHECKFILES;
cl_mode = (cv_serverinfoscreen.value && !addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES;
else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent)
{
if (CL_AskFileList(fileneedednum))
@@ -2757,7 +2773,19 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
{
// Gamestate is now handled within CL_LoadReceivedSavegame()
CL_LoadReceivedSavegame(false);
cl_mode = CL_CONNECTED;
if (addonsonly)
{
// close connection after savegame load
// we want the actual server state
// in case theres some stuff like records to be synched
cl_mode = CL_ABORTED;
}
else
{
cl_mode = CL_CONNECTED;
}
break;
} // don't break case continue to CL_CONNECTED
else
@@ -2771,7 +2799,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
case CL_ABORTED:
cl_mode = CL_SEARCHING;
return false;
}
GetPackets();
@@ -2793,24 +2820,20 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
{
if (key == KEY_ENTER || key == KEY_JOY1)
{
addonsonly = false;
cl_mode = CL_CHECKFILES;
if (map_icon != NULL)
Patch_Free(map_icon);
map_icon = NULL;
if (map_icon_data != NULL)
Z_Free(map_icon_data);
map_icon_data = NULL;
FreeMapIcon();
}
else if (key == KEY_ESCAPE || key == KEY_JOY1+1)
{
cl_mode = CL_ABORTED;
if (map_icon != NULL)
Patch_Free(map_icon);
map_icon = NULL;
if (map_icon_data != NULL)
Z_Free(map_icon_data);
map_icon_data = NULL;
map_icon_request_count = 0;
FreeMapIcon();
}
else if (key == KEY_SPACE || key == KEY_JOY1+2)
{
addonsonly = true;
cl_mode = CL_CHECKFILES;
FreeMapIcon();
}
}
@@ -2819,6 +2842,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
{
CONS_Printf(M_GetText("Network game synchronization aborted.\n"));
CL_AbortConnection();
addonsonly = false;
return false;
}
@@ -3315,6 +3339,10 @@ static void Command_connect(void)
CONS_Alert(CONS_ERROR, M_GetText("There is no network driver\n"));
}
// idk how that shit works
//if (*COM_Argv(3) && fasticmp(COM_Argv(3), "-addonsonly"))
//addonsonly = true;
CV_Set(&cv_lastserver, I_GetNodeAddress(servernode));
if (splitscreen != cv_splitplayers.value-1)
+2
View File
@@ -552,6 +552,8 @@ typedef enum
KR_LEAVE, //Quit the game
} kickreason_t;
extern boolean addonsonly;
/* the max number of name changes in some time period */
#define MAXNAMECHANGES (5)
#define NAMECHANGERATE (60*TICRATE)
+52 -13
View File
@@ -186,8 +186,8 @@ static INT16 itemOn = 1; // menu item skull is on, Hack by Tails 09-18-2002
static INT16 skullAnimCounter = 10; // skull animation counter
static boolean interpTimerHackAllow = 0;
static UINT8 setupcontrolplayer;
static INT32 (*setupcontrols)[2]; // pointer to the gamecontrols of the player being edited
static UINT8 setupcontrolplayer;
static INT32 (*setupcontrols)[2]; // pointer to the gamecontrols of the player being edited
// shhh... what am I doing... nooooo!
static INT32 vidm_testingmode = 0;
@@ -201,8 +201,8 @@ static char setupm_ip[64];
static textinput_t setupm_input_ip;
static fixed_t multi_tics;
static state_t *multi_state;
static fixed_t multi_tics;
static state_t *multi_state;
// this is set before entering the MultiPlayer setup menu,
// for either player 1 or 2
@@ -1024,9 +1024,9 @@ boolean M_Responder(event_t *ev)
//case KEY_JOY1 + 2:
ch = KEY_ENTER;
break;
/*case KEY_JOY1 + 3: // Brake can function as 'n' for message boxes now.
ch = 'n';
break;*/
/*case KEY_JOY1 + 3: // Brake can function as 'n' for message boxes now.
ch = 'n';
break;*/
case KEY_MOUSE1 + 1:
//case KEY_JOY1 + 1:
ch = KEY_BACKSPACE;
@@ -1250,6 +1250,20 @@ boolean M_Responder(event_t *ev)
routine = currentMenu->menuitems[itemOn].itemaction;
// really hacky but the whole menu system sucks so
// allows to just load addons and gamestate instead of joining
if (currentMenu == &MP_ConnectDef &&
(routine && routine == M_Connect) &&
(ch == gamecontrol[0][gc_lookback][0] ||
ch == gamecontrol[0][gc_lookback][1]))
{
addonsonly = true;
noFurtherInput = true;
currentMenu->lastOn = itemOn;
routine(itemOn);
return true;
}
// Handle menuitems which need a specific key handling
if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER)
{
@@ -1305,12 +1319,21 @@ boolean M_Responder(event_t *ev)
{
playback_last_menu_interaction_leveltime = leveltime;
// Flip left/right with up/down for the playback menu, since it's a horizontal icon row.
switch (ch)
{
case KEY_LEFTARROW: ch = KEY_UPARROW; break;
case KEY_UPARROW: ch = KEY_RIGHTARROW; break;
case KEY_RIGHTARROW: ch = KEY_DOWNARROW; break;
case KEY_DOWNARROW: ch = KEY_LEFTARROW; break;
case KEY_LEFTARROW:
ch = KEY_UPARROW;
break;
case KEY_UPARROW:
ch = KEY_RIGHTARROW;
break;
case KEY_RIGHTARROW:
ch = KEY_DOWNARROW;
break;
case KEY_DOWNARROW:
ch = KEY_LEFTARROW;
break;
// arbitrary keyboard shortcuts because fuck you
@@ -1361,7 +1384,8 @@ boolean M_Responder(event_t *ev)
G_AdjustView(4, 1, true);
break;
default: break;
default:
break;
}
}
@@ -1486,6 +1510,7 @@ boolean M_Responder(event_t *ev)
}
return false;
break;
default:
CON_Responder(ev);
@@ -7059,6 +7084,21 @@ static void M_DrawConnectMenu(void)
M_DrawServerLines(currentMenu->x, serverlistpage);
}
// copy pasted this abomination from encore toggle
if (itemOn > mp_connect_search)
{
char addontoggle[32] = {0};
const char *item1 = gamecontrol[0][gc_lookback][0] != 0 ? G_KeynumToString(gamecontrol[0][gc_lookback][0]) : NULL;
const char *item2 = gamecontrol[0][gc_lookback][1] != 0 ? G_KeynumToString(gamecontrol[0][gc_lookback][1]) : NULL;
if (item1 != NULL && item2 != NULL)
snprintf(addontoggle, 32, "%s/%s - Load Addons Only", item1, item2);
else
snprintf(addontoggle, 32, "%s - Load Addons Only", item1 != NULL ? item1 : item2 != NULL ? item2 : "Lookback");
V_DrawThinString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_TRANSLUCENT|V_ALLOWLOWERCASE, addontoggle);
}
INT32 input_y = currentMenu->menuitems[mp_connect_search].alphaKey;
V_DrawFill(currentMenu->x, currentMenu->y+input_y, MAXSTRINGLENGTH*8+6, 8+6, 239);
@@ -10046,7 +10086,6 @@ static void M_DrawVideoMode(void)
va("Wait %d second%s", testtime, (testtime > 1) ? "s" : ""));
M_CentreText(OP_VideoModeDef.y + 158,
"or press ESC to return");
}
else
{