324 static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 internal_id) |
324 static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 internal_id) |
325 { |
325 { |
326 /* Hack for add-on GRFs that need to modify another GRF's engines. This lets |
326 /* Hack for add-on GRFs that need to modify another GRF's engines. This lets |
327 * them use the same engine slots. */ |
327 * them use the same engine slots. */ |
328 const GRFFile *grf_match = NULL; |
328 const GRFFile *grf_match = NULL; |
329 if (_settings.vehicle.dynamic_engines) { |
329 if (_settings_game.vehicle.dynamic_engines) { |
330 uint32 override = _grf_id_overrides[file->grfid]; |
330 uint32 override = _grf_id_overrides[file->grfid]; |
331 if (override != 0) { |
331 if (override != 0) { |
332 grf_match = GetFileByGRFID(override); |
332 grf_match = GetFileByGRFID(override); |
333 if (grf_match == NULL) { |
333 if (grf_match == NULL) { |
334 grfmsg(5, "Tried mapping from GRFID %x to %x but target is not loaded", BSWAP32(file->grfid), BSWAP32(override)); |
334 grfmsg(5, "Tried mapping from GRFID %x to %x but target is not loaded", BSWAP32(file->grfid), BSWAP32(override)); |
375 EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id) |
375 EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id) |
376 { |
376 { |
377 extern uint32 GetNewGRFOverride(uint32 grfid); |
377 extern uint32 GetNewGRFOverride(uint32 grfid); |
378 |
378 |
379 const GRFFile *grf_match = NULL; |
379 const GRFFile *grf_match = NULL; |
380 if (_settings.vehicle.dynamic_engines) { |
380 if (_settings_game.vehicle.dynamic_engines) { |
381 uint32 override = _grf_id_overrides[file->grfid]; |
381 uint32 override = _grf_id_overrides[file->grfid]; |
382 if (override != 0) grf_match = GetFileByGRFID(override); |
382 if (override != 0) grf_match = GetFileByGRFID(override); |
383 } |
383 } |
384 |
384 |
385 const Engine *e = NULL; |
385 const Engine *e = NULL; |
386 FOR_ALL_ENGINES(e) { |
386 FOR_ALL_ENGINES(e) { |
387 if (_settings.vehicle.dynamic_engines && e->grffile != file && (grf_match == NULL || e->grffile != grf_match)) continue; |
387 if (_settings_game.vehicle.dynamic_engines && e->grffile != file && (grf_match == NULL || e->grffile != grf_match)) continue; |
388 if (e->type != type) continue; |
388 if (e->type != type) continue; |
389 if (e->internal_id != internal_id) continue; |
389 if (e->internal_id != internal_id) continue; |
390 |
390 |
391 return e->index; |
391 return e->index; |
392 } |
392 } |
1435 case 0x0F: { // Goods/candy, food/fizzy drinks acceptance |
1435 case 0x0F: { // Goods/candy, food/fizzy drinks acceptance |
1436 int8 goods = grf_load_byte(&buf); |
1436 int8 goods = grf_load_byte(&buf); |
1437 |
1437 |
1438 /* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance. |
1438 /* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance. |
1439 * Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */ |
1439 * Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */ |
1440 CargoID cid = (goods >= 0) ? ((_settings.game_creation.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) : |
1440 CargoID cid = (goods >= 0) ? ((_settings_game.game_creation.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) : |
1441 ((_settings.game_creation.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD); |
1441 ((_settings_game.game_creation.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD); |
1442 |
1442 |
1443 /* Make sure the cargo type is valid in this climate. */ |
1443 /* Make sure the cargo type is valid in this climate. */ |
1444 if (!GetCargo(cid)->IsValid()) goods = 0; |
1444 if (!GetCargo(cid)->IsValid()) goods = 0; |
1445 |
1445 |
1446 housespec->accepts_cargo[2] = cid; |
1446 housespec->accepts_cargo[2] = cid; |
3590 return true; |
3590 return true; |
3591 |
3591 |
3592 case 0x0F: // Rail track type cost factors |
3592 case 0x0F: // Rail track type cost factors |
3593 *value = 0; |
3593 *value = 0; |
3594 SB(*value, 0, 8, _railtype_cost_multiplier[0]); // normal rail |
3594 SB(*value, 0, 8, _railtype_cost_multiplier[0]); // normal rail |
3595 if (_settings.vehicle.disable_elrails) { |
3595 if (_settings_game.vehicle.disable_elrails) { |
3596 /* skip elrail multiplier - disabled */ |
3596 /* skip elrail multiplier - disabled */ |
3597 SB(*value, 8, 8, _railtype_cost_multiplier[2]); // monorail |
3597 SB(*value, 8, 8, _railtype_cost_multiplier[2]); // monorail |
3598 } else { |
3598 } else { |
3599 SB(*value, 8, 8, _railtype_cost_multiplier[1]); // electified railway |
3599 SB(*value, 8, 8, _railtype_cost_multiplier[1]); // electified railway |
3600 /* Skip monorail multiplier - no space in result */ |
3600 /* Skip monorail multiplier - no space in result */ |
4186 |
4186 |
4187 static uint32 GetPatchVariable(uint8 param) |
4187 static uint32 GetPatchVariable(uint8 param) |
4188 { |
4188 { |
4189 switch (param) { |
4189 switch (param) { |
4190 /* start year - 1920 */ |
4190 /* start year - 1920 */ |
4191 case 0x0B: return max(_settings.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR; |
4191 case 0x0B: return max(_settings_game.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR; |
4192 |
4192 |
4193 /* freight trains weight factor */ |
4193 /* freight trains weight factor */ |
4194 case 0x0E: return _settings.vehicle.freight_trains; |
4194 case 0x0E: return _settings_game.vehicle.freight_trains; |
4195 |
4195 |
4196 /* empty wagon speed increase */ |
4196 /* empty wagon speed increase */ |
4197 case 0x0F: return 0; |
4197 case 0x0F: return 0; |
4198 |
4198 |
4199 /* plane speed factor; our patch option is reversed from TTDPatch's, |
4199 /* plane speed factor; our patch option is reversed from TTDPatch's, |
4200 * the following is good for 1x, 2x and 4x (most common?) and... |
4200 * the following is good for 1x, 2x and 4x (most common?) and... |
4201 * well not really for 3x. */ |
4201 * well not really for 3x. */ |
4202 case 0x10: |
4202 case 0x10: |
4203 switch (_settings.vehicle.plane_speed) { |
4203 switch (_settings_game.vehicle.plane_speed) { |
4204 default: |
4204 default: |
4205 case 4: return 1; |
4205 case 4: return 1; |
4206 case 3: return 2; |
4206 case 3: return 2; |
4207 case 2: return 2; |
4207 case 2: return 2; |
4208 case 1: return 4; |
4208 case 1: return 4; |
4542 _traininfo_vehicle_pitch = res; |
4542 _traininfo_vehicle_pitch = res; |
4543 break; |
4543 break; |
4544 |
4544 |
4545 case 0x8F: // Rail track type cost factors |
4545 case 0x8F: // Rail track type cost factors |
4546 _railtype_cost_multiplier[0] = GB(res, 0, 8); |
4546 _railtype_cost_multiplier[0] = GB(res, 0, 8); |
4547 if (_settings.vehicle.disable_elrails) { |
4547 if (_settings_game.vehicle.disable_elrails) { |
4548 _railtype_cost_multiplier[1] = GB(res, 0, 8); |
4548 _railtype_cost_multiplier[1] = GB(res, 0, 8); |
4549 _railtype_cost_multiplier[2] = GB(res, 8, 8); |
4549 _railtype_cost_multiplier[2] = GB(res, 8, 8); |
4550 } else { |
4550 } else { |
4551 _railtype_cost_multiplier[1] = GB(res, 8, 8); |
4551 _railtype_cost_multiplier[1] = GB(res, 8, 8); |
4552 _railtype_cost_multiplier[2] = GB(res, 16, 8); |
4552 _railtype_cost_multiplier[2] = GB(res, 16, 8); |
5077 } |
5077 } |
5078 |
5078 |
5079 |
5079 |
5080 static void InitializeGRFSpecial() |
5080 static void InitializeGRFSpecial() |
5081 { |
5081 { |
5082 _ttdpatch_flags[0] = ((_settings.station.always_small_airport ? 1 : 0) << 0x0C) // keepsmallairport |
5082 _ttdpatch_flags[0] = ((_settings_game.station.always_small_airport ? 1 : 0) << 0x0C) // keepsmallairport |
5083 | (1 << 0x0D) // newairports |
5083 | (1 << 0x0D) // newairports |
5084 | (1 << 0x0E) // largestations |
5084 | (1 << 0x0E) // largestations |
5085 | ((_settings.construction.longbridges ? 1 : 0) << 0x0F) // longbridges |
5085 | ((_settings_game.construction.longbridges ? 1 : 0) << 0x0F) // longbridges |
5086 | (0 << 0x10) // loadtime |
5086 | (0 << 0x10) // loadtime |
5087 | (1 << 0x12) // presignals |
5087 | (1 << 0x12) // presignals |
5088 | (1 << 0x13) // extpresignals |
5088 | (1 << 0x13) // extpresignals |
5089 | ((_settings.vehicle.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist |
5089 | ((_settings_game.vehicle.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist |
5090 | (1 << 0x1B) // multihead |
5090 | (1 << 0x1B) // multihead |
5091 | (1 << 0x1D) // lowmemory |
5091 | (1 << 0x1D) // lowmemory |
5092 | (1 << 0x1E); // generalfixes |
5092 | (1 << 0x1E); // generalfixes |
5093 |
5093 |
5094 _ttdpatch_flags[1] = ((_settings.economy.station_noise_level ? 1 : 0) << 0x07) // moreairports - based on units of noise |
5094 _ttdpatch_flags[1] = ((_settings_game.economy.station_noise_level ? 1 : 0) << 0x07) // moreairports - based on units of noise |
5095 | ((_settings.vehicle.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains |
5095 | ((_settings_game.vehicle.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains |
5096 | (1 << 0x09) // trainrefit |
5096 | (1 << 0x09) // trainrefit |
5097 | (0 << 0x0B) // subsidiaries |
5097 | (0 << 0x0B) // subsidiaries |
5098 | ((_settings.order.gradual_loading ? 1 : 0) << 0x0C) // gradualloading |
5098 | ((_settings_game.order.gradual_loading ? 1 : 0) << 0x0C) // gradualloading |
5099 | (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD |
5099 | (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD |
5100 | (1 << 0x13) // unifiedmaglevmode - set bit 1 mode |
5100 | (1 << 0x13) // unifiedmaglevmode - set bit 1 mode |
5101 | (1 << 0x14) // bridgespeedlimits |
5101 | (1 << 0x14) // bridgespeedlimits |
5102 | (1 << 0x16) // eternalgame |
5102 | (1 << 0x16) // eternalgame |
5103 | (1 << 0x17) // newtrains |
5103 | (1 << 0x17) // newtrains |
5104 | (1 << 0x18) // newrvs |
5104 | (1 << 0x18) // newrvs |
5105 | (1 << 0x19) // newships |
5105 | (1 << 0x19) // newships |
5106 | (1 << 0x1A) // newplanes |
5106 | (1 << 0x1A) // newplanes |
5107 | ((_settings.construction.signal_side ? 1 : 0) << 0x1B) // signalsontrafficside |
5107 | ((_settings_game.construction.signal_side ? 1 : 0) << 0x1B) // signalsontrafficside |
5108 | ((_settings.vehicle.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway |
5108 | ((_settings_game.vehicle.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway |
5109 |
5109 |
5110 _ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote |
5110 _ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote |
5111 | (1 << 0x03) // semaphores |
5111 | (1 << 0x03) // semaphores |
5112 | (0 << 0x0B) // enhancedgui |
5112 | (0 << 0x0B) // enhancedgui |
5113 | (0 << 0x0C) // newagerating |
5113 | (0 << 0x0C) // newagerating |
5114 | ((_settings.construction.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes |
5114 | ((_settings_game.construction.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes |
5115 | (1 << 0x0E) // fullloadany |
5115 | (1 << 0x0E) // fullloadany |
5116 | (1 << 0x0F) // planespeed |
5116 | (1 << 0x0F) // planespeed |
5117 | (0 << 0x10) // moreindustriesperclimate - obsolete |
5117 | (0 << 0x10) // moreindustriesperclimate - obsolete |
5118 | (0 << 0x11) // moretoylandfeatures |
5118 | (0 << 0x11) // moretoylandfeatures |
5119 | (1 << 0x12) // newstations |
5119 | (1 << 0x12) // newstations |
5120 | (1 << 0x13) // tracktypecostdiff |
5120 | (1 << 0x13) // tracktypecostdiff |
5121 | (1 << 0x14) // manualconvert |
5121 | (1 << 0x14) // manualconvert |
5122 | ((_settings.construction.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts |
5122 | ((_settings_game.construction.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts |
5123 | (1 << 0x16) // canals |
5123 | (1 << 0x16) // canals |
5124 | (1 << 0x17) // newstartyear |
5124 | (1 << 0x17) // newstartyear |
5125 | ((_settings.vehicle.freight_trains > 1 ? 1 : 0) << 0x18) // freighttrains |
5125 | ((_settings_game.vehicle.freight_trains > 1 ? 1 : 0) << 0x18) // freighttrains |
5126 | (1 << 0x19) // newhouses |
5126 | (1 << 0x19) // newhouses |
5127 | (1 << 0x1A) // newbridges |
5127 | (1 << 0x1A) // newbridges |
5128 | (1 << 0x1B) // newtownnames |
5128 | (1 << 0x1B) // newtownnames |
5129 | (1 << 0x1C) // moreanimation |
5129 | (1 << 0x1C) // moreanimation |
5130 | ((_settings.vehicle.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits |
5130 | ((_settings_game.vehicle.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits |
5131 | (1 << 0x1E) // newshistory |
5131 | (1 << 0x1E) // newshistory |
5132 | (0 << 0x1F); // custombridgeheads |
5132 | (0 << 0x1F); // custombridgeheads |
5133 |
5133 |
5134 _ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution |
5134 _ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution |
5135 | (1 << 0x01) // windowsnap |
5135 | (1 << 0x01) // windowsnap |
5137 | (0 << 0x03) // pathbasedsignalling. To enable if ever pbs is back |
5137 | (0 << 0x03) // pathbasedsignalling. To enable if ever pbs is back |
5138 | (0 << 0x04) // aichoosechance |
5138 | (0 << 0x04) // aichoosechance |
5139 | (1 << 0x05) // resolutionwidth |
5139 | (1 << 0x05) // resolutionwidth |
5140 | (1 << 0x06) // resolutionheight |
5140 | (1 << 0x06) // resolutionheight |
5141 | (1 << 0x07) // newindustries |
5141 | (1 << 0x07) // newindustries |
5142 | ((_settings.order.improved_load ? 1 : 0) << 0x08) // fifoloading |
5142 | ((_settings_game.order.improved_load ? 1 : 0) << 0x08) // fifoloading |
5143 | (0 << 0x09) // townroadbranchprob |
5143 | (0 << 0x09) // townroadbranchprob |
5144 | (0 << 0x0A) // tempsnowline |
5144 | (0 << 0x0A) // tempsnowline |
5145 | (1 << 0x0B) // newcargo |
5145 | (1 << 0x0B) // newcargo |
5146 | (1 << 0x0C) // enhancemultiplayer |
5146 | (1 << 0x0C) // enhancemultiplayer |
5147 | (1 << 0x0D) // onewayroads |
5147 | (1 << 0x0D) // onewayroads |
5148 | ((_settings.station.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations |
5148 | ((_settings_game.station.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations |
5149 | (1 << 0x0F) // statistics |
5149 | (1 << 0x0F) // statistics |
5150 | (1 << 0x10) // newsounds |
5150 | (1 << 0x10) // newsounds |
5151 | (1 << 0x11) // autoreplace |
5151 | (1 << 0x11) // autoreplace |
5152 | (1 << 0x12) // autoslope |
5152 | (1 << 0x12) // autoslope |
5153 | (0 << 0x13) // followvehicle |
5153 | (0 << 0x13) // followvehicle |
5154 | (1 << 0x14) // trams |
5154 | (1 << 0x14) // trams |
5155 | (0 << 0x15) // enhancetunnels |
5155 | (0 << 0x15) // enhancetunnels |
5156 | (1 << 0x16) // shortrvs |
5156 | (1 << 0x16) // shortrvs |
5157 | (1 << 0x17) // articulatedrvs |
5157 | (1 << 0x17) // articulatedrvs |
5158 | ((_settings.vehicle.dynamic_engines ? 1 : 0) << 0x18) // dynamic engines |
5158 | ((_settings_game.vehicle.dynamic_engines ? 1 : 0) << 0x18) // dynamic engines |
5159 | (1 << 0x1E); // variablerunningcosts |
5159 | (1 << 0x1E); // variablerunningcosts |
5160 } |
5160 } |
5161 |
5161 |
5162 static void ResetCustomStations() |
5162 static void ResetCustomStations() |
5163 { |
5163 { |