Commit Graph

84 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
ZhilkinSerg 0b6d4f0a7c Use const references in function parameters 2020-10-09 00:49:56 +03:00
ZhilkinSerg 9565c9d085 Removed empty lines, unused and empty declarators 2020-10-09 00:49:55 +03:00
Kevin Granade cdaeab6eeb Simpler array initialization 2020-10-06 20:08:11 +00:00
Kevin Granade a67e7a86ee Bracketses 2020-10-04 03:13:42 +00:00
Kevin Granade 1798da8581 shadowcasting benchmark 2020-10-02 05:02:18 +00:00
Kevin Granade 9f6b2467f7 Clarify some shadowcasting test details 2020-09-27 03:51:08 +00:00
Kevin Granade 88b79eebd1 Add a shadowcasting unit test 2020-09-27 03:51:08 +00:00
Isaac Freund df8ae4a895 Fix memory leak 2020-09-27 03:51:08 +00:00
Kevin Granade 32aa793933 Add some 3D tests. 2020-09-27 03:51:08 +00:00
Kevin Granade b10cb434a2 Extend shadowcasting test to 3D 2020-09-27 03:51:08 +00:00
Ivan Zaitsev 9b2264e1de Fix #44068 (thick smoke causes character sprite to disappear completely) + more (#44112)
* fix #44068 (thick smoke causes character sprite to disappear completely)
fix related issue with character disappearance in the low light
document transparency and related caches

* introduce `VISIBILITY_FULL=1.0f` constant as the starting value for visibility calculation
remove `LIGHT_TRANSPARENCY_CLEAR` usage from tests
fix the crouching case that breaks the tests

* add vision test case for the avatar fully surrounded by walls (or smoke)
2020-09-13 21:40:50 +03:00
John Bytheway bf910e50e3 Declare lots of things static
Use the new clang-tidy check to convert a bunch of declarations to
static.

In a few cases, there were 'secret' dependencies being exposed without
headers.  Convert those to work via headers instead.
2020-09-05 23:13:04 -04: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
ZhilkinSerg e32c4a8b30 Use constexpr instead of macros 2020-06-15 21:24:43 +03:00
John Bytheway 78cb7c199a Automated refactoring of remaining code 2020-06-12 08:29:42 -04:00
John Bytheway 79e544f702 Port even more functions to point
Previously missed things in the test code.
2020-06-09 08:51:05 -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
ZhilkinSerg e1f432d11f Code style (2020-01-13) (#37021)
* Appease clang
* Remove excessive empty lines
* Remove excessive whitespaces before semicolons
* Remove excessive empty lines (tests)
* Remove excessive whitespaces before semicolons (tests)
2020-01-14 01:31:43 +00:00
John Bytheway 9793bfac0e Use point in some more gui code (#34026)
* Consolidate main_menu::LAST_TERM

* Add some point overloads for functions

Also a suppression for an SDL wrapper function

* Refactor calls to new functions

* Port function implementations
2019-09-15 10:30:14 +03:00
John Bytheway ee8d5721bf Refactor callers of line functions 2019-08-18 19:59:00 -04:00
John Bytheway 7bda6884c3 Custom clang-tidy check to suggest use of named point constants (#33200)
* Initial version of UseNamedPointConstantsCheck

This is intended to convert hand-rolled point constants like
point( 0, 0 ) into point_zero.

* Apply refactoring pass

* Manual fixup of refactored code

Add various manual tweaks to the automatically refactored code where I
think it makes sense.

* Remove some unnecessary initializations
2019-08-13 23:04:51 +03:00
John Bytheway 453551807b Omit zero-init of points and tripoints
Explicitly zero-initializing is unnecessary, and to have some code that
does and other code that does not is potentially confusing.
2019-07-30 12:15:18 -04: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
John Bytheway a58d75539b Update printf format specifiers
Can't find any format specifier that works portably for int64_t (PRId64
is problematic on MSYS) so just use long longs instead.
2019-06-18 19:10:50 +01:00
John Bytheway e5127560e3 Use int64_t for microsecond counts 2019-06-18 07:43:38 +01:00
ZhilkinSerg 0d06a1316c Used constant references in tests 2019-05-31 17:12:27 +03:00
ZhilkinSerg 913d257b5c Used constant references in tests 2019-05-31 17:12:27 +03: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
John Bytheway f9e2cde24e Use specific RNG engine, not default_random_engine
To help tests behave the same on different platforms.

On libstdc++ std::default_random_engine is std::minstd_rand0, so this is
no change there, but may potentially bring other platforms in line.
2019-05-18 19:52:06 -07:00
John Bytheway e3e7700aef Apply IWYU changes
This is a run of IWYU followed by astyle.
2019-04-22 11:42:51 +01:00
ZhilkinSerg c0bce91fa1 Used const where appropriate 2019-01-06 23:00:08 +03:00
ZhilkinSerg f6d0b6af22 Removed redundant control flow statements 2019-01-06 22:03:20 +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
John Bytheway f2dde6349a Tests for shadowcasting float vs quad
An equivalence test and a microbenchmark.
2018-11-18 20:48:11 +00:00
John Bytheway 6184a4964b Prevent seeing light on walls from dark side
New lighting model to resolve the issue whereby walls appear bright when
they are lit from the other side.

For each opaque tile (such as a wall) we store four different lighting
values, one for each quadrant from which the lighting may come.  Then,
when determining the lightness of such a tile, we consider only those
values for the quadrants where we can also observe an adjacent tile in
that quadrant.
2018-11-18 20:48:10 +00:00
John Bytheway 555f74fc64 Factor out comparison and printing code
More common code in shadowcasting tests.
2018-11-16 22:32:27 +00:00
John Bytheway 384fc1e83b Factor out random transparency generation
This was the same code in two shadowcasting tests.
2018-11-16 22:32:27 +00:00
John Bytheway c63d113b07 Make static tripoints constexpr
Wherever possible, static objects should be constexpr to avoid static
initialization.

These are all the static tripoints I can find.

I found no static point objects.
2018-11-15 18:19:09 +00:00
ZhilkinSerg 33cc6a157e Used proper Boolean values instead of compile-time constants 2018-11-07 15:25:22 +03:00
ZhilkinSerg 410a32c031 Refactored C-style ( T ) ( x ) casts to static_cast<T>( x ) 2018-11-07 14:19:56 +03:00
ZhilkinSerg f8eb2acd05 Optimized includes (tests) 2018-11-07 03:55:47 +03:00
Kevin Granade daf96798ea Astyled shadowcasting_test.cpp 2018-09-08 22:18:24 +00:00
Kevin Granade fe1c0f3fc5 Templatize castLight and hoist castLightAll into lightmap module. 2018-08-24 02:52:04 +01:00
Kevin Granade ca9dacfe9c Update cast_zlight() to accept an accumulator method. 2018-08-03 02:04:31 +00:00
Kevin Granade 6853eca7aa Update castLight functions to accept a type argument. 2018-08-03 02:04:31 +00:00
Kevin Granade c616161df8 Add a wrapper for cast_zlight to avoid exposig all the scary messiness outside lightmap.cpp. 2018-08-03 02:04:31 +00:00
Kevin Granade f7e81bf33e Silence warnings in tests. 2018-04-29 19:51:41 +00:00