Commit graph

425 commits

Author SHA1 Message Date
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
Celtic Minstrel
f02a038879 Fix wesnoth.erase_unit for recall units 2016-03-17 22:41:05 -04:00
Celtic Minstrel
46cee1df68 Allow wesnoth.match_unit to take a location, for hypothetical matches 2016-03-16 12:51:32 -04:00
Celtic Minstrel
2e6ad2bee3 Add wesnoth.select_unit(), deprecate wesnoth.select_hex()
wesnoth.select_unit() is also callable as u:select() where u is a unit
2016-03-16 12:51:31 -04:00
Celtic Minstrel
058ec266cf Re-enable/fix put_unit deprecation warning 2016-03-16 12:51:28 -04:00
Celtic Minstrel
a84500fb8f Add functions for transferring map locations to and from Lua stack
This also changes nearly all API functions taking locations to use the new functions.
As a result, these functions can now accept their location arguments in any of three formats:
- An array of two integers
- A table with x and y keys
- Two separate, consecutive integer arguments

Functions that return locations mostly still use whatever format they used before.
This is because changing return values is a more compatibility-breaking change.

This temporarily breaks compatibiliy for the following AI functions:
- ai.get_targets()
- ai.get_avoid()
- ai.get_attacks()
2016-03-16 12:50:54 -04:00
Celtic Minstrel
0f39cc3fe0 Fix function case 2016-03-14 13:15:33 -04:00
gfgtdf
b2fff5afd9 removed wesnoth.put_unit() warning
this warning triggered also when using u:to_map(x,y) which is clearly
not intended.
2016-03-14 14:42:28 +01:00
gfgtdf
310ba26704 remove unused queued_event parameter from WML_HANDLER_FUNCTION 2016-03-14 14:42:09 +01:00
gfgtdf
986550c040 move [teleport] actionwml to lua. 2016-03-14 14:42:05 +01:00
gfgtdf
ff5a37a064 lock unit_map while running filter or applying effects
This specially prevents lua form removing the unit that is currently
filtered or that currently gets effects, which would cause crashes
otherwise.
2016-03-14 14:42:01 +01:00
gfgtdf
413d8cf3d2 implement wesnoth.get_unit(string) directly
this is sure faster than applying a filter to all units on the map which
is what the previous implementation did.
2016-03-14 14:41:49 +01:00
gfgtdf
50a9a25ae7 move [unstore_unit] definition to lua
This also adds a 'color' parameter to wesnoth.float_label. It was already
previously possible to set a labels color using pango markup, but to
implement [unstore_unit] i need to support the color= syntax as given
by [unstore_unit]

This also adds a 'fire_event' parameter to wesnoth.put_unit to specify
whether the 'unit_placed' event is fired, this is needed to implement
fire_events=yes/no in [unstore_unit] but its also generally useful
for the same reason why [unstore_unit] has this parameter.
2016-03-14 14:41:45 +01:00
Charles Dang
497aee86ab Undeprecate wesnoth.highlight_hex()
wesnoth.select_hex has problems with simply highlighting units without displaying
their movement range. If you set its third argument to false, the unit gets
selected, but no hex cursors appears around it. Using this allows us to simply
highlight a location with the hex cursor, independent of unit presence (select_hex
works funny if no unit is present).
2016-03-14 09:41:12 +11:00
Celtic Minstrel
708af56409 Fix function name typo 2016-02-23 13:47:49 -05:00
gfgtdf
50725cabe3 add a setter for a units level in lua proxy units 2016-02-15 18:00:41 +01:00
gfgtdf
12b40cf458 make wesnoth.find_path function available to lua ganerators.
it doesn't support all parameters of the original find_path function
that is used during the game, because things like units or maps are not
avaiable.
2016-02-08 21:10:35 +01:00
gfgtdf
de0ad5e92a make unit.upkeep modifyable by lua. 2016-02-03 22:58:56 +01:00
gfgtdf
5deea2eb16 small unit class refactor
i moved the 'description', 'usage', 'halo', 'ellipse', 'random_traits',
'generate_name' and 'upkeep' from cfg_ into unit member variables.

This main advantage is that its now clearer which unit type attributes
exist, also it is a little faster becasue it doesn't need string lookps
when accesing those attributes.

I used scoped_ptr<string> instead of just string to store 'usage',
'halo' and 'ellipse' because that is closer to the previous memory
layout.
2016-02-03 22:58:37 +01:00
gfgtdf
08236f8953 added name= attribute to [item]
name= has no effect but can be used to delete the item. I also changed
[item] to automatically create an id (in case no id was given) and
return that (only usable if called from lua).

I used the id= field from overlay class for this, it was previously only
used by the editor. Not sure if it is a good idea to reuse the id field.
2016-01-31 02:25:46 +01:00
gfgtdf
a885c2bdf1 add alignment getter/setter for lua units 2016-01-31 02:24:54 +01:00
gfgtdf
d3615be714 cleanup cfg_ member of unit class.
the cfg_ field of the unit class now doesn’t store the advancements and
the abilities anymore. Instead they are stored in separate fields.

I used boost::ptr_vector<config> because that’s similar to how config
objects store their child values internally. Unfortunately
boost::ptr_vector defines ptr_vector::value_type in a bad way so that it
cannot be used for BOOST_FOREACH loops value types, so i had to
change lua's push_check file to use T::reference to be compatible
with ptr_vector

This commit removes all child tags of the unit cfg_ because the only
tags that are now left in cfg_ are [variation] and [advancefrom] from
[unit_type], which werent used in [unit] and only caused the savefiles
to bloat.
2016-01-29 22:48:06 +01:00
gfgtdf
a953848dda remove display dependency from show_help()
help_button still needs a display& for regierting it in the hotkey code.
2016-01-12 23:17:56 +01:00
Lari Nieminen
52a0bbc531 Added event type "unit placed" 2016-01-12 17:40:27 +02:00