Skip to content

Commit

Permalink
feat: fill some structures
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Oct 5, 2024
1 parent ec2db19 commit 7713156
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 77 deletions.
16 changes: 10 additions & 6 deletions src/ll/api/command/CommandHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,25 @@ char const* CommandHandle::storeStr(std::string_view str) {
std::lock_guard lock{impl->mutex};
return impl->storedStr.lazy_emplace(str, [&](auto const& ctor) { ctor(std::string{str}); })->c_str();
}

RuntimeOverload CommandHandle::runtimeOverload(std::weak_ptr<mod::Mod> mod) {
return RuntimeOverload{*this, std::move(mod)};
}

void CommandHandle::alias(std::string_view alias) {
CommandHandle& CommandHandle::alias(std::string_view alias) {
std::lock_guard lock{impl->mutex};
std::string str{alias};
if (impl->registrar.getRegistry().findCommand(str)) {
return;
if (!impl->registrar.getRegistry().findCommand(str)) {
impl->registrar.getRegistry().registerAlias(impl->signature.name, std::move(str));
}
impl->registrar.getRegistry().registerAlias(impl->signature.name, std::move(str));
return *this;
}
std::vector<std::string> CommandHandle::alias() const {
std::lock_guard lock{impl->mutex};
return impl->registrar.getRegistry().getAliases(impl->signature.name);
}
CommandHandle& CommandHandle::finalizeChainedSubcommandOverloadRules() {
if (!impl->signature.finalizedChainedSubcommands) {
impl->registrar.getRegistry().finalizeChainedSubcommandOverloadRules(impl->signature.name.c_str());
}
return *this;
}
} // namespace ll::command
7 changes: 4 additions & 3 deletions src/ll/api/command/CommandHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ class CommandHandle {
[[nodiscard]] auto overload(std::weak_ptr<mod::Mod> mod = mod::NativeMod::current()) -> Overload<Params> {
return Overload<Params>{*this, std::move(mod)};
}

LLNDAPI RuntimeOverload runtimeOverload(std::weak_ptr<mod::Mod> mod = mod::NativeMod::current());

LLAPI void alias(std::string_view alias);

LLNDAPI std::vector<std::string> alias() const;

LLAPI CommandHandle& alias(std::string_view alias);

LLAPI CommandHandle& finalizeChainedSubcommandOverloadRules();
};
} // namespace ll::command
9 changes: 9 additions & 0 deletions src/mc/deps/core/common/bedrock/ConditionVariable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "mc/_HeaderOutputPredefine.h"

namespace Bedrock::Threading {

using ConditionVariable = std::condition_variable;

}; // namespace Bedrock::Threading
10 changes: 6 additions & 4 deletions src/mc/deps/core/threading/SpinLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

