Skip to content

Commit

Permalink
Almost get everything compiling, fix formatting errors,
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazrius committed Nov 17, 2023
1 parent e646516 commit 0666449
Show file tree
Hide file tree
Showing 41 changed files with 269 additions and 278 deletions.
2 changes: 1 addition & 1 deletion FLHookSDK
12 changes: 6 additions & 6 deletions include/API/FLHook/Plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class DLL Plugin
Aft(void, OnSpRequestInvincibility, (ClientId client, ShipId shipId, bool enable, InvincibilityReason reason));
Aft(void, OnRequestEvent, (ClientId client, int eventType, ShipId ship, ObjectId dockTarget, uint unk1, uint unk2));
Aft(void, OnRequestCancel, (ClientId client, int eventType, ShipId ship, ObjectId dockTarget, uint unk1));
Aft(void, OnMineAsteroid, (ClientId client, SystemId system, const Vector& pos, ObjectId crateId, ObjectId lootId, uint count));
Aft(void, OnMineAsteroid, (ClientId client, SystemId system, const Vector& pos, ArchId crateId, ArchId lootId, uint count));
Aft(void, OnRequestCreateShip, (ClientId client));
Aft(void, OnSetManeuver, (ClientId client, const XSetManeuver& maneuver));
Aft(void, OnInterfaceItemUsed, (uint unk1, uint unk2));
Expand All @@ -202,7 +202,7 @@ class DLL Plugin
Aft(void, OnSetVisitedState, (ClientId client, uint objectHash, int state));
Aft(void, OnRequestBestPath, (ClientId client, uint unk1, int unk2));
Aft(void, OnRequestPlayerStats, (ClientId id, uint unk1, int unk2));
Aft(void, OnPopupDialogueConfirm, (ClientId client, uint buttonClicked));
Aft(void, OnPopupDialogueConfirm, (ClientId client, PopupDialog buttonClicked));
Aft(void, OnRequestGroupPositions, (ClientId client, uint unk1, int unk2));
Aft(void, OnSetInterfaceState, (ClientId client, uint unk1, int unk2));
Aft(void, OnRequestRankLevel, (ClientId client, uint unk1, int unk2));
Expand Down Expand Up @@ -263,11 +263,11 @@ class DLL PacketInterface

#undef Aft

#define SetupPlugin(type, info) \
EXPORT std::shared_ptr<type> PluginFactory() \
{ \
#define SetupPlugin(type, info) \
EXPORT std::shared_ptr<type> PluginFactory() \
{ \
__pragma(comment(linker, "/EXPORT:" __FUNCTION "=" __FUNCDNAME)); \
return std::move(std::make_shared<type>(info)); \
return std::move(std::make_shared<type>(info)); \
}

#define AddPluginTimer(func, time) AddTimer(static_cast<void (Plugin::*)()>(func), time)
7 changes: 4 additions & 3 deletions include/API/Types/BaseId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class BaseId
};

template <>
struct std::formatter<BaseId> : std::formatter<uint>
struct std::formatter<BaseId, wchar_t>
{
auto format(const BaseId &value, std::format_context &ctx) { return std::formatter<uint>::format(value.GetValue(), ctx); }
};
constexpr auto parse(std::wformat_parse_context &ctx) { return ctx.begin(); }
auto format(const BaseId &value, std::wformat_context &ctx) { return std::format_to(ctx.out(), L"{}", value.GetValue()); }
};
17 changes: 9 additions & 8 deletions include/API/Types/ClientId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "API/Types/ShipId.hpp"
#include "API/Types/SystemId.hpp"

#include <string>
#include <format>
#include <string>

class ShipId;
struct ClientData;
Expand All @@ -29,8 +29,9 @@ class ClientId
public:
explicit ClientId(const uint val) : value(val) {}
explicit ClientId(const SpecialChatIds id) { value = static_cast<const uint>(id); }
explicit ClientId(const std::wstring_view str) : value(GetClientIdFromCharacterName(str)){}
explicit ClientId(const std::wstring_view str) : value(GetClientIdFromCharacterName(str)) {}
explicit ClientId() = default;
ClientId(const ClientId &client) : value(client.value){};

