Commit graph

248 commits

Author SHA1 Message Date
Celtic Minstrel
a824d88079 Lua API: Make end level data mutable 2016-07-18 20:59:49 -04:00
Celtic Minstrel
be2a613fff Move Lua dispatch shim to top of file 2016-07-18 20:59:49 -04:00
gfgtdf
2825a9d84d add __cfg getter to lua attack userdata 2016-07-16 22:44:50 +02:00
Celtic Minstrel
b145513db3 Fix some issues with fog control
- add_fog removed fog and remove_fog added it
- similarly, [lift_fog] and [clear_fog] were swapped
- make sure first argument is a list of sides before trying to interpret it as one
2016-07-16 10:24:13 -04:00
gfgtdf
ceea75cf0a replace some victory with scenario_end events.
victory is an unsynced event to its potentially unsafe to change the
gamestate in it, this mostly effects LoW (which can be played as a mp
campaign) where i replaced most victory events.

But it also effects sp becasue it can casue bugs to create units in
unsynced events which are used later (here: in later scenarios), so i
replaced also all sp victory events that do that.

Note that the 'scenario_end event'+'proceed_to_next_scenario filter' has
a slightly different meaning than 'victory event': the second gets fired
when there is a local human side who won the scneario while the first
gets fired if there is any human side who on the scenario. In sp this
is the same since there are no remote human sides, but in mp this is the
reason why the first is synced and the second is not.

We could add a seperate event for this case ("before next scenario" or
similar) for easier use, but i didn't find a good name for
that yet.
2016-07-14 22:15:33 +02:00
Celtic Minstrel
c39af95a44 Move name generator and formula API to base Lua kernel 2016-07-12 11:08:33 -04:00
gfgtdf
dd82ed03dc fix comments 2016-07-11 22:33:55 +02:00
gfgtdf
f9d8a9a0ab fix compiler warning 2016-07-11 17:50:16 +02:00
gfgtdf
c8d098087c add support for lua_function= in location filters 2016-07-11 14:54:24 +02:00
gfgtdf
f4253c220a fix side specific variables
this fixes wesnoth.get_side_variable and wesnoth.set_side_variable
2016-07-09 21:42:10 +02:00
gfgtdf
685b69495a fix lua unit.upkeep getter 2016-07-09 21:42:10 +02:00
gfgtdf
bbc32856f1 handle [args] also in [lua] tags outside events. 2016-07-09 21:42:10 +02:00
Charles Dang
240b940618 Fixed [teleport] not working 2016-07-03 04:34:54 +11:00
loonycyborg
5acc945371 Fix -Wunused-variable from gcc 2016-06-19 00:40:24 +03:00
gfgtdf
b1ea08e291 add wesnoth.special_locations 2016-06-18 15:27:06 +02:00
Andreas Löf
a3831fead2 Various fixes to make travis happier
Take out the clag to suppress warnings for lua in clang as it's not needed.
Make cmake builds in travis verbose.
Fix uninitialised variables that clang picks up on in cmake builds.
2016-06-02 22:37:39 +12:00
Celtic Minstrel
1649930113 Lua API for the name generators 2016-04-15 15:51:23 -04:00
Celtic Minstrel
5cf12798ce Port "trivial" WML tags to Lua
This is more about adding Lua API for things that should have it than porting WML tags to Lua.
The following new Lua API functions have been added to the wesnoth table:
- add_fog, remove_fog
- add_sound_source, remove_sound_source, get_sound_source
- log
2016-04-05 02:24:42 -04:00
Celtic Minstrel
ff618e7eb3 Eliminate resources.hpp usage in game_lua_kernel 2016-04-04 22:20:40 -04:00
Celtic Minstrel
38010fd991 Revert "remove unused queued_event parameter from WML_HANDLER_FUNCTION"
This reverts commit 310ba26704.
2016-04-04 15:54:57 -04:00
Charles Dang
0ca4e6c943 Convert uses of boost functional to standard library variants
This commit converts the following function calls:

* boost::bind                          -> std::bind
* boost::function and boost::functionN -> std::function
* boost::ref and boost::cref           -> std::ref and std::cref
* boost::bad_function_call             -> std::bad_function_call

In the process, it was discovered that std::bind has trouble with overloaded
functions. There were two such cases in the code:

* gui2::twindow had an ancient unused overload to draw(). The overload was removed.
* gui2::trepeating_button was binding tdispatcher::fire. This case was converted
  to a lambda.
