Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

source/zakdef.h File Reference

the core set of definitions for the game. More...

#include <appconfig.h>
#include <tileheader.h>

Go to the source code of this file.

Data Structures

struct  _appConfig_01
 appliation configuration. More...

struct  _defence_unit
 a defence unit structure More...

struct  _game_struct05
 Structure kept around for historic purposes. More...

struct  _game_struct06a
 the central game structure. More...

struct  _history
 the structure containing graphical history More...

struct  _moveable_object
 a moveable item on the map More...

struct  _stat_to_value
 the statistic to value structure More...

struct  _vgame_struct
 volatile game structure More...

struct  _visual_tag
 game visual entities related to the game, but not the simulation More...

struct  zoneTypeValue
 the zone types for querying More...


Defines

#define STATS_PER   4
 the number of statistics held for a year/decade

#define STATS_COUNT   10
 number of years/decades kept

#define STAT_ENTRIES   (STATS_PER * STATS_COUNT)
 number of entries in array

#define OFFSET_FOR_CASHFLOW_BC   (1UL<<31)
 value for normalizing the cashflow within the range

#define OFFSET_FOR_CASHFLOW_STAT   ((~(Uint16)0) >> 1)
 this offset is 1/2 the value of an unsigned int16

#define CASHFLOW_STATMASK   (0xffff)
 this is the mask for setting the cashflow value

#define SIM_GAME_LOOP_DISASTER   2
 how often the disasters are updated - in seconds

#define SPEED_SLOW   15
 the number of seconds in a month at slow speed

#define SPEED_MEDIUM   10
 the number of seconds in a month at medium speed

#define SPEED_FAST   5
 the number of seconds in a month at fast speed

#define SPEED_TURBO   1
 the number of seconds in a month at turbo speed

#define SPEED_PAUSED   0
 the number of seconds in a month at pause speed

#define HORIZONTAL_TILESIZE   32
 the number of tiles that are stored laterally on a 'tilestripe'

#define SUPPLY_POWER_PLANT   100
 number of power units supplied by a coal power plant

#define SUPPLY_NUCLEAR_PLANT   300
 number of power units supplied by a nuclear power plant

#define SUPPLY_WATER_PUMP   200
 number of zones supplied by a water pump

#define INCOME_RESIDENTIAL   25
 income from a residential zone per value level

#define INCOME_COMMERCIAL   35
 income from a commercial zone per value level

#define INCOME_INDUSTRIAL   30
 income from an industrial zone per value level

#define UPKEEP_BRIDGE   10
 upkeep cost of a bridge

#define UPKEEP_ROAD   2
 upkeep cost of a road

#define UPKEEP_POWERLINE   1
 upkeep cost of a powerline

#define UPKEEP_NUCLEARPLANT   500
 upkeep cost of a coal power plant

#define UPKEEP_POWERPLANT   200
 upkeep cost of a nuclear power plant

#define UPKEEP_FIRE_STATIONS   150
 upkeep cost of a fire station

#define UPKEEP_POLICE_STATIONS   100
 upkeep cost of a police station

#define UPKEEP_MILITARY_BASES   500
 upkeep cost of a military base

#define NUM_OF_OBJECTS   10
 the number of objects that may be on the screen at a time.

#define OBJ_CHANCE_OF_TURNING   5
 Chance of object turning either clockwise or anti-clockwise.

#define NUM_OF_UNITS   10
 the number of defence units that may be on the screen at a time.

#define DEF_POLICE_START   0
 index in object array that police units start from

#define DEF_POLICE_END   2
 index in object array that police units end at

#define DEF_FIREMEN_START   3
 index in object array that fireman units start from

#define DEF_FIREMEN_END   7
 index in object array that fireman units end at

#define DEF_MILITARY_START   8
 index in object array that military units start from

#define DEF_MILITARY_END   9
 index in object array that military units end at

#define GRID_POWER   (UInt8)1
 code to say to update the power grid

#define GRID_WATER   (UInt8)2
 code to say to update the water grid

#define GRID_ALL   (GRID_POWER|GRID_WATER)
 code to say to update both water and power grids

#define CITYNAMELEN   20
 the maximum length of the city name string

#define CONFIG_VERSION   1
 version number of the configuration file

#define SAVEGAMEVERSION   "PC07"
 save game version

#define getMapWidth()   (GG.mapx)
 get the map size

#define getMapHeight()   (GG.mapy)
 get the map height

