Skip to content

Commit

Permalink
Merge pull request #183 from Deledrius/plWarpMsg
Browse files Browse the repository at this point in the history
Add plWarpMsg and pyWarpMsg.
  • Loading branch information
zrax authored Jul 24, 2020
2 parents d483742 + 7ceb213 commit 80e2990
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ set(PRP_MSG_SOURCES
PRP/Message/pySubWorldMsg.cpp
PRP/Message/pySwimMsg.cpp
PRP/Message/pyTimerCallbackMsg.cpp
PRP/Message/pyWarpMsg.cpp
PRP/Message/pyVariableEventData.cpp
)
set(PRP_MSG_HEADERS
Expand All @@ -412,6 +413,7 @@ set(PRP_MSG_HEADERS
PRP/Message/pySwimMsg.h
PRP/Message/pyResponderMsg.h
PRP/Message/pyTimerCallbackMsg.h
PRP/Message/pyWarpMsg.h
)

set(PRP_MISC_SOURCES
Expand Down
2 changes: 2 additions & 0 deletions Python/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
#include "PRP/Message/pySoundMsg.h"
#include "PRP/Message/pySwimMsg.h"
#include "PRP/Message/pyTimerCallbackMsg.h"
#include "PRP/Message/pyWarpMsg.h"
#include "PRP/Misc/pyRenderLevel.h"
#include "PRP/Misc/pyAgeLinkInfo.h"
#include "PRP/Misc/pyFogEnvironment.h"
Expand Down Expand Up @@ -891,6 +892,7 @@ PyMODINIT_FUNC initPyHSPlasma()
PyModule_AddObject(module, "plMessageWithCallbacks", Init_pyMessageWithCallbacks_Type());
PyModule_AddObject(module, "plAnimCmdMsg", Init_pyAnimCmdMsg_Type());
PyModule_AddObject(module, "plTimerCallbackMsg", Init_pyTimerCallbackMsg_Type());
PyModule_AddObject(module, "plWarpMsg", Init_pyWarpMsg_Type());
PyModule_AddObject(module, "plEnableMsg", Init_pyEnableMsg_Type());
PyModule_AddObject(module, "plExcludeRegionMsg", Init_pyExcludeRegionMsg_Type());
PyModule_AddObject(module, "plVolumeIsect", Init_pyVolumeIsect_Type());
Expand Down
51 changes: 51 additions & 0 deletions Python/PRP/Message/pyWarpMsg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* 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 "pyWarpMsg.h"

#include <PRP/Message/plWarpMsg.h>
#include "Math/pyMatrix.h"
#include "pyMessage.h"

PY_PLASMA_NEW(WarpMsg, plWarpMsg)

PY_PROPERTY(uint32_t, WarpMsg, warpFlags, getWarpFlags, setWarpFlags)
PY_PROPERTY(hsMatrix44, WarpMsg, transform, getTransform, setTransform)

static PyGetSetDef pyWarpMsg_GetSet[] = {
pyWarpMsg_warpFlags_getset,
pyWarpMsg_transform_getset,
PY_GETSET_TERMINATOR
};

PY_PLASMA_TYPE(WarpMsg, plWarpMsg, "plWarpMsg wrapper")

PY_PLASMA_TYPE_INIT(WarpMsg)
{
pyWarpMsg_Type.tp_new = pyWarpMsg_new;
pyWarpMsg_Type.tp_getset = pyWarpMsg_GetSet;
pyWarpMsg_Type.tp_base = &pyMessage_Type;
if (PyType_CheckAndReady(&pyWarpMsg_Type) < 0)
return nullptr;

PY_TYPE_ADD_CONST(WarpMsg, "kFlushTransform", plWarpMsg::kFlushTransform);
PY_TYPE_ADD_CONST(WarpMsg, "kZeroVelocity", plWarpMsg::kZeroVelocity);

Py_INCREF(&pyWarpMsg_Type);
return (PyObject*)&pyWarpMsg_Type;
}

PY_PLASMA_IFC_METHODS(WarpMsg, plWarpMsg)
24 changes: 24 additions & 0 deletions Python/PRP/Message/pyWarpMsg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* 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 _PYWARPMSG_H
#define _PYWARPMSG_H

#include "PyPlasma.h"

PY_WRAP_PLASMA(WarpMsg, class plWarpMsg);

#endif
3 changes: 3 additions & 0 deletions Python/PRP/pyCreatableConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
#include "PRP/Message/plSwimMsg.h"
#include "PRP/Message/plTimerCallbackMsg.h"
#include "PRP/Message/plTransitionMsg.h"
#include "PRP/Message/plWarpMsg.h"
#include "PRP/Misc/plFogEnvironment.h"
#include "PRP/Modifier/plAliasModifier.h"
#include "PRP/Modifier/plAnimEventModifier.h"
Expand Down Expand Up @@ -251,6 +252,7 @@
#include "PRP/Message/pySoundMsg.h"
#include "PRP/Message/pySwimMsg.h"
#include "PRP/Message/pyTimerCallbackMsg.h"
#include "PRP/Message/pyWarpMsg.h"
#include "PRP/Misc/pyRenderLevel.h"
#include "PRP/Misc/pyAgeLinkInfo.h"
#include "PRP/Misc/pyFogEnvironment.h"
Expand Down Expand Up @@ -605,6 +607,7 @@ PyObject* ICreate(plCreatable* pCre)
case kActivePrintShape: return pyActivePrintShape_FromActivePrintShape(plActivePrintShape::Convert(pCre));
case kSimSuppressMsg: return pySimSuppressMsg_FromSimSuppressMsg(plSimSuppressMsg::Convert(pCre));
case kGrassShaderMod: return pyGrassShaderMod_FromGrassShaderMod(plGrassShaderMod::Convert(pCre));
case kWarpMsg: return pyWarpMsg_FromWarpMsg(plWarpMsg::Convert(pCre));
default:
// many messages are not implemented, make sure they are at least a plMessage
if (pCre->ClassInstance(kMessage))
Expand Down
2 changes: 2 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ set(PRP_MSG_SOURCES
PRP/Message/plSwimMsg.cpp
PRP/Message/plTimerCallbackMsg.cpp
PRP/Message/plTransitionMsg.cpp
PRP/Message/plWarpMsg.cpp
PRP/Message/proEventData.cpp
)
set(PRP_MSG_HEADERS
Expand Down Expand Up @@ -373,6 +374,7 @@ set(PRP_MSG_HEADERS
PRP/Message/plSwimMsg.h
PRP/Message/plTimerCallbackMsg.h
PRP/Message/plTransitionMsg.h
PRP/Message/plWarpMsg.h
PRP/Message/proEventData.h
)

Expand Down
56 changes: 56 additions & 0 deletions core/PRP/Message/plWarpMsg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* 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 "plWarpMsg.h"

void plWarpMsg::read(hsStream* S, plResManager* mgr)
{
plMessage::read(S, mgr);

fTransform.read(S);
fWarpFlags = S->readInt();
}

void plWarpMsg::write(hsStream* S, plResManager* mgr)
{
plMessage::write(S, mgr);

fTransform.write(S);
S->writeInt(fWarpFlags);
}

void plWarpMsg::IPrcWrite(pfPrcHelper* prc)
{
plMessage::IPrcWrite(prc);

prc->startTag("WarpParams");
prc->writeParamHex("Flags", fWarpFlags);
prc->endTag(true);
prc->writeSimpleTag("WarpTo");
fTransform.prcWrite(prc);
prc->closeTag();
}

void plWarpMsg::IPrcParse(const pfPrcTag* tag, plResManager* mgr)
{
if (tag->getName() == "WarpParams") {
fWarpFlags = tag->getParam("Flags", "0").to_uint();
} else if (tag->getName() == "WarpTo") {
fTransform.prcParse(tag->getFirstChild());
} else {
plMessage::IPrcParse(tag, mgr);
}
}
51 changes: 51 additions & 0 deletions core/PRP/Message/plWarpMsg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* 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 _PLWARPMSG_H
#define _PLWARPMSG_H

#include "plMessage.h"
#include "Math/hsMatrix44.h"

class PLASMA_DLL plWarpMsg : public plMessage
{
CREATABLE(plWarpMsg, kWarpMsg, plMessage)

public:
enum { kFlushTransform = 0x1, kZeroVelocity = 0x2 };

private:
uint32_t fWarpFlags;
hsMatrix44 fTransform;

public:
plWarpMsg() : fWarpFlags(), fTransform() { }

uint32_t getWarpFlags() const { return fWarpFlags; }
void setWarpFlags(uint32_t f) { fWarpFlags = f; }

hsMatrix44 getTransform() { return fTransform; }
void setTransform(const hsMatrix44& mat) { fTransform = mat; }

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 @@ -110,6 +110,7 @@
#include "PRP/Message/plSwimMsg.h"
#include "PRP/Message/plTimerCallbackMsg.h"
#include "PRP/Message/plTransitionMsg.h"
#include "PRP/Message/plWarpMsg.h"
#include "PRP/Misc/plFogEnvironment.h"
#include "PRP/Modifier/plAliasModifier.h"
#include "PRP/Modifier/plAnimEventModifier.h"
Expand Down Expand Up @@ -647,7 +648,7 @@ plCreatable* plFactory::Create(short typeIdx)
//case kSpawnRequestMsg: return new plSpawnRequestMsg();
case kLoadCloneMsg: return new plLoadCloneMsg();
case kEnableMsg: return new plEnableMsg();
//case kWarpMsg: return new plWarpMsg();
case kWarpMsg: return new plWarpMsg();
//case kAttachMsg: return new plAttachMsg();
//case kConsole: return new pfConsole();
//case kRenderMsg: return new plRenderMsg();
Expand Down

0 comments on commit 80e2990

Please sign in to comment.