diff options
author | dominik <dominik@openttd.org> | 2004-08-15 13:21:18 +0000 |
---|---|---|
committer | dominik <dominik@openttd.org> | 2004-08-15 13:21:18 +0000 |
commit | 43d691df17d98aa5493e63d9e7e082d975290af8 (patch) | |
tree | 28db4e04a1455a8c875507c7a3e92e1af81af191 | |
parent | f5e2d7593149e603cb06673151d5799ffe708b23 (diff) | |
download | openttd-43d691df17d98aa5493e63d9e7e082d975290af8.tar.xz |
(svn r56) Improved order checker + patch setting for it (celestar)
-rw-r--r-- | lang/english.txt | 26 | ||||
-rw-r--r-- | order_cmd.c | 103 | ||||
-rw-r--r-- | settings.c | 1 | ||||
-rw-r--r-- | settings_gui.c | 1 | ||||
-rw-r--r-- | station.h | 2 | ||||
-rw-r--r-- | station_cmd.c | 14 | ||||
-rw-r--r-- | variables.h | 1 |
7 files changed, 85 insertions, 63 deletions
diff --git a/lang/english.txt b/lang/english.txt index 225bbf4ba..3571feaa4 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -903,22 +903,30 @@ STR_TRAIN_IS_LOST :{WHITE}Train {COMMA16} is lost. STR_TRAIN_IS_UNPROFITABLE :{WHITE}Train {COMMA16}'s profit last year was {CURRENCY} STR_EURO_INTRODUCE :{BLACK}{BIGFONT}European Monetary Union!{}{}The Euro is introduced as the sole currency for everyday transactions in your country! -STR_TRAIN_AUTORENEW_FAILED :{WHITE}Autorenew failed on train {COMMA16} (money limit) +# Start of order review system. +# DON'T ADD OR REMOVE LINES HERE STR_TRAIN_HAS_TOO_FEW_ORDERS :{WHITE}Train {COMMA16} has too few orders in the schedule STR_TRAIN_HAS_VOID_ORDER :{WHITE}Train {COMMA16} has a void order STR_TRAIN_HAS_DUPLICATE_ENTRY :{WHITE}Train {COMMA16} has duplicate orders -STR_AIRCRAFT_AUTORENEW_FAILED :{WHITE}Autorenew failed on aircraft {COMMA16} (money limit) -STR_AIRCRAFT_HAS_TOO_FEW_ORDERS :{WHITE}Aircraft {COMMA16} has too few orders in the schedule -STR_AIRCRAFT_HAS_VOID_ORDER :{WHITE}Aircraft {COMMA16} has void order -STR_AIRCRAFT_HAS_DUPLICATE_ENTRY :{WHITE}Aircraft {COMMA16} has duplicate orders -STR_ROADVEHICLE_AUTORENEW_FAILED :{WHITE}Autorenew failed on road vehicle {COMMA16} (money limit) +STR_TRAIN_HAS_INVALID_ENTRY :{WHITE}Train {COMMA16} has an invalid station in the orders STR_ROADVEHICLE_HAS_TOO_FEW_ORDERS :{WHITE}Road Vehicle {COMMA16} has too few orders in the schedule STR_ROADVEHICLE_HAS_VOID_ORDER :{WHITE}Road Vehicle {COMMA16} has void order STR_ROADVEHICLE_HAS_DUPLICATE_ENTRY :{WHITE}Road Vehicle {COMMA16} has duplicate orders -STR_SHIP_AUTORENEW_FAILED :{WHITE}Autorenew failed on ship {COMMA16} (money limit) +STR_ROADVEHICLE_HAS_INVALID_ENTRY :{WHITE}Road Vehicle {COMMA16} has an invalid station in the orders STR_SHIP_HAS_TOO_FEW_ORDERS :{WHITE}Ship {COMMA16} has too few orders in the schedule STR_SHIP_HAS_VOID_ORDER :{WHITE}Ship {COMMA16} has void order STR_SHIP_HAS_DUPLICATE_ENTRY :{WHITE}Ship {COMMA16} has duplicate orders +STR_SHIP_HAS_INVALID_ENTRY :{WHITE}Ship {COMMA16} has an invalid station in the orders +STR_AIRCRAFT_HAS_TOO_FEW_ORDERS :{WHITE}Aircraft {COMMA16} has too few orders in the schedule +STR_AIRCRAFT_HAS_VOID_ORDER :{WHITE}Aircraft {COMMA16} has void order +STR_AIRCRAFT_HAS_DUPLICATE_ENTRY :{WHITE}Aircraft {COMMA16} has duplicate orders +STR_AIRCRAFT_HAS_INVALID_ENTRY :{WHITE}Aircraft {COMMA16} has an invalid station in the orders +# end of order system + +STR_TRAIN_AUTORENEW_FAILED :{WHITE}Autorenew failed on train {COMMA16} (money limit) +STR_ROADVEHICLE_AUTORENEW_FAILED :{WHITE}Autorenew failed on road vehicle {COMMA16} (money limit) +STR_SHIP_AUTORENEW_FAILED :{WHITE}Autorenew failed on ship {COMMA16} (money limit) +STR_AIRCRAFT_AUTORENEW_FAILED :{WHITE}Autorenew failed on aircraft {COMMA16} (money limit) STR_CONFIG_PATCHES :{BLACK}Configure Patches STR_CONFIG_PATCHES_TIP :{BLACK}Configure the patches @@ -955,6 +963,10 @@ STR_CONFIG_PATCHES_SMALL_AIRPORTS :{LTBLUE}Always allow small airports: {ORANGE STR_CONFIG_PATCHES_LOST_TRAIN_DAYS :{LTBLUE}A train is lost if no progress is made for: {ORANGE}{STRING} days STR_CONFIG_PATCHES_LOST_TRAIN_DAYS_DISABLED :{LTBLUE}A train is lost if no progress is made for: {ORANGE}disabled +STR_CONFIG_PATCHES_ORDER_REVIEW :{LTBLUE}Review vehicles' orders: {ORANGE}{STRING} +STR_CONFIG_PATCHES_ORDER_REVIEW_OFF :no +STR_CONFIG_PATCHES_ORDER_REVIEW_EXDEPOT :yes, but exclude stopped vehicles +STR_CONFIG_PATCHES_ORDER_REVIEW_ON :of all vehicles STR_CONFIG_PATCHES_WARN_INCOME_LESS :{LTBLUE}Warn if a train's income is negative: {ORANGE}{STRING} STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES :{LTBLUE}Vehicles never expire: {ORANGE}{STRING} STR_CONFIG_PATCHES_AUTORENEW_VEHICLE :{LTBLUE}Autorenew vehicle when it gets old diff --git a/order_cmd.c b/order_cmd.c index fe45f9a57..25e114b54 100644 --- a/order_cmd.c +++ b/order_cmd.c @@ -357,77 +357,68 @@ int32 CmdRestoreOrderIndex(int x, int y, uint32 flags, uint32 p1, uint32 p2) int CheckOrders(Vehicle *v) { - int i, n_st, duplicate; - uint16 order, old_orderer; - uint16 dummy; - int message=0; - - /* check the order list */ - order = v->schedule_ptr[0]; - n_st = duplicate = dummy = 0; + if (!_patches.order_review_system) //User doesn't want things to be checked + return 0; + + if ( (_patches.order_review_system == 1) && (v->vehstatus & VS_STOPPED) ) + return 0; - /* only check every 20 days */ + /* only check every 20 days, so that we don't flood the message log */ if ( ( ( v->day_counter % 20) == 0 ) && (v->owner == _local_player) ) { - for(old_orderer = i = 0; order!=0; i++ ) { + + uint16 order, old_order; + int i, n_st, problem_type = -1; + Station *st; + int message=0; + TileIndex required_tile=-1; + + /* check the order list */ + order = v->schedule_ptr[0]; + n_st = 0; + + for (old_order = i = 0; order!=0; i++ ) { order = v->schedule_ptr[i]; - if (order == old_orderer) duplicate = -1; - if ( (order & OT_MASK) == OT_DUMMY ) dummy = -1; + if (order == old_order) { + problem_type = 2; + break; + } + if ( (order & OT_MASK) == OT_DUMMY ) { + problem_type = 1; + break; + } if ( ( (order & OT_MASK) == OT_GOTO_STATION ) /*&& (order != old_order) */) { //I uncommented this in order not to get two error messages //when two identical entries are in the list n_st++; + st = DEREF_STATION(order >> 8); + required_tile = GetStationTileForVehicle(v,st); } - old_orderer = order; //store the old order + old_order = order; //store the old order } //Now, check the last and the first order //as the last order is the end of order marker, jump back 2 - if ( (v->schedule_ptr[0] == v->schedule_ptr[i-2]) && ( i-2 != 0 ) ) duplicate = -1; + if ( (v->schedule_ptr[0] == v->schedule_ptr[i-2]) && ( i-2 != 0 ) ) { + problem_type = 2; + } + + if (n_st < 2) problem_type = 0; + + if (!required_tile) problem_type = 3; SET_DPARAM16(0, v->unitnumber); - - if (n_st < 2) { - switch (v->type) { - case VEH_Train: message = STR_TRAIN_HAS_TOO_FEW_ORDERS; break; - case VEH_Road: message = STR_ROADVEHICLE_HAS_TOO_FEW_ORDERS; break; - case VEH_Ship: message = STR_SHIP_HAS_TOO_FEW_ORDERS; break; - case VEH_Aircraft: message = STR_AIRCRAFT_HAS_TOO_FEW_ORDERS; break; - } - AddNewsItem( - message, - NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), - v->index, - 0); - } else if (duplicate) { - switch (v->type) { - case VEH_Train: message = STR_TRAIN_HAS_DUPLICATE_ENTRY; break; - case VEH_Road: message = STR_ROADVEHICLE_HAS_DUPLICATE_ENTRY; break; - case VEH_Ship: message = STR_SHIP_HAS_DUPLICATE_ENTRY; break; - case VEH_Aircraft: message = STR_AIRCRAFT_HAS_DUPLICATE_ENTRY; break; - } - AddNewsItem( - message, - NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), - v->index, - 0); - } else if (dummy) { - switch (v->type) { - case VEH_Train: message = STR_TRAIN_HAS_VOID_ORDER; break; - case VEH_Road: message = STR_ROADVEHICLE_HAS_VOID_ORDER; break; - case VEH_Ship: message = STR_SHIP_HAS_VOID_ORDER; break; - case VEH_Aircraft: message = STR_AIRCRAFT_HAS_VOID_ORDER; break; - } - AddNewsItem( - message, - NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), - v->index, - 0); - } + + message = (STR_TRAIN_HAS_TOO_FEW_ORDERS) + (((v->type) - VEH_Train) << 2) + problem_type; + + if (problem_type < 0) return 0; + + AddNewsItem( + message, + NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), + v->index, + 0); } // End of order check - if ( (n_st > 2) || (duplicate) || (dummy) ) - return 1; - else - return 0; + return 1; } diff --git a/settings.c b/settings.c index cbd0ffe44..d09431384 100644 --- a/settings.c +++ b/settings.c @@ -795,6 +795,7 @@ static const SettingDesc patch_settings[] = { {"join_stations", SDT_BOOL, (void*)true, (void*)offsetof(Patches, join_stations) }, {"station_spread", SDT_UINT8, (void*)12, (void*)offsetof(Patches, station_spread) }, {"full_load_any", SDT_BOOL, (void*)true, (void*)offsetof(Patches, full_load_any)}, + {"order_review_system", SDT_UINT8, (void*)2, (void*)offsetof(Patches, order_review_system)}, {"inflation", SDT_BOOL, (void*)true, (void*)offsetof(Patches, inflation)}, {"selectgoods", SDT_BOOL, (void*)true, (void*)offsetof(Patches, selectgoods)}, diff --git a/settings_gui.c b/settings_gui.c index 128b11656..a68c7af81 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -712,6 +712,7 @@ static const PatchEntry _patches_vehicles[] = { {PE_BOOL, 0, STR_CONFIG_PATCHES_NEW_TRAIN_PATHFIND, &_patches.new_pathfinding}, {PE_BOOL, 0, STR_CONFIG_PATCHES_WARN_INCOME_LESS, &_patches.train_income_warn}, + {PE_UINT8, PF_MULTISTRING, STR_CONFIG_PATCHES_ORDER_REVIEW, &_patches.order_review_system,0,2,1}, {PE_BOOL, 0, STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES, &_patches.never_expire_vehicles}, {PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_LOST_TRAIN_DAYS, &_patches.lost_train_days, 180, 720, 60}, @@ -73,6 +73,8 @@ enum { void ModifyStationRatingAround(TileIndex tile, byte owner, int amount, uint radius); +TileIndex GetStationTileForVehicle(Vehicle *v, Station *st); + void ShowStationViewWindow(int station); void UpdateAllStationVirtCoord(); diff --git a/station_cmd.c b/station_cmd.c index d10e9ef3b..3422e5a9a 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -61,6 +61,20 @@ static Station *GetStationAround(uint tile, int w, int h, int closest_station) return (closest_station == -1) ? NULL : DEREF_STATION(closest_station); } +TileIndex GetStationTileForVehicle(Vehicle *v, Station *st) +{ + TileIndex required_tile=0; + + switch (v->type) { + case VEH_Train: return st->train_tile; + case VEH_Aircraft: return st->airport_tile; + case VEH_Ship: return st->dock_tile; + case VEH_Road: return (v->cargo_type == CT_PASSENGERS) ? st->bus_tile : st->lorry_tile; + default: + assert(false); + return 0; + } +} static bool CheckStationSpreadOut(Station *st, uint tile, int w, int h) { diff --git a/variables.h b/variables.h index 3e9fb57db..11e1a8730 100644 --- a/variables.h +++ b/variables.h @@ -94,6 +94,7 @@ typedef struct Patches { bool multiple_industry_per_town; // allow many industries of the same type per town bool same_industry_close; // allow same type industries to be built close to each other uint16 lost_train_days; // if a train doesn't switch order in this amount of days, a train is lost warning is shown + uint8 order_review_system; bool train_income_warn; // if train is generating little income, show a warning bool status_long_date; // always show long date in status bar bool signal_side; // show signals on right side |