fix cmake compile errors

fix cmake compile errors
This commit is contained in:
zsilencer 2015-07-08 21:35:37 -06:00
parent f883e7a8da
commit f7be55eb9d
3 changed files with 12 additions and 23 deletions

View File

@ -344,7 +344,7 @@
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<StructMemberAlignment>1Byte</StructMemberAlignment>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ObjectFileName>$(IntDir)fake\%(RelativeDir)</ObjectFileName>
@ -375,7 +375,7 @@ xcopy /YS "$(SolutionDir)\..\Data" "$(TargetDir)\Data"</Command>
<OmitFramePointers>
</OmitFramePointers>
<BufferSecurityCheck>false</BufferSecurityCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)fake\%(RelativeDir)</ObjectFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
@ -415,7 +415,7 @@ xcopy /YS "$(SolutionDir)\..\Data" "$(TargetDir)\Data"</Command>
<OmitFramePointers>
</OmitFramePointers>
<BufferSecurityCheck>false</BufferSecurityCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;ENABLE_TESTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;CURL_STATICLIB;ENABLE_TESTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)fake\%(RelativeDir)</ObjectFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>

View File

@ -22,16 +22,15 @@
#include <math.h>
#include <set>
#include "network.h"
extern "C" {
#include "../addresses.h"
#include "../common.h"
#include "../game.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
#include "../management/news_item.h"
#include "../scenario.h"
}
#include "network.h"
#pragma comment(lib, "Ws2_32.lib")
@ -51,21 +50,17 @@ struct GameCommand
}
};
static network_packet* _packetQueue = NULL;
static int _wsaInitialised = 0;
static WSADATA _wsaData;
static SOCKET _listeningSocket = INVALID_SOCKET;
static SOCKET _serverSocket = INVALID_SOCKET;
static SOCKET _clientSocket = INVALID_SOCKET;
static network_packet _inboundPacket;
static std::vector<uint8> _chunkBuffer;
static NetworkConnection _serverConnection;
static std::list<std::unique_ptr<NetworkConnection>> _clientConnectionList;
static std::multiset<GameCommand> _gameCommandQueue;
static void network_process_packet(NetworkPacket& packet);
static int network_send_packet(network_packet *packet);
static void network_send_queued_packets();
NetworkPacket::NetworkPacket()
{
@ -76,12 +71,12 @@ NetworkPacket::NetworkPacket()
std::unique_ptr<NetworkPacket> NetworkPacket::AllocatePacket()
{
return std::move(std::make_unique<NetworkPacket>());
return std::move(std::unique_ptr<NetworkPacket>(new NetworkPacket)); // change to make_unique in c++14
}
std::unique_ptr<NetworkPacket> NetworkPacket::DuplicatePacket(NetworkPacket& packet)
{
return std::move(std::make_unique<NetworkPacket>(packet));
return std::move(std::unique_ptr<NetworkPacket>(new NetworkPacket(packet))); // change to make_unique in c++14
}
uint8* NetworkPacket::GetData()
@ -300,7 +295,7 @@ void network_end_server()
void network_add_client(SOCKET socket)
{
printf("New client connection\n");
auto networkconnection = std::make_unique<NetworkConnection>();
auto networkconnection = std::unique_ptr<NetworkConnection>(new NetworkConnection); // change to make_unique in c++14
networkconnection->socket = socket;
_clientConnectionList.push_back(std::move(networkconnection));
}

View File

@ -23,13 +23,16 @@
#ifndef DISABLE_NETWORK
#include "../common.h"
#ifdef __cplusplus
#include <list>
#include <memory>
#include <vector>
#include <SDL.h>
extern "C" {
#include "../common.h"
#include "../platform/platform.h"
}
class NetworkPacket
{
@ -66,15 +69,6 @@ private:
extern "C" {
#endif
typedef struct network_packet network_packet;
typedef struct network_packet {
uint16 size;
uint8* data;
int read;
network_packet* next;
} network_packet;
#define NETWORK_DEFAULT_PORT 11753
enum {