Debug: Add GRF debug window support for new landscape rocks

pull/461/head
Jonathan G Rennison 2 years ago
parent 1de38b1ca0
commit 2430a5113e

@ -1171,6 +1171,9 @@ GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
{
switch (GetTileType(tile)) {
default: return GSF_INVALID;
case MP_CLEAR:
if (IsClearGround(tile, CLEAR_ROCKS)) return GSF_NEWLANDSCAPE;
return GSF_INVALID;
case MP_RAILWAY: {
extern std::vector<const GRFFile *> _new_signals_grfs;
if (HasSignals(tile) && !_new_signals_grfs.empty()) {

@ -14,6 +14,7 @@
#include "map_func.h"
#include "clear_map.h"
#include "core/hash_func.hpp"
#include "string_func.h"
#include "safeguards.h"
@ -52,7 +53,7 @@ std::vector<const GRFFile *> _new_landscape_rocks_grfs;
TileIndex tile = this->ti->tile;
if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
uint32 result = 0;
if (extra->mask & ~0x100) result |= GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8, extra->mask);
if (extra->mask & ~0x100) result |= GetNearbyTileInformation(tile, this->ro.grffile == nullptr || this->ro.grffile->grf_version >= 8, extra->mask);
if (extra->mask & 0x100) {
switch (this->landscape_type) {
case NEW_LANDSCAPE_ROCKS:
@ -99,3 +100,17 @@ NewLandscapeResolverObject::NewLandscapeResolverObject(const GRFFile *grffile, c
this->root_spritegroup = nullptr;
}
}
void DumpNewLandscapeRocksSpriteGroups(DumpSpriteGroupPrinter print)
{
SpriteGroupDumper dumper(print);
bool first = true;
for (const GRFFile *grf : _new_landscape_rocks_grfs) {
if (!first) print(nullptr, DSGPO_PRINT, 0, "");
char buffer[64];
seprintf(buffer, lastof(buffer), "GRF: %08X", BSWAP32(grf->grfid));
print(nullptr, DSGPO_PRINT, 0, buffer);
first = false;
dumper.DumpSpriteGroup(grf->new_rocks_group, 0);
}
}

@ -13,6 +13,7 @@
#include "../newgrf_roadstop.h"
#include "../newgrf_cargo.h"
#include "../newgrf_newsignals.h"
#include "../newgrf_newlandscape.h"
#include "../date_func.h"
#include "../timetable.h"
#include "../ship.h"
@ -22,6 +23,7 @@
#include "../string_func_extra.h"
#include "../newgrf_extension.h"
#include "../animated_tile.h"
#include "../clear_map.h"
/* Helper for filling property tables */
#define NIP(prop, base, variable, type, name) { name, (ptrdiff_t)cpp_offsetof(base, variable), cpp_sizeof(base, variable), prop, type }
@ -1754,6 +1756,54 @@ static const NIFeature _nif_roadstop = {
new NIHRoadStop(),
};
static const NIVariable _niv_newlandscape[] = {
NIV(0x40, "terrain type"),
NIV(0x41, "tile slope"),
NIV(0x42, "tile height"),
NIV(0x43, "tile hash"),
NIV(0x44, "landscape type"),
NIV(0x60, "land info of nearby tiles"),
NIV_END(),
};
class NIHNewLandscape : public NIHelper {
bool IsInspectable(uint index) const override { return true; }
bool ShowExtraInfoOnly(uint index) const override { return _new_landscape_rocks_grfs.empty(); }
bool ShowSpriteDumpButton(uint index) const override { return true; }
uint GetParent(uint index) const override { return UINT32_MAX; }
const void *GetInstance(uint index)const override { return nullptr; }
const void *GetSpec(uint index) const override { return nullptr; }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_LAI_CLEAR_DESCRIPTION_ROCKS, INVALID_STRING_ID, index); }
uint32 GetGRFID(uint index) const override { return 0; }
uint Resolve(uint index, uint var, uint param, GetVariableExtra *extra) const override
{
if (!IsTileType(index, MP_CLEAR)) return 0;
TileInfo ti;
ti.x = TileX(index);
ti.y = TileY(index);
ti.tileh = GetTilePixelSlope(index, &ti.z);
ti.tile = index;
NewLandscapeResolverObject ro(nullptr, &ti, NEW_LANDSCAPE_ROCKS);
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, extra);
}
/* virtual */ void SpriteDump(uint index, DumpSpriteGroupPrinter print) const override
{
extern void DumpNewLandscapeRocksSpriteGroups(DumpSpriteGroupPrinter print);
DumpNewLandscapeRocksSpriteGroups(std::move(print));
}
};
static const NIFeature _nif_newlandscape = {
nullptr,
nullptr,
_niv_newlandscape,
new NIHNewLandscape(),
};
/** Table with all NIFeatures. */
static const NIFeature * const _nifeatures[] = {
&_nif_vehicle, // GSF_TRAINS
@ -1777,7 +1827,7 @@ static const NIFeature * const _nifeatures[] = {
&_nif_roadtype, // GSF_ROADTYPES
&_nif_roadtype, // GSF_TRAMTYPES
&_nif_roadstop, // GSF_ROADSTOPS
nullptr, // GSF_NEWLANDSCAPE
&_nif_newlandscape, // GSF_NEWLANDSCAPE
&_nif_town, // GSF_FAKE_TOWNS
&_nif_station_struct, // GSF_FAKE_STATION_STRUCT
};

Loading…
Cancel
Save