mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +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) | ||||
| 	: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 | ||||
| 	}; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user