soesrame::SRAMFile Class Reference

#include <sramfile.hh>

List of all members.


Detailed Description

Definition at line 168 of file sramfile.hh.

Public Member Functions

 SRAMFile (const QString &filename) throw (InvalidSRAMFileException)
 Creates a new SRAMFile.
bool save (const QString &filename)
 Saves this SRAMFile back to disk.
bool hasAlchemy (enum sf_alchemy alchemy) const
 Checks whether the boy knows a particular alchemy.
void setAlchemy (enum sf_alchemy alchemy, bool have=true)
 Sets whether the boy knows a particular alchemy.
std::pair< int, int > getAlchemyLevel (enum sf_alchemy alchemy) const
 Gets the alchemy level.
void setAlchemyLevel (enum sf_alchemy alchemy, std::pair< int, int > level)
 Sets the alchemy level.
std::pair< int, int > getAttackLevel () const
 Gets the dog's attack level.
void setAttackLevel (std::pair< int, int > level)
 Sets the dog's attack level.
bool hasCharm (enum sf_charm charm) const
 Checks whether the heros have a particular charm.
void setCharm (enum sf_charm charm, bool have=true)
 Sets whether the heros have a particular charm.
quint16 getCurrentHP (enum sf_hero hero) const
 Gets the current HP of one of the heros.
void setCurrentHP (enum sf_hero hero, quint16 hp)
 Sets the current HP of one of the heros.
quint32 getExperience (enum sf_hero hero) const
 Gets the experience of one of the heros.
void setExperience (enum sf_hero hero, quint32 experience)
 Sets the experience of one of the heros.
int getGame () const
 Gets the current game.
void setGame (int game=0)
 Sets the current game.
int getIngredient (enum sf_ingredient ingredient) const
 Gets the inventory count for a particular alchemy ingredient.
void setIngredient (enum sf_ingredient ingredient, int count)
 Sets the inventory count for a particular alchemy ingredient.
int getItem (enum sf_item item) const
 Gets the inventory count for a particular item.
void setItem (enum sf_item item, int count)
 Sets the inventory count for a particular item.
int getLevel (enum sf_hero hero) const
 Gets the level of one of the heros.
void setLevel (enum sf_hero hero, int level)
 Sets the level of one of the heros.
quint16 getMaxHP (enum sf_hero hero) const
 Gets the max HP of one of the heros.
void setMaxHP (enum sf_hero hero, quint16 hp)
 Sets the max HP of one of the heros.
bool isModified () const
 Checks whether this SRAMFile has been modified.
quint32 getMoney (enum sf_money money) const
 Gets the money count.
void setMoney (enum sf_money money, quint32 count)
 Sets the money count.
QString getName (enum sf_hero hero) const
 Gets the name of one of the heros.
void setName (enum sf_hero hero, const QString &name)
 Sets the name of one of the heros.
quint16 getTradeGood (enum sf_tradegood tradegood) const
 Gets the inventory count for one of the trade goods.
void setTradeGood (enum sf_tradegood tradegood, quint16 count)
 Sets the inventory count for one of the trade goods.
bool hasWeapon (enum sf_weapon weapon) const
 Checks whether the boy has a particular weapon.
void setWeapon (enum sf_weapon weapon, bool have=true)
 Sets whether the boy has a particular weapon.
std::pair< int, int > getWeaponLevel (enum sf_weapon weapon) const
 Gets the weapon level for one of the weapons.
void setWeaponLevel (enum sf_weapon weapon, std::pair< int, int > level)
 Sets the weapon level for one of the weapons.
bool isValid (int game) const
 Checks if a save game is a valid save.

Private Member Functions

quint16 checksum (int game) const
 Calculates the checksum for one of the save games.
quint16 getChecksum (int game) const
 Gets the checksum value.
void setChecksum (int game, quint16 checksum)
 Sets the game's checksum value.

Private Attributes

int game
unsigned char * offset
unsigned char sram [SRAM_FILE_SIZE]
bool modified
bool valid [4]

Static Private Attributes

static const std::pair< int,
int > 
SRAM_ALCHEMY_OFFSETS []
 the alchemy have/have not offsets
