/* ============== WriteEdict All pointer variables (except function pointers) must be handled specially. ============== */ void WriteEdict (FILE *f, edict_t *ent) { field_t *field; edict_t temp; if (Q_stricmp(ent->classname, "misc_viper") == 0) { temp = *ent; } // all of the ints, floats, and vectors stay as they are temp = *ent; // change the pointers to lengths or indexes for (field=savefields ; field->name ; field++) { WriteField1 (f, field, (byte *)&temp); } // write the block fwrite (&temp, sizeof(temp), 1, f); // now write any allocated data following the edict for (field=savefields ; field->name ; field++) { WriteField2 (f, field, (byte *)ent); } }
/* ============== WriteEdict All pointer variables (except function pointers) must be handled specially. ============== */ void WriteEdict (FILE *f, edict_t *ent) { field_t *field; edict_t temp; size_t size; // all of the ints, floats, and vectors stay as they are temp = *ent; // change the pointers to lengths or indexes for (field=fields ; field->name ; field++) { WriteField1 (f, field, (byte *)&temp); } // write the block size = fwrite (&temp, sizeof(temp), 1, f); // now write any allocated data following the edict for (field=fields ; field->name ; field++) { WriteField2 (f, field, (byte *)ent); } }
/* ============== WriteLevelLocals All pointer variables(except function pointers) must be handled specially. ============== */ void WriteLevelLocals(FILE *f){ field_t *field; level_locals_t temp; // all of the ints, floats, and vectors stay as they are temp = level; // change the pointers to lengths or indexes for(field = levelfields; field->name; field++){ WriteField1(f, field,(byte *)&temp); } // write the block fwrite(&temp, sizeof(temp), 1, f); // now write any allocated data following the edict for(field = levelfields; field->name; field++){ WriteField2(f, field,(byte *)&level); } }
/* * Write the client struct into a file. */ void WriteClient(FILE *f, gclient_t *client) { field_t *field; gclient_t temp; /* all of the ints, floats, and vectors stay as they are */ temp = *client; /* change the pointers to indexes */ for (field = clientfields; field->name; field++) { WriteField1(f, field, (byte *)&temp); } /* write the block */ fwrite(&temp, sizeof(temp), 1, f); /* now write any allocated data following the edict */ for (field = clientfields; field->name; field++) { WriteField2(f, field, (byte *)client); } }