Commit graph

127 commits

Author SHA1 Message Date
Elias Pschernig
0025ec1d0f If the python AI can't find the wesnoth install,
...fall back to the current directory.
2008-05-14 16:30:16 +00:00
Mark de Wever
7acbc98933 Fix some compiler warnings about unused variables. 2008-05-09 16:25:26 +00:00
Elias Pschernig
ff1229fadc Pierre Bourdon (delroth) added gold_per_village and is_border to the Python AI. 2008-04-30 16:47:15 +00:00
Elias Pschernig
cf449290cb Python's stderr is redirected to a file pyerr.txt...
...made the python script execute even if pyerr.txt cannot be written to.
2008-04-28 14:53:26 +00:00
Jörg Hinrichs
7e491a85c4 Cleaning up the unit_type stuff, to provide a much better encapsulation:
- get rid of redundant functionality

- make the unit_type_data interface more easily accessible

- reduce the public interface of unit_type_data

- rename unit_type_factory to unit_type_map_wrapper

- add a whole lot of "const"
2008-04-01 21:51:29 +00:00
Elias Pschernig
96f01a0cea Made the python AI compile again after the unit_type_data::instance() change,
...and also added the wesnoth.log() function to the Python AI which I
still had uncommitted in my local copy for some reason.
2008-03-30 15:39:05 +00:00
Eric S. Raymond
03a5505e4e Eliminate wesconfig.h includes where they are no longer needed.
Fix a minor Windows porting bug due to a typo (WIN32 -> _WIN32).

Make game_config.o explicitly dependent on the verion stamp file in scons.
2008-03-26 10:41:50 +00:00
Eric S. Raymond
d648270ebb Re-introduce wesconfig.h include to some files...
...where it will be handy for the scons build.
2008-03-24 13:43:45 +00:00
Bruno Wolff III
e8a45d8e93 Semantic change.
I silenced a gcc 4.3 warning by adding parens around a shift. Based on what
I see in the code it looks like the parens really were needed and that
previously it was doing the wrong thing.
2008-03-19 16:45:50 +00:00
Eric S. Raymond
f6e4419d2f unit::underlying_description_ -> unit::underlying_id_ 2008-03-12 20:07:36 +00:00
Mark de Wever
001af46e6e Updated all headers to 2008. 2008-02-16 08:47:16 +00:00
Ali El Gariani
3588d69fb5 Small optimization of the python wrapper for unit_type.attacks()
But we still don't cache it. Seems safe to do, will try after tagging.
2008-02-11 09:26:19 +00:00
Elias Pschernig
8609817b3b Applied patch patch #971:
Tommy fixed two bugs in the Python AI: There was a possible crash if
Python AIs would somehow try to attack non-existing units (or attack
with a non existing unit?), and unit.name used the C++ ::name() method
but ::underlying_description() (the patch had ::description() but this
seems the right one) is the WML description tag which should be
returned according to documentation.
2008-02-07 22:08:22 +00:00
Elias Pschernig
1e227a3d61 Applied patch #967 by Tommy <mesilliac>
which adds a function raise_user_interact to the Python AI, which can
fix Python AIs with a very long thinking period getting unresponsive,
and a function test_move, which adds the possibility to 'test' the
move of a unit without actually performing it.
2008-02-05 17:08:06 +00:00
Elias Pschernig
d1b7b257c6 Applied patch #962 by Tommy (yobbo):
Fixed missing unit.slowed and unit.max_movement properties in the Python AI.
2008-02-02 14:42:19 +00:00
Mark de Wever
9822e57712 Unclutter includes. 2007-12-22 16:04:59 +00:00
Mark de Wever
22377743f3 wassert -> assert 2007-12-10 18:15:20 +00:00
Elias Pschernig
6f1b87ddc8 Use new[]/delete[] instead of variable length C-style array. 2007-12-02 21:25:13 +00:00
Elias Pschernig
20291cc7a9 Really fixed ai_python.cpp. 2007-11-16 20:02:12 +00:00
Elias Pschernig
e017d6a9ef Trying to fix a problem where ai_python.cpp doesn't compile with python 2.5 2007-11-16 19:47:25 +00:00
Elias Pschernig
a8f2583432 Allow arbitrary python objects for set_variable and get_variable...
...in the python AI.
2007-11-16 18:21:08 +00:00
Elias Pschernig
6b08abbada Simplified whitelisting of python modules,
...and added information how to disable safe python
2007-11-16 16:07:45 +00:00
Elias Pschernig
2943296237 Fixed one giant memory leak in ai_python.cpp. 2007-11-12 21:19:29 +00:00
Hans Joachim Gurt
449d7e042b doxygen, comments 2007-09-21 21:40:25 +00:00
Elias Pschernig
c2580212d2 Fixed one million const warnings...
...triggered by a certain combination of gcc version and Python
headers version.
2007-09-21 14:48:07 +00:00
Mark de Wever
ea76140008 C-style cast cleanup. 2007-09-05 16:57:46 +00:00
Gunter Labes
ae9e10f260 codeclean run
set svn:eol-style to native where missing
2007-08-31 19:09:40 +00:00
Hans Joachim Gurt
f064e4ae2d doxygen, comments 2007-08-27 02:48:18 +00:00
Bruno Wolff III
ee3b870471 Restore unit_type::not_living()
so that the ai can guess whether or not recruits will have the not_living state.
2007-08-16 04:50:55 +00:00
Bruno Wolff III
a1da27a34f Set not_living based on the undead and mechanical traits...
...in a manner consistant with other trait definititions. Get rid of
not_living key from race. Still need to put back a way for AI to tell
if a unit_type is going to be not_living.
2007-08-15 15:03:56 +00:00
Mark de Wever
080eb69f60 Updated the headers to state GPL 2+ and a few changelog cleanups. 2007-08-15 13:41:56 +00:00
Mark de Wever
4bac696917 rename map.x() to map.w() and map.y() to map.h().
remove the duplicates named map.xsize() and map.ysize().
2007-08-09 16:37:08 +00:00
Mark de Wever
bb01934b85 A rather large update which updates the copyright info
* Wesnoth is distributed under the terms of the GPL version 2, made
  that more explicit

