Allow -upnp to override setting in wallet (and simplify logic a bit)
[novacoin.git] / src / init.cpp
index 292424f..12e890c 100644 (file)
@@ -237,6 +237,7 @@ bool AppInit2(int argc, char* argv[])
         return false;
     }
 
+    fTestNet = GetBoolArg("-testnet");
     fDebug = GetBoolArg("-debug");
 
 #ifndef __WXMSW__
@@ -499,7 +500,6 @@ bool AppInit2(int argc, char* argv[])
         }
     }
 
-    fTestNet = GetBoolArg("-testnet");
     bool fTor = (fUseProxy && addrProxy.port == htons(9050));
     if (fTor)
     {
@@ -516,16 +516,11 @@ bool AppInit2(int argc, char* argv[])
     fAllowDNS = GetBoolArg("-dns");
     fNoListen = GetBoolArg("-nolisten");
 
-    if (fHaveUPnP)
-    {
-#if USE_UPNP
-    if (GetBoolArg("-noupnp"))
-        fUseUPnP = false;
-#else
-    if (GetBoolArg("-upnp"))
-        fUseUPnP = true;
-#endif
-    }
+    // Command-line args override in-wallet settings:
+    if (mapArgs.count("-upnp"))
+        fUseUPnP = GetBoolArg("-upnp");
+    else if (mapArgs.count("-noupnp"))
+        fUseUPnP = !GetBoolArg("-noupnp");
 
     if (!fNoListen)
     {