Modify

Ticket #200 (closed bug: fixed)

Opened 9 years ago

Last modified 9 years ago

Save game support is broken

Reported by: zenbitz Owned by: parpg
Priority: critical Milestone: Release: Techdemo 2
Component: scripts Version: trunk
Keywords: Cc:
Blocked By: Blocking:
Department:

Description

Save game no longer works in release 396. Presumably trying to pickle a C++ SWIG object ref.

Traceback (most recent call last):

File "../../engine/extensions/pychan/events.py", line 159, in _redirectEvent

timer.delayCall(0,delayed_f)

File "../../engine/extensions/fife_timer.py", line 101, in delayCall

timer.callback = cbwa(real_callback, callback, timer)

File "../../engine/extensions/fife_timer.py", line 96, in cbwa

c(*args)

File "../../engine/extensions/fife_timer.py", line 99, in real_callback

c()

File "../../engine/extensions/pychan/events.py", line 158, in delayed_f

f( event )

File "../../engine/extensions/pychan/events.py", line 308, in captured_f

tools.applyOnlySuitable(self_ref().callbacks[group_name][event_name],event=event,widget=self_ref().widget_ref())

File "../../engine/extensions/pychan/tools.py", line 60, in applyOnlySuitable

return func(*args,kwargs)

File "/Users/hitz/Documents/workspace/FIFE/clients/parpg/scripts/gui/filebrowser.py", line 121, in _selectFile

u2s(self._widget.collectData('saveField')))

File "/Users/hitz/Documents/workspace/FIFE/clients/parpg/scripts/world.py", line 102, in saveGame

self.data.save(*args, kwargs)

File "/Users/hitz/Documents/workspace/FIFE/clients/parpg/scripts/engine.py", line 80, in save

pickle.dump(self.game_state, f)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 1362, in dump

Pickler(file, protocol).dump(obj)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 224, in dump

self.save(obj)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 331, in save

self.save_reduce(obj=obj, *rv)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 419, in save_reduce

save(state)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 331, in save

self.save_reduce(obj=obj, *rv)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 419, in save_reduce

save(state)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 331, in save

self.save_reduce(obj=obj, *rv)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 419, in save_reduce

save(state)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 306, in save

rv = reduce(self.proto)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/copy_reg.py", line 70, in _reduce_ex

raise TypeError?, "can't pickle %s objects" % base.name

TypeError?: can't pickle PySwigObject? objects

File "../../engine/extensions/pychan/events.py", line 181, in action

def action(self,e): self._redirectEvent("action",e)

File "../../engine/extensions/pychan/events.py", line 159, in _redirectEvent

timer.delayCall(0,delayed_f)

File "../../engine/extensions/fife_timer.py", line 101, in delayCall

timer.callback = cbwa(real_callback, callback, timer)

File "../../engine/extensions/fife_timer.py", line 96, in cbwa

c(*args)

File "../../engine/extensions/fife_timer.py", line 99, in real_callback

c()

File "../../engine/extensions/pychan/events.py", line 158, in delayed_f

f( event )

File "../../engine/extensions/pychan/events.py", line 308, in captured_f

tools.applyOnlySuitable(self_ref().callbacks[group_name][event_name],event=event,widget=self_ref().widget_ref())

File "../../engine/extensions/pychan/tools.py", line 60, in applyOnlySuitable

return func(*args,kwargs)

File "/Users/hitz/Documents/workspace/FIFE/clients/parpg/scripts/gui/filebrowser.py", line 121, in _selectFile

u2s(self._widget.collectData('saveField')))

File "/Users/hitz/Documents/workspace/FIFE/clients/parpg/scripts/world.py", line 102, in saveGame

self.data.save(*args, kwargs)

File "/Users/hitz/Documents/workspace/FIFE/clients/parpg/scripts/engine.py", line 80, in save

pickle.dump(self.game_state, f)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 1362, in dump

Pickler(file, protocol).dump(obj)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 224, in dump

self.save(obj)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 331, in save

self.save_reduce(obj=obj, *rv)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 419, in save_reduce

