X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/6e6de2ae8f5f661500c565aca8c36277e860b834..20d4dd0571e75d254444acf755a01b48a691c7c2:/stargazer/corps_impl.cpp diff --git a/stargazer/corps_impl.cpp b/stargazer/corps_impl.cpp index c0da9a67..b41b4559 100644 --- a/stargazer/corps_impl.cpp +++ b/stargazer/corps_impl.cpp @@ -42,11 +42,11 @@ Read(); int CorporationsImpl::Add(const CorpConf & corp, const Admin * admin) { std::lock_guard lock(mutex); -const auto priv = admin->GetPriv(); +const auto& priv = admin->priv(); -if (!priv->corpChg) +if (!priv.corpChg) { - std::string s = admin->GetLogStr() + " Add corporation \'" + corp.name + "\'. Access denied."; + std::string s = admin->logStr() + " Add corporation \'" + corp.name + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; @@ -57,7 +57,7 @@ crp_iter si(find(data.begin(), data.end(), corp)); if (si != data.end()) { strError = "Corporation \'" + corp.name + "\' cannot not be added. Corporation already exist."; - WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); + WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } @@ -67,12 +67,12 @@ data.push_back(corp); if (store->AddCorp(corp.name) == 0) { WriteServLog("%s Corporation \'%s\' added.", - admin->GetLogStr().c_str(), corp.name.c_str()); + admin->logStr().c_str(), corp.name.c_str()); return 0; } strError = "Corporation \'" + corp.name + "\' was not added. Error: " + store->GetStrError(); -WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); +WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } @@ -80,11 +80,11 @@ return -1; int CorporationsImpl::Del(const std::string & name, const Admin * admin) { std::lock_guard lock(mutex); -const auto priv = admin->GetPriv(); +const auto& priv = admin->priv(); -if (!priv->corpChg) +if (!priv.corpChg) { - std::string s = admin->GetLogStr() + " Delete corporation \'" + name + "\'. Access denied."; + std::string s = admin->logStr() + " Delete corporation \'" + name + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; @@ -95,7 +95,7 @@ crp_iter si(find(data.begin(), data.end(), CorpConf(name))); if (si == data.end()) { strError = "Corporation \'" + name + "\' cannot be deleted. Corporation does not exist."; - WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); + WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } @@ -112,23 +112,23 @@ data.erase(si); if (store->DelCorp(name) < 0) { strError = "Corporation \'" + name + "\' was not deleted. Error: " + store->GetStrError(); - WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); + WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } -WriteServLog("%s Corporation \'%s\' deleted.", admin->GetLogStr().c_str(), name.c_str()); +WriteServLog("%s Corporation \'%s\' deleted.", admin->logStr().c_str(), name.c_str()); return 0; } //----------------------------------------------------------------------------- int CorporationsImpl::Change(const CorpConf & corp, const Admin * admin) { std::lock_guard lock(mutex); -const auto priv = admin->GetPriv(); +const auto& priv = admin->priv(); -if (!priv->corpChg) +if (!priv.corpChg) { - std::string s = admin->GetLogStr() + " Change corporation \'" + corp.name + "\'. Access denied."; + std::string s = admin->logStr() + " Change corporation \'" + corp.name + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; @@ -139,7 +139,7 @@ crp_iter si(find(data.begin(), data.end(), corp)); if (si == data.end()) { strError = "Corporation \'" + corp.name + "\' cannot be changed " + ". Corporation does not exist."; - WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); + WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } @@ -152,7 +152,7 @@ if (store->SaveCorp(corp)) } WriteServLog("%s Corporation \'%s\' changed.", - admin->GetLogStr().c_str(), corp.name.c_str()); + admin->logStr().c_str(), corp.name.c_str()); return 0; } @@ -206,7 +206,7 @@ bool CorporationsImpl::Exists(const std::string & name) const std::lock_guard lock(mutex); if (data.empty()) { - printfd(__FILE__, "no admin in system!\n"); + printfd(__FILE__, "no corporations in system!\n"); return true; }