PackForClient.h 771 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * api/netpacks/PackForClient.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../../LuaWrapper.h"
  12. #include "../../../../lib/NetPacks.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. namespace scripting
  15. {
  16. namespace api
  17. {
  18. namespace netpacks
  19. {
  20. template <typename Derived>
  21. class PackForClientProxy
  22. {
  23. public:
  24. static int toNetpackLight(lua_State * L)
  25. {
  26. typename Derived::UDataType object;
  27. LuaStack S(L);
  28. if(!S.tryGet(1, object))
  29. return S.retVoid();
  30. lua_settop(L, 0);
  31. lua_pushlightuserdata(L, static_cast<CPackForClient *>(object.get()));
  32. return 1;
  33. }
  34. };
  35. }
  36. }
  37. }
  38. VCMI_LIB_NAMESPACE_END