This commit is contained in:
aozhiwei 2023-12-06 17:48:06 +08:00
parent 7f48d50a82
commit 271d3f22e3

View File

@ -8,6 +8,7 @@
#include <f8/msgqueue.h> #include <f8/msgqueue.h>
#include <f8/comgr.h> #include <f8/comgr.h>
#include <f8/coroutine.h> #include <f8/coroutine.h>
#include <f8/timer.h>
#include "playermgr.h" #include "playermgr.h"
#include "player.h" #include "player.h"
@ -17,7 +18,8 @@
void PlayerMgr::Init() void PlayerMgr::Init()
{ {
for (int i = 1; i <= 19; ++i) { #if 0
for (int i = 1; i <= 300; ++i) {
int idx = i; int idx = i;
std::string account_id = a8::Format("6513_2006_%d", {idx}); std::string account_id = a8::Format("6513_2006_%d", {idx});
auto hum = std::make_shared<Player>(); auto hum = std::make_shared<Player>();
@ -25,6 +27,21 @@ void PlayerMgr::Init()
account_id_hash_[hum->GetAccountId()] = hum; account_id_hash_[hum->GetAccountId()] = hum;
socket_id_hash_[hum->GetSocketId()] = hum; socket_id_hash_[hum->GetSocketId()] = hum;
} }
#endif
f8::Timer::Instance()->SetInterval
(
3000,
[this] (int et, const a8::Args* args)
{
if (et == a8::TIMER_EXEC_EVENT) {
int idx = account_id_hash_.size() + 1;
std::string account_id = a8::Format("6513_2006_%d", {idx});
auto hum = std::make_shared<Player>();
hum->Init(idx, account_id);
account_id_hash_[hum->GetAccountId()] = hum;
socket_id_hash_[hum->GetSocketId()] = hum;
}
});
} }
void PlayerMgr::UnInit() void PlayerMgr::UnInit()