浏览代码

save player registeer after a new player is added

Kolja Strohm 9 月之前
父节点
当前提交
136c21460f
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 11 5
      FactoryCraft/PlayerRegister.cpp

+ 11 - 5
FactoryCraft/PlayerRegister.cpp

@@ -41,15 +41,18 @@ RegisteredPlayer::RegisteredPlayer(Framework::StreamReader* zReader)
     delete[] buffer;
 }
 
-int RegisteredPlayer::getId() const {
+int RegisteredPlayer::getId() const
+{
     return id;
 }
 
-Framework::Text RegisteredPlayer::getName() const {
+Framework::Text RegisteredPlayer::getName() const
+{
     return name;
 }
 
-Framework::Text RegisteredPlayer::getSecret() const {
+Framework::Text RegisteredPlayer::getSecret() const
+{
     return secret;
 }
 
@@ -83,7 +86,8 @@ PlayerRegister::PlayerRegister(Framework::Text worldPath)
     regDat.close();
 }
 
-Framework::Text PlayerRegister::addPlayer(Framework::Text name) {
+Framework::Text PlayerRegister::addPlayer(Framework::Text name)
+{
     cs.lock();
     int nextId = 0;
     for (RegisteredPlayer* player : players)
@@ -97,6 +101,7 @@ Framework::Text PlayerRegister::addPlayer(Framework::Text name) {
     }
     RegisteredPlayer* p = new RegisteredPlayer(nextId, name);
     players.add(p);
+    save();
     cs.unlock();
     return p->getSecret();
 }
@@ -116,7 +121,8 @@ bool PlayerRegister::hasPlayer(Framework::Text name)
     return 0;
 }
 
-int PlayerRegister::getPlayerId(Framework::Text name) {
+int PlayerRegister::getPlayerId(Framework::Text name)
+{
     cs.lock();
     for (RegisteredPlayer* player : players)
     {