diff options
Diffstat (limited to 'src/net_server.c')
-rw-r--r-- | src/net_server.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/net_server.c b/src/net_server.c index 43584170..3d5df135 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -21,14 +21,15 @@ // Network server code // +#include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #include "config.h" -#include "doomdef.h" -#include "doomstat.h" +#include "doomtype.h" +#include "d_mode.h" #include "i_system.h" #include "i_timer.h" @@ -456,10 +457,8 @@ static void NET_SV_ParseSYN(net_packet_t *packet, net_addr_t *addr) { unsigned int magic; - unsigned int cl_gamemode, cl_gamemission; - unsigned int cl_recording_lowres; - unsigned int cl_drone; unsigned int is_freedoom; + net_connect_data_t data; md5_digest_t deh_md5sum, wad_md5sum; char *player_name; char *client_version; @@ -510,10 +509,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, // read the game mode and mission - if (!NET_ReadInt16(packet, &cl_gamemode) - || !NET_ReadInt16(packet, &cl_gamemission) - || !NET_ReadInt8(packet, &cl_recording_lowres) - || !NET_ReadInt8(packet, &cl_drone) + if (!NET_ReadConnectData(packet, &data) || !NET_ReadMD5Sum(packet, wad_md5sum) || !NET_ReadMD5Sum(packet, deh_md5sum) || !NET_ReadInt8(packet, &is_freedoom)) @@ -521,7 +517,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, return; } - if (!NET_ValidGameMode(cl_gamemode, cl_gamemission)) + if (!D_ValidGameMode(data.gamemission, data.gamemode)) { return; } @@ -588,7 +584,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, NET_SV_AssignPlayers(); num_players = NET_SV_NumPlayers(); - if ((!cl_drone && num_players >= MAXPLAYERS) + if ((!data.drone && num_players >= MAXPLAYERS) || NET_SV_NumClients() >= MAXNETNODES) { NET_SV_SendReject(addr, "Server is full!"); @@ -601,10 +597,10 @@ static void NET_SV_ParseSYN(net_packet_t *packet, // Adopt the game mode and mission of the first connecting client - if (num_players == 0 && !cl_drone) + if (num_players == 0 && !data.drone) { - sv_gamemode = cl_gamemode; - sv_gamemission = cl_gamemission; + sv_gamemode = data.gamemode; + sv_gamemission = data.gamemission; } // Save the MD5 checksums @@ -616,7 +612,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, // Check the connecting client is playing the same game as all // the other clients - if (cl_gamemode != sv_gamemode || cl_gamemission != sv_gamemission) + if (data.gamemode != sv_gamemode || data.gamemission != sv_gamemission) { NET_SV_SendReject(addr, "You are playing the wrong game!"); return; @@ -626,8 +622,8 @@ static void NET_SV_ParseSYN(net_packet_t *packet, NET_SV_InitNewClient(client, addr, player_name); - client->recording_lowres = cl_recording_lowres; - client->drone = cl_drone; + client->recording_lowres = data.lowres_turn; + client->drone = data.drone; } if (client->connection.state == NET_CONN_STATE_WAITING_ACK) @@ -690,6 +686,8 @@ static void NET_SV_ParseGameStart(net_packet_t *packet, net_client_t *client) } } + settings.num_players = NET_SV_NumPlayers(); + nowtime = I_GetTimeMS(); // Send start packets to each connected node @@ -704,8 +702,8 @@ static void NET_SV_ParseGameStart(net_packet_t *packet, net_client_t *client) startpacket = NET_Conn_NewReliable(&clients[i].connection, NET_PACKET_TYPE_GAMESTART); - NET_WriteInt8(startpacket, NET_SV_NumPlayers()); - NET_WriteInt8(startpacket, clients[i].player_number); + settings.consoleplayer = clients[i].player_number; + NET_WriteSettings(startpacket, &settings); } |