static const std::pair< int,
int > 
SRAM_CHARM_OFFSETS []
 the charm have/have not offsets
static const std::pair< int,
int > 
SRAM_WEAPON_OFFSETS []
 the weapon have/have not offsets


Constructor & Destructor Documentation

SRAMFile::SRAMFile ( const QString &  filename  )  throw (InvalidSRAMFileException)

Creates a new SRAMFile.

Parameters:
filename The SRAM file to load.
Exceptions:
InvalidSRAMFileException if the file is not a valid Secret of Evermore SRAM file.

Definition at line 117 of file sramfile.cc.


Member Function Documentation

quint16 SRAMFile::checksum ( int  game  )  const [private]

Calculates the checksum for one of the save games.

Parameters:
game The game to calculate the checksum for.
Returns:
The checksum.

Definition at line 151 of file sramfile.cc.

std::pair< int, int > SRAMFile::getAlchemyLevel ( enum sf_alchemy  alchemy  )  const

Gets the alchemy level.

Parameters:
alchemy The alchemy.
Returns:
The level.

Definition at line 217 of file sramfile.cc.

std::pair< int, int > SRAMFile::getAttackLevel (  )  const

Gets the dog's attack level.

Returns:
The attack level (major, progress to next).

Definition at line 237 of file sramfile.cc.

quint16 SRAMFile::getChecksum ( int  game  )  const [private]

Gets the checksum value.

Parameters:
game The game to get the checksum for.
Returns:
The checksum.

Definition at line 277 of file sramfile.cc.

quint16 SRAMFile::getCurrentHP ( enum sf_hero  hero  )  const

Gets the current HP of one of the heros.

Parameters:
hero Which hero's current HP to get.
Returns:
The hero's current HP.

Definition at line 294 of file sramfile.cc.

quint32 SRAMFile::getExperience ( enum sf_hero  hero  )  const

Gets the experience of one of the heros.

Parameters:
hero Which hero's experience to get.
Returns:
The hero's experience.

Definition at line 319 of file sramfile.cc.

int soesrame::SRAMFile::getGame (  )  const [inline]

Gets the current game.

Returns:
The game.

Definition at line 514 of file sramfile.hh.

int SRAMFile::getIngredient ( enum sf_ingredient  ingredient  )  const

Gets the inventory count for a particular alchemy ingredient.

Parameters:
ingredient The ingredient.
Returns:
The inventory count.

Definition at line 353 of file sramfile.cc.

int SRAMFile::getItem ( enum sf_item  item  )  const

Gets the inventory count for a particular item.

Parameters:
item The item.
Returns:
The inventory count.

Definition at line 367 of file sramfile.cc.

int SRAMFile::getLevel ( enum sf_hero  hero  )  const

Gets the level of one of the heros.

Parameters:
hero Which hero's level to get.
Returns:
The hero's level.

Definition at line 381 of file sramfile.cc.

quint16 SRAMFile::getMaxHP ( enum sf_hero  hero  )  const

Gets the max HP of one of the heros.

Parameters:
hero Which hero's max HP to get.
Returns:
The hero's max HP.

Definition at line 399 of file sramfile.cc.

quint32 SRAMFile::getMoney ( enum sf_money  money  )  const

Gets the money count.

Parameters:
money The money type.
Returns:
The money count.

Definition at line 424 of file sramfile.cc.

QString SRAMFile::getName ( enum sf_hero  hero  )  const

Gets the name of one of the heros.

Parameters:
hero Which hero's name to get.
Returns:
The name.

Definition at line 447 of file sramfile.cc.

quint16 SRAMFile::getTradeGood ( enum sf_tradegood  tradegood  )  const

Gets the inventory count for one of the trade goods.

Parameters:
tradegood The trade good.
Returns:
The inventory count.

Definition at line 472 of file sramfile.cc.

std::pair< int, int > SRAMFile::getWeaponLevel ( enum sf_weapon  weapon  )  const

Gets the weapon level for one of the weapons.

Parameters:
weapon The weapon.
Returns:
The weapon level (major level, progress to next).

Definition at line 513 of file sramfile.cc.

bool SRAMFile::hasAlchemy ( enum sf_alchemy  alchemy  )  const

