mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
feat: Reward codes (#1308)
* 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 * newlines * include array * delete cascade * newline * address feedback
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user