1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Add some debug logging, Fix one special case when updating terrain type, Improve visual look of updated terrain types

This commit is contained in:
beegee1
2015-03-22 20:32:22 +01:00
parent 6001a89632
commit dafaf86eef
8 changed files with 176 additions and 26 deletions

View File

@@ -88,10 +88,10 @@ CCreature * CreatureID::toCreature() const
CSpell * SpellID::toSpell() const
{
if(num < 0 || num >= VLC->spellh->objects.size())
{
{
logGlobal->errorStream() << "Unable to get spell of invalid ID " << int(num);
return nullptr;
}
}
return VLC->spellh->objects[*this];
}
@@ -129,3 +129,34 @@ std::ostream & operator<<(std::ostream & os, const Battle::ActionType actionType
if (it == actionTypeToString.end()) return os << "<Unknown type>";
else return os << it->second;
}
std::ostream & operator<<(std::ostream & os, const ETerrainType actionType)
{
static const std::map<ETerrainType::EETerrainType, std::string> terrainTypeToString =
{
#define DEFINE_ELEMENT(element) {ETerrainType::element, #element}
DEFINE_ELEMENT(WRONG),
DEFINE_ELEMENT(BORDER),
DEFINE_ELEMENT(DIRT),
DEFINE_ELEMENT(SAND),
DEFINE_ELEMENT(GRASS),
DEFINE_ELEMENT(SNOW),
DEFINE_ELEMENT(SWAMP),
DEFINE_ELEMENT(ROUGH),
DEFINE_ELEMENT(SUBTERRANEAN),
DEFINE_ELEMENT(LAVA),
DEFINE_ELEMENT(WATER),
DEFINE_ELEMENT(ROCK)
};
auto it = terrainTypeToString.find(actionType.num);
if (it == terrainTypeToString.end()) return os << "<Unknown type>";
else return os << it->second;
}
std::string ETerrainType::toString() const
{
std::stringstream ss;
ss << *this;
return ss.str();
}