+ if (cvar->flags & CVAR_ALLOCATED)
+ {
+ if (developer.integer)
+ Con_Printf("... replacing existing allocated cvar {\"%s\", \"%s\", %i}", cvar->name, cvar->string, cvar->flags);
+ // fixed variables replace allocated ones
+ // (because the engine directly accesses fixed variables)
+ // NOTE: this isn't actually used currently
+ // (all cvars are registered before config parsing)
+ variable->flags |= (cvar->flags & ~CVAR_ALLOCATED);
+ // cvar->string is now owned by variable instead
+ variable->string = cvar->string;
+ variable->value = atof (variable->string);
+ variable->integer = (int) variable->value;
+ // replace cvar with this one...
+ variable->next = cvar->next;
+ if (cvar_vars == cvar)
+ {
+ // head of the list is easy to change
+ cvar_vars = variable;
+ }
+ else
+ {
+ // otherwise find it somewhere in the list
+ for (cvar2 = cvar_vars;cvar2->next != cvar;cvar2 = cvar2->next);
+ if (cvar2->next == cvar)
+ cvar2->next = variable;
+ }
+
+ // get rid of old allocated cvar
+ // (but not the cvar->string, because we kept that)
+ Z_Free(cvar->name);
+ Z_Free(cvar);
+ }
+ else
+ Con_Printf("Can't register variable %s, already defined\n", variable->name);