equal
deleted
inserted
replaced
152 } |
152 } |
153 |
153 |
154 /** Convert existing rail to waypoint. Eg build a waypoint station over |
154 /** Convert existing rail to waypoint. Eg build a waypoint station over |
155 * piece of rail |
155 * piece of rail |
156 * @param x,y coordinates where waypoint will be built |
156 * @param x,y coordinates where waypoint will be built |
157 * @param p1 graphics for waypoint type, bit 8 signifies custom waypoint gfx (& 0x100) |
157 * @param p1 graphics for waypoint type, 0 indicates standard graphics |
158 * @param p2 unused |
158 * @param p2 unused |
159 * |
159 * |
160 * @todo When checking for the tile slope, |
160 * @todo When checking for the tile slope, |
161 * distingush between "Flat land required" and "land sloped in wrong direction" |
161 * distingush between "Flat land required" and "land sloped in wrong direction" |
162 */ |
162 */ |
168 uint dir; |
168 uint dir; |
169 |
169 |
170 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
170 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
171 |
171 |
172 /* if custom gfx are used, make sure it is within bounds */ |
172 /* if custom gfx are used, make sure it is within bounds */ |
173 if (p1 > 0x100 + (uint)GetCustomStationsCount(STAT_CLASS_WAYP)) return CMD_ERROR; |
173 if (p1 >= GetNumCustomStations(STAT_CLASS_WAYP)) return CMD_ERROR; |
174 |
174 |
175 if (!IsTileType(tile, MP_RAILWAY) || ((dir = 0, _m[tile].m5 != 1) && (dir = 1, _m[tile].m5 != 2))) |
175 if (!IsTileType(tile, MP_RAILWAY) || ((dir = 0, _m[tile].m5 != 1) && (dir = 1, _m[tile].m5 != 2))) |
176 return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK); |
176 return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK); |
177 |
177 |
178 if (!CheckTileOwnership(tile)) |
178 if (!CheckTileOwnership(tile)) |
198 } |
198 } |
199 |
199 |
200 if (flags & DC_EXEC) { |
200 if (flags & DC_EXEC) { |
201 bool reserved = PBSTileReserved(tile) != 0; |
201 bool reserved = PBSTileReserved(tile) != 0; |
202 ModifyTile(tile, MP_MAP5, RAIL_TYPE_WAYPOINT | dir); |
202 ModifyTile(tile, MP_MAP5, RAIL_TYPE_WAYPOINT | dir); |
203 if (--p1 & 0x100) { // waypoint type 0 uses default graphics |
203 if (p1 > 0) { // waypoint type 0 uses default graphics |
204 // custom graphics |
204 // custom graphics |
205 _m[tile].m3 |= 16; |
205 _m[tile].m3 |= 16; |
206 _m[tile].m4 = p1 & 0xff; |
206 _m[tile].m4 = (p1 - 1) & 0xff; |
207 } |
207 } |
208 if (reserved) { |
208 if (reserved) { |
209 PBSReserveTrack(tile, dir); |
209 PBSReserveTrack(tile, dir); |
210 } else { |
210 } else { |
211 PBSClearTrack(tile, dir); |
211 PBSClearTrack(tile, dir); |
385 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)); |
385 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)); |
386 |
386 |
387 x += 33; |
387 x += 33; |
388 y += 17; |
388 y += 17; |
389 |
389 |
390 /* draw default waypoint graphics of ID 0 */ |
390 stat = GetCustomStation(STAT_CLASS_WAYP, stat_id); |
391 if (stat_id == 0) { |
391 if (stat == NULL) { |
|
392 // stat is NULL for default waypoints and when waypoint graphics are |
|
393 // not loaded. |
392 DrawDefaultWaypointSprite(x, y, railtype); |
394 DrawDefaultWaypointSprite(x, y, railtype); |
393 return; |
395 return; |
394 } |
396 } |
395 |
397 |
396 stat = GetCustomStation(STAT_CLASS_WAYP, stat_id - 1); |
|
397 assert(stat); |
|
398 relocation = GetCustomStationRelocation(stat, NULL, 1); |
398 relocation = GetCustomStationRelocation(stat, NULL, 1); |
399 // emulate station tile - open with building |
399 // emulate station tile - open with building |
400 // add 1 to get the other direction |
400 // add 1 to get the other direction |
401 cust = &stat->renderdata[2]; |
401 cust = &stat->renderdata[2]; |
402 |
402 |