Checks whether the boy knows a particular alchemy.

Parameters:
alchemy The alchemy to check for.
Returns:
true if the boy knows the alchemy; false otherwise.

Definition at line 196 of file sramfile.cc.

bool SRAMFile::hasCharm ( enum sf_charm  charm  )  const

Checks whether the heros have a particular charm.

Parameters:
charm The charm to check for.
Returns:
true if they have the charm; false otherwise.

Definition at line 256 of file sramfile.cc.

bool SRAMFile::hasWeapon ( enum sf_weapon  weapon  )  const

Checks whether the boy has a particular weapon.

Parameters:
weapon The weapon to check for.
Returns:
true if the boy has the weapon; false otherwise.

Definition at line 492 of file sramfile.cc.

bool soesrame::SRAMFile::isModified (  )  const [inline]

Checks whether this SRAMFile has been modified.

Returns:
true if modified; false otherwise.

Definition at line 517 of file sramfile.hh.

bool soesrame::SRAMFile::isValid ( int  game  )  const [inline]

Checks if a save game is a valid save.

Parameters:
game The game to check (0-3).
Returns:
true if the game is valid; false otherwise.

Definition at line 520 of file sramfile.hh.

bool SRAMFile::save ( const QString &  filename  ) 

Saves this SRAMFile back to disk.

Parameters:
filename The filename to save to.
Returns:
true on success; false otherwise.

Definition at line 170 of file sramfile.cc.

void SRAMFile::setAlchemy ( enum sf_alchemy  alchemy,
bool  have = true 
)

Sets whether the boy knows a particular alchemy.

Parameters:
alchemy The alchemy to set.
have true to give; false to take away.

Definition at line 203 of file sramfile.cc.

void SRAMFile::setAlchemyLevel ( enum sf_alchemy  alchemy,
std::pair< int, int >  level 
)

Sets the alchemy level.

Parameters:
alchemy The alchemy.
level The new level.

Definition at line 225 of file sramfile.cc.

void SRAMFile::setAttackLevel ( std::pair< int, int >  level  ) 

Sets the dog's attack level.

Parameters:
level The new level.

Definition at line 245 of file sramfile.cc.

void SRAMFile::setCharm ( enum sf_charm  charm,
bool  have = true 
)

Sets whether the heros have a particular charm.

Parameters:
charm The charm to set.
have true to give; false to take away.

Definition at line 263 of file sramfile.cc.

void SRAMFile::setChecksum ( int  game,
quint16  checksum 
) [private]

Sets the game's checksum value.

Parameters:
game The game to set the checksum for.
checksum The new checksum.

Definition at line 286 of file sramfile.cc.

void SRAMFile::setCurrentHP ( enum sf_hero  hero,
quint16  hp 
)

Sets the current HP of one of the heros.

Parameters:
hero Which hero to set.
hp The new current HP.

Definition at line 306 of file sramfile.cc.

void SRAMFile::setExperience ( enum sf_hero  hero,
quint32  experience 
)

Sets the experience of one of the heros.

Parameters:
hero Which hero to set.
experience The new experience.

Definition at line 331 of file sramfile.cc.

void SRAMFile::setGame ( int  game = 0  ) 

Sets the current game.

Parameters:
game The new game.

Definition at line 346 of file sramfile.cc.

void SRAMFile::setIngredient ( enum sf_ingredient  ingredient,
int  count 
)

Sets the inventory count for a particular alchemy ingredient.

Parameters:
ingredient The ingredient.
count The new inventory count.

Definition at line 359 of file sramfile.cc.

void SRAMFile::setItem ( enum sf_item  item,
int  count 
)

Sets the inventory count for a particular item.

Parameters:
item The item.
count The new inventory count.

Definition at line 373 of file sramfile.cc.

void SRAMFile::setLevel ( enum sf_hero  hero,
int  level 
)

Sets the level of one of the heros.

Parameters:
hero Which hero's level to set.
level The new level.

Definition at line 389 of file sramfile.cc.

void SRAMFile::setMaxHP ( enum sf_hero  hero,
quint16  hp 
)

Sets the max HP of one of the heros.

