changeset 15083:68d1f9ea65c3 draft

(svn r19709) -Feature: NewGRF debugging/inspecting of (primarily) enabled callbacks and values of variables
author rubidium <rubidium@openttd.org>
date Sat, 24 Apr 2010 13:39:11 +0000
parents b9c35ad9b9f8
children d2731cec52ab
files src/industry_cmd.cpp src/industry_gui.cpp src/misc_gui.cpp src/rail_cmd.cpp src/station_cmd.cpp src/town_cmd.cpp src/vehicle.cpp src/vehicle_gui.cpp
diffstat 8 files changed, 57 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 	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 @@
 
 	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);
--- 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 @@
 		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 @@
 	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(),
--- 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 @@
 	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 @@
 
 public:
 	char landinfo_data[LAND_INFO_LINE_END][LAND_INFO_LINE_BUFF_SIZE];
+	TileIndex tile;
 
 	virtual void OnPaint()
 	{
@@ -135,7 +138,7 @@
 		}
 	}
 
-	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 @@
 		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)
--- 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 @@
 				}
 				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 @@
 					} else {
 						DoClearSquare(tile);
 					}
+					DeleteNewGRFInspectWindow(GSF_RAILTYPES, tile);
 				} else {
 					SetTrackBits(tile, present);
 					SetTrackReservation(tile, GetRailReservationTrackBits(tile) & present);
--- 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 @@
 			}
 
 			DoClearSquare(tile);
+			DeleteNewGRFInspectWindow(GSF_STATIONS, tile);
 			if (keep_rail) MakeRailNormal(tile, owner, TrackToTrackBits(track), rt);
 
 			st->rect.AfterRemoveTile(st, tile);
@@ -1557,6 +1559,7 @@
 				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 @@
 		if (flags & DC_EXEC) {
 			DeleteAnimatedTile(tile_cur);
 			DoClearSquare(tile_cur);
+			DeleteNewGRFInspectWindow(GSF_AIRPORTTILES, tile_cur);
 		}
 	}
 
@@ -2295,6 +2299,7 @@
 		st->UpdateVirtCoord();
 		st->RecomputeIndustriesNear();
 		DeleteStationIfEmpty(st);
+		DeleteNewGRFInspectWindow(GSF_AIRPORTS, st->index);
 	}
 
 	return cost;
--- 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 @@
 	}
 
 	DeleteSubsidyWith(ST_TOWN, this->index);
+	DeleteNewGRFInspectWindow(GSF_FAKE_TOWNS, this->index);
 	CargoPacket::InvalidateAllFrom(ST_TOWN, this->index);
 	MarkWholeScreenDirty();
 }
@@ -2210,6 +2211,8 @@
 	DecreaseBuildingCount(t, house);
 	DoClearSquare(tile);
 	DeleteAnimatedTile(tile);
+
+	DeleteNewGRFInspectWindow(GSF_HOUSES, tile);
 }
 
 /**
--- 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 @@
 
 	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
--- 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 @@
 	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 @@
 			}
 		}
 	}
+
+	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);
+	}
 };