Commit graph

121 commits

Author SHA1 Message Date
josteph
8fd251b5da statistics: Move the hitrate_t ostream formatter to the correct namespace, to match the declaration. 2019-06-13 19:15:29 +00:00
josteph
4fb2aaa7ab Another code style change.
https://github.com/wesnoth/wesnoth/pull/4070#discussion_r290087743
2019-06-05 10:31:10 +00:00
josteph
ea2be9919e statistics: Simplify expression.
Thanks @jyrkive
2019-06-05 10:31:09 +00:00
josteph
949d77f950 statistics: Avoid magic strings
https://github.com/wesnoth/wesnoth/pull/4070#discussion_r283444754
2019-06-05 10:31:09 +00:00
josteph
584716054a Hit stats: Change serialization keys/values
https://github.com/wesnoth/wesnoth/pull/4070#discussion_r283119711
2019-06-05 10:31:09 +00:00
josteph
bad65044dc Hit stats: Rename a type to reflect its content rather than its use 2019-06-05 10:31:09 +00:00
josteph
ff5df5141e statistics: Coding style changes suggested by @jyrkive. 2019-06-05 10:31:09 +00:00
josteph
5f34300bf9 Hit stats: Introduce a hitrate_map typedef. 2019-06-05 10:31:09 +00:00
josteph
24b59cb2bf Hit stats: Don't serialize by_cth_inflicted/by_cth_taken
They're superfluous in the savefile; their values can be deserialized from the
existing [attacks]/[defends] tags and the new [attacks_taken]/[defends_taken]
info.
2019-06-05 10:31:09 +00:00
josteph
13cf420adb statistics: Add attacks_taken, defends_taken
They'll be used to reconstruct by_cth_taken, like
attacks_inflicted/defends_inflicted will be used to reconstruct
by_cth_inflicted.
2019-06-05 10:31:09 +00:00
josteph
479be6e61b statistics: Rename a class member
To match the convention. The next commit adds the *_taken member.
2019-06-05 10:31:09 +00:00
josteph
494bdc51f7 Hit stats: Track current turn stats too. 2019-06-05 10:31:09 +00:00
josteph
b52eb32ba2 Hit stats: Save and restore hit stats. 2019-06-05 10:31:09 +00:00
josteph
7eb75539a6 Hit stats: Track both inflicted and taken hits. 2019-06-05 10:31:09 +00:00
josteph
38641d667a Hit stats: Track number of hits/misses by CTH in statistics::stats objects. 2019-06-05 10:31:08 +00:00
josteph
d3c1cc43e7 Fix #2852: Reset statistics when rewinding a replay to the beginning.
Currently, while watching a replay of Scenario N, the statistics dialog
has the following options:

- All scenarios
- S1
- S2
- ...
- SN
- SN

The last option shows the statistics of Scenario N from the beginning
through the current point in the replay.  The other options show
end-of-scenario stats of each scenario and the cumulative stats of all
scenarios through the end of SN.

This patch causes the stats shown by the the second SN option to reset
to zero when the "reset replay" ("stop") button is selected.
2019-03-25 13:37:58 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0
(cherry-picked from commit bc4d22dc72)
2018-10-07 03:23:36 +00:00
gfgtdf
758fe79fe2 fix issues caused by empty save id
ee50171d13 broke some codes that relied on
unique save ids, that is in particular the statistic code and
scoped_recall_unit, so now these codes fallback to the side number if
the save id is empty.

(cherry-picked from commit c79e1645c8)
2018-10-07 03:22:27 +00:00
Charles Dang
d9fb6c0bf5 Catch all exceptions (where possible) as const references
A few catch blocks modify something in their exceptions, so those are kept non-const.

(cherry-picked from commit 2bf4d68c87)
2018-10-07 03:20:58 +00:00
Charles Dang
2a6d9454de Replaced round_double and round_portable with std::round
std::round(double) uses the desired half-away-from-0 method.

(cherry-picked from commit 29fcbd053d)
2018-10-07 03:19:14 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f693)
2018-10-07 03:17:59 +00:00
Charles Dang
950a156712 Addressed most of the remaining whitespace issues from #2613
[ci skip]
2018-03-11 14:59:37 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
2f4f0d03c5 Deployed a few more cases of vector::emplace_back and deque::emplace_back 2017-05-22 13:12:32 +11:00
Charles Dang
5d6a37f990 Even more deployment of display_context::get_team 2017-04-26 10:23:19 +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
Charles Dang
4d48ed1319 Cleaned up util.hpp includes 2016-12-08 14:21:18 +11:00
Charles Dang
a477eb4014 Fixup 1a25d297b8 (unused variable)
This function can likely be removed now, but I don't want to do it just yet.
2016-09-16 23:34:43 +11:00
Wedge009
1a25d297b8 Don't duplicate recall count decrement when undoing a recall (bug #25060)
Looks like un_recall_unit_cost() is used to retrieve the unit cost of the recalled unit but it also decrements the recall count, duplicating the decrement in un_recall_unit().
2016-09-16 21:53:59 +10:00
Charles Dang
6235e18bbd Replace resources::teams with resources::gameboard->teams() 2016-08-11 07:27:48 +11:00
Celtic Minstrel
fba34c1eee Don't use unit IDs as WML keys when saving statistics 2016-08-08 21:16:30 -04:00
Celtic Minstrel
ca382018b7 BOOST_FOREACH -> range for 2016-04-02 09:38:29 -04:00
Celtic Minstrel
bc711f5f43 Consolidate related files into subdirectories 2016-03-20 16:20:09 -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
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Chris Beck
ee6b3ca02a move a barely used function out of unit into statistics 2014-07-06 16:19:25 -04:00
Mark de Wever
e35f4bb501 Strip trailing whitespace. 2014-06-09 15:26:19 +02: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
Aishiko
c6d11a5f5e Implement unit instance recall costs.
Actually allows for the unit instance recall costs to be used. Proper
taking of the gold and undoing the cost for each unit is implemented
and works.  At advancement if the unit's current recall matches their
unit_type's recall_cost then it takes the new unit_type's recall_cost
otherwise it keeps whatever value it currently has until it fails this
check.  Recall costs are also now persistant and will carry over from
one scenario into the next as well.

If a cost is not set, it will continue to use the team/side/default
costs, these changes should not affect the current workings when
dealing with unaltered scenarios, and unit config files.  I repeat This
will not affect or change the currently way things work UNLESS a user
alters a file or includes the new recall_cost (as in copies and
modifies a unit in the scenario unit files) for a unit instance in
their scenario file(s).
2014-03-17 17:49:15 -04:00
Ignacio R. Morelle
a4f47a63c7 New Year copyright update 2014-01-01 02:08:52 -03:00
Alexander van Gessel
20b0f3ac94 Fix a nullref if an unknown unit type is present in the statistics
Found by coverity
2013-12-08 00:23:38 +01:00
Eric S. Raymond
043c4f9fd3 Remove $Id$ cookies. 2013-03-26 21:41:37 -04:00
J. Tyne
d66a950a31 Keep track of the original unit type ID (variations can override it).
Use the original (base) ID when creating units.
2013-01-20 02:43:38 +00:00
Mark de Wever
43b71f2ff0 New year copyright update. 2013-01-01 09:22:03 +00:00
J. Tyne
acf390f95d Sync the data written in the two stats::write() functions. 2012-12-14 21:05:41 +00:00
J. Tyne
6edf508c1b Eliminate some unneeded conversions to strings. 2012-12-14 20:00:08 +00:00
J. Tyne
f0222685ae Make use of the new conversions from attribute_value to numeric types. 2012-12-14 16:01:49 +00:00
J. Tyne
1f68e0bb48 Add display of per-scenario statistics. 2012-09-08 19:02:29 +00:00
J. Tyne
887b552b1b Simplify the implementation of statistics::calculate_stats(). 2012-09-08 16:17:27 +00:00