Advertisement
sorvani

std::list char in inst

Jan 18th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.00 KB | None | 0 0
  1.  common/database.cpp  | 20 ++++++++++++++++++++
  2.  common/database.h    |  1 +
  3.  zone/lua_general.cpp | 14 ++++++++++++++
  4.  3 files changed, 35 insertions(+)
  5.  
  6. diff --git a/common/database.cpp b/common/database.cpp
  7. index 0ea3b88..ace5bf4 100644
  8. --- a/common/database.cpp
  9. +++ b/common/database.cpp
  10. @@ -2834,6 +2834,26 @@ uint16 Database::GetInstanceID(uint32 zone, uint32 charid, int16 version)
  11.     return 0;
  12.  }
  13.  
  14. +void Database::GetCharactersInInstance(uint16 instance_id, std::list<uint32> &charid_list) {
  15. +   char errbuf[MYSQL_ERRMSG_SIZE];
  16. +   char *query = 0;
  17. +   MYSQL_RES *result;
  18. +   MYSQL_ROW row;
  19. +
  20. +   if (RunQuery(query, MakeAnyLenString(&query, "SELECT charid FROM instance_lockout_player WHERE id=%u", instance_id), errbuf, &result)) {
  21. +       safe_delete_array(query);
  22. +       while ((row = mysql_fetch_row(result)))
  23. +       {
  24. +           charid_list.push_back(atoi(row[0]));
  25. +       }
  26. +       mysql_free_result(result);
  27. +   }
  28. +   else {
  29. +       LogFile->write(EQEMuLog::Error, "Error in GetCharactersInInstace query '%s': %s", query, errbuf);
  30. +       safe_delete_array(query);
  31. +   }
  32. +}
  33. +
  34.  void Database::AssignGroupToInstance(uint32 gid, uint32 instance_id)
  35.  {
  36.     char errbuf[MYSQL_ERRMSG_SIZE];
  37. diff --git a/common/database.h b/common/database.h
  38. index 849f6f6..300fc98 100644
  39. --- a/common/database.h
  40. +++ b/common/database.h
  41. @@ -163,6 +163,7 @@ public:
  42.     uint16 GetInstanceVersion(uint16 instance_id);
  43.     uint16 GetInstanceID(const char* zone, uint32 charid, int16 version);
  44.     uint16 GetInstanceID(uint32 zone, uint32 charid, int16 version);
  45. +   void GetCharactersInInstance(uint16 instance_id, std::list<uint32> &charid_list);
  46.     void AssignGroupToInstance(uint32 gid, uint32 instance_id);
  47.     void AssignRaidToInstance(uint32 rid, uint32 instance_id);
  48.     void FlagInstanceByGroupLeader(uint32 zone, int16 version, uint32 charid, uint32 gid);
  49. diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp
  50. index 5bddbd2..8746985 100644
  51. --- a/zone/lua_general.cpp
  52. +++ b/zone/lua_general.cpp
  53. @@ -781,6 +781,19 @@ int lua_get_zone_instance_version() {
  54.     return zone->GetInstanceVersion();
  55.  }
  56.  
  57. +luabind::object lua_get_characters_in_instance(lua_State *L, uint16 instance_id) {
  58. +   luabind::object ret = luabind::newtable(L);
  59. +
  60. +   std::list<uint32> charid_list;
  61. +   database.GetCharactersInInstance(instance_id,charid_list);
  62. +   auto iter = charid_list.begin();
  63. +   while(iter != charid_list.end()) {
  64. +       ret[*iter] = *iter;
  65. +       ++iter;
  66. +   }
  67. +   return ret;
  68. +}
  69. +
  70.  int lua_get_zone_weather() {
  71.     if(!zone)
  72.         return 0;
  73. @@ -1164,6 +1177,7 @@ luabind::scope lua_register_general() {
  74.         luabind::def("create_instance", &lua_create_instance),
  75.         luabind::def("destroy_instance", &lua_destroy_instance),
  76.         luabind::def("get_instance_id", &lua_get_instance_id),
  77. +       luabind::def("get_characters_in_instance", (luabind::object(*)(uint16))&lua_get_characters_in_instance),
  78.         luabind::def("assign_to_instance", &lua_assign_to_instance),
  79.         luabind::def("assign_group_to_instance", &lua_assign_group_to_instance),
  80.         luabind::def("assign_raid_to_instance", &lua_assign_raid_to_instance),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement