Browse Source

Fix issues from review, and pre-emptively fix a couple of potential plString::Format issues

Michael Hansen 12 years ago
parent
commit
7ba8fdf86e
  1. 12
      Sources/Plasma/CoreLib/plString.cpp
  2. 1
      Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp
  3. 10
      Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp
  4. 49
      Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.h

12
Sources/Plasma/CoreLib/plString.cpp

@ -513,17 +513,21 @@ plString plString::IFormat(const char *fmt, va_list vptr)
for ( ;; ) {
va_copy(vptr, vptr_save);
plStringBuffer<char> bigbuffer;
char *data = bigbuffer.CreateWritableBuffer(size);
char *data = bigbuffer.CreateWritableBuffer(size-1);
chars = vsnprintf(data, size, fmt, vptr);
if (chars >= 0)
return bigbuffer;
if (chars >= 0) {
// We need to construct a new string here so the length
// parameter is accurate :(
return plString::FromUtf8(bigbuffer.GetData(), chars);
}
size *= 2;
hsAssert(size > 0, "Formatted string output is waaaaay too long");
}
} else if (chars >= 256) {
va_copy(vptr, vptr_save);
plStringBuffer<char> bigbuffer;
char *data = bigbuffer.CreateWritableBuffer(chars+1);
char *data = bigbuffer.CreateWritableBuffer(chars);
vsnprintf(data, chars+1, fmt, vptr);
return bigbuffer;
}

1
Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp

@ -249,7 +249,6 @@ void plResPatcher::IssueRequest()
plFileUtils::EnsureFilePathExists(req.fFriendlyName.c_str());
plResDownloadStream* stream = new plResDownloadStream(fProgress, req.fFile.c_str());
uint32_t i = stream->ReadBE32();
if (stream->Open_TEMP(filename, "wb"))
NetCliFileDownloadRequest(req.fFile.c_str(), stream, FileDownloaded, this);
else {

10
Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp

@ -353,16 +353,6 @@ void plAgeInfoStruct::Clear()
fAgeLanguage = -1;
}
const char * plAgeInfoStruct::GetDisplayName() const
{
int seq = GetAgeSequenceNumber();
if ( seq>0 )
fDisplayName = plString::Format( "%s(%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
else
fDisplayName = plString::Format( "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str();
}
////////////////////////////////////////////////////////////////////

49
Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.h

@ -85,9 +85,6 @@ class plAgeInfoStruct : public plCreatable
// The language of the client that created this age
int32_t fAgeLanguage;
// Evil (TODO: Nuke this)
mutable plString fDisplayName;
enum
{
kHasAgeFilename = 1<<0,
@ -147,8 +144,6 @@ public:
void Read( hsStream * s, hsResMgr* );
void Write( hsStream * s, hsResMgr* );
const char * GetDisplayName() const;
plString AsString() const;
};
@ -305,48 +300,4 @@ public:
virtual void WriteVersion(hsStream* s, hsResMgr* mgr);
};
////////////////////////////////////////////////////////////////////
//class plVaultAgeInfoNode;
//class plAgeLinkingInfo : public plCreatable
//{
// int fLinkingRules;
// uint32_t fPlayerID;
// bool8 fSuperUser;
// mutable plAgeInfoStruct fAgeInfo;
// mutable plNetServerSessionInfo fServerInfo;
//
//public:
// plAgeLinkingInfo();
//
// CLASSNAME_REGISTER( plAgeLinkingInfo );
// GETINTERFACE_ANY( plAgeLinkingInfo, plCreatable );
//
// int GetLinkingRules( void ) const { return fLinkingRules;}
// void SetLinkingRules( int v ) { fLinkingRules=v;}
// uint32_t GetPlayerID( void ) const { return fPlayerID;}
// void SetPlayerID( uint32_t v ) { fPlayerID=v;}
// void SetSuperUser(bool b) { fSuperUser=b; }
// bool GetSuperUser() const { return fSuperUser ? true : false; }
//
// plAgeInfoStruct * GetAgeInfo();
// const plAgeInfoStruct * GetAgeInfo() const;
//
// // initializes info with age name and guid for you.
// plNetServerSessionInfo * GetServerInfo();
// const plNetServerSessionInfo * GetServerInfo() const;
// const plNetServerSessionInfo * AsServerInfo() const;
//
// void Clear( void );
// void CopyFrom( const plAgeLinkingInfo * other );
// void CopyFrom( const plVaultAgeInfoNode * node );
// void CopyFrom( const plNetServerSessionInfo * info );
// void CopyFrom( const plAgeInfoStruct * info );
//
// void Read(hsStream* s, hsResMgr* mgr=nil);
// void Write(hsStream* s, hsResMgr* mgr=nil);
//
// std::string AsStdString() const;
//};
#endif // plNetServerSessionInfo_h_inc

Loading…
Cancel
Save