199 Commits

Author SHA1 Message Date
Sergey Popov
136f42bd4f Fix bug #20205
Malformed data caused config::error exception to be thrown.

Unfortunately campaignd on catching such an exception had no way to
close the right connection, instead all connections were closed because
the local variable that was supposed to contain connection number wasn't
updated. This is fixed by using boost.exception to attach the necessary
data to config::error objects so it can be used at the catch site.
2012-10-04 02:23:15 +00:00
Mark de Wever
8a3fbdf30a Change a forward declared type to a struct.
The issue was spotted by CLang.
2012-07-05 18:33:42 +00:00
Mark de Wever
eb165d1885 Allow better error messages for missing children.
The caller's code still need to be changed but at least gives the option
to create better error messages.
2012-05-20 09:56:17 +00:00
Mark de Wever
9ebb260d01 Add config::has_child().
This allows to easily query whether a certain child exists.
2012-05-20 09:56:13 +00:00
Jon Daniel
1d71b8cf89 Fix number to string conversion and revert the changes to the variant type
fixing bug #19702, #19690 and maybe more
2012-05-04 15:36:57 +00:00
Jon Daniel
d6818a122b Fix variant type for systems where time_t is int 2012-05-03 01:55:17 +00:00
Jon Daniel
8eea6a8b9b fix bug #19681 and #19201: 2012-05-01 19:04:33 +00:00
Mark de Wever
c8d190a000 Use NULL instead of 0. 2012-04-01 08:22:59 +00:00
Ignacio R. Morelle
6ca69b2df5 New year copyright update 2012-01-07 02:35:17 +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
Mark de Wever
b4d927e967 Strip trailing whitespace. 2011-09-26 20:27:15 +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
28e92236ca Moved the Mandatory WML child exception...
...back into the object file where it belongs.  It is faster to attach
a breakpoint to, because it isn't inline.
2011-09-15 20:16:57 +00:00
Thonsew
9a9162f653 Modifed config::invalid to be a pointer to NULL...
...to prevent recursive explosion in gdb backtrace.  This will make
debugging easier.
2011-09-14 09:57:25 +00:00
Thonsew
d2690e0cc6 Move anonymous namespace static const t_token...
...into function local scope in order make sure control flows over
them and initializes in the correct order.
2011-09-11 18:21:49 +00:00
Mark de Wever
24c055cd44 Strip trailing whitespace. 2011-09-10 11:52:18 +00:00
Thonsew
bb02feb844 Make config::attribute_value.type_ a proper enum,
...to attempt to fix MSVC assigning an out-of-range value to enum.
2011-09-09 15:57:59 +00:00
Thonsew
82e7d2c6f8 Made load dialog faster when there are many saved games.
1. Added a child_range_index member function to config to generate an index

2. Changed the load dialog from the O(N^2) search for saved games to a
O(N) listing.
2011-09-08 19:17:20 +00:00
Thonsew
2bf6377351 Changed config and vconfig to use a token representation...
...t_token in place of std::string.  t_token compares, copies, copy
constructs and hashes in 1 operation instead of proportional to the
length of the string.
2011-09-08 19:16:01 +00:00
Thonsew
3d29107eff Refactored string interpolation to use tokens to improve speed...
...once token are used in config

