Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/Ketsji/KXNetwork')
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp92
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h59
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp208
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h77
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp258
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h85
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp31
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h31
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp31
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h31
-rw-r--r--source/gameengine/Ketsji/KXNetwork/Makefile48
11 files changed, 951 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
new file mode 100644
index 00000000000..99aa798cfa5
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
@@ -0,0 +1,92 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * Ketsji Logic Extenstion: Network Event Manager generic implementation
+ */
+
+// Ketsji specific sensor part
+#include "SCA_ISensor.h"
+
+// Ketsji specific network part
+#include "KX_NetworkEventManager.h"
+
+// Network module specific
+#include "NG_NetworkDeviceInterface.h"
+#include "NG_NetworkMessage.h"
+#include "NG_NetworkObject.h"
+
+KX_NetworkEventManager::KX_NetworkEventManager(class SCA_LogicManager*
+logicmgr, class NG_NetworkDeviceInterface *ndi) :
+SCA_EventManager(NETWORK_EVENTMGR), m_logicmgr(logicmgr), m_ndi(ndi)
+{
+ //printf("KX_NetworkEventManager constructor\n");
+}
+
+KX_NetworkEventManager::~KX_NetworkEventManager()
+{
+ //printf("KX_NetworkEventManager destructor\n");
+}
+
+void KX_NetworkEventManager::RegisterSensor(class SCA_ISensor* sensor)
+{
+ //printf("KX_NetworkEventManager RegisterSensor\n");
+ m_sensors.push_back(sensor);
+}
+
+void KX_NetworkEventManager::RemoveSensor(class SCA_ISensor* sensor)
+{
+ //printf("KX_NetworkEventManager RemoveSensor\n");
+ // Network specific RemoveSensor stuff goes here
+
+ // parent
+ SCA_EventManager::RemoveSensor(sensor);
+}
+
+void KX_NetworkEventManager::NextFrame(double curtime, double deltatime)
+{
+// printf("KX_NetworkEventManager::proceed %.2f - %.2f\n", curtime, deltatime);
+ // each frame, the logicmanager will call the network
+ // eventmanager to look for network events, and process it's
+ // 'network' sensors
+ vector<class SCA_ISensor*>::iterator it;
+
+ for (it = m_sensors.begin(); !(it==m_sensors.end()); it++) {
+// printf("KX_NetworkEventManager::proceed sensor %.2f\n", curtime);
+ // process queue
+ (*it)->Activate(m_logicmgr, NULL);
+ }
+
+ // now a list of triggerer sensors has been built
+}
+
+void KX_NetworkEventManager::EndFrame()
+{
+}
+
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h
new file mode 100644
index 00000000000..521a3b4d030
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h
@@ -0,0 +1,59 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * Ketsji Logic Extenstion: Network Event Manager class
+ */
+#ifndef KX_NETWORK_EVENTMANAGER_H
+#define KX_NETWORK_EVENTMANAGER_H
+
+#include "SCA_EventManager.h"
+
+class KX_NetworkEventManager : public SCA_EventManager
+{
+ class SCA_LogicManager* m_logicmgr;
+ class NG_NetworkDeviceInterface* m_ndi;
+
+public:
+ KX_NetworkEventManager(class SCA_LogicManager* logicmgr,
+ class NG_NetworkDeviceInterface *ndi);
+ virtual ~KX_NetworkEventManager ();
+
+ virtual void RegisterSensor(class SCA_ISensor* sensor);
+ virtual void RemoveSensor(class SCA_ISensor* sensor);
+
+ virtual void NextFrame(double curtime, double deltatime);
+ virtual void EndFrame();
+
+ SCA_LogicManager* GetLogicManager() { return m_logicmgr; }
+ class NG_NetworkDeviceInterface* GetNetworkDevice() {
+ return m_ndi; }
+};
+
+#endif //KX_NETWORK_EVENTMANAGER_H
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
new file mode 100644
index 00000000000..1eb85d60b29
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
@@ -0,0 +1,208 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * Ketsji Logic Extenstion: Network Message Actuator generic implementation
+ */
+
+#include "NG_NetworkScene.h"
+#include "KX_NetworkMessageActuator.h"
+
+KX_NetworkMessageActuator::KX_NetworkMessageActuator(
+ SCA_IObject* gameobj, // the actuator controlling object
+ NG_NetworkScene* networkscene, // needed for replication
+ const STR_String &toPropName,
+ const STR_String &subject,
+ int bodyType,
+ const STR_String &body,
+ PyTypeObject* T) :
+ SCA_IActuator(gameobj,T),
+ m_networkscene(networkscene),
+ m_toPropName(toPropName),
+ m_subject(subject),
+ m_bodyType(bodyType),
+ m_body(body)
+{
+}
+
+KX_NetworkMessageActuator::~KX_NetworkMessageActuator()
+{
+}
+
+// returns true if the actuators needs to be running over several frames
+bool KX_NetworkMessageActuator::Update(double curtime, double deltatime)
+{
+ //printf("update messageactuator\n");
+ bool bNegativeEvent = IsNegativeEvent();
+ RemoveAllEvents();
+
+ if (bNegativeEvent) {
+ return false; // do nothing on negative events
+ //printf("messageactuator false event\n");
+ }
+ //printf("messageactuator true event\n");
+
+ if (m_bodyType == 1) // ACT_MESG_PROP in DNA_actuator_types.h
+ {
+ m_networkscene->SendMessage(
+ m_toPropName,
+ GetParent()->GetName(),
+ m_subject,
+ GetParent()->GetPropertyText(m_body,""));
+ } else
+ {
+ m_networkscene->SendMessage(
+ m_toPropName,
+ GetParent()->GetName(),
+ m_subject,
+ m_body);
+ }
+ return false;
+}
+
+CValue* KX_NetworkMessageActuator::GetReplica()
+{
+ KX_NetworkMessageActuator* replica =
+ new KX_NetworkMessageActuator(*this);
+ replica->ProcessReplica();
+
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+/* -------------------------------------------------------------------- */
+/* Python interface --------------------------------------------------- */
+/* -------------------------------------------------------------------- */
+
+/* Integration hooks -------------------------------------------------- */
+PyTypeObject KX_NetworkMessageActuator::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "KX_NetworkMessageActuator",
+ sizeof(KX_NetworkMessageActuator),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject KX_NetworkMessageActuator::Parents[] = {
+ &KX_NetworkMessageActuator::Type,
+ &SCA_IActuator::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef KX_NetworkMessageActuator::Methods[] = {
+ {"setToPropName", (PyCFunction)
+ KX_NetworkMessageActuator::sPySetToPropName, METH_VARARGS},
+ {"setSubject", (PyCFunction)
+ KX_NetworkMessageActuator::sPySetSubject, METH_VARARGS},
+ {"setBodyType", (PyCFunction)
+ KX_NetworkMessageActuator::sPySetBodyType, METH_VARARGS},
+ {"setBody", (PyCFunction)
+ KX_NetworkMessageActuator::sPySetBody, METH_VARARGS},
+ {NULL,NULL} // Sentinel
+};
+
+PyObject* KX_NetworkMessageActuator::_getattr(char* attr) {
+ _getattr_up(SCA_IActuator);
+}
+
+// 1. SetToPropName
+PyObject* KX_NetworkMessageActuator::PySetToPropName(
+ PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ char* ToPropName;
+
+ if (PyArg_ParseTuple(args, "s", &ToPropName)) {
+ m_toPropName = ToPropName;
+ }
+
+ Py_Return;
+}
+
+// 2. SetSubject
+PyObject* KX_NetworkMessageActuator::PySetSubject(
+ PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ char* Subject;
+
+ if (PyArg_ParseTuple(args, "s", &Subject)) {
+ m_subject = Subject;
+ }
+
+ Py_Return;
+}
+
+// 3. SetBodyType
+PyObject* KX_NetworkMessageActuator::PySetBodyType(
+ PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ int BodyType;
+
+ if (PyArg_ParseTuple(args, "i", &BodyType)) {
+ m_bodyType = BodyType;
+ }
+
+ Py_Return;
+}
+
+// 4. SetBody
+PyObject* KX_NetworkMessageActuator::PySetBody(
+ PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ char* Body;
+
+ if (PyArg_ParseTuple(args, "s", &Body)) {
+ m_body = Body;
+ }
+
+ Py_Return;
+}
+
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
new file mode 100644
index 00000000000..2ab4319821c
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
@@ -0,0 +1,77 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * Ketsji Logic Extenstion: Network Message Actuator class
+ */
+#ifndef __KX_NETWORKMESSAGEACTUATOR_H
+#define __KX_NETWORKMESSAGEACTUATOR_H
+
+#include "STR_String.h"
+
+#include "SCA_IActuator.h"
+
+#include "NG_NetworkMessage.h"
+
+class KX_NetworkMessageActuator : public SCA_IActuator
+{
+ Py_Header;
+ bool m_lastEvent;
+ class NG_NetworkScene* m_networkscene; // needed for replication
+ STR_String m_toPropName;
+ STR_String m_subject;
+ int m_bodyType;
+ STR_String m_body;
+public:
+ KX_NetworkMessageActuator(
+ SCA_IObject* gameobj,
+ NG_NetworkScene* networkscene,
+ const STR_String &toPropName,
+ const STR_String &subject,
+ int bodyType,
+ const STR_String &body,
+ PyTypeObject* T=&Type);
+ virtual ~KX_NetworkMessageActuator();
+
+ virtual bool Update(double curtime, double deltatime);
+ virtual CValue* GetReplica();
+
+ /* ------------------------------------------------------------ */
+ /* Python interface ------------------------------------------- */
+ /* ------------------------------------------------------------ */
+
+ virtual PyObject* _getattr(char *attr);
+
+ KX_PYMETHOD(KX_NetworkMessageActuator, SetToPropName);
+ KX_PYMETHOD(KX_NetworkMessageActuator, SetSubject);
+ KX_PYMETHOD(KX_NetworkMessageActuator, SetBodyType);
+ KX_PYMETHOD(KX_NetworkMessageActuator, SetBody);
+
+};
+#endif //__KX_NETWORKMESSAGEACTUATOR_H
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
new file mode 100644
index 00000000000..1eeceb55469
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
@@ -0,0 +1,258 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * Ketsji Logic Extenstion: Network Message Sensor generic implementation
+ */
+
+#include "KX_NetworkMessageSensor.h"
+#include "KX_NetworkEventManager.h"
+#include "NG_NetworkMessage.h"
+#include "NG_NetworkScene.h"
+#include "NG_NetworkObject.h"
+#include "SCA_IObject.h"
+#include "InputParser.h"
+#include "ListValue.h"
+#include "StringValue.h"
+
+#ifdef NAN_NET_DEBUG
+ #include <iostream>
+#endif
+
+KX_NetworkMessageSensor::KX_NetworkMessageSensor(
+ class KX_NetworkEventManager* eventmgr, // our eventmanager
+ class NG_NetworkScene *NetworkScene, // our scene
+ SCA_IObject* gameobj, // the sensor controlling object
+ const STR_String &subject,
+ PyTypeObject* T
+) :
+ SCA_ISensor(gameobj,eventmgr,T),
+ m_Networkeventmgr(eventmgr),
+ m_NetworkScene(NetworkScene),
+ m_subject(subject),
+ m_frame_message_count (0),
+ m_IsUp(false),
+ m_BodyList(NULL)
+{
+}
+
+KX_NetworkMessageSensor::~KX_NetworkMessageSensor()
+{
+}
+
+CValue* KX_NetworkMessageSensor::GetReplica() {
+ // This is the standard sensor implementation of GetReplica
+ // There may be more network message sensor specific stuff to do here.
+ CValue* replica = new KX_NetworkMessageSensor(*this);
+
+ if (replica == NULL) return NULL;
+
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+// Return true only for flank (UP and DOWN)
+bool KX_NetworkMessageSensor::Evaluate(CValue* event)
+{
+ bool result = false;
+ bool WasUp = m_IsUp;
+
+ m_IsUp = false;
+ if (m_BodyList) {
+ m_BodyList->Release();
+ m_BodyList = NULL;
+ }
+
+ STR_String toname=GetParent()->GetName();
+ STR_String subject = this->m_subject;
+
+ vector<NG_NetworkMessage*> messages =
+ m_NetworkScene->FindMessages(toname,"",subject,true);
+
+ m_frame_message_count = messages.size();
+
+ if (!messages.empty()) {
+#ifdef NAN_NET_DEBUG
+ printf("KX_NetworkMessageSensor found one or more messages\n");
+#endif
+ m_IsUp = true;
+ m_BodyList = new CListValue();
+ }
+
+ vector<NG_NetworkMessage*>::iterator mesit;
+ for (mesit=messages.begin();mesit!=messages.end();mesit++)
+ {
+ // save the body
+ STR_String body = (*mesit)->GetMessageText();
+#ifdef NAN_NET_DEBUG
+ if (body) {
+ cout << "body [" << body << "]\n";
+ }
+#endif
+ m_BodyList->Add(new CStringValue(body,"body"));
+
+ // free the message
+ (*mesit)->Release();
+ }
+ messages.clear();
+
+ result = (WasUp != m_IsUp);
+
+ // Return true if the message received state has changed.
+ return result;
+}
+
+// return true for being up (no flank needed)
+bool KX_NetworkMessageSensor::IsPositiveTrigger()
+{
+// printf("KX_NetworkMessageSensor IsPositiveTrigger\n");
+ return m_IsUp;
+}
+
+/* --------------------------------------------------------------------- */
+/* Python interface ---------------------------------------------------- */
+/* --------------------------------------------------------------------- */
+
+/* Integration hooks --------------------------------------------------- */
+PyTypeObject KX_NetworkMessageSensor::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "KX_NetworkMessageSensor",
+ sizeof(KX_NetworkMessageSensor),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject KX_NetworkMessageSensor::Parents[] = {
+ &KX_NetworkMessageSensor::Type,
+ &SCA_ISensor::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef KX_NetworkMessageSensor::Methods[] = {
+ {"setSubjectFilterText", (PyCFunction)
+ KX_NetworkMessageSensor::sPySetSubjectFilterText, METH_VARARGS,
+ SetSubjectFilterText_doc},
+ {"getFrameMessageCount", (PyCFunction)
+ KX_NetworkMessageSensor::sPyGetFrameMessageCount, METH_VARARGS,
+ GetFrameMessageCount_doc},
+ {"getBodies", (PyCFunction)
+ KX_NetworkMessageSensor::sPyGetBodies, METH_VARARGS,
+ GetBodies_doc},
+ {"getSubject", (PyCFunction)
+ KX_NetworkMessageSensor::sPyGetSubject, METH_VARARGS,
+ GetSubject_doc},
+ {NULL,NULL} //Sentinel
+};
+
+PyObject* KX_NetworkMessageSensor::_getattr(char* attr) {
+ _getattr_up(SCA_ISensor); // implicit return!
+}
+
+// 1. Set the message subject that this sensor listens for
+char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] =
+"\tsetSubjectFilterText(value)\n"
+"\tChange the message subject text that this sensor is listening to.\n";
+
+PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText(
+ PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ char* Subject;
+
+ if (PyArg_ParseTuple(args, "s", &Subject))
+ {
+ m_subject = Subject;
+ }
+
+ Py_Return;
+}
+
+// 2. Get the number of messages received since the last frame
+char KX_NetworkMessageSensor::GetFrameMessageCount_doc[] =
+"\tgetFrameMessageCount()\n"
+"\tGet the number of messages received since the last frame.\n";
+
+PyObject* KX_NetworkMessageSensor::PyGetFrameMessageCount(
+ PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ return PyInt_FromLong(long(m_frame_message_count));
+}
+
+// 3. Get the message bodies
+char KX_NetworkMessageSensor::GetBodies_doc[] =
+"\tgetBodies()\n"
+"\tGet the list of message bodies.\n";
+
+PyObject* KX_NetworkMessageSensor::PyGetBodies(
+ PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ if (m_BodyList) {
+ return ((PyObject*) m_BodyList->AddRef());
+ }
+
+ Py_Return;
+}
+
+// 4. Get the message subject
+char KX_NetworkMessageSensor::GetSubject_doc[] =
+"\tgetSubject()\n"
+"\tGet the subject of the message.\n";
+
+PyObject* KX_NetworkMessageSensor::PyGetSubject(
+ PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ if (m_subject) {
+ return PyString_FromString(m_subject);
+ }
+
+ Py_Return;
+}
+
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
new file mode 100644
index 00000000000..2c30befd883
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
@@ -0,0 +1,85 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * Ketsji Logic Extenstion: Network Message Sensor class
+ */
+#ifndef __KX_NETWORKMESSAGE_SENSOR_H
+#define __KX_NETWORKMESSAGE_SENSOR_H
+
+#include "SCA_ISensor.h"
+
+class KX_NetworkEventManager;
+class NG_NetworkScene;
+
+class KX_NetworkMessageSensor : public SCA_ISensor
+{
+ // note: Py_Header MUST BE the first listed here
+ Py_Header;
+ KX_NetworkEventManager *m_Networkeventmgr;
+ NG_NetworkScene *m_NetworkScene;
+
+ // The subject we filter on.
+ STR_String m_subject;
+
+ // The number of messages caught since the last frame.
+ int m_frame_message_count;
+
+ bool m_IsUp;
+
+ class CListValue* m_BodyList;
+public:
+ KX_NetworkMessageSensor(
+ KX_NetworkEventManager* eventmgr, // our eventmanager
+ NG_NetworkScene *NetworkScene, // our scene
+ SCA_IObject* gameobj, // the sensor controlling object
+ const STR_String &subject,
+ PyTypeObject* T=&Type
+ );
+ virtual ~KX_NetworkMessageSensor();
+
+ virtual CValue* GetReplica();
+ virtual bool Evaluate(CValue* event);
+ virtual bool IsPositiveTrigger();
+ void EndFrame();
+
+ /* ------------------------------------------------------------- */
+ /* Python interface -------------------------------------------- */
+ /* ------------------------------------------------------------- */
+
+ virtual PyObject* _getattr(char *attr);
+
+ KX_PYMETHOD_DOC(KX_NetworkMessageSensor, SetSubjectFilterText);
+ KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetFrameMessageCount);
+ KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetBodies);
+ KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetSubject);
+
+
+};
+#endif //__KX_NETWORKMESSAGE_SENSOR_H
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp
new file mode 100644
index 00000000000..a7800aea8c8
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp
@@ -0,0 +1,31 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h
new file mode 100644
index 00000000000..a7800aea8c8
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h
@@ -0,0 +1,31 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp
new file mode 100644
index 00000000000..a7800aea8c8
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp
@@ -0,0 +1,31 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h
new file mode 100644
index 00000000000..a7800aea8c8
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h
@@ -0,0 +1,31 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
diff --git a/source/gameengine/Ketsji/KXNetwork/Makefile b/source/gameengine/Ketsji/KXNetwork/Makefile
new file mode 100644
index 00000000000..bce2cbc29a3
--- /dev/null
+++ b/source/gameengine/Ketsji/KXNetwork/Makefile
@@ -0,0 +1,48 @@
+#
+# $Id$
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# This program 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 2
+# of the License, or (at your option) any later version. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License. See http://www.blender.org/BL/ for information
+# about this.
+#
+# This program 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 this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+#
+#
+
+LIBNAME = KXNetwork
+DIR = $(OCGDIR)/gameengine/ketsji/$(LIBNAME)
+
+include nan_compile.mk
+
+CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
+
+CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
+CPPFLAGS += -I$(NAN_STRING)/include
+CPPFLAGS += -I../../Expressions
+CPPFLAGS += -I../../GameLogic
+CPPFLAGS += -I../../Network
+CPPFLAGS += -I../../../kernel/gen_system
+CPPFLAGS += -I..
+