MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / LuaRules

Method LuaRules

src/lua/LuaRules.cpp:91–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89//============================================================================//
90
91LuaRules::LuaRules()
92 : LuaHandle("LuaRules",
93 LUA_RULES_SCRIPT_ID,
94 LUA_RULES_GAME_ORDER,
95 LUA_RULES_DRAW_WORLD_ORDER,
96 LUA_RULES_DRAW_SCREEN_ORDER,
97 true, true, true) { // handle perms
98 static LuaVfsModes vfsModes;
99 vfsModes.readDefault = BZVFS_LUA_RULES;
100 vfsModes.readAllowed = BZVFS_LUA_RULES;
101 vfsModes.writeDefault = BZVFS_LUA_RULES_WRITE;
102 vfsModes.writeAllowed = BZVFS_LUA_RULES_WRITE;
103 if (devMode) {
104 vfsModes.readDefault = BZVFS_LUA_USER BZVFS_LUA_RULES;
105 vfsModes.readAllowed = BZVFS_LUA_USER BZVFS_LUA_RULES;
106 }
107
108 luaRules = this;
109
110 if (L == NULL) {
111 return;
112 }
113
114 // setup the handle pointer
115 LuaExtraSpace* LHH = L2ES(L);
116 LHH->handle = this;
117 LHH->handlePtr = (LuaHandle**)&luaRules;
118 LHH->vfsModes = &vfsModes;
119 LHH->bzdbReadCheck = BzdbReadCheck;
120 LHH->bzdbWriteCheck = BzdbWriteCheck;
121
122 if (!SetupEnvironment()) {
123 KillLua();
124 return;
125 }
126
127 const std::string sourceCode = LoadSourceCode(sourceFile, BZVFS_LUA_RULES);
128 if (sourceCode.empty()) {
129 KillLua();
130 return;
131 }
132
133 // register for call-ins
134 eventHandler.AddClient(this);
135
136 if (!ExecSourceCode(sourceCode, sourceFile)) {
137 KillLua();
138 return;
139 }
140}
141
142
143LuaRules::~LuaRules() {

Callers

nothing calls this directly

Calls 3

L2ESFunction · 0.85
AddClientMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected