1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Dedug tweaks

This commit is contained in:
AlexVinS 2016-02-13 17:16:00 +03:00
parent 5a92e0de2b
commit a59f0c23ce
5 changed files with 19 additions and 16 deletions

View File

@ -1852,7 +1852,7 @@ void CGameState::initMapObjects()
{
if(obj)
{
//logGlobal->traceStream() << boost::format ("Calling Init for object %d, %d") % obj->ID % obj->subID;
logGlobal->traceStream() << boost::format ("Calling Init for object %d, %s, %s") % obj->id.getNum() % obj->typeName % obj->subTypeName;
obj->initObj();
}
}

View File

@ -359,8 +359,6 @@ void CGObjectInstance::readJson(const JsonNode & json)
appearance.readJson(json["template"], false);
logGlobal->debugStream() <<"Loading: [" << pos << "] " << id << " " << ID << " " << subID << " " << typeName << " " << subTypeName;
readJsonOptions(json["options"]);
}

View File

@ -602,13 +602,15 @@ void CMapLoaderJson::readTerrain()
}
CMapLoaderJson::MapObjectLoader::MapObjectLoader(CMapLoaderJson * _owner, const JsonMap::value_type& json):
owner(_owner), instance(nullptr),handler(nullptr),id(-1), jsonKey(json.first), configuration(json.second), internalId(extractNumber(jsonKey, '_'))
owner(_owner), instance(nullptr),id(-1), jsonKey(json.first), configuration(json.second), internalId(extractNumber(jsonKey, '_'))
{
}
void CMapLoaderJson::MapObjectLoader::construct()
{
logGlobal->debugStream() <<"Loading: " <<jsonKey;
//TODO:consider move to ObjectTypeHandler
//find type handler
std::string typeName = configuration["type"].String(), subTypeName = configuration["subType"].String();
@ -618,12 +620,7 @@ void CMapLoaderJson::MapObjectLoader::construct()
logGlobal->traceStream() << configuration;
return;
}
if(subTypeName.empty())
{
logGlobal->errorStream() << "Object subType missing";
logGlobal->traceStream() << configuration;
return;
}
//special case for grail
if(typeName == "grail")
@ -633,9 +630,16 @@ void CMapLoaderJson::MapObjectLoader::construct()
pos.y = configuration["y"].Float();
pos.z = configuration["l"].Float();
owner->map->grailRadius = configuration["options"]["grailRadius"].Float();
return;
}
else if(subTypeName.empty())
{
logGlobal->errorStream() << "Object subType missing";
logGlobal->traceStream() << configuration;
return;
}
handler = VLC->objtypeh->getHandlerFor(typeName, subTypeName);
auto handler = VLC->objtypeh->getHandlerFor(typeName, subTypeName);
instance = handler->create(ObjectTemplate());
instance->id = ObjectInstanceID(owner->map->objects.size());

View File

@ -123,7 +123,6 @@ private:
MapObjectLoader(CMapLoaderJson * _owner, const JsonMap::value_type & json);
CMapLoaderJson * owner;
CGObjectInstance * instance;
std::shared_ptr<AObjectTypeHandler> handler;
ObjectInstanceID id;
std::string jsonKey;//full id defined by map creator
const JsonNode & configuration;

View File

@ -35,13 +35,15 @@ public:
{
CMapGenOptions opt;
opt.setHeight(CMapHeader::MAP_SIZE_SMALL);
opt.setWidth(CMapHeader::MAP_SIZE_SMALL);
opt.setHeight(CMapHeader::MAP_SIZE_LARGE);
opt.setWidth(CMapHeader::MAP_SIZE_LARGE);
opt.setHasTwoLevels(true);
opt.setPlayerCount(2);
opt.setPlayerCount(4);
opt.setPlayerTypeForStandardPlayer(PlayerColor(0), EPlayerType::HUMAN);
opt.setPlayerTypeForStandardPlayer(PlayerColor(1), EPlayerType::HUMAN);
opt.setPlayerTypeForStandardPlayer(PlayerColor(1), EPlayerType::AI);
opt.setPlayerTypeForStandardPlayer(PlayerColor(2), EPlayerType::AI);
opt.setPlayerTypeForStandardPlayer(PlayerColor(3), EPlayerType::AI);
CMapGenerator gen;