Mercurial > hg > openttd
changeset 7186:0a85b5cc61f4 draft
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 07 Jul 2007 08:53:19 +0000 |
parents | 0398071acc00 |
children | 84996de3b1df |
files | src/economy.cpp src/industry.h src/industry_cmd.cpp src/newgrf_industries.cpp src/openttd.cpp |
diffstat | 5 files changed, 40 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -1236,7 +1236,9 @@ if (best != NULL) { indspec = GetIndustrySpec(best->type); uint16 callback = indspec->callback_flags; + best->was_cargo_delivered = true; + best->last_cargo_accepted_at = _date; if (HASBIT(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HASBIT(callback, CBM_IND_PRODUCTION_256_TICKS)) { best->incoming_cargo_waiting[accepted_cargo_index] = min(num_pieces + best->incoming_cargo_waiting[accepted_cargo_index], 0xFFFF);
--- a/src/industry.h +++ b/src/industry.h @@ -49,6 +49,13 @@ CHECK_END, }; +enum IndustryConstructionType { + ICT_UNKNOWN, + ICT_NORMAL_GAMEPLAY, + ICT_MAP_GENERATION, + ICT_SCENARIO_EDITOR +}; + enum IndustyBehaviour { INDUSTRYBEH_NONE = 0, INDUSTRYBEH_PLANT_FIELDS = 1 << 0, ///< periodically plants fileds around itself (temp and artic farms) @@ -96,6 +103,11 @@ byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry IndustryID index; ///< index of the industry in the pool of industries + + OwnerByte founder; ///< Founder of the industry + Date construction_date; ///< Date of the construction of the industry + uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType) + Date last_cargo_accepted_at; ///< Last day cargo was accepted by this industry }; struct IndustryTileTable {
--- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -792,7 +792,9 @@ static void ChangeTileOwner_Industry(TileIndex tile, PlayerID old_player, PlayerID new_player) { - /* not used */ + /* If the founder merges, the industry was created by the merged company */ + Industry *i = GetIndustryByTile(tile); + if (i->founder == old_player) i->founder = (new_player == PLAYER_SPECTATOR) ? OWNER_NONE : new_player; } static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6}; @@ -1411,6 +1413,10 @@ i->last_prod_year = _cur_year; i->last_month_production[0] = i->production_rate[0] * 8; i->last_month_production[1] = i->production_rate[1] * 8; + i->founder = _current_player; + i->construction_date = _date; + i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR : + (_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY); if (!_generating_world) i->last_month_production[0] = i->last_month_production[1] = 0; @@ -1951,6 +1957,11 @@ SLE_CONDVAR(Industry, last_prod_year, SLE_INT32, 31, SL_MAX_VERSION), SLE_VAR(Industry, was_cargo_delivered, SLE_UINT8), + SLE_CONDVAR(Industry, owner, SLE_UINT8, 70, SL_MAX_VERSION), + SLE_CONDVAR(Industry, construction_date, SLE_INT32, 70, SL_MAX_VERSION), + SLE_CONDVAR(Industry, construction_type, SLE_UINT8, 70, SL_MAX_VERSION), + SLE_CONDVAR(Industry, last_cargo_accepted_at, SLE_INT32, 70, SL_MAX_VERSION), + /* reserve extra space in savegame here. (currently 32 bytes) */ SLE_CONDNULL(32, 2, SL_MAX_VERSION),
--- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -14,6 +14,7 @@ #include "newgrf_spritegroup.h" #include "newgrf_industries.h" #include "newgrf_commons.h" +#include "date.h" /* Since the industry IDs defined by the GRF file don't necessarily correlate * to those used by the game, the IDs used for overriding old industries must be @@ -151,15 +152,6 @@ * let's just say it is a beginning ;) */ case 0x67: return GetIndustryTypeCount(industry->type) << 16 | 0; - /* Industry founder information. - * 0x10 if randomly created or from a map pre-newindustry. - * Else, the company who funded it */ - case 0xA7: return 0x10; - - case 0xB0: // Date when built since 1920 (in days) - case 0xB3: // Construction type - case 0xB4: break; // Date last cargo accepted since 1920 (in days) - /* Industry structure access*/ case 0x80: return industry->xy; case 0x81: return GB(industry->xy, 8, 8); @@ -167,7 +159,7 @@ case 0x82: case 0x83: case 0x84: - case 0x85: break; // not supported + case 0x85: DEBUG(grf, 0, "NewGRFs shouldn't be doing pointer magic"); break; // not supported case 0x86: return industry->width; case 0x87: return industry->height;// xy dimensions /* */ @@ -208,12 +200,16 @@ case 0xA5: return GB(industry->last_month_transported[0], 8, 8); case 0xA6: return industry->type; - + case 0xA7: return industry->founder; case 0xA8: return industry->random_color; - case 0xA9: return industry->last_prod_year; // capped? + case 0xA9: return clamp(0, industry->last_prod_year - 1920, 255); case 0xAA: return industry->counter; case 0xAB: return GB(industry->counter, 8, 8); case 0xAC: return industry->was_cargo_delivered; + + case 0xB0: return clamp(0, industry->construction_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 65535); // Date when built since 1920 (in days) + case 0xB3: return industry->construction_type; // Construction type + case 0xB4: return clamp(0, industry->last_cargo_accepted_at - DAYS_TILL_ORIGINAL_BASE_YEAR, 65535); // Date last cargo accepted since 1920 (in days) } DEBUG(grf, 1, "Unhandled industry property 0x%X", variable);