]> git.stg.codes - stg.git/blobdiff - stargazer/corps_impl.cpp
Non-virtual admin.
[stg.git] / stargazer / corps_impl.cpp
index c0da9a67f7bd27ab2c0db32ef8eb72ed0e3f3d8b..b41b4559e66aef6386a3234577fe6e230751f2d0 100644 (file)
@@ -42,11 +42,11 @@ Read();
 int CorporationsImpl::Add(const CorpConf & corp, const Admin * admin)
 {
 std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> lock(mutex);
 if (data.empty())
     {
-    printfd(__FILE__, "no admin in system!\n");
+    printfd(__FILE__, "no corporations in system!\n");
     return true;
     }