From ecd8947d8ebbeaa7146b2adca11eae6ba643cb32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Tue, 25 Sep 2012 18:00:55 +0000 Subject: [PATCH] Crashes on starting next campaign mission should be fixed. --- client/CAdvmapInterface.cpp | 3 ++- client/Client.cpp | 2 ++ lib/Connection.cpp | 30 ++++++++++++++++++++++++++---- lib/Connection.h | 5 +++++ server/CGameHandler.cpp | 4 ++++ server/CVCMIServer.cpp | 1 - 6 files changed, 39 insertions(+), 6 deletions(-) diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index 0933cea0e..c12990873 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -1380,7 +1380,8 @@ void CAdvMapInt::tileHovered(const int3 &mapPos) if (guardingCreature) { CCS->curh->changeGraphic(0, 5 + turns*6); - } else + } + else { if(pnode->land) { diff --git a/client/Client.cpp b/client/Client.cpp index f806dc208..13996da8a 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -334,6 +334,8 @@ void CClient::newGame( CConnection *con, StartInfo *si ) c >> si; tlog0 <<"\tSending/Getting info to/from the server: "<(CGI)->state; gs->scenarioOps = si; diff --git a/lib/Connection.cpp b/lib/Connection.cpp index e6fdb9db7..f943535de 100644 --- a/lib/Connection.cpp +++ b/lib/Connection.cpp @@ -55,10 +55,8 @@ CTypeList typeList; void CConnection::init() { - CISer::smartPointerSerialization = false; - COSer::smartPointerSerialization = false; - CISer::sendStackInstanceByIds = true; - COSer::sendStackInstanceByIds = true; + enableSmartPointerSerializatoin(); + disableStackSendingByID(); registerTypes(static_cast&>(*this)); registerTypes(static_cast&>(*this)); #ifdef LIL_ENDIAN @@ -250,6 +248,30 @@ void CConnection::sendPackToServer(const CPack &pack, ui8 player, ui32 requestID *this << player << requestID << &pack; //packs has to be sent as polymorphic pointers! } +void CConnection::disableStackSendingByID() +{ + CISer::sendStackInstanceByIds = false; + COSer::sendStackInstanceByIds = false; +} + +void CConnection::enableStackSendingByID() +{ + CISer::sendStackInstanceByIds = true; + COSer::sendStackInstanceByIds = true; +} + +void CConnection::disableSmartPointerSerialization() +{ + CISer::smartPointerSerialization = false; + COSer::smartPointerSerialization = false; +} + +void CConnection::enableSmartPointerSerializatoin() +{ + CISer::smartPointerSerialization = true; + COSer::smartPointerSerialization = true; +} + CSaveFile::CSaveFile( const std::string &fname ) { registerTypes(*this); diff --git a/lib/Connection.h b/lib/Connection.h index 84f0ea344..61fa47b1c 100644 --- a/lib/Connection.h +++ b/lib/Connection.h @@ -1087,6 +1087,11 @@ public: CPack *retreivePack(); //gets from server next pack (allocates it with new) void sendPackToServer(const CPack &pack, ui8 player, ui32 requestID); + + void disableStackSendingByID(); + void enableStackSendingByID(); + void disableSmartPointerSerialization(); + void enableSmartPointerSerializatoin(); }; DLL_LINKAGE std::ostream &operator<<(std::ostream &str, const CConnection &cpc); diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 12ed7a9c4..aacd5880c 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1480,6 +1480,10 @@ void CGameHandler::run(bool resume) } } tlog0 << std::endl; + + cc->addStdVecItems(gs); + cc->enableStackSendingByID(); + cc->disableSmartPointerSerialization(); } for(std::set::iterator i = conns.begin(); i!=conns.end();i++) diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index 32bdd0daa..f0bcf31d9 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -328,7 +328,6 @@ CGameHandler * CVCMIServer::initGhFromHostingConnection(CConnection &c) } gh->init(&si); - c.addStdVecItems(gh->gs); gh->conns.insert(&c); return gh;