Skip to content

Commit

Permalink
refactor: make clang-cl compilable
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Oct 13, 2023
1 parent 127690d commit c8785e4
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 29 deletions.
2 changes: 2 additions & 0 deletions src/ll/api/base/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#pragma warning(disable : 4250)
#pragma warning(disable : 4949)

#pragma clang diagnostic ignored "-Wpragma-system-header-outside-header"

#include "ll/api/base/Macro.h"
#include "mc/_HeaderOutputPredefine.h"

Expand Down
4 changes: 2 additions & 2 deletions src/ll/api/service/GlobalService.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class GlobalService {
T* value = nullptr;

public:
GlobalService();
void init(T* ptr);
LLAPI GlobalService();
void init(T* ptr);

T* get() { return value; }
T* operator->() { return value; }
Expand Down
2 changes: 1 addition & 1 deletion src/ll/core/form/FormHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ll::form::handler {

void SimpleFormHandler::handle(Player& player, std::string const& data) const {
int selected = data != "null" ? stoi(data) : -1;
if (selected >= 0 && selected < mButtonCallbacks.size()) {
if (selected >= 0 && selected < (int)mButtonCallbacks.size()) {
if (mButtonCallbacks[selected]) { mButtonCallbacks[selected](player); }
}
if (mCallback) { mCallback(player, selected); }
Expand Down
2 changes: 2 additions & 0 deletions src/mc/_HeaderOutputPredefine.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#pragma clang diagnostic ignored "-Wignored-qualifiers"

#pragma warning(disable : 4099)
#pragma warning(disable : 4201)

Expand Down
1 change: 1 addition & 0 deletions src/mc/deps/core/common/bedrock/typeid_t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "mc/deps/core/common/bedrock/typeid_t.h"
#include "mc/server/commands/CommandRegistry.h"

template <>
std::atomic_ushort& Bedrock::typeid_t<CommandRegistry>::_getCounter() {
return *(std::atomic_ushort*)LL_RESOLVE_SYMBOL(
"?storage@?1??_getCounter@?$typeid_t@VCommandRegistry@@@Bedrock@@CAAEAU?$atomic@G@std@@XZ@4U45@A"
Expand Down
2 changes: 1 addition & 1 deletion src/mc/deps/core/common/bedrock/typeid_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ MCAPI typeid_t<CommandRegistry> type_id<CommandRegistry, class WildcardCommandSe
template <>
MCAPI typeid_t<CommandRegistry> type_id<CommandRegistry, class CommandItem>();
template <>
MCAPI typeid_t<CommandRegistry> type_id<CommandRegistry, class ActorDefinitionIdentifier const*>();
MCAPI typeid_t<CommandRegistry> type_id<CommandRegistry, struct ActorDefinitionIdentifier const*>();
template <>
MCAPI typeid_t<CommandRegistry> type_id<CommandRegistry, class CommandRawText>();
template <>
Expand Down
8 changes: 4 additions & 4 deletions src/mc/entity/EntityContextBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class EntityContextBase {
template <class T>
MCAPI bool hasComponent() const;

template <class T>
constexpr bool contains() const {
return _enttRegistry().any_of<T>(_getEntityId());
}
// template <class T>
// constexpr bool contains() const {
// return _enttRegistry().any_of<T>(_getEntityId());
// }

public:
// NOLINTBEGIN
Expand Down
14 changes: 6 additions & 8 deletions src/mc/entity/EntityId.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ class EntityId : public entt::entt_traits<entt::id_type> {

constexpr EntityId& operator=(EntityId const&) = default;

template <typename T>
constexpr EntityId(T rawId)
requires(
!(std::is_same_v<T, std::allocator<EntityId>> || std::is_same_v<T, entt::null_t>
|| std::is_same_v<T, entt::tombstone_t>)
)
: mRawId(static_cast<entity_type>(rawId)) {}
template <std::integral T>
constexpr EntityId(T rawId) : mRawId(static_cast<entity_type>(rawId)) {}

constexpr operator entity_type() const { return mRawId; }
template <std::integral T>
constexpr operator T() const {
return mRawId;
}
};
2 changes: 1 addition & 1 deletion src/mc/math/vector/component/FloatN.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "mc/math/vector/component/base/Field.h"

template <typename T, typename... Components>
requires ll::concepts::IsAllSame<Components...>
// requires ll::concepts::IsAllSame<Components...>
class LL_EBO FloatN : public Field<T, Components...>, FloatNTag {
public:
using first_type = Field<T, Components...>::first_type;
Expand Down
2 changes: 1 addition & 1 deletion src/mc/math/vector/component/IntN.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ template <size_t N>
class doubleN;

template <typename T, typename... Components>
requires ll::concepts::IsAllSame<Components...>
// requires ll::concepts::IsAllSame<Components...>
class LL_EBO IntN : public Field<T, Components...>, IntNTag {
public:
using first_type = Field<T, Components...>::first_type;
Expand Down
4 changes: 2 additions & 2 deletions src/mc/math/vector/component/base/VectorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ class LL_EBO VectorBase : VectorBaseTag {
}

[[nodiscard]] constexpr first_type& operator[](size_t index) noexcept
requires ll::concepts::IsAllSame<Components...>
requires ll::concepts::IsAllSame<first_type, Components...>
{
return static_cast<T*>(this)->template get<first_type>(index);
}

[[nodiscard]] constexpr first_type operator[](size_t index) const noexcept
requires ll::concepts::IsAllSame<Components...>
requires ll::concepts::IsAllSame<first_type, Components...>
{
return static_cast<T const*>(this)->template get<first_type>(index);
}
Expand Down
13 changes: 7 additions & 6 deletions src/mc/server/commands/CommandRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ class CommandRegistry {
};

struct LexicalToken {
const char* mText; // this+0x0
uint mLength; // this+0x8
Symbol mType; // this+0xC
Symbol mIdentifierInfo; // this+0x10
private:
CommandRegistry const& mRegistry; // this+0x18
const char* mText; // this+0x0
uint mLength; // this+0x8
Symbol mType; // this+0xC
Symbol mIdentifierInfo; // this+0x10
CommandRegistry const& mRegistry; // this+0x18

LexicalToken(CommandRegistry& registry): mRegistry(registry) {}

public:
// NOLINTBEGIN
Expand Down
8 changes: 6 additions & 2 deletions src/mc/world/actor/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ class Vec3 Actor::getHeadPos() const { return getAttachPos(ActorLocation::Head);

class BlockPos Actor::getFeetBlockPos() const { return {CommandUtils::getFeetPos(this)}; }

bool Actor::isSimulatedPlayer() const { return getEntityContext().contains<FlagComponent<SimulatedPlayerFlag>>(); }
bool Actor::isSimulatedPlayer() const {
// return getEntityContext().contains<FlagComponent<SimulatedPlayerFlag>>();
return *(void**)this == LL_RESOLVE_SYMBOL("??_7SimulatedPlayer@@6B@");
}

bool Actor::isPlayer(bool allowSimulatedPlayer) const {
if (allowSimulatedPlayer) { return hasCategory(ActorCategory::Player); }
return hasCategory(ActorCategory::Player) && !isSimulatedPlayer();
}
bool Actor::isItemActor() const { return hasCategory(ActorCategory::Item); }

bool Actor::isOnGround() const { return ActorCollision::isOnGround(getEntityContext()); }

void Actor::setOnFire(int num, bool isEffect) {
Expand Down Expand Up @@ -94,7 +98,7 @@ class HitResult Actor::traceRay(
resPos,
isPlayer()
);
if (resActor != nullptr) { result = std::move(HitResult{origin, rayDir, *resActor, resPos}); }
if (resActor != nullptr) { result = HitResult{origin, rayDir, *resActor, resPos}; }
}

if (includeBlock) {
Expand Down
3 changes: 2 additions & 1 deletion src/mc/world/level/ActorBlockSyncMessage.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "mc/_HeaderOutputPredefine.h"
#include "mc/world/ActorUniqueID.h"

class ActorBlockSyncMessage {
struct ActorBlockSyncMessage {
public:
// ActorBlockSyncMessage inner types define
enum class MessageId : int {
Expand Down

0 comments on commit c8785e4

Please sign in to comment.