1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
- 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
This commit is contained in:
Ivan Savenko 2013-12-28 18:57:08 +00:00
parent 344783efb5
commit f6c1dace6c
8 changed files with 46 additions and 36 deletions

View File

@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules)
# enable Release mode but only if it was not set # enable Release mode but only if it was not set
if (NOT CMAKE_BUILD_TYPE) if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif() endif()
# VCMI version # VCMI version

View File

@ -761,7 +761,7 @@ void CInfoBar::CVisibleInfo::loadGameStatus()
//generate list of allies and enemies //generate list of allies and enemies
for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; i++) 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) if (LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, PlayerColor(i)) != PlayerRelations::ENEMIES)
allies.push_back(PlayerColor(i)); allies.push_back(PlayerColor(i));

View File

@ -8,6 +8,7 @@
#include "../lib/JsonNode.h" #include "../lib/JsonNode.h"
#include "../lib/GameConstants.h" #include "../lib/GameConstants.h"
#include "../lib/filesystem/Filesystem.h" #include "../lib/filesystem/Filesystem.h"
#include "../lib/StringConstants.h"
/* /*
* CMusicHandler.cpp, part of VCMI engine * CMusicHandler.cpp, part of VCMI engine
@ -307,16 +308,21 @@ CMusicHandler::CMusicHandler():
// Vectors for helper // Vectors for helper
const std::string setEnemy[] = {"AITheme0", "AITheme1", "AITheme2"}; const std::string setEnemy[] = {"AITheme0", "AITheme1", "AITheme2"};
const std::string setBattle[] = {"Combat01", "Combat02", "Combat03", "Combat04"}; 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) auto fillSet = [=](std::string setName, const std::string list[], size_t amount)
{ {
for (size_t i=0; i < amount; i++) 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("enemy-turn", setEnemy, ARRAY_COUNT(setEnemy));
fillSet("battle", setBattle, ARRAY_COUNT(setBattle)); 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) void CMusicHandler::addEntryToSet(std::string set, int musicID, std::string musicURI)
@ -479,8 +485,6 @@ MusicEntry::~MusicEntry()
logGlobal->traceStream()<<"Del-ing music file "<<currentName; logGlobal->traceStream()<<"Del-ing music file "<<currentName;
if (music) if (music)
Mix_FreeMusic(music); Mix_FreeMusic(music);
/*if (musicFile) // Mix_FreeMusic will also free file data? Needs checking
SDL_FreeRW(musicFile);*/
} }
void MusicEntry::load(std::string musicURI) void MusicEntry::load(std::string musicURI)
@ -491,11 +495,6 @@ void MusicEntry::load(std::string musicURI)
Mix_FreeMusic(music); Mix_FreeMusic(music);
music = nullptr; music = nullptr;
} }
/*if (musicFile) // Mix_FreeMusic will also free file data? Needs checking
{
SDL_FreeRW(musicFile);
musicFile = nullptr;
}*/
currentName = musicURI; currentName = musicURI;

View File

