Commit Graph

917 Commits

Author SHA1 Message Date
Peter Nelson 7124b4eef1 Codechange: Use std::unique_ptr for all NWidgets. 2023-12-31 15:33:56 +00:00
Peter Nelson a0dfb76e34 Codechange: Replace mishmash of types for widget index with WidgetID.
Indices were stored as int, but often passed around as uint/uint8_t and casts.

Now they should all use WidgetID.
2023-12-30 00:23:57 +00:00
Peter Nelson b86182ab84 Codechange: Use std::map to provide indexed widget access.
This removes the need to determine the biggest widget index and replaces C-style memory handling.
2023-12-29 18:45:43 +00:00
Jonathan G Rennison 3b18877b87
Fix #11629: AirportGetNearestTown for rotated airports (#11631)
Add rotation parameter to AirportGetNearestTown
Add wrapper for existing stations
Remove unnecessary iterator cloning
2023-12-28 21:43:05 +00:00
Peter Nelson 33ff64ef74
Codechange: Simplify ConvertDateToYMD by returning YearMonthDay instead of outputting to a pointer. (#11637) 2023-12-28 21:34:08 +00:00
Loïc Guilloux 6c5a4aa2cb
Fix 2d3af14: Don't draw script log over panel borders (#11621) 2023-12-25 18:42:13 +01:00
Loïc Guilloux af8b8c2cfc
Fix 4a2038e301: fully restore script break filter on reopen (#11622) 2023-12-24 00:08:18 +00:00
Loïc Guilloux 2d3af14181
Add: Horizontal scroll for script debug log (#11597) 2023-12-20 22:50:03 +01:00
Peter Nelson 0ca4b4e146 Change: Allow opening multiple script debug windows by holding Ctrl. 2023-12-20 20:39:07 +00:00
Peter Nelson 4a2038e301 Codechange: Make script debug window filter state per-window. 2023-12-20 20:39:07 +00:00
Tyler Trahan e8d2ebb016
Fix: Add missing includes to timers from script implementation files (#11604) 2023-12-19 14:09:46 +00:00
SamuXarick fddcaef74a Codechange: Use town zone constants instead of magic numbers 2023-12-18 22:12:43 +01:00
Peter Nelson 302e8852c1
Fix: Crash if squirrel compatibility scripts cannot be parsed. (#11589) 2023-12-15 01:25:36 +00:00
Loïc Guilloux 7726f8f245
Fix: [Script] Properly store the previous AsyncMode state (#11587) 2023-12-14 21:29:44 +00:00
Peter Nelson bbf3028f89 Fix #11585: Crash when cleaning AI/GS with nested AsyncMode.
Do not throw sanity check when in_shutdown is true. This is also applied to
ExecMode and TestMode as they follow the same pattern.
2023-12-14 20:54:31 +00:00
Peter Nelson c0ea0589b4
Fix: AirportGetNearestTown incorrectly assumed first TileIterator result was origin. (#11565)
Not all TileIterators are equal, and some do not start at the top-corner, so the perimeter check was wrong. As the caller already has thie origin tile, use that instead.
2023-12-09 09:47:41 +00:00
Peter Nelson 58c252b81a Cleanup: Remove unnecessary pressed button offset code. 2023-12-05 21:12:35 +00:00
Peter Nelson aae6e0481e
Codechange: Rearrange AI/GS debug window following invalidate/set state/draw pattern. (#11483)
The AI/GS window updated its state as it was drawn, and would redraw again if some state had changed.

Instead, update state either during OnInvalidateData or before any drawing commences.
2023-12-03 18:53:31 +00:00
Peter Nelson 7b0afec11f Codechange: Use max_element to find highest cargo amount. 2023-11-28 22:30:48 +00:00
Peter Nelson 3f853d8003 Codechange: Use range-for to simplify getting first non-zero value.
This reduces indexed array access.
2023-11-28 22:30:48 +00:00
Peter Nelson c18a1494b7
Codechange: Remove FONT_HEIGHT_... macros. (#11481)
These make it look like we're dealing with a constant, but actually each is a call to `GetCharacterHeight(...)`.
2023-11-21 19:04:24 +00:00
Peter Nelson 1071acb483
Codechange: Redundant use of char * and c_str(). (#11454) 2023-11-10 00:17:36 +00: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
Michael Lutz 86e28e79fb Fix #11402: Make string filter locale-aware. 2023-11-03 22:34:01 +01:00
Peter Nelson 18fb8e153f Codechange: Add __FILE__/__LINE__ of WindowDesc to WindowDesc.
This is to allow unit-tests to produce more useful output.
2023-11-02 22:25:01 +00:00
Rubidium c6411168d8 Cleanup: missing spaces before continuation * in some comments 2023-11-01 22:56:11 +01:00
Rubidium c9276c2959 Codechange: replace x.size() == 0 with x.empty() 2023-10-20 23:05:43 +02:00
Peter Nelson fd6f1e844a
Codechange: Avoid emplace_back(new()) into a unique_ptr. (#11384)
This could theoretically leave an unmanaged pointer in certain circumstances, and directly using
make_unique shows intent.
2023-10-20 18:40:48 +01:00
Peter Nelson 9602de474d Codechange: Use iterators and/or range-for on cargo related loops. 2023-10-19 17:03:25 +01:00
Peter Nelson 49dae08a3b Codechange: Add missing override specifiers. 2023-09-25 21:27:45 +01:00
frosch f40816503f Codechange: Add enum items for dynmically created setting dropdowns. 2023-09-20 22:35:32 +02:00
frosch b5885295f0 Codechange: Use parameters, which should be used. 2023-09-19 22:49:59 +02:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
Rubidium 8ab0936491 Codechange: use parameter pack/folding instead of va_arg macros for widget states 2023-09-16 23:09:53 +02:00
Patric Stout ba67f39db6
Codechange: vendor the nlohmann-json library (#11290) 2023-09-13 16:11:34 +02:00
PeterN acd7d3c913
Codechange: Rename *Railtype* to *RailType* for consistency. (#11287) 2023-09-11 08:55:12 +00:00
Tyler Trahan 701a61c9af Codechange: Delete date_type.h 2023-09-10 08:40:25 -04:00
Tyler Trahan 77173a6a10 Codechange: Move date consts and functions to CalendarTime and TimerGameCalendar classes 2023-09-10 08:40:25 -04:00
Tyler Trahan fca2b37726 Codechange: Move Ticks into their own class 2023-09-10 08:40:25 -04:00
Patric Stout 30172fc037
Codechange: cleanup CargoPacket in terms of variable/function names (#11278)
Over the years, things got reused and changed, making the current
names somewhat unclear in what they actually mean and do.
2023-09-09 23:21:21 +02:00
Patric Stout 00f13282a9
Codechange: keep how we convert string <-> JSON private (#11269) 2023-09-08 19:03:10 +02:00
Patric Stout 5f9b8aaa95
Codechange: [Script] use nlohmann for Squirrel <-> JSON conversion (#11251) 2023-09-06 13:14:12 +02:00
Peter Nelson e8015e497d Codechange: Use begin/end of nwidget parts of begin/length.
This simplifies processing nwidget parts as, unlike the remaining length, the pointer to the end of the list never changes. This is the same principle as we use(d) for tracking end instead of length for C-style strings.

And this removes 160~ instances of the lengthof() macro.
2023-09-04 10:20:45 +01:00
Michael Lutz 0089323542 Add: [Script] Custom news message text for industry SetProductionLevel. 2023-09-02 16:20:59 +02:00
Michael Lutz 1c56991213 Add: [Script] Game script control of industry production level. 2023-09-02 16:20:59 +02:00
Patric Stout 7afd686541
Codechange: add tests for GS <-> AdminPort JSON conversion (#11252)
While at it, fix a bug where booleans were made integers.
2023-08-31 19:38:15 +00:00
Patric Stout 993e7be707
Fix: [Script] GSAdmin.Send() could generate invalid JSON (#11250) 2023-08-31 16:52:52 +00:00
Joan Josep 5e6b5d981f
Codechange: Use existing functions in GetMonthlyInfrastructureCosts. (#11237) 2023-08-27 22:12:44 +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