mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Stabilization
This commit is contained in:
		| @@ -165,7 +165,7 @@ void DangerHitMapAnalyzer::calculateTileOwners() | ||||
|  | ||||
| 	auto addTownHero = [&](const CGTownInstance * town) | ||||
| 	{ | ||||
| 			auto townHero = new CGHeroInstance(nullptr); | ||||
| 			auto townHero = new CGHeroInstance(town->cb); | ||||
| 			CRandomGenerator rng; | ||||
| 			auto visitablePos = town->visitablePos(); | ||||
| 			 | ||||
|   | ||||
| @@ -142,6 +142,8 @@ CServerHandler::CServerHandler() | ||||
| 	registerTypesLobbyPacks(*applier); | ||||
| } | ||||
|  | ||||
| CServerHandler::~CServerHandler() = default; | ||||
|  | ||||
| void CServerHandler::resetStateForLobby(const StartInfo::EMode mode, const std::vector<std::string> * names) | ||||
| { | ||||
| 	hostClientId = -1; | ||||
| @@ -260,6 +262,9 @@ void CServerHandler::justConnectToServer(const std::string & addr, const ui16 po | ||||
| 					addr.size() ? addr : getHostAddress(), | ||||
| 					port ? port : getHostPort(), | ||||
| 					NAME, uuid); | ||||
|  | ||||
| 			nextClient = std::make_unique<CClient>(); | ||||
| 			c->iser.cb = nextClient.get(); | ||||
| 		} | ||||
| 		catch(std::runtime_error & error) | ||||
| 		{ | ||||
| @@ -636,7 +641,8 @@ void CServerHandler::startGameplay(VCMI_LIB_WRAP_NAMESPACE(CGameState) * gameSta | ||||
| { | ||||
| 	if(CMM) | ||||
| 		CMM->disable(); | ||||
| 	client = new CClient(); | ||||
|  | ||||
| 	std::swap(client, nextClient);; | ||||
|  | ||||
| 	highScoreCalc = nullptr; | ||||
|  | ||||
| @@ -687,7 +693,7 @@ void CServerHandler::endGameplay(bool closeConnection, bool restart) | ||||
| 	} | ||||
|  | ||||
| 	client->endGame(); | ||||
| 	vstd::clear_pointer(client); | ||||
| 	client.reset(); | ||||
|  | ||||
| 	if(!restart) | ||||
| 	{ | ||||
|   | ||||
| @@ -95,6 +95,10 @@ class CServerHandler : public IServerAPI, public LobbyInfo | ||||
|  | ||||
| 	std::shared_ptr<HighScoreCalculation> highScoreCalc; | ||||
|  | ||||
| 	/// temporary helper member that exists while game in lobby mode | ||||
| 	/// required to correctly deserialize gamestate using client-side game callback | ||||
| 	std::unique_ptr<CClient> nextClient; | ||||
|  | ||||
| 	void threadHandleConnection(); | ||||
| 	void threadRunServer(); | ||||
| 	void onServerFinished(); | ||||
| @@ -116,13 +120,14 @@ public: | ||||
| 	std::shared_ptr<boost::thread> threadRunLocalServer; | ||||
|  | ||||
| 	std::shared_ptr<CConnection> c; | ||||
| 	CClient * client; | ||||
| 	std::unique_ptr<CClient> client; | ||||
|  | ||||
| 	CondSh<bool> campaignServerRestartLock; | ||||
|  | ||||
| 	static const std::string localhostAddress; | ||||
|  | ||||
| 	CServerHandler(); | ||||
| 	~CServerHandler(); | ||||
| 	 | ||||
| 	std::string getHostAddress() const; | ||||
| 	ui16 getHostPort() const; | ||||
|   | ||||
| @@ -173,7 +173,8 @@ void CClient::newGame(CGameState * initializedGameState) | ||||
| { | ||||
| 	CSH->th->update(); | ||||
| 	CMapService mapService; | ||||
| 	gs = initializedGameState ? initializedGameState : new CGameState(); | ||||
| 	assert(initializedGameState); | ||||
| 	gs = initializedGameState; | ||||
| 	gs->preInit(VLC, this); | ||||
| 	logNetwork->trace("\tCreating gamestate: %i", CSH->th->getDiff()); | ||||
| 	if(!initializedGameState) | ||||
|   | ||||
| @@ -18,7 +18,9 @@ class DLL_LINKAGE GameCallbackHolder | ||||
| public: | ||||
| 	IGameCallback * const cb; | ||||
|  | ||||
| 	GameCallbackHolder(IGameCallback *cb): | ||||
| 	explicit GameCallbackHolder(IGameCallback *cb): | ||||
| 		cb(cb) | ||||
| 	{} | ||||
| }; | ||||
|  | ||||
| VCMI_LIB_NAMESPACE_END | ||||
|   | ||||
| @@ -304,7 +304,7 @@ void CBonusSystemNode::detachFromSource(const CBonusSystemNode & parent) | ||||
| 			parent.removedRedDescendant(*this); | ||||
| 	} | ||||
|  | ||||
| 	if (vstd::contains(parentsToPropagate, &parent)) | ||||
| 	if (vstd::contains(parentsToInherit, &parent)) | ||||
| 	{ | ||||
| 		parentsToInherit -= &parent; | ||||
| 	} | ||||
| @@ -581,9 +581,9 @@ CBonusSystemNode::ENodeTypes CBonusSystemNode::getNodeType() const | ||||
| 	return nodeType; | ||||
| } | ||||
|  | ||||
| const TNodesVector& CBonusSystemNode::getParentNodes() const | ||||
| const TCNodesVector& CBonusSystemNode::getParentNodes() const | ||||
| { | ||||
| 	return parentsToPropagate; | ||||
| 	return parentsToInherit; | ||||
| } | ||||
|  | ||||
| void CBonusSystemNode::setNodeType(CBonusSystemNode::ENodeTypes type) | ||||
|   | ||||
| @@ -117,7 +117,7 @@ public: | ||||
| 	const BonusList & getExportedBonusList() const; | ||||
| 	CBonusSystemNode::ENodeTypes getNodeType() const; | ||||
| 	void setNodeType(CBonusSystemNode::ENodeTypes type); | ||||
| 	const TNodesVector & getParentNodes() const; | ||||
| 	const TCNodesVector & getParentNodes() const; | ||||
|  | ||||
| 	static void treeHasChanged(); | ||||
|  | ||||
|   | ||||
| @@ -277,6 +277,7 @@ int CGHeroInstance::movementPointsLimitCached(bool onLand, const TurnInfo * ti) | ||||
|  | ||||
| CGHeroInstance::CGHeroInstance(IGameCallback * cb) | ||||
| 	: CArmedInstance(cb), | ||||
| 	type(nullptr), | ||||
| 	tacticFormationEnabled(false), | ||||
| 	inTownGarrison(false), | ||||
| 	moveDir(4), | ||||
|   | ||||
| @@ -152,7 +152,7 @@ public: | ||||
|  | ||||
| 	std::map<ui32, void*> loadedPointers; | ||||
| 	std::map<const void*, std::shared_ptr<void>> loadedSharedPointers; | ||||
| 	IGameCallback * cb; | ||||
| 	IGameCallback * cb = nullptr; | ||||
| 	bool smartPointerSerialization; | ||||
| 	bool saving; | ||||
|  | ||||
| @@ -293,7 +293,7 @@ public: | ||||
| 		{ | ||||
| 			typedef typename std::remove_pointer<T>::type npT; | ||||
| 			typedef typename std::remove_const<npT>::type ncpT; | ||||
| 			data = ClassObjectCreator<ncpT>::invoke(nullptr); | ||||
| 			data = ClassObjectCreator<ncpT>::invoke(cb); | ||||
| 			ptrAllocated(data, pid); | ||||
| 			load(*data); | ||||
| 		} | ||||
|   | ||||
| @@ -22,10 +22,10 @@ class CGObjectInstance; | ||||
| class EntityService; | ||||
| class JsonNode; | ||||
| class ObjectTemplate; | ||||
| class CHeroClass; | ||||
|  | ||||
| VCMI_LIB_NAMESPACE_END | ||||
|  | ||||
| class CHeroClass; | ||||
| struct InfoAboutHero; | ||||
| struct InfoAboutTown; | ||||
| class Animation; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user