[Cleanup] Fix possible overflows in Client::AddPlatinum() and Client::TakePlatinum() (#3255)

# Notes
- Fix possible overflows by casting properly.
This commit is contained in:
Alex King 2023-04-05 10:10:33 -04:00 committed by GitHub
parent 2a094e8792
commit c1698a5bdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2222,7 +2222,7 @@ uint32 Client::GetCarriedPlatinum() {
bool Client::TakePlatinum(uint32 platinum, bool update_client) {
if (GetCarriedPlatinum() >= platinum) {
auto copper = static_cast<uint64>(platinum * 1000);
const auto copper = static_cast<uint64>(platinum) * 1000;
return TakeMoneyFromPP(copper, update_client);
}
@ -2316,7 +2316,7 @@ bool Client::TakeMoneyFromPP(uint64 copper, bool update_client) {
}
void Client::AddPlatinum(uint32 platinum, bool update_client) {
auto copper = static_cast<uint64>(platinum * 1000);
const auto copper = static_cast<uint64>(platinum) * 1000;
AddMoneyToPP(copper, update_client);
}