Author Topic: Savegame patch  (Read 19606 times)

jrepan

  • Guest
(No subject)
« Reply #25 on: 11 March 2008, 13:25:42 »
Quote from: "tux-gamer"
@jrepan@
Update bug info.
1.Segementation fault only happen when you play a few minute, and save the game, then load it.

2.Here screenshot when enemy and my archer , atacck to wrong place.

800x600

3.One more bug, all Guard command back to Stop command, so i must click Hold Position again after loading the saved games.


@daniel.santos@
Thanks alot, I'am downloading now.


ps: ia'm sory if my english is bad. :-[

Thanks for the feedback, but I think that there's no reason to fix them now, because saving is part of GAE. Anyway, I had fixed 2 before sending sources to daniel.santos and almost fixed 3(building and upgrading still don't work) after sending. If you want, I can send you newer binary where these 2 bugs are fixed.
« Last Edit: 1 January 1970, 00:00:00 by jrepan »

tux-gamer

  • Guest
(No subject)
« Reply #26 on: 12 March 2008, 02:59:27 »
thanks for the reply, yes now is part of GAE.
the first bug is fixed in GAE v0.1.4
2nd is not fixed yet.
3thrd is fixed in GAE v0.1.4 too
thanks again, i will waiting for GAE to fixed those bug.
« Last Edit: 1 January 1970, 00:00:00 by tux-gamer »

daniel.santos

  • Guest
(No subject)
« Reply #27 on: 12 March 2008, 12:35:40 »
I'm working out a bit of a technical documents for GAE is saving games as it changed some from jrepan's original design.  Also, I want to mention a few bugs.  Some of these are mentioned elsewhere, but this is just an exercise to compile them in one place.

GAE Saved Game Bug Summary
  • from looking at the code, effects are slightly broken when loading a saved game.  So if you are playing in FPM and your Lich is attacking something with withering despair when you save, then it'll probably crash when you reload.  In my working version, I've got this fixed, but it still have one deficiency; it isn't restoring the root cause for recourse effects.  I can't remember exactly what the impact of this is, but it may be very minor and behavior in nature (i.e., not a crash or memory leak)
  • Fog of war isn't saved (as mentioned before)
  • Crash if savegame directory doesn't exist and you try to load or save a game. (doesn't always crash on Linux)
  • Crash or weird behavior if there aren't any save games in savegames and you try to load.
  • Crash or confirmation dialog doesn't go away when you delete the last saved game from the load game menu.
  • units that were moving when saved do the "moon walk" very briefly when loaded.  I probably wont fix this as I think it's just an artifact of the engine morphing from one animation position to another and that previous state isn't there when loaded and it doesn't cause any problems.
  • long range attacks after restoring a saved game (I haven't confirmed this in recent version)
  • map resources aren't being saved (trees, gold, etc.)

I'm working on getting Bugzilla setup on my server so we can have a better mechanism to track bugs.  I'm open to having it used for any Glest mod as well (Indians, etc.).  I would also be open to it being used for Glest its self if the team were interested, I can even use a host name of your choosing like "bugs.glest.org".
« Last Edit: 1 January 1970, 00:00:00 by daniel.santos »

daniel.santos

  • Guest
(No subject)
« Reply #28 on: 12 March 2008, 16:27:05 »
Technical details of GAE saved games.

This post is intended for others who may want to understand the technical details of how GAE is performing serialization and deserialization of game data.  I wanted this available to others and I figured this is the best place as any.

First off, GAE is using the loosest coupling possible, preventing objects from knowing the details of each other.  GAE is using the Shared::Xml classes to perform serialization, keeping a standard interface for reading and writing data to the file system.  I have enhanced the XmlNode class to support a number of shortcut functions that reduce the amount of code I have to write to do common functions, like read or write a node that contains a single attribute named "value".  Overall, using xml seems to be the cleanest approach for serializing game data.

XML has a lot of drawbacks, it's slower, clunkier and makes big files, but I'm depending upon more recent hardware to offset those drawbacks.  Also, if we decide that we want saved game files to be smaller (I anticipate they will be 100k-ish), we can pull in the zlib library and compress them in gzip format.  This leaves it possible for players to still manually uncompress them to hack them to cheat (and we all know we like to do that sometimes!!! :) ) upon which it writes the XmlNode object to the saved game file.
Code: [Select]
Game::save(string name) const
 |
 +-> GameSettings::save(const XmlNode *) const
 |
 +-> World::save(const XmlNode *) const
      |
      +-> Stats::save(const XmlNode *) const
      |
      +-> Faction::save(XmlNode *) const //for each faction.
           |
           +-> UpgradeManager::save(const XmlNode *) const
           |
           +-> data members resources & stores persisted with tight coupling (1)
           |
           +-> Unit::save(const XmlNode *) const //for each unit.
                |
                +-> Effects::save(const XmlNode *) const (2)
                |    |
                |    +-> Effect::save(const XmlNode *) const (3)
                |
                +-> Command::save(const XmlNode *) const //for each command
