Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

BuildingLayer Class Reference

#include <buildinglayer.h>

Inheritance diagram for BuildingLayer:

Layer Persistence UI List of all members.

Public Member Functions

 BuildingLayer (const City &rcCity)
void SaveTo (std::fstream &rfs)
void LoadFrom (std::fstream &rfs)
void uiKeyboard (const SDL_KeyboardEvent &rcsSDLKeyboardEvent)
void uiMouseMotion (const SDL_MouseMotionEvent &rcsSDLMouseMotionEvent)
void uiMouseButton (const SDL_MouseButtonEvent &rcsSDLMouseButtonEvent)
void uiExpose (const SDL_ExposeEvent &rcsSDLExposeEvent)
void uiResize (const SDL_ResizeEvent &rcsSDLResizeEvent)
const bool IsConstructive (uint W1, uint L1, uint W2, uint L2, const OPENCITY_STRUCTURE_CODE &enumStructCode) const
const OPENCITY_ERR_CODE BuildPreview (const uint &W, const uint &L, const OPENCITY_STRUCTURE_CODE &enumStructCode, OPENCITY_GRAPHIC_CODE &enumGraphicCode) const
const OPENCITY_ERR_CODE BuildStructure (const uint &W1, const uint &L1, const uint &W2, const uint &L2, const OPENCITY_STRUCTURE_CODE &enumStructCode, uint &rCost)
const OPENCITY_ERR_CODE ResizeStructure (const uint &w, const uint &l, const OPENCITY_GRAPHIC_CODE &oldGC)
const OPENCITY_ERR_CODE DestroyStructure (uint W1, uint L1, uint W2, uint L2, uint &rCost)
StructureGetLinearStructure (const uint cuiLinearIndex) const
StructureGetStructure (const uint &w, const uint &l) const
StructureGetRandomStructure (uint &w, uint &l, const OPENCITY_STRUCTURE_CODE &enumStructCode=OC_STRUCTURE_UNDEFINED) const
const uint GetNumberStructure () const
void StructureSet (const OC_BYTE &status)
void StructureUnset (const OC_BYTE &status)
const bool ContainStructure (const uint &W1, const uint &L1, const uint &W2, const uint &L2, const OPENCITY_STRUCTURE_CODE &enumStructCode) const
const bool ContainStructureOnly (const uint &W1, const uint &L1, const uint &W2, const uint &L2, const OPENCITY_STRUCTURE_CODE &enumStructCode) const
GUIContainerQueryStructure (const uint &w, const uint &l) const

Private Member Functions

const bool _IsPathConstructive (const uint &w, const uint &h, const OPENCITY_STRUCTURE_CODE &enumStructCode) const
const OPENCITY_ERR_CODE _BuildPathStructure (uint W1, uint L1, uint W2, uint L2, const OPENCITY_STRUCTURE_CODE &enumStructCode, uint &rCost)
void _BuildPathStructure (const uint &w, const uint &h, const uint &linearIndex, const OPENCITY_STRUCTURE_CODE &enumStructCode, uint &rCost)
const OPENCITY_ERR_CODE _BuildRCIStructure (uint W1, uint L1, uint W2, uint L2, const OPENCITY_STRUCTURE_CODE &enumStructCode, uint &rCost)
const OPENCITY_ERR_CODE _BuildFloraStructure (uint W1, uint L1, uint W2, uint L2, const OPENCITY_STRUCTURE_CODE &enumStructCode, uint &rCost)
const OPENCITY_ERR_CODE _BuildWEGStructure (uint W1, uint L1, const OPENCITY_STRUCTURE_CODE &enumStructCode, uint &rCost)
void _BuildWEGStructure (uint W1, uint L1, uint W2, uint L2, const OPENCITY_STRUCTURE_CODE &enumStructCode, uint &rCost)
void _LoadStructure (const uint &w1, const uint &l1, Structure *pStruct)
const OPENCITY_ERR_CODE _DestroyStructure (const uint &w, const uint &l, uint &rCost)
const OPENCITY_ERR_CODE _DestroyPathStructure (uint w, uint l, const OPENCITY_STRUCTURE_CODE &enumStructCode)

Private Attributes

Structure ** _tabpStructure

Detailed Description

This class contains all the buildings added by the player

Definition at line 31 of file buildinglayer.h.


Member Function Documentation

void BuildingLayer::_BuildPathStructure const uint &  w,
const uint &  h,
const uint &  linearIndex,
const OPENCITY_STRUCTURE_CODE &  enumStructCode,
uint &  rCost
[private]
 

Build a path structure at the specified coordinates

Note:
If there's already a structure at the specified coordinates, this method returns without generating any error
Parameters:
w,h The coordinates
linearIndex The index of the structure in the structure array
enumStructCode The structure code (=STRUCTURE_ROAD)
rCost The cost of the construction

Definition at line 924 of file buildinglayer.cpp.

