Skip to content

Commit

Permalink
简单修改
Browse files Browse the repository at this point in the history
简单修改
  • Loading branch information
NingLeixueR committed Dec 20, 2023
1 parent b7cafbe commit e823b70
Show file tree
Hide file tree
Showing 23 changed files with 125 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ php/phpcode
bin
obj
lib
php
tools/public/rebuild.exe
tools/public/idl/IDL.exe
tools/public/idl/idlfile
Expand Down
4 changes: 4 additions & 0 deletions 3part/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")

SET(BOOST_LIB_SRC ${PROJECT_SOURCE_DIR}/boost/libs)

INCLUDE_DIRECTORIES(3part/boost)
INCLUDE_DIRECTORIES(3part/boost/boost)

#boost lib
AUX_SOURCE_DIRECTORY(${BOOST_LIB_SRC}/regex/src boost_regex_lib_src)
AUX_SOURCE_DIRECTORY(${BOOST_LIB_SRC}/serialization/src boost_serialization_lib_src)
Expand Down
10 changes: 5 additions & 5 deletions public/actor/actor_base/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace ngl
template <typename TDerived>
static void register_timer(Tfun<TDerived, timerparm> afun/* = &TDerived::timer_handle*/)
{
arfun<TDerived, EPROTOCOL_TYPE_CUSTOM>::instance().rfun_nonet<timerparm>(afun, false);
arfun<TDerived, EPROTOCOL_TYPE_CUSTOM>::instance().template rfun_nonet<TDerived, timerparm>(afun, false);
}

template <pbdb::ENUM_DB DBTYPE, typename TDBTAB>
Expand All @@ -54,7 +54,7 @@ namespace ngl
{
using tloaddb = actor_db_load_response<TYPE, DBTYPE, TDBTAB>;
auto lpfun = &actor_base::template handle<TYPE, DBTYPE, TDBTAB, TDerived>;
arfun<TDerived, TYPE>::instance().rfun<tloaddb>(lpfun, true);
arfun<TDerived, TYPE>::instance().template rfun<TDerived, tloaddb>(lpfun, true);
}

template <EPROTOCOL_TYPE TYPE, typename TDerived, pbdb::ENUM_DB DBTYPE, typename TDBTAB, typename ...ARG>
Expand All @@ -68,7 +68,7 @@ namespace ngl
template <EPROTOCOL_TYPE TYPE, typename TDerived, typename T>
static void register_actor_s(const std::function<void(TDerived*, T&)>& afun)
{
arfun<TDerived, TYPE>::instance().rfun<T>(afun);
arfun<TDerived, TYPE>::instance().template rfun<TDerived, T>(afun);
}

#pragma region register_actor
Expand Down Expand Up @@ -111,7 +111,7 @@ namespace ngl

