Guest User

Untitled

a guest
May 25th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. Index: sql/0055_add_user_birthdate.sql
  2. ===================================================================
  3. --- sql/0055_add_user_birthdate.sql (revision 0)
  4. +++ sql/0055_add_user_birthdate.sql (revision 0)
  5. @@ -0,0 +1 @@
  6. +ALTER TABLE `users` ADD `birthdate` DATE NOT NULL DEFAULT '0000-00-00' AFTER `gm`;
  7. Index: src/LoginServer/Characters.cpp
  8. ===================================================================
  9. --- src/LoginServer/Characters.cpp (revision 1551)
  10. +++ src/LoginServer/Characters.cpp (working copy)
  11. @@ -193,36 +193,40 @@
  12. void Characters::deleteCharacter(PlayerLogin *player, PacketReader &packet) {
  13. int32_t data = packet.getInt();
  14. int32_t id = packet.getInt();
  15. -
  16. +
  17. if (!ownerCheck(player, id)) {
  18. // hacking
  19. return;
  20. }
  21.  
  22. - mysqlpp::Query query = Database::getCharDB().query();
  23. + if (data == player->getBirthdate()) {
  24. + mysqlpp::Query query = Database::getCharDB().query();
  25.  
  26. - query << "DELETE FROM characters WHERE id = " << id;
  27. - query.exec();
  28. + query << "DELETE FROM characters WHERE id = " << id;
  29. + query.exec();
  30.  
  31. - query << "DELETE FROM keymap WHERE charid = " << id;
  32. - query.exec();
  33. + query << "DELETE FROM keymap WHERE charid = " << id;
  34. + query.exec();
  35.  
  36. - query << "DELETE pets, items FROM pets LEFT JOIN items ON pets.id = items.petid WHERE items.charid = " << id;
  37. - query.exec();
  38. + query << "DELETE pets, items FROM pets LEFT JOIN items ON pets.id = items.petid WHERE items.charid = " << id;
  39. + query.exec();
  40.  
  41. - query << "DELETE FROM items WHERE charid = " << id;
  42. - query.exec();
  43. + query << "DELETE FROM items WHERE charid = " << id;
  44. + query.exec();
  45.  
  46. - query << "DELETE FROM skills WHERE charid = " << id;
  47. - query.exec();
  48. + query << "DELETE FROM skills WHERE charid = " << id;
  49. + query.exec();
  50.  
  51. - query << "DELETE FROM skillmacros WHERE charid = " << id;
  52. - query.exec();
  53. + query << "DELETE FROM skillmacros WHERE charid = " << id;
  54. + query.exec();
  55.  
  56. - query << "DELETE FROM character_variables WHERE charid = " << id;
  57. - query.exec();
  58. + query << "DELETE FROM character_variables WHERE charid = " << id;
  59. + query.exec();
  60.  
  61. - LoginPacket::deleteCharacter(player, id);
  62. + LoginPacket::deleteCharacter(player, id, true);
  63. + }
  64. + else
  65. + LoginPacket::deleteCharacter(player, id, false);
  66. }
  67.  
  68. void Characters::connectGame(PlayerLogin *player, int32_t charid) {
  69. Index: src/LoginServer/Login.cpp
  70. ===================================================================
  71. --- src/LoginServer/Login.cpp (revision 1551)
  72. +++ src/LoginServer/Login.cpp (working copy)
  73. @@ -38,7 +38,7 @@
  74. }
  75.  
  76. mysqlpp::Query query = Database::getCharDB().query();
  77. - query << "SELECT id, password, salt, online, pin, gender, ban_reason, ban_expire, (ban_expire > NOW()) as banned FROM users WHERE username = " << mysqlpp::quote << username << " LIMIT 1";
  78. + query << "SELECT id, password, salt, online, pin, gender, ban_reason, ban_expire, (ban_expire > NOW()) as banned, DATE_FORMAT(birthdate,'%Y%m%d') AS dob FROM users WHERE username = " << mysqlpp::quote << username << " LIMIT 1";
  79. mysqlpp::StoreQueryResult res = query.store();
  80.  
  81. bool valid = true;
  82. @@ -97,6 +97,8 @@
  83. player->setStatus(5);
  84. else
  85. player->setGender((uint8_t) res[0]["gender"]);
  86. +
  87. + player->setBirthdate((uint32_t) res[0]["dob"]);
  88. LoginPacket::loginConnect(player, username);
  89. }
  90. }
  91. Index: src/LoginServer/LoginPacket.cpp
  92. ===================================================================
  93. --- src/LoginServer/LoginPacket.cpp (revision 1551)
  94. +++ src/LoginServer/LoginPacket.cpp (working copy)
  95. @@ -201,11 +201,11 @@
  96. player->getSession()->send(packet);
  97. }
  98.  
  99. -void LoginPacket::deleteCharacter(PlayerLogin *player, int32_t ID) {
  100. +void LoginPacket::deleteCharacter(PlayerLogin *player, int32_t ID, bool success) {
  101. PacketCreator packet;
  102. packet.addShort(SEND_DELETE_CHAR);
  103. packet.addInt(ID);
  104. - packet.addByte(0);
  105. + packet.addByte((success ? 0x00 : 0x12));
  106. player->getSession()->send(packet);
  107. }
  108.  
  109. Index: src/LoginServer/LoginPacket.h
  110. ===================================================================
  111. --- src/LoginServer/LoginPacket.h (revision 1551)
  112. +++ src/LoginServer/LoginPacket.h (working copy)
  113. @@ -47,7 +47,7 @@
  114. void showCharacters(PlayerLogin *player, const vector<Character> &chars);
  115. void showCharacter(PlayerLogin *player, const Character &charc);
  116. void checkName(PlayerLogin *player, const string &name, bool taken);
  117. - void deleteCharacter(PlayerLogin *player, int32_t ID);
  118. + void deleteCharacter(PlayerLogin *player, int32_t ID, bool success);
  119. void connectIP(PlayerLogin *player, int32_t charid);
  120. void relogResponse(PlayerLogin *player);
  121. };
  122. Index: src/LoginServer/PlayerLogin.h
  123. ===================================================================
  124. --- src/LoginServer/PlayerLogin.h (revision 1551)
  125. +++ src/LoginServer/PlayerLogin.h (working copy)
  126. @@ -37,6 +37,7 @@
  127. void setUserid(int32_t id) { this->userid = id; }
  128. void setStatus(int32_t status) { this->status = status; }
  129. void setPin(int32_t pin) { this->pin = pin; }
  130. + void setBirthdate(int32_t birthdate) { this->birthdate = birthdate; }
  131.  
  132. int8_t getGender() const { return this->gender; }
  133. int8_t getWorld() const { return this->world; }
  134. @@ -45,6 +46,7 @@
  135. int32_t getStatus() const { return this->status; }
  136. int32_t getPin() const { return this->pin; }
  137. int32_t addInvalidLogin() { return ++invalid_logins; }
  138. + int32_t getBirthdate() { return this->birthdate; }
  139.  
  140. void setOnline(bool online);
  141. private:
  142. @@ -56,6 +58,7 @@
  143. int32_t pin;
  144. int32_t invalid_logins;
  145. bool checked_pin;
  146. + int32_t birthdate;
  147. };
  148.  
  149. class PlayerLoginFactory : public AbstractPlayerFactory {
Add Comment
Please, Sign In to add comment