References _tabpStructure, PathStructure::AddNeighbour(), PropertyManager::Get(), Structure::GetCode(), Map::GetNeighbourWH(), GetStructure(), GlobalVar::gpMapMgr, and GlobalVar::gpPropertyMgr.

const OPENCITY_ERR_CODE BuildingLayer::_BuildPathStructure uint  W1,
uint  L1,
uint  W2,
uint  L2,
const OPENCITY_STRUCTURE_CODE &  enumStructCode,
uint &  rCost
[private]
 

Called internally by other methods, don't touch it

Definition at line 842 of file buildinglayer.cpp.

Referenced by BuildStructure().

const OPENCITY_ERR_CODE BuildingLayer::_DestroyStructure const uint &  w,
const uint &  l,
uint &  rCost
[private]
 

Destroy the structure built at the specified coordinates

Parameters:
w = OpenGL Ox
l = OpenGL Oz
rCost = the cost needed to clean up the specified cell
Returns:
Error code

Definition at line 1233 of file buildinglayer.cpp.

References _tabpStructure, PropertyManager::Get(), Structure::GetCode(), Structure::GetGraphicCode(), Structure::GetMain(), Map::GetPossibleWH(), PropertyManager::GetWLH(), GlobalVar::gpMapMgr, and GlobalVar::gpPropertyMgr.

Referenced by DestroyStructure(), and ResizeStructure().

void BuildingLayer::_LoadStructure const uint &  w1,
const uint &  l1,
Structure pStruct
[private]
 

Fast load a structure at the specified coordinates. If the structure is bigger than 1x1, then extra structures part will be built automatically. There is not any "Constructive" test.

Note:
If there's already a structure at the specified coordinates, this method returns without generating any error
Parameters:
w1,l1 The structure upper-left map coordinates
pStruct The pointer to the structure which will be deleted automatically when the program ends

Definition at line 1181 of file buildinglayer.cpp.

References _tabpStructure, Structure::GetGraphicCode(), PropertyManager::GetWLH(), and GlobalVar::gpPropertyMgr.

Referenced by LoadFrom().

const OPENCITY_ERR_CODE BuildingLayer::BuildPreview const uint &  W,
const uint &  L,
const OPENCITY_STRUCTURE_CODE &  enumStructCode,
OPENCITY_GRAPHIC_CODE &  enumGraphicCode
const [virtual]
 

see "layer.h" for more informations

See also:
Layer::BuildPreview()

Implements Layer.

Definition at line 274 of file buildinglayer.cpp.

References PropertyManager::GetGC(), PropertyManager::GetWLH(), GlobalVar::gpPropertyMgr, and IsConstructive().

const OPENCITY_ERR_CODE BuildingLayer::BuildStructure const uint &  W1,
const uint &  L1,
const uint &  W2,
const uint &  L2,
const OPENCITY_STRUCTURE_CODE &  enumStructCode,
uint &  rCost
[virtual]
 

see "layer.h" for more informations

See also:
Layer

Implements Layer.

Definition at line 313 of file buildinglayer.cpp.

References _BuildPathStructure().

Referenced by ResizeStructure().

const bool BuildingLayer::ContainStructure const uint &  W1,
const uint &  L1,
const uint &  W2,
const uint &  L2,
const OPENCITY_STRUCTURE_CODE &  enumStructCode
const [virtual]
 

see "layer.h" for more informations

Implements Layer.

Definition at line 595 of file buildinglayer.cpp.

References Structure::GetCode(), GetLinearStructure(), and Structure::IsSet().

Referenced by Simulator::CheckRange().

const bool BuildingLayer::ContainStructureOnly const uint &  W1,
const uint &  L1,
const uint &  W2,
const uint &  L2,
const OPENCITY_STRUCTURE_CODE &  enumStructCode
const [virtual]
 

see "layer.h" for more informations

Implements Layer.

Definition at line 663 of file buildinglayer.cpp.

References Structure::GetCode(), GetLinearStructure(), and Structure::IsSet().

const OPENCITY_ERR_CODE BuildingLayer::DestroyStructure uint  W1,
uint  L1,
uint  W2,
uint  L2,
uint &  rCost
[virtual]
 

Destroy all the structures built on the specified surface

Parameters:
W1,W2 = OpenGL Ox
L1,L2 = OpenGL Oz
rCost = the cost needed to clean up the specified surface
Returns:
Error code

Implements Layer.

Definition at line 479 of file buildinglayer.cpp.

References _DestroyStructure().

Structure * BuildingLayer::GetLinearStructure const uint  cuiLinearIndex  )  const [virtual]
 

Returns a pointer to a structure indexed by its linear index. The linear index of a structure is calculated by this formula: index = W + (H * city width)

Parameters:
cuiLinearIndex = linear index of the structure to retrieve
Returns:
A pointer to a structure if it exists NULL otherwise

Implements Layer.

Definition at line 503 of file buildinglayer.cpp.

References _tabpStructure.

