/* ============= ED_WriteGlobals ============= */ void ED_WriteGlobals (FILE *f) { ddef_t *def; int i; char *name; int type; fprintf (f,"{\n"); for (i=0 ; i<progs->numglobaldefs ; i++) { def = &pr_globaldefs[i]; type = def->type; if ( !(def->type & DEF_SAVEGLOBAL) ) continue; type &= ~DEF_SAVEGLOBAL; if (type != ev_string && type != ev_float && type != ev_entity) continue; name = PR_GetString(def->s_name); fprintf (f,"\"%s\" ", name); fprintf (f,"\"%s\"\n", PR_UglyValueString((etype_t)type, (eval_t *)&pr_globals[def->ofs])); } fprintf (f,"}\n"); }
void ED_WriteGlobals (FILE *f) { #if 0 ddef_t *def; int i; char *name; int type; fprintf (f,"{\n"); for(i = 0; i < progs->numglobaldefs; i++) { def = &pr_globaldefs[i]; type = def->type; if ( !(def->type & DEF_SAVEGLOBAL) ) continue; type &= ~DEF_SAVEGLOBAL; if(type != EV_STRING && type != EV_FLOAT && type != ev_entity) continue; name = pr_strings + def->s_name; fprintf (f,"\"%s\" ", name); fprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs])); } fprintf (f,"}\n"); #else Con_Printf("ED_WriteGlobals\n"); #endif }
/* ============= ED_Write For savegames ============= */ void ED_Write (FILE *f, edict_t *ed) { ddef_t *d; int *v; int i, j; const char *name; int type; fprintf (f, "{\n"); if (ed->free) { fprintf (f, "}\n"); return; } for (i = 1; i < progs->numfielddefs; i++) { d = &pr_fielddefs[i]; name = PR_GetString(d->s_name); j = strlen (name); if (j > 1 && name[j - 2] == '_') continue; // skip _x, _y, _z vars v = (int *)((char *)&ed->v + d->ofs*4); // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; for (j = 0; j < type_size[type]; j++) { if (v[j]) break; } if (j == type_size[type]) continue; fprintf (f, "\"%s\" ", name); fprintf (f, "\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v)); } //johnfitz -- save entity alpha manually when progs.dat doesn't know about alpha if (!pr_alpha_supported && ed->alpha != ENTALPHA_DEFAULT) fprintf (f, "\"alpha\" \"%f\"\n", ENTALPHA_TOSAVE(ed->alpha)); //johnfitz fprintf (f, "}\n"); }
/* For savegames [7/2/2013] TODO: Rewrite! ~hogsy */ void ED_Write(FILE *f, ServerEntity_t *ed) { // ddef_t *d; // int *v; int i; // char *name; // int type; fprintf (f, "{\n"); if (ed->free) { fprintf (f, "}\n"); return; } #if 0 for (i=1 ; i<progs->numfielddefs ; i++) { d = &pr_fielddefs[i]; name = pr_strings + d->s_name; if (name[strlen(name)-2] == '_') continue; // skip _x, _y, _z vars v = (int *)((char *)&ed->v + d->ofs*4); // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; for (j=0 ; j<type_size[type] ; j++) if (v[j]) break; if (j == type_size[type]) continue; fprintf (f,"\"%s\" ",name); fprintf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v)); } #else // [10/3/2013] Rewrite... ~hogsy for (i = 1; i < sizeof(ServerEntity_t); i++) { // fprintf(f,"\"%s\" "); } #endif fprintf (f, "}\n"); }
/* ============= ED_Write For savegames ============= */ void ED_Write (FILE *f, edict_t *ed) { ddef_t *d; int *v; int i, j; char *name; int type; fprintf (f, "{\n"); if (ed->e->free) { fprintf (f, "}\n"); return; } for (i=1 ; i<progs->numfielddefs ; i++) { d = &pr_fielddefs[i]; name = PR_GetString(d->s_name); if (name[strlen(name)-2] == '_') continue; // skip _x, _y, _z vars v = (int *)((char *)&ed->v + d->ofs*4); // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; for (j=0 ; j<type_size[type] ; j++) if (v[j]) break; if (j == type_size[type]) continue; fprintf (f,"\"%s\" ",name); fprintf (f,"\"%s\"\n", PR_UglyValueString((etype_t)d->type, (eval_t *)v)); } fprintf (f, "}\n"); }