| 2234 | } |
| 2235 | |
| 2236 | static void CallRegisteredLuaMemHook_LuaMatch(unsigned int address, int size, unsigned int value, LuaMemHookType hookType) |
| 2237 | { |
| 2238 | // std::map<int, LuaContextInfo*>::iterator iter = luaContextInfo.begin(); |
| 2239 | // std::map<int, LuaContextInfo*>::iterator end = luaContextInfo.end(); |
| 2240 | // while(iter != end) |
| 2241 | // { |
| 2242 | // LuaContextInfo& info = *iter->second; |
| 2243 | if(/*info.*/ numMemHooks) |
| 2244 | { |
| 2245 | // lua_State* L = info.L; |
| 2246 | if(L/* && !info.panic*/) |
| 2247 | { |
| 2248 | #ifdef USE_INFO_STACK |
| 2249 | infoStack.insert(infoStack.begin(), &info); |
| 2250 | struct Scope { ~Scope(){ infoStack.erase(infoStack.begin()); } } scope; |
| 2251 | #endif |
| 2252 | lua_settop(L, 0); |
| 2253 | lua_getfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[hookType]); |
| 2254 | for(unsigned int i = address; i != address+size; i++) |
| 2255 | { |
| 2256 | lua_rawgeti(L, -1, i); |
| 2257 | if (lua_isfunction(L, -1)) |
| 2258 | { |
| 2259 | bool wasRunning = (luaRunning!=0) /*info.running*/; |
| 2260 | luaRunning /*info.running*/ = true; |
| 2261 | //RefreshScriptSpeedStatus(); |
| 2262 | lua_pushinteger(L, address); |
| 2263 | lua_pushinteger(L, size); |
| 2264 | lua_pushinteger(L, value); |
| 2265 | int errorcode = lua_pcall(L, 3, 0, 0); |
| 2266 | luaRunning /*info.running*/ = wasRunning; |
| 2267 | //RefreshScriptSpeedStatus(); |
| 2268 | if (errorcode) |
| 2269 | { |
| 2270 | HandleCallbackError(L); |
| 2271 | //int uid = iter->first; |
| 2272 | //HandleCallbackError(L,info,uid,true); |
| 2273 | } |
| 2274 | break; |
| 2275 | } |
| 2276 | else |
| 2277 | { |
| 2278 | lua_pop(L,1); |
| 2279 | } |
| 2280 | } |
| 2281 | lua_settop(L, 0); |
| 2282 | } |
| 2283 | } |
| 2284 | // ++iter; |
| 2285 | // } |
| 2286 | } |
| 2287 | void CallRegisteredLuaMemHook(unsigned int address, int size, unsigned int value, LuaMemHookType hookType) |
| 2288 | { |
| 2289 | // performance critical! (called VERY frequently) |
no test coverage detected