Commit Graph

53 Commits

Author SHA1 Message Date
Binrui Dong 9fdb7ef59c Run IWYU
* Change _ctype.h and __locale to cctype and clocale

* Change _wctype.h to cwctype in game.cpp

* Change __functional_base to functional

* Remove libcxx internal headers

* Remove UNIX system headers

* Fix clang-tidy error with -nostdinc++
2021-02-06 00:18:41 -05:00
John Bytheway b285a13080 Make time_point( int ) constructor explicit
Resolves a TODO on that constructor, and one more TODO elsewhere due to
the resulting refactoring.

time_point was implicitly convertible from int.  This led to unclear
code.  In particular, the item constructor took a time_point and a
quantity, and these two ints appeared adjacent with no obvious way to
see what they meant at call sites.

Make the constructor explicit, so the conversion is no longer implicit.
Update the rest of the code accordingly.

In most cases switched from 0 to calendar::turn_zero, which is
equivalent.  In a couple of places, used start_of_cataclysm instead,
when it seemed more appropriate (such as birthday of toilet water).
It's possible there are more cases which should have been something
other than turn_zero.
2020-11-10 11:21:02 -08:00
Aivean c32a629ceb replace all item flag constants with static string_ids
remove adapter has_flag (and related) methods that took string argument
change all remaining method signatures where item flags were passed as strings
2020-10-18 19:56:40 -07:00
RoyBerube 3370bf3b76 reference misuse 2020-10-02 13:32:20 -06:00
RoyBerube 61118f7fae Unit tests for liquid reload 2020-10-02 12:53:32 -06:00
Kevin Granade c5ccf0c2c7 IWYU for tests (#42806) 2020-08-09 09:46:57 +03:00
Kevin Granade 6d1841ac67 Precompiled Catch2 header (#42453)
* Hoist catch.hpp include to the top of files

* Precompile the catch header in tests
2020-07-29 01:28:26 +03:00
olanti-p 21138ba6e2 Get rid of game::unload 2020-07-14 13:02:30 +03:00
Kevin Granade cf21972870 Global reference migration part 21 (#41942) 2020-07-08 09:26:50 +03:00
KorGgenT efabc25ab0 update tests with new logic 2020-05-20 16:49:20 -04:00
John Bytheway b83fc88b9e Convert itype_id to string_id<itype>
itype_id is (presumably) one of the oldest type ids in the game.  In
particular, it predates string_id, and was simply a typedef of
std::string.

This is bad for type safety.

Make it be a string_id specialization instead, and update the rest of
the code accordingly.
2020-05-19 21:07:40 -04:00
floyza 339ff0c750 Make unloading items not pick them up (#40541) 2020-05-16 00:36:18 +00:00
KorGgenT 4d3d69fedc fix seg fault in reloading test 2020-05-02 16:05:27 -04:00
KorGgenT fa3920371d adjust reloading code to work (mostly) 2020-05-02 16:05:24 -04:00
KorGgenT b388a06c07 fix crashes in reload test 2020-05-02 16:05:19 -04:00
KorGgenT 223cb3997b Update reloading_test.cpp 2020-05-02 16:05:17 -04:00
KorGgenT c9f3f91c4a more reloading test work 2020-05-02 16:05:14 -04:00
KorGgenT 72a98a7962 reload test refactoring 2020-05-02 16:05:14 -04:00
KorGgenT 0bce062569 fix INT_MIN failures in reloading test 2020-05-02 16:05:14 -04:00
KorGgenT 09ee4e1b90 nested containers code 2020-05-02 16:02:49 -04:00
John Bytheway e189957ff2 Run IWYU 20200408 (#39364)
* Helper script to run IWYU

* Run IWYU

* Update deprecated headers

* Run IWYU again

* Re-suppress cxxabi.h

This pragma got accidentally removed because it was deemed to be a
comment attached to a #include.

* Remove extra SDL header includes

* Fix ime.cpp headers

Some tweaks to help IWYU not break this file by messing with
platform-specific stuff not relevant on Linux.

* Update game.h

* Move new point.h includes inside #ifdef

* Re-add platform_win.h to mapsharing.cpp

* Apply suggestions from code review

Co-authored-by: ZhilkinSerg <ZhilkinSerg@users.noreply.github.com>
2020-04-10 12:16:19 +03:00
Kevin Granade 5fa9146f83 Revert string centralization (#38321)
* Revert "Moved more string consts into single file (#38237)"

This reverts commit 49877426ce.

* Revert "Moved more string consts into single file (#38220)"

This reverts commit d9c6079762.

* Revert "Move string consts into single file (#38195)"

This reverts commit b1b48badff.

* Revert "More string consts into single file (#38189)"

This reverts commit 4fffd96143.

* Revert "More string consts into single file (#38183)"

This reverts commit 05940bfe3a.

* Revert "Move string consts into single file (#38184)"

This reverts commit 19c569826b.

* Revert "Move string consts into single file (#38181)"

This reverts commit 55cabb794c.

* Revert "Move more string consts into single file (#38175)"

This reverts commit 571efb2f8e.

* Revert "Merge pull request #38176 from Ramza13/string_consts_and_more"

This reverts commit 9c9835ff08, reversing
changes made to 07995cdda5.

* Revert "Move more string consts into single file (#38169)"

This reverts commit 07995cdda5.

* Revert "Merge pull request #38168 from Ramza13/even_more_string_consts"

This reverts commit 2bf1c1ea18, reversing
changes made to 24a32c0d1a.

* Revert "Merge pull request #38141 from ZhilkinSerg/sa-2020-02-18"

This reverts commit 142295b1dc, reversing
changes made to f98c67d3c3.

* Revert "Move string consts into single file (#38158)"

This reverts commit 50059c8a24.

* Revert "Merge pull request #38157 from Ramza13/string_consts_more_flags"

This reverts commit 8ec8e78959, reversing
changes made to 72ef0222a0.

* Revert "Move string_consts"

This reverts commit 0a6bf67436.

* Revert "Merge pull request #38146 from Ramza13/battery"

This reverts commit 9286722b74, reversing
changes made to e9f1cd7787.

* Revert "Merge pull request #38134 from AMurkin/rename-blob"

This reverts commit 06f72d2b7d, reversing
changes made to bcfe0741e1.

* Revert "Yet more string consts moved out (#38130)"

This reverts commit b5f18f3574.

* Revert "Merge pull request #38115 from Ramza13/string_consts_game"

This reverts commit 98076577b0, reversing
changes made to 036465f517.

* Fixup to the picked_up

* RE-inline item_location initialization

* Update character.h

* Update item.cpp

* Update item.h

* Update item_action.cpp

* Update item_factory.cpp

* Update point.h

* Update safemode_ui.cpp
2020-02-25 23:00:09 +03:00
Eric 55cabb794c Move string consts into single file (#38181) 2020-02-20 18:34:51 +03:00
John Bytheway fd0fe4fe5e clear_player -> clear_avatar, clear_character
The tests have a clear_player helper.  I wanted to use it with an NPC,
so I've split it into clear_avatar for the avatar, and clear_character
for a generic character.  Currently clear_character actually takes a
player& argument, because not all the things it clears are yet in
Character, but that's the direction we're headed.
2020-01-11 21:27:53 -05:00
John Bytheway 095bd51974 Use C++-style includes
Convert all C library includes to their C++ equivalents (stdio.h ->
cstdio, etc.).
2019-12-24 17:04:16 -05:00
Curtis Merrill 347a0ae7e1 refactor game::unload (#36125) 2019-12-17 02:14:46 +00:00
Isaac Freund 7f01c23df8 Create a new value_ptr type for use in itype
This cleans up the code considerably over the previous iteration
2019-12-09 22:42:11 +01:00
Isaac Freund f486176e64 Replace optional with unique pointer in itype
This results in reduced memory usage compared to optional
2019-12-09 22:39:28 +01:00
John Bytheway 4321c025d2 IWYU 20190629 (#31990)
* Add IWYU pragma: keep

* Run IWYU and astyle

* Run IWYU a second time

* Prevent #include <cxxabi.h>

Unclear why IWYU thinks this is needed.  It isn't, and it causes
problems on Visual Studio.
2019-07-01 12:25:53 +03:00
Matthew Taylor 64516a6b95 Allow items to use multiple ammotypes (#30874) 2019-06-12 19:27:31 -07:00
John Bytheway f3049e5eea Fix missing declarations (#30739)
* Fix missing declarations
Mark functions with no prior declarations as static, and remove the
unused ones.
* Move debug_is_safe_string definition
Put it inside !WIN32 since it's only used there.
2019-05-22 11:00:54 -07:00
KorGgenT f42afc59d4 test includes 2019-05-21 10:25:49 -04:00
John Bytheway e3e7700aef Apply IWYU changes
This is a run of IWYU followed by astyle.
2019-04-22 11:42:51 +01:00
eso 0944c64ced Add unbound keybinding entry which reloads without trying weapons first. 2019-04-10 21:24:03 -07:00
Kevin Granade fd0996979d remove leftover fragment of test 2019-03-22 08:39:16 -07:00
Kevin Granade b2ff110046 Refactor reload to only handle non-guns if everything else is reloaded 2019-03-22 06:01:35 +00:00
Kevin Granade fef00b8d58 Initial version of auto-reload test 2019-03-22 06:01:35 +00:00
Kevin Granade 6b680e00d3 Use player test helpers 2019-03-22 06:01:35 +00:00
ZhilkinSerg c0bce91fa1 Used const where appropriate 2019-01-06 23:00:08 +03:00
John Bytheway b0576393e3 Sort headers according to IWYU conventions
A first step towards IWYU support.  Doing the sorting first because it
makes reviewing any additions or removals of headers much simpler.

The IWYU order is:
- Associated headers
- Misc system headers
- C++ STL headers
- Other project headers

The biggest change is moving system headers before project headers (they
are usually afterwards in Cata at the moment.

The associated header for a cpp file is the header file which declares
the functions defined in that cpp file.  Normally that's the one which
shares the same name (up to extension), and if so IWYU figures it out
automatically.

However, in this project there are many corner cases, so we need to use
IWYU pragma: associated to tell it which header (or, in some cases,
which headers) is the associated header.  We are unusual in having
multiple associated headers for some files, which might lead to
discovering some interesting IWYU bugs later, but in theory it is
supported.
2019-01-05 14:03:31 +00:00
John Bytheway 2041e449d0 Fix unused variable warnings 2018-12-06 22:02:17 +00:00
BevapDin a74bfd0298 Use default_charges_tag instead of false to create items with default charges
`false` was used in the previous version of the item constructor.
2018-07-11 03:57:32 +00:00
Kevin Granade 2af2ae6e0f Add tests for reload_option 2018-03-22 02:20:49 +00:00
Kevin Granade d3482a4942 Add Speedloaders. 2018-03-22 02:20:49 +00:00
BevapDin a6d13d4b2a Store item slot objects in cata::optional wrappers
Instead of `std::unique_ptr` wrappers. Those slot objects are optional by design and don't need to be allocated separately.
2018-02-01 19:50:54 +01:00
Kevin Granade dd707981e5 Astyling, the revenge. 2017-08-02 05:11:39 +00:00
Kevin Granade 44c0bd04c2 Add some asserts and tags to reload tests. 2017-05-28 21:39:39 +00:00
codemime 1c937dd97b Replace lambda with list 2016-07-04 00:22:46 +03:00
codemime 4ed58fa423 Fix unit tests 2016-07-04 00:22:45 +03:00
Steven Noonan b7a6cbe295 unbreak reload_gun* tests
The 'reload_gun_with_integral_magazine' test wasn't using a gun with an
integral magazine. It also was using ammunition without a quantity.

The 'reload_gun_with_swappable_magazine' was assuming that the gun would be
created with a magazine already present in it. It wasn't, so I've added the
expected magazine type to the gun. I also fixed the null ammo quantity.

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
2016-04-16 22:59:46 +00:00