From f6c1dace6cbb46a36cb063f7b2d2330f952d8685 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 28 Dec 2013 18:57:08 +0000 Subject: [PATCH] Minors: - By default, cmake will keep debug info - removed warnings from adventure map infobox (part of #1636) - adventure map infobox will refresh on artifact changes (part of #1636) - moved terrain music files to terrains.json file - player should act before AI in all games, not only campaigns --- CMakeLists.txt | 2 +- client/AdventureMapClasses.cpp | 2 +- client/CMusicHandler.cpp | 19 +++++++++---------- client/CPlayerInterface.cpp | 6 +++++- config/terrains.json | 30 ++++++++++++++++++++---------- lib/IGameCallback.cpp | 6 +++--- lib/IGameCallback.h | 2 +- server/CGameHandler.cpp | 15 ++++++--------- 8 files changed, 46 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5d45e4ea..629e87a70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules) # enable Release mode but only if it was not set if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) + set(CMAKE_BUILD_TYPE RelWithDebInfo) endif() # VCMI version diff --git a/client/AdventureMapClasses.cpp b/client/AdventureMapClasses.cpp index b7de70ef2..dc273def6 100644 --- a/client/AdventureMapClasses.cpp +++ b/client/AdventureMapClasses.cpp @@ -761,7 +761,7 @@ void CInfoBar::CVisibleInfo::loadGameStatus() //generate list of allies and enemies for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; i++) { - if(LOCPLINT->cb->getPlayerStatus(PlayerColor(i)) == EPlayerStatus::INGAME) + if(LOCPLINT->cb->getPlayerStatus(PlayerColor(i), false) == EPlayerStatus::INGAME) { if (LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, PlayerColor(i)) != PlayerRelations::ENEMIES) allies.push_back(PlayerColor(i)); diff --git a/client/CMusicHandler.cpp b/client/CMusicHandler.cpp index 76b4ae77a..505eecded 100644 --- a/client/CMusicHandler.cpp +++ b/client/CMusicHandler.cpp @@ -8,6 +8,7 @@ #include "../lib/JsonNode.h" #include "../lib/GameConstants.h" #include "../lib/filesystem/Filesystem.h" +#include "../lib/StringConstants.h" /* * CMusicHandler.cpp, part of VCMI engine @@ -307,16 +308,21 @@ CMusicHandler::CMusicHandler(): // Vectors for helper const std::string setEnemy[] = {"AITheme0", "AITheme1", "AITheme2"}; const std::string setBattle[] = {"Combat01", "Combat02", "Combat03", "Combat04"}; - const std::string setTerrain[] = {"Dirt", "Sand", "Grass", "Snow", "Swamp", "Rough", "Underground", "Lava", "Water"}; auto fillSet = [=](std::string setName, const std::string list[], size_t amount) { for (size_t i=0; i < amount; i++) - addEntryToSet(setName, i, std::string("music/") + list[i]); + addEntryToSet(setName, i, "music/" + list[i]); }; fillSet("enemy-turn", setEnemy, ARRAY_COUNT(setEnemy)); fillSet("battle", setBattle, ARRAY_COUNT(setBattle)); - fillSet("terrain", setTerrain, ARRAY_COUNT(setTerrain)); + + JsonNode terrains(ResourceID("config/terrains.json")); + for (auto entry : terrains.Struct()) + { + int terrIndex = vstd::find_pos(GameConstants::TERRAIN_NAMES, entry.first); + addEntryToSet("terrain", terrIndex, "Music/" + entry.second["music"].String()); + } } void CMusicHandler::addEntryToSet(std::string set, int musicID, std::string musicURI) @@ -479,8 +485,6 @@ MusicEntry::~MusicEntry() logGlobal->traceStream()<<"Del-ing music file "<infoBar.showSelection(); for(IShowActivatable *isa : GH.listInt) { auto artWin = dynamic_cast(isa); @@ -2526,6 +2527,7 @@ void CPlayerInterface::artifactRemoved(const ArtifactLocation &al) void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst) { EVENT_HANDLER_CALLED_BY_CLIENT; + adventureInt->infoBar.showSelection(); for(IShowActivatable *isa : GH.listInt) { auto artWin = dynamic_cast(isa); @@ -2537,6 +2539,7 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact void CPlayerInterface::artifactAssembled(const ArtifactLocation &al) { EVENT_HANDLER_CALLED_BY_CLIENT; + adventureInt->infoBar.showSelection(); for(IShowActivatable *isa : GH.listInt) { auto artWin = dynamic_cast(isa); @@ -2548,6 +2551,7 @@ void CPlayerInterface::artifactAssembled(const ArtifactLocation &al) void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al) { EVENT_HANDLER_CALLED_BY_CLIENT; + adventureInt->infoBar.showSelection(); for(IShowActivatable *isa : GH.listInt) { auto artWin = dynamic_cast(isa); @@ -2559,7 +2563,7 @@ void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al) void CPlayerInterface::playerStartsTurn(PlayerColor player) { EVENT_HANDLER_CALLED_BY_CLIENT; - + adventureInt->infoBar.showSelection(); if (!vstd::contains (GH.listInt, adventureInt)) { GH.popInts (GH.listInt.size()); //after map load - remove everything else diff --git a/config/terrains.json b/config/terrains.json index 99080f722..0e56d0986 100644 --- a/config/terrains.json +++ b/config/terrains.json @@ -3,60 +3,70 @@ { "moveCost" : 100, "minimapUnblocked" : [ 82, 56, 8 ], - "minimapBlocked" : [ 57, 40, 8 ] + "minimapBlocked" : [ 57, 40, 8 ], + "music" : "Dirt.mp3" }, "sand" : { "moveCost" : 150, "minimapUnblocked" : [ 222, 207, 140 ], - "minimapBlocked" : [ 165, 158, 107 ] + "minimapBlocked" : [ 165, 158, 107 ], + "music" : "Sand.mp3" }, "grass" : { "moveCost" : 100, "minimapUnblocked" : [ 0, 65, 0 ], - "minimapBlocked" : [ 0, 48, 0 ] + "minimapBlocked" : [ 0, 48, 0 ], + "music" : "Grass.mp3" }, "snow" : { "moveCost" : 150, "minimapUnblocked" : [ 181, 199, 198 ], - "minimapBlocked" : [ 140, 158, 156 ] + "minimapBlocked" : [ 140, 158, 156 ], + "music" : "Snow.mp3" }, "swamp" : { "moveCost" : 175, "minimapUnblocked" : [ 74, 134, 107 ], - "minimapBlocked" : [ 33, 89, 66 ] + "minimapBlocked" : [ 33, 89, 66 ], + "music" : "Swamp.mp3" }, "rough" : { "moveCost" : 125, "minimapUnblocked" : [ 132, 113, 49 ], - "minimapBlocked" : [ 99, 81, 33 ] + "minimapBlocked" : [ 99, 81, 33 ], + "music" : "Rough.mp3" }, "subterra" : { "moveCost" : 100, "minimapUnblocked" : [ 132, 48, 0 ], - "minimapBlocked" : [ 90, 8, 0 ] + "minimapBlocked" : [ 90, 8, 0 ], + "music" : "Underground.mp3" }, "lava" : { "moveCost" : 100, "minimapUnblocked" : [ 74, 73, 74 ], - "minimapBlocked" : [ 41, 40, 41 ] + "minimapBlocked" : [ 41, 40, 41 ], + "music" : "Lava.mp3" }, "water" : { "moveCost" : 100, "minimapUnblocked" : [ 8, 81, 148 ], - "minimapBlocked" : [ 8, 81, 148 ] + "minimapBlocked" : [ 8, 81, 148 ], + "music" : "Water.mp3" }, "rock" : { "moveCost" : -1, "minimapUnblocked" : [ 0, 0, 0 ], - "minimapBlocked" : [ 0, 0, 0 ] + "minimapBlocked" : [ 0, 0, 0 ], + "music" : "Underground.mp3" // Impossible in H3 } } diff --git a/lib/IGameCallback.cpp b/lib/IGameCallback.cpp index 8b7855808..23e10d4a4 100644 --- a/lib/IGameCallback.cpp +++ b/lib/IGameCallback.cpp @@ -633,10 +633,10 @@ bool CGameInfoCallback::hasAccess(boost::optional playerId) const return !player || gs->getPlayerRelations( *playerId, *player ) != PlayerRelations::ENEMIES; } -EPlayerStatus::EStatus CGameInfoCallback::getPlayerStatus(PlayerColor player) const +EPlayerStatus::EStatus CGameInfoCallback::getPlayerStatus(PlayerColor player, bool verbose) const { - const PlayerState *ps = gs->getPlayer(player, false); - ERROR_RET_VAL_IF(!ps, "No such player!", EPlayerStatus::WRONG); + const PlayerState *ps = gs->getPlayer(player, verbose); + ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!ps, verbose, "No such player!", EPlayerStatus::WRONG); return ps->status; } diff --git a/lib/IGameCallback.h b/lib/IGameCallback.h index 8a16a0bc7..d417a72f5 100644 --- a/lib/IGameCallback.h +++ b/lib/IGameCallback.h @@ -85,7 +85,7 @@ public: bool isVisible(int3 pos) const; PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const; void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object - EPlayerStatus::EStatus getPlayerStatus(PlayerColor player) const; //-1 if no such player + EPlayerStatus::EStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player PlayerColor getCurrentPlayer() const; //player that currently makes move // TODO synchronous turns virtual PlayerColor getLocalPlayer() const; //player that is currently owning given client (if not a client, then returns current player) const PlayerSettings * getPlayerSettings(PlayerColor color) const; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 77f9de91e..cfac7ec5e 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1519,19 +1519,16 @@ std::list CGameHandler::generatePlayerTurnOrder() const // Generate player turn order std::list playerTurnOrder; - bool playCampaign = gs->scenarioOps->campState != nullptr; - for(const auto & player : gs->players) // add human players for campaign only first OR all players for normal game + for(const auto & player : gs->players) // add human players first { - if(player.second.human || !playCampaign) playerTurnOrder.push_back(player.first); + if(player.second.human) + playerTurnOrder.push_back(player.first); } - if(playCampaign) + for(const auto & player : gs->players) // then add non-human players { - for(const auto & player : gs->players) // then add non-human players for campaign - { - if(!player.second.human) playerTurnOrder.push_back(player.first); - } + if(!player.second.human) + playerTurnOrder.push_back(player.first); } - return std::move(playerTurnOrder); }