Skip to content

Commit

Permalink
简单修改
Browse files Browse the repository at this point in the history
简单修改
  • Loading branch information
NingLeixueR committed Jan 12, 2024
1 parent 5a36946 commit e4308e4
Show file tree
Hide file tree
Showing 21 changed files with 175 additions and 41 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
#set(CMAKE_CXX_FLAGS "${COLLECT_GCC} -std=c++0x -pthread -lrt -L/usr/lib64/mysql -lmysqlclient -lcurl")
#-lboost_thread
#set(CMAKE_CXX_FLAGS "${COLLECT_GCC} -D_GLIBCXX_USE_CXX11_ABI=0 -Wfatal-errors -std=c++20 -march=native -msse4.1 -O3 -pthread -lrt -lprotobuf -L/usr/lib64/mysql -L/root/lbtest/lbtest/lib -lmysqlclient -lcurl -lcryptopp -lmycorekkk -lboost -I/usr/include/mysql -I/usr/include/curl -I/root/lbtest/lbtest/3part/boost/libs/atomic/src/")
set(CMAKE_CXX_FLAGS "${COLLECT_GCC} -D_GLIBCXX_USE_CXX11_ABI=0 -Wfatal-errors -std=c++20 -march=native -msse4.1 -O3 -pthread -lrt -lprotobuf -lmysqlclient -lcurl -lcryptopp -L/root/ngl/lib -lmycorekkk -I/usr/include/mysql -I/usr/include/curl -I/root/lbtest/lbtest/3part/boost/libs/atomic/src/")
set(CMAKE_CXX_FLAGS "${COLLECT_GCC} -std=c++20 -march=native -msse4.1 -O3 -lrt -L/root/ngl/3part/protobuf/lib -L/usr/lib64/mysql/ -lmysqlclient -lcurl -lcryptopp -L/root/ngl/lib -I/root/ngl/3part/protobuf/include -I/usr/include/mysql -I/usr/include/curl -I/root/lbtest/lbtest/3part/boost/libs/atomic/src/")
INCLUDE_DIRECTORIES(3part/boost/libs/atomic/src)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
Expand Down
2 changes: 1 addition & 1 deletion public/actor/actor_base/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace ngl
virtual void broadcast() {}

// 广播处理函数
bool handle(i32_threadid athread, const std::shared_ptr<pack>& apack, actor_broadcast& adata);
bool handle(message<actor_broadcast>& adata);

// ############# End[Actor 全员广播] #############
#pragma endregion
Expand Down
8 changes: 7 additions & 1 deletion public/actor/actor_base/actor_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "actor_register.h"
#include "cache_list.h"
#include "ttab_dbload.h"
#include <boost/type_index.hpp>

namespace ngl
{
Expand Down Expand Up @@ -166,6 +167,8 @@ namespace ngl

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

Expand Down Expand Up @@ -279,7 +282,10 @@ namespace ngl

bool handle(message<actor_db_load<PROTYPE, TDBTAB_TYPE, TDBTAB>>& adata)
{
//LogLocalInfo(" actor_db actor_db_load<%,%> [%]", TDBTAB_TYPE, TDBTAB::name(), adata.m_id);
std::string lname;
LogLocalError("load: [%] [%]",
tools::type_name<actor_db_load<PROTYPE, TDBTAB_TYPE, TDBTAB>>(lname),
adata.m_data->m_id);
actor_dbtab<PROTYPE, TDBTAB_TYPE, TDBTAB>::load(adata.m_thread, adata.m_pack, *adata.m_data);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion public/actor/actor_base/actor_db_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace ngl
{
bool actor::handle(i32_threadid athread, const std::shared_ptr<pack>& apack, actor_broadcast& adata)
bool actor::handle(message<actor_broadcast>& adata)
{
// ## 保存数据
if (get_actor_manage_dbclient() != nullptr)
Expand Down
9 changes: 9 additions & 0 deletions public/actor/actor_base/actor_db_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ namespace ngl
template <EPROTOCOL_TYPE PROTYPE, pbdb::ENUM_DB TDBTAB_TYPE, typename TDBTAB>
class actor_db;


template <EPROTOCOL_TYPE PROTYPE, pbdb::ENUM_DB DBTYPE, typename TDBTAB, typename TACTOR>
class actor_dbclient : public actor_dbclient_base
{
Expand Down Expand Up @@ -140,6 +141,12 @@ namespace ngl

i64_actorid ldbid = actor_guid::make(actor_type<actor_db<PROTYPE, DBTYPE, TDBTAB>>::type(), tab_self_area, dbnodeid());
nserver->sendtoserver(dbnodeid(), ldata, ldbid, m_actor->id_guid());

std::string lname;
LogLocalError("actor_dbclient loaddb [%] [%]"
, tools::type_name<actor_dbclient<PROTYPE, DBTYPE, TDBTAB, TACTOR>>(lname)
, aid
);
}

actor_guid m_id;
Expand Down Expand Up @@ -381,6 +388,8 @@ namespace ngl
{//加载失败 数据库中没有数据
return loadfinish();
}
std::string lname;
LogLocalError("db load respones:[%]", tools::type_name<actor_db_load_response<PROTYPE, DBTYPE, TDBTAB>>(lname));
loadfinish(adata.m_data->data(), adata.m_data->m_over);
}Catch;
return true;
Expand Down
10 changes: 10 additions & 0 deletions public/actor/actor_base/actor_manage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ namespace ngl
inline void nosafe_push_task_id(ptractor& lpactor, handle_pram& apram)
{
if (lpactor->get_activity_stat() == actor_stat_close || lpactor->get_activity_stat() == actor_stat_init)
{
std::cout << "activity_stat = " << (int)lpactor->get_activity_stat() <<" !!!" << std::endl;
return;
}

lpactor->push(apram);
if (lpactor->get_activity_stat() == actor_stat_free)
{
Expand Down Expand Up @@ -253,7 +257,10 @@ namespace ngl
ngl_lock;
ptractor lpptractor = nosafe_get_actorbyid(aguid, apram, abool);
if (lpptractor == nullptr || lpptractor->get_activity_stat() == actor_stat_close)
{
std::cout << "push_task_id fail !!!" << std::endl;
return;
}
nosafe_push_task_id(lpptractor, apram);
}

Expand All @@ -262,7 +269,10 @@ namespace ngl
ngl_lock;
// 单例不允许群发
if (enum_actor::is_signle(atype) && aotherserver)
{
std::cout << "enum_actor::is_signle("<< atype <<") && "<< aotherserver << std::endl;
return;
}
// 1.先发给本机上的atype
for (auto& [key, value] : m_actorbytype[atype])
{
Expand Down
6 changes: 5 additions & 1 deletion public/actor/actor_base/actor_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ namespace ngl

void init_actor_type()
{
#define dinit_atype(ACTORCLASS, ACTORTYPE) actor_type<ACTORCLASS>::inits(ACTORTYPE)
#define dinit_atype(ACTORCLASS, ACTORTYPE) \
actor_type<ACTORCLASS>::inits(ACTORTYPE);\
LogLocalError("init_actor_type [%]-[%]", boost::typeindex::type_id_with_cvr<ACTORCLASS>().pretty_name(), (int)(ACTORTYPE))



dinit_atype(actor_client, ACTOR_ADDRESS_CLIENT);
dinit_atype(actor_create, ACTOR_CREATE);
Expand Down
5 changes: 4 additions & 1 deletion public/actor/actor_base/actor_type.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "actor_enum.h"
#include <boost/type_index.hpp>

namespace ngl
{
Expand All @@ -16,7 +17,9 @@ namespace ngl

static ENUM_ACTOR type()
{
assert(m_type == ACTOR_NONE);
std::string lname;
std::cout << tools::type_name<T>(lname) << std::endl;
assert(m_type != ACTOR_NONE);
return m_type;
}
};
Expand Down
4 changes: 2 additions & 2 deletions public/actor/actor_logic/log/actor_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ namespace ngl
{
}

bool actor_log::handle(i32_threadid athread, const std::shared_ptr<pack>& apack, actor_logitempro& adata)
bool actor_log::handle(message<actor_logitempro>& adata)
{
actor_logitem& ldata = adata.m_data;
actor_logitem& ldata = adata.m_data->m_data;
m_log->printf(ldata);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion public/actor/actor_logic/log/actor_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ namespace ngl

virtual ~actor_log();

bool handle(i32_threadid athread, const std::shared_ptr<pack>& apack, actor_logitempro& adata);
bool handle(message<actor_logitempro>& adata);
};
}
32 changes: 26 additions & 6 deletions public/logic/public/public/brief/actor_brief.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,32 @@ namespace ngl

virtual void loaddb_finish(bool adbishave) {}

bool handle(
i32_threadid athread,
const std::shared_ptr<pack>& apack,
actor_roleinfo& adata)
bool handle(message<actor_roleinfo>& adata)
{
m_briefdb.update(*adata.m_vecinfo.m_data.get());

std::cout << "#####:" << (int64_t)(adata.m_data->m_vecinfo.m_data.get()) << std::endl;
return true;
if (adata.m_data->m_vecinfo.m_data == nullptr)
{
std::cout << "adata.m_vecinfo.m_data == nullptr" << std::endl;
return true;
}

if (adata.m_data->m_vecinfo.m_isbinary)
{
std::cout << "adata.m_vecinfo.m_isbinary = "<< adata.m_data->m_vecinfo.m_isbinary << std::endl;
//return true;
}
for (auto& item : *adata.m_data->m_vecinfo.m_data)
{
std::string json;
if (tools::protostr(item, json))
{
LogLocalError("recv actor_roleinfo [%]", json);
}
}
return true;
/*m_briefdb.update(*adata.m_vecinfo.m_data.get());
auto pro = std::make_shared<actor_roleinfo>();
*pro = adata;
Expand All @@ -55,7 +75,7 @@ namespace ngl
actor::static_send_actor(
actor_guid::make(ACTOR_CHAT,ttab_servers::tab()->m_crossarea, actor_guid::none_actordataid()),
actor_guid::make(), pro);
actor_guid::make(), pro);*/
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion public/logic/public/public/ranklist/actor_ranklist.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace ngl

virtual void loaddb_finish(bool adbishave) {}

/*bool handle(i32_threadid athread, const std::shared_ptr<pack>& apack, mforward<GM::PROBUFF_GM_GET_NOTICE>& adata)
/*bool handle(message<mforward<GM::PROBUFF_GM_GET_NOTICE>>& adata)
{
using type = mforward<GM::PROBUFF_GM_GET_NOTICE_RESPONSE>;
std::shared_ptr<type> pro(new type(adata.identifier()));
Expand Down
11 changes: 9 additions & 2 deletions public/logic/public/role/roleinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ namespace ngl
auto pro = std::make_shared<actor_roleinfo>();
pro->m_vecinfo.make();
pro->m_vecinfo.m_data->resize(1);
pbdb::db_brief& linfo = (*pro->m_vecinfo.m_data)[0];
linfo = m_base();
//pbdb::db_brief& linfo = (*pro->m_vecinfo.m_data)[0];
(*pro->m_vecinfo.m_data)[0] = m_base();

std::string ljson;
if (tools::protostr((*pro->m_vecinfo.m_data)[0], ljson))
{
LogLocalError("roleinfo::sync_actor_roleinfo [%]", ljson);
}

actor::static_send_actor(actor_guid::make_self(ACTOR_BRIEF), actor_guid::make(), pro);
}

Expand Down
8 changes: 5 additions & 3 deletions public/protocol/init_protobuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# define HASH_CODE_VALUE(_TYPE) typeid(T).hash_code()
#endif

#define TYPE_NAME(_TYPE) boost::typeindex::type_id_with_cvr<_TYPE>().pretty_name()

namespace ngl
{
template <typename T, EPROTOCOL_TYPE PROTYPE, bool ISUSING, typename TREAL>
Expand Down Expand Up @@ -55,7 +57,7 @@ namespace ngl
{
.m_type = atype,
.m_protocol = ++lcustoms,
.m_name = typeid(T).name()
.m_name = TYPE_NAME(T)
}));
LogLocalInfo("#[%][EPROTOCOL_TYPE_CUSTOM][%]", lcustoms, typeid(T).name());
}
Expand All @@ -70,7 +72,7 @@ namespace ngl
template <typename T>
static bool init_protobufs()
{
static std::string lname = boost::typeindex::type_id_with_cvr<T>().pretty_name();
static std::string lname = TYPE_NAME(T);
int32_t lprotocol = xmlprotocol::protocol(lname);
if (lprotocol == -1)
{
Expand All @@ -97,7 +99,7 @@ namespace ngl
auto itor = m_keyval.find(lcode);
if (itor == m_keyval.end())
{
std::cout << typeid(TRC).name() << std::endl;
std::cout << TYPE_NAME(TRC) << std::endl;
assert(init_protobufs<TRC>());
itor = m_keyval.find(lcode);
assert(itor != m_keyval.end());
Expand Down
39 changes: 29 additions & 10 deletions public/protocol/protocol/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,42 @@ namespace ngl
template <typename T, EPROTOCOL_TYPE TYPE>
static void registry_actor(ENUM_ACTOR atype, const char* aname)
{
typefun_pack lpackfun = [](std::shared_ptr<pack>& apack)->std::shared_ptr<void>
typefun_pack lpackfun = [atype](std::shared_ptr<pack>& apack)->std::shared_ptr<void>
{
Try
{
T* lp = new T();
std::shared_ptr<void> ltemp(lp);
//std::cout << typeid(T).name() << std::endl;
if (structbytes<T>::tostruct(apack, *lp))
Try
{
return ltemp;
}
}Catch;
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
);
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
Loading

0 comments on commit e4308e4

Please sign in to comment.