mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r56) Improved order checker + patch setting for it (celestar)
This commit is contained in:
parent
f5e2d75931
commit
43d691df17
|
@ -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_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_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_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_VOID_ORDER :{WHITE}Train {COMMA16} has a void order
|
||||||
STR_TRAIN_HAS_DUPLICATE_ENTRY :{WHITE}Train {COMMA16} has duplicate orders
|
STR_TRAIN_HAS_DUPLICATE_ENTRY :{WHITE}Train {COMMA16} has duplicate orders
|
||||||
STR_AIRCRAFT_AUTORENEW_FAILED :{WHITE}Autorenew failed on aircraft {COMMA16} (money limit)
|
STR_TRAIN_HAS_INVALID_ENTRY :{WHITE}Train {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_ROADVEHICLE_AUTORENEW_FAILED :{WHITE}Autorenew failed on road vehicle {COMMA16} (money limit)
|
|
||||||
STR_ROADVEHICLE_HAS_TOO_FEW_ORDERS :{WHITE}Road Vehicle {COMMA16} has too few orders in the schedule
|
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_VOID_ORDER :{WHITE}Road Vehicle {COMMA16} has void order
|
||||||
STR_ROADVEHICLE_HAS_DUPLICATE_ENTRY :{WHITE}Road Vehicle {COMMA16} has duplicate orders
|
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_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_VOID_ORDER :{WHITE}Ship {COMMA16} has void order
|
||||||
STR_SHIP_HAS_DUPLICATE_ENTRY :{WHITE}Ship {COMMA16} has duplicate orders
|
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 :{BLACK}Configure Patches
|
||||||
STR_CONFIG_PATCHES_TIP :{BLACK}Configure the 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 :{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_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_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_NEVER_EXPIRE_VEHICLES :{LTBLUE}Vehicles never expire: {ORANGE}{STRING}
|
||||||
STR_CONFIG_PATCHES_AUTORENEW_VEHICLE :{LTBLUE}Autorenew vehicle when it gets old
|
STR_CONFIG_PATCHES_AUTORENEW_VEHICLE :{LTBLUE}Autorenew vehicle when it gets old
|
||||||
|
|
103
order_cmd.c
103
order_cmd.c
|
@ -357,77 +357,68 @@ int32 CmdRestoreOrderIndex(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
int CheckOrders(Vehicle *v)
|
int CheckOrders(Vehicle *v)
|
||||||
{
|
{
|
||||||
int i, n_st, duplicate;
|
if (!_patches.order_review_system) //User doesn't want things to be checked
|
||||||
uint16 order, old_orderer;
|
return 0;
|
||||||
uint16 dummy;
|
|
||||||
int message=0;
|
if ( (_patches.order_review_system == 1) && (v->vehstatus & VS_STOPPED) )
|
||||||
|
return 0;
|
||||||
/* check the order list */
|
|
||||||
order = v->schedule_ptr[0];
|
|
||||||
n_st = duplicate = dummy = 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) ) {
|
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];
|
order = v->schedule_ptr[i];
|
||||||
if (order == old_orderer) duplicate = -1;
|
if (order == old_order) {
|
||||||
if ( (order & OT_MASK) == OT_DUMMY ) dummy = -1;
|
problem_type = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( (order & OT_MASK) == OT_DUMMY ) {
|
||||||
|
problem_type = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if ( ( (order & OT_MASK) == OT_GOTO_STATION ) /*&& (order != old_order) */) {
|
if ( ( (order & OT_MASK) == OT_GOTO_STATION ) /*&& (order != old_order) */) {
|
||||||
//I uncommented this in order not to get two error messages
|
//I uncommented this in order not to get two error messages
|
||||||
//when two identical entries are in the list
|
//when two identical entries are in the list
|
||||||
n_st++;
|
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
|
//Now, check the last and the first order
|
||||||
//as the last order is the end of order marker, jump back 2
|
//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);
|
SET_DPARAM16(0, v->unitnumber);
|
||||||
|
|
||||||
if (n_st < 2) {
|
message = (STR_TRAIN_HAS_TOO_FEW_ORDERS) + (((v->type) - VEH_Train) << 2) + problem_type;
|
||||||
switch (v->type) {
|
|
||||||
case VEH_Train: message = STR_TRAIN_HAS_TOO_FEW_ORDERS; break;
|
if (problem_type < 0) return 0;
|
||||||
case VEH_Road: message = STR_ROADVEHICLE_HAS_TOO_FEW_ORDERS; break;
|
|
||||||
case VEH_Ship: message = STR_SHIP_HAS_TOO_FEW_ORDERS; break;
|
AddNewsItem(
|
||||||
case VEH_Aircraft: message = STR_AIRCRAFT_HAS_TOO_FEW_ORDERS; break;
|
message,
|
||||||
}
|
NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
|
||||||
AddNewsItem(
|
v->index,
|
||||||
message,
|
0);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// End of order check
|
// End of order check
|
||||||
|
|
||||||
if ( (n_st > 2) || (duplicate) || (dummy) )
|
return 1;
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -795,6 +795,7 @@ static const SettingDesc patch_settings[] = {
|
||||||
{"join_stations", SDT_BOOL, (void*)true, (void*)offsetof(Patches, join_stations) },
|
{"join_stations", SDT_BOOL, (void*)true, (void*)offsetof(Patches, join_stations) },
|
||||||
{"station_spread", SDT_UINT8, (void*)12, (void*)offsetof(Patches, station_spread) },
|
{"station_spread", SDT_UINT8, (void*)12, (void*)offsetof(Patches, station_spread) },
|
||||||
{"full_load_any", SDT_BOOL, (void*)true, (void*)offsetof(Patches, full_load_any)},
|
{"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)},
|
{"inflation", SDT_BOOL, (void*)true, (void*)offsetof(Patches, inflation)},
|
||||||
{"selectgoods", SDT_BOOL, (void*)true, (void*)offsetof(Patches, selectgoods)},
|
{"selectgoods", SDT_BOOL, (void*)true, (void*)offsetof(Patches, selectgoods)},
|
||||||
|
|
|
@ -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_NEW_TRAIN_PATHFIND, &_patches.new_pathfinding},
|
||||||
|
|
||||||
{PE_BOOL, 0, STR_CONFIG_PATCHES_WARN_INCOME_LESS, &_patches.train_income_warn},
|
{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_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},
|
{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);
|
void ModifyStationRatingAround(TileIndex tile, byte owner, int amount, uint radius);
|
||||||
|
|
||||||
|
TileIndex GetStationTileForVehicle(Vehicle *v, Station *st);
|
||||||
|
|
||||||
void ShowStationViewWindow(int station);
|
void ShowStationViewWindow(int station);
|
||||||
void UpdateAllStationVirtCoord();
|
void UpdateAllStationVirtCoord();
|
||||||
|
|
||||||
|
|
|
@ -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);
|
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)
|
static bool CheckStationSpreadOut(Station *st, uint tile, int w, int h)
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,6 +94,7 @@ typedef struct Patches {
|
||||||
bool multiple_industry_per_town; // allow many industries of the same type per town
|
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
|
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
|
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 train_income_warn; // if train is generating little income, show a warning
|
||||||
bool status_long_date; // always show long date in status bar
|
bool status_long_date; // always show long date in status bar
|
||||||
bool signal_side; // show signals on right side
|
bool signal_side; // show signals on right side
|
||||||
|
|
Loading…
Reference in New Issue