HousingDB.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "../WorldDatabase.h"
  2. #include "../World.h"
  3. extern World world;
  4. void WorldDatabase::LoadHouseZones() {
  5. Query query;
  6. MYSQL_ROW row;
  7. MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT * FROM `houses`");
  8. if (result && mysql_num_rows(result) > 0) {
  9. while ((row = mysql_fetch_row(result))) {
  10. world.AddHouseZone(atoul(row[0]), row[1], atoi64(row[2]), atoul(row[3]), atoi64(row[4]), atoul(row[5]), atoi(row[6]), atoi(row[7]), atoi(row[8]), atoul(row[9]), atoul(row[10]), atof(row[11]), atof(row[12]), atof(row[13]), atof(row[14]));
  11. }
  12. }
  13. }
  14. int64 WorldDatabase::AddPlayerHouse(int32 char_id, int32 house_id, int32 instance_id, int32 upkeep_due) {
  15. Query query;
  16. string insert = string("INSERT INTO character_houses (char_id, house_id, instance_id, upkeep_due) VALUES (%u, %u, %u, %u) ");
  17. query.RunQuery2(Q_INSERT, insert.c_str(), char_id, house_id, instance_id, upkeep_due);
  18. int64 unique_id = query.GetLastInsertedID();
  19. return unique_id;
  20. }
  21. void WorldDatabase::RemovePlayerHouse(int32 char_id, int32 house_id) {
  22. }
  23. void WorldDatabase::LoadPlayerHouses() {
  24. Query query;
  25. MYSQL_ROW row;
  26. MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT h.id, h.char_id, h.house_id, h.instance_id, h.upkeep_due, h.escrow_coins, h.escrow_status, c.name FROM character_houses h, characters c WHERE h.char_id = c.id");
  27. if (result && mysql_num_rows(result) > 0) {
  28. while ((row = mysql_fetch_row(result))) {
  29. world.AddPlayerHouse(atoul(row[1]), atoul(row[2]), atoi64(row[0]), atoul(row[3]), atoul(row[4]), atoi64(row[5]), atoul(row[6]), row[7]);
  30. }
  31. }
  32. }