Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

source/globals.h File Reference

interface to the global routines More...

#include <zakdef.h>
#include <compilerpragmas.h>

Go to the source code of this file.

Defines

#define SETAUTOBULLDOZE(X)   setGameBit(sb_autobulldoze, (X))
#define GETAUTOBULLDOZE()   getGameBit(sb_autobulldoze)
#define SETMINIMAPVISIBLE(X)   setGameBit(sb_showminimap, (X))
#define GETMINIMAPVISIBLE()   getGameBit(sb_showminimap)
#define SETMINIMAPDETAILED(X)   setGameBit(sb_detailedminimap, (X))
#define GETMINIMAPDETAILED()   getGameBit(sb_detailedminimap)

Enumerations

enum  graphicupdate_t {
  gu_playarea = (1), gu_credits = (1<<1), gu_population = (1<<2), gu_date = (1<<3),
  gu_location = (1<<4), gu_buildicon = (1<<5), gu_speed = (1<<6), gu_desires = (1<<7),
  gu_all = (1<<8)
}
 thye types of things that need a graphic update More...

enum  gamestatusbit_t { sb_autobulldoze = (1), sb_showminimap = (1<<1), sb_detailedminimap = (1<<2) }
 these fields are to control game options. More...


Functions

EXPORT char * getDate (char *temp)
 Get the date in the game.

EXPORT UInt32 scaleNumber (UInt32 old_value, Char *scale)
 scale a number down using the K,M,B scale

EXPORT void * getIndexOf (char *ary, Int16 addit, Int16 key)
 find a key in an array.

EXPORT UInt8 getDisasterLevel (void)
 Get the disaster level setting of the game.

EXPORT void setDisasterLevel (UInt8 value)
 Set The disaster Level of the game.

EXPORT UInt8 getDifficultyLevel (void)
 Get the difficulty level of the game.

EXPORT void setDifficultyLevel (UInt8 value)
 Set the difficulty level of the game.

EXPORT Int16 InitWorld (void)
 initialize the world variables

EXPORT Int16 ResizeWorld (UInt32 size)
 make the world of a certain size

EXPORT void PurgeWorld (void)
 free all the game related structures

EXPORT welem_t getWorld (UInt32 pos)
 get the item on the surface of the world

EXPORT void setWorld (UInt32 pos, welem_t value)
 set the object at the position to the value in question

EXPORT selem_t getWorldFlags (UInt32 pos)
 get the flag corresponding to the game location

EXPORT void setWorldFlags (UInt32 pos, selem_t value)
 set the flag corresponding to the game location

EXPORT void orWorldFlags (UInt32 pos, selem_t value)
 or the value with the current location of the map world flags

EXPORT void andWorldFlags (UInt32 pos, selem_t value)
 and the value with the current location of the map world flags

EXPORT void getWorldAndFlag (UInt32 pos, welem_t *world, selem_t *flag)
 get the values of the field and it's flag

EXPORT void setWorldAndFlag (UInt32 pos, welem_t value, selem_t status)
 set the world field and field flag

EXPORT void addGraphicUpdate (graphicupdate_t entity)
 add an item that needs updating in the display

EXPORT void removeGraphicUpdate (graphicupdate_t entity)
 remove and item that needs updating in the display

EXPORT UInt8 checkGraphicUpdate (graphicupdate_t entity)
 check that a graphic entity needs changing

EXPORT UInt8 checkAnyGraphicUpdate (void)
 check that any graphic item needs repainting

EXPORT void clearGraphicUpdate (void)
 clear the need update fields in their entirety

EXPORT void setGameBit (gamestatusbit_t bit, UInt8 value)
 set one of the savegame status bits

EXPORT UInt8 getGameBit (gamestatusbit_t bit)
 get one of the savegame status bits

EXPORT void PackBits (void *src, void *dest, UInt8 nbits, UInt32 count)
 pack from src->dest count of the nbits-lowest order bits

EXPORT void UnpackBits (void *src, void *dest, UInt8 nbits, UInt32 count)
 unpack from src->dest the number of bits into the count specified