#pragma region register_actornonet
// ## 与register_actor类似 只不过不注册网络层
template <EPROTOCOL_TYPE TYPE, typename TDerived , typename T>
template <EPROTOCOL_TYPE TYPE, typename TDerived, typename T>
static void register_actornonet(bool aisload, T afun)
{
arfun<TDerived, TYPE>::instance().rfun_nonet(afun, aisload);
Expand All @@ -131,7 +131,7 @@ namespace ngl
template <EPROTOCOL_TYPE TYPE, bool IsForward, typename TDerived, typename T>
static void register_forward(T afun)
{
arfun<TDerived, TYPE>::instance().rfun_forward<IsForward>( afun, (ENUM_ACTOR)TDerived::ACTOR_TYPE, false);
arfun<TDerived, TYPE>::instance().template rfun_forward<IsForward>( afun, (ENUM_ACTOR)TDerived::ACTOR_TYPE, false);
}

template <EPROTOCOL_TYPE TYPE, bool IsForward, typename TDerived, typename T, typename ...ARG>
Expand Down
8 changes: 4 additions & 4 deletions public/actor/actor_base/actor_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ namespace ngl
{
auto itor = m_group.find(agroupid);
if (itor == m_group.end())
return false;
return;
if (itor->second.m_actortype != ACTOR_ROBOT)
{
handle_pram lpram;
Expand All @@ -306,10 +306,10 @@ namespace ngl
}
else
{
std::initializer_list<i64_actorid> itor(itor->second.m_actorlist);
send_client(itor, adata);
std::initializer_list<i64_actorid> ltemp(itor->second.m_actorlist);
send_client(ltemp, adata);
}
return true;
return;
}
#pragma endregion

Expand Down
27 changes: 10 additions & 17 deletions public/actor/actor_base/actor_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,9 @@ namespace ngl
//加载全部数据
Assert(m_tab->m_isloadall);
i64_actorid lrequestactor = apack->m_head.get_request_actor();

std::shared_ptr<actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>> pro(new actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>
{
.m_stat = true,
.m_over = false,
});
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)
{
Expand All @@ -97,11 +94,9 @@ namespace ngl
if (aindex % lsendmaxcount == 0)
{
actor::static_send_actor(lrequestactor, actor_guid::make(), pro);
pro = std::shared_ptr<actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>>(new actor_db_load_response<TDBTAB_TYPE, TDBTAB>
{
.m_stat = true,
.m_over = false,
});
pro = std::make_shared<actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>>();
pro->m_stat = true;
pro->m_over = false;
}
}
if constexpr (PROTYPE == EPROTOCOL_TYPE_PROTOCOLBUFF)
Expand All @@ -111,11 +106,9 @@ namespace ngl
if (aindex % lsendmaxcount == 0)
{
actor::static_send_actor(lrequestactor, actor_guid::make(), pro);
pro = std::shared_ptr<actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>>(new actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>
{
.m_stat = true,
.m_over = false,
});
pro = std::make_shared<actor_db_load_response<PROTYPE, TDBTAB_TYPE, TDBTAB>>();
pro->m_stat = true;
pro->m_over = false;
pro->m_data.make();
}
}
Expand Down Expand Up @@ -338,7 +331,7 @@ namespace ngl

