Explorar o código

Crashes on starting next campaign mission should be fixed.

Michał W. Urbańczyk %!s(int64=13) %!d(string=hai) anos
pai
achega
ecd8947d8e

+ 2 - 1
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)
 					{

+ 2 - 0
client/Client.cpp

@@ -334,6 +334,8 @@ void CClient::newGame( CConnection *con, StartInfo *si )
 
 	c >> si;
 	tlog0 <<"\tSending/Getting info to/from the server: "<<tmh.getDiff()<<std::endl;
+	c.enableStackSendingByID();
+	c.disableSmartPointerSerialization();
 
 	gs = const_cast<CGameInfo*>(CGI)->state;
 	gs->scenarioOps = si;

+ 26 - 4
lib/Connection.cpp

@@ -55,10 +55,8 @@ CTypeList typeList;
 
 void CConnection::init()
 {
-	CISer<CConnection>::smartPointerSerialization = false;
-	COSer<CConnection>::smartPointerSerialization = false;
-	CISer<CConnection>::sendStackInstanceByIds = true;
-	COSer<CConnection>::sendStackInstanceByIds = true;
+	enableSmartPointerSerializatoin();
+	disableStackSendingByID();
 	registerTypes(static_cast<CISer<CConnection>&>(*this));
 	registerTypes(static_cast<COSer<CConnection>&>(*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<CConnection>::sendStackInstanceByIds = false;
+	COSer<CConnection>::sendStackInstanceByIds = false;
+}
+
+void CConnection::enableStackSendingByID()
+{
+	CISer<CConnection>::sendStackInstanceByIds = true;
+	COSer<CConnection>::sendStackInstanceByIds = true;
+}
+
+void CConnection::disableSmartPointerSerialization()
+{
+	CISer<CConnection>::smartPointerSerialization = false;
+	COSer<CConnection>::smartPointerSerialization = false;
+}
+
+void CConnection::enableSmartPointerSerializatoin()
+{
+	CISer<CConnection>::smartPointerSerialization = true;
+	COSer<CConnection>::smartPointerSerialization = true;
+}
+
 CSaveFile::CSaveFile( const std::string &fname )
 {
 	registerTypes(*this);

+ 5 - 0
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);

+ 4 - 0
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<CConnection*>::iterator i = conns.begin(); i!=conns.end();i++)

+ 0 - 1
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;