1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Stabilization

This commit is contained in:
Ivan Savenko
2024-01-10 19:43:34 +02:00
parent 60ffb81b33
commit ea1f05d15a
10 changed files with 28 additions and 13 deletions

View File

@@ -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();

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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();

View File

@@ -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),

View File

@@ -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);
}

View File

@@ -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;