branch | cpp_gui |
changeset 6298 | c30fe89622df |
parent 6285 | 187e3ef04cc9 |
child 6303 | 84c215fc8eb8 |
6297:4bf29d14edba | 6298:c30fe89622df |
---|---|
328 SetDParam(1, st->facilities); |
328 SetDParam(1, st->facilities); |
329 UpdateViewportSignPos(&st->sign, pt.x, pt.y, STR_305C_0); |
329 UpdateViewportSignPos(&st->sign, pt.x, pt.y, STR_305C_0); |
330 } |
330 } |
331 |
331 |
332 // Update the virtual coords needed to draw the station sign for all stations. |
332 // Update the virtual coords needed to draw the station sign for all stations. |
333 void UpdateAllStationVirtCoord(void) |
333 void UpdateAllStationVirtCoord() |
334 { |
334 { |
335 Station* st; |
335 Station* st; |
336 |
336 |
337 FOR_ALL_STATIONS(st) { |
337 FOR_ALL_STATIONS(st) { |
338 UpdateStationVirtCoord(st); |
338 UpdateStationVirtCoord(st); |
447 } |
447 } |
448 } |
448 } |
449 } |
449 } |
450 } |
450 } |
451 |
451 |
452 typedef struct ottd_Rectangle { |
452 struct ottd_Rectangle { |
453 uint min_x; |
453 uint min_x; |
454 uint min_y; |
454 uint min_y; |
455 uint max_x; |
455 uint max_x; |
456 uint max_y; |
456 uint max_y; |
457 } ottd_Rectangle; |
457 }; |
458 |
458 |
459 static inline void MergePoint(ottd_Rectangle* rect, TileIndex tile) |
459 static inline void MergePoint(ottd_Rectangle* rect, TileIndex tile) |
460 { |
460 { |
461 uint x = TileX(tile); |
461 uint x = TileX(tile); |
462 uint y = TileY(tile); |
462 uint y = TileY(tile); |
1399 }; |
1399 }; |
1400 |
1400 |
1401 // Intercontinental Airport (vlarge) - 4 runways |
1401 // Intercontinental Airport (vlarge) - 4 runways |
1402 static const byte _airport_sections_intercontinental[] = { |
1402 static const byte _airport_sections_intercontinental[] = { |
1403 102, 120, 89, 89, 89, 89, 89, 89, 118, |
1403 102, 120, 89, 89, 89, 89, 89, 89, 118, |
1404 120, 22, 22, 22, 22, 22, 22, 119, 117, |
1404 120, 23, 23, 23, 23, 23, 23, 119, 117, |
1405 87, 54, 87, 8, 8, 8, 8, 51, 117, |
1405 87, 54, 87, 8, 8, 8, 8, 51, 117, |
1406 87, 162, 87, 85, 116, 116, 8, 9, 10, |
1406 87, 162, 87, 85, 116, 116, 8, 9, 10, |
1407 87, 8, 8, 11, 31, 11, 8, 160, 32, |
1407 87, 8, 8, 11, 31, 11, 8, 160, 32, |
1408 32, 160, 8, 11, 27, 11, 8, 8, 10, |
1408 32, 160, 8, 11, 27, 11, 8, 8, 10, |
1409 87, 8, 8, 11, 30, 11, 8, 8, 10, |
1409 87, 8, 8, 11, 30, 11, 8, 8, 10, |
1410 87, 142, 8, 11, 29, 11, 10, 163, 10, |
1410 87, 142, 8, 11, 29, 11, 10, 163, 10, |
1411 87, 164, 87, 8, 8, 8, 10, 37, 117, |
1411 87, 164, 87, 8, 8, 8, 10, 37, 117, |
1412 87, 120, 89, 89, 89, 89, 89, 89, 119, |
1412 87, 120, 89, 89, 89, 89, 89, 89, 119, |
1413 121, 22, 22, 22, 22, 22, 22, 119, 37 |
1413 121, 23, 23, 23, 23, 23, 23, 119, 37 |
1414 }; |
1414 }; |
1415 |
1415 |
1416 |
1416 |
1417 // Commuter Airfield (small) |
1417 // Commuter Airfield (small) |
1418 static const byte _airport_sections_commuter[] = { |
1418 static const byte _airport_sections_commuter[] = { |
1668 /* Checks if any ship is servicing the buoy specified. Returns yes or no */ |
1668 /* Checks if any ship is servicing the buoy specified. Returns yes or no */ |
1669 static bool CheckShipsOnBuoy(Station *st) |
1669 static bool CheckShipsOnBuoy(Station *st) |
1670 { |
1670 { |
1671 const Vehicle *v; |
1671 const Vehicle *v; |
1672 FOR_ALL_VEHICLES(v) { |
1672 FOR_ALL_VEHICLES(v) { |
1673 if (v->type == VEH_Ship) { |
1673 if (v->type == VEH_SHIP) { |
1674 const Order *order; |
1674 const Order *order; |
1675 FOR_VEHICLE_ORDERS(v, order) { |
1675 FOR_VEHICLE_ORDERS(v, order) { |
1676 if (order->type == OT_GOTO_STATION && order->dest == st->index) { |
1676 if (order->type == OT_GOTO_STATION && order->dest == st->index) { |
1677 return true; |
1677 return true; |
1678 } |
1678 } |
2069 } |
2069 } |
2070 |
2070 |
2071 |
2071 |
2072 static void AnimateTile_Station(TileIndex tile) |
2072 static void AnimateTile_Station(TileIndex tile) |
2073 { |
2073 { |
2074 typedef struct AnimData { |
2074 struct AnimData { |
2075 StationGfx from; // first sprite |
2075 StationGfx from; // first sprite |
2076 StationGfx to; // last sprite |
2076 StationGfx to; // last sprite |
2077 byte delay; |
2077 byte delay; |
2078 } AnimData; |
2078 }; |
2079 |
2079 |
2080 static const AnimData data[] = { |
2080 static const AnimData data[] = { |
2081 { GFX_RADAR_LARGE_FIRST, GFX_RADAR_LARGE_LAST, 3 }, |
2081 { GFX_RADAR_LARGE_FIRST, GFX_RADAR_LARGE_LAST, 3 }, |
2082 { GFX_WINDSACK_FIRST, GFX_WINDSACK_LAST, 1 }, |
2082 { GFX_WINDSACK_FIRST, GFX_WINDSACK_LAST, 1 }, |
2083 { GFX_RADAR_INTERNATIONAL_FIRST, GFX_RADAR_INTERNATIONAL_LAST, 3 }, |
2083 { GFX_RADAR_INTERNATIONAL_FIRST, GFX_RADAR_INTERNATIONAL_LAST, 3 }, |
2101 |
2101 |
2102 |
2102 |
2103 static void ClickTile_Station(TileIndex tile) |
2103 static void ClickTile_Station(TileIndex tile) |
2104 { |
2104 { |
2105 if (IsHangar(tile)) { |
2105 if (IsHangar(tile)) { |
2106 ShowDepotWindow(tile, VEH_Aircraft); |
2106 ShowDepotWindow(tile, VEH_AIRCRAFT); |
2107 } else { |
2107 } else { |
2108 ShowStationViewWindow(GetStationIndex(tile)); |
2108 ShowStationViewWindow(GetStationIndex(tile)); |
2109 } |
2109 } |
2110 } |
2110 } |
2111 |
2111 |
2113 215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0 |
2113 215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0 |
2114 }; |
2114 }; |
2115 |
2115 |
2116 static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y) |
2116 static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y) |
2117 { |
2117 { |
2118 if (v->type == VEH_Train) { |
2118 if (v->type == VEH_TRAIN) { |
2119 if (IsRailwayStation(tile) && IsFrontEngine(v) && |
2119 if (IsRailwayStation(tile) && IsFrontEngine(v) && |
2120 !IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) { |
2120 !IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) { |
2121 StationID station_id = GetStationIndex(tile); |
2121 StationID station_id = GetStationIndex(tile); |
2122 |
2122 |
2123 if ((!(v->current_order.flags & OF_NON_STOP) && !_patches.new_nonstop) || |
2123 if ((!(v->current_order.flags & OF_NON_STOP) && !_patches.new_nonstop) || |
2143 } |
2143 } |
2144 } |
2144 } |
2145 } |
2145 } |
2146 } |
2146 } |
2147 } |
2147 } |
2148 } else if (v->type == VEH_Road) { |
2148 } else if (v->type == VEH_ROAD) { |
2149 if (v->u.road.state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)v->u.road.state) && v->u.road.frame == 0) { |
2149 if (v->u.road.state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)v->u.road.state) && v->u.road.frame == 0) { |
2150 if (IsRoadStop(tile)) { |
2150 if (IsRoadStop(tile)) { |
2151 /* Attempt to allocate a parking bay in a road stop */ |
2151 /* Attempt to allocate a parking bay in a road stop */ |
2152 RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile)); |
2152 RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile)); |
2153 |
2153 |
2208 byte_inc_sat(&st->time_since_load); |
2208 byte_inc_sat(&st->time_since_load); |
2209 byte_inc_sat(&st->time_since_unload); |
2209 byte_inc_sat(&st->time_since_unload); |
2210 |
2210 |
2211 GoodsEntry *ge = st->goods; |
2211 GoodsEntry *ge = st->goods; |
2212 do { |
2212 do { |
2213 /* Slowly increase the rating back to his original level in the case we |
|
2214 * didn't deliver cargo yet to this station. This happens when a bribe |
|
2215 * failed while you didn't moved that cargo yet to a station. */ |
|
2216 if (ge->enroute_from == INVALID_STATION && ge->rating < INITIAL_STATION_RATING) |
|
2217 ge->rating++; |
|
2218 /* Only change the rating if we are moving this cargo */ |
|
2213 if (ge->enroute_from != INVALID_STATION) { |
2219 if (ge->enroute_from != INVALID_STATION) { |
2214 byte_inc_sat(&ge->enroute_time); |
2220 byte_inc_sat(&ge->enroute_time); |
2215 byte_inc_sat(&ge->days_since_pickup); |
2221 byte_inc_sat(&ge->days_since_pickup); |
2216 |
2222 |
2217 int rating = 0; |
2223 int rating = 0; |
2232 |
2238 |
2233 if (IsValidPlayer(st->owner) && HASBIT(st->town->statues, st->owner)) rating += 26; |
2239 if (IsValidPlayer(st->owner) && HASBIT(st->town->statues, st->owner)) rating += 26; |
2234 |
2240 |
2235 { |
2241 { |
2236 byte days = ge->days_since_pickup; |
2242 byte days = ge->days_since_pickup; |
2237 if (st->last_vehicle_type == VEH_Ship) |
2243 if (st->last_vehicle_type == VEH_SHIP) |
2238 days >>= 2; |
2244 days >>= 2; |
2239 (days > 21) || |
2245 (days > 21) || |
2240 (rating += 25, days > 12) || |
2246 (rating += 25, days > 12) || |
2241 (rating += 25, days > 6) || |
2247 (rating += 25, days > 6) || |
2242 (rating += 45, days > 3) || |
2248 (rating += 45, days > 3) || |
2297 st->delete_ctr = b; |
2303 st->delete_ctr = b; |
2298 |
2304 |
2299 if (b == 0) UpdateStationRating(st); |
2305 if (b == 0) UpdateStationRating(st); |
2300 } |
2306 } |
2301 |
2307 |
2302 void OnTick_Station(void) |
2308 void OnTick_Station() |
2303 { |
2309 { |
2304 if (_game_mode == GM_EDITOR) return; |
2310 if (_game_mode == GM_EDITOR) return; |
2305 |
2311 |
2306 uint i = _station_tick_ctr; |
2312 uint i = _station_tick_ctr; |
2307 if (++_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0; |
2313 if (++_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0; |
2310 |
2316 |
2311 Station *st; |
2317 Station *st; |
2312 FOR_ALL_STATIONS(st) StationHandleSmallTick(st); |
2318 FOR_ALL_STATIONS(st) StationHandleSmallTick(st); |
2313 } |
2319 } |
2314 |
2320 |
2315 void StationMonthlyLoop(void) |
2321 void StationMonthlyLoop() |
2316 { |
2322 { |
2317 } |
2323 } |
2318 |
2324 |
2319 |
2325 |
2320 void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius) |
2326 void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius) |
2535 st->train_tile = 0; |
2541 st->train_tile = 0; |
2536 st->had_vehicle_of_type = 0; |
2542 st->had_vehicle_of_type = 0; |
2537 st->time_since_load = 255; |
2543 st->time_since_load = 255; |
2538 st->time_since_unload = 255; |
2544 st->time_since_unload = 255; |
2539 st->delete_ctr = 0; |
2545 st->delete_ctr = 0; |
2540 st->last_vehicle_type = VEH_Invalid; |
2546 st->last_vehicle_type = VEH_INVALID; |
2541 st->facilities = FACIL_AIRPORT | FACIL_DOCK; |
2547 st->facilities = FACIL_AIRPORT | FACIL_DOCK; |
2542 st->build_date = _date; |
2548 st->build_date = _date; |
2543 |
2549 |
2544 for (uint j = 0; j != NUM_CARGO; j++) { |
2550 for (uint j = 0; j != NUM_CARGO; j++) { |
2545 st->goods[j].waiting_acceptance = 0; |
2551 st->goods[j].waiting_acceptance = 0; |
2546 st->goods[j].days_since_pickup = 0; |
2552 st->goods[j].days_since_pickup = 0; |
2547 st->goods[j].enroute_from = INVALID_STATION; |
2553 st->goods[j].enroute_from = INVALID_STATION; |
2548 st->goods[j].enroute_from_xy = INVALID_TILE; |
2554 st->goods[j].enroute_from_xy = INVALID_TILE; |
2549 st->goods[j].rating = 175; |
2555 st->goods[j].rating = INITIAL_STATION_RATING; |
2550 st->goods[j].last_speed = 0; |
2556 st->goods[j].last_speed = 0; |
2551 st->goods[j].last_age = 255; |
2557 st->goods[j].last_age = 255; |
2552 } |
2558 } |
2553 |
2559 |
2554 UpdateStationVirtCoordDirty(st); |
2560 UpdateStationVirtCoordDirty(st); |
2641 } |
2647 } |
2642 |
2648 |
2643 return CMD_ERROR; |
2649 return CMD_ERROR; |
2644 } |
2650 } |
2645 |
2651 |
2646 void InitializeStations(void) |
2652 void InitializeStations() |
2647 { |
2653 { |
2648 /* Clean the station pool and create 1 block in it */ |
2654 /* Clean the station pool and create 1 block in it */ |
2649 CleanPool(&_Station_pool); |
2655 CleanPool(&_Station_pool); |
2650 AddBlockToPool(&_Station_pool); |
2656 AddBlockToPool(&_Station_pool); |
2651 |
2657 |
2656 _station_tick_ctr = 0; |
2662 _station_tick_ctr = 0; |
2657 |
2663 |
2658 } |
2664 } |
2659 |
2665 |
2660 |
2666 |
2661 void AfterLoadStations(void) |
2667 void AfterLoadStations() |
2662 { |
2668 { |
2663 /* Update the speclists of all stations to point to the currently loaded custom stations. */ |
2669 /* Update the speclists of all stations to point to the currently loaded custom stations. */ |
2664 Station *st; |
2670 Station *st; |
2665 FOR_ALL_STATIONS(st) { |
2671 FOR_ALL_STATIONS(st) { |
2666 for (uint i = 0; i < st->num_specs; i++) { |
2672 for (uint i = 0; i < st->num_specs; i++) { |
2812 SlObject(&st->speclist[i], _station_speclist_desc); |
2818 SlObject(&st->speclist[i], _station_speclist_desc); |
2813 } |
2819 } |
2814 } |
2820 } |
2815 } |
2821 } |
2816 |
2822 |
2817 static void Save_STNS(void) |
2823 static void Save_STNS() |
2818 { |
2824 { |
2819 Station *st; |
2825 Station *st; |
2820 // Write the stations |
2826 // Write the stations |
2821 FOR_ALL_STATIONS(st) { |
2827 FOR_ALL_STATIONS(st) { |
2822 SlSetArrayIndex(st->index); |
2828 SlSetArrayIndex(st->index); |
2823 SlAutolength((AutolengthProc*)SaveLoad_STNS, st); |
2829 SlAutolength((AutolengthProc*)SaveLoad_STNS, st); |
2824 } |
2830 } |
2825 } |
2831 } |
2826 |
2832 |
2827 static void Load_STNS(void) |
2833 static void Load_STNS() |
2828 { |
2834 { |
2829 int index; |
2835 int index; |
2830 while ((index = SlIterateArray()) != -1) { |
2836 while ((index = SlIterateArray()) != -1) { |
2831 Station *st = new (index) Station(); |
2837 Station *st = new (index) Station(); |
2832 |
2838 |
2845 |
2851 |
2846 /* This is to ensure all pointers are within the limits of _stations_size */ |
2852 /* This is to ensure all pointers are within the limits of _stations_size */ |
2847 if (_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0; |
2853 if (_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0; |
2848 } |
2854 } |
2849 |
2855 |
2850 static void Save_ROADSTOP(void) |
2856 static void Save_ROADSTOP() |
2851 { |
2857 { |
2852 RoadStop *rs; |
2858 RoadStop *rs; |
2853 |
2859 |
2854 FOR_ALL_ROADSTOPS(rs) { |
2860 FOR_ALL_ROADSTOPS(rs) { |
2855 SlSetArrayIndex(rs->index); |
2861 SlSetArrayIndex(rs->index); |
2856 SlObject(rs, _roadstop_desc); |
2862 SlObject(rs, _roadstop_desc); |
2857 } |
2863 } |
2858 } |
2864 } |
2859 |
2865 |
2860 static void Load_ROADSTOP(void) |
2866 static void Load_ROADSTOP() |
2861 { |
2867 { |
2862 int index; |
2868 int index; |
2863 |
2869 |
2864 while ((index = SlIterateArray()) != -1) { |
2870 while ((index = SlIterateArray()) != -1) { |
2865 RoadStop *rs = new (index) RoadStop(INVALID_TILE); |
2871 RoadStop *rs = new (index) RoadStop(INVALID_TILE); |