explicit operator uint() const noexcept { return value; }
bool operator==(const ClientId next) const { return value == next.value; }
Expand Down Expand Up @@ -93,7 +94,7 @@ class ClientId
[[nodiscard]]
Action<ShipId, Error> GetShipId() const;

//TODO: Implement.
// TODO: Implement.
Action<uint, Error> GetLatency() const;

/**
Expand Down Expand Up @@ -325,14 +326,14 @@ class ClientId
* @returns On success : void
* @returns On fail : InCharacterSelect, UnknownError (when packet sending fails).
*/
Action<void, Error> SetEquip(const st6::list<EquipDesc> &equip);
Action<void, Error> SetEquip(const st6::list<EquipDesc> &equip) const;

Action<void, Error> AddEquip(uint goodId, const std::wstring &hardpoint) const;
};


template <>
struct std::formatter<ClientId> : std::formatter<uint>
struct std::formatter<ClientId, wchar_t>
{
auto format(const ClientId &client, std::format_context &ctx) { return std::formatter<uint>::format(client.GetValue(), ctx); }
};
constexpr auto parse(std::wformat_parse_context &ctx) { return ctx.begin(); }
auto format(const ClientId &client, std::wformat_context &ctx) { return std::format_to(ctx.out(), L"{}", client.GetValue()); }
};
5 changes: 3 additions & 2 deletions include/API/Types/EquipmentId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class EquipmentId
};

template <>
struct std::formatter<EquipmentId> : std::formatter<uint>
struct std::formatter<EquipmentId, wchar_t>
{
auto format(const EquipmentId &value, std::format_context &ctx) { return std::formatter<uint>::format(value.GetValue(), ctx); }
constexpr auto parse(std::wformat_parse_context &ctx) { return ctx.begin(); }
auto format(const EquipmentId &value, std::wformat_context &ctx) { return std::format_to(ctx.out(), L"{}", value.GetValue()); }
};
7 changes: 4 additions & 3 deletions include/API/Types/GroupId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class GroupId final
};

template <>
struct std::formatter<GroupId> : std::formatter<uint>
struct std::formatter<GroupId, wchar_t>
{
auto format(const GroupId& value, std::format_context& ctx) { return std::formatter<uint>::format(value.GetValue(), ctx); }
};
constexpr auto parse(std::wformat_parse_context& ctx) { return ctx.begin(); }
auto format(const GroupId& value, std::wformat_context& ctx) { return std::format_to(ctx.out(), L"{}", value.GetValue()); }
};
12 changes: 4 additions & 8 deletions include/API/Types/ObjectId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@ class ObjectId

public:
explicit ObjectId(const uint val) : value(val) {}
ObjectId(const ObjectId& obj) : value(obj.value) {}
explicit ObjectId() = default;
virtual ~ObjectId() = default;
ObjectId& operator=(const ObjectId& obj)
{
value = obj.GetValue();
return *this;
}

explicit operator uint() const noexcept { return value; }
bool operator==(const ObjectId& next) const { return value == next.value; }
explicit virtual operator bool() const;

Expand Down Expand Up @@ -49,7 +44,8 @@ class ObjectId
};

template <>
struct std::formatter<ObjectId> : std::formatter<uint>
struct std::formatter<ObjectId, wchar_t>
{
auto format(const ObjectId& value, std::format_context& ctx) { return std::formatter<uint>::format(value.GetValue(), ctx); }
constexpr auto parse(std::wformat_parse_context& ctx) { return ctx.begin(); }
auto format(const ObjectId& value, std::wformat_context& ctx) { return std::format_to(ctx.out(), L"{}", value.GetValue()); }
};
8 changes: 4 additions & 4 deletions include/API/Types/RepGroupId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RepGroupId final
public:
explicit RepGroupId(const uint val) : value(val) {}
explicit RepGroupId(std::wstring_view nickName);

