Skip to content

Commit

Permalink
Add plCloneSpawnModifier
Browse files Browse the repository at this point in the history
I believe this is only ever used for MQO.
  • Loading branch information
dpogue committed Sep 24, 2023
1 parent ed9c2d4 commit a3fcecd
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ set(PRP_MOD_SOURCES
PRP/Modifier/plAliasModifier.cpp
PRP/Modifier/plAnimEventModifier.cpp
PRP/Modifier/plAxisAnimModifier.cpp
PRP/Modifier/plCloneSpawnModifier.cpp
PRP/Modifier/plExcludeRegionModifier.cpp
PRP/Modifier/plFollowMod.cpp
PRP/Modifier/plGameMarkerModifier.cpp
Expand All @@ -416,6 +417,7 @@ set(PRP_MOD_HEADERS
PRP/Modifier/plAliasModifier.h
PRP/Modifier/plAnimEventModifier.h
PRP/Modifier/plAxisAnimModifier.h
PRP/Modifier/plCloneSpawnModifier.h
PRP/Modifier/plExcludeRegionModifier.h
PRP/Modifier/plFollowMod.h
PRP/Modifier/plGameMarkerModifier.h
Expand Down
64 changes: 64 additions & 0 deletions core/PRP/Modifier/plCloneSpawnModifier.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* This file is part of HSPlasma.
*
* HSPlasma is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HSPlasma is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HSPlasma. If not, see <http://www.gnu.org/licenses/>.
*/

#include "plCloneSpawnModifier.h"

void plCloneSpawnModifier::read(hsStream* S, plResManager* mgr)
{
if (S->getVer().isMoul()) {
plSingleModifier::read(S, mgr);
fTemplateName = S->readSafeStr();
fUserData = S->readInt();
} else {
// This is bad, but also never used in earlier Plasma versions
fTemplateName = S->readSafeStr();
plSingleModifier::read(S, mgr);
}
}

void plCloneSpawnModifier::write(hsStream* S, plResManager* mgr)
{
if (S->getVer().isMoul()) {
plSingleModifier::write(S, mgr);
S->writeSafeStr(fTemplateName);
S->writeInt(fUserData);
} else {
// This is bad, but also never used in earlier Plasma versions
S->writeSafeStr(fTemplateName);
plSingleModifier::write(S, mgr);
}
}

void plCloneSpawnModifier::IPrcWrite(pfPrcHelper* prc)
{
plSingleModifier::IPrcWrite(prc);

prc->startTag("SpawnParams");
prc->writeParam("TemplateName", fTemplateName);
prc->writeParam("UserData", fUserData);
prc->endTag(true);
}

void plCloneSpawnModifier::IPrcParse(const pfPrcTag* tag, plResManager* mgr)
{
if (tag->getName() == "SpawnParams") {
fTemplateName = tag->getParam("TemplateName", "");
fUserData = tag->getParam("UserData", "0").to_uint();
} else {
plSingleModifier::IPrcParse(tag, mgr);
}
}

41 changes: 41 additions & 0 deletions core/PRP/Modifier/plCloneSpawnModifier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* This file is part of HSPlasma.
*
* HSPlasma is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HSPlasma is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HSPlasma. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PLCLONESPAWNMODIFIER_H
#define _PLCLONESPAWNMODIFIER_H

#include "plModifier.h"

class HSPLASMA_EXPORT plCloneSpawnModifier : public plSingleModifier
{
CREATABLE(plCloneSpawnModifier, kCloneSpawnModifier, plSingleModifier)

protected:
ST::string fTemplateName;
uint32_t fUserData;

public:
plCloneSpawnModifier() : fUserData() { }

void read(hsStream* S, plResManager* mgr) HS_OVERRIDE;
void write(hsStream* S, plResManager* mgr) HS_OVERRIDE;

protected:
void IPrcWrite(pfPrcHelper* prc) HS_OVERRIDE;
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;
};

#endif
3 changes: 2 additions & 1 deletion core/ResManager/plFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
#include "PRP/Modifier/plAliasModifier.h"
#include "PRP/Modifier/plAnimEventModifier.h"
#include "PRP/Modifier/plAxisAnimModifier.h"
#include "PRP/Modifier/plCloneSpawnModifier.h"
#include "PRP/Modifier/plExcludeRegionModifier.h"
#include "PRP/Modifier/plFollowMod.h"
#include "PRP/Modifier/plGameMarkerModifier.h"
Expand Down Expand Up @@ -381,7 +382,7 @@ plCreatable* plFactory::Create(short typeIdx)
case kGUIKnobCtrl: return new pfGUIKnobCtrl();
case kAvLadderMod: return new plAvLadderMod();
case kCameraBrain1_FirstPerson: return new plCameraBrain1_FirstPerson();
//case kCloneSpawnModifier: return new plCloneSpawnModifier();
case kCloneSpawnModifier: return new plCloneSpawnModifier();
case kClothingItem: return new plClothingItem();
case kClothingOutfit: return new plClothingOutfit();
case kClothingBase: return new plClothingBase();
Expand Down

0 comments on commit a3fcecd

Please sign in to comment.