This commit is contained in:
aozhiwei 2019-10-09 11:35:54 +08:00
parent 4f3d747835
commit 224ced6c97
6 changed files with 30 additions and 27 deletions

View File

@ -5,8 +5,8 @@ set(GAME_ID 2002)
set(CMAKE_BUILD_TYPE "Debug") set(CMAKE_BUILD_TYPE "Debug")
#set(CMAKE_BUILD_TYPE "Release") #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_RELEASE "-O3 -g -std=gnu++11 -DGAME_ID=${GAME_ID}")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -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}")
include_directories( include_directories(
AFTER AFTER

View File

@ -12,6 +12,7 @@
#include <a8/collision.h> #include <a8/collision.h>
#include "framework/cpp/netmsghandler.h" #include "framework/cpp/netmsghandler.h"
#include "framework/cpp/btmgr.h"
#include "app.h" #include "app.h"
#include "jsondatamgr.h" #include "jsondatamgr.h"
@ -141,6 +142,7 @@ bool App::Init(int argc, char* argv[])
f8::MsgQueue::Instance()->Init(); f8::MsgQueue::Instance()->Init();
f8::TGLog::Instance()->Init(a8::Format(kPROJ_NAME_FMT, {GAME_ID}), false); 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::HttpClientPool::Instance()->Init(10, kMAX_SYS_HTTP_NUM, kMAX_USER_HTTP_NUM);
f8::BtMgr::Instance()->Init(GetResDir() + "behavior_tree");
JsonDataMgr::Instance()->Init(); JsonDataMgr::Instance()->Init();
MetaMgr::Instance()->Init(); MetaMgr::Instance()->Init();
uuid.SetMachineId((node_id - 1) * kMAX_NODE_ID + instance_id); uuid.SetMachineId((node_id - 1) * kMAX_NODE_ID + instance_id);
@ -179,6 +181,7 @@ void App::UnInit()
GGListener::Instance()->UnInit(); GGListener::Instance()->UnInit();
PlayerMgr::Instance()->UnInit(); PlayerMgr::Instance()->UnInit();
RoomMgr::Instance()->UnInit(); RoomMgr::Instance()->UnInit();
f8::BtMgr::Instance()->UnInit();
MetaMgr::Instance()->UnInit(); MetaMgr::Instance()->UnInit();
JsonDataMgr::Instance()->UnInit(); JsonDataMgr::Instance()->UnInit();
f8::HttpClientPool::Instance()->UnInit(); f8::HttpClientPool::Instance()->UnInit();

View File

@ -1,23 +1,8 @@
#include "precompile.h" #include "precompile.h"
#include "global.h" #include "global.h"
#include "app.h"
int g_hint_flags = 0; #include "framework/cpp/utils.h"
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;
}
int Global::g_nowtime = time(nullptr); int Global::g_nowtime = time(nullptr);
int Global::g_time_zone = 8; int Global::g_time_zone = 8;
@ -38,3 +23,23 @@ bool IsValidHumanAttr(int attr_type)
{ {
return attr_type > kHAT_Begin && attr_type < kHAT_End; 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;
}

View File

@ -1,7 +1,5 @@
#pragma once #pragma once
extern int g_hint_flags;
class ColliderComponent; class ColliderComponent;
class Global : public a8::Singleton<Global> class Global : public a8::Singleton<Global>
{ {
@ -10,10 +8,6 @@ class Global : public a8::Singleton<Global>
friend class a8::Singleton<Global>; friend class a8::Singleton<Global>;
public: 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_nowtime;
static int g_time_zone; // 默认东八区 static int g_time_zone; // 默认东八区
static bool g_shutdown; static bool g_shutdown;
@ -23,3 +17,4 @@ class Global : public a8::Singleton<Global>
bool IsValidSlotId(int slot_id); bool IsValidSlotId(int slot_id);
bool IsValidBuffEffect(int buff_effect); bool IsValidBuffEffect(int buff_effect);
bool IsValidHumanAttr(int attr_type); bool IsValidHumanAttr(int attr_type);
std::string GetResDir();

@ -1 +1 @@
Subproject commit 12b84ccd07a83502f0dff0e9689f7fd931256878 Subproject commit b9f2f205afe3226fa06b6a3b9e62fcd6eaca63b8

@ -1 +1 @@
Subproject commit 3d62b9c0c3d17c3036179073f0a4c0310b5a274a Subproject commit d6038d840074ee696b6c267f82091c5a1d9dc1cc