Variables

GameStruct game
 this is the central game struct

vGameStruct vgame
 This is the volatile game structure (memoizing to reduce op/s).

vGameVisuals visuals
 the game 'visuals' - tilesize and the likes

AppConfig_t gameConfig
 This is the game configuration.

void * worldPtr
 the world pointer

void * flagPtr
 the flags pointer

void * growablePtr
 the growable pointer


Detailed Description

interface to the global routines

Definition in file globals.h.


Define Documentation

 
#define GETAUTOBULLDOZE      getGameBit(sb_autobulldoze)
 

get the Auto Bulldoze flag

Definition at line 53 of file globals.h.

Referenced by IsBulldozable(), and setupOptions().

 
#define GETMINIMAPDETAILED      getGameBit(sb_detailedminimap)
 

get if the minimap is supposed to be detailed

Definition at line 61 of file globals.h.

Referenced by setupOptions().

 
#define GETMINIMAPVISIBLE      getGameBit(sb_showminimap)
 

get if the minimap is visible

Definition at line 57 of file globals.h.

Referenced by CheckTextClick(), performPaintDisplay(), setupOptions(), UIPaintPlayArea(), and UIScrollDisplay().

#define SETAUTOBULLDOZE      setGameBit(sb_autobulldoze, (X))
 

set the Auto Bulldoze flag

Definition at line 51 of file globals.h.

Referenced by InitGameStruct(), and saveOptions().

#define SETMINIMAPDETAILED      setGameBit(sb_detailedminimap, (X))
 

set to show the minimap in a detailed form

Definition at line 59 of file globals.h.

Referenced by saveOptions().

#define SETMINIMAPVISIBLE      setGameBit(sb_showminimap, (X))
 

set if the minimap is visible

Definition at line 55 of file globals.h.

Referenced by saveOptions().


Enumeration Type Documentation

enum gamestatusbit_t
 

these fields are to control game options.

Enumeration values:
sb_autobulldoze  do we auto-bulldoze trees
sb_showminimap  do we show the minimap
sb_detailedminimap  is the minimap detailed

Definition at line 44 of file globals.h.

Referenced by getGameBit(), and setGameBit().

enum graphicupdate_t
 

thye types of things that need a graphic update

This list contains all the items that may need to be updated as a result of changes to the simulation state. It is inteded to defer the repainting of the screen until the end. By doing this we reduce the number of painting calls significantly; it only checks what needs to be done and performs it. By doing this we allow multi-threading of the simulation routine. It simply tags what needs to be painted and a separate drawing thread can take care of it.

This is a significant departure from previous implementations where we repainted the items at the direct request of the command.

Enumeration values:
gu_playarea  The play area needs updating
gu_credits  The credits value needs updating
gu_population  The population needs updating
gu_date  The date field needs updating
gu_location  The map location needs updating (minimap)
gu_buildicon  The build icon needs updating
gu_speed  The speed indicator needs updating
gu_desires  The desires of the city
gu_all  Everything needs painting

Definition at line 29 of file globals.h.

Referenced by addGraphicUpdate(), checkGraphicUpdate(), and removeGraphicUpdate().


Function Documentation

EXPORT void addGraphicUpdate graphicupdate_t    entity
 

add an item that needs updating in the display

Parameters:
entity  the entity to be updated.

Definition at line 74 of file globals.c.

References graphicupdate_t, gu_all, and needchange.

Referenced by doButtonEvent(), RedrawAllFields(), Sim_Distribute_Specific(), Sim_DoPhase(), and SpendMoney().

EXPORT void andWorldFlags UInt32    pos,
selem_t    value
 

and the value with the current location of the map world flags

Parameters:
pos  the position on the map
value  the value to and the current value with.

Definition at line 324 of file globals.c.

References flagPtr, MapMul, selem_t, and UInt32.

Referenced by DoDistribute().

EXPORT UInt8 checkAnyGraphicUpdate void   
 

check that any graphic item needs repainting

Returns:
true if any of the entities need repainting

Definition at line 108 of file globals.c.

References needchange.

