diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/savegame.cfsml | 60 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 142 |
2 files changed, 41 insertions, 161 deletions
diff --git a/engines/sci/engine/savegame.cfsml b/engines/sci/engine/savegame.cfsml index 82a6778be1..f1bbabb2f8 100644 --- a/engines/sci/engine/savegame.cfsml +++ b/engines/sci/engine/savegame.cfsml @@ -125,66 +125,6 @@ int read_sci_version(Common::SeekableReadStream *fh, sci_version_t *foo, const c return version_parse(lastval, foo); } -void write_PTN(Common::WriteStream *fh, parse_tree_node_t const *foo) { - if (foo->type == PARSE_TREE_NODE_LEAF) - WSprintf(fh, "L%d", foo->content.value); - else - WSprintf(fh, "B(%d,%d)", foo->content.branches[0], foo->content.branches[1]); -} - -int read_PTN(Common::SeekableReadStream *fh, parse_tree_node_t *foo, const char *lastval, int *line, int *hiteof) { - if (lastval[0] == 'L') { - const char *c = lastval + 1; - char *strend; - - while (*c && isspace(*c)) - ++c; - - if (!*c) - return 1; - - foo->content.value = strtol(c, &strend, 0); - - return (strend == c); // Error if nothing could be read - - return 0; - } else if (lastval[0] == 'B') { - const char *c = lastval + 1; - char *strend; - - while (*c && isspace(*c)) - ++c; - if (*c++ != '(') return 1; - while (*c && isspace(*c)) - ++c; - - foo->content.branches[0] = strtol(c, &strend, 0); - if (strend == c) - return 1; - c = strend; - - while (*c && isspace(*c)) - ++c; - if (*c++ != ',') - return 1; - - while (*c && isspace(*c)) - ++c; - - foo->content.branches[1] = strtol(c, &strend, 0); - if (strend == c) - return 1; - c = strend; - - while (*c && isspace(*c)) - ++c; - if (*c++ != ')') - return 1; - - return 0; - } else return 1; // failure to parse anything -} - void write_CommonString(Common::WriteStream *fh, Common::String const *string); int read_CommonString(Common::SeekableReadStream *fh, Common::String *string, const char *lastval, int *line, int *hiteof); diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 9f68e05394..436c924dfb 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -125,66 +125,6 @@ int read_sci_version(Common::SeekableReadStream *fh, sci_version_t *foo, const c return version_parse(lastval, foo); } -void write_PTN(Common::WriteStream *fh, parse_tree_node_t const *foo) { - if (foo->type == PARSE_TREE_NODE_LEAF) - WSprintf(fh, "L%d", foo->content.value); - else - WSprintf(fh, "B(%d,%d)", foo->content.branches[0], foo->content.branches[1]); -} - -int read_PTN(Common::SeekableReadStream *fh, parse_tree_node_t *foo, const char *lastval, int *line, int *hiteof) { - if (lastval[0] == 'L') { - const char *c = lastval + 1; - char *strend; - - while (*c && isspace(*c)) - ++c; - - if (!*c) - return 1; - - foo->content.value = strtol(c, &strend, 0); - - return (strend == c); // Error if nothing could be read - - return 0; - } else if (lastval[0] == 'B') { - const char *c = lastval + 1; - char *strend; - - while (*c && isspace(*c)) - ++c; - if (*c++ != '(') return 1; - while (*c && isspace(*c)) - ++c; - - foo->content.branches[0] = strtol(c, &strend, 0); - if (strend == c) - return 1; - c = strend; - - while (*c && isspace(*c)) - ++c; - if (*c++ != ',') - return 1; - - while (*c && isspace(*c)) - ++c; - - foo->content.branches[1] = strtol(c, &strend, 0); - if (strend == c) - return 1; - c = strend; - - while (*c && isspace(*c)) - ++c; - if (*c++ != ')') - return 1; - - return 0; - } else return 1; // failure to parse anything -} - void write_CommonString(Common::WriteStream *fh, Common::String const *string); int read_CommonString(Common::SeekableReadStream *fh, Common::String *string, const char *lastval, int *line, int *hiteof); @@ -4008,7 +3948,7 @@ _cfsml_read_Script(Common::SeekableReadStream *fh, Script* save_struc, const cha // Auto-generated CFSML declaration and function block ends here // Auto-generation performed by cfsml.pl 0.8.2 -#line 445 "engines/sci/engine/savegame.cfsml" +#line 385 "engines/sci/engine/savegame.cfsml" void write_songlib_t(Common::WriteStream *fh, songlib_t const *songlib) { song_t *seeker = *(songlib->lib); @@ -4025,7 +3965,7 @@ void write_songlib_t(Common::WriteStream *fh, songlib_t const *songlib) { _cfsml_write_song_t(fh, seeker); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 457 "engines/sci/engine/savegame.cfsml" +#line 397 "engines/sci/engine/savegame.cfsml" seeker = seeker->next; } WSprintf(fh, "]\n"); @@ -4073,7 +4013,7 @@ int read_songlib_t(Common::SeekableReadStream *fh, songlib_t *songlib, const cha } } // End of auto-generated CFSML data reader code -#line 481 "engines/sci/engine/savegame.cfsml" +#line 421 "engines/sci/engine/savegame.cfsml" song_lib_add(*songlib, newsong); } l = fh->readLine(); // "]" @@ -4088,7 +4028,7 @@ void write_song_tp(Common::WriteStream *fh, const song_t * const *foo) { _cfsml_write_song_t(fh, *foo); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 491 "engines/sci/engine/savegame.cfsml" +#line 431 "engines/sci/engine/savegame.cfsml" } SongIterator *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id); @@ -4122,7 +4062,7 @@ int read_song_tp(Common::SeekableReadStream *fh, song_t **foo, const char *lastv } } // End of auto-generated CFSML data reader code -#line 501 "engines/sci/engine/savegame.cfsml" +#line 441 "engines/sci/engine/savegame.cfsml" (*foo)->_delay = 0; (*foo)->it = NULL; (*foo)->next_playing = (*foo)->next_stopping = (*foo)->next = NULL; @@ -4135,7 +4075,7 @@ void write_IntMapperPtr(Common::WriteStream *fh, const IntMapper * const *foo) { _cfsml_write_IntMapper(fh, *foo); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 509 "engines/sci/engine/savegame.cfsml" +#line 449 "engines/sci/engine/savegame.cfsml" } int read_IntMapperPtr(Common::SeekableReadStream *fh, IntMapper **foo, const char *lastval, int *line, int *hiteof) { @@ -4164,7 +4104,7 @@ int read_IntMapperPtr(Common::SeekableReadStream *fh, IntMapper **foo, const cha } } // End of auto-generated CFSML data reader code -#line 514 "engines/sci/engine/savegame.cfsml" +#line 454 "engines/sci/engine/savegame.cfsml" (*foo)->holes = NULL; return 0; } @@ -4180,7 +4120,7 @@ void write_IntMapperNodePtr(Common::WriteStream *fh, const IntMapper::Node * con write_IntMapperNodePtr(fh, &((*foo)->next)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 525 "engines/sci/engine/savegame.cfsml" +#line 465 "engines/sci/engine/savegame.cfsml" } else WSprintf(fh, "L"); WSprintf(fh, "]"); @@ -4228,7 +4168,7 @@ void write_menubar_tp(Common::WriteStream *fh, const menubar_t * const *foo) { _cfsml_write_menubar_t(fh, (*foo)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 568 "engines/sci/engine/savegame.cfsml" +#line 508 "engines/sci/engine/savegame.cfsml" } else { // Nothing to write WSprintf(fh, "\\null\\"); } @@ -4264,7 +4204,7 @@ int read_menubar_tp(Common::SeekableReadStream *fh, menubar_t **foo, const char } } // End of auto-generated CFSML data reader code -#line 580 "engines/sci/engine/savegame.cfsml" +#line 520 "engines/sci/engine/savegame.cfsml" } return *hiteof; } @@ -4304,7 +4244,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_int(fh, &foo->segmgr_id); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 615 "engines/sci/engine/savegame.cfsml" +#line 555 "engines/sci/engine/savegame.cfsml" switch (foo->type) { case MEM_OBJ_SCRIPT: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4312,7 +4252,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_Script(fh, &foo->data.script); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 618 "engines/sci/engine/savegame.cfsml" +#line 558 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_CLONES: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4320,7 +4260,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_CloneTable(fh, &foo->data.clones); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 621 "engines/sci/engine/savegame.cfsml" +#line 561 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_LOCALS: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4328,7 +4268,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_LocalVariables(fh, &foo->data.locals); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 624 "engines/sci/engine/savegame.cfsml" +#line 564 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_SYS_STRINGS: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4336,7 +4276,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_SystemStrings(fh, &foo->data.sys_strings); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 627 "engines/sci/engine/savegame.cfsml" +#line 567 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_STACK: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4344,7 +4284,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_int(fh, &foo->data.stack.nr); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 630 "engines/sci/engine/savegame.cfsml" +#line 570 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_HUNK: break; @@ -4356,7 +4296,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_ListTable(fh, &foo->data.lists); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 637 "engines/sci/engine/savegame.cfsml" +#line 577 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_NODES: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4364,7 +4304,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_NodeTable(fh, &foo->data.nodes); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 640 "engines/sci/engine/savegame.cfsml" +#line 580 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_DYNMEM: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4372,7 +4312,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_DynMem(fh, &foo->data.dynmem); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 643 "engines/sci/engine/savegame.cfsml" +#line 583 "engines/sci/engine/savegame.cfsml" break; default: break; @@ -4412,7 +4352,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 657 "engines/sci/engine/savegame.cfsml" +#line 597 "engines/sci/engine/savegame.cfsml" switch (foo->type) { case MEM_OBJ_SCRIPT: // Auto-generated CFSML data reader code @@ -4441,7 +4381,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 660 "engines/sci/engine/savegame.cfsml" +#line 600 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_CLONES: // Auto-generated CFSML data reader code @@ -4470,7 +4410,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 663 "engines/sci/engine/savegame.cfsml" +#line 603 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_LOCALS: // Auto-generated CFSML data reader code @@ -4499,7 +4439,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 666 "engines/sci/engine/savegame.cfsml" +#line 606 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_SYS_STRINGS: // Auto-generated CFSML data reader code @@ -4528,7 +4468,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 669 "engines/sci/engine/savegame.cfsml" +#line 609 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_LISTS: // Auto-generated CFSML data reader code @@ -4557,7 +4497,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 672 "engines/sci/engine/savegame.cfsml" +#line 612 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_NODES: // Auto-generated CFSML data reader code @@ -4586,7 +4526,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 675 "engines/sci/engine/savegame.cfsml" +#line 615 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_STACK: // Auto-generated CFSML data reader code @@ -4615,7 +4555,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 678 "engines/sci/engine/savegame.cfsml" +#line 618 "engines/sci/engine/savegame.cfsml" foo->data.stack.entries = (reg_t *)sci_calloc(foo->data.stack.nr, sizeof(reg_t)); break; case MEM_OBJ_HUNK: @@ -4650,7 +4590,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 687 "engines/sci/engine/savegame.cfsml" +#line 627 "engines/sci/engine/savegame.cfsml" break; default: break; @@ -4666,7 +4606,7 @@ void write_MemObjPtr(Common::WriteStream *fh, const MemObject * const *foo) { write_MemObject(fh, (*foo)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 698 "engines/sci/engine/savegame.cfsml" +#line 638 "engines/sci/engine/savegame.cfsml" } else { // Nothing to write WSprintf(fh, "\\null\\"); } @@ -4701,7 +4641,7 @@ int read_MemObjPtr(Common::SeekableReadStream *fh, MemObject **foo, const char * } } // End of auto-generated CFSML data reader code -#line 709 "engines/sci/engine/savegame.cfsml" +#line 649 "engines/sci/engine/savegame.cfsml" return *hiteof; } return 0; @@ -4715,7 +4655,7 @@ void write_CommonString(Common::WriteStream *fh, Common::String const *string) _cfsml_write_string(fh, (&t)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 718 "engines/sci/engine/savegame.cfsml" +#line 658 "engines/sci/engine/savegame.cfsml" } int read_CommonString(Common::SeekableReadStream *fh, Common::String *string, const char *lastval, int *line, int *hiteof) @@ -4750,7 +4690,7 @@ int read_CommonString(Common::SeekableReadStream *fh, Common::String *string, co } } // End of auto-generated CFSML data reader code -#line 725 "engines/sci/engine/savegame.cfsml" +#line 665 "engines/sci/engine/savegame.cfsml" if (*hiteof) return *hiteof; *string = t; free(t); @@ -4763,13 +4703,13 @@ void write_SegManagerPtr(Common::WriteStream *fh, const SegManager * const *foo) _cfsml_write_bool(fh, &((*foo)->isSci1_1)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 733 "engines/sci/engine/savegame.cfsml" +#line 673 "engines/sci/engine/savegame.cfsml" #line 822 "engines/sci/engine/savegame.cfsml" // Auto-generated CFSML data writer code _cfsml_write_SegManager(fh, *foo); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 734 "engines/sci/engine/savegame.cfsml" +#line 674 "engines/sci/engine/savegame.cfsml" } int read_SegManagerPtr(Common::SeekableReadStream *fh, SegManager **foo, const char *lastval, int *line, int *hiteof) { @@ -4800,7 +4740,7 @@ int read_SegManagerPtr(Common::SeekableReadStream *fh, SegManager **foo, const c } } // End of auto-generated CFSML data reader code -#line 741 "engines/sci/engine/savegame.cfsml" +#line 681 "engines/sci/engine/savegame.cfsml" *foo = new SegManager(sci11); token = _cfsml_get_identifier(fh, line, hiteof, &assignment); // Auto-generated CFSML data reader code @@ -4827,7 +4767,7 @@ int read_SegManagerPtr(Common::SeekableReadStream *fh, SegManager **foo, const c } } // End of auto-generated CFSML data reader code -#line 744 "engines/sci/engine/savegame.cfsml" +#line 684 "engines/sci/engine/savegame.cfsml" return 0; } @@ -4876,13 +4816,13 @@ int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename _cfsml_write_SavegameMetadata(fh, (&meta)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 788 "engines/sci/engine/savegame.cfsml" +#line 728 "engines/sci/engine/savegame.cfsml" #line 822 "engines/sci/engine/savegame.cfsml" // Auto-generated CFSML data writer code _cfsml_write_EngineState(fh, s); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 789 "engines/sci/engine/savegame.cfsml" +#line 729 "engines/sci/engine/savegame.cfsml" _gamestate_unfrob(s); @@ -5189,7 +5129,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { } } // End of auto-generated CFSML data reader code -#line 1064 "engines/sci/engine/savegame.cfsml" +#line 1004 "engines/sci/engine/savegame.cfsml" if (read_eof) return false; @@ -5245,7 +5185,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { } } // End of auto-generated CFSML data reader code -#line 1088 "engines/sci/engine/savegame.cfsml" +#line 1028 "engines/sci/engine/savegame.cfsml" sfx_exit(&s->sound); _gamestate_unfrob(retval); @@ -5383,7 +5323,7 @@ bool get_savegame_metadata(Common::SeekableReadStream* stream, SavegameMetadata* } } // End of auto-generated CFSML data reader code -#line 1194 "engines/sci/engine/savegame.cfsml" +#line 1134 "engines/sci/engine/savegame.cfsml" if (read_eof) return false; |