Skip to content

Commit

Permalink
简单修改
Browse files Browse the repository at this point in the history
简单修改
  • Loading branch information
NingLeixueR committed Jan 15, 2024
1 parent 3361097 commit c3d0ccc
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 75 deletions.
1 change: 1 addition & 0 deletions public/actor/actor_base/actor_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ namespace ngl

void actor_address::actor_add(i32_serverid aserverid, i64_actorid adataid)
{
LogLocalError("######################serverid:actorid [%]:[%]", aserverid, adataid);
m_impl_actor_address()->actor_add(aserverid, adataid);
}

Expand Down
54 changes: 27 additions & 27 deletions public/actor/actor_base/actor_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ namespace ngl
//加载全部数据
Assert(m_tab->m_isloadall);
i64_actorid lrequestactor = apack->m_head.get_request_actor();
auto pro = std::make_shared<actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>>();
pro->m_stat = true;
pro->m_over = false;
pro->m_data.make();
ngl::dbdata<TDBTAB>::foreach_index([lrequestactor, lsendmaxcount, &pro](int aindex, TDBTAB& atab)
actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB> pro;
pro.m_stat = true;
pro.m_over = false;
pro.m_data.make();
ngl::dbdata<TDBTAB>::foreach_index([lrequestactor, lsendmaxcount, apack, &pro](int aindex, TDBTAB& atab)
{

if constexpr (PROTYPE == EPROTOCOL_TYPE_CUSTOM)
Expand All @@ -94,29 +94,29 @@ namespace ngl
pro->m_data.insert(std::make_pair(lguid, atab));
if (aindex % lsendmaxcount == 0)
{
actor::static_send_actor(lrequestactor, actor_guid::make(), pro);
pro = std::make_shared<actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>>();
pro->m_stat = true;
pro->m_over = false;
nets::net()->send(apack->m_id, pro, lrequestactor, actor_guid::make());
pro = actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>();
pro.m_stat = true;
pro.m_over = false;
}
}
if constexpr (PROTYPE == EPROTOCOL_TYPE_PROTOCOLBUFF)
{
actor_guid lguid(atab.m_id());
pro->m_data.m_data->insert(std::make_pair(lguid, atab));
pro.m_data.m_data->insert(std::make_pair(lguid, atab));
if (aindex % lsendmaxcount == 0)
{
actor::static_send_actor(lrequestactor, actor_guid::make(), pro);
pro = std::make_shared<actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>>();
pro->m_stat = true;
pro->m_over = false;
pro->m_data.make();
nets::net()->send(apack->m_id, pro, lrequestactor, actor_guid::make());
pro = actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>();
pro.m_stat = true;
pro.m_over = false;
pro.m_data.make();
}
}

});
pro->m_over = true;
actor::static_send_actor(lrequestactor, actor_guid::make(), pro);
pro.m_over = true;
nets::net()->send(apack->m_id, pro, lrequestactor, actor_guid::make());
LogLocalInfo("loadall[%]", TDBTAB().descriptor()->full_name());
}

Expand Down Expand Up @@ -153,22 +153,22 @@ namespace ngl
}

load(athreadid, lid);
auto pro = std::make_shared<actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>>();
pro->m_data.make();
pro->m_over = true;

actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB> pro;
pro.m_data.make();
pro.m_over = true;
if constexpr (PROTYPE == EPROTOCOL_TYPE_CUSTOM)
{
pro->m_stat = ngl::dbdata<TDBTAB>::get(lid, pro->m_data[adata.m_id]);
pro.m_stat = ngl::dbdata<TDBTAB>::get(lid, pro.m_data[adata.m_id]);
}
if constexpr (PROTYPE == EPROTOCOL_TYPE_PROTOCOLBUFF)
{
pro->m_stat = ngl::dbdata<TDBTAB>::get(lid, (*pro->m_data.m_data)[adata.m_id]);
pro.m_stat = ngl::dbdata<TDBTAB>::get(lid, (*pro.m_data.m_data)[adata.m_id]);
}

