Skip to content

Commit

Permalink
refact: Updated Betting to 4.1 Plugin API,
Browse files Browse the repository at this point in the history
fix: Arena properly serializes its config. TODO: When charfile databasing is implemented implement the Autobuy Stringutils.
  • Loading branch information
MrNen committed Aug 21, 2023
1 parent 92a8c54 commit 3c0f134
Show file tree
Hide file tree
Showing 9 changed files with 517 additions and 508 deletions.
1 change: 1 addition & 0 deletions include/API/API.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
#include "API/FLServer/ZoneUtilities.hpp"

#include "API/FLHook/MailManager.hpp"
#include "API/Utils/IniUtils.hpp"
3 changes: 3 additions & 0 deletions plugins/arena/Arena.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ namespace Plugins
std::string targetBase;
std::string targetSystem;
std::string restrictedSystem;

Serialize(Config, targetBase, targetSystem, restrictedSystem);
};

std::unique_ptr<Config> config;
// Non-reflectable fields
uint targetBaseId = 0;
Expand Down
19 changes: 13 additions & 6 deletions plugins/autobuy/Autobuy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,23 @@

namespace Plugins
{



void Autobuy::LoadPlayerAutobuy(ClientId client)
{

//TODO: Implement chardata database retrieval for this as IniUtils is being deprecated for 4.1
AutobuyInfo playerAutobuyInfo{};
/*
playerAutobuyInfo.missiles = StringUtils::Cast<bool>(Hk::IniUtils::c()->GetFromPlayerFile(client, L"autobuy.missiles").value());
playerAutobuyInfo.torps = StringUtils::Cast<bool>(Hk::IniUtils::c()->GetFromPlayerFile(client, L"autobuy.torps").value());
playerAutobuyInfo.cd = StringUtils::Cast<bool>(Hk::IniUtils::c()->GetFromPlayerFile(client, L"autobuy.cd").value());
playerAutobuyInfo.cm = StringUtils::Cast<bool>(Hk::IniUtils::c()->GetFromPlayerFile(client, L"autobuy.cm").value());
playerAutobuyInfo.bb = StringUtils::Cast<bool>(Hk::IniUtils::c()->GetFromPlayerFile(client, L"autobuy.bb").value());
playerAutobuyInfo.repairs = StringUtils::Cast<bool>(Hk::IniUtils::c()->GetFromPlayerFile(client, L"autobuy.repairs").value());
autobuyInfo[client] = playerAutobuyInfo;
*/
}

void Autobuy::ClearClientInfo(ClientId& client) { autobuyInfo.erase(client); }
Expand Down Expand Up @@ -109,9 +116,9 @@ namespace Plugins

auto& equip = Players[client].equipDescList.equip;

if (&equip != &Players[client].lShadowEquipDescList.equip)
if (&equip != &Players[client].shadowEquipDescList.equip)
{
Players[client].lShadowEquipDescList.equip = equip;
Players[client].shadowEquipDescList.equip = equip;
}

st6::vector<EquipDesc> eqVector;
Expand All @@ -127,12 +134,12 @@ namespace Plugins
HookClient->Send_FLPACKET_SERVER_SETEQUIPMENT(client, eqVector);
}

if (auto& playerCollision = Players[client].collisionGroupDesc.data; !playerCollision.empty())
if (auto& playerCollision = Players[client].collisionGroupDesc; !playerCollision.empty())
{
st6::list<XCollision> componentList;
for (auto& colGrp : playerCollision)
{
auto* newColGrp = reinterpret_cast<XCollision*>(colGrp.data);
auto* newColGrp = reinterpret_cast<XCollision*>(colGrp);
newColGrp->componentHp = 1.0f;
componentList.push_back(*newColGrp);
}
Expand Down Expand Up @@ -185,9 +192,9 @@ namespace Plugins
// shield bats & nanobots

uint nanobotsId;
pub::GetGoodID(nanobotsId, config->nanobot_nickname.c_str());
pub::GetGoodID(nanobotsId, config->nanobotNickname.c_str());
uint shieldBatsId;
pub::GetGoodID(shieldBatsId, config->shield_battery_nickname.c_str());
pub::GetGoodID(shieldBatsId, config->shieldBatteryNickname.c_str());
bool nanobotsFound = false;
bool shieldBattsFound = false;
for (auto& item : cargo)
Expand Down
8 changes: 5 additions & 3 deletions plugins/autobuy/Autobuy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ namespace Plugins
};

//! Configurable fields for this plugin
struct Config
struct Config final
{
// Reflectable fields
//! Nickname of the nanobot item being used when performing the automatic purchase
std::string nanobot_nickname = "ge_s_repair_01";
std::string nanobotNickname = "ge_s_repair_01";
//! Nickname of the shield battery item being used when performing the automatic purchase
std::string shield_battery_nickname = "ge_s_battery_01";
std::string shieldBatteryNickname = "ge_s_battery_01";

Serialize(Config, nanobotNickname, shieldBatteryNickname);
};

void UserCmdAutobuy(std::wstring_view autobuyType, std::wstring_view newState);
Expand Down
Loading

0 comments on commit 3c0f134

Please sign in to comment.