载入中...
搜索中...
未找到
src
engine
common
EcsDefaultTable.cpp
浏览该文件的文档.
1
// The process-wide default ECS Table has exactly one owner.
2
//
3
// `ecs::default_table()` used to be an inline function with a function-local
4
// static (external/ECS.hpp). In a single-image build that is one Table, but the
5
// shared link-group route (EVENGINE_MODULE_LINKAGE=SHARED) puts the engine in
6
// several DLLs plus the host executable, and MSVC/ELF do not unify an inline
7
// function's local static across images: the host and each group would address a
8
// different Table, so an entity created through a domain module would be
9
// invisible to `ecs::current()` in the caller (and vice versa).
10
//
11
// external/ECS.hpp is patched (cmake/patches/ecs-shared-default-table.patch) so
12
// that in SHARED mode `ecs::default_table()` forwards to
13
// `ecs::engine_default_table()`, and this translation unit -- compiled into the
14
// foundation link unit, which every other group already depends on -- owns the
15
// storage. The OBJECT/static route keeps the inline definition, so a release SDK
16
// remains a single self-contained executable with no engine DLLs.
17
//
18
// The definition repeats EVE_ECS_DEFAULT_TABLE_API on purpose: MSVC rejects a
19
// plain declaration followed by a dllexport definition (C2375, "redefinition;
20
// different linkage"), so the header's declaration and this definition must carry
21
// the same annotation.
22
23
#include <ECS.hpp>
24
25
#if defined(EVENGINE_MODULE_DLL)
26
27
namespace
ecs {
28
29
EVE_ECS_DEFAULT_TABLE_API
Table
& engine_default_table() {
30
static
Table
table
;
31
return
table
;
32
}
33
34
}
// namespace ecs
35
36
#endif
eve::rpg::table
std::unordered_map< std::string, SkillDefinition > & table()
Definition
Skill.cpp:65
eve::Table
enum EVENGINE_API_FOUNDATION Table
OT_TABLE (editable via Runtime table APIs / ReflectedPropertyModel).
Definition
Runtime.h:121