#define setMapVariables(X, Y)
 set the map variables for the vgame structure

#define MapMul()   (vgame.mapmul)
 get the map array size

#define WorldSize()   (vgame.mapmul)
 get the world pointer size .. based on map

#define AddGridUpdate(T)   (GG.gridsToUpdate |= (T))
 add a grid to be updated

#define NeedsUpdate(T)   (GG.gridsToUpdate & (T))
 Check if a grid need updating.

#define ClearUpdate(T)   (GG.gridsToUpdate &= (UInt8)(~(UInt8)(T)))
 Clear the need to update a sertain grid.

#define WORLDPOS(x, y)   ((x) + (y) * (getMapWidth()))
 get the position of a map location in the world array

#define SaveSpeed()
 save the current speed, and change the speed to paused

#define RestoreSpeed()
 restore the saved game speed

#define getMonthsElapsed()   (GG.TimeElapsed >> 2)
 get the number of months that have elapsed in the game


Typedefs

typedef UInt8 welem_t
 the type of the world elements

typedef UInt8 selem_t
 the type of the world status flags

typedef _history stat_item
 the structure containing graphical history

typedef _moveable_object MoveableObject
 a moveable item on the map

typedef _defence_unit DefenceUnit
 a defence unit structure

typedef _game_struct05 GameStruct05
 Structure kept around for historic purposes.

typedef _game_struct06a GameStruct06
 the central game structure.

typedef _stat_to_value stat_to_value
 the statistic to value structure

typedef GameStruct06 GameStruct
 currently supported save game version

typedef _vgame_struct vGameStruct
 volatile game structure

typedef _visual_tag vGameVisuals
 game visual entities related to the game, but not the simulation

typedef _appConfig_01 appConfig_01_t
 appliation configuration.

typedef appConfig_01_t AppConfig_t
 currently used application conofiguration version


Enumerations

enum  disaster_t {
  diSTART = 0, diFireOutbreak, diPlantExplosion, diMonster,
  diDragon, diMeteor, diEND
}
 the possible errors/warnings. More...

enum  syserror_t { seOutOfMemory = 1 }
enum  problem_t {
  peSTART = 0, peFineOnMoney, peLowOnMoney, peOutOfMoney,
  peFineOnPower, peLowOnPower, peOutOfPower, peFineOnWater,
  peLowOnWater, peOutOfWater, peEND
}
enum  zoneType { ztWhat = 0, ztCommercial = Z_COMMERCIAL_SLUM, ztResidential, ztIndustrial }
 zone identification for scoring More...

enum  dirType { dtUp = 0, dtRight, dtDown, dtLeft }
 directions for checking power distribution routines More...

enum  StatisticItem {
  st_cashflow = 0, st_pollution, st_crime, st_residential,
  st_commercial, st_industrial, st_tail
}
 the statistics structure. More...

enum  BuildCount {
  bc_count_residential = 0, bc_value_residential, bc_count_commercial, bc_value_commercial,
  bc_count_industrial, bc_value_industrial, bc_count_roads, bc_value_roads,
  bc_count_trees, bc_value_trees, bc_water, bc_coalplants,
  bc_nuclearplants, bc_powerlines, bc_waterpumps, bc_waterpipes,
  bc_waste , bc_fire, bc_fire_stations, bc_police_departments,
  bc_military_bases, bc_cashflow, bc_pollution, bc_crime,
  bc_count_rail, bc_value_rail, bc_tail
}
 elements for the BuildCount[] array More...

enum  Objects {
  obj_monster = 0, obj_dragon, obj_chopper, obj_plane,
  obj_ship, obj_train, obj_power, obj_water
}
 type of object More...

enum  DefenceUnitTypes
 The type of a defence unit.

enum  UpkeepEntries { ue_traffic = 0, ue_power, ue_defense, ue_tail }
 the entries in the upkeep array. More...


Functions

char * getMonthString (UInt16 month, Char *string, UInt16 length)
 Function to return the character string for a month (short).


Variables

stat_to_value statvalues []
 the statistic to value array


Detailed Description

the core set of definitions for the game.

This consists of all the important types and structures that are needed to make the game function correctly.

Definition in file zakdef.h.


Define Documentation

#define AddGridUpdate      (GG.gridsToUpdate |= (T))
 

add a grid to be updated

Parameters:
T  the grid to add

Definition at line 195 of file zakdef.h.

Referenced by Build_Destroy(), BuildSomething(), forceRedistribute(), InitGameStruct(), and PostLoadGame().

