Commit Graph

63 Commits

Author SHA1 Message Date
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Peter Nelson 302e8852c1
Fix: Crash if squirrel compatibility scripts cannot be parsed. (#11589) 2023-12-15 01:25:36 +00:00
Peter Nelson 1071acb483
Codechange: Redundant use of char * and c_str(). (#11454) 2023-11-10 00:17:36 +00: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 18a31cca7c Codechange: do not make a string valid in place, to then copy it 2023-07-06 19:59:50 +02:00
Loïc Guilloux 1d9bc23525
Fix #10868: [Script] Handle errors when loading savegame data on stack (#11029) 2023-06-18 12:03:59 +02:00
Rubidium ab51175db2 Codechange: use std::string for script config 2023-05-14 22:54:10 +02:00
Rubidium e035705239 Codechange: introduce and use std::string variant of sq_throwerror 2023-05-14 22:54:10 +02:00
Rubidium a30f7c83bd Codechange: use std::string for script names to load 2023-05-14 22:54:10 +02:00
Rubidium 9b0123ab66 Codechange: use std::string for script API versions 2023-05-14 22:54:10 +02:00
Rubidium 6e3d3c0e7c Codechange: introduce std::string variant of sq_pushstring 2023-05-09 23:14:48 +02:00
PeterN b67cf7f94a
Change: Replace ScriptLog data array with std::deque. (#10770)
Due to cyclic header dependency this requires moving the data types used
by ScriptLog out of the ScriptLog class.
2023-05-06 14:54:58 +00:00
Rubidium 8b93e45e22 Codechange: use string/fmt instead of printf for squirrel's PRINTFUNC 2023-04-24 17:51:25 +02:00
dP c73b88ddca
Fix: Don't send unused tile field over the network (#10507) 2023-02-24 22:50:11 +01:00
Loïc Guilloux 07b40c02fe
Fix #10361, fe30f66: Don't try to give saved data to a dead script (#10433) 2023-01-29 22:27:29 +00:00
Rubidium 4e65ec1dc4 Codechange: do not declare functions in blocks 2023-01-29 20:28:45 +01:00
Loïc Guilloux fe30f66570
Fix #9720: Delay start of GS/AI to after loading of savegame (#9745) 2022-12-28 05:02:26 +01:00
dP 5e14a20b3b
Feature: [GS] Scriptable league tables (#10001) 2022-11-26 18:03:03 +01:00
Michael Lutz 41fa16f325 Codechange: Don't use globals for return values from vehicle command procs. 2021-12-16 22:28:32 +01:00
Michael Lutz 57b82e2e99 Codechange: Don't use globals for story/goal/sign/group command proc return values. 2021-12-16 22:28:32 +01:00
Michael Lutz 3e85e833a7 Codechange: Add support for additional command result values. 2021-12-16 22:28:32 +01:00
Michael Lutz eab18f06a4 Codechange: Pass additional data as byte stream to command callbacks. 2021-12-16 22:28:32 +01:00
Michael Lutz a38bbefe1b Codechange: Untangle command code, flags and error string for DoCommand*. 2021-12-16 22:28:32 +01:00
Loïc Guilloux eed49d7792
Fix #9626, ddafc0d: Incorrect loading of script saved data (#9629) 2021-10-20 12:23:16 +02:00
Loïc Guilloux ddafc0de05
Fix 39e90ec: Integers for scripts are 64bit, but saved as 32bit (#9415) 2021-07-06 21:09:08 +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
Patric Stout 97b94bdc9a Change: prefix SL_ARR with the length of the array
This means that during loading we can validate that what is saved
is also that what is expected. Additionally, this makes all list
types similar to how they are stored on disk:
First a gamma to indicate length, followed by the data.
The size still depends on the type.
2021-06-15 16:45:04 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
rubidium42 71f3c35288 Fix #9353: [Script] Garbage collecting on priority queues could crash the game 2021-06-12 19:58:14 +02:00
rubidium42 2924ac48c5 Fix: [Script] Ensure the saved script strings are properly validated and terminated when being read from the savegame 2021-06-10 22:03:23 +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
glx22 983c7ade60 Codechange: Replace FOR_ALL_SEARCHPATHS with range-based for loops 2021-05-03 19:46:57 +02:00
Rubidium 4400bbfa96 Change: [Script] Let Script_FatalError use std::string instead of const char * 2021-04-17 22:24:52 +02:00
Michael Lutz 65f65ad2ad Codechange: Convert some more FIO functions to take std::string. 2020-12-27 13:19:25 +01:00
Michael Lutz f3326d34e7 Codechange: Use std::string in FIO search path handling. 2020-12-27 13:19:25 +01:00
Michael Lutz 1c0ba07c3c Add: [Script] Native priority queue; useful e.g. for pathfinders. 2020-06-01 21:35:13 +02:00
Charles Pigott 60cbddbb5f Fix #7606: Game crash when trying to clean up a crashed script
Also fix another possible memory leak
2019-11-15 21:06:09 +01:00
Charles Pigott cf354f6668 Codechange: new instead of malloc 2019-11-15 21:06:09 +01:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Niels Martin Hansen 0549a81c30 Fix b3fd7879: Ignore command flags when verifying script commands
Multiplayer games has the server add some flags to the cmd value during the handling.
These flags should not be included in the verification, mask them out. Without this
masking out, scripts tend to die when executing their first command in multiplayer.
2019-09-07 19:38:13 +02:00
glx22 b3fd787959 Fix #7188: check the validity of command callback for scripts (#7701) 2019-09-07 17:37:01 +01:00
glx 09004f3697 Codechange: catch script exceptions by reference 2019-05-15 21:59:57 +02:00
Niels Martin Hansen 140a96b3a0 Change: Limit memory allocations for each Squirrel instance
This can avoid out-of-memory situations due to single scripts using up the entire address space.
Instead, scripts that go above the maximum are killed.
The maximum is default 1 GB per script, but can be configured by a setting.
2019-05-11 15:34:33 +02:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
rubidium 08cbf11539 (svn r26785) -Fix [Squirrel]: loading a value saved as boolean caused it to be of type integer instead of boolean 2014-09-07 09:30:57 +00:00
rubidium 7c4e9dd71d (svn r26771) -Cleanup: remove OTTD2SQ and SQ2OTTD 2014-09-06 17:30:33 +00:00
rubidium 21f991e235 (svn r26489) -Codechange: properly account for the end of buffers in the file io code instead of assuming MAX_PATH is okay 2014-04-23 21:23:21 +00:00
frosch ef4c2ce031 (svn r26485) -Codechange: Replace ttd_strlcpy and ttd_strlcat with strecpy and strecat. 2014-04-23 20:44:42 +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
rubidium b3e93d6520 (svn r26057) -Fix: a number of possibly uninitialised variables 2013-11-23 13:12:19 +00:00