explicit RepGroupId() = default;
~RepGroupId() = default;
RepGroupId(const RepGroupId&) = default;
Expand All @@ -25,11 +25,11 @@ class RepGroupId final
Action<std::wstring_view, Error> GetName() const;
Action<std::wstring_view, Error> GetShortName() const;
Action<float, Error> GetAttitudeTowardsRepId(RepId target) const;

};

template <>
struct std::formatter<RepGroupId> : std::formatter<uint>
struct std::formatter<RepGroupId, wchar_t>
{
auto format(const RepGroupId& value, std::format_context& ctx) { return std::formatter<uint>::format(value.GetValue(), ctx); }
constexpr auto parse(std::wformat_parse_context& ctx) { return ctx.begin(); }
auto format(const RepGroupId& value, std::wformat_context& ctx) { return std::format_to(ctx.out(), L"{}", value.GetValue()); }
};
5 changes: 3 additions & 2 deletions include/API/Types/RepId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class RepId final
};

template <>
struct std::formatter<RepId> : std::formatter<uint>
struct std::formatter<RepId, wchar_t>
{
auto format(const RepId& value, std::format_context& ctx) { return std::formatter<uint>::format(value.GetValue(), ctx); }
constexpr auto parse(std::wformat_parse_context& ctx) { return ctx.begin(); }
auto format(const RepId& value, std::wformat_context& ctx) { return std::format_to(ctx.out(), L"{}", value.GetValue()); }
};
8 changes: 5 additions & 3 deletions include/API/Types/ShipId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class ShipId final : public ObjectId
public:
explicit ShipId(const uint val) : ObjectId(val) {}
explicit ShipId() = default;
explicit ShipId(const ShipId& id) : ObjectId(id.GetValue()) {}

~ShipId() override = default;

[[nodiscard]]
Action<CShipPtr, Error> GetCShip(bool increment);
Expand Down Expand Up @@ -61,7 +62,8 @@ class ShipId final : public ObjectId
};

template <>
struct std::formatter<ShipId> : std::formatter<uint>
struct std::formatter<ShipId, wchar_t>
{
auto format(const ShipId& value, std::format_context& ctx) { return std::formatter<uint>::format(value.GetValue(), ctx); }
constexpr auto parse(std::wformat_parse_context& ctx) { return ctx.begin(); }
auto format(const ShipId& value, std::wformat_context& ctx) { return std::format_to(ctx.out(), L"{}", value.GetValue()); }
};
11 changes: 6 additions & 5 deletions include/API/Types/SystemId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class SystemId
public:
explicit SystemId(const uint val) : value(val) {}

explicit SystemId(std::wstring_view nickName, bool isInfoCardName = false);
explicit SystemId(std::wstring_view nickName, bool isInfoCardName = false);

explicit SystemId() : value(0) {}
bool operator==(const SystemId next) const { return value == next.value; }
explicit operator bool() const;
Expand All @@ -34,7 +34,8 @@ class SystemId
};

template <>
struct std::formatter<SystemId> : std::formatter<uint>
struct std::formatter<SystemId, wchar_t>
{
auto format(const SystemId &value, std::format_context &ctx) { return std::formatter<uint>::format(value.GetValue(), ctx); }
};
constexpr auto parse(std::wformat_parse_context &ctx) { return ctx.begin(); }
auto format(const SystemId &value, std::wformat_context &ctx) { return std::format_to(ctx.out(), L"{}", value.GetValue()); }
};
22 changes: 11 additions & 11 deletions include/Core/ClientServerInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class IServerImplHook
static bool __stdcall Startup(SStartupInfo& si);

// JumpInComplete.cpp
static void __stdcall JumpInComplete(uint systemId, uint shipId);
static void __stdcall JumpInComplete(SystemId systemId, ShipId shipId);

// LaunchComplete.cpp
static void __stdcall LaunchComplete(uint baseId, uint shipId);
static void __stdcall LaunchComplete(BaseId baseId, ShipId shipId);

