// 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_word_t statedosoffset = 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); return ((BE_Cross_write_classtype_To16LE(file, &o->obclass) == 2) && (BE_Cross_writeInt16LE(file, &activeint) == 2) && (BE_Cross_write_boolean_To16LE(file, &o->needtoreact) == 2) && (BE_Cross_write_boolean_To16LE(file, &o->needtoclip) == 2) && (BE_Cross_writeInt16LE(file, &o->nothink) == 2) && (BE_Cross_writeInt16LE(file, &o->x) == 2) && (BE_Cross_writeInt16LE(file, &o->y) == 2) && (BE_Cross_writeInt16LE(file, &o->xdir) == 2) && (BE_Cross_writeInt16LE(file, &o->ydir) == 2) && (BE_Cross_writeInt16LE(file, &o->xmove) == 2) && (BE_Cross_writeInt16LE(file, &o->ymove) == 2) && (BE_Cross_writeInt16LE(file, &o->xspeed) == 2) && (BE_Cross_writeInt16LE(file, &o->yspeed) == 2) && (BE_Cross_writeInt16LE(file, &o->ticcount) == 2) && (BE_Cross_writeInt16LE(file, &o->ticadjust) == 2) && (BE_Cross_writeInt16LE(file, &statedosoffset) == 2) // BACKWARD COMPATIBILITY && (BE_Cross_writeInt16LE(file, &o->shapenum) == 2) && (BE_Cross_writeInt16LE(file, &o->left) == 2) && (BE_Cross_writeInt16LE(file, &o->top) == 2) && (BE_Cross_writeInt16LE(file, &o->right) == 2) && (BE_Cross_writeInt16LE(file, &o->bottom) == 2) && (BE_Cross_writeInt16LE(file, &o->midx) == 2) && (BE_Cross_writeInt16LE(file, &o->tileleft) == 2) && (BE_Cross_writeInt16LE(file, &o->tiletop) == 2) && (BE_Cross_writeInt16LE(file, &o->tileright) == 2) && (BE_Cross_writeInt16LE(file, &o->tilebottom) == 2) && (BE_Cross_writeInt16LE(file, &o->tilemidx) == 2) && (BE_Cross_writeInt16LE(file, &o->hitnorth) == 2) && (BE_Cross_writeInt16LE(file, &o->hiteast) == 2) && (BE_Cross_writeInt16LE(file, &o->hitsouth) == 2) && (BE_Cross_writeInt16LE(file, &o->hitwest) == 2) && (BE_Cross_writeInt16LE(file, &o->temp1) == 2) && (BE_Cross_writeInt16LE(file, &o->temp2) == 2) && (BE_Cross_writeInt16LE(file, &o->temp3) == 2) && (BE_Cross_writeInt16LE(file, &o->temp4) == 2) // No need to write sprite, prev pointers as-is, // these are 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, &dummy) == 2) // sprite && (BE_Cross_writeInt16LE(file, &isnext) == 2) // next && (BE_Cross_writeInt16LE(file, &dummy) == 2) // prev ); }
// 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) ); }