mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
commit
fc4196e71c
@ -87,6 +87,7 @@
|
||||
|
||||
#include "../lib/gameState/CGameState.h"
|
||||
|
||||
#include "../lib/mapObjects/CGMarket.h"
|
||||
#include "../lib/mapObjects/CGTownInstance.h"
|
||||
#include "../lib/mapObjects/MiscObjects.h"
|
||||
#include "../lib/mapObjects/ObjectTemplate.h"
|
||||
@ -1659,6 +1660,15 @@ void CPlayerInterface::showMarketWindow(const IMarket *market, const CGHeroInsta
|
||||
cb->selectionMade(0, queryID);
|
||||
};
|
||||
|
||||
if (market->allowsTrade(EMarketMode::ARTIFACT_EXP) && dynamic_cast<const CGArtifactsAltar*>(market) == nullptr)
|
||||
{
|
||||
// compatibility check, safe to remove for 1.6
|
||||
// 1.4 saves loaded in 1.5 will not be able to visit Altar of Sacrifice due to Altar now requiring different map object class
|
||||
static_assert(ESerializationVersion::RELEASE_143 < ESerializationVersion::CURRENT, "Please remove this compatibility check once it no longer needed");
|
||||
onWindowClosed();
|
||||
return;
|
||||
}
|
||||
|
||||
if(market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL)
|
||||
GH.windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, EMarketMode::ARTIFACT_EXP);
|
||||
else if(market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD)
|
||||
|
@ -612,13 +612,6 @@ void CServerHandler::sendStartGame(bool allowOnlyAI) const
|
||||
sendLobbyPack(lpsg);
|
||||
|
||||
LobbyStartGame lsg;
|
||||
if(client)
|
||||
{
|
||||
lsg.initializedStartInfo = std::make_shared<StartInfo>(* const_cast<StartInfo *>(client->getStartInfo(true)));
|
||||
lsg.initializedStartInfo->mode = EStartMode::NEW_GAME;
|
||||
lsg.initializedStartInfo->seedToBeUsed = lsg.initializedStartInfo->seedPostInit = 0;
|
||||
* si = * lsg.initializedStartInfo;
|
||||
}
|
||||
sendLobbyPack(lsg);
|
||||
}
|
||||
|
||||
@ -845,7 +838,7 @@ void CServerHandler::debugStartTest(std::string filename, bool save)
|
||||
while(!settings["session"]["headless"].Bool() && !GH.windows().topWindow<CLobbyScreen>())
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(50));
|
||||
|
||||
while(!mi || mapInfo->fileURI != CSH->mi->fileURI)
|
||||
while(!mi || mapInfo->fileURI != mi->fileURI)
|
||||
{
|
||||
setMapInfo(mapInfo);
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(50));
|
||||
@ -932,10 +925,10 @@ void CServerHandler::onDisconnected(const std::shared_ptr<INetworkConnection> &
|
||||
|
||||
if(client)
|
||||
{
|
||||
CSH->endGameplay();
|
||||
endGameplay();
|
||||
GH.defActionsDef = 63;
|
||||
CMM->menu->switchToTab("main");
|
||||
CSH->showServerError(CGI->generaltexth->translate("vcmi.server.errors.disconnected"));
|
||||
showServerError(CGI->generaltexth->translate("vcmi.server.errors.disconnected"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -998,7 +991,7 @@ void CServerHandler::sendLobbyPack(const CPackForLobby & pack) const
|
||||
|
||||
bool CServerHandler::inLobbyRoom() const
|
||||
{
|
||||
return CSH->serverMode == EServerMode::LOBBY_HOST || CSH->serverMode == EServerMode::LOBBY_GUEST;
|
||||
return serverMode == EServerMode::LOBBY_HOST || serverMode == EServerMode::LOBBY_GUEST;
|
||||
}
|
||||
|
||||
bool CServerHandler::inGame() const
|
||||
|
@ -50,7 +50,7 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
|
||||
buttonSelect->addCallback([=]()
|
||||
{
|
||||
toggleTab(tabSel);
|
||||
if (getMapInfo()->isRandomMap)
|
||||
if (getMapInfo() && getMapInfo()->isRandomMap)
|
||||
CSH->setMapInfo(tabSel->getSelectedMapInfo());
|
||||
});
|
||||
|
||||
@ -78,7 +78,7 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
|
||||
buttonRMG->addCallback([this]()
|
||||
{
|
||||
toggleTab(tabRand);
|
||||
if (!getMapInfo()->isRandomMap)
|
||||
if (getMapInfo() && !getMapInfo()->isRandomMap)
|
||||
tabRand->updateMapInfoByHost();
|
||||
});
|
||||
|
||||
|
@ -243,10 +243,20 @@ JsonNode JsonUtils::assembleFromFiles(const std::vector<std::string> & files, bo
|
||||
|
||||
for(const auto & file : files)
|
||||
{
|
||||
bool isValidFile = false;
|
||||
JsonNode section(JsonPath::builtinTODO(file), isValidFile);
|
||||
merge(result, section);
|
||||
isValid |= isValidFile;
|
||||
JsonPath path = JsonPath::builtinTODO(file);
|
||||
|
||||
if (CResourceHandler::get()->existsResource(path))
|
||||
{
|
||||
bool isValidFile = false;
|
||||
JsonNode section(JsonPath::builtinTODO(file), isValidFile);
|
||||
merge(result, section);
|
||||
isValid |= isValidFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
logMod->error("Failed to find file %s", file);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -700,7 +700,7 @@ void CMap::resolveQuestIdentifiers()
|
||||
//FIXME: move to CMapLoaderH3M
|
||||
for (auto & quest : quests)
|
||||
{
|
||||
if (quest->killTarget != ObjectInstanceID::NONE)
|
||||
if (quest && quest->killTarget != ObjectInstanceID::NONE)
|
||||
quest->killTarget = questIdentifierToId[quest->killTarget.getNum()];
|
||||
}
|
||||
questIdentifierToId.clear();
|
||||
|
@ -32,19 +32,29 @@ std::unique_ptr<INetworkServer> NetworkHandler::createServerTCP(INetworkServerLi
|
||||
void NetworkHandler::connectToRemote(INetworkClientListener & listener, const std::string & host, uint16_t port)
|
||||
{
|
||||
auto socket = std::make_shared<NetworkSocket>(*io);
|
||||
boost::asio::ip::tcp::resolver resolver(*io);
|
||||
auto endpoints = resolver.resolve(host, std::to_string(port));
|
||||
boost::asio::async_connect(*socket, endpoints, [socket, &listener](const boost::system::error_code& error, const boost::asio::ip::tcp::endpoint& endpoint)
|
||||
auto resolver = std::make_shared<boost::asio::ip::tcp::resolver>(*io);
|
||||
|
||||
resolver->async_resolve(host, std::to_string(port),
|
||||
[&listener, resolver, socket](const boost::system::error_code& error, const boost::asio::ip::tcp::resolver::results_type & endpoints)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
listener.onConnectionFailed(error.message());
|
||||
return;
|
||||
}
|
||||
auto connection = std::make_shared<NetworkConnection>(listener, socket);
|
||||
connection->start();
|
||||
|
||||
listener.onConnectionEstablished(connection);
|
||||
boost::asio::async_connect(*socket, endpoints, [socket, &listener](const boost::system::error_code& error, const boost::asio::ip::tcp::endpoint& endpoint)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
listener.onConnectionFailed(error.message());
|
||||
return;
|
||||
}
|
||||
auto connection = std::make_shared<NetworkConnection>(listener, socket);
|
||||
connection->start();
|
||||
|
||||
listener.onConnectionEstablished(connection);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -42,5 +42,7 @@ enum class ESerializationVersion : int32_t
|
||||
TURN_TIMERS_STATE, // 839 current state of turn timers is serialized
|
||||
ARTIFACT_COSTUMES, // 840 swappable artifacts set added
|
||||
|
||||
RELEASE_150 = ARTIFACT_COSTUMES, // for convenience
|
||||
|
||||
CURRENT = ARTIFACT_COSTUMES
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user