HousingDB.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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::SetHouseUpkeepDue(int32 char_id, int32 house_id, int32 instance_id, int32 upkeep_due) {
  22. Query query;
  23. string update = string("UPDATE character_houses set upkeep_due=%u where char_id = %u and house_id = %u and instance_id = %u");
  24. query.RunQuery2(Q_UPDATE, update.c_str(), upkeep_due, char_id, house_id, instance_id);
  25. }
  26. void WorldDatabase::RemovePlayerHouse(int32 char_id, int32 house_id) {
  27. }
  28. void WorldDatabase::LoadPlayerHouses() {
  29. Query query;
  30. MYSQL_ROW row;
  31. 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");
  32. if (result && mysql_num_rows(result) > 0) {
  33. while ((row = mysql_fetch_row(result))) {
  34. 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]);
  35. }
  36. }
  37. }