Commit Graph

283 Commits

Author SHA1 Message Date
glx22 ce813ce644 Cleanup: Remove now unused FOR_EACH_SET_BIT_EX macro 2021-07-09 21:36:09 +02:00
glx22 89ab8b79a5 Codechange: Remove FOR_EACH_SET_BIT 2021-07-09 21:36:09 +02:00
Patric Stout 7dd5fd6ed4 Feature: framework to make savegames self-descriptive
We won't be able to make it fully self-descriptive (looking at you
MAP-chunks), but anything else can. With this framework, we can
add headers for each chunk explaining how each chunk looks like
in detail.

They also will all be tables, making it a lot easier to read in
external tooling, and opening the way to consider a database
(like SQLite) to use as savegame format.

Lastly, with the headers in the savegame, you can freely add
fields without needing a savegame version bump; older versions
of OpenTTD will simply ignore the new field. This also means
we can remove all the SLE_CONDNULL, as they are irrelevant.

The next few commits will start using this framework.
2021-07-02 22:21:58 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
Patric Stout 28e90769f7 Codechange: use "[[maybe_unused]]" instead of a wide variety of other ways we had
While at it, replace OTTD_ASSERT with WITH_ASSERT, as this
is always set if assert() is valid. No matter if NDEBUG is set
or not.
2021-06-03 17:30:00 +02:00
Patric Stout 9fff00ba20
Codechange: C++-ify lists for SaveLoad (#9323)
Basically, this changes "SaveLoad *" to either:
1) "SaveLoadTable" if a list of SaveLoads was meant
2) "SaveLoad &" if a single entry was meant

