diff --git a/source/src/command.cpp b/source/src/command.cpp index 312ae497..d5495f9e 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -169,7 +169,7 @@ COMMANDF(isconst, "s", (const char *name) { ident *id = idents->access(name); in int variable(const char *name, int minval, int cur, int maxval, int *storage, void (*fun)(), bool persist) { if(!idents) idents = new hashtable; - ident v(ID_VAR, name, minval, maxval, storage, fun, persist, IEXC_CORE); + ident v(ID_VAR, name, minval, maxval, storage, cur, fun, persist, IEXC_CORE); idents->access(name, v); return cur; } @@ -177,7 +177,7 @@ int variable(const char *name, int minval, int cur, int maxval, int *storage, vo float fvariable(const char *name, float minval, float cur, float maxval, float *storage, void (*fun)(), bool persist) { if(!idents) idents = new hashtable; - ident v(ID_FVAR, name, minval, maxval, storage, fun, persist, IEXC_CORE); + ident v(ID_FVAR, name, minval, maxval, storage, cur, fun, persist, IEXC_CORE); idents->access(name, v); return cur; } @@ -1440,8 +1440,16 @@ void writecfg() if(!id.persist) continue; switch(id.type) { - case ID_VAR: f->printf("%s %d\n", id.name, *id.storage.i); break; - case ID_FVAR: f->printf("%s %s\n", id.name, floatstr(*id.storage.f)); break; + case ID_VAR: + { + if(*id.storage.i != id.defaultval) f->printf("%s %d\n", id.name, *id.storage.i); + break; + } + case ID_FVAR: + { + if(*id.storage.f != id.defaultvalf) f->printf("%s %s\n", id.name, floatstr(*id.storage.f)); + break; + } case ID_SVAR: f->printf("%s [%s]\n", id.name, *id.storage.s); break; } ); diff --git a/source/src/command.h b/source/src/command.h index 3ed785a3..bd34bc25 100644 --- a/source/src/command.h +++ b/source/src/command.h @@ -39,22 +39,24 @@ struct ident { void (*getfun)(); // ID_SVAR (called /before/ reading the value string, as a chance for last-minute updates) char *executing; // ID_ALIAS - }; + int defaultval; // ID_VAR + float defaultvalf; // ID_FVAR + }; short context; bool persist; ident() {} // ID_VAR - ident(int type, const char *name, int minval, int maxval, int *i, void (*fun)(), bool persist, int context) + ident(int type, const char *name, int minval, int maxval, int *i, int defval, void (*fun)(), bool persist, int context) : type(type), name(name), isconst(false), minval(minval), maxval(maxval), fun(fun), - sig(NULL), action(NULL), executing(NULL), context(context), persist(persist) + sig(NULL), action(NULL), defaultval(defval), context(context), persist(persist) { storage.i = i; } // ID_FVAR - ident(int type, const char *name, float minval, float maxval, float *f, void (*fun)(), bool persist, int context) + ident(int type, const char *name, float minval, float maxval, float *f, float defval, void (*fun)(), bool persist, int context) : type(type), name(name), isconst(false), minvalf(minval), maxvalf(maxval), fun(fun), - sig(NULL), action(NULL), executing(NULL), context(context), persist(persist) + sig(NULL), action(NULL), defaultvalf(defval), context(context), persist(persist) { storage.f = f; } // ID_SVAR