save(state)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 331, in save

self.save_reduce(obj=obj, *rv)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 419, in save_reduce

save(state)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 331, in save

self.save_reduce(obj=obj, *rv)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 419, in save_reduce

save(state)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 649, in save_dict

self._batch_setitems(obj.iteritems())

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 663, in _batch_setitems

save(v)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/pickle.py", line 306, in save

rv = reduce(self.proto)

File "/Library/Frameworks/Python?.framework/Versions/2.6/lib/python2.6/copy_reg.py", line 70, in _reduce_ex

raise TypeError?, "can't pickle %s objects" % base.name

TypeError?: can't pickle PySwigObject? objects

The next error causes a crash.

Catched director exception

File "/Users/hitz/Documents/workspace/FIFE/clients/parpg/scripts/objects/actors.py", line 237, in onInstanceActionFinished

self.idle()

File "/Users/hitz/Documents/workspace/FIFE/clients/parpg/scripts/objects/actors.py", line 252, in idle

self.parent.wander(self.target_loc)

File "/Users/hitz/Documents/workspace/FIFE/clients/parpg/scripts/objects/actors.py", line 292, in wander

self.behaviour.agent.move('walk', location, self.behaviour.speed-1)

AttributeError?: 'NoneType?' object has no attribute 'agent'

Catched director exception Segmentation fault

Attachments

SaveLoad.patch (6.9 KB) - added by beliar 9 years ago.

Change History

comment:1 Changed 9 years ago by eliedebrauwer

This is probably related to revision #395 in trunk/game/scripts/objects/action.py

comment:2 Changed 9 years ago by eliedebrauwer

Just verified it here, revision #394 works, revision #395 fails

comment:3 Changed 9 years ago by eliedebrauwer

Okay I gave it a more close look, a first error is that the footlocker class (in containers.py) contains the layer and the agent:

<fife.Layer; proxy of <Swig Object of type 'FIFE::Layer *' at 0xb07363c0> > <fife.Instance; proxy of <Swig Object of type 'FIFE::Instance *' at 0xa5b11e8> >

these should be removed and reinitialized after serializing/deserializing (and instead of the layer we should store the layer id instead).

The same is already implemented for the NPC's so we can gather some inspiration there.

comment:4 Changed 9 years ago by beliar

I have looked into this and got the saving working, loading does not work correctly though. The game seems to have problems accessing the state member.

I'll attach a patch that solves the save issues. I can't find a fix for loading though. Maybe someone else will have better luck.

comment:5 Changed 9 years ago by kaydeth_parpg

The game is crashing when I try to load a game that was saved on the second map. Can anyone verify?

comment:6 Changed 9 years ago by beliar

The patch fixes saving, loading does work, however the Footlocker can't be opened when loading.

Changed 9 years ago by beliar

comment:7 Changed 9 years ago by b0rland_parpg

  • Summary changed from Save game FAILS again to s

Beliar's patch seems to have been applied. The animated container is still buggy -- after loading game you can't open the footlocker. It throws an exception.

comment:8 Changed 9 years ago by barra_parpg

  • Summary changed from s to Save game support is broken

comment:9 Changed 9 years ago by b0rland_parpg

(In [498]) Patch by b0rland

  • Fixed the saving/loading mechanism. All NPCs and objects work correctly after game load
  • Eventually the game still segfaults. Couldn't catch that yet refs #200

comment:10 Changed 9 years ago by beliar

  • Status changed from new to closed
  • Resolution set to worksforme

Saving and loading works for me. No segfault happens here either. If no one has problems with saving and loading this ticket can be set to fixed.

comment:11 Changed 9 years ago by beliar

  • Status changed from closed to reopened
  • Resolution worksforme deleted

Game crashes when loading a save that was saved when on another map than the start map.

comment:12 Changed 9 years ago by beliar

  • Status changed from reopened to closed
  • Resolution set to fixed

(In [563]) Ticket #200: Patch by Beliar.

  • Merging map_loading_change branch back into trunk closes #200
View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.