libfalltergeist::ProFileType* ResourceManager::proFileType(unsigned int PID) { unsigned int typeId = PID >> 24; std::string listFile; switch (typeId) { case libfalltergeist::ProFileType::TYPE_ITEM: listFile += "proto/items/items.lst"; break; case libfalltergeist::ProFileType::TYPE_CRITTER: listFile += "proto/critters/critters.lst"; break; case libfalltergeist::ProFileType::TYPE_SCENERY: listFile += "proto/scenery/scenery.lst"; break; case libfalltergeist::ProFileType::TYPE_WALL: listFile += "proto/walls/walls.lst"; break; case libfalltergeist::ProFileType::TYPE_TILE: listFile += "proto/tiles/tiles.lst"; break; case libfalltergeist::ProFileType::TYPE_MISC: listFile += "proto/misc/misc.lst"; break; default: debug("ResourceManager::proFileType(unsigned int) - wrong PID: " + std::to_string(PID), DEBUG_ERROR); return 0; } libfalltergeist::LstFileType * lst = lstFileType(listFile); unsigned int index = 0x00000FFF & PID; if (index > lst->strings()->size()) { debug("ResourceManager::proFileType(unsigned int) - LST size < PID: " + std::to_string(PID), DEBUG_ERROR); return 0; } std::string protoName = lst->strings()->at(index-1); switch (typeId) { case libfalltergeist::ProFileType::TYPE_ITEM: return proFileType("proto/items/" + protoName); case libfalltergeist::ProFileType::TYPE_CRITTER: return proFileType("proto/critters/" + protoName); case libfalltergeist::ProFileType::TYPE_SCENERY: return proFileType("proto/scenery/" + protoName); case libfalltergeist::ProFileType::TYPE_WALL: return proFileType("proto/walls/" + protoName); case libfalltergeist::ProFileType::TYPE_TILE: return proFileType("proto/tiles/" + protoName); case libfalltergeist::ProFileType::TYPE_MISC: return proFileType("proto/misc/" + protoName); } return 0; }
libfalltergeist::Pro::File* ResourceManager::proFileType(unsigned int PID) { unsigned int typeId = PID >> 24; std::string listFile; switch ((OBJECT_TYPE)typeId) { case OBJECT_TYPE::ITEM: listFile += "proto/items/items.lst"; break; case OBJECT_TYPE::CRITTER: listFile += "proto/critters/critters.lst"; break; case OBJECT_TYPE::SCENERY: listFile += "proto/scenery/scenery.lst"; break; case OBJECT_TYPE::WALL: listFile += "proto/walls/walls.lst"; break; case OBJECT_TYPE::TILE: listFile += "proto/tiles/tiles.lst"; break; case OBJECT_TYPE::MISC: listFile += "proto/misc/misc.lst"; break; default: Logger::error() << "ResourceManager::proFileType(unsigned int) - wrong PID: " << PID << std::endl; return nullptr; } auto lst = lstFileType(listFile); unsigned int index = 0x00000FFF & PID; if (index > lst->strings()->size()) { Logger::error() << "ResourceManager::proFileType(unsigned int) - LST size < PID: " << PID << std::endl; return nullptr; } std::string protoName = lst->strings()->at(index-1); switch ((OBJECT_TYPE)typeId) { case OBJECT_TYPE::ITEM: return proFileType("proto/items/" + protoName); case OBJECT_TYPE::CRITTER: return proFileType("proto/critters/" + protoName); case OBJECT_TYPE::SCENERY: return proFileType("proto/scenery/" + protoName); case OBJECT_TYPE::WALL: return proFileType("proto/walls/" + protoName); case OBJECT_TYPE::TILE: return proFileType("proto/tiles/" + protoName); case OBJECT_TYPE::MISC: return proFileType("proto/misc/" + protoName); } return nullptr; }