mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Now netcode branch may be compiled with gcc. Sorry can't check build with MSVC
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
#include "../global.h"
|
||||
#include "../lib/Connection.h"
|
||||
#include "zlib.h"
|
||||
#ifndef __GNUC__
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
#include "CVCMIServer.h"
|
||||
#include <boost/crc.hpp>
|
||||
#include <boost/serialization/split_member.hpp>
|
||||
@@ -19,7 +21,7 @@ using namespace boost;
|
||||
using namespace boost::asio;
|
||||
using namespace boost::asio::ip;
|
||||
|
||||
bool end = false;
|
||||
bool end2 = false;
|
||||
|
||||
CVCMIServer::CVCMIServer()
|
||||
: io(new io_service()), acceptor(new tcp::acceptor(*io, tcp::endpoint(tcp::v4(), 3030)))
|
||||
@@ -31,14 +33,14 @@ CVCMIServer::~CVCMIServer()
|
||||
//delete acceptor;
|
||||
}
|
||||
|
||||
void CVCMIServer::newGame(CConnection &c)
|
||||
void CVCMIServer::newGame(CConnection *c)
|
||||
{
|
||||
CGameHandler gh;
|
||||
boost::system::error_code error;
|
||||
StartInfo *si = new StartInfo;
|
||||
ui8 clients;
|
||||
c >> clients; //how many clients should be connected - TODO: support more than one
|
||||
c >> *si; //get start options
|
||||
*c >> clients; //how many clients should be connected - TODO: support more than one
|
||||
*c >> *si; //get start options
|
||||
int problem;
|
||||
#ifdef _MSC_VER
|
||||
FILE *f;
|
||||
@@ -49,13 +51,13 @@ void CVCMIServer::newGame(CConnection &c)
|
||||
#endif
|
||||
if(problem)
|
||||
{
|
||||
c << ui8(problem); //WRONG!
|
||||
*c << ui8(problem); //WRONG!
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(f);
|
||||
c << ui8(0); //OK!
|
||||
*c << ui8(0); //OK!
|
||||
}
|
||||
|
||||
gh.init(si,rand());
|
||||
@@ -65,7 +67,7 @@ void CVCMIServer::newGame(CConnection &c)
|
||||
{
|
||||
if(!i)
|
||||
{
|
||||
cc=&c;
|
||||
cc=c;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -95,20 +97,20 @@ void CVCMIServer::start()
|
||||
std::cout<<"Got connection but there is an error " << std::endl;
|
||||
return;
|
||||
}
|
||||
CConnection connection(s,NAME,std::cout);
|
||||
CConnection *connection = new CConnection(s,NAME,std::cout);
|
||||
std::cout<<"Got connection!" << std::endl;
|
||||
while(!end)
|
||||
while(!end2)
|
||||
{
|
||||
uint8_t mode;
|
||||
connection >> mode;
|
||||
*connection >> mode;
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
connection.socket->close();
|
||||
connection->socket->close();
|
||||
exit(0);
|
||||
break;
|
||||
case 1:
|
||||
connection.socket->close();
|
||||
connection->socket->close();
|
||||
return;
|
||||
break;
|
||||
case 2:
|
||||
@@ -118,7 +120,11 @@ void CVCMIServer::start()
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
#else
|
||||
int main(int argc, _TCHAR* argv[])
|
||||
#endif
|
||||
{
|
||||
CLodHandler h3bmp;
|
||||
h3bmp.init("Data\\H3bitmap.lod","Data");
|
||||
@@ -128,7 +134,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
io_service io_service;
|
||||
CVCMIServer server;
|
||||
while(!end)
|
||||
while(!end2)
|
||||
server.start();
|
||||
io_service.run();
|
||||
} HANDLE_EXCEPTION
|
||||
|
||||
Reference in New Issue
Block a user