Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

palm/savegame_be.c File Reference

This file handles savegame back end. More...

#include <PalmOS.h>
#include <StringMgr.h>
#include <Form.h>
#include <stddef.h>
#include <zakdef.h>
#include <simcity.h>
#include <globals.h>
#include <handler.h>
#include <locking.h>
#include <logging.h>
#include <palmutils.h>
#include <simcity_resconsts.h>
#include <resCompat.h>
#include <savegame_be.h>
#include <mem_compat.h>
#include <pack.h>
#include <beam.h>

Go to the source code of this file.

Functions

int ReadCityRecord (MemHandle rec, GameStruct *gs, MemPtr *wp, MemPtr *fp) SAVE_SECTION
 Read the city record.

void WriteCityRecord (MemHandle rec, GameStruct *gs, MemPtr wp, MemPtr fp) SAVE_SECTION
 Write the city record.

int SaveGameByIndex (UInt16 index) SAVE_SECTION
 Save a game into the database of savegames.

int LoadGameByIndex (UInt16 index) SAVE_SECTION
 Load a game by index from the savegames.

void getAutoSaveName (char *name) SAVE_SECTION
 Get the name of the autosave city.

void DeleteGameByIndex (UInt16 index) SAVE_SECTION
 Delete the savegame from the list of savegames.

Int16 comparator (void *p1, void *p2, Int32 other) SAVE_SECTION
 comparison function for CityNames list

DmOpenRef OpenMyDB (void)
 Open up the savegame database.

void CloseMyDB (void)
 close the savegame database

UInt16 FindGameByName (char *name)
 Find a savegame by the name passed.

void ResetViewable (void)
 set the tile size

int GameExists (char *name)
 Check if a saved city by this name exists.

void SaveGameByName (char *name)
 save the city that is currently being used by the name passed

int LoadGameByName (char *name)
 Load a game by name.

Int32 BeamCityByName (Char *cityName)
 beam the city named

int LoadAutoSave (void)
 Load the autosave city.

void SetAutoSave (char *name)
 set the autosave name

void DeleteAutoSave (void)
 Clear the autosave name.

void DeleteGameByName (char *name)
 Delete a city from the DB by name.

int RenameCity (char *oldname, char *newname)
 rename a city

char ** CityNames (int *count)
 Get The City Names.

void FreeCityNames (char **names)
 release the list of city names returned using cityNames


Detailed Description

This file handles savegame back end.

Definition in file savegame_be.c.


Function Documentation

Int32 BeamCityByName Char   cityName
 

beam the city named

Parameters:
cityName  the name of the city to beam
Returns:
-1 if the city could not be beamed

Definition at line 354 of file savegame_be.c.

References BeamSend(), Char, FindGameByName(), Int32, OpenMyDB(), UInt16, and UInt8.

char** CityNames int *    count
 

Get The City Names.

Parameters:
count  the count returned
Returns:
a NULL terminated array of the city names

Definition at line 592 of file savegame_be.c.

References CITYNAMELEN, comparator(), OpenMyDB(), and UInt16.

Referenced by UpdateSaveGameList().

void CloseMyDB void   
 

close the savegame database

This will close the savegame database if it is open, otherwise it will do nothing. Needed for the game shutdown routine

Definition at line 79 of file savegame_be.c.

Referenced by BeamReceive().

Int16 comparator void *    p1,
void *    p2,
Int32    other
[static]
 

comparison function for CityNames list

Parameters:
p1  left side
p2  right side
other  a useless variable
Returns:
-1 (before), 0 (equals), 1 (greater)

Definition at line 586 of file savegame_be.c.

References Int32.

Referenced by CityNames().

void DeleteGameByIndex UInt16    index [static]
 

Delete the savegame from the list of savegames.

Parameters:
index  the index into the savegames
This will also compact the database of savegames. i.e. when the savegame is deleted it is removed completely.

Definition at line 472 of file savegame_be.c.

References OpenMyDB(), and UInt16.

Referenced by DeleteGameByName().

void DeleteGameByName char *    name
 

Delete a city from the DB by name.

Parameters:
name  the name of the city to delete

Definition at line 489 of file savegame_be.c.

References DeleteGameByIndex(), FindGameByName(), and UInt16.

Referenced by DeleteFromList().

UInt16 FindGameByName char *    name
 

Find a savegame by the name passed.

Parameters:
name  the name of the city
Returns:
the index, or LASTGAME if it's not there.

Definition at line 88 of file savegame_be.c.

References Char, _game_struct06a::cityname, OpenMyDB(), and UInt16.

Referenced by BeamCityByName(), BeamReceive(), DeleteGameByName(), GameExists(), LoadGameByName(), and SaveGameByName().

void FreeCityNames char **    names
 

