// we assume that prog is already set to the target progs static void Cvar_UpdateAutoCvar(cvar_t *var) { int i; int j; const char *s; vec3_t v; prvm_prog_t *prog; for (i = 0;i < PRVM_PROG_MAX;i++) { prog = &prvm_prog_list[i]; if (prog->loaded && var->globaldefindex_progid[i] == prog->id) { // MUST BE SYNCED WITH prvm_edict.c PRVM_LoadProgs switch(prog->globaldefs[var->globaldefindex[i]].type & ~DEF_SAVEGLOBAL) { case ev_float: PRVM_GLOBALFIELDFLOAT(prog->globaldefs[var->globaldefindex[i]].ofs) = var->value; break; case ev_vector: s = var->string; VectorClear(v); for (j = 0;j < 3;j++) { while (*s && ISWHITESPACE(*s)) s++; if (!*s) break; v[j] = atof(s); while (!ISWHITESPACE(*s)) s++; if (!*s) break; } VectorCopy(v, PRVM_GLOBALFIELDVECTOR(prog->globaldefs[var->globaldefindex[i]].ofs)); break; case ev_string: PRVM_ChangeEngineString(prog, var->globaldefindex_stringno[i], var->string); PRVM_GLOBALFIELDSTRING(prog->globaldefs[var->globaldefindex[i]].ofs) = var->globaldefindex_stringno[i]; break; } } } }
// we assume that prog is already set to the target progs static void Cvar_UpdateAutoCvar(cvar_t *var) { int i; if(!prog) Host_Error("Cvar_UpdateAutoCvar: no prog set"); i = PRVM_GetProgNr(); if(var->globaldefindex_progid[i] == prog->id) { // MUST BE SYNCED WITH prvm_edict.c PRVM_LoadProgs int j; const char *s; vec3_t v; switch(prog->globaldefs[var->globaldefindex[i]].type & ~DEF_SAVEGLOBAL) { case ev_float: PRVM_GLOBALFIELDFLOAT(prog->globaldefs[var->globaldefindex[i]].ofs) = var->value; break; case ev_vector: s = var->string; VectorClear(v); for (j = 0;j < 3;j++) { while (*s && ISWHITESPACE(*s)) s++; if (!*s) break; v[j] = atof(s); while (!ISWHITESPACE(*s)) s++; if (!*s) break; } VectorCopy(v, PRVM_GLOBALFIELDVECTOR(prog->globaldefs[var->globaldefindex[i]].ofs)); break; case ev_string: PRVM_ChangeEngineString(var->globaldefindex_stringno[i], var->string); PRVM_GLOBALFIELDSTRING(prog->globaldefs[var->globaldefindex[i]].ofs) = var->globaldefindex_stringno[i]; break; } } }