diff --git a/CMakeLists.txt b/CMakeLists.txt index 55515d86..4434712a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/public/actor/actor_base/actor.h b/public/actor/actor_base/actor.h index 644a0ac5..c2383901 100644 --- a/public/actor/actor_base/actor.h +++ b/public/actor/actor_base/actor.h @@ -180,7 +180,7 @@ namespace ngl virtual void broadcast() {} // 广播处理函数 - bool handle(i32_threadid athread, const std::shared_ptr& apack, actor_broadcast& adata); + bool handle(message& adata); // ############# End[Actor 全员广播] ############# #pragma endregion diff --git a/public/actor/actor_base/actor_db.h b/public/actor/actor_base/actor_db.h index 4a7a6cb8..2fdc7a70 100644 --- a/public/actor/actor_base/actor_db.h +++ b/public/actor/actor_base/actor_db.h @@ -11,6 +11,7 @@ #include "actor_register.h" #include "cache_list.h" #include "ttab_dbload.h" +#include namespace ngl { @@ -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>(lname)); } } @@ -279,7 +282,10 @@ namespace ngl bool handle(message>& adata) { - //LogLocalInfo(" actor_db actor_db_load<%,%> [%]", TDBTAB_TYPE, TDBTAB::name(), adata.m_id); + std::string lname; + LogLocalError("load: [%] [%]", + tools::type_name>(lname), + adata.m_data->m_id); actor_dbtab::load(adata.m_thread, adata.m_pack, *adata.m_data); return true; } diff --git a/public/actor/actor_base/actor_db_client.cpp b/public/actor/actor_base/actor_db_client.cpp index 4dfaf1a7..a00eb193 100644 --- a/public/actor/actor_base/actor_db_client.cpp +++ b/public/actor/actor_base/actor_db_client.cpp @@ -3,7 +3,7 @@ namespace ngl { - bool actor::handle(i32_threadid athread, const std::shared_ptr& apack, actor_broadcast& adata) + bool actor::handle(message& adata) { // ## if (get_actor_manage_dbclient() != nullptr) diff --git a/public/actor/actor_base/actor_db_client.h b/public/actor/actor_base/actor_db_client.h index 516e1a7c..1d99cf38 100644 --- a/public/actor/actor_base/actor_db_client.h +++ b/public/actor/actor_base/actor_db_client.h @@ -98,6 +98,7 @@ namespace ngl template class actor_db; + template class actor_dbclient : public actor_dbclient_base { @@ -140,6 +141,12 @@ namespace ngl i64_actorid ldbid = actor_guid::make(actor_type>::type(), tab_self_area, dbnodeid()); nserver->sendtoserver(dbnodeid(), ldata, ldbid, m_actor->id_guid()); + + std::string lname; + LogLocalError("actor_dbclient loaddb [%] [%]" + , tools::type_name>(lname) + , aid + ); } actor_guid m_id; @@ -381,6 +388,8 @@ namespace ngl {//ʧ ݿû return loadfinish(); } + std::string lname; + LogLocalError("db load respones:[%]", tools::type_name>(lname)); loadfinish(adata.m_data->data(), adata.m_data->m_over); }Catch; return true; diff --git a/public/actor/actor_base/actor_manage.cpp b/public/actor/actor_base/actor_manage.cpp index 62542c58..b468d2ae 100644 --- a/public/actor/actor_base/actor_manage.cpp +++ b/public/actor/actor_base/actor_manage.cpp @@ -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) { @@ -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); } @@ -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]) { diff --git a/public/actor/actor_base/actor_type.cpp b/public/actor/actor_base/actor_type.cpp index dedd5353..c517e8d0 100644 --- a/public/actor/actor_base/actor_type.cpp +++ b/public/actor/actor_base/actor_type.cpp @@ -37,7 +37,11 @@ namespace ngl void init_actor_type() { -#define dinit_atype(ACTORCLASS, ACTORTYPE) actor_type::inits(ACTORTYPE) +#define dinit_atype(ACTORCLASS, ACTORTYPE) \ + actor_type::inits(ACTORTYPE);\ + LogLocalError("init_actor_type [%]-[%]", boost::typeindex::type_id_with_cvr().pretty_name(), (int)(ACTORTYPE)) + + dinit_atype(actor_client, ACTOR_ADDRESS_CLIENT); dinit_atype(actor_create, ACTOR_CREATE); diff --git a/public/actor/actor_base/actor_type.h b/public/actor/actor_base/actor_type.h index 67dd1335..65fbb931 100644 --- a/public/actor/actor_base/actor_type.h +++ b/public/actor/actor_base/actor_type.h @@ -1,6 +1,7 @@ #pragma once #include "actor_enum.h" +#include namespace ngl { @@ -16,7 +17,9 @@ namespace ngl static ENUM_ACTOR type() { - assert(m_type == ACTOR_NONE); + std::string lname; + std::cout << tools::type_name(lname) << std::endl; + assert(m_type != ACTOR_NONE); return m_type; } }; diff --git a/public/actor/actor_logic/log/actor_log.cpp b/public/actor/actor_logic/log/actor_log.cpp index 312d830f..ca361eeb 100644 --- a/public/actor/actor_logic/log/actor_log.cpp +++ b/public/actor/actor_logic/log/actor_log.cpp @@ -40,9 +40,9 @@ namespace ngl { } - bool actor_log::handle(i32_threadid athread, const std::shared_ptr& apack, actor_logitempro& adata) + bool actor_log::handle(message& adata) { - actor_logitem& ldata = adata.m_data; + actor_logitem& ldata = adata.m_data->m_data; m_log->printf(ldata); return true; } diff --git a/public/actor/actor_logic/log/actor_log.h b/public/actor/actor_logic/log/actor_log.h index edbe7f35..f0764aa4 100644 --- a/public/actor/actor_logic/log/actor_log.h +++ b/public/actor/actor_logic/log/actor_log.h @@ -29,6 +29,6 @@ namespace ngl virtual ~actor_log(); - bool handle(i32_threadid athread, const std::shared_ptr& apack, actor_logitempro& adata); + bool handle(message& adata); }; } \ No newline at end of file diff --git a/public/logic/public/public/brief/actor_brief.h b/public/logic/public/public/brief/actor_brief.h index e9b2aed9..764290eb 100644 --- a/public/logic/public/public/brief/actor_brief.h +++ b/public/logic/public/public/brief/actor_brief.h @@ -41,12 +41,32 @@ namespace ngl virtual void loaddb_finish(bool adbishave) {} - bool handle( - i32_threadid athread, - const std::shared_ptr& apack, - actor_roleinfo& adata) + bool handle(message& 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(); *pro = adata; @@ -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; } diff --git a/public/logic/public/public/ranklist/actor_ranklist.h b/public/logic/public/public/ranklist/actor_ranklist.h index 7eb611fc..ab652d00 100644 --- a/public/logic/public/public/ranklist/actor_ranklist.h +++ b/public/logic/public/public/ranklist/actor_ranklist.h @@ -44,7 +44,7 @@ namespace ngl virtual void loaddb_finish(bool adbishave) {} - /*bool handle(i32_threadid athread, const std::shared_ptr& apack, mforward& adata) + /*bool handle(message>& adata) { using type = mforward; std::shared_ptr pro(new type(adata.identifier())); diff --git a/public/logic/public/role/roleinfo.cpp b/public/logic/public/role/roleinfo.cpp index d8c3bfca..616c2bf6 100644 --- a/public/logic/public/role/roleinfo.cpp +++ b/public/logic/public/role/roleinfo.cpp @@ -9,8 +9,15 @@ namespace ngl auto pro = std::make_shared(); 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); } diff --git a/public/protocol/init_protobuf.h b/public/protocol/init_protobuf.h index 44b5a79d..f84a5fc9 100644 --- a/public/protocol/init_protobuf.h +++ b/public/protocol/init_protobuf.h @@ -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 @@ -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()); } @@ -70,7 +72,7 @@ namespace ngl template static bool init_protobufs() { - static std::string lname = boost::typeindex::type_id_with_cvr().pretty_name(); + static std::string lname = TYPE_NAME(T); int32_t lprotocol = xmlprotocol::protocol(lname); if (lprotocol == -1) { @@ -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()); itor = m_keyval.find(lcode); assert(itor != m_keyval.end()); diff --git a/public/protocol/protocol/protocol.h b/public/protocol/protocol/protocol.h index b69d59ca..0e8ed217 100644 --- a/public/protocol/protocol/protocol.h +++ b/public/protocol/protocol/protocol.h @@ -36,23 +36,42 @@ namespace ngl template static void registry_actor(ENUM_ACTOR atype, const char* aname) { - typefun_pack lpackfun = [](std::shared_ptr& apack)->std::shared_ptr + typefun_pack lpackfun = [atype](std::shared_ptr& apack)->std::shared_ptr { - Try - { - T* lp = new T(); - std::shared_ptr ltemp(lp); - //std::cout << typeid(T).name() << std::endl; - if (structbytes::tostruct(apack, *lp)) + Try { - return ltemp; - } - }Catch; + std::string lname; + + LogLocalError("registry_actor pop [%][%] beg" + , tools::type_name(lname) + , atype + ); + T* lp = new T(); + std::shared_ptr ltemp(lp); + //std::cout << typeid(T).name() << std::endl; + if (structbytes::tostruct(apack, *lp)) + { + LogLocalError("registry_actor pop [%][%] end" + , tools::type_name(lname) + , atype + ); + return ltemp; + } + }Catch; + LogLocalError("registry_actor pop [%][%] fail" + , boost::typeindex::type_id_with_cvr().pretty_name() + , atype + ); return nullptr; }; std::string lname = aname; typefun_run lrunfun = [atype, lname](std::shared_ptr& apack, std::shared_ptr& aptrpram)->bool { + std::string lname; + LogLocalError("registry_actor dosth [%][%] beg" + , tools::type_name(lname) + , atype + ); actor_guid lactorguid(apack->m_head.get_actor()); actor_guid lrequestactorguid(apack->m_head.get_request_actor()); std::shared_ptr ldatapack = std::static_pointer_cast(aptrpram); diff --git a/public/tools/serialize/serialize.h b/public/tools/serialize/serialize.h index 2442d496..7ea63ab3 100644 --- a/public/tools/serialize/serialize.h +++ b/public/tools/serialize/serialize.h @@ -20,6 +20,7 @@ #include "varint.h" #include "define.h" #include "db.pb.h" +#include "tools.h" #include @@ -41,12 +42,24 @@ namespace ngl protobuf_data() : m_data(nullptr) , m_isbinary(true) - {} + { + std::string lname; + std::cout << "protobuf_data<" << tools::type_name(lname) << ">()" << std::endl; + } protobuf_data(std::shared_ptr& adata) : m_data(adata) , m_isbinary(true) - {} + { + std::string lname; + std::cout << "protobuf_data<" << tools::type_name(lname) << ">(std::shared_ptr& adata)" << std::endl; + } + + ~protobuf_data() + { + std::string lname; + std::cout << "~protobuf_data<" << tools::type_name(lname) << ">()" << std::endl; + } void make() { @@ -57,6 +70,8 @@ namespace ngl { return true; } + + }; class serialize @@ -430,34 +445,44 @@ namespace ngl template bool pop(protobuf_data>& adata) { - if (adata.m_data == nullptr) - adata.make(); + //if (adata.m_data == nullptr) + adata.make(); if (adata.m_isbinary) { - std::vector& lstl = *adata.m_data; + //std::vector& lstl = *adata.m_data; int16_t lsize = 0; if (pop(lsize) == false) return false; + std::string lname; + std::cout << tools::type_name(lname) << ": lsize = " << lsize <(lname) << ": lbytes = " << lbytes << std::endl; T ltemp; if (ltemp.ParseFromArray(&buff()[byte()], lbytes) == false) return false; + std::string json; + if (tools::protostr(ltemp, json)) + { + std::cout << tools::type_name(lname) << "recv actor_roleinfo [%]" << json << std::endl; + } add_bytes(lbytes); - lstl.push_back(ltemp); + (*adata.m_data).push_back(ltemp); } - } + } + std::cout << "#####:" << (int64_t)(adata.m_data.get()) << std::endl; return true; } template bool pop(const protobuf_data>& adata) { - if (adata.m_data == nullptr) - adata.make(); + //if (adata.m_data == nullptr) + adata.make(); if (adata.m_isbinary) { std::list& lstl = adata.m_data; diff --git a/public/tools/tools.h b/public/tools/tools.h index 6ed99844..ba676e95 100644 --- a/public/tools/tools.h +++ b/public/tools/tools.h @@ -3,6 +3,8 @@ #include #include #include +#include +#include namespace ngl { @@ -35,6 +37,23 @@ namespace ngl static bool is_lanip(const std::string& aip); static bool is_mem(const char* astr1, const char* astr2); + + template + static bool protostr(T& adata, std::string& json) + { + google::protobuf::util::JsonPrintOptions options; + options.add_whitespace = false; + options.always_print_primitive_fields = false; + options.preserve_proto_field_names = false; + return google::protobuf::util::MessageToJsonString(adata, &json, options).ok(); + } + + template + static std::string& type_name(std::string& astr) + { + astr = boost::typeindex::type_id_with_cvr().pretty_name(); + return astr; + } }; } \ No newline at end of file diff --git a/server/libmycorekkk.zip b/server/libmycorekkk.zip new file mode 100644 index 00000000..1c58f9bf Binary files /dev/null and b/server/libmycorekkk.zip differ diff --git a/server/node/core/main.cpp b/server/node/core/main.cpp index 60e96734..a5ecaafb 100644 --- a/server/node/core/main.cpp +++ b/server/node/core/main.cpp @@ -82,6 +82,16 @@ int main(int argc, char** argv) ngl::xmlprotocol::load(); ngl::init_protobuf::initall(); + std::string lnameksp = "ngl::actor_forward"; + + int32_t lprotocol = ngl::xmlprotocol::protocol(lnameksp); + if (lprotocol == -1) + { + std::cout << "\n################[ngl::actor_forward]###################" << std::endl; + return 0; + } + + ngl::nlog::getInstance().isinitfinish() = true; LogLocalError("[%]", 123); diff --git a/server/node/core/server_main.h b/server/node/core/server_main.h index 128eecd5..718a1fac 100644 --- a/server/node/core/server_main.h +++ b/server/node/core/server_main.h @@ -231,6 +231,7 @@ bool start_world() ngl::actor_gm::getInstance(); ngl::actor_mail::getInstance(); ngl::actor_chat::getInstance(); + ngl::actor_brief::getInstance(); ngl::actor_manage_activity::getInstance(); ngl::actor_client::getInstance().actor_server_register(); @@ -325,7 +326,6 @@ bool start_game() ngl::actor_base::create(ngl::ACTOR_LOG, 0, <ype); ngl::actor_manage_role::getInstance(); ngl::actor_create::getInstance(); - ngl::actor_brief::getInstance(); //ngl::actor_reloadcsv::getInstance(); ngl::actor_client::getInstance().actor_server_register(); diff --git a/tools/public/proto/protoc.exe b/tools/public/proto/protoc.exe index 7dd01ed3..0ac6c9ea 100644 Binary files a/tools/public/proto/protoc.exe and b/tools/public/proto/protoc.exe differ