uint64_t lrequestactor = apack->m_head.get_request_actor();
actor::static_send_actor(lrequestactor, actor_guid::make(), pro);
i64_actorid lrequestactor = apack->m_head.get_request_actor();
nets::net()->send(apack->m_id, pro, lrequestactor, actor_guid::make());
std::string lname;
LogLocalError("load finish: [%]", tools::type_name<actor_db_load<PROTYPE, TDBTAB_TYPE, TDBTAB>>(lname));
LogLocalError("load finish: [%][%]", lrequestactor, tools::type_name<actor_db_load<PROTYPE, TDBTAB_TYPE, TDBTAB>>(lname));
}
}

Expand Down
13 changes: 12 additions & 1 deletion public/actor/actor_base/actor_db_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ namespace ngl
return loadfinish();
}
std::string lname;
LogLocalError("db load respones:[%]", tools::type_name<actor_db_load_response<PROTYPE, DBTYPE, TDBTAB>>(lname));
LogLocalError("db load respones:[%] recv_over[%]"
, tools::type_name<actor_db_load_response<PROTYPE, DBTYPE, TDBTAB>>(lname)
, adata.m_data->m_over? "true":"false"
);
loadfinish(adata.m_data->data(), adata.m_data->m_over);
}Catch;
return true;
Expand Down Expand Up @@ -443,7 +446,11 @@ namespace ngl
bool on_load_finish(bool adbishave)
{
if (m_typedbclientmap.empty())
{
LogLocalError("on_load_finish m_typedbclientmap.empty()");
return false;
}

for (auto itor = m_typedbclientmap.begin(); itor != m_typedbclientmap.end();)
{
if (!itor->second->isload())
Expand All @@ -456,7 +463,11 @@ namespace ngl
itor = m_typedbclientmap.erase(itor);
}
if (!m_typedbclientmap.empty())
{
LogLocalError("on_load_finish !m_typedbclientmap.empty()");
return false;
}

m_actor->db_component_init_data();
// 1、将数据修改为[裁剪修改]
for (auto& [_, data] : m_dbclientmap)
Expand Down
1 change: 1 addition & 0 deletions public/logic/public/public/chat/actor_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace ngl
{
*pro->add_m_chatlist() = item;
}
LogLocalError("Send All [pbnet::PROBUFF_NET_CHAT_RESPONSE]");
send_allclient(pro);
std::list<pbnet::chatitem>& ls = m_chatitem[_channelid];
ls.insert(ls.end(), _update.begin(), _update.end());
Expand Down
6 changes: 3 additions & 3 deletions public/logic/public/public/chat/actor_chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ namespace ngl
virtual void loaddb_finish(bool adbishave) {}


bool handle(
message<mforward<pbnet::PROBUFF_NET_CHAT>>& adata)
bool handle(message<mforward<pbnet::PROBUFF_NET_CHAT>>& adata)
{

pbnet::PROBUFF_NET_CHAT& recv = *adata.m_data->data();
LogLocalError("recv [pbnet::PROBUFF_NET_CHAT] type:%", recv.m_type());

if (recv.m_type() == pbnet::chat_speak)
{
auto pro = std::make_shared<pbnet::PROBUFF_NET_CHAT_RESPONSE>();
Expand Down
6 changes: 3 additions & 3 deletions public/protocol/protocol/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ namespace ngl
if (itor1 == m_protocolfun.end())
{
char m_hexstr[1024] = {0};
LogLocalInfo("protocol::push [%] Error protocolnum[%] ", lprotocoltype, protocoltools::hex_str(m_hexstr, lprotocolnum));
LogLocalError("protocol::push [%] Error protocolnum[%] ", lprotocoltype, protocoltools::hex_str(m_hexstr, lprotocolnum));
return;
}
auto itor2 = itor1->second.find(lprotocolnum);
if (itor2 == itor1->second.end())
{
char m_hexstr[1024] = { 0 };
LogLocalInfo("protocol::push Error protocolnum[%] ", protocoltools::hex_str(m_hexstr, lprotocolnum));
LogLocalError("protocol::push Error protocolnum[%] ", protocoltools::hex_str(m_hexstr, lprotocolnum));
return;
}
const char* lpprotocolname = protocoltools::name(lprotocolnum, lprotocoltype);
LogLocalInfo("protocol::push Info [%]", lpprotocolname);
LogLocalError("protocol::push Info [%]", lpprotocolname);
lpfun = &itor2->second;
}
std::shared_ptr<void> lptrpram = lpfun->m_packfun(apack);
Expand Down
82 changes: 41 additions & 41 deletions public/protocol/protocol/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,46 +32,40 @@ namespace ngl
, const char* aname);
static i32_serverid nodeid();


template <typename T>
static void log(const char* astr)
{
std::string lname;
LogLocalError("% [%] success"
, astr
, tools::type_name<T>(lname)
);
}

//// --- ACTOR间通信
template <typename T, EPROTOCOL_TYPE TYPE>
static void registry_actor(ENUM_ACTOR atype, const char* aname)
{
typefun_pack lpackfun = [atype](std::shared_ptr<pack>& apack)->std::shared_ptr<void>
{
Try
Try
{
std::string lname;
T* lp = new T();
std::shared_ptr<void> ltemp(lp);
if (structbytes<T>::tostruct(apack, *lp))
{
std::string lname;

LogLocalError("registry_actor pop [%][%] beg"
, tools::type_name<T>(lname)
, atype
);
T* lp = new T();
std::shared_ptr<void> ltemp(lp);
//std::cout << typeid(T).name() << std::endl;
if (structbytes<T>::tostruct(apack, *lp))
{
LogLocalError("registry_actor pop [%][%] end"
, tools::type_name<T>(lname)
, atype
);
return ltemp;
}
}Catch;
LogLocalError("registry_actor pop [%][%] fail"
, boost::typeindex::type_id_with_cvr<T>().pretty_name()
, atype
);
protocol::log<T>("pop success");
return ltemp;
}
}Catch;
protocol::log<T>("pop fail");
return nullptr;
};
std::string lname = aname;
typefun_run lrunfun = [atype, lname](std::shared_ptr<pack>& apack, std::shared_ptr<void>& aptrpram)->bool
{
std::string lname;
LogLocalError("registry_actor dosth [%][%] beg"
, tools::type_name<T>(lname)
, atype
);
actor_guid lactorguid(apack->m_head.get_actor());
actor_guid lrequestactorguid(apack->m_head.get_request_actor());
std::shared_ptr<T> ldatapack = std::static_pointer_cast<T>(aptrpram);
Expand Down Expand Up @@ -109,16 +103,19 @@ namespace ngl
{
typefun_pack lpackfun = [](std::shared_ptr<pack>& apack)->std::shared_ptr<void>
{
Try
Try
{
using typeforward = actor_forward<T, TYPE, ISTRUE, ngl::forward>;
typeforward* lp = new typeforward();
lp->m_recvpack = apack;
std::shared_ptr<void> ltemp(lp);
if (structbytes<typeforward>::tostruct(apack, *lp, true))
{
using typeforward = actor_forward<T, TYPE, ISTRUE, ngl::forward>;
typeforward* lp = new typeforward();
lp->m_recvpack = apack;
std::shared_ptr<void> ltemp(lp);
if (structbytes<typeforward>::tostruct(apack, *lp, true) == false)
return nullptr;
protocol::log<T>("pop success");
return ltemp;
}
}Catch;
protocol::log<T>("pop fail");
return nullptr;
};
typefun_run lrunfun = [atype](std::shared_ptr<pack>& apack, std::shared_ptr<void>& aptrpram)->bool
Expand All @@ -142,15 +139,18 @@ namespace ngl
{
typefun_pack lpackfun = [](std::shared_ptr<pack>& apack)->std::shared_ptr<void>
{
Try
Try
{
using typeforward = actor_forward<T, TYPE, ISTRUE, T>;
typeforward* lp = new typeforward();
std::shared_ptr<void> ltemp(lp);
if (structbytes<typeforward>::tostruct(apack, *lp))
{
using typeforward = actor_forward<T, TYPE, ISTRUE, T>;
typeforward* lp = new typeforward();
std::shared_ptr<void> ltemp(lp);
if (structbytes<typeforward>::tostruct(apack, *lp) == false)
return nullptr;
protocol::log<T>("pop success");
return ltemp;
}
}Catch;
protocol::log<T>("pop fail");
return nullptr;
};
typefun_run lrunfun = [atype](std::shared_ptr<pack>& apack, std::shared_ptr<void>& aptrpram)->bool
Expand Down

0 comments on commit c3d0ccc

Please sign in to comment.