EXPORT UInt8 checkGraphicUpdate graphicupdate_t    entity
 

check that a graphic entity needs changing

Parameters:
entity  the entity to check
Returns:
whether the entity needs changing

Definition at line 98 of file globals.c.

References graphicupdate_t, and needchange.

Referenced by performPaintDisplay().

EXPORT char* getDate char *    temp
 

Get the date in the game.

Todo:
deal with phenomenally big dates
Parameters:
temp  buffer to put date string into
Returns:
the temp buffer (silli!)

Definition at line 129 of file globals.c.

References getMonthsElapsed, getMonthString(), and UInt16.

Referenced by UIDrawDate(), and UIPaintDate().

EXPORT UInt8 getDifficultyLevel void   
 

Get the difficulty level of the game.

Returns:
the difficulty level

Definition at line 187 of file globals.c.

Referenced by ConfigureNewGame(), NewGame(), and setupOptions().

EXPORT UInt8 getDisasterLevel void   
 

Get the disaster level setting of the game.

Returns:
disaster level

Definition at line 166 of file globals.c.

Referenced by DoRandomDisaster(), and setupOptions().

EXPORT UInt8 getGameBit gamestatusbit_t    bit
 

get one of the savegame status bits

Parameters:
bit  the field to get the value of
Returns:
non-zero if the bit is set, zero otherwise

Definition at line 410 of file globals.c.

References gamestatusbit_t.

EXPORT void* getIndexOf char *    ary,
Int16    addit,
Int16    key
 

find a key in an array.

Array is an array of possibly structs with key as the first element

Parameters:
ary  the arry to look into
addit  amount ot add to get to next element in array
key  key to check against
Returns:
array item, or NULL

Definition at line 151 of file globals.c.

References Int16.

EXPORT welem_t getWorld UInt32    pos
 

get the item on the surface of the world

Parameters:
pos  the position in the world map to obtain
Returns:
the item at that position.

Definition at line 254 of file globals.c.

References MapMul, UInt32, welem_t, and worldPtr.

Referenced by Build_Bulldoze(), Build_Destroy(), Build_Generic(), Build_Generic4(), Build_PowerLine(), Build_Rail(), Build_Road(), Build_WaterPipe(), BurnField(), CheckNextTo1(), CreateDragon(), CreateForest(), CreateMeteor(), CreateMonster(), CreateWaste(), DistributeUnvisited(), DoCommitmentNasties(), DoDistribute(), DoNastyStuffTo(), DoRandomDisaster(), DowngradeZone(), ExistsNextto(), GetGraphicNumber(), GetRandomZone(), GetZoneScore(), RenderMaps(), UpdateDisasters(), and UpdateVolatiles().

EXPORT void getWorldAndFlag UInt32    pos,
welem_t   world,
selem_t   flag
 

get the values of the field and it's flag

Parameters:
pos  the location on the map to extract the value of
world  a pointer to fill with the value of the world field
flag  a pointer to fill with the value of the flag at that location

Definition at line 351 of file globals.c.

References flagPtr, MapMul, selem_t, UInt32, welem_t, and worldPtr.

Referenced by DrawFieldWithoutInit(), hoverUpdate(), and querySetup().

EXPORT selem_t getWorldFlags UInt32    pos
 

get the flag corresponding to the game location

Parameters:
pos  the position of the location
Returns:
the value at that position

Definition at line 298 of file globals.c.

References flagPtr, MapMul, selem_t, and UInt32.

Referenced by DistributeUnvisited(), DoDistribute(), GetZoneScore(), SetSupplied(), and UIDrawPlayArea().

EXPORT Int16 InitWorld void   
 

initialize the world variables

Returns:
1 if the allocation succeeded, 0 otherwise

Definition at line 243 of file globals.c.

Referenced by PCityMain().

EXPORT void orWorldFlags UInt32    pos,
selem_t    value
 

or the value with the current location of the map world flags

Parameters:
pos  the position on the map
value  the value to or the current value with.

Definition at line 337 of file globals.c.

References flagPtr, MapMul, selem_t, and UInt32.

