From b2041e53370ead83559db35367e1a0a63595d532 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sat, 16 Jul 2022 11:27:43 -0700 Subject: [PATCH] Add plCloneSpawnModifier I believe this is only ever used for MQO. --- core/CMakeLists.txt | 2 + core/PRP/Modifier/plCloneSpawnModifier.cpp | 64 ++++++++++++++++++++++ core/PRP/Modifier/plCloneSpawnModifier.h | 41 ++++++++++++++ core/ResManager/plFactory.cpp | 3 +- 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 core/PRP/Modifier/plCloneSpawnModifier.cpp create mode 100644 core/PRP/Modifier/plCloneSpawnModifier.h diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index eb02af355..c0130d9cd 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -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 @@ -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 diff --git a/core/PRP/Modifier/plCloneSpawnModifier.cpp b/core/PRP/Modifier/plCloneSpawnModifier.cpp new file mode 100644 index 000000000..a74572194 --- /dev/null +++ b/core/PRP/Modifier/plCloneSpawnModifier.cpp @@ -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 . + */ + +#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); + } +} + diff --git a/core/PRP/Modifier/plCloneSpawnModifier.h b/core/PRP/Modifier/plCloneSpawnModifier.h new file mode 100644 index 000000000..72c332747 --- /dev/null +++ b/core/PRP/Modifier/plCloneSpawnModifier.h @@ -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 . + */ + +#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 diff --git a/core/ResManager/plFactory.cpp b/core/ResManager/plFactory.cpp index b20fe20c5..f6be25193 100644 --- a/core/ResManager/plFactory.cpp +++ b/core/ResManager/plFactory.cpp @@ -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" @@ -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();