浏览代码

Only remove extension if it belongs to specified file type

This one fixes issue 1557
Now it's possible to load maps with dots in filename.
ArseniyShestakov 10 年之前
父节点
当前提交
19d1de3142
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      lib/filesystem/ResourceID.cpp

+ 6 - 3
lib/filesystem/ResourceID.cpp

@@ -35,14 +35,14 @@ ResourceID::ResourceID()
 ResourceID::ResourceID(std::string name)
 ResourceID::ResourceID(std::string name)
 {
 {
 	CFileInfo info(std::move(name));
 	CFileInfo info(std::move(name));
-	setName(info.getStem());
 	setType(info.getType());
 	setType(info.getType());
+	setName(info.getStem());
 }
 }
 
 
 ResourceID::ResourceID(std::string name, EResType::Type type)
 ResourceID::ResourceID(std::string name, EResType::Type type)
 {
 {
-	setName(std::move(name));
 	setType(type);
 	setType(type);
+	setName(std::move(name));
 }
 }
 
 
 std::string ResourceID::getName() const
 std::string ResourceID::getName() const
@@ -61,8 +61,11 @@ void ResourceID::setName(std::string name)
 
 
 	size_t dotPos = this->name.find_last_of("/.");
 	size_t dotPos = this->name.find_last_of("/.");
 
 
-	if(dotPos != std::string::npos && this->name[dotPos] == '.')
+	if(dotPos != std::string::npos && this->name[dotPos] == '.'
+		&& this->type == EResTypeHelper::getTypeFromExtension(this->name.substr(dotPos)))
+	{
 		this->name.erase(dotPos);
 		this->name.erase(dotPos);
+	}
 
 
 #ifdef ENABLE_TRIVIAL_TOUPPER
 #ifdef ENABLE_TRIVIAL_TOUPPER
 	toUpper(this->name);
 	toUpper(this->name);