Skip to content

Commit

Permalink
refactor: rename members
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed May 26, 2024
1 parent d2d90d2 commit fdd3179
Show file tree
Hide file tree
Showing 32 changed files with 166 additions and 137 deletions.
10 changes: 5 additions & 5 deletions include/bedrock/command/command_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

class CommandContext {
public:
CommandContext(std::string command_line, std::unique_ptr<CommandOrigin> origin, int version)
: command_line_(std::move(command_line)), origin_(std::move(origin)), version_(version)
CommandContext(std::string command, std::unique_ptr<CommandOrigin> origin, int version)
: command_(std::move(command)), origin_(std::move(origin)), version_(version)
{
}

[[nodiscard]] std::string getCommandLine() const
[[nodiscard]] std::string getCommand() const
{
return command_line_;
return command_;
}

[[nodiscard]] CommandOrigin &getOrigin() const
Expand All @@ -38,7 +38,7 @@ class CommandContext {
}

private:
std::string command_line_; // +0
std::string command_; // +0
std::unique_ptr<CommandOrigin> origin_; // +32
int version_; // +40
};
Expand Down
4 changes: 2 additions & 2 deletions include/bedrock/command/command_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class CommandOutputMessage {

class CommandOutputParameter {
public:
std::string text; // +0
int count; // +32
std::string string; // +0
int count; // +32
};

class CommandOutput {
Expand Down
4 changes: 2 additions & 2 deletions include/bedrock/command/command_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#pragma once

struct CommandVersion {
int min;
int max;
int from;
int to;

static const int CurrentVersion;
};
1 change: 0 additions & 1 deletion include/bedrock/command/minecraft_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ class MinecraftCommands {
std::unique_ptr<CommandOutputSender> output_sender_; // +8
std::unique_ptr<CommandRegistry> registry_; // +16
};
BEDROCK_STATIC_ASSERT_SIZE(MinecraftCommands, 24, 24);
17 changes: 8 additions & 9 deletions include/bedrock/common/minecraft.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ class Minecraft : public Bedrock::EnableNonOwnerReferences {
private:
GameCallbacks *callbacks_; // +24
IMinecraftEventing *eventing_; // +32
std::unique_ptr<ResourcePackManager> resource_pack_manager_; // +40
std::unique_ptr<ResourcePackManager> resource_loader_; // +40
std::unique_ptr<StructureManager> structure_manager_; // +48
std::shared_ptr<GameModuleServer> game_module_server_; // +56
AllowList *allow_list_; // +72
PermissionsFile *permissions_file_; // +80
std::unique_ptr<PrivateKeyManager> private_key_manager_; // +88
std::string unk3_; // +96
std::unique_ptr<PrivateKeyManager> server_keys_; // +88
std::string save_game_path_; // +96
Bedrock::NonOwnerPointer<Core::FilePathManager> file_path_manager_; // +128
ServerMetrics *metrics_; // +144
bool unk4_; // +152
bool unk5_; // +153
double elapsed_time_seconds_; // +160
double last_update_seconds_; // +168
std::chrono::seconds unk6_; // +176
ServerMetrics *server_metrics_; // +144
bool corruption_detected_; // +152
double frame_duration_; // +160
double last_update_; // +168
std::chrono::seconds max_player_idle_time_; // +176
std::unique_ptr<MinecraftCommands> commands_; // +184
};
1 change: 1 addition & 0 deletions include/bedrock/forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class ResolvedItemIconInfo;
class ResolvedTextObject;
class ResourceLoadManager;
class ResourcePackManager;
class RopeSystem;
class SavedDataStorage;
class Scheduler;
class Scoreboard;
Expand Down
2 changes: 1 addition & 1 deletion include/bedrock/hashed_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class HashedString {
public:
std::uint64_t hash;
std::uint64_t str_hash;
std::string str;
const HashedString *last_match;
};
12 changes: 6 additions & 6 deletions include/bedrock/mce.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
namespace mce {
class UUID {
public:
std::int64_t msb; // most significant bits
std::int64_t lsb; // least significant bits
std::int64_t data_0; // most significant bits
std::int64_t data_1; // least significant bits

static mce::UUID fromEndstone(const endstone::UUID &in)
{
mce::UUID out;
auto *ms = reinterpret_cast<uint8_t *>(&out.msb);
auto *ls = reinterpret_cast<uint8_t *>(&out.lsb);
auto *ms = reinterpret_cast<uint8_t *>(&out.data_0);
auto *ls = reinterpret_cast<uint8_t *>(&out.data_1);
std::reverse_copy(in.data + 0, in.data + 4, ms + 4);
std::reverse_copy(in.data + 4, in.data + 6, ms + 2);
std::reverse_copy(in.data + 6, in.data + 8, ms + 0);
Expand All @@ -43,8 +43,8 @@ class UUID {
[[nodiscard]] endstone::UUID toEndstone() const
{
auto out = endstone::UUID{};
const auto *ms = reinterpret_cast<const uint8_t *>(&msb);
const auto *ls = reinterpret_cast<const uint8_t *>(&lsb);
const auto *ms = reinterpret_cast<const uint8_t *>(&data_0);
const auto *ls = reinterpret_cast<const uint8_t *>(&data_1);
std::reverse_copy(ms + 4, ms + 8, out.data + 0);
std::reverse_copy(ms + 2, ms + 4, out.data + 4);
std::reverse_copy(ms + 0, ms + 2, out.data + 6);
Expand Down
16 changes: 8 additions & 8 deletions include/bedrock/network/network_identifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class NetworkIdentifier {
Generic = 4,
};

std::uint32_t nether_net_id; // +0
RakNet::RakNetGUID raknet_guid; // +8
union { //
sockaddr_storage sa_stor; //
sockaddr_in6 addr6; //
sockaddr_in addr4; //
} address; // +24
Type type; // +152
std::uint32_t nether_net_id; // +0
RakNet::RakNetGUID guid; // +8
union { //
sockaddr_storage sa_stor; //
sockaddr_in6 addr6; //
sockaddr_in addr4; //
} sock; // +24
Type type; // +152

[[nodiscard]] std::string getAddress() const;
[[nodiscard]] std::uint16_t getPort() const;
Expand Down
53 changes: 27 additions & 26 deletions include/bedrock/world/actor/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,25 +227,25 @@ class Actor {
template <typename Component>
[[nodiscard]] bool hasComponent() const
{
return context_.hasComponent<Component>();
return entity_context_.hasComponent<Component>();
}

template <typename Component>
Component *tryGetComponent()
{
return context_.tryGetComponent<Component>();
return entity_context_.tryGetComponent<Component>();
}

template <typename Component>
Component *tryGetComponent() const
{
return context_.tryGetComponent<Component>();
return entity_context_.tryGetComponent<Component>();
}

template <typename Component>
gsl::not_null<Component *> getPersistentComponent() const
{
return context_.tryGetComponent<Component>();
return entity_context_.tryGetComponent<Component>();
};

BEDROCK_API void setDimension(WeakRef<Dimension>);
Expand All @@ -272,28 +272,29 @@ class Actor {
static Actor *tryGetFromEntity(EntityContext const &, bool include_removed);

protected:
EntityContext context_; // +8
ActorInitializationMethod initialization_method_; // +32
std::string unknown2_; // +40
std::array<char[16], 10> unknown3_; // +72 (+64)
std::int16_t unknown4_; // +232 (+224)
ActorDefinitionGroup *actor_definitions_; // +240 (+232)
std::unique_ptr<ActorDefinitionDescriptor> actor_definition_desc_; // +248 (+240)
std::shared_ptr<void *> unknown5_; // +256 (+248)
std::string unknown6_; // +272 (+264)
char unknown7_[72]; // +304 (+288)
std::map<HashedString, std::vector<std::vector<glm::mat4x4>>> unknown8_; // +376 (+360)
std::int32_t unknown9_; // +392 (+384)
SynchedActorDataEntityWrapper data_; // +400 (+392)
std::unique_ptr<SpatialActorNetworkData> spatial_data_; // +448 (+440)
Vec3 unknown10_; // +456 (+448)
char unknown11_[116]; // +468 (+460)
WeakRef<Dimension> dimension_; // +584 (+576)
Level *level_; // +600 (+592)
HashedString renderer_id_; // +608 (+600)
ActorCategory categories_; // +656 (+640)
BuiltInActorComponents components_; // +664 (+648)
HashedString unknown13_; // +696 (+680)
EntityContext entity_context_; // +8
ActorInitializationMethod init_method_; // +32
std::string custom_init_event_name_; // +40
std::array<char[16], 10> unknown3_; // +72 (+64)
bool force_init_method_to_spawn_on_reload_; // +232 (+224)
bool added_; // +233 (+225)
ActorDefinitionGroup *definitions_; // +240 (+232)
std::unique_ptr<ActorDefinitionDescriptor> current_description_; // +248 (+240)
std::shared_ptr<RopeSystem> leash_rope_system_; // +256 (+248)
std::string unknown6_; // +272 (+264)
char unknown7_[72]; // +304 (+288)
std::map<HashedString, std::vector<std::vector<glm::mat4x4>>> unknown8_; // +376 (+360)
std::int32_t unknown9_; // +392 (+384)
SynchedActorDataEntityWrapper entity_data_; // +400 (+392)
std::unique_ptr<SpatialActorNetworkData> network_data_; // +448 (+440)
Vec3 sent_delta_; // +456 (+448)
char unknown11_[116]; // +468 (+460)
WeakRef<Dimension> dimension_; // +584 (+576)
Level *level_; // +600 (+592)
HashedString actor_renderer_id_; // +608 (+600)
ActorCategory categories_; // +656 (+640)
BuiltInActorComponents built_in_components_; // +664 (+648)
HashedString actor_renderer_id_that_animation_component_was_initialized_with_; // +696 (+680)

public:
[[nodiscard]] endstone::detail::EndstoneActor &getEndstoneActor() const;
Expand Down
9 changes: 8 additions & 1 deletion include/bedrock/world/actor/actor_location.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@

enum class ActorLocation {
Feet = 0,
Eyes = 6
Body = 1,
WeaponAttachPoint = 2,
Head = 3,
DropAttachPoint = 4,
ExplosionPoint = 5,
Eyes = 6,
BreathingPoint = 7,
Mouth = 8
};
2 changes: 1 addition & 1 deletion include/bedrock/world/actor/actor_runtime_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

class ActorRuntimeID {
public:
std::uint64_t id{0};
std::uint64_t raw_id{0};
};
2 changes: 1 addition & 1 deletion include/bedrock/world/actor/actor_unique_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

class ActorUniqueID {
public:
std::int64_t id{-1};
std::int64_t raw_id{-1};
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#pragma once

#include "bedrock/world/level/game_type.h"

struct ActorGameTypeComponent {
GameType game_type;
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

class ActorOwnerComponent {
public:
Actor *owner;
std::unique_ptr<Actor> actor;
};
// static_assert(entt::type_hash<ActorOwnerComponent>::value() == 0x132A5818);
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
#include "bedrock/world/actor/actor.h"

struct ActorUniqueIDComponent {
ActorUniqueID id;
ActorUniqueID unique_id;
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#pragma once

#include "bedrock/world/math/vec3.h"
#include "bedrock/world/actor/components/vec3_component.h"

struct PostTickPositionDeltaComponent {
Vec3 position_delta_;
};
struct PostTickPositionDeltaComponent : public Vec3Component {};
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
#include "bedrock/world/actor/actor.h"

struct RuntimeIDComponent {
ActorRuntimeID id;
ActorRuntimeID runtime_id;
};
21 changes: 21 additions & 0 deletions include/bedrock/world/actor/components/vec3_component.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2024, The Endstone Project. (https://endstone.dev) All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "bedrock/world/math/vec3.h"

struct Vec3Component {
Vec3 value;
};
15 changes: 9 additions & 6 deletions include/bedrock/world/actor/player/abilities/ability.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ class Ability {
Bool = 2,
Float = 3,
};

enum class Options {
Default = 0
};

union Value {
bool bool_val;
float float_val;
};

Ability() = default;

[[nodiscard]] Type getType() const
Expand All @@ -37,20 +43,17 @@ class Ability {

[[nodiscard]] bool getBool() const
{
return type_ == Type::Bool ? value_.b : false;
return type_ == Type::Bool ? value_.bool_val : false;
}

[[nodiscard]] float getFloat() const
{
return type_ == Type::Float ? value_.f : 0.0F;
return type_ == Type::Float ? value_.float_val : 0.0F;
}

private:
Type type_;
union {
bool b;
float f;
} value_;
Value value_;
Options options_;
};
BEDROCK_STATIC_ASSERT_SIZE(Ability, 12, 12);
4 changes: 2 additions & 2 deletions include/bedrock/world/item/item_stack_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class ItemStackBase {
std::chrono::steady_clock::time_point pick_up_time_; // +40
bool show_pick_up_; // +48
bool was_picked_up_; // +49
std::vector<BlockLegacy const *> can_place_on_; // +56
std::vector<const BlockLegacy *> can_place_on_; // +56
std::uint64_t can_place_on_hash_; // +80
std::vector<BlockLegacy const *> can_destroy_; // +88
std::vector<const BlockLegacy *> can_destroy_; // +88
std::uint64_t can_destroy_hash_; // +112
Tick blocking_tick_; // +120
std::unique_ptr<ItemInstance> charged_item_; // +128
Expand Down
Loading

0 comments on commit fdd3179

Please sign in to comment.