diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/activeobjectmgr.h | 4 | ||||
-rw-r--r-- | src/client/render/core.h | 5 | ||||
-rw-r--r-- | src/gui/cheatMenu.cpp | 58 | ||||
-rw-r--r-- | src/gui/cheatMenu.h | 29 | ||||
-rw-r--r-- | src/network/networkprotocol.h | 10 | ||||
-rw-r--r-- | src/network/serveropcodes.cpp | 1 | ||||
-rw-r--r-- | src/script/cpp_api/s_cheats.cpp | 31 | ||||
-rw-r--r-- | src/script/lua_api/l_client.h | 11 | ||||
-rw-r--r-- | src/script/lua_api/l_server.cpp | 19 | ||||
-rw-r--r-- | src/script/lua_api/l_server.h | 3 | ||||
-rw-r--r-- | src/server.cpp | 12 | ||||
-rw-r--r-- | src/server.h | 2 |
12 files changed, 81 insertions, 104 deletions
diff --git a/src/activeobjectmgr.h b/src/activeobjectmgr.h index 8c4630c79..5139d61dd 100644 --- a/src/activeobjectmgr.h +++ b/src/activeobjectmgr.h @@ -41,12 +41,12 @@ public: m_active_objects.find(id); return (n != m_active_objects.end() ? n->second : nullptr); } - + std::unordered_map<u16, T *> getAllActiveObjects() const { return m_active_objects; } - + protected: u16 getFreeId() const { diff --git a/src/client/render/core.h b/src/client/render/core.h index 609892416..90b81b060 100644 --- a/src/client/render/core.h +++ b/src/client/render/core.h @@ -48,7 +48,7 @@ protected: Camera *camera; Minimap *mapper; Hud *hud; - + void updateScreenSize(); virtual void initTextures() {} virtual void clearTextures() {} @@ -72,7 +72,8 @@ public: void initialize(); void draw(video::SColor _skycolor, bool _show_hud, bool _show_minimap, - bool _draw_wield_tool, bool _draw_crosshair, bool _draw_tracers, bool _draw_esp); + bool _draw_wield_tool, bool _draw_crosshair, bool _draw_tracers, + bool _draw_esp); inline v2u32 getVirtualSize() const { return virtual_size; } }; diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index 5707ed696..b22b8da30 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -15,15 +15,14 @@ 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 "cheatMenu.h" #include "script/scripting_client.h" #include "client/client.h" #include "client/fontengine.h" -CheatMenu::CheatMenu(Client *client): - m_client(client) +CheatMenu::CheatMenu(Client *client) : m_client(client) { m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Fallback); @@ -38,7 +37,8 @@ CheatMenu::CheatMenu(Client *client): m_fontsize.Y = MYMAX(m_fontsize.Y, 1); } -void CheatMenu::drawEntry(video::IVideoDriver* driver, std::string name, int number, bool selected, bool active, CheatMenuEntryType entry_type) +void CheatMenu::drawEntry(video::IVideoDriver* driver, std::string name, int number, + bool selected, bool active, CheatMenuEntryType entry_type) { int x = m_gap, y = m_gap, width = m_entry_width, height = m_entry_height; video::SColor *bgcolor = &m_bg_color, *fontcolor = &m_font_color; @@ -47,7 +47,9 @@ void CheatMenu::drawEntry(video::IVideoDriver* driver, std::string name, int num height = m_head_height; } else { bool is_category = entry_type == CHEAT_MENU_ENTRY_TYPE_CATEGORY; - y += m_gap + m_head_height + (number + (is_category ? 0 : m_selected_category)) * (m_entry_height + m_gap); + y += m_gap + m_head_height + + (number + (is_category ? 0 : m_selected_category)) * + (m_entry_height + m_gap); x += (is_category ? 0 : m_gap + m_entry_width); if (active) bgcolor = &m_active_bg_color; @@ -56,9 +58,12 @@ void CheatMenu::drawEntry(video::IVideoDriver* driver, std::string name, int num } driver->draw2DRectangle(*bgcolor, core::rect<s32>(x, y, x + width, y + height)); if (selected) - driver->draw2DRectangleOutline(core::rect<s32>(x - 1, y - 1, x + width, y + height), *fontcolor); + driver->draw2DRectangleOutline( + core::rect<s32>(x - 1, y - 1, x + width, y + height), + *fontcolor); int fx = x + 5, fy = y + (height - m_fontsize.Y) / 2; - core::rect<s32> fontbounds(fx, fy, fx + m_fontsize.X * name.size(), fy + m_fontsize.Y); + core::rect<s32> fontbounds( + fx, fy, fx + m_fontsize.X * name.size(), fy + m_fontsize.Y); m_font->draw(name.c_str(), fontbounds, *fontcolor, false, false); } @@ -66,16 +71,22 @@ void CheatMenu::draw(video::IVideoDriver* driver, bool show_debug) { CHEAT_MENU_GET_SCRIPTPTR - if (! show_debug) - drawEntry(driver, "Dragonfireclient", 0, false, false, CHEAT_MENU_ENTRY_TYPE_HEAD); + if (!show_debug) + drawEntry(driver, "Dragonfireclient", 0, false, false, + CHEAT_MENU_ENTRY_TYPE_HEAD); int category_count = 0; - for (auto category = script->m_cheat_categories.begin(); category != script->m_cheat_categories.end(); category++) { + for (auto category = script->m_cheat_categories.begin(); + category != script->m_cheat_categories.end(); category++) { bool is_selected = category_count == m_selected_category; - drawEntry(driver, (*category)->m_name, category_count, is_selected, false, CHEAT_MENU_ENTRY_TYPE_CATEGORY); + drawEntry(driver, (*category)->m_name, category_count, is_selected, false, + CHEAT_MENU_ENTRY_TYPE_CATEGORY); if (is_selected && m_cheat_layer) { int cheat_count = 0; - for (auto cheat = (*category)->m_cheats.begin(); cheat != (*category)->m_cheats.end(); cheat++) { - drawEntry(driver, (*cheat)->m_name, cheat_count, cheat_count == m_selected_cheat, (*cheat)->is_enabled()); + for (auto cheat = (*category)->m_cheats.begin(); + cheat != (*category)->m_cheats.end(); cheat++) { + drawEntry(driver, (*cheat)->m_name, cheat_count, + cheat_count == m_selected_cheat, + (*cheat)->is_enabled()); cheat_count++; } } @@ -87,7 +98,10 @@ void CheatMenu::selectUp() { CHEAT_MENU_GET_SCRIPTPTR - int max = (m_cheat_layer ? script->m_cheat_categories[m_selected_category]->m_cheats.size() : script->m_cheat_categories.size()) - 1; + int max = (m_cheat_layer ? script->m_cheat_categories[m_selected_category] + ->m_cheats.size() + : script->m_cheat_categories.size()) - + 1; int *selected = m_cheat_layer ? &m_selected_cheat : &m_selected_category; --*selected; if (*selected < 0) @@ -98,7 +112,10 @@ void CheatMenu::selectDown() { CHEAT_MENU_GET_SCRIPTPTR - int max = (m_cheat_layer ? script->m_cheat_categories[m_selected_category]->m_cheats.size() : script->m_cheat_categories.size()) - 1; + int max = (m_cheat_layer ? script->m_cheat_categories[m_selected_category] + ->m_cheats.size() + : script->m_cheat_categories.size()) - + 1; int *selected = m_cheat_layer ? &m_selected_cheat : &m_selected_category; ++*selected; if (*selected > max) @@ -114,16 +131,17 @@ void CheatMenu::selectRight() } void CheatMenu::selectLeft() -{ - if (! m_cheat_layer) +{ + if (!m_cheat_layer) return; m_cheat_layer = false; } void CheatMenu::selectConfirm() -{ +{ CHEAT_MENU_GET_SCRIPTPTR if (m_cheat_layer) - script->toggle_cheat(script->m_cheat_categories[m_selected_category]->m_cheats[m_selected_cheat]); + script->toggle_cheat(script->m_cheat_categories[m_selected_category] + ->m_cheats[m_selected_cheat]); } diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index aaa433ceb..de369485c 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -15,14 +15,17 @@ 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" #include <string> -#define CHEAT_MENU_GET_SCRIPTPTR ClientScripting *script = m_client->getScript(); if (! script || ! script->m_cheats_loaded) return; +#define CHEAT_MENU_GET_SCRIPTPTR \ + ClientScripting *script = m_client->getScript(); \ + if (! script || ! script->m_cheats_loaded) \ + return; class Client; @@ -31,42 +34,42 @@ typedef enum CHEAT_MENU_ENTRY_TYPE_HEAD, CHEAT_MENU_ENTRY_TYPE_CATEGORY, CHEAT_MENU_ENTRY_TYPE_ENTRY, -} -CheatMenuEntryType; +} CheatMenuEntryType; class CheatMenu { public: CheatMenu(Client* client); - + 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); - + + void drawEntry(video::IVideoDriver* driver, std::string name, int number, + bool selected, bool active, + CheatMenuEntryType entry_type = CHEAT_MENU_ENTRY_TYPE_ENTRY); + void selectUp(); void selectDown(); void selectLeft(); void selectRight(); void selectConfirm(); - + private: bool m_cheat_layer = false; int m_selected_cheat = 0; int m_selected_category = 0; - + int m_head_height = 50; int m_entry_height = 40; int m_entry_width = 200; int m_gap = 3; - + video::SColor m_bg_color = video::SColor(192, 255, 145, 88); video::SColor m_active_bg_color = video::SColor(192, 255, 87, 53); video::SColor m_font_color = video::SColor(255, 0, 0, 0); video::SColor m_selected_font_color = video::SColor(255, 255, 252, 88); - Client *m_client; - + gui::IGUIFont *m_font = nullptr; v2u32 m_fontsize; }; diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h index 3ac9b4af8..e57a7a794 100644 --- a/src/network/networkprotocol.h +++ b/src/network/networkprotocol.h @@ -204,8 +204,6 @@ with this program; if not, write to the Free Software Foundation, Inc., PROTOCOL VERSION 39: Updated set_sky packet Adds new sun, moon and stars packets - PROTOCOL VERSION 40: - Added TOCLIENT_REDIRECT */ #define LATEST_PROTOCOL_VERSION 40 @@ -765,13 +763,7 @@ enum ToClientCommand u16 len u8[len] formspec */ - - TOCLIENT_REDIRECT = 0x62, - /* - std::string address - u16 port - */ - + TOCLIENT_NUM_MSG_TYPES = 0x63, }; diff --git a/src/network/serveropcodes.cpp b/src/network/serveropcodes.cpp index 61f0dfeeb..2fc3197c2 100644 --- a/src/network/serveropcodes.cpp +++ b/src/network/serveropcodes.cpp @@ -221,5 +221,4 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] = null_command_factory, // 0x5f { "TOSERVER_SRP_BYTES_S_B", 0, true }, // 0x60 { "TOCLIENT_FORMSPEC_PREPEND", 0, true }, // 0x61 - { "TOCLIENT_REDIRECT", 0, true }, // 0x62 }; diff --git a/src/script/cpp_api/s_cheats.cpp b/src/script/cpp_api/s_cheats.cpp index 8f3e4ef14..4ad62f2fe 100644 --- a/src/script/cpp_api/s_cheats.cpp +++ b/src/script/cpp_api/s_cheats.cpp @@ -15,44 +15,42 @@ 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 "cpp_api/s_cheats.h" #include "cpp_api/s_base.h" #include "cpp_api/s_internal.h" #include "settings.h" -ScriptApiCheatsCheat::ScriptApiCheatsCheat(const std::string &name, const std::string &setting) : - m_name(name), - m_setting(setting), - m_function_ref(0) +ScriptApiCheatsCheat::ScriptApiCheatsCheat( + const std::string &name, const std::string &setting) : + m_name(name), + m_setting(setting), m_function_ref(0) { } ScriptApiCheatsCheat::ScriptApiCheatsCheat(const std::string &name, const int &function) : - m_name(name), - m_setting(""), - m_function_ref(function) + m_name(name), m_setting(""), m_function_ref(function) { } bool ScriptApiCheatsCheat::is_enabled() { try { - return ! m_function_ref && g_settings->getBool(m_setting); + return !m_function_ref && g_settings->getBool(m_setting); } catch (SettingNotFoundException &) { return false; } } void ScriptApiCheatsCheat::toggle(lua_State *L, int error_handler) -{ +{ if (m_function_ref) { lua_rawgeti(L, LUA_REGISTRYINDEX, m_function_ref); lua_pcall(L, 0, 0, error_handler); } else - g_settings->setBool(m_setting, ! is_enabled()); + g_settings->setBool(m_setting, !is_enabled()); } ScriptApiCheatsCategory::ScriptApiCheatsCategory(const std::string &name) : @@ -75,7 +73,8 @@ void ScriptApiCheatsCategory::read_cheats(lua_State *L) if (lua_isstring(L, -1)) cheat = new ScriptApiCheatsCheat(name, lua_tostring(L, -1)); else if (lua_isfunction(L, -1)) { - cheat = new ScriptApiCheatsCheat(name, luaL_ref(L, LUA_REGISTRYINDEX)); + cheat = new ScriptApiCheatsCheat( + name, luaL_ref(L, LUA_REGISTRYINDEX)); lua_pushnil(L); } if (cheat) @@ -93,10 +92,10 @@ ScriptApiCheats::~ScriptApiCheats() void ScriptApiCheats::init_cheats() { SCRIPTAPI_PRECHECKHEADER - + lua_getglobal(L, "core"); lua_getfield(L, -1, "cheats"); - if (! lua_istable(L, -1)) { + if (!lua_istable(L, -1)) { lua_pop(L, 2); return; } @@ -116,10 +115,10 @@ void ScriptApiCheats::init_cheats() void ScriptApiCheats::toggle_cheat(ScriptApiCheatsCheat *cheat) { SCRIPTAPI_PRECHECKHEADER - + PUSH_ERROR_HANDLER(L); int error_handler = lua_gettop(L) - 1; lua_insert(L, error_handler); - + cheat->toggle(L, error_handler); } diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index ebce7c02a..4e49ad60e 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -104,24 +104,25 @@ private: // get_csm_restrictions() static int l_get_csm_restrictions(lua_State *L); - + // send_damage(damage) static int l_send_damage(lua_State *L); - + // place_node(pos) static int l_place_node(lua_State *L); - + // dig_node(pos) static int l_dig_node(lua_State *L); - + // get_inventory(location) static int l_get_inventory(lua_State *L); - + // set_keypress(key_setting, pressed) static int l_set_keypress(lua_State *L); // drop_selected_item() static int l_drop_selected_item(lua_State *L); + public: static void Initialize(lua_State *L, int top); }; diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp index befbfb936..64ae924d2 100644 --- a/src/script/lua_api/l_server.cpp +++ b/src/script/lua_api/l_server.cpp @@ -338,23 +338,6 @@ int ModApiServer::l_kick_player(lua_State *L) return 1; } -// redirect_player(name, address, port) -int ModApiServer::l_redirect_player(lua_State *L) -{ - NO_MAP_LOCK_REQUIRED; - const char *name = luaL_checkstring(L, 1); - const char *address = luaL_checkstring(L, 2); - u16 port = luaL_checknumber(L, 3); - RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name); - if (player == NULL) { - lua_pushboolean(L, false); // No such player - return 1; - } - getServer(L)->RedirectPeer(player->getPeerId(), address, port); - lua_pushboolean(L, true); - return 1; -} - // remove_player(name) int ModApiServer::l_remove_player(lua_State *L) { @@ -580,8 +563,6 @@ void ModApiServer::Initialize(lua_State *L, int top) API_FCT(get_ban_description); API_FCT(ban_player); API_FCT(kick_player); - API_FCT(redirect_player); - API_FCT(remove_player); API_FCT(unban_player_or_ip); API_FCT(notify_authentication_modified); diff --git a/src/script/lua_api/l_server.h b/src/script/lua_api/l_server.h index 3b590af9d..938bfa8ef 100644 --- a/src/script/lua_api/l_server.h +++ b/src/script/lua_api/l_server.h @@ -96,9 +96,6 @@ private: // kick_player(name, [message]) -> success static int l_kick_player(lua_State *L); - - // redirect_player(name, address, port) -> success - static int l_redirect_player(lua_State *L); // remove_player(name) static int l_remove_player(lua_State *L); diff --git a/src/server.cpp b/src/server.cpp index b9f6d1b0f..fe2bb3840 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1376,13 +1376,6 @@ void Server::SendAccessDenied_Legacy(session_t peer_id,const std::wstring &reaso Send(&pkt); } -void Server::SendRedirect(session_t peer_id, const std::string address, u16 port) -{ - NetworkPacket pkt(TOCLIENT_REDIRECT, 0, peer_id); - pkt << address << port; - Send(&pkt); -} - void Server::SendDeathscreen(session_t peer_id, bool set_camera_point_target, v3f camera_point_target) { @@ -2784,11 +2777,6 @@ void Server::DisconnectPeer(session_t peer_id) m_con->DisconnectPeer(peer_id); } -void Server::RedirectPeer(session_t peer_id, const std::string address, u16 port) -{ - SendRedirect(peer_id, address, port); -} - void Server::acceptAuth(session_t peer_id, bool forSudoMode) { if (!forSudoMode) { diff --git a/src/server.h b/src/server.h index 023aee519..f44716531 100644 --- a/src/server.h +++ b/src/server.h @@ -315,7 +315,6 @@ public: void acceptAuth(session_t peer_id, bool forSudoMode); void DenyAccess_Legacy(session_t peer_id, const std::wstring &reason); void DisconnectPeer(session_t peer_id); - void RedirectPeer(session_t peer_id, const std::string address, u16 port); bool getClientConInfo(session_t peer_id, con::rtt_stat_type type, float *retval); bool getClientInfo(session_t peer_id, ClientState *state, u32 *uptime, u8* ser_vers, u16* prot_vers, u8* major, u8* minor, u8* patch, @@ -381,7 +380,6 @@ private: void SendAccessDenied(session_t peer_id, AccessDeniedCode reason, const std::string &custom_reason, bool reconnect = false); void SendAccessDenied_Legacy(session_t peer_id, const std::wstring &reason); - void SendRedirect(session_t peer_id, const std::string address, u16 port); void SendDeathscreen(session_t peer_id, bool set_camera_point_target, v3f camera_point_target); void SendItemDef(session_t peer_id, IItemDefManager *itemdef, u16 protocol_version); |