2001-01-26 16:38:23 +00:00
|
|
|
// This file may be redistributed and modified only under the terms of
|
2001-03-16 11:38:14 +00:00
|
|
|
// the GNU General Public License (See COPYING for details).
|
2001-01-26 16:38:23 +00:00
|
|
|
// Copyright (C) 2000 Alistair Riddoch
|
|
|
|
|
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp,
rulesets/Py_Map.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h,
rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h,
rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.cpp, rulesets/Py_Vector3D.h,
rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
#include "Python_API.h"
|
2000-11-14 15:52:10 +00:00
|
|
|
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp,
rulesets/Py_Map.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h,
rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h,
rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.cpp, rulesets/Py_Vector3D.h,
rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
#include "Py_Object.h"
|
|
|
|
|
#include "Py_Thing.h"
|
|
|
|
|
#include "Py_Mind.h"
|
|
|
|
|
#include "Py_Map.h"
|
|
|
|
|
#include "Py_Location.h"
|
|
|
|
|
#include "Py_Vector3D.h"
|
2002-03-03 00:48:28 +00:00
|
|
|
#include "Py_Quaternion.h"
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp,
rulesets/Py_Map.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h,
rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h,
rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.cpp, rulesets/Py_Vector3D.h,
rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
#include "Py_WorldTime.h"
|
|
|
|
|
#include "Py_World.h"
|
|
|
|
|
#include "Py_Operation.h"
|
|
|
|
|
#include "Py_Oplist.h"
|
|
|
|
|
#include "Py_Optime.h"
|
2000-11-14 15:52:10 +00:00
|
|
|
|
2001-04-10 19:05:14 +00:00
|
|
|
#include "PythonThingScript.h"
|
|
|
|
|
#include "PythonMindScript.h"
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
#include "World.h"
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
#include "Entity.h"
|
2001-04-10 19:05:14 +00:00
|
|
|
#include "BaseMind.h"
|
2000-11-21 19:24:29 +00:00
|
|
|
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/globals.h"
|
|
|
|
|
#include "common/const.h"
|
|
|
|
|
#include "common/debug.h"
|
|
|
|
|
#include "common/log.h"
|
2000-11-14 15:52:10 +00:00
|
|
|
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/Tick.h"
|
|
|
|
|
#include "common/Burn.h"
|
|
|
|
|
#include "common/Chop.h"
|
|
|
|
|
#include "common/Cut.h"
|
|
|
|
|
#include "common/Setup.h"
|
|
|
|
|
#include "common/Eat.h"
|
|
|
|
|
#include "common/Nourish.h"
|
2001-02-26 14:41:10 +00:00
|
|
|
|
2002-07-14 21:04:50 +00:00
|
|
|
#include <Atlas/Objects/Operation/Create.h>
|
|
|
|
|
#include <Atlas/Objects/Operation/Look.h>
|
|
|
|
|
#include <Atlas/Objects/Operation/Move.h>
|
|
|
|
|
#include <Atlas/Objects/Operation/Set.h>
|
|
|
|
|
#include <Atlas/Objects/Operation/Sight.h>
|
|
|
|
|
#include <Atlas/Objects/Operation/Talk.h>
|
|
|
|
|
#include <Atlas/Objects/Operation/Touch.h>
|
|
|
|
|
#include <Atlas/Objects/Operation/Info.h>
|
|
|
|
|
|
2002-10-03 16:14:10 +00:00
|
|
|
#include <cstdio>
|
|
|
|
|
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
static const bool debug_flag = false;
|
|
|
|
|
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp,
rulesets/Py_Map.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h,
rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h,
rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.cpp, rulesets/Py_Vector3D.h,
rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
typedef struct {
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
} FunctionObject;
|
|
|
|
|
|
2000-11-29 18:02:01 +00:00
|
|
|
static void Function_dealloc(FunctionObject * self)
|
|
|
|
|
{
|
|
|
|
|
PyMem_DEL(self);
|
|
|
|
|
}
|
|
|
|
|
|
2000-12-01 00:13:39 +00:00
|
|
|
static PyObject * log_debug(PyObject * self, PyObject * args, PyObject * kwds)
|
2000-11-29 18:02:01 +00:00
|
|
|
{
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyTypeObject log_debug_type = {
|
2003-07-18 23:05:26 +00:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0,
|
|
|
|
|
"Function",
|
|
|
|
|
sizeof(FunctionObject),
|
|
|
|
|
0,
|
|
|
|
|
/* methods */
|
|
|
|
|
(destructor)Function_dealloc,
|
|
|
|
|
0, /* tp_print */
|
|
|
|
|
0, /* tp_getattr */
|
|
|
|
|
0, /* tp_setattr */
|
|
|
|
|
0, /* tp_compare */
|
|
|
|
|
0, /* tp_repr */
|
|
|
|
|
0, /* tp_as_number */
|
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
|
0, /* tp_hash */
|
|
|
|
|
log_debug, /* tp_call */
|
2000-11-29 18:02:01 +00:00
|
|
|
};
|
2000-11-19 00:02:29 +00:00
|
|
|
|
2003-08-30 11:41:58 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Logger replaces sys.stdout and sys.stderr so the nothing goes to output
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
} PyLogger;
|
|
|
|
|
|
|
|
|
|
static PyObject * PyLogger_write(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
|
|
|
|
char * mesg;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s", &mesg)) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log(SCRIPT, mesg);
|
|
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject * PyErrorLogger_write(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
|
|
|
|
char * mesg;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s", &mesg)) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log(SCRIPT, mesg);
|
|
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyMethodDef PyLogger_methods[] = {
|
|
|
|
|
{"write", PyLogger_write, METH_VARARGS},
|
|
|
|
|
{NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static PyMethodDef PyErrorLogger_methods[] = {
|
|
|
|
|
{"write", PyErrorLogger_write, METH_VARARGS},
|
|
|
|
|
{NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void PyLogger_dealloc(PyObject * self)
|
|
|
|
|
{
|
|
|
|
|
PyMem_DEL(self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject * PyLogger_getattr(PyObject * self, char *name)
|
|
|
|
|
{
|
|
|
|
|
return Py_FindMethod(PyLogger_methods, self, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject * PyErrorLogger_getattr(PyObject * self, char *name)
|
|
|
|
|
{
|
|
|
|
|
return Py_FindMethod(PyErrorLogger_methods, self, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyTypeObject PyLogger_Type = {
|
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0, // ob_size
|
|
|
|
|
"Logger", // tp_name
|
|
|
|
|
sizeof(PyLogger), // tp_basicsize
|
|
|
|
|
0, // tp_itemsize
|
|
|
|
|
// methods
|
|
|
|
|
PyLogger_dealloc, // tp_dealloc
|
|
|
|
|
0, // tp_print
|
|
|
|
|
PyLogger_getattr, // tp_getattr
|
|
|
|
|
0, // tp_setattr
|
|
|
|
|
0, // tp_compare
|
|
|
|
|
0, // tp_repr
|
|
|
|
|
0, // tp_as_number
|
|
|
|
|
0, // tp_as_sequence
|
|
|
|
|
0, // tp_as_mapping
|
|
|
|
|
0, // tp_hash
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PyTypeObject PyErrorLogger_Type = {
|
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0, // ob_size
|
|
|
|
|
"ErrorLogger", // tp_name
|
|
|
|
|
sizeof(PyLogger), // tp_basicsize
|
|
|
|
|
0, // tp_itemsize
|
|
|
|
|
// methods
|
|
|
|
|
PyLogger_dealloc, // tp_dealloc
|
|
|
|
|
0, // tp_print
|
|
|
|
|
PyErrorLogger_getattr, // tp_getattr
|
|
|
|
|
0, // tp_setattr
|
|
|
|
|
0, // tp_compare
|
|
|
|
|
0, // tp_repr
|
|
|
|
|
0, // tp_as_number
|
|
|
|
|
0, // tp_as_sequence
|
|
|
|
|
0, // tp_as_mapping
|
|
|
|
|
0, // tp_hash
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// dictlist
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2000-12-06 18:21:35 +00:00
|
|
|
static PyObject * dictlist_remove_value(PyObject * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2000-12-30 23:16:57 +00:00
|
|
|
PyObject * dict;
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyEntity * item;
|
2000-12-06 18:21:35 +00:00
|
|
|
long remove_empty_key = 1;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OO|i", &dict, &item, &remove_empty_key)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
int flag = 0;
|
2000-12-06 18:21:35 +00:00
|
|
|
if (!PyDict_Check(dict)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Trying to set item in not dictlist");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyObject * keys = PyDict_Keys(dict);
|
|
|
|
|
PyObject * values = PyDict_Values(dict);
|
|
|
|
|
|
|
|
|
|
if ((keys == NULL) || (values == NULL)) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyErr_SetString(PyExc_RuntimeError, "Error getting keys from dictlist");
|
2000-12-06 18:21:35 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
int i, size = PyList_Size(keys);
|
|
|
|
|
for(i = 0; i < size; i++) {
|
|
|
|
|
PyObject * value = PyList_GetItem(values, i);
|
|
|
|
|
PyObject * key = PyList_GetItem(keys, i);
|
|
|
|
|
int j, lsize = PyList_Size(value);
|
|
|
|
|
for(j = 0; j < lsize; j++) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyEntity * entry = (PyEntity*)PyList_GetItem(value, j);
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
if (entry->m_entity == item->m_entity) {
|
2000-12-06 18:21:35 +00:00
|
|
|
flag = 1;
|
|
|
|
|
PyList_SetSlice(value, j, j+1, NULL);
|
2000-12-30 23:16:57 +00:00
|
|
|
j--; lsize--;
|
2000-12-06 18:21:35 +00:00
|
|
|
if ((remove_empty_key !=0) && (PyList_Size(value) == 0)) {
|
|
|
|
|
PyDict_DelItem(dict, key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-12-11 13:06:12 +00:00
|
|
|
Py_DECREF(keys);
|
|
|
|
|
Py_DECREF(values);
|
2000-12-06 18:21:35 +00:00
|
|
|
return PyInt_FromLong(flag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyTypeObject dictlist_remove_value_type = {
|
2003-07-18 23:05:26 +00:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0,
|
|
|
|
|
"Function",
|
|
|
|
|
sizeof(FunctionObject),
|
|
|
|
|
0,
|
|
|
|
|
/* methods */
|
|
|
|
|
(destructor)Function_dealloc,
|
|
|
|
|
0, /* tp_print */
|
|
|
|
|
0, /* tp_getattr */
|
|
|
|
|
0, /* tp_setattr */
|
|
|
|
|
0, /* tp_compare */
|
|
|
|
|
0, /* tp_repr */
|
|
|
|
|
0, /* tp_as_number */
|
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
|
0, /* tp_hash */
|
|
|
|
|
dictlist_remove_value, /* tp_call */
|
2000-12-06 18:21:35 +00:00
|
|
|
};
|
2000-12-01 00:13:39 +00:00
|
|
|
static PyObject * dictlist_add_value(PyObject * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2000-12-30 23:16:57 +00:00
|
|
|
PyObject * dict;
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyEntity * item;
|
2000-12-01 00:13:39 +00:00
|
|
|
char * key;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OsO", &dict, &key, &item)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!PyDict_Check(dict)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Dict is not a dictionary");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyObject * list = PyDict_GetItemString(dict, key);
|
|
|
|
|
if (list != NULL) {
|
|
|
|
|
if (!PyList_Check(list)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Dict does not contain a list");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
int i, size = PyList_Size(list);
|
|
|
|
|
for(i = 0; i < size; i++) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyEntity * entry = (PyEntity*)PyList_GetItem(list,i);
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
if (entry->m_entity == item->m_entity) {
|
2000-12-01 00:13:39 +00:00
|
|
|
goto present;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-12-30 23:16:57 +00:00
|
|
|
PyList_Append(list, (PyObject*)item);
|
2000-12-01 00:13:39 +00:00
|
|
|
} else {
|
2000-12-06 18:21:35 +00:00
|
|
|
list = PyList_New(0);
|
2000-12-30 23:16:57 +00:00
|
|
|
PyList_Append(list, (PyObject*)item);
|
2000-12-01 00:13:39 +00:00
|
|
|
PyDict_SetItemString(dict, key, list);
|
2000-12-03 14:23:26 +00:00
|
|
|
Py_DECREF(list);
|
2000-12-01 00:13:39 +00:00
|
|
|
}
|
|
|
|
|
present:
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyTypeObject dictlist_add_value_type = {
|
2003-07-18 23:05:26 +00:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0,
|
|
|
|
|
"Function",
|
|
|
|
|
sizeof(FunctionObject),
|
|
|
|
|
0,
|
|
|
|
|
/* methods */
|
|
|
|
|
(destructor)Function_dealloc,
|
|
|
|
|
0, /* tp_print */
|
|
|
|
|
0, /* tp_getattr */
|
|
|
|
|
0, /* tp_setattr */
|
|
|
|
|
0, /* tp_compare */
|
|
|
|
|
0, /* tp_repr */
|
|
|
|
|
0, /* tp_as_number */
|
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
|
0, /* tp_hash */
|
|
|
|
|
dictlist_add_value, /* tp_call */
|
2000-12-01 00:13:39 +00:00
|
|
|
};
|
|
|
|
|
|
2001-08-02 14:27:06 +00:00
|
|
|
static PyObject * Get_PyClass(const std::string & package,
|
|
|
|
|
const std::string & _type)
|
2000-11-19 00:02:29 +00:00
|
|
|
{
|
2001-08-02 14:27:06 +00:00
|
|
|
std::string type = _type;
|
2000-12-03 14:23:26 +00:00
|
|
|
type[0] = toupper(type[0]);
|
2000-12-13 12:10:48 +00:00
|
|
|
PyObject * package_name = PyString_FromString((char *)package.c_str());
|
2001-06-22 22:03:59 +00:00
|
|
|
PyObject * mod_dict = PyImport_Import(package_name);
|
|
|
|
|
Py_DECREF(package_name);
|
|
|
|
|
if (mod_dict == NULL) {
|
2002-07-14 21:04:50 +00:00
|
|
|
std::string msg = std::string("Missing python module ") + package;
|
|
|
|
|
log(ERROR, msg.c_str());
|
2001-08-14 17:52:50 +00:00
|
|
|
PyErr_Print();
|
2001-04-10 19:05:14 +00:00
|
|
|
return NULL;
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
|
|
|
|
PyObject * my_class = PyObject_GetAttrString(mod_dict, (char *)type.c_str());
|
2001-04-10 19:05:14 +00:00
|
|
|
Py_DECREF(mod_dict);
|
2000-11-19 00:02:29 +00:00
|
|
|
if (my_class == NULL) {
|
2002-07-14 21:04:50 +00:00
|
|
|
std::string msg = std::string("Missing class ") + package + "." + type;
|
|
|
|
|
log(ERROR, msg.c_str());
|
2000-12-11 13:06:12 +00:00
|
|
|
PyErr_Print();
|
2001-04-10 19:05:14 +00:00
|
|
|
return NULL;
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
|
|
|
|
if (PyCallable_Check(my_class) == 0) {
|
2002-07-14 21:04:50 +00:00
|
|
|
std::string msg = std::string("Could not instance python class ")
|
|
|
|
|
+ package + "." + type;
|
|
|
|
|
log(ERROR, msg.c_str());
|
2001-06-22 22:03:59 +00:00
|
|
|
Py_DECREF(my_class);
|
2001-04-10 19:05:14 +00:00
|
|
|
return NULL;
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
2003-11-22 15:30:30 +00:00
|
|
|
#if 0
|
2004-04-19 10:14:17 +00:00
|
|
|
// In later versions of python using PyType_* will become the right thing to do.
|
2003-08-30 11:41:58 +00:00
|
|
|
if (PyType_Check(my_class) == 0) {
|
|
|
|
|
std::cerr << "PyCallable_Check returned true, but PyType_Check returned false " << package << "." << type << std::endl << std::flush;
|
|
|
|
|
} else {
|
|
|
|
|
std::cerr << "PyType_Check returned true" << std::endl << std::flush;
|
|
|
|
|
}
|
2003-11-22 15:30:30 +00:00
|
|
|
#endif
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
return my_class;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
static PyObject * Create_PyScript(PyObject * pyEntity, PyObject * pyClass)
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
{
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
PyObject * pyob = PyEval_CallFunction(pyClass,"(O)", pyEntity);
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
|
|
|
|
|
if (pyob == NULL) {
|
2000-11-19 00:02:29 +00:00
|
|
|
if (PyErr_Occurred() == NULL) {
|
2002-07-14 21:04:50 +00:00
|
|
|
log(ERROR, "Could not create python instance");
|
2000-11-19 00:02:29 +00:00
|
|
|
} else {
|
2002-07-14 21:04:50 +00:00
|
|
|
log(ERROR, "Reporting python error");
|
2000-11-19 00:02:29 +00:00
|
|
|
PyErr_Print();
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-10-10 09:40:24 +00:00
|
|
|
Py_DECREF(pyClass);
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
Py_DECREF(pyEntity);
|
2001-04-10 19:05:14 +00:00
|
|
|
return pyob;
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
template<class T>
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
void Subscribe_Script(T * entity, PyObject * pyclass,
|
|
|
|
|
const std::string& package)
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
{
|
|
|
|
|
PyObject * dmap = PyObject_GetAttrString(pyclass, "__dict__");
|
|
|
|
|
if (dmap == NULL) {
|
2002-07-14 21:04:50 +00:00
|
|
|
std::string msg = std::string( "Python class for ") + package
|
|
|
|
|
+ " has no __dict__";
|
|
|
|
|
log(ERROR, msg.c_str());
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!PyDict_Check(dmap)) {
|
2002-07-14 21:04:50 +00:00
|
|
|
std::string msg = std::string( "Python class for ") + package
|
|
|
|
|
+ " is malformed";
|
|
|
|
|
log(ERROR, msg.c_str());
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PyObject * keys = PyDict_Keys(dmap);
|
|
|
|
|
if (keys == NULL) {
|
2002-07-14 21:04:50 +00:00
|
|
|
std::string msg = std::string("Error getting attribute list of Python class for ") + package;
|
|
|
|
|
log(ERROR, msg.c_str());
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for(int i = 0; i < PyList_Size(keys); i++) {
|
|
|
|
|
std::string method(PyString_AsString(PyList_GetItem(keys, i)));
|
|
|
|
|
std::string::size_type l = method.find("_operation", 0, 10);
|
|
|
|
|
if (l == std::string::npos) {
|
|
|
|
|
debug(std::cout << method << " is not a method" << std::endl
|
|
|
|
|
<< std::flush;);
|
|
|
|
|
} else {
|
|
|
|
|
std::string op_name = method.substr(0,l);
|
|
|
|
|
debug(std::cout << method << " is a method, it contains _op.. at "
|
|
|
|
|
<< l << " so we can register for "
|
|
|
|
|
<< method.substr(0,l) << std::endl << std::flush;);
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
entity->scriptSubscribe(op_name);
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-07-21 02:36:58 +00:00
|
|
|
Py_DECREF(keys);
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
}
|
|
|
|
|
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
void Create_PyEntity(Entity * entity, const std::string & package,
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
const std::string & _type)
|
2001-04-10 19:05:14 +00:00
|
|
|
{
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
PyObject * c = Get_PyClass(package, _type);
|
|
|
|
|
if (c == NULL) { return; }
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyEntity * pyEntity = newPyEntity();
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
pyEntity->m_entity = entity;
|
|
|
|
|
Subscribe_Script(entity, c, package);
|
|
|
|
|
PyObject * o = Create_PyScript((PyObject *)pyEntity, c);
|
2001-04-10 19:05:14 +00:00
|
|
|
if (o != NULL) {
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
entity->setScript(new PythonEntityScript(o, *entity));
|
2001-04-10 19:05:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-02 14:27:06 +00:00
|
|
|
void Create_PyMind(BaseMind * mind, const std::string & package,
|
|
|
|
|
const std::string & _type)
|
2001-04-10 19:05:14 +00:00
|
|
|
{
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
PyObject * c = Get_PyClass(package, _type);
|
|
|
|
|
if (c == NULL) { return; }
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyMind * pyMind = newPyMind();
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
pyMind->m_mind = mind;
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
Subscribe_Script(mind, c, package);
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
PyObject * o = Create_PyScript((PyObject *)pyMind, c);
|
|
|
|
|
|
2001-04-10 19:05:14 +00:00
|
|
|
if (o != NULL) {
|
2001-04-11 14:34:15 +00:00
|
|
|
mind->setScript(new PythonMindScript(o, *mind));
|
2001-04-10 19:05:14 +00:00
|
|
|
}
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
2000-12-04 20:08:21 +00:00
|
|
|
static PyObject * is_location(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
|
|
|
|
PyObject * loc;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O", &loc)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-12-16 20:28:06 +00:00
|
|
|
if (PyLocation_Check(loc)) {
|
2000-12-04 20:08:21 +00:00
|
|
|
Py_INCREF(Py_True);
|
|
|
|
|
return Py_True;
|
|
|
|
|
}
|
|
|
|
|
Py_INCREF(Py_False);
|
|
|
|
|
return Py_False;
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-20 20:28:08 +00:00
|
|
|
static PyObject * location_new(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyLocation *o;
|
2000-12-05 14:26:04 +00:00
|
|
|
// We need to deal with actual args here
|
2001-02-19 06:13:31 +00:00
|
|
|
PyObject * refO, * coordsO = NULL;
|
2001-10-09 14:03:12 +00:00
|
|
|
bool decrefO = false;
|
2001-02-19 06:13:31 +00:00
|
|
|
if (PyArg_ParseTuple(args, "O|O", &refO, &coordsO)) {
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
if ((!PyEntity_Check(refO)) && (!PyWorld_Check(refO)) && (!PyMind_Check(refO))) {
|
2001-02-19 06:13:31 +00:00
|
|
|
if (PyObject_HasAttrString(refO, "cppthing")) {
|
|
|
|
|
refO = PyObject_GetAttrString(refO, "cppthing");
|
2001-10-09 14:03:12 +00:00
|
|
|
decrefO = true;
|
2000-12-07 12:14:35 +00:00
|
|
|
}
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
if (!PyEntity_Check(refO) && !PyMind_Check(refO)) {
|
2001-02-19 06:13:31 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Arg ref required");
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
2000-12-07 12:14:35 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-12-16 20:28:06 +00:00
|
|
|
if ((coordsO != NULL) && (!PyVector3D_Check(coordsO))) {
|
2000-12-07 12:14:35 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Arg coords required");
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
2000-12-05 14:26:04 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-12-13 12:10:48 +00:00
|
|
|
|
2001-04-16 16:26:44 +00:00
|
|
|
Entity * ref_ent;
|
2001-02-19 06:13:31 +00:00
|
|
|
if (PyWorld_Check(refO)) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyWorld * ref = (PyWorld*)refO;
|
|
|
|
|
#ifndef NDEBUG
|
2001-02-19 06:13:31 +00:00
|
|
|
if (ref->world == NULL) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "Parent world is invalid");
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
2000-12-13 12:10:48 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
#endif // NDEBUG
|
2003-05-04 18:31:38 +00:00
|
|
|
ref_ent = &ref->world->m_gameWorld;
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
} else if (PyMind_Check(refO)) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyMind * ref = (PyMind*)refO;
|
|
|
|
|
#ifndef NDEBUG
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
if (ref->m_mind == NULL) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "Parent mind is invalid");
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
#endif // NDEBUG
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
ref_ent = ref->m_mind;
|
2000-12-13 12:10:48 +00:00
|
|
|
} else {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyEntity * ref = (PyEntity*)refO;
|
|
|
|
|
#ifndef NDEBUG
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
if (ref->m_entity == NULL) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "Parent thing is invalid");
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
2000-12-13 12:10:48 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
#endif // NDEBUG
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
ref_ent = ref->m_entity;
|
2000-12-05 14:26:04 +00:00
|
|
|
}
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * coords = (PyVector3D*)coordsO;
|
|
|
|
|
o = newPyLocation();
|
2000-12-05 14:26:04 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-12-11 13:06:12 +00:00
|
|
|
if (coords == NULL) {
|
2002-09-06 15:56:08 +00:00
|
|
|
o->location = new Location(ref_ent);
|
2000-12-11 13:06:12 +00:00
|
|
|
} else {
|
2001-02-19 06:13:31 +00:00
|
|
|
o->location = new Location(ref_ent, coords->coords);
|
2000-12-11 13:06:12 +00:00
|
|
|
}
|
2000-12-08 11:40:32 +00:00
|
|
|
o->own = 1;
|
2000-12-05 14:26:04 +00:00
|
|
|
} else if (PyArg_ParseTuple(args, "")) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
o = newPyLocation();
|
2000-12-05 14:26:04 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
o->location = new Location;
|
2000-12-08 11:40:32 +00:00
|
|
|
o->own = 1;
|
2000-12-05 14:26:04 +00:00
|
|
|
} else {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)o;
|
2000-11-20 20:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject * vector3d_new(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D *o;
|
2000-12-01 00:13:39 +00:00
|
|
|
Vector3D val;
|
2003-07-18 23:05:26 +00:00
|
|
|
// We need to deal with actual args here
|
2000-12-01 00:13:39 +00:00
|
|
|
PyObject * clist;
|
2000-12-15 19:25:19 +00:00
|
|
|
switch (PyTuple_Size(args)) {
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
clist = PyTuple_GetItem(args, 0);
|
|
|
|
|
if ((!PyList_Check(clist)) || (PyList_Size(clist) != 3)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D() from single value must a list 3 long");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
for(int i = 0; i < 3; i++) {
|
|
|
|
|
PyObject * item = PyList_GetItem(clist, i);
|
|
|
|
|
if (PyInt_Check(item)) {
|
2003-10-29 Al Riddoch <alriddoch@zepler.org>
* common/const.cpp, common/const.h, common/random.h,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Python_API.cpp,
tests/collisiontest.cpp: Update variables relating to geometry
from double to float as this is the type used internall by
WFMath.
* physics/Vector3D.cpp, physics/Quaternion.cpp, physics/Quaternion.h:
Remove legacy code.
* server/CommPSQLSocket.cpp: Reformatting.
2003-10-29 01:39:09 +00:00
|
|
|
val[i] = (float)PyInt_AsLong(item);
|
2000-12-15 19:25:19 +00:00
|
|
|
} else if (PyFloat_Check(item)) {
|
|
|
|
|
val[i] = PyFloat_AsDouble(item);
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D() must take list of floats, or ints");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-18 00:43:53 +00:00
|
|
|
val.setValid();
|
2000-12-15 19:25:19 +00:00
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
for(int i = 0; i < 3; i++) {
|
|
|
|
|
PyObject * item = PyTuple_GetItem(args, i);
|
|
|
|
|
if (PyInt_Check(item)) {
|
2003-10-29 Al Riddoch <alriddoch@zepler.org>
* common/const.cpp, common/const.h, common/random.h,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Python_API.cpp,
tests/collisiontest.cpp: Update variables relating to geometry
from double to float as this is the type used internall by
WFMath.
* physics/Vector3D.cpp, physics/Quaternion.cpp, physics/Quaternion.h:
Remove legacy code.
* server/CommPSQLSocket.cpp: Reformatting.
2003-10-29 01:39:09 +00:00
|
|
|
val[i] = (float)PyInt_AsLong(item);
|
2000-12-15 19:25:19 +00:00
|
|
|
} else if (PyFloat_Check(item)) {
|
|
|
|
|
val[i] = PyFloat_AsDouble(item);
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D() must take list of floats, or ints");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-18 00:43:53 +00:00
|
|
|
val.setValid();
|
2000-12-15 19:25:19 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D must take list of floats, or ints, 3 ints or 3 floats");
|
2000-12-01 00:13:39 +00:00
|
|
|
return NULL;
|
2000-12-15 19:25:19 +00:00
|
|
|
break;
|
2000-12-01 00:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
o = newPyVector3D();
|
2003-07-18 23:05:26 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-12-01 00:13:39 +00:00
|
|
|
o->coords = val;
|
2003-07-18 23:05:26 +00:00
|
|
|
return (PyObject *)o;
|
2000-11-20 20:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
2002-03-03 00:48:28 +00:00
|
|
|
static PyObject * quaternion_new(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyQuaternion *o;
|
2002-03-03 00:48:28 +00:00
|
|
|
Quaternion val;
|
|
|
|
|
|
|
|
|
|
PyObject * clist;
|
|
|
|
|
switch (PyTuple_Size(args)) {
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
clist = PyTuple_GetItem(args, 0);
|
|
|
|
|
if ((!PyList_Check(clist)) || (PyList_Size(clist) != 4)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Quaternion() from single value must a list 4 long");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-07-19 02:11:49 +00:00
|
|
|
{
|
|
|
|
|
float quaternion[4];
|
2002-03-03 00:48:28 +00:00
|
|
|
for(int i = 0; i < 4; i++) {
|
|
|
|
|
PyObject * item = PyList_GetItem(clist, i);
|
|
|
|
|
if (PyInt_Check(item)) {
|
2003-07-19 02:11:49 +00:00
|
|
|
quaternion[i] = (WFMath::CoordType)PyInt_AsLong(item);
|
2002-03-03 00:48:28 +00:00
|
|
|
} else if (PyFloat_Check(item)) {
|
2003-07-19 02:11:49 +00:00
|
|
|
quaternion[i] = PyFloat_AsDouble(item);
|
2002-03-03 00:48:28 +00:00
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Quaternion() must take list of floats, or ints");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-19 02:11:49 +00:00
|
|
|
val = Quaternion(quaternion[3], quaternion[0],
|
|
|
|
|
quaternion[1], quaternion[2]);
|
|
|
|
|
}
|
2002-03-03 00:48:28 +00:00
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
PyObject * v1 = PyTuple_GetItem(args, 0);
|
|
|
|
|
PyObject * v2 = PyTuple_GetItem(args, 0);
|
|
|
|
|
if (!PyVector3D_Check(v1) || !PyVector3D_Check(v2)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Quaternion(a,b) must take two vectors");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * from = (PyVector3D *)v1;
|
|
|
|
|
PyVector3D * to = (PyVector3D *)v2;
|
2003-07-18 00:43:53 +00:00
|
|
|
val = quaternionFromTo(from->coords, to->coords);
|
2002-03-03 00:48:28 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2003-07-19 02:11:49 +00:00
|
|
|
{
|
|
|
|
|
float quaternion[4];
|
2002-03-03 00:48:28 +00:00
|
|
|
for(int i = 0; i < 4; i++) {
|
|
|
|
|
PyObject * item = PyTuple_GetItem(args, i);
|
|
|
|
|
if (PyInt_Check(item)) {
|
2003-07-19 02:11:49 +00:00
|
|
|
quaternion[i] = (WFMath::CoordType)PyInt_AsLong(item);
|
2002-03-03 00:48:28 +00:00
|
|
|
} else if (PyFloat_Check(item)) {
|
2003-07-19 02:11:49 +00:00
|
|
|
quaternion[i] = PyFloat_AsDouble(item);
|
2002-03-03 00:48:28 +00:00
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Quaternion() must take list of floats, or ints");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-19 02:11:49 +00:00
|
|
|
val = Quaternion(quaternion[3], quaternion[0],
|
|
|
|
|
quaternion[1], quaternion[2]);
|
|
|
|
|
}
|
2002-03-03 00:48:28 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Quaternion must take list of floats, or ints, 4 ints or 4 floats");
|
|
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
o = newPyQuaternion();
|
2003-07-18 23:05:26 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-03-03 00:48:28 +00:00
|
|
|
o->rotation = val;
|
2003-07-18 23:05:26 +00:00
|
|
|
return (PyObject *)o;
|
2002-03-03 00:48:28 +00:00
|
|
|
}
|
|
|
|
|
|
2000-11-29 15:19:36 +00:00
|
|
|
static PyObject * worldtime_new(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyWorldTime *o;
|
2003-07-18 23:05:26 +00:00
|
|
|
|
2000-11-29 15:19:36 +00:00
|
|
|
int seconds;
|
2003-07-18 23:05:26 +00:00
|
|
|
if (!PyArg_ParseTuple(args, "i", &seconds)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
o = newPyWorldTime();
|
2003-07-18 23:05:26 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
o->time = new WorldTime(seconds);
|
2001-06-22 22:03:59 +00:00
|
|
|
o->own = true;
|
2003-07-18 23:05:26 +00:00
|
|
|
return (PyObject *)o;
|
2000-11-29 15:19:36 +00:00
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
static inline void addToOplist(PyOperation * op, PyOplist * o)
|
2000-12-07 12:14:35 +00:00
|
|
|
{
|
|
|
|
|
if (op != NULL) {
|
2000-12-16 20:28:06 +00:00
|
|
|
if (PyOperation_Check(op)) {
|
|
|
|
|
o->ops->push_back(op->operation);
|
|
|
|
|
op->own = 0;
|
|
|
|
|
} else if ((PyObject*)op != Py_None) {
|
2000-12-07 12:14:35 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Argument must be an op");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-11-29 15:19:36 +00:00
|
|
|
static PyObject * oplist_new(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyOplist *o;
|
2003-07-18 23:05:26 +00:00
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyOperation *op1 = NULL, *op2 = NULL, *op3 = NULL, *op4 = NULL;
|
2003-07-18 23:05:26 +00:00
|
|
|
if (!PyArg_ParseTuple(args, "|OOOO", &op1, &op2, &op3, &op4)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
o = newPyOplist();
|
2003-07-18 23:05:26 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
o->ops = new OpVector();
|
2000-12-07 12:14:35 +00:00
|
|
|
addToOplist(op1, o);
|
|
|
|
|
addToOplist(op2, o);
|
|
|
|
|
addToOplist(op3, o);
|
|
|
|
|
addToOplist(op4, o);
|
2003-07-18 23:05:26 +00:00
|
|
|
return (PyObject *)o;
|
2000-11-29 15:19:36 +00:00
|
|
|
}
|
|
|
|
|
|
2000-11-17 00:18:32 +00:00
|
|
|
static PyObject * object_new(PyObject * self, PyObject * args)
|
2000-11-16 16:35:03 +00:00
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyMessageElement *o;
|
2003-07-18 23:05:26 +00:00
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "")) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
o = newPyMessageElement();
|
2003-07-18 23:05:26 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
o->m_obj = new Element(Element::MapType());
|
|
|
|
|
return (PyObject *)o;
|
2000-11-16 16:35:03 +00:00
|
|
|
}
|
|
|
|
|
|
2000-12-01 00:13:39 +00:00
|
|
|
static PyObject * entity_new(PyObject * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyMessageElement *o;
|
2000-12-30 23:16:57 +00:00
|
|
|
char * id = NULL;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "|s", &id)) {
|
* tools/cycmd.cpp: Ensure that login op is flushed after it is sent.
* server/Player.cpp: Arg order of std::string.compare() is
incompatable between recent libstdc++ versions. Switch
back to old version, still in most common use.
* rulesets/Thing.cpp: Set refno on ops handled in game.
* rulesets/Python_API.cpp: Modify Entity() python constructor
so that commonly used attributes from old atlas are translated
to their modern equivalents.
* rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp: Differentiate
between previously identical error messages in several places.
* rulesets/Py_Object.cpp: Rework conversion of python dict to
Atlas map to be more efficient and clean.
* rulesets/Py_Location.cpp: Rework setting of vector parts of
location so that it can accept vectors from python in more
formats, including lists and tuples.
* rulesets/Creator.h, rulesets/Character.h, common/BaseEntity.h:
Re-order virtual methods declarations to fit a convention.
* common/stringstream.h: Hardcode use of local stringstream class,
as the version provided with older libstdc++ seems to be broken.
* common/database.cpp: Use the common header to pick the right
stringstream implementation.
* common/BaseWorld.cpp, server/Persistance.cpp: Removed unused
stringstream include.
* rulesets/Creator.cpp: Added extra debug output.
* client/define_world.h, client/define_world.cpp, client/CommClient.h:
Use CreatorClient to store Creators mind, instead of BaseMind.
* client/client.cpp,
client/ObserverClient.h, client/ObserverClient.cpp,
client/CreatorClient.h, client/CommClient.h, client/CommClient.cpp:
Modify method names to fit capitalisation conventions.
* client/CreatorClient.cpp: Implement creation of in-game entities,
using creator entity.
* client/CommClient.cpp: Added correct client side monitoring of
creator entity.
* client/ClientConnection.h, client/ClientConnection.cpp: Added
pending method to establish if ops are in the queue. Switched send()
method so we only send ops. Add setting of serialno of sent
ops, starting with an offset of 512.
* client/CharacterClient.h: Removed unused member, opFound.
* client/CharacterClient.cpp: Debugged sendAndWait() method.
Al Riddoch <alriddoch@zepler.org>
2001-08-16 17:39:42 +00:00
|
|
|
return NULL;
|
2000-12-30 23:16:57 +00:00
|
|
|
}
|
2003-03-22 Al Riddoch <alriddoch@zepler.org>
* client/CommClient.cpp, client/CreatorClient.cpp,
client/ObserverClient.cpp, client/Py_CreatorClient.cpp,
common/BaseEntity.cpp, common/BaseEntity.h,
common/types.h, rulesets/Area.cpp, rulesets/BaseMind.cpp,
rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/MemMap.cpp, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp, server/CommClient.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp,
server/Persistance.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/WorldRouter.cpp:
Switch to using Element as name for Atlas::Message::Object,
to avoid name clashes on Object, and bring into line with
the way Atlas-C++ will be.
2003-03-23 00:55:09 +00:00
|
|
|
Element::MapType omap;
|
2000-12-30 23:16:57 +00:00
|
|
|
if (id != NULL) {
|
2001-08-02 14:27:06 +00:00
|
|
|
omap["id"] = std::string(id);
|
2000-12-30 23:16:57 +00:00
|
|
|
}
|
|
|
|
|
if ((kwds != NULL) && (PyDict_Check(kwds))) {
|
2000-12-06 18:21:35 +00:00
|
|
|
PyObject * keys = PyDict_Keys(kwds);
|
|
|
|
|
PyObject * vals = PyDict_Values(kwds);
|
2000-12-01 00:13:39 +00:00
|
|
|
if ((keys == NULL) || (vals == NULL)) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyErr_SetString(PyExc_RuntimeError, "Error in keywords");
|
2000-12-01 00:13:39 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
int i, size = PyList_Size(keys);
|
2000-12-01 00:13:39 +00:00
|
|
|
for(i = 0; i < size; i++) {
|
|
|
|
|
char * key = PyString_AsString(PyList_GetItem(keys, i));
|
|
|
|
|
PyObject * val = PyList_GetItem(vals, i);
|
2000-12-16 20:28:06 +00:00
|
|
|
if ((strcmp(key, "location") == 0) && (PyLocation_Check(val))) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyLocation * loc = (PyLocation*)val;
|
* server/server.cpp, server/ServerRouting.h, server/ServerRouting.cpp,
server/CommServer.h: Added support for server "name" which
defaults to the hostname of the server machine, but is
customisable in the config. This can be used in preference to
IP address when doing lookups with the metaserver.
* server/Lobby.h, server/ServerRouting.h, server/Account.h,
server/Account.cpp, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Python_API.cpp, rulesets/Py_Object.cpp, rulesets/Plant.cpp,
rulesets/Pedestrian.cpp, rulesets/Entity.h, rulesets/Entity.cpp,
rulesets/Character.h, rulesets/Character.cpp, common/BaseEntity.h,
common/BaseEntity.cpp: Modied asObect() and addToObject()
methods to make them more efficient.
* modules/Location.h, modules/Location.cpp: Removed old obsolete
Message::Object based addToObject() method.
* rulesets/Thing.cpp: Optimised apperance/disappearance code.
Al Riddoch <alriddoch@zepler.org>
2001-07-16 17:52:23 +00:00
|
|
|
loc->location->addToObject(omap);
|
* tools/cycmd.cpp: Ensure that login op is flushed after it is sent.
* server/Player.cpp: Arg order of std::string.compare() is
incompatable between recent libstdc++ versions. Switch
back to old version, still in most common use.
* rulesets/Thing.cpp: Set refno on ops handled in game.
* rulesets/Python_API.cpp: Modify Entity() python constructor
so that commonly used attributes from old atlas are translated
to their modern equivalents.
* rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp: Differentiate
between previously identical error messages in several places.
* rulesets/Py_Object.cpp: Rework conversion of python dict to
Atlas map to be more efficient and clean.
* rulesets/Py_Location.cpp: Rework setting of vector parts of
location so that it can accept vectors from python in more
formats, including lists and tuples.
* rulesets/Creator.h, rulesets/Character.h, common/BaseEntity.h:
Re-order virtual methods declarations to fit a convention.
* common/stringstream.h: Hardcode use of local stringstream class,
as the version provided with older libstdc++ seems to be broken.
* common/database.cpp: Use the common header to pick the right
stringstream implementation.
* common/BaseWorld.cpp, server/Persistance.cpp: Removed unused
stringstream include.
* rulesets/Creator.cpp: Added extra debug output.
* client/define_world.h, client/define_world.cpp, client/CommClient.h:
Use CreatorClient to store Creators mind, instead of BaseMind.
* client/client.cpp,
client/ObserverClient.h, client/ObserverClient.cpp,
client/CreatorClient.h, client/CommClient.h, client/CommClient.cpp:
Modify method names to fit capitalisation conventions.
* client/CreatorClient.cpp: Implement creation of in-game entities,
using creator entity.
* client/CommClient.cpp: Added correct client side monitoring of
creator entity.
* client/ClientConnection.h, client/ClientConnection.cpp: Added
pending method to establish if ops are in the queue. Switched send()
method so we only send ops. Add setting of serialno of sent
ops, starting with an offset of 512.
* client/CharacterClient.h: Removed unused member, opFound.
* client/CharacterClient.cpp: Debugged sendAndWait() method.
Al Riddoch <alriddoch@zepler.org>
2001-08-16 17:39:42 +00:00
|
|
|
} else if (strcmp(key, "xyz") == 0) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
omap["pos"] = PyObject_asMessageElement(val);
|
* tools/cycmd.cpp: Ensure that login op is flushed after it is sent.
* server/Player.cpp: Arg order of std::string.compare() is
incompatable between recent libstdc++ versions. Switch
back to old version, still in most common use.
* rulesets/Thing.cpp: Set refno on ops handled in game.
* rulesets/Python_API.cpp: Modify Entity() python constructor
so that commonly used attributes from old atlas are translated
to their modern equivalents.
* rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp: Differentiate
between previously identical error messages in several places.
* rulesets/Py_Object.cpp: Rework conversion of python dict to
Atlas map to be more efficient and clean.
* rulesets/Py_Location.cpp: Rework setting of vector parts of
location so that it can accept vectors from python in more
formats, including lists and tuples.
* rulesets/Creator.h, rulesets/Character.h, common/BaseEntity.h:
Re-order virtual methods declarations to fit a convention.
* common/stringstream.h: Hardcode use of local stringstream class,
as the version provided with older libstdc++ seems to be broken.
* common/database.cpp: Use the common header to pick the right
stringstream implementation.
* common/BaseWorld.cpp, server/Persistance.cpp: Removed unused
stringstream include.
* rulesets/Creator.cpp: Added extra debug output.
* client/define_world.h, client/define_world.cpp, client/CommClient.h:
Use CreatorClient to store Creators mind, instead of BaseMind.
* client/client.cpp,
client/ObserverClient.h, client/ObserverClient.cpp,
client/CreatorClient.h, client/CommClient.h, client/CommClient.cpp:
Modify method names to fit capitalisation conventions.
* client/CreatorClient.cpp: Implement creation of in-game entities,
using creator entity.
* client/CommClient.cpp: Added correct client side monitoring of
creator entity.
* client/ClientConnection.h, client/ClientConnection.cpp: Added
pending method to establish if ops are in the queue. Switched send()
method so we only send ops. Add setting of serialno of sent
ops, starting with an offset of 512.
* client/CharacterClient.h: Removed unused member, opFound.
* client/CharacterClient.cpp: Debugged sendAndWait() method.
Al Riddoch <alriddoch@zepler.org>
2001-08-16 17:39:42 +00:00
|
|
|
} else if ((strcmp(key, "parent") == 0) && (PyString_Check(val))) {
|
2003-05-04 18:31:38 +00:00
|
|
|
omap["loc"] = PyString_AsString(val);
|
* tools/cycmd.cpp: Ensure that login op is flushed after it is sent.
* server/Player.cpp: Arg order of std::string.compare() is
incompatable between recent libstdc++ versions. Switch
back to old version, still in most common use.
* rulesets/Thing.cpp: Set refno on ops handled in game.
* rulesets/Python_API.cpp: Modify Entity() python constructor
so that commonly used attributes from old atlas are translated
to their modern equivalents.
* rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp: Differentiate
between previously identical error messages in several places.
* rulesets/Py_Object.cpp: Rework conversion of python dict to
Atlas map to be more efficient and clean.
* rulesets/Py_Location.cpp: Rework setting of vector parts of
location so that it can accept vectors from python in more
formats, including lists and tuples.
* rulesets/Creator.h, rulesets/Character.h, common/BaseEntity.h:
Re-order virtual methods declarations to fit a convention.
* common/stringstream.h: Hardcode use of local stringstream class,
as the version provided with older libstdc++ seems to be broken.
* common/database.cpp: Use the common header to pick the right
stringstream implementation.
* common/BaseWorld.cpp, server/Persistance.cpp: Removed unused
stringstream include.
* rulesets/Creator.cpp: Added extra debug output.
* client/define_world.h, client/define_world.cpp, client/CommClient.h:
Use CreatorClient to store Creators mind, instead of BaseMind.
* client/client.cpp,
client/ObserverClient.h, client/ObserverClient.cpp,
client/CreatorClient.h, client/CommClient.h, client/CommClient.cpp:
Modify method names to fit capitalisation conventions.
* client/CreatorClient.cpp: Implement creation of in-game entities,
using creator entity.
* client/CommClient.cpp: Added correct client side monitoring of
creator entity.
* client/ClientConnection.h, client/ClientConnection.cpp: Added
pending method to establish if ops are in the queue. Switched send()
method so we only send ops. Add setting of serialno of sent
ops, starting with an offset of 512.
* client/CharacterClient.h: Removed unused member, opFound.
* client/CharacterClient.cpp: Debugged sendAndWait() method.
Al Riddoch <alriddoch@zepler.org>
2001-08-16 17:39:42 +00:00
|
|
|
} else if ((strcmp(key, "type") == 0) && (PyString_Check(val))) {
|
2003-03-22 Al Riddoch <alriddoch@zepler.org>
* client/CommClient.cpp, client/CreatorClient.cpp,
client/ObserverClient.cpp, client/Py_CreatorClient.cpp,
common/BaseEntity.cpp, common/BaseEntity.h,
common/types.h, rulesets/Area.cpp, rulesets/BaseMind.cpp,
rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/MemMap.cpp, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp, server/CommClient.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp,
server/Persistance.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/WorldRouter.cpp:
Switch to using Element as name for Atlas::Message::Object,
to avoid name clashes on Object, and bring into line with
the way Atlas-C++ will be.
2003-03-23 00:55:09 +00:00
|
|
|
omap["parents"] = Element::ListType(1,std::string(PyString_AsString(val)));
|
2000-12-01 00:13:39 +00:00
|
|
|
} else {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
Element val_obj = PyObject_asMessageElement(val);
|
2003-08-07 23:03:26 +00:00
|
|
|
if (val_obj.getType() == Element::TYPE_NONE) {
|
2000-12-03 14:23:26 +00:00
|
|
|
fprintf(stderr, "Could not handle %s value in Entity()", key);
|
2000-12-01 00:13:39 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Argument type error to Entity()");
|
2000-12-11 13:06:12 +00:00
|
|
|
Py_DECREF(keys);
|
|
|
|
|
Py_DECREF(vals);
|
2000-12-01 00:13:39 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
omap[key] = val_obj;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-12-11 13:06:12 +00:00
|
|
|
Py_DECREF(keys);
|
|
|
|
|
Py_DECREF(vals);
|
2000-12-30 23:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
o = newPyMessageElement();
|
2000-12-30 23:16:57 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-03-22 Al Riddoch <alriddoch@zepler.org>
* client/CommClient.cpp, client/CreatorClient.cpp,
client/ObserverClient.cpp, client/Py_CreatorClient.cpp,
common/BaseEntity.cpp, common/BaseEntity.h,
common/types.h, rulesets/Area.cpp, rulesets/BaseMind.cpp,
rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/MemMap.cpp, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp, server/CommClient.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp,
server/Persistance.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/WorldRouter.cpp:
Switch to using Element as name for Atlas::Message::Object,
to avoid name clashes on Object, and bring into line with
the way Atlas-C++ will be.
2003-03-23 00:55:09 +00:00
|
|
|
o->m_obj = new Element(omap);
|
2000-12-30 23:16:57 +00:00
|
|
|
return (PyObject *)o;
|
2000-12-01 00:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
2000-11-17 00:18:32 +00:00
|
|
|
static PyObject * cppthing_new(PyObject * self, PyObject * args)
|
2000-11-16 16:35:03 +00:00
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyEntity *o;
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "")) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
o = newPyEntity();
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)o;
|
2000-11-16 16:35:03 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-22 Al Riddoch <alriddoch@zepler.org>
* client/CommClient.cpp, client/CreatorClient.cpp,
client/ObserverClient.cpp, client/Py_CreatorClient.cpp,
common/BaseEntity.cpp, common/BaseEntity.h,
common/types.h, rulesets/Area.cpp, rulesets/BaseMind.cpp,
rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/MemMap.cpp, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp, server/CommClient.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp,
server/Persistance.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/WorldRouter.cpp:
Switch to using Element as name for Atlas::Message::Object,
to avoid name clashes on Object, and bring into line with
the way Atlas-C++ will be.
2003-03-23 00:55:09 +00:00
|
|
|
static inline void addToArgs(Element::ListType & args, PyObject * ent)
|
2000-12-03 23:17:52 +00:00
|
|
|
{
|
|
|
|
|
if (ent == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
if (PyMessageElement_Check(ent)) {
|
|
|
|
|
PyMessageElement * obj = (PyMessageElement*)ent;
|
2000-12-03 23:17:52 +00:00
|
|
|
if (obj->m_obj == NULL) {
|
|
|
|
|
fprintf(stderr, "Invalid object in Operation arguments\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-03-22 Al Riddoch <alriddoch@zepler.org>
* client/CommClient.cpp, client/CreatorClient.cpp,
client/ObserverClient.cpp, client/Py_CreatorClient.cpp,
common/BaseEntity.cpp, common/BaseEntity.h,
common/types.h, rulesets/Area.cpp, rulesets/BaseMind.cpp,
rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/MemMap.cpp, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp, server/CommClient.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp,
server/Persistance.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/WorldRouter.cpp:
Switch to using Element as name for Atlas::Message::Object,
to avoid name clashes on Object, and bring into line with
the way Atlas-C++ will be.
2003-03-23 00:55:09 +00:00
|
|
|
Element o(*obj->m_obj);
|
2003-08-07 23:03:26 +00:00
|
|
|
if (o.isMap() && (obj->Object_attr != NULL)) {
|
|
|
|
|
Element::MapType & ent = o.asMap();
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
Element::MapType ent2 = PyDictObject_asElementMap(obj->Object_attr);
|
2003-03-22 Al Riddoch <alriddoch@zepler.org>
* client/CommClient.cpp, client/CreatorClient.cpp,
client/ObserverClient.cpp, client/Py_CreatorClient.cpp,
common/BaseEntity.cpp, common/BaseEntity.h,
common/types.h, rulesets/Area.cpp, rulesets/BaseMind.cpp,
rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/MemMap.cpp, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp, server/CommClient.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp,
server/Persistance.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/WorldRouter.cpp:
Switch to using Element as name for Atlas::Message::Object,
to avoid name clashes on Object, and bring into line with
the way Atlas-C++ will be.
2003-03-23 00:55:09 +00:00
|
|
|
Element::MapType::const_iterator I = ent2.begin();
|
2001-05-20 19:02:41 +00:00
|
|
|
for(; I != ent2.end(); I++) {
|
|
|
|
|
if (ent.find(I->first) != ent.end()) {
|
|
|
|
|
ent[I->first] = I->second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
args.push_back(o);
|
2000-12-16 20:28:06 +00:00
|
|
|
} else if (PyOperation_Check(ent)) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyOperation * op = (PyOperation*)ent;
|
2000-12-14 12:03:05 +00:00
|
|
|
if (op->operation == NULL) {
|
|
|
|
|
fprintf(stderr, "Invalid operation in Operation arguments\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-08-07 23:03:26 +00:00
|
|
|
args.push_back(op->operation->asObject());
|
2000-12-03 23:17:52 +00:00
|
|
|
} else {
|
|
|
|
|
fprintf(stderr, "Non-entity passed as arg to Operation()\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-21 19:24:29 +00:00
|
|
|
static PyObject * operation_new(PyObject * self, PyObject * args, PyObject * kwds)
|
2000-11-14 15:52:10 +00:00
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyOperation * op;
|
2000-11-21 19:24:29 +00:00
|
|
|
|
|
|
|
|
char * type;
|
|
|
|
|
PyObject * arg1 = NULL;
|
|
|
|
|
PyObject * arg2 = NULL;
|
|
|
|
|
PyObject * arg3 = NULL;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s|OOO", &type, &arg1, &arg2, &arg3)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
op = newPyOperation();
|
2000-11-21 19:24:29 +00:00
|
|
|
if (op == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-11-26 19:58:36 +00:00
|
|
|
if (strcmp(type, "tick") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Tick();
|
2000-12-14 12:03:05 +00:00
|
|
|
} else if (strcmp(type, "sight") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Sight();
|
2000-12-14 12:03:05 +00:00
|
|
|
} else if (strcmp(type, "set") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Set();
|
2002-07-26 16:47:39 +00:00
|
|
|
} else if (strcmp(type, "burn") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Burn();
|
2001-05-06 23:51:37 +00:00
|
|
|
} else if (strcmp(type, "action") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Action();
|
2000-12-30 23:16:57 +00:00
|
|
|
} else if (strcmp(type, "chop") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Chop();
|
2000-12-30 23:16:57 +00:00
|
|
|
} else if (strcmp(type, "cut") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Cut();
|
2000-11-26 19:58:36 +00:00
|
|
|
} else if (strcmp(type, "create") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Create();
|
2000-11-26 19:58:36 +00:00
|
|
|
} else if (strcmp(type, "setup") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Setup();
|
2000-11-26 19:58:36 +00:00
|
|
|
} else if (strcmp(type, "look") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Look();
|
2000-11-26 19:58:36 +00:00
|
|
|
} else if (strcmp(type, "move") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Move();
|
2000-11-26 19:58:36 +00:00
|
|
|
} else if (strcmp(type, "talk") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Talk();
|
2000-12-30 23:16:57 +00:00
|
|
|
} else if (strcmp(type, "touch") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Touch();
|
2000-12-30 23:16:57 +00:00
|
|
|
} else if (strcmp(type, "eat") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Eat();
|
2000-12-30 23:16:57 +00:00
|
|
|
} else if (strcmp(type, "nourish") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Nourish();
|
2001-05-03 22:04:43 +00:00
|
|
|
} else if (strcmp(type, "info") == 0) {
|
2004-01-22 03:03:07 +00:00
|
|
|
op->operation = new Info();
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
} else if (strcmp(type, "thought") == 0 ||
|
|
|
|
|
strcmp(type, "goal_info") == 0) {
|
2000-12-14 12:03:05 +00:00
|
|
|
Py_DECREF(op);
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
2000-11-21 19:24:29 +00:00
|
|
|
} else {
|
2004-01-22 03:03:07 +00:00
|
|
|
// FIXME use generic, once generic is fixed again.
|
|
|
|
|
op->operation = new RootOperation();
|
|
|
|
|
op->operation->setParents(Element::ListType(1, type));
|
* tools/cydbload.cpp: Added parameter handling so any file can
be loaded into the database.
* tools/cycmd.cpp: Cleaned up usage and help functions.
* tools/cyisoload.cpp: Cleaned up usage(), and made sure build
completes okay if libraries are missing, and missing
functionality is reported to the user.
* server/server.cpp: Added config options that specifies that
the contents of the db should loaded on server startup. Cleaned
up some debug code.
* server/WorldTime.cpp, server/WorldRouter.cpp,
server/Connection.cpp, rulesets/Structure.h,
rulesets/Python_API.cpp, rulesets/Py_WorldTime.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp,
physics/Vector3D.h, common/persistance.cpp,
common/database.h, common/database.cpp: Removed output either
to debug mode, or removed altogether.
* common/BaseEntity.h, common/BaseEntity.cpp: Removed redundant header
includes.
* server/ServerRouting.cpp, common/persistance.h,
common/persistance.cpp: Modified admin account function names it
fit convention.
* module/Location.h: Fixed collision detection so that entities
with velocity set to 0 still get checked.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/Character.cpp,
rulesets/BaseMind.cpp, rulesets/Creator.cpp,
rulesets/ExternalMind.cpp, rulesets/Food.cpp, rulesets/MemMap.cpp,
rulesets/Movement.cpp, rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Location.cpp, rulesets/Py_*.cpp, rulesets/World.cpp:
Removed unnecessary #includes.
Al Riddoch <alriddoch@zepler.org>
2001-06-04 11:22:27 +00:00
|
|
|
// fprintf(stderr, "NOTICE: Python creating a custom %s op\n", type);
|
2004-01-22 03:03:07 +00:00
|
|
|
//*op->operation = Root;
|
2001-05-22 17:59:43 +00:00
|
|
|
// Py_DECREF(op);
|
|
|
|
|
// Py_INCREF(Py_None);
|
|
|
|
|
// return Py_None;
|
2000-11-21 19:24:29 +00:00
|
|
|
}
|
2000-12-06 18:21:35 +00:00
|
|
|
op->own = 1;
|
2000-11-21 19:24:29 +00:00
|
|
|
if (PyMapping_HasKeyString(kwds, "to")) {
|
2001-10-09 14:03:12 +00:00
|
|
|
PyObject * to = PyMapping_GetItemString(kwds, "to");
|
2000-12-03 16:56:10 +00:00
|
|
|
PyObject * to_id;
|
2000-12-14 12:03:05 +00:00
|
|
|
if (PyString_Check(to)) {
|
|
|
|
|
to_id = to;
|
|
|
|
|
} else if ((to_id = PyObject_GetAttrString(to, "id")) == NULL) {
|
2000-12-03 16:56:10 +00:00
|
|
|
fprintf(stderr, "To was not really an entity, as it had no id\n");
|
2001-10-09 14:03:12 +00:00
|
|
|
Py_DECREF(to);
|
2000-12-03 16:56:10 +00:00
|
|
|
return NULL;
|
2001-10-09 14:03:12 +00:00
|
|
|
} else {
|
|
|
|
|
// to_id == to.getattr("id") and to is finished with
|
|
|
|
|
Py_DECREF(to);
|
2000-12-03 16:56:10 +00:00
|
|
|
}
|
|
|
|
|
if (!PyString_Check(to_id)) {
|
|
|
|
|
fprintf(stderr, "To id is not a string\n");
|
2001-10-09 14:03:12 +00:00
|
|
|
Py_DECREF(to_id);
|
2000-12-03 16:56:10 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-08-07 23:03:26 +00:00
|
|
|
op->operation->setTo(PyString_AsString(to_id));
|
2001-10-09 14:03:12 +00:00
|
|
|
Py_DECREF(to_id);
|
2000-11-21 19:24:29 +00:00
|
|
|
}
|
|
|
|
|
if (PyMapping_HasKeyString(kwds, "from_")) {
|
2001-10-09 14:03:12 +00:00
|
|
|
PyObject * from = PyMapping_GetItemString(kwds, "from_");
|
2000-12-03 16:56:10 +00:00
|
|
|
PyObject * from_id;
|
2000-12-14 12:03:05 +00:00
|
|
|
if (PyString_Check(from)) {
|
|
|
|
|
from_id = from;
|
|
|
|
|
} else if ((from_id = PyObject_GetAttrString(from, "id")) == NULL) {
|
2000-12-03 16:56:10 +00:00
|
|
|
fprintf(stderr, "From was not really an entity, as it had no id\n");
|
2001-10-09 14:03:12 +00:00
|
|
|
Py_DECREF(from);
|
2000-12-03 16:56:10 +00:00
|
|
|
return NULL;
|
2001-10-09 14:03:12 +00:00
|
|
|
} else {
|
|
|
|
|
Py_DECREF(from);
|
2000-12-03 16:56:10 +00:00
|
|
|
}
|
|
|
|
|
if (!PyString_Check(from_id)) {
|
|
|
|
|
fprintf(stderr, "From id is not a string\n");
|
2001-10-09 14:03:12 +00:00
|
|
|
Py_DECREF(from_id);
|
2000-12-03 16:56:10 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-08-07 23:03:26 +00:00
|
|
|
op->operation->setFrom(PyString_AsString(from_id));
|
2001-10-09 14:03:12 +00:00
|
|
|
Py_DECREF(from_id);
|
2000-11-21 19:24:29 +00:00
|
|
|
}
|
2003-03-22 Al Riddoch <alriddoch@zepler.org>
* client/CommClient.cpp, client/CreatorClient.cpp,
client/ObserverClient.cpp, client/Py_CreatorClient.cpp,
common/BaseEntity.cpp, common/BaseEntity.h,
common/types.h, rulesets/Area.cpp, rulesets/BaseMind.cpp,
rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/MemMap.cpp, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp, server/CommClient.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp,
server/Persistance.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/WorldRouter.cpp:
Switch to using Element as name for Atlas::Message::Object,
to avoid name clashes on Object, and bring into line with
the way Atlas-C++ will be.
2003-03-23 00:55:09 +00:00
|
|
|
Element::ListType args_list;
|
2000-12-03 23:17:52 +00:00
|
|
|
addToArgs(args_list, arg1);
|
|
|
|
|
addToArgs(args_list, arg2);
|
|
|
|
|
addToArgs(args_list, arg3);
|
2003-08-07 23:03:26 +00:00
|
|
|
op->operation->setArgs(args_list);
|
2000-11-21 19:24:29 +00:00
|
|
|
return (PyObject *)op;
|
2000-11-14 15:52:10 +00:00
|
|
|
}
|
|
|
|
|
|
2000-11-30 12:51:59 +00:00
|
|
|
static PyObject * set_kw(PyObject * meth_self, PyObject * args)
|
2000-11-24 01:41:06 +00:00
|
|
|
{
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
// Takes self, kw, name, default = None
|
2000-11-30 12:51:59 +00:00
|
|
|
PyObject * self;
|
|
|
|
|
PyObject * kw;
|
|
|
|
|
char * name;
|
|
|
|
|
PyObject * def = NULL;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OOs|O", &self, &kw, &name, &def)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyObject * attr = PyObject_GetAttrString(self, "attributes");
|
|
|
|
|
if (attr == NULL) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyErr_SetString(PyExc_AttributeError, "SET_KW: No attributes list");
|
2000-11-30 12:51:59 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
int i = PyList_Size(attr);
|
|
|
|
|
char * entry;
|
|
|
|
|
PyObject * item;
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
for(i = 0; i < PyList_Size(attr); i++) {
|
2000-11-30 12:51:59 +00:00
|
|
|
item = PyList_GetItem(attr, i);
|
|
|
|
|
if (!PyString_Check(item)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
entry = PyString_AsString(item);
|
|
|
|
|
if (strcmp(entry, name) == 0) {
|
|
|
|
|
goto list_contains_it;
|
|
|
|
|
}
|
|
|
|
|
// Should I free entry at this point?
|
|
|
|
|
}
|
2000-12-03 14:23:26 +00:00
|
|
|
{
|
|
|
|
|
PyObject * namestr = PyString_FromString(name);
|
|
|
|
|
PyList_Append(attr, namestr);
|
|
|
|
|
Py_DECREF(namestr);
|
|
|
|
|
}
|
2000-11-30 12:51:59 +00:00
|
|
|
list_contains_it:
|
2001-10-09 14:03:12 +00:00
|
|
|
Py_DECREF(attr);
|
2000-11-30 12:51:59 +00:00
|
|
|
if (!PyDict_Check(kw)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "SET_KW: kw not a dict");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyObject * value = NULL;
|
2001-10-09 14:03:12 +00:00
|
|
|
bool decvalue = false;
|
2000-11-30 12:51:59 +00:00
|
|
|
if ((value = PyDict_GetItemString(kw, name)) == NULL) {
|
|
|
|
|
PyObject * copy = PyDict_GetItemString(kw, "copy");
|
|
|
|
|
if ((copy != NULL) && (PyObject_HasAttrString(copy, name))) {
|
|
|
|
|
value = PyObject_GetAttrString(copy, name);
|
2001-10-09 14:03:12 +00:00
|
|
|
decvalue = true;
|
2000-11-30 12:51:59 +00:00
|
|
|
} else {
|
|
|
|
|
value = def;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (value == NULL) {
|
|
|
|
|
Py_INCREF(Py_None);
|
2000-12-03 14:23:26 +00:00
|
|
|
value = Py_None;
|
2000-11-30 12:51:59 +00:00
|
|
|
}
|
|
|
|
|
PyObject_SetAttrString(self, name, value);
|
2001-10-09 14:03:12 +00:00
|
|
|
|
|
|
|
|
if (decvalue) { Py_DECREF(value); }
|
2000-11-30 12:51:59 +00:00
|
|
|
|
2000-12-03 16:56:10 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
2000-11-24 01:41:06 +00:00
|
|
|
}
|
|
|
|
|
|
2000-11-19 00:02:29 +00:00
|
|
|
static PyMethodDef atlas_methods[] = {
|
2003-07-18 23:05:26 +00:00
|
|
|
/* {"system", spam_system, METH_VARARGS}, */
|
|
|
|
|
{"Operation", (PyCFunction)operation_new, METH_VARARGS|METH_KEYWORDS},
|
|
|
|
|
{"isLocation", is_location, METH_VARARGS},
|
|
|
|
|
{"Location", location_new, METH_VARARGS},
|
|
|
|
|
{"Object", object_new, METH_VARARGS},
|
|
|
|
|
{"Entity", (PyCFunction)entity_new, METH_VARARGS|METH_KEYWORDS},
|
|
|
|
|
{"Message", oplist_new, METH_VARARGS},
|
|
|
|
|
{"cppEntity", cppthing_new, METH_VARARGS},
|
|
|
|
|
{NULL, NULL} /* Sentinel */
|
2000-11-14 15:52:10 +00:00
|
|
|
};
|
|
|
|
|
|
2001-02-26 14:41:10 +00:00
|
|
|
static PyMethodDef vector3d_methods[] = {
|
2003-07-18 23:05:26 +00:00
|
|
|
{"Vector3D", vector3d_new, METH_VARARGS},
|
|
|
|
|
{NULL, NULL} /* Sentinel */
|
2000-11-20 20:28:08 +00:00
|
|
|
};
|
|
|
|
|
|
2002-03-03 00:48:28 +00:00
|
|
|
static PyMethodDef quaternion_methods[] = {
|
2003-07-18 23:05:26 +00:00
|
|
|
{"Quaternion", quaternion_new, METH_VARARGS},
|
|
|
|
|
{NULL, NULL} /* Sentinel */
|
2002-03-03 00:48:28 +00:00
|
|
|
};
|
|
|
|
|
|
2000-11-20 20:28:08 +00:00
|
|
|
static PyMethodDef server_methods[] = {
|
2003-07-18 23:05:26 +00:00
|
|
|
{"WorldTime", worldtime_new, METH_VARARGS},
|
|
|
|
|
{NULL, NULL} /* Sentinel */
|
2000-11-20 20:28:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static PyMethodDef common_methods[] = {
|
2003-07-18 23:05:26 +00:00
|
|
|
//{"null", null_new, METH_VARARGS},
|
|
|
|
|
{NULL, NULL} /* Sentinel */
|
2000-11-20 20:28:08 +00:00
|
|
|
};
|
|
|
|
|
|
2000-11-24 01:41:06 +00:00
|
|
|
static PyMethodDef misc_methods[] = {
|
2003-07-18 23:05:26 +00:00
|
|
|
{"set_kw", set_kw, METH_VARARGS},
|
|
|
|
|
{NULL, NULL} /* Sentinel */
|
2000-11-24 01:41:06 +00:00
|
|
|
};
|
|
|
|
|
|
2000-11-14 15:52:10 +00:00
|
|
|
void init_python_api()
|
|
|
|
|
{
|
2001-08-19 18:37:38 +00:00
|
|
|
std::string importCmd("ruleset_import_hooks.install([");
|
2002-03-08 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp, common/globals.h, rulesets/Python_API.cpp,
tools/cyloadrules.cpp: Make rulesets list a vector for
efficiency.
* common/utility.cpp, common/utility.h: New function to create
an operation from a message Object.
* rulesets/BaseMind.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/MemMap_methods.h, rulesets/Py_Map.cpp: Clean up
mind/memory interface, eliminating copies, unecessary allocations,
and passing more apropriate types around.
* server/CommClient.cpp, rulesets/Py_Operation.cpp: Make use of
operation converter where it is apropriate.
2002-03-08 11:52:27 +00:00
|
|
|
std::vector<std::string>::const_iterator I;
|
2000-12-13 12:10:48 +00:00
|
|
|
for(I = rulesets.begin(); I != rulesets.end(); I++) {
|
2001-08-19 18:37:38 +00:00
|
|
|
if (I != rulesets.begin()) {
|
|
|
|
|
importCmd = importCmd + ",";
|
|
|
|
|
}
|
|
|
|
|
importCmd = importCmd + "\"" + *I + "\"";
|
2000-12-13 12:10:48 +00:00
|
|
|
}
|
2001-08-19 18:37:38 +00:00
|
|
|
importCmd = importCmd + "])\n";
|
|
|
|
|
|
2000-12-13 12:10:48 +00:00
|
|
|
Py_Initialize();
|
2000-11-14 15:52:10 +00:00
|
|
|
|
2003-08-30 11:41:58 +00:00
|
|
|
PyObject * sys_name = PyString_FromString("sys");
|
|
|
|
|
PyObject * sys_module = PyImport_Import(sys_name);
|
|
|
|
|
Py_DECREF(sys_name);
|
2004-06-15 18:06:59 +00:00
|
|
|
|
|
|
|
|
if (sys_module == 0) {
|
|
|
|
|
log(CRITICAL, "Python could not import sys module");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyObject * logger = (PyObject*)PyObject_NEW(PyLogger, &PyLogger_Type);
|
|
|
|
|
PyObject_SetAttrString(sys_module, "stdout", logger);
|
|
|
|
|
Py_DECREF(logger);
|
|
|
|
|
PyObject * errorLogger = (PyObject*)PyObject_NEW(PyLogger,
|
|
|
|
|
&PyErrorLogger_Type);
|
|
|
|
|
PyObject_SetAttrString(sys_module, "stderr", errorLogger);
|
|
|
|
|
Py_DECREF(errorLogger);
|
|
|
|
|
|
|
|
|
|
PyObject * sys_path = PyObject_GetAttrString(sys_module, "path");
|
|
|
|
|
if (sys_path != 0) {
|
|
|
|
|
if (PyList_Check(sys_path)) {
|
|
|
|
|
for(I = rulesets.begin(); I != rulesets.end(); I++) {
|
|
|
|
|
std::string p = share_directory + "/cyphesis/rulesets/" + *I;
|
|
|
|
|
PyObject * path = PyString_FromString(p.c_str());
|
|
|
|
|
PyList_Append(sys_path, path);
|
|
|
|
|
Py_DECREF(path);
|
2004-05-16 03:51:28 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2004-06-15 18:06:59 +00:00
|
|
|
log(CRITICAL, "Python sys.path is not a list");
|
2004-05-16 03:51:28 +00:00
|
|
|
}
|
2003-08-30 11:41:58 +00:00
|
|
|
} else {
|
2004-06-15 18:06:59 +00:00
|
|
|
log(CRITICAL, "Python could not import sys.path");
|
2003-08-30 11:41:58 +00:00
|
|
|
}
|
2004-06-15 18:06:59 +00:00
|
|
|
Py_DECREF(sys_module);
|
2003-08-30 11:41:58 +00:00
|
|
|
|
2000-12-13 12:10:48 +00:00
|
|
|
if (Py_InitModule("atlas", atlas_methods) == NULL) {
|
|
|
|
|
fprintf(stderr, "Failed to Create atlas module\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2000-11-20 20:28:08 +00:00
|
|
|
|
2001-02-26 14:41:10 +00:00
|
|
|
if (Py_InitModule("Vector3D", vector3d_methods) == NULL) {
|
2000-12-13 12:10:48 +00:00
|
|
|
fprintf(stderr, "Failed to Create Vector3D module\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2000-11-20 20:28:08 +00:00
|
|
|
|
2002-03-03 00:48:28 +00:00
|
|
|
if (Py_InitModule("Quaternion", quaternion_methods) == NULL) {
|
|
|
|
|
fprintf(stderr, "Failed to Create Quaternion module\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-08 23:21:18 +00:00
|
|
|
if (Py_InitModule("misc", misc_methods) == NULL) {
|
2000-12-13 12:10:48 +00:00
|
|
|
fprintf(stderr, "Failed to Create misc module\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2000-11-24 01:41:06 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
PyObject * common = Py_InitModule("common", common_methods);
|
|
|
|
|
if (common == NULL) {
|
2000-12-13 12:10:48 +00:00
|
|
|
fprintf(stderr, "Failed to Create common module\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-09-14 18:46:34 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
PyObject * common_dict = PyModule_GetDict(common);
|
2002-09-14 18:46:34 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
/// Create the common.log module
|
|
|
|
|
PyObject * log = PyModule_New("log");
|
|
|
|
|
PyDict_SetItemString(common_dict, "log", log);
|
2002-09-14 18:46:34 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
PyObject * debug = (PyObject*)PyObject_NEW(FunctionObject, &log_debug_type);
|
2000-12-13 12:10:48 +00:00
|
|
|
PyObject_SetAttrString(log, "debug", debug);
|
2001-10-08 23:21:18 +00:00
|
|
|
Py_DECREF(debug);
|
|
|
|
|
Py_DECREF(log);
|
2003-07-22 15:06:31 +00:00
|
|
|
|
2001-10-08 23:21:18 +00:00
|
|
|
PyObject * o;
|
2002-09-14 18:46:34 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
/// Create the common.const module
|
|
|
|
|
PyObject * _const = PyModule_New("const");
|
|
|
|
|
PyDict_SetItemString(common_dict, "const", _const);
|
|
|
|
|
|
2001-10-08 23:21:18 +00:00
|
|
|
o = PyInt_FromLong(0);
|
|
|
|
|
PyObject_SetAttrString(_const, "server_python", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
o = PyInt_FromLong(consts::debug_level);
|
|
|
|
|
PyObject_SetAttrString(_const, "debug_level", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
o = PyInt_FromLong(consts::debug_thinking);
|
|
|
|
|
PyObject_SetAttrString(_const, "debug_thinking", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
|
|
|
|
|
o = PyFloat_FromDouble(consts::time_multiplier);
|
|
|
|
|
PyObject_SetAttrString(_const, "time_multiplier", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
o = PyFloat_FromDouble(consts::base_velocity_coefficient);
|
|
|
|
|
PyObject_SetAttrString(_const, "base_velocity_coefficient", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
o = PyFloat_FromDouble(consts::base_velocity);
|
|
|
|
|
PyObject_SetAttrString(_const, "base_velocity", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
|
|
|
|
|
o = PyFloat_FromDouble(consts::basic_tick);
|
|
|
|
|
PyObject_SetAttrString(_const, "basic_tick", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
|
|
|
|
|
o = PyFloat_FromDouble(consts::sight_range);
|
|
|
|
|
PyObject_SetAttrString(_const, "sight_range", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
o = PyFloat_FromDouble(consts::hearing_range);
|
|
|
|
|
PyObject_SetAttrString(_const, "hearing_range", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
o = PyInt_FromLong(consts::enable_ranges);
|
|
|
|
|
PyObject_SetAttrString(_const, "enable_ranges", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
Py_DECREF(_const);
|
2000-12-13 12:10:48 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
/// Create the common.globals module
|
|
|
|
|
PyObject * globals = PyModule_New("globals");
|
|
|
|
|
PyDict_SetItemString(common_dict, "globals", globals);
|
2002-09-14 18:46:34 +00:00
|
|
|
o = PyString_FromString(share_directory.c_str());
|
|
|
|
|
PyObject_SetAttrString(globals, "share_directory", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
Py_DECREF(globals);
|
|
|
|
|
|
2000-12-13 12:10:48 +00:00
|
|
|
PyObject * server;
|
|
|
|
|
if ((server = Py_InitModule("server", server_methods)) == NULL) {
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
fprintf(stderr, "Failed to Create server module\n");
|
2000-12-13 12:10:48 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2003-07-22 15:06:31 +00:00
|
|
|
PyObject * server_dict = PyModule_GetDict(server);
|
2000-12-13 12:10:48 +00:00
|
|
|
PyObject * dictlist = PyModule_New("dictlist");
|
|
|
|
|
PyObject * add_value = (PyObject *)PyObject_NEW(FunctionObject, &dictlist_add_value_type);
|
|
|
|
|
PyObject_SetAttrString(dictlist, "add_value", add_value);
|
2001-10-08 23:21:18 +00:00
|
|
|
Py_DECREF(add_value);
|
2000-12-13 12:10:48 +00:00
|
|
|
PyObject * remove_value = (PyObject *)PyObject_NEW(FunctionObject, &dictlist_remove_value_type);
|
|
|
|
|
PyObject_SetAttrString(dictlist, "remove_value", remove_value);
|
2001-10-08 23:21:18 +00:00
|
|
|
Py_DECREF(remove_value);
|
2003-07-22 15:06:31 +00:00
|
|
|
PyDict_SetItemString(server_dict, "dictlist", dictlist);
|
2001-10-08 23:21:18 +00:00
|
|
|
Py_DECREF(dictlist);
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp,
rulesets/Py_Map.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h,
rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h,
rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.cpp, rulesets/Py_Vector3D.h,
rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
|
2002-09-14 18:46:34 +00:00
|
|
|
PyRun_SimpleString("from hooks import ruleset_import_hooks\n");
|
|
|
|
|
PyRun_SimpleString((char *)importCmd.c_str());
|
|
|
|
|
|
2004-06-15 18:06:59 +00:00
|
|
|
debug(std::cout << Py_GetPath() << std::endl << std::flush;);
|
2001-10-08 23:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void shutdown_python_api()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Py_Finalize();
|
2000-11-14 15:52:10 +00:00
|
|
|
}
|