Files
mcpe/source/world/level/storage/LevelData.cpp
Brent a0f71c7b27 C++03 Support & Partial Xbox 360 Support (#37)
* WIP C++03 + Xbox 360 Support

* math.h & _USE_MATH_DEFINES on Level.hpp
Updated Xenon vcxproj file for new file structure.

* * Fix bad GUI scale setup.

* * Gui: Use ratios instead of hardcoded sub-1 floating point values, to make the mechanism more clear.

* Add Direct Connect Button and Screen (#30)

* Add Direct Connect Button and Screen

* Remove accidental extra build directories for wasm

* Add DirectConnectScreen.cpp to the CMake

* Use Hungarian coding style notation

* * Fix errors caused by #30

* * Improve the Chat Screen

* * Improve the DirectConnectScreen, among other things.

* * Update the game title once again.

* * Add build-wasm.bat.

* * Add info about compiling for wasm

* * Fix send to specific GUID actually broadcasting to everyone

* * Add command manager.

* * Add writeable configuration.

* * Allow dynamic screen size change on windows

* * Allow the same thing on the emscripten version.

* WIP C++03 + Xbox 360 Support

* Fixed a possible merging issue that broke RakNet?

* Additional Xbox 360 compatability fixes

---------

Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
Co-authored-by: iProgramInCpp <iprogramincpp@gmail.com>
Co-authored-by: ts <124226059+uniformization@users.noreply.github.com>
2023-08-07 15:48:52 +03:00

99 lines
2.4 KiB
C++

/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#include "LevelData.hpp"
void LevelData::_init(TLong seed, int x)
{
m_seed = seed;
field_10 = 0;
field_14 = 0;
field_18 = 0;
field_1C = 0;
field_20 = x;
m_nPlayers = -1;
}
void LevelData::_init(TLong seed, int x, const std::string& name)
{
_init(seed, x);
field_78 = name;
}
void LevelData::read(RakNet::BitStream& bs, int version)
{
field_20 = version;
bs.Read(m_seed);
bs.Read(m_spawnPos.x);
bs.Read(m_spawnPos.y);
bs.Read(m_spawnPos.z);
bs.Read(field_10);
bs.Read(field_18);
bs.Read(field_14);
RakNet::RakString rs;
bs.Read(rs);
field_78 = std::string(rs.C_String());
}
void LevelData::write(RakNet::BitStream& bs)
{
bs.Write(m_seed);
bs.Write(m_spawnPos.x);
bs.Write(m_spawnPos.y);
bs.Write(m_spawnPos.z);
bs.Write(field_10);
bs.Write(field_18);
bs.Write(int(getEpochTimeS()));
RakNet::RakString rs(field_78.c_str());
bs.Write(rs);
}
void PlayerData::loadPlayer(Player* player)
{
player->setPos(0.0f, 0.0f, 0.0f);
player->m_pos = m_pos;
player->field_3C = m_pos;
player->field_98 = m_pos;
player->m_vel.x = Mth::abs(m_vel.x) > 10.0f ? 0.0f : m_vel.x;
player->m_vel.y = Mth::abs(m_vel.y) > 10.0f ? 0.0f : m_vel.y;
player->m_vel.z = Mth::abs(m_vel.z) > 10.0f ? 0.0f : m_vel.z;
player->m_pitch = player->field_60 = m_pitch;
player->m_yaw = player->field_5C = m_yaw;
player->m_distanceFallen = m_distanceFallen;
player->field_C0 = field_24;
player->field_BC = field_26;
player->field_7C = field_28;
// @NOTE: Why are we updating m_pos, field_3C and field_98 above if we do this?
player->setPos(m_pos.x, m_pos.y, m_pos.z);
// TODO: survival mode stuff
for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++)
player->m_pInventory->setQuickSlotIndexByItemId(i, m_hotbar[i]);
}
void PlayerData::savePlayer(Player* player)
{
m_pos = player->m_pos;
m_vel = player->m_vel;
m_pitch = player->m_pitch;
m_yaw = player->m_yaw;
m_distanceFallen = player->m_distanceFallen;
field_24 = player->field_C0;
field_26 = player->field_BC;
field_28 = player->field_7C;
// TODO: survival mode stuff
for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++)
m_hotbar[i] = player->m_pInventory->getQuickSlotItemId(i);
}