Advertisement
Guest User

DynamicTeleportMgr.cpp

a guest
Mar 24th, 2014
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. /*******************************************************
  2. * File:'DynamicTeleportMgr.cpp'
  3. * (c)2011 - Wolf Officious (ladislav.alexa@gmail.com)
  4. *******************************************************/
  5.  
  6. #include "DynamicTeleportMgr.h"
  7. #include "ProgressBar.h"
  8.  
  9. bool DynamicTeleportMgr::Init()
  10. {
  11. uint32 oldMSTime = getMSTime();
  12.  
  13. mTeleportData.clear();
  14. mTeleportLoc.clear();
  15.  
  16. // 0 1 2 3 4 5 6 7 8 9 10
  17. QueryResult_AutoPtr result = WorldDatabase.Query("SELECT entry, menu_parent, menu_sub, icon, faction, name, map, position_x, position_y, position_z, position_o "
  18. "FROM dynamic_teleporter ORDER BY entry");
  19.  
  20. if(!result)
  21. {
  22. barGoLink bar(1);
  23. bar.step();
  24.  
  25. sLog.outString();
  26. sLog.outString(">> Loaded 0 Dynamic Teleporter rows. DB table `dynamic_teleporter` is empty!");
  27. return false;
  28. }
  29.  
  30. barGoLink bar(result->GetRowCount());
  31.  
  32. uint32 counter = 0;
  33.  
  34. do
  35. {
  36. Field *fields = result->Fetch();
  37. bar.step();
  38.  
  39. TeleportData td;
  40. td.entry = fields[0].GetUInt32();
  41. td.menu_parent = fields[1].GetUInt32();
  42. td.menu_sub = fields[2].GetInt32();
  43. td.icon = fields[3].GetUInt8();
  44. td.faction = fields[4].GetUInt32();
  45. td.name = fields[5].GetString();
  46.  
  47. if(td.menu_sub < 0)
  48. {
  49. TeleportLoc tl;
  50. tl.map = fields[6].GetUInt32();
  51. tl.position_x = fields[7].GetFloat();
  52. tl.position_y = fields[8].GetFloat();
  53. tl.position_z = fields[9].GetFloat();
  54. tl.position_o = fields[10].GetFloat();
  55. mTeleportLoc[td.entry] = tl;
  56. }
  57.  
  58. mTeleportData[counter] = td;
  59. ++counter;
  60. } while(result->NextRow());
  61.  
  62. sLog.outString();
  63. sLog.outString(">> Loaded %u Dynamic Teleporter rows in %u ms", counter, getMSTimeDiff(oldMSTime, getMSTime()));
  64.  
  65. _IsLoaded = true;
  66. return true;
  67. }
  68.  
  69. void DynamicTeleportMgr::Update()
  70. {
  71. _IsLoaded = false;
  72. Init();
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement