src/waypoint.cpp
changeset 6573 7624f942237f
parent 5990 b3c4c4b66249
child 6307 f40e88cff863
child 6928 44797333bcbf
child 9903 dc85aaa556ae
equal deleted inserted replaced
6572:e35266003390 6573:7624f942237f
    38 }
    38 }
    39 
    39 
    40 DEFINE_OLD_POOL(Waypoint, Waypoint, WaypointPoolNewBlock, NULL)
    40 DEFINE_OLD_POOL(Waypoint, Waypoint, WaypointPoolNewBlock, NULL)
    41 
    41 
    42 /* Create a new waypoint */
    42 /* Create a new waypoint */
    43 static Waypoint* AllocateWaypoint(void)
    43 static Waypoint* AllocateWaypoint()
    44 {
    44 {
    45 	Waypoint *wp;
    45 	Waypoint *wp;
    46 
    46 
    47 	/* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
    47 	/* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
    48 	 * TODO - This is just a temporary stage, this will be removed. */
    48 	 * TODO - This is just a temporary stage, this will be removed. */
    80 		wp->sign.left + (wp->sign.width_1 << 2) + 12,
    80 		wp->sign.left + (wp->sign.width_1 << 2) + 12,
    81 		wp->sign.top + 48);
    81 		wp->sign.top + 48);
    82 }
    82 }
    83 
    83 
    84 /* Update all signs */
    84 /* Update all signs */
    85 void UpdateAllWaypointSigns(void)
    85 void UpdateAllWaypointSigns()
    86 {
    86 {
    87 	Waypoint *wp;
    87 	Waypoint *wp;
    88 
    88 
    89 	FOR_ALL_WAYPOINTS(wp) {
    89 	FOR_ALL_WAYPOINTS(wp) {
    90 		UpdateWaypointSign(wp);
    90 		UpdateWaypointSign(wp);
   149 
   149 
   150 /**
   150 /**
   151  * Update waypoint graphics id against saved GRFID/localidx.
   151  * Update waypoint graphics id against saved GRFID/localidx.
   152  * This is to ensure the chosen graphics are correct if GRF files are changed.
   152  * This is to ensure the chosen graphics are correct if GRF files are changed.
   153  */
   153  */
   154 void AfterLoadWaypoints(void)
   154 void AfterLoadWaypoints()
   155 {
   155 {
   156 	Waypoint *wp;
   156 	Waypoint *wp;
   157 
   157 
   158 	FOR_ALL_WAYPOINTS(wp) {
   158 	FOR_ALL_WAYPOINTS(wp) {
   159 		uint i;
   159 		uint i;
   252 
   252 
   253 	return _price.build_train_depot;
   253 	return _price.build_train_depot;
   254 }
   254 }
   255 
   255 
   256 /* Daily loop for waypoints */
   256 /* Daily loop for waypoints */
   257 void WaypointsDailyLoop(void)
   257 void WaypointsDailyLoop()
   258 {
   258 {
   259 	Waypoint *wp;
   259 	Waypoint *wp;
   260 
   260 
   261 	/* Check if we need to delete a waypoint */
   261 	/* Check if we need to delete a waypoint */
   262 	FOR_ALL_WAYPOINTS(wp) {
   262 	FOR_ALL_WAYPOINTS(wp) {
   377 		DrawDefaultWaypointSprite(x, y, railtype);
   377 		DrawDefaultWaypointSprite(x, y, railtype);
   378 	}
   378 	}
   379 }
   379 }
   380 
   380 
   381 /* Fix savegames which stored waypoints in their old format */
   381 /* Fix savegames which stored waypoints in their old format */
   382 void FixOldWaypoints(void)
   382 void FixOldWaypoints()
   383 {
   383 {
   384 	Waypoint *wp;
   384 	Waypoint *wp;
   385 
   385 
   386 	/* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */
   386 	/* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */
   387 	FOR_ALL_WAYPOINTS(wp) {
   387 	FOR_ALL_WAYPOINTS(wp) {
   392 			wp->string = STR_NULL;
   392 			wp->string = STR_NULL;
   393 		}
   393 		}
   394 	}
   394 	}
   395 }
   395 }
   396 
   396 
   397 void InitializeWaypoints(void)
   397 void InitializeWaypoints()
   398 {
   398 {
   399 	CleanPool(&_Waypoint_pool);
   399 	CleanPool(&_Waypoint_pool);
   400 	AddBlockToPool(&_Waypoint_pool);
   400 	AddBlockToPool(&_Waypoint_pool);
   401 }
   401 }
   402 
   402 
   414 	SLE_CONDVAR(Waypoint, grfid,      SLE_UINT32,                 17, SL_MAX_VERSION),
   414 	SLE_CONDVAR(Waypoint, grfid,      SLE_UINT32,                 17, SL_MAX_VERSION),
   415 
   415 
   416 	SLE_END()
   416 	SLE_END()
   417 };
   417 };
   418 
   418 
   419 static void Save_WAYP(void)
   419 static void Save_WAYP()
   420 {
   420 {
   421 	Waypoint *wp;
   421 	Waypoint *wp;
   422 
   422 
   423 	FOR_ALL_WAYPOINTS(wp) {
   423 	FOR_ALL_WAYPOINTS(wp) {
   424 		SlSetArrayIndex(wp->index);
   424 		SlSetArrayIndex(wp->index);
   425 		SlObject(wp, _waypoint_desc);
   425 		SlObject(wp, _waypoint_desc);
   426 	}
   426 	}
   427 }
   427 }
   428 
   428 
   429 static void Load_WAYP(void)
   429 static void Load_WAYP()
   430 {
   430 {
   431 	int index;
   431 	int index;
   432 
   432 
   433 	while ((index = SlIterateArray()) != -1) {
   433 	while ((index = SlIterateArray()) != -1) {
   434 		Waypoint *wp;
   434 		Waypoint *wp;