multiple fixes to UniversalId constructor

This commit is contained in:
Marc Zinnschlag 2013-04-06 19:20:46 +02:00
parent 0fb583e065
commit 9bc3945f40

View file

@ -55,44 +55,41 @@ CSMWorld::UniversalId::UniversalId (const std::string& universalId)
{ {
std::string type = universalId.substr (0, index); std::string type = universalId.substr (0, index);
if (index==std::string::npos) for (int i=0; sIdArg[i].mName; ++i)
{ if (type==sIdArg[i].mName)
for (int i=0; sNoArg[i].mName; ++i) {
if (type==sNoArg[i].mName) mArgumentType = ArgumentType_Id;
{ mType = sIdArg[i].mType;
mArgumentType = ArgumentType_None; mClass = sIdArg[i].mClass;
mType = sNoArg[i].mType; mId = universalId.substr (index+2);
mClass = sNoArg[i].mClass; return;
}
for (int i=0; sIndexArg[i].mName; ++i)
if (type==sIndexArg[i].mName)
{
mArgumentType = ArgumentType_Index;
mType = sIndexArg[i].mType;
mClass = sIndexArg[i].mClass;
std::istringstream stream (universalId.substr (index+2));
if (stream >> mIndex)
return; return;
}
}
else
{
for (int i=0; sIdArg[i].mName; ++i)
if (type==sIdArg[i].mName)
{
mArgumentType = ArgumentType_Id;
mType = sIdArg[i].mType;
mClass = sIdArg[i].mClass;
mId = universalId.substr (0, index);
return;
}
for (int i=0; sIndexArg[i].mName; ++i) break;
if (type==sIndexArg[i].mName) }
{ }
mArgumentType = ArgumentType_Index; else
mType = sIndexArg[i].mType; {
mClass = sIndexArg[i].mClass; for (int i=0; sNoArg[i].mName; ++i)
if (universalId==sNoArg[i].mName)
std::istringstream stream (universalId.substr (0, index)); {
mArgumentType = ArgumentType_None;
if (stream >> mIndex) mType = sNoArg[i].mType;
return; mClass = sNoArg[i].mClass;
return;
break; }
}
}
} }
throw std::runtime_error ("invalid UniversalId: " + universalId); throw std::runtime_error ("invalid UniversalId: " + universalId);