1
0

Compare commits

..

5 Commits

14 changed files with 44 additions and 13 deletions

View File

@ -23,7 +23,7 @@ local function vector_absmax(v)
return max(max(abs(v.x), abs(v.y)), abs(v.z)) return max(max(abs(v.x), abs(v.y)), abs(v.z))
end end
local vdivide, vlength, vsubtract = vector.divide, vector.length, vector.subtract local vadd, vdivide, vlength, vsubtract = vector.add, vector.divide, vector.length, vector.subtract
core.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, unused_dir, damage) core.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, unused_dir, damage)
if player:get_hp() == 0 then if player:get_hp() == 0 then
return -- RIP return -- RIP
@ -31,7 +31,8 @@ core.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool
-- Server::handleCommand_Interact() adds eye offset to one but not the other -- Server::handleCommand_Interact() adds eye offset to one but not the other
-- so the direction is slightly off, calculate it ourselves -- so the direction is slightly off, calculate it ourselves
local dir = vsubtract(player:get_pos(), hitter:get_pos()) local player_pos = player:get_pos()
local dir = vsubtract(player_pos, hitter:get_pos())
local d = vlength(dir) local d = vlength(dir)
if d ~= 0.0 then if d ~= 0.0 then
dir = vdivide(dir, d) dir = vdivide(dir, d)
@ -44,5 +45,7 @@ core.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool
return -- barely noticeable, so don't even send return -- barely noticeable, so don't even send
end end
player:add_velocity(kdir) if core.is_valid_pos(vadd(player_pos, kdir)) then
player:add_velocity(kdir)
end
end) end)

View File

@ -408,6 +408,10 @@ keymap_slot31 (Hotbar slot 31 key) key
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot32 (Hotbar slot 32 key) key keymap_slot32 (Hotbar slot 32 key) key
# Key for use by mods.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_tabb (Tab key) key KEY_TAB
# Key for toggling the display of the HUD. # Key for toggling the display of the HUD.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_toggle_hud (HUD toggle key) key KEY_F1 keymap_toggle_hud (HUD toggle key) key KEY_F1

View File