// Location.cpp
static void __stdcall SetVisitedState(ClientId client, uint objHash, int state);
Expand All @@ -101,7 +101,7 @@ class IServerImplHook
static void __stdcall SetManeuver(ClientId client, const XSetManeuver& sm);

// MineAsteroid.cpp
static void __stdcall MineAsteroid(uint systemId, const Vector& pos, uint crateId, uint lootId, uint count, ClientId client);
static void __stdcall MineAsteroid(SystemId systemId, const Vector& pos, ArchId crateId, ArchId lootId, uint count, ClientId client);

// Mission.cpp
static void __stdcall AbortMission(ClientId client, uint unk1);
Expand All @@ -121,42 +121,42 @@ class IServerImplHook
static void __stdcall OnConnect(ClientId client);

// PlayerLaunch.cpp
static void __stdcall PlayerLaunch(uint shipId, ClientId client);
static void __stdcall PlayerLaunch(ShipId shipId, ClientId client);

// Ship.cpp
static void __stdcall RequestCreateShip(ClientId client);
static void __stdcall ReqCollisionGroups(const st6::list<CollisionGroupDesc>& collisionGroups, ClientId client);
static void __stdcall ReqShipArch(uint archId, ClientId client);
static void __stdcall ReqHullStatus(float status, ClientId client);
static void __stdcall SpRequestInvincibility(uint shipId, bool enable, InvincibilityReason reason, ClientId client);
static void __stdcall SpRequestInvincibility(ShipId shipId, bool enable, InvincibilityReason reason, ClientId client);

// SpObjectUpdate.cpp
static void __stdcall SpObjUpdate(const SSPObjUpdateInfo& ui, ClientId client);

// SystemSwitchOutComplete.cpp
static void __stdcall SystemSwitchOutComplete(uint shipId, ClientId client);
static void __stdcall SystemSwitchOutComplete(ShipId shipId, ClientId client);

// Trade.cpp
static void __stdcall InitiateTrade(ClientId client1, ClientId client2);
static void __stdcall AcceptTrade(ClientId client, bool unk1);
static void __stdcall SetTradeMoney(ClientId client, ulong unk1);
static void __stdcall AddTradeEquip(ClientId client, const EquipDesc& ed);
static void __stdcall DelTradeEquip(ClientId client, const EquipDesc& ed);
static void __stdcall RequestTrade(uint unk1, uint unk2);
static void __stdcall RequestTrade(ClientId client1, ClientId client2);
static void __stdcall StopTradeRequest(ClientId client);
static void __stdcall TradeResponse(const unsigned char* unk1, int unk2, ClientId client);
static void __stdcall TerminateTrade(ClientId client, int accepted);

// Tradelane.cpp
static void __stdcall GoTradelane(ClientId client, const XGoTradelane& gt);
static void __stdcall StopTradelane(ClientId client, uint shipId, uint tradelaneRing1, uint tradelaneRing2);
static void __stdcall StopTradelane(ClientId client, ShipId shipId, ObjectId tradelaneRing1, ObjectId tradelaneRing2);

