diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index fc2a079e..c6559416 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 00000000..a7457219 --- /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 00000000..72c33274 --- /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 b20fe20c..f6be2519 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();