Browse Source

Fix problems with age display name formatting

- Age User Name and Age Instance Name are equal in the case of some child
  and public ages. If they are, only return one of them. Don't return
  "Ae'gura Ae'gura"
- Changed to return plString instead of a pointer to a temporary buffer
  that immediately goes out of scope
Adam Johnson 12 years ago
parent
commit
fa85812a47
  1. 32
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp
  2. 4
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.h
  3. 4
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStructGlue.cpp

32
Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp

@ -178,14 +178,22 @@ void pyAgeInfoStruct::SetAgeLanguage( int32_t v )
fAgeInfo.SetAgeLanguage( v );
}
const char * pyAgeInfoStruct::GetDisplayName() const
plString pyAgeInfoStruct::GetDisplayName() const
{
const char* instance = GetAgeInstanceName();
const char* user = GetAgeUserDefinedName();
bool namesEqual = (stricmp(user, instance) == 0); // Ae'gura Ae'gura
if (namesEqual)
return instance;
else
{
int32_t seq = GetAgeSequenceNumber();
if (seq > 0)
fDisplayName = plString::Format( "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
return plString::Format("%s (%d) %s", user, seq, instance);
else
fDisplayName = plString::Format( "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str();
return plString::Format("%s %s", user, instance);
}
}
@ -255,12 +263,20 @@ void pyAgeInfoStructRef::SetAgeSequenceNumber( int32_t v )
fAgeInfo.SetAgeSequenceNumber( v );
}
const char * pyAgeInfoStructRef::GetDisplayName() const
plString pyAgeInfoStructRef::GetDisplayName() const
{
const char* instance = GetAgeInstanceName();
const char* user = GetAgeUserDefinedName();
bool namesEqual = (stricmp(user, instance) == 0); // Ae'gura Ae'gura
if (namesEqual)
return instance;
else
{
int32_t seq = GetAgeSequenceNumber();
if (seq > 0)
fDisplayName = plString::Format( "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
return plString::Format("%s (%d) %s", user, seq, instance);
else
fDisplayName = plString::Format( "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str();
return plString::Format("%s %s", user, instance);
}
}

4
Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.h

@ -101,7 +101,7 @@ public:
void SetAgeSequenceNumber( int32_t v );
int32_t GetAgeLanguage() const;
void SetAgeLanguage( int32_t v );
const char * GetDisplayName() const;
plString GetDisplayName() const;
};
class pyAgeInfoStructRef
@ -142,7 +142,7 @@ public:
void SetAgeInstanceGuid( const char * guid );
int32_t GetAgeSequenceNumber() const;
void SetAgeSequenceNumber( int32_t v );
const char * GetDisplayName() const;
plString GetDisplayName() const;
};
#endif // pyAgeInfoStruct_h_inc

4
Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStructGlue.cpp

@ -234,7 +234,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeLanguage, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getDisplayName)
{
return PyString_FromString(self->fThis->GetDisplayName());
return PyString_FromPlString(self->fThis->GetDisplayName());
}
PYTHON_START_METHODS_TABLE(ptAgeInfoStruct)
@ -410,7 +410,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeSequenceNumber, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getDisplayName)
{
return PyString_FromString(self->fThis->GetDisplayName());
return PyString_FromPlString(self->fThis->GetDisplayName());
}
PYTHON_START_METHODS_TABLE(ptAgeInfoStructRef)

Loading…
Cancel
Save