mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
8 Commits
1d931a2916
...
867a995c1b
Author | SHA1 | Date |
---|---|---|
|
867a995c1b | |
|
9ce2aca949 | |
|
55098a2f2e | |
|
7ff0c67f77 | |
|
b2de1ff66f | |
|
cb7bb6ce6a | |
|
fc924161ab | |
|
61a299bc99 |
137
changelog.md
137
changelog.md
|
@ -1,5 +1,142 @@
|
||||||
## 15.x
|
## 15.x
|
||||||
|
|
||||||
|
### 15.0-beta3 (2025-07-11)
|
||||||
|
|
||||||
|
- Add: Buttons to change picker preview image height. (#14373)
|
||||||
|
- Add: Show and sort online content version in content list. (#14355)
|
||||||
|
- Add: Hover on graph legend to highlight line. (#14314)
|
||||||
|
- Add: Allow separate expansion of town buildings and roads in scenario editor. (#14341)
|
||||||
|
- Add: [Script] Cloning ScriptList (#14305)
|
||||||
|
- Add: [Script] Framework for cloning selected ScriptObject
|
||||||
|
- Add: Badge dropdown filters and configuration.for picker and vehicle windows. (#14021)
|
||||||
|
- Add: Configuration of NewGRF badges for picker and vehicle windows. (#13993)
|
||||||
|
- Add: [Script] GSBaseStation::GetOwner (#13406)
|
||||||
|
- Add: [Script] ScriptVehicleList_Waypoint (#13456)
|
||||||
|
- Add: [NewGRF] All callbacks returning D0xx strings, have now the option to return any string id via register 0x100. (#14224)
|
||||||
|
- Add: [NewGRF] Special value 0x7FFE for VarAction2 results specifying 'return calculated result'. (#14149)
|
||||||
|
- Add: [NewGRF] Special value 0x7FFF for Action2 references specifying explicit 'callback/sprite-resolving failed'. (#14149)
|
||||||
|
- Add: [NewGRF] Add purchase list Action3 CID for houses, industries, industry tiles, airports and airport tiles. (#14121)
|
||||||
|
- Add: "Many random towns" button in scenario editor now prompts for the number of towns, with defaults based on new game settings (#14158)
|
||||||
|
- Add: [BaseSet] Allow basesets to set minor and patch versions in obg/obs/obm files. (#14169)
|
||||||
|
- Add: Limit height of settings description, and add scrollbar. (#14102)
|
||||||
|
- Add: [NewGRF] Provide random bits in var10 of house callback 1C 'construction stage changed'. (#14095)
|
||||||
|
- Add: [NewGRF] Station/roadstop animation-triggers 'tile loop' (bit 7) and 'path reservation' (bit 8). (#14080)
|
||||||
|
- Add: Add scrollbar to infrastructure window. (#14056)
|
||||||
|
- Change: Make truncation ellipsis translatable. (#14417)
|
||||||
|
- Change: Improve sprite ellipsis appearance. (#14404)
|
||||||
|
- Change: New company face definition system and UI. (#14319)
|
||||||
|
- Change: Consistent toolbar sizes with dedicated NWidgetParts. (#14344)
|
||||||
|
- Change: [Script] Don't allow scripts to instantiate ScriptEvent (#14276)
|
||||||
|
- Change: [Script] ScriptVehicleList_Station accepts an optional VehicleType parameter (#14260)
|
||||||
|
- Change: Remove Apply button from NewGRF config window when unneeded. (#14254)
|
||||||
|
- Change: Remove extra close buttons from some windows. (#14124)
|
||||||
|
- Change: Move OpenTTD version to intro viewport. (#14233)
|
||||||
|
- Change: [NewGRF] Increase the textstack for all callbacks to 16 registers.
|
||||||
|
- Change: Rearrange buttons in the intro screen, remove unnecessary ones.
|
||||||
|
- Change: [Script] Remove the limit of 20 parameters to a Script Text string. (#14193)
|
||||||
|
- Change: [NewGRF] Animation-trigger 'construction stage changed' of houses and industries now also triggers at construction start. (#14089)
|
||||||
|
- Change: [Script] Reject scripts using negative version (#14096)
|
||||||
|
- Change: [NewGRF] Provide shared random bits in multi-tile animation-triggers of airport tiles and objects, just like for other features. (#14090)
|
||||||
|
- Change: Move Game Options toggles to before label, add Off/On text. (#14097)
|
||||||
|
- Change: Remove minimum width from advanced settings panel of Game Options window. (#14088)
|
||||||
|
- Change: Merge Game Options and Game Settings together. (#13242)
|
||||||
|
- Change: Enhance visibility of disabled bool button. (#14071)
|
||||||
|
- Change: Use scaled instead of fixed dimensions for framerate graphs. (#14039)
|
||||||
|
- Change: Include dragged train in depot tile length display. (#14060)
|
||||||
|
- Change: Use standard boolean toggle buttons for game options toggles. (#14051)
|
||||||
|
- Change: "setting" console command now shows default value (#14061)
|
||||||
|
- Change: Allow Double-Ctrl+Click on default size box to clear saved size. (#14055)
|
||||||
|
- Change: Don't select content when toggling its download status. (#14059)
|
||||||
|
- Fix 0455627d: Don't draw timetable panel if no orders (#14441)
|
||||||
|
- Fix: Scale graph gridlines and axes with GUI scale (#12131)
|
||||||
|
- Fix #14396: Industry production graph showed zero instead of N/A. (#14416)
|
||||||
|
- Fix #14375: When loading config, validate timekeeping mode and minutes per year (#14405)
|
||||||
|
- Fix #14377: Make house picker window remember house protection state when closed (#14406)
|
||||||
|
- Fix #14385: [Strgen] Don't count parameters more than one time (#14413)
|
||||||
|
- Fix #14360: Don't reuse strings for Low/Medium/High setting values (#14409)
|
||||||
|
- Fix: Include sort button width in content list header minimal size. (#14402)
|
||||||
|
- Fix: Don't draw truncation ellipsis if it's too wide. (#14401)
|
||||||
|
- Fix: Don't include ellipsis width in RTL truncation offset. (#14400)
|
||||||
|
- Fix 319caef58f: Buildings with non-zero subtile offsets broken in house picker. (#14390)
|
||||||
|
- Fix #14081: Check if removed item is a savegame (#14371)
|
||||||
|
- Fix: Allow object picker to resize if there are no classes. (#14372)
|
||||||
|
- Fix: Train path reservations on different railtypes could join leading to train crashes. (#14366)
|
||||||
|
- Fix #14362, 4b677e8256: Class with non static methods may have a default constructor (#14363)
|
||||||
|
- Fix #14356, ff7eb996e6: Incorrect sprite group chosen for stations and road stops. (#14359)
|
||||||
|
- Fix 0455627d16: Order backups were no longer created when selling vehicles. (#14352)
|
||||||
|
- Fix: [Script] Make ScriptOrder functions aware of road waypoints (#13419)
|
||||||
|
- Fix: Wrong error message about script Save() returned value (#14334)
|
||||||
|
- Fix: Drag drop line position when dragging NewGRF from file to active panel (#14316)
|
||||||
|
- Fix 4c8f1b0f81: Hidden-by-facility station signs were not ignored when handling clicks. (#14326)
|
||||||
|
- Fix: [Script] SQOpsLimiter had no effect for native valuator/filter (#14322)
|
||||||
|
- Fix bd1a3fe0b7: Crash if loading compatibility scripts fails. (#14318)
|
||||||
|
- Fix 5664b1e2f6: Upgrade button in NewGRF window no longer worked. (#14315)
|
||||||
|
- Fix #14295, 0455627d16: v->cur_implicit_order_index is never INVALID_VEH_ORDER_ID (#14296)
|
||||||
|
- Fix 0455627d16: Incorrect script order position mapping. (#14294)
|
||||||
|
- Fix #14234, 5aa4ad5135: Crash due to unexpected NUL char in string. (#14235)
|
||||||
|
- Fix: Clear rail vehicle flipped flag if reverse probability callback returns false. (#14281)
|
||||||
|
- Fix #14271, 7fd0e6c27d: Crash due to incorrect parameter index in string. (#14272)
|
||||||
|
- Fix: Restore the behaviour when entering numbers in query windows: clamp integers out of range to the maximum valid value. (#14268)
|
||||||
|
- Fix b2c57123: [Script] Conversion from ScriptEvent to ScriptEventCompanyTown subclasses (#14274)
|
||||||
|
- Fix f8bdc1e612: Empty first parameter of EncodedString was skipped. (#14273)
|
||||||
|
- Fix #14256, dfd9fbf873: Company finance windows not updated when paused. (#14258)
|
||||||
|
- Fix 0829604b4f: Dragging of selected order was still not possible. (#14259)
|
||||||
|
- Fix 0ce30d05c8: Replacing a dropdown list could reposition it partially off-screen. (#14261)
|
||||||
|
- Fix 3cf9b159: Incorrect tile colour in smallmap for snowy MP_CLEAR tiles in vegetation mode (#14257)
|
||||||
|
- Fix #14251: Out-of-bounds writes via TextRefStack. (#14255)
|
||||||
|
- Fix 51a7edd: NewGRF debug sprite picker was broken. (#14246)
|
||||||
|
- Fix #14241, 6e10584: Invalid string parameters in subsidies list window (#14243)
|
||||||
|
- Fix #13854: 40bpp-anim blitter recolouring failed for 32bpp pixels without mask channel. (#14242)
|
||||||
|
- Fix #14234, 16b4e73: Skip PLURAL data if parameter is invalid. (#14236)
|
||||||
|
- Fix #14216, d030d17: RealSpriteGroups referencing CallbackResultSpriteGroups were always treated as callback-failure. (#14218)
|
||||||
|
- Fix: Closing the Game Options window closes all textfile windows. (#14210)
|
||||||
|
- Fix: Zoom-scroll extra viewports only if the mouse cursor is over the viewport. (#14209)
|
||||||
|
- Fix: Changing monospace font didn't refresh the monospace width cache. (#14185)
|
||||||
|
- Fix #14098: Use 64-bit type for MIDI realtime informatio [to allow longer tracks to play]. (#14144)
|
||||||
|
- Fix: [NewGRF] If Action123 does not resolve in a valid SpriteSet, prefer drawing the default sprite instead of an invalid sprite. (#14143)
|
||||||
|
- Fix: Crash/Undefined behaviour in station view window. (#14183)
|
||||||
|
- Fix: Small order list arrow was wrong direction for RTL text. (#14174)
|
||||||
|
- Fix: [Script] Access to enum/consts defined outside of main.nut (#14176)
|
||||||
|
- Fix: Handle \t when loading GS strings from savegame (#14180)
|
||||||
|
- Fix bf8a241f: Handle \t in trailing whitespaces (#14178)
|
||||||
|
- Fix 66733e2a: Textbuf was broken, and did not insert any input. (#14173)
|
||||||
|
- Fix #14170, 7fd0e6c27d: Missing spaces for timetabled order strings. (#14172)
|
||||||
|
- Fix 261e09a549: Compilation failure with Fluidsynth enabled. (#14167)
|
||||||
|
- Fix #14166, dfd9fbf873: Loan was no longer invalidated when refreshing finance window. (#14168)
|
||||||
|
- Fix: [NewGRF] Computed VarAction2 callback results were not always properly masked to 15 bit results. (#14138)
|
||||||
|
- Fix: [NewGRF] The result of Action123 evaluation affected rerandomisation in a weird corner case. (#14139)
|
||||||
|
- Fix: [NewGRF] AI station construction callback did not work for stations with ID >= 0x100. (#14142)
|
||||||
|
- Fix: Out-of-bounds read, if NewGRF stations provided no spritesets. (#14140)
|
||||||
|
- Fix: List Ctrl+Click behaviour for vehicle details tooltip (#14127)
|
||||||
|
- Fix 29ceaf0a8: checking std::optional against nullptr caused crash (#14133)
|
||||||
|
- Fix #14125, 828e808444: NewGRF sounds were not loaded. (#14130)
|
||||||
|
- Fix #14104, 67a0fcc: Don't base timetable timing decisions on client settings. (#14105)
|
||||||
|
- Fix 5575379: Crash with default airports. (#14120)
|
||||||
|
- Fix: Road vehicle blocking and train collissions used slightly inconsistent distance thresholds. (#14114)
|
||||||
|
- Fix: [NewGRF] Cargo-types for airport-tile animation-triggers were not properly translated. (#14092)
|
||||||
|
- Fix: [NewGRF] For animation-triggers which do not supply a cargo-type in var18, the var18 bits should remain empty. (#14091)
|
||||||
|
- Fix #14107: Mark the company value in the company view window dirty when it changes. (#14112)
|
||||||
|
- Fix #14107: Invalidate all shared vehicle windows when changing group. (#14110)
|
||||||
|
- Fix: Focus settings filter box (only) when the tab becomes active. (#14100)
|
||||||
|
- Fix 2b80812922: Map size column in server list may be too wide. (#14094)
|
||||||
|
- Fix: [NewGRF] Randomisation-trigger 'path reservation' did not work for waypoints. (#14076)
|
||||||
|
- Fix a4dc7249ee: Changing language or interface scale could hang. (#14087)
|
||||||
|
- Fix: [NewGRF] For roadstop multi-tile-animation-triggers, the upper 16 bits were not the same for all tiles. (#14084)
|
||||||
|
- Fix f5ffd47: Don't skip separator while reading a record (#14083)
|
||||||
|
- Fix c7d6934816: Town view caption lost "(City)" flag. (#14082)
|
||||||
|
- Fix e114ed357d: Incorrect test of object flags allowed HQ to be removed. (#14062)
|
||||||
|
- Fix: Odd drawing and crash if scrollbar is not tall enough. (#14052)
|
||||||
|
- Fix #14044: Negative string parameters from GS were rendered as zero. (#14049)
|
||||||
|
- Fix: Incorrect string display for autoreplace wagon removal status. (#14038)
|
||||||
|
- Fix e49150f9ca: House picker crashes if selection is not available. (#14030)
|
||||||
|
- Fix: [NewGRF] Strange things happened, when using the synchronised tile loop animation trigger for houses. (#14011)
|
||||||
|
- Fix: [NewGRF] PrepareLayout worked on a copy of the data resulting in bad sprite layouts. (#14013)
|
||||||
|
- Fix: [NewGRF] Animation speed properties of houses and stations had wrong default. (#14005)
|
||||||
|
- Fix: [NewGRF] Roadstop animation/randomisation was not triggered on vehicle arrival. (#14003)
|
||||||
|
- Fix #13954: Plotting graphs with limited data to the right. (#13956)
|
||||||
|
- Fix: Don't display badges if the class has no name. (#13994)
|
||||||
|
- Revert 0853c1979b: Button to toggle showing advanced signal types (#9617) (#14219)
|
||||||
|
|
||||||
### 15.0-beta2 (2025-04-13)
|
### 15.0-beta2 (2025-04-13)
|
||||||
|
|
||||||
- Feature: Snow-covered rocks are now visible (#13627)
|
- Feature: Snow-covered rocks are now visible (#13627)
|
||||||
|
|
|
@ -103,14 +103,14 @@ void SpriteFontCache::ClearFontCache()
|
||||||
|
|
||||||
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
||||||
{
|
{
|
||||||
SpriteID sprite = this->GetUnicodeGlyph(static_cast<char32_t>(key & ~SPRITE_GLYPH));
|
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
||||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
||||||
return GetSprite(sprite, SpriteType::Font);
|
return GetSprite(sprite, SpriteType::Font);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint SpriteFontCache::GetGlyphWidth(GlyphID key)
|
uint SpriteFontCache::GetGlyphWidth(GlyphID key)
|
||||||
{
|
{
|
||||||
SpriteID sprite = this->GetUnicodeGlyph(static_cast<char32_t>(key & ~SPRITE_GLYPH));
|
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
||||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
||||||
return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
|
return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ GlyphID SpriteFontCache::MapCharToGlyph(char32_t key, [[maybe_unused]] bool allo
|
||||||
assert(IsPrintable(key));
|
assert(IsPrintable(key));
|
||||||
SpriteID sprite = this->GetUnicodeGlyph(key);
|
SpriteID sprite = this->GetUnicodeGlyph(key);
|
||||||
if (sprite == 0) return 0;
|
if (sprite == 0) return 0;
|
||||||
return SPRITE_GLYPH | key;
|
return SPRITE_GLYPH | sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpriteFontCache::GetDrawGlyphShadow()
|
bool SpriteFontCache::GetDrawGlyphShadow()
|
||||||
|
|
|
@ -105,8 +105,8 @@ static ChangeInfoResult RoadStopChangeInfo(uint first, uint last, int prop, Byte
|
||||||
AddStringForMapping(GRFStringID{buf.ReadWord()}, [rs = rs.get()](StringID str) { RoadStopClass::Get(rs->class_index)->name = str; });
|
AddStringForMapping(GRFStringID{buf.ReadWord()}, [rs = rs.get()](StringID str) { RoadStopClass::Get(rs->class_index)->name = str; });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0C: // The draw mode
|
case 0x0C: // The draw modes
|
||||||
rs->draw_mode = static_cast<RoadStopDrawMode>(buf.ReadByte());
|
rs->draw_mode = static_cast<RoadStopDrawModes>(buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0D: // Cargo types for random triggers
|
case 0x0D: // Cargo types for random triggers
|
||||||
|
|
|
@ -298,7 +298,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec,
|
||||||
|
|
||||||
RoadStopDrawModes draw_mode;
|
RoadStopDrawModes draw_mode;
|
||||||
if (spec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) {
|
if (spec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) {
|
||||||
draw_mode = static_cast<RoadStopDrawMode>(object.GetRegister(0x100));
|
draw_mode = static_cast<RoadStopDrawModes>(object.GetRegister(0x100));
|
||||||
} else {
|
} else {
|
||||||
draw_mode = spec->draw_mode;
|
draw_mode = spec->draw_mode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||||
|
|
||||||
/* static */ uint ScriptController::GetTick()
|
/* static */ uint ScriptController::GetTick()
|
||||||
{
|
{
|
||||||
return ScriptObject::GetActiveInstance().GetController()->ticks;
|
return ScriptObject::GetActiveInstance().GetController().ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int ScriptController::GetOpsTillSuspend()
|
/* static */ int ScriptController::GetOpsTillSuspend()
|
||||||
|
@ -96,9 +96,9 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||||
|
|
||||||
/* static */ HSQOBJECT ScriptController::Import(const std::string &library, const std::string &class_name, int version)
|
/* static */ HSQOBJECT ScriptController::Import(const std::string &library, const std::string &class_name, int version)
|
||||||
{
|
{
|
||||||
ScriptController *controller = ScriptObject::GetActiveInstance().GetController();
|
ScriptController &controller = ScriptObject::GetActiveInstance().GetController();
|
||||||
Squirrel *engine = ScriptObject::GetActiveInstance().engine;
|
Squirrel &engine = *ScriptObject::GetActiveInstance().engine;
|
||||||
HSQUIRRELVM vm = engine->GetVM();
|
HSQUIRRELVM vm = engine.GetVM();
|
||||||
|
|
||||||
ScriptInfo *lib = ScriptObject::GetActiveInstance().FindLibrary(library, version);
|
ScriptInfo *lib = ScriptObject::GetActiveInstance().FindLibrary(library, version);
|
||||||
if (lib == nullptr) {
|
if (lib == nullptr) {
|
||||||
|
@ -114,11 +114,11 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||||
|
|
||||||
std::string fake_class;
|
std::string fake_class;
|
||||||
|
|
||||||
LoadedLibraryList::iterator it = controller->loaded_library.find(library_name);
|
LoadedLibraryList::iterator it = controller.loaded_library.find(library_name);
|
||||||
if (it != controller->loaded_library.end()) {
|
if (it != controller.loaded_library.end()) {
|
||||||
fake_class = (*it).second;
|
fake_class = (*it).second;
|
||||||
} else {
|
} else {
|
||||||
int next_number = ++controller->loaded_library_count;
|
int next_number = ++controller.loaded_library_count;
|
||||||
|
|
||||||
/* Create a new fake internal name */
|
/* Create a new fake internal name */
|
||||||
fake_class = fmt::format("_internalNA{}", next_number);
|
fake_class = fmt::format("_internalNA{}", next_number);
|
||||||
|
@ -128,14 +128,14 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||||
sq_pushstring(vm, fake_class);
|
sq_pushstring(vm, fake_class);
|
||||||
sq_newclass(vm, SQFalse);
|
sq_newclass(vm, SQFalse);
|
||||||
/* Load the library */
|
/* Load the library */
|
||||||
if (!engine->LoadScript(vm, lib->GetMainScript(), false)) {
|
if (!engine.LoadScript(vm, lib->GetMainScript(), false)) {
|
||||||
throw sq_throwerror(vm, fmt::format("there was a compile error when importing '{}' version {}", library, version));
|
throw sq_throwerror(vm, fmt::format("there was a compile error when importing '{}' version {}", library, version));
|
||||||
}
|
}
|
||||||
/* Create the fake class */
|
/* Create the fake class */
|
||||||
sq_newslot(vm, -3, SQFalse);
|
sq_newslot(vm, -3, SQFalse);
|
||||||
sq_pop(vm, 1);
|
sq_pop(vm, 1);
|
||||||
|
|
||||||
controller->loaded_library[library_name] = fake_class;
|
controller.loaded_library[library_name] = fake_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the real class inside the fake class (like 'sets.Vector') */
|
/* Find the real class inside the fake class (like 'sets.Vector') */
|
||||||
|
|
|
@ -45,7 +45,7 @@ void SimpleCountedObject::Release()
|
||||||
* Get the storage associated with the current ScriptInstance.
|
* Get the storage associated with the current ScriptInstance.
|
||||||
* @return The storage.
|
* @return The storage.
|
||||||
*/
|
*/
|
||||||
static ScriptStorage *GetStorage()
|
static ScriptStorage &GetStorage()
|
||||||
{
|
{
|
||||||
return ScriptObject::GetActiveInstance().GetStorage();
|
return ScriptObject::GetActiveInstance().GetStorage();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
||||||
: AutoRestoreBackup(GetStorage()->allow_do_command, false)
|
: AutoRestoreBackup(GetStorage().allow_do_command, false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/* static */ ScriptInstance &ScriptObject::GetActiveInstance()
|
/* static */ ScriptInstance &ScriptObject::GetActiveInstance()
|
||||||
|
@ -78,181 +78,181 @@ ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
||||||
/* static */ void ScriptObject::SetDoCommandDelay(uint ticks)
|
/* static */ void ScriptObject::SetDoCommandDelay(uint ticks)
|
||||||
{
|
{
|
||||||
assert(ticks > 0);
|
assert(ticks > 0);
|
||||||
GetStorage()->delay = ticks;
|
GetStorage().delay = ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ uint ScriptObject::GetDoCommandDelay()
|
/* static */ uint ScriptObject::GetDoCommandDelay()
|
||||||
{
|
{
|
||||||
return GetStorage()->delay;
|
return GetStorage().delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetDoCommandMode(ScriptModeProc *proc, ScriptObject *instance)
|
/* static */ void ScriptObject::SetDoCommandMode(ScriptModeProc *proc, ScriptObject *instance)
|
||||||
{
|
{
|
||||||
GetStorage()->mode = proc;
|
GetStorage().mode = proc;
|
||||||
GetStorage()->mode_instance = instance;
|
GetStorage().mode_instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptModeProc *ScriptObject::GetDoCommandMode()
|
/* static */ ScriptModeProc *ScriptObject::GetDoCommandMode()
|
||||||
{
|
{
|
||||||
return GetStorage()->mode;
|
return GetStorage().mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptObject *ScriptObject::GetDoCommandModeInstance()
|
/* static */ ScriptObject *ScriptObject::GetDoCommandModeInstance()
|
||||||
{
|
{
|
||||||
return GetStorage()->mode_instance;
|
return GetStorage().mode_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetDoCommandAsyncMode(ScriptAsyncModeProc *proc, ScriptObject *instance)
|
/* static */ void ScriptObject::SetDoCommandAsyncMode(ScriptAsyncModeProc *proc, ScriptObject *instance)
|
||||||
{
|
{
|
||||||
GetStorage()->async_mode = proc;
|
GetStorage().async_mode = proc;
|
||||||
GetStorage()->async_mode_instance = instance;
|
GetStorage().async_mode_instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptAsyncModeProc *ScriptObject::GetDoCommandAsyncMode()
|
/* static */ ScriptAsyncModeProc *ScriptObject::GetDoCommandAsyncMode()
|
||||||
{
|
{
|
||||||
return GetStorage()->async_mode;
|
return GetStorage().async_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptObject *ScriptObject::GetDoCommandAsyncModeInstance()
|
/* static */ ScriptObject *ScriptObject::GetDoCommandAsyncModeInstance()
|
||||||
{
|
{
|
||||||
return GetStorage()->async_mode_instance;
|
return GetStorage().async_mode_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastCommand(const CommandDataBuffer &data, Commands cmd)
|
/* static */ void ScriptObject::SetLastCommand(const CommandDataBuffer &data, Commands cmd)
|
||||||
{
|
{
|
||||||
ScriptStorage *s = GetStorage();
|
ScriptStorage &s = GetStorage();
|
||||||
Debug(script, 6, "SetLastCommand company={:02d} cmd={} data={}", s->root_company, cmd, FormatArrayAsHex(data));
|
Debug(script, 6, "SetLastCommand company={:02d} cmd={} data={}", s.root_company, cmd, FormatArrayAsHex(data));
|
||||||
s->last_data = data;
|
s.last_data = data;
|
||||||
s->last_cmd = cmd;
|
s.last_cmd = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptObject::CheckLastCommand(const CommandDataBuffer &data, Commands cmd)
|
/* static */ bool ScriptObject::CheckLastCommand(const CommandDataBuffer &data, Commands cmd)
|
||||||
{
|
{
|
||||||
ScriptStorage *s = GetStorage();
|
ScriptStorage &s = GetStorage();
|
||||||
Debug(script, 6, "CheckLastCommand company={:02d} cmd={} data={}", s->root_company, cmd, FormatArrayAsHex(data));
|
Debug(script, 6, "CheckLastCommand company={:02d} cmd={} data={}", s.root_company, cmd, FormatArrayAsHex(data));
|
||||||
if (s->last_cmd != cmd) return false;
|
if (s.last_cmd != cmd) return false;
|
||||||
if (s->last_data != data) return false;
|
if (s.last_data != data) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetDoCommandCosts(Money value)
|
/* static */ void ScriptObject::SetDoCommandCosts(Money value)
|
||||||
{
|
{
|
||||||
GetStorage()->costs = CommandCost(INVALID_EXPENSES, value); // Expense type is never read.
|
GetStorage().costs = CommandCost(INVALID_EXPENSES, value); // Expense type is never read.
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::IncreaseDoCommandCosts(Money value)
|
/* static */ void ScriptObject::IncreaseDoCommandCosts(Money value)
|
||||||
{
|
{
|
||||||
GetStorage()->costs.AddCost(value);
|
GetStorage().costs.AddCost(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money ScriptObject::GetDoCommandCosts()
|
/* static */ Money ScriptObject::GetDoCommandCosts()
|
||||||
{
|
{
|
||||||
return GetStorage()->costs.GetCost();
|
return GetStorage().costs.GetCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastError(ScriptErrorType last_error)
|
/* static */ void ScriptObject::SetLastError(ScriptErrorType last_error)
|
||||||
{
|
{
|
||||||
GetStorage()->last_error = last_error;
|
GetStorage().last_error = last_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptErrorType ScriptObject::GetLastError()
|
/* static */ ScriptErrorType ScriptObject::GetLastError()
|
||||||
{
|
{
|
||||||
return GetStorage()->last_error;
|
return GetStorage().last_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastCost(Money last_cost)
|
/* static */ void ScriptObject::SetLastCost(Money last_cost)
|
||||||
{
|
{
|
||||||
GetStorage()->last_cost = last_cost;
|
GetStorage().last_cost = last_cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money ScriptObject::GetLastCost()
|
/* static */ Money ScriptObject::GetLastCost()
|
||||||
{
|
{
|
||||||
return GetStorage()->last_cost;
|
return GetStorage().last_cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetRoadType(RoadType road_type)
|
/* static */ void ScriptObject::SetRoadType(RoadType road_type)
|
||||||
{
|
{
|
||||||
GetStorage()->road_type = road_type;
|
GetStorage().road_type = road_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ RoadType ScriptObject::GetRoadType()
|
/* static */ RoadType ScriptObject::GetRoadType()
|
||||||
{
|
{
|
||||||
return GetStorage()->road_type;
|
return GetStorage().road_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetRailType(RailType rail_type)
|
/* static */ void ScriptObject::SetRailType(RailType rail_type)
|
||||||
{
|
{
|
||||||
GetStorage()->rail_type = rail_type;
|
GetStorage().rail_type = rail_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ RailType ScriptObject::GetRailType()
|
/* static */ RailType ScriptObject::GetRailType()
|
||||||
{
|
{
|
||||||
return GetStorage()->rail_type;
|
return GetStorage().rail_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastCommandRes(bool res)
|
/* static */ void ScriptObject::SetLastCommandRes(bool res)
|
||||||
{
|
{
|
||||||
GetStorage()->last_command_res = res;
|
GetStorage().last_command_res = res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptObject::GetLastCommandRes()
|
/* static */ bool ScriptObject::GetLastCommandRes()
|
||||||
{
|
{
|
||||||
return GetStorage()->last_command_res;
|
return GetStorage().last_command_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastCommandResData(CommandDataBuffer data)
|
/* static */ void ScriptObject::SetLastCommandResData(CommandDataBuffer data)
|
||||||
{
|
{
|
||||||
GetStorage()->last_cmd_ret = std::move(data);
|
GetStorage().last_cmd_ret = std::move(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ const CommandDataBuffer &ScriptObject::GetLastCommandResData()
|
/* static */ const CommandDataBuffer &ScriptObject::GetLastCommandResData()
|
||||||
{
|
{
|
||||||
return GetStorage()->last_cmd_ret;
|
return GetStorage().last_cmd_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetCompany(::CompanyID company)
|
/* static */ void ScriptObject::SetCompany(::CompanyID company)
|
||||||
{
|
{
|
||||||
if (GetStorage()->root_company == INVALID_OWNER) GetStorage()->root_company = company;
|
if (GetStorage().root_company == INVALID_OWNER) GetStorage().root_company = company;
|
||||||
GetStorage()->company = company;
|
GetStorage().company = company;
|
||||||
|
|
||||||
_current_company = company;
|
_current_company = company;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ::CompanyID ScriptObject::GetCompany()
|
/* static */ ::CompanyID ScriptObject::GetCompany()
|
||||||
{
|
{
|
||||||
return GetStorage()->company;
|
return GetStorage().company;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ::CompanyID ScriptObject::GetRootCompany()
|
/* static */ ::CompanyID ScriptObject::GetRootCompany()
|
||||||
{
|
{
|
||||||
return GetStorage()->root_company;
|
return GetStorage().root_company;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptObject::CanSuspend()
|
/* static */ bool ScriptObject::CanSuspend()
|
||||||
{
|
{
|
||||||
Squirrel *squirrel = ScriptObject::GetActiveInstance().engine;
|
Squirrel *squirrel = ScriptObject::GetActiveInstance().engine;
|
||||||
return GetStorage()->allow_do_command && squirrel->CanSuspend();
|
return GetStorage().allow_do_command && squirrel->CanSuspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptEventQueue &ScriptObject::GetEventQueue()
|
/* static */ ScriptEventQueue &ScriptObject::GetEventQueue()
|
||||||
{
|
{
|
||||||
return GetStorage()->event_queue;
|
return GetStorage().event_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptLogTypes::LogData &ScriptObject::GetLogData()
|
/* static */ ScriptLogTypes::LogData &ScriptObject::GetLogData()
|
||||||
{
|
{
|
||||||
return GetStorage()->log_data;
|
return GetStorage().log_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetCallbackVariable(int index, int value)
|
/* static */ void ScriptObject::SetCallbackVariable(int index, int value)
|
||||||
{
|
{
|
||||||
if (static_cast<size_t>(index) >= GetStorage()->callback_value.size()) GetStorage()->callback_value.resize(index + 1);
|
if (static_cast<size_t>(index) >= GetStorage().callback_value.size()) GetStorage().callback_value.resize(index + 1);
|
||||||
GetStorage()->callback_value[index] = value;
|
GetStorage().callback_value[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int ScriptObject::GetCallbackVariable(int index)
|
/* static */ int ScriptObject::GetCallbackVariable(int index)
|
||||||
{
|
{
|
||||||
return GetStorage()->callback_value[index];
|
return GetStorage().callback_value[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ CommandCallbackData *ScriptObject::GetDoCommandCallback()
|
/* static */ CommandCallbackData *ScriptObject::GetDoCommandCallback()
|
||||||
|
@ -310,8 +310,8 @@ ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
||||||
IncreaseDoCommandCosts(res.GetCost());
|
IncreaseDoCommandCosts(res.GetCost());
|
||||||
if (!_generating_world) {
|
if (!_generating_world) {
|
||||||
/* Charge a nominal fee for asynchronously executed commands */
|
/* Charge a nominal fee for asynchronously executed commands */
|
||||||
Squirrel *engine = ScriptObject::GetActiveInstance().engine;
|
Squirrel &engine = *ScriptObject::GetActiveInstance().engine;
|
||||||
Squirrel::DecreaseOps(engine->GetVM(), 100);
|
Squirrel::DecreaseOps(engine.GetVM(), 100);
|
||||||
}
|
}
|
||||||
if (callback != nullptr) {
|
if (callback != nullptr) {
|
||||||
/* Insert return value into to stack and throw a control code that
|
/* Insert return value into to stack and throw a control code that
|
||||||
|
|
|
@ -100,7 +100,7 @@ void ScriptInstance::Initialize(const std::string &main_script, const std::strin
|
||||||
|
|
||||||
void ScriptInstance::RegisterAPI()
|
void ScriptInstance::RegisterAPI()
|
||||||
{
|
{
|
||||||
squirrel_register_std(this->engine);
|
squirrel_register_std(*this->engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptInstance::LoadCompatibilityScript(std::string_view api_version, Subdirectory dir)
|
bool ScriptInstance::LoadCompatibilityScript(std::string_view api_version, Subdirectory dir)
|
||||||
|
@ -318,9 +318,10 @@ void ScriptInstance::CollectGarbage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScriptStorage *ScriptInstance::GetStorage()
|
ScriptStorage &ScriptInstance::GetStorage()
|
||||||
{
|
{
|
||||||
return this->storage;
|
assert(this->storage != nullptr);
|
||||||
|
return *this->storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptLogTypes::LogData &ScriptInstance::GetLogData()
|
ScriptLogTypes::LogData &ScriptInstance::GetLogData()
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Get the storage of this script.
|
* Get the storage of this script.
|
||||||
*/
|
*/
|
||||||
class ScriptStorage *GetStorage();
|
class ScriptStorage &GetStorage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the log pointer of this script.
|
* Get the log pointer of this script.
|
||||||
|
@ -146,7 +146,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* Get the controller attached to the instance.
|
* Get the controller attached to the instance.
|
||||||
*/
|
*/
|
||||||
class ScriptController *GetController() { return controller; }
|
class ScriptController &GetController()
|
||||||
|
{
|
||||||
|
assert(this->controller != nullptr);
|
||||||
|
return *this->controller;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the "this script died" value
|
* Return the "this script died" value
|
||||||
|
|
|
@ -536,7 +536,7 @@ void Squirrel::Initialize()
|
||||||
sq_setforeignptr(this->vm, this);
|
sq_setforeignptr(this->vm, this);
|
||||||
|
|
||||||
sq_pushroottable(this->vm);
|
sq_pushroottable(this->vm);
|
||||||
squirrel_register_global_std(this);
|
squirrel_register_global_std(*this);
|
||||||
|
|
||||||
/* Set consts table as delegate of root table, so consts/enums defined via require() are accessible */
|
/* Set consts table as delegate of root table, so consts/enums defined via require() are accessible */
|
||||||
sq_pushconsttable(this->vm);
|
sq_pushconsttable(this->vm);
|
||||||
|
|
|
@ -82,20 +82,20 @@ SQInteger SquirrelStd::notifyallexceptions(HSQUIRRELVM vm)
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void squirrel_register_global_std(Squirrel *engine)
|
void squirrel_register_global_std(Squirrel &engine)
|
||||||
{
|
{
|
||||||
/* We don't use squirrel_helper here, as we want to register to the global
|
/* We don't use squirrel_helper here, as we want to register to the global
|
||||||
* scope and not to a class. */
|
* scope and not to a class. */
|
||||||
engine->AddMethod("require", &SquirrelStd::require, ".s");
|
engine.AddMethod("require", &SquirrelStd::require, ".s");
|
||||||
engine->AddMethod("notifyallexceptions", &SquirrelStd::notifyallexceptions, ".b");
|
engine.AddMethod("notifyallexceptions", &SquirrelStd::notifyallexceptions, ".b");
|
||||||
}
|
}
|
||||||
|
|
||||||
void squirrel_register_std(Squirrel *engine)
|
void squirrel_register_std(Squirrel &engine)
|
||||||
{
|
{
|
||||||
/* We don't use squirrel_helper here, as we want to register to the global
|
/* We don't use squirrel_helper here, as we want to register to the global
|
||||||
* scope and not to a class. */
|
* scope and not to a class. */
|
||||||
engine->AddMethod("min", &SquirrelStd::min, ".ii");
|
engine.AddMethod("min", &SquirrelStd::min, ".ii");
|
||||||
engine->AddMethod("max", &SquirrelStd::max, ".ii");
|
engine.AddMethod("max", &SquirrelStd::max, ".ii");
|
||||||
|
|
||||||
sqstd_register_mathlib(engine->GetVM());
|
sqstd_register_mathlib(engine.GetVM());
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,12 +52,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Register all standard functions we want to give to a script.
|
* Register all standard functions we want to give to a script.
|
||||||
*/
|
*/
|
||||||
void squirrel_register_std(Squirrel *engine);
|
void squirrel_register_std(Squirrel &engine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register all standard functions that are available on first startup.
|
* Register all standard functions that are available on first startup.
|
||||||
* @note this set is very limited, and is only meant to load other scripts and things like that.
|
* @note this set is very limited, and is only meant to load other scripts and things like that.
|
||||||
*/
|
*/
|
||||||
void squirrel_register_global_std(Squirrel *engine);
|
void squirrel_register_global_std(Squirrel &engine);
|
||||||
|
|
||||||
#endif /* SQUIRREL_STD_HPP */
|
#endif /* SQUIRREL_STD_HPP */
|
||||||
|
|
|
@ -3331,7 +3331,7 @@ draw_default_foundation:
|
||||||
auto result = GetRoadStopLayout(ti, stopspec, st, type, view, regs100);
|
auto result = GetRoadStopLayout(ti, stopspec, st, type, view, regs100);
|
||||||
if (result.has_value()) {
|
if (result.has_value()) {
|
||||||
if (stopspec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) {
|
if (stopspec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) {
|
||||||
stop_draw_mode = static_cast<RoadStopDrawMode>(regs100[0]);
|
stop_draw_mode = static_cast<RoadStopDrawModes>(regs100[0]);
|
||||||
}
|
}
|
||||||
if (type == StationType::RoadWaypoint && stop_draw_mode.Test(RoadStopDrawMode::WaypGround)) {
|
if (type == StationType::RoadWaypoint && stop_draw_mode.Test(RoadStopDrawMode::WaypGround)) {
|
||||||
draw_ground = true;
|
draw_ground = true;
|
||||||
|
|
|
@ -427,6 +427,7 @@ struct TimetableWindow : Window {
|
||||||
void DrawTimetablePanel(const Rect &r) const
|
void DrawTimetablePanel(const Rect &r) const
|
||||||
{
|
{
|
||||||
const Vehicle *v = this->vehicle;
|
const Vehicle *v = this->vehicle;
|
||||||
|
if (v->GetNumOrders() == 0) return;
|
||||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||||
int i = this->vscroll->GetPosition();
|
int i = this->vscroll->GetPosition();
|
||||||
VehicleOrderID order_id = (i + 1) / 2;
|
VehicleOrderID order_id = (i + 1) / 2;
|
||||||
|
|
Loading…
Reference in New Issue