diff --git a/include/cl_slist.h b/include/cl_slist.h index 715e2c1..dac38e7 100644 --- a/include/cl_slist.h +++ b/include/cl_slist.h @@ -36,10 +36,6 @@ typedef struct server_entry_s { char *server; char *desc; - char *status; - int waitstatus; - struct timeval pingsent; - struct timeval pongback; struct server_entry_s *next; struct server_entry_s *prev; } server_entry_t; diff --git a/include/keys.h b/include/keys.h index 3dbce3f..3b3245e 100644 --- a/include/keys.h +++ b/include/keys.h @@ -161,7 +161,7 @@ typedef enum { } keynum_t; -typedef enum {key_game, key_console, key_message, key_menu} keydest_t; +typedef enum {key_game, key_console, key_message} keydest_t; extern keydest_t key_dest; extern char *keybindings[256]; diff --git a/include/qtypes.h b/include/qtypes.h index f8a0197..8b7cc1f 100644 --- a/include/qtypes.h +++ b/include/qtypes.h @@ -62,17 +62,4 @@ typedef int func_t; typedef int string_t; typedef byte pixel_t; -/* -typedef enum {key_game, key_console, key_message, key_menu} keydest_t; -typedef enum { ALIAS_SINGLE=0, ALIAS_GROUP } aliasframetype_t; -typedef enum { ALIAS_SKIN_SINGLE=0, ALIAS_SKIN_GROUP } aliasskintype_t; -typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t; -typedef void (*builtin_t) (void); -typedef enum {touchessolid, drawnode, nodrawnode} solidstate_t; -typedef enum { ST_SYNC=0, ST_RAND } synctype_t; -typedef enum { SPR_SINGLE=0, SPR_GROUP } spriteframetype_t; -typedef enum {MS_WINDOWED, MS_FULLSCREEN, MS_FULLDIB, MS_UNINIT} modestate_t; -typedef enum {mod_brush, mod_sprite, mod_alias} modtype_t; -*/ - #endif // _QTYPES_H diff --git a/source/Makefile.am b/source/Makefile.am index d3a8e6e..d7ab716 100644 --- a/source/Makefile.am +++ b/source/Makefile.am @@ -162,7 +162,7 @@ endif client_SOURCES= cl_cam.c cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c \ cl_main.c cl_misc.c cl_parse.c cl_pred.c cl_slist.c cl_tent.c \ - console.c keys.c menu.c model_alias.c model_sprite.c nonintel.c \ + console.c keys.c model_alias.c model_sprite.c nonintel.c \ pcx.c r_view.c sbar.c skin.c teamplay.c tga.c wad.c vid.c $(client_ASM) # diff --git a/source/cl_main.c b/source/cl_main.c index 9b3f21d..34f324c 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -30,8 +30,6 @@ # include "config.h" #endif #include -#include -#include #include "host.h" #include "bothdefs.h" @@ -53,7 +51,6 @@ #include "view.h" #include "checksum.h" #include "sys.h" -#include "menu.h" #include "compat.h" #include "buildnum.h" #include "keys.h" @@ -97,9 +94,6 @@ void CL_RemoveQFInfoKeys (); -// we need to declare some mouse variables here, because the menu system -// references them even when on a unix system. - qboolean noclip_anglehack; // remnant from old quake @@ -217,12 +211,6 @@ CL_Quit_f void CL_Quit_f (void) { - if (confirm_quit-> - int_val /* key_dest != key_console *//* && cls.state != ca_dedicated */ - ) { - M_Menu_Quit_f (); - return; - } CL_Disconnect (); Sys_Quit (); } @@ -1004,29 +992,7 @@ CL_ConnectionlessPacket (void) } // print command from somewhere if (c == A2C_PRINT) { - netadr_t addy; - server_entry_t *temp; s = MSG_ReadString (); - for (temp = slist; temp; temp = temp->next) - if (temp->waitstatus) - { - NET_StringToAdr (temp->server, &addy); - if (NET_CompareBaseAdr (net_from, addy)) - { - int i; - temp->status = realloc(temp->status, strlen(s) + 1); - strcpy(temp->status, s); - temp->waitstatus = 0; - for (i = 0; i < strlen(temp->status); i++) - if (temp->status[i] == '\n') - { - temp->status[i] = '\\'; - break; - } - Con_Printf("status response\n"); - return; - } - } Con_Printf ("print\n"); Con_Print (s); return; @@ -1071,24 +1037,6 @@ CL_ConnectionlessPacket (void) Con_Printf ("unknown: %c\n", c); } -void -CL_PingPacket (void) -{ - server_entry_t *temp; - netadr_t addy; - MSG_ReadByte ();; - for (temp = slist; temp; temp = temp->next) - if ((temp->pingsent.tv_sec || temp->pingsent.tv_usec) && !temp->pongback.tv_sec && !temp->pongback.tv_usec) - { - NET_StringToAdr (temp->server, &addy); - if (NET_CompareBaseAdr (net_from, addy)) - { - gettimeofday(&(temp->pongback), 0); - timepassed(&(temp->pingsent), &(temp->pongback)); - } - } -} - /* ================= CL_ReadPackets @@ -1106,11 +1054,6 @@ CL_ReadPackets (void) CL_ConnectionlessPacket (); continue; } - if (*(char *) net_message.data == A2A_ACK) - { - CL_PingPacket (); - continue; - } if (net_message.cursize < 8) { Con_Printf ("%s: Runt packet\n", NET_AdrToString (net_from)); continue; @@ -1710,7 +1653,6 @@ Host_Init (void) W_LoadWadFile ("gfx.wad"); Key_Init (); Con_Init (); - M_Init (); Mod_Init (); // Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); diff --git a/source/cl_slist.c b/source/cl_slist.c index acf88b6..fc0c865 100644 --- a/source/cl_slist.c +++ b/source/cl_slist.c @@ -34,8 +34,6 @@ #endif #include -#include -#include #include "cl_slist.h" #include "bothdefs.h" @@ -96,8 +94,6 @@ SL_Del (server_entry_t *start, server_entry_t *del) free (del->server); free (del->desc); - if (del->status) - free (del->status); if (del->prev) del->prev->next = del->next; if (del->next) @@ -250,8 +246,6 @@ SL_Del_All (server_entry_t *start) n = start->next; free (start->server); free (start->desc); - if (start->status) - free (start->status); free (start); start = n; } @@ -303,14 +297,3 @@ gettoklen (char *str, int req, char delim) } return len; } - -void timepassed (struct timeval *time1, struct timeval *time2) -{ - if (time2->tv_usec < time1->tv_usec) - { - time2->tv_usec = time2->tv_usec + 1000000; - time2->tv_sec--; - } - time2->tv_sec -= time1->tv_sec; - time2->tv_usec -= time1->tv_usec; -} \ No newline at end of file diff --git a/source/gl_draw.c b/source/gl_draw.c index 4685fb5..5e6b1ae 100644 --- a/source/gl_draw.c +++ b/source/gl_draw.c @@ -216,8 +216,6 @@ typedef struct cachepic_s { static cachepic_t cachepics[MAX_CACHED_PICS]; static int numcachepics; -static byte menuplyr_pixels[4096]; - qpic_t * Draw_PicFromWad (char *name) { @@ -289,7 +287,7 @@ Draw_CachePic (char *path) // Its not cached, lets make sure we have space in the cache.. if (numcachepics == MAX_CACHED_PICS) - Sys_Error ("menu_numcachepics == MAX_CACHED_PICS"); + Sys_Error ("numcachepics == MAX_CACHED_PICS"); // Load the picture.. dat = (qpic_t *) COM_LoadTempFile (path); @@ -322,15 +320,6 @@ Draw_CachePic (char *path) pic->dirty = false; numcachepics++; - // FIXME: - // A really ugly kluge, keep a specific image in memory - // for the menu system. - // - // Some days I really dislike legacy support.. - - if (!strcmp (path, "gfx/menuplyr.lmp")) - memcpy (menuplyr_pixels, dat->data, dat->width * dat->height); - // And now we are done, return what was asked for.. return &pic->pic; } @@ -736,61 +725,6 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, glColor3ubv (lighthalf_v); } -/* -============= -Draw_TransPicTranslate - -Only used for the player color selection menu -============= -*/ -void -Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation) -{ - int v, u, c; - unsigned int trans[64 * 64], *dest; - byte *src; - int p; - - glBindTexture (GL_TEXTURE_2D, translate_texture); - - c = pic->width * pic->height; - - dest = trans; - for (v = 0; v < 64; v++, dest += 64) { - src = &menuplyr_pixels[((v * pic->height) >> 6) * pic->width]; - for (u = 0; u < 64; u++) { - p = src[(u * pic->width) >> 6]; - if (p == 255) - dest[u] = p; - else - dest[u] = d_8to24table[translation[p]]; - } - } - - glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 64, 64, 0, GL_RGBA, - GL_UNSIGNED_BYTE, trans); - - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - if (lighthalf) - glColor3f (0.4, 0.4, 0.4); - else - glColor3f (0.8, 0.8, 0.8); - glBegin (GL_QUADS); - glTexCoord2f (0, 0); - glVertex2f (x, y); - glTexCoord2f (1, 0); - glVertex2f (x + pic->width, y); - glTexCoord2f (1, 1); - glVertex2f (x + pic->width, y + pic->height); - glTexCoord2f (0, 1); - glVertex2f (x, y + pic->height); - glEnd (); - glColor3ubv (lighthalf_v); -} - - /* Draw_ConsoleBackground diff --git a/source/gl_ngraph.c b/source/gl_ngraph.c index 327f3ae..10ce381 100644 --- a/source/gl_ngraph.c +++ b/source/gl_ngraph.c @@ -44,7 +44,6 @@ #include "wad.h" #include "draw.h" #include "cvar.h" -#include "menu.h" #include "net.h" // needed by: client.h #include "protocol.h" // needed by: client.h #include "cmd.h" diff --git a/source/gl_screen.c b/source/gl_screen.c index 16583fa..acfa0dd 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -40,7 +40,6 @@ #include "glquake.h" #include "host.h" #include "keys.h" -#include "menu.h" #include "pcx.h" #include "qendian.h" #include "sbar.h" @@ -60,7 +59,6 @@ notify lines intermission / finale overlay loading plaque console -menu required background clears required update regions @@ -1008,7 +1006,6 @@ SCR_UpdateScreen (void) SCR_CheckDrawCenterString (); Sbar_Draw (); SCR_DrawConsole (); - M_Draw (); } // LordHavoc: adjustable brightness and contrast, diff --git a/source/in_sdl.c b/source/in_sdl.c index 5a81e4f..1b44667 100644 --- a/source/in_sdl.c +++ b/source/in_sdl.c @@ -41,7 +41,6 @@ #include "input.h" #include "joystick.h" #include "keys.h" -#include "menu.h" #include "sys.h" #include "qargs.h" #include "qendian.h" diff --git a/source/keys.c b/source/keys.c index a4df89b..645f113 100644 --- a/source/keys.c +++ b/source/keys.c @@ -43,7 +43,6 @@ #include "qtypes.h" #include "sys.h" #include "keys.h" -#include "menu.h" #include "cmd.h" #include "console.h" #include "cvar.h" @@ -70,13 +69,8 @@ keydest_t key_dest; char *keybindings[256]; qboolean consolekeys[256]; // if true, can't be rebound while in - // console -qboolean menubound[256]; // if true, can't be rebound while in - - // menu int keyshift[256]; // key to map to if shift held down - // in console int key_repeats[256]; // if > 1, it is autorepeating qboolean keydown[256]; @@ -744,10 +738,6 @@ Key_Init (void) keyshift['`'] = '~'; keyshift['\\'] = '|'; - menubound[K_ESCAPE] = true; - for (i = 0; i < 12; i++) - menubound[K_F1 + i] = true; - // // register our functions // @@ -823,12 +813,9 @@ Key_Event (int key, int alt_key, qboolean down) case key_message: Key_Message (key); break; - case key_menu: - M_Keydown (key); - break; case key_game: case key_console: - M_ToggleMenu_f (); + Con_ToggleConsole_f (); break; default: Sys_Error ("Bad key_dest"); @@ -863,27 +850,7 @@ Key_Event (int key, int alt_key, qboolean down) if (cls.demoplayback && down && consolekeys[key] && key_dest == key_game && key != K_CTRL && key != K_DEL && key != K_HOME && key != K_END && key != K_TAB) { - M_ToggleMenu_f (); - return; - } -// -// if not a consolekey, send to the interpreter no matter what mode is -// - if ((key_dest == key_menu && menubound[key]) - || (key_dest == key_console && !consolekeys[key]) - || (key_dest == key_game - && (cls.state == ca_active || !consolekeys[key]))) { - kb = keybindings[key]; - if (kb) { - if (kb[0] == '+') { // button commands add keynum as a - // parm - snprintf (cmd, sizeof (cmd), "%s %i\n", kb, key); - Cbuf_AddText (cmd); - } else { - Cbuf_AddText (kb); - Cbuf_AddText ("\n"); - } - } + Con_ToggleConsole_f (); return; } @@ -898,10 +865,6 @@ Key_Event (int key, int alt_key, qboolean down) case key_message: Key_Message (key); break; - case key_menu: - M_Keydown (key); - break; - case key_game: case key_console: Key_Console (key); diff --git a/source/menu.c b/source/menu.c deleted file mode 100644 index 88f3f2b..0000000 --- a/source/menu.c +++ /dev/null @@ -1,1736 +0,0 @@ -/* - menu.c - - (description) - - Copyright (C) 1996-1997 Id Software, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to: - - Free Software Foundation, Inc. - 59 Temple Place - Suite 330 - Boston, MA 02111-1307, USA - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include - -#include "host.h" -#include "sys.h" -#ifdef _WIN32 -#include "winquake.h" -#endif -#include "cl_slist.h" -#include "keys.h" -#include "menu.h" -#include "vid.h" -#include "va.h" -#include "draw.h" -#include "cmd.h" -#include "screen.h" -#include "client.h" -#include "console.h" -#include "input.h" -#include "view.h" -#include "cl_main.h" -#include "cl_input.h" -#include "net.h" -#include - -void (*vid_menudrawfn) (void); -void (*vid_menukeyfn) (int key); - -enum { m_none, m_main, m_singleplayer, m_load, m_save, m_multiplayer, m_setup, - m_net, m_options, m_video, m_keys, m_help, m_quit, m_serialconfig, - m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_sedit } m_state; - -void M_Menu_Main_f (void); -void M_Menu_SinglePlayer_f (void); -void M_Menu_Load_f (void); -void M_Menu_Save_f (void); -void M_Menu_MultiPlayer_f (void); -void M_Menu_SEdit_f (void); -void M_Menu_Options_f (void); -void M_Menu_Keys_f (void); -void M_Menu_Video_f (void); -void M_Menu_Help_f (void); -void M_Menu_Quit_f (void); -void M_Menu_SerialConfig_f (void); -void M_Menu_ModemConfig_f (void); -void M_Menu_LanConfig_f (void); -void M_Menu_GameOptions_f (void); -void M_Menu_Search_f (void); -void M_Menu_ServerList_f (void); - -void M_Main_Draw (void); -void M_SinglePlayer_Draw (void); -void M_Load_Draw (void); -void M_Save_Draw (void); -void M_MultiPlayer_Draw (void); -void M_Setup_Draw (void); -void M_Net_Draw (void); -void M_Options_Draw (void); -void M_Keys_Draw (void); -void M_Video_Draw (void); -void M_Help_Draw (void); -void M_Quit_Draw (void); -void M_SerialConfig_Draw (void); -void M_ModemConfig_Draw (void); -void M_LanConfig_Draw (void); -void M_GameOptions_Draw (void); -void M_Search_Draw (void); -void M_ServerList_Draw (void); - -void M_Main_Key (int key); -void M_SinglePlayer_Key (int key); -void M_Load_Key (int key); -void M_Save_Key (int key); -void M_MultiPlayer_Key (int key); -void M_Setup_Key (int key); -void M_Net_Key (int key); -void M_Options_Key (int key); -void M_Keys_Key (int key); -void M_Video_Key (int key); -void M_Help_Key (int key); -void M_Quit_Key (int key); -void M_SerialConfig_Key (int key); -void M_ModemConfig_Key (int key); -void M_LanConfig_Key (int key); -void M_GameOptions_Key (int key); -void M_Search_Key (int key); -void M_ServerList_Key (int key); - -qboolean m_entersound; // play after drawing a frame, so - - // caching - // won't disrupt the sound -qboolean m_recursiveDraw; - -int m_return_state; -qboolean m_return_onerror; -char m_return_reason[32]; - -#define StartingGame (m_multiplayer_cursor == 1) -#define JoiningGame (m_multiplayer_cursor == 0) -#define SerialConfig (m_net_cursor == 0) -#define DirectConfig (m_net_cursor == 1) -#define IPXConfig (m_net_cursor == 2) -#define TCPIPConfig (m_net_cursor == 3) - -void M_ConfigureNetSubsystem (void); - -//============================================================================= -/* Support Routines */ - -/* -================ -M_DrawCharacter - -Draws one solid graphics character -================ -*/ -void -M_DrawCharacter (int cx, int line, int num) -{ - Draw_Character8 (cx + ((vid.width - 320) >> 1), line, num); -} - -void -M_Print (int cx, int cy, char *str) -{ - while (*str) { - M_DrawCharacter (cx, cy, (*str) + 128); - str++; - cx += 8; - } -} - -void -M_PrintWhite (int cx, int cy, char *str) -{ - while (*str) { - M_DrawCharacter (cx, cy, *str); - str++; - cx += 8; - } -} - -void -M_DrawTransPic (int x, int y, qpic_t *pic) -{ - Draw_Pic (x + ((vid.width - 320) >> 1), y, pic); -} - -void -M_DrawPic (int x, int y, qpic_t *pic) -{ - Draw_Pic (x + ((vid.width - 320) >> 1), y, pic); -} - -byte identityTable[256]; -byte translationTable[256]; - -void -M_BuildTranslationTable (int top, int bottom) -{ - int j; - byte *dest, *source; - - for (j = 0; j < 256; j++) - identityTable[j] = j; - dest = translationTable; - source = identityTable; - memcpy (dest, source, 256); - - if (top < 128) // the artists made some backwards - // ranges. sigh. - memcpy (dest + TOP_RANGE, source + top, 16); - else - for (j = 0; j < 16; j++) - dest[TOP_RANGE + j] = source[top + 15 - j]; - - if (bottom < 128) - memcpy (dest + BOTTOM_RANGE, source + bottom, 16); - else - for (j = 0; j < 16; j++) - dest[BOTTOM_RANGE + j] = source[bottom + 15 - j]; -} - - -void -M_DrawTransPicTranslate (int x, int y, qpic_t *pic) -{ - Draw_TransPicTranslate (x + ((vid.width - 320) >> 1), y, pic, - translationTable); -} - - -void -M_DrawTextBox (int x, int y, int width, int lines) -{ - qpic_t *p; - int cx, cy; - int n; - - // draw left side - cx = x; - cy = y; - p = Draw_CachePic ("gfx/box_tl.lmp"); - M_DrawTransPic (cx, cy, p); - p = Draw_CachePic ("gfx/box_ml.lmp"); - for (n = 0; n < lines; n++) { - cy += 8; - M_DrawTransPic (cx, cy, p); - } - p = Draw_CachePic ("gfx/box_bl.lmp"); - M_DrawTransPic (cx, cy + 8, p); - - // draw middle - cx += 8; - while (width > 0) { - cy = y; - p = Draw_CachePic ("gfx/box_tm.lmp"); - M_DrawTransPic (cx, cy, p); - p = Draw_CachePic ("gfx/box_mm.lmp"); - for (n = 0; n < lines; n++) { - cy += 8; - if (n == 1) - p = Draw_CachePic ("gfx/box_mm2.lmp"); - M_DrawTransPic (cx, cy, p); - } - p = Draw_CachePic ("gfx/box_bm.lmp"); - M_DrawTransPic (cx, cy + 8, p); - width -= 2; - cx += 16; - } - - // draw right side - cy = y; - p = Draw_CachePic ("gfx/box_tr.lmp"); - M_DrawTransPic (cx, cy, p); - p = Draw_CachePic ("gfx/box_mr.lmp"); - for (n = 0; n < lines; n++) { - cy += 8; - M_DrawTransPic (cx, cy, p); - } - p = Draw_CachePic ("gfx/box_br.lmp"); - M_DrawTransPic (cx, cy + 8, p); -} - -//============================================================================= - -int m_save_demonum; - -/* -================ -M_ToggleMenu_f -================ -*/ -void -M_ToggleMenu_f (void) -{ - m_entersound = true; - - if (key_dest == key_menu) { - if (m_state != m_main) { - M_Menu_Main_f (); - return; - } - key_dest = key_game; - m_state = m_none; - return; - } - if (key_dest == key_console) { - Con_ToggleConsole_f (); - if (key_dest == key_console) // Still suck on console? - M_Menu_Main_f (); - } else { - M_Menu_Main_f (); - } -} - - -//============================================================================= -/* MAIN MENU */ - -int m_main_cursor; - -#define MAIN_ITEMS 5 - - -void -M_Menu_Main_f (void) -{ - if (key_dest != key_menu) { - m_save_demonum = cls.demonum; - cls.demonum = -1; - } - key_dest = key_menu; - m_state = m_main; - m_entersound = true; -} - - -void -M_Main_Draw (void) -{ - int f; - qpic_t *p; - - M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp")); - p = Draw_CachePic ("gfx/ttl_main.lmp"); - M_DrawPic ((320 - p->width) / 2, 4, p); - M_DrawTransPic (72, 32, Draw_CachePic ("gfx/mainmenu.lmp")); - - f = (int) (realtime * 10) % 6; - - M_DrawTransPic (54, 32 + m_main_cursor * 20, - Draw_CachePic (va ("gfx/menudot%i.lmp", f + 1))); -} - - -void -M_Main_Key (int key) -{ - switch (key) { - case K_ESCAPE: - key_dest = key_game; - m_state = m_none; - cls.demonum = m_save_demonum; - if (cls.demonum != -1 && !cls.demoplayback - && cls.state == ca_disconnected) CL_NextDemo (); - break; - - case K_DOWNARROW: - S_LocalSound ("misc/menu1.wav"); - if (++m_main_cursor >= MAIN_ITEMS) - m_main_cursor = 0; - break; - - case K_UPARROW: - S_LocalSound ("misc/menu1.wav"); - if (--m_main_cursor < 0) - m_main_cursor = MAIN_ITEMS - 1; - break; - - case K_ENTER: - m_entersound = true; - - switch (m_main_cursor) { - case 0: - M_Menu_SinglePlayer_f (); - break; - - case 1: - M_Menu_MultiPlayer_f (); - break; - - case 2: - M_Menu_Options_f (); - break; - - case 3: - M_Menu_Help_f (); - break; - - case 4: - M_Menu_Quit_f (); - break; - } - } -} - - -//============================================================================= -/* OPTIONS MENU */ - -#define OPTIONS_ITEMS 17 - -#define SLIDER_RANGE 10 - -int options_cursor; - -void -M_Menu_Options_f (void) -{ - key_dest = key_menu; - m_state = m_options; - m_entersound = true; -} - - -void -M_AdjustSliders (int dir) -{ - S_LocalSound ("misc/menu3.wav"); - - switch (options_cursor) { - case 3: // screen size - Cvar_SetValue (scr_viewsize, - bound (30, scr_viewsize->int_val + (dir * 10), 120)); - break; - case 4: // Brightness - Cvar_SetValue (brightness, - bound (1, brightness->value + (dir * 0.25), 5)); - break; - case 5: // Contrast - Cvar_SetValue (contrast, - bound (0.0, contrast->value + (dir * 0.05), 1)); - break; - case 6: // mouse speed - Cvar_SetValue (sensitivity, - bound (1, sensitivity->value + dir, 25)); - break; - case 7: // music volume -#ifdef _WIN32 - Cvar_SetValue (bgmvolume, bound (0, bgmvolume->value + dir, 1)); -#else - Cvar_SetValue (bgmvolume, - bound (0, bgmvolume->value + (dir * 0.1), 1)); -#endif - break; - case 8: // sfx volume - Cvar_SetValue (volume, bound (0, volume->value + (dir * 0.1), 1)); - break; - - case 9: // allways run - if (cl_forwardspeed->value > 200) { - Cvar_SetValue (cl_forwardspeed, 200); - Cvar_SetValue (cl_backspeed, 200); - } else { - Cvar_SetValue (cl_forwardspeed, 400); - Cvar_SetValue (cl_backspeed, 400); - } - break; - - case 10: // invert mouse - Cvar_SetValue (m_pitch, -m_pitch->value); - break; - - case 11: // lookspring - Cvar_SetValue (lookspring, !lookspring->int_val); - break; - - case 12: // lookstrafe - Cvar_SetValue (lookstrafe, !lookstrafe->int_val); - break; - - case 13: // Use old-style sbar - Cvar_SetValue (cl_sbar, !cl_sbar->int_val); - break; - - case 14: // HUD on left side - Cvar_SetValue (cl_hudswap, !cl_hudswap->int_val); - break; - - case 16: // _windowed_mouse - Cvar_SetValue (_windowed_mouse, !_windowed_mouse->int_val); - break; - } -} - - -void -M_DrawSlider (int x, int y, float range) -{ - int i; - - range = bound (0, range, 1); - M_DrawCharacter (x - 8, y, 128); - for (i = 0; i < SLIDER_RANGE; i++) - M_DrawCharacter (x + i * 8, y, 129); - M_DrawCharacter (x + i * 8, y, 130); - M_DrawCharacter (x + (SLIDER_RANGE - 1) * 8 * range, y, 131); -} - -void -M_DrawCheckbox (int x, int y, int on) -{ -#if 0 - if (on) - M_DrawCharacter (x, y, 131); - else - M_DrawCharacter (x, y, 129); -#endif - if (on) - M_Print (x, y, "on"); - else - M_Print (x, y, "off"); -} - -void -M_Options_Draw (void) -{ - float r; - qpic_t *p; - - M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp")); - p = Draw_CachePic ("gfx/p_option.lmp"); - M_DrawPic ((320 - p->width) / 2, 4, p); - - M_Print (16, 32, " Customize controls"); - M_Print (16, 40, " Go to console"); - M_Print (16, 48, " Reset to defaults"); - - M_Print (16, 56, " Screen size"); - r = (scr_viewsize->int_val - 30) / (120.0 - 30.0); - M_DrawSlider (220, 56, r); - - M_Print (16, 64, " Brightness"); - r = (brightness->value - 1) / 4; - M_DrawSlider (220, 64, r); - - M_Print (16, 72, " Contrast"); - r = contrast->value; - M_DrawSlider (220, 72, r); - - M_Print (16, 80, " Mouse Speed"); - r = (sensitivity->value - 1) / 24; - M_DrawSlider (220, 80, r); - - M_Print (16, 88, " CD Music Volume"); - r = bgmvolume->value; - M_DrawSlider (220, 88, r); - - M_Print (16, 96, " Sound Volume"); - r = volume->value; - M_DrawSlider (220, 96, r); - - M_Print (16, 104, " Always Run"); - M_DrawCheckbox (220, 104, cl_forwardspeed->value > 200); - - M_Print (16, 112, " Invert Mouse"); - M_DrawCheckbox (220, 112, m_pitch->value < 0); - - M_Print (16, 120, " Lookspring"); - M_DrawCheckbox (220, 120, lookspring->int_val); - - M_Print (16, 128, " Lookstrafe"); - M_DrawCheckbox (220, 128, lookstrafe->int_val); - - M_Print (16, 136, " Use old status bar"); - M_DrawCheckbox (220, 136, cl_sbar->int_val); - - M_Print (16, 144, " HUD on left side"); - M_DrawCheckbox (220, 144, cl_hudswap->int_val); - - if (vid_menudrawfn) - M_Print (16, 152, " Video Options"); - -#ifdef _WIN32 - if (modestate == MS_WINDOWED) { -#endif - if (_windowed_mouse) { - M_Print (16, 160, " Use Mouse"); - M_DrawCheckbox (220, 160, _windowed_mouse->int_val); - } -#ifdef _WIN32 - } -#endif - -// cursor - M_DrawCharacter (200, 32 + options_cursor * 8, - 12 + ((int) (realtime * 4) & 1)); -} - - -void -M_Options_Key (int k) -{ - switch (k) { - case K_ESCAPE: - M_Menu_Main_f (); - break; - - case K_ENTER: - m_entersound = true; - switch (options_cursor) { - case 0: - M_Menu_Keys_f (); - break; - case 1: - m_state = m_none; - Con_ToggleConsole_f (); - break; - case 2: - Cbuf_AddText ("exec default.cfg\n"); - break; - case 15: - if (vid_menudrawfn) - M_Menu_Video_f (); - break; - default: - M_AdjustSliders (1); - break; - } - return; - - case K_UPARROW: - S_LocalSound ("misc/menu1.wav"); - options_cursor--; - if (options_cursor < 0) - options_cursor = OPTIONS_ITEMS - 1; -#ifdef _WIN32 - if (options_cursor == 16 - && (!(_windowed_mouse) - || (modestate != MS_WINDOWED))) options_cursor--; -#endif - if (options_cursor == 15 && !(vid_menudrawfn)) - options_cursor--; - break; - - case K_DOWNARROW: - S_LocalSound ("misc/menu1.wav"); - options_cursor++; - if (options_cursor == 15 && !(vid_menudrawfn)) - options_cursor++; -#ifdef _WIN32 - if (options_cursor == 16 && (!(_windowed_mouse) || (modestate != MS_WINDOWED))) // ARGH!!!!! - options_cursor++; -#endif - if (options_cursor >= OPTIONS_ITEMS) - options_cursor = 0; - break; - - case K_LEFTARROW: - M_AdjustSliders (-1); - break; - - case K_RIGHTARROW: - M_AdjustSliders (1); - break; - } -} - - -//============================================================================= -/* KEYS MENU */ - -char *bindnames[][2] = { - {"+attack", "attack"}, - {"impulse 10", "change weapon"}, - {"+jump", "jump / swim up"}, - {"+forward", "walk forward"}, - {"+back", "backpedal"}, - {"+left", "turn left"}, - {"+right", "turn right"}, - {"+speed", "run"}, - {"+moveleft", "step left"}, - {"+moveright", "step right"}, - {"+strafe", "sidestep"}, - {"+lookup", "look up"}, - {"+lookdown", "look down"}, - {"centerview", "center view"}, - {"+mlook", "mouse look"}, - {"+klook", "keyboard look"}, - {"+moveup", "swim up"}, - {"+movedown", "swim down"} -}; - -#define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0])) - -int keys_cursor; -int bind_grab; - -void -M_Menu_Keys_f (void) -{ - key_dest = key_menu; - m_state = m_keys; - m_entersound = true; -} - - -void -M_FindKeysForCommand (char *command, int *twokeys) -{ - int count; - int j; - int l; - char *b; - - twokeys[0] = twokeys[1] = -1; - l = strlen (command); - count = 0; - - for (j = 0; j < 256; j++) { - b = keybindings[j]; - if (!b) - continue; - if (!strncmp (b, command, l)) { - twokeys[count] = j; - count++; - if (count == 2) - break; - } - } -} - -void -M_UnbindCommand (char *command) -{ - int j; - int l; - char *b; - - l = strlen (command); - - for (j = 0; j < 256; j++) { - b = keybindings[j]; - if (!b) - continue; - if (!strncmp (b, command, l)) - Key_SetBinding (j, ""); - } -} - - -void -M_Keys_Draw (void) -{ - int i, l; - int keys[2]; - char *name; - int x, y; - qpic_t *p; - - p = Draw_CachePic ("gfx/ttl_cstm.lmp"); - M_DrawPic ((320 - p->width) / 2, 4, p); - - if (bind_grab) - M_Print (12, 32, "Press a key or button for this action"); - else - M_Print (18, 32, "Enter to change, backspace to clear"); - -// search for known bindings - for (i = 0; i < NUMCOMMANDS; i++) { - y = 48 + 8 * i; - - M_Print (16, y, bindnames[i][1]); - - l = strlen (bindnames[i][0]); - - M_FindKeysForCommand (bindnames[i][0], keys); - - if (keys[0] == -1) { - M_Print (140, y, "?" "?" "?"); // avoid any possibility of - // trigraphs - } else { - name = Key_KeynumToString (keys[0]); - M_Print (140, y, name); - x = strlen (name) * 8; - if (keys[1] != -1) { - M_Print (140 + x + 8, y, "or"); - M_Print (140 + x + 32, y, Key_KeynumToString (keys[1])); - } - } - } - - if (bind_grab) - M_DrawCharacter (130, 48 + keys_cursor * 8, '='); - else - M_DrawCharacter (130, 48 + keys_cursor * 8, - 12 + ((int) (realtime * 4) & 1)); -} - - -void -M_Keys_Key (int k) -{ - char cmd[80]; - int keys[2]; - - if (bind_grab) { // defining a key - S_LocalSound ("misc/menu1.wav"); - if (k == K_ESCAPE) { - bind_grab = false; - } else if (k != '`') { - snprintf (cmd, sizeof (cmd), "bind %s \"%s\"\n", - Key_KeynumToString (k), bindnames[keys_cursor][0]); - Cbuf_InsertText (cmd); - } - - bind_grab = false; - return; - } - - switch (k) { - case K_ESCAPE: - M_Menu_Options_f (); - break; - - case K_LEFTARROW: - case K_UPARROW: - S_LocalSound ("misc/menu1.wav"); - keys_cursor--; - if (keys_cursor < 0) - keys_cursor = NUMCOMMANDS - 1; - break; - - case K_DOWNARROW: - case K_RIGHTARROW: - S_LocalSound ("misc/menu1.wav"); - keys_cursor++; - if (keys_cursor >= NUMCOMMANDS) - keys_cursor = 0; - break; - - case K_ENTER: // go into bind mode - M_FindKeysForCommand (bindnames[keys_cursor][0], keys); - S_LocalSound ("misc/menu2.wav"); - if (keys[1] != -1) - M_UnbindCommand (bindnames[keys_cursor][0]); - bind_grab = true; - break; - - case K_BACKSPACE: // delete bindings - case K_DEL: // delete bindings - S_LocalSound ("misc/menu2.wav"); - M_UnbindCommand (bindnames[keys_cursor][0]); - break; - } -} - -//============================================================================= -/* VIDEO MENU */ - -void -M_Menu_Video_f (void) -{ - key_dest = key_menu; - m_state = m_video; - m_entersound = true; -} - - -void -M_Video_Draw (void) -{ - (*vid_menudrawfn) (); -} - - -void -M_Video_Key (int key) -{ - (*vid_menukeyfn) (key); -} - -//============================================================================= -/* HELP MENU */ - -int help_page; - -#define NUM_HELP_PAGES 6 - - -void -M_Menu_Help_f (void) -{ - key_dest = key_menu; - m_state = m_help; - m_entersound = true; - help_page = 0; -} - - - -void -M_Help_Draw (void) -{ - M_DrawPic (0, 0, Draw_CachePic (va ("gfx/help%i.lmp", help_page))); -} - - -void -M_Help_Key (int key) -{ - switch (key) { - case K_ESCAPE: - M_Menu_Main_f (); - break; - - case K_UPARROW: - case K_RIGHTARROW: - m_entersound = true; - if (++help_page >= NUM_HELP_PAGES) - help_page = 0; - break; - - case K_DOWNARROW: - case K_LEFTARROW: - m_entersound = true; - if (--help_page < 0) - help_page = NUM_HELP_PAGES - 1; - break; - } - -} - -//============================================================================= -/* QUIT MENU */ - -int msgNumber; -int m_quit_prevstate; -qboolean wasInMenus; - -char *quitMessage[] = { -/* .........1.........2.... */ - " Are you gonna quit ", - " this game just like ", - " everything else? ", - " ", - - " Milord, methinks that ", - " thou art a lowly ", - " quitter. Is this true? ", - " ", - - " Do I need to bust your ", - " face open for trying ", - " to quit? ", - " ", - - " Man, I oughta smack you", - " for trying to quit! ", - " Press Y to get ", - " smacked out. ", - - " Press Y to quit like a ", - " big loser in life. ", - " Press N to stay proud ", - " and successful! ", - - " If you press Y to ", - " quit, I will summon ", - " Satan all over your ", - " hard drive! ", - - " Um, Asmodeus dislikes ", - " his children trying to ", - " quit. Press Y to return", - " to your Tinkertoys. ", - - " If you quit now, I'll ", - " throw a blanket-party ", - " for you next time! ", - " " -}; - -void -M_Menu_Quit_f (void) -{ - if (m_state == m_quit) - return; - wasInMenus = (key_dest == key_menu); - key_dest = key_menu; - m_quit_prevstate = m_state; - m_state = m_quit; - m_entersound = true; - msgNumber = rand () & 7; -} - - -void -M_Quit_Key (int key) -{ - switch (key) { - case K_ESCAPE: - case 'n': - case 'N': - if (wasInMenus) { - m_state = m_quit_prevstate; - m_entersound = true; - } else { - key_dest = key_game; - m_state = m_none; - } - break; - - case 'Y': - case 'y': - key_dest = key_console; - CL_Disconnect (); - Sys_Quit (); - break; - - default: - break; - } - -} - -void -M_Menu_SinglePlayer_f (void) -{ - m_state = m_singleplayer; -} - -void -M_SinglePlayer_Draw (void) -{ - qpic_t *p; - - M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp")); -// M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); - p = Draw_CachePic ("gfx/ttl_sgl.lmp"); - M_DrawPic ((320 - p->width) / 2, 4, p); -// M_DrawTransPic (72, 32, Draw_CachePic ("gfx/sp_menu.lmp") ); - - M_DrawTextBox (60, 10 * 8, 23, 4); - M_PrintWhite (88, 12 * 8, "This client is for"); - M_PrintWhite (88, 13 * 8, "Internet play only"); - -} - -void -M_SinglePlayer_Key (key) -{ - if (key == K_ESCAPE || key == K_ENTER) - m_state = m_main; -} - -#define MENU_X 50 -#define MENU_Y 30 -#define STAT_X 50 -#define STAT_Y 122 - -static int m_multip_cursor = 0; -static int m_multip_mins = 0; -static int m_multip_maxs = 10; -static int m_multip_horiz; - -static server_entry_t *pingupdate = 0; -static server_entry_t *statusupdate = 0; - -void -M_Menu_MultiPlayer_f (void) -{ - key_dest = key_menu; - m_entersound = true; - m_state = m_multiplayer; - m_multip_horiz = 0; -} - -void -M_MultiPlayer_Draw (void) -{ - int serv; - int line = 1; - server_entry_t *cp; - qpic_t *p; - - static double lastping = 0; - - int f; - - M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp")); - p = Draw_CachePic ("gfx/p_multi.lmp"); - M_DrawPic ((320 - p->width) / 2, 4, p); - - if (!slist) { - M_DrawTextBox (60, 80, 23, 4); - M_PrintWhite (110, 12 * 8, "No server list"); - M_PrintWhite (140, 13 * 8, "found."); - return; - } - M_DrawTextBox (STAT_X, STAT_Y, 23, 7); - //M_DrawTextBox (STAT_X, STAT_Y + 38, 23, 3); - M_DrawTextBox (MENU_X, MENU_Y, 23, (m_multip_maxs - m_multip_mins) + 1); - for (serv = m_multip_mins; serv <= m_multip_maxs && serv < SL_Len (slist); serv++) { - cp = SL_Get_By_Num (slist, serv); - M_Print (MENU_X + 18, line * 8 + MENU_Y, - va ("%1.22s", - strlen (cp->desc) <= - m_multip_horiz ? "" : cp->desc + m_multip_horiz)); - line++; - } - cp = SL_Get_By_Num (slist, m_multip_cursor); - M_PrintWhite (STAT_X + 10, STAT_Y + 8, "IP/Hostname:"); - M_Print (STAT_X + 10, STAT_Y + 16, cp->server); - if (pingupdate && realtime - lastping >= .25) - { - netadr_t addy; - char data[6]; - - data[0] = '\377'; - data[1] = '\377'; - data[2] = '\377'; - data[3] = '\377'; - data[4] = A2A_PING; - data[5] = 0; - - NET_StringToAdr (pingupdate->server, &addy); - - if (!addy.port) - addy.port = ntohs (27500); - - gettimeofday(&(pingupdate->pingsent), 0); - pingupdate->pongback.tv_sec = 0; - pingupdate->pongback.tv_usec = 0; - NET_SendPacket (6, data, addy); - pingupdate = pingupdate->next; - lastping = realtime; - } - if (statusupdate && realtime - lastping >= .25) - { - netadr_t addy; - char data[] = "\377\377\377\377status"; - - NET_StringToAdr (statusupdate->server, &addy); - - if (!addy.port) - addy.port = ntohs (27500); - - NET_SendPacket (strlen(data) + 1, data, addy); - statusupdate->waitstatus = 1; - statusupdate = statusupdate->next; - lastping = realtime; - } - - if (!pingupdate && !statusupdate) - { - int playercount = 0, i; - M_PrintWhite (STAT_X + 10, STAT_Y + 24, "Ping:"); - M_PrintWhite (STAT_X + 10, STAT_Y + 32, "Game:"); - M_PrintWhite (STAT_X + 10, STAT_Y + 40, "Map:"); - M_PrintWhite (STAT_X + 10, STAT_Y + 48, "Players:"); - if (cp->pongback.tv_usec || cp->pongback.tv_sec) - M_Print (STAT_X + 58, STAT_Y + 24, va("%i", (int)(cp->pongback.tv_sec * 1000 + cp->pongback.tv_usec / 1000))); - else - M_Print (STAT_X + 58, STAT_Y + 24, "N/A"); - if (cp->status) - { - for (i = 0; i < strlen(cp->status); i++) - if (cp->status[i] == '\n') - playercount++; - M_Print (STAT_X + 58, STAT_Y + 32, Info_ValueForKey (cp->status, "*gamedir")); - M_Print (STAT_X + 50, STAT_Y + 40, Info_ValueForKey (cp->status, "map")); - M_Print (STAT_X + 82, STAT_Y + 48, va("%i/%s", playercount, Info_ValueForKey(cp->status, "maxclients"))); - } - else - { - M_Print (STAT_X + 58, STAT_Y + 32, "N/A"); - M_Print (STAT_X + 50, STAT_Y + 40, "N/A"); - M_Print (STAT_X + 82, STAT_Y + 48, "N/A"); - } - } - else - { - M_PrintWhite (STAT_X + 10, STAT_Y + 24, "Updating..."); - f = (int)(realtime * 10) % 6; - M_PrintWhite(STAT_X+118,STAT_Y+48,"uakeforge!"); - M_DrawTransPic(STAT_X+105,STAT_Y+38,Draw_CachePic(va("gfx/menudot%i.lmp",f+1))); - } - - M_DrawCharacter (MENU_X + 8, (m_multip_cursor - m_multip_mins + 1) * 8 + MENU_Y, 12 + ((int) (realtime * 4) & 1)); -} - -void -M_MultiPlayer_Key (key) -{ - server_entry_t *temp; - - if (!slist && key != K_ESCAPE && key != K_INS) - return; - switch (key) { - case K_ESCAPE: - M_Menu_Main_f (); - break; - case KP_DOWNARROW: - case K_DOWNARROW: - S_LocalSound ("misc/menu1.wav"); - m_multip_cursor++; - break; - case KP_UPARROW: - case K_UPARROW: - S_LocalSound ("misc/menu1.wav"); - m_multip_cursor--; - break; - case K_PGUP: - S_LocalSound ("misc/menu1.wav"); - m_multip_cursor -= (m_multip_maxs - m_multip_mins); - if (m_multip_cursor < 0) - m_multip_cursor = 0; - break; - case K_PGDN: - S_LocalSound ("misc/menu1.wav"); - m_multip_cursor += (m_multip_maxs - m_multip_mins); - if (SL_Len (slist) - 1 < m_multip_cursor) - m_multip_cursor = SL_Len (slist) - 1; - break; - case K_RIGHTARROW: - S_LocalSound ("misc/menu1.wav"); - if (m_multip_horiz < 256) - m_multip_horiz++; - break; - case K_LEFTARROW: - S_LocalSound ("misc/menu1.wav"); - if (m_multip_horiz > 0) - m_multip_horiz--; - break; - case K_ENTER: - m_state = m_main; - M_ToggleMenu_f (); - CL_Disconnect (); - strncpy (cls.servername, - SL_Get_By_Num (slist, m_multip_cursor)->server, - sizeof (cls.servername) - 1); - CL_BeginServerConnect (); - break; - case 'e': - case 'E': - M_Menu_SEdit_f (); - break; - case 'p': - case 'P': - if (pingupdate || statusupdate) - break; - pingupdate = slist; - for (temp = slist; temp; temp = temp->next) - temp->pingsent.tv_sec = temp->pingsent.tv_usec = temp->pongback.tv_sec = temp->pongback.tv_usec = 0; - break; - case 's': - case 'S': - if (pingupdate || statusupdate) - break; - statusupdate = slist; - for (temp = slist; temp; temp = temp->next) - temp->waitstatus = 0; - break; - case 'u': - case 'U': - if (pingupdate || statusupdate) - break; - pingupdate = slist; - statusupdate = slist; - for (temp = slist; temp; temp = temp->next) - { - temp->pingsent.tv_sec = temp->pingsent.tv_usec = temp->pongback.tv_sec = temp->pongback.tv_usec = 0; - temp->waitstatus = 0; - } - break; - case K_INS: - if (pingupdate || statusupdate) - break; - S_LocalSound ("misc/menu2.wav"); - if (!slist) { - m_multip_cursor = 0; - slist = SL_Add (slist, cls.state >= ca_connected ? cls.servername : "127.0.0.1", cls.state == ca_connected ? Info_ValueForKey (cl.serverinfo, "hostname") : ""); - } else { - temp = SL_Get_By_Num (slist, m_multip_cursor); - slist = SL_InsB (slist, temp, cls.state >= ca_connected ? cls.servername : "127.0.0.1", cls.state >= ca_connected ? Info_ValueForKey (cl.serverinfo, "hostname") : ""); - } - break; - case K_DEL: - if (pingupdate || statusupdate) - break; - S_LocalSound ("misc/menu2.wav"); - if (SL_Len (slist) > 0) { - slist = SL_Del (slist, SL_Get_By_Num (slist, m_multip_cursor)); - if (SL_Len (slist) == m_multip_cursor && slist) - m_multip_cursor--; - } - break; - case ']': - case '}': - if (pingupdate || statusupdate) - break; - S_LocalSound ("misc/menu1.wav"); - if (m_multip_cursor != SL_Len (slist) - 1) { - SL_Swap (SL_Get_By_Num (slist, m_multip_cursor), - SL_Get_By_Num (slist, m_multip_cursor + 1)); - m_multip_cursor++; - } - break; - case '[': - case '{': - if (pingupdate || statusupdate) - break; - S_LocalSound ("misc/menu1.wav"); - if (m_multip_cursor) { - SL_Swap (SL_Get_By_Num (slist, m_multip_cursor), - SL_Get_By_Num (slist, m_multip_cursor - 1)); - m_multip_cursor--; - } - break; - default: - break; - } - if (m_multip_cursor < 0) - m_multip_cursor = SL_Len (slist) - 1; - if (m_multip_cursor >= SL_Len (slist)) - m_multip_cursor = 0; - if (m_multip_cursor < m_multip_mins) { - m_multip_maxs -= (m_multip_mins - m_multip_cursor); - m_multip_mins = m_multip_cursor; - } - if (m_multip_cursor > m_multip_maxs) { - m_multip_mins += (m_multip_cursor - m_multip_maxs); - m_multip_maxs = m_multip_cursor; - } -} - -#define SERV_X 60 -#define SERV_Y 64 -#define DESC_X 60 -#define DESC_Y 40 -#define SERV_L 22 -#define DESC_L 22 - -char serv[256]; -char desc[256]; -int serv_max; -int serv_min; -int desc_max; -int desc_min; -qboolean sedit_state; - -void -M_Menu_SEdit_f (void) -{ - server_entry_t *c; - - key_dest = key_menu; - m_entersound = true; - m_state = m_sedit; - sedit_state = false; - c = SL_Get_By_Num (slist, m_multip_cursor); - strncpy (serv, c->server, 255); - serv[strlen (c->server) + 1] = 0; - strncpy (desc, c->desc, 255); - desc[strlen (c->desc) + 1] = 0; - serv_max = strlen (serv) > SERV_L ? strlen (serv) : SERV_L; - serv_min = serv_max - (SERV_L); - desc_max = strlen (desc) > DESC_L ? strlen (desc) : DESC_L; - desc_min = desc_max - (DESC_L); -} - -void -M_SEdit_Draw (void) -{ - qpic_t *p; - - M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp")); - p = Draw_CachePic ("gfx/p_multi.lmp"); - M_DrawPic ((320 - p->width) / 2, 4, p); - - M_DrawTextBox (SERV_X, SERV_Y, 23, 1); - M_DrawTextBox (DESC_X, DESC_Y, 23, 1); - M_PrintWhite (SERV_X, SERV_Y - 4, "Hostname/IP:"); - M_PrintWhite (DESC_X, DESC_Y - 4, "Description:"); - M_Print (SERV_X + 9, SERV_Y + 8, va ("%1.22s", serv + serv_min)); - M_Print (DESC_X + 9, DESC_Y + 8, va ("%1.22s", desc + desc_min)); - if (sedit_state == 0) - M_DrawCharacter (SERV_X + 9 + 8 * (strlen (serv) - serv_min), - SERV_Y + 8, 10 + ((int) (realtime * 4) & 1)); - if (sedit_state == 1) - M_DrawCharacter (DESC_X + 9 + 8 * (strlen (desc) - desc_min), - DESC_Y + 8, 10 + ((int) (realtime * 4) & 1)); -} - - -void -M_SEdit_Key (int key) -{ - int l; - server_entry_t *c; - - switch (key) { - case K_ESCAPE: - M_Menu_MultiPlayer_f (); - break; - case K_ENTER: - c = SL_Get_By_Num (slist, m_multip_cursor); - free (c->server); - free (c->desc); - c->server = malloc (strlen (serv) + 1); - c->desc = malloc (strlen (desc) + 1); - strcpy (c->server, serv); - strcpy (c->desc, desc); - M_Menu_MultiPlayer_f (); - break; - case K_UPARROW: - S_LocalSound ("misc/menu1.wav"); - sedit_state = !sedit_state; - break; - case K_DOWNARROW: - S_LocalSound ("misc/menu1.wav"); - sedit_state = !sedit_state; - break; - case K_BACKSPACE: - if (sedit_state) { - if ((l = strlen (desc))) - desc[--l] = 0; - if (strlen (desc) - 6 < desc_min && desc_min) { - desc_min--; - desc_max--; - } - } else { - if ((l = strlen (serv))) - serv[--l] = 0; - if (strlen (serv) - 6 < serv_min && serv_min) { - serv_min--; - serv_max--; - } - } - break; - default: - if (key < 32 || key > 127) - break; - if (sedit_state) { - l = strlen (desc); - if (l < 254) { - desc[l + 1] = 0; - desc[l] = key; - } - if (strlen (desc) > desc_max) { - desc_min++; - desc_max++; - } - } else { - l = strlen (serv); - if (l < 254) { - serv[l + 1] = 0; - serv[l] = key; - } - if (strlen (serv) > serv_max) { - serv_min++; - serv_max++; - } - } - break; - } -} - -void -M_Quit_Draw (void) -{ -#define VSTR(x) #x -#define VSTR2(x) VSTR(x) -// char *cmsg[] = { -// 0123456789012345678901234567890123456789 -// "0 QuakeWorld", -// "1 version " VSTR2(VERSION) " by id Software", -// "0Programming", -// "1 John Carmack Michael Abrash", -// "1 John Cash Christian Antkow", -// "0Additional Programming", -// "1 Dave 'Zoid' Kirsch", -// "1 Jack 'morbid' Mathews", -// "0Id Software is not responsible for", -// "0providing technical support for", -// "0QUAKEWORLD(tm). (c)1996 Id Software,", -// "0Inc. All Rights Reserved.", -// "0QUAKEWORLD(tm) is a trademark of Id", -// "0Software, Inc.", -// "1NOTICE: THE COPYRIGHT AND TRADEMARK", -// "1NOTICES APPEARING IN YOUR COPY OF", -// "1QUAKE(r) ARE NOT MODIFIED BY THE USE", -// "1OF QUAKEWORLD(tm) AND REMAIN IN FULL", -// "1FORCE.", -// "0NIN(r) is a registered trademark", -// "0licensed to Nothing Interactive, Inc.", -// "0All rights reserved. Press y to exit", -// NULL }; -// char **p; -// int y; - - if (wasInMenus) { - m_state = m_quit_prevstate; - m_recursiveDraw = true; - M_Draw (); - m_state = m_quit; - } -#if 0 - M_DrawTextBox (0, 0, 38, 23); - y = 12; - for (p = cmsg; *p; p++, y += 8) { - if (**p == '0') - M_PrintWhite (16, y, *p + 1); - else - M_Print (16, y, *p + 1); - } -#else - M_DrawTextBox (56, 76, 24, 4); - M_Print (64, 84, quitMessage[msgNumber * 4 + 0]); - M_Print (64, 92, quitMessage[msgNumber * 4 + 1]); - M_Print (64, 100, quitMessage[msgNumber * 4 + 2]); - M_Print (64, 108, quitMessage[msgNumber * 4 + 3]); -#endif -} - - - -//============================================================================= -/* Menu Subsystem */ - - -void -M_Init (void) -{ - Cmd_AddCommand ("togglemenu", M_ToggleMenu_f); - - Cmd_AddCommand ("menu_main", M_Menu_Main_f); - Cmd_AddCommand ("menu_options", M_Menu_Options_f); - Cmd_AddCommand ("menu_keys", M_Menu_Keys_f); - Cmd_AddCommand ("menu_video", M_Menu_Video_f); - Cmd_AddCommand ("menu_help", M_Menu_Help_f); - Cmd_AddCommand ("menu_quit", M_Menu_Quit_f); -} - - -void -M_Draw (void) -{ - if (m_state == m_none || key_dest != key_menu) - return; - - if (!m_recursiveDraw) { - scr_copyeverything = 1; - - if (scr_con_current) { - Draw_ConsoleBackground (vid.height); - VID_UnlockBuffer (); - S_ExtraUpdate (); - VID_LockBuffer (); - } else - Draw_FadeScreen (); - - scr_fullupdate = 0; - } else { - m_recursiveDraw = false; - } - - switch (m_state) { - case m_none: - break; - - case m_main: - M_Main_Draw (); - break; - - case m_singleplayer: - M_SinglePlayer_Draw (); - break; - - case m_load: -// M_Load_Draw (); - break; - - case m_save: -// M_Save_Draw (); - break; - - case m_multiplayer: - M_MultiPlayer_Draw (); - break; - - case m_setup: -// M_Setup_Draw (); - break; - - case m_net: -// M_Net_Draw (); - break; - - case m_options: - M_Options_Draw (); - break; - - case m_keys: - M_Keys_Draw (); - break; - - case m_video: - M_Video_Draw (); - break; - - case m_help: - M_Help_Draw (); - break; - - case m_quit: - M_Quit_Draw (); - break; - - case m_serialconfig: -// M_SerialConfig_Draw (); - break; - - case m_modemconfig: -// M_ModemConfig_Draw (); - break; - - case m_lanconfig: -// M_LanConfig_Draw (); - break; - - case m_gameoptions: -// M_GameOptions_Draw (); - break; - - case m_search: -// M_Search_Draw (); - break; - -// case m_slist: -// M_ServerList_Draw (); -// break; - case m_sedit: - M_SEdit_Draw (); - break; - } - - if (m_entersound) { - S_LocalSound ("misc/menu2.wav"); - m_entersound = false; - } - - VID_UnlockBuffer (); - S_ExtraUpdate (); - VID_LockBuffer (); -} - - -void -M_Keydown (int key) -{ - switch (m_state) { - case m_none: - return; - - case m_main: - M_Main_Key (key); - return; - - case m_singleplayer: - M_SinglePlayer_Key (key); - return; - - case m_load: -// M_Load_Key (key); - return; - - case m_save: -// M_Save_Key (key); - return; - - case m_multiplayer: - M_MultiPlayer_Key (key); - return; - - case m_setup: -// M_Setup_Key (key); - return; - - case m_net: -// M_Net_Key (key); - return; - - case m_options: - M_Options_Key (key); - return; - - case m_keys: - M_Keys_Key (key); - return; - - case m_video: - M_Video_Key (key); - return; - - case m_help: - M_Help_Key (key); - return; - - case m_quit: - M_Quit_Key (key); - return; - - case m_serialconfig: -// M_SerialConfig_Key (key); - return; - - case m_modemconfig: -// M_ModemConfig_Key (key); - return; - - case m_lanconfig: -// M_LanConfig_Key (key); - return; - - case m_gameoptions: -// M_GameOptions_Key (key); - return; - - case m_search: -// M_Search_Key (key); - break; - -// case m_slist: -// M_ServerList_Key (key); -// return; - case m_sedit: - M_SEdit_Key (key); - break; - } -} diff --git a/source/r_misc.c b/source/r_misc.c index f58a58f..30d324f 100644 --- a/source/r_misc.c +++ b/source/r_misc.c @@ -37,7 +37,6 @@ #include "sbar.h" #include "r_local.h" #include "draw.h" -#include "menu.h" #include "cl_parse.h" qboolean allowskybox; // whether or not to allow skyboxes @@ -252,7 +251,7 @@ R_NetGraph (void) y = vid.height - sb_lines - 24 - r_graphheight->int_val * 2 - 2; //M_DrawTextBox (x, y, (w + 7) / 8, (r_graphheight->int_val * 2 + 7) / 8 + 1); - M_DrawTextBox (x-w, y, (w+7)/8, (r_graphheight->int_val*2+7)/8+1); + //M_DrawTextBox (x-w, y, (w+7)/8, (r_graphheight->int_val*2+7)/8+1); y2 = y + 8; y = vid.height - sb_lines - 8 - 2; diff --git a/source/screen.c b/source/screen.c index 22563c5..6a4f49a 100644 --- a/source/screen.c +++ b/source/screen.c @@ -40,7 +40,6 @@ #include "draw.h" #include "host.h" #include "keys.h" -#include "menu.h" #include "pcx.h" #include "qendian.h" #include "sbar.h" @@ -60,7 +59,6 @@ notify lines intermission / finale overlay loading plaque console -menu required background clears required update regions @@ -1000,7 +998,6 @@ SCR_UpdateScreen (void) SCR_CheckDrawCenterString (); Sbar_Draw (); SCR_DrawConsole (); - M_Draw (); } diff --git a/source/vid_mgl.c b/source/vid_mgl.c index fe4c039..eedad85 100644 --- a/source/vid_mgl.c +++ b/source/vid_mgl.c @@ -54,9 +54,6 @@ #define MAX_MODE_LIST 30 #define VID_ROW_SIZE 3 -extern void (*vid_menudrawfn) (void); -extern void (*vid_menukeyfn) (int); - /* Unused */ int VGA_width, VGA_height, VGA_rowbytes, VGA_bufferrowbytes, VGA_planar; byte *VGA_pagebase; @@ -174,9 +171,6 @@ static vmode_t badmode; static byte backingbuf[48 * 24]; -void VID_MenuDraw (void); -void VID_MenuKey (int key); - LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); void AppActivate (BOOL fActive, BOOL minimize); @@ -2103,9 +2097,6 @@ VID_Init (unsigned char *palette) VID_SetPalette (palette); - vid_menudrawfn = VID_MenuDraw; - vid_menukeyfn = VID_MenuKey; - strcpy (badmode.modedesc, "Bad mode"); } @@ -2963,7 +2954,6 @@ MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } -extern void M_Menu_Options_f (void); extern void M_Print (int cx, int cy, char *str); extern void M_PrintWhite (int cx, int cy, char *str); extern void M_DrawCharacter (int cx, int line, int num); @@ -2986,259 +2976,6 @@ typedef struct { static modedesc_t modedescs[MAX_MODEDESCS]; -/* -================ -VID_MenuDraw -================ -*/ -void -VID_MenuDraw (void) -{ - qpic_t *p; - char *ptr; - int lnummodes, i, j, k, column, row, dup, dupmode = 0; - char temp[100]; - vmode_t *pv; - modedesc_t tmodedesc; - - p = Draw_CachePic ("gfx/vidmodes.lmp"); - M_DrawPic ((320 - p->width) / 2, 4, p); - - for (i = 0; i < 3; i++) { - ptr = VID_GetModeDescriptionMemCheck (i); - modedescs[i].modenum = modelist[i].modenum; - modedescs[i].desc = ptr; - modedescs[i].ismode13 = 0; - modedescs[i].iscur = 0; - - if (vid_modenum == i) - modedescs[i].iscur = 1; - } - - vid_wmodes = 3; - lnummodes = VID_NumModes (); - - for (i = 3; i < lnummodes; i++) { - ptr = VID_GetModeDescriptionMemCheck (i); - pv = VID_GetModePtr (i); - - // we only have room for 15 fullscreen modes, so don't allow - // 360-wide modes, because if there are 5 320-wide modes and - // 5 360-wide modes, we'll run out of space - if (ptr && ((pv->width != 360) || COM_CheckParm ("-allow360"))) { - dup = 0; - - for (j = 3; j < vid_wmodes; j++) { - if (!strcmp (modedescs[j].desc, ptr)) { - dup = 1; - dupmode = j; - break; - } - } - - if (dup || (vid_wmodes < MAX_MODEDESCS)) { - if (!dup || !modedescs[dupmode].ismode13 - || COM_CheckParm ("-noforcevga")) { - if (dup) { - k = dupmode; - } else { - k = vid_wmodes; - } - - modedescs[k].modenum = i; - modedescs[k].desc = ptr; - modedescs[k].ismode13 = pv->mode13; - modedescs[k].iscur = 0; - modedescs[k].width = pv->width; - - if (i == vid_modenum) - modedescs[k].iscur = 1; - - if (!dup) - vid_wmodes++; - } - } - } - } - -// sort the modes on width (to handle picking up oddball dibonly modes -// after all the others) - for (i = 3; i < (vid_wmodes - 1); i++) { - for (j = (i + 1); j < vid_wmodes; j++) { - if (modedescs[i].width > modedescs[j].width) { - tmodedesc = modedescs[i]; - modedescs[i] = modedescs[j]; - modedescs[j] = tmodedesc; - } - } - } - - - M_Print (13 * 8, 36, "Windowed Modes"); - - column = 16; - row = 36 + 2 * 8; - - for (i = 0; i < 3; i++) { - if (modedescs[i].iscur) - M_PrintWhite (column, row, modedescs[i].desc); - else - M_Print (column, row, modedescs[i].desc); - - column += 13 * 8; - } - - if (vid_wmodes > 3) { - M_Print (12 * 8, 36 + 4 * 8, "Fullscreen Modes"); - - column = 16; - row = 36 + 6 * 8; - - for (i = 3; i < vid_wmodes; i++) { - if (modedescs[i].iscur) - M_PrintWhite (column, row, modedescs[i].desc); - else - M_Print (column, row, modedescs[i].desc); - - column += 13 * 8; - - if (((i - 3) % VID_ROW_SIZE) == (VID_ROW_SIZE - 1)) { - column = 16; - row += 8; - } - } - } -// line cursor - if (vid_testingmode) { - snprintf (temp, sizeof (temp), "TESTING %s", modedescs[vid_line].desc); - M_Print (13 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 4, temp); - M_Print (9 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 6, - "Please wait 5 seconds..."); - } else { - M_Print (9 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8, - "Press Enter to set mode"); - M_Print (6 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 3, - "T to test mode for 5 seconds"); - ptr = VID_GetModeDescription2 (vid_modenum); - - if (ptr) { - snprintf (temp, sizeof (temp), "D to set default: %s", ptr); - M_Print (2 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 5, temp); - } - - ptr = VID_GetModeDescription2 (_vid_default_mode_win->int_val); - - if (ptr) { - snprintf (temp, sizeof (temp), "Current default: %s", ptr); - M_Print (3 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 6, temp); - } - - M_Print (15 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 8, "Esc to exit"); - - row = 36 + 2 * 8 + (vid_line / VID_ROW_SIZE) * 8; - column = 8 + (vid_line % VID_ROW_SIZE) * 13 * 8; - - if (vid_line >= 3) - row += 3 * 8; - - M_DrawCharacter (column, row, 12 + ((int) (realtime * 4) & 1)); - } -} - - -/* -================ -VID_MenuKey -================ -*/ -void -VID_MenuKey (int key) -{ - if (vid_testingmode) - return; - - switch (key) { - case K_ESCAPE: - S_LocalSound ("misc/menu1.wav"); - M_Menu_Options_f (); - break; - - case K_LEFTARROW: - - S_LocalSound ("misc/menu1.wav"); - vid_line = ((vid_line / VID_ROW_SIZE) * VID_ROW_SIZE) + - ((vid_line + 2) % VID_ROW_SIZE); - - if (vid_line >= vid_wmodes) - vid_line = vid_wmodes - 1; - break; - - case K_RIGHTARROW: - S_LocalSound ("misc/menu1.wav"); - vid_line = ((vid_line / VID_ROW_SIZE) * VID_ROW_SIZE) + - ((vid_line + 4) % VID_ROW_SIZE); - - if (vid_line >= vid_wmodes) - vid_line = (vid_line / VID_ROW_SIZE) * VID_ROW_SIZE; - break; - - case K_UPARROW: - S_LocalSound ("misc/menu1.wav"); - vid_line -= VID_ROW_SIZE; - - if (vid_line < 0) { - vid_line += ((vid_wmodes + (VID_ROW_SIZE - 1)) / - VID_ROW_SIZE) * VID_ROW_SIZE; - - while (vid_line >= vid_wmodes) - vid_line -= VID_ROW_SIZE; - } - break; - - case K_DOWNARROW: - S_LocalSound ("misc/menu1.wav"); - vid_line += VID_ROW_SIZE; - - if (vid_line >= vid_wmodes) { - vid_line -= ((vid_wmodes + (VID_ROW_SIZE - 1)) / - VID_ROW_SIZE) * VID_ROW_SIZE; - - while (vid_line < 0) - vid_line += VID_ROW_SIZE; - } - break; - - case K_ENTER: - S_LocalSound ("misc/menu1.wav"); - VID_SetMode (modedescs[vid_line].modenum, vid_curpal); - break; - - case 'T': - case 't': - S_LocalSound ("misc/menu1.wav"); - // have to set this before setting the mode because WM_PAINT - // happens during the mode set and does a VID_Update, which - // checks vid_testingmode - vid_testingmode = 1; - vid_testendtime = realtime + 5.0; - - if (!VID_SetMode (modedescs[vid_line].modenum, vid_curpal)) { - vid_testingmode = 0; - } - break; - - case 'D': - case 'd': - S_LocalSound ("misc/menu1.wav"); - firstupdate = 0; - Cvar_SetValue (_vid_default_mode_win, vid_modenum); - break; - - default: - break; - } -} - void VID_SetCaption (char *text) { diff --git a/source/vid_wgl.c b/source/vid_wgl.c index c9dc145..444109c 100644 --- a/source/vid_wgl.c +++ b/source/vid_wgl.c @@ -47,9 +47,6 @@ #include "sbar.h" #include "host.h" -extern void (*vid_menudrawfn) (void); -extern void (*vid_menukeyfn) (int); - #define MAX_MODE_LIST 30 #define VID_ROW_SIZE 3 #define WARP_WIDTH 320 @@ -140,9 +137,6 @@ float gldepthmin, gldepthmax; modestate_t modestate = MS_UNINIT; -void VID_MenuDraw (void); -void VID_MenuKey (int key); - LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); void AppActivate (BOOL fActive, BOOL minimize); char *VID_GetModeDescription (int mode); @@ -1751,9 +1745,6 @@ VID_Init (unsigned char *palette) // Check for 3DFX Extensions and initialize them. VID_Init8bitPalette (); - vid_menudrawfn = VID_MenuDraw; - vid_menukeyfn = VID_MenuKey; - strcpy (badmode.modedesc, "Bad mode"); vid_canalttab = true; @@ -1768,17 +1759,6 @@ VID_Init_Cvars () } -//======================================================== -// Video menu stuff -//======================================================== - -extern void M_Menu_Options_f (void); -extern void M_Print (int cx, int cy, char *str); -extern void M_PrintWhite (int cx, int cy, char *str); -extern void M_DrawCharacter (int cx, int line, int num); -extern void M_DrawTransPic (int x, int y, qpic_t *pic); -extern void M_DrawPic (int x, int y, qpic_t *pic); - static int vid_line, vid_wmodes; typedef struct { @@ -1793,93 +1773,6 @@ typedef struct { static modedesc_t modedescs[MAX_MODEDESCS]; -/* -================ -VID_MenuDraw -================ -*/ -void -VID_MenuDraw (void) -{ - qpic_t *p; - char *ptr; - int lnummodes, i, k, column, row; - vmode_t *pv; - - p = Draw_CachePic ("gfx/vidmodes.lmp"); - M_DrawPic ((320 - p->width) / 2, 4, p); - - vid_wmodes = 0; - lnummodes = VID_NumModes (); - - for (i = 1; (i < lnummodes) && (vid_wmodes < MAX_MODEDESCS); i++) { - ptr = VID_GetModeDescription (i); - pv = VID_GetModePtr (i); - - k = vid_wmodes; - - modedescs[k].modenum = i; - modedescs[k].desc = ptr; - modedescs[k].iscur = 0; - - if (i == vid_modenum) - modedescs[k].iscur = 1; - - vid_wmodes++; - - } - - if (vid_wmodes > 0) { - M_Print (2 * 8, 36 + 0 * 8, "Fullscreen Modes (WIDTHxHEIGHTxBPP)"); - - column = 8; - row = 36 + 2 * 8; - - for (i = 0; i < vid_wmodes; i++) { - if (modedescs[i].iscur) - M_PrintWhite (column, row, modedescs[i].desc); - else - M_Print (column, row, modedescs[i].desc); - - column += 13 * 8; - - if ((i % VID_ROW_SIZE) == (VID_ROW_SIZE - 1)) { - column = 8; - row += 8; - } - } - } - - M_Print (3 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 2, - "Video modes must be set from the"); - M_Print (3 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 3, - "command line with -width "); - M_Print (3 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 4, - "and -bpp "); - M_Print (3 * 8, 36 + MODE_AREA_HEIGHT * 8 + 8 * 6, - "Select windowed mode with -window"); -} - - -/* -================ -VID_MenuKey -================ -*/ -void -VID_MenuKey (int key) -{ - switch (key) { - case K_ESCAPE: - S_LocalSound ("misc/menu1.wav"); - M_Menu_Options_f (); - break; - - default: - break; - } -} - void VID_SetCaption (char *text) { diff --git a/source/vid_x11.c b/source/vid_x11.c index 06f83dd..ad76011 100644 --- a/source/vid_x11.c +++ b/source/vid_x11.c @@ -73,7 +73,6 @@ #include "input.h" #include "input.h" #include "keys.h" -#include "menu.h" #include "qargs.h" #include "qendian.h" #include "sys.h"