@ -2515,6 +2515,7 @@ void CPlayerInterface::artifactPut(const ArtifactLocation &al)
void CPlayerInterface::artifactRemoved(const ArtifactLocation &al) void CPlayerInterface::artifactRemoved(const ArtifactLocation &al)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
adventureInt->infoBar.showSelection();
for(IShowActivatable *isa : GH.listInt) for(IShowActivatable *isa : GH.listInt)
{ {
auto artWin = dynamic_cast<CArtifactHolder*>(isa); auto artWin = dynamic_cast<CArtifactHolder*>(isa);
@ -2526,6 +2527,7 @@ void CPlayerInterface::artifactRemoved(const ArtifactLocation &al)
void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst) void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
adventureInt->infoBar.showSelection();
for(IShowActivatable *isa : GH.listInt) for(IShowActivatable *isa : GH.listInt)
{ {
auto artWin = dynamic_cast<CArtifactHolder*>(isa); auto artWin = dynamic_cast<CArtifactHolder*>(isa);
@ -2537,6 +2539,7 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact
void CPlayerInterface::artifactAssembled(const ArtifactLocation &al) void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
adventureInt->infoBar.showSelection();
for(IShowActivatable *isa : GH.listInt) for(IShowActivatable *isa : GH.listInt)
{ {
auto artWin = dynamic_cast<CArtifactHolder*>(isa); auto artWin = dynamic_cast<CArtifactHolder*>(isa);
@ -2548,6 +2551,7 @@ void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al) void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
adventureInt->infoBar.showSelection();
for(IShowActivatable *isa : GH.listInt) for(IShowActivatable *isa : GH.listInt)
{ {
auto artWin = dynamic_cast<CArtifactHolder*>(isa); auto artWin = dynamic_cast<CArtifactHolder*>(isa);
@ -2559,7 +2563,7 @@ void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al)
void CPlayerInterface::playerStartsTurn(PlayerColor player) void CPlayerInterface::playerStartsTurn(PlayerColor player)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
adventureInt->infoBar.showSelection();
if (!vstd::contains (GH.listInt, adventureInt)) if (!vstd::contains (GH.listInt, adventureInt))
{ {
GH.popInts (GH.listInt.size()); //after map load - remove everything else GH.popInts (GH.listInt.size()); //after map load - remove everything else

View File

@ -3,60 +3,70 @@
{ {
"moveCost" : 100, "moveCost" : 100,
"minimapUnblocked" : [ 82, 56, 8 ], "minimapUnblocked" : [ 82, 56, 8 ],
"minimapBlocked" : [ 57, 40, 8 ] "minimapBlocked" : [ 57, 40, 8 ],
"music" : "Dirt.mp3"
}, },
"sand" : "sand" :
{ {
"moveCost" : 150, "moveCost" : 150,
"minimapUnblocked" : [ 222, 207, 140 ], "minimapUnblocked" : [ 222, 207, 140 ],
"minimapBlocked" : [ 165, 158, 107 ] "minimapBlocked" : [ 165, 158, 107 ],
"music" : "Sand.mp3"
}, },
"grass" : "grass" :
{ {
"moveCost" : 100, "moveCost" : 100,
"minimapUnblocked" : [ 0, 65, 0 ], "minimapUnblocked" : [ 0, 65, 0 ],
"minimapBlocked" : [ 0, 48, 0 ] "minimapBlocked" : [ 0, 48, 0 ],
"music" : "Grass.mp3"
}, },
"snow" : "snow" :
{ {
"moveCost" : 150, "moveCost" : 150,
"minimapUnblocked" : [ 181, 199, 198 ], "minimapUnblocked" : [ 181, 199, 198 ],
"minimapBlocked" : [ 140, 158, 156 ] "minimapBlocked" : [ 140, 158, 156 ],
"music" : "Snow.mp3"
}, },
"swamp" : "swamp" :
{ {
"moveCost" : 175, "moveCost" : 175,
"minimapUnblocked" : [ 74, 134, 107 ], "minimapUnblocked" : [ 74, 134, 107 ],
"minimapBlocked" : [ 33, 89, 66 ] "minimapBlocked" : [ 33, 89, 66 ],
"music" : "Swamp.mp3"
}, },
"rough" : "rough" :
{ {
"moveCost" : 125, "moveCost" : 125,
"minimapUnblocked" : [ 132, 113, 49 ], "minimapUnblocked" : [ 132, 113, 49 ],
"minimapBlocked" : [ 99, 81, 33 ] "minimapBlocked" : [ 99, 81, 33 ],
"music" : "Rough.mp3"
}, },
"subterra" : "subterra" :
{ {
"moveCost" : 100, "moveCost" : 100,
"minimapUnblocked" : [ 132, 48, 0 ], "minimapUnblocked" : [ 132, 48, 0 ],
"minimapBlocked" : [ 90, 8, 0 ] "minimapBlocked" : [ 90, 8, 0 ],
"music" : "Underground.mp3"
}, },
"lava" : "lava" :
{ {
"moveCost" : 100, "moveCost" : 100,
"minimapUnblocked" : [ 74, 73, 74 ], "minimapUnblocked" : [ 74, 73, 74 ],
"minimapBlocked" : [ 41, 40, 41 ] "minimapBlocked" : [ 41, 40, 41 ],
"music" : "Lava.mp3"
}, },
"water" : "water" :
{ {
"moveCost" : 100, "moveCost" : 100,
"minimapUnblocked" : [ 8, 81, 148 ], "minimapUnblocked" : [ 8, 81, 148 ],
"minimapBlocked" : [ 8, 81, 148 ] "minimapBlocked" : [ 8, 81, 148 ],
"music" : "Water.mp3"
}, },
"rock" : "rock" :
{ {
"moveCost" : -1, "moveCost" : -1,
"minimapUnblocked" : [ 0, 0, 0 ], "minimapUnblocked" : [ 0, 0, 0 ],
"minimapBlocked" : [ 0, 0, 0 ] "minimapBlocked" : [ 0, 0, 0 ],
"music" : "Underground.mp3" // Impossible in H3
} }
} }

View File

@ -633,10 +633,10 @@ bool CGameInfoCallback::hasAccess(boost::optional<PlayerColor> playerId) const
return !player || gs->getPlayerRelations( *playerId, *player ) != PlayerRelations::ENEMIES; 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); const PlayerState *ps = gs->getPlayer(player, verbose);
ERROR_RET_VAL_IF(!ps, "No such player!", EPlayerStatus::WRONG); ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!ps, verbose, "No such player!", EPlayerStatus::WRONG);
return ps->status; return ps->status;
} }

View File

@ -85,7 +85,7 @@ public:
bool isVisible(int3 pos) const; bool isVisible(int3 pos) const;
PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) 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 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 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) 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; const PlayerSettings * getPlayerSettings(PlayerColor color) const;

View File

@ -1519,19 +1519,16 @@ std::list<PlayerColor> CGameHandler::generatePlayerTurnOrder() const
// Generate player turn order // Generate player turn order
std::list<PlayerColor> playerTurnOrder; std::list<PlayerColor> playerTurnOrder;
bool playCampaign = gs->scenarioOps->campState != nullptr; for(const auto & player : gs->players) // add human players first
for(const auto & player : gs->players) // add human players for campaign only first OR all players for normal game
{ {
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); return std::move(playerTurnOrder);
} }