Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking world limit 3: Network compatible with old clients/servers [WIP] #12142

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bc7b07a
Breaking world limits. Part 1
proller Dec 7, 2021
489dfe2
Fix schematic
proller Dec 7, 2021
17a32c2
Rename to *pos_t*
proller Dec 7, 2021
0d20bbd
Fix replace bug
proller Dec 7, 2021
edc2cff
Better names, more bpos
proller Dec 7, 2021
4c4b804
Better bpos_t
proller Dec 7, 2021
42fb97a
Oops
proller Dec 7, 2021
e2ce232
sqlite error on limit
proller Dec 7, 2021
cd1a407
Some lost s16
proller Dec 8, 2021
b8f6b7a
Fix sqlite limit message
proller Dec 11, 2021
59c3ca0
Merge remote-tracking branch 'upstream/master' into minetest32
proller Dec 30, 2021
9246101
float -> double part 0
proller Dec 30, 2021
6f47355
Fixes
proller Dec 30, 2021
f7eae54
static pos save
proller Dec 30, 2021
f2b127d
Better
proller Dec 31, 2021
9c23294
Merge remote-tracking branch 'upstream/master' into minetest32
proller Dec 31, 2021
67af9d5
Merge branch 'minetest32' into minetest32double
proller Dec 31, 2021
7bdf5d0
clean
proller Dec 31, 2021
ca6d1ff
Merge branch 'master' into minetest32double
proller Jan 10, 2022
198ab80
Merge branch 'master' into minetest32
proller Feb 1, 2022
45995aa
Merge remote-tracking branch 'upstream/master' into minetest32
proller Feb 9, 2022
c40b27d
upstream merge fix
proller Feb 9, 2022
8ad9e83
Merge branch 'minetest32' into minetest32double
proller Feb 9, 2022
7198d9c
Merge remote-tracking branch 'origin/minetest32double' into minetest3…
proller Feb 9, 2022
e35ab6b
split USE_POS32 and USE_OPOS64
proller Feb 10, 2022
dded77e
total split fix
proller Feb 10, 2022
0368e5d
Merge remote-tracking branch 'minetest/master' into minetest32
proller Feb 25, 2022
183ab91
Merge branch 'minetest32' into minetest32double
proller Feb 25, 2022
e7f82e6
fix merge
proller Feb 25, 2022
6746d98
Merge branch 'minetest32' into minetest32double
proller Feb 25, 2022
efdc22a
fix pg
proller Feb 25, 2022
e8f1fee
Merge remote-tracking branch 'upstream/master' into minetest32
proller Mar 10, 2022
7da04ef
Merge branch 'minetest32' into minetest32double
proller Mar 10, 2022
27d0de2
Merge remote-tracking branch 'upstream/master' into minetest32
proller Mar 13, 2022
9bcdecc
Merge remote-tracking branch 'origin/minetest32' into minetest32double
proller Mar 13, 2022
2db9271
Breaking world limit 3: Network compatible with old clients/servers
proller Mar 19, 2022
0fe6cee
fix
proller Mar 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -28,6 +28,7 @@ gtags.files
# Visual Studio Code & plugins
.vscode/
build/.cmake/
.cache
# Gradle
.gradle

Expand Down
2 changes: 1 addition & 1 deletion builtin/game/chat.lua
Expand Up @@ -524,7 +524,7 @@ end

-- Teleports player <name> to <p> if possible
local function teleport_to_pos(name, p)
local lm = 31007 -- equals MAX_MAP_GENERATION_LIMIT in C++
local lm = tonumber(core.settings:get("mapgen_limit")) -- equals MAX_MAP_GENERATION_LIMIT in C++
if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm
or p.z < -lm or p.z > lm then
return false, S("Cannot teleport out of map bounds!")
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Expand Up @@ -31,6 +31,8 @@ if(NOT (BUILD_CLIENT OR BUILD_SERVER))
set(BUILD_SERVER TRUE)
endif()

option(USE_POS32 "32 bit node/block positions (experimental, not compatible with 16 bit)" FALSE)
option(USE_OPOS64 "64 bit object positions (experimental, not compatible with 32 bit)" ${USE_POS32})

option(ENABLE_CURL "Enable cURL support for fetching media" TRUE)
set(USE_CURL FALSE)
Expand Down
2 changes: 1 addition & 1 deletion src/activeobject.h
Expand Up @@ -103,7 +103,7 @@ class ActiveObject
* The box's coordinates are world coordinates.
* @returns true if the object has a collision box.
*/
virtual bool getCollisionBox(aabb3f *toset) const = 0;
virtual bool getCollisionBox(aabb3o *toset) const = 0;