@ -6547,7 +6547,7 @@ object you are working with still exists.
* `get_player_control()`: returns table with player pressed keys * `get_player_control()`: returns table with player pressed keys
* The table consists of fields with the following boolean values * The table consists of fields with the following boolean values
representing the pressed keys: `up`, `down`, `left`, `right`, `jump`, representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
`aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`. `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, `zoom`, and `tabb`.
* The fields `LMB` and `RMB` are equal to `dig` and `place` respectively, * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
and exist only to preserve backwards compatibility. and exist only to preserve backwards compatibility.
* `get_player_control_bits()`: returns integer with bit packed player pressed * `get_player_control_bits()`: returns integer with bit packed player pressed
@ -6562,6 +6562,7 @@ object you are working with still exists.
* 7 - dig * 7 - dig
* 8 - place * 8 - place
* 9 - zoom * 9 - zoom
* 10 - tabb
* `set_physics_override(override_table)` * `set_physics_override(override_table)`
* `override_table` is a table with the following fields: * `override_table` is a table with the following fields:
* `speed`: multiplier to default walking speed value (default: `1`) * `speed`: multiplier to default walking speed value (default: `1`)

View File

@ -449,6 +449,11 @@
# type: key # type: key
# keymap_slot32 = # keymap_slot32 =
# Key for use by mods.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_tabb = KEY_TAB
# Key for toggling the display of the HUD. # Key for toggling the display of the HUD.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key # type: key

View File

@ -2530,6 +2530,7 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
isKeyDown(KeyType::SPECIAL1), isKeyDown(KeyType::SPECIAL1),
isKeyDown(KeyType::SNEAK), isKeyDown(KeyType::SNEAK),
isKeyDown(KeyType::ZOOM), isKeyDown(KeyType::ZOOM),
isKeyDown(KeyType::TABB),
isKeyDown(KeyType::DIG), isKeyDown(KeyType::DIG),
isKeyDown(KeyType::PLACE), isKeyDown(KeyType::PLACE),
cam.camera_pitch, cam.camera_pitch,
@ -2553,7 +2554,8 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
( (u32)(isKeyDown(KeyType::SNEAK) & 0x1) << 6) | ( (u32)(isKeyDown(KeyType::SNEAK) & 0x1) << 6) |
( (u32)(isKeyDown(KeyType::DIG) & 0x1) << 7) | ( (u32)(isKeyDown(KeyType::DIG) & 0x1) << 7) |
( (u32)(isKeyDown(KeyType::PLACE) & 0x1) << 8) | ( (u32)(isKeyDown(KeyType::PLACE) & 0x1) << 8) |
( (u32)(isKeyDown(KeyType::ZOOM) & 0x1) << 9) ( (u32)(isKeyDown(KeyType::ZOOM) & 0x1) << 9) |
( (u32)(isKeyDown(KeyType::TABB) & 0x1) << 10)
); );
LocalPlayer *player = client->getEnv().getLocalPlayer(); LocalPlayer *player = client->getEnv().getLocalPlayer();

View File

@ -90,6 +90,8 @@ void KeyCache::populate()
key[KeyType::QUICKTUNE_INC] = getKeySetting("keymap_quicktune_inc"); key[KeyType::QUICKTUNE_INC] = getKeySetting("keymap_quicktune_inc");
key[KeyType::QUICKTUNE_DEC] = getKeySetting("keymap_quicktune_dec"); key[KeyType::QUICKTUNE_DEC] = getKeySetting("keymap_quicktune_dec");
key[KeyType::TABB] = getKeySetting("keymap_tabb");
for (int i = 0; i < HUD_HOTBAR_ITEMCOUNT_MAX; i++) { for (int i = 0; i < HUD_HOTBAR_ITEMCOUNT_MAX; i++) {
std::string slot_key_name = "keymap_slot" + std::to_string(i + 1); std::string slot_key_name = "keymap_slot" + std::to_string(i + 1);
key[KeyType::SLOT_1 + i] = getKeySetting(slot_key_name.c_str()); key[KeyType::SLOT_1 + i] = getKeySetting(slot_key_name.c_str());
@ -111,14 +113,14 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
if (event.EventType == irr::EET_SDL_CONTROLLER_BUTTON_EVENT || if (event.EventType == irr::EET_SDL_CONTROLLER_BUTTON_EVENT ||
event.EventType == irr::EET_SDL_CONTROLLER_AXIS_EVENT) { event.EventType == irr::EET_SDL_CONTROLLER_AXIS_EVENT) {
if (g_settings->getBool("enable_joysticks")) { if (g_settings->getBool("enable_joysticks") && sdl_game_controller) {
sdl_game_controller->translateEvent(event); sdl_game_controller->translateEvent(event);
input->setCursorVisible(sdl_game_controller->isCursorVisible()); input->setCursorVisible(sdl_game_controller->isCursorVisible());
} }
} else if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT && } else if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == irr::EMIE_MOUSE_MOVED) || event.MouseInput.Event == irr::EMIE_MOUSE_MOVED) ||
event.EventType == irr::EET_TOUCH_INPUT_EVENT) { event.EventType == irr::EET_TOUCH_INPUT_EVENT) {
if (!sdl_game_controller->isFakeEvent() && if (sdl_game_controller && !sdl_game_controller->isFakeEvent() &&
sdl_game_controller->isActive()) { sdl_game_controller->isActive()) {
sdl_game_controller->setActive(false); sdl_game_controller->setActive(false);
input->setCursorVisible(sdl_game_controller->isCursorVisible()); input->setCursorVisible(sdl_game_controller->isCursorVisible());
@ -133,7 +135,7 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
m_touchscreengui->show(); m_touchscreengui->show();
} else if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT && } else if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == irr::EMIE_MOUSE_MOVED) || event.MouseInput.Event == irr::EMIE_MOUSE_MOVED) ||
sdl_game_controller->isActive()) { (sdl_game_controller && sdl_game_controller->isActive())) {
TouchScreenGUI::setActive(false); TouchScreenGUI::setActive(false);
if (m_touchscreengui && !isMenuActive()) if (m_touchscreengui && !isMenuActive())
m_touchscreengui->hide(); m_touchscreengui->hide();
@ -204,7 +206,10 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
if (event.JoystickEvent != joystick_we_listen_for) if (event.JoystickEvent != joystick_we_listen_for)
return false; return false;
*/ */
return joystick->handleEvent(event.JoystickEvent); if (joystick)
return joystick->handleEvent(event.JoystickEvent);
else
return true;
} else if (event.EventType == irr::EET_MOUSE_INPUT_EVENT) { } else if (event.EventType == irr::EET_MOUSE_INPUT_EVENT) {
// Handle mouse events // Handle mouse events
KeyPress key; KeyPress key;

View File

@ -76,6 +76,8 @@ public:
QUICKTUNE_INC, QUICKTUNE_INC,
QUICKTUNE_DEC, QUICKTUNE_DEC,
TABB,
// hotbar // hotbar
SLOT_1, SLOT_1,
SLOT_2, SLOT_2,

View File

@ -159,6 +159,8 @@ void set_default_settings()
settings->setDefault("keymap_quicktune_dec", "KEY_NEXT"); settings->setDefault("keymap_quicktune_dec", "KEY_NEXT");
settings->setDefault("keymap_quicktune_inc", "KEY_PRIOR"); settings->setDefault("keymap_quicktune_inc", "KEY_PRIOR");
settings->setDefault("keymap_tabb", "KEY_TAB");
// Visuals // Visuals
#ifdef NDEBUG #ifdef NDEBUG
settings->setDefault("show_debug", "false"); settings->setDefault("show_debug", "false");

View File

@ -525,6 +525,7 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
player->control.dig = (keyPressed & (0x1 << 7)); player->control.dig = (keyPressed & (0x1 << 7));
player->control.place = (keyPressed & (0x1 << 8)); player->control.place = (keyPressed & (0x1 << 8));
player->control.zoom = (keyPressed & (0x1 << 9)); player->control.zoom = (keyPressed & (0x1 << 9));
player->control.tabb = (keyPressed & (0x1 << 10));
if (playersao->checkMovementCheat()) { if (playersao->checkMovementCheat()) {
// Call callbacks // Call callbacks

View File

@ -57,6 +57,7 @@ struct PlayerControl
bool a_aux1, bool a_aux1,
bool a_sneak, bool a_sneak,
bool a_zoom, bool a_zoom,
bool a_tabb,
bool a_dig, bool a_dig,
bool a_place, bool a_place,
float a_pitch, float a_pitch,
@ -73,6 +74,7 @@ struct PlayerControl
aux1 = a_aux1; aux1 = a_aux1;
sneak = a_sneak; sneak = a_sneak;
zoom = a_zoom; zoom = a_zoom;
tabb = a_tabb;
dig = a_dig; dig = a_dig;
place = a_place; place = a_place;
pitch = a_pitch; pitch = a_pitch;
@ -88,6 +90,7 @@ struct PlayerControl
bool aux1 = false; bool aux1 = false;
bool sneak = false; bool sneak = false;
bool zoom = false; bool zoom = false;
bool tabb = false;
bool dig = false; bool dig = false;
bool place = false; bool place = false;
float pitch = 0.0f; float pitch = 0.0f;

View File

@ -231,6 +231,7 @@ int LuaLocalPlayer::l_get_control(lua_State *L)
set("aux1", c.aux1); set("aux1", c.aux1);
set("sneak", c.sneak); set("sneak", c.sneak);
set("zoom", c.zoom); set("zoom", c.zoom);
set("tabb", c.tabb);
set("dig", c.dig); set("dig", c.dig);
set("place", c.place); set("place", c.place);

View File

@ -1417,6 +1417,8 @@ int ObjectRef::l_get_player_control(lua_State *L)
lua_setfield(L, -2, "RMB"); lua_setfield(L, -2, "RMB");
lua_pushboolean(L, control.zoom); lua_pushboolean(L, control.zoom);
lua_setfield(L, -2, "zoom"); lua_setfield(L, -2, "zoom");
lua_pushboolean(L, control.tabb);
lua_setfield(L, -2, "tabb");
return 1; return 1;
} }

View File

@ -3312,7 +3312,7 @@ std::string Server::getStatusString()
// Disabled due to misuse. // Disabled due to misuse.
// Information about clients // Information about clients
/*bool first = true; bool first = true;
os << ", clients={"; os << ", clients={";
if (m_env) { if (m_env) {
std::vector<session_t> clients = m_clients.getClientIDs(); std::vector<session_t> clients = m_clients.getClientIDs();
@ -3330,7 +3330,7 @@ std::string Server::getStatusString()
os << name; os << name;
} }
} }
os << "}";*/ os << "}";
if (m_env && !((ServerMap*)(&m_env->getMap()))->isSavingEnabled()) if (m_env && !((ServerMap*)(&m_env->getMap()))->isSavingEnabled())
os << std::endl << "# Server: " << " WARNING: Map saving is disabled."; os << std::endl << "# Server: " << " WARNING: Map saving is disabled.";

View File

@ -100,10 +100,10 @@ void sendAnnounce(AnnounceAction action,
server["mapgen"] = mg_name; server["mapgen"] = mg_name;
server["privs"] = g_settings->get("default_privs"); server["privs"] = g_settings->get("default_privs");
server["can_see_far_names"] = g_settings->getS16("player_transfer_distance") <= 0; server["can_see_far_names"] = g_settings->getS16("player_transfer_distance") <= 0;
/*server["mods"] = Json::Value(Json::arrayValue); server["mods"] = Json::Value(Json::arrayValue);
for (const ModSpec &mod : mods) { for (const ModSpec &mod : mods) {
server["mods"].append(mod.name); server["mods"].append(mod.name);
}*/ }
} else if (action == AA_UPDATE) { } else if (action == AA_UPDATE) {
if (lag) if (lag)
server["lag"] = lag; server["lag"] = lag;