Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3541ba4
Codechange: use unique_ptr over CallocT and avoid copying table
rubidium42 Jan 13, 2025
3a7cfaf
Codechange: use std::unique_ptr over CallocT for tiles
rubidium42 Jan 13, 2025
9ab936f
Add: [Script] ScriptEventCompanyRename (#12878)
bjornwarmedal Jan 14, 2025
29129e1
Add: [Script] Event for when a company's president name changes
rubidium42 Dec 30, 2024
95f8fc9
Codechange: Make GroupFlags an enum class. (#13312)
PeterN Jan 14, 2025
84e049e
Codechange: Use ranges to get select server list position. (#13316)
PeterN Jan 14, 2025
e2b0ea1
Codechange: use std::unique_ptr over MallocT/free for dedicated video…
rubidium42 Jan 14, 2025
3edf19a
Add: Sandbox settings to Sandbox Options window. (#13268)
PeterN Jan 14, 2025
74bd064
Codechange: Pass first and last ID range instead of first and count. …
PeterN Jan 14, 2025
4c8f1b0
Add: Ability to toggle visibility of station signs by facility. (#13207)
PeterN Jan 14, 2025
71efd64
Update: Translations from eints
Jan 15, 2025
4018179
Cleanup: Remove unused includes and function (#13321)
SamuXarick Jan 15, 2025
8942ac1
Fix 4c8f1b0f8: Remove unnecessary icon from settings drop down list. …
PeterN Jan 15, 2025
8f74684
Codechange: use std::unique_ptr over manual memory management
rubidium42 Jan 15, 2025
5fea35b
Update: Translations from eints
Jan 16, 2025
348e6b7
Codefix: Use correct GRF version during safety and label scans.
PeterN Jan 11, 2025
0a99bf7
Codechange: NewGRF varaction parameter is 32 bit.
PeterN Jan 10, 2025
0602920
Change: [NewGRF] Implement GRFv9.
PeterN Jan 10, 2025
606ae94
Change: [NewGRF] Remove properties removed in GRFv9.
PeterN Jan 12, 2025
7548137
Doc: GRFv8 to GRFv9 changes.
PeterN Jan 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions docs/GRFv9_changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
## GRFv9 changes from GRFv8.

* ALL existing Extended Byte fields are now Word fields.
* Action 00:
* `num-info` is now a Word.
* Feature 00: Trains
* Property 05 `tracktype` is now a Word.
* Property 15 `cargotype` is now a Word.
* Property 1D `refitmask` is **removed**.
* Property 2C/2D `cttinclude`/`cttexclude` are now a Word followed by a list of Words.
* Feature 01: Road vehicles
* Property 05 `roadtramtype` is now a Word.
* Property 10 `cargotype` is now a Word.
* Property 12 `sfx` is now a Word.
* Property 16 `refitmask` is **removed**.
* Property 24/25 `cttinclude`/`cttexclude` are now a Word followed by a list of Words.
* Feature 02: Ships
* Property 0C `cargotype` is now a Word.
* Property 10 `sfx` is now a Word.
* Property 11 `refitmask` is **removed**.
* Property 1E/1F `cttinclude`/`cttexclude` are now a Word followed by a list of Words.
* Feature 03: Aircraft
* Property 12 `sfx` is now a Word.
* Property 13 `refitmask` is **removed**.
* Property 1D/1E `cttinclude`/`cttexclude` are now a Word followed by a list of Words.
* Feature 07: Houses
* Properties 0D, 0E, 0F and 1E are **removed**.
* Property 20 `watched cargoes` is now a Word followed by a list of Words.
* Property 23 `accepted cargoes` is now a Word followed by a list of (Word, Byte).
* Feature 09: Industry tiles
* Properties 0A, 0B and 0C are **removed**.
* Property 13 `cargo acceptance` is now a Word followed by a list of (Word, Byte).
* Feature 0A: Industries
* Properties 10, 11, 12, 13 are **removed**.
* Property 15 `sfx` is now a Word followed by a list of Words.
* Properties 1C, 1D and 1E are **removed**.
* Properties 25/16 `producedcargoes`/`acceptedcargoes` are now a Word followed by a list of Words.
* Property 27 `productionrates` is now a Word follow by a list of Bytes.
* Feature 10: Railtypes
* Properties 0E, 0F, 18, 19 and 1D are now a Word followed by a list of DWords.
* Feature 12/13: Roadtypes and Tramtypes
* Properties 0F, 18, 19 and 1D are now a Word followed by a list of DWords.
* Action 02:
* `set-id` is now a Word. Maximum set-id is now 7FFF instead of FF.
* `subroutine` is now a Word.
* `parameter` is now a **DWord**.
* VariationalAction2 `nvar` is now a Word.
* RandomAction2 `nrand` is now a Word.
* Action 03:
* `n-id` is now a Word.
* `ids...` are each now a Word.
* `num-cid` is now a Word.
* `cargo-type` is now a Word.
* Action 04:
* `num-ent` is now a Word.
* `offset` is now always a Word, instead of varying depending on feature/flags.
* Action 07/09:
* `num-sprites` is now a Word. If bit 15 is set, then this is a label instead of the number of sprites.
* Action 0A:
* `num-sets` is now a Word.
* `num-sprites` is now a Word.
* Action 0E:
* `num` is now a Word.
* Action 10:
* `label` is now a Word. Labels MUST have bit 15 set. This means there is no longer any conflict with labels overlapping numbers.
* Action 12:
* `num-def` is now a Word.
* `num-char` is now a Word.
* `base-char` is now a **DWord**. This allows custom glyphs between 0x10000 and 0x1FFFFD to be defined.
* Action 13:
* `num-ent` is now a Word.
14 changes: 14 additions & 0 deletions regression/regression/main.nut
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,20 @@ function Regression::Start()
print(" VehicleID: " + c.GetVehicleID());
} break;

case AIEvent.ET_COMPANY_RENAMED: {
local c = AIEventCompanyRenamed.Convert(e);
print(" EventName: CompanyRenamed");
print(" CompanyID: " + c.GetCompanyID());
print(" CompanyName: " + c.GetNewName());
} break;

case AIEvent.ET_PRESIDENT_RENAMED: {
local c = AIEventPresidentRenamed.Convert(e);
print(" EventName: PresidentRenamed");
print(" CompanyID: " + c.GetCompanyID());
print(" PresidentName: " + c.GetNewName());
} break;

default:
print(" Unknown Event");
break;
Expand Down
21 changes: 18 additions & 3 deletions regression/regression/result.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9711,6 +9711,21 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetDestinationType(): 1
GetDestinationIndex(): 7
GetCargoType(): 0
GetNextEvent: instance
GetEventType: 33
EventName: CompanyRenamed
CompanyID: 1
CompanyName: Regression
GetNextEvent: instance
GetEventType: 34
EventName: PresidentRenamed
CompanyID: 1
PresidentName: Regression AI
GetNextEvent: instance
GetEventType: 33
EventName: CompanyRenamed
CompanyID: 1
CompanyName: Little Frutford Transport
IsEventWaiting: false

--Math--
Expand Down Expand Up @@ -9748,9 +9763,9 @@ ERROR: IsEnd() is invalid as Begin() is never called
--Valuate() with excessive CPU usage--
Your script made an error: excessive CPU usage in valuator function

*FUNCTION [unknown()] regression/main.nut line [2051]
*FUNCTION [unknown()] regression/main.nut line [2065]
*FUNCTION [Valuate()] NATIVE line [-1]
*FUNCTION [Start()] regression/main.nut line [2052]
*FUNCTION [Start()] regression/main.nut line [2066]

[id] 0
[this] TABLE
Expand All @@ -9759,7 +9774,7 @@ Your script made an error: excessive CPU usage in valuator function
[this] INSTANCE
Your script made an error: excessive CPU usage in valuator function

*FUNCTION [Start()] regression/main.nut line [2052]
*FUNCTION [Start()] regression/main.nut line [2066]

[Infinite] CLOSURE
[list] INSTANCE
Expand Down
2 changes: 1 addition & 1 deletion src/autoreplace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void RemoveAllEngineReplacement(EngineRenewList *erl)
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old)
{
const EngineRenew *er = GetEngineReplacement(erl, engine, group);
if (er == nullptr && (group == DEFAULT_GROUP || (Group::IsValidID(group) && !HasBit(Group::Get(group)->flags, GroupFlags::GF_REPLACE_PROTECTION)))) {
if (er == nullptr && (group == DEFAULT_GROUP || (Group::IsValidID(group) && !HasFlag(Group::Get(group)->flags, GroupFlags::ReplaceProtection)))) {
/* We didn't find anything useful in the vehicle's own group so we will try ALL_GROUP */
er = GetEngineReplacement(erl, engine, ALL_GROUP);
}
Expand Down
2 changes: 1 addition & 1 deletion src/autoreplace_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ CommandCost CmdAutoreplaceVehicle(DoCommandFlag flags, VehicleID veh_id)
bool wagon_removal = c->settings.renew_keep_length;

const Group *g = Group::GetIfValid(v->group_id);
if (g != nullptr) wagon_removal = HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL);
if (g != nullptr) wagon_removal = HasFlag(g->flags, GroupFlags::ReplaceWagonRemoval);

/* Test whether any replacement is set, before issuing a whole lot of commands that would end in nothing changed */
Vehicle *w = v;
Expand Down
4 changes: 2 additions & 2 deletions src/autoreplace_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class ReplaceVehicleWindow : public Window {
bool remove_wagon;
const Group *g = Group::GetIfValid(this->sel_group);
if (g != nullptr) {
remove_wagon = HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL);
remove_wagon = HasFlag(g->flags, GroupFlags::ReplaceWagonRemoval);
SetDParam(0, STR_GROUP_NAME);
SetDParam(1, sel_group);
} else {
Expand Down Expand Up @@ -554,7 +554,7 @@ class ReplaceVehicleWindow : public Window {
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
const Group *g = Group::GetIfValid(this->sel_group);
if (g != nullptr) {
Command<CMD_SET_GROUP_FLAG>::Post(this->sel_group, GroupFlags::GF_REPLACE_WAGON_REMOVAL, !HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL), _ctrl_pressed);
Command<CMD_SET_GROUP_FLAG>::Post(this->sel_group, GroupFlags::ReplaceWagonRemoval, !HasFlag(g->flags, GroupFlags::ReplaceWagonRemoval), _ctrl_pressed);
} else {
// toggle renew_keep_length
Command<CMD_CHANGE_COMPANY_SETTING>::Post("company.renew_keep_length", Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1);
Expand Down
2 changes: 1 addition & 1 deletion src/base_station_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
* @param available will return false if ever the variable asked for does not exist
* @return the value stored in the corresponding variable
*/
virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const = 0;
virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint32_t parameter, bool &available) const = 0;

/**
* Update the coordinated of the sign (as shown in the viewport).
Expand Down
10 changes: 2 additions & 8 deletions src/blitter/32bpp_anim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
/** Instantiation of the 32bpp with animation blitter factory. */
static FBlitter_32bppAnim iFBlitter_32bppAnim;

Blitter_32bppAnim::~Blitter_32bppAnim()
{
free(this->anim_alloc);
}

template <BlitterMode mode>
inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
{
Expand Down Expand Up @@ -545,13 +540,12 @@ void Blitter_32bppAnim::PostResize()
if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height ||
_screen.pitch != this->anim_buf_pitch) {
/* The size of the screen changed; we can assume we can wipe all data from our buffer */
free(this->anim_alloc);
this->anim_buf_width = _screen.width;
this->anim_buf_height = _screen.height;
this->anim_buf_pitch = (_screen.width + 7) & ~7;
this->anim_alloc = CallocT<uint16_t>(this->anim_buf_pitch * this->anim_buf_height + 8);
this->anim_alloc = std::make_unique<uint16_t[]>(this->anim_buf_pitch * this->anim_buf_height + 8);

/* align buffer to next 16 byte boundary */
this->anim_buf = reinterpret_cast<uint16_t *>((reinterpret_cast<uintptr_t>(this->anim_alloc) + 0xF) & (~0xF));
this->anim_buf = reinterpret_cast<uint16_t *>((reinterpret_cast<uintptr_t>(this->anim_alloc.get()) + 0xF) & (~0xF));
}
}
5 changes: 1 addition & 4 deletions src/blitter/32bpp_anim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class Blitter_32bppAnim : public Blitter_32bppOptimized {
protected:
uint16_t *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
void *anim_alloc; ///< The raw allocated buffer, not necessarily aligned correctly
std::unique_ptr<uint16_t[]> anim_alloc; ///< The raw allocated buffer, not necessarily aligned correctly
int anim_buf_width; ///< The width of the animation buffer.
int anim_buf_height; ///< The height of the animation buffer.
int anim_buf_pitch; ///< The pitch of the animation buffer (width rounded up to 16 byte boundary).
Expand All @@ -25,16 +25,13 @@ class Blitter_32bppAnim : public Blitter_32bppOptimized {
public:
Blitter_32bppAnim() :
anim_buf(nullptr),
anim_alloc(nullptr),
anim_buf_width(0),
anim_buf_height(0),
anim_buf_pitch(0)
{
this->palette = _cur_palette;
}

~Blitter_32bppAnim();

void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
void SetPixel(void *video, int x, int y, uint8_t colour) override;
Expand Down
23 changes: 10 additions & 13 deletions src/blitter/32bpp_optimized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
/* streams of pixels (a, r, g, b channels)
*
* stored in separated stream so data are always aligned on 4B boundary */
Colour *dst_px_orig[ZOOM_LVL_END];
std::array<std::unique_ptr<Colour[]>, ZOOM_LVL_END> dst_px_orig;

/* interleaved stream of 'm' channel and 'n' channel
* 'n' is number of following pixels with the same alpha channel class
* there are 3 classes: 0, 255, others
*
* it has to be stored in one stream so fewer registers are used -
* x86 has problems with register allocation even with this solution */
uint16_t *dst_n_orig[ZOOM_LVL_END];
std::array<std::unique_ptr<uint16_t[]>, ZOOM_LVL_END> dst_n_orig;

/* lengths of streams */
uint32_t lengths[ZOOM_LVL_END][2];
Expand All @@ -320,11 +320,11 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const

uint size = src_orig->height * src_orig->width;

dst_px_orig[z] = CallocT<Colour>(size + src_orig->height * 2);
dst_n_orig[z] = CallocT<uint16_t>(size * 2 + src_orig->height * 4 * 2);
dst_px_orig[z] = std::make_unique<Colour[]>(size + src_orig->height * 2);
dst_n_orig[z] = std::make_unique<uint16_t[]>(size * 2 + src_orig->height * 4 * 2);

uint32_t *dst_px_ln = (uint32_t *)dst_px_orig[z];
uint32_t *dst_n_ln = (uint32_t *)dst_n_orig[z];
uint32_t *dst_px_ln = reinterpret_cast<uint32_t *>(dst_px_orig[z].get());
uint32_t *dst_n_ln = reinterpret_cast<uint32_t *>(dst_n_orig[z].get());

const SpriteLoader::CommonPixel *src = (const SpriteLoader::CommonPixel *)src_orig->data;

Expand Down Expand Up @@ -405,8 +405,8 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
dst_n_ln = (uint32_t *)dst_n;
}

lengths[z][0] = (uint8_t *)dst_px_ln - (uint8_t *)dst_px_orig[z]; // all are aligned to 4B boundary
lengths[z][1] = (uint8_t *)dst_n_ln - (uint8_t *)dst_n_orig[z];
lengths[z][0] = reinterpret_cast<uint8_t *>(dst_px_ln) - reinterpret_cast<uint8_t *>(dst_px_orig[z].get()); // all are aligned to 4B boundary
lengths[z][1] = reinterpret_cast<uint8_t *>(dst_n_ln) - reinterpret_cast<uint8_t *>(dst_n_orig[z].get());
}

uint len = 0; // total length of data
Expand All @@ -428,11 +428,8 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
dst->offset[z][0] = z == zoom_min ? 0 : lengths[z - 1][1] + dst->offset[z - 1][1];
dst->offset[z][1] = lengths[z][0] + dst->offset[z][0];

memcpy(dst->data + dst->offset[z][0], dst_px_orig[z], lengths[z][0]);
memcpy(dst->data + dst->offset[z][1], dst_n_orig[z], lengths[z][1]);

free(dst_px_orig[z]);
free(dst_n_orig[z]);
memcpy(dst->data + dst->offset[z][0], dst_px_orig[z].get(), lengths[z][0]);
memcpy(dst->data + dst->offset[z][1], dst_n_orig[z].get(), lengths[z][1]);
}

return dest_sprite;
Expand Down
Loading
Loading