talk function

This commit is contained in:
Henrique 2011-11-03 14:07:51 -02:00
parent 8808587b35
commit e171d72f40
3 changed files with 32 additions and 0 deletions

View File

@ -54,6 +54,7 @@ public:
void sendTurnEast();
void sendTurnSouth();
void sendTurnWest();
void sendTalk(int channelType, const std::string& message, int channelId = 1, const std::string& receiver = "");
void sendAddVip(const std::string& name);
void sendRemoveVip(int id);

View File

@ -158,6 +158,35 @@ void ProtocolGame::sendTurnWest()
send(oMsg);
}
void ProtocolGame::sendTalk(int channelType, const std::string& message, int channelId, const std::string& receiver)
{
// Game.getProtocolGame():sendTalk(1, "lalala", 0, "ignore")
// TODO: MAKE SURE IT WAS AN USER EVENT AND NOT DIRECTLY FROM SCRIPT.
if(message.length() > 255 && message.length() <= 0)
return;
OutputMessage oMsg;
oMsg.addU8(Otc::ClientTalk);
assert(channelType >= 0);
oMsg.addU8(channelType);
switch(channelType) {
case Otc::SpeakPrivate:
case Otc::SpeakPrivateRed:
oMsg.addString(receiver);
break;
case Otc::SpeakChannelYellow:
case Otc::SpeakChannelRed:
oMsg.addU16(channelId);
break;
}
oMsg.addString(message);
send(oMsg);
}
void ProtocolGame::sendAddVip(const std::string& name)
{
OutputMessage oMsg;

View File

@ -49,6 +49,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassMemberFunction("cancelLogin", &ProtocolLogin::cancelLogin);
g_lua.registerClass<ProtocolGame, Protocol>();
g_lua.bindClassMemberFunction("sendTalk", &ProtocolGame::sendTalk);
g_lua.registerClass<Thing>();
g_lua.registerClass<Creature>();
@ -63,6 +64,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("logout", std::bind(&Game::logout, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("cancelLogin", std::bind(&Game::cancelLogin, &g_game));
g_lua.bindClassStaticFunction<Game>("isOnline", std::bind(&Game::isOnline, &g_game));
g_lua.bindClassStaticFunction<Game>("getProtocolGame", std::bind(&Game::getProtocolGame, &g_game));
g_lua.registerClass<UIMap, UIWidget>();
g_lua.bindClassStaticFunction<UIMap>("create", &UIWidget::create<UIMap>);