[Scummvm-cvs-logs] SF.net SVN: scummvm:[38613] scummvm/trunk/engines/sci/engine
wjpalenstijn at users.sourceforge.net
wjpalenstijn at users.sourceforge.net
Fri Feb 20 20:32:27 CET 2009
Revision: 38613
http://scummvm.svn.sourceforge.net/scummvm/?rev=38613&view=rev
Author: wjpalenstijn
Date: 2009-02-20 19:32:27 +0000 (Fri, 20 Feb 2009)
Log Message:
-----------
use new instead of malloc for int_hash_map_t
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/savegame.cfsml
scummvm/trunk/engines/sci/engine/savegame.cpp
Modified: scummvm/trunk/engines/sci/engine/savegame.cfsml
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cfsml 2009-02-20 19:08:38 UTC (rev 38612)
+++ scummvm/trunk/engines/sci/engine/savegame.cfsml 2009-02-20 19:32:27 UTC (rev 38613)
@@ -472,7 +472,7 @@
}
int 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));
+ *foo = new int_hash_map_t;
%CFSMLREAD int_hash_map_t (*foo) FROM fh ERRVAR *hiteof FIRSTTOKEN lastval LINECOUNTER *line;
(*foo)->holes = NULL;
return 0;
Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp 2009-02-20 19:08:38 UTC (rev 38612)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp 2009-02-20 19:32:27 UTC (rev 38613)
@@ -171,15 +171,15 @@
*/
-// Auto-generated CFSML declaration and function block
+/* Auto-generated CFSML declaration and function block */
-#line 740 "savegame.cfsml"
+#line 778 "savegame.cfsml"
#define CFSML_SUCCESS 0
#define CFSML_FAILURE 1
#line 102 "savegame.cfsml"
-#include <stdarg.h> // We need va_lists
+#include <stdarg.h> /* We need va_lists */
#include "sci/include/sci_memory.h"
#ifdef CFSML_DEBUG_MALLOC
@@ -195,19 +195,22 @@
#define realloc dbg_sci_realloc
#endif
-static void _cfsml_error(const char *fmt, ...) {
- va_list argp;
+static void
+_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;
@@ -215,3654 +218,3737 @@
static char *_cfsml_last_value_retrieved = NULL;
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;
+static void
+_cfsml_free_pointer_references_recursively(struct _cfsml_pointer_refstruct *refs, int free_pointers)
+{
+ if (!refs)
+ return;
- _cfsml_free_pointer_references_recursively(refs->next, free_pointers);
+ _cfsml_free_pointer_references_recursively(refs->next, free_pointers);
- if (free_pointers)
- free(refs->ptr);
+ if (free_pointers)
+ free(refs->ptr);
- free(refs);
+ free(refs);
}
-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;
+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;
}
-static struct _cfsml_pointer_refstruct **_cfsml_get_current_refpointer() {
- return _cfsml_pointer_references_current;
+static struct _cfsml_pointer_refstruct **
+_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));
- 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));
+ 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;
- 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;
- }
- *writer = 0; // Terminate string
+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;
- return (char *)sci_realloc(target, strlen(target) + 1);
+ 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;
+
+ }
+ *writer = 0; /* Terminate string */
+
+ 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;
- 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
+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;
- return (char *)sci_realloc(target, strlen(target) + 1);
+ 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);
}
-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);
- if (_cfsml_last_identifier_retrieved) {
- free(_cfsml_last_identifier_retrieved);
- _cfsml_last_identifier_retrieved = NULL;
- }
+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);
- 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;
- }
+ if (_cfsml_last_identifier_retrieved) {
+ free(_cfsml_last_identifier_retrieved);
+ _cfsml_last_identifier_retrieved = NULL;
+ }
- ungetc(c, fd);
+ 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 (((c = fgetc(fd)) != EOF) && ((pos == 0) || (c != '\n')) && (c != '=')) {
- if (pos == mem - 1) // Need more memory?
- retval = (char *)sci_realloc(retval, mem *= 2);
+ ungetc(c, fd);
- 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);
- }
+ while (((c = fgetc(fd)) != EOF) && ((pos == 0) || (c != '\n')) && (c != '=')) {
- if (c == EOF) {
- _cfsml_error("Unexpected end of file at line %d\n", *line);
- free(retval);
- *hiteof = 1;
- return NULL;
- }
+ if (pos == mem - 1) /* Need more memory? */
+ retval = (char *) sci_realloc(retval, mem *= 2);
- if (c == '\n') {
- ++(*line);
- if (assignment)
- *assignment = 0;
- } else
- if (assignment)
- *assignment = 1;
+ 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 (pos == 0) {
- _cfsml_error("Missing identifier in assignment at line %d\n", *line);
- free(retval);
- return NULL;
- }
+ if (c == EOF) {
+ _cfsml_error("Unexpected end of file at line %d\n", *line);
+ free(retval);
+ *hiteof = 1;
+ return NULL;
+ }
- if (pos == mem - 1) // Need more memory?
- retval = (char *)sci_realloc(retval, mem += 1);
+ if (c == '\n') {
+ ++(*line);
+ if (assignment)
+ *assignment = 0;
+ } else
+ if (assignment)
+ *assignment = 1;
- retval[pos] = 0; // Terminate string
-#line 282 "savegame.cfsml"
+ if (pos == 0) {
+ _cfsml_error("Missing identifier in assignment at line %d\n", *line);
+ free(retval);
+ return NULL;
+ }
- return _cfsml_last_identifier_retrieved = retval;
+ if (pos == mem - 1) /* Need more memory? */
+ retval = (char *) sci_realloc(retval, mem += 1);
+
+ retval[pos] = 0; /* Terminate string */
+#line 304 "savegame.cfsml"
+
+ 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);
- if (_cfsml_last_value_retrieved) {
- free(_cfsml_last_value_retrieved);
- _cfsml_last_value_retrieved = NULL;
- }
+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);
- while (((c = fgetc(fd)) != EOF) && (c != '\n')) {
- if (pos == mem - 1) // Need more memory?
- retval = (char *)sci_realloc(retval, mem *= 2);
+ if (_cfsml_last_value_retrieved) {
+ free(_cfsml_last_value_retrieved);
+ _cfsml_last_value_retrieved = NULL;
+ }
- if (pos || (!isspace(c)))
- retval[pos++] = c;
- }
+ while (((c = fgetc(fd)) != EOF) && (c != '\n')) {
- while ((pos > 0) && (isspace(retval[pos - 1])))
- --pos; // Strip trailing whitespace
+ if (pos == mem - 1) /* Need more memory? */
+ retval = (char *) sci_realloc(retval, mem *= 2);
- if (c == EOF)
- *hiteof = 1;
+ if (pos || (!isspace(c)))
+ retval[pos++] = c;
- if (pos == 0) {
- _cfsml_error("Missing value in assignment at line %d\n", *line);
- free(retval);
- return NULL;
- }
+ }
- if (c == '\n')
- ++(*line);
+ while ((pos > 0) && (isspace(retval[pos - 1])))
+ --pos; /* Strip trailing whitespace */
- if (pos == mem - 1) // Need more memory?
- retval = (char *)sci_realloc(retval, mem += 1);
+ if (c == EOF)
+ *hiteof = 1;
- retval[pos] = 0; // Terminate string
-#line 334 "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)
+ if (pos == 0) {
+ _cfsml_error("Missing value in assignment at line %d\n", *line);
+ free(retval);
+ return NULL;
+ }
+
+ if (c == '\n')
+ ++(*line);
+
+ if (pos == mem - 1) /* Need more memory? */
+ retval = (char *) sci_realloc(retval, mem += 1);
+
+ retval[pos] = 0; /* Terminate string */
+#line 361 "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)
+ */
}
-#line 384 "savegame.cfsml"
-static void _cfsml_write_sfx_state_t(FILE *fh, sfx_state_t* save_struc);
-static int _cfsml_read_sfx_state_t(FILE *fh, sfx_state_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_sfx_state_t(FILE *fh, sfx_state_t* save_struc);
+static int
+_cfsml_read_sfx_state_t(FILE *fh, sfx_state_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_clone_entry_t(FILE *fh, clone_entry_t* save_struc);
-static int _cfsml_read_clone_entry_t(FILE *fh, clone_entry_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_clone_entry_t(FILE *fh, clone_entry_t* save_struc);
+static int
+_cfsml_read_clone_entry_t(FILE *fh, clone_entry_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_object_t(FILE *fh, object_t* save_struc);
-static int _cfsml_read_object_t(FILE *fh, object_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_object_t(FILE *fh, object_t* save_struc);
+static int
+_cfsml_read_object_t(FILE *fh, object_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_string(FILE *fh, char ** save_struc);
-static int _cfsml_read_string(FILE *fh, char ** save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_string(FILE *fh, char ** save_struc);
+static int
+_cfsml_read_string(FILE *fh, char ** save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_menubar_t(FILE *fh, menubar_t* save_struc);
-static int _cfsml_read_menubar_t(FILE *fh, menubar_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_menubar_t(FILE *fh, menubar_t* save_struc);
+static int
+_cfsml_read_menubar_t(FILE *fh, menubar_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_size_t(FILE *fh, size_t* save_struc);
-static int _cfsml_read_size_t(FILE *fh, size_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_size_t(FILE *fh, size_t* save_struc);
+static int
+_cfsml_read_size_t(FILE *fh, size_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_list_entry_t(FILE *fh, list_entry_t* save_struc);
-static int _cfsml_read_list_entry_t(FILE *fh, list_entry_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_list_entry_t(FILE *fh, list_entry_t* save_struc);
+static int
+_cfsml_read_list_entry_t(FILE *fh, list_entry_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_int_hash_map_t(FILE *fh, int_hash_map_t* save_struc);
-static int _cfsml_read_int_hash_map_t(FILE *fh, int_hash_map_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_int_hash_map_t(FILE *fh, int_hash_map_t* save_struc);
+static int
+_cfsml_read_int_hash_map_t(FILE *fh, int_hash_map_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_song_t(FILE *fh, song_t* save_struc);
-static int _cfsml_read_song_t(FILE *fh, song_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_song_t(FILE *fh, song_t* save_struc);
+static int
+_cfsml_read_song_t(FILE *fh, song_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_menu_item_t(FILE *fh, menu_item_t* save_struc);
-static int _cfsml_read_menu_item_t(FILE *fh, menu_item_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_menu_item_t(FILE *fh, menu_item_t* save_struc);
+static int
+_cfsml_read_menu_item_t(FILE *fh, menu_item_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_node_entry_t(FILE *fh, node_entry_t* save_struc);
-static int _cfsml_read_node_entry_t(FILE *fh, node_entry_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_node_entry_t(FILE *fh, node_entry_t* save_struc);
+static int
+_cfsml_read_node_entry_t(FILE *fh, node_entry_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_seg_id_t(FILE *fh, seg_id_t* save_struc);
-static int _cfsml_read_seg_id_t(FILE *fh, seg_id_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_seg_id_t(FILE *fh, seg_id_t* save_struc);
+static int
+_cfsml_read_seg_id_t(FILE *fh, seg_id_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_dynmem_t(FILE *fh, dynmem_t* save_struc);
-static int _cfsml_read_dynmem_t(FILE *fh, dynmem_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_dynmem_t(FILE *fh, dynmem_t* save_struc);
+static int
+_cfsml_read_dynmem_t(FILE *fh, dynmem_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_local_variables_t(FILE *fh, local_variables_t* save_struc);
-static int _cfsml_read_local_variables_t(FILE *fh, local_variables_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_local_variables_t(FILE *fh, local_variables_t* save_struc);
+static int
+_cfsml_read_local_variables_t(FILE *fh, local_variables_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_state_t(FILE *fh, state_t* save_struc);
-static int _cfsml_read_state_t(FILE *fh, state_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_state_t(FILE *fh, state_t* save_struc);
+static int
+_cfsml_read_state_t(FILE *fh, state_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_node_table_t(FILE *fh, node_table_t* save_struc);
-static int _cfsml_read_node_table_t(FILE *fh, node_table_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_node_table_t(FILE *fh, node_table_t* save_struc);
+static int
+_cfsml_read_node_table_t(FILE *fh, node_table_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_sys_strings_t(FILE *fh, sys_strings_t* save_struc);
-static int _cfsml_read_sys_strings_t(FILE *fh, sys_strings_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_sys_strings_t(FILE *fh, sys_strings_t* save_struc);
+static int
+_cfsml_read_sys_strings_t(FILE *fh, sys_strings_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_byte(FILE *fh, byte* save_struc);
-static int _cfsml_read_byte(FILE *fh, byte* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_byte(FILE *fh, byte* save_struc);
+static int
+_cfsml_read_byte(FILE *fh, byte* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_node_t(FILE *fh, node_t* save_struc);
-static int _cfsml_read_node_t(FILE *fh, node_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_node_t(FILE *fh, node_t* save_struc);
+static int
+_cfsml_read_node_t(FILE *fh, node_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_list_table_t(FILE *fh, list_table_t* save_struc);
-static int _cfsml_read_list_table_t(FILE *fh, list_table_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_list_table_t(FILE *fh, list_table_t* save_struc);
+static int
+_cfsml_read_list_table_t(FILE *fh, list_table_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_class_t(FILE *fh, class_t* save_struc);
-static int _cfsml_read_class_t(FILE *fh, class_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_class_t(FILE *fh, class_t* save_struc);
+static int
+_cfsml_read_class_t(FILE *fh, class_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_song_handle_t(FILE *fh, song_handle_t* save_struc);
-static int _cfsml_read_song_handle_t(FILE *fh, song_handle_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_song_handle_t(FILE *fh, song_handle_t* save_struc);
+static int
+_cfsml_read_song_handle_t(FILE *fh, song_handle_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_int(FILE *fh, int* save_struc);
-static int _cfsml_read_int(FILE *fh, int* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_int(FILE *fh, int* save_struc);
+static int
+_cfsml_read_int(FILE *fh, int* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_menu_t(FILE *fh, menu_t* save_struc);
-static int _cfsml_read_menu_t(FILE *fh, menu_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_menu_t(FILE *fh, menu_t* save_struc);
+static int
+_cfsml_read_menu_t(FILE *fh, menu_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_clone_table_t(FILE *fh, clone_table_t* save_struc);
-static int _cfsml_read_clone_table_t(FILE *fh, clone_table_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_clone_table_t(FILE *fh, clone_table_t* save_struc);
+static int
+_cfsml_read_clone_table_t(FILE *fh, clone_table_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_clone_t(FILE *fh, clone_t* save_struc);
-static int _cfsml_read_clone_t(FILE *fh, clone_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_clone_t(FILE *fh, clone_t* save_struc);
+static int
+_cfsml_read_clone_t(FILE *fh, clone_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_list_t(FILE *fh, list_t* save_struc);
-static int _cfsml_read_list_t(FILE *fh, list_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_list_t(FILE *fh, list_t* save_struc);
+static int
+_cfsml_read_list_t(FILE *fh, list_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_sys_string_t(FILE *fh, sys_string_t* save_struc);
-static int _cfsml_read_sys_string_t(FILE *fh, sys_string_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_sys_string_t(FILE *fh, sys_string_t* save_struc);
+static int
+_cfsml_read_sys_string_t(FILE *fh, sys_string_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_script_t(FILE *fh, script_t* save_struc);
-static int _cfsml_read_script_t(FILE *fh, script_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_script_t(FILE *fh, script_t* save_struc);
+static int
+_cfsml_read_script_t(FILE *fh, script_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 384 "savegame.cfsml"
-static void _cfsml_write_seg_manager_t(FILE *fh, seg_manager_t* save_struc);
-static int _cfsml_read_seg_manager_t(FILE *fh, seg_manager_t* save_struc, const char *lastval, int *line, int *hiteof);
+#line 413 "savegame.cfsml"
+static void
+_cfsml_write_seg_manager_t(FILE *fh, seg_manager_t* save_struc);
+static int
+_cfsml_read_seg_manager_t(FILE *fh, seg_manager_t* save_struc, const char *lastval, int *line, int *hiteof);
-#line 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_sfx_state_t(FILE *fh, sfx_state_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "songlib = ");
- write_songlib_t(fh, (songlib_t*) &(save_struc->songlib));
- fprintf(fh, "\n");
- fprintf(fh, "}");
+#line 446 "savegame.cfsml"
+ fprintf(fh, "{\n");
+ fprintf(fh, "songlib = ");
+ write_songlib_t(fh, (songlib_t*) &(save_struc->songlib));
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "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;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ 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")) {
-#line 694 "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
-#line 703 "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;
+ 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 731 "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
+#line 740 "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;
}
-#line 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_clone_entry_t(FILE *fh, clone_entry_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "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, "}");
+#line 446 "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, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "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;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ 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")) {
-#line 694 "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")) {
-#line 694 "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
-#line 703 "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;
+ 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 731 "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")) {
+#line 731 "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
+#line 740 "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;
}
-#line 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_object_t(FILE *fh, object_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "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 */
-#line 442 "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, "}");
+#line 446 "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 */
+#line 472 "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, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "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;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ 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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 609 "savegame.cfsml"
- if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
- _cfsml_error("Opening brackets expected at line %d\n", *line);
- return CFSML_FAILURE;
- }
-#line 619 "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;
- }
+ 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 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 645 "savegame.cfsml"
+ if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
+ _cfsml_error("Opening brackets expected at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+#line 655 "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;
+ }
- 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;
-#line 643 "savegame.cfsml"
- done = i = 0;
- do {
- if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
-#line 651 "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
-#line 703 "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_register_pointer(save_struc->variables);
+ }
+ else
+ save_struc->variables = NULL;
+#line 681 "savegame.cfsml"
+ done = i = 0;
+ do {
+ if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
+#line 689 "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
+#line 740 "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;
}
-#line 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_string(FILE *fh, char ** save_struc)
{
-#line 406 "savegame.cfsml"
- if (!(*save_struc))
- fprintf(fh, "\\null\\");
- else {
- char *token = _cfsml_mangle_string((const char *) *save_struc);
- fprintf(fh, "\"%s\"", token);
- free(token);
- }
+#line 436 "savegame.cfsml"
+ if (!(*save_struc))
+ fprintf(fh, "\\null\\");
+ else {
+ char *token = _cfsml_mangle_string((const char *) *save_struc);
+ fprintf(fh, "\"%s\"", token);
+ free(token);
+ }
}
-#line 489 "savegame.cfsml"
+#line 520 "savegame.cfsml"
static int
_cfsml_read_string(FILE *fh, char ** save_struc, const char *lastval, int *line, int *hiteof)
{
- char *token;
-#line 525 "savegame.cfsml"
+ char *token;
+#line 559 "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 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_menubar_t(FILE *fh, menubar_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "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 */
-#line 442 "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, "}");
+#line 446 "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 */
+#line 472 "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, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "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;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ 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")) {
-#line 609 "savegame.cfsml"
- if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
- _cfsml_error("Opening brackets expected at line %d\n", *line);
- return CFSML_FAILURE;
- }
-#line 619 "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;
- }
+ 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 645 "savegame.cfsml"
+ if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
+ _cfsml_error("Opening brackets expected at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+#line 655 "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;
+ }
- 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;
-#line 643 "savegame.cfsml"
- done = i = 0;
- do {
- if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
-#line 651 "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
-#line 703 "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_register_pointer(save_struc->menus);
+ }
+ else
+ save_struc->menus = NULL;
+#line 681 "savegame.cfsml"
+ done = i = 0;
+ do {
+ if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
+#line 689 "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
+#line 740 "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;
}
-#line 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_size_t(FILE *fh, size_t* save_struc)
{
- fprintf(fh, "%li", (long)*save_struc);
+ fprintf(fh, "%li", (long) *save_struc);
}
-#line 489 "savegame.cfsml"
+#line 520 "savegame.cfsml"
static int
_cfsml_read_size_t(FILE *fh, size_t* save_struc, const char *lastval, int *line, int *hiteof)
{
- char *token;
-#line 513 "savegame.cfsml"
+ char *token;
+#line 546 "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 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_list_entry_t(FILE *fh, list_entry_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "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, "}");
+#line 446 "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, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "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;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ 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")) {
-#line 694 "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")) {
-#line 694 "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
-#line 703 "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;
+ 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 731 "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")) {
+#line 731 "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
+#line 740 "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;
}
-#line 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_int_hash_map_t(FILE *fh, int_hash_map_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "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;
-#line 442 "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, "}");
+#line 446 "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;
+#line 472 "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, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "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;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ 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")) {
-#line 694 "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")) {
-#line 609 "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;
-#line 643 "savegame.cfsml"
- done = i = 0;
- do {
- if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
-#line 651 "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
-#line 703 "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;
+ 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 731 "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")) {
+#line 645 "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;
+#line 681 "savegame.cfsml"
+ done = i = 0;
+ do {
+ if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
+#line 689 "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
+#line 740 "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;
}
-#line 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_song_t(FILE *fh, song_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "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, "}");
+#line 446 "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, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "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;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ 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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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
-#line 703 "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;
+ 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 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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
+#line 740 "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;
}
-#line 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_menu_item_t(FILE *fh, menu_item_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "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;
-#line 442 "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, "}");
+#line 446 "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;
+#line 472 "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, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "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;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ 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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 609 "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;
-#line 643 "savegame.cfsml"
- done = i = 0;
- do {
- if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
-#line 651 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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")) {
-#line 694 "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
-#line 703 "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;
+ 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 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 645 "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;
+#line 681 "savegame.cfsml"
+ done = i = 0;
+ do {
+ if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
+#line 689 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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")) {
+#line 731 "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
+#line 740 "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;
}
-#line 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_node_entry_t(FILE *fh, node_entry_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "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_node_t(fh, (node_t*) &(save_struc->entry));
- fprintf(fh, "\n");
- fprintf(fh, "}");
+#line 446 "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_node_t(fh, (node_t*) &(save_struc->entry));
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "savegame.cfsml"
static int
_cfsml_read_node_entry_t(FILE *fh, node_entry_t* save_struc, const char *lastval, int *line, int *hiteof)
{
- char *token;
- int min, max, i;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record node_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 node_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")) {
-#line 694 "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")) {
-#line 694 "savegame.cfsml"
- if (_cfsml_read_node_t(fh, (node_t*) &(save_struc->entry), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_node_t() for entry at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
-#line 703 "savegame.cfsml"
- {
- _cfsml_error("node_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;
+ 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 731 "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")) {
+#line 731 "savegame.cfsml"
+ if (_cfsml_read_node_t(fh, (node_t*) &(save_struc->entry), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_node_t() for entry at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+#line 740 "savegame.cfsml"
+ {
+ _cfsml_error("node_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 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_seg_id_t(FILE *fh, seg_id_t* save_struc)
{
- fprintf(fh, "%li", (long)*save_struc);
+ fprintf(fh, "%li", (long) *save_struc);
}
-#line 489 "savegame.cfsml"
+#line 520 "savegame.cfsml"
static int
_cfsml_read_seg_id_t(FILE *fh, seg_id_t* save_struc, const char *lastval, int *line, int *hiteof)
{
- char *token;
-#line 513 "savegame.cfsml"
+ char *token;
+#line 546 "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 396 "savegame.cfsml"
+#line 426 "savegame.cfsml"
static void
_cfsml_write_dynmem_t(FILE *fh, dynmem_t* save_struc)
{
- int min, max, i;
+ int min, max, i;
-#line 416 "savegame.cfsml"
- fprintf(fh, "{\n");
- fprintf(fh, "size = ");
- _cfsml_write_int(fh, (int*) &(save_struc->size));
- fprintf(fh, "\n");
- fprintf(fh, "description = ");
- _cfsml_write_string(fh, (char **) &(save_struc->description));
- fprintf(fh, "\n");
- fprintf(fh, "buf = ");
- min = max = save_struc->size;
- if (!save_struc->buf)
- min = max = 0; /* Don't write if it points to NULL */
-#line 442 "savegame.cfsml"
- fprintf(fh, "[%d][\n", max);
- for (i = 0; i < min; i++) {
- _cfsml_write_byte(fh, &(save_struc->buf[i]));
- fprintf(fh, "\n");
- }
- fprintf(fh, "]");
- fprintf(fh, "\n");
- fprintf(fh, "}");
+#line 446 "savegame.cfsml"
+ fprintf(fh, "{\n");
+ fprintf(fh, "size = ");
+ _cfsml_write_int(fh, (int*) &(save_struc->size));
+ fprintf(fh, "\n");
+ fprintf(fh, "description = ");
+ _cfsml_write_string(fh, (char **) &(save_struc->description));
+ fprintf(fh, "\n");
+ fprintf(fh, "buf = ");
+ min = max = save_struc->size;
+ if (!save_struc->buf)
+ min = max = 0; /* Don't write if it points to NULL */
+#line 472 "savegame.cfsml"
+ fprintf(fh, "[%d][\n", max);
+ for (i = 0; i < min; i++) {
+ _cfsml_write_byte(fh, &(save_struc->buf[i]));
+ fprintf(fh, "\n");
+ }
+ fprintf(fh, "]");
+ fprintf(fh, "\n");
+ fprintf(fh, "}");
}
-#line 489 "savegame.cfsml"
+#line 520 "savegame.cfsml"
static int
_cfsml_read_dynmem_t(FILE *fh, dynmem_t* save_struc, const char *lastval, int *line, int *hiteof)
{
- char *token;
- int min, max, i;
-#line 547 "savegame.cfsml"
- int assignment, closed, done;
+ char *token;
+int min, max, i;
+#line 581 "savegame.cfsml"
+ int assignment, closed, done;
- if (strcmp(lastval, "{")) {
- _cfsml_error("Reading record dynmem_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 dynmem_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, "size")) {
-#line 694 "savegame.cfsml"
- if (_cfsml_read_int(fh, (int*) &(save_struc->size), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_int() for size at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "description")) {
-#line 694 "savegame.cfsml"
- if (_cfsml_read_string(fh, (char **) &(save_struc->description), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_string() for description at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- if (!strcmp(token, "buf")) {
-#line 609 "savegame.cfsml"
- if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
- _cfsml_error("Opening brackets expected at line %d\n", *line);
- return CFSML_FAILURE;
- }
-#line 619 "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;
- }
+ 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, "size")) {
+#line 731 "savegame.cfsml"
+ if (_cfsml_read_int(fh, (int*) &(save_struc->size), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_int() for size at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "description")) {
+#line 731 "savegame.cfsml"
+ if (_cfsml_read_string(fh, (char **) &(save_struc->description), value, line, hiteof)) {
+ _cfsml_error("Token expected by _cfsml_read_string() for description at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+ } else
+ if (!strcmp(token, "buf")) {
+#line 645 "savegame.cfsml"
+ if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
+ _cfsml_error("Opening brackets expected at line %d\n", *line);
+ return CFSML_FAILURE;
+ }
+#line 655 "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;
+ }
- if (max) {
- save_struc->buf = (byte *)sci_malloc(max * sizeof(byte));
+ if (max) {
+ save_struc->buf = (byte *) sci_malloc(max * sizeof(byte));
#ifdef SATISFY_PURIFY
- memset(save_struc->buf, 0, max * sizeof(byte));
+ memset(save_struc->buf, 0, max * sizeof(byte));
#endif
- _cfsml_register_pointer(save_struc->buf);
- } else
- save_struc->buf = NULL;
-#line 643 "savegame.cfsml"
- done = i = 0;
- do {
- if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
-#line 651 "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->buf[i++]), value, line, hiteof)) {
- _cfsml_error("Token expected by _cfsml_read_byte() for buf[i++] at line %d\n", *line);
- return CFSML_FAILURE;
- }
- } else
- done = 1;
- } while (!done);
- save_struc->size = max ; // Set array size accordingly
- } else
-#line 703 "savegame.cfsml"
- {
- _cfsml_error("dynmem_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
- return CFSML_FAILURE;
- }
- }
@@ 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