summaryrefslogtreecommitdiff
path: root/industry_cmd.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-08-26 19:51:49 +0000
committertruelight <truelight@openttd.org>2006-08-26 19:51:49 +0000
commitb7fcce091eba6ab8603f7ae10d8952c26015baf7 (patch)
tree6ea2d59fac96e685c5333e8f358b59b50f7f67a4 /industry_cmd.c
parentb3cf0189a3163781fb661e9b1431b5c381d18c80 (diff)
downloadopenttd-b7fcce091eba6ab8603f7ae10d8952c26015baf7.tar.xz
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
-Codechange: DestroyIndustry is called by DeleteIndustry to remove all things where a industry depends on. Last 2 changes to prepare for new pool system. Not pretty now, will be soon.
Diffstat (limited to 'industry_cmd.c')
-rw-r--r--industry_cmd.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/industry_cmd.c b/industry_cmd.c
index 43397b47d..1fd1124be 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -25,6 +25,13 @@
#include "genworld.h"
#include "date.h"
+void ShowIndustryViewWindow(int industry);
+void BuildOilRig(TileIndex tile);
+void DeleteOilRig(TileIndex tile);
+
+static byte _industry_sound_ctr;
+static TileIndex _industry_sound_tile;
+
enum {
/* Max industries: 64000 (8 * 8000) */
INDUSTRY_POOL_BLOCK_SIZE_BITS = 3, /* In bits, so (1 << 3) == 8 */
@@ -46,13 +53,6 @@ static void IndustryPoolNewBlock(uint start_item)
/* Initialize the industry-pool */
MemoryPool _industry_pool = { "Industry", INDUSTRY_POOL_MAX_BLOCKS, INDUSTRY_POOL_BLOCK_SIZE_BITS, sizeof(Industry), &IndustryPoolNewBlock, NULL, 0, 0, NULL };
-static byte _industry_sound_ctr;
-static TileIndex _industry_sound_tile;
-
-void ShowIndustryViewWindow(int industry);
-void BuildOilRig(TileIndex tile);
-void DeleteOilRig(TileIndex tile);
-
static const IndustryType _industry_close_mode[IT_END] = {
/* COAL_MINE */ INDUSTRYLIFE_PRODUCTION,
/* POWER_STATION */ INDUSTRYLIFE_NOT_CLOSABLE,
@@ -132,6 +132,34 @@ const IndustrySpec *GetIndustrySpec(IndustryType thistype)
return &_industry_specs[thistype];
}
+void DestroyIndustry(Industry *i)
+{
+ BEGIN_TILE_LOOP(tile_cur, i->width, i->height, i->xy);
+ if (IsTileType(tile_cur, MP_INDUSTRY)) {
+ if (GetIndustryIndex(tile_cur) == i->index) {
+ DoClearSquare(tile_cur);
+ }
+ } else if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
+ DeleteOilRig(tile_cur);
+ }
+ END_TILE_LOOP(tile_cur, i->width, i->height, i->xy);
+
+ if (i->type == IT_FARM || i->type == IT_FARM_2) {
+ /* Remove the farmland and convert it to regular tiles over time. */
+ BEGIN_TILE_LOOP(tile_cur, 42, 42, i->xy - TileDiffXY(21, 21)) {
+ if (IsTileType(tile_cur, MP_CLEAR) && IsClearGround(tile_cur, CLEAR_FIELDS) &&
+ GetIndustryIndexOfField(tile_cur) == i->index) {
+ SetIndustryIndexOfField(tile_cur, INVALID_INDUSTRY);
+ }
+ } END_TILE_LOOP(tile_cur, 42, 42, i->xy - TileDiff(21, 21))
+ }
+
+ _industry_sort_dirty = true;
+ DeleteSubsidyWithIndustry(i->index);
+ DeleteWindowById(WC_INDUSTRY_VIEW, i->index);
+ InvalidateWindow(WC_INDUSTRY_DIRECTORY, 0);
+}
+
static void IndustryDrawSugarMine(const TileInfo *ti)
{
const DrawIndustrySpec1Struct *d;
@@ -743,35 +771,6 @@ static void ChangeTileOwner_Industry(TileIndex tile, PlayerID old_player, Player
/* not used */
}
-void DeleteIndustry(Industry *i)
-{
- BEGIN_TILE_LOOP(tile_cur, i->width, i->height, i->xy);
- if (IsTileType(tile_cur, MP_INDUSTRY)) {
- if (GetIndustryIndex(tile_cur) == i->index) {
- DoClearSquare(tile_cur);
- }
- } else if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
- DeleteOilRig(tile_cur);
- }
- END_TILE_LOOP(tile_cur, i->width, i->height, i->xy);
-
- if (i->type == IT_FARM || i->type == IT_FARM_2) {
- /* Remove the farmland and convert it to regular tiles over time. */
- BEGIN_TILE_LOOP(tile_cur, 42, 42, i->xy - TileDiffXY(21, 21)) {
- if (IsTileType(tile_cur, MP_CLEAR) && IsClearGround(tile_cur, CLEAR_FIELDS) &&
- GetIndustryIndexOfField(tile_cur) == i->index) {
- SetIndustryIndexOfField(tile_cur, INVALID_INDUSTRY);
- }
- } END_TILE_LOOP(tile_cur, 42, 42, i->xy - TileDiff(21, 21))
- }
-
- i->xy = 0;
- _industry_sort_dirty = true;
- DeleteSubsidyWithIndustry(i->index);
- DeleteWindowById(WC_INDUSTRY_VIEW, i->index);
- InvalidateWindow(WC_INDUSTRY_DIRECTORY, 0);
-}
-
static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
static bool IsBadFarmFieldTile(TileIndex tile)