Skip to content

Commit 10272cb

Browse files
committed
Add plCloneSpawnModifier
I believe this is only ever used for MQO.
1 parent e043a0e commit 10272cb

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ set(PRP_MOD_SOURCES
394394
PRP/Modifier/plAliasModifier.cpp
395395
PRP/Modifier/plAnimEventModifier.cpp
396396
PRP/Modifier/plAxisAnimModifier.cpp
397+
PRP/Modifier/plCloneSpawnModifier.cpp
397398
PRP/Modifier/plExcludeRegionModifier.cpp
398399
PRP/Modifier/plFollowMod.cpp
399400
PRP/Modifier/plGameMarkerModifier.cpp
@@ -416,6 +417,7 @@ set(PRP_MOD_HEADERS
416417
PRP/Modifier/plAliasModifier.h
417418
PRP/Modifier/plAnimEventModifier.h
418419
PRP/Modifier/plAxisAnimModifier.h
420+
PRP/Modifier/plCloneSpawnModifier.h
419421
PRP/Modifier/plExcludeRegionModifier.h
420422
PRP/Modifier/plFollowMod.h
421423
PRP/Modifier/plGameMarkerModifier.h
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* This file is part of HSPlasma.
2+
*
3+
* HSPlasma is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* HSPlasma is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with HSPlasma. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
#include "plCloneSpawnModifier.h"
18+
19+
void plCloneSpawnModifier::read(hsStream* S, plResManager* mgr)
20+
{
21+
if (S->getVer().isMoul()) {
22+
plSingleModifier::read(S, mgr);
23+
fTemplateName = S->readSafeStr();
24+
fUserData = S->readInt();
25+
} else {
26+
// This is bad, but also never used in earlier Plasma versions
27+
fTemplateName = S->readSafeStr();
28+
plSingleModifier::read(S, mgr);
29+
}
30+
}
31+
32+
void plCloneSpawnModifier::write(hsStream* S, plResManager* mgr)
33+
{
34+
if (S->getVer().isMoul()) {
35+
plSingleModifier::write(S, mgr);
36+
S->writeSafeStr(fTemplateName);
37+
S->writeInt(fUserData);
38+
} else {
39+
// This is bad, but also never used in earlier Plasma versions
40+
S->writeSafeStr(fTemplateName);
41+
plSingleModifier::write(S, mgr);
42+
}
43+
}
44+
45+
void plCloneSpawnModifier::IPrcWrite(pfPrcHelper* prc)
46+
{
47+
plSingleModifier::IPrcWrite(prc);
48+
49+
prc->startTag("SpawnParams");
50+
prc->writeParam("TemplateName", fTemplateName);
51+
prc->writeParam("UserData", fUserData);
52+
prc->endTag(true);
53+
}
54+
55+
void plCloneSpawnModifier::IPrcParse(const pfPrcTag* tag, plResManager* mgr)
56+
{
57+
if (tag->getName() == "SpawnParams") {
58+
fTemplateName = tag->getParam("TemplateName", "");
59+
fUserData = tag->getParam("UserData", "0").to_uint();
60+
} else {
61+
plSingleModifier::IPrcParse(tag, mgr);
62+
}
63+
}
64+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* This file is part of HSPlasma.
2+
*
3+
* HSPlasma is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* HSPlasma is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with HSPlasma. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
#ifndef _PLCLONESPAWNMODIFIER_H
18+
#define _PLCLONESPAWNMODIFIER_H
19+
20+
#include "plModifier.h"
21+
22+
class HSPLASMA_EXPORT plCloneSpawnModifier : public plSingleModifier
23+
{
24+
CREATABLE(plCloneSpawnModifier, kCloneSpawnModifier, plSingleModifier)
25+
26+
protected:
27+
ST::string fTemplateName;
28+
uint32_t fUserData;
29+
30+
public:
31+
plCloneSpawnModifier() : fUserData() { }
32+
33+
void read(hsStream* S, plResManager* mgr) HS_OVERRIDE;
34+
void write(hsStream* S, plResManager* mgr) HS_OVERRIDE;
35+
36+
protected:
37+
void IPrcWrite(pfPrcHelper* prc) HS_OVERRIDE;
38+
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;
39+
};
40+
41+
#endif

core/ResManager/plFactory.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
#include "PRP/Modifier/plAliasModifier.h"
117117
#include "PRP/Modifier/plAnimEventModifier.h"
118118
#include "PRP/Modifier/plAxisAnimModifier.h"
119+
#include "PRP/Modifier/plCloneSpawnModifier.h"
119120
#include "PRP/Modifier/plExcludeRegionModifier.h"
120121
#include "PRP/Modifier/plFollowMod.h"
121122
#include "PRP/Modifier/plGameMarkerModifier.h"
@@ -381,7 +382,7 @@ plCreatable* plFactory::Create(short typeIdx)
381382
case kGUIKnobCtrl: return new pfGUIKnobCtrl();
382383
case kAvLadderMod: return new plAvLadderMod();
383384
case kCameraBrain1_FirstPerson: return new plCameraBrain1_FirstPerson();
384-
//case kCloneSpawnModifier: return new plCloneSpawnModifier();
385+
case kCloneSpawnModifier: return new plCloneSpawnModifier();
385386
case kClothingItem: return new plClothingItem();
386387
case kClothingOutfit: return new plClothingOutfit();
387388
case kClothingBase: return new plClothingBase();

0 commit comments

Comments
 (0)