Notes:
   1. This is one of the few exceptions to the loose coupling because it seemed to make more sense to do it this way.
   2. This applies to data members Unit::effects and Unit::effectsCreated.
   3. Bug: Effect isn't saving it's root ("root cause") data member, which only applies to recourse effects. Some effects have a recourse, an additional effect that is applied to the unit caused the original effect on it's target.  An example in FPM is the Lich's soul steal effect.  The effect "soul_steal" does damage over time on it's target.  When the Lich uses this attack, he gets an effect named "soul_steal_recourse" applied to him that regenerates his health.  These effects are tied together so that if his target dies, his regeneration stops.  But if the Lich dies early, the "soul_steal" effect on his target is also supposed to end early.  With this bug, that wont happen after reloading a saved game.  In order to fix this, we would have to create some type of EffectReference class and have an "effect registry" in the World object so we can keep track of all effects in that way and look them up later.  I'm not sure that's warranted.

Also of note, I learned a few things about why Martiño was using these UnitReference objects.  For one, they are really easy to persist.  Since, I converted my code to use a UnitRefernce object for all the pets collection object and the master.  The data member (a.k.a. "field" is what I'm used to calling them since doing so much Java now) master is NULL if the unit is free (not a "pet"), otherwise, it points to the owner of the unit where pets is a list of units that are "owned" by the this unit.

Reconstituting the object stream is more tricky.  I prefer to use a constructor that accepts a const XmlNode * object when possible, but some of the objects have to be constructed and initialized before deserialization, so this is what it ends up looking like.  The code that initiates this chain of events is in MenuStateLoadGame::mouseClick().
Code: [Select]
XmlNode *root = XmlIo::getInstance().load("savegames/" + selectedItem + ".sav");
program->setState(new Game(program, root));
The root XmlNode object is later deleted by the Game object after it's done with it.  Here is the sequence diagram:
Code: [Select]
Program::setState(ProgramState *programState) //in this case, the programState calls the Game constructor below.
 |
 +-> Game::Game(Program *program, const XmlNode *node)
 |    |
 |    +-> GameSettings::GameSettings(const XmlNode *node)
 |    |
 |    +-> World::World()
 |    |
 | <--+ //control returned
 |
 +-> Game::load() (1)
 |    |
 | <--+
 |
 +-> Game::init()
 |    |
 |    +-> calls some other objects we don't care about
 |    |
 |    +-> World::init(Game *, const XmlNode *)
 |         |
 |         +-> World::loadSaved(GameSettings *, const XmlNode *)
 |         |    |
 |         |    +-> Stats::init()
 |         |    |
 |         |    +-> Stats::load(const XmlNode *)
 |         |    |
 |         |    +-> Faction::load(const XmlNode *, World *, const FactionType *, ControlType, TechTree *)
 |         |         |
 |         |         +-> UpgradeManager::load(const XmlNode *, const FactionType *)
 |         |         |
 |         |         +-> //resources and stores deserialized using tight coupling
 |         |         |
 |         |         +-> Unit::Unit(const XmlNode *, World *, Faction *, Map *, const TechTree *) //for each unit
 |         |             |
 |         |             +-> Effects::Effects(const XmlNode *, World *, const TechTree *)
 |         |             |    |
 |         |             |    +-> Effect::Effect(const XmlNode *, World *, const TechTree *) //for each effect
 |         |             |
 |         |             +-> Command::Command(const XmlNode *, World *, const UnitType *, const FactionType *) //for each command
 |         |             |
 |         |             +-> reinitializes stats based upon upgrades, effects, levels, etc.
 |         |             |
 |         | <-----------+
 |         |
 |         +-> Faction::reinit() //for each faction
 |         |
 | <-------+
 |
 +- //game starts...

Notes
   1. Loads tech tree, tileset, etc.

EDIT: Added call to Faction::reinit() that I forgot earlier. Also of note, I'm leaving out a lot of initialization details that aren't directly related to loading a saved game.
« Last Edit: 1 January 1970, 00:00:00 by daniel.santos »

aiexpert

  • Guest
Save game patch source file not found
« Reply #29 on: 13 May 2008, 19:08:42 »
The save game patch file for Glest is not there on the given link. can any one tell me where to find the source for this patch.
« Last Edit: 1 January 1970, 00:00:00 by aiexpert »

jrepan

  • Guest
Re: Save game patch source file not found
« Reply #30 on: 14 May 2008, 11:38:55 »
Quote from: "aiexpert"
The save game patch file for Glest is not there on the given link. can any one tell me where to find the source for this patch.

Savegame is now in Glest Advanced Engine( http://www.glest.org/glest_board/viewtopic.php?t=3454 )
« Last Edit: 1 January 1970, 00:00:00 by jrepan »

daniel.santos

  • Guest
(No subject)
« Reply #31 on: 14 May 2008, 21:41:34 »
It still doesn't save weather though and in multiplayer, the clients don't get their camera & selection groups saved (i.e., 0-9 buttons).  It seems there was something else that wasn't being saved, but I can't remember now.
« Last Edit: 1 January 1970, 00:00:00 by daniel.santos »

 

anything