Referenced by DrawFieldWithoutInit(), and SetSupplied().

EXPORT void PackBits void *    src,
void *    dest,
UInt8    nbits,
UInt32    count
 

pack from src->dest count of the nbits-lowest order bits

Parameters:
src  source memory
dest  destination memory
nbits  number of bits to pack
count  count of entries to pack

Definition at line 23 of file pack.c.

EXPORT void removeGraphicUpdate graphicupdate_t    entity
 

remove and item that needs updating in the display

Parameters:
entity  the entity that needs removal

Definition at line 87 of file globals.c.

References graphicupdate_t, and needchange.

EXPORT Int16 ResizeWorld UInt32    size
 

make the world of a certain size

This, naturally erases the current world map.

Parameters:
size  the new size of the world (x*y)
Returns:
0 if it all went pear shaped.

Definition at line 212 of file globals.c.

References flagPtr, gMemSet, Int32, LockZone(), lz_flags, lz_world, seOutOfMemory, UInt32, UnlockZone(), and worldPtr.

Referenced by setMapSize().

EXPORT UInt32 scaleNumber UInt32    old_value,
Char   scale
 

scale a number down using the K,M,B scale

Don't use the value returned for any math! it's for display only.

Parameters:
old_value  the value that needs to be scaled
scale  (out) the scale i.e. none, K, M, B ...
Returns:
the scaled value (could be the original value)

Definition at line 378 of file globals.c.

References Char, and UInt32.

Referenced by UIPaintCredits(), UIPaintPopulation(), and updateBudgetValue().

EXPORT void setDifficultyLevel UInt8    value
 

Set the difficulty level of the game.

Parameters:
value  the new difficulty level

Definition at line 197 of file globals.c.

References UInt8.

Referenced by cnCreateButtonPressed(), NewGame(), and saveOptions().

EXPORT void setDisasterLevel UInt8    value
 

Set The disaster Level of the game.

Parameters:
value  the new value of disaster level

Definition at line 176 of file globals.c.

References UInt8.

Referenced by cnCreateButtonPressed(), InitGameStruct(), NewGame(), and saveOptions().

EXPORT void setGameBit gamestatusbit_t    bit,
UInt8    value
 

set one of the savegame status bits

Parameters:
bit  the bit to set
value  the value of the new status bit
It sets the bit to 1 if value is non zero.

Definition at line 398 of file globals.c.

References gamestatusbit_t, and UInt8.

EXPORT void setWorld UInt32    pos,
welem_t    value
 

set the object at the position to the value in question

Parameters:
pos  the position of the item
value  the value of the item

Definition at line 268 of file globals.c.

References MapMul, UInt32, welem_t, and worldPtr.

Referenced by DowngradeZone().

EXPORT void setWorldAndFlag UInt32    pos,
welem_t    value,
selem_t    status
 

set the world field and field flag

Parameters:
pos  the position
value  the value
status  the status of this position

Definition at line 283 of file globals.c.

References flagPtr, MapMul, selem_t, UInt32, welem_t, and worldPtr.

Referenced by Build_Destroy(), Build_Generic(), Build_Generic4(), Build_PowerLine(), Build_Rail(), Build_Road(), Build_WaterPipe(), BurnField(), CreateForest(), CreateFullRiver(), CreateMeteor(), CreateWaste(), and UpdateDisasters().

EXPORT void setWorldFlags UInt32    pos,
selem_t    value
 

set the flag corresponding to the game location

Parameters:
pos  the position of the location
value  the value at that position

Definition at line 311 of file globals.c.

References flagPtr, MapMul, selem_t, and UInt32.

EXPORT void UnpackBits void *    src,
void *    dest,
UInt8    nbits,
UInt32    count
 

unpack from src->dest the number of bits into the count specified

Parameters:
src  source memory to unpack from
dest  dest memory to unpack into
nbits  number of bits in this element
count  number of elements
Process: shift the current value right by offset bits and and with the mask This works providing we have more bits left in the field than bits we want to shift by.

Definition at line 63 of file pack.c.


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