--- a/src/waypoint.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/waypoint.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,11 +1,14 @@
/* $Id$ */
+/** @file waypoint.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "command.h"
#include "functions.h"
#include "gfx.h"
+#include "landscape.h"
#include "map.h"
#include "order.h"
#include "rail_map.h"
@@ -20,6 +23,7 @@
#include "vehicle.h"
#include "yapf/yapf.h"
#include "date.h"
+#include "newgrf.h"
enum {
MAX_WAYPOINTS_PER_TOWN = 64,
@@ -39,7 +43,9 @@
DEFINE_OLD_POOL(Waypoint, Waypoint, WaypointPoolNewBlock, NULL)
-/* Create a new waypoint */
+/**
+ * Create a new waypoint
+ * @return a pointer to the newly created Waypoint */
static Waypoint* AllocateWaypoint()
{
Waypoint *wp;
@@ -63,7 +69,9 @@
return NULL;
}
-/* Update the sign for the waypoint */
+/**
+ * Update the sign for the waypoint
+ * @param wp Waypoint to update sign */
static void UpdateWaypointSign(Waypoint* wp)
{
Point pt = RemapCoords2(TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE);
@@ -71,7 +79,9 @@
UpdateViewportSignPos(&wp->sign, pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
}
-/* Redraw the sign of a waypoint */
+/**
+ * Redraw the sign of a waypoint
+ * @param wp Waypoint to redraw sign */
static void RedrawWaypointSign(const Waypoint* wp)
{
MarkAllViewportsDirty(
@@ -81,7 +91,9 @@
wp->sign.top + 48);
}
-/* Update all signs */
+/**
+ * Update all signs
+ */
void UpdateAllWaypointSigns()
{
Waypoint *wp;
@@ -91,7 +103,10 @@
}
}
-/* Internal handler to delete a waypoint */
+/**
+ * Internal handler to delete a waypoint
+ * @param wp Waypoint to delete
+ */
void DestroyWaypoint(Waypoint *wp)
{
RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, wp->index);
@@ -101,7 +116,10 @@
RedrawWaypointSign(wp);
}
-/* Set the default name for a waypoint */
+/**
+ * Set the default name for a waypoint
+ * @param wp Waypoint to work on
+ */
static void MakeDefaultWaypointName(Waypoint* wp)
{
Waypoint *local_wp;
@@ -127,7 +145,10 @@
wp->town_cn = i;
}
-/* Find a deleted waypoint close to a tile. */
+/**
+ * Find a deleted waypoint close to a tile.
+ * @param tile to search from
+ */
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile)
{
Waypoint *wp, *best = NULL;
@@ -162,7 +183,7 @@
for (i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) {
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, i);
- if (statspec != NULL && statspec->grfid == wp->grfid && statspec->localidx == wp->localidx) {
+ if (statspec != NULL && statspec->grffile->grfid == wp->grfid && statspec->localidx == wp->localidx) {
wp->stat_id = i;
break;
}
@@ -173,6 +194,7 @@
/** Convert existing rail to waypoint. Eg build a waypoint station over
* piece of rail
* @param tile tile where waypoint will be built
+ * @param flags type of operation
* @param p1 graphics for waypoint type, 0 indicates standard graphics
* @param p2 unused
*
@@ -230,10 +252,10 @@
if (statspec != NULL) {
wp->stat_id = p1;
- wp->grfid = statspec->grfid;
+ wp->grfid = statspec->grffile->grfid;
wp->localidx = statspec->localidx;
} else {
- // Specified custom graphics do not exist, so use default.
+ /* Specified custom graphics do not exist, so use default. */
wp->stat_id = 0;
wp->grfid = 0;
wp->localidx = 0;
@@ -253,7 +275,9 @@
return _eco->GetPrice(CEconomy::BUILD_TRAIN_DEPOT);
}
-/* Daily loop for waypoints */
+/**
+ * Daily loop for waypoints
+ */
void WaypointsDailyLoop()
{
Waypoint *wp;
@@ -264,7 +288,13 @@
}
}
-/* Remove a waypoint */
+/**
+ * Remove a waypoint
+ * @param tile from which to remove waypoint
+ * @param flags type of operation
+ * @param justremove will indicate if it is removed from rail or if rails are removed too
+ * @return cost of operation or error
+ */
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
{
Waypoint *wp;
@@ -297,10 +327,13 @@
return _eco->GetPrice(CEconomy::REMOVE_TRAIN_DEPOT);
}
-/** Delete a waypoint
+/**
+ * Delete a waypoint
* @param tile tile where waypoint is to be deleted
+ * @param flags type of operation
* @param p1 unused
* @param p2 unused
+ * @return cost of operation or error
*/
int32 CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -308,10 +341,13 @@
return RemoveTrainWaypoint(tile, flags, true);
}
-/** Rename a waypoint.
+/**
+ * Rename a waypoint.
* @param tile unused
+ * @param flags type of operation
* @param p1 id of waypoint
* @param p2 unused
+ * @return cost of operation or error
*/
int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -349,7 +385,11 @@
return 0;
}
-/* This hacks together some dummy one-shot Station structure for a waypoint. */
+/**
+ * This hacks together some dummy one-shot Station structure for a waypoint.
+ * @param tile on which to work
+ * @return pointer to a Station
+ */
Station *ComposeWaypointStation(TileIndex tile)
{
Waypoint *wp = GetWaypointByTile(tile);
@@ -367,7 +407,13 @@
return &stat;
}
-/* Draw a waypoint */
+/**
+ * Draw a waypoint
+ * @param x coordinate
+ * @param y coordinate
+ * @param stat_id station id
+ * @param railtype RailType to use for
+ */
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
{
x += 33;
@@ -378,7 +424,9 @@
}
}
-/* Fix savegames which stored waypoints in their old format */
+/**
+ * Fix savegames which stored waypoints in their old format
+ */
void FixOldWaypoints()
{
Waypoint *wp;