Commit Graph

158 Commits

Author SHA1 Message Date
Rubidium 77c188e6da Codechange: use std::vector instead of malloced array 2024-05-12 12:55:52 +02:00
Rubidium 6cea49c117 Codechange: replace uint with size_t in binary heap 2024-05-12 12:55:52 +02:00
Peter Nelson d074ab909c
Codechange: Replace Array/FixedSizeArray with std::deque. (#12409)
Array/FixedSizeArray is actually a resizeable container that allocates space in chunks and allows resizing without invalidating pointers.

This is also a behaviour of std::deque, so use that instead.
2024-05-04 10:55:16 +01:00
Peter Nelson 40fa45a76a Codechange: Emplace std::pair into vectors.
This creates the pair in the vector, instead of creating it then copying it in.
2024-04-20 10:25:20 +01: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
Rubidium afd7878de0 Codechange: internally use a span of arguments for GetOptData 2024-04-11 12:00:36 +02:00
Rubidium 5592b4409b Codechange: use ranged for loop and separate function instead of goto 2024-04-11 12:00:36 +02:00
Rubidium e8a56db21d Codechange: use designated initializers for OptionData and pass as span 2024-04-11 12:00:36 +02:00
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Patric Stout fd073a2810 Remove: replace custom span with std::span 2024-01-17 00:25:08 +01:00
Rubidium e3f49ee7a0 Codechange: coding style fixes 2024-01-04 16:23:54 +01:00
Peter Nelson d4008850e3 Codechange: Ensure function opening `{` is on new line. 2023-11-09 20:15:38 +00:00
Peter Nelson ab535c0a86
Codechange: Add base() method to StrongType to allow access to the base type without casting. (#11445)
This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
2023-11-06 20:29:35 +00:00
Rubidium f16399f4c9 Codechange: replace x.size() > 0 with !x.empty() 2023-10-20 23:05:43 +02:00
Patric Stout 07730584d7
Codechange: make explicit when a TileIndex is cast to its basetype (#11190)
This prevents people accidentially assigning a TileIndex to a Date
or any other type they shouldn't.
2023-08-15 18:12:05 +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 5fba47b0f7
Codechange: make no assumptions on how the internals of TileIndex work (#11183)
Basically, avoid ".value", and just cast it to its original type
if you want to retrieve this.
2023-08-11 14:53:51 +02:00
Rubidium eaae0bb5e7 Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
Rubidium 84037d4a57 Codechange: use std::string for parameters in the dbg_helpers 2023-06-04 15:56:53 +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
Peter Nelson 9f26e74e1e Codechange: Rename item_t to Item. 2023-04-24 09:17:37 +01:00
Rubidium 71b46db8d0 Cleanup: remove commented out code 2023-01-26 23:47:55 +01:00
PeterN 4031894aef
Cleanup: Remove svn-style `$Id$` comments. (#10122) 2022-11-01 18:24:31 -06:00
Michael Lutz 13528bfcd0 Codechange: Un-bitstuff all remaining commands. 2021-12-16 22:28:32 +01:00
Michael Lutz a05fd7aa50 Change: [Network] Transfer command data as serialized byte stream without fixed structure.
The data will be transmitted as the length followed by the serialized data. This allows the command
data to be different for every command type in the future.
2021-12-16 22:28:32 +01: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
rubidium42 9197de39e4 Cleanup: remove unused copy-constructor without copy-assignment 2021-05-27 18:30:56 +02:00
Charles Pigott e8a94dc8bb Cleanup: Delete remaining Blob code 2021-04-04 08:01:54 +01:00
Charles Pigott f481c9fc2c Codechange: Replace CStrA with std::string 2021-04-04 08:01:54 +01:00
Patric Stout fece1c57ca
Codechange: Suppress warnings when asserts are disabled (#8917) 2021-04-01 11:16:19 +02:00
Michael Lutz 1e1a9f3999 Add: A simple, templated cache map that uses a least recently used eviction strategy. 2021-02-22 22:16:07 +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
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
Charles Pigott 64b1c70fdd Codechange: Add WARN_FORMAT to vseprintf and fix the cascade of warnings that followed 2020-06-27 14:51:14 +01: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
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
JMcKiern 04f659e768 Fix: Some typos found using codespell 2019-09-29 21:27:32 +01:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Charles Pigott f5b1115039 Doc: Lots and lots of doxymentation fixes 2018-10-31 12:35:54 +01:00
PeterN 8a7de36463
Change [#6689]: Tweak HashTable hash calculation to reduce collisions. (kernigh2) (#6786) 2018-05-19 22:04:25 +01:00
frosch e5d105900d (svn r27379) -Codechange: Do not throw in the destructors of ScriptTest/ExecMode. 2015-08-10 20:04:31 +00:00
alberth 1105b4d2c9 (svn r27363) -Codechange: Fix codestyle of one-line methods and header codestyle of derived structs. 2015-08-08 13:19:38 +00:00
alberth b885d79f50 (svn r27362) -Codechange: Codestyle fixes for reference var declarations, static cast type, operator methods. 2015-08-08 10:06:24 +00:00
rubidium e61fe21237 (svn r26506) -Codechange: replace most of vsnprintf with vseprintf 2014-04-24 19:51:45 +00:00
rubidium 0463dbdc9e (svn r26482) -Codechange: add an include that allows us to undefine/redefine "unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values 2014-04-23 20:13:33 +00:00
planetmaker c24374f99c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow) 2013-01-08 22:46:42 +00:00
truebrain 1c9bec1999 (svn r23640) -Fix: stop using FORCEINLINE (1/3rd of the instances were, the others were still regular inline), but make sure inline is always a 'forced' inline (I am looking at you MSVC) 2011-12-20 17:57:56 +00:00
michi_cc f227e90c24 (svn r22875) -Codechange: Add some asserts and checks to better prevent overflow of the argument to malloc. (monoid) 2011-09-02 20:54:51 +00:00