Compare commits

...

5 Commits

Author SHA1 Message Date
Quentin Bazin 5f1cd555cd Move client-specific files to 'src/client' (#7902)
Update Android.mk
Remove 'src/client' from include_directories
2018-11-28 20:01:49 +01:00
Michael Muller ddd9317b73 Clean up stack after script_get_backtrace (#7854)
script_get_backtrace() was leaving its return value on the stack, corrupting
subsequent lua operations for functions that did not immediately return.

This problem can specifically be observed in the case of multiple "groupcaps"
entries, each of which provides the legacy "maxwear" property.  These cause a
backtrace and thus pollute the stack for the following lua_next() call.
2018-11-28 20:01:01 +01:00
CoderForTheBetter faa358e797 Add Lua methods 'set_rotation()' and 'get_rotation()' (#7395)
* Adds Lua methods 'set_rotation()' and 'get_rotation'. Also changed some method names to be more clear. Instead of an f32 being sent over network for yaw, now a v3f is sent for rotation on xyz axes. Perserved Lua method set_yaw/setyaw so that old mods still work, other wise to set yaw they would need to switch to set_rotation(0, yaw, 0).
2018-11-28 09:38:50 +01:00
stujones11 9519d57017 Make non-formspec modal menus respect gui scale (#7850) 2018-11-26 22:55:24 +01:00
ClobberXD 8ba64e43fe Content store: Hide navigation buttons when there's no packages 2018-11-26 18:47:33 +00:00
108 changed files with 526 additions and 334 deletions

2
.gitignore vendored
View File

@ -56,6 +56,7 @@ debug.txt
## Other files generated by minetest
screenshot_*.png
testbm.txt
## Doxygen files
doc/Doxyfile
@ -95,6 +96,7 @@ cmake-build-release/
cmake_config.h
cmake_config_githash.h
CMakeDoxy*
compile_commands.json
## Android build files
build/android/src/main/assets

View File

@ -113,20 +113,20 @@ LOCAL_C_INCLUDES := \
LOCAL_SRC_FILES := \
jni/src/ban.cpp \
jni/src/camera.cpp \
jni/src/client/camera.cpp \
jni/src/mapgen/cavegen.cpp \
jni/src/chat.cpp \
jni/src/client.cpp \
jni/src/clientenvironment.cpp \
jni/src/client/client.cpp \
jni/src/client/clientenvironment.cpp \
jni/src/clientiface.cpp \
jni/src/clientmap.cpp \
jni/src/clientmedia.cpp \
jni/src/clientobject.cpp \
jni/src/clouds.cpp \
jni/src/client/clientmap.cpp \
jni/src/client/clientmedia.cpp \
jni/src/client/clientobject.cpp \
jni/src/client/clouds.cpp \
jni/src/collision.cpp \
jni/src/content_cao.cpp \
jni/src/content_cso.cpp \
jni/src/content_mapblock.cpp \
jni/src/client/content_cao.cpp \
jni/src/client/content_cso.cpp \
jni/src/client/content_mapblock.cpp \
jni/src/content_mapnode.cpp \
jni/src/content_nodemeta.cpp \
jni/src/content_sao.cpp \
@ -147,10 +147,10 @@ LOCAL_SRC_FILES := \
jni/src/emerge.cpp \
jni/src/environment.cpp \
jni/src/face_position_cache.cpp \
jni/src/filecache.cpp \
jni/src/client/filecache.cpp \
jni/src/filesys.cpp \
jni/src/fontengine.cpp \
jni/src/game.cpp \
jni/src/client/fontengine.cpp \
jni/src/client/game.cpp \
jni/src/genericobject.cpp \
jni/src/gettext.cpp \
jni/src/gui/guiChatConsole.cpp \
@ -162,7 +162,7 @@ LOCAL_SRC_FILES := \
jni/src/gui/guiKeyChangeMenu.cpp \
jni/src/gui/guiPasswordChange.cpp \
jni/src/gui/guiTable.cpp \
jni/src/guiscalingfilter.cpp \
jni/src/client/guiscalingfilter.cpp \
jni/src/gui/guiVolumeChange.cpp \
jni/src/gui/intlGUIEditBox.cpp \
jni/src/gui/modalMenu.cpp \
@ -170,20 +170,20 @@ LOCAL_SRC_FILES := \
jni/src/gui/touchscreengui.cpp \
jni/src/httpfetch.cpp \
jni/src/hud.cpp \
jni/src/imagefilters.cpp \
jni/src/client/imagefilters.cpp \
jni/src/inventory.cpp \
jni/src/inventorymanager.cpp \
jni/src/itemdef.cpp \
jni/src/itemstackmetadata.cpp \
jni/src/keycode.cpp \
jni/src/client/keycode.cpp \
jni/src/light.cpp \
jni/src/localplayer.cpp \
jni/src/client/localplayer.cpp \
jni/src/log.cpp \
jni/src/main.cpp \
jni/src/map.cpp \
jni/src/map_settings_manager.cpp \
jni/src/mapblock.cpp \
jni/src/mapblock_mesh.cpp \
jni/src/client/mapblock_mesh.cpp \
jni/src/mapgen/mapgen.cpp \
jni/src/mapgen/mapgen_carpathian.cpp \
jni/src/mapgen/mapgen_flat.cpp \
@ -195,14 +195,14 @@ LOCAL_SRC_FILES := \
jni/src/mapgen/mapgen_valleys.cpp \
jni/src/mapnode.cpp \
jni/src/mapsector.cpp \
jni/src/mesh.cpp \
jni/src/mesh_generator_thread.cpp \
jni/src/client/mesh.cpp \
jni/src/client/mesh_generator_thread.cpp \
jni/src/metadata.cpp \
jni/src/mapgen/mg_biome.cpp \
jni/src/mapgen/mg_decoration.cpp \
jni/src/mapgen/mg_ore.cpp \
jni/src/mapgen/mg_schematic.cpp \
jni/src/minimap.cpp \
jni/src/client/minimap.cpp \
jni/src/modchannels.cpp \
jni/src/nameidmapping.cpp \
jni/src/nodedef.cpp \
@ -211,7 +211,7 @@ LOCAL_SRC_FILES := \
jni/src/noise.cpp \
jni/src/objdef.cpp \
jni/src/object_properties.cpp \
jni/src/particles.cpp \
jni/src/client/particles.cpp \
jni/src/pathfinder.cpp \
jni/src/player.cpp \
jni/src/porting_android.cpp \
@ -229,8 +229,8 @@ LOCAL_SRC_FILES := \
jni/src/serverenvironment.cpp \
jni/src/serverlist.cpp \
jni/src/serverobject.cpp \
jni/src/shader.cpp \
jni/src/sky.cpp \
jni/src/client/shader.cpp \
jni/src/client/sky.cpp \
jni/src/staticobject.cpp \
jni/src/tileanimation.cpp \
jni/src/translation.cpp \
@ -275,7 +275,7 @@ LOCAL_SRC_FILES := \
jni/src/unittest/test_voxelalgorithms.cpp \
jni/src/unittest/test_voxelmanipulator.cpp \
jni/src/settings.cpp \
jni/src/wieldmesh.cpp \
jni/src/client/wieldmesh.cpp \
jni/src/client/meshgen/collector.cpp \
jni/src/client/clientlauncher.cpp \
jni/src/client/gameui.cpp \

View File

@ -357,7 +357,7 @@ function store.get_formspec()
end
local formspec
if #store.packages ~= 0 then
if #store.packages > 0 then
formspec = {
"size[12,7;true]",
"position[0.5,0.55]",
@ -371,12 +371,30 @@ function store.get_formspec()
";", filter_type, "]",
-- "textlist[0,1;2.4,5.6;a;",
-- table.concat(taglist, ","), "]",
-- Page nav buttons
"container[0,",
num_per_page + 1.5, "]",
"button[-0.1,0;3,1;back;",
fgettext("Back to Main Menu"), "]",
"button[7.1,0;1,1;pstart;<<]",
"button[8.1,0;1,1;pback;<]",
"label[9.2,0.2;",
tonumber(cur_page), " / ",
tonumber(pages), "]",
"button[10.1,0;1,1;pnext;>]",
"button[11.1,0;1,1;pend;>>]",
"container_end[]",
}
else
formspec = {
"size[12,7;true]",
"position[0.5,0.55]",
"label[4,3;No packages could be retrieved]",
"button[-0.1,",
num_per_page + 1.5,
";3,1;back;",
fgettext("Back to Main Menu"), "]",
}
end
@ -433,24 +451,6 @@ function store.get_formspec()
formspec[#formspec + 1] = "container_end[]"
end
formspec[#formspec + 1] = "container[0,"
formspec[#formspec + 1] = num_per_page + 1.5
formspec[#formspec + 1] = "]"
formspec[#formspec + 1] = "button[-0.1,0;3,1;back;"
formspec[#formspec + 1] = fgettext("Back to Main Menu")
formspec[#formspec + 1] = "]"
formspec[#formspec + 1] = "button[7.1,0;1,1;pstart;<<]"
formspec[#formspec + 1] = "button[8.1,0;1,1;pback;<]"
formspec[#formspec + 1] = "label[9.2,0.2;"
formspec[#formspec + 1] = tonumber(cur_page)
formspec[#formspec + 1] = " / "
formspec[#formspec + 1] = tonumber(pages)
formspec[#formspec + 1] = "]"
formspec[#formspec + 1] = "button[10.1,0;1,1;pnext;>]"
formspec[#formspec + 1] = "button[11.1,0;1,1;pend;>>]"
formspec[#formspec + 1] = "container_end[]"
formspec[#formspec + 1] = "]"
return table.concat(formspec, "")
end

View File

@ -5070,6 +5070,9 @@ This is basically a reference to a C++ `ServerActiveObject`
* `set_acceleration(acc)`
* `acc` is a vector
* `get_acceleration()`: returns the acceleration, a vector
* `set_rotation(rot)`
* `rot` is a vector (radians)
* `get_rotation()` : returns the rotation, a vector (radians)
* `set_yaw(radians)`
* `get_yaw()`: returns number in radians
* `set_texture_mod(mod)`

View File

@ -397,12 +397,14 @@ set(common_SRCS
genericobject.cpp
gettext.cpp
httpfetch.cpp
hud.cpp
inventory.cpp
inventorymanager.cpp
itemdef.cpp
itemstackmetadata.cpp
light.cpp
log.cpp
main.cpp
map.cpp
map_settings_manager.cpp
mapblock.cpp
@ -482,34 +484,6 @@ set(client_SRCS
${gui_SRCS}
${client_network_SRCS}
${client_irrlicht_changes_SRCS}
camera.cpp
client.cpp
clientenvironment.cpp
clientmap.cpp
clientmedia.cpp
clientobject.cpp
clouds.cpp
content_cao.cpp
content_cso.cpp
content_mapblock.cpp
convert_json.cpp
filecache.cpp
fontengine.cpp
game.cpp
guiscalingfilter.cpp
hud.cpp
imagefilters.cpp
keycode.cpp
localplayer.cpp
main.cpp
mapblock_mesh.cpp
mesh.cpp
mesh_generator_thread.cpp
minimap.cpp
particles.cpp
shader.cpp
sky.cpp
wieldmesh.cpp
${client_SCRIPT_SRCS}
${UNITTEST_CLIENT_SRCS}
)
@ -518,7 +492,6 @@ list(SORT client_SRCS)
# Server sources
set(server_SRCS
${common_SRCS}
main.cpp
)
list(SORT server_SRCS)
@ -829,10 +802,10 @@ if(BUILD_CLIENT)
endif()
if(USE_FREETYPE)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
FILES_MATCHING PATTERN "*.ttf" PATTERN "*.txt")
else()
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
FILES_MATCHING PATTERN "*.png" PATTERN "*.xml")
endif()

View File

@ -25,12 +25,37 @@ set(client_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/render/plain.cpp
${CMAKE_CURRENT_SOURCE_DIR}/render/sidebyside.cpp
${CMAKE_CURRENT_SOURCE_DIR}/render/stereo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/renderingengine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/camera.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client.cpp
${CMAKE_CURRENT_SOURCE_DIR}/clientenvironment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/clientlauncher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/clientmap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/clientmedia.cpp
${CMAKE_CURRENT_SOURCE_DIR}/clientobject.cpp
${CMAKE_CURRENT_SOURCE_DIR}/clouds.cpp
${CMAKE_CURRENT_SOURCE_DIR}/content_cao.cpp
${CMAKE_CURRENT_SOURCE_DIR}/content_cso.cpp
${CMAKE_CURRENT_SOURCE_DIR}/content_mapblock.cpp
${CMAKE_CURRENT_SOURCE_DIR}/filecache.cpp
${CMAKE_CURRENT_SOURCE_DIR}/fontengine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/game.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gameui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/inputhandler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/joystick_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/guiscalingfilter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hud.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagefilters.cpp
${CMAKE_CURRENT_SOURCE_DIR}/inputhandler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/joystick_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/keycode.cpp
${CMAKE_CURRENT_SOURCE_DIR}/localplayer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mapblock_mesh.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mesh.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mesh_generator_thread.cpp
${CMAKE_CURRENT_SOURCE_DIR}/minimap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/particles.cpp
${CMAKE_CURRENT_SOURCE_DIR}/renderingengine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/shader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sky.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wieldmesh.cpp
PARENT_SCOPE
)

View File

@ -114,6 +114,41 @@ void SmoothTranslatorWrapped::translate(f32 dtime)
val_diff * moveratio, 360.f);
}
void SmoothTranslatorWrappedv3f::translate(f32 dtime)
{
anim_time_counter = anim_time_counter + dtime;
v3f val_diff_v3f;
val_diff_v3f.X = std::abs(val_target.X - val_old.X);
val_diff_v3f.Y = std::abs(val_target.Y - val_old.Y);
val_diff_v3f.Z = std::abs(val_target.Z - val_old.Z);
if (val_diff_v3f.X > 180.f)
val_diff_v3f.X = 360.f - val_diff_v3f.X;
if (val_diff_v3f.Y > 180.f)
val_diff_v3f.Y = 360.f - val_diff_v3f.Y;
if (val_diff_v3f.Z > 180.f)
val_diff_v3f.Z = 360.f - val_diff_v3f.Z;
f32 moveratio = 1.0;
if (anim_time > 0.001)
moveratio = anim_time_counter / anim_time;
f32 move_end = aim_is_end ? 1.0 : 1.5;
// Move a bit less than should, to avoid oscillation
moveratio = std::min(moveratio * 0.8f, move_end);
wrappedApproachShortest(val_current.X, val_target.X,
val_diff_v3f.X * moveratio, 360.f);
wrappedApproachShortest(val_current.Y, val_target.Y,
val_diff_v3f.Y * moveratio, 360.f);
wrappedApproachShortest(val_current.Z, val_target.Z,
val_diff_v3f.Z * moveratio, 360.f);
}
/*
Other stuff
*/
@ -331,7 +366,7 @@ void GenericCAO::processInitData(const std::string &data)
m_is_player = readU8(is);
m_id = readU16(is);
m_position = readV3F1000(is);
m_yaw = readF1000(is);
m_rotation = readV3F1000(is);
m_hp = readS16(is);
num_messages = readU8(is);
} else {
@ -345,9 +380,9 @@ void GenericCAO::processInitData(const std::string &data)
processMessage(message);
}
m_yaw = wrapDegrees_0_360(m_yaw);
m_rotation = wrapDegrees_0_360_v3f(m_rotation);
pos_translator.init(m_position);
yaw_translator.init(m_yaw);
rot_translator.init(m_rotation);
updateNodePos();
}
@ -735,8 +770,7 @@ void GenericCAO::updateNodePos()
v3s16 camera_offset = m_env->getCameraOffset();
node->setPosition(pos_translator.val_current - intToFloat(camera_offset, BS));
if (node != m_spritenode) { // rotate if not a sprite
v3f rot = node->getRotation();
rot.Y = m_is_local_player ? -m_yaw : -yaw_translator.val_current;
v3f rot = m_is_local_player ? -m_rotation : -rot_translator.val_current;
node->setRotation(rot);
}
}
@ -751,11 +785,11 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
int old_anim = player->last_animation;
float old_anim_speed = player->last_animation_speed;
m_position = player->getPosition();
m_yaw = wrapDegrees_0_360(player->getYaw());
m_rotation.Y = wrapDegrees_0_360(player->getYaw());
m_velocity = v3f(0,0,0);
m_acceleration = v3f(0,0,0);
pos_translator.val_current = m_position;
yaw_translator.val_current = m_yaw;
rot_translator.val_current = m_rotation;
const PlayerControl &controls = player->getPlayerControl();
bool walking = false;
@ -867,7 +901,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
m_env->getLocalPlayer()->parent = getParent();
}
} else {
yaw_translator.translate(dtime);
rot_translator.translate(dtime);
v3f lastpos = pos_translator.val_current;
if(m_prop.physical)
@ -938,8 +972,8 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
}
}
if (!getParent() && std::fabs(m_prop.automatic_rotate) > 0.001) {
m_yaw += dtime * m_prop.automatic_rotate * 180 / M_PI;
yaw_translator.val_current = m_yaw;
m_rotation.Y += dtime * m_prop.automatic_rotate * 180 / M_PI;
rot_translator.val_current = m_rotation;
updateNodePos();
}
@ -951,8 +985,9 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
float max_rotation_delta =
dtime * m_prop.automatic_face_movement_max_rotation_per_sec;
wrappedApproachShortest(m_yaw, target_yaw, max_rotation_delta, 360.f);
yaw_translator.val_current = m_yaw;
wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
rot_translator.val_current = m_rotation;
updateNodePos();
}
}
@ -980,7 +1015,7 @@ void GenericCAO::updateTexturePos()
else {
float mob_dir =
atan2(cam_to_entity.Z, cam_to_entity.X) / M_PI * 180.;
float dir = mob_dir - m_yaw;
float dir = mob_dir - m_rotation.Y;
dir = wrapDegrees_180(dir);
if (std::fabs(wrapDegrees_180(dir - 0)) <= 45.1f)
col += 2;
@ -1314,11 +1349,13 @@ void GenericCAO::processMessage(const std::string &data)
m_position = readV3F1000(is);
m_velocity = readV3F1000(is);
m_acceleration = readV3F1000(is);
if (std::fabs(m_prop.automatic_rotate) < 0.001f)
m_yaw = readF1000(is);
m_rotation = readV3F1000(is);
else
readF1000(is);
m_yaw = wrapDegrees_0_360(m_yaw);
readV3F1000(is);
m_rotation = wrapDegrees_0_360_v3f(m_rotation);
bool do_interpolate = readU8(is);
bool is_end_position = readU8(is);
float update_interval = readF1000(is);
@ -1338,7 +1375,7 @@ void GenericCAO::processMessage(const std::string &data)
} else {
pos_translator.init(m_position);
}
yaw_translator.update(m_yaw, false, update_interval);
rot_translator.update(m_rotation, false, update_interval);
updateNodePos();
} else if (cmd == GENERIC_CMD_SET_TEXTURE_MOD) {
std::string mod = deSerializeString(is);

View File

@ -59,6 +59,11 @@ struct SmoothTranslatorWrapped : SmoothTranslator<f32>
void translate(f32 dtime);
};
struct SmoothTranslatorWrappedv3f : SmoothTranslator<v3f>
{
void translate(f32 dtime);
};
class GenericCAO : public ClientActiveObject
{
private:
@ -80,10 +85,10 @@ private:
v3f m_position = v3f(0.0f, 10.0f * BS, 0);
v3f m_velocity;
v3f m_acceleration;
float m_yaw = 0.0f;
v3f m_rotation;
s16 m_hp = 1;
SmoothTranslator<v3f> pos_translator;
SmoothTranslatorWrapped yaw_translator;
SmoothTranslatorWrappedv3f rot_translator;
// Spritesheet/animation stuff
v2f m_tx_size = v2f(1,1);
v2s16 m_tx_basepos;
@ -146,9 +151,10 @@ public:
virtual bool getSelectionBox(aabb3f *toset) const;
v3f getPosition();
inline float getYaw() const
inline const v3f &getRotation()
{
return m_yaw;
return m_rotation;
}
const bool isImmortal();

View File

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "collector.h"
#include <stdexcept>
#include "log.h"
#include "mesh.h"
#include "client/mesh.h"
void MeshCollector::append(const TileSpec &tile, const video::S3DVertex *vertices,
u32 numVertices, const u16 *indices, u32 numIndices)

View File

@ -19,11 +19,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "core.h"
#include "camera.h"
#include "client.h"
#include "clientmap.h"
#include "hud.h"
#include "minimap.h"
#include "client/camera.h"
#include "client/client.h"
#include "client/clientmap.h"
#include "client/hud.h"
#include "client/minimap.h"
RenderingCore::RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud)
: device(_device), driver(device->getVideoDriver()), smgr(device->getSceneManager()),

View File

@ -19,8 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "interlaced.h"
#include "client.h"
#include "shader.h"
#include "client/client.h"
#include "client/shader.h"
#include "client/tile.h"
RenderingCoreInterlaced::RenderingCoreInterlaced(

View File

@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "stereo.h"
#include "camera.h"
#include "client/camera.h"
#include "constants.h"
#include "settings.h"

View File

@ -134,8 +134,8 @@ void RemoteClient::GetNextBlocks (
// Camera position and direction
v3f camera_pos = sao->getEyePosition();
v3f camera_dir = v3f(0,0,1);
camera_dir.rotateYZBy(sao->getPitch());
camera_dir.rotateXZBy(sao->getYaw());
camera_dir.rotateYZBy(sao->getLookPitch());
camera_dir.rotateXZBy(sao->getRotation().Y);
/*infostream<<"camera_dir=("<<camera_dir.X<<","<<camera_dir.Y<<","
<<camera_dir.Z<<")"<<std::endl;*/

View File

@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h"
#include "gamedef.h"
#ifndef SERVER
#include "clientenvironment.h"
#include "client/clientenvironment.h"
#endif
#include "serverenvironment.h"
#include "serverobject.h"

View File

@ -349,7 +349,7 @@ ServerActiveObject* LuaEntitySAO::create(ServerEnvironment *env, v3f pos,
std::string state;
s16 hp = 1;
v3f velocity;
float yaw = 0;
v3f rotation;
if (!data.empty()) {
std::istringstream is(data, std::ios::binary);
// read version
@ -364,7 +364,7 @@ ServerActiveObject* LuaEntitySAO::create(ServerEnvironment *env, v3f pos,
state = deSerializeLongString(is);
hp = readS16(is);
velocity = readV3F1000(is);
yaw = readF1000(is);
rotation = readV3F1000(is);
}
}
// create object
@ -373,7 +373,7 @@ ServerActiveObject* LuaEntitySAO::create(ServerEnvironment *env, v3f pos,
LuaEntitySAO *sao = new LuaEntitySAO(env, pos, name, state);
sao->m_hp = hp;
sao->m_velocity = velocity;
sao->m_yaw = yaw;
sao->m_rotation = rotation;
return sao;
}
@ -443,8 +443,8 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
float max_rotation_delta =
dtime * m_prop.automatic_face_movement_max_rotation_per_sec;
m_yaw = wrapDegrees_0_360(m_yaw);
wrappedApproachShortest(m_yaw, target_yaw, max_rotation_delta, 360.f);
m_rotation.Y = wrapDegrees_0_360(m_rotation.Y);
wrappedApproachShortest(m_rotation.Y, target_yaw, max_rotation_delta, 360.f);
}
}
@ -468,7 +468,10 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
move_d += m_last_sent_move_precision;
float vel_d = m_velocity.getDistanceFrom(m_last_sent_velocity);
if (move_d > minchange || vel_d > minchange ||
std::fabs(m_yaw - m_last_sent_yaw) > 1.0) {
std::fabs(m_rotation.X - m_last_sent_rotation.X) > 1.0f ||
std::fabs(m_rotation.Y - m_last_sent_rotation.Y) > 1.0f ||
std::fabs(m_rotation.Z - m_last_sent_rotation.Z) > 1.0f) {
sendPosition(true, false);
}
}
@ -530,7 +533,7 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
writeU8(os, 0); // is_player
writeS16(os, getId()); //id
writeV3F1000(os, m_base_position);
writeF1000(os, m_yaw);
writeV3F1000(os, m_rotation);
writeS16(os, m_hp);
std::ostringstream msg_os(std::ios::binary);
@ -585,8 +588,9 @@ void LuaEntitySAO::getStaticData(std::string *result) const
writeS16(os, m_hp);
// velocity
writeV3F1000(os, m_velocity);
// yaw
writeF1000(os, m_yaw);
// rotation
writeV3F1000(os, m_rotation);
*result = os.str();
}
@ -767,10 +771,10 @@ void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end)
m_last_sent_move_precision = m_base_position.getDistanceFrom(
m_last_sent_position);
m_last_sent_position_timer = 0;
m_last_sent_yaw = m_yaw;
m_last_sent_position = m_base_position;
m_last_sent_velocity = m_velocity;
//m_last_sent_acceleration = m_acceleration;
m_last_sent_rotation = m_rotation;
float update_interval = m_env->getSendRecommendedInterval();
@ -778,7 +782,7 @@ void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end)
m_base_position,
m_velocity,
m_acceleration,
m_yaw,
m_rotation,
do_interpolate,
is_movement_end,
update_interval
@ -919,9 +923,9 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
writeU8(os, 1); // version
os << serializeString(m_player->getName()); // name
writeU8(os, 1); // is_player
writeS16(os, getId()); //id
writeS16(os, getId()); // id
writeV3F1000(os, m_base_position);
writeF1000(os, m_yaw);
writeV3F1000(os, m_rotation);
writeS16(os, getHP());
std::ostringstream msg_os(std::ios::binary);
@ -1073,7 +1077,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
return;
// If the object is attached client-side, don't waste bandwidth sending its
// position to clients.
// position or rotation to clients.
if (m_position_not_sent && !isAttached()) {
m_position_not_sent = false;
float update_interval = m_env->getSendRecommendedInterval();
@ -1087,7 +1091,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
pos,
v3f(0.0f, 0.0f, 0.0f),
v3f(0.0f, 0.0f, 0.0f),
m_yaw,
v3f(0.0f, 0.0f, 0.0f),
true,
false,
update_interval
@ -1188,12 +1192,14 @@ void PlayerSAO::moveTo(v3f pos, bool continuous)
m_env->getGameDef()->SendMovePlayer(m_peer_id);
}
void PlayerSAO::setYaw(const float yaw)
void PlayerSAO::setPlayerYaw(const float yaw)
{
if (m_player && yaw != m_yaw)
v3f rotation(0, yaw, 0);
if (m_player && yaw != m_rotation.Y)
m_player->setDirty(true);
UnitSAO::setYaw(yaw);
// Set player model yaw, not look view
UnitSAO::setRotation(rotation);
}
void PlayerSAO::setFov(const float fov)
@ -1212,13 +1218,13 @@ void PlayerSAO::setWantedRange(const s16 range)
m_wanted_range = range;
}
void PlayerSAO::setYawAndSend(const float yaw)
void PlayerSAO::setPlayerYawAndSend(const float yaw)
{
setYaw(yaw);
setPlayerYaw(yaw);
m_env->getGameDef()->SendMovePlayer(m_peer_id);
}
void PlayerSAO::setPitch(const float pitch)
void PlayerSAO::setLookPitch(const float pitch)
{
if (m_player && pitch != m_pitch)
m_player->setDirty(true);
@ -1226,9 +1232,9 @@ void PlayerSAO::setPitch(const float pitch)
m_pitch = pitch;
}
void PlayerSAO::setPitchAndSend(const float pitch)
void PlayerSAO::setLookPitchAndSend(const float pitch)
{
setPitch(pitch);
setLookPitch(pitch);
m_env->getGameDef()->SendMovePlayer(m_peer_id);
}

View File

@ -32,11 +32,12 @@ public:
UnitSAO(ServerEnvironment *env, v3f pos);
virtual ~UnitSAO() = default;
virtual void setYaw(const float yaw) { m_yaw = yaw; }
float getYaw() const { return m_yaw; };
f32 getRadYaw() const { return m_yaw * core::DEGTORAD; }
void setRotation(v3f rotation) { m_rotation = rotation; }
const v3f &getRotation() const { return m_rotation; }
v3f getRadRotation() { return m_rotation * core::DEGTORAD; }
// Deprecated
f32 getRadYawDep() const { return (m_yaw + 90.) * core::DEGTORAD; }
f32 getRadYawDep() const { return (m_rotation.Y + 90.) * core::DEGTORAD; }
s16 getHP() const { return m_hp; }
// Use a function, if isDead can be defined by other conditions
@ -64,7 +65,8 @@ public:
void notifyObjectPropertiesModified();
protected:
s16 m_hp = -1;
float m_yaw = 0.0f;
v3f m_rotation;
bool m_properties_sent = true;
ObjectProperties m_prop;
@ -156,9 +158,9 @@ private:
v3f m_velocity;
v3f m_acceleration;
float m_last_sent_yaw = 0.0f;
v3f m_last_sent_position;
v3f m_last_sent_velocity;
v3f m_last_sent_rotation;
float m_last_sent_position_timer = 0.0f;
float m_last_sent_move_precision = 0.0f;
std::string m_current_texture_modifier = "";
@ -232,16 +234,16 @@ public:
void setBasePosition(const v3f &position);
void setPos(const v3f &pos);
void moveTo(v3f pos, bool continuous);
void setYaw(const float yaw);
void setPlayerYaw(const float yaw);
// Data should not be sent at player initialization
void setYawAndSend(const float yaw);
void setPitch(const float pitch);
void setPlayerYawAndSend(const float yaw);
void setLookPitch(const float pitch);
// Data should not be sent at player initialization
void setPitchAndSend(const float pitch);
f32 getPitch() const { return m_pitch; }
f32 getRadPitch() const { return m_pitch * core::DEGTORAD; }
void setLookPitchAndSend(const float pitch);
f32 getLookPitch() const { return m_pitch; }
f32 getRadLookPitch() const { return m_pitch * core::DEGTORAD; }
// Deprecated
f32 getRadPitchDep() const { return -1.0 * m_pitch * core::DEGTORAD; }
f32 getRadLookPitchDep() const { return -1.0 * m_pitch * core::DEGTORAD; }
void setFov(const float pitch);
f32 getFov() const { return m_fov; }
void setWantedRange(const s16 range);

View File

@ -41,8 +41,8 @@ void PlayerDatabaseFiles::serialize(std::ostringstream &os, RemotePlayer *player
sanity_check(player->getPlayerSAO());
args.setS32("hp", player->getPlayerSAO()->getHP());
args.setV3F("position", player->getPlayerSAO()->getBasePosition());
args.setFloat("pitch", player->getPlayerSAO()->getPitch());
args.setFloat("yaw", player->getPlayerSAO()->getYaw());
args.setFloat("pitch", player->getPlayerSAO()->getLookPitch());
args.setFloat("yaw", player->getPlayerSAO()->getRotation().Y);
args.setS32("breath", player->getPlayerSAO()->getBreath());
std::string extended_attrs;

View File

@ -454,8 +454,8 @@ void PlayerDatabasePostgreSQL::savePlayer(RemotePlayer *player)
verifyDatabase();
v3f pos = sao->getBasePosition();
std::string pitch = ftos(sao->getPitch());
std::string yaw = ftos(sao->getYaw());
std::string pitch = ftos(sao->getLookPitch());
std::string yaw = ftos(sao->getRotation().Y);
std::string posx = ftos(pos.X);
std::string posy = ftos(pos.Y);
std::string posz = ftos(pos.Z);
@ -545,8 +545,8 @@ bool PlayerDatabasePostgreSQL::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
return false;
}
sao->setPitch(pg_to_float(results, 0, 0));
sao->setYaw(pg_to_float(results, 0, 1));
sao->setLookPitch(pg_to_float(results, 0, 0));
sao->setRotation(v3f(0, pg_to_float(results, 0, 1), 0));
sao->setBasePosition(v3f(
pg_to_float(results, 0, 2),
pg_to_float(results, 0, 3),

View File

@ -456,8 +456,8 @@ void PlayerDatabaseSQLite3::savePlayer(RemotePlayer *player)
if (!playerDataExists(player->getName())) {
beginSave();
str_to_sqlite(m_stmt_player_add, 1, player->getName());
double_to_sqlite(m_stmt_player_add, 2, sao->getPitch());
double_to_sqlite(m_stmt_player_add, 3, sao->getYaw());
double_to_sqlite(m_stmt_player_add, 2, sao->getLookPitch());
double_to_sqlite(m_stmt_player_add, 3, sao->getRotation().Y);
double_to_sqlite(m_stmt_player_add, 4, pos.X);
double_to_sqlite(m_stmt_player_add, 5, pos.Y);
double_to_sqlite(m_stmt_player_add, 6, pos.Z);
@ -468,8 +468,8 @@ void PlayerDatabaseSQLite3::savePlayer(RemotePlayer *player)
sqlite3_reset(m_stmt_player_add);
} else {
beginSave();
double_to_sqlite(m_stmt_player_update, 1, sao->getPitch());
double_to_sqlite(m_stmt_player_update, 2, sao->getYaw());
double_to_sqlite(m_stmt_player_update, 1, sao->getLookPitch());
double_to_sqlite(m_stmt_player_update, 2, sao->getRotation().Y);
double_to_sqlite(m_stmt_player_update, 3, pos.X);
double_to_sqlite(m_stmt_player_update, 4, pos.Y);
double_to_sqlite(m_stmt_player_update, 5, pos.Z);
@ -542,8 +542,8 @@ bool PlayerDatabaseSQLite3::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
sqlite3_reset(m_stmt_player_load);
return false;
}
sao->setPitch(sqlite_to_float(m_stmt_player_load, 0));
sao->setYaw(sqlite_to_float(m_stmt_player_load, 1));
sao->setLookPitch(sqlite_to_float(m_stmt_player_load, 0));
sao->setPlayerYaw(sqlite_to_float(m_stmt_player_load, 1));
sao->setBasePosition(sqlite_to_v3f(m_stmt_player_load, 2));
sao->setHPRaw((s16) MYMIN(sqlite_to_int(m_stmt_player_load, 5), S16_MAX));
sao->setBreath((u16) MYMIN(sqlite_to_int(m_stmt_player_load, 6), U16_MAX), false);

View File

@ -40,7 +40,7 @@ std::string gob_cmd_update_position(
v3f position,
v3f velocity,
v3f acceleration,
f32 yaw,
v3f rotation,
bool do_interpolate,
bool is_movement_end,
f32 update_interval
@ -54,8 +54,8 @@ std::string gob_cmd_update_position(
writeV3F1000(os, velocity);
// acceleration
writeV3F1000(os, acceleration);
// yaw
writeF1000(os, yaw);
// rotation
writeV3F1000(os, rotation);
// do_interpolate
writeU8(os, do_interpolate);
// is_end_position (for interpolation)

View File

@ -48,7 +48,7 @@ std::string gob_cmd_update_position(
v3f position,
v3f velocity,
v3f acceleration,
f32 yaw,
v3f rotation,
bool do_interpolate,
bool is_movement_end,
f32 update_interval

View File

@ -19,14 +19,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiChatConsole.h"
#include "chat.h"
#include "client.h"
#include "client/client.h"
#include "debug.h"
#include "gettime.h"
#include "keycode.h"
#include "client/keycode.h"
#include "settings.h"
#include "porting.h"
#include "client/tile.h"
#include "fontengine.h"
#include "client/fontengine.h"
#include "log.h"
#include "gettext.h"
#include <string>

View File

@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "guiConfirmRegistration.h"
#include "client.h"
#include "client/client.h"
#include <IGUICheckBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
@ -70,13 +70,16 @@ void GUIConfirmRegistration::regenerateGui(v2u32 screensize)
/*
Calculate new sizes and positions
*/
core::rect<s32> rect(screensize.X / 2 - 600 / 2, screensize.Y / 2 - 360 / 2,
screensize.X / 2 + 600 / 2, screensize.Y / 2 + 360 / 2);
DesiredRect = rect;
const float s = m_gui_scale;
DesiredRect = core::rect<s32>(
screensize.X / 2 - 600 * s / 2,
screensize.Y / 2 - 360 * s / 2,
screensize.X / 2 + 600 * s / 2,
screensize.Y / 2 + 360 * s / 2
);
recalculateAbsolutePosition(false);
v2s32 size = rect.getSize();
v2s32 size = DesiredRect.getSize();
v2s32 topleft_client(0, 0);
const wchar_t *text;
@ -84,13 +87,13 @@ void GUIConfirmRegistration::regenerateGui(v2u32 screensize)
/*
Add stuff
*/
s32 ypos = 30;
s32 ypos = 30 * s;
{
std::string address = m_address;
if (address.empty())
address = "localhost";
core::rect<s32> rect2(0, 0, 540, 180);
rect2 += topleft_client + v2s32(30, ypos);
core::rect<s32> rect2(0, 0, 540 * s, 180 * s);
rect2 += topleft_client + v2s32(30 * s, ypos);
static const std::string info_text_template = strgettext(
"You are about to join the server at %1$s with the "
"name \"%2$s\" for the first time. If you proceed, a "
@ -114,33 +117,33 @@ void GUIConfirmRegistration::regenerateGui(v2u32 screensize)
e->setTextAlignment(gui::EGUIA_UPPERLEFT, gui::EGUIA_CENTER);
}
ypos += 210;
ypos += 210 * s;
{
core::rect<s32> rect2(0, 0, 540, 30);
rect2 += topleft_client + v2s32(30, ypos);
core::rect<s32> rect2(0, 0, 540 * s, 30 * s);
rect2 += topleft_client + v2s32(30 * s, ypos);
gui::IGUIEditBox *e = Environment->addEditBox(m_pass_confirm.c_str(),
rect2, true, this, ID_confirmPassword);
e->setPasswordBox(true);
}
ypos += 60;
ypos += 60 * s;
{
core::rect<s32> rect2(0, 0, 230, 35);
rect2 = rect2 + v2s32(size.X / 2 - 220, ypos);
core::rect<s32> rect2(0, 0, 230 * s, 35 * s);
rect2 = rect2 + v2s32(size.X / 2 - 220 * s, ypos);
text = wgettext("Register and Join");
Environment->addButton(rect2, this, ID_confirm, text);
delete[] text;
}
{
core::rect<s32> rect2(0, 0, 120, 35);
rect2 = rect2 + v2s32(size.X / 2 + 70, ypos);
core::rect<s32> rect2(0, 0, 120 * s, 35 * s);
rect2 = rect2 + v2s32(size.X / 2 + 70 * s, ypos);
text = wgettext("Cancel");
Environment->addButton(rect2, this, ID_cancel, text);
delete[] text;
}
{
core::rect<s32> rect2(0, 0, 200, 20);
rect2 += topleft_client + v2s32(30, ypos - 40);
core::rect<s32> rect2(0, 0, 200 * s, 20 * s);
rect2 += topleft_client + v2s32(30 * s, ypos - 40 * s);
text = wgettext("Passwords do not match!");
IGUIElement *e = Environment->addStaticText(
text, rect2, false, true, this, ID_message);

View File

@ -32,11 +32,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiMainMenu.h"
#include "sound.h"
#include "client/sound_openal.h"
#include "clouds.h"
#include "client/clouds.h"
#include "httpfetch.h"
#include "log.h"
#include "fontengine.h"
#include "guiscalingfilter.h"
#include "client/fontengine.h"
#include "client/guiscalingfilter.h"
#include "irrlicht_changes/static_text.h"
#ifdef __ANDROID__

View File

@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiTable.h"
#include "constants.h"
#include "gamedef.h"
#include "keycode.h"
#include "client/keycode.h"
#include "util/strfnd.h"
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
@ -47,13 +47,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mainmenumanager.h"
#include "porting.h"
#include "settings.h"
#include "client.h"
#include "fontengine.h"
#include "client/client.h"
#include "client/fontengine.h"
#include "util/hex.h"
#include "util/numeric.h"
#include "util/string.h" // for parseColorString()
#include "irrlicht_changes/static_text.h"
#include "guiscalingfilter.h"
#include "client/guiscalingfilter.h"
#include "guiEditBoxWithScrollbar.h"
#include "intlGUIEditBox.h"
@ -673,10 +673,10 @@ void GUIFormSpecMenu::parseBackground(parserData* data, const std::string &eleme
pos.Y = stoi(v_pos[1]); //acts as offset
clip = true;
}
if (!data->explicit_size && !clip)
warningstream << "invalid use of unclipped background without a size[] element" << std::endl;
m_backgrounds.emplace_back(name, pos, geom, clip);
return;

View File

@ -116,20 +116,22 @@ void GUIKeyChangeMenu::removeChildren()
void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
{
removeChildren();
v2s32 size(745, 430);
core::rect < s32 > rect(screensize.X / 2 - size.X / 2,
screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2,
screensize.Y / 2 + size.Y / 2);
DesiredRect = rect;
const float s = m_gui_scale;
DesiredRect = core::rect<s32>(
screensize.X / 2 - 745 * s / 2,
screensize.Y / 2 - 430 * s / 2,
screensize.X / 2 + 745 * s / 2,
screensize.Y / 2 + 430 * s / 2
);
recalculateAbsolutePosition(false);
v2s32 size = DesiredRect.getSize();
v2s32 topleft(0, 0);
{
core::rect < s32 > rect(0, 0, 600, 40);
rect += topleft + v2s32(25, 3);
core::rect<s32> rect(0, 0, 600 * s, 40 * s);
rect += topleft + v2s32(25 * s, 3 * s);
//gui::IGUIStaticText *t =
const wchar_t *text = wgettext("Keybindings. (If this menu screws up, remove stuff from minetest.conf)");
Environment->addStaticText(text,
@ -140,68 +142,68 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
// Build buttons
v2s32 offset(25, 60);
v2s32 offset(25 * s, 60 * s);
for(size_t i = 0; i < key_settings.size(); i++)
{
key_setting *k = key_settings.at(i);
{
core::rect < s32 > rect(0, 0, 150, 20);
core::rect<s32> rect(0, 0, 150 * s, 20 * s);
rect += topleft + v2s32(offset.X, offset.Y);
Environment->addStaticText(k->button_name, rect, false, true, this, -1);
}
{
core::rect < s32 > rect(0, 0, 100, 30);
rect += topleft + v2s32(offset.X + 120, offset.Y - 5);
core::rect<s32> rect(0, 0, 100 * s, 30 * s);
rect += topleft + v2s32(offset.X + 120 * s, offset.Y - 5 * s);
const wchar_t *text = wgettext(k->key.name());
k->button = Environment->addButton(rect, this, k->id, text);
delete[] text;
}
if ((i + 1) % KMaxButtonPerColumns == 0) {
offset.X += 230;
offset.Y = 60;
offset.X += 230 * s;
offset.Y = 60 * s;
} else {
offset += v2s32(0, 25);
offset += v2s32(0, 25 * s);
}
}
{
s32 option_x = offset.X;
s32 option_y = offset.Y + 5;
u32 option_w = 180;
s32 option_y = offset.Y + 5 * s;
u32 option_w = 180 * s;
{
core::rect<s32> rect(0, 0, option_w, 30);
core::rect<s32> rect(0, 0, option_w, 30 * s);
rect += topleft + v2s32(option_x, option_y);
const wchar_t *text = wgettext("\"Special\" = climb down");
Environment->addCheckBox(g_settings->getBool("aux1_descends"), rect, this,
GUI_ID_CB_AUX1_DESCENDS, text);
delete[] text;
}
offset += v2s32(0, 25);
offset += v2s32(0, 25 * s);
}
{
s32 option_x = offset.X;
s32 option_y = offset.Y + 5;
u32 option_w = 280;
s32 option_y = offset.Y + 5 * s;
u32 option_w = 280 * s;
{
core::rect<s32> rect(0, 0, option_w, 30);
core::rect<s32> rect(0, 0, option_w, 30 * s);
rect += topleft + v2s32(option_x, option_y);
const wchar_t *text = wgettext("Double tap \"jump\" to toggle fly");
Environment->addCheckBox(g_settings->getBool("doubletap_jump"), rect, this,
GUI_ID_CB_DOUBLETAP_JUMP, text);
delete[] text;
}
offset += v2s32(0, 25);
offset += v2s32(0, 25 * s);
}
{
s32 option_x = offset.X;
s32 option_y = offset.Y + 5;
s32 option_y = offset.Y + 5 * s;
u32 option_w = 280;
{
core::rect<s32> rect(0, 0, option_w, 30);
core::rect<s32> rect(0, 0, option_w, 30 * s);
rect += topleft + v2s32(option_x, option_y);
const wchar_t *text = wgettext("Automatic jumping");
Environment->addCheckBox(g_settings->getBool("autojump"), rect, this,
@ -212,16 +214,16 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
}
{
core::rect < s32 > rect(0, 0, 100, 30);
rect += topleft + v2s32(size.X / 2 - 105, size.Y - 40);
core::rect<s32> rect(0, 0, 100 * s, 30 * s);
rect += topleft + v2s32(size.X / 2 - 105 * s, size.Y - 40 * s);
const wchar_t *text = wgettext("Save");
Environment->addButton(rect, this, GUI_ID_BACK_BUTTON,
text);
delete[] text;
}
{
core::rect < s32 > rect(0, 0, 100, 30);
rect += topleft + v2s32(size.X / 2 + 5, size.Y - 40);
core::rect<s32> rect(0, 0, 100 * s, 30 * s);
rect += topleft + v2s32(size.X / 2 + 5 * s, size.Y - 40 * s);
const wchar_t *text = wgettext("Cancel");
Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON,
text);
@ -237,12 +239,7 @@ void GUIKeyChangeMenu::drawMenu()
video::IVideoDriver* driver = Environment->getVideoDriver();
video::SColor bgcolor(140, 0, 0, 0);
{
core::rect < s32 > rect(0, 0, 745, 620);
rect += AbsoluteRect.UpperLeftCorner;
driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
}
driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
gui::IGUIElement::draw();
}

View File

@ -24,7 +24,7 @@
#include "irrlichttypes_extrabloated.h"
#include "modalMenu.h"
#include "gettext.h"
#include "keycode.h"
#include "client/keycode.h"
#include <string>
#include <vector>

View File

@ -17,7 +17,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "guiPasswordChange.h"
#include "client.h"
#include "client/client.h"
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
@ -76,91 +76,90 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
/*
Calculate new sizes and positions
*/
core::rect<s32> rect(
screensize.X/2 - 580/2,
screensize.Y/2 - 300/2,
screensize.X/2 + 580/2,
screensize.Y/2 + 300/2
const float s = m_gui_scale;
DesiredRect = core::rect<s32>(
screensize.X / 2 - 580 * s / 2,
screensize.Y / 2 - 300 * s / 2,
screensize.X / 2 + 580 * s / 2,
screensize.Y / 2 + 300 * s / 2
);
DesiredRect = rect;
recalculateAbsolutePosition(false);
v2s32 size = rect.getSize();
v2s32 topleft_client(40, 0);
v2s32 size = DesiredRect.getSize();
v2s32 topleft_client(40 * s, 0);
const wchar_t *text;
/*
Add stuff
*/
s32 ypos = 50;
s32 ypos = 50 * s;
{
core::rect<s32> rect(0, 0, 150, 20);
rect += topleft_client + v2s32(25, ypos + 6);
core::rect<s32> rect(0, 0, 150 * s, 20 * s);
rect += topleft_client + v2s32(25 * s, ypos + 6 * s);
text = wgettext("Old Password");
Environment->addStaticText(text, rect, false, true, this, -1);
delete[] text;
}
{
core::rect<s32> rect(0, 0, 230, 30);
rect += topleft_client + v2s32(160, ypos);
core::rect<s32> rect(0, 0, 230 * s, 30 * s);
rect += topleft_client + v2s32(160 * s, ypos);
gui::IGUIEditBox *e = Environment->addEditBox(
m_oldpass.c_str(), rect, true, this, ID_oldPassword);
Environment->setFocus(e);
e->setPasswordBox(true);
}
ypos += 50;
ypos += 50 * s;
{
core::rect<s32> rect(0, 0, 150, 20);
rect += topleft_client + v2s32(25, ypos + 6);
core::rect<s32> rect(0, 0, 150 * s, 20 * s);
rect += topleft_client + v2s32(25 * s, ypos + 6 * s);
text = wgettext("New Password");
Environment->addStaticText(text, rect, false, true, this, -1);
delete[] text;
}
{
core::rect<s32> rect(0, 0, 230, 30);
rect += topleft_client + v2s32(160, ypos);
core::rect<s32> rect(0, 0, 230 * s, 30 * s);
rect += topleft_client + v2s32(160 * s, ypos);
gui::IGUIEditBox *e = Environment->addEditBox(
m_newpass.c_str(), rect, true, this, ID_newPassword1);
e->setPasswordBox(true);
}
ypos += 50;
ypos += 50 * s;
{
core::rect<s32> rect(0, 0, 150, 20);
rect += topleft_client + v2s32(25, ypos + 6);
core::rect<s32> rect(0, 0, 150 * s, 20 * s);
rect += topleft_client + v2s32(25 * s, ypos + 6 * s);
text = wgettext("Confirm Password");
Environment->addStaticText(text, rect, false, true, this, -1);
delete[] text;
}
{
core::rect<s32> rect(0, 0, 230, 30);
rect += topleft_client + v2s32(160, ypos);
core::rect<s32> rect(0, 0, 230 * s, 30 * s);
rect += topleft_client + v2s32(160 * s, ypos);
gui::IGUIEditBox *e = Environment->addEditBox(
m_newpass_confirm.c_str(), rect, true, this, ID_newPassword2);
e->setPasswordBox(true);
}
ypos += 50;
ypos += 50 * s;
{
core::rect<s32> rect(0, 0, 100, 30);
rect = rect + v2s32(size.X / 4 + 56, ypos);
core::rect<s32> rect(0, 0, 100 * s, 30 * s);
rect = rect + v2s32(size.X / 4 + 56 * s, ypos);
text = wgettext("Change");
Environment->addButton(rect, this, ID_change, text);
delete[] text;
}
{
core::rect<s32> rect(0, 0, 100, 30);
rect = rect + v2s32(size.X / 4 + 185, ypos);
core::rect<s32> rect(0, 0, 100 * s, 30 * s);
rect = rect + v2s32(size.X / 4 + 185 * s, ypos);
text = wgettext("Cancel");
Environment->addButton(rect, this, ID_cancel, text);
delete[] text;
}
ypos += 50;
ypos += 50 * s;
{
core::rect<s32> rect(0, 0, 300, 20);
rect += topleft_client + v2s32(35, ypos);
core::rect<s32> rect(0, 0, 300 * s, 20 * s);
rect += topleft_client + v2s32(35 * s, ypos);
text = wgettext("Passwords do not match!");
IGUIElement *e =
Environment->addStaticText(

View File

@ -41,7 +41,7 @@ void GUIFileSelectMenu::regenerateGui(v2u32 screensize)
removeChildren();
m_fileOpenDialog = 0;
core::dimension2du size(600, 400);
core::dimension2du size(600 * m_gui_scale, 400 * m_gui_scale);
core::rect<s32> rect(0, 0, screensize.X, screensize.Y);
DesiredRect = rect;

View File

@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h" // for parseColorString()
#include "settings.h" // for settings
#include "porting.h" // for dpi
#include "guiscalingfilter.h"
#include "client/guiscalingfilter.h"
/*
GUITable

View File

@ -66,15 +66,15 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize)
Remove stuff
*/
removeChildren();
/*
Calculate new sizes and positions
*/
const float s = m_gui_scale;
DesiredRect = core::rect<s32>(
screensize.X/2 - 380/2,
screensize.Y/2 - 200/2,
screensize.X/2 + 380/2,
screensize.Y/2 + 200/2
screensize.X / 2 - 380 * s / 2,
screensize.Y / 2 - 200 * s / 2,
screensize.X / 2 + 380 * s / 2,
screensize.Y / 2 + 200 * s / 2
);
recalculateAbsolutePosition(false);
@ -85,8 +85,8 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize)
Add stuff
*/
{
core::rect<s32> rect(0, 0, 160, 20);
rect = rect + v2s32(size.X / 2 - 80, size.Y / 2 - 70);
core::rect<s32> rect(0, 0, 160 * s, 20 * s);
rect = rect + v2s32(size.X / 2 - 80 * s, size.Y / 2 - 70 * s);
const wchar_t *text = wgettext("Sound Volume: ");
core::stringw volume_text = text;
@ -97,24 +97,24 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize)
true, this, ID_soundText);
}
{
core::rect<s32> rect(0, 0, 80, 30);
rect = rect + v2s32(size.X/2-80/2, size.Y/2+55);
core::rect<s32> rect(0, 0, 80 * s, 30 * s);
rect = rect + v2s32(size.X / 2 - 80 * s / 2, size.Y / 2 + 55 * s);
const wchar_t *text = wgettext("Exit");
Environment->addButton(rect, this, ID_soundExitButton,
text);
delete[] text;
}
{
core::rect<s32> rect(0, 0, 300, 20);
rect = rect + v2s32(size.X / 2 - 150, size.Y / 2);
core::rect<s32> rect(0, 0, 300 * s, 20 * s);
rect = rect + v2s32(size.X / 2 - 150 * s, size.Y / 2);
gui::IGUIScrollBar *e = Environment->addScrollBar(true,
rect, this, ID_soundSlider);
e->setMax(100);
e->setPos(volume);
}
{
core::rect<s32> rect(0, 0, 160, 20);
rect = rect + v2s32(size.X / 2 - 80, size.Y / 2 - 35);
core::rect<s32> rect(0, 0, 160 * s, 20 * s);
rect = rect + v2s32(size.X / 2 - 80 * s, size.Y / 2 - 35 * s);
const wchar_t *text = wgettext("Muted");
Environment->addCheckBox(g_settings->getBool("mute_sound"), rect, this,
ID_soundMuteButton, text);

View File

@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "modalMenu.h"
#include "gettext.h"
#include "porting.h"
#include "settings.h"
#ifdef HAVE_TOUCHSCREENGUI
#include "touchscreengui.h"
@ -37,6 +38,11 @@ GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
#endif
m_menumgr(menumgr)
{
m_gui_scale = g_settings->getFloat("gui_scaling");
#ifdef __ANDROID__
float d = porting::getDisplayDensity();
m_gui_scale *= 1.1 - 0.3 * d + 0.2 * d * d;
#endif
setVisible(true);
Environment->setFocus(this);
m_menumgr->createdMenu(this);

View File

@ -65,6 +65,7 @@ protected:
v2s32 m_pointer;
v2s32 m_old_pointer; // Mouse position after previous mouse event
v2u32 m_screensize_old;
float m_gui_scale;
#ifdef __ANDROID__
v2s32 m_down_pos;
std::string m_jni_field_name;

View File

@ -24,11 +24,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "tool.h"
#include "inventory.h"
#ifndef SERVER
#include "mapblock_mesh.h"
#include "mesh.h"
#include "wieldmesh.h"
#include "client/mapblock_mesh.h"
#include "client/mesh.h"
#include "client/wieldmesh.h"
#include "client/tile.h"
#include "client.h"
#include "client/client.h"
#endif
#include "log.h"
#include "settings.h"

View File

@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "server.h"
#include "filesys.h"
#include "version.h"
#include "game.h"
#include "client/game.h"
#include "defaultsettings.h"
#include "gettext.h"
#include "log.h"

View File

@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_nodemeta.h" // For legacy deserialization
#include "serialization.h"
#ifndef SERVER
#include "mapblock_mesh.h"
#include "client/mapblock_mesh.h"
#endif
#include "porting.h"
#include "util/string.h"

View File

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
#include "client.h"
#include "client/client.h"
#include "networkprotocol.h"
class NetworkPacket;

View File

@ -17,15 +17,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "client.h"
#include "client/client.h"
#include "util/base64.h"
#include "chatmessage.h"
#include "clientmedia.h"
#include "client/clientmedia.h"
#include "log.h"
#include "map.h"
#include "mapsector.h"
#include "minimap.h"
#include "client/minimap.h"
#include "modchannels.h"
#include "nodedef.h"
#include "serialization.h"

View File

@ -473,8 +473,8 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
playersao->setBasePosition(position);
player->setSpeed(speed);
playersao->setPitch(pitch);
playersao->setYaw(yaw);
playersao->setLookPitch(pitch);
playersao->setPlayerYaw(yaw);
playersao->setFov(fov);
playersao->setWantedRange(wanted_range);
player->keyPressed = keyPressed;

View File

@ -21,9 +21,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemdef.h"
#ifndef SERVER
#include "mesh.h"
#include "shader.h"
#include "client.h"
#include "client/mesh.h"
#include "client/shader.h"
#include "client/client.h"
#include "client/renderingengine.h"
#include "client/tile.h"
#include <IMeshManipulator.h>

View File

@ -110,10 +110,10 @@ void RemotePlayer::deSerialize(std::istream &is, const std::string &playername,
} catch (SettingNotFoundException &e) {}
try {
sao->setPitch(args.getFloat("pitch"));
sao->setLookPitch(args.getFloat("pitch"));
} catch (SettingNotFoundException &e) {}
try {
sao->setYaw(args.getFloat("yaw"));
sao->setPlayerYaw(args.getFloat("yaw"));
} catch (SettingNotFoundException &e) {}
try {
@ -172,8 +172,8 @@ void RemotePlayer::serialize(std::ostream &os)
assert(m_sao);
args.setS32("hp", m_sao->getHP());
args.setV3F("position", m_sao->getBasePosition());
args.setFloat("pitch", m_sao->getPitch());
args.setFloat("yaw", m_sao->getYaw());
args.setFloat("pitch", m_sao->getLookPitch());
args.setFloat("yaw", m_sao->getRotation().Y);
args.setS32("breath", m_sao->getBreath());
std::string extended_attrs;

View File

@ -27,7 +27,9 @@ std::string script_get_backtrace(lua_State *L)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_BACKTRACE);
lua_call(L, 0, 1);
return luaL_checkstring(L, -1);
std::string result = luaL_checkstring(L, -1);
lua_pop(L, 1);
return result;
}
int script_exception_wrapper(lua_State *L, lua_CFunction f)

View File

@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h"
#include "server.h"
#ifndef SERVER
#include "client.h"
#include "client/client.h"
#endif

View File

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "s_client.h"
#include "s_internal.h"
#include "client.h"
#include "client/client.h"
#include "common/c_converter.h"
#include "common/c_content.h"
#include "s_item.h"

View File

@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "porting.h"
#include "server.h"
#include "client.h"
#include "client/client.h"
#include "settings.h"
#include <cerrno>

View File

@ -21,9 +21,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <cmath>
#include "script/common/c_converter.h"
#include "l_internal.h"
#include "content_cao.h"
#include "camera.h"
#include "client.h"
#include "client/content_cao.h"
#include "client/camera.h"
#include "client/client.h"
LuaCamera::LuaCamera(Camera *m) : m_camera(m)
{

View File

@ -20,10 +20,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "l_client.h"
#include "chatmessage.h"
#include "client.h"
#include "client/client.h"
#include "client/clientevent.h"
#include "client/sound.h"
#include "clientenvironment.h"
#include "client/clientenvironment.h"
#include "common/c_content.h"
#include "common/c_converter.h"
#include "cpp_api/s_base.h"

View File

@ -40,7 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "face_position_cache.h"
#include "remoteplayer.h"
#ifndef SERVER
#include "client.h"
#include "client/client.h"
#endif
struct EnumString ModApiEnvMod::es_ClearObjectsMode[] =

View File

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "l_localplayer.h"
#include "l_internal.h"
#include "script/common/c_converter.h"
#include "localplayer.h"
#include "client/localplayer.h"
#include "hud.h"
#include "common/c_content.h"

View File

@ -21,8 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_minimap.h"
#include "lua_api/l_internal.h"
#include "common/c_converter.h"
#include "client.h"
#include "minimap.h"
#include "client/client.h"
#include "client/minimap.h"
#include "settings.h"
LuaMinimap::LuaMinimap(Minimap *m) : m_minimap(m)

View File

@ -889,19 +889,51 @@ int ObjectRef::l_get_acceleration(lua_State *L)
return 1;
}
// set_rotation(self, {x=num, y=num, z=num})
// Each 'num' is in radians
int ObjectRef::l_set_rotation(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
LuaEntitySAO *co = getluaobject(ref);
if (!co)
return 0;
v3f rotation = check_v3f(L, 2) * core::RADTODEG;
co->setRotation(rotation);
return 0;
}
// get_rotation(self)
// returns: {x=num, y=num, z=num}
// Each 'num' is in radians
int ObjectRef::l_get_rotation(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
LuaEntitySAO *co = getluaobject(ref);
if (!co)
return 0;
lua_newtable(L);
v3f rotation = co->getRotation() * core::DEGTORAD;
push_v3f(L, rotation);
return 1;
}
// set_yaw(self, radians)
int ObjectRef::l_set_yaw(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
LuaEntitySAO *co = getluaobject(ref);
if (co == NULL) return 0;
if (isNaN(L, 2))
throw LuaError("ObjectRef::set_yaw: NaN value is not allowed.");
float yaw = readParam<float>(L, 2) * core::RADTODEG;
// Do it
co->setYaw(yaw);
co->setRotation(v3f(0, yaw, 0));
return 0;
}
@ -911,9 +943,10 @@ int ObjectRef::l_get_yaw(lua_State *L)
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
LuaEntitySAO *co = getluaobject(ref);
if (co == NULL) return 0;
// Do it
float yaw = co->getYaw() * core::DEGTORAD;
if (!co)
return 0;
float yaw = co->getRotation().Y * core::DEGTORAD;
lua_pushnumber(L, yaw);
return 1;
}
@ -1046,7 +1079,7 @@ int ObjectRef::l_get_look_dir(lua_State *L)
PlayerSAO* co = getplayersao(ref);
if (co == NULL) return 0;
// Do it
float pitch = co->getRadPitchDep();
float pitch = co->getRadLookPitchDep();
float yaw = co->getRadYawDep();
v3f v(std::cos(pitch) * std::cos(yaw), std::sin(pitch), std::cos(pitch) *
std::sin(yaw));
@ -1067,7 +1100,7 @@ int ObjectRef::l_get_look_pitch(lua_State *L)
PlayerSAO* co = getplayersao(ref);
if (co == NULL) return 0;
// Do it
lua_pushnumber(L, co->getRadPitchDep());
lua_pushnumber(L, co->getRadLookPitchDep());
return 1;
}
@ -1096,7 +1129,7 @@ int ObjectRef::l_get_look_vertical(lua_State *L)
PlayerSAO* co = getplayersao(ref);
if (co == NULL) return 0;
// Do it
lua_pushnumber(L, co->getRadPitch());
lua_pushnumber(L, co->getRadLookPitch());
return 1;
}
@ -1108,7 +1141,7 @@ int ObjectRef::l_get_look_horizontal(lua_State *L)
PlayerSAO* co = getplayersao(ref);
if (co == NULL) return 0;
// Do it
lua_pushnumber(L, co->getRadYaw());
lua_pushnumber(L, co->getRadRotation().Y);
return 1;
}
@ -1121,7 +1154,7 @@ int ObjectRef::l_set_look_vertical(lua_State *L)
if (co == NULL) return 0;
float pitch = readParam<float>(L, 2) * core::RADTODEG;
// Do it
co->setPitchAndSend(pitch);
co->setLookPitchAndSend(pitch);
return 1;
}
@ -1134,7 +1167,7 @@ int ObjectRef::l_set_look_horizontal(lua_State *L)
if (co == NULL) return 0;
float yaw = readParam<float>(L, 2) * core::RADTODEG;
// Do it
co->setYawAndSend(yaw);
co->setPlayerYawAndSend(yaw);
return 1;
}
@ -1152,7 +1185,7 @@ int ObjectRef::l_set_look_pitch(lua_State *L)
if (co == NULL) return 0;
float pitch = readParam<float>(L, 2) * core::RADTODEG;
// Do it
co->setPitchAndSend(pitch);
co->setLookPitchAndSend(pitch);
return 1;
}
@ -1170,7 +1203,7 @@ int ObjectRef::l_set_look_yaw(lua_State *L)
if (co == NULL) return 0;
float yaw = readParam<float>(L, 2) * core::RADTODEG;
// Do it
co->setYawAndSend(yaw);
co->setPlayerYawAndSend(yaw);
return 1;
}
@ -1861,6 +1894,8 @@ luaL_Reg ObjectRef::methods[] = {
luamethod_aliased(ObjectRef, get_acceleration, getacceleration),
luamethod_aliased(ObjectRef, set_yaw, setyaw),
luamethod_aliased(ObjectRef, get_yaw, getyaw),
luamethod(ObjectRef, set_rotation),
luamethod(ObjectRef, get_rotation),
luamethod_aliased(ObjectRef, set_texture_mod, settexturemod),
luamethod_aliased(ObjectRef, set_sprite, setsprite),
luamethod(ObjectRef, get_entity_name),

View File

@ -172,6 +172,12 @@ private:
// get_acceleration(self)
static int l_get_acceleration(lua_State *L);
// set_rotation(self, {x=num, y=num, z=num})
static int l_set_rotation(lua_State *L);
// get_rotation(self)
static int l_get_rotation(lua_State *L);
// set_yaw(self, radians)
static int l_set_yaw(lua_State *L);

Some files were not shown because too many files have changed in this diff Show More