/*!
Expand Down
2 changes: 1 addition & 1 deletion src/client/activeobjectmgr.cpp
Expand Up @@ -90,7 +90,7 @@ void ActiveObjectMgr::removeObject(u16 id)
}

// clang-format on
void ActiveObjectMgr::getActiveObjects(const v3f &origin, f32 max_d,
void ActiveObjectMgr::getActiveObjects(const v3opos_t &origin, f32 max_d,
std::vector<DistanceSortedActiveObject> &dest)
{
f32 max_d2 = max_d * max_d;
Expand Down
2 changes: 1 addition & 1 deletion src/client/activeobjectmgr.h
Expand Up @@ -35,7 +35,7 @@ class ActiveObjectMgr : public ::ActiveObjectMgr<ClientActiveObject>
bool registerObject(ClientActiveObject *obj) override;
void removeObject(u16 id) override;

void getActiveObjects(const v3f &origin, f32 max_d,
void getActiveObjects(const v3opos_t &origin, f32 max_d,
std::vector<DistanceSortedActiveObject> &dest);
};
} // namespace client
20 changes: 11 additions & 9 deletions src/client/camera.cpp
Expand Up @@ -313,7 +313,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 tool_reload_ratio)
// Get player position
// Smooth the movement when walking up stairs
v3f old_player_position = m_playernode->getPosition();
v3f player_position = player->getPosition();
auto player_position = player->getPosition();

// This is worse than `LocalPlayer::getPosition()` but
// mods expect the player head to be at the parent's position
Expand All @@ -338,7 +338,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 tool_reload_ratio)
}

// Set player node transformation
m_playernode->setPosition(player_position);
m_playernode->setPosition(oposToV3f(player_position));
m_playernode->setRotation(v3f(0, -1 * player->getYaw(), 0));
m_playernode->updateAbsolutePosition();

Expand Down Expand Up @@ -405,14 +405,16 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 tool_reload_ratio)
}

// Compute absolute camera position and target
m_headnode->getAbsoluteTransformation().transformVect(m_camera_position, rel_cam_pos);
auto tmp = oposToV3f(m_camera_position); // TODO use offset?
m_headnode->getAbsoluteTransformation().transformVect(tmp, rel_cam_pos);
m_camera_position = v3fToOpos(tmp);
m_headnode->getAbsoluteTransformation().rotateVect(m_camera_direction, rel_cam_target - rel_cam_pos);

v3f abs_cam_up;
m_headnode->getAbsoluteTransformation().rotateVect(abs_cam_up, rel_cam_up);

// Seperate camera position for calculation
v3f my_cp = m_camera_position;
auto my_cp = m_camera_position;

// Reposition the camera for third person view
if (m_camera_mode > CAMERA_MODE_FIRST)
Expand Down Expand Up @@ -452,17 +454,17 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 tool_reload_ratio)

// Update offset if too far away from the center of the map
m_camera_offset.X += CAMERA_OFFSET_STEP*
(((s16)(my_cp.X/BS) - m_camera_offset.X)/CAMERA_OFFSET_STEP);
(((pos_t)(my_cp.X/BS) - m_camera_offset.X)/CAMERA_OFFSET_STEP);
m_camera_offset.Y += CAMERA_OFFSET_STEP*
(((s16)(my_cp.Y/BS) - m_camera_offset.Y)/CAMERA_OFFSET_STEP);
(((pos_t)(my_cp.Y/BS) - m_camera_offset.Y)/CAMERA_OFFSET_STEP);
m_camera_offset.Z += CAMERA_OFFSET_STEP*
(((s16)(my_cp.Z/BS) - m_camera_offset.Z)/CAMERA_OFFSET_STEP);
(((pos_t)(my_cp.Z/BS) - m_camera_offset.Z)/CAMERA_OFFSET_STEP);

// Set camera node transformation
m_cameranode->setPosition(my_cp-intToFloat(m_camera_offset, BS));
m_cameranode->setPosition(oposToV3f(my_cp-posToOpos(m_camera_offset, BS)));
m_cameranode->setUpVector(abs_cam_up);
// *100.0 helps in large map coordinates
m_cameranode->setTarget(my_cp-intToFloat(m_camera_offset, BS) + 100 * m_camera_direction);
m_cameranode->setTarget(oposToV3f(my_cp-posToOpos(m_camera_offset, BS) + v3fToOpos(100 * m_camera_direction)));

// update the camera position in third-person mode to render blocks behind player
// and correctly apply liquid post FX.
Expand Down
12 changes: 6 additions & 6 deletions src/client/camera.h
Expand Up @@ -91,15 +91,15 @@ class Camera

// Get the camera position (in absolute scene coordinates).
// This has view bobbing applied.
inline v3f getPosition() const
inline v3opos_t getPosition() const
{
return m_camera_position;
}

// Returns the absolute position of the head SceneNode in the world
inline v3f getHeadPosition() const
inline v3opos_t getHeadPosition() const
{
return m_headnode->getAbsolutePosition();
return v3fToOpos(m_headnode->getAbsolutePosition());
}

// Get the camera direction (in absolute camera coordinates).
Expand All @@ -110,7 +110,7 @@ class Camera
}

// Get the camera offset
inline v3s16 getOffset() const
inline v3pos_t getOffset() const
{
return m_camera_offset;
}
Expand Down Expand Up @@ -207,11 +207,11 @@ class Camera
f32 m_cache_fov;

// Absolute camera position
v3f m_camera_position;
v3opos_t m_camera_position;
// Absolute camera direction
v3f m_camera_direction;
// Camera offset
v3s16 m_camera_offset;
v3pos_t m_camera_offset;

bool m_stepheight_smooth_active = false;

Expand Down