src/depot_func.h
author truebrain
Fri, 13 Jun 2008 19:57:25 +0000
branchnoai
changeset 10957 7a140b4cd91d
parent 10249 58810805030e
permissions -rw-r--r--
(svn r13511) [NoAI] -Fix: add a reference to objects given in Valuate(), so they remain valid during their usage. This allows nameless functions (lambda functions) in Valuate() on long lists.
10249
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
     1
/* $Id$ */
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
     2
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
     3
/** @file depot_func.h Functions related to depots. */
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
     4
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
     5
#ifndef DEPOT_FUNC_H
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
     6
#define DEPOT_FUNC_H
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
     7
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
     8
#include "depot_type.h"
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
     9
#include "tile_type.h"
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    10
#include "vehicle_type.h"
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    11
#include "direction_type.h"
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    12
#include "slope_type.h"
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    13
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    14
void ShowDepotWindow(TileIndex tile, VehicleType type);
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    15
void InitializeDepots();
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    16
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    17
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    18
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    19
/**
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    20
 * Find out if the slope of the tile is suitable to build a depot of given direction
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    21
 * @param direction The direction in which the depot's exit points
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    22
 * @param tileh The slope of the tile in question
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    23
 * @return true if the construction is possible
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    24
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    25
 * This is checked by the ugly 0x4C >> direction magic, which does the following:
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    26
 * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    27
 * So: for direction (only the significant bits are shown)<p>
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    28
 * 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    29
 * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    30
 * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    31
 * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    32
 * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    33
 */
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    34
static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    35
{
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    36
	return ((0x4C >> direction) & tileh) != 0;
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    37
}
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    38
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
diff changeset
    39
#endif /* DEPOT_FUNC_H */