template <EPROTOCOL_TYPE PROTYPE, pbdb::ENUM_DB TDBTAB_TYPE, typename TDBTAB>
template <typename TDB>
static void actor_dbtab<PROTYPE, TDBTAB_TYPE, TDBTAB>::cachelist(enum_cache_list atype, std::set<i64_actorid>& aset)
void actor_dbtab<PROTYPE, TDBTAB_TYPE, TDBTAB>::cachelist(enum_cache_list atype, std::set<i64_actorid>& aset)
{
if (aset.empty())
return;
Expand Down
2 changes: 1 addition & 1 deletion public/actor/actor_base/actor_manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace ngl
}
Catch;
});
ltemp.init_rfun<T>();
ltemp.template init_rfun<T>();
T::actor_register();
}Catch;
}
Expand Down
20 changes: 10 additions & 10 deletions public/actor/actor_base/actor_register.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,48 @@
namespace ngl
{
template <typename TDerived, EPROTOCOL_TYPE TYPE>
template <typename T>
arfun<TDerived, TYPE>& arfun<TDerived, TYPE>::rfun(const std::function<void(TDerived*, T&)>& afun)
template <typename TTTDerived, typename T>
arfun<TDerived, TYPE>& arfun<TDerived, TYPE>::rfun(const std::function<void(TTTDerived*, T&)>& afun)
{
m_fun[init_protobuf::protocol<T>()] = alogicfun
{
.m_isdbload = false,
.m_fun = [afun](actor_base* aactor, i32_threadid athreadid, handle_pram& apram)
{
afun((TDerived*)aactor, *(T*)apram.m_data.get());
afun((TTTDerived*)aactor, *(T*)apram.m_data.get());
}
};
protocol::registry_actor<T, TYPE>((ENUM_ACTOR)TDerived::ACTOR_TYPE, init_protobuf::protocol_name<T>().c_str());
return *this;
}

template <typename TDerived, EPROTOCOL_TYPE TYPE>
template <typename T>
arfun<TDerived, TYPE>& arfun<TDerived, TYPE>::rfun_nonet(Tfun<TDerived, T> afun, bool aisload/* = false*/)
template <typename TTTDerived, typename T>
arfun<TDerived, TYPE>& arfun<TDerived, TYPE>::rfun_nonet(Tfun<TTTDerived, T> afun, bool aisload/* = false*/)
{
m_fun[init_protobuf::protocol<T>()] = alogicfun
{
.m_isdbload = aisload,
.m_fun = [afun](actor_base* aactor, i32_threadid athreadid, handle_pram& apram)
{
message<T> lmessage(athreadid, apram.m_pack.get(), (T*)apram.m_data.get());
(((TDerived*)(aactor))->*afun)(lmessage);
(((TTTDerived*)(aactor))->*afun)(lmessage);
}
};
return *this;
}

template <typename TDerived, EPROTOCOL_TYPE TYPE>
template <typename T>
arfun<TDerived, TYPE>& arfun<TDerived, TYPE>::rfun(Tfun<TDerived, T> afun, bool aisload/* = false*/)
template <typename TTTDerived, typename T>
arfun<TDerived, TYPE>& arfun<TDerived, TYPE>::rfun(Tfun<TTTDerived, T> afun, bool aisload/* = false*/)
{
rfun(afun, (ENUM_ACTOR)TDerived::ACTOR_TYPE, aisload);
return *this;
}

template <typename TDerived, EPROTOCOL_TYPE TYPE>
template <typename T>
arfun<TDerived, TYPE>& arfun<TDerived, TYPE>::rfun(Tfun<TDerived, T> afun, ENUM_ACTOR atype, bool aisload/* = false*/)
template <typename TTTDerived, typename T>
arfun<TDerived, TYPE>& arfun<TDerived, TYPE>::rfun(Tfun<TTTDerived, T> afun, ENUM_ACTOR atype, bool aisload/* = false*/)
{
rfun_nonet(afun, aisload);
protocol::registry_actor<T, TYPE>(atype, init_protobuf::protocol_name<T>().c_str());
Expand Down
18 changes: 10 additions & 8 deletions public/actor/actor_base/actor_rfun.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,20 @@ namespace ngl
return ltemp;
}

template <typename T>
arfun& rfun(const std::function<void(TDerived*, T&)>& afun);
template <typename TTTDerived, typename T>
arfun& rfun(const std::function<void(TTTDerived*, T&)>& afun);

//// #### bool aisload = false 是否允许db数据加载完成之前处理此消息
template <typename T>
arfun& rfun(Tfun<TDerived, T> afun, bool aisload = false);
template <typename TTTDerived, typename T>
arfun& rfun(Tfun<TTTDerived, T> afun, bool aisload = false);

template <typename TTTDerived, typename T>
arfun& rfun(Tfun<TTTDerived, T> afun, ENUM_ACTOR atype, bool aisload = false);

template <typename TTTDerived, typename T>
arfun& rfun_nonet(Tfun<TTTDerived, T> afun, bool aisload = false);

template <typename T>
arfun& rfun(Tfun<TDerived, T> afun, ENUM_ACTOR atype, bool aisload = false);

template <typename T>
arfun& rfun_nonet(Tfun<TDerived, T> afun, bool aisload = false);

template <bool BOOL, typename T>
arfun& rfun_forward(Tfun<TDerived, actor_forward<T, TYPE, BOOL, ngl::forward>> afun, ENUM_ACTOR atype, bool aisload = false);
Expand Down
11 changes: 11 additions & 0 deletions public/logic/public/template_tab/ttab_servers.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ namespace ngl
return nullptr;
}

static void foreach_server(const std::function<void(const tab_servers*)>& afun)
{
for (const auto& [_area, _vec] : m_areaofserver)
{
for (const tab_servers* iserver : _vec)
{
afun(iserver);
}
}
}

