1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-30 09:36:43 +00:00

changed UniversalId to string conversion

This commit is contained in:
Marc Zinnschlag 2012-12-09 11:10:35 +01:00
parent 9fe7ff9690
commit 832fc56d34
2 changed files with 40 additions and 35 deletions

View file

@ -17,5 +17,5 @@ void CSMTools::MandatoryIdStage::perform (int stage, std::vector<std::string>& m
{ {
if (mIdCollection.searchId (mIds.at (stage))==-1 || if (mIdCollection.searchId (mIds.at (stage))==-1 ||
mIdCollection.getRecord (mIds.at (stage)).isDeleted()) mIdCollection.getRecord (mIds.at (stage)).isDeleted())
messages.push_back (mCollectionId.toString() + " Missing mandatory record: " + mIds.at (stage)); messages.push_back (mCollectionId.toString() + "|Missing mandatory record: " + mIds.at (stage));
} }

View file

@ -43,39 +43,44 @@ CSMWorld::UniversalId::UniversalId (const std::string& universalId)
{ {
std::string type = universalId.substr (0, index); std::string type = universalId.substr (0, index);
for (int i=0; sNoArg[i].mName; ++i) if (index==std::string::npos)
if (type==sNoArg[i].mName) {
{ for (int i=0; sNoArg[i].mName; ++i)
mArgumentType = ArgumentType_None; if (type==sNoArg[i].mName)
mType = sNoArg[i].mType; {
mClass = sNoArg[i].mClass; mArgumentType = ArgumentType_None;
return; mType = sNoArg[i].mType;
} mClass = sNoArg[i].mClass;
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)
if (type==sIndexArg[i].mName)
{
mArgumentType = ArgumentType_Index;
mType = sIndexArg[i].mType;
mClass = sIndexArg[i].mClass;
std::istringstream stream (universalId.substr (0, index));
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;
}
break; 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 (0, index));
if (stream >> mIndex)
return;
break;
}
}
} }
throw std::runtime_error ("invalid UniversalId: " + universalId); throw std::runtime_error ("invalid UniversalId: " + universalId);
@ -197,13 +202,13 @@ std::string CSMWorld::UniversalId::toString() const
{ {
std::ostringstream stream; std::ostringstream stream;
stream << getTypeName() << ":"; stream << getTypeName();
switch (mArgumentType) switch (mArgumentType)
{ {
case ArgumentType_None: break; case ArgumentType_None: break;
case ArgumentType_Id: stream << " " << mId; case ArgumentType_Id: stream << ": " << mId;
case ArgumentType_Index: stream << " " << mIndex; case ArgumentType_Index: stream << ": " << mIndex;
} }
return stream.str(); return stream.str();