mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 10:52:46 +00:00
Convert plUoid's object name to a plString
This commit is contained in:
@ -109,12 +109,7 @@ hsBool NameMatches(const char* obName, const char* pKName, hsBool subString)
|
||||
}
|
||||
else
|
||||
{
|
||||
char oCopy[256], pCopy[256];
|
||||
strcpy(oCopy, o);
|
||||
strcpy(pCopy, p);
|
||||
hsStrLower(oCopy);
|
||||
hsStrLower(pCopy);
|
||||
if (strstr(pCopy, oCopy))
|
||||
if (plString(_TEMP_CONVERT_FROM_LITERAL(p)).Find(p, plString::kCaseInsensitive) >= 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -122,7 +117,7 @@ hsBool NameMatches(const char* obName, const char* pKName, hsBool subString)
|
||||
}
|
||||
|
||||
plKey plKeyFinder::StupidSearch(const char * age, const char * rm,
|
||||
const char *className, const char *obName, hsBool subString)
|
||||
const char *className, const plString &obName, hsBool subString)
|
||||
{
|
||||
UInt16 ty = plFactory::FindClassIndex(className);
|
||||
return StupidSearch(age, rm, ty, obName, subString);
|
||||
@ -132,7 +127,7 @@ class plKeyFinderIter : public plRegistryKeyIterator, public plRegistryPageItera
|
||||
{
|
||||
protected:
|
||||
UInt16 fClassType;
|
||||
const char *fObjName;
|
||||
plString fObjName;
|
||||
hsBool fSubstr;
|
||||
plKey fFoundKey;
|
||||
const char *fAgeName;
|
||||
@ -140,17 +135,17 @@ protected:
|
||||
public:
|
||||
plKey GetFoundKey( void ) const { return fFoundKey; }
|
||||
|
||||
plKeyFinderIter( UInt16 classType, const char *obName, hsBool substr )
|
||||
plKeyFinderIter( UInt16 classType, const plString &obName, hsBool substr )
|
||||
: fFoundKey( nil ), fClassType( classType ), fObjName( obName ), fSubstr( substr ) { }
|
||||
|
||||
plKeyFinderIter( UInt16 classType, const char *obName, hsBool substr, const char *ageName )
|
||||
plKeyFinderIter( UInt16 classType, const plString &obName, hsBool substr, const char *ageName )
|
||||
: fFoundKey( nil ), fClassType( classType ), fObjName( obName ), fSubstr( substr ),
|
||||
fAgeName( ageName ) {}
|
||||
|
||||
virtual hsBool EatKey( const plKey& key )
|
||||
{
|
||||
if( key->GetUoid().GetClassType() == fClassType &&
|
||||
NameMatches( fObjName, key->GetUoid().GetObjectName(), fSubstr ) )
|
||||
NameMatches( fObjName.c_str(), key->GetUoid().GetObjectName().c_str(), fSubstr ) )
|
||||
{
|
||||
fFoundKey = key;
|
||||
return false;
|
||||
@ -187,9 +182,9 @@ public:
|
||||
};
|
||||
|
||||
plKey plKeyFinder::StupidSearch(const char * age, const char * rm,
|
||||
UInt16 classType, const char *obName, hsBool subString)
|
||||
UInt16 classType, const plString &obName, hsBool subString)
|
||||
{
|
||||
if (!obName)
|
||||
if (obName.IsNull())
|
||||
return nil;
|
||||
|
||||
plUoid newOid;
|
||||
@ -239,12 +234,12 @@ plKey plKeyFinder::StupidSearch(const char * age, const char * rm,
|
||||
return nil;
|
||||
}
|
||||
|
||||
void plKeyFinder::ReallyStupidResponderSearch(const char *name, std::vector<plKey>& foundKeys, const plLocation &hintLocation )
|
||||
void plKeyFinder::ReallyStupidResponderSearch(const plString &name, std::vector<plKey>& foundKeys, const plLocation &hintLocation )
|
||||
{
|
||||
ReallyStupidSubstringSearch(name, CLASS_INDEX_SCOPED(plResponderModifier), foundKeys, hintLocation);
|
||||
}
|
||||
|
||||
void plKeyFinder::ReallyStupidActivatorSearch(const char *name, std::vector<plKey>& foundKeys, const plLocation &hintLocation)
|
||||
void plKeyFinder::ReallyStupidActivatorSearch(const plString &name, std::vector<plKey>& foundKeys, const plLocation &hintLocation)
|
||||
{
|
||||
// use the createable macro so we don't have to pull in all of Python
|
||||
ReallyStupidSubstringSearch(name, CLASS_INDEX_SCOPED(plLogicModifier), foundKeys, hintLocation);
|
||||
@ -252,7 +247,7 @@ void plKeyFinder::ReallyStupidActivatorSearch(const char *name, std::vector<plKe
|
||||
ReallyStupidSubstringSearch(name, CLASS_INDEX_SCOPED(plSittingModifier), foundKeys, hintLocation);
|
||||
}
|
||||
|
||||
void plKeyFinder::IGetNames(std::vector<std::string>& names, const char* searchName, int index)
|
||||
void plKeyFinder::IGetNames(std::vector<plString>& names, const plString& searchName, int index)
|
||||
{
|
||||
// Not really searching for any particular key, just need all the logic mods
|
||||
std::vector<plKey> keys;
|
||||
@ -267,14 +262,14 @@ void plKeyFinder::IGetNames(std::vector<std::string>& names, const char* searchN
|
||||
}
|
||||
}
|
||||
|
||||
void plKeyFinder::GetResponderNames(std::vector<std::string>& names)
|
||||
void plKeyFinder::GetResponderNames(std::vector<plString>& names)
|
||||
{
|
||||
IGetNames(names, "", CLASS_INDEX_SCOPED(plResponderModifier));
|
||||
IGetNames(names, _TEMP_CONVERT_FROM_LITERAL(""), CLASS_INDEX_SCOPED(plResponderModifier));
|
||||
}
|
||||
|
||||
void plKeyFinder::GetActivatorNames(std::vector<std::string>& names)
|
||||
void plKeyFinder::GetActivatorNames(std::vector<plString>& names)
|
||||
{
|
||||
IGetNames(names, "", CLASS_INDEX_SCOPED(plLogicModifier));
|
||||
IGetNames(names, _TEMP_CONVERT_FROM_LITERAL(""), CLASS_INDEX_SCOPED(plLogicModifier));
|
||||
}
|
||||
|
||||
class plKeyFinderIterator : public plRegistryKeyIterator, public plRegistryPageIterator
|
||||
@ -282,19 +277,19 @@ class plKeyFinderIterator : public plRegistryKeyIterator, public plRegistryPageI
|
||||
protected:
|
||||
|
||||
UInt16 fClassType;
|
||||
const char *fObjName;
|
||||
plString fObjName;
|
||||
|
||||
std::vector<plKey> &fFoundKeys;
|
||||
|
||||
public:
|
||||
|
||||
plKeyFinderIterator( UInt16 classType, const char *obName, std::vector<plKey>& foundKeys )
|
||||
plKeyFinderIterator( UInt16 classType, const plString &obName, std::vector<plKey>& foundKeys )
|
||||
: fClassType( classType ), fObjName( obName ), fFoundKeys( foundKeys ) { }
|
||||
|
||||
virtual hsBool EatKey( const plKey& key )
|
||||
{
|
||||
if( key->GetUoid().IsValid() && key->GetUoid().GetClassType() == fClassType &&
|
||||
strstr( key->GetUoid().GetObjectName(), fObjName ) )
|
||||
key->GetUoid().GetObjectName().Find( fObjName ) >= 0 )
|
||||
{
|
||||
fFoundKeys.push_back( key );
|
||||
}
|
||||
@ -309,9 +304,9 @@ class plKeyFinderIterator : public plRegistryKeyIterator, public plRegistryPageI
|
||||
}
|
||||
};
|
||||
|
||||
void plKeyFinder::ReallyStupidSubstringSearch(const char *name, UInt16 objType, std::vector<plKey>& foundKeys, const plLocation &hintLocation )
|
||||
void plKeyFinder::ReallyStupidSubstringSearch(const plString &name, UInt16 objType, std::vector<plKey>& foundKeys, const plLocation &hintLocation )
|
||||
{
|
||||
if (!name)
|
||||
if (name.IsNull())
|
||||
return;
|
||||
|
||||
plKeyFinderIterator collector( objType, name, foundKeys );
|
||||
|
@ -89,19 +89,19 @@ public:
|
||||
static plKeyFinder& Instance();
|
||||
|
||||
// These are Stupid search because they just do string searchs on the objects.
|
||||
plKey StupidSearch(const char * age, const char * rm, const char *className, const char *obName, hsBool subString=false);
|
||||
plKey StupidSearch(const char * age, const char * rm, UInt16 objType, const char *obName, hsBool subString=false);
|
||||
plKey StupidSearch(const char * age, const char * rm, const char *className, const plString &obName, hsBool subString=false);
|
||||
plKey StupidSearch(const char * age, const char * rm, UInt16 objType, const plString &obName, hsBool subString=false);
|
||||
|
||||
eErrCodes GetLastErrorCode() { return fLastError; }
|
||||
const char* GetLastErrorString(); // For Console display
|
||||
|
||||
void ReallyStupidResponderSearch(const char* name, std::vector<plKey>& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc);
|
||||
void ReallyStupidActivatorSearch(const char* name, std::vector<plKey>& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc);
|
||||
void ReallyStupidResponderSearch(const plString& name, std::vector<plKey>& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc);
|
||||
void ReallyStupidActivatorSearch(const plString& name, std::vector<plKey>& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc);
|
||||
|
||||
void ReallyStupidSubstringSearch(const char* name, UInt16 objType, std::vector<plKey>& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc);
|
||||
void ReallyStupidSubstringSearch(const plString& name, UInt16 objType, std::vector<plKey>& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc);
|
||||
|
||||
void GetActivatorNames(std::vector<std::string>& names);
|
||||
void GetResponderNames(std::vector<std::string>& names);
|
||||
void GetActivatorNames(std::vector<plString>& names);
|
||||
void GetResponderNames(std::vector<plString>& names);
|
||||
|
||||
plKey FindSceneNodeKey(const char* pageOrFullLocName) const;
|
||||
plKey FindSceneNodeKey(const char* ageName, const char* pageName) const;
|
||||
@ -113,7 +113,7 @@ public:
|
||||
protected:
|
||||
plKeyFinder() {}
|
||||
|
||||
void IGetNames(std::vector<std::string>& names, const char* name, int index);
|
||||
void IGetNames(std::vector<plString>& names, const plString& name, int index);
|
||||
plKey IFindSceneNodeKey(plRegistryPageNode* page) const;
|
||||
|
||||
eErrCodes fLastError;
|
||||
|
@ -69,11 +69,11 @@ plRegistryKeyList::~plRegistryKeyList()
|
||||
class plSearchKeyImp : public plKeyImp
|
||||
{
|
||||
public:
|
||||
const char* fSearchKeyName;
|
||||
const char* GetName() const { return fSearchKeyName; }
|
||||
plString fSearchKeyName;
|
||||
const plString& GetName() const { return fSearchKeyName; }
|
||||
};
|
||||
|
||||
plKeyImp* plRegistryKeyList::FindKey(const char* keyName)
|
||||
plKeyImp* plRegistryKeyList::FindKey(const plString& keyName)
|
||||
{
|
||||
static plSearchKeyImp searchKey;
|
||||
searchKey.fSearchKeyName = keyName;
|
||||
@ -86,7 +86,7 @@ plKeyImp* plRegistryKeyList::FindKey(const char* keyName)
|
||||
for (int i = 0; i < fStaticKeys.size(); i++)
|
||||
{
|
||||
plKeyImp* curKey = fStaticKeys[i];
|
||||
if (curKey && hsStrCaseEQ(keyName, curKey->GetName()))
|
||||
if (curKey && !keyName.Compare(curKey->GetName(), plString::kCaseInsensitive))
|
||||
return curKey;
|
||||
}
|
||||
}
|
||||
@ -94,7 +94,7 @@ plKeyImp* plRegistryKeyList::FindKey(const char* keyName)
|
||||
{
|
||||
// We're sorted, do a fast lookup
|
||||
StaticVec::const_iterator it = std::lower_bound(fStaticKeys.begin(), fStaticKeys.end(), &searchKey, KeySorter());
|
||||
if (it != fStaticKeys.end() && hsStrCaseEQ(keyName, (*it)->GetName()))
|
||||
if (it != fStaticKeys.end() && !keyName.Compare((*it)->GetName(), plString::kCaseInsensitive))
|
||||
return *it;
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ plKeyImp* plRegistryKeyList::FindKey(const plUoid& uoid)
|
||||
// because of local data. Verify that we have the right key by
|
||||
// name, and if it's wrong, do the slower find-by-name.
|
||||
plKeyImp *keyImp = fStaticKeys[objectID-1];
|
||||
if (!hsStrCaseEQ(keyImp->GetName(), uoid.GetObjectName()))
|
||||
if (keyImp->GetName().Compare(uoid.GetObjectName(), plString::kCaseInsensitive) != 0)
|
||||
return FindKey(uoid.GetObjectName());
|
||||
else
|
||||
return keyImp;
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
bool operator() (plKeyImp* k1, plKeyImp* k2) const
|
||||
{
|
||||
hsAssert(k1 && k2, "Should have valid keys here");
|
||||
return stricmp(k1->GetName(), k2->GetName()) < 0;
|
||||
return k1->GetName().Compare(k2->GetName(), plString::kCaseInsensitive) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -100,7 +100,7 @@ public:
|
||||
UInt16 GetClassType() const { return fClassType; }
|
||||
|
||||
// Find a key by name (case-insensitive)
|
||||
plKeyImp* FindKey(const char* keyName);
|
||||
plKeyImp* FindKey(const plString& keyName);
|
||||
// Find a key by uoid index.
|
||||
plKeyImp* FindKey(const plUoid& uoid);
|
||||
|
||||
|
@ -309,7 +309,7 @@ hsBool plRegistryPageNode::IterateKeys(plRegistryKeyIterator* iterator, UInt16 c
|
||||
return true;
|
||||
}
|
||||
|
||||
plKeyImp* plRegistryPageNode::FindKey(UInt16 classType, const char* name) const
|
||||
plKeyImp* plRegistryPageNode::FindKey(UInt16 classType, const plString& name) const
|
||||
{
|
||||
plRegistryKeyList* keys = IGetKeyList(classType);
|
||||
if (keys == nil)
|
||||
@ -350,8 +350,7 @@ void plRegistryPageNode::AddKey(plKeyImp* key)
|
||||
// Attempt recovery
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
char tempName[512];
|
||||
sprintf(tempName, "%s%d", key->GetUoid().GetObjectName(), i);
|
||||
plString tempName = plString::Format("%s%d", key->GetUoid().GetObjectName().c_str(), i);
|
||||
if (keys->FindKey(tempName) == nil)
|
||||
{
|
||||
plUoid uoid(key->GetUoid().GetLocation(), key->GetUoid().GetClassType(), tempName, key->GetUoid().GetLoadMask());
|
||||
|
@ -118,7 +118,7 @@ public:
|
||||
void UnloadKeys(); // Frees all our keys
|
||||
|
||||
// Find a key by type and name
|
||||
plKeyImp* FindKey(UInt16 classType, const char* name) const;
|
||||
plKeyImp* FindKey(UInt16 classType, const plString& name) const;
|
||||
// Find a key by direct uoid lookup (or fallback to name lookup if that doesn't work)
|
||||
plKeyImp* FindKey(const plUoid& uoid) const;
|
||||
|
||||
|
@ -528,15 +528,15 @@ void plResManager::IPageOutSceneNodes(hsBool forceAll)
|
||||
|
||||
inline plKeyImp* IFindKeyLocalized(const plUoid& uoid, plRegistryPageNode* page)
|
||||
{
|
||||
const char* objectName = uoid.GetObjectName();
|
||||
const plString& objectName = uoid.GetObjectName();
|
||||
|
||||
// If we're running localized, try to find a localized version first
|
||||
if ((objectName != nil) && plLocalization::IsLocalized())
|
||||
if ((!objectName.IsNull()) && plLocalization::IsLocalized())
|
||||
{
|
||||
char localName[256];
|
||||
if (plLocalization::GetLocalized(objectName, localName))
|
||||
if (plLocalization::GetLocalized(_TEMP_CONVERT_TO_CONST_CHAR(objectName), localName))
|
||||
{
|
||||
plKeyImp* localKey = page->FindKey(uoid.GetClassType(), localName);
|
||||
plKeyImp* localKey = page->FindKey(uoid.GetClassType(), _TEMP_CONVERT_FROM_LITERAL(localName));
|
||||
if (localKey != nil)
|
||||
return localKey;
|
||||
}
|
||||
@ -743,9 +743,9 @@ plKey plResManager::ReadKeyNotifyMe(hsStream* stream, plRefMsg* msg, plRefFlags:
|
||||
// Creates a new key and assigns it to the given keyed object, also placing
|
||||
// it into the registry.
|
||||
|
||||
plKey plResManager::NewKey(const char* name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m )
|
||||
plKey plResManager::NewKey(const plString& name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m )
|
||||
{
|
||||
hsAssert(name && name[0] != '\0', "No name for new key");
|
||||
hsAssert(!name.IsEmpty(), "No name for new key");
|
||||
plUoid newUoid(loc, object->ClassIndex(), name, m);
|
||||
return NewKey(newUoid, object);
|
||||
}
|
||||
@ -764,7 +764,7 @@ plKey plResManager::NewKey(plUoid& newUoid, hsKeyedObject* object)
|
||||
return keyPtr;
|
||||
}
|
||||
|
||||
plKey plResManager::ReRegister(const char* nm, const plUoid& oid)
|
||||
plKey plResManager::ReRegister(const plString& nm, const plUoid& oid)
|
||||
{
|
||||
hsAssert(fInited, "Attempting to reregister a key before we're inited!");
|
||||
|
||||
@ -919,7 +919,7 @@ plKey plResManager::ICloneKey(const plUoid& objUoid, UInt32 playerID, UInt32 clo
|
||||
fCurCloneID = cloneID;
|
||||
fCurClonePlayerID = playerID;
|
||||
|
||||
plKey cloneKey = ReRegister("", objUoid);
|
||||
plKey cloneKey = ReRegister(_TEMP_CONVERT_FROM_LITERAL(""), objUoid);
|
||||
|
||||
fCurClonePlayerID = 0;
|
||||
fCurCloneID = 0;
|
||||
@ -1270,7 +1270,7 @@ public:
|
||||
{
|
||||
if (stricmp(page->GetPageInfo().GetAge(), fAgeName) == 0)
|
||||
{
|
||||
plUoid uoid(page->GetPageInfo().GetLocation(), 0, "");
|
||||
plUoid uoid(page->GetPageInfo().GetLocation(), 0, _TEMP_CONVERT_FROM_LITERAL(""));
|
||||
fLocations.push_back(uoid.GetLocation());
|
||||
}
|
||||
return true;
|
||||
|
@ -123,7 +123,7 @@ public:
|
||||
//---------------------------
|
||||
// Registry Modification Functions
|
||||
//---------------------------
|
||||
virtual plKey NewKey(const char* name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m = plLoadMask::kAlways);
|
||||
virtual plKey NewKey(const plString& name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m = plLoadMask::kAlways);
|
||||
virtual plKey NewKey(plUoid& newUoid, hsKeyedObject* object);
|
||||
|
||||
virtual plDispatchBase* Dispatch();
|
||||
@ -174,7 +174,7 @@ protected:
|
||||
friend class plKeyImp;
|
||||
friend class plResManagerHelper;
|
||||
|
||||
virtual plKey ReRegister(const char* nm, const plUoid& uoid);
|
||||
virtual plKey ReRegister(const plString& nm, const plUoid& uoid);
|
||||
virtual hsBool ReadObject(plKeyImp* key); // plKeys call this when needed
|
||||
virtual hsBool IReadObject(plKeyImp* pKey, hsStream *stream);
|
||||
|
||||
|
Reference in New Issue
Block a user