diff --git a/src/python/method.h b/src/python/method.h index b56ddd6..52b490e 100644 --- a/src/python/method.h +++ b/src/python/method.h @@ -67,6 +67,12 @@ namespace python */ std::string name () const; + /** + * Return name of enclosing script. + * @return script name. + */ + std::string script () const { return Script->class_name(); } + /** * Execute the connected %method with the given arguments. * @param args a python tuple to be passed to the %method. diff --git a/src/python/python.cc b/src/python/python.cc index f97a63c..9bbfbb0 100644 --- a/src/python/python.cc +++ b/src/python/python.cc @@ -127,8 +127,8 @@ namespace python // copy remaining objects, if any for (u_int16 i = len; i < size; i++) { - PyObject *o = PyTuple_GET_ITEM (tuple, i - len); - Py_INCREF (o); + PyObject *o = PyTuple_GET_ITEM (tuple, i - len); + Py_XINCREF (o); PyTuple_SET_ITEM (new_tuple, i, o); } @@ -146,6 +146,11 @@ namespace python { switch (int type = in.next (&value)) { + case base::flat::T_CHAR: + { + PyTuple_SetItem (tuple, i, Py_None); + break; + } case base::flat::T_STRING: { // Stolen reference @@ -180,10 +185,12 @@ namespace python { // Borrowed reference PyObject *item = PyTuple_GetItem (tuple, i); + if (item == NULL) + out.put_char ("n", ' '); // Check for the type of this object // String? - if (PyString_Check (item)) + else if (PyString_Check (item)) out.put_string ("s", PyString_AsString (item)); // Integer? diff --git a/src/world/action.h b/src/world/action.h index aba181f..6052c01 100644 --- a/src/world/action.h +++ b/src/world/action.h @@ -75,6 +75,20 @@ namespace world * @param target the object acted on. */ void execute (world::character *actor, world::object *target); + + /** + * Get the method that implements the action. Might be + * NULL if the action is not initialized yet. + * + * @return the method that implements the action. + */ + python::method *get_method () const { return Action; } + + /** + * Get the arguments used to execute the action. + * @return the method arguments. + */ + PyObject *get_args () const { return Args; } #endif /** diff --git a/src/world/area.cc b/src/world/area.cc index 760f723..3e736b0 100644 --- a/src/world/area.cc +++ b/src/world/area.cc @@ -253,9 +253,7 @@ bool area::put_state (base::flat & file) const if (!data.Anonymous.empty()) { base::flat anonym; - j = data.Anonymous.begin(); - - for (; j != data.Anonymous.end(); j++) + for (j = data.Anonymous.begin(); j != data.Anonymous.end(); j++) { // save location action if ((*j)->has_action ()) @@ -309,10 +307,6 @@ bool area::put_state (base::flat & file) const file.put_flat ("states", record); - // reset - index = 0; - record.clear(); - // save the zones std::list ::const_iterator zone_i = Zones.begin(); base::flat zone_list;