-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgameroot.cpp
More file actions
104 lines (90 loc) · 2.16 KB
/
Copy pathgameroot.cpp
File metadata and controls
104 lines (90 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/***************************************************************************************
# Copyright (c) 2019
# All rights reserved
#
# @author :
# @name :
# @file :
# @date :
# @describe:
#***************************************************************************************/
#include "gameroot.h"
#include "config/gameconfig.h"
#include "config/pluginconfig.h"
#include "context/context.h"
#include "process/process.h"
#include "gameserver.h"
namespace game
{
using namespace config;
using namespace context;
using namespace process;
using namespace gameserver;
GameRoot::GameRoot(int iInitMode, GameInitParam const &sInitParams)
: sParams(sInitParams)
, cfg(NULL)
, plg(NULL)
, con(NULL)
, pro(NULL)
, gs(NULL)
{
if (cfg == NULL)
{
cfg = config::GameConfig::Create();
}
if (plg == NULL)
{
plg = config::PluginConfig::Create();
}
if (con == NULL)
{
con = Context::Create(this);
}
if (pro == NULL)
{
pro = Process::Create(this);
}
if (gs == NULL)
{
gs = GameServer::Create(this);
}
//
std::string cfgPath = sInitParams.strConfigPath + "lib" + sInitParams.strConfigParam + ".cfg";
if (!cfg->loadConfigFile(cfgPath.c_str()))
{
DLOG_TRACE("error cfgPath, cfgPath = " << cfgPath);
}
else
{
cfg->printConfigFile(sInitParams);
}
}
GameRoot::~GameRoot()
{
if (cfg != NULL)
{
delete cfg;
cfg = NULL;
}
if (plg != NULL)
{
delete plg;
plg = NULL;
}
if (con != NULL)
{
delete con;
con = NULL;
}
if (pro != NULL)
{
delete pro;
pro = NULL;
}
if (gs != NULL)
{
delete gs;
gs = NULL;
}
}
}