waypoint.c
changeset 2546 50b42e72a6f1
parent 2520 8a52362c4ada
child 2603 284d7837725a
equal deleted inserted replaced
2545:aa71b3d576ce 2546:50b42e72a6f1
    12 #include "station.h"
    12 #include "station.h"
    13 #include "tile.h"
    13 #include "tile.h"
    14 #include "town.h"
    14 #include "town.h"
    15 #include "waypoint.h"
    15 #include "waypoint.h"
    16 #include "variables.h"
    16 #include "variables.h"
       
    17 #include "pbs.h"
    17 #include "table/sprites.h"
    18 #include "table/sprites.h"
    18 #include "table/strings.h"
    19 #include "table/strings.h"
    19 
    20 
    20 enum {
    21 enum {
    21 	/* Max waypoints: 64000 (8 * 8000) */
    22 	/* Max waypoints: 64000 (8 * 8000) */
   195 		wp->string = STR_NULL;
   196 		wp->string = STR_NULL;
   196 		wp->town_cn = 0;
   197 		wp->town_cn = 0;
   197 	}
   198 	}
   198 
   199 
   199 	if (flags & DC_EXEC) {
   200 	if (flags & DC_EXEC) {
       
   201 		bool reserved = PBSTileReserved(tile) != 0;
   200 		ModifyTile(tile, MP_MAP5, RAIL_TYPE_WAYPOINT | dir);
   202 		ModifyTile(tile, MP_MAP5, RAIL_TYPE_WAYPOINT | dir);
   201 		if (--p1 & 0x100) { // waypoint type 0 uses default graphics
   203 		if (--p1 & 0x100) { // waypoint type 0 uses default graphics
   202 			// custom graphics
   204 			// custom graphics
   203 			_m[tile].m3 |= 16;
   205 			_m[tile].m3 |= 16;
   204 			_m[tile].m4 = p1 & 0xff;
   206 			_m[tile].m4 = p1 & 0xff;
   205 		}
   207 		}
       
   208 		if (reserved) PBSReserveTrack(tile, dir);
   206 
   209 
   207 		wp->deleted = 0;
   210 		wp->deleted = 0;
   208 		wp->xy = tile;
   211 		wp->xy = tile;
   209 		wp->build_date = _date;
   212 		wp->build_date = _date;
   210 
   213 
   270 
   273 
   271 		wp->deleted = 30; // let it live for this many days before we do the actual deletion.
   274 		wp->deleted = 30; // let it live for this many days before we do the actual deletion.
   272 		RedrawWaypointSign(wp);
   275 		RedrawWaypointSign(wp);
   273 
   276 
   274 		if (justremove) {
   277 		if (justremove) {
       
   278 			bool reserved = PBSTileReserved(tile) != 0;
   275 			ModifyTile(tile, MP_MAP5, 1<<direction);
   279 			ModifyTile(tile, MP_MAP5, 1<<direction);
   276 			_m[tile].m3 &= ~16;
   280 			_m[tile].m3 &= ~16;
   277 			_m[tile].m4 = 0;
   281 			_m[tile].m4 = 0;
       
   282 			if (reserved) PBSReserveTrack(tile, direction);
   278 		} else {
   283 		} else {
   279 			DoClearSquare(tile);
   284 			DoClearSquare(tile);
   280 			SetSignalsOnBothDir(tile, direction);
   285 			SetSignalsOnBothDir(tile, direction);
   281 		}
   286 		}
   282 	}
   287 	}