From 224ced6c970246df5d322f72a7ee4d8a740de5ac Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2019 11:35:54 +0800 Subject: [PATCH] 1 --- server/gameserver/CMakeLists.txt | 4 ++-- server/gameserver/app.cc | 3 +++ server/gameserver/global.cc | 39 ++++++++++++++++++-------------- server/gameserver/global.h | 7 +----- third_party/behaviac | 2 +- third_party/framework | 2 +- 6 files changed, 30 insertions(+), 27 deletions(-) diff --git a/server/gameserver/CMakeLists.txt b/server/gameserver/CMakeLists.txt index a69318b..cd49868 100644 --- a/server/gameserver/CMakeLists.txt +++ b/server/gameserver/CMakeLists.txt @@ -5,8 +5,8 @@ set(GAME_ID 2002) set(CMAKE_BUILD_TYPE "Debug") #set(CMAKE_BUILD_TYPE "Release") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1") -set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -std=gnu++11 -DGAME_ID=${GAME_ID}") +set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID}") include_directories( AFTER diff --git a/server/gameserver/app.cc b/server/gameserver/app.cc index d3464f8..1fb52a6 100755 --- a/server/gameserver/app.cc +++ b/server/gameserver/app.cc @@ -12,6 +12,7 @@ #include #include "framework/cpp/netmsghandler.h" +#include "framework/cpp/btmgr.h" #include "app.h" #include "jsondatamgr.h" @@ -141,6 +142,7 @@ bool App::Init(int argc, char* argv[]) f8::MsgQueue::Instance()->Init(); f8::TGLog::Instance()->Init(a8::Format(kPROJ_NAME_FMT, {GAME_ID}), false); f8::HttpClientPool::Instance()->Init(10, kMAX_SYS_HTTP_NUM, kMAX_USER_HTTP_NUM); + f8::BtMgr::Instance()->Init(GetResDir() + "behavior_tree"); JsonDataMgr::Instance()->Init(); MetaMgr::Instance()->Init(); uuid.SetMachineId((node_id - 1) * kMAX_NODE_ID + instance_id); @@ -179,6 +181,7 @@ void App::UnInit() GGListener::Instance()->UnInit(); PlayerMgr::Instance()->UnInit(); RoomMgr::Instance()->UnInit(); + f8::BtMgr::Instance()->UnInit(); MetaMgr::Instance()->UnInit(); JsonDataMgr::Instance()->UnInit(); f8::HttpClientPool::Instance()->UnInit(); diff --git a/server/gameserver/global.cc b/server/gameserver/global.cc index ef281c6..b032aa4 100755 --- a/server/gameserver/global.cc +++ b/server/gameserver/global.cc @@ -1,23 +1,8 @@ #include "precompile.h" #include "global.h" +#include "app.h" -int g_hint_flags = 0; - -time_t Global::BetweenDays(time_t time1, time_t time2) -{ - return (time1 + g_time_zone*3600)/3600/24 - (time2 + g_time_zone*3600)/3600/24; -} - -time_t Global::GetDaySeconds(time_t time, int incdays) -{ - return time_t((time + g_time_zone * 3600)/3600/24 + incdays) * 3600 * 24 - 3600 * g_time_zone; -} - -bool Global::IsTimeToReset(int time) -{ - return BetweenDays(g_nowtime - 60 * kSYS_RESET_TIME, time - 60 * kSYS_RESET_TIME) > 0; -} - +#include "framework/cpp/utils.h" int Global::g_nowtime = time(nullptr); int Global::g_time_zone = 8; @@ -38,3 +23,23 @@ bool IsValidHumanAttr(int attr_type) { return attr_type > kHAT_Begin && attr_type < kHAT_End; } + +std::string GetResDir() +{ + std::string res_path; + if (!f8::IsOnlineEnv()) { + if (App::Instance()->HasFlag(2)) { + res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver/res/", + { + GAME_ID, + App::Instance()->instance_id, + GAME_ID + }); + } else { + res_path = a8::Format("/var/data/conf_test/game%d/gameserver/res/", {GAME_ID}); + } + } else { + res_path = "../res/"; + } + return res_path; +} diff --git a/server/gameserver/global.h b/server/gameserver/global.h index 642b021..989beb5 100755 --- a/server/gameserver/global.h +++ b/server/gameserver/global.h @@ -1,7 +1,5 @@ #pragma once -extern int g_hint_flags; - class ColliderComponent; class Global : public a8::Singleton { @@ -10,10 +8,6 @@ class Global : public a8::Singleton friend class a8::Singleton; public: - static bool IsTimeToReset(int time); - static time_t BetweenDays(time_t time1, time_t time2); - static time_t GetDaySeconds(time_t time, int incdays = 0); - static int g_nowtime; static int g_time_zone; // 默认东八区 static bool g_shutdown; @@ -23,3 +17,4 @@ class Global : public a8::Singleton bool IsValidSlotId(int slot_id); bool IsValidBuffEffect(int buff_effect); bool IsValidHumanAttr(int attr_type); +std::string GetResDir(); diff --git a/third_party/behaviac b/third_party/behaviac index 12b84cc..b9f2f20 160000 --- a/third_party/behaviac +++ b/third_party/behaviac @@ -1 +1 @@ -Subproject commit 12b84ccd07a83502f0dff0e9689f7fd931256878 +Subproject commit b9f2f205afe3226fa06b6a3b9e62fcd6eaca63b8 diff --git a/third_party/framework b/third_party/framework index 3d62b9c..d6038d8 160000 --- a/third_party/framework +++ b/third_party/framework @@ -1 +1 @@ -Subproject commit 3d62b9c0c3d17c3036179073f0a4c0310b5a274a +Subproject commit d6038d840074ee696b6c267f82091c5a1d9dc1cc