Parameters:
hero Which heros' max HP to set.
hp The new max HP.

Definition at line 411 of file sramfile.cc.

void SRAMFile::setMoney ( enum sf_money  money,
quint32  count 
)

Sets the money count.

Parameters:
money The money type.
count The new money count.

Definition at line 434 of file sramfile.cc.

void SRAMFile::setName ( enum sf_hero  hero,
const QString &  name 
)

Sets the name of one of the heros.

Parameters:
hero Which hero's name to set.
name The new name.

Definition at line 459 of file sramfile.cc.

void SRAMFile::setTradeGood ( enum sf_tradegood  tradegood,
quint16  count 
)

Sets the inventory count for one of the trade goods.

Parameters:
tradegood The trade good.
count The new inventory count.

Definition at line 481 of file sramfile.cc.

void SRAMFile::setWeapon ( enum sf_weapon  weapon,
bool  have = true 
)

Sets whether the boy has a particular weapon.

Parameters:
weapon The weapon to set.
have true to give; false to take away.

Definition at line 499 of file sramfile.cc.

void SRAMFile::setWeaponLevel ( enum sf_weapon  weapon,
std::pair< int, int >  level 
)

Sets the weapon level for one of the weapons.

Parameters:
weapon The weapon.
level The new level.

Definition at line 523 of file sramfile.cc.


Member Data Documentation

int soesrame::SRAMFile::game [private]

Definition at line 170 of file sramfile.hh.

bool soesrame::SRAMFile::modified [private]

Definition at line 173 of file sramfile.hh.

unsigned char* soesrame::SRAMFile::offset [private]

Definition at line 171 of file sramfile.hh.

unsigned char soesrame::SRAMFile::sram[SRAM_FILE_SIZE] [private]

Definition at line 172 of file sramfile.hh.

const std::pair< int, int > SRAMFile::SRAM_ALCHEMY_OFFSETS [static, private]

the alchemy have/have not offsets

Definition at line 176 of file sramfile.hh.

const std::pair< int, int > SRAMFile::SRAM_CHARM_OFFSETS [static, private]

Initial value:

    {
        std::pair<int, int>(0x200, 0x20),   
        std::pair<int, int>(0x200, 0x40),   
        std::pair<int, int>(0x200, 0x80),   
        
        std::pair<int, int>(0x201, 0x01),   
        std::pair<int, int>(0x201, 0x02),   
        std::pair<int, int>(0x201, 0x04),   
        std::pair<int, int>(0x201, 0x08),   
        std::pair<int, int>(0x201, 0x10),   
        std::pair<int, int>(0x201, 0x20),   
        std::pair<int, int>(0x201, 0x40),   
        std::pair<int, int>(0x201, 0x80),   
        
        std::pair<int, int>(0x202, 0x01),   
        std::pair<int, int>(0x202, 0x02),   
        std::pair<int, int>(0x202, 0x04)    
    }
the charm have/have not offsets

Definition at line 179 of file sramfile.hh.

const std::pair< int, int > SRAMFile::SRAM_WEAPON_OFFSETS [static, private]

Initial value:

    {
        std::pair<int, int>(0x279, 0x02),  
        std::pair<int, int>(0x279, 0x04),  
        std::pair<int, int>(0x279, 0x08),  
        std::pair<int, int>(0x279, 0x10),  
        
        std::pair<int, int>(0x279, 0x20),  
        std::pair<int, int>(0x279, 0x40),  
        std::pair<int, int>(0x279, 0x80),  
        std::pair<int, int>(0x27A, 0x01),  
        
        std::pair<int, int>(0x27A, 0x02),  
        std::pair<int, int>(0x27A, 0x04),  
        std::pair<int, int>(0x27A, 0x08),  
        std::pair<int, int>(0x27A, 0x10),  
        
        std::pair<int, int>(0x27A, 0x20)   
    }
the weapon have/have not offsets

Definition at line 182 of file sramfile.hh.

bool soesrame::SRAMFile::valid[4] [private]

Definition at line 173 of file sramfile.hh.


Generated on Wed Sep 6 23:11:56 2006 for Secret of Evermore SRAM Editor by  doxygen 1.4.7