2016-04-04 02:20:52 +11:00
Celtic Minstrel
cc7c124744 Merge branch 'lua_formula_bridge'
Allows calling WFL code from Lua
2016-04-02 09:38:59 -04:00
Celtic Minstrel
5bb6c30b05 Lua API: Add wesnoth.compile_formula which returns a callable userdata 2016-04-02 09:38:49 -04:00
Celtic Minstrel
4d1c9bdd43 Add wesnoth.eval_formula which compiles and evaluates a formula in the formula engine 2016-04-02 09:38:43 -04:00
Celtic Minstrel
fe818f8005 Add Lua API function to set the current time of day 2016-04-02 09:38:34 -04:00
Celtic Minstrel
ca382018b7 BOOST_FOREACH -> range for 2016-04-02 09:38:29 -04:00
Celtic Minstrel
982394fe3a Remove custom FOREACH macro in favour of range-for 2016-04-01 12:08:05 -04:00
Charles Dang
a0a8836bbe Used to_string() method instead of enum::enum_to_string() when possible 2016-04-01 02:41:17 +11:00
Celtic Minstrel
fb6031d6a1 lua_function= in SUF now has limited support for non-global functions
To be precise, the string is considered as a dot-separated list of components.
2016-03-31 02:13:40 -04:00
Celtic Minstrel
4c45683d4d Modernize luaW_getglobal
The variadic form now uses a variadic template, and a vector form has been added.
Since the nullptr sentinel argument is no longer required, it has been removed from all calls.
2016-03-31 02:13:39 -04:00
Celtic Minstrel
86b4680371 Use vector/templating for Lua-like bulk registration functions 2016-03-31 02:13:38 -04:00
Celtic Minstrel
3ac7f8d970 NULL -> nullptr
A few cases of NULL were missed, since changing them led to errors
(Mainly instances where it was passed to a boost::function)
2016-03-31 00:42:38 -04:00
Charles Dang
cf6fa69d27 Removed C++11 include guards
This also expands the OVERRIDE compatibility macro (FINAL was not used).
2016-03-31 12:06:35 +11:00
Charles Dang
876710af8c Use std::to_string() or equivalent wherever possible
This commit removes the utility srt_cast() function and replaces its calls,
along with calls to lexical_cast<std::string>() (and its boost variant),
with std::to_string().

In a few cases where the input type isn't compatible with to_string,
lexical_cast<std::string> is still used.

In other cases where lexical_cast was operating on MAKE_ENUM enums, the
call has been replaced with ENUM::enum_to_string, which is faster.
2016-03-31 11:18:51 +11:00
Celtic Minstrel
64892b8c81 Align formula and Lua views of unit types
- New key in both - race
2016-03-30 02:15:21 -04:00
Celtic Minstrel
02cfb7c279 Update/correct RN and changelog 2016-03-27 15:13:23 -04:00
Celtic Minstrel
503c2f01ae Lua API: More info in wesnoth.get_terrain_info 2016-03-27 15:13:22 -04:00
Celtic Minstrel
17ea7fac6b Reorganize the AI source files a little
This also tries to make them include everything by full paths instead of relative paths.
2016-03-24 00:08:12 -04:00
gfgtdf
b017a2b6b2 Add wesnoth.game_events.on_mouse_move/on_mouse_actions
This attempts to implement http://gna.org/bugs/?22635 and also allows
users to implement a 'queries a location from the user' (as suggested
from the easycosing page) in lua.
2016-03-24 00:42:10 +01:00
gfgtdf
fa1c1f033c fix msvc compilation 2016-03-24 00:42:10 +01:00
Celtic Minstrel
1d67892e07 Use luaW_checklocation in teleport_unit 2016-03-21 21:08:55 -04:00
Celtic Minstrel
bc711f5f43 Consolidate related files into subdirectories 2016-03-20 16:20:09 -04:00
Celtic Minstrel
fe0df45947 Consolidate formula and hotkey files in corresponding dirs 2016-03-20 16:15:50 -04:00
Charles Dang
37d9b102b7 Include SDL files as system headers
This excludes inclusions in SDL_GPU files.
2016-03-20 15:07:16 +11:00
Celtic Minstrel
8122039707 Rename .tpp -> .hpp
Several header files used the .tpp extension, which means that they are not correctly detected as C++ (though this can be overridden and has been for one case in the XCode project). The .tpp extension is one of several intended for private template instantiations, but these headers were topleve headers included in many places.
2016-03-19 21:57:03 -04:00
Celtic Minstrel
8e588972f4 Ensure logging objects are constructed on first used
This makes it safe to log messages during static initialization.
2016-03-19 21:12:11 -04:00
Celtic Minstrel
5eb9d80c2c Fix wesnoth.put_unit checking wrong arg for location 2016-03-19 17:27:02 -04:00
Charles Dang
df6bc83543 Merge pull request #618 from CelticMinstrel/lua_unit_effects
Include built-in effects in wesnoth.effects
2016-03-19 17:50:32 +11:00
Celtic Minstrel
0f1b21a5be Include built-in effects in wesnoth.effects and allow them to be overridden 2016-03-19 02:05:53 -04:00
Celtic Minstrel
26a2638f2c Make the formula and Lua views of a unit coincide more closely
Several keys were either missing or misnamed in the formula view.
These have been changed to match the Lua and WML names for the keys.
This affects canrecruit, moves, and max_moves, as well as status.

In addition, a large number of keys were missing entirely from the formula view.
Most of these keys have now been added and can be accessed from formulas.
A few that have little use in filters (such as image_mods or profile) are still missing.

The Lua view missed a few keys that the formula view did provide.
Although these could in principle have been obtained by using the special __cfg key,
they have now been added to the Lua view anyway.
2016-03-17 23:27:03 -04:00