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); plMessage::IMsgRead(stream, mgr);
delete [] fAgeFilename;
// read agename // read agename
uint8_t len; uint8_t len;
stream->ReadLE(&len); stream->ReadLE(&len);
if (len) if (len)
{ {
fAgeFilename=new char[len+1]; plStringBuffer<char> filename;
stream->Read(len, fAgeFilename); char* buffer = filename.CreateWritableBuffer(len);
fAgeFilename[len]=0; stream->Read(len, buffer);
buffer[len] = 0;
fAgeFilename = filename;
} }
fUnload = stream->ReadBool(); fUnload = stream->ReadBool();
stream->ReadLE(&fPlayerID); stream->ReadLE(&fPlayerID);
@ -70,11 +70,11 @@ void plLoadAgeMsg::Write(hsStream* stream, hsResMgr* mgr)
plMessage::IMsgWrite(stream, mgr); plMessage::IMsgWrite(stream, mgr);
// write agename // write agename
uint8_t len = fAgeFilename ? strlen(fAgeFilename) : 0; uint8_t len = static_cast<uint8_t>(fAgeFilename.GetSize());
stream->WriteLE(len); stream->WriteLE(len);
if (len) if (len)
{ {
stream->Write(len, fAgeFilename); stream->Write(len, fAgeFilename.c_str());
} }
stream->WriteBool(fUnload); stream->WriteBool(fUnload);
stream->WriteLE(fPlayerID); stream->WriteLE(fPlayerID);
@ -99,8 +99,7 @@ void plLoadAgeMsg::ReadVersion(hsStream* s, hsResMgr* mgr)
if (contentFlags.IsBitSet(kLoadAgeAgeName)) if (contentFlags.IsBitSet(kLoadAgeAgeName))
{ {
// read agename // read agename
delete [] fAgeFilename; fAgeFilename = s->ReadSafeString_TEMP();
fAgeFilename = s->ReadSafeString();
} }
if (contentFlags.IsBitSet(kLoadAgeUnload)) 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 "pnMessage/plMessage.h"
#include "pnUUID/pnUUID.h" #include "pnUUID/pnUUID.h"
#include "plString.h"
// //
@ -55,19 +56,18 @@ class hsResMgr;
class plLoadAgeMsg : public plMessage class plLoadAgeMsg : public plMessage
{ {
protected: protected:
char* fAgeFilename; // the age to load/unload plString fAgeFilename; // the age to load/unload
plUUID fAgeGuid; plUUID fAgeGuid;
bool fUnload; // true if we want to unload the age bool fUnload; // true if we want to unload the age
int fPlayerID; int fPlayerID;
public: public:
plLoadAgeMsg() : fAgeFilename(nil), fUnload(false), fPlayerID(-1){ } plLoadAgeMsg() : fUnload(false), fPlayerID(-1) { }
virtual ~plLoadAgeMsg() { delete [] fAgeFilename; }
CLASSNAME_REGISTER( plLoadAgeMsg ); CLASSNAME_REGISTER( plLoadAgeMsg );
GETINTERFACE_ANY( plLoadAgeMsg, plMessage ); GETINTERFACE_ANY( plLoadAgeMsg, plMessage );
void SetAgeFilename(const char* a) { delete [] fAgeFilename; fAgeFilename=a?hsStrcpy(a):nil; } void SetAgeFilename(const plString& a) { fAgeFilename = a; }
char* GetAgeFilename() const { return fAgeFilename; } plString GetAgeFilename() const { return fAgeFilename; }
void SetAgeGuid( const plUUID * v ) { fAgeGuid.CopyFrom( v ); } void SetAgeGuid( const plUUID * v ) { fAgeGuid.CopyFrom( v ); }
const plUUID * GetAgeGuid() const { return &fAgeGuid; } const plUUID * GetAgeGuid() const { return &fAgeGuid; }

Loading…
Cancel
Save