mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
Check that resource type set before setName used
This commit is contained in:
@ -33,6 +33,7 @@ ResourceID::ResourceID()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResourceID::ResourceID(std::string name)
|
ResourceID::ResourceID(std::string name)
|
||||||
|
:type(EResType::UNDEFINED)
|
||||||
{
|
{
|
||||||
CFileInfo info(std::move(name));
|
CFileInfo info(std::move(name));
|
||||||
setType(info.getType());
|
setType(info.getType());
|
||||||
@ -40,6 +41,7 @@ ResourceID::ResourceID(std::string name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResourceID::ResourceID(std::string name, EResType::Type type)
|
ResourceID::ResourceID(std::string name, EResType::Type type)
|
||||||
|
:type(EResType::UNDEFINED)
|
||||||
{
|
{
|
||||||
setType(type);
|
setType(type);
|
||||||
setName(std::move(name));
|
setName(std::move(name));
|
||||||
@ -57,6 +59,9 @@ EResType::Type ResourceID::getType() const
|
|||||||
|
|
||||||
void ResourceID::setName(std::string name)
|
void ResourceID::setName(std::string name)
|
||||||
{
|
{
|
||||||
|
// setName shouldn't be used if type is UNDEFINED
|
||||||
|
assert(type != EResType::UNDEFINED);
|
||||||
|
|
||||||
this->name = std::move(name);
|
this->name = std::move(name);
|
||||||
|
|
||||||
size_t dotPos = this->name.find_last_of("/.");
|
size_t dotPos = this->name.find_last_of("/.");
|
||||||
|
@ -56,7 +56,8 @@ namespace EResType
|
|||||||
ERM,
|
ERM,
|
||||||
ERT,
|
ERT,
|
||||||
ERS,
|
ERS,
|
||||||
OTHER
|
OTHER,
|
||||||
|
UNDEFINED
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user