mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
extended opcode disabled by default. current locale is sent to server on login, bot protection exception
This commit is contained in:
@@ -5,6 +5,7 @@ ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)
|
||||
|
||||
# otclient options
|
||||
OPTION(BOT_PROTECTION "Enable bot protection" ON)
|
||||
OPTION(EXTENDED_OPCODE "Enable extended opcode" OFF)
|
||||
SET(PROTOCOL 860 CACHE "Protocol version" STRING)
|
||||
OPTION(CIPSOFT_RSA "Use cipsoft RSA to login into original tibia" OFF)
|
||||
ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL})
|
||||
@@ -24,6 +25,13 @@ ELSE(BOT_PROTECTION)
|
||||
MESSAGE(STATUS "Bot protection: OFF")
|
||||
ENDIF(BOT_PROTECTION)
|
||||
|
||||
IF(EXTENDED_OPCODE)
|
||||
ADD_DEFINITIONS(-DEXTENDED_OPCODE)
|
||||
MESSAGE(STATUS "Extended opcode: ON")
|
||||
ELSE(EXTENDED_OPCODE)
|
||||
MESSAGE(STATUS "Extended opcode: OFF")
|
||||
ENDIF(EXTENDED_OPCODE)
|
||||
|
||||
SET(otclient_SOURCES ${otclient_SOURCES}
|
||||
# otclient
|
||||
${CMAKE_CURRENT_LIST_DIR}/otclient.cpp
|
||||
|
@@ -42,6 +42,11 @@ Game::Game()
|
||||
|
||||
void Game::resetGameStates()
|
||||
{
|
||||
#ifdef BOT_PROTECTION
|
||||
m_denyBotCall = true;
|
||||
#else
|
||||
m_denyBotCall = false;
|
||||
#endif
|
||||
m_dead = false;
|
||||
m_serverBeat = 50;
|
||||
m_canReportBugs = false;
|
||||
@@ -114,8 +119,10 @@ void Game::processGameStart(const LocalPlayerPtr& localPlayer, int serverBeat, b
|
||||
// synchronize fight modes with the server
|
||||
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
|
||||
|
||||
// NOTE: the entire map description and local player information is not known yet
|
||||
// NOTE: the entire map description and local player information is not known yet (bot call is allowed here)
|
||||
enableBotCall();
|
||||
g_lua.callGlobalField("g_game", "onGameStart");
|
||||
disableBotCall();
|
||||
}
|
||||
|
||||
void Game::processGameEnd()
|
||||
@@ -991,14 +998,12 @@ void Game::mount(bool mount)
|
||||
|
||||
bool Game::checkBotProtection()
|
||||
{
|
||||
#ifdef BOT_PROTECTION
|
||||
// accepts calls comming from a stacktrace containing only C++ functions,
|
||||
// if the stacktrace contains a lua function, then only accept if the engine is processing an input event
|
||||
if(g_lua.isInCppCallback() && !g_app->isOnInputEvent()) {
|
||||
if(g_lua.isInCppCallback() && !g_app->isOnInputEvent() && m_denyBotCall) {
|
||||
logError(g_lua.traceback("caught a lua call to a bot protected game function, the call was canceled"));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -232,6 +232,8 @@ public:
|
||||
bool canPerformGameAction();
|
||||
bool canReportBugs() { return m_canReportBugs; }
|
||||
bool checkBotProtection();
|
||||
void enableBotCall() { m_denyBotCall = false; }
|
||||
void disableBotCall() { m_denyBotCall = true; }
|
||||
|
||||
bool isOnline() { return !!m_localPlayer; }
|
||||
bool isDead() { return m_dead; }
|
||||
@@ -261,6 +263,7 @@ private:
|
||||
std::map<int, ContainerPtr> m_containers;
|
||||
std::map<int, Vip> m_vips;
|
||||
|
||||
bool m_denyBotCall;
|
||||
bool m_dead;
|
||||
int m_serverBeat;
|
||||
Otc::FightModes m_fightMode;
|
||||
|
@@ -1212,11 +1212,13 @@ void ProtocolGame::parseExtendedOpcode(const InputMessagePtr& msg)
|
||||
int opcode = msg->getU8();
|
||||
std::string buffer = msg->getString();
|
||||
|
||||
#ifdef EXTENDED_OPCODE
|
||||
try {
|
||||
callLuaField("onExtendedOpcode", opcode, buffer);
|
||||
} catch(Exception& e) {
|
||||
logError("Network exception in extended opcode ", opcode, ": ", e.what());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProtocolGame::setMapDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height)
|
||||
|
@@ -33,11 +33,13 @@ void ProtocolGame::safeSend(const OutputMessagePtr& outputMessage)
|
||||
|
||||
void ProtocolGame::sendExtendedOpcode(uint8 opcode, const std::string& buffer)
|
||||
{
|
||||
#ifdef EXTENDED_OPCODE
|
||||
OutputMessagePtr msg(new OutputMessage);
|
||||
msg->addU8(Proto::ClientExtendedOpcode);
|
||||
msg->addU8(opcode);
|
||||
msg->addString(buffer);
|
||||
safeSend(msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProtocolGame::sendLoginPacket(uint challangeTimestamp, uint8 challangeRandom)
|
||||
|
Reference in New Issue
Block a user