Commit graph

204 commits

Author SHA1 Message Date
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
Charles Dang
4afd415143 Decoupled delay() from display class and moved it to a static CVideo function 2016-01-12 10:55:55 +11:00
CelticMinstrel
ac77c262bd Merge pull request #578 from CelticMinstrel/fix-message
Fix [message] issues
2016-01-09 00:50:14 -05:00
gfgtdf
ffe5cd44e3 fix [endlevel] end_text=translatable string 2016-01-06 02:47:37 +01:00
Chris Beck
ba51524f6e update copyright to year 2016
using this shell script:

find src -type f -print0 | xargs -0 sed -i "s|Copyright (C) \([[:digit:]]*\)\([ ]*\)-\([ ]*\)2015|Copyright (C) \1\2-\32016|g"
2016-01-02 23:59:31 -05:00
Celtic Minstrel
2e293fb61d Apply TC to unit sprites in [message] 2016-01-02 20:36:29 -05:00
gfgtdf
3955308e7e reorder includes 2015-12-28 14:27:36 +01:00
Elvish_Hunter
9b7b1751fd Removed trailing tabs and whitespaces from C++ source
I used this command line: find <source directory> -name \*.\[ch\]pp -print0 | xargs -0 sed -i 's/[[:blank:]]*$//'
2015-12-21 20:39:46 +01:00
Charles Dang
c43df77725 Added support for color= in [unstore_unit] and [print] 2015-12-16 01:26:03 +11:00
Charles Dang
5813eb0aad Pass color value directly to game_display::float_label
This is to allow color values created using different util functions -
ie, create_color() or string_to_color().
2015-12-16 01:25:31 +11:00
gfgtdf
1d7efd019d Revert "initialize wml menu item handlers when they are set, not in ctor"
This reverts commit eaa078a86d.

This attempts to fix gna.org/bugs/?23545 but is reintroduces
https://gna.org/bugs/?23115 so the commit that casues that one will
also be reverted.
2015-12-14 16:46:07 +01:00
gfgtdf
1aea4da8cf Attempt to fix broken [event] in [unit_type]
This reverts commit c5e31e83f1.
This reverts commit 8447ebbb88.

[event] in [unit_type] was broken during a refactor of the gamestate
initilisation that also involved the commits above. The commits above
didn't directly cause this bug but reverting them makes fixing this bug
much easier.

We fix the bug by initilizing the game_events manager before creating the
units.
2015-12-14 16:46:05 +01:00
gfgtdf
7f13156c28 Revert "Rename team_name/user_team_name to team_id/team_name (old syntax still valid)"
And related commits.

This reverts commit 545253ec2b.
This reverts commit 1215f65eb8.
This reverts commit 11664f4024.
This reverts commit e948df3424.
This reverts commit 3781e7839f.

This commits were reverted to exclude them from wesnoth 1.13.2 release because:
1) We are still unsure about the best name oftthese attributes
2) This breaks multiple campaigns, including LoW and the tutorial.
Feel free to revert this revert after 1.13.2 when thse issues can be solved..
2015-12-10 21:29:52 +01:00
gfgtdf
d7acb178d2 Revert "Added util function for converting an RGB string to color"
And also other commits that used that function.

This reverts commit 0d8c008018.
This reverts commit 956e5f9322.
This reverts commit 8f35c4bfcf.
This reverts commit dcb265ae70.

This commit just contained too many bugs, including:
1) string_to_color not parsing any input correctly
2) string_to_color segfaulting on some input strings
3) missing backwards compability in [unstore_unit]
2015-12-10 21:26:39 +01:00
Charles Dang
956e5f9322 Enable [print] color= and deprecate red,green,blue= keys 2015-12-10 22:06:34 +11:00
Charles Dang
8f35c4bfcf Pass color value directly to game_display::float_label
This is to allow color values created using different util functions -
ie, create_color() or string_to_color().
2015-12-10 22:06:33 +11:00
Celtic Minstrel
c5a08251a1 Lua API: Fix location in put_unit not working as 2nd/3rd param 2015-12-07 20:00:37 -05:00
gfgtdf
9aa6722622 improve performance of wesnoth.delay(0)
In this case we don't need to call SDL_GetTicks() or
game_display_->delay(10)
2015-12-07 15:43:56 +01:00
gfgtdf
91943451c7 move most of [endlevel] implementation to lua
as a side effect we get read/write fields
side.carryover_bonus/carryover_add/carryover_percentage in lua sides.
2015-11-30 02:49:01 +01:00
Ignacio R. Morelle
de44790d7d Make [*time_area] Lua API functions take a single time area id
This means the Lua code implementing the WML tags are now solely
responsible for parsing the comma-separated id list. It just so happens
that I added code for that without realizing that I was duplicating
existing functionality on the C++ side.

As a result:
 * wesnoth.add_time_area and wesnoth.remove_time_area can operate on
   time area ids that contain commas (if someone feels this is needed
   for some weird reason)
 * [time_area] no longer warns about adding time areas with commas in
   their ids (actually adding the first id of the list instead)
 * [time_area] remove=yes and [remove_time_area] still handle
   comma-separated lists of ids, in the Lua side instead of C++.

This makes the Lua API for this consistent with [event]/[remove_event].

Since the Lua API functions in question are undocumented at this moment,
it's unlikely this impacts anyone, really.
2015-11-26 23:29:16 -03:00
Charles Dang
3781e7839f Rename team_name/user_team_name to team_id/team_name (old syntax still valid) 2015-10-26 00:44:28 +11:00
Celtic Minstrel
e9cfef3b72 Lua API: Fix unit:vision() and unit:jamming() returning movement cost 2015-10-19 23:16:37 -04:00