#define ClearUpdate      (GG.gridsToUpdate &= (UInt8)(~(UInt8)(T)))
 

Clear the need to update a sertain grid.

Parameters:
T  the grid to clear

Definition at line 206 of file zakdef.h.

Referenced by Sim_Distribute_Specific(), and Sim_DoPhase().

#define NeedsUpdate      (GG.gridsToUpdate & (T))
 

Check if a grid need updating.

Parameters:
T  the grid to check
Returns:
whether the grid need updating

Definition at line 201 of file zakdef.h.

Referenced by Sim_DoPhase().

#define NUM_OF_OBJECTS   10
 

the number of objects that may be on the screen at a time.

Currently defined as a fixed count, if you exceed this value then it will cause an overflow of an array in the savegame structure

Definition at line 120 of file zakdef.h.

Referenced by DrawFieldWithoutInit(), LoadGameByIndex(), and MoveAllObjects().

#define NUM_OF_UNITS   10
 

the number of defence units that may be on the screen at a time.

Currently defined as a fixed count, if you exceed this value then it will cause an overflow of an array in the savegame structure

Definition at line 132 of file zakdef.h.

Referenced by Build_Defence(), ContainsDefence(), DrawFieldWithoutInit(), LoadGameByIndex(), RemoveAllDefence(), and RemoveDefence().

 
#define RestoreSpeed  
 

Value:

{ \
        GG.gameLoopSeconds = vgame.oldLoopSeconds; \
}
restore the saved game speed

Definition at line 223 of file zakdef.h.

 
#define SaveSpeed  
 

Value:

{ \
        vgame.oldLoopSeconds = GG.gameLoopSeconds; \
        GG.gameLoopSeconds = SPEED_PAUSED; \
}
save the current speed, and change the speed to paused

Definition at line 217 of file zakdef.h.

#define setMapVariables X,
 
 

Value:

{ \
        GG.mapx = X; \
        GG.mapy = Y; \
        vgame.mapmul = (UInt16)GG.mapx * GG.mapy; \
}
set the map variables for the vgame structure

Parameters:
X  the size on the X axis
Y  the size on the Y axis

Definition at line 179 of file zakdef.h.

Referenced by PostLoadGame(), and setMapSize().

#define WORLDPOS x,
     ((x) + (y) * (getMapWidth()))
 

get the position of a map location in the world array

Parameters:
x  the x position
y  the y position
Returns:
the position in the array

Definition at line 214 of file zakdef.h.

Referenced by Build_Bulldoze(), Build_Destroy(), Build_Generic(), Build_Generic4(), Build_PowerLine(), Build_Rail(), Build_Road(), Build_WaterPipe(), BuildSomething(), BurnField(), CreateDragon(), CreateForest(), CreateFullRiver(), CreateMeteor(), CreateMonster(), CreateWaste(), DrawFieldWithoutInit(), GetZoneScore(), hoverUpdate(), RenderMaps(), UIDrawPlayArea(), and UpdateDisasters().


Typedef Documentation

typedef struct _appConfig_01 appConfig_01_t
 

appliation configuration.

This contains configuration information for an application; not for an individual game.

typedef struct _game_struct06a GameStruct06
 

the central game structure.

This is the central game struct only one of this exists at a time and is called 'game'. This entire struct will be saved between games.

Anything with an underscore will be removed later on.

typedef struct _history stat_item
 

the structure containing graphical history

the entries are logarithmically scaled. We have: 4 entries per year for the first 10 years Then we have: 4 entries per decade for the next 100 years

typedef struct _vgame_struct vGameStruct
 

volatile game structure

Items that are needed during the execution of the game, but not needed for persistence.


Enumeration Type Documentation

enum BuildCount
 

elements for the BuildCount[] array

Enumeration values:
bc_count_residential  count of residential areas
bc_value_residential  values of residential units
bc_count_commercial  count of the commercial units
bc_value_commercial  value of commercial units
bc_count_industrial  count of industrial units
bc_value_industrial  value of industrial units
bc_count_roads  count of roads
bc_value_roads  value of roads
bc_count_trees  count of trees/forests/parks
bc_value_trees  value of trees/forests/parks (unnatural)
bc_water  count of water (unnatural)
bc_coalplants  count of coal power plants
bc_nuclearplants  count of nuclear power plants
bc_powerlines  count of power lines
bc_waterpumps  count of water pumps
bc_waterpipes  count of water pipes
bc_waste  count of wasteland zones
bc_fire  count of fire elements
bc_fire_stations  count of fire stations
bc_police_departments  count of police stations
bc_military_bases  count of military bases
bc_cashflow  cashflow value
bc_pollution  pollution valuation
bc_crime  Criminal level
bc_count_rail  Count of rail zones
bc_value_rail  Value of rail zones
bc_tail  tail ender

