mirror of
https://github.com/BigJk/end_of_eden.git
synced 2026-02-06 10:48:09 +00:00
fix: save being broken after a while
This commit is contained in:
parent
1604f876a8
commit
efbc74077a
@ -281,20 +281,25 @@ func (s *Session) LuaErrors() chan LuaError {
|
|||||||
// ToSavedState creates a saved state of the session that can be serialized with Gob.
|
// ToSavedState creates a saved state of the session that can be serialized with Gob.
|
||||||
func (s *Session) ToSavedState() SavedState {
|
func (s *Session) ToSavedState() SavedState {
|
||||||
return SavedState{
|
return SavedState{
|
||||||
State: s.state,
|
State: s.state,
|
||||||
Seed: s.seed,
|
Seed: s.seed,
|
||||||
Rand: s.randSrc,
|
Rand: s.randSrc,
|
||||||
Actors: s.actors,
|
Actors: s.actors,
|
||||||
Instances: s.instances,
|
Instances: s.instances,
|
||||||
StagesCleared: s.stagesCleared,
|
StagesCleared: s.stagesCleared,
|
||||||
CurrentEvent: s.currentEvent,
|
CurrentEvent: s.currentEvent,
|
||||||
CurrentFight: s.currentFight,
|
CurrentFight: s.currentFight,
|
||||||
PointsPerRound: s.pointsPerRound,
|
PointsPerRound: s.pointsPerRound,
|
||||||
Merchant: s.merchant,
|
Merchant: s.merchant,
|
||||||
EventHistory: s.eventHistory,
|
EventHistory: s.eventHistory,
|
||||||
StateCheckpoints: s.stateCheckpoints,
|
StateCheckpoints: lo.Map(s.stateCheckpoints, func(item StateCheckpoint, index int) StateCheckpoint {
|
||||||
CtxData: s.ctxData,
|
return StateCheckpoint{
|
||||||
LoadedMods: s.loadedMods,
|
Session: nil,
|
||||||
|
Events: item.Events,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
CtxData: s.ctxData,
|
||||||
|
LoadedMods: s.loadedMods,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,6 +517,14 @@ func (s *Session) SetEvent(id string) {
|
|||||||
if _, ok := s.resources.Events[id]; ok {
|
if _, ok := s.resources.Events[id]; ok {
|
||||||
s.eventHistory = append(s.eventHistory, id)
|
s.eventHistory = append(s.eventHistory, id)
|
||||||
_, _ = s.resources.Events[id].OnEnter.Call(CreateContext("type_id", id))
|
_, _ = s.resources.Events[id].OnEnter.Call(CreateContext("type_id", id))
|
||||||
|
} else {
|
||||||
|
s.log.Println("Event not found:", id)
|
||||||
|
s.currentEvent = ""
|
||||||
|
|
||||||
|
// If we can't find the event, we just go to the next state
|
||||||
|
if s.state == GameStateEvent {
|
||||||
|
s.SetGameState(GameStateRandom)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user