Commit graph

182 commits

Author SHA1 Message Date
Charles Dang
f23305f7e2 Formatting cleanup: T const& -> const T& 2018-01-23 01:26:23 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
gfgtdf
dac782925a vconfig optimisation 2017-08-27 21:57:41 +02:00
Celtic Minstrel
96ca0b026e Replace config_of with new variadic config constructor 2017-05-21 16:27:46 -04:00
Celtic Minstrel
67ba87a36c Move config_variable_set class into a header 2017-05-18 22:33:55 -04:00
Charles Dang
9585a58a2d Use direct or aggregate initialization in a bunch more places I've generally missed 2017-05-17 22:58:40 +11:00
gfgtdf
08df684937 fixes to c++14 build 2017-05-06 18:06:18 +02:00
gfgtdf
12f9215da2 deployed some range for loops on gameboard::teams() (#1007)
deployed some range for loops on gameboard::teams()
2017-04-29 16:08:45 +02:00
Charles Dang
4bc0ac0041 Variable: remove asserts on resources::gamedata absence
In the case of as_nonempty_range, the function was rewritten to remove absolute reliance on gamedata.
In the other case, we simply silently return now.
2017-04-09 04:57:09 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Charles Dang
e22c8967ee Cleaned up global.hpp includes 2016-12-17 15:21:04 +11:00
Jyrki Vesterinen
af733360a8 Fix a bunch of MSVC2015 compiler warnings about hiding declarations
This commit still doesn't fix all of them. I decided to leave alone
cases where variables with the same name are assigned in multiple
conditions of the same if...else if...else statement, and cases where a
scope logging macro is used multiple times in the same scope. In any
case, this commit greatly reduces the warning count on MSVC2015 and makes
new warnings much easier to spot.
2016-10-06 00:11:56 +03:00
gfgtdf
553ac0fd05 add wml_x/y() getter & setter in map_location 2016-09-16 22:35:41 +02:00
Celtic Minstrel
116ff67c6e Improvements to the config interfaces, mainly iterators
- config::attribute_count() now excludes blank (ie, unset) attributes
  Blank attributes in the map are generally a result of the mutating
  behaviour of operator[], so they're not "logically" existing attributes.
- Non-const versions of attribute iterator and all-children iterator
- Attribute iterators are now bi-directional
- vconfig all-children iterator is now a bi-directional Boost iterator range
- vconfig now has a bidirectional attribute iterator
2016-08-29 16:47:17 -04:00
gfgtdf
4d84d42c47 iterator_range instead of pair for config::child_itors
with this wwe can use .size(), .empty(), .front(), operator bool, etc.
on config::child_itors objects.
2016-08-13 16:59:34 +02:00
Charles Dang
6235e18bbd Replace resources::teams with resources::gameboard->teams() 2016-08-11 07:27:48 +11:00
Charles Dang
05092ba2f6 Refactor most boost pointer related stuff to use their stdlib counterparts
This constitutes drop-in replacements for:

* boost::shared_ptr
* boost::scoped_ptr
* boost::weak_ptr
* boost::enable_shared_from_this
* boost::static_pointer_cast
* boost::dynamic_pointer_cast

This excludes boost::intrusive_ptr, except for stray includes. Refactoring that is more complicated.
2016-07-25 09:28:42 +11:00
Celtic Minstrel
ca382018b7 BOOST_FOREACH -> range for 2016-04-02 09:38:29 -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
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
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
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
Celtic Minstrel
a5184181df Fix SUF $this_unit only working within [filter_wml] 2015-09-19 00:19:26 -04:00
Ignacio R. Morelle
056189d1c6 Fix several null pointer checks done after first use 2015-08-19 02:08:39 -03:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
gfgtdf
7da44d91dc fix segfault in [replace_map]
a default constructed vconfig was previously unable to be derefereced,
Now it can be dereferenced.
The previous behaviour led to segfaults on wrong parameters to
[replace_map].
2014-11-14 19:21:08 +01:00
gfgtdf
cc3ff2da90 fixup variable.cpp refactor 2014-07-19 02:33:44 +02:00
gfgtdf
7531089162 add const 2014-07-19 02:03:09 +02:00
gfgtdf
cbbce2339d refactor variable.cpp 2014-07-19 02:03:08 +02:00
Mark de Wever
c119584895 Strip trailing whitespace. 2014-07-13 12:41:43 +02:00
Chris Beck
e3d34a34be remove pointless static singleton getter for teams 2014-07-06 16:19:49 -04:00
Chris Beck
f87177c711 filters hold safe vconfig, const vconfigs can call make safe 2014-07-06 12:22:26 -04:00
gfgtdf
1a8d3c6fa2 refactor variable_info
we now use const correctness to ensure that we sont change teh game
config if we just want to read values.

Also we use a new algorithm that is a little slower when parsing small
variablenames and much faster when parsing long variablenames.
2014-07-01 04:49:49 +02:00
gfgtdf
23b0c5343f catch invalid variablename exception when using
these exceptiosn are not thrown yet in all cases. This patch prepares a
patch taht makes use of it.
2014-06-30 00:45:02 +02:00
gfgtdf
c366acb96e make different functions for different variable access
the const_cast there is an improvement of the previous solution where we
just hided it by using resources::gamedata which is never const.
2014-06-30 00:44:58 +02:00
gfgtdf
450735090e make variable_info members private 2014-06-30 00:44:56 +02:00
gfgtdf
5d3040c0b8 move variable_info to own file
and also move game_data::temporarites_ to that file as a static
variable.

This fixes variable_info being dependent on game_data.
2014-06-30 00:44:49 +02:00
gfgtdf
16938d397d add game_data::get_variable_accesss method. 2014-06-30 00:44:48 +02:00
Chris Beck
b51d6a15d1 rename gamestatus.?pp -> game_data.?pp, b/c of content changes 2014-06-24 13:44:25 -04:00
Chris Beck
9e7dc5ba00 unit_map, lua, team recall lists use reference counted UnitPtr
Defines a UnitPtr (boost::intrusive_ptr<unit>, after irc
discussion), which the engine will use to pass units between
different modules, and which it is planned that the animation
engine will also hold, to avoid segfaulting.

Unfortunately this commit could not really be made smaller, it is
necessary to change all of these things over at once, or specify
very complicated deletion policies for the units at the
boundaries of the modules.

The main intention of the commit is to get these three modules
using a reference counting system to hold units, even as they
are passed between the modules. Eventually the fake units and
other kinds of units will all also be held in such pointers, and
the unit_map::unit_pod object will be replaced itself with a
single smart pointer.

Finally the animations objects will hold weak pointers to units,
to fix the segfault issues.

This commit required us to change over the whiteboard, most of
the action_wml, and the AI modules, since these make use of the
recall list from the team class.

We also add the unit_ptr.hpp header file, to allow to forward
declare the UnitPtr object essentially, and it's const variation.

If we forward declare the intrusive_ptr functions, we can forward
declare the UnitPtr type and avoid including unit in a bunch of
places that we don't need to. (Good as that is a very heavy
include.)