release the list of city names returned using cityNames

Parameters:
names  the names of the cities

Definition at line 639 of file savegame_be.c.

Referenced by CleanSaveGameList(), and UpdateSaveGameList().

int GameExists char *    name
 

Check if a saved city by this name exists.

Parameters:
name  the name of the city
Returns:
true if game exists

Definition at line 256 of file savegame_be.c.

References FindGameByName().

Referenced by cnCreateButtonPressed().

void getAutoSaveName char *    name [static]
 

Get the name of the autosave city.

Parameters:
name  the name of the city (fills out string, must be big enough)

Definition at line 386 of file savegame_be.c.

References CITYNAMELEN, and OpenMyDB().

Referenced by LoadAutoSave().

int LoadGameByIndex UInt16    index [static]
 

Load a game by index from the savegames.

Parameters:
index  index of game to load
Returns:
0 if loaded, -1 otherwise

Definition at line 309 of file savegame_be.c.

References LockZone(), lz_flags, lz_world, NUM_OF_OBJECTS, NUM_OF_UNITS, OpenMyDB(), PostLoadGame(), ReadCityRecord(), ResetViewable(), UInt16, and UnlockZone().

Referenced by LoadAutoSave(), and LoadGameByName().

int LoadGameByName char *    name
 

Load a game by name.

Parameters:
name  the name of the city
Returns:
0 if the city was loaded, -1 otherwise

Definition at line 343 of file savegame_be.c.

References FindGameByName(), LoadGameByIndex(), and UInt16.

Referenced by cnCreateButtonPressed(), LoadAutoSave(), and LoadFromList().

DmOpenRef OpenMyDB void   
 

Open up the savegame database.

Returns:
reference to the database or NULL.
If it does not exist, then it tries to create it.

Definition at line 40 of file savegame_be.c.

References Char, CITYNAMELEN, GetCreatorID(), and UInt16.

Referenced by BeamCityByName(), BeamReceive(), CityNames(), DeleteGameByIndex(), FindGameByName(), getAutoSaveName(), LoadGameByIndex(), RenameCity(), SaveGameByIndex(), and SetAutoSave().

int ReadCityRecord MemHandle    rec,
GameStruct   gs,
MemPtr *    wp,
MemPtr *    fp
[static]
 

Read the city record.

Parameters:
rec  the record to read
gs  the game structure
wp  the pointer to the world (resized in call)
fp  the world field pointer to be replaced on write
Returns:
0 if it all went well, -1 otherwise.

Definition at line 154 of file savegame_be.c.

References Int32, _game_struct06a::mapx, _game_struct06a::mapy, SAVEGAMEVERSION, UInt32, and UnpackBits().

Referenced by LoadGameByIndex().

int RenameCity char *    oldname,
char *    newname
 

rename a city

Parameters:
oldname  the old name of the city
newname  the new name of the city
Returns:
-1 if database could not be fount, 0 if not changes, 1 otherwise

Definition at line 498 of file savegame_be.c.

References Char, _game_struct06a::cityname, OpenMyDB(), and UInt16.

void ResetViewable void   
 

set the tile size

We set the tile size (16 pels). We reserve 2 tiles (one at the top, one at the bottom) for use with status information.

Definition at line 128 of file savegame_be.c.

References UInt16.

Referenced by LoadGameByIndex(), and main().

int SaveGameByIndex UInt16    index [static]
 

Save a game into the database of savegames.

Parameters:
index  the index to save game into
Returns:
0 if saved OK, -1 otherwise

Definition at line 220 of file savegame_be.c.

References LockZone(), lz_flags, lz_world, OpenMyDB(), UInt16, UnlockZone(), and WriteCityRecord().

Referenced by SaveGameByName().

void SaveGameByName char *    name
 

save the city that is currently being used by the name passed

Parameters:
name  the name of the city

Definition at line 262 of file savegame_be.c.

References FindGameByName(), SaveGameByIndex(), and UInt16.

Referenced by cnCreateButtonPressed(), and UISaveMyCity().

void SetAutoSave char *    name
 

set the autosave name

Parameters:
name  the name for the auto save game

Definition at line 423 of file savegame_be.c.

References CITYNAMELEN, and OpenMyDB().

Referenced by BeamReceive(), DeleteAutoSave(), and UISaveAutoGame().

void WriteCityRecord MemHandle    rec,
GameStruct   gs,
MemPtr    wp,
MemPtr    fp
[static]
 

Write the city record.

Parameters:
rec  the record to write to
gs  the game structure
wp  the world pointer
fp  the flags pointer

Definition at line 194 of file savegame_be.c.

References _game_struct06a::mapx, _game_struct06a::mapy, PackBits(), and UInt32.

Referenced by SaveGameByIndex().


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