122 Commits

Author SHA1 Message Date
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
Thonsew
2b29c157f2 Changed uint to unsigned int 2011-09-08 20:46:44 +00:00
Mark de Wever
bae50a5556 Remove a not allowed typename. 2011-09-08 19:33:48 +00:00
Thonsew
9ce82aec1a Upgraded game_events.cpp...
...and files that interacted with game_events to use t_token in place
of std::string for config objects
2011-09-08 19:16:49 +00:00
Thonsew
576a3feab1 Updated parts of unit class to use t_token...
...in place of std:string in order to speed up comparisons, copies and
hashing which are 1 cycle operations.

Added z_sub t_token.

Added lru_cache unit test
2011-09-08 19:16:26 +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
b304723c5b Append private variables with an underscore. 2011-03-13 18:59:05 +00:00
Mark de Wever
1f2bab3930 Rethrow original exception instead of a copy.
Issue found by cppcheck.
2011-03-06 19:08:03 +00:00
Mark de Wever
ecbabea838 New year copyright update. 2011-01-01 15:57:50 +00:00
Guillaume Melquiond
f82fcc6c85 Allowed skipping over [insert_tag] children when visiting vconfig objects. 2010-12-28 15:09:06 +00:00
Ignacio R. Morelle
d6a3de1938 Apply patch #2213 by stikonas, using file #11274 2010-11-21 01:56:29 +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
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
ba06242145 Removed unused assignment operator for class vconfig. 2010-08-14 14:15:25 +00:00
Guillaume Melquiond
d48a63a995 Avoided copying scoped units. (Partial fix for bug #16363.)
This brings the profile footprint of variable_info from 9% to 4%.
2010-08-06 17:31:14 +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
908e470543 Avoided copies. 2010-07-23 14:43:40 +00:00
Guillaume Melquiond
85a6592a1c Cleaned typing of proxy iterators a bit. 2010-07-23 14:43:28 +00:00
Guillaume Melquiond
050cd9495a Removed auto_ptr from proxy iterator. 2010-07-23 13:34:01 +00:00
Guillaume Melquiond
04a240c55e Reverted change of vconfig::child introduced by 2010-05-25T00:54:52Z!ai0867@gmail.com.
(Fix for bug #16211.)
2010-07-20 10:47:04 +00:00
Guillaume Melquiond
9aa0af7fe6 Avoided costly roundtrip through strings. 2010-06-12 18:58:02 +00:00
Alexander van Gessel
0872afac6c Factor out vconfig's tstring variable interpolation...
...to formula_string_utils and document its issues
2010-05-30 21:22:58 +01:00
Alexander van Gessel
e0f819292f Split vconfig no-arg constructor into unconstructed_vconfig() and...
...empty_vconfig(), the latter of which is backed by an empty config
object, rather than NULL.

This should eliminate segfaults due to accidental dereferencing of
the nullpointer in default-constructed vconfigs
2010-05-25 01:54:52 +01: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
8119629789 Removed functions [v]config::all_children_iterator::get_index. 2010-04-05 06:00:00 +00:00
Guillaume Melquiond
bf148d8dd9 Switched variable_info::array_range to config::child_itors.
Fixed [set_variable/join] when separator and remove_empty attributes
are combined.
2010-04-05 05:59:53 +00:00
Guillaume Melquiond
ad3ebbba05 Removed locations from unit maps so that they are not duplicated.
As a side effect, iterators became much nicer, e.g. usable in foreach.
2010-03-28 10:42:41 +00:00
Guillaume Melquiond
bd9937e53c Renamed config::get_children...
...so that people stop adding it again and again in new places.
2010-03-27 18:49:19 +00:00
Guillaume Melquiond
8f32240573 Added accessors for the nth child of a config object. 2010-03-27 18:49:14 +00:00
Guillaume Melquiond
f451a8991b Removed usage of config::get_children. 2010-03-27 18:49:02 +00:00
Guillaume Melquiond
1896b603f1 Prevented t_string non-const references from being returned by functions.
(Original patch #1139 by Frank Richter.)

This avoids leaking an implementation detail from the config class and
opens the door to a considerable reduction of the memory footprint of
lexical data.
2010-03-27 09:32:58 +00:00
Mark de Wever
92f5f92ce5 New year copyright update. 2010-01-01 13:16:49 +00:00
Guillaume Melquiond
2ce41e58d2 Enabled warning only when dubious attributes/children are about to be created. 2009-12-24 08:22:09 +00:00