mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Merge branch 'develop' into patch-4map_overview_rework
This commit is contained in:
@@ -2738,7 +2738,7 @@ bool CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocat
|
||||
}
|
||||
|
||||
MoveArtifact ma(&src, &dst);
|
||||
if(dst.slot == ArtifactPosition::TRANSITION_POS)
|
||||
if(src.artHolder == dst.artHolder)
|
||||
ma.askAssemble = false;
|
||||
sendAndApply(&ma);
|
||||
}
|
||||
@@ -2853,7 +2853,7 @@ bool CGameHandler::bulkMoveArtifacts(ObjectInstanceID srcHero, ObjectInstanceID
|
||||
* @param assembleTo If assemble is true, this represents the artifact ID of the combination
|
||||
* artifact to assemble to. Otherwise it's not used.
|
||||
*/
|
||||
bool CGameHandler::assembleArtifacts (ObjectInstanceID heroID, ArtifactPosition artifactSlot, bool assemble, ArtifactID assembleTo)
|
||||
bool CGameHandler::assembleArtifacts(ObjectInstanceID heroID, ArtifactPosition artifactSlot, bool assemble, ArtifactID assembleTo)
|
||||
{
|
||||
const CGHeroInstance * hero = getHero(heroID);
|
||||
const CArtifactInstance * destArtifact = hero->getArt(artifactSlot);
|
||||
@@ -2861,23 +2861,27 @@ bool CGameHandler::assembleArtifacts (ObjectInstanceID heroID, ArtifactPosition
|
||||
if(!destArtifact)
|
||||
COMPLAIN_RET("assembleArtifacts: there is no such artifact instance!");
|
||||
|
||||
const auto dstLoc = ArtifactLocation(hero, artifactSlot);
|
||||
if(assemble)
|
||||
{
|
||||
CArtifact * combinedArt = VLC->arth->objects[assembleTo];
|
||||
if(!combinedArt->isCombined())
|
||||
COMPLAIN_RET("assembleArtifacts: Artifact being attempted to assemble is not a combined artifacts!");
|
||||
if (!vstd::contains(ArtifactUtils::assemblyPossibilities(hero, destArtifact->getTypeId(),
|
||||
ArtifactUtils::isSlotEquipment(artifactSlot)), combinedArt))
|
||||
if(!vstd::contains(ArtifactUtils::assemblyPossibilities(hero, destArtifact->getTypeId()), combinedArt))
|
||||
{
|
||||
COMPLAIN_RET("assembleArtifacts: It's impossible to assemble requested artifact!");
|
||||
}
|
||||
|
||||
if(!destArtifact->canBePutAt(dstLoc)
|
||||
&& !destArtifact->canBePutAt(ArtifactLocation(hero, ArtifactPosition::BACKPACK_START)))
|
||||
{
|
||||
COMPLAIN_RET("assembleArtifacts: It's impossible to give the artholder requested artifact!");
|
||||
}
|
||||
|
||||
if(ArtifactUtils::checkSpellbookIsNeeded(hero, assembleTo, artifactSlot))
|
||||
giveHeroNewArtifact(hero, VLC->arth->objects[ArtifactID::SPELLBOOK], ArtifactPosition::SPELLBOOK);
|
||||
|
||||
AssembledArtifact aa;
|
||||
aa.al = ArtifactLocation(hero, artifactSlot);
|
||||
aa.al = dstLoc;
|
||||
aa.builtArt = combinedArt;
|
||||
sendAndApply(&aa);
|
||||
}
|
||||
@@ -2891,7 +2895,7 @@ bool CGameHandler::assembleArtifacts (ObjectInstanceID heroID, ArtifactPosition
|
||||
COMPLAIN_RET("assembleArtifacts: Artifact being attempted to disassemble but backpack is full!");
|
||||
|
||||
DisassembledArtifact da;
|
||||
da.al = ArtifactLocation(hero, artifactSlot);
|
||||
da.al = dstLoc;
|
||||
sendAndApply(&da);
|
||||
}
|
||||
|
||||
@@ -3217,7 +3221,7 @@ void CGameHandler::handleTimeEvents()
|
||||
//prepare dialog
|
||||
InfoWindow iw;
|
||||
iw.player = color;
|
||||
iw.text.appendRawString(ev.message);
|
||||
iw.text = ev.message;
|
||||
|
||||
for (int i=0; i<ev.resources.size(); i++)
|
||||
{
|
||||
@@ -3268,7 +3272,7 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
||||
// dialog
|
||||
InfoWindow iw;
|
||||
iw.player = player;
|
||||
iw.text.appendRawString(ev.message);
|
||||
iw.text = ev.message;
|
||||
|
||||
if (ev.resources.nonZero())
|
||||
{
|
||||
|
||||
@@ -211,21 +211,20 @@ void CVCMIServer::establishRemoteConnections()
|
||||
|
||||
uuid = cmdLineOptions["lobby-uuid"].as<std::string>();
|
||||
int numOfConnections = cmdLineOptions["connections"].as<ui16>();
|
||||
auto address = cmdLineOptions["lobby"].as<std::string>();
|
||||
int port = cmdLineOptions["lobby-port"].as<ui16>();
|
||||
logGlobal->info("Server is connecting to remote at %s:%d with uuid %s %d times", address, port, uuid, numOfConnections);
|
||||
|
||||
for(int i = 0; i < numOfConnections; ++i)
|
||||
connectToRemote(address, port);
|
||||
connectToRemote();
|
||||
}
|
||||
|
||||
void CVCMIServer::connectToRemote(const std::string & addr, int port)
|
||||
void CVCMIServer::connectToRemote()
|
||||
{
|
||||
std::shared_ptr<CConnection> c;
|
||||
try
|
||||
{
|
||||
logNetwork->info("Establishing connection...");
|
||||
c = std::make_shared<CConnection>(addr, port, SERVER_NAME, uuid);
|
||||
auto address = cmdLineOptions["lobby"].as<std::string>();
|
||||
int port = cmdLineOptions["lobby-port"].as<ui16>();
|
||||
|
||||
logNetwork->info("Establishing connection to remote at %s:%d with uuid %s", address, port, uuid);
|
||||
c = std::make_shared<CConnection>(address, port, SERVER_NAME, uuid);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@@ -235,6 +234,7 @@ void CVCMIServer::connectToRemote(const std::string & addr, int port)
|
||||
if(c)
|
||||
{
|
||||
connections.insert(c);
|
||||
remoteConnections.insert(c);
|
||||
c->handler = std::make_shared<boost::thread>(&CVCMIServer::threadHandleClient, this, c);
|
||||
}
|
||||
}
|
||||
@@ -732,7 +732,7 @@ void CVCMIServer::updateStartInfoOnMapChange(std::shared_ptr<CMapInfo> mapInfo,
|
||||
if(pset.hero.getNum() != PlayerSettings::RANDOM && pinfo.hasCustomMainHero())
|
||||
{
|
||||
pset.hero = pinfo.mainCustomHeroId;
|
||||
pset.heroName = pinfo.mainCustomHeroName;
|
||||
pset.heroNameTextId = pinfo.mainCustomHeroNameTextId;
|
||||
pset.heroPortrait = pinfo.mainCustomHeroPortrait;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
|
||||
boost::program_options::variables_map cmdLineOptions;
|
||||
std::set<std::shared_ptr<CConnection>> connections;
|
||||
std::set<std::shared_ptr<CConnection>> remoteConnections;
|
||||
std::set<std::shared_ptr<CConnection>> hangingConnections; //keep connections of players disconnected during the game
|
||||
|
||||
std::atomic<int> currentClientId;
|
||||
@@ -78,7 +79,7 @@ public:
|
||||
void startGameImmidiately();
|
||||
|
||||
void establishRemoteConnections();
|
||||
void connectToRemote(const std::string & addr, int port);
|
||||
void connectToRemote();
|
||||
void startAsyncAccept();
|
||||
void connectionAccepted(const boost::system::error_code & ec);
|
||||
void threadHandleClient(std::shared_ptr<CConnection> c);
|
||||
|
||||
@@ -189,6 +189,12 @@ void ApplyOnServerAfterAnnounceNetPackVisitor::visitLobbyClientDisconnected(Lobb
|
||||
srv.addToAnnounceQueue(std::move(ph));
|
||||
}
|
||||
srv.updateAndPropagateLobbyState();
|
||||
|
||||
if(srv.getState() != EServerState::SHUTDOWN && srv.remoteConnections.count(pack.c))
|
||||
{
|
||||
srv.remoteConnections -= pack.c;
|
||||
srv.connectToRemote();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientPermissionsCheckerNetPackVisitor::visitLobbyChatMessage(LobbyChatMessage & pack)
|
||||
|
||||
Reference in New Issue
Block a user