summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2009-01-20 16:06:57 +0000
committerbelugas <belugas@openttd.org>2009-01-20 16:06:57 +0000
commit9bd7b6bd0cc314a086100a72df6efbc7c9b0d996 (patch)
treeabdaad1237105397c3de13de28b2b39440a921b7
parent1f5b8c97df949f33cfd339aded85ea58aadb49ff (diff)
downloadopenttd-9bd7b6bd0cc314a086100a72df6efbc7c9b0d996.tar.xz
(svn r15172) -Feature: Allow a grf to customize house name via callback 0x14D, during Tile Inquiry process
-rw-r--r--src/newgrf_callbacks.h4
-rw-r--r--src/town_cmd.cpp16
2 files changed, 18 insertions, 2 deletions
diff --git a/src/newgrf_callbacks.h b/src/newgrf_callbacks.h
index d8e1cf8cd..0d3471da0 100644
--- a/src/newgrf_callbacks.h
+++ b/src/newgrf_callbacks.h
@@ -208,6 +208,9 @@ enum CallbackID {
/** Customize the output cargo types of a newly build industry. */
CBID_INDUSTRY_OUTPUT_CARGO_TYPES = 0x14C, // 8 bit callback
+
+ /** Called on the Get Tile Description for an house tile. */
+ CBID_HOUSE_CUSTOM_NAME = 0x14D, // 15 bit callback
};
/**
@@ -251,6 +254,7 @@ enum HouseCallbackMask {
CBM_HOUSE_ACCEPT_CARGO = 8,
CBM_HOUSE_PRODUCE_CARGO = 9,
CBM_HOUSE_DENY_DESTRUCTION = 10,
+
};
/**
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index b7c6709c8..9ef890a91 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -31,6 +31,7 @@
#include "newgrf_house.h"
#include "newgrf_commons.h"
#include "newgrf_townname.h"
+#include "newgrf_text.h"
#include "autoslope.h"
#include "waypoint.h"
#include "transparency.h"
@@ -628,10 +629,21 @@ static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
{
- const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
+ const HouseID house = GetHouseType(tile);
+ const HouseSpec *hs = GetHouseSpecs(house);
+ bool house_completed = IsHouseCompleted(tile);
td->str = hs->building_name;
- if (!IsHouseCompleted(tile)) {
+
+ uint16 callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, GetTownByTile(tile), tile);
+ if (callback_res != CALLBACK_FAILED) {
+ StringID new_name = GetGRFStringID(hs->grffile->grfid, 0xD000 + callback_res);
+ if (new_name != STR_NULL && new_name != STR_UNDEFINED) {
+ td->str = new_name;
+ }
+ }
+
+ if (!house_completed) {
SetDParamX(td->dparam, 0, td->str);
td->str = STR_2058_UNDER_CONSTRUCTION;
}