As added bonus, this removes SL_END / SLE_END / SLEG_END. This
also adds core/span.hpp, a "std::span"-lite.
2021-05-31 22:26:44 +02:00
rubidium42 b9797a81c0 Codechange: pass large parameter by reference instead of value, especially in a recursive function 2021-05-27 18:30:56 +02:00
Peter Nelson 5ff15443e9 Cleanup: Replace single-use Pair struct with std::pair.
This struct is defined in geometry_type but not used by any geometry-related
code, only for subsidy code where both parameters are cast from int to
NewsReferenceType.
2021-04-21 21:39:00 +02:00
Patric Stout 4d501655ad
Fix: building on Raspberry Pi failed because of const vs constexpr (#8924) 2021-04-01 19:39:55 +02:00
Patric Stout 8e0d48a0f6
Fix: [SDL2] simplify what to redraw to prevent tearing (#8685)
When there are a lot of rects to redraw, of which one of the last
ones is almost the full screen, visual tearing happens over the
vertical axis. This is most visible when scrolling the map.

This can be prevented by using less rects. To simplify the situation,
and as solutions like OpenGL need this anyway, keep a single rect
that shows the biggest size that updates everything correctly.

Although this means it needs a bit more time redrawing where it
is strictly seen not needed, it also means less commands have
to be executed in the backend. In the end, this is a trade-off,
and from experiments it seems the approach of this commit gives
a better result.
2021-02-17 21:19:32 +01:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
Charles Pigott 860c270c73 Codechange: Replace assert_compile macro with static_assert 2020-12-27 10:55:42 +00:00
Michael Lutz 79240eab1e Codechange: Make use of the improved C++17 emplace_back function. 2020-12-15 00:29:30 +01:00
TechGeekNZ 716c883737 Fix: Globally apply preprocessor directive coding style
Global; except for the 32-bit SSE blitter, which has some #DEFINEs
in not-very-nice places.
2020-07-03 09:08:46 +02:00
Patric Stout 56d54cf60e Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.

Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.

This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.

Addtiionally, this heavily improves our detection of libraries, etc.
2020-06-05 19:36:05 +02:00
Michael Lutz f2b40f40aa Codechange: Replace SmallPair with std::pair.
std::pair is already the smallest possible pair, and it already handles non-POD types correctly.
2020-05-21 20:02:34 +02:00
Charlène 2196cd3cf8 Fix: OpenBSD endianness detection 2020-02-11 13:01:45 +00:00
Jonathan G Rennison 150dfba95b Codechange: Remove std::function from Pool iteration wrapper
Add a separate template wrapper for filtered iteration
2020-01-07 09:00:45 +00:00
glx e3c75a30ba Fix: unused variable warnings 2019-12-21 20:13:03 +01:00
glx ae532008ff Cleanup: remove FOR_ALL_ITEMS 2019-12-21 20:13:03 +01:00
glx 68f22134cb Add: Allow iteration of pools in range-based for loops 2019-12-21 20:13:03 +01:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Gabda 652fb40652 Codechange: Performance improvement in k-d tree FindNearest() 2019-10-08 08:53:19 +02:00
JMcKiern 04f659e768 Fix: Some typos found using codespell 2019-09-29 21:27:32 +01:00
Nikolas Nyby 28e11623bd Codechange: math functions - use cpp-style casts 2019-08-31 20:27:56 +01:00
Gabda b870596f15 Add #6887: Option to show zone inside local authority boundary of towns
Can be found at town information > local authority window
Layout for button is same as Graph Keys
Turn on/off for every town individually
2019-08-17 21:45:20 +01:00
glx 26aa3b8623 Remove: grow() helper function 2019-05-04 19:50:53 +01:00
Charles Pigott 9e19a5f93e Remove: (Simple)TinyEnumT 2019-04-29 17:40:22 +01:00
peter1138 66cd32a252 Codechange: Use std::underlying_type for DECLARE_POSTFIX_INCREMENT. 2019-04-21 22:31:12 +01:00
peter1138 ac1e1a272f Fix: Replace int with std::underlying_type in DECLARE_ENUM_AS_BIT_SET.
This fixes 64 bit uses of this macro.
2019-04-21 22:31:12 +01:00
glx ebd4f32d15 Cleanup: remove core/sort_func.hpp as it's not used anymore 2019-04-18 21:49:34 +02:00
glx 9195f2337a Codechange: use std::vector for _resolutions 2019-04-18 21:49:34 +02:00
Michael Lutz 38729297f9 Codechange: No need for AutoFreePtr if there's std::unique_ptr. 2019-04-15 22:52:50 +01:00
Michael Lutz 4e85ccf3c0 Codechange: Replace SmallStackSafeStackAlloc with std::array.
The only port that ever used it to make heap allocations instead of stack ones was the NDS port, which got thrown out some time ago.
2019-04-15 22:52:50 +01:00
glx 410b81537c Fix 801cbea9c: operator< is not always the best idea
Also removes unused and anyway broken SmallMap::SortByKey() function.
2019-04-13 21:05:25 +02:00
glx 801cbea9cc Codechange: use std::sort() for all std::vector types 2019-04-13 12:49:18 +01:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Michael Lutz 8b1880187a Remove: AutoFreeSmallVector.
The last use was for storing a list of memory blocks. As the way these lists are accessed is very
specific, it is easier to just write an explicit destructor instead of trying to exactly match the behaviour.
2019-04-09 22:45:15 +02:00
Michael Lutz e804173595 Codechange: If something is a vector of strings, use a vector of strings instead of an AutoFreeSmallVector. 2019-04-09 22:45:15 +02:00
Michael Lutz c7b9987d08 Codechange: Switch DropDownList to directly use std::vector, thus making AutoDeleteSmallVector obsolete.
DropDownListItem are strongly managed using std::unique_ptr to ensure leak-free handling. Appropriate use
of move-semantics make intent a lot clearer than parameter comments and allows the compiler to generate
copy-free code for most situations.
2019-04-09 22:45:15 +02:00
Michael Lutz 05f4e73608 Codechange: Replace custom mutex code with C++11 mutex'es.
A conforming compiler with a valid <mutex>-header is expected.
Most parts of the code assume that locking a mutex will never fail unexpectedly,
which is generally true on all common platforms that don't just pretend to
be C++11. The use of condition variables in driver code is checked.
2019-04-06 11:27:39 +02:00
Michael Lutz 21d9e87b46 Fix #7165: Const overload SmallMap::Contains(key) compared wrong types.
Const and non-const Find() have different return types.
2019-03-28 00:04:28 +00:00
stormcone ee260e4704 Fix #7165: SmallMap::Erase(key) does not work correctly 2019-03-28 00:04:28 +00:00
glx22 66dd7c3879
Fix: MSVC warnings (#7423) 2019-03-28 00:09:33 +01:00
Charles Pigott ed9005690a Fix #7421: Don't (directly) dereference std::vector::end() in SmallMap 2019-03-27 06:31:49 +00:00
Henry Wilson 03ca3190c9 Codechange: Use range-based for-loop in Auto[Free|Delete]SmallVector 2019-03-26 20:15:57 +00:00
Henry Wilson cc62f4163f Cleanup: Remove unused size template parameters from SmallMap and Auto[Free|Delete]SmallVector 2019-03-26 20:15:57 +00:00
Henry Wilson c01a2e2a81 Codechange: Removed SmallVector completely 2019-03-26 20:15:57 +00:00
Henry Wilson 6570f7989f Codechange: Declare SmallVector as an alias for std::vector 2019-03-26 20:15:57 +00:00
Henry Wilson ab711e6942 Codechange: Replaced SmallVector::[Begin|End]() with std alternatives 2019-03-26 20:15:57 +00:00