src/ai/api/ai_bridgelist.cpp
author truebrain
Sat, 07 Jun 2008 23:05:36 +0000
branchnoai
changeset 10853 87f2238f47d4
parent 10670 a39c9d7c2562
permissions -rw-r--r--
(svn r13404) [NoAI] -Change [API CHANGE]: AITile::IsBuildable no longer returns 'true' on road, but only on a halve piece of road (as that is auto-removed). This should make this function return less 'true', and more sane results :)
9820
8c116d4c6033 (svn r12423) [NoAI] -Change: bring a little more uniformness into the first few lines of the API related files (add missing /* $Id$ */ and such).
rubidium
parents: 9792
diff changeset
     1
/* $Id$ */
8c116d4c6033 (svn r12423) [NoAI] -Change: bring a little more uniformness into the first few lines of the API related files (add missing /* $Id$ */ and such).
rubidium
parents: 9792
diff changeset
     2
9833
89a64246458f (svn r12496) [NoAI] -Documentation: give the .cpp files a nice uniform format too
truebrain
parents: 9820
diff changeset
     3
/** @file ai_bridgelist.cpp Implementation of AIBridgeList and friends. */
9820
8c116d4c6033 (svn r12423) [NoAI] -Change: bring a little more uniformness into the first few lines of the API related files (add missing /* $Id$ */ and such).
rubidium
parents: 9792
diff changeset
     4
9792
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
     5
#include "ai_bridgelist.hpp"
10670
a39c9d7c2562 (svn r13214) [NoAI] -Fix: fix AIBridgeList_Length, as the max-length is weird (tnx Anton84)
truebrain
parents: 10339
diff changeset
     6
#include "ai_bridge.hpp"
10339
ce6cd68d9eb8 (svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
truebrain
parents: 9833
diff changeset
     7
#include "../../openttd.h"
9792
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
     8
#include "../../bridge.h"
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
     9
#include "../../date_func.h"
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    10
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    11
AIBridgeList::AIBridgeList()
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    12
{
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    13
	/* Add all bridges, no matter if they are available or not */
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    14
	for (byte j = 0; j < MAX_BRIDGES; j++)
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    15
		if (::GetBridgeSpec(j)->avail_year <= _cur_year)
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    16
			this->AddItem(j);
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    17
}
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    18
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    19
AIBridgeList_Length::AIBridgeList_Length(uint length)
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    20
{
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    21
	for (byte j = 0; j < MAX_BRIDGES; j++)
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    22
		if (::GetBridgeSpec(j)->avail_year <= _cur_year)
10670
a39c9d7c2562 (svn r13214) [NoAI] -Fix: fix AIBridgeList_Length, as the max-length is weird (tnx Anton84)
truebrain
parents: 10339
diff changeset
    23
			if (length >= (uint)AIBridge::GetMinLength(j) && length <= (uint)AIBridge::GetMaxLength(j))
9792
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    24
				this->AddItem(j);
e1222f4674c2 (svn r12294) [NoAI] -Add: added AIBridge(List), which lists all available bridges (no build yet)
truebrain
parents:
diff changeset
    25
}