1
0
Fork 0

(svn r3030) More work for GB/SB, this time concerning the waiting_acceptance attribute of stations

release/0.4.5
tron 2005-10-11 13:54:21 +00:00
parent 6fb7381efa
commit 9fea263c77
4 changed files with 16 additions and 16 deletions

View File

@ -1244,7 +1244,7 @@ static void MaybeCrashAirplane(Vehicle *v)
// Crash the airplane. Remove all goods stored at the station. // Crash the airplane. Remove all goods stored at the station.
for(i=0; i!=NUM_CARGO; i++) { for(i=0; i!=NUM_CARGO; i++) {
st->goods[i].rating = 1; st->goods[i].rating = 1;
st->goods[i].waiting_acceptance &= ~0xFFF; SB(st->goods[i].waiting_acceptance, 0, 12, 0);
} }
CrashAirplane(v); CrashAirplane(v);

View File

@ -1364,7 +1364,8 @@ int LoadUnloadVehicle(Vehicle *v)
unloading_time += v->cargo_count; unloading_time += v->cargo_count;
if ((t=ge->waiting_acceptance & 0xFFF) == 0) { t = GB(ge->waiting_acceptance, 0, 12);
if (t == 0) {
// No goods waiting at station // No goods waiting at station
ge->enroute_time = v->cargo_days; ge->enroute_time = v->cargo_days;
ge->enroute_from = v->cargo_source; ge->enroute_from = v->cargo_source;
@ -1376,7 +1377,7 @@ int LoadUnloadVehicle(Vehicle *v)
ge->enroute_from = v->cargo_source; ge->enroute_from = v->cargo_source;
} }
// Update amount of waiting cargo // Update amount of waiting cargo
ge->waiting_acceptance = (ge->waiting_acceptance &~0xFFF) | min(v->cargo_count + t, 0xFFF); SB(ge->waiting_acceptance, 0, 12, min(v->cargo_count + t, 0xFFF));
ge->feeder_profit += v_profit; ge->feeder_profit += v_profit;
u->profit_this_year += v_profit; u->profit_this_year += v_profit;
result |= 2; result |= 2;
@ -1402,7 +1403,8 @@ int LoadUnloadVehicle(Vehicle *v)
// If there's goods waiting at the station, and the vehicle // If there's goods waiting at the station, and the vehicle
// has capacity for it, load it on the vehicle. // has capacity for it, load it on the vehicle.
if ((count=ge->waiting_acceptance & 0xFFF) != 0 && count = GB(ge->waiting_acceptance, 0, 12);
if (count != 0 &&
(cap = v->cargo_cap - v->cargo_count) != 0) { (cap = v->cargo_cap - v->cargo_count) != 0) {
int cargoshare; int cargoshare;
int feeder_profit_share; int feeder_profit_share;

View File

@ -711,7 +711,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
(i == CT_PASSENGERS && !(st->facilities & (byte)~FACIL_TRUCK_STOP))) (i == CT_PASSENGERS && !(st->facilities & (byte)~FACIL_TRUCK_STOP)))
amt = 0; amt = 0;
st->goods[i].waiting_acceptance = (st->goods[i].waiting_acceptance & ~0xF000) + (amt << 12); SB(st->goods[i].waiting_acceptance, 12, 4, amt);
} }
// Only show a message in case the acceptance was actually changed. // Only show a message in case the acceptance was actually changed.
@ -2590,7 +2590,7 @@ static void UpdateStationRating(Station *st)
} }
{ {
waiting = ge->waiting_acceptance & 0xFFF; waiting = GB(ge->waiting_acceptance, 0, 12);
(rating -= 90, waiting > 1500) || (rating -= 90, waiting > 1500) ||
(rating += 55, waiting > 1000) || (rating += 55, waiting > 1000) ||
(rating += 35, waiting > 600) || (rating += 35, waiting > 600) ||
@ -2622,8 +2622,7 @@ static void UpdateStationRating(Station *st)
} }
} }
if (waiting_changed) if (waiting_changed) SB(ge->waiting_acceptance, 0, 12, waiting);
ge->waiting_acceptance = (ge->waiting_acceptance & ~0xFFF) + waiting;
} }
} }
} while (++ge != endof(st->goods)); } while (++ge != endof(st->goods));
@ -2701,9 +2700,9 @@ void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint
static void UpdateStationWaiting(Station *st, int type, uint amount) static void UpdateStationWaiting(Station *st, int type, uint amount)
{ {
st->goods[type].waiting_acceptance = SB(st->goods[type].waiting_acceptance, 0, 12,
(st->goods[type].waiting_acceptance & ~0xFFF) + min(0xFFF, GB(st->goods[type].waiting_acceptance, 0, 12) + amount)
min(0xFFF, (st->goods[type].waiting_acceptance & 0xFFF) + amount); );
st->goods[type].enroute_time = 0; st->goods[type].enroute_time = 0;
st->goods[type].enroute_from = st->index; st->goods[type].enroute_from = st->index;

View File

@ -188,7 +188,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
// show cargo waiting and station ratings // show cargo waiting and station ratings
for(j=0; j!=NUM_CARGO; j++) { for(j=0; j!=NUM_CARGO; j++) {
int acc = (st->goods[j].waiting_acceptance & 0xFFF); int acc = GB(st->goods[j].waiting_acceptance, 0, 12);
if (acc != 0) { if (acc != 0) {
StationsWndShowStationRating(x, y, j, acc, st->goods[j].rating); StationsWndShowStationRating(x, y, j, acc, st->goods[j].rating);
x += 10; x += 10;
@ -324,7 +324,7 @@ static void DrawStationViewWindow(Window *w)
num = 1; num = 1;
for(i=0; i!=NUM_CARGO; i++) { for(i=0; i!=NUM_CARGO; i++) {
if ((st->goods[i].waiting_acceptance & 0xFFF) != 0) { if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) {
num++; num++;
if (st->goods[i].enroute_from != station_id) if (st->goods[i].enroute_from != station_id)
num++; num++;
@ -351,8 +351,7 @@ static void DrawStationViewWindow(Window *w)
if (--pos < 0) { if (--pos < 0) {
str = STR_00D0_NOTHING; str = STR_00D0_NOTHING;
for(i=0; i!=NUM_CARGO; i++) for(i=0; i!=NUM_CARGO; i++)
if (st->goods[i].waiting_acceptance & 0xFFF) if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) str = STR_EMPTY;
str = STR_EMPTY;
SetDParam(0, str); SetDParam(0, str);
DrawString(x, y, STR_0008_WAITING, 0); DrawString(x, y, STR_0008_WAITING, 0);
y += 10; y += 10;
@ -360,7 +359,7 @@ static void DrawStationViewWindow(Window *w)
i = 0; i = 0;
do { do {
uint waiting = (st->goods[i].waiting_acceptance & 0xFFF); uint waiting = GB(st->goods[i].waiting_acceptance, 0, 12);
if (waiting == 0) if (waiting == 0)
continue; continue;