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:
parent
19d1de3142
commit
8f08effe93
@ -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("/.");
|
||||
|
@ -56,7 +56,8 @@ namespace EResType
|
||||
ERM,
|
||||
ERT,
|
||||
ERS,
|
||||
OTHER
|
||||
OTHER,
|
||||
UNDEFINED
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user