Referenced by ContainStructure(), ContainStructureOnly(), PathFinder::findShortestPath(), GetRandomStructure(), and MainSim::RefreshSimValue().

const uint BuildingLayer::GetNumberStructure  )  const [virtual]
 

Get the number of the structures built on the layer

Implements Layer.

Definition at line 558 of file buildinglayer.cpp.

Structure * BuildingLayer::GetRandomStructure uint &  w,
uint &  l,
const OPENCITY_STRUCTURE_CODE &  enumStructCode = OC_STRUCTURE_UNDEFINED
const [virtual]
 

Random access to the structure of the specified type

Parameters:
w,l The structure NorthWest (top left) coordinates
enumStructCode The structure code
Returns:
The randomly selected structure pointer

Implements Layer.

Definition at line 521 of file buildinglayer.cpp.

References Structure::GetCode(), and GetLinearStructure().

Structure * BuildingLayer::GetStructure const uint &  w,
const uint &  l
const [virtual]
 

Access to the structure specified by its WL coordinates

Parameters:
w,l The structure NorthWest (top left) coordinates

Implements Layer.

Definition at line 511 of file buildinglayer.cpp.

References _tabpStructure.

Referenced by _BuildPathStructure(), and PathFinder::findShortestPath().

const bool BuildingLayer::IsConstructive uint  W1,
uint  L1,
uint  W2,
uint  L2,
const OPENCITY_STRUCTURE_CODE &  enumStructCode
const [virtual]
 

Is the specified area constructive ? Can we build the specified structure on it ?

Parameters:
W1,W2 = OpenGL Ox
L1,L2 = OpenGL Oz
enumStructCode = The code of the structure that we're going to build
Returns:
True or False

Implements Layer.

Definition at line 210 of file buildinglayer.cpp.

References GlobalVar::gpMapMgr, and Map::IsSquarePlane().

Referenced by BuildPreview().

void BuildingLayer::LoadFrom std::fstream &  rfs  )  [virtual]
 

Load the data from the specified stream

Parameters:
rfs A reference to a file stream which is ready for reading
See also:
Persistence

Implements Persistence.

Definition at line 106 of file buildinglayer.cpp.

References _LoadStructure(), _tabpStructure, Structure::LoadFrom(), and Structure::SetNumber().

GUIContainer * BuildingLayer::QueryStructure const uint &  w,
const uint &  l
const [virtual]
 

see "layer.h" for more informations

Implements Layer.

Definition at line 739 of file buildinglayer.cpp.

References _tabpStructure, GUIContainer::Add(), Structure::IsSet(), Layer::pbtnQC, Layer::pbtnQE, Layer::pbtnQG, Layer::pbtnQI, Layer::pbtnQR, Layer::pbtnQW, and GUIButton::SetBackground().

const OPENCITY_ERR_CODE BuildingLayer::ResizeStructure const uint &  w,
const uint &  l,
const OPENCITY_GRAPHIC_CODE &  oldGC
[virtual]
 

Resize the surface used by the structure to the new surface thanks to its new GraphicCode.

Parameters:
w,l = The structure's map coordinates
oldGC = The old graphic code of the structure

Implements Layer.

Definition at line 365 of file buildinglayer.cpp.

References _DestroyStructure(), _tabpStructure, BuildStructure(), Structure::GetCode(), Structure::GetGraphicCode(), Structure::GetMain(), PropertyManager::GetWLH(), and GlobalVar::gpPropertyMgr.

void BuildingLayer::SaveTo std::fstream &  rfs  )  [virtual]
 

Save the data to the specified fstream

Parameters:
rfs A reference to a file stream which is ready for writing
See also:
Persistence

Implements Persistence.

Definition at line 74 of file buildinglayer.cpp.

References _tabpStructure, Structure::GetMain(), Structure::GetType(), and Structure::SaveTo().

void BuildingLayer::StructureSet const OC_BYTE &  status  )  [virtual]
 

Set all the structures contained by this layer to the specified status.

Parameters:
status = The new status of the structures

Implements Layer.

Definition at line 569 of file buildinglayer.cpp.

References _tabpStructure, and Structure::Set().

void BuildingLayer::StructureUnset const OC_BYTE &  status  )  [virtual]
 

Unset the specified status of all the structures contained by this layer.

Parameters:
status = The status of the structures to be unset

Implements Layer.

Definition at line 582 of file buildinglayer.cpp.

References _tabpStructure, and Structure::Unset().


Member Data Documentation

Structure** BuildingLayer::_tabpStructure [private]
 

All the buildings are here

Definition at line 226 of file buildinglayer.h.

Referenced by _BuildPathStructure(), _DestroyStructure(), _LoadStructure(), GetLinearStructure(), GetStructure(), LoadFrom(), QueryStructure(), ResizeStructure(), SaveTo(), StructureSet(), and StructureUnset().


The documentation for this class was generated from the following files:
Generated on Sat Nov 11 10:21:10 2006 for OpenCity by  doxygen 1.4.2