Added unit tests for string interpolation
2011-09-08 19:15:40 +00:00
Mark de Wever
ecbabea838 New year copyright update. 2011-01-01 15:57:50 +00:00
Guillaume Melquiond
50bf9dc74c Removed unused function config::find_child_recursive. 2010-11-07 20:16:10 +00:00
Guillaume Melquiond
333f3761a2 Added a move-aware implementation of config::add_child. 2010-10-31 09:21:51 +00:00
Guillaume Melquiond
63caf15a2f Added move operators to class config,
...in order to speed up standard containers (e.g. std::vector).
2010-10-31 08:44:19 +00:00
Guillaume Melquiond
f0ede721df Used explicit boolean conversion when available,
...instead of the safe_bool idiom.
2010-10-30 22:51:03 +00:00
Mark de Wever
e1dde75c29 Remove an unneeded include. 2010-10-26 21:37:54 +00:00
Guillaume Melquiond
181494eb43 Removed usage of two separate numeric types for attribute values.
(Fix for bug #16950.)
2010-10-25 19:48:27 +00:00
Guillaume Melquiond
eeb047de55 Fixed file headers so that they match the content of the COPYING file. 2010-09-01 21:12:38 +00:00
Mark de Wever
b21f23db09 Remove duplicate definitions of string_map.
Issue spotted by cppcheck.
2010-08-29 20:13:31 +00:00
Guillaume Melquiond
ae7cc0a6d2 Modified vconfig so that it is no longer forced...
...to return translatable strings after variable expansion.

In particular, the engine no longer tries to expand variables inside
plain numbers or booleans.
2010-08-19 22:07:53 +00:00
Guillaume Melquiond
8373a90e87 Optimized config handling by comparing pointers...
...instead of strings when visiting the ordered children.
2010-08-09 19:57:31 +00:00
Guillaume Melquiond
0a996b70d5 Added function for splicing children between config objects.
This speeds up configuration loading by 50%.
2010-08-09 15:57:32 +00:00
Guillaume Melquiond
8d40b87f89 Avoided conversion of attribute values to translatable strings.
Optimized string escaping.

Fixed strange indentation of embedded textdomain changes.

Reduced amount of useless quotes and spaces.

This patch brings the time needed for outputting the cache for the
test scenario from 17% of the total time down to negligible.
2010-08-08 20:03:36 +00:00
Guillaume Melquiond
dc4b3bb2ef Sped up child lookup by converting the value argument only once.
Avoided using a translatable string argument since it was stored as
plain string anyway.
2010-08-08 15:33:27 +00:00
Guillaume Melquiond
0bf604f20e Avoided creating blank attributes when doing complete copies. 2010-08-06 20:24:59 +00:00
Guillaume Melquiond
419cf84a9d Added visitors for converting config attributes.
(Partial fix for bug #16363.)

This brings the profile footprint of pushing units to Lua tables from
15% to 5%.
2010-08-06 16:31:01 +00:00
Mark de Wever
a99c78e0d8 Update doxygen comment.
The filename after the @file comment is optional (spotted by alink).
2010-07-26 21:32:18 +00:00
Guillaume Melquiond
85a6592a1c Cleaned typing of proxy iterators a bit. 2010-07-23 14:43:28 +00:00
Guillaume Melquiond
939313f336 Allowed negative index for accessing from the end of a config object. 2010-06-13 06:28:03 +00:00
Guillaume Melquiond
408dc492a5 Added config accessor combining has_attribute and get_attribute.
Ideally, a bool operator would have been added to attribute_value
instead of adding yet another accessor to config.

But it can't work for now:

  - conversion to a safe bool would lose against the conversion to int;

  - conversion to plain bool would conflict with the conversion to int.

So we are stuck with using a pointer to emulate an option type.
2010-06-12 18:58:39 +00:00
Guillaume Melquiond
997643d2eb Uninlined, added validity check, and documented functions. 2010-06-12 18:58:35 +00:00
Jérémy Rosen
cc5330c08c new buttons and logic to navigate story screen,
...allowing back an forth, patch #1587 by icelus
2010-06-07 18:22:49 +00:00
Ali El Gariani
5cd78eac52 Add possibility to log a WML error in the new functions...
...handling backward compatible keys.
2010-06-03 18:15:48 +00:00
Ali El Gariani
ffe6d898d6 Add helper functions to handle backward compatible keys. 2010-06-03 01:46:41 +00:00
Guillaume Melquiond
8343fb32eb Reduced compilation time and binary size...
...by uninlining heavy members (-13% on amd64 at -O1).
2010-05-29 17:21:32 +00:00
Guillaume Melquiond
52d3523782 Reduced compilation time and binary size...
...by uninlining variants (-2% on amd64 at -O1).
2010-05-29 15:00:35 +00:00
Mark de Wever
20c7748f00 Added constructor to initialize all members. 2010-05-24 17:44:33 +00:00
Guillaume Melquiond
76c34a23d3 Modified WML attributes so that they are stored with...
...smaller effective types when they are not translatable.

This patch considerably reduces the memory footprint of WML and speeds it up.

It should not change any WML behavior, except for a few corner cases
detailled below:

- "off" is no longer a synonym for "no" (it wasn't used anyway),

- _"42" is no longer an integer,

- untranslatable "true" and "false" are stored as booleans, hence
  displayed as "yes" and "no",

- "042" is now understood as octal notation (hence 34) rather than decimal,

- hexadecimal notation "0x42" is now recognized.
2010-05-24 08:01:31 +00:00
Guillaume Melquiond
ab21de1ef1 Added conversions from config::proxy_string to int. 2010-04-05 06:02:01 +00:00
Guillaume Melquiond
a4716378ed Added proxy for writing integer values into config attributes. 2010-04-05 06:01:11 +00:00