Commit Graph

215 Commits

Author SHA1 Message Date
Peter Nelson
908ee7292b
Codechange: Replace all FILE * with FileHandle RAII class. (#12718)
This removes the need to manually ensure all files are closed.
2024-09-16 08:45:26 +01:00
Peter Nelson
100dd7b6d1
Codechange: Use find_if to get default writeable saveload format. (#12849)
* Codechange: Use find_if to get default writeable savegame format.

This removes the last of lastof, and so the lastof macro is removed.
2024-07-09 17:07:40 +01:00
Rubidium
c377c4740d Codechange: replace cpp_lengthof with safe alternatives 2024-04-20 13:36:19 +02:00
Rubidium
434c49a1f8 Codechange: remove now unused endof macro 2024-04-20 11:30:46 +02:00
Peter Nelson
a28ab8cac2
Codechange: Replace C-style casts to size_t with static_cast. (#12455)
* Codechange: Replace C-style casts to size_t with static_cast.

This touches only simple value-type casts.

* Codechange: Replace static_cast<size_t>(-1) with SIZE_MAX

Co-authored-by: Rubidium <rubidium@openttd.org>
2024-04-19 20:34:36 +01:00
Peter Nelson
4eaeccdaeb
Codechange: Introduce FioRemove() to remove files. (#12491)
New function FioRemove() handles OTTD2FS conversion, and uses std::filesystem::remove instead of unlink, all in one location.
2024-04-14 23:43:50 +01:00
Rubidium
97bea563d7 Codechange: let lengthof fail when anything that isn't a C-style array is passed 2024-04-06 07:21:31 +02:00
Rubidium
caa7c44052 Cleanup: remove checks for old MSVC versions 2024-03-24 10:09:15 +01:00
Patric Stout
a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Rubidium
e4b3f3f495 Codechange: use std::source_location over __FILE__ and __LINE__ for NOT_REACHED 2024-03-10 10:14:20 +01:00
Rubidium
bab5a8a787 Codechange: use std::source_location over __FILE__ and __LINE__ for Backup 2024-03-10 10:14:20 +01:00
frosch
b1718478c8 Codechange: Replace old non-standard attributes with C++17/20 standard attributes. 2024-02-02 22:29:28 +01:00
frosch
4d2fc28834 Codechange: wrap 'if' in macros into 'do { ... } while (false)', so it does not break on following 'else'. 2024-01-30 23:43:42 +01:00
Rubidium
47c0184a0b Codechange: replace ROR/ROL with std::rotr/rotl 2024-01-17 23:05:40 +01:00
Patric Stout
fd073a2810 Remove: replace custom span with std::span 2024-01-17 00:25:08 +01:00
Rubidium
3a676a5af0 Codechange: replace static inline with static for non-class functions 2024-01-06 13:37:33 +01:00
Rubidium
4cf88e068a Remove: unused include of cstdarg/stdarg.h 2023-09-16 23:09:53 +02:00
Patric Stout
d725fa14a2
Fix: asserts unintentially being partially disabled in release-builds (#11268)
The nlohmann-json header file includes assert.h, which rudely resets
the assert macro to what that header thinks is right. As we set the
assert macro to be active with release builds when WITH_ASSERT is
active, this means that every file including nlohmann-json has their
asserts disabled (for release-builds) but files that don't do no.

Let's avoid this issue, by telling nlohmann to not include assert.h.
2023-09-08 10:11:37 +00:00
Patric Stout
cd10ddf9ae
Remove: last remnants of SunOS (#11210)
We have no evidence SunOS has been tried in the last few years,
and the code is awkward enough to just remove.
2023-08-19 00:52:58 +02:00
Patric Stout
299570b2c1
Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761) 2023-08-12 18:14:21 +00:00
Patric Stout
0238a2b567
Codechange: use std::variant instead of using bitflags in the value (#11191) 2023-08-12 16:05:00 +00:00
Rubidium
461b4b8861 Cleanup: remove typedefs for non _t (u)int types and WChar 2023-07-19 19:30:14 +02:00
Owen Rudge
1a3d1bca59 Remove: OS/2 port 2023-06-16 14:29:14 +01:00
Rubidium
48dcb79145 Cleanup: remove seprintf and vsnprintf 2023-06-09 06:41:33 +02:00
Peter Nelson
f177ce7c9a Codechange: Base CargoArray off std::array.
This avoids needing to define array accessors and allows use of
default value initialization.
2023-05-23 19:07:36 +01:00
Rubidium
a19a43a4f7 Codechange: use fmt::format and time conversions over "custom" implementation 2023-05-22 15:36:09 +02:00
Peter Nelson
56085be9bd Codechange: Move includes for common STL headers to stdafx. 2023-05-17 10:14:41 +01:00
Rubidium
68ff3fd062 Change: include fmt.h C++ headers in stdafx.h
This to prevent compilation issues between runs with and without precompiled
headers. Also remove the headers from the rest of the code base as they are
not needed there anymore, although they do relatively little harm.
2023-05-08 16:49:23 +02:00
Rubidium
4dd5f994be Codechange: replace strncasecmp with case ignoring variant of StrStarts/EndsWith 2023-04-29 10:25:25 +02:00
PeterN
57f2d70fef
Change: Use cstdint instead of rolling our own types. (#10651) 2023-04-27 10:04:18 +02:00
Rubidium
75cd790ab9 Codechange: use fmt::format for FormatHexNumber 2023-04-26 18:46:17 +02:00
Charles Pigott
80bd5ad727
Codechange: Use std::strto* variants everywhere (#10720) 2023-04-26 12:56:14 +01:00
Rubidium
f74e26ca7e Codechange: replace error/usererror printf variant with fmt variant and rename 2023-04-25 17:55:09 +02:00
Rubidium
dfe52da1ea Codechange: use string/fmt instead of print for strgen warnings/errors/fatals 2023-04-18 23:20:53 +02:00
Charles Pigott
6fc28d649e Cleanup: Unused alloca definitions and includes 2023-04-15 16:57:00 +01:00
Patric Stout
5e1bcee39b Codechange: introduce a framework for all our timers
IntervalTimer and TimeoutTimer use RAII, and can be used to replace
all the time-based timeouts, lag-detection, "execute every N" we
have.
As it uses RAII, you can safely use it as static variable, class
member, temporary variable, etc. As soon as it goes out-of-scope,
it will be safely removed.
This allows for much easier to read code when it comes to intervals.
2023-04-15 13:58:55 +02:00
Rubidium
b7a5d8e296 Codechange: add annotation to selectively force inlining in debug build 2023-01-28 20:32:45 +01:00
dP
548f0496a9
Change: Make _tick_counter 64bit to avoid wrapping (#10035) 2022-09-21 12:42:29 +02:00
glx22
bba6ad1f4e Fix #9935: Use more selectivity when building SSE specific code 2022-08-26 19:36:18 +02:00
rubidium42
a99ac62c1a Codechange: use the fmt library for simpler debug formats 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
f8dd5dd00a Codechange: remove unused assert_msg() macro 2021-06-03 17:30:00 +02:00
milek7
7607277380 Fix: Network on Haiku, remove old code for BeOS 2021-05-24 08:56:18 +02:00
rubidium42
aa5a8fe28a Codechange: use thread safe time functions
Functions like localtime, gmtime and asctime are not thread safe as they (might) reuse the same buffer. So use the safer _s/_r variant for localtime and gmtime, and use strftime in favour of asctime.
2021-05-14 23:22:29 +02:00
embeddedt
a879996012
Fix: [Emscripten] Use non-XDG directories to simplify lolac storage (#9207) 2021-05-08 09:43:17 +02:00
Loïc Guilloux
356bbbb90a
Fix: [MinGW] Set minimum OS version to Windows XP (#9135) 2021-04-29 14:26:08 +02:00
Milek7
8e9eca6ddd
Codechange: Use __attribute__ access none to silence GCC 11 -Wmaybe-uninitialized warnings (#9124) 2021-04-28 22:06:47 +01:00
Wim Leflere
9aebfca083
Fix: clang-cl build (#9018)
Remove macro redefinitions
Add final and fallthrough attributes for clang-cl
2021-04-11 14:15:37 +01:00
Niels Martin Hansen
746f1ca11a Codechange: Remove the now meaningless console_cp parameter from OTTD2FS 2021-04-07 09:31:47 +02:00
Niels Martin Hansen
e0561dbded Fix #8713: Change OTTD2FS and FS2OTTD to return string objects instead of static buffers 2021-04-07 09:31:47 +02:00