bind all channels/chat lua functions

This commit is contained in:
Eduardo Bart 2012-02-02 20:29:44 -02:00
parent a4546942d2
commit 496efc44ce
8 changed files with 38 additions and 19 deletions

View File

@ -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())

View File

@ -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);

View File

@ -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) {

View File

@ -190,6 +190,9 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("requestOutfit", std::bind(&Game::requestOutfit, &g_game));
g_lua.bindClassStaticFunction<Game>("requestChannels", std::bind(&Game::requestChannels, &g_game));
g_lua.bindClassStaticFunction<Game>("joinChannel", std::bind(&Game::joinChannel, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("leaveChannel", std::bind(&Game::leaveChannel, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("closeNpcChannel", std::bind(&Game::closeNpcChannel, &g_game));
g_lua.bindClassStaticFunction<Game>("openPrivateChannel", std::bind(&Game::openPrivateChannel, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("setOutfit", std::bind(&Game::setOutfit, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("look", std::bind(&Game::look, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("open", std::bind(&Game::open, &g_game, _1, _2));

View File

@ -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,

View File

@ -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);

View File

@ -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)

View File

@ -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);
}