static void foreach_server(NODE_TYPE atype, const std::function<void(const tab_servers*)>& afun)
{
for (const auto& [_area, _vec] : m_areaofserver)
Expand Down
2 changes: 1 addition & 1 deletion public/protocol/csvtable.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 注意【rebuild.bat 工具生成文件,不要手动修改】
// 创建时间 // 创建时间 23-12-12 16:48:39
// 创建时间 // 创建时间 23-12-15 17:18:28
#include "csvtable.h"
namespace ngl{
tab_servers::tab_servers()
Expand Down
8 changes: 5 additions & 3 deletions public/protocol/csvtable.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 注意【rebuild.bat 工具生成文件,不要手动修改】
// 创建时间 // 创建时间 23-12-12 16:48:39
// 创建时间 // 创建时间 23-12-15 17:18:28
#ifndef _csvtable_H_
#define _csvtable_H_
#include "actor_define.h"
Expand Down Expand Up @@ -45,6 +45,7 @@ enum NODE_TYPE
RELOADCSV = 9, // 重载分发csv服务器
CROSS = 10, // 跨服服务器
CROSSDB = 11, // 跨服数据库服务器
PUSHSERVERCONFIG = 12, // 将服务器配置上传lbgmsys
FAIL = -1, // 服务器类型错误
};
enum ENET_PROTOCOL
Expand Down Expand Up @@ -146,6 +147,7 @@ struct tab_servers
int32_t m_tcount; // 同类型服务器的序号
ENET_PROTOCOL m_net; // 服务器协议(1tcp2udp3ws)
std::string m_ip; // ip
std::string m_nip; // 内网ip
int16_t m_port; // 端口
int32_t m_threadnum; // socket线程数
int32_t m_actorthreadnum; // actor线程池线程数
Expand All @@ -158,9 +160,9 @@ struct tab_servers
/*********************************/
tab_servers();
// 序列化反序列化相关
def_portocol(tab_servers, m_id, m_name, m_remarks, m_area, m_type, m_tcount, m_net, m_ip, m_port, m_threadnum, m_actorthreadnum, m_outernet, m_db, m_reloadcsv, m_login, m_crossarea, m_actorserver)
def_portocol(tab_servers, m_id, m_name, m_remarks, m_area, m_type, m_tcount, m_net, m_ip, m_nip, m_port, m_threadnum, m_actorthreadnum, m_outernet, m_db, m_reloadcsv, m_login, m_crossarea, m_actorserver)
// csv相关
def_rcsv(m_id,m_name,m_remarks,m_area,m_type,m_tcount,m_net,m_ip,m_port,m_threadnum,m_actorthreadnum,m_outernet,m_db,m_reloadcsv,m_login,m_crossarea,m_actorserver)
def_rcsv(m_id,m_name,m_remarks,m_area,m_type,m_tcount,m_net,m_ip,m_nip,m_port,m_threadnum,m_actorthreadnum,m_outernet,m_db,m_reloadcsv,m_login,m_crossarea,m_actorserver)
};
struct tab_dbload
{
Expand Down
4 changes: 2 additions & 2 deletions public/tools/db/mysql/db_manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ namespace ngl
public:
static void fun(db* adb, T& adata)
{
char lbuff[] =
"INSERT INTO %s (%s)VALUES(%s) ON DUPLICATE KEY UPDATE %s;";
//char lbuff[] =
// "INSERT INTO %s (%s)VALUES(%s) ON DUPLICATE KEY UPDATE %s;";

//REPLACE INTO 则会先删除数据,然后再插入。
char lbuff[] =
Expand Down
4 changes: 2 additions & 2 deletions public/tools/rfun.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace ngl
template <typename TDerived, typename ...TARG>
static void registers(Tfun<TDerived, TARG...> afun, const char* amessage = "")
{
rguid lvalues(typeid(std::remove_const<TDerived>::type).hash_code());
rguid lvalues(typeid(typename std::remove_const<TDerived>::type).hash_code());
using targ = std::tuple<typename std::remove_reference<TARG>::type...>;
lvalues.init(targ{});
m_fun[lvalues] = mame_function
Expand All @@ -97,7 +97,7 @@ namespace ngl
template <typename TDerived, typename ...TARG>
static bool handle_switch(TDerived* aeffect, TARG&&... arg)
{
rguid lvalues(typeid(std::remove_const<TDerived>::type).hash_code());
rguid lvalues(typeid(typename std::remove_const<TDerived>::type).hash_code());
lvalues.init(arg...);
auto itor = m_fun.find(lvalues);
if (itor == m_fun.end())
Expand Down
1 change: 1 addition & 0 deletions public/tools/serialize/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "varint.h"
#include "define.h"
#include "db.pb.h"

#include <google/protobuf/util/json_util.h>

namespace ngl
Expand Down
1 change: 1 addition & 0 deletions public/tools/tab/xml/xmlnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ namespace ngl
em<NODE_TYPE>::set(LOG, "log");
em<NODE_TYPE>::set(RELOADCSV, "reloadcsv");
em<NODE_TYPE>::set(CROSS, "cross");
em<NODE_TYPE>::set(PUSHSERVERCONFIG, "pushserverconfig");
}

NODE_TYPE xmlnode::node_type()
Expand Down
4 changes: 4 additions & 0 deletions server/node/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ int main(int argc, char** argv)
{
start_cross();
}
else if (nconfig::node_type() == ngl::PUSHSERVERCONFIG)
{
start_pushserverconfig();
}

ngl::test_attribute();

Expand Down
Loading

0 comments on commit e823b70

Please sign in to comment.