Make lint happy; Remove stupid redirector
parent
3b596a96e0
commit
3a718f12b4
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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; }
|
||||
};
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue