____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

ai_building.cpp File Reference

AI building functions. More...

#include <stdio.h>
#include <stdlib.h>
#include "stratagus.h"
#include "unit.h"
#include "unittype.h"
#include "map.h"
#include "pathfinder.h"
#include "ai_local.h"
#include "player.h"

Go to the source code of this file.

Functions

static int AiCheckSurrounding (const CUnit *worker, const CUnitType *type, int x, int y, bool &backupok)
static int AiFindBuildingPlace2 (const CUnit *worker, const CUnitType *type, int ox, int oy, int *dx, int *dy)
int AiFindBuildingPlace (const CUnit *worker, const CUnitType *type, int *dx, int *dy)
 < Find nice building place


Detailed Description

AI building functions.

Definition in file ai_building.cpp.


Function Documentation

static int AiCheckSurrounding ( const CUnit worker,
const CUnitType type,
int  x,
int  y,
bool &  backupok 
) [static]

Check if the surrounding are free. Depending on the value of flag, it will check : 0: the building will not block any way 1: all surrounding is free

Parameters:
worker Worker to build.
type Type of building.
x X map tile position for the building.
y Y map tile position for the building.
backupok Location can be used as a backup
Returns:
True if the surrounding is free, false otherwise.
Note:
Can be faster written.

Definition at line 69 of file ai_building.cpp.

References CMap::Field(), CMapField::Flags, CMap::Info, Map, MapFieldBuilding, MapFieldCoastAllowed, MapFieldLandAllowed, MapFieldUnpassable, MapFieldWaterAllowed, CMapInfo::MapHeight, CMapInfo::MapWidth, CUnitType::ShoreBuilding, CUnitType::TileWidth, CUnit::X, and CUnit::Y.

Referenced by AiFindBuildingPlace2().

int AiFindBuildingPlace ( const CUnit worker,
const CUnitType type,
int *  dx,
int *  dy 
)

< Find nice building place

Find free building place.

Parameters:
worker Worker to build building.
type Type of building.
dx Pointer for X position returned.
dy Pointer for Y position returned.
Returns:
True if place found, false if no found.
Todo:
Better and faster way to find building place of oil platforms Special routines for special buildings.

Definition at line 298 of file ai_building.cpp.

References _C_, AiFindBuildingPlace2(), DebugPrint, CUnitType::Ident, CUnitType::Name, CUnit::X, and CUnit::Y.

Referenced by AiBuildBuilding().

static int AiFindBuildingPlace2 ( const CUnit worker,
const CUnitType type,
int  ox,
int  oy,
int *  dx,
int *  dy 
) [static]

Find free building place. (flood fill version)

Parameters:
worker Worker to build building.
type Type of building.
ox Original X position to try building
oy Original Y position to try building
dx Pointer for X position returned.
dy Pointer for Y position returned.
Returns:
True if place found, false if no found.

Definition at line 147 of file ai_building.cpp.

References AiCheckSurrounding(), AiEnemyUnitsInDistance(), CanBuildUnitType(), CanMoveToMask(), CreateMatrix(), CMap::Info, Map, MapFieldAirUnit, MapFieldLandUnit, MapFieldSeaUnit, CMapInfo::MapHeight, CMapInfo::MapWidth, CUnitType::MovementMask, CUnit::Player, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, and y.

Referenced by AiFindBuildingPlace().


Generated on Sat Feb 21 00:28:15 2009 for Bos Wars by  doxygen 1.5.6