Move NewGRF sprite dump declarations to new header file
This commit is contained in:
@@ -284,6 +284,7 @@ add_files(
|
|||||||
newgrf_config.h
|
newgrf_config.h
|
||||||
newgrf_debug.h
|
newgrf_debug.h
|
||||||
newgrf_debug_gui.cpp
|
newgrf_debug_gui.cpp
|
||||||
|
newgrf_dump.h
|
||||||
newgrf_engine.cpp
|
newgrf_engine.cpp
|
||||||
newgrf_engine.h
|
newgrf_engine.h
|
||||||
newgrf_extension.cpp
|
newgrf_extension.cpp
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
#include "newgrf_airport.h"
|
#include "newgrf_airport.h"
|
||||||
#include "newgrf_airporttiles.h"
|
#include "newgrf_airporttiles.h"
|
||||||
#include "newgrf_debug.h"
|
#include "newgrf_debug.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
#include "newgrf_object.h"
|
#include "newgrf_object.h"
|
||||||
#include "newgrf_spritegroup.h"
|
#include "newgrf_spritegroup.h"
|
||||||
#include "newgrf_station.h"
|
#include "newgrf_station.h"
|
||||||
|
59
src/newgrf_dump.h
Normal file
59
src/newgrf_dump.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file newgrf_dump.h Functions/types related to NewGRF sprite group dumping. */
|
||||||
|
|
||||||
|
#ifndef NEWGRF_DUMP_H
|
||||||
|
#define NEWGRF_DUMP_H
|
||||||
|
|
||||||
|
#include "3rdparty/robin_hood/robin_hood.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
enum DumpSpriteGroupPrintOp {
|
||||||
|
DSGPO_PRINT,
|
||||||
|
DSGPO_START,
|
||||||
|
DSGPO_END,
|
||||||
|
DSGPO_NFO_LINE,
|
||||||
|
};
|
||||||
|
|
||||||
|
using DumpSpriteGroupPrinter = std::function<void(const struct SpriteGroup *, DumpSpriteGroupPrintOp, uint32_t, const char *)>;
|
||||||
|
|
||||||
|
struct SpriteGroupDumper {
|
||||||
|
bool use_shadows = false;
|
||||||
|
bool more_details = false;
|
||||||
|
|
||||||
|
private:
|
||||||
|
char buffer[1024];
|
||||||
|
DumpSpriteGroupPrinter print_fn;
|
||||||
|
|
||||||
|
const SpriteGroup *top_default_group = nullptr;
|
||||||
|
const SpriteGroup *top_graphics_group = nullptr;
|
||||||
|
robin_hood::unordered_flat_set<const struct DeterministicSpriteGroup *> seen_dsgs;
|
||||||
|
|
||||||
|
enum SpriteGroupDumperFlags {
|
||||||
|
SGDF_DEFAULT = 1 << 0,
|
||||||
|
SGDF_RANGE = 1 << 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
char *DumpSpriteGroupAdjust(char *p, const char *last, const struct DeterministicSpriteGroupAdjust &adjust, const char *padding, uint32_t &highlight_tag, uint &conditional_indent);
|
||||||
|
void DumpSpriteGroup(const struct SpriteGroup *sg, const char *prefix, uint flags);
|
||||||
|
|
||||||
|
public:
|
||||||
|
SpriteGroupDumper(DumpSpriteGroupPrinter print) : print_fn(print) {}
|
||||||
|
|
||||||
|
void DumpSpriteGroup(const SpriteGroup *sg, uint flags)
|
||||||
|
{
|
||||||
|
this->DumpSpriteGroup(sg, "", flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print(const char *msg)
|
||||||
|
{
|
||||||
|
this->print_fn(nullptr, DSGPO_PRINT, 0, msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* NEWGRF_DEBUG_H */
|
@@ -28,6 +28,7 @@
|
|||||||
#include "scope_info.h"
|
#include "scope_info.h"
|
||||||
#include "newgrf_extension.h"
|
#include "newgrf_extension.h"
|
||||||
#include "newgrf_analysis.h"
|
#include "newgrf_analysis.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include "newgrf_extension.h"
|
#include "newgrf_extension.h"
|
||||||
#include "water_map.h"
|
#include "water_map.h"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "strings_func.h"
|
#include "strings_func.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "clear_map.h"
|
#include "clear_map.h"
|
||||||
#include "core/hash_func.hpp"
|
#include "core/hash_func.hpp"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include "map_func.h"
|
#include "map_func.h"
|
||||||
#include "tracerestrict.h"
|
#include "tracerestrict.h"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "clear_func.h"
|
#include "clear_func.h"
|
||||||
#include "newgrf_animation_base.h"
|
#include "newgrf_animation_base.h"
|
||||||
#include "newgrf_extension.h"
|
#include "newgrf_extension.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include "town.h"
|
#include "town.h"
|
||||||
#include "signal_func.h"
|
#include "signal_func.h"
|
||||||
#include "road.h"
|
#include "road.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "newgrf_animation_base.h"
|
#include "newgrf_animation_base.h"
|
||||||
#include "newgrf_sound.h"
|
#include "newgrf_sound.h"
|
||||||
#include "newgrf_extension.h"
|
#include "newgrf_extension.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include "date_func.h"
|
#include "date_func.h"
|
||||||
#include "depot_base.h"
|
#include "depot_base.h"
|
||||||
#include "town.h"
|
#include "town.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "debug_settings.h"
|
#include "debug_settings.h"
|
||||||
#include "newgrf_engine.h"
|
#include "newgrf_engine.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
#include <bit>
|
#include <bit>
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
@@ -20,8 +20,6 @@
|
|||||||
#include "newgrf_storage.h"
|
#include "newgrf_storage.h"
|
||||||
#include "newgrf_commons.h"
|
#include "newgrf_commons.h"
|
||||||
|
|
||||||
#include "3rdparty/robin_hood/robin_hood.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -747,49 +745,6 @@ struct ResolverObject {
|
|||||||
virtual uint32_t GetDebugID() const { return 0; }
|
virtual uint32_t GetDebugID() const { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DumpSpriteGroupPrintOp {
|
|
||||||
DSGPO_PRINT,
|
|
||||||
DSGPO_START,
|
|
||||||
DSGPO_END,
|
|
||||||
DSGPO_NFO_LINE,
|
|
||||||
};
|
|
||||||
|
|
||||||
using DumpSpriteGroupPrinter = std::function<void(const SpriteGroup *, DumpSpriteGroupPrintOp, uint32_t, const char *)>;
|
|
||||||
|
|
||||||
struct SpriteGroupDumper {
|
|
||||||
bool use_shadows = false;
|
|
||||||
bool more_details = false;
|
|
||||||
|
|
||||||
private:
|
|
||||||
char buffer[1024];
|
|
||||||
DumpSpriteGroupPrinter print_fn;
|
|
||||||
|
|
||||||
const SpriteGroup *top_default_group = nullptr;
|
|
||||||
const SpriteGroup *top_graphics_group = nullptr;
|
|
||||||
robin_hood::unordered_flat_set<const DeterministicSpriteGroup *> seen_dsgs;
|
|
||||||
|
|
||||||
enum SpriteGroupDumperFlags {
|
|
||||||
SGDF_DEFAULT = 1 << 0,
|
|
||||||
SGDF_RANGE = 1 << 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
char *DumpSpriteGroupAdjust(char *p, const char *last, const DeterministicSpriteGroupAdjust &adjust, const char *padding, uint32_t &highlight_tag, uint &conditional_indent);
|
|
||||||
void DumpSpriteGroup(const SpriteGroup *sg, const char *prefix, uint flags);
|
|
||||||
|
|
||||||
public:
|
|
||||||
SpriteGroupDumper(DumpSpriteGroupPrinter print) : print_fn(print) {}
|
|
||||||
|
|
||||||
void DumpSpriteGroup(const SpriteGroup *sg, uint flags)
|
|
||||||
{
|
|
||||||
this->DumpSpriteGroup(sg, "", flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Print(const char *msg)
|
|
||||||
{
|
|
||||||
this->print_fn(nullptr, DSGPO_PRINT, 0, msg);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
uint32_t EvaluateDeterministicSpriteGroupAdjust(DeterministicSpriteGroupSize size, const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, uint32_t last_value, uint32_t value);
|
uint32_t EvaluateDeterministicSpriteGroupAdjust(DeterministicSpriteGroupSize size, const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, uint32_t last_value, uint32_t value);
|
||||||
|
|
||||||
#endif /* NEWGRF_SPRITEGROUP_H */
|
#endif /* NEWGRF_SPRITEGROUP_H */
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include "newgrf_animation_base.h"
|
#include "newgrf_animation_base.h"
|
||||||
#include "newgrf_class_func.h"
|
#include "newgrf_class_func.h"
|
||||||
#include "newgrf_extension.h"
|
#include "newgrf_extension.h"
|
||||||
|
#include "newgrf_dump.h"
|
||||||
#include "core/checksum_func.hpp"
|
#include "core/checksum_func.hpp"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "../tunnelbridge.h"
|
#include "../tunnelbridge.h"
|
||||||
#include "../train_speed_adaptation.h"
|
#include "../train_speed_adaptation.h"
|
||||||
#include "../tracerestrict.h"
|
#include "../tracerestrict.h"
|
||||||
|
#include "../newgrf_dump.h"
|
||||||
|
|
||||||
/* Helper for filling property tables */
|
/* 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 }
|
#define NIP(prop, base, variable, type, name) { name, (ptrdiff_t)cpp_offsetof(base, variable), cpp_sizeof(base, variable), prop, type }
|
||||||
|
Reference in New Issue
Block a user