* updated the copyright range to 2007

* updated Dave's email adress
2007-07-21 07:28:04 +00:00
Elias Pschernig
28deba32c1 Added a team.targets() method to the Python AI, to query WML targets.
This allows writing e.g. an AI which just has all its units run
towards those targets and attack them.
2007-07-02 18:39:44 +00:00
Elias Pschernig
c6f9766d6e Made Python AI log to std::cerr...
...instead of the internal stderr, so errors can be seen under
Windows. And fixed a problem where game_config::path can be empty
under Windows, causing AIs to not work at all.
2007-04-22 18:43:02 +00:00
Elias Pschernig
2f6a73d7c7 Added support for querying poison special of attacks to the Python API.
(bug #8950)
2007-04-18 19:21:34 +00:00
Elias Pschernig
b0f00f6c6b Fixed bug #8802
- movement maps used by the Python AI are now adjusted after recruiting.
2007-03-28 17:36:05 +00:00
Patrick Parker
fe5e275cd3 apply patch by macias (allefant, please review) 2007-03-25 22:41:56 +00:00
Elias Pschernig
768744be94 Fixed querying of unit type abilities in the Python API,
thanks to MSchmahl for reporting.
2007-03-23 19:19:59 +00:00
Elias Pschernig
37ec6e8aaf More work on the safe python AIs:
- Using safe.py from the given SVN repository, which is much cleaner,
  no more notes or tests.

- Added a preprocessor, as a way to allow a limited import again.

- Made runtime docs work again, with a --python-api switch instead of
  the previous AI hack.
2007-03-21 15:24:48 +00:00
Elias Pschernig
a0bf9a7209 First step for restricted (and therefore safe) Python in trunk.
For script authors this means:

- no more exceptions (try..except)

- no more unsafe builtins (eval, file, type, ...)

- no more import (some whitelisted modules are auto-imported currently)

- no more access to internals (e.g. __dict__, __name__, ...)

The campaign server for now still doesn't allow .py scripts, but
likely this restriction can be removed.
2007-03-18 16:26:22 +00:00
Elias Pschernig
575b47de80 Python's unittype.name now uses id() instead of language_name().
(fixes bug #7632)
2006-11-05 21:34:51 +00:00
Elias Pschernig
afeb2e3188 Applied patch #614 by Mark de Wever (Mordante/SkeletonCrew):
- Python AI
   - Added various input validations
   - Set Python errors upon error
2006-10-03 21:13:31 +00:00
Elias Pschernig
289ab0db0e Applied patch #608 by Mark de Wever <mordante>:
Add wesnoth.get_version() to Python AI API.
2006-09-19 21:21:49 +00:00
Elias Pschernig
ae6c066d09 Simple addition for now to never execute unchecked Python files
downloaded from the campaign server:

- Only files ending in ".py" can be executed as Python AI.

- The campaign server will rename all *.py files to *.py.unchecked
  before sending.

- This means, Python files are not executed anymore without manually
  removing the .unchecked.

- If a campaign has a python="allowed" property on the CS, the
  renaming is not done (so someone with direct CS access could already
  mark trusted campaigns - a better interface might be needed though).
2006-09-16 11:31:53 +00:00
Elias Pschernig
b3396419a5 Fixed a small memory leak in module search path initialization...
...when running a python script.
2006-09-12 10:46:50 +00:00
Elias Pschernig
33a6f40711 Applied patch #600 by Mark de Wever <mordante>:
Add missing "unit.stoned" to Python API
2006-09-09 09:54:20 +00:00
Elias Pschernig
2d1e09d561 Applied patch #591 by Mark de Wever <mordante> (typo fix for python AI docs). 2006-09-03 10:32:28 +00:00
Elias Pschernig
df249a5082 fixed my previous commit 2006-09-02 17:55:26 +00:00
Elias Pschernig
db765347ca Updated Python-API documentation for find_path according to bug #6853. 2006-09-02 17:44:14 +00:00