Browse Source

plNPCSpawnMod => plString

Michael Hansen 11 years ago
parent
commit
b16274a8cc
  1. 26
      Sources/Plasma/PubUtilLib/plAvatar/plNPCSpawnMod.cpp
  2. 6
      Sources/Plasma/PubUtilLib/plAvatar/plNPCSpawnMod.h

26
Sources/Plasma/PubUtilLib/plAvatar/plNPCSpawnMod.cpp

@ -59,34 +59,22 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// plNPCSpawnMod ctor // plNPCSpawnMod ctor
plNPCSpawnMod::plNPCSpawnMod() plNPCSpawnMod::plNPCSpawnMod()
: fModelName(nil), : fAutoSpawn(false),
fAccountName(nil),
fAutoSpawn(false),
fNotify(nil) fNotify(nil)
{ {
} }
// plNPCSpawnMod ctor modelName accountName // plNPCSpawnMod ctor modelName accountName
plNPCSpawnMod::plNPCSpawnMod(const char * modelName, const char * accountName, bool autoSpawn) plNPCSpawnMod::plNPCSpawnMod(const plString &modelName, const plString &accountName, bool autoSpawn)
: fAutoSpawn(autoSpawn), fNotify(nil) : fAutoSpawn(autoSpawn), fNotify(nil)
{ {
fModelName = hsStrcpy(modelName); fModelName = modelName;
fAccountName = hsStrcpy(accountName); fAccountName = accountName;
} }
// plNPCSpawnMod dtor // plNPCSpawnMod dtor
plNPCSpawnMod::~plNPCSpawnMod() plNPCSpawnMod::~plNPCSpawnMod()
{ {
if(fModelName)
{
delete[] fModelName;
fModelName = nil;
}
if(fAccountName)
{
delete[] fAccountName;
fAccountName = nil;
}
if (fNotify) if (fNotify)
fNotify->UnRef(); fNotify->UnRef();
} }
@ -108,7 +96,7 @@ bool plNPCSpawnMod::Trigger()
// will netpropagate // will netpropagate
if(this->IsLocallyOwned()) if(this->IsLocallyOwned())
{ {
if(fModelName) if (!fModelName.IsEmpty())
{ {
// spawn the NPC // spawn the NPC
plKey spawnPoint = GetTarget(0)->GetKey(); plKey spawnPoint = GetTarget(0)->GetKey();
@ -140,8 +128,8 @@ void plNPCSpawnMod::Read(hsStream *stream, hsResMgr *mgr)
{ {
plSingleModifier::Read(stream, mgr); plSingleModifier::Read(stream, mgr);
fModelName = stream->ReadSafeString(); fModelName = stream->ReadSafeString_TEMP();
fAccountName = stream->ReadSafeString(); fAccountName = stream->ReadSafeString_TEMP();
fAutoSpawn = stream->ReadBool(); fAutoSpawn = stream->ReadBool();
if(stream->ReadBool()) if(stream->ReadBool())
fNotify = plNotifyMsg::ConvertNoRef(mgr->ReadCreatable(stream)); fNotify = plNotifyMsg::ConvertNoRef(mgr->ReadCreatable(stream));

6
Sources/Plasma/PubUtilLib/plAvatar/plNPCSpawnMod.h

@ -47,7 +47,7 @@ class plNPCSpawnMod : public plSingleModifier
{ {
public: public:
plNPCSpawnMod(); plNPCSpawnMod();
plNPCSpawnMod(const char * modelName, const char *accountName, bool autoSpawn); plNPCSpawnMod(const plString &modelName, const plString &accountName, bool autoSpawn);
~plNPCSpawnMod(); ~plNPCSpawnMod();
bool Trigger(); bool Trigger();
@ -68,8 +68,8 @@ protected:
void ISendNotify(plKey &avatarKey); // send our notification message void ISendNotify(plKey &avatarKey); // send our notification message
private: private:
char *fModelName; plString fModelName;
char *fAccountName; plString fAccountName;
bool fAutoSpawn; // spawn immediately on loading bool fAutoSpawn; // spawn immediately on loading
plKey fSpawnedKey; // if we want to be able to spawn many things, we should make this a vector plKey fSpawnedKey; // if we want to be able to spawn many things, we should make this a vector
plNotifyMsg *fNotify; // notify message that we send when we spawn. plNotifyMsg *fNotify; // notify message that we send when we spawn.

Loading…
Cancel
Save