diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index a369e2a0..3ed0c25e 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -478,6 +478,14 @@ void Game::talkPrivate(const std::string& speakTypeDesc, const std::string& rece m_protocolGame->sendTalk(speakTypeDesc, 0, receiver, message); } + +void Game::openPrivateChannel(const std::string& receiver) +{ + if(!isOnline() || !checkBotProtection()) + return; + m_protocolGame->sendOpenPrivateChannel(receiver); +} + void Game::requestChannels() { if(!isOnline() || !checkBotProtection()) diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index 718dbb7f..c93d984b 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -84,6 +84,7 @@ public: void talk(const std::string& message); void talkChannel(const std::string& speakTypeDesc, int channelId, const std::string& message); void talkPrivate(const std::string& speakTypeDesc, const std::string& receiver, const std::string& message); + void openPrivateChannel(const std::string& receiver); void requestChannels(); void joinChannel(int channelId); void leaveChannel(int channelId); diff --git a/src/otclient/core/mapview.cpp b/src/otclient/core/mapview.cpp index 984b691b..c94e0f8a 100644 --- a/src/otclient/core/mapview.cpp +++ b/src/otclient/core/mapview.cpp @@ -86,6 +86,7 @@ void MapView::draw(const Rect& rect) ++it; tile->draw(transformPositionTo2D(tile->getPosition()), scaleFactor, drawFlags); + g_painter.drawBoundingRect(Rect(transformPositionTo2D(tile->getPosition()), Size(1,1)*Otc::TILE_PIXELS*scaleFactor)); } if(drawFlags & Otc::DrawMissiles) { diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index d7f661ed..41922212 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -190,6 +190,9 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("requestOutfit", std::bind(&Game::requestOutfit, &g_game)); g_lua.bindClassStaticFunction("requestChannels", std::bind(&Game::requestChannels, &g_game)); g_lua.bindClassStaticFunction("joinChannel", std::bind(&Game::joinChannel, &g_game, _1)); + g_lua.bindClassStaticFunction("leaveChannel", std::bind(&Game::leaveChannel, &g_game, _1)); + g_lua.bindClassStaticFunction("closeNpcChannel", std::bind(&Game::closeNpcChannel, &g_game)); + g_lua.bindClassStaticFunction("openPrivateChannel", std::bind(&Game::openPrivateChannel, &g_game, _1)); g_lua.bindClassStaticFunction("setOutfit", std::bind(&Game::setOutfit, &g_game, _1)); g_lua.bindClassStaticFunction("look", std::bind(&Game::look, &g_game, _1)); g_lua.bindClassStaticFunction("open", std::bind(&Game::open, &g_game, _1, _2)); diff --git a/src/otclient/net/protocolcodes.h b/src/otclient/net/protocolcodes.h index 599ad384..4a6b0e16 100644 --- a/src/otclient/net/protocolcodes.h +++ b/src/otclient/net/protocolcodes.h @@ -123,7 +123,7 @@ namespace Proto { GameServerTalk = 170, GameServerChannels = 171, GameServerOpenChannel = 172, - GameServerPrivateChannel = 173, + GameServerOpenPrivateChannel = 173, GameServerRuleViolationChannel = 174, // deprecated in last tibia GameServerRuleViolationRemove = 175, // deprecated in last tibia GameServerRuleViolationCancel = 176, // deprecated in last tibia @@ -190,7 +190,7 @@ namespace Proto { ClientGetChannels = 151, ClientJoinChannel = 152, ClientLeaveChannel = 153, - ClientPrivateChannel = 154, + ClientOpenPrivateChannel = 154, ClientCloseNpcChannel = 158, ClientSetTactics = 160, ClientAttack = 161, diff --git a/src/otclient/net/protocolgame.h b/src/otclient/net/protocolgame.h index 38e5f1e5..dcf6dab4 100644 --- a/src/otclient/net/protocolgame.h +++ b/src/otclient/net/protocolgame.h @@ -77,7 +77,7 @@ public: void sendGetChannels(); void sendJoinChannel(int channelId); void sendLeaveChannel(int channelId); - void sendPrivateChannel(const std::string& receiver); + void sendOpenPrivateChannel(const std::string& receiver); void sendCloseNpcChannel(); void sendFightTatics(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight); void sendAttack(uint creatureId); @@ -155,9 +155,9 @@ private: void parseCreatureSpeak(InputMessage& msg); void parseChannelList(InputMessage& msg); void parseOpenChannel(InputMessage& msg); - void parseOpenPrivatePlayerChat(InputMessage& msg); - void parseCreatePrivateChannel(InputMessage& msg); - void parseClosePrivateChannel(InputMessage& msg); + void parseOpenPrivateChannel(InputMessage& msg); + void parseCreateOwnPrivateChannel(InputMessage& msg); + void parseCloseChannel(InputMessage& msg); void parseSafeTradeRequest(InputMessage& msg); void parseSafeTradeClose(InputMessage&); void parseTextMessage(InputMessage& msg); diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/net/protocolgameparse.cpp index ebf8dc38..0987616b 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/net/protocolgameparse.cpp @@ -195,8 +195,8 @@ void ProtocolGame::parseMessage(InputMessage& msg) case Proto::GameServerOpenChannel: parseOpenChannel(msg); break; - case Proto::GameServerPrivateChannel: - parseOpenPrivatePlayerChat(msg); + case Proto::GameServerOpenPrivateChannel: + parseOpenPrivateChannel(msg); break; case Proto::GameServerRuleViolationChannel: msg.getU16(); @@ -210,10 +210,10 @@ void ProtocolGame::parseMessage(InputMessage& msg) case Proto::GameServerRuleViolationLock: break; case Proto::GameServerOpenOwnChannel: - parseCreatePrivateChannel(msg); + parseCreateOwnPrivateChannel(msg); break; case Proto::GameServerCloseChannel: - parseClosePrivateChannel(msg); + parseCloseChannel(msg); break; case Proto::GameServerMessage: parseTextMessage(msg); @@ -780,20 +780,26 @@ void ProtocolGame::parseOpenChannel(InputMessage& msg) g_lua.callGlobalField("Game", "onOpenChannel", channelId, name); } -void ProtocolGame::parseOpenPrivatePlayerChat(InputMessage& msg) +void ProtocolGame::parseOpenPrivateChannel(InputMessage& msg) { - msg.getString(); // name + std::string name = msg.getString(); + + g_lua.callGlobalField("Game", "onOpenPrivateChannel", name); } -void ProtocolGame::parseCreatePrivateChannel(InputMessage& msg) +void ProtocolGame::parseCreateOwnPrivateChannel(InputMessage& msg) { - msg.getU16(); // channel id - msg.getString(); // channel name + int id = msg.getU16(); // channel id + std::string name = msg.getString(); // channel name + + g_lua.callGlobalField("Game", "onOpenOwnPrivateChannel", id, name); } -void ProtocolGame::parseClosePrivateChannel(InputMessage& msg) +void ProtocolGame::parseCloseChannel(InputMessage& msg) { - msg.getU16(); // channel id + int id = msg.getU16(); // channel id + + g_lua.callGlobalField("Game", "onCloseChannel", id); } void ProtocolGame::parseTextMessage(InputMessage& msg) diff --git a/src/otclient/net/protocolgamesend.cpp b/src/otclient/net/protocolgamesend.cpp index 8f1b493f..d12ad2a4 100644 --- a/src/otclient/net/protocolgamesend.cpp +++ b/src/otclient/net/protocolgamesend.cpp @@ -390,10 +390,10 @@ void ProtocolGame::sendLeaveChannel(int channelId) send(oMsg); } -void ProtocolGame::sendPrivateChannel(const std::string& receiver) +void ProtocolGame::sendOpenPrivateChannel(const std::string& receiver) { OutputMessage oMsg; - oMsg.addU8(Proto::ClientPrivateChannel); + oMsg.addU8(Proto::ClientOpenPrivateChannel); oMsg.addString(receiver); send(oMsg); }