1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Check that resource type set before setName used

This commit is contained in:
ArseniyShestakov 2015-02-06 10:51:32 +03:00
parent 19d1de3142
commit 8f08effe93
2 changed files with 7 additions and 1 deletions

View File

@ -33,6 +33,7 @@ ResourceID::ResourceID()
}
ResourceID::ResourceID(std::string name)
:type(EResType::UNDEFINED)
{
CFileInfo info(std::move(name));
setType(info.getType());
@ -40,6 +41,7 @@ ResourceID::ResourceID(std::string name)
}
ResourceID::ResourceID(std::string name, EResType::Type type)
:type(EResType::UNDEFINED)
{
setType(type);
setName(std::move(name));
@ -57,6 +59,9 @@ EResType::Type ResourceID::getType() const
void ResourceID::setName(std::string name)
{
// setName shouldn't be used if type is UNDEFINED
assert(type != EResType::UNDEFINED);
this->name = std::move(name);
size_t dotPos = this->name.find_last_of("/.");

View File

@ -56,7 +56,8 @@ namespace EResType
ERM,
ERT,
ERS,
OTHER
OTHER,
UNDEFINED
};
}