(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)

This commit is contained in:
darkvater
2004-09-04 13:06:09 +00:00
parent b4cf633f66
commit 85628544ee
13 changed files with 104 additions and 33 deletions

View File

@@ -39,6 +39,9 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
switch(e->event) {
case WE_PAINT:
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2);
if (!_patches.servint_roadveh) // disable service-scroller when interval is set to disabled
w->disabled_state |= (1 << 5) | (1 << 6);
SET_DPARAM16(0, v->string_id);
SET_DPARAM16(1, v->unitnumber);
DrawWindowWidgets(w);
@@ -86,7 +89,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
{
SET_DPARAM16(0, v->service_interval);
SET_DPARAM16(1, v->date_of_last_service);
DrawString(13, 90, STR_883C_SERVICING_INTERVAL_DAYS, 0);
DrawString(13, 90, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0);
}
DrawRoadVehImage(v, 3, 57, INVALID_VEHICLE);
@@ -118,14 +121,19 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
break;
case 5: /* increase int */
mod = 10;
mod = _ctrl_pressed? 5 : 10;
goto change_int;
case 6: /* decrease int */
mod = -10;
mod = _ctrl_pressed? -5 : -10;
change_int:
mod += v->service_interval;
if (!IS_INT_INSIDE(mod, 30, 800+1))
/* %-based service interval max 5%-90%
day-based service interval max 30-800 days */
mod = _patches.servint_ispercent ? clamp(mod, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(mod, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS+1);
if (mod == v->service_interval)
return;
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_ROADVEH_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
break;
}