ew-engine/mq engine src/menu_multi.c
2006-10-08 00:00:00 +00:00

1947 lines
No EOL
43 KiB
C

/*
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "quakedef.h"
#include "winquake.h"
#include "menu.h"
/*
================
MultiPlayer Menu
================
*/
int m_multiplayer_cursor;
#define MULTIPLAYER_ITEMS 3
void M_Menu_MultiPlayer_f (void)
{
key_dest = key_menu;
m_state = m_multiplayer;
m_entersound = true;
}
void M_MultiPlayer_Draw (void)
{
//When making demo mode just comment out everything and print a msg to screen.
//C_Print (-124, -4, "Multiplayer in fullversion only");
/*
//first menu system
int f;
qpic_t *p1, *p2, *p3;
f = (int)(host_time * 10)%6;
//precache pics
p1 = Draw_CachePic("gfx/p_multi.lmp");
p2 = Draw_CachePic("gfx/mp_menu.lmp");
p3 = Draw_CachePic(va("gfx/menudot%i.lmp", f+1));
Draw_Pic(((vid.width - p1->width)>>1),((vid.height - p1->height - p2->height)>>1), p1);
Draw_Pic(((vid.width - p2->width)>>1),((vid.height - p2->height + p1->height)>>1), p2);
Draw_Pic(((vid.width - p3->width - p2->width - 5)>>1),(((vid.height - p2->height + p3->height)>>1) + m_multiplayer_cursor * 20), p3);
*/
/*
//second menu system
//variable declarations
qpic_t *p;
char *menu0, *menu1, *menu2;
menu0 = " Join Game ";
menu1 = " New Game ";
menu2 = " Setup ";
//menu title
p = Draw_CachePic("gfx/p_multi.lmp");
C_DrawPic(-104,(-1 * (p->height + 16)),p);
//advanced cursor drawing system
if (m_multiplayer_cursor == 0)
C_PrintWhite (-92, -16, menu0);
else
C_Print (-92, -16, menu0);
if (m_multiplayer_cursor == 1)
C_PrintWhite (-92, -8, menu1);
else
C_Print (-92, -8, menu1);
if (m_multiplayer_cursor == 2)
C_PrintWhite (-92, 0, menu2);
else
C_Print (-92, 0, menu2);
*/
//third menu system
int f;
qpic_t *p[3];
f = (int)(host_time * 10)%6;
//image setup
p[0] = Draw_CachePic("gfx/p_multi.lmp");
p[1] = Draw_CachePic("gfx/mp_menu.lmp");
p[2] = Draw_CachePic(va("gfx/menudot%i.lmp", f+1));
//draw menu
C_DrawPic(-104,(-1 * (p[0]->height + p[1]->height - 50)),p[0]);
C_DrawPic(-104,(-1 * (p[1]->height - 50)),p[1]);
//draw cursor
C_DrawPic (-120,((m_multiplayer_cursor * 20) - p[1]->height + 50),p[2]);
}
void M_MultiPlayer_Key (int key)
{
switch (key)
{
case K_ESCAPE:
M_Menu_Main_f ();
break;
case K_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
if (++m_multiplayer_cursor >= MULTIPLAYER_ITEMS)
m_multiplayer_cursor = 0;
break;
case K_UPARROW:
S_LocalSound ("misc/menu1.wav");
if (--m_multiplayer_cursor < 0)
m_multiplayer_cursor = MULTIPLAYER_ITEMS - 1;
break;
case K_ENTER:
m_entersound = true;
switch (m_multiplayer_cursor)
{
case 0:
if (serialAvailable || ipxAvailable || tcpipAvailable)
M_Menu_Net_f ();
break;
case 1:
if (serialAvailable || ipxAvailable || tcpipAvailable)
M_Menu_Net_f ();
break;
case 2:
M_Menu_Setup_f ();
break;
}
}
}
/*
==========
Setup Menu
==========
*/
int setup_cursor = 0;
int setup_cursor_table[] = {-10, 6, 80};
char setup_hostname[16];
char setup_myname[16];
#define NUM_SETUP_CMDS 3
void M_Menu_Setup_f (void)
{
key_dest = key_menu;
m_state = m_setup;
m_entersound = true;
Q_strcpy(setup_myname, cl_name.string);
Q_strcpy(setup_hostname, hostname.string);
}
void M_Setup_Draw (void)
{
/*
//first menu system
qpic_t *p;
M_DrawPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic ("gfx/p_multi.lmp");
M_DrawPic ( (320-p->width)/2, 4, p);
M_Print (64, 40, "Hostname");
M_DrawTextBox (160, 32, 16, 1);
M_Print (168, 40, setup_hostname);
M_Print (64, 56, "Your name");
M_DrawTextBox (160, 48, 16, 1);
M_Print (168, 56, setup_myname);
M_DrawTextBox (64, 72, 14, 1);
M_Print (72, 80, "Accept Changes");
M_DrawCharacter (56, setup_cursor_table[setup_cursor], 12+((int)(realtime*4)&1));
if (setup_cursor == 0)
M_DrawCharacter (168 + 8*strlen(setup_hostname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
if (setup_cursor == 1)
M_DrawCharacter (168 + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
*/
//second menu system
//variable declarations
qpic_t *p;
int x;
char *menu0, *menu1, *menu2;
x = -132;
menu0 = "Host Name ";
menu1 = "Your Name ";
menu2 = "Accept Changes ";
//menu title
p = Draw_CachePic("gfx/p_multi.lmp");
C_DrawPic(-104,(-1 * (p->height + 14)),p);
//advanced cursor drawing system
if (setup_cursor == 0)
C_PrintWhite (x, -12, menu0);
else
C_Print (x, -12, menu0);
if (setup_cursor == 1)
C_PrintWhite (x, 4, menu1);
else
C_Print (x, 4, menu1);
if (setup_cursor == 2)
C_PrintWhite (x, 20, menu2);
else
C_Print (x, 20, menu2);
//textbox stuff
x = 4;
//menu0
C_DrawTextBox (x, -18, 16, 1);
C_Print ((x + 8), -10, setup_hostname);
//menu1
C_DrawTextBox (x, -2, 16, 1);
C_Print ((x + 8), 6, setup_myname);
//blinking cursor for typing
if (setup_cursor == 0)
C_DrawCharacter (x + 8*strlen(setup_hostname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
if (setup_cursor == 1)
C_DrawCharacter (x + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
}
void M_Setup_Key (int k)
{
int l;
switch (k)
{
case K_ESCAPE:
M_Menu_MultiPlayer_f ();
break;
case K_UPARROW:
S_LocalSound ("misc/menu1.wav");
setup_cursor--;
if (setup_cursor < 0)
setup_cursor = NUM_SETUP_CMDS-1;
break;
case K_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
setup_cursor++;
if (setup_cursor >= NUM_SETUP_CMDS)
setup_cursor = 0;
break;
case K_LEFTARROW:
if (setup_cursor < 2)
return;
S_LocalSound ("misc/menu3.wav");
break;
case K_RIGHTARROW:
if (setup_cursor < 2)
return;
S_LocalSound ("misc/menu3.wav");
break;
case K_ENTER:
if (setup_cursor == 0 || setup_cursor == 1)
return;
// setup_cursor == 4 (OK)
if (Q_strcmp(cl_name.string, setup_myname) != 0)
Cbuf_AddText ( va ("name \"%s\"\n", setup_myname) );
if (Q_strcmp(hostname.string, setup_hostname) != 0)
Cvar_Set("hostname", setup_hostname);
m_entersound = true;
M_Menu_MultiPlayer_f ();
break;
case K_BACKSPACE:
if (setup_cursor == 0)
{
if (strlen(setup_hostname))
setup_hostname[strlen(setup_hostname)-1] = 0;
}
if (setup_cursor == 1)
{
if (strlen(setup_myname))
setup_myname[strlen(setup_myname)-1] = 0;
}
break;
default:
if (k < 32 || k > 127)
break;
if (setup_cursor == 0)
{
l = strlen(setup_hostname);
if (l < 15)
{
setup_hostname[l+1] = 0;
setup_hostname[l] = k;
}
}
if (setup_cursor == 1)
{
l = strlen(setup_myname);
if (l < 15)
{
setup_myname[l+1] = 0;
setup_myname[l] = k;
}
}
}
}
/*
========
Net Menu
========
*/
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);
int m_multiplayer_cursor;
//=============================================================================
/* NET MENU */
int m_net_cursor;
int m_net_items;
int m_net_saveHeight;
char *net_helpMessage [] =
{
/* .........1.........2.... */
" ",
" Two computers connected",
" through two modems. ",
" ",
" ",
" Two computers connected",
" by a null-modem cable. ",
" ",
" Novell network LANs ",
" or Windows 95 DOS-box. ",
" ",
"(LAN=Local Area Network)",
" Commonly used to play ",
" over the Internet, but ",
" also used on a Local ",
" Area Network. "
};
void M_Menu_Net_f (void)
{
key_dest = key_menu;
m_state = m_net;
m_entersound = true;
m_net_items = 4;
if (m_net_cursor >= m_net_items)
m_net_cursor = 0;
m_net_cursor--;
M_Net_Key (K_DOWNARROW);
}
//new M_Net_Draw
void M_Net_Draw (void)
{
int f, x, y;
qpic_t *p;
p = Draw_CachePic ("gfx/p_multi.lmp");
C_DrawPic(-104,(-1 * (p->height + 14)),p);
f = 32;
y = 27;
if (serialAvailable)
{
p = Draw_CachePic ("gfx/netmen1.lmp");
}
else
{
p = NULL;
}
if (p)
{
C_DrawPic (-104,(-1 * (p->height - f + y)), p);
f += 19;
}
if (serialAvailable)
{
p = Draw_CachePic ("gfx/netmen2.lmp");
}
else
{
p = NULL;
}
if (p)
{
C_DrawPic (-104,(-1 * (p->height - f + y)), p);
f += 19;
}
if (ipxAvailable)
p = Draw_CachePic ("gfx/netmen3.lmp");
else
p = Draw_CachePic ("gfx/dim_ipx.lmp");
C_DrawPic (-104,(-1 * (p->height - f + y)), p);
f += 19;
if (tcpipAvailable)
p = Draw_CachePic ("gfx/netmen4.lmp");
else
p = Draw_CachePic ("gfx/dim_tcp.lmp");
C_DrawPic (-104,(-1 * (p->height - f + y)), p);
if (m_net_items == 5) // JDC, could just be removed
{
f += 19;
p = Draw_CachePic ("gfx/netmen5.lmp");
C_DrawPic (-104,(-1 * (p->height - f + y)), p);
}
y = -27;
C_DrawTextBox (-104,(-1 * (48 - f + y)), 24, 4);
x = -104;
x += 8;
y -= 8;
C_Print (x,(-1 * (48 - f + y)), net_helpMessage[m_net_cursor*4+0]);
y -= 8;
C_Print (x,(-1 * (48 - f + y)), net_helpMessage[m_net_cursor*4+1]);
y -= 8;
C_Print (x,(-1 * (48 - f + y)), net_helpMessage[m_net_cursor*4+2]);
y -= 8;
C_Print (x,(-1 * (48 - f + y)), net_helpMessage[m_net_cursor*4+3]);
f = (int)(host_time * 10)%6;
//draw cursor
p = Draw_CachePic(va("gfx/menudot%i.lmp",f+1));
C_DrawPic (-120,(((m_net_cursor - 2) * 20) - 20),p);
}
/*
//old M_Net_Draw
void M_Net_Draw (void)
{
int f;
qpic_t *p;
M_DrawPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic ("gfx/p_multi.lmp");
M_DrawPic ( (320-p->width)/2, 4, p);
f = 32;
if (serialAvailable)
{
p = Draw_CachePic ("gfx/netmen1.lmp");
}
else
{
p = NULL;
}
if (p)
M_DrawPic (72, f, p);
f += 19;
if (serialAvailable)
{
p = Draw_CachePic ("gfx/netmen2.lmp");
}
else
{
p = NULL;
}
if (p)
M_DrawPic (72, f, p);
f += 19;
if (ipxAvailable)
p = Draw_CachePic ("gfx/netmen3.lmp");
else
p = Draw_CachePic ("gfx/dim_ipx.lmp");
M_DrawPic (72, f, p);
f += 19;
if (tcpipAvailable)
p = Draw_CachePic ("gfx/netmen4.lmp");
else
p = Draw_CachePic ("gfx/dim_tcp.lmp");
M_DrawPic (72, f, p);
if (m_net_items == 5) // JDC, could just be removed
{
f += 19;
p = Draw_CachePic ("gfx/netmen5.lmp");
M_DrawPic (72, f, p);
}
f = (320-26*8)/2;
M_DrawTextBox (f, 134, 24, 4);
f += 8;
M_Print (f, 142, net_helpMessage[m_net_cursor*4+0]);
M_Print (f, 150, net_helpMessage[m_net_cursor*4+1]);
M_Print (f, 158, net_helpMessage[m_net_cursor*4+2]);
M_Print (f, 166, net_helpMessage[m_net_cursor*4+3]);
f = (int)(host_time * 10)%6;
M_DrawPic (54, 32 + m_net_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
}
*/
void M_Net_Key (int k)
{
again:
switch (k)
{
case K_ESCAPE:
M_Menu_MultiPlayer_f ();
break;
case K_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
if (++m_net_cursor >= m_net_items)
m_net_cursor = 0;
break;
case K_UPARROW:
S_LocalSound ("misc/menu1.wav");
if (--m_net_cursor < 0)
m_net_cursor = m_net_items - 1;
break;
case K_ENTER:
m_entersound = true;
switch (m_net_cursor)
{
case 0:
M_Menu_SerialConfig_f ();
break;
case 1:
M_Menu_SerialConfig_f ();
break;
case 2:
M_Menu_LanConfig_f ();
break;
case 3:
M_Menu_LanConfig_f ();
break;
case 4:
// multiprotocol
break;
}
}
if (m_net_cursor == 0 && !serialAvailable)
goto again;
if (m_net_cursor == 1 && !serialAvailable)
goto again;
if (m_net_cursor == 2 && !ipxAvailable)
goto again;
if (m_net_cursor == 3 && !tcpipAvailable)
goto again;
}
//=============================================================================
/* SERIAL CONFIG MENU */
int serialConfig_cursor;
int serialConfig_cursor_table[] = {48, 64, 80, 96, 112, 132};
#define NUM_SERIALCONFIG_CMDS 6
static int ISA_uarts[] = {0x3f8,0x2f8,0x3e8,0x2e8};
static int ISA_IRQs[] = {4,3,4,3};
int serialConfig_baudrate[] = {9600,14400,19200,28800,38400,57600};
int serialConfig_comport;
int serialConfig_irq ;
int serialConfig_baud;
char serialConfig_phone[16];
void M_Menu_SerialConfig_f (void)
{
int n;
int port;
int baudrate;
qboolean useModem;
key_dest = key_menu;
m_state = m_serialconfig;
m_entersound = true;
if (JoiningGame && SerialConfig)
serialConfig_cursor = 4;
else
serialConfig_cursor = 5;
(*GetComPortConfig) (0, &port, &serialConfig_irq, &baudrate, &useModem);
// map uart's port to COMx
for (n = 0; n < 4; n++)
if (ISA_uarts[n] == port)
break;
if (n == 4)
{
n = 0;
serialConfig_irq = 4;
}
serialConfig_comport = n + 1;
// map baudrate to index
for (n = 0; n < 6; n++)
if (serialConfig_baudrate[n] == baudrate)
break;
if (n == 6)
n = 5;
serialConfig_baud = n;
m_return_onerror = false;
m_return_reason[0] = 0;
}
void M_SerialConfig_Draw (void)
{
qpic_t *p;
int basex;
char *startJoin;
char *directModem;
M_DrawPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic ("gfx/p_multi.lmp");
basex = (320-p->width)/2;
M_DrawPic (basex, 4, p);
if (StartingGame)
startJoin = "New Game";
else
startJoin = "Join Game";
if (SerialConfig)
directModem = "Modem";
else
directModem = "Direct Connect";
M_Print (basex, 32, va ("%s - %s", startJoin, directModem));
basex += 8;
M_Print (basex, serialConfig_cursor_table[0], "Port");
M_DrawTextBox (160, 40, 4, 1);
M_Print (168, serialConfig_cursor_table[0], va("COM%u", serialConfig_comport));
M_Print (basex, serialConfig_cursor_table[1], "IRQ");
M_DrawTextBox (160, serialConfig_cursor_table[1]-8, 1, 1);
M_Print (168, serialConfig_cursor_table[1], va("%u", serialConfig_irq));
M_Print (basex, serialConfig_cursor_table[2], "Baud");
M_DrawTextBox (160, serialConfig_cursor_table[2]-8, 5, 1);
M_Print (168, serialConfig_cursor_table[2], va("%u", serialConfig_baudrate[serialConfig_baud]));
if (SerialConfig)
{
M_Print (basex, serialConfig_cursor_table[3], "Modem Setup...");
if (JoiningGame)
{
M_Print (basex, serialConfig_cursor_table[4], "Phone number");
M_DrawTextBox (160, serialConfig_cursor_table[4]-8, 16, 1);
M_Print (168, serialConfig_cursor_table[4], serialConfig_phone);
}
}
if (JoiningGame)
{
M_DrawTextBox (basex, serialConfig_cursor_table[5]-8, 7, 1);
M_Print (basex+8, serialConfig_cursor_table[5], "Connect");
}
else
{
M_DrawTextBox (basex, serialConfig_cursor_table[5]-8, 2, 1);
M_Print (basex+8, serialConfig_cursor_table[5], "OK");
}
M_DrawCharacter (basex-8, serialConfig_cursor_table [serialConfig_cursor], 12+((int)(realtime*4)&1));
if (serialConfig_cursor == 4)
M_DrawCharacter (168 + 8*strlen(serialConfig_phone), serialConfig_cursor_table [serialConfig_cursor], 10+((int)(realtime*4)&1));
if (*m_return_reason)
M_PrintWhite (basex, 148, m_return_reason);
}
void M_SerialConfig_Key (int key)
{
int l;
switch (key)
{
case K_ESCAPE:
M_Menu_Net_f ();
break;
case K_UPARROW:
S_LocalSound ("misc/menu1.wav");
serialConfig_cursor--;
if (serialConfig_cursor < 0)
serialConfig_cursor = NUM_SERIALCONFIG_CMDS-1;
break;
case K_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
serialConfig_cursor++;
if (serialConfig_cursor >= NUM_SERIALCONFIG_CMDS)
serialConfig_cursor = 0;
break;
case K_LEFTARROW:
if (serialConfig_cursor > 2)
break;
S_LocalSound ("misc/menu3.wav");
if (serialConfig_cursor == 0)
{
serialConfig_comport--;
if (serialConfig_comport == 0)
serialConfig_comport = 4;
serialConfig_irq = ISA_IRQs[serialConfig_comport-1];
}
if (serialConfig_cursor == 1)
{
serialConfig_irq--;
if (serialConfig_irq == 6)
serialConfig_irq = 5;
if (serialConfig_irq == 1)
serialConfig_irq = 7;
}
if (serialConfig_cursor == 2)
{
serialConfig_baud--;
if (serialConfig_baud < 0)
serialConfig_baud = 5;
}
break;
case K_RIGHTARROW:
if (serialConfig_cursor > 2)
break;
forward:
S_LocalSound ("misc/menu3.wav");
if (serialConfig_cursor == 0)
{
serialConfig_comport++;
if (serialConfig_comport > 4)
serialConfig_comport = 1;
serialConfig_irq = ISA_IRQs[serialConfig_comport-1];
}
if (serialConfig_cursor == 1)
{
serialConfig_irq++;
if (serialConfig_irq == 6)
serialConfig_irq = 7;
if (serialConfig_irq == 8)
serialConfig_irq = 2;
}
if (serialConfig_cursor == 2)
{
serialConfig_baud++;
if (serialConfig_baud > 5)
serialConfig_baud = 0;
}
break;
case K_ENTER:
if (serialConfig_cursor < 3)
goto forward;
m_entersound = true;
if (serialConfig_cursor == 3)
{
(*SetComPortConfig) (0, ISA_uarts[serialConfig_comport-1], serialConfig_irq, serialConfig_baudrate[serialConfig_baud], SerialConfig);
M_Menu_ModemConfig_f ();
break;
}
if (serialConfig_cursor == 4)
{
serialConfig_cursor = 5;
break;
}
// serialConfig_cursor == 5 (OK/CONNECT)
(*SetComPortConfig) (0, ISA_uarts[serialConfig_comport-1], serialConfig_irq, serialConfig_baudrate[serialConfig_baud], SerialConfig);
M_ConfigureNetSubsystem ();
if (StartingGame)
{
M_Menu_GameOptions_f ();
break;
}
m_return_state = m_state;
m_return_onerror = true;
key_dest = key_game;
m_state = m_none;
if (SerialConfig)
Cbuf_AddText (va ("connect \"%s\"\n", serialConfig_phone));
else
Cbuf_AddText ("connect\n");
break;
case K_BACKSPACE:
if (serialConfig_cursor == 4)
{
if (strlen(serialConfig_phone))
serialConfig_phone[strlen(serialConfig_phone)-1] = 0;
}
break;
default:
if (key < 32 || key > 127)
break;
if (serialConfig_cursor == 4)
{
l = strlen(serialConfig_phone);
if (l < 15)
{
serialConfig_phone[l+1] = 0;
serialConfig_phone[l] = key;
}
}
}
if (DirectConfig && (serialConfig_cursor == 3 || serialConfig_cursor == 4))
{
if (key == K_UPARROW)
serialConfig_cursor = 2;
else
serialConfig_cursor = 5;
}
if (SerialConfig && StartingGame && serialConfig_cursor == 4)
{
if (key == K_UPARROW)
serialConfig_cursor = 3;
else
serialConfig_cursor = 5;
}
}
//=============================================================================
/* MODEM CONFIG MENU */
int modemConfig_cursor;
int modemConfig_cursor_table [] = {40, 56, 88, 120, 156};
#define NUM_MODEMCONFIG_CMDS 5
char modemConfig_dialing;
char modemConfig_clear [16];
char modemConfig_init [32];
char modemConfig_hangup [16];
void M_Menu_ModemConfig_f (void)
{
key_dest = key_menu;
m_state = m_modemconfig;
m_entersound = true;
(*GetModemConfig) (0, &modemConfig_dialing, modemConfig_clear, modemConfig_init, modemConfig_hangup);
}
void M_ModemConfig_Draw (void)
{
qpic_t *p;
int basex;
M_DrawPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic ("gfx/p_multi.lmp");
basex = (320-p->width)/2;
M_DrawPic (basex, 4, p);
basex += 8;
if (modemConfig_dialing == 'P')
M_Print (basex, modemConfig_cursor_table[0], "Pulse Dialing");
else
M_Print (basex, modemConfig_cursor_table[0], "Touch Tone Dialing");
M_Print (basex, modemConfig_cursor_table[1], "Clear");
M_DrawTextBox (basex, modemConfig_cursor_table[1]+4, 16, 1);
M_Print (basex+8, modemConfig_cursor_table[1]+12, modemConfig_clear);
if (modemConfig_cursor == 1)
M_DrawCharacter (basex+8 + 8*strlen(modemConfig_clear), modemConfig_cursor_table[1]+12, 10+((int)(realtime*4)&1));
M_Print (basex, modemConfig_cursor_table[2], "Init");
M_DrawTextBox (basex, modemConfig_cursor_table[2]+4, 30, 1);
M_Print (basex+8, modemConfig_cursor_table[2]+12, modemConfig_init);
if (modemConfig_cursor == 2)
M_DrawCharacter (basex+8 + 8*strlen(modemConfig_init), modemConfig_cursor_table[2]+12, 10+((int)(realtime*4)&1));
M_Print (basex, modemConfig_cursor_table[3], "Hangup");
M_DrawTextBox (basex, modemConfig_cursor_table[3]+4, 16, 1);
M_Print (basex+8, modemConfig_cursor_table[3]+12, modemConfig_hangup);
if (modemConfig_cursor == 3)
M_DrawCharacter (basex+8 + 8*strlen(modemConfig_hangup), modemConfig_cursor_table[3]+12, 10+((int)(realtime*4)&1));
M_DrawTextBox (basex, modemConfig_cursor_table[4]-8, 2, 1);
M_Print (basex+8, modemConfig_cursor_table[4], "OK");
M_DrawCharacter (basex-8, modemConfig_cursor_table [modemConfig_cursor], 12+((int)(realtime*4)&1));
}
void M_ModemConfig_Key (int key)
{
int l;
switch (key)
{
case K_ESCAPE:
M_Menu_SerialConfig_f ();
break;
case K_UPARROW:
S_LocalSound ("misc/menu1.wav");
modemConfig_cursor--;
if (modemConfig_cursor < 0)
modemConfig_cursor = NUM_MODEMCONFIG_CMDS-1;
break;
case K_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
modemConfig_cursor++;
if (modemConfig_cursor >= NUM_MODEMCONFIG_CMDS)
modemConfig_cursor = 0;
break;
case K_LEFTARROW:
case K_RIGHTARROW:
if (modemConfig_cursor == 0)
{
if (modemConfig_dialing == 'P')
modemConfig_dialing = 'T';
else
modemConfig_dialing = 'P';
S_LocalSound ("misc/menu1.wav");
}
break;
case K_ENTER:
if (modemConfig_cursor == 0)
{
if (modemConfig_dialing == 'P')
modemConfig_dialing = 'T';
else
modemConfig_dialing = 'P';
m_entersound = true;
}
if (modemConfig_cursor == 4)
{
(*SetModemConfig) (0, va ("%c", modemConfig_dialing), modemConfig_clear, modemConfig_init, modemConfig_hangup);
m_entersound = true;
M_Menu_SerialConfig_f ();
}
break;
case K_BACKSPACE:
if (modemConfig_cursor == 1)
{
if (strlen(modemConfig_clear))
modemConfig_clear[strlen(modemConfig_clear)-1] = 0;
}
if (modemConfig_cursor == 2)
{
if (strlen(modemConfig_init))
modemConfig_init[strlen(modemConfig_init)-1] = 0;
}
if (modemConfig_cursor == 3)
{
if (strlen(modemConfig_hangup))
modemConfig_hangup[strlen(modemConfig_hangup)-1] = 0;
}
break;
default:
if (key < 32 || key > 127)
break;
if (modemConfig_cursor == 1)
{
l = strlen(modemConfig_clear);
if (l < 15)
{
modemConfig_clear[l+1] = 0;
modemConfig_clear[l] = key;
}
}
if (modemConfig_cursor == 2)
{
l = strlen(modemConfig_init);
if (l < 29)
{
modemConfig_init[l+1] = 0;
modemConfig_init[l] = key;
}
}
if (modemConfig_cursor == 3)
{
l = strlen(modemConfig_hangup);
if (l < 15)
{
modemConfig_hangup[l+1] = 0;
modemConfig_hangup[l] = key;
}
}
}
}
//=============================================================================
/* LAN CONFIG MENU */
int lanConfig_cursor = -1;
int lanConfig_cursor_table [] = {14, 28, 50};
#define NUM_LANCONFIG_CMDS 3
int lanConfig_port;
char lanConfig_portname[6];
char lanConfig_joinname[22];
void M_Menu_LanConfig_f (void)
{
key_dest = key_menu;
m_state = m_lanconfig;
m_entersound = true;
if (lanConfig_cursor == -1)
{
if (JoiningGame && TCPIPConfig)
lanConfig_cursor = 2;
else
lanConfig_cursor = 1;
}
if (StartingGame && lanConfig_cursor == 2)
lanConfig_cursor = 1;
lanConfig_port = DEFAULTnet_hostport;
sprintf(lanConfig_portname, "%u", lanConfig_port);
m_return_onerror = false;
m_return_reason[0] = 0;
}
//new M_LanConfig_Draw
void M_LanConfig_Draw (void)
{
qpic_t *p;
int basex;
char *startJoin;
char *protocol;
p = Draw_CachePic ("gfx/p_multi.lmp");
basex = -104;
C_DrawPic (basex,(-1 * (p->height + 14)), p);
if (StartingGame)
startJoin = "New Game";
else
startJoin = "Join Game";
if (IPXConfig)
protocol = "IPX";
else
protocol = "TCP/IP";
C_Print (basex, -10, va ("%s - %s", startJoin, protocol));
C_Print (basex, 0, "Address:");
if (IPXConfig)
C_Print (basex+9*8, 0, my_ipx_address);
else
C_Print (basex+9*8, 0, my_tcpip_address);
C_Print (basex, lanConfig_cursor_table[0], "Port");
C_DrawTextBox (basex+8*8, lanConfig_cursor_table[0]-8, 6, 1);
C_Print (basex+9*8, lanConfig_cursor_table[0], lanConfig_portname);
if (JoiningGame)
{
C_Print (basex, lanConfig_cursor_table[1], "Search for local games...");
C_Print (basex,(lanConfig_cursor_table[2] - 12), "Join game at:");
C_DrawTextBox (basex+8, lanConfig_cursor_table[2]-8, 22, 1);
C_Print (basex+16, lanConfig_cursor_table[2], lanConfig_joinname);
}
else
{
C_DrawTextBox (basex, lanConfig_cursor_table[1]-8, 2, 1);
C_Print (basex+8, lanConfig_cursor_table[1], "OK");
}
C_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*4)&1));
if (lanConfig_cursor == 0)
C_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*4)&1));
if (lanConfig_cursor == 2)
C_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*4)&1));
if (*m_return_reason)
C_PrintWhite (basex, 148, m_return_reason);
}
/*
//old M_LanConfig_Draw
void M_LanConfig_Draw (void)
{
qpic_t *p;
int basex;
char *startJoin;
char *protocol;
M_DrawPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic ("gfx/p_multi.lmp");
basex = (320-p->width)/2;
M_DrawPic (basex, 4, p);
if (StartingGame)
startJoin = "New Game";
else
startJoin = "Join Game";
if (IPXConfig)
protocol = "IPX";
else
protocol = "TCP/IP";
M_Print (basex, 32, va ("%s - %s", startJoin, protocol));
basex += 8;
M_Print (basex, 52, "Address:");
if (IPXConfig)
M_Print (basex+9*8, 52, my_ipx_address);
else
M_Print (basex+9*8, 52, my_tcpip_address);
M_Print (basex, lanConfig_cursor_table[0], "Port");
M_DrawTextBox (basex+8*8, lanConfig_cursor_table[0]-8, 6, 1);
M_Print (basex+9*8, lanConfig_cursor_table[0], lanConfig_portname);
if (JoiningGame)
{
M_Print (basex, lanConfig_cursor_table[1], "Search for local games...");
M_Print (basex, 108, "Join game at:");
M_DrawTextBox (basex+8, lanConfig_cursor_table[2]-8, 22, 1);
M_Print (basex+16, lanConfig_cursor_table[2], lanConfig_joinname);
}
else
{
M_DrawTextBox (basex, lanConfig_cursor_table[1]-8, 2, 1);
M_Print (basex+8, lanConfig_cursor_table[1], "OK");
}
M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*4)&1));
if (lanConfig_cursor == 0)
M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*4)&1));
if (lanConfig_cursor == 2)
M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*4)&1));
if (*m_return_reason)
M_PrintWhite (basex, 148, m_return_reason);
}
*/
void M_LanConfig_Key (int key)
{
int l;
switch (key)
{
case K_ESCAPE:
M_Menu_Net_f ();
break;
case K_UPARROW:
S_LocalSound ("misc/menu1.wav");
lanConfig_cursor--;
if (lanConfig_cursor < 0)
lanConfig_cursor = NUM_LANCONFIG_CMDS-1;
break;
case K_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
lanConfig_cursor++;
if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
lanConfig_cursor = 0;
break;
case K_ENTER:
if (lanConfig_cursor == 0)
break;
m_entersound = true;
M_ConfigureNetSubsystem ();
if (lanConfig_cursor == 1)
{
if (StartingGame)
{
M_Menu_GameOptions_f ();
break;
}
M_Menu_Search_f();
break;
}
if (lanConfig_cursor == 2)
{
m_return_state = m_state;
m_return_onerror = true;
key_dest = key_game;
m_state = m_none;
Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
break;
}
break;
case K_BACKSPACE:
if (lanConfig_cursor == 0)
{
if (strlen(lanConfig_portname))
lanConfig_portname[strlen(lanConfig_portname)-1] = 0;
}
if (lanConfig_cursor == 2)
{
if (strlen(lanConfig_joinname))
lanConfig_joinname[strlen(lanConfig_joinname)-1] = 0;
}
break;
default:
if (key < 32 || key > 127)
break;
if (lanConfig_cursor == 2)
{
l = strlen(lanConfig_joinname);
if (l < 21)
{
lanConfig_joinname[l+1] = 0;
lanConfig_joinname[l] = key;
}
}
if (key < '0' || key > '9')
break;
if (lanConfig_cursor == 0)
{
l = strlen(lanConfig_portname);
if (l < 5)
{
lanConfig_portname[l+1] = 0;
lanConfig_portname[l] = key;
}
}
}
if (StartingGame && lanConfig_cursor == 2)
{
if (key == K_UPARROW)
lanConfig_cursor = 1;
else
lanConfig_cursor = 0;
}
l = Q_atoi(lanConfig_portname);
if (l > 65535)
l = lanConfig_port;
else
lanConfig_port = l;
sprintf(lanConfig_portname, "%u", lanConfig_port);
}
//=============================================================================
/* GAME OPTIONS MENU */
typedef struct
{
char *name;
char *description;
} level_t;
level_t levels[] =
{
{"floodmp1", "floodmp1"},
{"floodmp2", "floodmp2"},
{"floodmp3", "floodmp3"},
{"floodmp4", "floodmp4"},
{"floodmp5", "floodmp5"},
{"floodmp6", "floodmp6"},
{"coopmp1", "coopmp1"},
{"coopmp2", "coopmp2"},
{"coopmp3", "coopmp3"},
{"coopmp4", "coopmp4"},
{"coopmp5", "coopmp5"},
};
int startlevel;
int maxplayers;
qboolean m_serverInfoMessage = false;
double m_serverInfoMessageTime;
void M_Menu_GameOptions_f (void)
{
key_dest = key_menu;
m_state = m_gameoptions;
m_entersound = true;
if (maxplayers == 0)
maxplayers = svs.maxclients;
if (maxplayers < 2)
maxplayers = svs.maxclientslimit;
}
int gameoptions_cursor_table[] = {-2, 14, 22, 30, 46, 54, 62, 78};
#define NUM_GAMEOPTIONS 8
#define MAX_BOTS 8
int gameoptions_cursor;
//new M_GameOptions_Draw
void M_GameOptions_Draw (void)
{
qpic_t *p;
int leftx, rightx, x, tempbots;
leftx = -134;
rightx = 6;
tempbots = numbots;
p = Draw_CachePic ("gfx/p_multi.lmp");
C_DrawPic (-104,(-1 * (p->height + 14)), p);
C_DrawTextBox ((rightx - 8), -10, 10, 1);
C_Print (rightx, -2, "begin game");
C_Print (leftx, 14, " Max players");
C_Print (rightx, 14, va("%i", maxplayers) );
// Xsniper - Added in bot support
C_Print (leftx - 24, 22, " Number of Bots");
C_Print (rightx, 22, va("%i", tempbots) );
C_Print (leftx, 30, " Game Type");
if (coop.value)
C_Print (rightx, 30, "Co-op");
else
C_Print (rightx, 30, "Flood");
C_Print (leftx, 46, " Skill");
if (skill.value == 0)
C_Print (rightx, 46, "Easy difficulty");
else if (skill.value == 1)
C_Print (rightx, 46, "Normal difficulty");
else if (skill.value == 2)
C_Print (rightx, 46, "Hard difficulty");
else
C_Print (rightx, 46, "Nightmare difficulty");
C_Print (leftx, 54, "Banish Limit");
if (fraglimit.value == 0)
C_Print (rightx, 54, "none");
else
C_Print (rightx, 54, va("%i banishes", (int)fraglimit.value));
C_Print (leftx, 62, " Time Limit");
if (timelimit.value == 0)
C_Print (rightx, 62, "none");
else
C_Print (rightx, 62, va("%i minutes", (int)timelimit.value));
C_Print (leftx, 78, " Level");
if (coop.value)
{
if (startlevel >= 5)
startlevel = 0;
C_Print (rightx, 78, levels[startlevel + 6].description);
C_Print (rightx, 86, levels[startlevel + 6].name);
}
else
{
C_Print (rightx, 78, levels[startlevel].description);
C_Print (rightx, 86, levels[startlevel].name);
}
// line cursor
C_DrawCharacter ((rightx - 16), gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1));
if (m_serverInfoMessage)
{
if ((realtime - m_serverInfoMessageTime) < 5.0)
{
x = -96;
C_DrawTextBox (x, 102, 24, 4);
x += 8;
C_Print (x, 110, " More than 4 players ");
C_Print (x, 118, " requires using command ");
C_Print (x, 126, "line parameters; please ");
C_Print (x, 134, " see techinfo.txt. ");
}
else
{
m_serverInfoMessage = false;
}
}
}
/*
//old M_GameOptions_Draw
void M_GameOptions_Draw (void)
{
qpic_t *p;
int x;
M_DrawPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic ("gfx/p_multi.lmp");
M_DrawPic ( (320-p->width)/2, 4, p);
M_DrawTextBox (152, 32, 10, 1);
M_Print (160, 40, "begin game");
M_Print (0, 56, " Max players");
M_Print (160, 56, va("%i", maxplayers) );
M_Print (0, 64, " Game Type");
if (coop.value)
M_Print (160, 64, "Co-op");
else
M_Print (160, 64, "Flood");
M_Print (0, 80, " Skill");
if (skill.value == 0)
M_Print (160, 80, "Easy difficulty");
else if (skill.value == 1)
M_Print (160, 80, "Normal difficulty");
else if (skill.value == 2)
M_Print (160, 80, "Hard difficulty");
else
M_Print (160, 80, "Nightmare difficulty");
M_Print (0, 88, " Banish Limit");
if (fraglimit.value == 0)
M_Print (160, 88, "none");
else
M_Print (160, 88, va("%i banishes", (int)fraglimit.value));
M_Print (0, 96, " Time Limit");
if (timelimit.value == 0)
M_Print (160, 96, "none");
else
M_Print (160, 96, va("%i minutes", (int)timelimit.value));
M_Print (0, 112, " Level");
if (coop.value)
{
M_Print (160, 112, levels[startlevel + 5].description);
M_Print (160, 120, levels[startlevel + 5].name);
}
else
{
M_Print (160, 112, levels[startlevel].description);
M_Print (160, 120, levels[startlevel].name);
}
// line cursor
M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1));
if (m_serverInfoMessage)
{
if ((realtime - m_serverInfoMessageTime) < 5.0)
{
x = (320-26*8)/2;
M_DrawTextBox (x, 138, 24, 4);
x += 8;
M_Print (x, 146, " More than 4 players ");
M_Print (x, 154, " requires using command ");
M_Print (x, 162, "line parameters; please ");
M_Print (x, 170, " see techinfo.txt. ");
}
else
{
m_serverInfoMessage = false;
}
}
}
*/
void M_NetStart_Change (int dir)
{
int count;
switch (gameoptions_cursor)
{
case 1:
maxplayers += dir;
if (maxplayers > svs.maxclientslimit)
{
maxplayers = svs.maxclientslimit;
m_serverInfoMessage = true;
m_serverInfoMessageTime = realtime;
}
if (maxplayers < 2)
maxplayers = 2;
break;
case 2:
numbots += dir;
if (numbots > MAX_BOTS)
numbots = 0;
if (numbots < 0)
numbots = MAX_BOTS;
break;
case 3:
Cvar_SetValue ("coop", coop.value ? 0 : 1);
break;
case 4:
Cvar_SetValue ("skill", skill.value + dir);
if (skill.value > 3)
Cvar_SetValue ("skill", 3);
if (skill.value < 0)
Cvar_SetValue ("skill", 0);
break;
case 5:
Cvar_SetValue ("fraglimit", fraglimit.value + dir*10);
if (fraglimit.value > 100)
Cvar_SetValue ("fraglimit", 0);
if (fraglimit.value < 0)
Cvar_SetValue ("fraglimit", 100);
break;
case 6:
Cvar_SetValue ("timelimit", timelimit.value + dir*5);
if (timelimit.value > 60)
Cvar_SetValue ("timelimit", 0);
if (timelimit.value < 0)
Cvar_SetValue ("timelimit", 60);
break;
case 7:
startlevel += dir;
count = 6;
if (startlevel < 0)
startlevel = count - 1;
if (startlevel >= count)
startlevel = 0;
break;
}
}
void M_GameOptions_Key (int key)
{
switch (key)
{
case K_ESCAPE:
M_Menu_Net_f ();
break;
case K_UPARROW:
S_LocalSound ("misc/menu1.wav");
gameoptions_cursor--;
if (gameoptions_cursor < 0)
gameoptions_cursor = NUM_GAMEOPTIONS-1;
break;
case K_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
gameoptions_cursor++;
if (gameoptions_cursor >= NUM_GAMEOPTIONS)
gameoptions_cursor = 0;
break;
case K_LEFTARROW:
if (gameoptions_cursor == 0)
break;
S_LocalSound ("misc/menu3.wav");
M_NetStart_Change (-1);
break;
case K_RIGHTARROW:
if (gameoptions_cursor == 0)
break;
S_LocalSound ("misc/menu3.wav");
M_NetStart_Change (1);
break;
case K_ENTER:
S_LocalSound ("misc/menu2.wav");
if (gameoptions_cursor == 0)
{
if (sv.active)
Cbuf_AddText ("disconnect\n");
Cbuf_AddText ("listen 0\n"); // so host_netport will be re-examined
Cbuf_AddText ( va ("maxplayers %u\n", maxplayers) );
SCR_BeginLoadingPlaque ();
if (coop.value)
Cbuf_AddText (va("map %s\n", levels[startlevel + 6].name));
else
Cbuf_AddText (va("map %s\n", levels[startlevel].name));
return;
}
M_NetStart_Change (1);
break;
}
}
//=============================================================================
/* SEARCH MENU */
qboolean searchComplete = false;
double searchCompleteTime;
void M_Menu_Search_f (void)
{
key_dest = key_menu;
m_state = m_search;
m_entersound = false;
slistSilent = true;
slistLocal = false;
searchComplete = false;
NET_Slist_f();
}
//new M_Search_Draw
void M_Search_Draw (void)
{
qpic_t *p;
int x;
x = -104;
p = Draw_CachePic ("gfx/p_multi.lmp");
C_DrawPic (x,(-1 * (p->height + 14)), p);
C_DrawTextBox (-48, -10, 12, 1);
C_Print (-40, -2, "Searching...");
if(slistInProgress)
{
NET_Poll();
return;
}
if (! searchComplete)
{
searchComplete = true;
searchCompleteTime = realtime;
}
if (hostCacheCount)
{
M_Menu_ServerList_f ();
return;
}
C_PrintWhite (-112, 22, "No Eternal War servers found");
if ((realtime - searchCompleteTime) < 3.0)
return;
M_Menu_LanConfig_f ();
}
/*
//old M_Search_Draw
void M_Search_Draw (void)
{
qpic_t *p;
int x;
p = Draw_CachePic ("gfx/p_multi.lmp");
M_DrawPic ( (320-p->width)/2, 4, p);
x = 116; // Tomaz - Speed
M_DrawTextBox (x-8, 32, 12, 1);
M_Print (x, 40, "Searching...");
if(slistInProgress)
{
NET_Poll();
return;
}
if (! searchComplete)
{
searchComplete = true;
searchCompleteTime = realtime;
}
if (hostCacheCount)
{
M_Menu_ServerList_f ();
return;
}
M_PrintWhite (72, 64, "No Eternal War servers found"); // Tomaz - Speed
if ((realtime - searchCompleteTime) < 3.0)
return;
M_Menu_LanConfig_f ();
}
*/
void M_Search_Key (int key)
{
}
//=============================================================================
/* SLIST MENU */
int slist_cursor;
qboolean slist_sorted;
void M_Menu_ServerList_f (void)
{
key_dest = key_menu;
m_state = m_slist;
m_entersound = true;
slist_cursor = 0;
m_return_onerror = false;
m_return_reason[0] = 0;
slist_sorted = false;
}
//new M_ServerList_Draw
void M_ServerList_Draw (void)
{
int basex, n;
char string [64];
qpic_t *p;
basex = -104;
if (!slist_sorted)
{
if (hostCacheCount > 1)
{
int i,j;
hostcache_t temp;
for (i = 0; i < hostCacheCount; i++)
for (j = i+1; j < hostCacheCount; j++)
if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
{
Q_memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
Q_memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t));
Q_memcpy(&hostcache[i], &temp, sizeof(hostcache_t));
}
}
slist_sorted = true;
}
p = Draw_CachePic ("gfx/p_multi.lmp");
C_DrawPic (basex,(-1 * (p->height + 14)), p);
for (n = 0; n < hostCacheCount; n++)
{
if (hostcache[n].maxusers)
sprintf(string, "%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers);
else
sprintf(string, "%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map);
C_Print (basex, -10 + 8*n, string);
}
C_DrawCharacter ((basex - 16), -10 + slist_cursor*8, 12+((int)(realtime*4)&1));
if (*m_return_reason)
C_PrintWhite (basex, 148, m_return_reason);
}
/*
//old M_ServerList_Draw
void M_ServerList_Draw (void)
{
int n;
char string [64];
qpic_t *p;
if (!slist_sorted)
{
if (hostCacheCount > 1)
{
int i,j;
hostcache_t temp;
for (i = 0; i < hostCacheCount; i++)
for (j = i+1; j < hostCacheCount; j++)
if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
{
Q_memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
Q_memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t));
Q_memcpy(&hostcache[i], &temp, sizeof(hostcache_t));
}
}
slist_sorted = true;
}
p = Draw_CachePic ("gfx/p_multi.lmp");
M_DrawPic ( (320-p->width)/2, 4, p);
for (n = 0; n < hostCacheCount; n++)
{
if (hostcache[n].maxusers)
sprintf(string, "%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers);
else
sprintf(string, "%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map);
M_Print (16, 32 + 8*n, string);
}
M_DrawCharacter (0, 32 + slist_cursor*8, 12+((int)(realtime*4)&1));
if (*m_return_reason)
M_PrintWhite (16, 148, m_return_reason);
}
*/
void M_ServerList_Key (int k)
{
switch (k)
{
case K_ESCAPE:
M_Menu_LanConfig_f ();
break;
case K_SPACE:
M_Menu_Search_f ();
break;
case K_UPARROW:
case K_LEFTARROW:
S_LocalSound ("misc/menu1.wav");
slist_cursor--;
if (slist_cursor < 0)
slist_cursor = hostCacheCount - 1;
break;
case K_DOWNARROW:
case K_RIGHTARROW:
S_LocalSound ("misc/menu1.wav");
slist_cursor++;
if (slist_cursor >= hostCacheCount)
slist_cursor = 0;
break;
case K_ENTER:
S_LocalSound ("misc/menu2.wav");
m_return_state = m_state;
m_return_onerror = true;
slist_sorted = false;
key_dest = key_game;
m_state = m_none;
Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname) );
break;
default:
break;
}
}
//=============================================================================
/* Menu Subsystem */
void M_ConfigureNetSubsystem(void)
{
// enable/disable net systems to match desired config
Cbuf_AddText ("stopdemo\n");
if (SerialConfig || DirectConfig)
{
Cbuf_AddText ("com1 enable\n");
}
if (IPXConfig || TCPIPConfig)
net_hostport = lanConfig_port;
}