Files
metin2-server/src/server/common/point_drop.h
T
shenandshen 65db9fc365 feat: add account point rewards and extended item storage
Implement configurable kill rewards with account-wide daily limits, transactional deduplication, and game-to-db retries. Add the approved wide rules and tested isolation tooling.

Stage wear40 equipment and persistent extra item metadata with an explicit migration plan and client revision gate. Track all 168 remaining offers; sixteen have staged data/assets, while live acceptance and other systems remain incomplete. This commit is not a production deployment.
2026-10-19 18:30:19 -07:00

33 lines
1.4 KiB
C++

#pragma once
#include <stdint.h>
#include <algorithm>
#include <string>
// User-authorized extension. Chance uses basis points; zero disables that source.
struct PortPointDropRule {
int chance, minimum, maximum, minimumLevel, maximumOverlevel, dailyCap;
bool valid() const {
return chance >= 0 && chance <= 10000 && minimum >= 1 && maximum >= minimum &&
maximum <= 1000000 && minimumLevel >= 0 && maximumOverlevel >= 0 && dailyCap >= 0;
}
bool eligible(int targetLevel, int playerLevel) const {
return valid() && chance > 0 && targetLevel >= minimumLevel && playerLevel > 0 &&
(!maximumOverlevel || playerLevel - targetLevel <= maximumOverlevel);
}
};
template<class Lookup> PortPointDropRule PortPointRule(Lookup flag, bool stone) {
const std::string prefix = stone ? "points_stone_" : "points_mob_";
const int minimum = flag(prefix + "min");
const int maximum = flag(prefix + "max");
return {flag(prefix + "chance"), minimum ? minimum : 1,
maximum ? maximum : (minimum ? minimum : 1), flag("points_min_level"),
flag("points_max_overlevel"), flag("points_daily_cap")};
}
inline uint32_t PortPointDropAmount(uint32_t requested, uint64_t earned, uint32_t cap) {
if (!cap) return requested;
if (earned >= cap) return 0;
return static_cast<uint32_t>(std::min<uint64_t>(requested, cap - earned));
}