// Similar new methods for writing/reading game state static id0_boolean_t SaveGameState(BE_FILE_T file, gametype *state) { return ((BE_Cross_writeInt16LE(file, &state->worldx) == 2) && (BE_Cross_writeInt16LE(file, &state->worldy) == 2) && (BE_Cross_write_booleans_To16LEBuffer(file, state->leveldone, 2*sizeof(state->leveldone)/sizeof(id0_boolean_t)) == 2*sizeof(state->leveldone)/sizeof(id0_boolean_t)) && (BE_Cross_writeInt32LE(file, &state->score) == 4) && (BE_Cross_writeInt32LE(file, &state->nextextra) == 4) && (BE_Cross_writeInt16LE(file, &state->flowerpowers) == 2) && (BE_Cross_writeInt16LE(file, &state->boobusbombs) == 2) && (BE_Cross_writeInt16LE(file, &state->bombsthislevel) == 2) && (BE_Cross_writeInt16LE(file, &state->keys) == 2) && (BE_Cross_writeInt16LE(file, &state->mapon) == 2) && (BE_Cross_writeInt16LE(file, &state->lives) == 2) && (BE_Cross_writeInt16LE(file, &state->difficulty) == 2) ); }
// Similar new methods for writing/reading game state static id0_boolean_t SaveGameState(BE_FILE_T file, gametype *state) { id0_word_t padding; // Two bytes of struct tail padding for 2015 port return ((BE_Cross_writeInt16LE(file, &state->worldx) == 2) && (BE_Cross_writeInt16LE(file, &state->worldy) == 2) && (((refkeen_current_gamever != BE_GAMEVER_KDREAMS2015) && (BE_Cross_write_booleans_To16LEBuffer(file, state->leveldone, 2*sizeof(state->leveldone)/sizeof(id0_boolean_t)) == 2*sizeof(state->leveldone)/sizeof(id0_boolean_t))) || ((refkeen_current_gamever == BE_GAMEVER_KDREAMS2015) && (BE_Cross_write_booleans_To32LEBuffer(file, state->leveldone, 4*sizeof(state->leveldone)/sizeof(id0_boolean_t)) == 4*sizeof(state->leveldone)/sizeof(id0_boolean_t))) ) && (BE_Cross_writeInt32LE(file, &state->score) == 4) && (BE_Cross_writeInt32LE(file, &state->nextextra) == 4) && (BE_Cross_writeInt16LE(file, &state->flowerpowers) == 2) && (BE_Cross_writeInt16LE(file, &state->boobusbombs) == 2) && (BE_Cross_writeInt16LE(file, &state->bombsthislevel) == 2) && (BE_Cross_writeInt16LE(file, &state->keys) == 2) && (BE_Cross_writeInt16LE(file, &state->mapon) == 2) && (BE_Cross_writeInt16LE(file, &state->lives) == 2) && (BE_Cross_writeInt16LE(file, &state->difficulty) == 2) && (((refkeen_current_gamever != BE_GAMEVER_KDREAMS2015) || (BE_Cross_writeInt16LE(file, &padding) == 2))) ); }
// REFKEEN - New cross-platform methods for reading/writing objects from/to saved games static id0_boolean_t SaveObject(BE_FILE_T file, objtype *o) { id0_int_t dummy = 0; // for active enum (anonymous type) id0_int_t activeint = (id0_int_t)(o->active); // BACKWARD COMPATIBILITY id0_longword_t statedosfarptr = o->state ? o->state->compatdospointer : 0; // Just tells if "o->next" is zero or not id0_int_t isnext = o->next ? 1 : 0; // Now writing size_t BE_Cross_write_classtype_To16LE(BE_FILE_T fp, const classtype *ptr); size_t BE_Cross_write_dirtype_To16LE(BE_FILE_T fp, const dirtype *ptr); return ((BE_Cross_writeInt16LE(file, &o->ticcount) == 2) && (BE_Cross_writeInt32LE(file, &statedosfarptr) == 4) // BACKWARD COMPATIBILITY && (BE_Cross_writeInt32LE(file, &o->x) == 4) && (BE_Cross_writeInt32LE(file, &o->y) == 4) && (BE_Cross_writeInt16LE(file, &o->viewx) == 2) && (BE_Cross_writeInt16LE(file, &o->tilex) == 2) && (BE_Cross_writeInt16LE(file, &o->tiley) == 2) && (BE_Cross_writeInt16LE(file, &o->viewheight) == 2) && (BE_Cross_writeInt16LE(file, &o->size) == 2) // No need to write prev pointer as-is, // this is ignored on loading. So write dummy value. // Furthermore, all we need to know about next on loading is // if it's zero or not. && (BE_Cross_writeInt16LE(file, &isnext) == 2) // next && (BE_Cross_writeInt8LEBuffer(file, &dummy, 2) == 2) // prev // && (BE_Cross_writeInt16LE(file, &activeint) == 2) && (BE_Cross_write_classtype_To16LE(file, &o->obclass) == 2) && (BE_Cross_writeInt8LE(file, &o->flags) == 1) && (BE_Cross_writeInt8LE(file, &dummy) == 1) // Padding due to word alignment in original code && (BE_Cross_writeInt32LE(file, &o->distance) == 4) && (BE_Cross_write_dirtype_To16LE(file, &o->dir) == 2) && (BE_Cross_writeInt16LE(file, &o->angle) == 2) && (BE_Cross_writeInt16LE(file, &o->hitpoints) == 2) && (BE_Cross_writeInt32LE(file, &o->speed) == 4) && (BE_Cross_writeInt32LE(file, &o->xl) == 4) && (BE_Cross_writeInt32LE(file, &o->xh) == 4) && (BE_Cross_writeInt32LE(file, &o->yl) == 4) && (BE_Cross_writeInt32LE(file, &o->yh) == 4) && (BE_Cross_writeInt16LE(file, &o->temp1) == 2) && (BE_Cross_writeInt16LE(file, &o->temp2) == 2) ); }
// Similar new methods for writing/reading game state static id0_boolean_t SaveGameState(BE_FILE_T file, gametype *state) { return ((BE_Cross_writeInt16LE(file, &state->difficulty) == 2) && (BE_Cross_writeInt16LE(file, &state->mapon) == 2) && (BE_Cross_writeInt16LE(file, &state->bolts) == 2) && (BE_Cross_writeInt16LE(file, &state->nukes) == 2) && (BE_Cross_writeInt16LE(file, &state->potions) == 2) && (BE_Cross_writeInt16LEBuffer(file, state->keys, sizeof(state->keys)) == sizeof(state->keys)) && (BE_Cross_writeInt16LEBuffer(file, state->scrolls, sizeof(state->scrolls)) == sizeof(state->scrolls)) && (BE_Cross_writeInt32LE(file, &state->score) == 4) && (BE_Cross_writeInt16LE(file, &state->body) == 2) && (BE_Cross_writeInt16LE(file, &state->shotpower) == 2) ); }