Commit Graph
874 Commits
Author SHA1 Message Date
Peter NelsonandPeterN 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 StoutandGitHub 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 StoutandGitHub 993e7be707 Fix: [Script] GSAdmin.Send() could generate invalid JSON (#11250) 2023-08-31 16:52:52 +00:00
Joan JosepandGitHub 5e6b5d981f Codechange: Use existing functions in GetMonthlyInfrastructureCosts. (#11237) 2023-08-27 22:12:44 +02:00
Patric StoutandGitHub 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 StoutandGitHub 299570b2c1 Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761) 2023-08-12 18:14:21 +00:00
Patric StoutandGitHub 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
AndyandGitHub ce9305a5ee Add: [Script] GSIndustry.GetConstructionDate() method (#11145) 2023-07-20 20:35:37 +02:00
Rubidiumandrubidium42 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
Rubidiumandrubidium42 18a31cca7c Codechange: do not make a string valid in place, to then copy it 2023-07-06 19:59:50 +02:00
Rubidiumandrubidium42 af9b9327af Codechange: do not keep local variable for temporary string parameters 2023-07-03 18:08:03 +02:00
Rubidiumandrubidium42 78f5d58dc6 Codechange: use std::string without const as return
Otherwise some compilers, e.g. MSVC, do not pick up that these are temporaries
and as such it will pass the temporaries to `const std::string &` instead of
the wanted `std::string &&`
2023-07-03 18:08:03 +02:00
PeterNandGitHub d42a78f3e8 Codechange: Make DropDownListStringItem preformat and remove other implementations. (#11063)
Having to choose between DropDownListStringItem, DropDownListCharStringItem, and DropDownListParamStringItem depending on whether to draw a StringID, a raw string, or a StringID with extra parameters was needlessly complex.

Instead, allow passing a StringID or raw string to DropDownListStringItem. This will preformat the StringID into a raw string, and can therefore accept parameters via the normal SetDParam mechanism.

This also means that strings no longer need to be formatted on every draw.
2023-06-23 08:30:13 +00:00
PeterNandGitHub 2a2443dd01 Feature: Create group of vehicles from manage vehicle list button. (#10890) 2023-06-18 20:48:04 +01:00
Loïc GuillouxandGitHub 1d9bc23525 Fix #10868: [Script] Handle errors when loading savegame data on stack (#11029) 2023-06-18 12:03:59 +02:00
Rubidiumandrubidium42 d4c2043294 Codechange: remove a number of unneeded c_str() calls 2023-06-15 22:14:45 +02:00
Loïc GuillouxandGitHub 1cd49bf5e5 Fix ca1e34c: [Script] Wrong value printed for {RAW_STRING} (#11011) 2023-06-14 22:07:11 +00:00
Rubidiumandrubidium42 7c37dcb8e3 Fix: do not use {STRING} when {STRING1} or {STRING2} is needed 2023-06-14 09:44:06 +02:00
mrmbernardiandGitHub 35ef6c1723 Feature: [GS] Goal destination can be updated (#10817) 2023-06-08 18:00:31 +01:00
Rubidiumandrubidium42 2ae7367024 Codechange: replace StrMakeValidInPlace with StrValid 2023-06-08 18:29:44 +02:00
Rubidiumandrubidium42 ca1e34c121 Codechange: use std::string to build ScriptText's encoded text 2023-06-06 18:07:54 +02:00
Rubidiumandrubidium42 fbd71a9d72 Codechange: replace C-style string processing with C++-style for the listing callbacks 2023-06-05 23:25:49 +02:00
Patric StoutandGitHub 3b1407d240 Feature: allow to do a hostile takeover of an AI company (in singleplayer) (#10914)
With the removal of the share-system, you could no longer make an
AI disappear in a single player game. At least, not without going
into the console.
2023-06-05 19:32:22 +02:00
PeterNandGitHub f814c86389 Codechange: Reorganise hotkey initialisation. (#10951)
Hotkeys are now initialized inline, and use std::vector instead of
separate static C-arrays and std::string instead of char *. The list end
marker is no longer required.
2023-06-05 18:12:30 +01:00
Bernard TeoandGitHub 2c667b1773 Doc: Fix spelling error in ScriptTileList::RemoveRectangle (#10937) 2023-06-04 17:45:18 +00:00
Patric StoutandGitHub 6b1c38e303 Fix 3effb893: mention GSAsyncMode in changelog (#10924) 2023-06-04 11:10:22 +00:00
Jonathan G RennisonandGitHub 3effb8931c Add: [Script] GSAsyncMode to set async mode of gamescript commands (#10913)
In asynchronous mode, don't wait for result of executed command,
just fire-and-forget, and return estimated cost/result
2023-06-04 11:15:35 +02:00
Peter NelsonandPeterN 2511649938 Codechange: Use window parent association for dropdowns.
This replaces the separate window class and number properties, and
allows the window system to close dropdowns automatically.
2023-06-03 14:17:05 +01:00
PeterNandGitHub d086f288cd Codechange: Remove duplicated includes. (#10888)
These are now included by stdafx.h so don't need to be included again.
2023-05-29 14:29:00 +01:00
PeterNandGitHub 584faaf064 Change: Reorganise industry accept/produce arrays. (#10853)
Use a array of struct for each cargo instead of an array for each statistic.
This makes iterating for acceptance and production much simpler.
pct_transported is now calculated when needed.
2023-05-25 21:25:46 +01:00
Peter NelsonandPeterN 09408e8e46 Codechange: Add IsCargoAccepted/Produced() helpers. 2023-05-24 17:34:11 +01:00
Peter NelsonandPeterN 633f19419d Codechange: Make more use of GetCargoAccepted/ProducedIndex(). 2023-05-24 17:34:11 +01:00
Peter NelsonandPeterN 76516d7f70 Codechange: Use IsValidCargoID/IsValidCargoType.
IsValidCargoType() is used only for unmapped IDs.
2023-05-22 20:43:40 +01:00
Rubidiumandrubidium42 63d9bb93b8 Codechange: migrate from C-style GetString to C++-style GetString 2023-05-21 21:17:12 +02:00
Rubidiumandrubidium42 275ebf4509 Codechange: replace fprintf(<FILE*> with fmt::print(<FILE*> 2023-05-21 15:12:02 +02:00
Rubidiumandrubidium42 c518293135 Codechange: replace printf with fmt::print 2023-05-21 15:12:02 +02:00
Rubidiumandrubidium42 07860e67e2 Codechange: use fmt::format_to to format the help message 2023-05-20 16:50:03 +02:00
Rubidiumandrubidium42 d9a04ba446 Codechange: make the MD5 hash/digest/checksum variables a std::array 2023-05-19 11:24:44 +02:00
Peter NelsonandPeterN c38df2d589 Codechange: Use std::map instead of custom SmallMap. 2023-05-18 12:18:30 +01:00
Peter NelsonandPeterN 83f2ad500e Codechange: stdarg.h include not needed as cstdarg is included. 2023-05-17 10:14:41 +01:00
Peter NelsonandPeterN 56085be9bd Codechange: Move includes for common STL headers to stdafx. 2023-05-17 10:14:41 +01:00
Patric StoutandGitHub 199e41c762 Codechange: use default dtor instead of empty (#10826) 2023-05-14 23:31:03 +02:00
Rubidiumandrubidium42 62fda0f505 Codechange: remove manual allocation/free for SQ_instance 2023-05-14 22:54:10 +02:00
Rubidiumandrubidium42 f9b5bc7ee6 Cleanup: the need for SQAutoFreePointers has gone 2023-05-14 22:54:10 +02:00
Rubidiumandrubidium42 d9e93edc8b Codechange: replace 'const char *' script API parameters with std::string 2023-05-14 22:54:10 +02:00
Rubidiumandrubidium42 b1b578f988 Cleanup: stredup-ing string variant for calling scripts 2023-05-14 22:54:10 +02:00
Rubidiumandrubidium42 ab51175db2 Codechange: use std::string for script config 2023-05-14 22:54:10 +02:00
Rubidiumandrubidium42 bbcb55ebc9 Codechange: use std::string as script API return type 2023-05-14 22:54:10 +02:00