src/network/network_server.cpp
branchnoai
changeset 9723 eee46cb39750
parent 9722 ebf0ece7d8f6
child 9724 b39bc69bb2f2
equal deleted inserted replaced
9722:ebf0ece7d8f6 9723:eee46cb39750
     3 #ifdef ENABLE_NETWORK
     3 #ifdef ENABLE_NETWORK
     4 
     4 
     5 #include "../stdafx.h"
     5 #include "../stdafx.h"
     6 #include "../openttd.h" // XXX StringID
     6 #include "../openttd.h" // XXX StringID
     7 #include "../debug.h"
     7 #include "../debug.h"
     8 #include "../string.h"
     8 #include "../strings_func.h"
     9 #include "../strings.h"
       
    10 #include "network_data.h"
     9 #include "network_data.h"
    11 #include "core/tcp.h"
    10 #include "core/tcp.h"
    12 #include "../train.h"
    11 #include "../train.h"
    13 #include "../aircraft.h"
    12 #include "../aircraft.h"
    14 #include "../date.h"
    13 #include "../date_func.h"
    15 #include "table/strings.h"
    14 #include "table/strings.h"
    16 #include "../functions.h"
       
    17 #include "network_server.h"
    15 #include "network_server.h"
    18 #include "network_udp.h"
    16 #include "network_udp.h"
    19 #include "../console.h"
    17 #include "../console.h"
    20 #include "../command.h"
    18 #include "../command_func.h"
    21 #include "../saveload.h"
    19 #include "../saveload.h"
    22 #include "../vehicle.h"
       
    23 #include "../station.h"
    20 #include "../station.h"
    24 #include "../variables.h"
    21 #include "../variables.h"
    25 #include "../genworld.h"
    22 #include "../genworld.h"
    26 #include "../helpers.hpp"
    23 #include "../core/alloc_func.hpp"
    27 #include "../fileio.h"
    24 #include "../fileio.h"
       
    25 #include "../string_func.h"
    28 
    26 
    29 // This file handles all the server-commands
    27 // This file handles all the server-commands
    30 
    28 
    31 static void NetworkHandleCommandQueue(NetworkTCPSocketHandler* cs);
    29 static void NetworkHandleCommandQueue(NetworkTCPSocketHandler* cs);
    32 
    30 
   222 
   220 
   223 	cs->status = STATUS_AUTHORIZING;
   221 	cs->status = STATUS_AUTHORIZING;
   224 
   222 
   225 	Packet *p = NetworkSend_Init(PACKET_SERVER_NEED_PASSWORD);
   223 	Packet *p = NetworkSend_Init(PACKET_SERVER_NEED_PASSWORD);
   226 	p->Send_uint8(type);
   224 	p->Send_uint8(type);
       
   225 	p->Send_uint32(_patches.generation_seed);
       
   226 	p->Send_string(_network_unique_id);
   227 	cs->Send_Packet(p);
   227 	cs->Send_Packet(p);
   228 }
   228 }
   229 
   229 
   230 DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WELCOME)
   230 DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WELCOME)
   231 {
   231 {
   245 	cs->status = STATUS_AUTH;
   245 	cs->status = STATUS_AUTH;
   246 	_network_game_info.clients_on++;
   246 	_network_game_info.clients_on++;
   247 
   247 
   248 	p = NetworkSend_Init(PACKET_SERVER_WELCOME);
   248 	p = NetworkSend_Init(PACKET_SERVER_WELCOME);
   249 	p->Send_uint16(cs->index);
   249 	p->Send_uint16(cs->index);
       
   250 	p->Send_uint32(_patches.generation_seed);
       
   251 	p->Send_string(_network_unique_id);
   250 	cs->Send_Packet(p);
   252 	cs->Send_Packet(p);
   251 
   253 
   252 		// Transmit info about all the active clients
   254 		// Transmit info about all the active clients
   253 	FOR_ALL_CLIENTS(new_cs) {
   255 	FOR_ALL_CLIENTS(new_cs) {
   254 		if (new_cs != cs && new_cs->status > STATUS_AUTH)
   256 		if (new_cs != cs && new_cs->status > STATUS_AUTH)