The declaration is now in unit_ptr.hpp

Since we can't forward declare inheritance, the easiest way to
resolve linker problems is to not derive unit from the
reference_counted_object class and just include the intrusive_ptr
boilerplate as usual instead.
2014-06-15 14:57:47 -04:00
Chris Beck
3c9844889b Make sure all error logs flush with std::endl, so we get on travis.
This is the result of running this command in directory src/

find . -type f -exec sed -i 's/\(ERR.*\)\\n\"\;/\1\" << std::endl\;/g' '{}' \;

and carefully inspecting the results.
2014-05-20 15:37:52 -04:00
gfgtdf
7e7cef96fe Update variable.cpp 2014-04-14 22:01:34 +02:00
Ignacio R. Morelle
a4f47a63c7 New Year copyright update 2014-01-01 02:08:52 -03:00
JaMiT
52cfe2b17d Eliminate variable::manager.
With the simplification of vconfig, this class no longer serves
a purpose.
2013-09-21 11:41:53 -05:00
JaMiT
919efb4ed5 Localize a static variable to the function where it is used. 2013-09-21 11:41:53 -05:00
JaMiT
acb7e7a6ae New (and simpler) memory management for vconfig.
The old management had potential, but in practice it was rarely in
a position to show off. It ended up doing little more than reference
counting; a shared_ptr can do this with less overhead.
2013-09-21 11:41:52 -05:00
JaMiT
b79a908d06 No reason to qualify a non-ref return value as "const". 2013-09-14 12:01:26 -05:00
JaMiT
04c0a8f011 Force vconfig members of wml_menu_item to manage their own memory.
Fixes bug #21127.
2013-09-14 11:22:25 -05:00
JaMiT
20c60b5094 Some tweaks to vconfig construction and documentation.
The only real change is to empty_vconfig(), which no longer requires
the overhead of the vconfig making a copy of the empty config.
2013-09-07 03:24:07 -05:00