static int NehGameType;
enum m_state_e m_state;
-char m_return_reason[128];
void M_Menu_Main_f(cmd_state_t *cmd);
void M_Menu_SinglePlayer_f(cmd_state_t *cmd);
static qbool m_entersound; ///< play after drawing a frame, so caching won't disrupt the sound
-void M_Update_Return_Reason(const char *s)
-{
- strlcpy(m_return_reason, s, sizeof(m_return_reason));
- if (s)
- Con_DPrintf("%s\n", s);
-}
-
#define StartingGame (m_multiplayer_cursor == 1)
#define JoiningGame (m_multiplayer_cursor == 0)
for (i=0 ; i<MAX_SAVEGAMES ; i++)
{
- strlcpy (m_filenames[i], "--- UNUSED SLOT ---", sizeof(m_filenames[i]));
+ dp_strlcpy (m_filenames[i], "--- UNUSED SLOT ---", sizeof(m_filenames[i]));
loadable[i] = false;
dpsnprintf (name, sizeof(name), "s%i.sav", (int)i);
f = FS_OpenRealFile (name, "rb", false);
//version = atoi(com_token);
// description
COM_ParseToken_Simple(&t, false, false, true);
- strlcpy (m_filenames[i], com_token, sizeof (m_filenames[i]));
+ dp_strlcpy (m_filenames[i], com_token, sizeof (m_filenames[i]));
// change _ back to space
for (j=0 ; j<SAVEGAME_COMMENT_LENGTH ; j++)
key_dest = key_menu;
m_state = m_setup;
m_entersound = true;
- strlcpy(setup_myname, cl_name.string, sizeof(setup_myname));
+ dp_strlcpy(setup_myname, cl_name.string, sizeof(setup_myname));
setup_top = setup_oldtop = cl_topcolor.integer;
setup_bottom = setup_oldbottom = cl_bottomcolor.integer;
setup_rate = cl_rate.integer;
// LadyHavoc: redesigned to print more than 2 keys, inspired by Tomaz's MiniRacer
if (keys[0] == -1)
- strlcpy(keystring, "???", sizeof(keystring));
+ dp_strlcpy(keystring, "???", sizeof(keystring));
else
{
- char tinystr[2];
+ char tinystr[TINYSTR_LEN];
keystring[0] = 0;
for (j = 0;j < NUMKEYS;j++)
{
if (keys[j] != -1)
{
if (j > 0)
- strlcat(keystring, " or ", sizeof(keystring));
- strlcat(keystring, Key_KeynumToString (keys[j], tinystr, sizeof(tinystr)), sizeof(keystring));
+ dp_strlcat(keystring, " or ", sizeof(keystring));
+ dp_strlcat(keystring, Key_KeynumToString (keys[j], tinystr, TINYSTR_LEN), sizeof(keystring));
}
}
}
{
char line[80];
int keys[NUMKEYS];
- char tinystr[2];
+ char tinystr[TINYSTR_LEN];
if (bind_grab)
{ // defining a key
}
else //if (k != '`')
{
- dpsnprintf(line, sizeof(line), "bind \"%s\" \"%s\"\n", Key_KeynumToString(k, tinystr, sizeof(tinystr)), bindnames[keys_cursor][0]);
+ dpsnprintf(line, sizeof(line), "bind \"%s\" \"%s\"\n", Key_KeynumToString(k, tinystr, TINYSTR_LEN), bindnames[keys_cursor][0]);
Cbuf_InsertText (cmd, line);
}
lanConfig_port = 26000;
dpsnprintf(lanConfig_portname, sizeof(lanConfig_portname), "%u", (unsigned int) lanConfig_port);
- M_Update_Return_Reason("");
+ cl_connect_status[0] = '\0';
}
if (lanConfig_cursor == 3)
M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [lanConfig_cursor], 10+((int)(host.realtime*4)&1));
- if (*m_return_reason)
- M_Print(basex, 168, m_return_reason);
+ if (*cl_connect_status)
+ M_Print(basex, 168, cl_connect_status);
}
//=============================================================================
/* SLIST MENU */
-static int slist_cursor;
+static unsigned slist_cursor;
+static unsigned slist_visible;
void M_Menu_ServerList_f(cmd_state_t *cmd)
{
m_state = m_slist;
m_entersound = true;
slist_cursor = 0;
- M_Update_Return_Reason("");
+ cl_connect_status[0] = '\0';
if (lanConfig_cursor == 2)
Net_SlistQW_f(cmd);
else
static void M_ServerList_Draw (void)
{
- int n, y, visible, start, end, statnumplayers, statmaxplayers;
+ unsigned n, y, start, end, statnumplayers, statmaxplayers;
cachepic_t *p;
const char *s;
char vabuf[1024];
M_Background(640, vid_conheight.integer);
// scroll the list as the cursor moves
ServerList_GetPlayerStatistics(&statnumplayers, &statmaxplayers);
- s = va(vabuf, sizeof(vabuf), "%i/%i masters %i/%i servers %i/%i players", masterreplycount, masterquerycount, serverreplycount, serverquerycount, statnumplayers, statmaxplayers);
+ s = va(vabuf, sizeof(vabuf), "%u/%u masters %u/%u servers %u/%u players", masterreplycount, masterquerycount, serverreplycount, serverquerycount, statnumplayers, statmaxplayers);
M_PrintRed((640 - strlen(s) * 8) / 2, 32, s);
- if (*m_return_reason)
- M_Print(16, menu_height - 8, m_return_reason);
+ if (*cl_connect_status)
+ M_Print(16, menu_height - 8, cl_connect_status);
y = 48;
- visible = (int)((menu_height - 16 - y) / 8 / 2);
- start = bound(0, slist_cursor - (visible >> 1), serverlist_viewcount - visible);
- end = min(start + visible, serverlist_viewcount);
+ slist_visible = (menu_height - 16 - y) / 8 / 2;
+ start = min(slist_cursor - min(slist_cursor, slist_visible >> 1), serverlist_viewcount - min(serverlist_viewcount, slist_visible));
+ end = min(start + slist_visible, serverlist_viewcount);
p = Draw_CachePic ("gfx/p_multi");
M_DrawPic((640 - Draw_GetPicWidth(p)) / 2, 4, "gfx/p_multi");
Net_Slist_f(cmd);
break;
+ case K_PGUP:
+ slist_cursor -= slist_visible - 2;
case K_UPARROW:
case K_LEFTARROW:
S_LocalSound ("sound/misc/menu1.wav");
slist_cursor--;
- if (slist_cursor < 0)
+ if (slist_cursor >= serverlist_viewcount)
slist_cursor = serverlist_viewcount - 1;
break;
+ case K_PGDN:
+ slist_cursor += slist_visible - 2;
case K_DOWNARROW:
case K_RIGHTARROW:
S_LocalSound ("sound/misc/menu1.wav");
slist_cursor = 0;
break;
+ case K_HOME:
+ S_LocalSound ("sound/misc/menu1.wav");
+ slist_cursor = 0;
+ break;
+
+ case K_END:
+ S_LocalSound ("sound/misc/menu1.wav");
+ slist_cursor = serverlist_viewcount - 1;
+ break;
+
case K_ENTER:
S_LocalSound ("sound/misc/menu2.wav");
if (serverlist_viewcount)
description = FS_CheckGameDir(list.strings[i]);
if (description == NULL || description == fs_checkgamedir_missing) continue;
- strlcpy (modlist[modlist_count].dir, list.strings[i], sizeof(modlist[modlist_count].dir));
+ dp_strlcpy (modlist[modlist_count].dir, list.strings[i], sizeof(modlist[modlist_count].dir));
//check currently loaded mods
modlist[modlist_count].loaded = false;
if (fs_numgamedirs)
// copy our mod list into an array for FS_ChangeGameDirs
numgamedirs = modlist_numenabled;
for (i = 0; i < modlist_numenabled; i++)
- strlcpy (gamedirs[i], modlist[modlist_enabled[i]].dir,sizeof (gamedirs[i]));
+ dp_strlcpy (gamedirs[i], modlist[modlist_enabled[i]].dir,sizeof (gamedirs[i]));
// this code snippet is from FS_ChangeGameDirs
if (fs_numgamedirs == numgamedirs)
m_state = m_modlist;
m_entersound = true;
modlist_cursor = 0;
- M_Update_Return_Reason("");
+ cl_connect_status[0] = '\0';
ModList_RebuildList();
}
for (y = 0; y < modlist_numenabled; y++)
M_PrintRed(432, 48 + y * 8, modlist[modlist_enabled[y]].dir);
- if (*m_return_reason)
- M_Print(16, menu_height - 8, m_return_reason);
+ if (*cl_connect_status)
+ M_Print(16, menu_height - 8, cl_connect_status);
// scroll the list as the cursor moves
y = 48;
visible = (int)((menu_height - 16 - y) / 8 / 2);
void MVM_error_cmd(const char *format, ...) DP_FUNC_PRINTF(1);
void MVM_error_cmd(const char *format, ...)
{
- prvm_prog_t *prog = MVM_prog;
static qbool processingError = false;
char errorstring[MAX_INPUTLINE];
va_list argptr;
+ int outfd = sys.outfd;
+
+ // set output to stderr
+ sys.outfd = fileno(stderr);
va_start (argptr, format);
dpvsnprintf (errorstring, sizeof(errorstring), format, argptr);
va_end (argptr);
if (host.framecount < 3)
- Sys_Error("Menu_Error: %s\n", errorstring);
+ Sys_Error("Menu_Error: %s", errorstring);
- Con_Printf( "Menu_Error: %s\n", errorstring );
+ Con_Printf(CON_ERROR "Menu_Error: %s\n", errorstring);
- if( !processingError ) {
+ if(!processingError)
+ {
processingError = true;
- PRVM_Crash(prog);
+ PRVM_Crash();
processingError = false;
- } else {
- Con_Printf( "Menu_Error: Recursive call to MVM_error_cmd (from PRVM_Crash)!\n" );
}
+ else
+ Sys_Error("Menu_Error: Recursive call to MVM_error_cmd (from PRVM_Crash)!");
- // fall back to the normal menu
-
- // say it
- Con_Print("Falling back to normal menu\n");
-
+ Con_Print("Falling back to engine menu\n");
key_dest = key_game;
-
- // init the normal menu now -> this will also correct the menu router pointers
MR_SetRouting (true);
// reset the active scene, too (to be on the safe side ;))
R_SelectScene( RST_CLIENT );
+ // prevent an endless loop if the error was triggered by a command
+ Cbuf_Clear(cmd_local->cbuf);
+
+ // restore configured outfd
+ sys.outfd = outfd;
+
// Let video start at least
Host_AbortCurrentFrame();
}
for (i=0 ; i<prog->num_edicts ; i++)
{
ent = PRVM_EDICT_NUM(i);
- if (ent->priv.required->free)
+ if (ent->free)
continue;
active++;
}
static void MP_Draw (void)
{
prvm_prog_t *prog = MVM_prog;
- // declarations that are needed right now
-
float oldquality;
+ // don't crash if we draw a frame between prog shutdown and restart, see Host_LoadConfig_f
+ if (!prog->loaded)
+ return;
+
R_SelectScene( RST_MENU );
// reset the temp entities each frame