feat: reward codes

this is for giving rewards across characters as the did in live.
Tested that the default config works
Tested that all claim codes work
Tested that saving and loading claim codes work
Tested that mail sends correctly
This commit is contained in:
Aaron Kimbre
2023-11-19 01:28:07 -06:00
parent 8e84cafdfa
commit 138dc0fab6
19 changed files with 219 additions and 8 deletions

View File

@@ -29,6 +29,22 @@
#include "eMasterMessageType.h"
#include "eGameMasterLevel.h"
namespace {
std::vector<uint32_t> claimCodes;
}
void AuthPackets::LoadClaimCodes() {
if(!claimCodes.empty()) return;
auto rcstring = Game::config->GetValue("rewardcodes");
auto codestrings = GeneralUtils::SplitString(rcstring, ',');
for(auto const &codestring: codestrings){
uint32_t code = -1;
if(GeneralUtils::TryParse(codestring, code) && code != -1){
claimCodes.push_back(code);
}
}
}
void AuthPackets::HandleHandshake(dServer* server, Packet* packet) {
RakNet::BitStream inStream(packet->data, packet->length, false);
uint64_t header = inStream.Read(header);
@@ -129,6 +145,10 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username);
});
}
for(auto const code: claimCodes){
Database::Get()->InsertRewardCode(accountInfo->id, code);
}
}
void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username) {

View File

@@ -15,6 +15,8 @@ namespace AuthPackets {
void HandleLoginRequest(dServer* server, Packet* packet);
void SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username);
void LoadClaimCodes();
}
#endif // AUTHPACKETS_H