class SpinLock {
public:
char unk[0x20];
// prevent constructor by default
SpinLock& operator=(SpinLock const&);
SpinLock(SpinLock const&);
static constexpr uint const LOOP_LIMIT_BEFORE_YIELD = 3000;

std::hash<std::thread::id> mThreadHasher; // location=0x0
size_t const mNoThreadId; // location=0x8
std::atomic_size_t mOwnerThread; // location=0x10
uint mOwnerRefCount; // location=0x18

public:
// NOLINTBEGIN
Expand Down
15 changes: 8 additions & 7 deletions src/mc/network/NetworkConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ class NetworkConnection {
NetworkConnection(NetworkConnection const&);
NetworkConnection();

NetworkIdentifier mId; // this+0x0
NetworkConnectionType mType; // this+0xA0
std::weak_ptr<NetworkPeer> mUnknown; // this+0xA8
std::weak_ptr<EncryptedNetworkPeer> mEncryptedPeer; // this+0xB8
std::weak_ptr<CompressedNetworkPeer> mCompressedPeer; // this+0xC8
std::weak_ptr<BatchedNetworkPeer> mBatchedPeer; // this+0xD8
std::shared_ptr<NetworkPeer> mPeer; // this+0xE8
NetworkIdentifier mId; // this+0x0
NetworkConnectionType mType; // this+0xA0
std::weak_ptr<NetworkPeer> mNetworkPacketRecorder; // this+0xA8
std::weak_ptr<EncryptedNetworkPeer> mEncryptedPeer; // this+0xB8
std::weak_ptr<CompressedNetworkPeer> mCompressedPeer; // this+0xC8
std::weak_ptr<BatchedNetworkPeer> mBatchedPeer; // this+0xD8
std::shared_ptr<NetworkPeer> mPeer; // this+0xE8
// std::shared_ptr<NetworkPeer> mTransportPeer;
std::chrono::steady_clock::time_point mLastPacketTime; // this+0xF8
std::chrono::steady_clock::time_point mClosedTime; // this+0x100
bool mShouldCloseConnection; // this+0x108
Expand Down
12 changes: 7 additions & 5 deletions src/mc/network/NetworkSettingOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

struct NetworkSettingOptions {
public:
ushort mCompressionThreshold;
PacketCompressionAlgorithm mCompressionAlgorithm;
bool mClientThrottleEnabled;
schar mClientThrottleThreshold;
float mClientThrottleScalar;
ushort mCompressionThreshold; // this+0x0
PacketCompressionAlgorithm mCompressionAlgorithm; // this+0x2
bool mClientThrottleEnabled; // this+0x4
int mClientThrottleThreshold; // this+0x8
float mClientThrottleScalar; // this+0xc
bool mRaknetJoinFloodProtectionEnabled; // this+0x10
bool mEncryptionDisabled; // this+0x11
};
1 change: 0 additions & 1 deletion src/mc/network/packet/NetworkSettingsPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class NetworkSettingsPacket : public ::Packet {
public:
NetworkSettingOptions mNetworkSettings; // this+0x30
bool mUnknown; // this+0x40

// prevent constructor by default
NetworkSettingsPacket& operator=(NetworkSettingsPacket const&);
Expand Down
17 changes: 8 additions & 9 deletions src/mc/network/packet/TextPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@

class TextPacket : public ::Packet {
public:
TextPacketType mType; // this+0x30
std::string mAuthor; // this+0x38
std::string mMessage; // this+0x58
std::string mFilteredMessage; // this+0x78
bool mUnknown; // this+0x98
std::vector<std::string> mParams; // this+0xA0
bool mLocalize; // this+0x88
std::string mXuid; // this+0xC0
std::string mPlatformId; // this+0xE0
TextPacketType mType; // this+0x30
std::string mAuthor; // this+0x38
std::string mMessage; // this+0x58
std::optional<std::string> mFilteredMessage; // this+0x78
std::vector<std::string> mParams; // this+0xA0
bool mLocalize; // this+0x88
std::string mXuid; // this+0xC0
std::string mPlatformId; // this+0xE0

[[nodiscard]] inline static TextPacket createRawMessage(std::string_view msg) {
auto res = TextPacket{};
Expand Down
8 changes: 4 additions & 4 deletions src/mc/server/commands/CommandRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,14 @@ class CommandRegistry {
std::vector<OptionalParameterChain> mOptionals; // this+0xB0
std::vector<std::string> mEnumValues; // this+0xC8
std::vector<Enum> mEnums; // this+0xE0
std::vector<int> mUnknown1; // this+0xF8
std::vector<int> mUnknown2; // this+0x110
std::vector<std::string> mChainedSubcommandValues; // this+0xF8
std::vector<ChainedSubcommand> mChainedSubcommands; // this+0x110
std::vector<Factorization> mFactorizations; // this+0x128
std::vector<std::string> mPostfixes; // this+0x140
std::map<std::string, uint> mEnumLookup; // this+0x158
std::map<std::string, uint64> mEnumValueLookup; // this+0x168
std::map<std::string, int> mUnknown3; // this+0x178
std::map<std::string, int> mChainedSubcommandLookUp; // this+0x188
std::map<std::string, uint> mChainedSubcommandLookUp; // this+0x178
std::map<std::string, uint64> mChainedSubcommandValueLookup; // this+0x188
std::vector<Symbol> mCommandSymbols; // this+0x198
std::map<std::string, Signature> mSignatures; // this+0x1B0
std::map<Bedrock::typeid_t<CommandRegistry>, int> mTypeLookup; // this+0x1C0
Expand Down
19 changes: 19 additions & 0 deletions src/mc/world/level/ScatterParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class ScatterParams {

// ScatterParams inner types define
class ChanceInformation {
public:
ExpressionNode mChancePercent;
int mNumerator;
int mDenominator;

public:
// prevent constructor by default
ChanceInformation& operator=(ChanceInformation const&);
Expand Down Expand Up @@ -86,6 +91,20 @@ class ScatterParams {
// NOLINTEND
};

enum class CoordinateEvalOrder : int {
xzy = 0x1,
yxz = 0x2,
yzx = 0x3,
zxy = 0x4,
zyx = 0x5,
};

public:
CoordinateRange mCoordinateRanges[3]; // this+0x0
CoordinateEvalOrder mEvalOrder; // this+0x5B8
ChanceInformation mScatterChance; // this+0x5C0
ExpressionNode mIterations; // this+0x6B0

public:
// prevent constructor by default
ScatterParams& operator=(ScatterParams const&);
Expand Down
26 changes: 6 additions & 20 deletions src/mc/world/level/biome/components/BiomeDecorationFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,16 @@
#include "mc/_HeaderOutputPredefine.h"
#include "mc/util/ExpressionNode.h"
#include "mc/world/level/ScatterParams.h"
#include "mc/world/level/levelgen/feature/gamerefs_feature/WeakStorageFeature.h"
#include "mc/world/level/levelgen/feature/gamerefs_feature/FeatureRefTraits.h"

struct BiomeDecorationFeature {
public:
enum class CoordinateEvalOrder : int {
xzy = 0x1,
yxz = 0x2,
yzx = 0x3,
zxy = 0x4,
zyx = 0x5,
};

public:
ScatterParams::CoordinateRange mX; // this+0x0
ScatterParams::CoordinateRange mY; // this+0x1E8
ScatterParams::CoordinateRange mZ; // this+0x3D0
CoordinateEvalOrder mCoordinateEvalOrder; // this+0x5B8
ExpressionNode mScatterChance; // this+0x5C0
int mUnknown2; // this+0x6A8
int mUnknown3; // this+0x6AC
ExpressionNode mIterations; // this+0x6B0
WeakStorageFeature mFeature; // this+0x798
HashedString mIdentifier; // this+0x7B0
std::string mPlacementPass; // this+0x7E0
ScatterParams mScatter;
WeakRef<IFeature> mFeature;
HashedString mIdentifier;
std::string mPlacementPass;
bool mCanUseInternalFeature;

public:
// prevent constructor by default
Expand Down
16 changes: 9 additions & 7 deletions src/mc/world/level/levelgen/WorldGenerator.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include "mc/_HeaderOutputPredefine.h"
#include "mc/deps/core/common/bedrock/ConditionVariable.h"
#include "mc/deps/core/common/bedrock/Mutex.h"
#include "mc/deps/core/threading/SpinLock.h"
#include "mc/world/level/chunk/ChunkSource.h"
#include "mc/world/level/levelgen/v1/IPreliminarySurfaceProvider.h"
Expand Down Expand Up @@ -29,13 +31,13 @@ class WorldGenerator : public ChunkSource, public IPreliminarySurfaceProvider {
uint mHeight; // this+0x8
};

std::unique_ptr<HardcodedSpawnAreaRegistry> mHardcodedSpawnTypes; // this+0x78
std::unique_ptr<StructureFeatureRegistry> mStructureFeatureRegistry; // this+0x80
uchar mUnknown1[160]; // this+0x88

// mUnknown2 is std::unordered_map but unknown key and value
uchar mUnknown2[64]; // this+0x128
SpinLock mSpinLock; // this+0x168
std::unique_ptr<HardcodedSpawnAreaRegistry> mHardcodedSpawnTypes; // this+0x78
std::unique_ptr<StructureFeatureRegistry> mStructureFeatureRegistry; // this+0x80
Bedrock::Threading::Mutex mCreateStructureInstancesMutex; // location=0x80
Bedrock::Threading::ConditionVariable mStructureInstanceWaitVar; // location=0xa8
std::atomic<int> mActiveStructureInstanceCreateCount;
std::unordered_set<ChunkPos> visitedPositions;
SpinLock visitedPositionsMutex; // this+0x168

public:
// prevent constructor by default
Expand Down
2 changes: 1 addition & 1 deletion src/mc/world/level/levelgen/feature/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class WorldChangeTransaction;

class Feature : public ::IFeature {
public:
short mUnknown; // this+0x8 Feature::Feature -> *((_WORD *)this + 4) = 257;
ActorUniqueID mPlacerID; // this+0x10
WorldChangeTransaction* mTransaction; // this+0x18

public:
// prevent constructor by default
Feature& operator=(Feature const&);
Expand Down
6 changes: 2 additions & 4 deletions src/mc/world/level/levelgen/feature/IFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ class RenderParams;

class IFeature {
public:
// prevent constructor by default
IFeature& operator=(IFeature const&);
IFeature(IFeature const&);
IFeature();
bool mInternal; // this+0x8
bool mCanUseInternalFeature; // this+0x9

public:
// NOLINTBEGIN
Expand Down
6 changes: 4 additions & 2 deletions src/mc/world/level/levelgen/structure/StructureFeature.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include "mc/_HeaderOutputPredefine.h"
#include "mc/deps/core/common/bedrock/ConditionVariable.h"
#include "mc/deps/core/common/bedrock/Mutex.h"
#include "mc/deps/core/threading/SpinLock.h"
#include "mc/world/level/ChunkPos.h"
#include "mc/world/level/levelgen/structure/StructureStart.h"
Expand All @@ -21,8 +23,8 @@ class StructureFeature {
uint mRadius; // this+184
int mXScale; // this+188
int mZScale; // this+192
std::mutex mCreateBlueprintsMutex; // this+200
std::condition_variable mBlueprintWaitVar; // this+280
Bedrock::Threading::Mutex mCreateBlueprintsMutex; // this+200
Bedrock::Threading::ConditionVariable mBlueprintWaitVar; // this+280
std::atomic_int mActiveBlueprintCreateCount; // this+352
std::atomic_bool mBlueprintsFinished; // this+356
public:
Expand Down
2 changes: 1 addition & 1 deletion src/mc/world/level/levelgen/structure/StructureTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class StructureTemplate {
uchar mStructureVersion; // this+0xD8
Bedrock::NonOwnerPointer<IUnknownBlockTypeRegistry> mUnknownBlockRegistry; // this+0xE0
uchar mRemovable; // this+0xF0
std::map<Block const*, int> mUnknown0; // this+0xF8
std::map<Block const*, int> mBlockToIndex; // this+0xF8
uchar mUnoptimized; // this+0x108

inline bool load(class CompoundTag const& nbt) { return mStructureTemplateData.load(nbt); }
Expand Down
6 changes: 3 additions & 3 deletions src/mc/world/level/levelgen/v1/Aquifer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Aquifer {
float mLastBarrier; // this+0x20
FluidSample::FluidType mFluidType; // this+0x24
bool mShouldScheduleFluidUpdate; // this+0x25
BlockPos mUnknown0; // this+0x28
BlockPos mUnknown1; // this+0x34
std::vector<FluidSample> mUnknown2; // this+0x40
BlockPos mMinGrid; // this+0x28
BlockPos mGridSize; // this+0x34
std::vector<FluidSample> mFluidLevelCache; // this+0x40
Block const& mWaterBlock; // this+0x58 Aquifer::getLastFluidBlockType
Block const& mLavaBlock; // this+0x60
Block const& mFlowingWaterBlock; // this+0x68
Expand Down

0 comments on commit 7713156

Please sign in to comment.