|
| 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 | + |
0 commit comments