mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-03-28 23:50:02 +00:00
Nanocom Boosters and Authentic FM-Taro Scale Logic (#315)
* Groundwork for nanocom boosters * The item use handler now has a switch for multiple item types (currently gumballs, and a stub for boosters) * All item types are now checked for expiration, not just vehicles * implement nanocom booster helpers, save and expiry * implement authentic taro and fm modfication * magic number and code refactor * make sure only close by group members are counted * add safe taro fm handling, rate command, race and mission booster logic * add config option to disable authentic group scaling * rename for consistency * make rates percentages, fix chat message, add config options * add config option to the ini file * add index guard for hasBoost functions * reorder config ini options * add bank item expiry option * fix trade oversight --------- Co-authored-by: CakeLancelot <CakeLancelot@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "MobAI.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "TableData.hpp" // for flush()
|
||||
#include "Items.hpp" // for checkAndRemoveExpiredItems()
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -23,6 +24,7 @@ CNShardServer::CNShardServer(uint16_t p) {
|
||||
pHandler = &CNShardServer::handlePacket;
|
||||
REGISTER_SHARD_TIMER(keepAliveTimer, 4000);
|
||||
REGISTER_SHARD_TIMER(periodicSaveTimer, settings::DBSAVEINTERVAL*1000);
|
||||
REGISTER_SHARD_TIMER(periodicItemExpireTimer, 60000);
|
||||
init();
|
||||
|
||||
if (settings::MONITORENABLED)
|
||||
@@ -88,6 +90,22 @@ void CNShardServer::periodicSaveTimer(CNServer* serv, time_t currTime) {
|
||||
std::cout << "[INFO] Done." << std::endl;
|
||||
}
|
||||
|
||||
void CNShardServer::periodicItemExpireTimer(CNServer* serv, time_t currTime) {
|
||||
size_t playersWithExpiredItems = 0;
|
||||
size_t itemsRemoved = 0;
|
||||
|
||||
for (const auto& [sock, player] : PlayerManager::players) {
|
||||
// check and remove expired items
|
||||
size_t removed = Items::checkAndRemoveExpiredItems(sock, player);
|
||||
itemsRemoved += removed;
|
||||
playersWithExpiredItems += (removed == 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
if (playersWithExpiredItems > 0) {
|
||||
std::cout << "[INFO] Removed " << itemsRemoved << " expired items from " << playersWithExpiredItems << " players." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool CNShardServer::checkExtraSockets(int i) {
|
||||
return Monitor::acceptConnection(fds[i].fd, fds[i].revents);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ private:
|
||||
|
||||
static void keepAliveTimer(CNServer*, time_t);
|
||||
static void periodicSaveTimer(CNServer* serv, time_t currTime);
|
||||
static void periodicItemExpireTimer(CNServer* serv, time_t currTime);
|
||||
|
||||
public:
|
||||
static std::map<uint32_t, PacketHandler> ShardPackets;
|
||||
|
||||
Reference in New Issue
Block a user