]> git.stg.codes - stg.git/commitdiff
Method GetParamValue and correction method Connect(user_imp)
authorNaffanya <naffanya@naffanya.(none)>
Wed, 24 Jul 2013 22:17:39 +0000 (01:17 +0300)
committerNaffanya <naffanya@naffanya.(none)>
Wed, 24 Jul 2013 22:17:39 +0000 (01:17 +0300)
include/stg/user.h
projects/stargazer/user_impl.cpp
projects/stargazer/user_impl.h

index b011555581dfc0e8e75c4160bb9bcf6d6a1b7dd2..365c71ef1f0c53567e251e95c1dfe5da707f9f28 100644 (file)
@@ -101,7 +101,7 @@ public:
     virtual void                OnAdd() = 0;
     virtual void                OnDelete() = 0;
 
-    virtual const std::string & GetParamValue(const std::string & name) const = 0;
+    virtual std::string GetParamValue(const std::string & name) const = 0;
 };
 
 typedef USER * USER_PTR;
index 95989c45361d8dd880dd12856cfffb16eef016fd..55b5ffe7a194eaeeda8ac8c8446039d6ec20c834 100644 (file)
@@ -588,14 +588,21 @@ if (!fakeConnect)
             }
 
         std::string scriptOnConnectParams;
-        strprintf(&scriptOnConnectParams,
-                "%s \"%s\" \"%s\" \"%f\" \"%d\" \"%s\"",
-                scriptOnConnect.c_str(),
-                login.c_str(),
-                inet_ntostring(currIP).c_str(),
-                cash.ConstData(),
-                id,
-                dirsStr);
+
+        std::vector<std::string>::const_iterator it(settings->GetScriptParams().begin());
+        while (it != settings->GetScriptParams().end())
+            {
+            scriptOnConnectParams  += GetParamValue(it->c_str());
+            }
+
+//        strprintf(&scriptOnConnectParams,
+//                "%s \"%s\" \"%s\" \"%f\" \"%d\" \"%s\"",
+//                scriptOnConnect.c_str(),
+//                login.c_str(),
+//                inet_ntostring(currIP).c_str(),
+//                cash.ConstData(),
+//                id,
+//                dirsStr);
 
         ScriptExec(scriptOnConnectParams.c_str());
         }
@@ -1457,119 +1464,116 @@ while (it != messages.end())
     }
 }
 //-----------------------------------------------------------------------------
-const std::string & USER_IMPL::GetParamValue(const std::string & name) const
+std::string USER_IMPL::GetParamValue(const std::string & name) const
     {
-    std::string value;
-
-    if (name=="cash")
+    if (name == "cash")
         {
-        value=property.cash;
+        return static_cast<std::string>(property.cash);
         }
-    if (name=="freeMb")
+    if (name == "freeMb")
         {
-        value=property.freeMb;
+        return static_cast<std::string>(property.freeMb);
         }
-    if (name=="passive")
+    if (name == "passive")
         {
-        value=property.passive;
+        return static_cast<std::string>(property.passive);
         }
-    if (name=="disabled")
+    if (name == "disabled")
         {
-        value=property.disabled;
+        return static_cast<std::string>(property.disabled);
         }
-    if (name=="alwaysOnline")
+    if (name == "alwaysOnline")
         {
-        value=property.alwaysOnline;
+        return static_cast<std::string>(property.alwaysOnline);
         }
-    if (name=="tariffName")
+    if (name == "tariffName")
         {
-        value=property.tariffName;
+        return property.tariffName;
         }
-    if (name=="nextTariff")
+    if (name == "nextTariff")
         {
-        value=property.nextTariff;
+        return property.nextTariff;
         }
-    if (name=="address")
+    if (name == "address")
         {
-        value=property.address;
+        return property.address;
         }
-    if (name=="note")
+    if (name == "note")
         {
-        value=property.note;
+        return property.note;
         }
-    if (name=="group")
+    if (name == "group")
         {
-        value=property.group;
+        return property.group;
         }
-    if (name=="email")
+    if (name == "email")
         {
-        value=property.email;
+        return property.email;
         }
-    if (name=="phone")
+    if (name == "phone")
         {
-        value=property.phone;
+        return property.phone;
         }
-    if (name=="realName")
+    if (name == "realName")
         {
-        value=property.realName;
+        return property.realName;
         }
-    if (name=="credit")
+    if (name == "credit")
         {
-        value=property.credit;
+        return static_cast<std::string>(property.credit);
         }
-    if (name=="userdata0")
+    if (name == "userdata0")
         {
-        value=property.userdata0;
+        return property.userdata0;
         }
-    if (name=="userdata1")
+    if (name == "userdata1")
         {
-        value=property.userdata1;
+        return property.userdata1;
         }
-    if (name=="userdata2")
+    if (name == "userdata2")
         {
-        value=property.userdata2;
+        return property.userdata2;
         }
-    if (name=="userdata3")
+    if (name == "userdata3")
         {
-        value=property.userdata3;
+        return property.userdata3;
         }
-    if (name=="userdata4")
+    if (name == "userdata4")
         {
-        value=property.userdata4;
+        return property.userdata4;
         }
-    if (name=="userdata5")
+    if (name == "userdata5")
         {
-        value=property.userdata5;
+        return property.userdata5;
         }
-    if (name=="userdata6")
+    if (name == "userdata6")
         {
-        value=property.userdata6;
+        return property.userdata6;
         }
-    if (name=="userdata7")
+    if (name == "userdata7")
         {
-        value=property.userdata7;
+        return property.userdata7;
         }
-    if (name=="userdata8")
+    if (name == "userdata8")
         {
-        value=property.userdata8;
+        return property.userdata8;
         }
-    if (name=="userdata9")
+    if (name == "userdata9")
         {
-        value=property.userdata9;
+        return property.userdata9;
         }
-    if (name=="id")
+    if (name == "id")
         {
-        value=id;
+        return static_cast<std::string>(id);
         }
-    if (name=="login")
+    if (name == "login")
         {
-        value=login;
+        return login;
         }
-    if (name=="ip")
+    if (name == "ip")
         {
-        value=currIP;
+        return static_cast<std::string>(currIP);
         }
-    return value;
     }
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
index 5fe02bb35cfa62847a3ce18c1b1f6e7c02cd2383..d240f0c8c161ae85a42ddcd2d3fee522fe803181 100644 (file)
@@ -216,7 +216,7 @@ public:
     void            OnAdd();
     void            OnDelete();
 
-    virtual const std::string & GetParamValue(const std::string & name) const;
+    virtual std::string GetParamValue(const std::string & name) const;
 
 private:
     USER_IMPL & operator=(const USER_IMPL & rvalue);