[Scummvm-cvs-logs] SF.net SVN: scummvm:[38336] scummvm/trunk/engines/sci
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Feb 16 01:35:22 CET 2009
Revision: 38336
http://scummvm.svn.sourceforge.net/scummvm/?rev=38336&view=rev
Author: fingolfin
Date: 2009-02-16 00:35:22 +0000 (Mon, 16 Feb 2009)
Log Message:
-----------
SCI: cleanup
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/grammar.cpp
scummvm/trunk/engines/sci/engine/heap.cpp
scummvm/trunk/engines/sci/engine/kfile.cpp
scummvm/trunk/engines/sci/engine/kpathing.cpp
scummvm/trunk/engines/sci/engine/savegame.cfsml
scummvm/trunk/engines/sci/engine/savegame.cpp
scummvm/trunk/engines/sci/engine/scriptdebug.cpp
scummvm/trunk/engines/sci/engine/sys_strings.cpp
scummvm/trunk/engines/sci/gfx/resource/sci_resmgr.cpp
scummvm/trunk/engines/sci/include/console.h
scummvm/trunk/engines/sci/include/int_hashmap.h
scummvm/trunk/engines/sci/include/resource.h
scummvm/trunk/engines/sci/include/sci_memory.h
Modified: scummvm/trunk/engines/sci/engine/grammar.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/grammar.cpp 2009-02-16 00:34:40 UTC (rev 38335)
+++ scummvm/trunk/engines/sci/engine/grammar.cpp 2009-02-16 00:35:22 UTC (rev 38336)
@@ -26,8 +26,6 @@
#include "sci/include/resource.h"
#include "sci/include/vocabulary.h"
#include "sci/include/console.h"
-#include <stdarg.h>
-#include <string.h>
#define TOKEN_OPAREN 0xff000000
#define TOKEN_CPAREN 0xfe000000
Modified: scummvm/trunk/engines/sci/engine/heap.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/heap.cpp 2009-02-16 00:34:40 UTC (rev 38335)
+++ scummvm/trunk/engines/sci/engine/heap.cpp 2009-02-16 00:35:22 UTC (rev 38336)
@@ -1,7 +1,3 @@
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-
#include "sci/include/engine.h"
#include "sci/include/console.h"
#include "sci/engine/heap.h"
Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp 2009-02-16 00:34:40 UTC (rev 38335)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp 2009-02-16 00:35:22 UTC (rev 38336)
@@ -29,6 +29,7 @@
#include "sci/include/engine.h"
+#include <errno.h>
#ifdef WIN32
# define WIN32_LEAN_AND_MEAN
Modified: scummvm/trunk/engines/sci/engine/kpathing.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kpathing.cpp 2009-02-16 00:34:40 UTC (rev 38335)
+++ scummvm/trunk/engines/sci/engine/kpathing.cpp 2009-02-16 00:35:22 UTC (rev 38336)
@@ -29,8 +29,6 @@
** which can be downloaded from FIXME.
*/
-#include <math.h>
-
#include "sci/include/engine.h"
#include "sci/include/aatree.h"
#include "sci/include/list.h"
Modified: scummvm/trunk/engines/sci/engine/savegame.cfsml
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cfsml 2009-02-16 00:34:40 UTC (rev 38335)
+++ scummvm/trunk/engines/sci/engine/savegame.cfsml 2009-02-16 00:35:22 UTC (rev 38336)
@@ -34,7 +34,6 @@
#include "sci/include/gfx_operations.h"
#include "sci/include/sfx_engine.h"
#include "sci/include/engine.h"
-#include <assert.h>
#include "sci/engine/heap.h"
#ifdef _MSC_VER
@@ -58,18 +57,15 @@
void
-write_reg_t(FILE *fh, reg_t *foo)
-{
+write_reg_t(FILE *fh, reg_t *foo) {
fprintf(fh, PREG, PRINT_REG(*foo));
}
int
-read_reg_t(FILE *fh, reg_t *foo, const char *lastval, int *line, int *hiteof)
-{
+read_reg_t(FILE *fh, reg_t *foo, const char *lastval, int *line, int *hiteof) {
int segment, offset;
- if (sscanf(lastval, PREG, &segment, &offset)<2)
- {
+ if (sscanf(lastval, PREG, &segment, &offset)<2) {
sciprintf("Error parsing reg_t on line %d\n", *line);
return 1;
}
@@ -79,21 +75,18 @@
}
void
-write_sci_version(FILE *fh, sci_version_t *foo)
-{
+write_sci_version(FILE *fh, sci_version_t *foo) {
fprintf(fh, "%d.%03d.%03d", SCI_VERSION_MAJOR(*foo), SCI_VERSION_MINOR(*foo),
SCI_VERSION_PATCHLEVEL(*foo));
}
int
-read_sci_version(FILE *fh, sci_version_t *foo, const char *lastval, int *line, int *hiteof)
-{
+read_sci_version(FILE *fh, sci_version_t *foo, const char *lastval, int *line, int *hiteof) {
return version_parse(lastval, foo);
}
void
-write_PTN(FILE *fh, parse_tree_node_t *foo)
-{
+write_PTN(FILE *fh, parse_tree_node_t *foo) {
if (foo->type == PARSE_TREE_NODE_LEAF)
fprintf(fh, "L%d", foo->content.value);
else
@@ -101,8 +94,7 @@
}
int
-read_PTN(FILE *fh, parse_tree_node_t *foo, const char *lastval, int *line, int *hiteof)
-{
+read_PTN(FILE *fh, parse_tree_node_t *foo, const char *lastval, int *line, int *hiteof) {
if (lastval[0] == 'L') {
const char *c = lastval + 1;
char *strend;
@@ -401,48 +393,43 @@
%END CFSML
void
-write_songlib_t(FILE *fh, songlib_t *songlib)
-{
- song_t *seeker = *(songlib->lib);
- int songcount = song_lib_count(*songlib);
+write_songlib_t(FILE *fh, songlib_t *songlib) {
+ song_t *seeker = *(songlib->lib);
+ int songcount = song_lib_count(*songlib);
- fprintf(fh, "{\n");
- fprintf(fh, "songcount = %d\n", songcount);
- fprintf(fh, "list = \n");
- fprintf(fh, "[\n");
- while (seeker)
- {
- seeker->restore_time = seeker->it->get_timepos(seeker->it);
- %CFSMLWRITE song_t seeker INTO fh;
- seeker = seeker->next;
- }
- fprintf(fh, "]\n");
- fprintf(fh, "}\n");
+ fprintf(fh, "{\n");
+ fprintf(fh, "songcount = %d\n", songcount);
+ fprintf(fh, "list = \n");
+ fprintf(fh, "[\n");
+ while (seeker) {
+ seeker->restore_time = seeker->it->get_timepos(seeker->it);
+ %CFSMLWRITE song_t seeker INTO fh;
+ seeker = seeker->next;
+ }
+ fprintf(fh, "]\n");
+ fprintf(fh, "}\n");
}
-int
-read_songlib_t(FILE *fh, songlib_t *songlib, const char *lastval, int *line, int *hiteof)
-{
- int songcount;
- int i;
- song_t *newsong;
- int oldstatus;
+int read_songlib_t(FILE *fh, songlib_t *songlib, const char *lastval, int *line, int *hiteof) {
+ int songcount;
+ int i;
+ song_t *newsong;
+ int oldstatus;
- fscanf(fh, "{\n");
- fscanf(fh, "songcount = %d\n", &songcount);
- fscanf(fh, "list = \n");
- fscanf(fh, "[\n");
- *line += 4;
- song_lib_init(songlib);
- for (i = 0; i < songcount; i++)
- {
- %CFSMLREAD song_tp &newsong FROM fh ERRVAR *hiteof FIRSTTOKEN lastval LINECOUNTER *line;
- song_lib_add(*songlib, newsong);
- }
- fscanf(fh, "]\n");
- fscanf(fh, "}\n");;
- *line += 2;
- return 0;
+ fscanf(fh, "{\n");
+ fscanf(fh, "songcount = %d\n", &songcount);
+ fscanf(fh, "list = \n");
+ fscanf(fh, "[\n");
+ *line += 4;
+ song_lib_init(songlib);
+ for (i = 0; i < songcount; i++) {
+ %CFSMLREAD song_tp &newsong FROM fh ERRVAR *hiteof FIRSTTOKEN lastval LINECOUNTER *line;
+ song_lib_add(*songlib, newsong);
+ }
+ fscanf(fh, "]\n");
+ fscanf(fh, "}\n");;
+ *line += 2;
+ return 0;
}
struct {
@@ -460,13 +447,11 @@
{MEM_OBJ_HUNK,"HUNK"},
{MEM_OBJ_DYNMEM,"DYNMEM"}};
-int
-mem_obj_string_to_enum(const char *str)
-{
+int mem_obj_string_to_enum(const char *str) {
int i;
- for (i = 0; i <= MEM_OBJ_MAX; i++)
- { if (!strcasecmp(mem_obj_string_names[i].name, str))
+ for (i = 0; i <= MEM_OBJ_MAX; i++) {
+ if (!strcasecmp(mem_obj_string_names[i].name, str))
return i;
}
@@ -475,24 +460,17 @@
static int bucket_length;
-void
-write_int_hash_map_tp(FILE *fh, int_hash_map_t **foo)
-{
+void write_int_hash_map_tp(FILE *fh, int_hash_map_t **foo) {
%CFSMLWRITE int_hash_map_t *foo INTO fh;
}
-void
-write_song_tp(FILE *fh, song_t **foo)
-{
+void write_song_tp(FILE *fh, song_t **foo) {
%CFSMLWRITE song_t *foo INTO fh;
}
-song_iterator_t *
-build_iterator(state_t *s, int song_nr, int type, songit_id_t id);
+song_iterator_t *build_iterator(state_t *s, int song_nr, int type, songit_id_t id);
-int
-read_song_tp(FILE *fh, song_t **foo, const char *lastval, int *line, int *hiteof)
-{
+int read_song_tp(FILE *fh, song_t **foo, const char *lastval, int *line, int *hiteof) {
char *token;
int assignment;
*foo = (song_t*) malloc(sizeof(song_t));
@@ -504,8 +482,7 @@
return 0;
}
int
-read_int_hash_map_tp(FILE *fh, int_hash_map_t **foo, const char *lastval, int *line, int *hiteof)
-{
+read_int_hash_map_tp(FILE *fh, int_hash_map_t **foo, const char *lastval, int *line, int *hiteof) {
*foo = (int_hash_map_t*)malloc(sizeof(int_hash_map_t));
%CFSMLREAD int_hash_map_t (*foo) FROM fh ERRVAR *hiteof FIRSTTOKEN lastval LINECOUNTER *line;
(*foo)->holes = NULL;
@@ -513,16 +490,12 @@
}
void
-write_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo)
-{
- if (!(*foo))
- {
+write_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo) {
+ if (!(*foo)) {
fputs("\\null", fh);
- } else
- {
+ } else {
fprintf(fh,"[\n%d=>%d\n", (*foo)->name, (*foo)->value);
- if ((*foo)->next)
- {
+ if ((*foo)->next) {
%CFSMLWRITE int_hash_map_node_tp &((*foo)->next) INTO fh;
} else fputc('L', fh);
fputs("]", fh);
@@ -530,16 +503,14 @@
}
int
-read_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo, const char *lastval, int *line, int *hiteof)
-{
+read_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo, const char *lastval, int *line, int *hiteof) {
static char buffer[80];
if (lastval[0] == '\\') {
*foo = NULL; /* No hash map node */
} else {
*foo = (int_hash_map_node_t*)malloc(sizeof(int_hash_map_node_t));
- if (lastval[0] != '[')
- {
+ if (lastval[0] != '[') {
sciprintf("Expected opening bracket in hash_map_node_t on line %d\n", *line);
return 1;
}
@@ -547,22 +518,18 @@
do {
(*line)++;
fgets(buffer, 80, fh);
- if (buffer[0] == 'L')
- {
+ if (buffer[0] == 'L') {
(*foo)->next = NULL;
buffer[0] = buffer[1];
} /* HACK: deliberately no else clause here */
- if (buffer[0] == ']')
- {
+ if (buffer[0] == ']') {
break;
}
- else if (buffer[0] == '[')
- {
+ else if (buffer[0] == '[') {
if (read_int_hash_map_node_tp(fh, &((*foo)->next), buffer, line, hiteof))
return 1;
}
- else if (sscanf(buffer, "%d=>%d", &((*foo)->name), &((*foo)->value))<2)
- {
+ else if (sscanf(buffer, "%d=>%d", &((*foo)->name), &((*foo)->value))<2) {
sciprintf("Error parsing hash_map_node_t on line %d\n", *line);
return 1;
}
@@ -573,8 +540,7 @@
}
void
-write_menubar_tp(FILE *fh, menubar_t **foo)
-{
+write_menubar_tp(FILE *fh, menubar_t **foo) {
if (*foo) {
%CFSMLWRITE menubar_t (*foo) INTO fh;
@@ -586,8 +552,7 @@
int
-read_menubar_tp(FILE *fh, menubar_t **foo, const char *lastval, int *line, int *hiteof)
-{
+read_menubar_tp(FILE *fh, menubar_t **foo, const char *lastval, int *line, int *hiteof) {
if (lastval[0] == '\\') {
*foo = NULL; /* No menu bar */
@@ -601,12 +566,10 @@
}
void
-write_mem_obj_t(FILE *fh, mem_obj_t *foo)
-{
+write_mem_obj_t(FILE *fh, mem_obj_t *foo) {
fprintf(fh, "%s\n", mem_obj_string_names[foo->type].name);
%CFSMLWRITE int &foo->segmgr_id INTO fh;
- switch (foo->type)
- {
+ switch (foo->type) {
case MEM_OBJ_SCRIPT:
%CFSMLWRITE script_t &foo->data.script INTO fh;
break;
@@ -637,19 +600,16 @@
}
int
-read_mem_obj_t(FILE *fh, mem_obj_t *foo, const char *lastval, int *line, int *hiteof)
-{
+read_mem_obj_t(FILE *fh, mem_obj_t *foo, const char *lastval, int *line, int *hiteof) {
char buffer[80];
foo->type = mem_obj_string_to_enum(lastval);
- if (foo->type < 0)
- {
+ if (foo->type < 0) {
sciprintf("Unknown mem_obj_t type %s on line %d\n", lastval, *line);
return 1;
}
%CFSMLREAD int &foo->segmgr_id FROM fh ERRVAR *hiteof LINECOUNTER *line;
- switch (foo->type)
- {
+ switch (foo->type) {
case MEM_OBJ_SCRIPT:
%CFSMLREAD script_t &foo->data.script FROM fh ERRVAR *hiteof LINECOUNTER *line;
break;
@@ -684,8 +644,7 @@
}
void
-write_mem_obj_tp(FILE *fh, mem_obj_t **foo)
-{
+write_mem_obj_tp(FILE *fh, mem_obj_t **foo) {
if (*foo) {
%CFSMLWRITE mem_obj_t (*foo) INTO fh;
@@ -696,8 +655,7 @@
}
int
-read_mem_obj_tp(FILE *fh, mem_obj_t **foo, const char *lastval, int *line, int *hiteof)
-{
+read_mem_obj_tp(FILE *fh, mem_obj_t **foo, const char *lastval, int *line, int *hiteof) {
if (lastval[0] == '\\') {
*foo = NULL; /* No menu bar */
@@ -715,14 +673,12 @@
** to writing a gamestate to disk
*/
void
-_gamestate_unfrob(state_t *s)
-{
+_gamestate_unfrob(state_t *s) {
}
int
-gamestate_save(state_t *s, char *dirname)
-{
+gamestate_save(state_t *s, char *dirname) {
FILE *fh;
sci_dir_t dir;
char *filename;
@@ -741,7 +697,7 @@
scimkdir (dirname, 0700);
- if (chdir (dirname)) {
+ if (chdir(dirname)) {
sciprintf("Could not enter directory '%s'\n", dirname);
return 1;
}
@@ -759,7 +715,7 @@
if (s->sound_server) {
if ((s->sound_server->save)(s, dirname)) {
sciprintf("Saving failed for the sound subsystem\n");
- chdir ("..");
+ chdir("..");
return 1;
}
}
@@ -778,13 +734,12 @@
_gamestate_unfrob(s);
- chdir ("..");
+ chdir("..");
return 0;
}
static seg_id_t
-find_unique_seg_by_type(seg_manager_t *self, int type)
-{
+find_unique_seg_by_type(seg_manager_t *self, int type) {
int i;
for (i = 0; i < self->heap_size; i++)
@@ -795,8 +750,7 @@
}
static byte *
-find_unique_script_block(state_t *s, byte *buf, int type)
-{
+find_unique_script_block(state_t *s, byte *buf, int type) {
int magic_pos_adder = s->version >= SCI_VERSION_FTU_NEW_SCRIPT_HEADER ? 0 : 2;
buf += magic_pos_adder;
@@ -815,8 +769,7 @@
}
static
-void reconstruct_stack(state_t *retval)
-{
+void reconstruct_stack(state_t *retval) {
seg_id_t stack_seg = find_unique_seg_by_type(&retval->seg_manager, MEM_OBJ_STACK);
dstack_t *stack = &(retval->seg_manager.heap[stack_seg]->data.stack);
@@ -826,8 +779,7 @@
}
static
-int clone_entry_used(clone_table_t *table, int n)
-{
+int clone_entry_used(clone_table_t *table, int n) {
int backup;
int seeker = table->first_free;
clone_entry_t *entries = table->table;
@@ -844,8 +796,7 @@
}
static
-void load_script(state_t *s, seg_id_t seg)
-{
+void load_script(state_t *s, seg_id_t seg) {
resource_t *script, *heap;
script_t *scr = &(s->seg_manager.heap[seg]->data.script);
@@ -855,8 +806,7 @@
if (s->version >= SCI_VERSION(1,001,000))
heap = scir_find_resource(s->resmgr, sci_heap, scr->nr, 0);
- switch (s->seg_manager.sci1_1)
- {
+ switch (s->seg_manager.sci1_1) {
case 0 :
sm_mcpy_in_out( &s->seg_manager, 0, script->data, script->size, seg, SEG_ID);
break;
@@ -868,20 +818,16 @@
}
static
-void reconstruct_scripts(state_t *s, seg_manager_t *self)
-{
+void reconstruct_scripts(state_t *s, seg_manager_t *self) {
int i;
mem_obj_t *mobj;
object_t **objects;
int *objects_nr;
for (i = 0; i < self->heap_size; i++)
- if (self->heap[i])
- {
+ if (self->heap[i]) {
mobj = self->heap[i];
- switch (mobj->type)
- {
- case MEM_OBJ_SCRIPT:
- {
+ switch (mobj->type) {
+ case MEM_OBJ_SCRIPT: {
int j;
script_t *scr = &mobj->data.script;
@@ -897,8 +843,7 @@
if (!self->sci1_1)
scr->export_table += 3;
- for (j = 0; j < scr->objects_nr; j++)
- {
+ for (j = 0; j < scr->objects_nr; j++) {
byte *data = scr->buf + scr->objects[j].pos.offset;
scr->objects[j].base = scr->buf;
scr->objects[j].base_obj = data;
@@ -909,36 +854,29 @@
}
for (i = 0; i < self->heap_size; i++)
- if (self->heap[i])
- {
+ if (self->heap[i]) {
mobj = self->heap[i];
- switch (mobj->type)
- {
- case MEM_OBJ_SCRIPT:
- {
+ switch (mobj->type) {
+ case MEM_OBJ_SCRIPT: {
int j;
script_t *scr = &mobj->data.script;
- for (j = 0; j < scr->objects_nr; j++)
- {
+ for (j = 0; j < scr->objects_nr; j++) {
byte *data = scr->buf + scr->objects[j].pos.offset;
- if (self->sci1_1)
- {
+ if (self->sci1_1) {
guint16 *funct_area = (guint16 *) (scr->buf + getUInt16( data + 6 ));
guint16 *prop_area = (guint16 *) (scr->buf + getUInt16( data + 4 ));
scr->objects[j].base_method = funct_area;
scr->objects[j].base_vars = prop_area;
- } else
- {
+ } else {
int funct_area = getUInt16( data + SCRIPT_FUNCTAREAPTR_OFFSET );
object_t *base_obj;
base_obj = obj_get(s, scr->objects[j].variables[SCRIPT_SPECIES_SELECTOR]);
- if (!base_obj)
- {
+ if (!base_obj) {
sciprintf("Object without a base class: Script %d, index %d (reg address "PREG"\n",
scr->nr, j, PRINT_REG(scr->objects[j].variables[SCRIPT_SPECIES_SELECTOR]));
continue;
@@ -956,41 +894,34 @@
}
void
-reconstruct_clones(state_t *s, seg_manager_t *self)
-{
+reconstruct_clones(state_t *s, seg_manager_t *self) {
int i;
mem_obj_t *mobj;
for (i = 0; i < self->heap_size; i++)
- if (self->heap[i])
- {
+ if (self->heap[i]) {
mobj = self->heap[i];
- switch (mobj->type)
- {
- case MEM_OBJ_CLONES:
- {
+ switch (mobj->type) {
+ case MEM_OBJ_CLONES: {
int j;
clone_entry_t *seeker = mobj->data.clones.table;
sciprintf("Free list: ");
for (j = mobj->data.clones.first_free;
j != HEAPENTRY_INVALID;
- j = mobj->data.clones.table[j].next_free)
- {
+ j = mobj->data.clones.table[j].next_free) {
sciprintf("%d ", j);
}
sciprintf("\n");
sciprintf("Entries w/zero vars: ");
- for (j = 0; j < mobj->data.clones.max_entry; j++)
- {
+ for (j = 0; j < mobj->data.clones.max_entry; j++) {
if (mobj->data.clones.table[j].entry.variables == NULL)
sciprintf("%d ", j);
}
sciprintf("\n");
- for (j = 0; j < mobj->data.clones.max_entry; j++)
- {
+ for (j = 0; j < mobj->data.clones.max_entry; j++) {
object_t *base_obj;
if (!clone_entry_used(&mobj->data.clones, j)) {
@@ -998,8 +929,7 @@
continue;
}
base_obj = obj_get(s, seeker->entry.variables[SCRIPT_SPECIES_SELECTOR]);
- if (!base_obj)
- {
+ if (!base_obj) {
sciprintf("Clone entry without a base class: %d\n", j);
seeker->entry.base = seeker->entry.base_obj = NULL;
seeker->entry.base_vars = seeker->entry.base_method = NULL;
@@ -1026,8 +956,7 @@
new_fast_forward_iterator(song_iterator_t *it, int delta);
static
-void reconstruct_sounds(state_t *s)
-{
+void reconstruct_sounds(state_t *s) {
song_t *seeker;
int it_type = s->resmgr->sci_version >= SCI_VERSION_01 ?
SCI_SONG_ITERATOR_TYPE_SCI1
@@ -1035,13 +964,11 @@
if (s->sound.songlib.lib)
seeker = *(s->sound.songlib.lib);
- else
- {
+ else {
song_lib_init(&s->sound.songlib);
seeker = NULL;
}
- while (seeker)
- {
+ while (seeker) {
song_iterator_t *base, *ff;
int oldstatus;
song_iterator_message_t msg;
@@ -1067,8 +994,7 @@
}
state_t *
-gamestate_restore(state_t *s, char *dirname)
-{
+gamestate_restore(state_t *s, char *dirname) {
FILE *fh;
int fd;
int i;
@@ -1076,7 +1002,7 @@
state_t *retval;
songlib_t temp;
- if (chdir (dirname)) {
+ if (chdir(dirname)) {
sciprintf("Game state '%s' does not exist\n", dirname);
return NULL;
}
@@ -1104,7 +1030,7 @@
return NULL;
}
- /* Backwards compatibility settings */
+ /* Backwards compatibility settings */
retval->dyn_views = NULL;
retval->drop_views = NULL;
retval->port = NULL;
@@ -1117,7 +1043,7 @@
fclose(fh);
- if ((retval->savegame_version < FREESCI_MINIMUM_SAVEGAME_VERSION) ||
+ if ((retval->savegame_version < FREESCI_MINIMUM_SAVEGAME_VERSION) ||
(retval->savegame_version > FREESCI_CURRENT_SAVEGAME_VERSION)) {
if (retval->savegame_version < FREESCI_MINIMUM_SAVEGAME_VERSION)
@@ -1162,8 +1088,7 @@
retval->save_dir_edit_offset = 0;
retval->sys_strings_segment = find_unique_seg_by_type(&retval->seg_manager, MEM_OBJ_SYS_STRINGS);
retval->sys_strings = &(((mem_obj_t *)(GET_SEGMENT(retval->seg_manager, retval->sys_strings_segment, MEM_OBJ_SYS_STRINGS)))->data.sys_strings);
- sys_strings_restore(retval->sys_strings,
- s->sys_strings);
+ sys_strings_restore(retval->sys_strings, s->sys_strings);
/* Time state: */
sci_get_current_time(&(retval->last_wait_time));
Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp 2009-02-16 00:34:40 UTC (rev 38335)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp 2009-02-16 00:35:22 UTC (rev 38336)
@@ -34,14 +34,13 @@
#include "sci/include/gfx_operations.h"
#include "sci/include/sfx_engine.h"
#include "sci/include/engine.h"
-#include <assert.h>
#include "sci/engine/heap.h"
#ifdef _MSC_VER
#include <direct.h>
#endif
-#ifdef WIN32
+#ifdef _WIN32
#pragma warning( disable : 4101 )
#endif
@@ -66,7 +65,7 @@
read_reg_t(FILE *fh, reg_t *foo, const char *lastval, int *line, int *hiteof) {
int segment, offset;
- if (sscanf(lastval, PREG, &segment, &offset) < 2) {
+ if (sscanf(lastval, PREG, &segment, &offset)<2) {
sciprintf("Error parsing reg_t on line %d\n", *line);
return 1;
}
@@ -78,7 +77,7 @@
void
write_sci_version(FILE *fh, sci_version_t *foo) {
fprintf(fh, "%d.%03d.%03d", SCI_VERSION_MAJOR(*foo), SCI_VERSION_MINOR(*foo),
- SCI_VERSION_PATCHLEVEL(*foo));
+ SCI_VERSION_PATCHLEVEL(*foo));
}
int
@@ -199,20 +198,21 @@
#endif
static void
-_cfsml_error(const char *fmt, ...) {
- va_list argp;
+_cfsml_error(const char *fmt, ...)
+{
+ va_list argp;
- fprintf(stderr, "Error: ");
- va_start(argp, fmt);
- vfprintf(stderr, fmt, argp);
- va_end(argp);
+ fprintf(stderr, "Error: ");
+ va_start(argp, fmt);
+ vfprintf(stderr, fmt, argp);
+ va_end(argp);
}
static struct _cfsml_pointer_refstruct {
- struct _cfsml_pointer_refstruct *next;
- void *ptr;
+ struct _cfsml_pointer_refstruct *next;
+ void *ptr;
} *_cfsml_pointer_references = NULL;
static struct _cfsml_pointer_refstruct **_cfsml_pointer_references_current = &_cfsml_pointer_references;
@@ -221,221 +221,229 @@
static char *_cfsml_last_identifier_retrieved = NULL;
static void
-_cfsml_free_pointer_references_recursively(struct _cfsml_pointer_refstruct *refs, int free_pointers) {
- if (!refs)
- return;
-#ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
-#endif
+_cfsml_free_pointer_references_recursively(struct _cfsml_pointer_refstruct *refs, int free_pointers)
+{
+ if (!refs)
+ return;
+ #ifdef CFSML_DEBUG_MALLOC
+ SCI_MEMTEST;
+ #endif
- _cfsml_free_pointer_references_recursively(refs->next, free_pointers);
-#ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
+ _cfsml_free_pointer_references_recursively(refs->next, free_pointers);
+ #ifdef CFSML_DEBUG_MALLOC
+ SCI_MEMTEST;
- fprintf(stderr, "Freeing ptrref %p [%p] %s\n", refs->ptr, refs, free_pointers ?
- "ALL" : "cleanup only");
-#endif
+ fprintf(stderr,"Freeing ptrref %p [%p] %s\n", refs->ptr, refs, free_pointers?
+ "ALL": "cleanup only");
+ #endif
- if (free_pointers)
- free(refs->ptr);
+ if (free_pointers)
+ free(refs->ptr);
-#ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
-#endif
- free(refs);
-#ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
-#endif
+ #ifdef CFSML_DEBUG_MALLOC
+ SCI_MEMTEST;
+ #endif
+ free(refs);
+ #ifdef CFSML_DEBUG_MALLOC
+ SCI_MEMTEST;
+ #endif
}
static void
-_cfsml_free_pointer_references(struct _cfsml_pointer_refstruct **meta_ref, int free_pointers) {
- _cfsml_free_pointer_references_recursively(*meta_ref, free_pointers);
- *meta_ref = NULL;
- _cfsml_pointer_references_current = meta_ref;
+_cfsml_free_pointer_references(struct _cfsml_pointer_refstruct **meta_ref, int free_pointers)
+{
+ _cfsml_free_pointer_references_recursively(*meta_ref, free_pointers);
+ *meta_ref = NULL;
+ _cfsml_pointer_references_current = meta_ref;
}
static struct _cfsml_pointer_refstruct **
- _cfsml_get_current_refpointer() {
- return _cfsml_pointer_references_current;
+_cfsml_get_current_refpointer()
+{
+ return _cfsml_pointer_references_current;
}
-static void _cfsml_register_pointer(void *ptr) {
- struct _cfsml_pointer_refstruct *newref = (struct _cfsml_pointer_refstruct*)sci_malloc(sizeof(struct _cfsml_pointer_refstruct));
-#ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
- fprintf(stderr, "Registering ptrref %p [%p]\n", ptr, newref);
-#endif
- newref->next = *_cfsml_pointer_references_current;
- newref->ptr = ptr;
- *_cfsml_pointer_references_current = newref;
+static void _cfsml_register_pointer(void *ptr)
+{
+ struct _cfsml_pointer_refstruct *newref = (struct _cfsml_pointer_refstruct*)sci_malloc(sizeof (struct _cfsml_pointer_refstruct));
+ #ifdef CFSML_DEBUG_MALLOC
+ SCI_MEMTEST;
+ fprintf(stderr,"Registering ptrref %p [%p]\n", ptr, newref);
+ #endif
+ newref->next = *_cfsml_pointer_references_current;
+ newref->ptr = ptr;
+ *_cfsml_pointer_references_current = newref;
}
static char *
-_cfsml_mangle_string(const char *s) {
- const char *source = s;
- char c;
- char *target = (char *) sci_malloc(1 + strlen(s) * 2); /* We will probably need less than that */
- char *writer = target;
+_cfsml_mangle_string(const char *s)
+{
+ const char *source = s;
+ char c;
+ char *target = (char *) sci_malloc(1 + strlen(s) * 2); /* We will probably need less than that */
+ char *writer = target;
- while ((c = *source++)) {
+ while ((c = *source++)) {
- if (c < 32) { /* Special character? */
- *writer++ = '\\'; /* Escape... */
- c += ('a' - 1);
- } else if (c == '\\' || c == '"')
- *writer++ = '\\'; /* Escape, but do not change */
- *writer++ = c;
+ if (c < 32) { /* Special character? */
+ *writer++ = '\\'; /* Escape... */
+ c += ('a' - 1);
+ } else if (c == '\\' || c == '"')
+ *writer++ = '\\'; /* Escape, but do not change */
+ *writer++ = c;
- }
- *writer = 0; /* Terminate string */
+ }
+ *writer = 0; /* Terminate string */
- return (char *) sci_realloc(target, strlen(target) + 1);
+ return (char *) sci_realloc(target, strlen(target) + 1);
}
static char *
-_cfsml_unmangle_string(const char *s, unsigned int length) {
- char *target = (char *) sci_malloc(1 + strlen(s));
- char *writer = target;
- const char *source = s;
- const char *end = s + length;
- char c;
+_cfsml_unmangle_string(const char *s, unsigned int length)
+{
+ char *target = (char *) sci_malloc(1 + strlen(s));
+ char *writer = target;
+ const char *source = s;
+ const char *end = s + length;
+ char c;
- while ((source != end) && (c = *source++) && (c > 31)) {
- if (c == '\\') { /* Escaped character? */
- c = *source++;
- if ((c != '\\') && (c != '"')) /* Un-escape 0-31 only */
- c -= ('a' - 1);
- }
- *writer++ = c;
- }
- *writer = 0; /* Terminate string */
+ while ((source != end) && (c = *source++) && (c > 31)) {
+ if (c == '\\') { /* Escaped character? */
+ c = *source++;
+ if ((c != '\\') && (c != '"')) /* Un-escape 0-31 only */
+ c -= ('a' - 1);
+ }
+ *writer++ = c;
+ }
+ *writer = 0; /* Terminate string */
- return (char *) sci_realloc(target, strlen(target) + 1);
+ return (char *) sci_realloc(target, strlen(target) + 1);
}
static char *
-_cfsml_get_identifier(FILE *fd, int *line, int *hiteof, int *assignment) {
- int c;
- int mem = 32;
- int pos = 0;
- int done = 0;
- char *retval = (char *) sci_malloc(mem);
+_cfsml_get_identifier(FILE *fd, int *line, int *hiteof, int *assignment)
+{
+ int c;
+ int mem = 32;
+ int pos = 0;
+ int done = 0;
+ char *retval = (char *) sci_malloc(mem);
- if (_cfsml_last_identifier_retrieved) {
- free(_cfsml_last_identifier_retrieved);
- _cfsml_last_identifier_retrieved = NULL;
- }
+ if (_cfsml_last_identifier_retrieved) {
+ free(_cfsml_last_identifier_retrieved);
+ _cfsml_last_identifier_retrieved = NULL;
+ }
- while (isspace(c = fgetc(fd)) && (c != EOF));
- if (c == EOF) {
- _cfsml_error("Unexpected end of file at line %d\n", *line);
- free(retval);
- *hiteof = 1;
- return NULL;
- }
+ while (isspace(c = fgetc(fd)) && (c != EOF));
+ if (c == EOF) {
+ _cfsml_error("Unexpected end of file at line %d\n", *line);
+ free(retval);
+ *hiteof = 1;
+ return NULL;
+ }
- ungetc(c, fd);
+ ungetc(c, fd);
- while (((c = fgetc(fd)) != EOF) && ((pos == 0) || (c != '\n')) && (c != '=')) {
+ while (((c = fgetc(fd)) != EOF) && ((pos == 0) || (c != '\n')) && (c != '=')) {
- if (pos == mem - 1) /* Need more memory? */
- retval = (char *) sci_realloc(retval, mem *= 2);
+ if (pos == mem - 1) /* Need more memory? */
+ retval = (char *) sci_realloc(retval, mem *= 2);
- if (!isspace(c)) {
- if (done) {
- _cfsml_error("Single word identifier expected at line %d\n", *line);
- free(retval);
- return NULL;
- }
- retval[pos++] = c;
- } else
- if (pos != 0)
- done = 1; /* Finished the variable name */
- else if (c == '\n')
- ++(*line);
- }
+ if (!isspace(c)) {
+ if (done) {
+ _cfsml_error("Single word identifier expected at line %d\n", *line);
+ free(retval);
+ return NULL;
+ }
+ retval[pos++] = c;
+ } else
+ if (pos != 0)
+ done = 1; /* Finished the variable name */
+ else if (c == '\n')
+ ++(*line);
+ }
- if (c == EOF) {
- _cfsml_error("Unexpected end of file at line %d\n", *line);
- free(retval);
- *hiteof = 1;
- return NULL;
- }
+ if (c == EOF) {
+ _cfsml_error("Unexpected end of file at line %d\n", *line);
+ free(retval);
+ *hiteof = 1;
+ return NULL;
+ }
- if (c == '\n') {
- ++(*line);
- if (assignment)
- *assignment = 0;
- } else
- if (assignment)
- *assignment = 1;
+ if (c == '\n') {
+ ++(*line);
+ if (assignment)
+ *assignment = 0;
+ } else
+ if (assignment)
+ *assignment = 1;
- if (pos == 0) {
- _cfsml_error("Missing identifier in assignment at line %d\n", *line);
- free(retval);
- return NULL;
- }
+ if (pos == 0) {
+ _cfsml_error("Missing identifier in assignment at line %d\n", *line);
+ free(retval);
+ return NULL;
+ }
- if (pos == mem - 1) /* Need more memory? */
- retval = (char *) sci_realloc(retval, mem += 1);
+ if (pos == mem - 1) /* Need more memory? */
+ retval = (char *) sci_realloc(retval, mem += 1);
- retval[pos] = 0; /* Terminate string */
+ retval[pos] = 0; /* Terminate string */
#line 323 "savegame.cfsml"
- return _cfsml_last_identifier_retrieved = retval;
+ return _cfsml_last_identifier_retrieved = retval;
}
static char *
-_cfsml_get_value(FILE *fd, int *line, int *hiteof) {
- int c;
- int mem = 64;
- int pos = 0;
- char *retval = (char *) sci_malloc(mem);
+_cfsml_get_value(FILE *fd, int *line, int *hiteof)
+{
+ int c;
+ int mem = 64;
+ int pos = 0;
+ char *retval = (char *) sci_malloc(mem);
- if (_cfsml_last_value_retrieved) {
- free(_cfsml_last_value_retrieved);
- _cfsml_last_value_retrieved = NULL;
- }
+ if (_cfsml_last_value_retrieved) {
+ free(_cfsml_last_value_retrieved);
+ _cfsml_last_value_retrieved = NULL;
+ }
- while (((c = fgetc(fd)) != EOF) && (c != '\n')) {
+ while (((c = fgetc(fd)) != EOF) && (c != '\n')) {
- if (pos == mem - 1) /* Need more memory? */
- retval = (char *) sci_realloc(retval, mem *= 2);
+ if (pos == mem - 1) /* Need more memory? */
+ retval = (char *) sci_realloc(retval, mem *= 2);
- if (pos || (!isspace(c)))
- retval[pos++] = c;
+ if (pos || (!isspace(c)))
+ retval[pos++] = c;
- }
+ }
- while ((pos > 0) && (isspace(retval[pos - 1])))
- --pos; /* Strip trailing whitespace */
+ while ((pos > 0) && (isspace(retval[pos - 1])))
+ --pos; /* Strip trailing whitespace */
- if (c == EOF)
- *hiteof = 1;
+ if (c == EOF)
+ *hiteof = 1;
- if (pos == 0) {
- _cfsml_error("Missing value in assignment at line %d\n", *line);
- free(retval);
- return NULL;
- }
+ if (pos == 0) {
+ _cfsml_error("Missing value in assignment at line %d\n", *line);
+ free(retval);
+ return NULL;
+ }
- if (c == '\n')
- ++(*line);
+ if (c == '\n')
+ ++(*line);
- if (pos == mem - 1) /* Need more memory? */
- retval = (char *) sci_realloc(retval, mem += 1);
+ if (pos == mem - 1) /* Need more memory? */
+ retval = (char *) sci_realloc(retval, mem += 1);
- retval[pos] = 0; /* Terminate string */
+ retval[pos] = 0; /* Terminate string */
#line 380 "savegame.cfsml"
- return (_cfsml_last_value_retrieved = (char *) sci_realloc(retval, strlen(retval) + 1));
- /* Re-allocate; this value might be used for quite some while (if we are
- ** restoring a string)
- */
+ return (_cfsml_last_value_retrieved = (char *) sci_realloc(retval, strlen(retval) + 1));
+ /* Re-allocate; this value might be used for quite some while (if we are
+ ** restoring a string)
+ */
}
#line 432 "savegame.cfsml"
static void
@@ -637,3404 +645,3482 @@
#line 445 "savegame.cfsml"
static void
-_cfsml_write_synonym_t(FILE *fh, synonym_t* save_struc) {
- int min, max, i;
+_cfsml_write_synonym_t(FILE *fh, synonym_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "replaceant = ");
- _cfsml_write_int(fh, (int*) &(save_struc->replaceant));
- fprintf(fh, "\n");
- fprintf(fh, "replacement = ");
- _cfsml_write_int(fh, (int*) &(save_struc->replacement));
- fprintf(fh, "\n");
- fprintf(fh, "}");
+ fprintf(fh, "{\n");
+ fprintf(fh, "replaceant = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->replaceant));
+ fprintf(fh, "\n");
+ fprintf(fh, "replacement = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->replacement));
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_synonym_t(FILE *fh, synonym_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
- int min, max, i;
+_cfsml_read_synonym_t(FILE *fh, synonym_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
+int min, max, i;
#line 600 "savegame.cfsml"
- int assignment, closed, done;
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record synonym_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
- return CFSML_FAILURE;
- };
- closed = 0;
- do {
- const char *value;
- token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+ if (strcmp(lastval, "{")) {
+ _cfsml_error("Reading record synonym_t; expected opening braces in line %d, got \"%s\"\n",*line, lastval);
+ return CFSML_FAILURE;
+ };
+ closed = 0;
+ do {
+ const char *value;
+ token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
- if (!token) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!assignment) {
- if (!strcmp(token, "}"))
- closed = 1;
- else {
- _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else {
- value = "";
- while (!value || !strcmp(value, ""))
- value = _cfsml_get_value(fh, line, hiteof);
- if (!value) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!strcmp(token, "replaceant")) {
+ if (!token) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!assignment) {
+ if (!strcmp(token, "}"))
+ closed = 1;
+ else {
+ _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else {
+ value = "";
+ while (!value || !strcmp(value, ""))
+ value = _cfsml_get_value(fh, line, hiteof);
+ if (!value) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!strcmp(token, "replaceant")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->replaceant), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for replaceant at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "replacement")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->replaceant), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for replaceant at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "replacement")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->replacement), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for replacement at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
+ if (_cfsml_read_int(fh, (int*) &(save_struc->replacement), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for replacement at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
#line 759 "savegame.cfsml"
- {
- _cfsml_error("synonym_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
- } while (!closed); /* Until closing braces are hit */
- return CFSML_SUCCESS;
+ {
+ _cfsml_error("synonym_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
+ }
+ } while (!closed); /* Until closing braces are hit */
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_sfx_state_t(FILE *fh, sfx_state_t* save_struc) {
- int min, max, i;
+_cfsml_write_sfx_state_t(FILE *fh, sfx_state_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "songlib = ");
- write_songlib_t(fh, (songlib_t*) &(save_struc->songlib));
- fprintf(fh, "\n");
- fprintf(fh, "}");
+ fprintf(fh, "{\n");
+ fprintf(fh, "songlib = ");
+ write_songlib_t(fh, (songlib_t*) &(save_struc->songlib));
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_sfx_state_t(FILE *fh, sfx_state_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
- int min, max, i;
+_cfsml_read_sfx_state_t(FILE *fh, sfx_state_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
+int min, max, i;
#line 600 "savegame.cfsml"
- int assignment, closed, done;
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record sfx_state_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
- return CFSML_FAILURE;
- };
- closed = 0;
- do {
- const char *value;
- token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+ if (strcmp(lastval, "{")) {
+ _cfsml_error("Reading record sfx_state_t; expected opening braces in line %d, got \"%s\"\n",*line, lastval);
+ return CFSML_FAILURE;
+ };
+ closed = 0;
+ do {
+ const char *value;
+ token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
- if (!token) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!assignment) {
- if (!strcmp(token, "}"))
- closed = 1;
- else {
- _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else {
- value = "";
- while (!value || !strcmp(value, ""))
- value = _cfsml_get_value(fh, line, hiteof);
- if (!value) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!strcmp(token, "songlib")) {
+ if (!token) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!assignment) {
+ if (!strcmp(token, "}"))
+ closed = 1;
+ else {
+ _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else {
+ value = "";
+ while (!value || !strcmp(value, ""))
+ value = _cfsml_get_value(fh, line, hiteof);
+ if (!value) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!strcmp(token, "songlib")) {
#line 750 "savegame.cfsml"
- if (read_songlib_t(fh, (songlib_t*) &(save_struc->songlib), value, line, hiteof)) {
- _cfsml_error("Token expected by read_songlib_t() for songlib at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
+ if (read_songlib_t(fh, (songlib_t*) &(save_struc->songlib), value, line, hiteof)) {
+ _cfsml_error("Token expected by read_songlib_t() for songlib at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
#line 759 "savegame.cfsml"
- {
- _cfsml_error("sfx_state_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
- } while (!closed); /* Until closing braces are hit */
- return CFSML_SUCCESS;
+ {
+ _cfsml_error("sfx_state_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
+ }
+ } while (!closed); /* Until closing braces are hit */
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_clone_entry_t(FILE *fh, clone_entry_t* save_struc) {
- int min, max, i;
+_cfsml_write_clone_entry_t(FILE *fh, clone_entry_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "next_free = ");
- _cfsml_write_int(fh, (int*) &(save_struc->next_free));
- fprintf(fh, "\n");
- fprintf(fh, "entry = ");
- _cfsml_write_clone_t(fh, (clone_t*) &(save_struc->entry));
- fprintf(fh, "\n");
- fprintf(fh, "}");
+ fprintf(fh, "{\n");
+ fprintf(fh, "next_free = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->next_free));
+ fprintf(fh, "\n");
+ fprintf(fh, "entry = ");
+ _cfsml_write_clone_t(fh, (clone_t*) &(save_struc->entry));
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_clone_entry_t(FILE *fh, clone_entry_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
- int min, max, i;
+_cfsml_read_clone_entry_t(FILE *fh, clone_entry_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
+int min, max, i;
#line 600 "savegame.cfsml"
- int assignment, closed, done;
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record clone_entry_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
- return CFSML_FAILURE;
- };
- closed = 0;
- do {
- const char *value;
- token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+ if (strcmp(lastval, "{")) {
+ _cfsml_error("Reading record clone_entry_t; expected opening braces in line %d, got \"%s\"\n",*line, lastval);
+ return CFSML_FAILURE;
+ };
+ closed = 0;
+ do {
+ const char *value;
+ token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
- if (!token) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!assignment) {
- if (!strcmp(token, "}"))
- closed = 1;
- else {
- _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else {
- value = "";
- while (!value || !strcmp(value, ""))
- value = _cfsml_get_value(fh, line, hiteof);
- if (!value) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!strcmp(token, "next_free")) {
+ if (!token) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!assignment) {
+ if (!strcmp(token, "}"))
+ closed = 1;
+ else {
+ _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else {
+ value = "";
+ while (!value || !strcmp(value, ""))
+ value = _cfsml_get_value(fh, line, hiteof);
+ if (!value) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!strcmp(token, "next_free")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->next_free), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for next_free at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "entry")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->next_free), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for next_free at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "entry")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_clone_t(fh, (clone_t*) &(save_struc->entry), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_clone_t() for entry at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
+ if (_cfsml_read_clone_t(fh, (clone_t*) &(save_struc->entry), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_clone_t() for entry at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
#line 759 "savegame.cfsml"
- {
- _cfsml_error("clone_entry_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
- } while (!closed); /* Until closing braces are hit */
- return CFSML_SUCCESS;
+ {
+ _cfsml_error("clone_entry_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
+ }
+ } while (!closed); /* Until closing braces are hit */
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_object_t(FILE *fh, object_t* save_struc) {
- int min, max, i;
+_cfsml_write_object_t(FILE *fh, object_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "flags = ");
- _cfsml_write_int(fh, (int*) &(save_struc->flags));
- fprintf(fh, "\n");
- fprintf(fh, "pos = ");
- write_reg_t(fh, (reg_t*) &(save_struc->pos));
- fprintf(fh, "\n");
- fprintf(fh, "variables_nr = ");
- _cfsml_write_int(fh, (int*) &(save_struc->variables_nr));
- fprintf(fh, "\n");
- fprintf(fh, "variable_names_nr = ");
- _cfsml_write_int(fh, (int*) &(save_struc->variable_names_nr));
- fprintf(fh, "\n");
- fprintf(fh, "methods_nr = ");
- _cfsml_write_int(fh, (int*) &(save_struc->methods_nr));
- fprintf(fh, "\n");
- fprintf(fh, "variables = ");
- min = max = save_struc->variables_nr;
- if (!save_struc->variables)
- min = max = 0; /* Don't write if it points to NULL */
+ fprintf(fh, "{\n");
+ fprintf(fh, "flags = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->flags));
+ fprintf(fh, "\n");
+ fprintf(fh, "pos = ");
+ write_reg_t(fh, (reg_t*) &(save_struc->pos));
+ fprintf(fh, "\n");
+ fprintf(fh, "variables_nr = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->variables_nr));
+ fprintf(fh, "\n");
+ fprintf(fh, "variable_names_nr = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->variable_names_nr));
+ fprintf(fh, "\n");
+ fprintf(fh, "methods_nr = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->methods_nr));
+ fprintf(fh, "\n");
+ fprintf(fh, "variables = ");
+ min = max = save_struc->variables_nr;
+ if (!save_struc->variables)
+ min = max = 0; /* Don't write if it points to NULL */
#line 491 "savegame.cfsml"
- fprintf(fh, "[%d][\n", max);
- for (i = 0; i < min; i++) {
- write_reg_t(fh, &(save_struc->variables[i]));
- fprintf(fh, "\n");
- }
- fprintf(fh, "]");
- fprintf(fh, "\n");
- fprintf(fh, "}");
+ fprintf(fh, "[%d][\n", max);
+ for (i = 0; i < min; i++) {
+ write_reg_t(fh, &(save_struc->variables[i]));
+ fprintf(fh, "\n");
+ }
+ fprintf(fh, "]");
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_object_t(FILE *fh, object_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
- int min, max, i;
+_cfsml_read_object_t(FILE *fh, object_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
+int min, max, i;
#line 600 "savegame.cfsml"
- int assignment, closed, done;
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record object_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
- return CFSML_FAILURE;
- };
- closed = 0;
- do {
- const char *value;
- token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+ if (strcmp(lastval, "{")) {
+ _cfsml_error("Reading record object_t; expected opening braces in line %d, got \"%s\"\n",*line, lastval);
+ return CFSML_FAILURE;
+ };
+ closed = 0;
+ do {
+ const char *value;
+ token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
- if (!token) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!assignment) {
- if (!strcmp(token, "}"))
- closed = 1;
- else {
- _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else {
- value = "";
- while (!value || !strcmp(value, ""))
- value = _cfsml_get_value(fh, line, hiteof);
- if (!value) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!strcmp(token, "flags")) {
+ if (!token) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!assignment) {
+ if (!strcmp(token, "}"))
+ closed = 1;
+ else {
+ _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else {
+ value = "";
+ while (!value || !strcmp(value, ""))
+ value = _cfsml_get_value(fh, line, hiteof);
+ if (!value) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!strcmp(token, "flags")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->flags), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for flags at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "pos")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->flags), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for flags at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "pos")) {
#line 750 "savegame.cfsml"
- if (read_reg_t(fh, (reg_t*) &(save_struc->pos), value, line, hiteof)) {
- _cfsml_error("Token expected by read_reg_t() for pos at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "variables_nr")) {
+ if (read_reg_t(fh, (reg_t*) &(save_struc->pos), value, line, hiteof)) {
+ _cfsml_error("Token expected by read_reg_t() for pos at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "variables_nr")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->variables_nr), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for variables_nr at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "variable_names_nr")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->variables_nr), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for variables_nr at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "variable_names_nr")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->variable_names_nr), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for variable_names_nr at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "methods_nr")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->variable_names_nr), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for variable_names_nr at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "methods_nr")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->methods_nr), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for methods_nr at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "variables")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->methods_nr), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for methods_nr at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "variables")) {
#line 664 "savegame.cfsml"
- if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
- _cfsml_error("Opening brackets expected at line %d\n", *line);
- return CFSML_FAILURE;
- }
+ if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
+ _cfsml_error("Opening brackets expected at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
#line 674 "savegame.cfsml"
- /* Prepare to restore dynamic array */
- max = strtol(value + 1, NULL, 0);
- if (max < 0) {
- _cfsml_error("Invalid number of elements to allocate for dynamic array '%s' at line %d\n", token, *line);
- return CFSML_FAILURE;
- }
+ /* Prepare to restore dynamic array */
+ max = strtol(value + 1, NULL, 0);
+ if (max < 0) {
+ _cfsml_error("Invalid number of elements to allocate for dynamic array '%s' at line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
- if (max) {
- save_struc->variables = (reg_t *) sci_malloc(max * sizeof(reg_t));
+ if (max) {
+ save_struc->variables = (reg_t *) sci_malloc(max * sizeof(reg_t));
#ifdef SATISFY_PURIFY
- memset(save_struc->variables, 0, max * sizeof(reg_t));
+ memset(save_struc->variables, 0, max * sizeof(reg_t));
#endif
- _cfsml_register_pointer(save_struc->variables);
- } else
- save_struc->variables = NULL;
+ _cfsml_register_pointer(save_struc->variables);
+ }
+ else
+ save_struc->variables = NULL;
#line 700 "savegame.cfsml"
- done = i = 0;
- do {
- if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
+ done = i = 0;
+ do {
+ if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
#line 708 "savegame.cfsml"
- _cfsml_error("Token expected at line %d\n", *line);
- return 1;
- }
- if (strcmp(value, "]")) {
- if (i == max) {
- _cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
- return CFSML_FAILURE;
- }
- if (read_reg_t(fh, &(save_struc->variables[i++]), value, line, hiteof)) {
- _cfsml_error("Token expected by read_reg_t() for variables[i++] at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else done = 1;
- } while (!done);
- save_struc->variables_nr = max ; /* Set array size accordingly */
- } else
+ _cfsml_error("Token expected at line %d\n", *line);
+ return 1;
+ }
+ if (strcmp(value, "]")) {
+ if (i == max) {
+ _cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
+ return CFSML_FAILURE;
+ }
+ if (read_reg_t(fh, &(save_struc->variables[i++]), value, line, hiteof)) {
+ _cfsml_error("Token expected by read_reg_t() for variables[i++] at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else done = 1;
+ } while (!done);
+ save_struc->variables_nr = max ; /* Set array size accordingly */
+ } else
#line 759 "savegame.cfsml"
- {
- _cfsml_error("object_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
- } while (!closed); /* Until closing braces are hit */
- return CFSML_SUCCESS;
+ {
+ _cfsml_error("object_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
+ }
+ } while (!closed); /* Until closing braces are hit */
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_string(FILE *fh, char ** save_struc) {
+_cfsml_write_string(FILE *fh, char ** save_struc)
+{
#line 455 "savegame.cfsml"
- if (!(*save_struc))
- fprintf(fh, "\\null\\");
- else {
- char *token = _cfsml_mangle_string((const char *) * save_struc);
- fprintf(fh, "\"%s\"", token);
- free(token);
- }
+ if (!(*save_struc))
+ fprintf(fh, "\\null\\");
+ else {
+ char *token = _cfsml_mangle_string((const char *) *save_struc);
+ fprintf(fh, "\"%s\"", token);
+ free(token);
+ }
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_string(FILE *fh, char ** save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
+_cfsml_read_string(FILE *fh, char ** save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
#line 578 "savegame.cfsml"
- if (strcmp(lastval, "\\null\\")) { /* null pointer? */
- unsigned int length = strlen(lastval);
- if (*lastval == '"') { /* Quoted string? */
- while (lastval[length] != '"')
- --length;
+ if (strcmp(lastval, "\\null\\")) { /* null pointer? */
+ unsigned int length = strlen(lastval);
+ if (*lastval == '"') { /* Quoted string? */
+ while (lastval[length] != '"')
+ --length;
- if (!length) { /* No matching double-quotes? */
- _cfsml_error("Unbalanced quotes at line %d\n", *line);
- return CFSML_FAILURE;
- }
+ if (!length) { /* No matching double-quotes? */
+ _cfsml_error("Unbalanced quotes at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
- lastval++; /* ...and skip the opening quotes locally */
- length--;
- }
- *save_struc = _cfsml_unmangle_string(lastval, length);
- _cfsml_register_pointer(*save_struc);
- return CFSML_SUCCESS;
- } else {
- *save_struc = NULL;
- return CFSML_SUCCESS;
- }
+ lastval++; /* ...and skip the opening quotes locally */
+ length--;
+ }
+ *save_struc = _cfsml_unmangle_string(lastval, length);
+ _cfsml_register_pointer(*save_struc);
+ return CFSML_SUCCESS;
+ } else {
+ *save_struc = NULL;
+ return CFSML_SUCCESS;
+ }
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_menubar_t(FILE *fh, menubar_t* save_struc) {
- int min, max, i;
+_cfsml_write_menubar_t(FILE *fh, menubar_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "menus = ");
- min = max = save_struc->menus_nr;
- if (!save_struc->menus)
- min = max = 0; /* Don't write if it points to NULL */
+ fprintf(fh, "{\n");
+ fprintf(fh, "menus = ");
+ min = max = save_struc->menus_nr;
+ if (!save_struc->menus)
+ min = max = 0; /* Don't write if it points to NULL */
#line 491 "savegame.cfsml"
- fprintf(fh, "[%d][\n", max);
- for (i = 0; i < min; i++) {
- _cfsml_write_menu_t(fh, &(save_struc->menus[i]));
- fprintf(fh, "\n");
- }
- fprintf(fh, "]");
- fprintf(fh, "\n");
- fprintf(fh, "}");
+ fprintf(fh, "[%d][\n", max);
+ for (i = 0; i < min; i++) {
+ _cfsml_write_menu_t(fh, &(save_struc->menus[i]));
+ fprintf(fh, "\n");
+ }
+ fprintf(fh, "]");
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_menubar_t(FILE *fh, menubar_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
- int min, max, i;
+_cfsml_read_menubar_t(FILE *fh, menubar_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
+int min, max, i;
#line 600 "savegame.cfsml"
- int assignment, closed, done;
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record menubar_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
- return CFSML_FAILURE;
- };
- closed = 0;
- do {
- const char *value;
- token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+ if (strcmp(lastval, "{")) {
+ _cfsml_error("Reading record menubar_t; expected opening braces in line %d, got \"%s\"\n",*line, lastval);
+ return CFSML_FAILURE;
+ };
+ closed = 0;
+ do {
+ const char *value;
+ token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
- if (!token) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!assignment) {
- if (!strcmp(token, "}"))
- closed = 1;
- else {
- _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else {
- value = "";
- while (!value || !strcmp(value, ""))
- value = _cfsml_get_value(fh, line, hiteof);
- if (!value) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!strcmp(token, "menus")) {
+ if (!token) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!assignment) {
+ if (!strcmp(token, "}"))
+ closed = 1;
+ else {
+ _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else {
+ value = "";
+ while (!value || !strcmp(value, ""))
+ value = _cfsml_get_value(fh, line, hiteof);
+ if (!value) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!strcmp(token, "menus")) {
#line 664 "savegame.cfsml"
- if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
- _cfsml_error("Opening brackets expected at line %d\n", *line);
- return CFSML_FAILURE;
- }
+ if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
+ _cfsml_error("Opening brackets expected at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
#line 674 "savegame.cfsml"
- /* Prepare to restore dynamic array */
- max = strtol(value + 1, NULL, 0);
- if (max < 0) {
- _cfsml_error("Invalid number of elements to allocate for dynamic array '%s' at line %d\n", token, *line);
- return CFSML_FAILURE;
- }
+ /* Prepare to restore dynamic array */
+ max = strtol(value + 1, NULL, 0);
+ if (max < 0) {
+ _cfsml_error("Invalid number of elements to allocate for dynamic array '%s' at line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
- if (max) {
- save_struc->menus = (menu_t *) sci_malloc(max * sizeof(menu_t));
+ if (max) {
+ save_struc->menus = (menu_t *) sci_malloc(max * sizeof(menu_t));
#ifdef SATISFY_PURIFY
- memset(save_struc->menus, 0, max * sizeof(menu_t));
+ memset(save_struc->menus, 0, max * sizeof(menu_t));
#endif
- _cfsml_register_pointer(save_struc->menus);
- } else
- save_struc->menus = NULL;
+ _cfsml_register_pointer(save_struc->menus);
+ }
+ else
+ save_struc->menus = NULL;
#line 700 "savegame.cfsml"
- done = i = 0;
- do {
- if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
+ done = i = 0;
+ do {
+ if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
#line 708 "savegame.cfsml"
- _cfsml_error("Token expected at line %d\n", *line);
- return 1;
- }
- if (strcmp(value, "]")) {
- if (i == max) {
- _cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
- return CFSML_FAILURE;
- }
- if (_cfsml_read_menu_t(fh, &(save_struc->menus[i++]), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_menu_t() for menus[i++] at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else done = 1;
- } while (!done);
- save_struc->menus_nr = max ; /* Set array size accordingly */
- } else
+ _cfsml_error("Token expected at line %d\n", *line);
+ return 1;
+ }
+ if (strcmp(value, "]")) {
+ if (i == max) {
+ _cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
+ return CFSML_FAILURE;
+ }
+ if (_cfsml_read_menu_t(fh, &(save_struc->menus[i++]), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_menu_t() for menus[i++] at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else done = 1;
+ } while (!done);
+ save_struc->menus_nr = max ; /* Set array size accordingly */
+ } else
#line 759 "savegame.cfsml"
- {
- _cfsml_error("menubar_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
- } while (!closed); /* Until closing braces are hit */
- return CFSML_SUCCESS;
+ {
+ _cfsml_error("menubar_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
+ }
+ } while (!closed); /* Until closing braces are hit */
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_size_t(FILE *fh, size_t* save_struc) {
- fprintf(fh, "%li", (long) *save_struc);
+_cfsml_write_size_t(FILE *fh, size_t* save_struc)
+{
+ fprintf(fh, "%li", (long) *save_struc);
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_size_t(FILE *fh, size_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
+_cfsml_read_size_t(FILE *fh, size_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
#line 565 "savegame.cfsml"
- *save_struc = strtol(lastval, &token, 0);
- if ((*save_struc == 0) && (token == lastval)) {
- _cfsml_error("strtol failed at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (*token != 0) {
- _cfsml_error("Non-integer encountered while parsing int value at line %d\n", *line);
- return CFSML_FAILURE;
- }
- return CFSML_SUCCESS;
+ *save_struc = strtol(lastval, &token, 0);
+ if ( (*save_struc == 0) && (token == lastval) ) {
+ _cfsml_error("strtol failed at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (*token != 0) {
+ _cfsml_error("Non-integer encountered while parsing int value at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_list_entry_t(FILE *fh, list_entry_t* save_struc) {
- int min, max, i;
+_cfsml_write_list_entry_t(FILE *fh, list_entry_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "next_free = ");
- _cfsml_write_int(fh, (int*) &(save_struc->next_free));
- fprintf(fh, "\n");
- fprintf(fh, "entry = ");
- _cfsml_write_list_t(fh, (list_t*) &(save_struc->entry));
- fprintf(fh, "\n");
- fprintf(fh, "}");
+ fprintf(fh, "{\n");
+ fprintf(fh, "next_free = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->next_free));
+ fprintf(fh, "\n");
+ fprintf(fh, "entry = ");
+ _cfsml_write_list_t(fh, (list_t*) &(save_struc->entry));
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_list_entry_t(FILE *fh, list_entry_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
- int min, max, i;
+_cfsml_read_list_entry_t(FILE *fh, list_entry_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
+int min, max, i;
#line 600 "savegame.cfsml"
- int assignment, closed, done;
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record list_entry_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
- return CFSML_FAILURE;
- };
- closed = 0;
- do {
- const char *value;
- token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+ if (strcmp(lastval, "{")) {
+ _cfsml_error("Reading record list_entry_t; expected opening braces in line %d, got \"%s\"\n",*line, lastval);
+ return CFSML_FAILURE;
+ };
+ closed = 0;
+ do {
+ const char *value;
+ token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
- if (!token) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!assignment) {
- if (!strcmp(token, "}"))
- closed = 1;
- else {
- _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else {
- value = "";
- while (!value || !strcmp(value, ""))
- value = _cfsml_get_value(fh, line, hiteof);
- if (!value) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!strcmp(token, "next_free")) {
+ if (!token) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!assignment) {
+ if (!strcmp(token, "}"))
+ closed = 1;
+ else {
+ _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else {
+ value = "";
+ while (!value || !strcmp(value, ""))
+ value = _cfsml_get_value(fh, line, hiteof);
+ if (!value) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!strcmp(token, "next_free")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->next_free), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for next_free at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "entry")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->next_free), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for next_free at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "entry")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_list_t(fh, (list_t*) &(save_struc->entry), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_list_t() for entry at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
+ if (_cfsml_read_list_t(fh, (list_t*) &(save_struc->entry), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_list_t() for entry at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
#line 759 "savegame.cfsml"
- {
- _cfsml_error("list_entry_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
- } while (!closed); /* Until closing braces are hit */
- return CFSML_SUCCESS;
+ {
+ _cfsml_error("list_entry_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
+ }
+ } while (!closed); /* Until closing braces are hit */
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_int_hash_map_t(FILE *fh, int_hash_map_t* save_struc) {
- int min, max, i;
+_cfsml_write_int_hash_map_t(FILE *fh, int_hash_map_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "base_value = ");
- _cfsml_write_int(fh, (int*) &(save_struc->base_value));
- fprintf(fh, "\n");
- fprintf(fh, "nodes = ");
- min = max = DCS_INT_HASH_MAX + 1;
+ fprintf(fh, "{\n");
+ fprintf(fh, "base_value = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->base_value));
+ fprintf(fh, "\n");
+ fprintf(fh, "nodes = ");
+ min = max = DCS_INT_HASH_MAX+1;
#line 491 "savegame.cfsml"
- fprintf(fh, "[%d][\n", max);
- for (i = 0; i < min; i++) {
- write_int_hash_map_node_tp(fh, &(save_struc->nodes[i]));
- fprintf(fh, "\n");
- }
- fprintf(fh, "]");
- fprintf(fh, "\n");
- fprintf(fh, "}");
+ fprintf(fh, "[%d][\n", max);
+ for (i = 0; i < min; i++) {
+ write_int_hash_map_node_tp(fh, &(save_struc->nodes[i]));
+ fprintf(fh, "\n");
+ }
+ fprintf(fh, "]");
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_int_hash_map_t(FILE *fh, int_hash_map_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
- int min, max, i;
+_cfsml_read_int_hash_map_t(FILE *fh, int_hash_map_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
+int min, max, i;
#line 600 "savegame.cfsml"
- int assignment, closed, done;
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record int_hash_map_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
- return CFSML_FAILURE;
- };
- closed = 0;
- do {
- const char *value;
- token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+ if (strcmp(lastval, "{")) {
+ _cfsml_error("Reading record int_hash_map_t; expected opening braces in line %d, got \"%s\"\n",*line, lastval);
+ return CFSML_FAILURE;
+ };
+ closed = 0;
+ do {
+ const char *value;
+ token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
- if (!token) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!assignment) {
- if (!strcmp(token, "}"))
- closed = 1;
- else {
- _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else {
- value = "";
- while (!value || !strcmp(value, ""))
- value = _cfsml_get_value(fh, line, hiteof);
- if (!value) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!strcmp(token, "base_value")) {
+ if (!token) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!assignment) {
+ if (!strcmp(token, "}"))
+ closed = 1;
+ else {
+ _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else {
+ value = "";
+ while (!value || !strcmp(value, ""))
+ value = _cfsml_get_value(fh, line, hiteof);
+ if (!value) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!strcmp(token, "base_value")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->base_value), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for base_value at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "nodes")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->base_value), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for base_value at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "nodes")) {
#line 664 "savegame.cfsml"
- if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
- _cfsml_error("Opening brackets expected at line %d\n", *line);
- return CFSML_FAILURE;
- }
- /* Prepare to restore static array */
- max = DCS_INT_HASH_MAX + 1;
+ if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
+ _cfsml_error("Opening brackets expected at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ /* Prepare to restore static array */
+ max = DCS_INT_HASH_MAX+1;
#line 700 "savegame.cfsml"
- done = i = 0;
- do {
- if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
+ done = i = 0;
+ do {
+ if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
#line 708 "savegame.cfsml"
- _cfsml_error("Token expected at line %d\n", *line);
- return 1;
- }
- if (strcmp(value, "]")) {
- if (i == max) {
- _cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
- return CFSML_FAILURE;
- }
- if (read_int_hash_map_node_tp(fh, &(save_struc->nodes[i++]), value, line, hiteof)) {
- _cfsml_error("Token expected by read_int_hash_map_node_tp() for nodes[i++] at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else done = 1;
- } while (!done);
- } else
+ _cfsml_error("Token expected at line %d\n", *line);
+ return 1;
+ }
+ if (strcmp(value, "]")) {
+ if (i == max) {
+ _cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
+ return CFSML_FAILURE;
+ }
+ if (read_int_hash_map_node_tp(fh, &(save_struc->nodes[i++]), value, line, hiteof)) {
+ _cfsml_error("Token expected by read_int_hash_map_node_tp() for nodes[i++] at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else done = 1;
+ } while (!done);
+ } else
#line 759 "savegame.cfsml"
- {
- _cfsml_error("int_hash_map_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
- } while (!closed); /* Until closing braces are hit */
- return CFSML_SUCCESS;
+ {
+ _cfsml_error("int_hash_map_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
+ }
+ } while (!closed); /* Until closing braces are hit */
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_gint16(FILE *fh, gint16* save_struc) {
- fprintf(fh, "%li", (long) *save_struc);
+_cfsml_write_gint16(FILE *fh, gint16* save_struc)
+{
+ fprintf(fh, "%li", (long) *save_struc);
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_gint16(FILE *fh, gint16* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
+_cfsml_read_gint16(FILE *fh, gint16* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
#line 565 "savegame.cfsml"
- *save_struc = strtol(lastval, &token, 0);
- if ((*save_struc == 0) && (token == lastval)) {
- _cfsml_error("strtol failed at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (*token != 0) {
- _cfsml_error("Non-integer encountered while parsing int value at line %d\n", *line);
- return CFSML_FAILURE;
- }
- return CFSML_SUCCESS;
+ *save_struc = strtol(lastval, &token, 0);
+ if ( (*save_struc == 0) && (token == lastval) ) {
+ _cfsml_error("strtol failed at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (*token != 0) {
+ _cfsml_error("Non-integer encountered while parsing int value at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_song_t(FILE *fh, song_t* save_struc) {
- int min, max, i;
+_cfsml_write_song_t(FILE *fh, song_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "handle = ");
- _cfsml_write_song_handle_t(fh, (song_handle_t*) &(save_struc->handle));
- fprintf(fh, "\n");
- fprintf(fh, "resource_num = ");
- _cfsml_write_int(fh, (int*) &(save_struc->resource_num));
- fprintf(fh, "\n");
- fprintf(fh, "priority = ");
- _cfsml_write_int(fh, (int*) &(save_struc->priority));
- fprintf(fh, "\n");
- fprintf(fh, "status = ");
- _cfsml_write_int(fh, (int*) &(save_struc->status));
- fprintf(fh, "\n");
- fprintf(fh, "restore_behavior = ");
- _cfsml_write_int(fh, (int*) &(save_struc->restore_behavior));
- fprintf(fh, "\n");
- fprintf(fh, "restore_time = ");
- _cfsml_write_int(fh, (int*) &(save_struc->restore_time));
- fprintf(fh, "\n");
- fprintf(fh, "loops = ");
- _cfsml_write_int(fh, (int*) &(save_struc->loops));
- fprintf(fh, "\n");
- fprintf(fh, "hold = ");
- _cfsml_write_int(fh, (int*) &(save_struc->hold));
- fprintf(fh, "\n");
- fprintf(fh, "}");
+ fprintf(fh, "{\n");
+ fprintf(fh, "handle = ");
+ _cfsml_write_song_handle_t(fh, (song_handle_t*) &(save_struc->handle));
+ fprintf(fh, "\n");
+ fprintf(fh, "resource_num = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->resource_num));
+ fprintf(fh, "\n");
+ fprintf(fh, "priority = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->priority));
+ fprintf(fh, "\n");
+ fprintf(fh, "status = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->status));
+ fprintf(fh, "\n");
+ fprintf(fh, "restore_behavior = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->restore_behavior));
+ fprintf(fh, "\n");
+ fprintf(fh, "restore_time = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->restore_time));
+ fprintf(fh, "\n");
+ fprintf(fh, "loops = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->loops));
+ fprintf(fh, "\n");
+ fprintf(fh, "hold = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->hold));
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_song_t(FILE *fh, song_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
- int min, max, i;
+_cfsml_read_song_t(FILE *fh, song_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
+int min, max, i;
#line 600 "savegame.cfsml"
- int assignment, closed, done;
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record song_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
- return CFSML_FAILURE;
- };
- closed = 0;
- do {
- const char *value;
- token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+ if (strcmp(lastval, "{")) {
+ _cfsml_error("Reading record song_t; expected opening braces in line %d, got \"%s\"\n",*line, lastval);
+ return CFSML_FAILURE;
+ };
+ closed = 0;
+ do {
+ const char *value;
+ token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
- if (!token) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!assignment) {
- if (!strcmp(token, "}"))
- closed = 1;
- else {
- _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else {
- value = "";
- while (!value || !strcmp(value, ""))
- value = _cfsml_get_value(fh, line, hiteof);
- if (!value) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!strcmp(token, "handle")) {
+ if (!token) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!assignment) {
+ if (!strcmp(token, "}"))
+ closed = 1;
+ else {
+ _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else {
+ value = "";
+ while (!value || !strcmp(value, ""))
+ value = _cfsml_get_value(fh, line, hiteof);
+ if (!value) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!strcmp(token, "handle")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_song_handle_t(fh, (song_handle_t*) &(save_struc->handle), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_song_handle_t() for handle at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "resource_num")) {
+ if (_cfsml_read_song_handle_t(fh, (song_handle_t*) &(save_struc->handle), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_song_handle_t() for handle at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "resource_num")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->resource_num), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for resource_num at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "priority")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->resource_num), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for resource_num at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "priority")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->priority), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for priority at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "status")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->priority), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for priority at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "status")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->status), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for status at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "restore_behavior")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->status), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for status at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "restore_behavior")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->restore_behavior), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for restore_behavior at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "restore_time")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->restore_behavior), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for restore_behavior at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "restore_time")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->restore_time), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for restore_time at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "loops")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->restore_time), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for restore_time at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "loops")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->loops), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for loops at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "hold")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->loops), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for loops at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "hold")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->hold), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for hold at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
+ if (_cfsml_read_int(fh, (int*) &(save_struc->hold), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for hold at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
#line 759 "savegame.cfsml"
- {
- _cfsml_error("song_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
- } while (!closed); /* Until closing braces are hit */
- return CFSML_SUCCESS;
+ {
+ _cfsml_error("song_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
+ }
+ } while (!closed); /* Until closing braces are hit */
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_menu_item_t(FILE *fh, menu_item_t* save_struc) {
- int min, max, i;
+_cfsml_write_menu_item_t(FILE *fh, menu_item_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "type = ");
- _cfsml_write_int(fh, (int*) &(save_struc->type));
- fprintf(fh, "\n");
- fprintf(fh, "keytext = ");
- _cfsml_write_string(fh, (char **) &(save_struc->keytext));
- fprintf(fh, "\n");
- fprintf(fh, "keytext_size = ");
- _cfsml_write_int(fh, (int*) &(save_struc->keytext_size));
- fprintf(fh, "\n");
- fprintf(fh, "flags = ");
- _cfsml_write_int(fh, (int*) &(save_struc->flags));
- fprintf(fh, "\n");
- fprintf(fh, "said = ");
- min = max = MENU_SAID_SPEC_SIZE;
+ fprintf(fh, "{\n");
+ fprintf(fh, "type = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->type));
+ fprintf(fh, "\n");
+ fprintf(fh, "keytext = ");
+ _cfsml_write_string(fh, (char **) &(save_struc->keytext));
+ fprintf(fh, "\n");
+ fprintf(fh, "keytext_size = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->keytext_size));
+ fprintf(fh, "\n");
+ fprintf(fh, "flags = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->flags));
+ fprintf(fh, "\n");
+ fprintf(fh, "said = ");
+ min = max = MENU_SAID_SPEC_SIZE;
#line 491 "savegame.cfsml"
- fprintf(fh, "[%d][\n", max);
- for (i = 0; i < min; i++) {
- _cfsml_write_byte(fh, &(save_struc->said[i]));
- fprintf(fh, "\n");
- }
- fprintf(fh, "]");
- fprintf(fh, "\n");
- fprintf(fh, "said_pos = ");
- write_reg_t(fh, (reg_t*) &(save_struc->said_pos));
- fprintf(fh, "\n");
- fprintf(fh, "text = ");
- _cfsml_write_string(fh, (char **) &(save_struc->text));
- fprintf(fh, "\n");
- fprintf(fh, "text_pos = ");
- write_reg_t(fh, (reg_t*) &(save_struc->text_pos));
- fprintf(fh, "\n");
- fprintf(fh, "modifiers = ");
- _cfsml_write_int(fh, (int*) &(save_struc->modifiers));
- fprintf(fh, "\n");
- fprintf(fh, "key = ");
- _cfsml_write_int(fh, (int*) &(save_struc->key));
- fprintf(fh, "\n");
- fprintf(fh, "enabled = ");
- _cfsml_write_int(fh, (int*) &(save_struc->enabled));
- fprintf(fh, "\n");
- fprintf(fh, "tag = ");
- _cfsml_write_int(fh, (int*) &(save_struc->tag));
- fprintf(fh, "\n");
- fprintf(fh, "}");
+ fprintf(fh, "[%d][\n", max);
+ for (i = 0; i < min; i++) {
+ _cfsml_write_byte(fh, &(save_struc->said[i]));
+ fprintf(fh, "\n");
+ }
+ fprintf(fh, "]");
+ fprintf(fh, "\n");
+ fprintf(fh, "said_pos = ");
+ write_reg_t(fh, (reg_t*) &(save_struc->said_pos));
+ fprintf(fh, "\n");
+ fprintf(fh, "text = ");
+ _cfsml_write_string(fh, (char **) &(save_struc->text));
+ fprintf(fh, "\n");
+ fprintf(fh, "text_pos = ");
+ write_reg_t(fh, (reg_t*) &(save_struc->text_pos));
+ fprintf(fh, "\n");
+ fprintf(fh, "modifiers = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->modifiers));
+ fprintf(fh, "\n");
+ fprintf(fh, "key = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->key));
+ fprintf(fh, "\n");
+ fprintf(fh, "enabled = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->enabled));
+ fprintf(fh, "\n");
+ fprintf(fh, "tag = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->tag));
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
#line 539 "savegame.cfsml"
static int
-_cfsml_read_menu_item_t(FILE *fh, menu_item_t* save_struc, const char *lastval, int *line, int *hiteof) {
- char *token;
- int min, max, i;
+_cfsml_read_menu_item_t(FILE *fh, menu_item_t* save_struc, const char *lastval, int *line, int *hiteof)
+{
+ char *token;
+int min, max, i;
#line 600 "savegame.cfsml"
- int assignment, closed, done;
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record menu_item_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
- return CFSML_FAILURE;
- };
- closed = 0;
- do {
- const char *value;
- token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+ if (strcmp(lastval, "{")) {
+ _cfsml_error("Reading record menu_item_t; expected opening braces in line %d, got \"%s\"\n",*line, lastval);
+ return CFSML_FAILURE;
+ };
+ closed = 0;
+ do {
+ const char *value;
+ token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
- if (!token) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!assignment) {
- if (!strcmp(token, "}"))
- closed = 1;
- else {
- _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else {
- value = "";
- while (!value || !strcmp(value, ""))
- value = _cfsml_get_value(fh, line, hiteof);
- if (!value) {
- _cfsml_error("Expected token at line %d\n", *line);
- return CFSML_FAILURE;
- }
- if (!strcmp(token, "type")) {
+ if (!token) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!assignment) {
+ if (!strcmp(token, "}"))
+ closed = 1;
+ else {
+ _cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else {
+ value = "";
+ while (!value || !strcmp(value, ""))
+ value = _cfsml_get_value(fh, line, hiteof);
+ if (!value) {
+ _cfsml_error("Expected token at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ if (!strcmp(token, "type")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->type), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for type at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "keytext")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->type), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for type at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "keytext")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_string(fh, (char **) &(save_struc->keytext), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_string() for keytext at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "keytext_size")) {
+ if (_cfsml_read_string(fh, (char **) &(save_struc->keytext), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_string() for keytext at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "keytext_size")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->keytext_size), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for keytext_size at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "flags")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->keytext_size), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for keytext_size at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "flags")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->flags), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for flags at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "said")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->flags), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for flags at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "said")) {
#line 664 "savegame.cfsml"
- if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
- _cfsml_error("Opening brackets expected at line %d\n", *line);
- return CFSML_FAILURE;
- }
- /* Prepare to restore static array */
- max = MENU_SAID_SPEC_SIZE;
+ if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
+ _cfsml_error("Opening brackets expected at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ /* Prepare to restore static array */
+ max = MENU_SAID_SPEC_SIZE;
#line 700 "savegame.cfsml"
- done = i = 0;
- do {
- if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
+ done = i = 0;
+ do {
+ if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
#line 708 "savegame.cfsml"
- _cfsml_error("Token expected at line %d\n", *line);
- return 1;
- }
- if (strcmp(value, "]")) {
- if (i == max) {
- _cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
- return CFSML_FAILURE;
- }
- if (_cfsml_read_byte(fh, &(save_struc->said[i++]), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_byte() for said[i++] at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else done = 1;
- } while (!done);
- } else
- if (!strcmp(token, "said_pos")) {
+ _cfsml_error("Token expected at line %d\n", *line);
+ return 1;
+ }
+ if (strcmp(value, "]")) {
+ if (i == max) {
+ _cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
+ return CFSML_FAILURE;
+ }
+ if (_cfsml_read_byte(fh, &(save_struc->said[i++]), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_byte() for said[i++] at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else done = 1;
+ } while (!done);
+ } else
+ if (!strcmp(token, "said_pos")) {
#line 750 "savegame.cfsml"
- if (read_reg_t(fh, (reg_t*) &(save_struc->said_pos), value, line, hiteof)) {
- _cfsml_error("Token expected by read_reg_t() for said_pos at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "text")) {
+ if (read_reg_t(fh, (reg_t*) &(save_struc->said_pos), value, line, hiteof)) {
+ _cfsml_error("Token expected by read_reg_t() for said_pos at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "text")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_string(fh, (char **) &(save_struc->text), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_string() for text at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "text_pos")) {
+ if (_cfsml_read_string(fh, (char **) &(save_struc->text), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_string() for text at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "text_pos")) {
#line 750 "savegame.cfsml"
- if (read_reg_t(fh, (reg_t*) &(save_struc->text_pos), value, line, hiteof)) {
- _cfsml_error("Token expected by read_reg_t() for text_pos at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "modifiers")) {
+ if (read_reg_t(fh, (reg_t*) &(save_struc->text_pos), value, line, hiteof)) {
+ _cfsml_error("Token expected by read_reg_t() for text_pos at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "modifiers")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->modifiers), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for modifiers at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "key")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->modifiers), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for modifiers at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "key")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->key), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for key at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "enabled")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->key), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for key at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "enabled")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->enabled), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for enabled at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "tag")) {
+ if (_cfsml_read_int(fh, (int*) &(save_struc->enabled), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for enabled at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "tag")) {
#line 750 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->tag), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for tag at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
+ if (_cfsml_read_int(fh, (int*) &(save_struc->tag), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for tag at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
#line 759 "savegame.cfsml"
- {
- _cfsml_error("menu_item_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
- } while (!closed); /* Until closing braces are hit */
- return CFSML_SUCCESS;
+ {
+ _cfsml_error("menu_item_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+ return CFSML_FAILURE;
+ }
+ }
+ } while (!closed); /* Until closing braces are hit */
+ return CFSML_SUCCESS;
}
#line 445 "savegame.cfsml"
static void
-_cfsml_write_node_entry_t(FILE *fh, node_entry_t* save_struc) {
- int min, max, i;
+_cfsml_write_node_entry_t(FILE *fh, node_entry_t* save_struc)
+{
+ int min, max, i;
#line 465 "savegame.cfsml"
- fprintf(fh, "{\n");
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list