aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/client.h6
-rw-r--r--src/client/content_cao.cpp3
-rw-r--r--src/client/game.cpp50
-rw-r--r--src/client/game.h3
-rw-r--r--src/client/inputhandler.cpp3
-rw-r--r--src/client/keys.h5
-rw-r--r--src/client/mapblock_mesh.cpp20
-rw-r--r--src/client/mesh_generator_thread.h2
-rw-r--r--src/gui/guiInventoryList.cpp45
-rw-r--r--src/gui/guiInventoryList.h8
-rw-r--r--src/network/clientpackethandler.cpp9
-rw-r--r--src/nodedef.cpp6
-rw-r--r--src/script/lua_api/l_localplayer.cpp2
13 files changed, 127 insertions, 35 deletions
diff --git a/src/client/client.h b/src/client/client.h
index 1e6ba4140..3c0c133e0 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -445,6 +445,10 @@ public:
{
return m_env.getLocalPlayer()->formspec_prepend;
}
+
+ void sendPlayerPos();
+ MeshUpdateThread m_mesh_update_thread;
+
private:
void loadMods();
bool checkBuiltinIntegrity();
@@ -459,7 +463,6 @@ private:
void ReceiveAll();
- void sendPlayerPos();
void deleteAuthData();
// helper method shared with clientpackethandler
@@ -492,7 +495,6 @@ private:
MtEventManager *m_event;
- MeshUpdateThread m_mesh_update_thread;
ClientEnvironment m_env;
ParticleManager m_particle_manager;
std::unique_ptr<con::Connection> m_con;
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index 5d719293a..fa2ed43c9 100644
--- a/src/client/content_cao.cpp
+++ b/src/client/content_cao.cpp
@@ -793,6 +793,9 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
void GenericCAO::updateLight(u8 light_at_pos)
{
+ if (g_settings->getBool("fullbright"))
+ light_at_pos = 255;
+
// Don't update light of attached one
if (getParent() != NULL) {
return;
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 9f8eb8c94..7c2249296 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -1069,6 +1069,12 @@ void Game::processKeyInput()
toggleFast();
} else if (wasKeyDown(KeyType::NOCLIP)) {
toggleNoClip();
+ } else if (wasKeyDown(KeyType::XRAY)) {
+ toggleXray();
+ } else if (wasKeyDown(KeyType::FULLBRIGHT)) {
+ toggleFullbright();
+ } else if (wasKeyDown(KeyType::KILLAURA)) {
+ toggleKillaura();
} else if (wasKeyDown(KeyType::MUTE)) {
bool new_mute_sound = !g_settings->getBool("mute_sound");
g_settings->setBool("mute_sound", new_mute_sound);
@@ -1327,6 +1333,44 @@ void Game::toggleNoClip()
}
}
+void Game::toggleXray()
+{
+ bool xray = ! g_settings->getBool("xray");
+ g_settings->set("xray", bool_to_cstr(xray));
+
+ if (xray) {
+ m_game_ui->showTranslatedStatusText("Xray enabled");
+ } else {
+ m_game_ui->showTranslatedStatusText("Xray disabled");
+ }
+ client->m_mesh_update_thread.doUpdate();
+}
+
+void Game::toggleFullbright()
+{
+ bool fullbright = ! g_settings->getBool("fullbright");
+ g_settings->set("fullbright", bool_to_cstr(fullbright));
+
+ if (fullbright) {
+ m_game_ui->showTranslatedStatusText("Fullbright enabled");
+ } else {
+ m_game_ui->showTranslatedStatusText("Fullbright disabled");
+ }
+ client->m_mesh_update_thread.doUpdate();
+}
+
+void Game::toggleKillaura()
+{
+ bool killaura = ! g_settings->getBool("killaura");
+ g_settings->set("killaura", bool_to_cstr(killaura));
+
+ if (killaura) {
+ m_game_ui->showTranslatedStatusText("Killaura enabled");
+ } else {
+ m_game_ui->showTranslatedStatusText("Killaura disabled");
+ }
+}
+
void Game::toggleCinematic()
{
bool cinematic = !g_settings->getBool("cinematic");
@@ -2181,7 +2225,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
f32 d = getToolRange(selected_def, hand_item.getDefinition(itemdef_manager));
if(g_settings->getBool("increase_tool_range"))
- d = 1000;
+ d = 5;
core::line3d<f32> shootline;
@@ -2697,7 +2741,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed,
m_game_ui->setInfoText(infotext);
- if (input->getLeftState() || g_settings->getBool("killaura")) {
+ if (input->getLeftState() || (g_settings->getBool("killaura") && ! g_settings->getBool("killaura_fast"))) {
bool do_punch = false;
bool do_punch_damage = false;
@@ -2707,7 +2751,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed,
runData.object_hit_delay_timer = object_hit_delay;
}
- if (input->getLeftClicked() || g_settings->getBool("killaura"))
+ if (input->getLeftClicked() || (g_settings->getBool("killaura") && ! g_settings->getBool("killaura_fast")))
do_punch = true;
if (do_punch) {
diff --git a/src/client/game.h b/src/client/game.h
index c1afb79fa..43b366057 100644
--- a/src/client/game.h
+++ b/src/client/game.h
@@ -736,6 +736,9 @@ public:
void togglePitchMove();
void toggleFast();
void toggleNoClip();
+ void toggleXray();
+ void toggleFullbright();
+ void toggleKillaura();
void toggleCinematic();
void toggleAutoforward();
diff --git a/src/client/inputhandler.cpp b/src/client/inputhandler.cpp
index a79b04a90..b8c236b8d 100644
--- a/src/client/inputhandler.cpp
+++ b/src/client/inputhandler.cpp
@@ -71,6 +71,9 @@ void KeyCache::populate()
getKeySetting("keymap_decrease_viewing_range_min");
key[KeyType::RANGESELECT] = getKeySetting("keymap_rangeselect");
key[KeyType::ZOOM] = getKeySetting("keymap_zoom");
+ key[KeyType::XRAY] = "KEY_KEY_X";
+ key[KeyType::FULLBRIGHT] = "KEY_KEY_F";
+ key[KeyType::KILLAURA] = "KEY_KEY_C";
key[KeyType::QUICKTUNE_NEXT] = getKeySetting("keymap_quicktune_next");
key[KeyType::QUICKTUNE_PREV] = getKeySetting("keymap_quicktune_prev");
diff --git a/src/client/keys.h b/src/client/keys.h
index 50d3d194b..08f5e36ab 100644
--- a/src/client/keys.h
+++ b/src/client/keys.h
@@ -68,7 +68,10 @@ public:
DECREASE_VIEWING_RANGE,
RANGESELECT,
ZOOM,
-
+ XRAY,
+ FULLBRIGHT,
+ KILLAURA,
+
QUICKTUNE_NEXT,
QUICKTUNE_PREV,
QUICKTUNE_INC,
diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp
index c165438a0..ec8967366 100644
--- a/src/client/mapblock_mesh.cpp
+++ b/src/client/mapblock_mesh.cpp
@@ -681,6 +681,7 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent,
u8 c1 = f1.solidness;
u8 c2 = f2.solidness;
+
if (c1 == c2)
return 0;
@@ -689,6 +690,7 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent,
else if (c2 == 0)
c2 = f2.visual_solidness;
+
if (c1 == c2) {
*equivalent = true;
// If same solidness, liquid takes precense
@@ -805,25 +807,35 @@ static void getTileInfo(
VoxelManipulator &vmanip = data->m_vmanip;
const NodeDefManager *ndef = data->m_client->ndef();
v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
-
+ content_t cXray = ndef->getId(g_settings->get("xray_node"));
+ bool xray = g_settings->getBool("xray");
+
const MapNode &n0 = vmanip.getNodeRefUnsafe(blockpos_nodes + p);
+ content_t c0 = n0.getContent();
+ if (xray && c0 == cXray)
+ c0 = CONTENT_AIR;
+
// Don't even try to get n1 if n0 is already CONTENT_IGNORE
- if (n0.getContent() == CONTENT_IGNORE) {
+ if (c0 == CONTENT_IGNORE) {
makes_face = false;
return;
}
const MapNode &n1 = vmanip.getNodeRefUnsafeCheckFlags(blockpos_nodes + p + face_dir);
- if (n1.getContent() == CONTENT_IGNORE) {
+ content_t c1 = n1.getContent();
+ if (xray && c1 == cXray)
+ c1 = CONTENT_AIR;
+
+ if (c1 == CONTENT_IGNORE) {
makes_face = false;
return;
}
// This is hackish
bool equivalent = false;
- u8 mf = face_contents(n0.getContent(), n1.getContent(),
+ u8 mf = face_contents(c0, c1,
&equivalent, ndef);
if (mf == 0) {
diff --git a/src/client/mesh_generator_thread.h b/src/client/mesh_generator_thread.h
index 9a42852a3..2bb74589e 100644
--- a/src/client/mesh_generator_thread.h
+++ b/src/client/mesh_generator_thread.h
@@ -126,6 +126,6 @@ private:
// TODO: Add callback to update these when g_settings changes
int m_generation_interval;
-protected:
+public:
virtual void doUpdate();
};
diff --git a/src/gui/guiInventoryList.cpp b/src/gui/guiInventoryList.cpp
index 536471229..58d7ae771 100644
--- a/src/gui/guiInventoryList.cpp
+++ b/src/gui/guiInventoryList.cpp
@@ -1,17 +1,14 @@
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
-
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
-
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
-
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -47,7 +44,8 @@ GUIInventoryList::GUIInventoryList(gui::IGUIEnvironment *env,
m_fs_menu(fs_menu),
m_options(options),
m_font(font),
- m_hovered_i(-1)
+ m_hovered_i(-1),
+ m_already_warned(false)
{
}
@@ -58,20 +56,27 @@ void GUIInventoryList::draw()
Inventory *inv = m_invmgr->getInventory(m_inventoryloc);
if (!inv) {
- warningstream << "GUIInventoryList::draw(): "
- << "The inventory location "
- << "\"" << m_inventoryloc.dump() << "\" doesn't exist anymore"
- << std::endl;
+ if (!m_already_warned) {
+ warningstream << "GUIInventoryList::draw(): "
+ << "The inventory location "
+ << "\"" << m_inventoryloc.dump() << "\" doesn't exist"
+ << std::endl;
+ m_already_warned = true;
+ }
return;
}
InventoryList *ilist = inv->getList(m_listname);
if (!ilist) {
- warningstream << "GUIInventoryList::draw(): "
- << "The inventory list \"" << m_listname << "\" @ \""
- << m_inventoryloc.dump() << "\" doesn't exist anymore"
- << std::endl;
+ if (!m_already_warned) {
+ warningstream << "GUIInventoryList::draw(): "
+ << "The inventory list \"" << m_listname << "\" @ \""
+ << m_inventoryloc.dump() << "\" doesn't exist"
+ << std::endl;
+ m_already_warned = true;
+ }
return;
}
+ m_already_warned = false;
video::IVideoDriver *driver = Environment->getVideoDriver();
Client *client = m_fs_menu->getClient();
@@ -80,9 +85,11 @@ void GUIInventoryList::draw()
core::rect<s32> imgrect(0, 0, m_slot_size.X, m_slot_size.Y);
v2s32 base_pos = AbsoluteRect.UpperLeftCorner;
+ const s32 list_size = (s32)ilist->getSize();
+
for (s32 i = 0; i < m_geom.X * m_geom.Y; i++) {
s32 item_i = i + m_start_item_i;
- if (item_i >= (s32)ilist->getSize())
+ if (item_i >= list_size)
break;
v2s32 p((i % m_geom.X) * m_slot_spacing.X,
@@ -192,10 +199,19 @@ bool GUIInventoryList::OnEvent(const SEvent &event)
s32 GUIInventoryList::getItemIndexAtPos(v2s32 p) const
{
+ // no item if no gui element at pointer
if (!IsVisible || AbsoluteClippingRect.getArea() <= 0 ||
!AbsoluteClippingRect.isPointInside(p))
return -1;
+ // there can not be an item if the inventory or the inventorylist does not exist
+ Inventory *inv = m_invmgr->getInventory(m_inventoryloc);
+ if (!inv)
+ return -1;
+ InventoryList *ilist = inv->getList(m_listname);
+ if (!ilist)
+ return -1;
+
core::rect<s32> imgrect(0, 0, m_slot_size.X, m_slot_size.Y);
v2s32 base_pos = AbsoluteRect.UpperLeftCorner;
@@ -210,7 +226,8 @@ s32 GUIInventoryList::getItemIndexAtPos(v2s32 p) const
rect.clipAgainst(AbsoluteClippingRect);
- if (rect.getArea() > 0 && rect.isPointInside(p))
+ if (rect.getArea() > 0 && rect.isPointInside(p) &&
+ i + m_start_item_i < (s32)ilist->getSize())
return i + m_start_item_i;
return -1;
diff --git a/src/gui/guiInventoryList.h b/src/gui/guiInventoryList.h
index fd2c3601b..934d9ea3a 100644
--- a/src/gui/guiInventoryList.h
+++ b/src/gui/guiInventoryList.h
@@ -1,17 +1,14 @@
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
-
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
-
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
-
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -107,7 +104,7 @@ private:
const InventoryLocation m_inventoryloc;
const std::string m_listname;
- // specifies the width and height of the inventorylist in itemslots
+ // the specified width and height of the shown inventorylist in itemslots
const v2s32 m_geom;
// the first item's index in inventory
const s32 m_start_item_i;
@@ -127,4 +124,7 @@ private:
// the index of the hovered item; -1 if no item is hovered
s32 m_hovered_i;
+
+ // we do not want to write a warning on every draw
+ bool m_already_warned;
};
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 0fa15858f..ab31c165a 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -1199,6 +1199,13 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt)
player->hud_flags &= ~mask;
player->hud_flags |= flags;
+ if (g_settings->getBool("hud_flags_bypass"))
+ player->hud_flags = HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
+ HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
+ HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE |
+ HUD_FLAG_MINIMAP_RADAR_VISIBLE;
+
+
m_minimap_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE);
bool m_minimap_radar_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE);
@@ -1211,6 +1218,8 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt)
// Switch to surface mode if radar disabled by server
if (m_minimap && m_minimap_radar_disabled_by_server && was_minimap_radar_visible)
m_minimap->setMinimapMode(MINIMAP_MODE_SURFACEx1);
+
+
}
void Client::handleCommand_HudSetParam(NetworkPacket* pkt)
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index cb0f4a0c1..308cb7465 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -705,8 +705,6 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
tdef[j] = tiledef[j];
if (tdef[j].name.empty())
tdef[j].name = "unknown_node.png";
- if (g_settings->getBool("xray") && tdef[j].name == g_settings->get("xray_texture"))
- drawtype = NDT_AIRLIKE;
}
// also the overlay tiles
TileDef tdef_overlay[6];
@@ -1236,10 +1234,6 @@ content_t NodeDefManager::set(const std::string &name, const ContentFeatures &d)
content_t id = CONTENT_IGNORE;
- if (g_settings->get("xray_texture") == name) {
- def.drawtype = NDT_AIRLIKE;
- }
-
if (m_name_id_mapping.getId(name, id)) {
#ifndef SERVER
ContentFeatures old_def = get(name);
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp
index 3538c4fe4..2a87a3b05 100644
--- a/src/script/lua_api/l_localplayer.cpp
+++ b/src/script/lua_api/l_localplayer.cpp
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/localplayer.h"
#include "hud.h"
#include "common/c_content.h"
+#include "client/client.h"
LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m) : m_localplayer(m)
{
@@ -223,6 +224,7 @@ int LuaLocalPlayer::l_set_pos(lua_State *L)
v3f pos = checkFloatPos(L, 2);
player->setPosition(pos);
+ getClient(L)->sendPlayerPos();
return 0;
}