Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
38d534d6cf | ||
![]() |
f797e73be9 | ||
![]() |
14a5149668 | ||
![]() |
75df23693b | ||
![]() |
9cf49c2e49 | ||
![]() |
c388dbf87e |
@ -15,6 +15,14 @@ else()
|
|||||||
set(CMAKE_BUILD_TYPE "Debug")
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
message("debug mode")
|
message("debug mode")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (${LIB_DIR})
|
||||||
|
message(LIB_DIR: ${LIB_DIR})
|
||||||
|
else()
|
||||||
|
set(LIB_DIR )
|
||||||
|
message(LIB_DIR: ${LIB_DIR} )
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DNDEBUG")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DDEBUG")
|
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DDEBUG")
|
||||||
|
|
||||||
@ -28,6 +36,7 @@ include_directories(
|
|||||||
/usr/include/glm
|
/usr/include/glm
|
||||||
../../third_party
|
../../third_party
|
||||||
../../third_party/behaviac/inc
|
../../third_party/behaviac/inc
|
||||||
|
../../third_party/recastnavigation/Recast/Include
|
||||||
../../third_party/recastnavigation/Detour/Include
|
../../third_party/recastnavigation/Detour/Include
|
||||||
../../third_party/recastnavigation/DetourTileCache/Include
|
../../third_party/recastnavigation/DetourTileCache/Include
|
||||||
.
|
.
|
||||||
@ -36,7 +45,7 @@ include_directories(
|
|||||||
link_directories(
|
link_directories(
|
||||||
/usr/lib64/mysql
|
/usr/lib64/mysql
|
||||||
/usr/local/lib
|
/usr/local/lib
|
||||||
../../third_party/behaviac/lib
|
../../third_party/behaviac/lib/${LIB_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
aux_source_directory(../../third_party/a8engine/a8
|
aux_source_directory(../../third_party/a8engine/a8
|
||||||
@ -47,6 +56,10 @@ aux_source_directory(../../third_party/framework/cpp
|
|||||||
SRC_LIST
|
SRC_LIST
|
||||||
)
|
)
|
||||||
|
|
||||||
|
aux_source_directory(../../third_party/recastnavigation/Recast/Source
|
||||||
|
SRC_LIST
|
||||||
|
)
|
||||||
|
|
||||||
aux_source_directory(../../third_party/recastnavigation/Detour/Source
|
aux_source_directory(../../third_party/recastnavigation/Detour/Source
|
||||||
SRC_LIST
|
SRC_LIST
|
||||||
)
|
)
|
||||||
@ -97,7 +110,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
hiredis
|
hiredis
|
||||||
tinyxml2
|
tinyxml2
|
||||||
tcmalloc
|
tcmalloc
|
||||||
behaviac_gcc_debug
|
behaviac_gcc_release
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include "framework/cpp/msgqueue.h"
|
#include "framework/cpp/msgqueue.h"
|
||||||
#include "framework/cpp/tglog.h"
|
#include "framework/cpp/tglog.h"
|
||||||
#include "framework/cpp/utils.h"
|
|
||||||
|
|
||||||
struct MsgNode
|
struct MsgNode
|
||||||
{
|
{
|
||||||
@ -484,25 +483,7 @@ bool App::IsSeparateChannel(int channel)
|
|||||||
void App::LoadSeparateChannelConfig()
|
void App::LoadSeparateChannelConfig()
|
||||||
{
|
{
|
||||||
std::string data;
|
std::string data;
|
||||||
std::string filename = "../config/separate_channels.csv";
|
a8::ReadStringFromFile("../config/separate_channels.csv", data);
|
||||||
if (!f8::IsOnlineEnv()) {
|
|
||||||
if (f8::IsTestEnv()) {
|
|
||||||
filename = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver.test/separate_channels.csv",
|
|
||||||
{
|
|
||||||
GAME_ID,
|
|
||||||
App::Instance()->instance_id,
|
|
||||||
GAME_ID
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
filename = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver.dev/separate_channels.csv",
|
|
||||||
{
|
|
||||||
GAME_ID,
|
|
||||||
App::Instance()->instance_id,
|
|
||||||
GAME_ID
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a8::ReadStringFromFile(filename, data);
|
|
||||||
std::vector<std::string> strings;
|
std::vector<std::string> strings;
|
||||||
a8::Split(data, strings, ',');
|
a8::Split(data, strings, ',');
|
||||||
separate_channel_hash_.clear();
|
separate_channel_hash_.clear();
|
||||||
@ -512,9 +493,8 @@ void App::LoadSeparateChannelConfig()
|
|||||||
separate_channel_hash_.insert(channel);
|
separate_channel_hash_.insert(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a8::UdpLog::Instance()->Debug("LoadSeparateChannelConfig %s channelids:%s",
|
a8::UdpLog::Instance()->Info("LoadSeparateChannelConfig channelids:%s",
|
||||||
{
|
{
|
||||||
filename,
|
|
||||||
GetSeparateChannelConfigData()
|
GetSeparateChannelConfigData()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
13
server/masterserver/error_code.h
Executable file
13
server/masterserver/error_code.h
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/*
|
||||||
|
类似http的错误码设计
|
||||||
|
0:成功
|
||||||
|
<400: 客户端的错
|
||||||
|
>500: 服务器的错
|
||||||
|
*/
|
||||||
|
enum ErrorCode_e
|
||||||
|
{
|
||||||
|
ERRNO_OK = 0,
|
||||||
|
|
||||||
|
};
|
@ -26,8 +26,18 @@ void GSMgr::UnInit()
|
|||||||
|
|
||||||
void GSMgr::_SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_RequestTargetServer& msg)
|
void GSMgr::_SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_RequestTargetServer& msg)
|
||||||
{
|
{
|
||||||
int target_channel = GetTargetChannel(msg);
|
int channel = f8::ExtractChannelIdFromAccountId(msg.account_id());
|
||||||
|
if (!App::Instance()->IsSeparateChannel(channel)) {
|
||||||
|
channel = 0;
|
||||||
|
}
|
||||||
|
#if 1
|
||||||
|
int src_channel = f8::ExtractChannelIdFromAccountId(msg.account_id());
|
||||||
|
if (channel == 0 &&
|
||||||
|
src_channel == kTouTiaoChannelId &&
|
||||||
|
msg.proto_version() == 2019071502) {
|
||||||
|
channel = src_channel;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
ss::SS_MS_ResponseTargetServer respmsg;
|
ss::SS_MS_ResponseTargetServer respmsg;
|
||||||
respmsg.set_context_id(msg.context_id());
|
respmsg.set_context_id(msg.context_id());
|
||||||
if (msg.is_reconnect()) {
|
if (msg.is_reconnect()) {
|
||||||
@ -41,11 +51,11 @@ void GSMgr::_SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_Reques
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GSNode* node = GetNodeByTeamId(msg.team_id());
|
GSNode* node = GetNodeByTeamId(msg.team_id());
|
||||||
if (node && node->channel == target_channel) {
|
if (node && node->channel == channel) {
|
||||||
respmsg.set_host(node->ip);
|
respmsg.set_host(node->ip);
|
||||||
respmsg.set_port(node->port);
|
respmsg.set_port(node->port);
|
||||||
} else {
|
} else {
|
||||||
node = AllocNode(target_channel);
|
node = AllocNode(channel);
|
||||||
if (node) {
|
if (node) {
|
||||||
respmsg.set_host(node->ip);
|
respmsg.set_host(node->ip);
|
||||||
respmsg.set_port(node->port);
|
respmsg.set_port(node->port);
|
||||||
@ -188,6 +198,21 @@ GSNode* GSMgr::AllocNode(int channel)
|
|||||||
std::vector<GSNode*>* sorted_nodes = GetSortedNodesByChannel(channel);
|
std::vector<GSNode*>* sorted_nodes = GetSortedNodesByChannel(channel);
|
||||||
if (sorted_nodes && !sorted_nodes->empty()) {
|
if (sorted_nodes && !sorted_nodes->empty()) {
|
||||||
size_t rnd = std::min((size_t)2, sorted_nodes->size());
|
size_t rnd = std::min((size_t)2, sorted_nodes->size());
|
||||||
|
if (rnd >= 2) {
|
||||||
|
GSNode* n1 = sorted_nodes->at(sorted_nodes->size() - 1);
|
||||||
|
GSNode* n2 = sorted_nodes->at(sorted_nodes->size() - 2);
|
||||||
|
if (n1->online_num < 100 && n2->online_num < 100) {
|
||||||
|
if (n1->instance_id < n2->instance_id) {
|
||||||
|
if (n1->servicing) {
|
||||||
|
return n1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (n2->servicing) {
|
||||||
|
return n2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
int idx = rand() % rnd;
|
int idx = rand() % rnd;
|
||||||
while (idx >= 0) {
|
while (idx >= 0) {
|
||||||
if (sorted_nodes->at(idx)->servicing) {
|
if (sorted_nodes->at(idx)->servicing) {
|
||||||
@ -304,19 +329,3 @@ void GSMgr::OnChannelChange(GSNode* node)
|
|||||||
RemoveNodeFromSortedNodes(node);
|
RemoveNodeFromSortedNodes(node);
|
||||||
AddNodeToSortedNodes(node);
|
AddNodeToSortedNodes(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GSMgr::GetTargetChannel(const ss::SS_WSP_RequestTargetServer& msg)
|
|
||||||
{
|
|
||||||
int channel = f8::ExtractChannelIdFromAccountId(msg.account_id());
|
|
||||||
if ((channel == 6000 || channel == 0) && !msg.url().empty()) {
|
|
||||||
std::vector<std::string> strings;
|
|
||||||
a8::Split(msg.url(), strings, '/');
|
|
||||||
if (strings.size() > 1) {
|
|
||||||
channel = a8::XValue(strings[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!App::Instance()->IsSeparateChannel(channel)) {
|
|
||||||
channel = 0;
|
|
||||||
}
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
|
@ -48,7 +48,6 @@ class GSMgr : public a8::Singleton<GSMgr>
|
|||||||
void RemoveNodeFromSortedNodes(GSNode* node);
|
void RemoveNodeFromSortedNodes(GSNode* node);
|
||||||
std::vector<GSNode*>* GetSortedNodesByChannel(int channel);
|
std::vector<GSNode*>* GetSortedNodesByChannel(int channel);
|
||||||
void OnChannelChange(GSNode* node);
|
void OnChannelChange(GSNode* node);
|
||||||
int GetTargetChannel(const ss::SS_WSP_RequestTargetServer& msg);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -10,17 +10,13 @@ void JsonDataMgr::Init()
|
|||||||
std::string masterserver_cluster_json_file;
|
std::string masterserver_cluster_json_file;
|
||||||
if (!f8::IsOnlineEnv()) {
|
if (!f8::IsOnlineEnv()) {
|
||||||
if (f8::IsTestEnv()) {
|
if (f8::IsTestEnv()) {
|
||||||
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver.test",
|
work_path_ = a8::Format("../../../conf_test/game%d/masterserver.test",
|
||||||
{
|
{
|
||||||
GAME_ID,
|
|
||||||
App::Instance()->instance_id,
|
|
||||||
GAME_ID
|
GAME_ID
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver.dev",
|
work_path_ = a8::Format("../../../conf_test/game%d/masterserver.dev",
|
||||||
{
|
{
|
||||||
GAME_ID,
|
|
||||||
App::Instance()->instance_id,
|
|
||||||
GAME_ID
|
GAME_ID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "constant.h"
|
#include "constant.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "error_code.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
namespace google
|
namespace google
|
||||||
|
@ -22,9 +22,6 @@ message SS_WSP_RequestTargetServer
|
|||||||
optional string server_info = 4;
|
optional string server_info = 4;
|
||||||
optional int32 is_reconnect = 5;
|
optional int32 is_reconnect = 5;
|
||||||
optional int32 proto_version = 6; //协议版本号Constant_e.ProtoVersion
|
optional int32 proto_version = 6; //协议版本号Constant_e.ProtoVersion
|
||||||
optional string url = 7;
|
|
||||||
optional string query_str = 8;
|
|
||||||
optional string session_id = 9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message SS_MS_ResponseTargetServer
|
message SS_MS_ResponseTargetServer
|
||||||
|
2
third_party/a8engine
vendored
2
third_party/a8engine
vendored
@ -1 +1 @@
|
|||||||
Subproject commit cdb87a3e673aee3401b3e2ffce3ea1a1e6a603b0
|
Subproject commit 9c890ba78e289d4879f921b94b558e10d66b2b64
|
2
third_party/behaviac
vendored
2
third_party/behaviac
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 240414570ee2848291d24ff8d3102dc43d4104a3
|
Subproject commit 5beca57f6555aa0d9e4de71c93653cade928a654
|
2
third_party/framework
vendored
2
third_party/framework
vendored
@ -1 +1 @@
|
|||||||
Subproject commit eb455bb95f97dc506566c443be0c72960ceebabf
|
Subproject commit 180f9e3f5cdad81a58fe4f8a96b0bd6388eef222
|
2
third_party/tools
vendored
2
third_party/tools
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 43a09bd136f0d28c61cd03103b9d151af1317381
|
Subproject commit 725d70ebaba30c20124075cf5e4bd751d2404d28
|
Loading…
x
Reference in New Issue
Block a user