// UserInterface.cpp
static void __stdcall Hail(unsigned int unk1, unsigned int unk2, unsigned int unk3);
static void __stdcall RequestEvent(int eventType, uint shipId, uint dockTarget, uint unk1, ulong unk2, ClientId client);
static void __stdcall RequestCancel(int eventType, uint shipId, uint unk1, ulong unk2, ClientId client);
static void __stdcall RequestEvent(int eventType, ShipId shipId, ObjectId dockTarget, uint unk1, ulong unk2, ClientId client);
static void __stdcall RequestCancel(int eventType, ShipId shipId, ObjectId dockTarget, ulong unk2, ClientId client);
static void __stdcall InterfaceItemUsed(uint unk1, uint unk2);
static void __stdcall PopupDialog(ClientId client, uint buttonClicked);
static void __stdcall PopupDialog(ClientId client, PopupDialog buttonClicked);
static void __stdcall SetInterfaceState(ClientId client, uint unk1, int unk2);
static void __stdcall RequestGroupPositions(ClientId client, uint unk1, int unk2);
static void __stdcall SetTarget(ClientId client, const XSetTarget& st);
Expand Down
2 changes: 1 addition & 1 deletion include/Core/IEngineHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ class IEngineHook
static void __stdcall AddDamageEntry(DamageList* dmgList, unsigned short subObjId, float hitPts, DamageEntry::SubObjFate fate);
static void __stdcall NonGunWeaponHitsBaseBefore(const char* ECX, const char* p1, const DamageList* dmg);
static int __stdcall DisconnectPacketSent(ClientId client);
static void SendDeathMessage(const std::wstring& msg, uint systemId, ClientId clientVictim, ClientId clientKiller);
static void SendDeathMessage(const std::wstring& msg, SystemId systemId, ClientId clientVictim, ClientId clientKiller);
static void __stdcall ShipDestroyed(DamageList* dmgList, DWORD* ecx, uint kill);
};
3 changes: 2 additions & 1 deletion source/API/Types/BaseId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Action<std::pair<std::wstring_view, std::wstring_view>, Error> BaseId::GetDescri
ValidBaseCheck;

// TODO: Get internal description of base
return { {} };
}

Action<std::vector<uint>, Error> BaseId::GetItemsForSale() const
Expand Down Expand Up @@ -158,4 +159,4 @@ Action<std::vector<ClientId>, Error> BaseId::GetDockedPlayers()
}

return { players };
}
}
10 changes: 5 additions & 5 deletions source/API/Types/ClientId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ Action<std::wstring, Error> ClientId::GetPlayerIp() const
push eax
lea eax, sizeOfIp
push eax
lea eax, wIP
lea eax, wIp
push eax
lea eax, hostname
push eax
Expand Down Expand Up @@ -461,7 +461,7 @@ Action<void, Error> ClientId::SaveChar() const
const auto& data = FLHook::Clients()[value];

// Save account data
auto dir = GetAccount().Unwrap().GetDirectoryName();
auto dir = GetAccount().Unwrap().GetDirectoryName().Unwrap();
const std::wstring userFile = std::format(L"{}{}\\accData.json", FLHook::GetAccountPath(), dir);

const auto content = data.accountData.dump(4);
Expand All @@ -486,8 +486,8 @@ Action<void, Error> ClientId::SetCash(uint amount) const
ClientCheck;
CharSelectCheck;



// TODO: Implement me!
return { {} };
}

Action<void, Error> ClientId::AddCash(const uint amount) const { return AdjustCash(static_cast<int>(amount)); }
Expand Down Expand Up @@ -619,7 +619,7 @@ Action<void, Error> ClientId::MessageFrom(ClientId destinationClient, std::wstri
return { {} };
}

void ClientId::SetEquip(const st6::list<EquipDesc>& equip)
Action<void, Error> ClientId::SetEquip(const st6::list<EquipDesc>& equip) const
{
ClientCheck;
CharSelectCheck;
Expand Down
2 changes: 2 additions & 0 deletions source/API/Types/GroupId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Action<void, Error> GroupId::InviteMember(ClientId client)
}

group->AddInvite(client.GetValue());
return { {} };
}

Action<void, Error> GroupId::AddMember(ClientId client)
Expand All @@ -67,4 +68,5 @@ Action<void, Error> GroupId::AddMember(ClientId client)
}

group->AddMember(client.GetValue());
return { {} };
}
2 changes: 1 addition & 1 deletion source/API/Types/ShipId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void ShipId::Relocate(const Vector& pos, const std::optional<Matrix>& orientatio
}

const auto system = GetSystem().Unwrap();
pub::SpaceObj::Relocate(value, system.GetValue(), pos, orientation.value_or(glm::mat3()));
pub::SpaceObj::Relocate(value, system.GetValue(), pos, orientation.value_or(Matrix::Identity()));
}

Action<void, Error> ShipId::IgniteFuse(uint fuseId, float id) const
Expand Down
Loading

0 comments on commit 0666449

Please sign in to comment.