1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Smart map object serialization over net.

Fixed doubling click sound on map selection.
This commit is contained in:
Michał W. Urbańczyk
2009-10-06 00:32:33 +00:00
parent 2cf3e6885f
commit fe7ef6bbe1
13 changed files with 169 additions and 40 deletions

View File

@@ -4,10 +4,18 @@
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <fstream>
#ifndef _MSC_VER
#include "../lib/RegisterTypes.cpp"
#include "../hch/CObjectHandler.h"
#endif
//for smart objs serialization over net
#include "CGameState.h"
#include "map.h"
#include "../hch/CObjectHandler.h"
/*
* Connection.cpp, part of VCMI engine
*
@@ -54,6 +62,7 @@ void CConnection::init()
tlog0 << "Established connection with "<<pom<<std::endl;
wmx = new boost::mutex;
rmx = new boost::mutex;
gs = NULL;
}
CConnection::CConnection(std::string host, std::string port, std::string Name)
@@ -173,6 +182,27 @@ void CConnection::close()
}
}
CGObjectInstance *CConnection::loadObject()
{
assert(gs);
si32 id;
*this >> id;
assert(id >= 0 && id < gs->map->objects.size());
return gs->map->objects[id];
}
void CConnection::saveObject( const CGObjectInstance *data )
{
assert(gs);
assert(data);
*this << data->id;
}
void CConnection::setGS( CGameState *state )
{
gs = state;
}
CSaveFile::CSaveFile( const std::string &fname )
:sfile(new std::ofstream((USER_DIR "/" + fname).c_str(),std::ios::binary))
{