talk functions on game class
This commit is contained in:
parent
e171d72f40
commit
4fb59e25f4
|
@ -104,6 +104,8 @@ void Game::processTextMessage(int type, const std::string& message)
|
|||
|
||||
void Game::walk(Otc::Direction direction)
|
||||
{
|
||||
if(!m_online)
|
||||
return;
|
||||
|
||||
// TODO: check if we can walk.
|
||||
|
||||
|
@ -157,3 +159,22 @@ void Game::turn(Otc::Direction direction)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Game.talkChannel(1, 0, "lalala")
|
||||
// TODO: MAKE SURE IT WAS AN USER EVENT AND NOT DIRECTLY FROM SCRIPT.
|
||||
|
||||
void Game::talkChannel(int channelType, int channelId, const std::string& message)
|
||||
{
|
||||
if(!m_online)
|
||||
return;
|
||||
|
||||
m_protocolGame->sendTalk(channelType, channelId, "", message);
|
||||
}
|
||||
|
||||
void Game::talkPrivate(int channelType, const std::string& receiver, const std::string& message)
|
||||
{
|
||||
if(!m_online)
|
||||
return;
|
||||
|
||||
m_protocolGame->sendTalk(channelType, 0, receiver, message);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
|
||||
void walk(Otc::Direction direction);
|
||||
void turn(Otc::Direction direction);
|
||||
void talkChannel(int channelType, int channelId, const std::string& message);
|
||||
void talkPrivate(int channelType, const std::string& receiver, const std::string& message);
|
||||
|
||||
bool isOnline() { return m_online; }
|
||||
|
||||
|
|
|
@ -54,7 +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 sendTalk(int channelType, int channelId, const std::string& receiver, const std::string& message);
|
||||
void sendAddVip(const std::string& name);
|
||||
void sendRemoveVip(int id);
|
||||
|
||||
|
|
|
@ -158,12 +158,9 @@ void ProtocolGame::sendTurnWest()
|
|||
send(oMsg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendTalk(int channelType, const std::string& message, int channelId, const std::string& receiver)
|
||||
void ProtocolGame::sendTalk(int channelType, int channelId, const std::string& receiver, const std::string& message)
|
||||
{
|
||||
// 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)
|
||||
if(message.length() > 255 || message.length() <= 0)
|
||||
return;
|
||||
|
||||
OutputMessage oMsg;
|
||||
|
|
|
@ -49,7 +49,6 @@ 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>();
|
||||
|
@ -64,7 +63,8 @@ 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.bindClassStaticFunction<Game>("talkChannel", std::bind(&Game::talkChannel, &g_game, _1, _2, _3));
|
||||
g_lua.bindClassStaticFunction<Game>("talkPrivate", std::bind(&Game::talkPrivate, &g_game, _1, _2, _3));
|
||||
|
||||
g_lua.registerClass<UIMap, UIWidget>();
|
||||
g_lua.bindClassStaticFunction<UIMap>("create", &UIWidget::create<UIMap>);
|
||||
|
|
Loading…
Reference in New Issue