From 1f76601c56b92ed859fb6dac7e354e88a5caaab4 Mon Sep 17 00:00:00 2001 From: John Reese Date: Thu, 29 Sep 2011 09:54:44 -0400 Subject: [PATCH] Get missing defaults and save options when loading Follow-up to ref 60632d42f. Initial implementation would lose loaded options when the module was reloaded, and would cause errors if the loaded dictionary did not contain all of the option values. --- push.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/push.cpp b/push.cpp index 1fd83d1..1170c71 100644 --- a/push.cpp +++ b/push.cpp @@ -963,6 +963,26 @@ class CPushMod : public CModule if (status == MCString::MCS_SUCCESS) { PutModule("Options loaded from " + file_path); + + // Restore any defaults that aren't in the loaded dictionary, + // and save loaded options to ZNC's data store + for (MCString::iterator i = defaults.begin(); i != defaults.end(); i++) + { + CString option = i->first; + MCString::iterator pos = options.find(option); + + if (pos == options.end()) + { + options[option] = defaults[option]; + DelNV(option); + } + else + { + SetNV(option, options[option]); + } + } + + authencode(); } else {