src/network/network_data.cpp
branchcustombridgeheads
changeset 5650 aefc131bf5ce
parent 5649 55c8267c933f
equal deleted inserted replaced
5649:55c8267c933f 5650:aefc131bf5ce
     7 #include "network_data.h"
     7 #include "network_data.h"
     8 #include "../string.h"
     8 #include "../string.h"
     9 #include "network_client.h"
     9 #include "network_client.h"
    10 #include "../command.h"
    10 #include "../command.h"
    11 #include "../callback_table.h"
    11 #include "../callback_table.h"
       
    12 #include "../helpers.hpp"
    12 
    13 
    13 // Add a command to the local command queue
    14 // Add a command to the local command queue
    14 void NetworkAddCommandQueue(NetworkClientState *cs, CommandPacket *cp)
    15 void NetworkAddCommandQueue(NetworkClientState *cs, CommandPacket *cp)
    15 {
    16 {
    16 	CommandPacket* new_cp = malloc(sizeof(*new_cp));
    17 	CommandPacket* new_cp;
       
    18 	MallocT(&new_cp, 1);
    17 
    19 
    18 	*new_cp = *cp;
    20 	*new_cp = *cp;
    19 
    21 
    20 	if (cs->command_queue == NULL) {
    22 	if (cs->command_queue == NULL) {
    21 		cs->command_queue = new_cp;
    23 		cs->command_queue = new_cp;
    27 }
    29 }
    28 
    30 
    29 // Prepare a DoCommand to be send over the network
    31 // Prepare a DoCommand to be send over the network
    30 void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback)
    32 void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback)
    31 {
    33 {
    32 	CommandPacket *c = malloc(sizeof(CommandPacket));
    34 	CommandPacket *c;
       
    35 	MallocT(&c, 1);
    33 	byte temp_callback;
    36 	byte temp_callback;
    34 
    37 
    35 	c->player = _local_player;
    38 	c->player = _local_player;
    36 	c->next = NULL;
    39 	c->next = NULL;
    37 	c->tile = tile;
    40 	c->tile = tile;