From c1a25efc7ecc82eb644203092a81c659aa523092 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 2 Jan 2006 00:00:08 +0000 Subject: Neater prefixes: NET_Client -> NET_CL_. NET_Server -> NET_SV_. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 239 --- src/d_net.c | 17 ++++++++++------- src/net_client.c | 49 ++++++++++++++++++++++++++----------------------- src/net_client.h | 11 +++++++---- src/net_server.c | 49 ++++++++++++++++++++++++++----------------------- src/net_server.h | 9 ++++++--- 5 files changed, 75 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/d_net.c b/src/d_net.c index f404d4ca..0e9fa253 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: d_net.c 238 2006-01-01 23:54:31Z fraggle $ +// $Id: d_net.c 239 2006-01-02 00:00:08Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -22,6 +22,9 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.12 2006/01/02 00:00:08 fraggle +// Neater prefixes: NET_Client -> NET_CL_. NET_Server -> NET_SV_. +// // Revision 1.11 2006/01/01 23:54:31 fraggle // Client disconnect code // @@ -70,7 +73,7 @@ //----------------------------------------------------------------------------- -static const char rcsid[] = "$Id: d_net.c 238 2006-01-01 23:54:31Z fraggle $"; +static const char rcsid[] = "$Id: d_net.c 239 2006-01-02 00:00:08Z fraggle $"; #include "m_menu.h" @@ -425,8 +428,8 @@ void NetUpdate (void) // Temporary hack - hook new client/server code into Doom - NET_ClientRun(); - NET_ServerRun(); + NET_CL_Run(); + NET_SV_Run(); // check time nowtime = I_GetTime ()/ticdup; @@ -621,13 +624,13 @@ void D_CheckNetGame (void) if (M_CheckParm("-server") > 0) { net_addr_t *addr; - NET_ServerInit(); + NET_SV_Init(); addr = net_loop_client_module.ResolveAddress(""); printf("address resolved: %p\n", addr); - if (NET_ClientConnect(addr)) + if (NET_CL_Connect(addr)) { printf("connected to local server\n"); } @@ -687,7 +690,7 @@ void D_QuitNetGame (void) if (debugfile) fclose (debugfile); - NET_ClientDisconnect(); + NET_CL_Disconnect(); if (!netgame || !usergame || consoleplayer == -1 || demoplayback) return; diff --git a/src/net_client.c b/src/net_client.c index e75ad2b2..d7bf4278 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_client.c 238 2006-01-01 23:54:31Z fraggle $ +// $Id: net_client.c 239 2006-01-02 00:00:08Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -21,6 +21,9 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.5 2006/01/02 00:00:08 fraggle +// Neater prefixes: NET_Client -> NET_CL_. NET_Server -> NET_SV_. +// // Revision 1.4 2006/01/01 23:54:31 fraggle // Client disconnect code // @@ -82,7 +85,7 @@ static int last_send_time; // data received while we are waiting for the game to start -static void ClientParseWaitingData(net_packet_t *packet) +static void NET_CL_ParseWaitingData(net_packet_t *packet) { unsigned int num_players; unsigned int is_controller; @@ -101,7 +104,7 @@ static void ClientParseWaitingData(net_packet_t *packet) // Received an ACK -static void ClientParseACK(net_packet_t *packet) +static void NET_CL_ParseACK(net_packet_t *packet) { net_packet_t *reply; @@ -122,7 +125,7 @@ static void ClientParseACK(net_packet_t *packet) // parse a DISCONNECT packet -static void ClientParseDisconnect(net_packet_t *packet) +static void NET_CL_ParseDisconnect(net_packet_t *packet) { net_packet_t *reply; @@ -144,7 +147,7 @@ static void ClientParseDisconnect(net_packet_t *packet) // parse a DISCONNECT_ACK packet -static void ClientParseDisconnectACK(net_packet_t *packet) +static void NET_CL_ParseDisconnectACK(net_packet_t *packet) { if (client_state == CLIENT_STATE_DISCONNECTING) { @@ -158,7 +161,7 @@ static void ClientParseDisconnectACK(net_packet_t *packet) // parse a received packet -static void ClientParsePacket(net_packet_t *packet) +static void NET_CL_ParsePacket(net_packet_t *packet) { unsigned int packet_type; @@ -173,12 +176,12 @@ static void ClientParsePacket(net_packet_t *packet) // received an acknowledgement to the SYN we sent - ClientParseACK(packet); + NET_CL_ParseACK(packet); break; case NET_PACKET_TYPE_WAITING_DATA: - ClientParseWaitingData(packet); + NET_CL_ParseWaitingData(packet); break; case NET_PACKET_TYPE_GAMESTART: @@ -188,11 +191,11 @@ static void ClientParsePacket(net_packet_t *packet) break; case NET_PACKET_TYPE_DISCONNECT: - ClientParseDisconnect(packet); + NET_CL_ParseDisconnect(packet); break; case NET_PACKET_TYPE_DISCONNECT_ACK: - ClientParseDisconnectACK(packet); + NET_CL_ParseDisconnectACK(packet); break; default: @@ -202,7 +205,7 @@ static void ClientParsePacket(net_packet_t *packet) // called when we are in the "connecting" state -static void ClientConnecting(void) +static void NET_CL_Connecting(void) { net_packet_t *packet; @@ -235,7 +238,7 @@ static void ClientConnecting(void) // Called when we are in the "disconnecting" state, disconnecting from // the server. -static void ClientDisconnecting(void) +static void NET_CL_Disconnecting(void) { net_packet_t *packet; @@ -264,7 +267,7 @@ static void ClientDisconnecting(void) // "Run" the client code: check for new packets, send packets as // needed -void NET_ClientRun(void) +void NET_CL_Run(void) { net_addr_t *addr; net_packet_t *packet; @@ -280,7 +283,7 @@ void NET_ClientRun(void) if (addr == server_addr) { - ClientParsePacket(packet); + NET_CL_ParsePacket(packet); } NET_FreePacket(packet); @@ -291,10 +294,10 @@ void NET_ClientRun(void) switch (client_state) { case CLIENT_STATE_CONNECTING: - ClientConnecting(); + NET_CL_Connecting(); break; case CLIENT_STATE_DISCONNECTING: - ClientDisconnecting(); + NET_CL_Disconnecting(); break; default: break; @@ -303,7 +306,7 @@ void NET_ClientRun(void) // connect to a server -boolean NET_ClientConnect(net_addr_t *addr) +boolean NET_CL_Connect(net_addr_t *addr) { int start_time; @@ -343,12 +346,12 @@ boolean NET_ClientConnect(net_addr_t *addr) // run client code - NET_ClientRun(); + NET_CL_Run(); // run the server, just incase we are doing a loopback // connect - NET_ServerRun(); + NET_SV_Run(); // Don't hog the CPU @@ -371,7 +374,7 @@ boolean NET_ClientConnect(net_addr_t *addr) // disconnect from the server -void NET_ClientDisconnect(void) +void NET_CL_Disconnect(void) { int start_time; @@ -398,12 +401,12 @@ void NET_ClientDisconnect(void) client_state = CLIENT_STATE_DISCONNECTED; - fprintf(stderr, "NET_ClientDisconnect: Timeout while disconnecting from server\n"); + fprintf(stderr, "NET_CL_Disconnect: Timeout while disconnecting from server\n"); break; } - NET_ClientRun(); - NET_ServerRun(); + NET_CL_Run(); + NET_SV_Run(); I_Sleep(10); } diff --git a/src/net_client.h b/src/net_client.h index 7f3c08d5..b746a8e7 100644 --- a/src/net_client.h +++ b/src/net_client.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_client.h 238 2006-01-01 23:54:31Z fraggle $ +// $Id: net_client.h 239 2006-01-02 00:00:08Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -21,6 +21,9 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.5 2006/01/02 00:00:08 fraggle +// Neater prefixes: NET_Client -> NET_CL_. NET_Server -> NET_SV_. +// // Revision 1.4 2006/01/01 23:54:31 fraggle // Client disconnect code // @@ -45,9 +48,9 @@ #include "net_defs.h" -boolean NET_ClientConnect(net_addr_t *addr); -void NET_ClientDisconnect(void); -void NET_ClientRun(void); +boolean NET_CL_Connect(net_addr_t *addr); +void NET_CL_Disconnect(void); +void NET_CL_Run(void); #endif /* #ifndef NET_CLIENT_H */ diff --git a/src/net_server.c b/src/net_server.c index 85c4eeed..28e52260 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_server.c 238 2006-01-01 23:54:31Z fraggle $ +// $Id: net_server.c 239 2006-01-02 00:00:08Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -21,6 +21,9 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.5 2006/01/02 00:00:08 fraggle +// Neater prefixes: NET_Client -> NET_CL_. NET_Server -> NET_SV_. +// // Revision 1.4 2006/01/01 23:54:31 fraggle // Client disconnect code // @@ -100,7 +103,7 @@ static boolean ClientConnected(net_client_t *client) // returns the number of clients connected -static int ServerNumClients(void) +static int NET_SV_NumClients(void) { int count; int i; @@ -120,7 +123,7 @@ static int ServerNumClients(void) // returns a pointer to the client which controls the server -static net_client_t *ServerController(void) +static net_client_t *NET_SV_Controller(void) { int i; @@ -139,7 +142,7 @@ static net_client_t *ServerController(void) // Given an address, find the corresponding client -static net_client_t *ServerFindClient(net_addr_t *addr) +static net_client_t *NET_SV_FindClient(net_addr_t *addr) { int i; @@ -158,7 +161,7 @@ static net_client_t *ServerFindClient(net_addr_t *addr) // parse a SYN from a client(initiating a connection) -static void ServerParseSYN(net_packet_t *packet, +static void NET_SV_ParseSYN(net_packet_t *packet, net_client_t *client, net_addr_t *addr) { @@ -216,7 +219,7 @@ static void ServerParseSYN(net_packet_t *packet, // parse an ACK packet from a client -static void ServerParseACK(net_packet_t *packet, net_client_t *client) +static void NET_SV_ParseACK(net_packet_t *packet, net_client_t *client) { if (client == NULL) { @@ -235,7 +238,7 @@ static void ServerParseACK(net_packet_t *packet, net_client_t *client) } } -static void ServerParseDisconnect(net_packet_t *packet, net_client_t *client) +static void NET_SV_ParseDisconnect(net_packet_t *packet, net_client_t *client) { net_packet_t *reply; @@ -270,14 +273,14 @@ static void ServerParseDisconnect(net_packet_t *packet, net_client_t *client) // Process a packet received by the server -static void ServerPacket(net_packet_t *packet, net_addr_t *addr) +static void NET_SV_Packet(net_packet_t *packet, net_addr_t *addr) { net_client_t *client; unsigned int packet_type; // Find which client this packet came from - client = ServerFindClient(addr); + client = NET_SV_FindClient(addr); // Read the packet type @@ -291,17 +294,17 @@ static void ServerPacket(net_packet_t *packet, net_addr_t *addr) switch (packet_type) { case NET_PACKET_TYPE_SYN: - ServerParseSYN(packet, client, addr); + NET_SV_ParseSYN(packet, client, addr); break; case NET_PACKET_TYPE_ACK: - ServerParseACK(packet, client); + NET_SV_ParseACK(packet, client); break; case NET_PACKET_TYPE_GAMESTART: break; case NET_PACKET_TYPE_GAMEDATA: break; case NET_PACKET_TYPE_DISCONNECT: - ServerParseDisconnect(packet, client); + NET_SV_ParseDisconnect(packet, client); break; default: // unknown packet type @@ -312,14 +315,14 @@ static void ServerPacket(net_packet_t *packet, net_addr_t *addr) // If this address is not in the list of clients, be sure to // free it back. - if (ServerFindClient(addr) == NULL) + if (NET_SV_FindClient(addr) == NULL) { NET_FreeAddress(addr); } } -static void ServerSendWaitingData(net_client_t *client) +static void NET_SV_SendWaitingData(net_client_t *client) { net_packet_t *packet; @@ -330,11 +333,11 @@ static void ServerSendWaitingData(net_client_t *client) // include the number of clients waiting - NET_WriteInt8(packet, ServerNumClients()); + NET_WriteInt8(packet, NET_SV_NumClients()); // indicate whether the client is the controller - NET_WriteInt8(packet, ServerController() == client); + NET_WriteInt8(packet, NET_SV_Controller() == client); // send packet to client and free @@ -348,7 +351,7 @@ static void ServerSendWaitingData(net_client_t *client) // Perform any needed action on a client -static void ServerRunClient(net_client_t *client) +static void NET_SV_RunClient(net_client_t *client) { net_packet_t *packet; @@ -391,13 +394,13 @@ static void ServerRunClient(net_client_t *client) if (client->last_send_time < 0 || I_GetTimeMS() - client->last_send_time > 1000) { - ServerSendWaitingData(client); + NET_SV_SendWaitingData(client); } } // Client has disconnected. // - // See ServerParseDisconnect() above. + // See NET_SV_ParseDisconnect() above. if (client->state == CLIENT_STATE_DISCONNECTED) { @@ -413,7 +416,7 @@ static void ServerRunClient(net_client_t *client) // Initialise server and wait for connections -void NET_ServerInit(void) +void NET_SV_Init(void) { int i; @@ -436,7 +439,7 @@ void NET_ServerInit(void) // Run server code to check for new packets/send packets as the server // requires -void NET_ServerRun(void) +void NET_SV_Run(void) { net_addr_t *addr; net_packet_t *packet; @@ -449,7 +452,7 @@ void NET_ServerRun(void) while (NET_RecvPacket(server_context, &addr, &packet)) { - ServerPacket(packet, addr); + NET_SV_Packet(packet, addr); } // "Run" any clients that may have things to do, independent of responses @@ -459,7 +462,7 @@ void NET_ServerRun(void) { if (clients[i].active) { - ServerRunClient(&clients[i]); + NET_SV_RunClient(&clients[i]); } } } diff --git a/src/net_server.h b/src/net_server.h index 00e24531..21922919 100644 --- a/src/net_server.h +++ b/src/net_server.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_server.h 232 2005-12-29 17:48:25Z fraggle $ +// $Id: net_server.h 239 2006-01-02 00:00:08Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -21,6 +21,9 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.2 2006/01/02 00:00:08 fraggle +// Neater prefixes: NET_Client -> NET_CL_. NET_Server -> NET_SV_. +// // Revision 1.1 2005/12/29 17:48:25 fraggle // Add initial client/server connect code. Reorganise sources list in // Makefile.am. @@ -34,11 +37,11 @@ // initialise server and wait for connections -void NET_ServerInit(void); +void NET_SV_Init(void); // run server: check for new packets received etc. -void NET_ServerRun(void); +void NET_SV_Run(void); #endif /* #ifndef NET_SERVER_H */ -- cgit v1.2.3