Browse Source

Convert plLoadAgeMsg's age filename to a plString

Michael Hansen 11 years ago
parent
commit
829277bcc4
  1. 17
      Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.cpp
  2. 10
      Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.h

17
Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.cpp

@ -49,16 +49,16 @@ void plLoadAgeMsg::Read(hsStream* stream, hsResMgr* mgr)
{
plMessage::IMsgRead(stream, mgr);
delete [] fAgeFilename;
// read agename
uint8_t len;
stream->ReadLE(&len);
if (len)
{
fAgeFilename=new char[len+1];
stream->Read(len, fAgeFilename);
fAgeFilename[len]=0;
plStringBuffer<char> filename;
char* buffer = filename.CreateWritableBuffer(len);
stream->Read(len, buffer);
buffer[len] = 0;
fAgeFilename = filename;
}
fUnload = stream->ReadBool();
stream->ReadLE(&fPlayerID);
@ -70,11 +70,11 @@ void plLoadAgeMsg::Write(hsStream* stream, hsResMgr* mgr)
plMessage::IMsgWrite(stream, mgr);
// write agename
uint8_t len = fAgeFilename ? strlen(fAgeFilename) : 0;
uint8_t len = static_cast<uint8_t>(fAgeFilename.GetSize());
stream->WriteLE(len);
if (len)
{
stream->Write(len, fAgeFilename);
stream->Write(len, fAgeFilename.c_str());
}
stream->WriteBool(fUnload);
stream->WriteLE(fPlayerID);
@ -99,8 +99,7 @@ void plLoadAgeMsg::ReadVersion(hsStream* s, hsResMgr* mgr)
if (contentFlags.IsBitSet(kLoadAgeAgeName))
{
// read agename
delete [] fAgeFilename;
fAgeFilename = s->ReadSafeString();
fAgeFilename = s->ReadSafeString_TEMP();
}
if (contentFlags.IsBitSet(kLoadAgeUnload))

10
Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.h

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnMessage/plMessage.h"
#include "pnUUID/pnUUID.h"
#include "plString.h"
//
@ -55,19 +56,18 @@ class hsResMgr;
class plLoadAgeMsg : public plMessage
{
protected:
char* fAgeFilename; // the age to load/unload
plString fAgeFilename; // the age to load/unload
plUUID fAgeGuid;
bool fUnload; // true if we want to unload the age
int fPlayerID;
public:
plLoadAgeMsg() : fAgeFilename(nil), fUnload(false), fPlayerID(-1){ }
virtual ~plLoadAgeMsg() { delete [] fAgeFilename; }
plLoadAgeMsg() : fUnload(false), fPlayerID(-1) { }
CLASSNAME_REGISTER( plLoadAgeMsg );
GETINTERFACE_ANY( plLoadAgeMsg, plMessage );
void SetAgeFilename(const char* a) { delete [] fAgeFilename; fAgeFilename=a?hsStrcpy(a):nil; }
char* GetAgeFilename() const { return fAgeFilename; }
void SetAgeFilename(const plString& a) { fAgeFilename = a; }
plString GetAgeFilename() const { return fAgeFilename; }
void SetAgeGuid( const plUUID * v ) { fAgeGuid.CopyFrom( v ); }
const plUUID * GetAgeGuid() const { return &fAgeGuid; }

Loading…
Cancel
Save