-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement rep, rep group, and group ids, as well as polish more…
… of the client id functions.
- Loading branch information
Showing
22 changed files
with
630 additions
and
199 deletions.
There are no files selected for viewing
Submodule FLHookSDK
updated
from a6fa75 to a5b480
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
#pragma once | ||
//TODO: Reimplement DLL loader and De-loader | ||
// TODO: Reimplement DLL loader and De-loader | ||
namespace Hk::Chat | ||
{ | ||
DLL Action<void, Error> Msg(const std::variant<uint, std::wstring_view>& player, std::wstring_view message); | ||
DLL Action<void, Error> MsgS(const std::variant<std::wstring_view, uint>& system, std::wstring_view message); | ||
DLL Action<void, Error> MsgU(std::wstring_view message); | ||
DLL Action<void, Error> FMsgEncodeXml(std::wstring_view xml, char* buf, uint size, uint& ret); | ||
DLL Action<void, Error> FMsg(ClientId client, std::wstring_view xml); | ||
DLL Action<void, Error> FMsg(const std::variant<uint, std::wstring_view>& player, std::wstring_view XML); | ||
DLL Action<void, Error> FMsgS(const std::variant<std::wstring_view, uint>& system, std::wstring_view XML); | ||
DLL Action<void, Error> FMsgU(const std::wstring& xml); | ||
DLL std::wstring FormatMsg(MessageColor color, MessageFormat format, const std::wstring& msg); | ||
DLL std::wstring GetWStringFromIdS(uint idS); | ||
DLL Action<void, Error> FormatSendChat(uint toClientId, const std::wstring& sender, const std::wstring& text, const std::wstring& textColor); | ||
DLL void SendGroupChat(uint fromClientId, const std::wstring& text); | ||
DLL void SendLocalSystemChat(uint fromClientId, const std::wstring& text); | ||
DLL Action<void, Error> SendPrivateChat(uint fromClientId, uint toClientId, const std::wstring& text); | ||
DLL void SendSystemChat(uint fromClientId, const std::wstring& text); | ||
DLL void FMsgSendChat(ClientId client, char* buffer, uint size); | ||
// TODO: Move DLL loading and IDS accessing to its own class | ||
DLL void UnloadStringDLLs(); | ||
DLL void LoadStringDLLs(); | ||
} | ||
DLL Action<void, Error> Msg(const std::variant<uint, std::wstring_view>& player, std::wstring_view message); | ||
DLL Action<void, Error> MsgS(const std::variant<std::wstring_view, uint>& system, std::wstring_view message); | ||
DLL Action<void, Error> MsgU(std::wstring_view message); | ||
DLL Action<void, Error> FMsgEncodeXml(std::wstring_view xml, char* buf, uint size, uint& ret); | ||
DLL Action<void, Error> FMsg(ClientId client, std::wstring_view xml); | ||
DLL Action<void, Error> FMsg(const std::variant<uint, std::wstring_view>& player, std::wstring_view XML); | ||
DLL Action<void, Error> FMsgS(const std::variant<std::wstring_view, uint>& system, std::wstring_view XML); | ||
DLL Action<void, Error> FMsgU(const std::wstring& xml); | ||
DLL std::wstring FormatMsg(MessageColor color, MessageFormat format, const std::wstring& msg); | ||
DLL Action<void, Error> FormatSendChat(uint toClientId, const std::wstring& sender, const std::wstring& text, const std::wstring& textColor); | ||
DLL void SendGroupChat(uint fromClientId, const std::wstring& text); | ||
DLL void SendLocalSystemChat(uint fromClientId, const std::wstring& text); | ||
DLL Action<void, Error> SendPrivateChat(uint fromClientId, uint toClientId, const std::wstring& text); | ||
DLL void SendSystemChat(uint fromClientId, const std::wstring& text); | ||
DLL void FMsgSendChat(ClientId client, char* buffer, uint size); | ||
} // namespace Hk::Chat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
class GroupId final | ||
{ | ||
uint value = 0; | ||
|
||
Action<void, Error> ForEachGroupMember(const std::function<std::optional<Error>(ClientId client)>& func, bool stopIfErr = true) const; | ||
|
||
template <typename T, T> | ||
struct Proxy; | ||
|
||
template <typename T, typename R, typename... Args, R (T::*MemberFunc)(Args...)> | ||
struct Proxy<R (T::*)(Args...), MemberFunc> | ||
{ | ||
static R Call(T& obj, Args&&... args) { return (obj.*MemberFunc)(std::forward<Args>(args)...); } | ||
}; | ||
|
||
public: | ||
explicit GroupId(const uint val) : value(val) {} | ||
explicit GroupId() = default; | ||
~GroupId() = default; | ||
GroupId(const GroupId&) = default; | ||
GroupId& operator=(GroupId) = default; | ||
GroupId(GroupId&&) = default; | ||
GroupId& operator=(GroupId&&) = delete; | ||
|
||
bool operator==(const GroupId& next) const { return value == next.value; } | ||
explicit operator bool() const { return value != 0; } | ||
|
||
uint GetValue() const { return value; } | ||
|
||
Action<std::vector<ClientId>, Error> GetGroupMembers() const; | ||
Action<uint, Error> GetGroupSize() const; | ||
|
||
template <typename FunctionPtr, typename... Args> | ||
requires std::is_same_v<typename MemberFunctionPointerClassType<FunctionPtr>::type, ClientId> | ||
Action<void, Error> GroupAction(FunctionPtr ptr, bool stopIfErr, Args... args) const | ||
{ | ||
return ForEachGroupMember([ptr, args](ClientId client) { Proxy<void (ClientId::*)(), ptr>::Call(client, args...); }, stopIfErr); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
class RepGroupId final | ||
{ | ||
uint value = 0; | ||
|
||
public: | ||
explicit RepGroupId(const uint val) : value(val) {} | ||
explicit RepGroupId() = default; | ||
~RepGroupId() = default; | ||
RepGroupId(const RepGroupId&) = default; | ||
RepGroupId& operator=(RepGroupId) = delete; | ||
RepGroupId(RepGroupId&&) = default; | ||
RepGroupId& operator=(RepGroupId&&) = delete; | ||
|
||
bool operator==(const RepGroupId& next) const { return value == next.value; } | ||
explicit operator bool() const { return value != 0; }; | ||
|
||
uint GetValue() const { return value; } | ||
|
||
Action<std::wstring_view, Error> GetName() const; | ||
Action<std::wstring_view, Error> GetShortName() const; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
#include "RepGroupId.hpp" | ||
|
||
class RepId final | ||
{ | ||
int value = 0; | ||
|
||
public: | ||
explicit RepId(const ObjectId& spaceObj, bool isSolar); | ||
explicit RepId(const int val) : value(val) {} | ||
explicit RepId() = default; | ||
~RepId() = default; | ||
RepId(const RepId&) = default; | ||
RepId& operator=(RepId) = delete; | ||
RepId(RepId&&) = default; | ||
RepId& operator=(RepId&&) = delete; | ||
|
||
bool operator==(const RepId& next) const { return value == next.value; } | ||
explicit operator bool() const; | ||
|
||
int GetValue() const { return value; } | ||
|
||
Action<RepGroupId, Error> GetAffiliation() const; | ||
Action<float, Error> GetAttitudeTowardsRepId(const RepId& target) const; | ||
Action<float, Error> GetAttitudeTowardsFaction(const RepGroupId& group) const; | ||
Action<int, Error> GetRank() const; | ||
Action<std::pair<FmtStr, FmtStr>, Error> GetName() const; | ||
|
||
Action<void, Error> SetRank(int rank) const; | ||
Action<void, Error> SetAttitudeTowardsRepId(RepId target, float newAttitude) const; | ||
Action<void, Error> SetAffiliation(RepGroupId group) const; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,59 @@ | ||
#pragma once | ||
|
||
#include "ObjectId.hpp" | ||
|
||
class SystemId; | ||
#include "RepId.hpp" | ||
|
||
class ShipId final : ObjectId | ||
{ | ||
public: | ||
explicit ShipId(const uint val) : ObjectId(val) {} | ||
explicit ShipId() {} | ||
|
||
Action<CShipPtr, Error> GetCShip(bool increment) const; | ||
[[nodiscard]] | ||
Action<CShipPtr, Error> GetCShip(bool increment); | ||
Action<Archetype::Ship*, Error> GetShipArchetype(); | ||
Action<float,Error> GetHealth(bool percentage = false); | ||
st6::list<EquipDesc>& GetEquipment(); // TODO: We should define a lambda to make it easy for people to get Equip lists. | ||
Action<float,Error> GetShields(bool percentage = false); | ||
void* GetCargo(); // TODO: Similar to equipment but for cargo (duh). | ||
Action<float, Error> GetHealth(bool percentage = false); | ||
Action<float, Error> GetShields(bool percentage = false); | ||
void* GetNpcPersonality(); | ||
std::optional<ShipId> GetTarget(); | ||
Action<RepId, Error> GetReputation(); | ||
std::wstring GetAffiliation(); | ||
// TODO: AI states such as formation, go to, dock etc. | ||
Action<float,Error> GetSpeed(); | ||
Action<float, Error> GetSpeed(); | ||
|
||
bool IsPlayer(); | ||
bool IsNpc(); | ||
bool IsInTradeLane(); | ||
|
||
void Destroy(DestroyType type = DestroyType::Fuse); | ||
Action<void,Error> SetHealth(float amount, bool percentage = false); | ||
Action<void,Error> AddCargo(std::wstring good, int count, bool mission); | ||
Action<void, Error> SetHealth(float amount, bool percentage = false); | ||
Action<void, Error> AddCargo(uint good, uint count, bool mission); | ||
void SetEquip(const st6::list<EquipDesc>& equip); | ||
void AddEquip(uint goodId, const std::wstring& hardpoint); | ||
void Relocate(Vector, std::optional<Matrix> orientation); | ||
|
||
template <typename EquipType = CEquip> | ||
requires std::is_base_of_v<CEquip, EquipType> | ||
Action<std::list<EquipType*>, Error> GetEquipment(EquipmentClass equipmentType = EquipmentClass::All) | ||
{ | ||
auto ship = GetCShip(false).Unwrap(); | ||
if (!ship) | ||
{ | ||
return { cpp::fail(Error::InvalidShip) }; | ||
} | ||
|
||
CEquipTraverser traverser(equipmentType); | ||
CEquipManager* manager = GetEquipManager(ship.get()); | ||
CEquip* equip = manager->Traverse(traverser); | ||
|
||
std::list<EquipType*> equipment; | ||
|
||
while (equip) | ||
{ | ||
equipment.emplace_back(static_cast<EquipType*>(equip)); | ||
equip = manager->Traverse(traverser); | ||
} | ||
|
||
return { equipment }; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,7 +107,7 @@ struct BaseInfo | |
|
||
struct GroupMember | ||
{ | ||
ClientId client; | ||
uint client; | ||
std::wstring character; | ||
}; | ||
|
||
|
Oops, something went wrong.