1
This commit is contained in:
parent
d58896c69a
commit
f8c7e083bf
@ -16,17 +16,8 @@
|
||||
#include <f8/netmsghandler.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "jsondatamgr.h"
|
||||
#include "handlermgr.h"
|
||||
#include "roommgr.h"
|
||||
#include "player.h"
|
||||
#include "playermgr.h"
|
||||
#include "mapmgr.h"
|
||||
#include "entityfactory.h"
|
||||
#include "perfmonitor.h"
|
||||
#include "killmgr.h"
|
||||
#include "httpproxy.h"
|
||||
#include "lispenv.h"
|
||||
|
||||
#include "ss_msgid.pb.h"
|
||||
#include "ss_proto.pb.h"
|
||||
@ -37,14 +28,6 @@
|
||||
#include "f8/btmgr.h"
|
||||
#include <f8/timer.h>
|
||||
|
||||
#include "tracemgr.h"
|
||||
#include "matchmgr.h"
|
||||
#include "selfchecker.h"
|
||||
|
||||
#include "skillhelper.h"
|
||||
#include "mt/MetaMgr.h"
|
||||
#include "mt/Skill.h"
|
||||
|
||||
struct MsgNode
|
||||
{
|
||||
SocketFrom_e sockfrom;
|
||||
@ -62,62 +45,6 @@ const char* const PROJ_LOG_FILENAME_FMT = "log_$pid_%Y%m%d.log";
|
||||
|
||||
static void SavePerfLog()
|
||||
{
|
||||
f8::UdpLog::Instance()->Info
|
||||
("max_rundelay:%d room_num:%d player_num:%d online_num:%d alive_count:%d "
|
||||
"sys_request_delay:%d user_request_delay:%d http_pending_num:%d real_alive_count:%d "
|
||||
"account_num:%d level0_num:%d level1_num:%d "
|
||||
"max_full_obj:%d max_part_obj:%d max_bullet:%d max_packet:%d "
|
||||
"his_max_full_obj:%d his_max_part_obj:%d his_max_bullet:%d his_max_packet:%d",
|
||||
{
|
||||
PerfMonitor::Instance()->max_run_delay_time,
|
||||
RoomMgr::Instance()->RoomNum(),
|
||||
PerfMonitor::Instance()->entity_num[ET_Player],
|
||||
PlayerMgr::Instance()->OnlineNum(),
|
||||
PerfMonitor::Instance()->alive_count,
|
||||
f8::HttpClientPool::Instance()->max_sys_request_delay,
|
||||
f8::HttpClientPool::Instance()->max_user_request_delay,
|
||||
f8::HttpClientPool::Instance()->GetPendingNum(),
|
||||
PerfMonitor::Instance()->real_alive_count,
|
||||
PlayerMgr::Instance()->GetAccountNum(),
|
||||
PerfMonitor::Instance()->room_num[RT_NewBrid],
|
||||
PerfMonitor::Instance()->room_num[RT_MidBrid],
|
||||
PerfMonitor::Instance()->max_full_objects_num,
|
||||
PerfMonitor::Instance()->max_part_objects_num,
|
||||
PerfMonitor::Instance()->max_bullet_num,
|
||||
GGListener::Instance()->max_packet_size,
|
||||
PerfMonitor::Instance()->his_max_full_objects_num,
|
||||
PerfMonitor::Instance()->his_max_part_objects_num,
|
||||
PerfMonitor::Instance()->his_max_bullet_num,
|
||||
GGListener::Instance()->his_max_packet_size
|
||||
});
|
||||
{
|
||||
PerfMonitor::Instance()->his_max_full_objects_num = std::max
|
||||
(PerfMonitor::Instance()->his_max_full_objects_num, PerfMonitor::Instance()->max_full_objects_num);
|
||||
PerfMonitor::Instance()->his_max_part_objects_num = std::max
|
||||
(PerfMonitor::Instance()->his_max_part_objects_num, PerfMonitor::Instance()->max_part_objects_num);
|
||||
PerfMonitor::Instance()->his_max_bullet_num = std::max
|
||||
(PerfMonitor::Instance()->his_max_bullet_num, PerfMonitor::Instance()->max_bullet_num);
|
||||
GGListener::Instance()->his_max_packet_size = std::max
|
||||
(GGListener::Instance()->his_max_packet_size, GGListener::Instance()->max_packet_size);
|
||||
}
|
||||
PerfMonitor::Instance()->max_run_delay_time = 0;
|
||||
PerfMonitor::Instance()->max_dispatchmsg_time = 0;
|
||||
PerfMonitor::Instance()->max_timer_idle = 0;
|
||||
PerfMonitor::Instance()->grid_chg_times = 0;
|
||||
PerfMonitor::Instance()->test_times = 0;
|
||||
PerfMonitor::Instance()->params[0] = 0;
|
||||
PerfMonitor::Instance()->params[1] = 0;
|
||||
PerfMonitor::Instance()->params[2] = 0;
|
||||
PerfMonitor::Instance()->params[3] = 0;
|
||||
PerfMonitor::Instance()->params[4] = 0;
|
||||
PerfMonitor::Instance()->params[5] = 0;
|
||||
PerfMonitor::Instance()->params[6] = 0;
|
||||
PerfMonitor::Instance()->max_full_objects_num = 0;
|
||||
PerfMonitor::Instance()->max_part_objects_num = 0;
|
||||
PerfMonitor::Instance()->max_bullet_num = 0;
|
||||
GGListener::Instance()->max_packet_size = 0;
|
||||
f8::HttpClientPool::Instance()->max_sys_request_delay = 0;
|
||||
f8::HttpClientPool::Instance()->max_user_request_delay = 0;
|
||||
}
|
||||
|
||||
bool App::Init(int argc, char* argv[])
|
||||
@ -157,10 +84,6 @@ bool App::Init(int argc, char* argv[])
|
||||
|
||||
srand(time(nullptr));
|
||||
InitLog();
|
||||
#ifdef DEBUG
|
||||
TraceMgr::Instance()->Init("gameserver2006");
|
||||
#endif
|
||||
PerfMonitor::Instance()->Init();
|
||||
f8::MsgQueue::Instance()->Init();
|
||||
HandlerMgr::Instance()->Init();
|
||||
f8::Timer::Instance()->Init();
|
||||
@ -170,28 +93,9 @@ bool App::Init(int argc, char* argv[])
|
||||
#ifdef DEBUG
|
||||
f8::BtMgr::Instance()->SetLogging(true);
|
||||
#endif
|
||||
SkillHelper::Init();
|
||||
JsonDataMgr::Instance()->Init();
|
||||
LispEnv::Instance()->Init();
|
||||
mt::MetaMgr::Instance()->Init();
|
||||
SelfChecker::Init();
|
||||
EntityFactory::Instance()->Init();
|
||||
uuid.SetMachineId((node_id - 1) * MAX_NODE_ID + instance_id);
|
||||
KillMgr::Instance()->Init();
|
||||
RoomMgr::Instance()->Init();
|
||||
MatchMgr::Instance()->Init();
|
||||
MapMgr::Instance()->Init();
|
||||
PlayerMgr::Instance()->Init();
|
||||
GGListener::Instance()->Init();
|
||||
HttpProxy::Instance()->Init();
|
||||
|
||||
f8::UdpLog::Instance()->Info("gameserver starting instance_id:%d pid:%d debug_mode:%d channel:%d",
|
||||
{
|
||||
instance_id,
|
||||
getpid(),
|
||||
debug_mode,
|
||||
JsonDataMgr::Instance()->channel
|
||||
});
|
||||
{
|
||||
int perf_log_time = 1000 * 30;
|
||||
f8::Timer::Instance()->SetInterval
|
||||
@ -223,27 +127,12 @@ void App::UnInit()
|
||||
//const char* s2 = GetEnumString<int>();
|
||||
//int i = static_cast<int>(Test_e::kFlyBuffId);
|
||||
HttpProxy::Instance()->UnInit();
|
||||
GGListener::Instance()->UnInit();
|
||||
PlayerMgr::Instance()->UnInit();
|
||||
MapMgr::Instance()->UnInit();
|
||||
MatchMgr::Instance()->UnInit();
|
||||
RoomMgr::Instance()->UnInit();
|
||||
KillMgr::Instance()->UnInit();
|
||||
EntityFactory::Instance()->UnInit();
|
||||
SelfChecker::UnInit();
|
||||
mt::MetaMgr::Instance()->UnInit();
|
||||
LispEnv::Instance()->UnInit();
|
||||
JsonDataMgr::Instance()->UnInit();
|
||||
f8::BtMgr::Instance()->UnInit();
|
||||
f8::HttpClientPool::Instance()->UnInit();
|
||||
HandlerMgr::Instance()->UnInit();
|
||||
f8::MsgQueue::Instance()->UnInit();
|
||||
f8::Timer::Instance()->UnInit();
|
||||
PerfMonitor::Instance()->UnInit();
|
||||
f8::TGLog::Instance()->UnInit();
|
||||
#ifdef DEBUG
|
||||
TraceMgr::Instance()->UnInit();
|
||||
#endif
|
||||
UnInitLog();
|
||||
|
||||
FreeSocketMsgQueue();
|
||||
@ -260,14 +149,10 @@ int App::Run()
|
||||
int delta_time = 0;
|
||||
while (!terminated) {
|
||||
a8::tick_t begin_tick = a8::XGetTickCount();
|
||||
Global::g_nowtime = time(nullptr);
|
||||
QuickExecute(delta_time);
|
||||
SlowerExecute(delta_time);
|
||||
Schedule();
|
||||
a8::tick_t end_tick = a8::XGetTickCount();
|
||||
if (end_tick - begin_tick > PerfMonitor::Instance()->max_run_delay_time) {
|
||||
PerfMonitor::Instance()->max_run_delay_time = end_tick - begin_tick;
|
||||
}
|
||||
delta_time = end_tick - begin_tick;
|
||||
}
|
||||
return ret;
|
||||
@ -311,7 +196,6 @@ void App::QuickExecute(int delta_time)
|
||||
{
|
||||
f8::MsgQueue::Instance()->Update();
|
||||
DispatchMsg();
|
||||
RoomMgr::Instance()->Update(delta_time);
|
||||
f8::Timer::Instance()->Update();
|
||||
}
|
||||
|
||||
@ -394,47 +278,10 @@ void App::DispatchMsg()
|
||||
working_msgnode_size_ = 0;
|
||||
}
|
||||
a8::tick_t end_tick = a8::XGetTickCount();
|
||||
if (end_tick - begin_tick > PerfMonitor::Instance()->max_dispatchmsg_time) {
|
||||
PerfMonitor::Instance()->max_dispatchmsg_time = end_tick - begin_tick;
|
||||
}
|
||||
}
|
||||
|
||||
void App::ProcessGameGateMsg(f8::MsgHdr& hdr)
|
||||
{
|
||||
if (hdr.msgid == ss::_SS_Ping) {
|
||||
ss::SS_Pong pongmsg;
|
||||
GGListener::Instance()->SendProxyMsg(hdr.socket_handle, pongmsg);
|
||||
return;
|
||||
}
|
||||
f8::NetMsgHandler* handler = f8::GetNetMsgHandler(&HandlerMgr::Instance()->ggmsghandler,
|
||||
hdr.msgid);
|
||||
if (handler) {
|
||||
switch (handler->handlerid) {
|
||||
case HID_RoomMgr:
|
||||
ProcessNetMsg(handler, RoomMgr::Instance(), hdr);
|
||||
break;
|
||||
case HID_MatchTeam:
|
||||
{
|
||||
auto match_info = MatchMgr::Instance()->GetMatchInfo(hdr.socket_handle);
|
||||
if (match_info) {
|
||||
ProcessNetMsg(handler, std::get<1>(*match_info), hdr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HID_PlayerMgr:
|
||||
ProcessNetMsg(handler, PlayerMgr::Instance(), hdr);
|
||||
break;
|
||||
case HID_Player:
|
||||
{
|
||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(hdr.socket_handle);
|
||||
if (hum) {
|
||||
hdr.hum = hum;
|
||||
ProcessNetMsg(handler, hum, hdr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::InitLog()
|
||||
|
@ -8,17 +8,9 @@
|
||||
|
||||
#include "handlermgr.h"
|
||||
|
||||
#include "GGListener.h"
|
||||
#include "app.h"
|
||||
#include "player.h"
|
||||
#include "playermgr.h"
|
||||
#include "roommgr.h"
|
||||
#include "cs_proto.pb.h"
|
||||
#include "ss_proto.pb.h"
|
||||
#include "jsondatamgr.h"
|
||||
#include "perfmonitor.h"
|
||||
#include "matchmgr.h"
|
||||
#include "matchteam.h"
|
||||
|
||||
static void _GMOpsSelfChecking(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
{
|
||||
@ -26,15 +18,12 @@ static void _GMOpsSelfChecking(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->resp_xobj->SetVal("healthy", 1);
|
||||
request->resp_xobj->SetVal("servicing", App::Instance()->servicing ? 1 : 0);
|
||||
request->resp_xobj->SetVal("max_rundelay", PerfMonitor::Instance()->max_run_delay_time);
|
||||
request->resp_xobj->SetVal("max_timer_idle", PerfMonitor::Instance()->max_timer_idle);
|
||||
}
|
||||
|
||||
static void _GMOpsReload(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
JsonDataMgr::Instance()->Reload();
|
||||
f8::UdpLog::Instance()->Info("reload config files", {});
|
||||
}
|
||||
|
||||
@ -64,8 +53,6 @@ static void _GMStatGetRealTimeOnline(std::shared_ptr<f8::JsonHttpRequest> reques
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->resp_xobj->SetVal("num", PerfMonitor::Instance()->entity_num[ET_Player]);
|
||||
request->resp_xobj->SetVal("room_num", RoomMgr::Instance()->RoomNum());
|
||||
}
|
||||
|
||||
void HandlerMgr::Init()
|
||||
@ -103,40 +90,12 @@ void HandlerMgr::UnInit()
|
||||
|
||||
void HandlerMgr::RegisterNetMsgHandlers()
|
||||
{
|
||||
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_WSP_SocketDisconnect);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_Ping);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMJoin);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMReconnect);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMPing);
|
||||
|
||||
RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchCancel);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchChoose);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchStartGame);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchCancelStartGame);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchSendMsg);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchBroadcastMsg);
|
||||
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMove);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMImmediateMsg);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMExecCommand);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMEmote);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMVoice);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMGameOver);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMWatchWar);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMLeave);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMRevive);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMCancelRevive);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMRequestBulletDmg);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMRequestThrowDmg);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMStowShield);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMTeamMarkTargetPos);
|
||||
}
|
||||
|
||||
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
||||
const std::string& url, const std::string& querystr)
|
||||
{
|
||||
if (url != "/webapp/index.php") {
|
||||
GGListener::Instance()->SendText(sockhandle, a8::HttpResponse(404, ""));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -158,10 +117,10 @@ void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
||||
if (!request->pending){
|
||||
std::string response;
|
||||
request->resp_xobj->ToJsonStr(response);
|
||||
GGListener::Instance()->SendText(sockhandle, a8::HttpResponse(response));
|
||||
//GGListener::Instance()->SendText(sockhandle, a8::HttpResponse(response));
|
||||
}
|
||||
} else {
|
||||
GGListener::Instance()->SendText(sockhandle, a8::HttpResponse("{}"));
|
||||
//GGListener::Instance()->SendText(sockhandle, a8::HttpResponse("{}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
123
server/robotserver/jsondatamgr.cc
Normal file
123
server/robotserver/jsondatamgr.cc
Normal file
@ -0,0 +1,123 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "jsondatamgr.h"
|
||||
#include "app.h"
|
||||
|
||||
#include <f8/utils.h>
|
||||
#include <f8/udplog.h>
|
||||
|
||||
void JsonDataMgr::Init()
|
||||
{
|
||||
if (!f8::IsOnlineEnv()) {
|
||||
if (f8::IsTestEnv()) {
|
||||
work_path_ = a8::Format("../../../conf_test/game%d/gameserver.test",
|
||||
{
|
||||
GAME_ID
|
||||
});
|
||||
} else {
|
||||
work_path_ = a8::Format("../../../conf_test/game%d/gameserver.dev",
|
||||
{
|
||||
GAME_ID
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
std::string gameserver_cluster_json_file;
|
||||
std::string setting_json_file;
|
||||
std::string httpproxy_json_file;
|
||||
|
||||
gameserver_cluster_json_file = a8::Format("%s/node%d/game%d.gameserver.cluster.json",
|
||||
{
|
||||
work_path_,
|
||||
App::Instance()->node_id,
|
||||
GAME_ID
|
||||
});
|
||||
setting_json_file = a8::Format("%s/setting.json",
|
||||
{
|
||||
work_path_,
|
||||
});
|
||||
httpproxy_json_file = a8::Format("%s/httpproxy.cluster.json",
|
||||
{
|
||||
work_path_,
|
||||
});
|
||||
gameserver_cluster_json_.ReadFromFile(gameserver_cluster_json_file);
|
||||
setting_json_.ReadFromFile(setting_json_file);
|
||||
httpproxy_cluster_json_.ReadFromFile(httpproxy_json_file);
|
||||
if (setting_json_.GetType() == a8::XOT_OBJECT &&
|
||||
setting_json_.HasKey("api_url")) {
|
||||
api_url_ = setting_json_.Get("api_url").GetString();
|
||||
}
|
||||
|
||||
ip = GetConf()->At("ip")->AsXValue().GetString();
|
||||
listen_port = GetConf()->At("listen_port")->AsXValue();
|
||||
if (GetConf()->HasKey("channel")) {
|
||||
channel = GetConf()->At("channel")->AsXValue();
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (!f8::IsOnlineEnv()) {
|
||||
if (!f8::IsTestEnv()) {
|
||||
bool ok = a8::GetLocalIp(ip);
|
||||
if (getenv("HOST_IP")) {
|
||||
ip = getenv("HOST_IP");
|
||||
}
|
||||
if (!ok) {
|
||||
A8_ABORT();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
server_info = a8::Format("%s:%d", {ip, listen_port});
|
||||
Reload();
|
||||
|
||||
f8::UdpLog::Instance()->Info("api_url:%s",
|
||||
{
|
||||
api_url_
|
||||
});
|
||||
}
|
||||
|
||||
void JsonDataMgr::UnInit()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<a8::XObject> JsonDataMgr::GetConf()
|
||||
{
|
||||
for (int i = 0; i < gameserver_cluster_json_.Size(); ++i) {
|
||||
std::shared_ptr<a8::XObject> conf = gameserver_cluster_json_.At(i);
|
||||
if (conf->At("instance_id")->AsXValue().GetInt() == App::Instance()->instance_id) {
|
||||
return conf;
|
||||
}
|
||||
}
|
||||
A8_ABORT();
|
||||
}
|
||||
|
||||
std::shared_ptr<a8::XObject> JsonDataMgr::GetMasterServerClusterConf()
|
||||
{
|
||||
return std::make_shared<a8::XObject>(masterserver_cluster_json_);
|
||||
}
|
||||
|
||||
void JsonDataMgr::Reload()
|
||||
{
|
||||
std::string masterserver_cluster_json_file;
|
||||
masterserver_cluster_json_file = a8::Format("%s/node%d/game%d.masterserver.cluster.json",
|
||||
{
|
||||
work_path_,
|
||||
App::Instance()->node_id,
|
||||
GAME_ID
|
||||
});
|
||||
masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file);
|
||||
}
|
||||
|
||||
void JsonDataMgr::GetApiUrl(std::string& url)
|
||||
{
|
||||
if (!api_url_.empty()) {
|
||||
url = api_url_;
|
||||
}
|
||||
}
|
||||
|
||||
void JsonDataMgr::GetHttpProxyUrl(std::string& url)
|
||||
{
|
||||
if (httpproxy_cluster_json_.Size() > 0) {
|
||||
std::shared_ptr<a8::XObject> conf = httpproxy_cluster_json_.At(0);
|
||||
url = conf->At("url")->AsXValue().GetString();
|
||||
}
|
||||
}
|
36
server/robotserver/jsondatamgr.h
Normal file
36
server/robotserver/jsondatamgr.h
Normal file
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <a8/singleton.h>
|
||||
|
||||
class JsonDataMgr : public a8::Singleton<JsonDataMgr>
|
||||
{
|
||||
private:
|
||||
JsonDataMgr() {};
|
||||
friend class a8::Singleton<JsonDataMgr>;
|
||||
|
||||
public:
|
||||
void Init();
|
||||
void UnInit();
|
||||
|
||||
std::shared_ptr<a8::XObject> GetConf();
|
||||
std::shared_ptr<a8::XObject> GetMasterServerClusterConf();
|
||||
|
||||
std::string ip;
|
||||
int listen_port = 0;
|
||||
int channel = 0;
|
||||
std::string server_info;
|
||||
|
||||
void Reload();
|
||||
void GetApiUrl(std::string& url);
|
||||
void GetHttpProxyUrl(std::string& url);
|
||||
|
||||
private:
|
||||
std::string api_url_;
|
||||
|
||||
private:
|
||||
std::string work_path_ = "../config";
|
||||
a8::XObject setting_json_;
|
||||
a8::XObject gameserver_cluster_json_;
|
||||
a8::XObject masterserver_cluster_json_;
|
||||
a8::XObject httpproxy_cluster_json_;
|
||||
};
|
@ -8,7 +8,4 @@
|
||||
|
||||
#include "constant.h"
|
||||
#include "constant_export.h"
|
||||
#include "mt/Forward.h"
|
||||
#include "types.h"
|
||||
#include "global.h"
|
||||
#include "glmhelper.h"
|
||||
|
@ -3,29 +3,3 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include "human.h"
|
||||
#include "glmhelper.h"
|
||||
|
||||
float Position::Distance2D2(const Position& pos) const
|
||||
{
|
||||
glm::vec2 v1 = glm::vec2(GetX(), GetZ());
|
||||
glm::vec2 v2 = glm::vec2(pos.GetX(), pos.GetZ());
|
||||
return glm::length(v2 - v1);
|
||||
}
|
||||
|
||||
float Position::ManhattanDistance2D(const Position& target_pos) const
|
||||
{
|
||||
float distance = std::fabs(GetX() - target_pos.GetX()) + std::fabs(GetZ() - target_pos.GetZ());
|
||||
return distance;
|
||||
}
|
||||
|
||||
glm::vec3 Position::CalcDir(const Position& target_pos) const
|
||||
{
|
||||
return target_pos.loc_ - loc_;
|
||||
}
|
||||
|
||||
float Position::DistanceGlmVec3(const glm::vec3& v) const
|
||||
{
|
||||
return GlmHelper::Norm(v - ToGlmVec3());
|
||||
}
|
||||
|
@ -1,101 +1 @@
|
||||
#pragma once
|
||||
|
||||
#include "weakptr.h"
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
struct Equip;
|
||||
struct Skill;
|
||||
}
|
||||
|
||||
namespace cs
|
||||
{
|
||||
struct CMJoin;
|
||||
}
|
||||
|
||||
class Room;
|
||||
class Buff;
|
||||
class Creature;
|
||||
|
||||
struct AddItemDTO
|
||||
{
|
||||
int uniid = 0;
|
||||
int item_id = 0;
|
||||
int count = 0;
|
||||
int item_level = 0;
|
||||
const mt::Equip* item_meta = nullptr;
|
||||
bool handled = false;
|
||||
};
|
||||
|
||||
struct BulletCheckResult
|
||||
{
|
||||
float flyed_distance = 0.0f;
|
||||
int c_hit_num = 0;
|
||||
int t_hit_num = 0;
|
||||
int o_hit_num = 0;
|
||||
bool eat = false;
|
||||
std::set<Entity*> objects;
|
||||
};
|
||||
|
||||
class ITask
|
||||
{
|
||||
public:
|
||||
virtual void Update(int delta_time) = 0;
|
||||
virtual bool IsDone() = 0;
|
||||
};
|
||||
|
||||
class DelayAddBuffHandle
|
||||
{
|
||||
public:
|
||||
std::function<void(Creature*)> pre_add_cb;
|
||||
std::function<void(Creature*, int)> post_add_cb;
|
||||
};
|
||||
|
||||
struct Position
|
||||
{
|
||||
void SetX(float x) { loc_.x = x; };
|
||||
void SetY(float y) { loc_.y = y; };
|
||||
void SetZ(float z) { loc_.z = z; };
|
||||
float GetX() const { return loc_.x; };
|
||||
float GetY() const { return loc_.y; };
|
||||
float GetZ() const { return loc_.z; };
|
||||
|
||||
float Distance2D2(const Position& pos) const;
|
||||
float DistanceGlmVec3(const glm::vec3& v) const;
|
||||
float ManhattanDistance2D(const Position& target_pos) const;
|
||||
glm::vec3 CalcDir(const Position& target_pos) const;
|
||||
|
||||
void FromGlmVec3(const glm::vec3 v) { loc_ = v; };
|
||||
|
||||
glm::vec3 ToGlmVec3() const { return loc_; };
|
||||
|
||||
const Position& AddGlmVec3(const glm::vec3& v) { loc_ += v; return *this; };
|
||||
|
||||
private:
|
||||
glm::vec3 loc_ = glm::vec3(0.0, 0.0, 0.0);
|
||||
};
|
||||
|
||||
class IBullet
|
||||
{
|
||||
public:
|
||||
virtual const Position& GetPos() = 0;
|
||||
virtual const glm::vec3& GetDir() = 0;
|
||||
virtual float GetStrengthenWall() = 0;
|
||||
virtual long long GetWeaponUniId() = 0;
|
||||
virtual const mt::Skill* GetSkillMeta() = 0;
|
||||
virtual const mt::Equip* GetGunMeta() = 0;
|
||||
virtual const mt::Equip* GetBulletMeta() = 0;
|
||||
virtual CreatureWeakPtr GetSender() = 0;
|
||||
virtual CreatureWeakPtr GetPassenger() = 0;
|
||||
virtual bool IsBomb() = 0;
|
||||
virtual bool IsPreBattleBullet() = 0;
|
||||
virtual Room* GetRoom() = 0;
|
||||
virtual float GetHitRadius() = 0;
|
||||
virtual void ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos) = 0;
|
||||
};
|
||||
|
||||
typedef std::weak_ptr<struct AttrAdditionPtr> AttrAdditionHandle;
|
||||
typedef std::weak_ptr<struct AttrRuducePtr> AttrRuduceHandle;
|
||||
typedef std::weak_ptr<struct AttrAbsPtr> AttrAbsHandle;
|
||||
typedef std::weak_ptr<struct AttrRatePtr> AttrRateHandle;
|
||||
typedef std::weak_ptr<struct AttrDirectPtr> AttrDirectHandle;
|
||||
|
Loading…
x
Reference in New Issue
Block a user