From: Naffanya Date: Sun, 6 Oct 2013 20:34:20 +0000 (+0300) Subject: Correction of the container map X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/9b8f74aec65e4e61ae82e14e6cb439da736ee808?ds=sidebyside Correction of the container map --- diff --git a/include/stg/user_property.h b/include/stg/user_property.h index fbcf8856..f53b416d 100644 --- a/include/stg/user_property.h +++ b/include/stg/user_property.h @@ -72,7 +72,8 @@ public: bool isPassword, bool isStat, STG_LOGGER & logger, - const std::string & sd); + const std::string & sd, + std::map & properties); virtual ~USER_PROPERTY_LOGGED() {} USER_PROPERTY_LOGGED * GetPointer() throw() { return this; } @@ -122,6 +123,7 @@ private: USER_STAT stat; USER_CONF conf; + std::map & properties; public: USER_PROPERTIES(const std::string & sd); @@ -171,8 +173,6 @@ public: USER_PROPERTY_LOGGED userdata7; USER_PROPERTY_LOGGED userdata8; USER_PROPERTY_LOGGED userdata9; - - std::map params; }; //============================================================================= @@ -276,7 +276,8 @@ USER_PROPERTY_LOGGED::USER_PROPERTY_LOGGED(varT & val, bool isPass, bool isSt, STG_LOGGER & logger, - const std::string & sd) + const std::string & sd, + std::map & properties) : USER_PROPERTY(val), stgLogger(logger), @@ -285,6 +286,7 @@ USER_PROPERTY_LOGGED::USER_PROPERTY_LOGGED(varT & val, name(n), scriptsDir(sd) { +properties.insert(std::make_pair(name, this)); } //------------------------------------------------------------------------- template @@ -386,9 +388,10 @@ else //------------------------------------------------------------------------- std::string USER_PROPERTIES::GetPropertyValue(const std::string & name) const { - std::map::iterator it = params.find(name); - if (it != params.end()) return it->second.ToString(); - else return ""; +std::map::iterator it = properties.find(name); +if (it == properties.end()) + return ""; +return it->second.ToString(); } //------------------------------------------------------------------------- //------------------------------------------------------------------------- @@ -401,6 +404,7 @@ return stream << value.ConstData(); } //----------------------------------------------------------------------------- template +inline std::string USER_PROPERTY::ToString() const { std::stringstream stream; diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index d3f78bcc..b2ac841f 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -1474,7 +1474,15 @@ while (it != messages.end()) //----------------------------------------------------------------------------- std::string USER_IMPL::GetParamValue(const std::string & name) const { - return properties.GetPropertyValue(&name); + if (name == "id") + { + std::stringstream stream; + stream << id; + return stream.str();; + } + if (name == "login") return login; + if (name == "ip") return currIP.ToString(); + return properties.GetPropertyValue(&name); //if (name == "freeMb") return property.freeMb.ToString(); //if (name == "passive") return property.passive.ToString(); //if (name == "disabled") return property.disabled.ToString(); @@ -1499,14 +1507,6 @@ std::string USER_IMPL::GetParamValue(const std::string & name) const //if (name == "userdata8") return property.userdata8; //if (name == "userdata9") return property.userdata9; //if (name == "cash") return property.cash.ToString(); -//if (name == "id") -// { -// std::stringstream stream; -// stream << id; -// return stream.str();; -// } -//if (name == "login") return login; -//if (name == "ip") return currIP.ToString(); //return ""; } //----------------------------------------------------------------------------- diff --git a/projects/stargazer/user_property.cpp b/projects/stargazer/user_property.cpp index 5af05a46..1bb6c51c 100644 --- a/projects/stargazer/user_property.cpp +++ b/projects/stargazer/user_property.cpp @@ -3,40 +3,40 @@ USER_PROPERTIES::USER_PROPERTIES(const std::string & sd) : stat(), conf(), - cash (stat.cash, "cash", false, true, GetStgLogger(), sd), - up (stat.up, "upload", false, true, GetStgLogger(), sd), - down (stat.down, "download", false, true, GetStgLogger(), sd), - lastCashAdd (stat.lastCashAdd, "lastCashAdd", false, true, GetStgLogger(), sd), - passiveTime (stat.passiveTime, "passiveTime", false, true, GetStgLogger(), sd), - lastCashAddTime (stat.lastCashAddTime, "lastCashAddTime", false, true, GetStgLogger(), sd), - freeMb (stat.freeMb, "freeMb", false, true, GetStgLogger(), sd), - lastActivityTime(stat.lastActivityTime, "lastActivityTime", false, true, GetStgLogger(), sd), + cash (stat.cash, "cash", false, true, GetStgLogger(), sd, properties), + up (stat.up, "upload", false, true, GetStgLogger(), sd, properties), + down (stat.down, "download", false, true, GetStgLogger(), sd, properties), + lastCashAdd (stat.lastCashAdd, "lastCashAdd", false, true, GetStgLogger(), sd, properties), + passiveTime (stat.passiveTime, "passiveTime", false, true, GetStgLogger(), sd, properties), + lastCashAddTime (stat.lastCashAddTime, "lastCashAddTime", false, true, GetStgLogger(), sd, properties), + freeMb (stat.freeMb, "freeMb", false, true, GetStgLogger(), sd, properties), + lastActivityTime(stat.lastActivityTime, "lastActivityTime", false, true, GetStgLogger(), sd, properties), - password (conf.password, "password", true, false, GetStgLogger(), sd), - passive (conf.passive, "passive", false, false, GetStgLogger(), sd), - disabled (conf.disabled, "disabled", false, false, GetStgLogger(), sd), - disabledDetailStat(conf.disabledDetailStat, "DisabledDetailStat", false, false, GetStgLogger(), sd), - alwaysOnline(conf.alwaysOnline, "alwaysOnline", false, false, GetStgLogger(), sd), - tariffName (conf.tariffName, "tariff", false, false, GetStgLogger(), sd), - nextTariff (conf.nextTariff, "new tariff", false, false, GetStgLogger(), sd), - address (conf.address, "address", false, false, GetStgLogger(), sd), - note (conf.note, "note", false, false, GetStgLogger(), sd), - group (conf.group, "group", false, false, GetStgLogger(), sd), - email (conf.email, "email", false, false, GetStgLogger(), sd), - phone (conf.phone, "phone", false, false, GetStgLogger(), sd), - realName (conf.realName, "realName", false, false, GetStgLogger(), sd), - credit (conf.credit, "credit", false, false, GetStgLogger(), sd), - creditExpire(conf.creditExpire, "creditExpire", false, false, GetStgLogger(), sd), - ips (conf.ips, "IP", false, false, GetStgLogger(), sd), - userdata0 (conf.userdata[0], "userdata0", false, false, GetStgLogger(), sd), - userdata1 (conf.userdata[1], "userdata1", false, false, GetStgLogger(), sd), - userdata2 (conf.userdata[2], "userdata2", false, false, GetStgLogger(), sd), - userdata3 (conf.userdata[3], "userdata3", false, false, GetStgLogger(), sd), - userdata4 (conf.userdata[4], "userdata4", false, false, GetStgLogger(), sd), - userdata5 (conf.userdata[5], "userdata5", false, false, GetStgLogger(), sd), - userdata6 (conf.userdata[6], "userdata6", false, false, GetStgLogger(), sd), - userdata7 (conf.userdata[7], "userdata7", false, false, GetStgLogger(), sd), - userdata8 (conf.userdata[8], "userdata8", false, false, GetStgLogger(), sd), - userdata9 (conf.userdata[9], "userdata9", false, false, GetStgLogger(), sd) + password (conf.password, "password", true, false, GetStgLogger(), sd, properties), + passive (conf.passive, "passive", false, false, GetStgLogger(), sd, properties), + disabled (conf.disabled, "disabled", false, false, GetStgLogger(), sd, properties), + disabledDetailStat(conf.disabledDetailStat, "DisabledDetailStat", false, false, GetStgLogger(), sd, properties), + alwaysOnline(conf.alwaysOnline, "alwaysOnline", false, false, GetStgLogger(), sd, properties), + tariffName (conf.tariffName, "tariff", false, false, GetStgLogger(), sd, properties), + nextTariff (conf.nextTariff, "new tariff", false, false, GetStgLogger(), sd, properties), + address (conf.address, "address", false, false, GetStgLogger(), sd, properties), + note (conf.note, "note", false, false, GetStgLogger(), sd, properties), + group (conf.group, "group", false, false, GetStgLogger(), sd, properties), + email (conf.email, "email", false, false, GetStgLogger(), sd, properties), + phone (conf.phone, "phone", false, false, GetStgLogger(), sd, properties), + realName (conf.realName, "realName", false, false, GetStgLogger(), sd, properties), + credit (conf.credit, "credit", false, false, GetStgLogger(), sd, properties), + creditExpire(conf.creditExpire, "creditExpire", false, false, GetStgLogger(), sd, properties), + ips (conf.ips, "IP", false, false, GetStgLogger(), sd, properties), + userdata0 (conf.userdata[0], "userdata0", false, false, GetStgLogger(), sd, properties), + userdata1 (conf.userdata[1], "userdata1", false, false, GetStgLogger(), sd, properties), + userdata2 (conf.userdata[2], "userdata2", false, false, GetStgLogger(), sd, properties), + userdata3 (conf.userdata[3], "userdata3", false, false, GetStgLogger(), sd, properties), + userdata4 (conf.userdata[4], "userdata4", false, false, GetStgLogger(), sd, properties), + userdata5 (conf.userdata[5], "userdata5", false, false, GetStgLogger(), sd, properties), + userdata6 (conf.userdata[6], "userdata6", false, false, GetStgLogger(), sd, properties), + userdata7 (conf.userdata[7], "userdata7", false, false, GetStgLogger(), sd, properties), + userdata8 (conf.userdata[8], "userdata8", false, false, GetStgLogger(), sd, properties), + userdata9 (conf.userdata[9], "userdata9", false, false, GetStgLogger(), sd, properties) {}