From 8044c537b64b0bdfbaa076bba70d57e859e0094c Mon Sep 17 00:00:00 2001 From: Elias Pschernig Date: Tue, 19 Sep 2006 21:32:18 +0000 Subject: [PATCH] Applied patch #608 by Mark de Wever : Add wesnoth.get_version() to Python AI API. --- changelog | 4 ++++ src/ai_python.cpp | 12 +++++++++++- src/ai_python.hpp | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index d03df79bb1a..6fdaf4bbf4c 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +Version 1.1.11 (or 1.2.0?): + * Python AI + * there is now wesnoth.get_version() + Version 1.1.10: * campaigns: * Heir to the Throne diff --git a/src/ai_python.cpp b/src/ai_python.cpp index b85965867b1..7855276b120 100644 --- a/src/ai_python.cpp +++ b/src/ai_python.cpp @@ -23,6 +23,7 @@ #include "filesystem.hpp" #include "menu_events.hpp" #include "game_events.hpp" +#include "game_config.hpp" #include @@ -1586,6 +1587,13 @@ PyObject* python_ai::wrapper_get_variable(PyObject* /*self*/, PyObject* args) return Py_BuildValue("s", memory[variable].c_str()); } +PyObject* python_ai::wrapper_get_version(PyObject* /*self*/, PyObject* args) +{ + if (!PyArg_ParseTuple(args, "" )) + return NULL; + return Py_BuildValue("s", game_config::version.c_str()); +} + static PyMethodDef wesnoth_python_methods[] = { { "log_message", python_ai::wrapper_log_message, METH_VARARGS, "Parameters: string\n" @@ -1654,7 +1662,9 @@ static PyMethodDef wesnoth_python_methods[] = { "Returns: value\n" "Retrieves a persistent variable 'variable' from the AI, which has " "previously been set with set_variable."}, - { NULL, NULL, 0, NULL} + { "get_version", python_ai::wrapper_get_version, METH_VARARGS, + "Returns a string containing current Wesnoth version"}, + { NULL, NULL, 0, NULL} }; diff --git a/src/ai_python.hpp b/src/ai_python.hpp index 29c0fbf49be..6465f4b2588 100644 --- a/src/ai_python.hpp +++ b/src/ai_python.hpp @@ -49,6 +49,7 @@ public: static PyObject* wrapper_get_gamestatus(PyObject* self, PyObject* args); static PyObject* wrapper_set_variable(PyObject*, PyObject* args); static PyObject* wrapper_get_variable(PyObject*, PyObject* args); + static PyObject* wrapper_get_version(PyObject*, PyObject* args); static PyObject* unittype_advances_to( wesnoth_unittype* type, PyObject* args ); static PyObject* wrapper_team_recruits( wesnoth_team* team, PyObject* args );