Commit graph

155 commits

Author SHA1 Message Date
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
fendrin
8ab9659f36 Avoid a null pointer access. 2013-05-03 21:51:25 +02:00
Eric S. Raymond
043c4f9fd3 Remove $Id$ cookies. 2013-03-26 21:41:37 -04:00
Mark de Wever
43b71f2ff0 New year copyright update. 2013-01-01 09:22:03 +00:00
J. Tyne
11a6fb368e Define attribute_value::apply_visitor().
This is for better encapsulation, leading to fewer friends.
2012-12-13 19:44:13 +00:00
J. Tyne
d17965a26c End a private data member name with an underscore. 2012-12-13 18:42:33 +00:00
J. Tyne
0b4d03b77a Adding some anonymous namespaces to reduce the work required when linking. 2012-11-13 01:45:27 +00:00
Anja Keicher
c17d84b12f Moved in-game data to make sure it can't be accessed out of game 2012-07-26 15:18:08 +00:00
Sergey Popov
6b6eafb213 Use BOOST_FOREACH directly instead of #define foreach BOOST_FOREACH
The define is extremely unreliable, will break compile with boost >=
1.50 and upstream can't fix issues with it, see
https://svn.boost.org/trac/boost/ticket/6131
2012-07-07 00:49:45 +00:00
Ignacio R. Morelle
6ca69b2df5 New year copyright update 2012-01-07 02:35:17 +00:00
Simon Forsyth
bdfc1307ba Reduce invasiveness of fix for bug #18701...
...(eliminates regression found by shadowmaster)
2011-10-31 22:48:58 +00:00
Simon Forsyth
900c6ca1f1 fix bug 18701 2011-10-23 15:40:01 +00:00
Anonymissimus
c26f9ac9ed fix $this_unit being broken for recall list units (bug #18821)
Remove duplicate storing, which was clearing the already stored
unit from the gamestate variables again. Silene forgot to delete
the line in 2010-08-06T17:31:14Z!guillaume.melquiond@gmail.com.
2011-10-18 23:19:33 +00:00
Alexander van Gessel
81e0a2007f Revert token t_token commits from 2011-09-08T19:15:40Z!thonsew@yahoo.com on. 2011-10-10 03:43:29 +01:00
Thonsew
b1826e2a55 Fix bug #18749 clearing a specific index of an array doesn't work.
The problem was when the cleared index was 0 the entire array was
cleared.  The fix was to correctly set explicit_index_ to true even
when the index is 0.
2011-09-29 15:55:48 +00:00
Mark de Wever
b4d927e967 Strip trailing whitespace. 2011-09-26 20:27:15 +00:00
Thonsew
e39c4700ec Fixes variable indices should default to [0] if absent or unitinialized.
If the variable index is absent it now defaults to 0.

This fixes bug #18728.  It might also fix all FOREACH and lua while
loops as Gambit described but I need to double check.
2011-09-26 19:57:56 +00:00
Thonsew
8d4d2bf0f5 Fixed variable_info to return 0 for non existent containers.
See bug #18701 Added hooks but no functionality for removing WML
warnings are non-existent variables when doing conditional checks.
2011-09-22 22:03:19 +00:00
Thonsew
88b5546118 Attempt to fix static de-initialization problems.
Some compilers are calling destructors for static objects before other
static objects use them in their destructors.  This patch initializes
static t_interned objects with new and intentionally doesn't call
delete in order to guarrantee their existence throughout the static
de-initialization phase.  It creates a new function
generate_safe_static_const_t_interned for this purpose.  It might
address bug #18666, although I can not duplicate the crash with gcc on
fedora 15.
2011-09-20 21:21:31 +00:00
Thonsew
cdb129508d Fix implicit static cast...
...of config::attribute_value & to tstring & or t_token reference
causes crashes.  Some compilers were generating a temporary object and
binding a reference to the temporary when creating an implicit cast to
an attribute value.  I removed the implicit cast and replaced all (I
think) instances of the implicit cast with explicit 2 step operation.
This fixes bugs like bug #18663, bug #18684
2011-09-20 21:20:54 +00:00
Thonsew
03bcf5a77c Reverted wml parsing error behavior to sending a console log warning 2011-09-16 12:28:37 +00:00
Thonsew
235760192b Fixed handling of force_valid in variable.cpp...
...to correctly account for the difference between created array and
plain variables.
2011-09-15 20:17:03 +00:00
Anonymissimus
943be2ca8f fixed and MSVC warning about unreachable code
thonsew: You are sure it's a gooc idea to throw such a lot from here ?
Since that line is clearly not the only one which gets
skipped. WRN_NGs are emitted to the console in any case, even in
normal play without debug mode or log domains set.
2011-09-14 16:11:06 +00:00
Thonsew
9391bd4dc8 [[Improvements to WML error handling]]
1. Fixed some Mandatory WML child missing errors due to parsing errors
when new t_token parsing was added to variable_info.

2. Upgraded all WML errors to console errors to increase their visibility.
2011-09-14 09:57:39 +00:00
Thonsew
d02e41530c Moved WML formatting error messages from std::cerr...
...to the wesnoth console, as per discussion with Espreon.  See bug
#18627 Marked error messages as translatable.
2011-09-12 21:30:04 +00:00
Mark de Wever
24c055cd44 Strip trailing whitespace. 2011-09-10 11:52:18 +00:00
Thonsew
4584b5cca2 Fix for bug #18627.
Changed assertion to a wml_syntax_exception that provides an error to
user informing them of invalid wml syntax and then continues with the
variable marked as invalid.
2011-09-10 07:19:12 +00:00
Thonsew
ae4d943d56 Fix for crash in MSVC debugger,
...where it dereferences vector iterators immediately on creation.
This patch checked by anonymissimus.
2011-09-09 19:14:54 +00:00