45 Commits

Author SHA1 Message Date
Mark de Wever
5d3e36b2ff Let operator= return a reference.
Issue found by cppcheck.
2012-11-03 15:08:45 +00:00
Ignacio R. Morelle
6ca69b2df5 New year copyright update 2012-01-07 02:35:17 +00:00
Mark de Wever
8ef22b2269 Let operator++() return a reference. 2011-09-28 19:21:16 +00:00
Anonymissimus
69c0e582d7 fixed compilation in MSVC
mordante: cmath apparently doesn't contain round() here, and round()
also seems not guaranteed to yield consistent results
on different platforms (as opposed to round_portable according to
what its comment says)
(bug #18165)
2011-06-05 17:11:15 +00:00
Mark de Wever
5e5ebdad23 Add missing copyright headers. 2011-06-05 09:31:11 +00:00
Mark de Wever
7f3b536112 Possibly fixes errors when using ^ in formulas.
The previous implementation truncated instead of rounded, also
increase the precision of the calculations. (Possibly fixes bug
#18165).
2011-06-05 09:25:05 +00:00
Mark de Wever
f873fd0bb2 Fixes issues with singular variant iterators.
The variant_iterator class used singular iterators in several cases,
which lead to undefined behaviour. The following changes have been made:

- Removed variant::get_iterator() it always returned singular iterators,
  also updated all callers.

- Fixed construction and copying in variant_iterator to not copy
  singular iterators.

- Added doxygen comment.
2011-06-02 11:53:12 +00:00
Alexander van Gessel
6ff8ec8748 Make type_error and parse_error inherit from game::error 2010-08-07 02:21:29 +01:00
Mark de Wever
4b8f17ceb3 Pass parameter by const ref instead of const value.
Issue found by cppcheck.
2009-10-02 19:25:06 +00:00
Mark de Wever
b23d3bf2f4 Initialize all members. 2009-09-11 19:57:15 +00:00
Mark de Wever
671b0b256c Strip trailing whitespace. 2009-08-29 18:46:38 +00:00
Tomasz Śniatowski
ef0805deab int64_t -> long long to avoid a MSVC problem...
...or having to include a boost header just for that
2009-08-15 09:07:54 +01:00
Bartek Waresiak
debc721016 New formula functions: as_decimal, ceil, floor, round 2009-08-14 23:43:33 +00:00
Bartek Waresiak
bf95928eca Allow comparision between integer and fixed point in formula language 2009-08-14 15:12:10 +00:00
Bartek Waresiak
b1baf2e36f Added fixed-point arythmetic for formula language 2009-08-14 12:35:36 +00:00
Iurii Chernyi
423667731a added basic tracing capabilities to formula_debugger 2009-08-11 20:15:19 +00:00
Bartek Waresiak
3bb651f0f4 Added safe_call() formula function...
...that allows execution of 'backup formula' in case of failure, made
formula check for action result and return appriopriate error number
in case of error. It's still a bit WIP, but it should be good enough
for now
2009-07-11 10:27:12 +00:00
Bartek Waresiak
5a720bcb1d Added operators: .+ .- .* ./ for formula language 2009-07-04 21:16:39 +00:00
Bartek Waresiak
c50c39edc6 Made debug_print print complete info to the console 2009-06-24 09:09:05 +00:00
Mark de Wever
973a0a7d5c Remove trailing whitespace. 2009-01-01 10:28:26 +00:00
Eric S. Raymond
9223460daa Remove unused headers. 2008-11-09 04:35:13 +00:00
Mark de Wever
d438f80f12 Added a MSVC 9 projectfile and some fixes for that compiler (patch #1093). 2008-08-17 08:07:54 +00:00
Bartek Waresiak
0949ad9539 Made variant_map use [] brackets instead of {} ones 2008-07-25 22:58:43 +00:00
Bartek Waresiak
118debb437 Fix to variant_iterator 2008-06-28 10:42:14 +00:00
Bartek Waresiak
0c37c667e3 [[Engine improvements]]
* added variant_iterator to iterate over variant elements

* added key_value_pair class, used while iterating over variant_list and
  variant_map type

* fixed bug in map, filter and find formula functions, which caused game to
  crash when optional parameter was specified and self was used within a 
  function formula

* changed choose, filter, find and map funcions, to use new variant_iterator
  so they work for both variant_lists and variant_maps now

* added tolist formula function
2008-06-28 08:47:15 +00:00
Mark de Wever
bd43678f2a Added comment to the formatter class, based on what Sirp said on IRC.
Removed the implicit string conversion and fixed the users. 

Added svn $id$.
2008-06-17 17:29:53 +00:00
Bartek Waresiak
664cf01cc7 New formula AI function: unit_chooser 2008-05-21 18:23:55 +00:00
Mark de Wever
7e993d3f78 Make sure #include "variant.hpp" can be used...
...without the need to include more items.

Cleaned a duplicate in variant.cpp.
2008-04-12 09:31:59 +00:00
Bartek Waresiak
43a4d8a62a Added new formula functions: keys() and values()
Added support for [] operator, examples:

[1, 2, 3][0] returns 1,

{'elf' -> 1, 'orc' -> 2}['orc'] returns 2
2008-04-10 22:11:46 +00:00
Bartek Waresiak
980047b054 Add support for a map to the formula system
Syntax:

{ 'elvish fighter' -> 40, 'elvish archer' -> 30 }

Changed comments in the formula system from

{ text of a comment }  to  # text of a comment #
2008-04-09 18:36:16 +00:00
Tomasz Śniatowski
9869a97a66 Worked around a number of signed/unisgned comparison warnings...
...and unused var warnings.

Mostly changed int to size_t or used static_cast, and commented out
the unused variables.
2008-04-06 16:47:16 +01:00
David White
a86d16a8db fixed behavior of map function 2008-04-02 05:33:53 +00:00
David White
7538016574 some fixes to unit specific formulas 2008-03-21 06:58:19 +00:00
Benoît Timbert
584c664cba Fix some svn properties (eol style=native; keyword substitution) 2008-03-09 16:41:10 +00:00
Bartek Waresiak
bdb646c440 Small fixes for variant's operator<= 2008-03-08 19:11:57 +00:00
Mark de Wever
11aa3625ca Silence some compiler warnings.
Sirp please check whether the warnings in variant.cpp were really
false positives.
2008-03-08 16:23:53 +00:00
Bruno Wolff III
6f6c69062c Missing include was blocking compilation on Fedora rawhide using gcc 4.3
(and probably other systems).
2008-03-08 14:58:18 +00:00
Patrick Parker
0df73b3a1c get another one working for my outdated compiler 2008-03-05 04:59:05 +00:00
David White
ba2a4c2ad4 merged in formula AI branch 2008-03-03 05:40:29 +00:00
Bartek Waresiak
231ad8cd90 Small fix for the operator<= 2008-03-02 19:57:40 +00:00
Bartek Waresiak
117f16f8ec Added missing variant destructor 2008-02-28 22:49:04 +00:00
Bartek Waresiak
3805bbffc6 Small fix: added increment_refcount(); to variant's constructors 2008-02-28 21:47:28 +00:00
David White
1be59961e3 changes to improve formula AI 2008-02-23 16:38:09 +00:00
David White
d9d5905b69 added very basic AI which uses the formula AI 2008-02-03 18:59:40 +00:00
David White
5c0df60c23 initial branch changes 2008-01-28 03:04:25 +00:00