Changeset - r6393:f9322fdf4c2c
[Not reviewed]
master
0 14 0
belugas - 18 years ago 2007-03-28 20:41:35
belugas@openttd.org
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
14 files changed with 91 insertions and 65 deletions:
0 comments (0 inline, 0 general)
src/rail.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file rail.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "bridge_map.h"
src/rail_cmd.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file rail_cmd.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "bridge_map.h"
src/rail_map.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file rail_map.h Hides the direct accesses to the map array with map accessors */
 

	
 
#ifndef RAIL_MAP_H
 
#define RAIL_MAP_H
 

	
src/railtypes.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef RAILTYPES_H
 
#define RAILTYPES_H
 

	
 
/** @file railtypes.h
 
 * All the railtype-specific information is stored here.
 
 */
 

	
 
#ifndef RAILTYPES_H
 
#define RAILTYPES_H
 

	
 
/** Global Railtype definition
 
 */
 
RailtypeInfo _railtypes[] = {
src/resource.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file resource.h */
 

	
 
//{{NO_DEPENDENCIES}}
 
// Microsoft Developer Studio generated include file.
 
// Used by ttd.rc
src/road.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file road.h */
 

	
 
#ifndef ROAD_H
 
#define ROAD_H
 

	
src/road_cmd.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file road_cmd.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "bridge_map.h"
 
@@ -46,16 +48,16 @@ bool CheckAllowRemoveRoad(TileIndex tile
 

	
 
	if (_game_mode == GM_EDITOR) return true;
 

	
 
	// Only do the special processing for actual players.
 
	/* Only do the special processing for actual players. */
 
	if (!IsValidPlayer(_current_player)) return true;
 

	
 
	// Only do the special processing if the road is owned
 
	// by a town
 
	/* Only do the special processing if the road is owned
 
	 * by a town */
 
	if (owner != OWNER_TOWN) return (owner == OWNER_NONE) || CheckOwnership(owner);
 

	
 
	if (_cheats.magic_bulldozer.value) return true;
 

	
 
	// Get a bitmask of which neighbouring roads has a tile
 
	/* Get a bitmask of which neighbouring roads has a tile */
 
	n = ROAD_NONE;
 
	present = GetAnyRoadBits(tile);
 
	if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile,-1, 0)) & ROAD_SW) n |= ROAD_NE;
 
