CapsAdmin

Untitled

Oct 5th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. void my_suppress_lock()
  2. {
  3.     supress = true;
  4. }
  5.  
  6. void my_allow_lock()
  7. {
  8.     supress = false;
  9. }
  10.  
  11. const char *my_call(lua_State *L, int arguments, int results)
  12. {
  13.     if (supress)
  14.     {
  15.         if (!lua_isfunction(L, -(arguments+1)))
  16.         {
  17.             auto err = lua_tostring(L, -1);
  18.             lua_remove(L, -1);
  19.             return err;
  20.         }
  21.  
  22.         if (lua_pcall(L, arguments, results, 0) != 0)
  23.         {  
  24.             auto err = lua_tostring(L, -1);
  25.             lua_remove(L, -1);
  26.             return err;
  27.         }
  28.  
  29.         return 0;
  30.     }
  31.  
  32.     concurrency::critical_section ::scoped_lock slock(lock);
  33.  
  34.     if (!lua_isfunction(L, -(arguments+1)))
  35.     {
  36.         auto err = lua_tostring(L, -1);
  37.         lua_remove(L, -1);
  38.         return err;
  39.     }
  40.  
  41.     if (lua_pcall(L, arguments, results, 0) != 0)
  42.     {  
  43.         auto err = lua_tostring(L, -1);
  44.         lua_remove(L, -1);
  45.         return err;
  46.     }
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment