summaryrefslogtreecommitdiff
path: root/unmovable_cmd.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-03-31 08:59:19 +0000
committercelestar <celestar@openttd.org>2006-03-31 08:59:19 +0000
commite875be1a44404b5783d743aaddf9b2b71125bdf1 (patch)
tree3727f85f2767737fb8f5414b2ed6b0fe2ee22a24 /unmovable_cmd.c
parentb47d27932a7db5683dffa94c1db4a33404e9c3e6 (diff)
downloadopenttd-e875be1a44404b5783d743aaddf9b2b71125bdf1.tar.xz
(svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
Diffstat (limited to 'unmovable_cmd.c')
-rw-r--r--unmovable_cmd.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 1b1de5876..497a61167 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -59,6 +59,35 @@ static int32 DestroyCompanyHQ(TileIndex tile, uint32 flags)
return CalculateCompanyValue(p) / 100;
}
+void UpdateCompanyHQ(Player *p, uint score)
+{
+ byte val;
+ TileIndex tile = p->location_of_house;
+
+ if (tile == 0)
+ return;
+
+ (val = 128, score < 170) ||
+ (val+= 4, score < 350) ||
+ (val+= 4, score < 520) ||
+ (val+= 4, score < 720) ||
+ (val+= 4, true);
+
+/* house is already big enough */
+ if (val <= _m[tile].m5)
+ return;
+
+ _m[tile + TileDiffXY(0, 0)].m5 = val;
+ _m[tile + TileDiffXY(0, 1)].m5 = ++val;
+ _m[tile + TileDiffXY(1, 0)].m5 = ++val;
+ _m[tile + TileDiffXY(1, 1)].m5 = ++val;
+
+ MarkTileDirtyByTile(tile + TileDiffXY(0, 0));
+ MarkTileDirtyByTile(tile + TileDiffXY(0, 1));
+ MarkTileDirtyByTile(tile + TileDiffXY(1, 0));
+ MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
+}
+
/** Build or relocate the HQ. This depends if the HQ is already built or not
* @param x,y the coordinates where the HQ will be built or relocated to
* @param p1 unused
@@ -91,7 +120,7 @@ int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
MakeCompanyHQ(tile, _current_player);
- UpdatePlayerHouse(p, score);
+ UpdateCompanyHQ(p, score);
InvalidateWindow(WC_COMPANY, p->index);
}