@@ -63,12 +65,12 @@ bool CheckAllowRemoveRoad(TileIndex tile
 
	if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0)) & ROAD_NE) n |= ROAD_SW;
 
	if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0,-1)) & ROAD_SE) n |= ROAD_NW;
 

	
 
	// If 0 or 1 bits are set in n, or if no bits that match the bits to remove,
 
	// then allow it
 
	/* If 0 or 1 bits are set in n, or if no bits that match the bits to remove,
 
	 * then allow it */
 
	if ((n & (n - 1)) != 0 && (n & remove) != 0) {
 
		Town *t;
 
		*edge_road = false;
 
		// you can remove all kind of roads with extra dynamite
 
		/* you can remove all kind of roads with extra dynamite */
 
		if (_patches.extra_dynamite) return true;
 

	
 
		t = ClosestTownFromTile(tile, (uint)-1);
 
@@ -93,7 +95,7 @@ static bool CheckAllowRemoveRoad(TileInd
 
 */
 
int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	// cost for removing inner/edge -roads
 
	/* cost for removing inner/edge -roads */
 
	static const uint16 road_remove_cost[2] = {50, 18};
 

	
 
	Owner owner;
 
@@ -120,8 +122,8 @@ int32 CmdRemoveRoad(TileIndex tile, uint
 

	
 
	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
 

	
 
	// check if you're allowed to remove the street owned by a town
 
	// removal allowance depends on difficulty setting
 
	/* check if you're allowed to remove the street owned by a town
 
	 * removal allowance depends on difficulty setting */
 
	if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR;
 

	
 
	switch (GetRoadTileType(tile)) {
 
@@ -137,7 +139,7 @@ int32 CmdRemoveRoad(TileIndex tile, uint
 
				c |= (RoadBits)((c & 0x3) << 2);
 
			}
 

	
 
			// limit the bits to delete to the existing bits.
 
			/* limit the bits to delete to the existing bits. */
 
			c &= present;
 
			if (c == 0) return CMD_ERROR;
 

	
 
@@ -178,7 +180,7 @@ int32 CmdRemoveRoad(TileIndex tile, uint
 

	
 

	
 
static const RoadBits _valid_tileh_slopes_road[][15] = {
 
	// set of normal ones
 
	/* set of normal ones */
 
	{
 
		ROAD_ALL, ROAD_NONE, ROAD_NONE,
 
		ROAD_X,   ROAD_NONE, ROAD_NONE,  // 3, 4, 5
 
@@ -186,7 +188,7 @@ static const RoadBits _valid_tileh_slope
 
		ROAD_Y,   ROAD_NONE, ROAD_NONE,  // 9, 10, 11
 
		ROAD_X,   ROAD_NONE, ROAD_NONE
 
	},
 
	// allowed road for an evenly raised platform
 
	/* allowed road for an evenly raised platform */
 
	{
 
		ROAD_NONE,
 
		ROAD_SW | ROAD_NW,
 
@@ -216,7 +218,7 @@ static uint32 CheckRoadSlope(Slope tileh
 

	
 
	if (IsSteepSlope(tileh)) {
 
		if (existing == 0) {
 
			// force full pieces.
 
			/* force full pieces. */
 
			*pieces |= (RoadBits)((*pieces & 0xC) >> 2);
 
			*pieces |= (RoadBits)((*pieces & 0x3) << 2);
 
			if (*pieces == ROAD_X || *pieces == ROAD_Y) return _price.terraform;
 
@@ -225,21 +227,21 @@ static uint32 CheckRoadSlope(Slope tileh
 
	}
 
	road_bits = *pieces | existing;
 

	
 
	// no special foundation
 
	/* no special foundation */
 
	if ((~_valid_tileh_slopes_road[0][tileh] & road_bits) == 0) {
 
		// force that all bits are set when we have slopes
 
		/* force that all bits are set when we have slopes */
 
		if (tileh != SLOPE_FLAT) *pieces |= _valid_tileh_slopes_road[0][tileh];
 
		return 0; // no extra cost
 
	}
 

	
 
	// foundation is used. Whole tile is leveled up
 
	/* foundation is used. Whole tile is leveled up */
 
	if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == 0) {
 
		return existing != 0 ? 0 : _price.terraform;
 
	}
 

	
 
	// partly leveled up tile, only if there's no road on that tile
 
	/* partly leveled up tile, only if there's no road on that tile */
 
	if (existing == 0 && (tileh == SLOPE_W || tileh == SLOPE_S || tileh == SLOPE_E || tileh == SLOPE_N)) {
 
		// force full pieces.
 
		/* force full pieces. */
 
		*pieces |= (RoadBits)((*pieces & 0xC) >> 2);
 
		*pieces |= (RoadBits)((*pieces & 0x3) << 2);
 
		if (*pieces == ROAD_X || *pieces == ROAD_Y) return _price.terraform;
 
@@ -349,7 +351,7 @@ do_clear:;
 
	cost += ret;
 

	
 
	if (IsTileType(tile, MP_STREET)) {
 
		// Don't put the pieces that already exist
 
		/* Don't put the pieces that already exist */
 
		pieces &= ComplementRoadBits(existing);
 
	}
 

	
 
@@ -377,15 +379,15 @@ do_clear:;
 
 */
 
int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
 
{
 
	// not a railroad crossing?
 
	/* not a railroad crossing? */
 
	if (!IsLevelCrossing(tile)) return CMD_ERROR;
 

	
 
	// not owned by me?
 
	/* not owned by me? */
 
	if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
 

	
 
	if (GetRailType(tile) == totype) return CMD_ERROR;
 

	
 
	// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
 
	/* 'hidden' elrails can't be downgraded to normal rail when elrails are disabled */
 
	if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
 

	
 
	if (exec) {
 
@@ -431,7 +433,7 @@ int32 CmdBuildLongRoad(TileIndex end_til
 

	
 
	cost = 0;
 
	tile = start_tile;
 
	// Start tile is the small number.
 
	/* Start tile is the small number. */
 
	for (;;) {
 
		RoadBits bits = HASBIT(p2, 2) ? ROAD_Y : ROAD_X;
 

	
 
@@ -487,14 +489,14 @@ int32 CmdRemoveLongRoad(TileIndex end_ti
 

	
 
	cost = 0;
 
	tile = start_tile;
 
	// Start tile is the small number.
 
	/* Start tile is the small number. */
 
	for (;;) {
 
		RoadBits bits = HASBIT(p2, 2) ? ROAD_Y : ROAD_X;
 

	
 
		if (tile == end_tile && !HASBIT(p2, 1)) bits &= ROAD_NW | ROAD_NE;
 
		if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW;
 

	
 
		// try to remove the halves.
 
		/* try to remove the halves. */
 
		if (bits != 0) {
 
			ret = DoCommand(tile, bits, 0, flags, CMD_REMOVE_ROAD);
 
			if (!CmdFailed(ret)) cost += ret;
 
@@ -621,13 +623,13 @@ uint GetRoadFoundation(Slope tileh, Road
 
{
 
	uint i;
 

	
 
	// normal level sloped building
 
	/* normal level sloped building */
 
	if (!IsSteepSlope(tileh) &&
 
			(~_valid_tileh_slopes_road[1][tileh] & bits) == 0) {
 
		return tileh;
 
	}
 

	
 
	// inclined sloped building
 
	/* inclined sloped building */
 
	switch (bits) {
 
		case ROAD_X: i = 0; break;
 
		case ROAD_Y: i = 1; break;
 
@@ -672,8 +674,8 @@ static void DrawRoadBits(TileInfo* ti)
 

	
 
		if (foundation != 0) DrawFoundation(ti, foundation);
 

	
 
		// DrawFoundation() modifies ti.
 
		// Default sloped sprites..
 
		/* DrawFoundation() modifies ti.
 
		 * Default sloped sprites.. */
 
		if (ti->tileh != SLOPE_FLAT) image = _road_sloped_sprites[ti->tileh - 1] + 0x53F;
 
	}
 

	
 
@@ -695,15 +697,15 @@ static void DrawRoadBits(TileInfo* ti)
 
	DrawGroundSprite(image, pal);
 

	
 
	if (HasRoadWorks(ti->tile)) {
 
		// Road works
 
		/* Road works */
 
		DrawGroundSprite(road & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, PAL_NONE);
 
		return;
 
	}
 

	
 
	// Return if full detail is disabled, or we are zoomed fully out.
 
	/* Return if full detail is disabled, or we are zoomed fully out. */
 
	if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2) return;
 

	
 
	// Draw extra details.
 
	/* Draw extra details. */
 
	for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) {
 
		int x = ti->x | drts->subcoord_x;
 
		int y = ti->y | drts->subcoord_y;
 
@@ -896,7 +898,7 @@ static void TileLoop_Road(TileIndex tile
 
		if (t != NULL) {
 
			grp = GetTownRadiusGroup(t, tile);
 

	
 
			// Show an animation to indicate road work
 
			/* Show an animation to indicate road work */
 
			if (t->road_build_months != 0 &&
 
					(DistanceManhattan(t->xy, tile) < 8 || grp != 0) &&
 
					GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) {
src/road_cmd.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file road_cmd.h */
 

	
 
#ifndef ROAD_CMD_H
 
#define ROAD_CMD_H
 

	
src/road_gui.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file road_gui.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "road_cmd.h"
src/road_map.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file road_map.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "bridge_map.h"
src/road_map.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file road_map.h */
 

	
 
#ifndef ROAD_MAP_H
 
#define ROAD_MAP_H
 

	
src/roadveh.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file roadveh.h */
 

	
 
#ifndef ROADVEH_H
 
#define ROADVEH_H
 

	
src/roadveh_cmd.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file roadveh_cmd.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "debug.h"
 
@@ -533,7 +535,7 @@ static byte SetRoadVehPosition(Vehicle *
 
{
 
	byte new_z, old_z;
 

	
 
	// need this hint so it returns the right z coordinate on bridges.
 
	/* need this hint so it returns the right z coordinate on bridges. */
 
	v->x_pos = x;
 
	v->y_pos = y;
 
	new_z = GetSlopeZ(x, y);
 
@@ -663,7 +665,7 @@ static void ProcessRoadVehOrder(Vehicle 
 

	
 
	switch (v->current_order.type) {
 
		case OT_GOTO_DEPOT:
 
			// Let a depot order in the orderlist interrupt.
 
			/* Let a depot order in the orderlist interrupt. */
 
			if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return;
 
			if (v->current_order.flags & OF_SERVICE_IF_NEEDED &&
 
					!VehicleNeedsService(v)) {
 
@@ -723,7 +725,7 @@ static void ProcessRoadVehOrder(Vehicle 
 
				}
 
				v->dest_tile = dest;
 
			} else {
 
				// There is no stop left at the station, so don't even TRY to go there
 
				/* There is no stop left at the station, so don't even TRY to go there */
 
				v->cur_order_index++;
 
				v->dest_tile = 0;
 
			}
 
@@ -828,10 +830,10 @@ static Vehicle* RoadVehFindCloseTo(Vehic
 
	rvf.veh = v;
 
	u = (Vehicle*)VehicleFromPos(TileVirtXY(x, y), &rvf, EnumCheckRoadVehClose);
 

	
 
	// This code protects a roadvehicle from being blocked for ever
 
	//  If more than 1480 / 74 days a road vehicle is blocked, it will
 
	//  drive just through it. The ultimate backup-code of TTD.
 
	// It can be disabled.
 
	/* This code protects a roadvehicle from being blocked for ever
 
	 * If more than 1480 / 74 days a road vehicle is blocked, it will
 
	 * drive just through it. The ultimate backup-code of TTD.
 
	 * It can be disabled. */
 
	if (u == NULL) {
 
		v->u.road.blocked_ctr = 0;
 
		return NULL;
 
@@ -881,13 +883,13 @@ static bool RoadVehAccelerate(Vehicle *v
 
	uint spd = v->cur_speed + 1 + (v->u.road.overtaking != 0 ? 1 : 0);
 
	byte t;
 

	
 
	// Clamp
 
	/* Clamp */
 
	spd = min(spd, v->max_speed);
 
	if (v->u.road.state == RVSB_WORMHOLE && !(v->vehstatus & VS_HIDDEN)) {
 
		spd = min(spd, GetBridge(GetBridgeType(v->tile))->speed * 2);
 
	}
 

	
 
	//updates statusbar only if speed have changed to save CPU time
 
	/* updates statusbar only if speed have changed to save CPU time */
 
	if (spd != v->cur_speed) {
 
		v->cur_speed = spd;
 
		if (_patches.vehicle_speed) {
 
@@ -895,7 +897,7 @@ static bool RoadVehAccelerate(Vehicle *v
 
		}
 
	}
 

	
 
	// Decrease somewhat when turning
 
	/* Decrease somewhat when turning */
 
	if (!(v->direction & 1)) spd = spd * 3 >> 2;
 

	
 
	if (spd == 0) return false;
 
@@ -1153,9 +1155,9 @@ static Trackdir RoadFindPathToDest(Vehic
 

	
 
		ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE);
 
		if (ftd.best_trackdir == INVALID_TRACKDIR) {
 
			/* We are already at our target. Just do something */
 
			//TODO: maybe display error?
 
			//TODO: go straight ahead if possible?
 
			/* We are already at our target. Just do something
 
			 * @todo: maybe display error?
 
			 * @todo: go straight ahead if possible? */
 
			return_track(FindFirstBit2x64(trackdirs));
 
		} else {
 
			/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
 
@@ -1223,10 +1225,10 @@ static uint RoadFindPathToStop(const Veh
 
{
 
	uint dist;
 
	if (_patches.yapf.road_use_yapf) {
 
		// use YAPF
 
		/* use YAPF */
 
		dist = YapfRoadVehDistanceToTile(v, tile);
 
	} else {
 
		// use NPF
 
		/* use NPF */
 
		NPFFindStationOrTileData fstd;
 
		Trackdir trackdir = GetVehicleTrackdir(v);
 
		assert(trackdir != INVALID_TRACKDIR);
 
@@ -1235,7 +1237,7 @@ static uint RoadFindPathToStop(const Veh
 
		fstd.station_index = INVALID_STATION; // indicates that the destination is a tile, not a station
 

	
 
		dist = NPFRouteToStationOrTile(v->tile, trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE).best_path_dist;
 
		// change units from NPF_TILE_LENGTH to # of tiles
 
		/* change units from NPF_TILE_LENGTH to # of tiles */
 
		if (dist != UINT_MAX)
 
			dist = (dist + NPF_TILE_LENGTH - 1) / NPF_TILE_LENGTH;
 
	}
 
@@ -1277,11 +1279,11 @@ static void RoadVehController(Vehicle *v
 
	int x,y;
 
	uint32 r;
 

	
 
	// decrease counters
 
	/* decrease counters */
 
	v->tick_counter++;
 
	if (v->u.road.reverse_ctr != 0) v->u.road.reverse_ctr--;
 

	
 
	// handle crashed
 
	/* handle crashed */
 
	if (v->u.road.crashed_ctr != 0) {
 
		RoadVehIsCrashed(v);
 
		return;
 
@@ -1289,7 +1291,7 @@ static void RoadVehController(Vehicle *v
 

	
 
	RoadVehCheckTrainCrash(v);
 

	
 
	// road vehicle has broken down?
 
	/* road vehicle has broken down? */
 
	if (v->breakdown_ctr != 0) {
 
		if (v->breakdown_ctr <= 2) {
 
			HandleBrokenRoadVeh(v);
 
@@ -1628,9 +1630,9 @@ again:
 
			/* We are leaving the correct station */
 
			ClearSlot(v);
 
		} else if (v->u.road.slot != NULL) {
 
			/* We are leaving the wrong station */
 
			//XXX The question is .. what to do? Actually we shouldn't be here
 
			//but I guess we need to clear the slot
 
			/* We are leaving the wrong station
 
			 * XXX The question is .. what to do? Actually we shouldn't be here
 
			 * but I guess we need to clear the slot */
 
			DEBUG(ms, 0, "Vehicle %d (index %d) arrived at wrong stop", v->unitnumber, v->index);
 
			if (v->tile != v->dest_tile) {
 
				DEBUG(ms, 2, " current tile 0x%X is not destination tile 0x%X. Route problem", v->tile, v->dest_tile);
 
@@ -1692,13 +1694,13 @@ static void CheckIfRoadVehNeedsService(V
 
	if (v->vehstatus & VS_STOPPED) return;
 
	if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
 

	
 
	// Don't interfere with a depot visit scheduled by the user, or a
 
	// depot visit by the order list.
 
	/* Don't interfere with a depot visit scheduled by the user, or a
 
	 * depot visit by the order list. */
 
	if (v->current_order.type == OT_GOTO_DEPOT &&
 
			(v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0)
 
		return;
 

	
 
	// If we already got a slot at a stop, use that FIRST, and go to a depot later
 
	/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
 
	if (v->u.road.slot != NULL) return;
 

	
 
	if (IsRoadVehInDepot(v)) {
 
@@ -1706,7 +1708,7 @@ static void CheckIfRoadVehNeedsService(V
 
		return;
 
	}
 

	
 
	// XXX If we already have a depot order, WHY do we search over and over?
 
	/* XXX If we already have a depot order, WHY do we search over and over? */
 
	depot = FindClosestRoadDepot(v);
 

	
 
	if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) {
 
@@ -1743,7 +1745,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
 

	
 
	CheckOrders(v);
 

	
 
	//Current slot has expired
 
	/* Current slot has expired */
 
	if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot != NULL && v->u.road.slot_age-- == 0) {
 
		DEBUG(ms, 3, "Slot expired for vehicle %d (index %d) at stop 0x%X",
 
			v->unitnumber, v->index, v->u.road.slot->xy);
src/roadveh_gui.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file roadveh_gui.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "debug.h"
 
@@ -34,7 +36,7 @@ static void RoadVehDetailsWndProc(Window
 
		StringID str;
 

	
 
		SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
 
		// disable service-scroller when interval is set to disabled
 
		/* disable service-scroller when interval is set to disabled */
 
		SetWindowWidgetDisabledState(w, 5, !_patches.servint_roadveh);
 
		SetWindowWidgetDisabledState(w, 6, !_patches.servint_roadveh);
 

	
0 comments (0 inline, 0 general)