42 } |
42 } |
43 |
43 |
44 uint32 CalculateCompanyValue(Player *p) { |
44 uint32 CalculateCompanyValue(Player *p) { |
45 byte owner = p->index; |
45 byte owner = p->index; |
46 uint32 value; |
46 uint32 value; |
47 |
47 |
48 { |
48 { |
49 Station *st; |
49 Station *st; |
50 uint num = 0; |
50 uint num = 0; |
51 |
51 |
52 FOR_ALL_STATIONS(st) { |
52 FOR_ALL_STATIONS(st) { |
53 if (st->xy != 0 && st->owner == owner) { |
53 if (st->xy != 0 && st->owner == owner) { |
54 uint facil = st->facilities; |
54 uint facil = st->facilities; |
55 do num += (facil&1); while (facil >>= 1); |
55 do num += (facil&1); while (facil >>= 1); |
56 } |
56 } |
208 s = (_score_part[owner][i] >= score_info[i].needed) ? score_info[i].score : ((_score_part[owner][i] * score_info[i].score) / score_info[i].needed); |
208 s = (_score_part[owner][i] >= score_info[i].needed) ? score_info[i].score : ((_score_part[owner][i] * score_info[i].score) / score_info[i].needed); |
209 if (s < 0) s = 0; |
209 if (s < 0) s = 0; |
210 score += s; |
210 score += s; |
211 total_score += score_info[i].score; |
211 total_score += score_info[i].score; |
212 } |
212 } |
213 |
213 |
214 _score_part[owner][SCORE_TOTAL] = score; |
214 _score_part[owner][SCORE_TOTAL] = score; |
215 |
215 |
216 // We always want the score scaled to SCORE_MAX (1000) |
216 // We always want the score scaled to SCORE_MAX (1000) |
217 if (total_score != SCORE_MAX) |
217 if (total_score != SCORE_MAX) |
218 score = score * SCORE_MAX / total_score; |
218 score = score * SCORE_MAX / total_score; |
219 } |
219 } |
220 |
220 |
221 if (update) { |
221 if (update) { |
222 p->old_economy[0].performance_history = score; |
222 p->old_economy[0].performance_history = score; |
223 UpdatePlayerHouse(p, score); |
223 UpdatePlayerHouse(p, score); |
224 p->old_economy[0].company_value = CalculateCompanyValue(p); |
224 p->old_economy[0].company_value = CalculateCompanyValue(p); |
225 } |
225 } |
226 |
226 |
227 InvalidateWindow(WC_PERFORMANCE_DETAIL, 0); |
227 InvalidateWindow(WC_PERFORMANCE_DETAIL, 0); |
228 return score; |
228 return score; |
229 } |
229 } |
230 |
230 |
231 // use 255 as new_player to delete the player. |
231 // use 255 as new_player to delete the player. |
234 byte old = _current_player; |
234 byte old = _current_player; |
235 _current_player = old_player; |
235 _current_player = old_player; |
236 |
236 |
237 if (new_player == 255) { |
237 if (new_player == 255) { |
238 Subsidy *s; |
238 Subsidy *s; |
239 |
239 |
240 for(s=_subsidies; s != endof(_subsidies); s++) { |
240 for(s=_subsidies; s != endof(_subsidies); s++) { |
241 if (s->cargo_type != 0xff && s->age >= 12) { |
241 if (s->cargo_type != 0xff && s->age >= 12) { |
242 Station *st = DEREF_STATION(s->to); |
242 Station *st = DEREF_STATION(s->to); |
243 if (st->owner == old_player) |
243 if (st->owner == old_player) |
244 s->cargo_type = 0xff; |
244 s->cargo_type = 0xff; |
247 } |
247 } |
248 |
248 |
249 // take care of rating in towns |
249 // take care of rating in towns |
250 { |
250 { |
251 Town *t; |
251 Town *t; |
252 |
252 |
253 // if a player takes over, give the ratings to that player. |
253 // if a player takes over, give the ratings to that player. |
254 if (new_player != 255) { |
254 if (new_player != 255) { |
255 FOR_ALL_TOWNS(t) if (t->xy && HASBIT(t->have_ratings, old_player)) { |
255 FOR_ALL_TOWNS(t) if (t->xy && HASBIT(t->have_ratings, old_player)) { |
256 if (HASBIT(t->have_ratings, new_player)) { |
256 if (HASBIT(t->have_ratings, new_player)) { |
257 // use max of the two ratings. |
257 // use max of the two ratings. |
351 |
351 |
352 owner = p->index; |
352 owner = p->index; |
353 |
353 |
354 if (p->quarters_of_bankrupcy == 2) { |
354 if (p->quarters_of_bankrupcy == 2) { |
355 year_2: |
355 year_2: |
356 AddNewsItem( (StringID)(owner + 16), |
356 AddNewsItem( (StringID)(owner + 16), |
357 NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0); |
357 NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0); |
358 |
358 |
359 } else if (p->quarters_of_bankrupcy == 3) { |
359 } else if (p->quarters_of_bankrupcy == 3) { |
360 if (IS_HUMAN_PLAYER(owner)) |
360 if (IS_HUMAN_PLAYER(owner)) |
361 goto year_2; |
361 goto year_2; |
394 |
394 |
395 void DrawNewsBankrupcy(Window *w) |
395 void DrawNewsBankrupcy(Window *w) |
396 { |
396 { |
397 Player *p; |
397 Player *p; |
398 |
398 |
399 DrawNewsBorder(w); |
399 DrawNewsBorder(w); |
400 |
400 |
401 p = DEREF_PLAYER(WP(w,news_d).ni->string_id & 15); |
401 p = DEREF_PLAYER(WP(w,news_d).ni->string_id & 15); |
402 DrawPlayerFace(p->face, p->player_color, 2, 23); |
402 DrawPlayerFace(p->face, p->player_color, 2, 23); |
403 GfxFillRect(3, 23, 3+91, 23+118, 0x4323); |
403 GfxFillRect(3, 23, 3+91, 23+118, 0x4323); |
404 |
404 |
444 DrawStringMultiCenter( |
444 DrawStringMultiCenter( |
445 ((w->width - 101) >> 1) + 98, |
445 ((w->width - 101) >> 1) + 98, |
446 90, |
446 90, |
447 STR_705D_HAS_BEEN_CLOSED_DOWN_BY, |
447 STR_705D_HAS_BEEN_CLOSED_DOWN_BY, |
448 w->width - 101); |
448 w->width - 101); |
449 break; |
449 break; |
450 |
450 |
451 case 4: |
451 case 4: |
452 DrawStringCentered(w->width>>1, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, 0); |
452 DrawStringCentered(w->width>>1, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, 0); |
453 SET_DPARAM16(0, p->name_1); |
453 SET_DPARAM16(0, p->name_1); |
454 SET_DPARAM32(1, p->name_2); |
454 SET_DPARAM32(1, p->name_2); |
561 for(i=0; i!=NUM_PRICES; i++) { |
561 for(i=0; i!=NUM_PRICES; i++) { |
562 AddSingleInflation( (int32*)&_price + i, _price_frac + i, inf ); |
562 AddSingleInflation( (int32*)&_price + i, _price_frac + i, inf ); |
563 } |
563 } |
564 |
564 |
565 _economy.max_loan_unround += BIGMULUS(_economy.max_loan_unround, inf, 16); |
565 _economy.max_loan_unround += BIGMULUS(_economy.max_loan_unround, inf, 16); |
566 |
566 |
567 if (_economy.max_loan + 50000 <= _economy.max_loan_unround) |
567 if (_economy.max_loan + 50000 <= _economy.max_loan_unround) |
568 _economy.max_loan += 50000; |
568 _economy.max_loan += 50000; |
569 |
569 |
570 inf = _economy.infl_amount_pr * 54; |
570 inf = _economy.infl_amount_pr * 54; |
571 for(i=0; i!=NUM_CARGO; i++) { |
571 for(i=0; i!=NUM_CARGO; i++) { |
572 AddSingleInflation( |
572 AddSingleInflation( |
573 _cargo_payment_rates + i, |
573 _cargo_payment_rates + i, |
574 _cargo_payment_rates_frac + i, |
574 _cargo_payment_rates_frac + i, |
575 inf |
575 inf |
576 ); |
576 ); |
577 } |
577 } |
590 if (!p->is_active) |
590 if (!p->is_active) |
591 continue; |
591 continue; |
592 |
592 |
593 _current_player = p->index; |
593 _current_player = p->index; |
594 SET_EXPENSES_TYPE(EXPENSES_LOAN_INT); |
594 SET_EXPENSES_TYPE(EXPENSES_LOAN_INT); |
595 |
595 |
596 SubtractMoneyFromPlayer(BIGMULUS(p->current_loan, interest, 16)); |
596 SubtractMoneyFromPlayer(BIGMULUS(p->current_loan, interest, 16)); |
597 |
597 |
598 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
598 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
599 SubtractMoneyFromPlayer(_price.station_value >> 2); |
599 SubtractMoneyFromPlayer(_price.station_value >> 2); |
600 } |
600 } |
765 } |
765 } |
766 |
766 |
767 void DeleteSubsidyWithIndustry(byte index) |
767 void DeleteSubsidyWithIndustry(byte index) |
768 { |
768 { |
769 Subsidy *s; |
769 Subsidy *s; |
770 |
770 |
771 for(s=_subsidies; s != endof(_subsidies); s++) { |
771 for(s=_subsidies; s != endof(_subsidies); s++) { |
772 if (s->cargo_type != 0xFF && s->age < 12 && |
772 if (s->cargo_type != 0xFF && s->age < 12 && |
773 s->cargo_type != CT_PASSENGERS && s->cargo_type != CT_MAIL && |
773 s->cargo_type != CT_PASSENGERS && s->cargo_type != CT_MAIL && |
774 (index == s->from || (s->cargo_type!=CT_GOODS && s->cargo_type!=CT_FOOD && index==s->to))) { |
774 (index == s->from || (s->cargo_type!=CT_GOODS && s->cargo_type!=CT_FOOD && index==s->to))) { |
775 s->cargo_type = 0xFF; |
775 s->cargo_type = 0xFF; |
776 } |
776 } |
777 } |
777 } |
778 } |
778 } |
779 |
779 |
780 void DeleteSubsidyWithStation(byte index) |
780 void DeleteSubsidyWithStation(byte index) |
781 { |
781 { |
782 Subsidy *s; |
782 Subsidy *s; |
783 bool dirty = false; |
783 bool dirty = false; |
784 |
784 |
785 for(s=_subsidies; s != endof(_subsidies); s++) { |
785 for(s=_subsidies; s != endof(_subsidies); s++) { |
786 if (s->cargo_type != 0xFF && s->age >= 12 && |
786 if (s->cargo_type != 0xFF && s->age >= 12 && |
787 (s->from == index || s->to == index)) { |
787 (s->from == index || s->to == index)) { |
788 s->cargo_type = 0xFF; |
788 s->cargo_type = 0xFF; |
789 dirty = true; |
789 dirty = true; |
790 } |
790 } |
791 } |
791 } |
792 |
792 |
793 if (dirty) |
793 if (dirty) |
794 InvalidateWindow(WC_SUBSIDIES_LIST, 0); |
794 InvalidateWindow(WC_SUBSIDIES_LIST, 0); |
795 } |
795 } |
796 |
796 |
850 fr->cargo = cargo; |
850 fr->cargo = cargo; |
851 |
851 |
852 if (cargo == CT_GOODS || cargo == CT_FOOD) { |
852 if (cargo == CT_GOODS || cargo == CT_FOOD) { |
853 // The destination is a town |
853 // The destination is a town |
854 Town *t = DEREF_TOWN(RandomRange(_total_towns)); |
854 Town *t = DEREF_TOWN(RandomRange(_total_towns)); |
855 |
855 |
856 // Only want big towns |
856 // Only want big towns |
857 if (t->xy == 0 || t->population < 900) |
857 if (t->xy == 0 || t->population < 900) |
858 return; |
858 return; |
859 fr->distance = GetTileDist(i->xy, t->xy); |
859 fr->distance = GetTileDist(i->xy, t->xy); |
860 fr->to = t; |
860 fr->to = t; |
861 } else { |
861 } else { |
862 // The destination is an industry |
862 // The destination is an industry |
863 Industry *i2 = DEREF_INDUSTRY(RandomRange(_total_industries)); |
863 Industry *i2 = DEREF_INDUSTRY(RandomRange(_total_industries)); |
864 |
864 |
865 // The industry must accept the cargo |
865 // The industry must accept the cargo |
866 if (i == i2 || i2->xy == 0 || |
866 if (i == i2 || i2->xy == 0 || |
867 (cargo != i2->accepts_cargo[0] && |
867 (cargo != i2->accepts_cargo[0] && |
868 cargo != i2->accepts_cargo[1] && |
868 cargo != i2->accepts_cargo[1] && |
869 cargo != i2->accepts_cargo[2])) |
869 cargo != i2->accepts_cargo[2])) |
870 return; |
870 return; |
871 fr->distance = GetTileDist(i->xy, i2->xy); |
871 fr->distance = GetTileDist(i->xy, i2->xy); |
872 fr->to = i2; |
872 fr->to = i2; |
873 } |
873 } |
874 } |
874 } |
875 |
875 |
876 static bool CheckSubsidyDuplicate(Subsidy *s) |
876 static bool CheckSubsidyDuplicate(Subsidy *s) |
877 { |
877 { |
878 Subsidy *ss; |
878 Subsidy *ss; |
879 |
879 |
880 for(ss=_subsidies; ss != endof(_subsidies); ss++) { |
880 for(ss=_subsidies; ss != endof(_subsidies); ss++) { |
881 if (s != ss && |
881 if (s != ss && |
882 // ss->age < 12 && |
882 // ss->age < 12 && |
883 ss->from == s->from && |
883 ss->from == s->from && |
884 ss->to == s->to && |
884 ss->to == s->to && |
885 ss->cargo_type == s->cargo_type) { |
885 ss->cargo_type == s->cargo_type) { |
886 s->cargo_type = 0xFF; |
886 s->cargo_type = 0xFF; |
887 return true; |
887 return true; |
888 } |
888 } |
889 } |
889 } |
927 s = _subsidies; |
927 s = _subsidies; |
928 while (s->cargo_type != 0xFF) { |
928 while (s->cargo_type != 0xFF) { |
929 if (++s == endof(_subsidies)) |
929 if (++s == endof(_subsidies)) |
930 goto no_add; |
930 goto no_add; |
931 } |
931 } |
932 |
932 |
933 n = 1000; |
933 n = 1000; |
934 do { |
934 do { |
935 FindSubsidyPassengerRoute(&fr); |
935 FindSubsidyPassengerRoute(&fr); |
936 if (fr.distance <= 70) { |
936 if (fr.distance <= 70) { |
937 s->cargo_type = CT_PASSENGERS; |
937 s->cargo_type = CT_PASSENGERS; |
1000 |
1000 |
1001 f = 255; |
1001 f = 255; |
1002 if (transit_days > _cargoc.transit_days_1[cargo]) { |
1002 if (transit_days > _cargoc.transit_days_1[cargo]) { |
1003 transit_days -= _cargoc.transit_days_1[cargo]; |
1003 transit_days -= _cargoc.transit_days_1[cargo]; |
1004 f -= transit_days; |
1004 f -= transit_days; |
1005 |
1005 |
1006 if (transit_days > _cargoc.transit_days_2[cargo]) { |
1006 if (transit_days > _cargoc.transit_days_2[cargo]) { |
1007 transit_days -= _cargoc.transit_days_2[cargo]; |
1007 transit_days -= _cargoc.transit_days_2[cargo]; |
1008 |
1008 |
1009 if (f < transit_days) |
1009 if (f < transit_days) |
1010 f = 0; |
1010 f = 0; |
1017 return BIGMULSS(dist * f * num_pieces, _cargo_payment_rates[cargo], 21); |
1017 return BIGMULSS(dist * f * num_pieces, _cargo_payment_rates[cargo], 21); |
1018 } |
1018 } |
1019 |
1019 |
1020 static void DeliverGoodsToIndustry(TileIndex xy, byte cargo_type, int num_pieces) |
1020 static void DeliverGoodsToIndustry(TileIndex xy, byte cargo_type, int num_pieces) |
1021 { |
1021 { |
1022 Industry *ind, *best; |
1022 Industry *ind, *best; |
1023 int t, u; |
1023 int t, u; |
1024 |
1024 |
1025 /* Check if there's an industry close to the station that accepts |
1025 /* Check if there's an industry close to the station that accepts |
1026 * the cargo */ |
1026 * the cargo */ |
1027 best = NULL; |
1027 best = NULL; |
1029 for(ind = _industries; ind != endof(_industries); ind++) { |
1029 for(ind = _industries; ind != endof(_industries); ind++) { |
1030 if (ind->xy != 0 && (cargo_type == ind->accepts_cargo[0] || cargo_type |
1030 if (ind->xy != 0 && (cargo_type == ind->accepts_cargo[0] || cargo_type |
1031 == ind->accepts_cargo[1] || cargo_type == ind->accepts_cargo[2]) && |
1031 == ind->accepts_cargo[1] || cargo_type == ind->accepts_cargo[2]) && |
1032 ind->produced_cargo[0] != 0xFF && |
1032 ind->produced_cargo[0] != 0xFF && |
1033 ind->produced_cargo[0] != cargo_type && |
1033 ind->produced_cargo[0] != cargo_type && |
1034 (t=GetTileDist(ind->xy, xy)) < u) { |
1034 (t=GetTileDist(ind->xy, xy)) < u) { |
1035 u = t; |
1035 u = t; |
1036 best = ind; |
1036 best = ind; |
1037 } |
1037 } |
1038 } |
1038 } |
1039 |
1039 |
1061 } |
1061 } |
1062 |
1062 |
1063 /* check if there's a new subsidy that applies.. */ |
1063 /* check if there's a new subsidy that applies.. */ |
1064 for(s=_subsidies; s != endof(_subsidies); s++) { |
1064 for(s=_subsidies; s != endof(_subsidies); s++) { |
1065 if (s->cargo_type == cargo_type && s->age < 12) { |
1065 if (s->cargo_type == cargo_type && s->age < 12) { |
1066 |
1066 |
1067 /* Check distance from source */ |
1067 /* Check distance from source */ |
1068 if (cargo_type == CT_PASSENGERS || cargo_type == CT_MAIL) { |
1068 if (cargo_type == CT_PASSENGERS || cargo_type == CT_MAIL) { |
1069 xy = DEREF_TOWN(s->from)->xy; |
1069 xy = DEREF_TOWN(s->from)->xy; |
1070 } else { |
1070 } else { |
1071 xy = (DEREF_INDUSTRY(s->from))->xy; |
1071 xy = (DEREF_INDUSTRY(s->from))->xy; |
1072 } |
1072 } |
1073 if (GetTileDist1D(xy, from->xy) > 9) |
1073 if (GetTileDist1D(xy, from->xy) > 9) |
1074 continue; |
1074 continue; |
1075 |
1075 |
1076 /* Check distance from dest */ |
1076 /* Check distance from dest */ |
1077 if (cargo_type == CT_PASSENGERS || cargo_type == CT_MAIL || cargo_type == CT_GOODS || cargo_type == CT_FOOD) { |
1077 if (cargo_type == CT_PASSENGERS || cargo_type == CT_MAIL || cargo_type == CT_GOODS || cargo_type == CT_FOOD) { |
1078 xy = DEREF_TOWN(s->to)->xy; |
1078 xy = DEREF_TOWN(s->to)->xy; |
1079 } else { |
1079 } else { |
1080 xy = (DEREF_INDUSTRY(s->to))->xy; |
1080 xy = (DEREF_INDUSTRY(s->to))->xy; |
1094 |
1094 |
1095 p = DEREF_PLAYER(_current_player); |
1095 p = DEREF_PLAYER(_current_player); |
1096 SET_DPARAM16(0, p->name_1); |
1096 SET_DPARAM16(0, p->name_1); |
1097 SET_DPARAM32(1, p->name_2); |
1097 SET_DPARAM32(1, p->name_2); |
1098 AddNewsItem( |
1098 AddNewsItem( |
1099 STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier, |
1099 STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier, |
1100 NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0), |
1100 NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0), |
1101 pair.a, pair.b); |
1101 pair.a, pair.b); |
1102 |
1102 |
1103 InvalidateWindow(WC_SUBSIDIES_LIST, 0); |
1103 InvalidateWindow(WC_SUBSIDIES_LIST, 0); |
1104 return true; |
1104 return true; |
1136 if (cargo_type == CT_STEEL) t->new_act_water += num_pieces; |
1136 if (cargo_type == CT_STEEL) t->new_act_water += num_pieces; |
1137 } |
1137 } |
1138 |
1138 |
1139 // Give the goods to the industry. |
1139 // Give the goods to the industry. |
1140 DeliverGoodsToIndustry(s_to->xy, cargo_type, num_pieces); |
1140 DeliverGoodsToIndustry(s_to->xy, cargo_type, num_pieces); |
1141 |
1141 |
1142 // Determine profit |
1142 // Determine profit |
1143 { |
1143 { |
1144 int t = GetTileDist(s_from->xy, s_to->xy); |
1144 int t = GetTileDist(s_from->xy, s_to->xy); |
1145 int r = num_pieces; |
1145 int r = num_pieces; |
1146 profit = 0; |
1146 profit = 0; |
1195 st = DEREF_STATION(last_visited = v->last_station_visited); |
1195 st = DEREF_STATION(last_visited = v->last_station_visited); |
1196 |
1196 |
1197 for(;;) { |
1197 for(;;) { |
1198 if (v->cargo_cap == 0) |
1198 if (v->cargo_cap == 0) |
1199 goto next_vehicle; |
1199 goto next_vehicle; |
1200 |
1200 |
1201 ge = &st->goods[v->cargo_type]; |
1201 ge = &st->goods[v->cargo_type]; |
1202 |
1202 |
1203 /* unload? */ |
1203 /* unload? */ |
1204 if (v->cargo_count != 0) { |
1204 if (v->cargo_count != 0) { |
1205 if (v->cargo_source != (byte)last_visited && ge->waiting_acceptance & 0x8000) { |
1205 if (v->cargo_source != (byte)last_visited && ge->waiting_acceptance & 0x8000) { |
1209 result |= 1; |
1209 result |= 1; |
1210 v->cargo_count = 0; |
1210 v->cargo_count = 0; |
1211 } else if (u->next_order & OF_UNLOAD) { |
1211 } else if (u->next_order & OF_UNLOAD) { |
1212 /* unload goods and let it wait at the station */ |
1212 /* unload goods and let it wait at the station */ |
1213 st->time_since_unload = 0; |
1213 st->time_since_unload = 0; |
1214 |
1214 |
1215 if ((t=ge->waiting_acceptance & 0xFFF) == 0) { |
1215 if ((t=ge->waiting_acceptance & 0xFFF) == 0) { |
1216 // No goods waiting at station |
1216 // No goods waiting at station |
1217 ge->enroute_time = v->cargo_days; |
1217 ge->enroute_time = v->cargo_days; |
1218 ge->enroute_from = v->cargo_source; |
1218 ge->enroute_from = v->cargo_source; |
1219 } else { |
1219 } else { |
1227 ge->waiting_acceptance = (ge->waiting_acceptance &~0xFFF) | min(v->cargo_count + t, 0xFFF); |
1227 ge->waiting_acceptance = (ge->waiting_acceptance &~0xFFF) | min(v->cargo_count + t, 0xFFF); |
1228 result |= 2; |
1228 result |= 2; |
1229 v->cargo_count = 0; |
1229 v->cargo_count = 0; |
1230 } |
1230 } |
1231 } |
1231 } |
1232 |
1232 |
1233 /* don't pick up goods that we unloaded */ |
1233 /* don't pick up goods that we unloaded */ |
1234 if (u->next_order & OF_UNLOAD) |
1234 if (u->next_order & OF_UNLOAD) |
1235 goto next_vehicle; |
1235 goto next_vehicle; |
1236 |
1236 |
1237 /* update stats */ |
1237 /* update stats */ |
1238 ge->days_since_pickup = 0; |
1238 ge->days_since_pickup = 0; |
1239 t = u->max_speed; |
1239 t = u->max_speed; |
1240 if (u->type == VEH_Road) t >>=1; |
1240 if (u->type == VEH_Road) t >>=1; |
1241 |
1241 |
1242 // if last speed is 0, we treat that as if no vehicle has ever visited the station. |
1242 // if last speed is 0, we treat that as if no vehicle has ever visited the station. |
1243 ge->last_speed = t < 255 ? t : 255; |
1243 ge->last_speed = t < 255 ? t : 255; |
1244 ge->last_age = _cur_year - v->build_year; |
1244 ge->last_age = _cur_year - v->build_year; |
1245 |
1245 |
1246 // If there's goods waiting at the station, and the vehicle |
1246 // If there's goods waiting at the station, and the vehicle |
1250 if (cap > count) cap = count; |
1250 if (cap > count) cap = count; |
1251 v->cargo_count += cap; |
1251 v->cargo_count += cap; |
1252 ge->waiting_acceptance -= cap; |
1252 ge->waiting_acceptance -= cap; |
1253 unloading_time += cap; |
1253 unloading_time += cap; |
1254 st->time_since_load = 0; |
1254 st->time_since_load = 0; |
1255 |
1255 |
1256 // And record the source of the cargo, and the days in travel. |
1256 // And record the source of the cargo, and the days in travel. |
1257 v->cargo_source = ge->enroute_from; |
1257 v->cargo_source = ge->enroute_from; |
1258 v->cargo_days = ge->enroute_time; |
1258 v->cargo_days = ge->enroute_time; |
1259 result |= 2; |
1259 result |= 2; |
1260 st->last_vehicle = v->index; |
1260 st->last_vehicle = v->index; |