Definition at line 351 of file zakdef.h.

Referenced by RecordStatistics().

enum dirType
 

directions for checking power distribution routines

Enumeration values:
dtUp  Up
dtRight  right
dtDown  down
dtLeft  left

Definition at line 299 of file zakdef.h.

Referenced by DistributeMoveOn(), MoveCursor(), ScrollDisplay(), and UIScrollDisplay().

enum disaster_t
 

the possible errors/warnings.

Make sure they don't intersect as the overlap in the warning dialogs.

Enumeration values:
diSTART  starting disaster guard
diFireOutbreak  a fire disaster
diPlantExplosion  a power plant explosion
diMonster  a monster
diDragon  a dragon
diMeteor  a meteor
diEND  ending guard for disasters

Definition at line 262 of file zakdef.h.

Referenced by DoSpecificDisaster().

enum Objects
 

type of object

Enumeration values:
obj_monster  'zilla
obj_dragon  Fire dragon
obj_chopper  Helicopter
obj_plane  Aeroplane
obj_ship  a boat to wander up & down the river
obj_train  a train
obj_power  the invisible power-supply fairy
obj_water  The invisible water-supply fairy

Definition at line 391 of file zakdef.h.

enum problem_t
 

Enumeration values:
peSTART  starting guard for errors
peFineOnMoney  money status is OK
peLowOnMoney  low on money
peOutOfMoney  out of money
peFineOnPower  power is OK
peLowOnPower  running low on power
peOutOfPower  power consumption > power supply
peFineOnWater  water is OK
peLowOnWater  running low on water
peOutOfWater  running out of water
peEND  ending guard for errors

Definition at line 276 of file zakdef.h.

Referenced by UIProblemNotify().

enum StatisticItem
 

the statistics structure.

This is used by the simulation to record the varoius values for use in the graph screen.

The items are obtained using the buildcount array, so we need a mapping of the items in the build count array to the entries in the statistics array

Enumeration values:
st_cashflow  History information about cashflow
st_pollution  History information about pollution
st_crime  History information about crime
st_residential  Histroy information about residential averages
st_commercial  History information about commercial values
st_industrial  History information about industrial values
st_tail  tail ender, for allocating the array

Definition at line 323 of file zakdef.h.

Referenced by RecordStatistics().

enum syserror_t
 

Enumeration values:
seOutOfMemory  out of memory error

Definition at line 272 of file zakdef.h.

enum UpkeepEntries
 

the entries in the upkeep array.

If you add something here you will have to add it to the savegame structure so it will require revving up the savegame version.

Enumeration values:
ue_traffic  Upkeep percentage entry for the traffic
ue_power  Upkeep percentage entry for the power
ue_defense  Upkeep percentage entry for the defence
ue_tail  Tail ender, for allocating the array in game structure

Definition at line 423 of file zakdef.h.

enum zoneType
 

zone identification for scoring

Enumeration values:
ztWhat  Unknown Zone
ztCommercial  Commercial Zone - connivant
ztResidential  Residential Zone
ztIndustrial  Industrial Zone

Definition at line 291 of file zakdef.h.

Referenced by GetScoreFor(), GetZoneScore(), and IsZone().


Function Documentation

char* getMonthString UInt16    month,
Char   string,
UInt16    length
 

Function to return the character string for a month (short).

Uses strftime to get the brief month name for a specific month.

Parameters:
month  the zero offset month (0 = jan)
string  the string that filled in with the month
length  the maximum length of the month
Returns:
the string passed (useful for printf; etc.)

Definition at line 18 of file pglobals.c.

References Char, and UInt16.

Referenced by getDate().


Variable Documentation

stat_to_value statvalues[]  
 

the statistic to value array

this is used to produce the graphs. As all the values in the BuildCount array are 32bit values and all the statistic items are 16 bit values an amount of shifting is done to the build count value once it exceeds the maximum 16bit value

Definition at line 493 of file zakdef.h.


Generated on Mon Aug 30 19:44:18 2004 for pocketcity by doxygen1.2.18