From c027ebd62529c4fc951ccd03cb64b4517b93814f Mon Sep 17 00:00:00 2001 From: Vincent Date: Fri, 14 Jun 2024 16:37:07 +0100 Subject: [PATCH] fix: hiding seeds from the client --- .../network/packet/start_game_packet.h | 35 ------------------- include/bedrock/world/level/level_settings.h | 6 ---- .../network/packet/start_game_packet.cpp | 15 +++++++- 3 files changed, 14 insertions(+), 42 deletions(-) diff --git a/include/bedrock/network/packet/start_game_packet.h b/include/bedrock/network/packet/start_game_packet.h index b6e8e4f51..f0c32d7e4 100644 --- a/include/bedrock/network/packet/start_game_packet.h +++ b/include/bedrock/network/packet/start_game_packet.h @@ -18,51 +18,16 @@ #include #include "bedrock/bedrock.h" -#include "bedrock/core/math/vec2.h" -#include "bedrock/core/math/vec3.h" #include "bedrock/core/utility/uuid.h" -#include "bedrock/forward.h" #include "bedrock/nbt/compound_tag.h" #include "bedrock/network/packet.h" #include "bedrock/server/packs/content_identity.h" -#include "bedrock/world/actor/actor_runtime_id.h" -#include "bedrock/world/actor/actor_unique_id.h" -#include "bedrock/world/actor/player/synced_player_movement_settings.h" -#include "bedrock/world/level/game_type.h" #include "bedrock/world/level/level_settings.h" -class NetworkPermissions { -public: - bool unknown; -}; - class StartGamePacket : public Packet { public: ENDSTONE_HOOK virtual void write(BinaryStream &) const; private: mutable LevelSettings settings_; // +48 - ActorUniqueID entity_id_; // +1296 (+1072) - ActorRuntimeID runtime_id_; // +1304 (+1080) - GameType game_type_; // +1312 (+1088) - Vec3 position_; // +1316 - Vec2 rotation_; // +1328 - std::string level_id_; // +1336 - std::string level_name_; // +1368 - ContentIdentity template_content_identity_; // +1400 - mce::UUID world_template_id_; // +1424 - bool is_trial_; // +1440 - SyncedPlayerMovementSettings movement_settings_; // +1444 - std::uint64_t level_current_time_; // +1456 - int enchantment_seed_; // +1464 - std::string multiplayer_correlation_id_; // +1472 - std::vector item_data_; // +1504 - bool enable_item_stack_net_manager_; // +1528 - std::string server_version_; // +1536 - CompoundTag player_property_data_; // +1568 - std::uint64_t server_block_type_registry_checksum_; // +1592 - bool server_enabled_client_side_generation_; // +1600 (+1352) - bool block_network_ids_are_hashes_; // +1601 (+1353) - NetworkPermissions network_permissions_; // +1602 (+1354) - std::vector> block_properties_; // +1608 (+1360) }; diff --git a/include/bedrock/world/level/level_settings.h b/include/bedrock/world/level/level_settings.h index 39f931001..22827cb8a 100644 --- a/include/bedrock/world/level/level_settings.h +++ b/include/bedrock/world/level/level_settings.h @@ -31,10 +31,4 @@ class LevelSettings { private: LevelSeed64 seed_; -#ifdef _WIN32 - size_t pad_[1248 / 8 - 1]; -#else - size_t pad_[1024 / 8 - 1]; -#endif }; -BEDROCK_STATIC_ASSERT_SIZE(LevelSettings, 1248, 1024); diff --git a/src/endstone_runtime/bedrock/network/packet/start_game_packet.cpp b/src/endstone_runtime/bedrock/network/packet/start_game_packet.cpp index c632c8359..d0a2efea7 100644 --- a/src/endstone_runtime/bedrock/network/packet/start_game_packet.cpp +++ b/src/endstone_runtime/bedrock/network/packet/start_game_packet.cpp @@ -14,11 +14,24 @@ #include "bedrock/network/packet/start_game_packet.h" +#include + #include "endstone/detail/hook.h" +#include "endstone/detail/level/level.h" +#include "endstone/detail/server.h" + +using endstone::detail::EndstoneLevel; +using endstone::detail::EndstoneServer; void StartGamePacket::write(BinaryStream &stream) const { - if (!server_enabled_client_side_generation_) { + static bool client_side_generation_enabled = []() { + auto &server = entt::locator::value(); + auto *level = static_cast(server.getLevels()[0]); + return level->getHandle().isClientSideGenerationEnabled(); + }(); + + if (!client_side_generation_enabled) { settings_.setRandomSeed({0}); }