AltAdvancementDB.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifdef WIN32
  17. #include <WinSock2.h>
  18. #include <windows.h>
  19. #endif
  20. #include <mysql.h>
  21. #include <assert.h>
  22. #include "../../common/Log.h"
  23. #include "../../common/DatabaseNew.h"
  24. #include "../WorldDatabase.h"
  25. #include "AltAdvancement.h"
  26. extern MasterAAList master_aa_list;
  27. extern MasterAANodeList master_tree_nodes;
  28. void WorldDatabase::LoadAltAdvancements()
  29. {
  30. Query query;
  31. MYSQL_ROW row;
  32. AltAdvanceData* data;
  33. //MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT `spell_id`, `group`, `icon`, `icon2`, `col`, `row`, `rank_cost`, `max_cost`, `rank_prereq_id`, `rank_prereq`, `class_req`, `tier`, `class_name`, `subclass_name`, `line_title` FROM spell_aa");
  34. MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT `nodeid`,`minlevel`, `spellcrc`, `name`, `description`, `aa_list_fk`, `icon_id`, `icon_backdrop`, `xcoord`, `ycoord`, `pointspertier`, `maxtier`, `firstparentid`, `firstparentrequiredtier`, `displayedclassification`,`requiredclassification`, `classificationpointsrequired`, `pointsspentintreetounlock`, `title`,`titlelevel` FROM spell_aa_nodelist");
  35. while (result && (row = mysql_fetch_row(result))) {
  36. data = new AltAdvanceData;
  37. int8 i = 0;
  38. data->spellID = strtoul(row[0], NULL, 0);
  39. data->min_level = atoi(row[++i]);
  40. data->spell_crc = strtoul(row[++i], NULL, 0);
  41. data->name = string(row[++i]);
  42. data->description = string(row[++i]);
  43. data->group = atoi(row[++i]);
  44. data->icon = atoi(row[++i]);
  45. data->icon2 = atoi(row[++i]);
  46. data->col = atoi(row[++i]);
  47. data->row = atoi(row[++i]);
  48. data->rankCost = atoi(row[++i]);
  49. data->maxRank = atoi(row[++i]);
  50. data->rankPrereqID = strtoul(row[++i], NULL, 0);
  51. data->rankPrereq = atoi(row[++i]);
  52. data->tier = 1;
  53. data->class_name = string(row[++i]);
  54. data->subclass_name = string(row[i]);
  55. data->req_points = atoi(row[++i]);
  56. data->req_tree_points = atoi(row[++i]);
  57. data->line_title = string(row[++i]);
  58. data->title_level = atoi(row[++i]);
  59. master_aa_list.AddAltAdvancement(data);
  60. }
  61. LogWrite(SPELL__INFO, 0, "AA", "Loaded %u Alternate Advancement(s)", master_aa_list.Size());
  62. }
  63. void WorldDatabase::LoadTreeNodes()
  64. {
  65. Query query;
  66. MYSQL_ROW row;
  67. TreeNodeData* data;
  68. MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT class_id, tree_node, aa_tree_id FROM spell_aa_class_list");
  69. while (result && (row = mysql_fetch_row(result))) {
  70. data = new TreeNodeData;
  71. data->classID = strtoul(row[0], NULL, 0);
  72. data->treeID = strtoul(row[1], NULL, 0);
  73. data->AAtreeID = strtoul(row[2], NULL, 0);
  74. master_tree_nodes.AddTreeNode(data);
  75. }
  76. LogWrite(SPELL__INFO, 0, "AA", "Loaded %u AA Tree Nodes", master_tree_nodes.Size());
  77. }
  78. void WorldDatabase::LoadPlayerAA(Player *player)
  79. {
  80. Query query;
  81. MYSQL_ROW row;
  82. MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT `template_id`,`tab_id`,`aa_id`,`order`,treeid FROM character_aa where char_id = %i order by `order`",player->id);
  83. while (result && (row = mysql_fetch_row(result))) {
  84. }
  85. LogWrite(SPELL__INFO, 0, "AA", "Loaded %u AA Tree Nodes", master_tree_nodes.Size());
  86. }