mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2025-04-01 10:11:49 +00:00
[PATCH] Remove IPX and Serial network code from NQ.
Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
parent
71aa7fefff
commit
15725036a8
1
Makefile
1
Makefile
@ -393,7 +393,6 @@ NQ_W32_C_OBJS = \
|
||||
in_win.o \
|
||||
net_win.o \
|
||||
net_wins.o \
|
||||
net_wipx.o \
|
||||
snd_win.o \
|
||||
sys_win.o
|
||||
|
||||
|
@ -89,8 +89,6 @@ Host_Status_f(void)
|
||||
print("version: TyrQuake-%s\n", stringify(TYR_VERSION));
|
||||
if (tcpipAvailable)
|
||||
print("tcp/ip: %s\n", my_tcpip_address);
|
||||
if (ipxAvailable)
|
||||
print("ipx: %s\n", my_ipx_address);
|
||||
print("map: %s\n", sv.name);
|
||||
print("players: %i active (%i max)\n\n", net_activeconnections,
|
||||
svs.maxclients);
|
||||
|
710
NQ/menu.c
710
NQ/menu.c
@ -47,12 +47,9 @@ static void M_Menu_Load_f(void);
|
||||
static void M_Menu_Save_f(void);
|
||||
static void M_Menu_MultiPlayer_f(void);
|
||||
static void M_Menu_Setup_f(void);
|
||||
static void M_Menu_Net_f(void);
|
||||
static void M_Menu_Keys_f(void);
|
||||
static void M_Menu_Video_f(void);
|
||||
static void M_Menu_Help_f(void);
|
||||
static void M_Menu_SerialConfig_f(void);
|
||||
static void M_Menu_ModemConfig_f(void);
|
||||
static void M_Menu_LanConfig_f(void);
|
||||
static void M_Menu_GameOptions_f(void);
|
||||
static void M_Menu_Search_f(void);
|
||||
@ -64,14 +61,11 @@ static void M_Load_Draw(void);
|
||||
static void M_Save_Draw(void);
|
||||
static void M_MultiPlayer_Draw(void);
|
||||
static void M_Setup_Draw(void);
|
||||
static void M_Net_Draw(void);
|
||||
static void M_Options_Draw(void);
|
||||
static void M_Keys_Draw(void);
|
||||
static void M_Video_Draw(void);
|
||||
static void M_Help_Draw(void);
|
||||
static void M_Quit_Draw(void);
|
||||
static void M_SerialConfig_Draw(void);
|
||||
static void M_ModemConfig_Draw(void);
|
||||
static void M_LanConfig_Draw(void);
|
||||
static void M_GameOptions_Draw(void);
|
||||
static void M_Search_Draw(void);
|
||||
@ -83,14 +77,11 @@ static void M_Load_Key(int key);
|
||||
static void M_Save_Key(int key);
|
||||
static void M_MultiPlayer_Key(int key);
|
||||
static void M_Setup_Key(int key);
|
||||
static void M_Net_Key(int key);
|
||||
static void M_Options_Key(int key);
|
||||
static void M_Keys_Key(int key);
|
||||
static void M_Video_Key(int key);
|
||||
static void M_Help_Key(int key);
|
||||
static void M_Quit_Key(int key);
|
||||
static void M_SerialConfig_Key(int key);
|
||||
static void M_ModemConfig_Key(int key);
|
||||
static void M_LanConfig_Key(int key);
|
||||
static void M_GameOptions_Key(int key);
|
||||
static void M_Search_Key(int key);
|
||||
@ -106,10 +97,6 @@ int m_return_state;
|
||||
|
||||
#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)
|
||||
|
||||
static void M_ConfigureNetSubsystem(void);
|
||||
|
||||
@ -653,7 +640,7 @@ M_MultiPlayer_Draw(void)
|
||||
M_DrawTransPic(54, 32 + m_multiplayer_cursor * 20,
|
||||
Draw_CachePic(va("gfx/menudot%i.lmp", f + 1)));
|
||||
|
||||
if (serialAvailable || ipxAvailable || tcpipAvailable)
|
||||
if (tcpipAvailable)
|
||||
return;
|
||||
M_PrintWhite((320 / 2) - ((27 * 8) / 2), 148,
|
||||
"No Communications Available");
|
||||
@ -684,13 +671,13 @@ M_MultiPlayer_Key(int key)
|
||||
m_entersound = true;
|
||||
switch (m_multiplayer_cursor) {
|
||||
case 0:
|
||||
if (serialAvailable || ipxAvailable || tcpipAvailable)
|
||||
M_Menu_Net_f();
|
||||
if (tcpipAvailable)
|
||||
M_Menu_LanConfig_f();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (serialAvailable || ipxAvailable || tcpipAvailable)
|
||||
M_Menu_Net_f();
|
||||
if (tcpipAvailable)
|
||||
M_Menu_LanConfig_f();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@ -875,181 +862,6 @@ M_Setup_Key(int k)
|
||||
setup_bottom = 13;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/* NET MENU */
|
||||
|
||||
static int m_net_cursor;
|
||||
static int m_net_items;
|
||||
|
||||
static const char *const net_helpMessage[] = {
|
||||
" ",
|
||||
" 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. "
|
||||
};
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
M_Net_Draw(void)
|
||||
{
|
||||
int f;
|
||||
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);
|
||||
|
||||
f = 32;
|
||||
|
||||
if (serialAvailable) {
|
||||
p = Draw_CachePic("gfx/netmen1.lmp");
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
p = NULL;
|
||||
#else
|
||||
p = Draw_CachePic("gfx/dim_modm.lmp");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (p)
|
||||
M_DrawTransPic(72, f, p);
|
||||
|
||||
f += 19;
|
||||
|
||||
if (serialAvailable) {
|
||||
p = Draw_CachePic("gfx/netmen2.lmp");
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
p = NULL;
|
||||
#else
|
||||
p = Draw_CachePic("gfx/dim_drct.lmp");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (p)
|
||||
M_DrawTransPic(72, f, p);
|
||||
|
||||
f += 19;
|
||||
if (ipxAvailable)
|
||||
p = Draw_CachePic("gfx/netmen3.lmp");
|
||||
else
|
||||
p = Draw_CachePic("gfx/dim_ipx.lmp");
|
||||
M_DrawTransPic(72, f, p);
|
||||
|
||||
f += 19;
|
||||
if (tcpipAvailable)
|
||||
p = Draw_CachePic("gfx/netmen4.lmp");
|
||||
else
|
||||
p = Draw_CachePic("gfx/dim_tcp.lmp");
|
||||
M_DrawTransPic(72, f, p);
|
||||
|
||||
if (m_net_items == 5) // JDC, could just be removed
|
||||
{
|
||||
f += 19;
|
||||
p = Draw_CachePic("gfx/netmen5.lmp");
|
||||
M_DrawTransPic(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_DrawTransPic(54, 32 + m_net_cursor * 20,
|
||||
Draw_CachePic(va("gfx/menudot%i.lmp", f + 1)));
|
||||
}
|
||||
|
||||
|
||||
static 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;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/* OPTIONS MENU */
|
||||
|
||||
@ -1683,468 +1495,6 @@ M_Quit_Draw(void)
|
||||
M_Print(64, 108, quitMessage[msgNumber * 4 + 3]);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/* SERIAL CONFIG MENU */
|
||||
|
||||
static int serialConfig_cursor;
|
||||
static 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 };
|
||||
static int serialConfig_baudrate[] =
|
||||
{ 9600, 14400, 19200, 28800, 38400, 57600 };
|
||||
|
||||
static int serialConfig_comport;
|
||||
static int serialConfig_irq;
|
||||
static int serialConfig_baud;
|
||||
static char serialConfig_phone[16];
|
||||
|
||||
static 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;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
M_SerialConfig_Draw(void)
|
||||
{
|
||||
qpic_t *p;
|
||||
int basex;
|
||||
char *startJoin;
|
||||
char *directModem;
|
||||
|
||||
M_DrawTransPic(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);
|
||||
}
|
||||
|
||||
|
||||
static 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 */
|
||||
|
||||
static int modemConfig_cursor;
|
||||
static int modemConfig_cursor_table[] = { 40, 56, 88, 120, 156 };
|
||||
|
||||
#define NUM_MODEMCONFIG_CMDS 5
|
||||
|
||||
static char modemConfig_dialing;
|
||||
static char modemConfig_clear[16];
|
||||
static char modemConfig_init[32];
|
||||
static char modemConfig_hangup[16];
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
M_ModemConfig_Draw(void)
|
||||
{
|
||||
qpic_t *p;
|
||||
int basex;
|
||||
|
||||
M_DrawTransPic(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));
|
||||
}
|
||||
|
||||
|
||||
static 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 */
|
||||
|
||||
@ -2164,7 +1514,7 @@ M_Menu_LanConfig_f(void)
|
||||
m_state = m_lanconfig;
|
||||
m_entersound = true;
|
||||
if (lanConfig_cursor == -1) {
|
||||
if (JoiningGame && TCPIPConfig)
|
||||
if (JoiningGame)
|
||||
lanConfig_cursor = 2;
|
||||
else
|
||||
lanConfig_cursor = 1;
|
||||
@ -2196,18 +1546,12 @@ M_LanConfig_Draw(void)
|
||||
startJoin = "New Game";
|
||||
else
|
||||
startJoin = "Join Game";
|
||||
if (IPXConfig)
|
||||
protocol = "IPX";
|
||||
else
|
||||
protocol = "TCP/IP";
|
||||
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 + 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);
|
||||
@ -2249,7 +1593,7 @@ M_LanConfig_Key(int key)
|
||||
|
||||
switch (key) {
|
||||
case K_ESCAPE:
|
||||
M_Menu_Net_f();
|
||||
M_Menu_MultiPlayer_f();
|
||||
break;
|
||||
|
||||
case K_UPARROW:
|
||||
@ -2759,7 +2103,7 @@ M_GameOptions_Key(int key)
|
||||
{
|
||||
switch (key) {
|
||||
case K_ESCAPE:
|
||||
M_Menu_Net_f();
|
||||
M_Menu_MultiPlayer_f();
|
||||
break;
|
||||
|
||||
case K_UPARROW:
|
||||
@ -3059,10 +2403,6 @@ M_Draw(void)
|
||||
M_Setup_Draw();
|
||||
break;
|
||||
|
||||
case m_net:
|
||||
M_Net_Draw();
|
||||
break;
|
||||
|
||||
case m_options:
|
||||
M_Options_Draw();
|
||||
break;
|
||||
@ -3083,14 +2423,6 @@ M_Draw(void)
|
||||
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;
|
||||
@ -3150,10 +2482,6 @@ M_Keydown(int key)
|
||||
M_Setup_Key(key);
|
||||
return;
|
||||
|
||||
case m_net:
|
||||
M_Net_Key(key);
|
||||
return;
|
||||
|
||||
case m_options:
|
||||
M_Options_Key(key);
|
||||
return;
|
||||
@ -3174,14 +2502,6 @@ M_Keydown(int key)
|
||||
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;
|
||||
@ -3204,13 +2524,7 @@ M_Keydown(int key)
|
||||
static void
|
||||
M_ConfigureNetSubsystem(void)
|
||||
{
|
||||
// enable/disable net systems to match desired config
|
||||
|
||||
/* 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;
|
||||
net_hostport = lanConfig_port;
|
||||
}
|
||||
|
14
NQ/menu.h
14
NQ/menu.h
@ -23,15 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "wad.h"
|
||||
|
||||
//
|
||||
// the net drivers should just set the apropriate bits in m_activenet,
|
||||
// instead of having the menu code look through their internal tables
|
||||
//
|
||||
#define MNET_IPX 1
|
||||
#define MNET_TCP 2
|
||||
|
||||
extern int m_activenet;
|
||||
|
||||
//
|
||||
// menus
|
||||
//
|
||||
@ -55,9 +46,8 @@ extern char m_return_reason[32];
|
||||
extern int m_return_state;
|
||||
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_slist
|
||||
m_options, m_video, m_keys, m_help, m_quit, m_lanconfig, m_gameoptions,
|
||||
m_search, m_slist
|
||||
} m_state;
|
||||
|
||||
#endif /* MENU_H */
|
||||
|
12
NQ/net.h
12
NQ/net.h
@ -315,21 +315,9 @@ typedef struct _PollProcedure {
|
||||
|
||||
void SchedulePollProcedure(PollProcedure *pp, double timeOffset);
|
||||
|
||||
extern qboolean serialAvailable;
|
||||
extern qboolean ipxAvailable;
|
||||
extern qboolean tcpipAvailable;
|
||||
extern char my_ipx_address[NET_NAMELEN];
|
||||
extern char my_tcpip_address[NET_NAMELEN];
|
||||
|
||||
extern void (*GetComPortConfig)(int portNumber, int *port, int *irq,
|
||||
int *baud, qboolean *useModem);
|
||||
extern void (*SetComPortConfig)(int portNumber, int port, int irq, int baud,
|
||||
qboolean useModem);
|
||||
extern void (*GetModemConfig)(int portNumber, char *dialType, char *clear,
|
||||
char *init, char *hangup);
|
||||
extern void (*SetModemConfig)(int portNumber, char *dialType, char *clear,
|
||||
char *init, char *hangup);
|
||||
|
||||
extern qboolean slistInProgress;
|
||||
extern qboolean slistSilent;
|
||||
extern qboolean slistLocal;
|
||||
|
@ -30,25 +30,13 @@ qsocket_t *net_activeSockets = NULL;
|
||||
qsocket_t *net_freeSockets = NULL;
|
||||
static int net_numsockets = 0;
|
||||
|
||||
qboolean serialAvailable = false;
|
||||
qboolean ipxAvailable = false;
|
||||
qboolean tcpipAvailable = false;
|
||||
|
||||
int net_hostport;
|
||||
int DEFAULTnet_hostport = 26000;
|
||||
|
||||
char my_ipx_address[NET_NAMELEN];
|
||||
char my_tcpip_address[NET_NAMELEN];
|
||||
|
||||
void (*GetComPortConfig)(int portNumber, int *port, int *irq,
|
||||
int *baud, qboolean *useModem);
|
||||
void (*SetComPortConfig)(int portNumber, int port, int irq, int baud,
|
||||
qboolean useModem);
|
||||
void (*GetModemConfig)(int portNumber, char *dialType, char *clear,
|
||||
char *init, char *hangup);
|
||||
void (*SetModemConfig)(int portNumber, char *dialType, char *clear,
|
||||
char *init, char *hangup);
|
||||
|
||||
static qboolean listening = false;
|
||||
|
||||
qboolean slistInProgress = false;
|
||||
@ -75,16 +63,6 @@ int unreliableMessagesReceived = 0;
|
||||
cvar_t net_messagetimeout = { "net_messagetimeout", "300" };
|
||||
cvar_t hostname = { "hostname", "UNNAMED" };
|
||||
|
||||
qboolean configRestored = false;
|
||||
cvar_t config_com_port = { "_config_com_port", "0x3f8", true };
|
||||
cvar_t config_com_irq = { "_config_com_irq", "4", true };
|
||||
cvar_t config_com_baud = { "_config_com_baud", "57600", true };
|
||||
cvar_t config_com_modem = { "_config_com_modem", "1", true };
|
||||
cvar_t config_modem_dialtype = { "_config_modem_dialtype", "T", true };
|
||||
cvar_t config_modem_clear = { "_config_modem_clear", "ATZ", true };
|
||||
cvar_t config_modem_init = { "_config_modem_init", "", true };
|
||||
cvar_t config_modem_hangup = { "_config_modem_hangup", "AT H", true };
|
||||
|
||||
net_driver_t *net_driver;
|
||||
double net_time;
|
||||
|
||||
@ -711,8 +689,6 @@ NET_Init(void)
|
||||
i = COM_CheckParm("-port");
|
||||
if (!i)
|
||||
i = COM_CheckParm("-udpport");
|
||||
if (!i)
|
||||
i = COM_CheckParm("-ipxport");
|
||||
|
||||
if (i) {
|
||||
if (i < com_argc - 1)
|
||||
@ -742,14 +718,6 @@ NET_Init(void)
|
||||
|
||||
Cvar_RegisterVariable(&net_messagetimeout);
|
||||
Cvar_RegisterVariable(&hostname);
|
||||
Cvar_RegisterVariable(&config_com_port);
|
||||
Cvar_RegisterVariable(&config_com_irq);
|
||||
Cvar_RegisterVariable(&config_com_baud);
|
||||
Cvar_RegisterVariable(&config_com_modem);
|
||||
Cvar_RegisterVariable(&config_modem_dialtype);
|
||||
Cvar_RegisterVariable(&config_modem_clear);
|
||||
Cvar_RegisterVariable(&config_modem_init);
|
||||
Cvar_RegisterVariable(&config_modem_hangup);
|
||||
|
||||
Cmd_AddCommand("slist", NET_Slist_f);
|
||||
Cmd_AddCommand("listen", NET_Listen_f);
|
||||
@ -768,8 +736,6 @@ NET_Init(void)
|
||||
net_driver->Listen(true);
|
||||
}
|
||||
|
||||
if (*my_ipx_address)
|
||||
Con_DPrintf("IPX address %s\n", my_ipx_address);
|
||||
if (*my_tcpip_address)
|
||||
Con_DPrintf("TCP/IP address %s\n", my_tcpip_address);
|
||||
}
|
||||
@ -809,24 +775,6 @@ void
|
||||
NET_Poll(void)
|
||||
{
|
||||
PollProcedure *pp;
|
||||
qboolean useModem;
|
||||
|
||||
if (!configRestored) {
|
||||
if (serialAvailable) {
|
||||
if (config_com_modem.value == 1.0)
|
||||
useModem = true;
|
||||
else
|
||||
useModem = false;
|
||||
SetComPortConfig(0, (int)config_com_port.value,
|
||||
(int)config_com_irq.value,
|
||||
(int)config_com_baud.value, useModem);
|
||||
SetModemConfig(0, config_modem_dialtype.string,
|
||||
config_modem_clear.string,
|
||||
config_modem_init.string,
|
||||
config_modem_hangup.string);
|
||||
}
|
||||
configRestored = true;
|
||||
}
|
||||
|
||||
SetNetTime();
|
||||
|
||||
|
41
NQ/net_ser.h
41
NQ/net_ser.h
@ -1,41 +0,0 @@
|
||||
/*
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NET_SER_H
|
||||
#define NET_SER_H
|
||||
|
||||
#include "common.h"
|
||||
#include "net.h"
|
||||
#include "qtypes.h"
|
||||
|
||||
int Serial_Init(void);
|
||||
void Serial_Listen(qboolean state);
|
||||
void Serial_SearchForHosts(qboolean xmit);
|
||||
qsocket_t *Serial_Connect(char *host);
|
||||
qsocket_t *Serial_CheckNewConnections(void);
|
||||
int Serial_GetMessage(qsocket_t *sock);
|
||||
int Serial_SendMessage(qsocket_t *sock, sizebuf_t *data);
|
||||
int Serial_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data);
|
||||
qboolean Serial_CanSendMessage(qsocket_t *sock);
|
||||
qboolean Serial_CanSendUnreliableMessage(qsocket_t *sock);
|
||||
void Serial_Close(qsocket_t *sock);
|
||||
void Serial_Shutdown(void);
|
||||
|
||||
#endif /* NET_SER_H */
|
26
NQ/net_win.c
26
NQ/net_win.c
@ -21,9 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#include "net.h"
|
||||
#include "net_dgrm.h"
|
||||
#include "net_loop.h"
|
||||
#include "net_ser.h"
|
||||
#include "net_wins.h"
|
||||
#include "net_wipx.h"
|
||||
|
||||
#include "quakedef.h"
|
||||
|
||||
@ -87,29 +85,7 @@ net_landriver_t net_landrivers[MAX_NET_DRIVERS] = {
|
||||
.AddrCompare = WINS_AddrCompare,
|
||||
.GetSocketPort = WINS_GetSocketPort,
|
||||
.SetSocketPort = WINS_SetSocketPort
|
||||
}, {
|
||||
.name = "Winsock IPX",
|
||||
.initialized = false,
|
||||
.controlSock = 0,
|
||||
.Init = WIPX_Init,
|
||||
.Shutdown = WIPX_Shutdown,
|
||||
.Listen = WIPX_Listen,
|
||||
.OpenSocket = WIPX_OpenSocket,
|
||||
.CloseSocket = WIPX_CloseSocket,
|
||||
.Connect = WIPX_Connect,
|
||||
.CheckNewConnections = WIPX_CheckNewConnections,
|
||||
.Read = WIPX_Read,
|
||||
.Write = WIPX_Write,
|
||||
.Broadcast = WIPX_Broadcast,
|
||||
.AddrToString = WIPX_AddrToString,
|
||||
.StringToAddr = WIPX_StringToAddr,
|
||||
.GetSocketAddr = WIPX_GetSocketAddr,
|
||||
.GetNameFromAddr = WIPX_GetNameFromAddr,
|
||||
.GetAddrFromName = WIPX_GetAddrFromName,
|
||||
.AddrCompare = WIPX_AddrCompare,
|
||||
.GetSocketPort = WIPX_GetSocketPort,
|
||||
.SetSocketPort = WIPX_SetSocketPort
|
||||
}
|
||||
};
|
||||
|
||||
int net_numlandrivers = 2;
|
||||
int net_numlandrivers = 1;
|
||||
|
467
NQ/net_wipx.c
467
NQ/net_wipx.c
@ -1,467 +0,0 @@
|
||||
/*
|
||||
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.
|
||||
|
||||
*/
|
||||
// net_wipx.c
|
||||
|
||||
#include "console.h"
|
||||
#include "net.h"
|
||||
#include "quakedef.h"
|
||||
#include "sys.h"
|
||||
#include "winquake.h"
|
||||
|
||||
/* Needs to be after winquake.h?? - FIXME (remove it) */
|
||||
#include <wsipx.h>
|
||||
|
||||
#include "net_wipx.h"
|
||||
|
||||
/*
|
||||
// FIXME - End fix for missing wsipx.h in MinGW?
|
||||
struct sockaddr_ipx {
|
||||
short sa_family;
|
||||
char sa_netnum[4];
|
||||
char sa_nodenum[6];
|
||||
unsigned short sa_socket;
|
||||
};
|
||||
#define NSPROTO_IPX 1000
|
||||
*/
|
||||
|
||||
#include "net_wipx.h"
|
||||
|
||||
static int net_acceptsocket = -1; // socket for fielding new connections
|
||||
static int net_controlsocket;
|
||||
static struct qsockaddr broadcastaddr;
|
||||
|
||||
#define IPXSOCKETS 18
|
||||
static int ipxsocket[IPXSOCKETS];
|
||||
static int sequence[IPXSOCKETS];
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_Init(void)
|
||||
{
|
||||
int i;
|
||||
char buff[MAXHOSTNAMELEN];
|
||||
struct qsockaddr addr;
|
||||
char *p;
|
||||
int r;
|
||||
WORD wVersionRequested;
|
||||
|
||||
if (COM_CheckParm("-noipx"))
|
||||
return -1;
|
||||
|
||||
// make sure LoadLibrary has happened successfully
|
||||
if (!winsock_lib_initialized)
|
||||
return -1;
|
||||
|
||||
if (winsock_initialized == 0) {
|
||||
wVersionRequested = MAKEWORD(1, 1);
|
||||
|
||||
r = pWSAStartup(MAKEWORD(1, 1), &winsockdata);
|
||||
|
||||
if (r) {
|
||||
Con_Printf("Winsock initialization failed.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
winsock_initialized++;
|
||||
|
||||
for (i = 0; i < IPXSOCKETS; i++)
|
||||
ipxsocket[i] = 0;
|
||||
|
||||
// determine my name & address
|
||||
if (pgethostname(buff, MAXHOSTNAMELEN) == 0) {
|
||||
// if the quake hostname isn't set, set it to the machine name
|
||||
if (strcmp(hostname.string, "UNNAMED") == 0) {
|
||||
// see if it's a text IP address (well, close enough)
|
||||
for (p = buff; *p; p++)
|
||||
if ((*p < '0' || *p > '9') && *p != '.')
|
||||
break;
|
||||
|
||||
// if it is a real name, strip off the domain; we only want the host
|
||||
if (*p) {
|
||||
for (i = 0; i < 15; i++)
|
||||
if (buff[i] == '.')
|
||||
break;
|
||||
buff[i] = 0;
|
||||
}
|
||||
Cvar_Set("hostname", buff);
|
||||
}
|
||||
}
|
||||
|
||||
if ((net_controlsocket = WIPX_OpenSocket(0)) == -1) {
|
||||
Con_Printf("WIPX_Init: Unable to open control socket\n");
|
||||
if (--winsock_initialized == 0)
|
||||
pWSACleanup();
|
||||
return -1;
|
||||
}
|
||||
|
||||
((struct sockaddr_ipx *)&broadcastaddr)->sa_family = AF_IPX;
|
||||
memset(((struct sockaddr_ipx *)&broadcastaddr)->sa_netnum, 0, 4);
|
||||
memset(((struct sockaddr_ipx *)&broadcastaddr)->sa_nodenum, 0xff, 6);
|
||||
((struct sockaddr_ipx *)&broadcastaddr)->sa_socket =
|
||||
htons((unsigned short)net_hostport);
|
||||
|
||||
WIPX_GetSocketAddr(net_controlsocket, &addr);
|
||||
strcpy(my_ipx_address, WIPX_AddrToString(&addr));
|
||||
p = strrchr(my_ipx_address, ':');
|
||||
if (p)
|
||||
*p = 0;
|
||||
|
||||
Con_Printf("Winsock IPX Initialized\n");
|
||||
ipxAvailable = true;
|
||||
|
||||
return net_controlsocket;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
void
|
||||
WIPX_Shutdown(void)
|
||||
{
|
||||
WIPX_Listen(false);
|
||||
WIPX_CloseSocket(net_controlsocket);
|
||||
if (--winsock_initialized == 0)
|
||||
pWSACleanup();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
void
|
||||
WIPX_Listen(qboolean state)
|
||||
{
|
||||
// enable listening
|
||||
if (state) {
|
||||
if (net_acceptsocket != -1)
|
||||
return;
|
||||
if ((net_acceptsocket = WIPX_OpenSocket(net_hostport)) == -1)
|
||||
Sys_Error("%s: Unable to open accept socket", __func__);
|
||||
return;
|
||||
}
|
||||
// disable listening
|
||||
if (net_acceptsocket == -1)
|
||||
return;
|
||||
WIPX_CloseSocket(net_acceptsocket);
|
||||
net_acceptsocket = -1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_OpenSocket(int port)
|
||||
{
|
||||
int handle;
|
||||
int newsocket;
|
||||
struct sockaddr_ipx address;
|
||||
u_long _true = 1;
|
||||
|
||||
for (handle = 0; handle < IPXSOCKETS; handle++)
|
||||
if (ipxsocket[handle] == 0)
|
||||
break;
|
||||
if (handle == IPXSOCKETS)
|
||||
return -1;
|
||||
|
||||
if ((newsocket =
|
||||
psocket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == INVALID_SOCKET)
|
||||
return -1;
|
||||
|
||||
if (pioctlsocket(newsocket, FIONBIO, &_true) == -1)
|
||||
goto ErrorReturn;
|
||||
|
||||
if (psetsockopt
|
||||
(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&_true,
|
||||
sizeof(_true)) < 0)
|
||||
goto ErrorReturn;
|
||||
|
||||
address.sa_family = AF_IPX;
|
||||
memset(address.sa_netnum, 0, 4);
|
||||
memset(address.sa_nodenum, 0, 6);;
|
||||
address.sa_socket = htons((unsigned short)port);
|
||||
if (bind(newsocket, (struct sockaddr *)&address, sizeof(address)) == 0) {
|
||||
ipxsocket[handle] = newsocket;
|
||||
sequence[handle] = 0;
|
||||
return handle;
|
||||
}
|
||||
|
||||
Sys_Error("Winsock IPX bind failed");
|
||||
ErrorReturn:
|
||||
pclosesocket(newsocket);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_CloseSocket(int handle)
|
||||
{
|
||||
int socket = ipxsocket[handle];
|
||||
int ret;
|
||||
|
||||
ret = pclosesocket(socket);
|
||||
ipxsocket[handle] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_Connect(int handle, struct qsockaddr *addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_CheckNewConnections(void)
|
||||
{
|
||||
unsigned long available;
|
||||
|
||||
if (net_acceptsocket == -1)
|
||||
return -1;
|
||||
|
||||
if (pioctlsocket(ipxsocket[net_acceptsocket], FIONREAD, &available) == -1)
|
||||
Sys_Error("%s: ioctlsocket (FIONREAD) failed", __func__);
|
||||
if (available)
|
||||
return net_acceptsocket;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
static byte packetBuffer[NET_DATAGRAMSIZE + 4];
|
||||
|
||||
int
|
||||
WIPX_Read(int handle, byte *buf, int len, struct qsockaddr *addr)
|
||||
{
|
||||
int addrlen = sizeof(struct qsockaddr);
|
||||
int socket = ipxsocket[handle];
|
||||
int ret;
|
||||
|
||||
ret =
|
||||
precvfrom(socket, packetBuffer, len + 4, 0, (struct sockaddr *)addr,
|
||||
&addrlen);
|
||||
if (ret == -1) {
|
||||
int err = pWSAGetLastError();
|
||||
|
||||
if (err == WSAEWOULDBLOCK || err == WSAECONNREFUSED)
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
if (ret < 4)
|
||||
return 0;
|
||||
|
||||
// remove sequence number, it's only needed for DOS IPX
|
||||
ret -= 4;
|
||||
memcpy(buf, packetBuffer + 4, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_Broadcast(int handle, byte *buf, int len)
|
||||
{
|
||||
return WIPX_Write(handle, buf, len, &broadcastaddr);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_Write(int handle, byte *buf, int len, struct qsockaddr *addr)
|
||||
{
|
||||
int socket = ipxsocket[handle];
|
||||
int ret;
|
||||
|
||||
// build packet with sequence number
|
||||
*(int *)(&packetBuffer[0]) = sequence[handle];
|
||||
sequence[handle]++;
|
||||
memcpy(&packetBuffer[4], buf, len);
|
||||
len += 4;
|
||||
|
||||
ret =
|
||||
psendto(socket, packetBuffer, len, 0, (struct sockaddr *)addr,
|
||||
sizeof(struct qsockaddr));
|
||||
if (ret == -1)
|
||||
if (pWSAGetLastError() == WSAEWOULDBLOCK)
|
||||
return 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
char *
|
||||
WIPX_AddrToString(struct qsockaddr *addr)
|
||||
{
|
||||
static char buf[28];
|
||||
|
||||
sprintf(buf, "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%u",
|
||||
((struct sockaddr_ipx *)addr)->sa_netnum[0] & 0xff,
|
||||
((struct sockaddr_ipx *)addr)->sa_netnum[1] & 0xff,
|
||||
((struct sockaddr_ipx *)addr)->sa_netnum[2] & 0xff,
|
||||
((struct sockaddr_ipx *)addr)->sa_netnum[3] & 0xff,
|
||||
((struct sockaddr_ipx *)addr)->sa_nodenum[0] & 0xff,
|
||||
((struct sockaddr_ipx *)addr)->sa_nodenum[1] & 0xff,
|
||||
((struct sockaddr_ipx *)addr)->sa_nodenum[2] & 0xff,
|
||||
((struct sockaddr_ipx *)addr)->sa_nodenum[3] & 0xff,
|
||||
((struct sockaddr_ipx *)addr)->sa_nodenum[4] & 0xff,
|
||||
((struct sockaddr_ipx *)addr)->sa_nodenum[5] & 0xff,
|
||||
ntohs(((struct sockaddr_ipx *)addr)->sa_socket)
|
||||
);
|
||||
return buf;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_StringToAddr(char *string, struct qsockaddr *addr)
|
||||
{
|
||||
int val;
|
||||
char buf[3];
|
||||
|
||||
buf[2] = 0;
|
||||
memset(addr, 0, sizeof(struct qsockaddr));
|
||||
addr->sa_family = AF_IPX;
|
||||
|
||||
#define DO(src,dest) \
|
||||
buf[0] = string[src]; \
|
||||
buf[1] = string[src + 1]; \
|
||||
if (sscanf (buf, "%x", &val) != 1) \
|
||||
return -1; \
|
||||
((struct sockaddr_ipx *)addr)->dest = val
|
||||
|
||||
DO(0, sa_netnum[0]);
|
||||
DO(2, sa_netnum[1]);
|
||||
DO(4, sa_netnum[2]);
|
||||
DO(6, sa_netnum[3]);
|
||||
DO(9, sa_nodenum[0]);
|
||||
DO(11, sa_nodenum[1]);
|
||||
DO(13, sa_nodenum[2]);
|
||||
DO(15, sa_nodenum[3]);
|
||||
DO(17, sa_nodenum[4]);
|
||||
DO(19, sa_nodenum[5]);
|
||||
#undef DO
|
||||
|
||||
sscanf(&string[22], "%u", &val);
|
||||
((struct sockaddr_ipx *)addr)->sa_socket = htons((unsigned short)val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_GetSocketAddr(int handle, struct qsockaddr *addr)
|
||||
{
|
||||
int socket = ipxsocket[handle];
|
||||
int addrlen = sizeof(struct qsockaddr);
|
||||
|
||||
memset(addr, 0, sizeof(struct qsockaddr));
|
||||
if (pgetsockname(socket, (struct sockaddr *)addr, &addrlen) != 0) {
|
||||
int err = pWSAGetLastError();
|
||||
|
||||
// FIXME - hack to get rid of unused warning
|
||||
// - find out what should really be done
|
||||
if (err)
|
||||
err = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_GetNameFromAddr(struct qsockaddr *addr, char *name)
|
||||
{
|
||||
strcpy(name, WIPX_AddrToString(addr));
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_GetAddrFromName(char *name, struct qsockaddr *addr)
|
||||
{
|
||||
int n;
|
||||
char buf[32];
|
||||
|
||||
n = strlen(name);
|
||||
|
||||
if (n == 12) {
|
||||
sprintf(buf, "00000000:%s:%u", name, net_hostport);
|
||||
return WIPX_StringToAddr(buf, addr);
|
||||
}
|
||||
if (n == 21) {
|
||||
sprintf(buf, "%s:%u", name, net_hostport);
|
||||
return WIPX_StringToAddr(buf, addr);
|
||||
}
|
||||
if (n > 21 && n <= 27)
|
||||
return WIPX_StringToAddr(name, addr);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_AddrCompare(struct qsockaddr *addr1, struct qsockaddr *addr2)
|
||||
{
|
||||
if (addr1->sa_family != addr2->sa_family)
|
||||
return -1;
|
||||
|
||||
if (*((struct sockaddr_ipx *)addr1)->sa_netnum
|
||||
&& *((struct sockaddr_ipx *)addr2)->sa_netnum)
|
||||
if (memcmp
|
||||
(((struct sockaddr_ipx *)addr1)->sa_netnum,
|
||||
((struct sockaddr_ipx *)addr2)->sa_netnum, 4) != 0)
|
||||
return -1;
|
||||
if (memcmp
|
||||
(((struct sockaddr_ipx *)addr1)->sa_nodenum,
|
||||
((struct sockaddr_ipx *)addr2)->sa_nodenum, 6) != 0)
|
||||
return -1;
|
||||
|
||||
if (((struct sockaddr_ipx *)addr1)->sa_socket !=
|
||||
((struct sockaddr_ipx *)addr2)->sa_socket)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
WIPX_GetSocketPort(struct qsockaddr *addr)
|
||||
{
|
||||
return ntohs(((struct sockaddr_ipx *)addr)->sa_socket);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
WIPX_SetSocketPort(struct qsockaddr *addr, int port)
|
||||
{
|
||||
((struct sockaddr_ipx *)addr)->sa_socket = htons((unsigned short)port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NET_WIPX_H
|
||||
#define NET_WIPX_H
|
||||
|
||||
// net_wipx.h
|
||||
|
||||
#include "net.h"
|
||||
|
||||
int WIPX_Init(void);
|
||||
void WIPX_Shutdown(void);
|
||||
void WIPX_Listen(qboolean state);
|
||||
int WIPX_OpenSocket(int port);
|
||||
int WIPX_CloseSocket(int socket);
|
||||
int WIPX_Connect(int socket, struct qsockaddr *addr);
|
||||
int WIPX_CheckNewConnections(void);
|
||||
int WIPX_Read(int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WIPX_Write(int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WIPX_Broadcast(int socket, byte *buf, int len);
|
||||
char *WIPX_AddrToString(struct qsockaddr *addr);
|
||||
int WIPX_StringToAddr(char *string, struct qsockaddr *addr);
|
||||
int WIPX_GetSocketAddr(int socket, struct qsockaddr *addr);
|
||||
int WIPX_GetNameFromAddr(struct qsockaddr *addr, char *name);
|
||||
int WIPX_GetAddrFromName(char *name, struct qsockaddr *addr);
|
||||
int WIPX_AddrCompare(struct qsockaddr *addr1, struct qsockaddr *addr2);
|
||||
int WIPX_GetSocketPort(struct qsockaddr *addr);
|
||||
int WIPX_SetSocketPort(struct qsockaddr *addr, int port);
|
||||
|
||||
#endif /* NET_WIPX_H */
|
Loading…
x
Reference in New Issue
Block a user