Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

source/globals.c File Reference

convenience routines More...

#include <config.h>
#include <zakdef.h>
#include <stdio.h>
#include <mem_compat.h>
#include <logging.h>
#include <locking.h>
#include <ui.h>
#include <stack.h>
#include <globals.h>

Go to the source code of this file.

Functions

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

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

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

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

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

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

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

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

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

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

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

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

Int16 InitWorld (void)
 initialize the world variables

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

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

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

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

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

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

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

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

void PurgeWorld (void)
 free all the game related structures

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

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

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


Variables

stat_to_value statvalues []
 the statistic to value array

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

void * worldPtr
 the world pointer

void * flagPtr
 the flags pointer

void * growablePtr
 the growable pointer

AppConfig_t gameConfig
 This is the game configuration.

UInt16 needchange
 the varaible used to record what elements of the world need change


Detailed Description

convenience routines

This contains routines for working on the difficulty, disaster level of the simulation, as well as displaying the date.

Definition in file globals.c.


Function Documentation

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().

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().

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.

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().

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().

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().

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().

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.

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.

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().

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().

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().

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().

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().

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.

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().

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().

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().

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().

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.

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().

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().

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.


Variable Documentation

AppConfig_t gameConfig
 

Initial value:

 {
        CONFIG_VERSION,
        DEFAULT_APPCONFIG
}
This is the game configuration.

Definition at line 61 of file globals.c.

stat_to_value statvalues[]
 

Initial value:

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 34 of file globals.c.


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