summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-04-24 13:39:11 +0000
committerrubidium <rubidium@openttd.org>2010-04-24 13:39:11 +0000
commitf56ebd81c35beb0094c487cc3dc45dc0427fae46 (patch)
tree36776a247dae7d416030b82239b506698c94ce29
parent21883a84d7883df5feb25d6536ec8f67a053fe42 (diff)
downloadopenttd-f56ebd81c35beb0094c487cc3dc45dc0427fae46.tar.xz
(svn r19709) -Feature: NewGRF debugging/inspecting of (primarily) enabled callbacks and values of variables
-rw-r--r--src/industry_cmd.cpp4
-rw-r--r--src/industry_gui.cpp12
-rw-r--r--src/misc_gui.cpp15
-rw-r--r--src/rail_cmd.cpp3
-rw-r--r--src/station_cmd.cpp5
-rw-r--r--src/town_cmd.cpp5
-rw-r--r--src/vehicle.cpp2
-rw-r--r--src/vehicle_gui.cpp13
8 files changed, 57 insertions, 2 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 35a5fe49c..17e6e46cd 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -26,6 +26,7 @@
#include "newgrf.h"
#include "newgrf_cargo.h"
#include "newgrf_commons.h"
+#include "newgrf_debug.h"
#include "newgrf_industries.h"
#include "newgrf_industrytiles.h"
#include "autoslope.h"
@@ -141,6 +142,8 @@ Industry::~Industry()
TILE_AREA_LOOP(tile_cur, this->location) {
if (IsTileType(tile_cur, MP_INDUSTRY)) {
if (GetIndustryIndex(tile_cur) == this->index) {
+ DeleteNewGRFInspectWindow(GSF_INDUSTRYTILES, tile_cur);
+
/* MakeWaterKeepingClass() can also handle 'land' */
MakeWaterKeepingClass(tile_cur, OWNER_NONE);
@@ -173,6 +176,7 @@ Industry::~Industry()
DeleteIndustryNews(this->index);
DeleteWindowById(WC_INDUSTRY_VIEW, this->index);
+ DeleteNewGRFInspectWindow(GSF_INDUSTRIES, this->index);
DeleteSubsidyWith(ST_INDUSTRY, this->index);
CargoPacket::InvalidateAllFrom(ST_INDUSTRY, this->index);
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index d9fc30eb7..0f6d8ba62 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -23,6 +23,7 @@
#include "newgrf.h"
#include "newgrf_industries.h"
#include "newgrf_text.h"
+#include "newgrf_debug.h"
#include "strings_func.h"
#include "company_func.h"
#include "tilehighlight_func.h"
@@ -834,6 +835,16 @@ public:
UpdateIndustryProduction(i);
this->SetDirty();
}
+
+ virtual bool IsNewGRFInspectable() const
+ {
+ return ::IsNewGRFInspectable(GSF_INDUSTRIES, this->window_number);
+ }
+
+ virtual void ShowNewGRFInspectWindow() const
+ {
+ ::ShowNewGRFInspectWindow(GSF_INDUSTRIES, this->window_number);
+ }
};
static void UpdateIndustryProduction(Industry *i)
@@ -850,6 +861,7 @@ static const NWidgetPart _nested_industry_view_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_CREAM),
NWidget(WWT_CAPTION, COLOUR_CREAM, IVW_CAPTION), SetDataTip(STR_INDUSTRY_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
+ NWidget(WWT_DEBUGBOX, COLOUR_CREAM),
NWidget(WWT_SHADEBOX, COLOUR_CREAM),
NWidget(WWT_STICKYBOX, COLOUR_CREAM),
EndContainer(),
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 477c187ba..fe108c553 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -35,6 +35,7 @@
#include "querystring_gui.h"
#include "console_func.h"
#include "core/geometry_func.hpp"
+#include "newgrf_debug.h"
#include "table/strings.h"
@@ -65,6 +66,7 @@ static const NWidgetPart _nested_land_info_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_LAND_AREA_INFORMATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
+ NWidget(WWT_DEBUGBOX, COLOUR_GREY),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, LIW_BACKGROUND), EndContainer(),
};
@@ -87,6 +89,7 @@ class LandInfoWindow : public Window {
public:
char landinfo_data[LAND_INFO_LINE_END][LAND_INFO_LINE_BUFF_SIZE];
+ TileIndex tile;
virtual void OnPaint()
{
@@ -135,7 +138,7 @@ public:
}
}
- LandInfoWindow(TileIndex tile) : Window() {
+ LandInfoWindow(TileIndex tile) : Window(), tile(tile) {
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
@@ -315,6 +318,16 @@ public:
DEBUG(misc, LANDINFOD_LEVEL, "m7 = %#x", _me[tile].m7);
#undef LANDINFOD_LEVEL
}
+
+ virtual bool IsNewGRFInspectable() const
+ {
+ return ::IsNewGRFInspectable(GetGrfSpecFeature(this->tile), this->tile);
+ }
+
+ virtual void ShowNewGRFInspectWindow() const
+ {
+ ::ShowNewGRFInspectWindow(GetGrfSpecFeature(this->tile), this->tile);
+ }
};
static void Place_LandInfo(TileIndex tile)
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index de9b2543d..81bd3a5bc 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -19,6 +19,7 @@
#include "pathfinder/yapf/yapf_cache.h"
#include "newgrf_engine.h"
#include "landscape_type.h"
+#include "newgrf_debug.h"
#include "newgrf_railtype.h"
#include "newgrf_commons.h"
#include "train.h"
@@ -537,6 +538,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
}
owner = GetTileOwner(tile);
MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM));
+ DeleteNewGRFInspectWindow(GSF_RAILTYPES, tile);
}
break;
}
@@ -579,6 +581,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
} else {
DoClearSquare(tile);
}
+ DeleteNewGRFInspectWindow(GSF_RAILTYPES, tile);
} else {
SetTrackBits(tile, present);
SetTrackReservation(tile, GetRailReservationTrackBits(tile) & present);
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 13d16f962..0b928cfbe 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -22,6 +22,7 @@
#include "roadveh.h"
#include "industry.h"
#include "newgrf_cargo.h"
+#include "newgrf_debug.h"
#include "newgrf_station.h"
#include "pathfinder/yapf/yapf_cache.h"
#include "road_internal.h" /* For drawing catenary/checking road removal */
@@ -1412,6 +1413,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected
}
DoClearSquare(tile);
+ DeleteNewGRFInspectWindow(GSF_STATIONS, tile);
if (keep_rail) MakeRailNormal(tile, owner, TrackToTrackBits(track), rt);
st->rect.AfterRemoveTile(st, tile);
@@ -1557,6 +1559,7 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags)
if (v != NULL) FreeTrainTrackReservation(v);
}
DoClearSquare(tile);
+ DeleteNewGRFInspectWindow(GSF_STATIONS, tile);
AddTrackToSignalBuffer(tile, track, owner);
YapfNotifyTrackLayoutChange(tile, track);
if (v != NULL) TryPathReserve(v, true);
@@ -2264,6 +2267,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
if (flags & DC_EXEC) {
DeleteAnimatedTile(tile_cur);
DoClearSquare(tile_cur);
+ DeleteNewGRFInspectWindow(GSF_AIRPORTTILES, tile_cur);
}
}
@@ -2295,6 +2299,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
st->UpdateVirtCoord();
st->RecomputeIndustriesNear();
DeleteStationIfEmpty(st);
+ DeleteNewGRFInspectWindow(GSF_AIRPORTS, st->index);
}
return cost;
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index a77203014..47bd8b219 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -24,7 +24,7 @@
#include "unmovable_map.h"
#include "variables.h"
#include "genworld.h"
-#include "newgrf.h"
+#include "newgrf_debug.h"
#include "newgrf_house.h"
#include "newgrf_commons.h"
#include "newgrf_text.h"
@@ -98,6 +98,7 @@ Town::~Town()
}
DeleteSubsidyWith(ST_TOWN, this->index);
+ DeleteNewGRFInspectWindow(GSF_FAKE_TOWNS, this->index);
CargoPacket::InvalidateAllFrom(ST_TOWN, this->index);
MarkWholeScreenDirty();
}
@@ -2210,6 +2211,8 @@ static void DoClearTownHouseHelper(TileIndex tile, Town *t, HouseID house)
DecreaseBuildingCount(t, house);
DoClearSquare(tile);
DeleteAnimatedTile(tile);
+
+ DeleteNewGRFInspectWindow(GSF_HOUSES, tile);
}
/**
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index bd016c683..8d902b241 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -24,6 +24,7 @@
#include "vehicle_gui.h"
#include "train.h"
#include "aircraft.h"
+#include "newgrf_debug.h"
#include "newgrf_engine.h"
#include "newgrf_sound.h"
#include "newgrf_station.h"
@@ -681,6 +682,7 @@ Vehicle::~Vehicle()
UpdateVehiclePosHash(this, INVALID_COORD, 0);
DeleteVehicleNews(this->index, INVALID_STRING_ID);
+ DeleteNewGRFInspectWindow(GetGrfSpecFeature(this->type), this->index);
}
/** Adds a vehicle to the list of vehicles, that visited a depot this tick
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index e9a9839d6..fa14063fe 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -20,6 +20,7 @@
#include "viewport_func.h"
#include "newgrf_engine.h"
#include "newgrf_text.h"
+#include "newgrf_debug.h"
#include "waypoint_base.h"
#include "roadveh.h"
#include "train.h"
@@ -41,6 +42,7 @@
#include "company_base.h"
#include "engine_base.h"
#include "engine_func.h"
+#include "newgrf.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -1763,6 +1765,7 @@ static const NWidgetPart _nested_vehicle_view_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, VVW_WIDGET_CAPTION), SetDataTip(STR_VEHICLE_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
+ NWidget(WWT_DEBUGBOX, COLOUR_GREY),
NWidget(WWT_SHADEBOX, COLOUR_GREY),
NWidget(WWT_STICKYBOX, COLOUR_GREY),
EndContainer(),
@@ -2195,6 +2198,16 @@ public:
}
}
}
+
+ virtual bool IsNewGRFInspectable() const
+ {
+ return ::IsNewGRFInspectable(GetGrfSpecFeature(Vehicle::Get(this->window_number)->type), this->window_number);
+ }
+
+ virtual void ShowNewGRFInspectWindow() const
+ {
+ ::ShowNewGRFInspectWindow(GetGrfSpecFeature(Vehicle::Get(this->window_number)->type), this->window_number);
+ }
};