mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
Revert "multiplayer load changes"
This reverts commit 368d2c8836cc6e3b5af9cf71e892bf4515f26bda.
This commit is contained in:
parent
99a63c4bbd
commit
3685e96042
@ -247,8 +247,6 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
|
|||||||
serv = sh.justConnectToServer(ipaddr,port=="" ? "3030" : port);
|
serv = sh.justConnectToServer(ipaddr,port=="" ? "3030" : port);
|
||||||
|
|
||||||
CStopWatch tmh;
|
CStopWatch tmh;
|
||||||
if(server)
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string clientSaveName = *CResourceHandler::get("local")->getResourceName(ResourceID(fname, EResType::CLIENT_SAVEGAME));
|
std::string clientSaveName = *CResourceHandler::get("local")->getResourceName(ResourceID(fname, EResType::CLIENT_SAVEGAME));
|
||||||
@ -290,24 +288,9 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
|
|||||||
logGlobal->errorStream() << "Cannot load game " << fname << ". Error: " << e.what();
|
logGlobal->errorStream() << "Cannot load game " << fname << ". Error: " << e.what();
|
||||||
throw; //obviously we cannot continue here
|
throw; //obviously we cannot continue here
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(server)
|
if(server)
|
||||||
{
|
|
||||||
serv = sh.connectToServer();
|
serv = sh.connectToServer();
|
||||||
(*serv) << *this;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(*serv) >> *this;
|
|
||||||
|
|
||||||
const_cast<CGameInfo*>(CGI)->mh = new CMapHandler();
|
|
||||||
CGI->mh->map = gs->map;
|
|
||||||
logNetwork->infoStream() <<"Creating mapHandler: "<<tmh.getDiff();
|
|
||||||
CGI->mh->init();
|
|
||||||
pathInfo = make_unique<CPathsInfo>(getMapSize());
|
|
||||||
logNetwork->infoStream() <<"Initializing mapHandler (together): "<<tmh.getDiff();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(player_==-1)
|
if(player_==-1)
|
||||||
player_ = player->getNum();
|
player_ = player->getNum();
|
||||||
@ -330,13 +313,13 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
|
|||||||
logNetwork->infoStream() << "Server opened savegame properly.";
|
logNetwork->infoStream() << "Server opened savegame properly.";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<PlayerColor> clientPlayers;
|
|
||||||
if(server)
|
if(server)
|
||||||
{
|
{
|
||||||
|
*serv << ui32(gs->scenarioOps->playerInfos.size()+2-loadNumPlayers); //number of players + neutral
|
||||||
for(auto & elem : gs->scenarioOps->playerInfos)
|
for(auto & elem : gs->scenarioOps->playerInfos)
|
||||||
if(!std::count(humanplayerindices.begin(),humanplayerindices.end(),elem.first.getNum()) || elem.first==player)
|
if(!std::count(humanplayerindices.begin(),humanplayerindices.end(),elem.first.getNum()) || elem.first==player)
|
||||||
{
|
{
|
||||||
clientPlayers.insert(elem.first);
|
*serv << ui8(elem.first.getNum()); //players
|
||||||
if(elem.first!=player)
|
if(elem.first!=player)
|
||||||
{
|
{
|
||||||
auto AiToGive = aiNameForPlayer(elem.second, false);
|
auto AiToGive = aiNameForPlayer(elem.second, false);
|
||||||
@ -348,21 +331,20 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
|
|||||||
installNewPlayerInterface(make_shared<CPlayerInterface>(*player),*player);
|
installNewPlayerInterface(make_shared<CPlayerInterface>(*player),*player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clientPlayers.insert(PlayerColor::NEUTRAL);
|
*serv << ui8(PlayerColor::NEUTRAL.getNum());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clientPlayers.insert(*player);
|
*serv << ui32(1);
|
||||||
|
*serv << ui8(player->getNum());
|
||||||
installNewPlayerInterface(make_shared<CPlayerInterface>(*player),*player);
|
installNewPlayerInterface(make_shared<CPlayerInterface>(*player),*player);
|
||||||
}
|
}
|
||||||
|
|
||||||
serv->enableStackSendingByID();
|
|
||||||
serv->disableSmartPointerSerialization();
|
|
||||||
(*serv) << clientPlayers;
|
|
||||||
|
|
||||||
logNetwork->infoStream() <<"Sent info to server: "<<tmh.getDiff();
|
logNetwork->infoStream() <<"Sent info to server: "<<tmh.getDiff();
|
||||||
|
|
||||||
serv->addStdVecItems(gs);
|
serv->addStdVecItems(gs);
|
||||||
|
serv->enableStackSendingByID();
|
||||||
|
serv->disableSmartPointerSerialization();
|
||||||
|
|
||||||
loadNeutralBattleAI();
|
loadNeutralBattleAI();
|
||||||
|
|
||||||
|
@ -32,12 +32,6 @@
|
|||||||
|
|
||||||
#include "../lib/UnlockGuard.h"
|
#include "../lib/UnlockGuard.h"
|
||||||
|
|
||||||
#include "../client/Client.h"
|
|
||||||
|
|
||||||
extern template void CClient::serialize<COSer<CSaveFile>>( COSer<CSaveFile> &h, const int version );
|
|
||||||
extern template void CClient::serialize<CISer<CConnection>>( CISer<CConnection> &h, const int version );
|
|
||||||
extern template void CClient::serialize<COSer<CConnection>>( COSer<CConnection> &h, const int version );
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined (__MINGW32__) && !defined(VCMI_ANDROID)
|
#if defined(__GNUC__) && !defined (__MINGW32__) && !defined(VCMI_ANDROID)
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#endif
|
#endif
|
||||||
@ -497,13 +491,11 @@ void CVCMIServer::loadGame()
|
|||||||
c << ui8(0);
|
c << ui8(0);
|
||||||
|
|
||||||
CConnection* cc; //tcp::socket * ss;
|
CConnection* cc; //tcp::socket * ss;
|
||||||
CClient client_in;
|
|
||||||
for(int i=0; i<clients; i++)
|
for(int i=0; i<clients; i++)
|
||||||
{
|
{
|
||||||
if(!i)
|
if(!i)
|
||||||
{
|
{
|
||||||
cc = &c;
|
cc = &c;
|
||||||
(*cc) >> client_in;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -516,7 +508,7 @@ void CVCMIServer::loadGame()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cc = new CConnection(s,NAME);
|
cc = new CConnection(s,NAME);
|
||||||
(*cc) << client_in;
|
cc->addStdVecItems(gh.gs);
|
||||||
}
|
}
|
||||||
gh.conns.insert(cc);
|
gh.conns.insert(cc);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user