bind rule violations/bug report functions

This commit is contained in:
Eduardo Bart 2012-04-30 19:24:50 -03:00
parent 45d3097504
commit 42ba5b7a2a
7 changed files with 219 additions and 39 deletions

View File

@ -43,6 +43,7 @@ void Game::resetGameStates()
{
m_dead = false;
m_serverBeat = 50;
m_canReportBugs = false;
m_fightMode = Otc::FightBalanced;
m_chaseMode = Otc::DontChase;
m_safeFight = true;
@ -56,6 +57,7 @@ void Game::resetGameStates()
}
m_containers.clear();
m_vips.clear();
m_gmActions.clear();
m_worldName = "";
}
@ -105,13 +107,14 @@ void Game::processLoginWait(const std::string& message, int time)
g_lua.callGlobalField("g_game", "onLoginWait", message, time);
}
void Game::processGameStart(const LocalPlayerPtr& localPlayer, int serverBeat)
void Game::processGameStart(const LocalPlayerPtr& localPlayer, int serverBeat, bool canReportBugs)
{
// reset the new game state
resetGameStates();
m_localPlayer = localPlayer;
m_serverBeat = serverBeat;
m_canReportBugs = canReportBugs;
// synchronize fight modes with the server
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
@ -151,7 +154,35 @@ void Game::processDeath(int penality)
m_dead = true;
m_localPlayer->stopWalk();
g_lua.callGlobalField("g_game","onDeath", penality);
g_lua.callGlobalField("g_game", "onDeath", penality);
}
void Game::processGMActions(const std::vector<uint8>& actions)
{
m_gmActions = actions;
g_lua.callGlobalField("g_game", "onGMActions", actions);
}
void Game::processPlayerStats(double health, double maxHealth,
double freeCapacity, double experience,
double level, double levelPercent,
double mana, double maxMana,
double magicLevel, double magicLevelPercent,
double soul, double stamina)
{
if(!m_localPlayer) {
logTraceError("there is no local player");
return;
}
m_localPlayer->setHealth(health, maxHealth);
m_localPlayer->setFreeCapacity(freeCapacity);
m_localPlayer->setExperience(experience);
m_localPlayer->setLevel(level, levelPercent);
m_localPlayer->setMana(mana, maxMana);
m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent);
m_localPlayer->setStamina(stamina);
m_localPlayer->setSoul(soul);
}
void Game::processPing()
@ -287,6 +318,26 @@ void Game::processCloseChannel(int channelId)
g_lua.callGlobalField("g_game", "onCloseChannel", channelId);
}
void Game::processRuleViolationChannel(int channelId)
{
g_lua.callGlobalField("g_game", "onRuleViolationChannel", channelId);
}
void Game::processRuleViolationRemove(const std::string& name)
{
g_lua.callGlobalField("g_game", "onRuleViolationRemove", name);
}
void Game::processRuleViolationCancel(const std::string& name)
{
g_lua.callGlobalField("g_game", "onRuleViolationCancel", name);
}
void Game::processRuleViolationLock()
{
g_lua.callGlobalField("g_game", "onRuleViolationLock");
}
void Game::processVipAdd(uint id, const std::string& name, bool online)
{
m_vips[id] = Vip(name, online);
@ -299,6 +350,16 @@ void Game::processVipStateChange(uint id, bool online)
g_lua.callGlobalField("g_game", "onVipStateChange", id, online);
}
void Game::processTutorialHint(int id)
{
g_lua.callGlobalField("g_game", "onTutorialHint", id);
}
void Game::processAutomapFlag(const Position& pos, int icon, const std::string& message)
{
}
void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int>>& outfitList)
{
CreaturePtr virtualCreature = CreaturePtr(new Creature);
@ -919,6 +980,25 @@ void Game::editList(int listId, uint id, const std::string& text)
m_protocolGame->sendEditList(listId, id, text);
}
void Game::reportBug(const std::string& comment)
{
if(!canPerformGameAction())
return;
m_protocolGame->sendBugReport(comment);
}
void Game::reportRuleVilation(const std::string& target, int reason, int action, const std::string& comment, const std::string& statement, int statementId, bool ipBanishment)
{
if(!canPerformGameAction())
return;
m_protocolGame->sendRuleVilation(target, reason, action, comment, statement, statementId, ipBanishment);
}
void Game::debugReport(const std::string& a, const std::string& b, const std::string& c, const std::string& d)
{
m_protocolGame->sendDebugReport(a, b, c, d);
}
void Game::requestQuestLog()
{
if(!canPerformGameAction())

View File

@ -51,10 +51,11 @@ protected:
void processLogin();
void processLogout();
void processGameStart(const LocalPlayerPtr& localPlayer, int serverBeat);
void processGameStart(const LocalPlayerPtr& localPlayer, int serverBeat, bool canReportBugs);
void processGameEnd();
void processDeath(int penality);
void processGMActions(const std::vector<uint8>& actions);
void processPlayerStats(double health, double maxHealth,
double freeCapacity, double experience,
double level, double levelPercent,
@ -86,10 +87,20 @@ protected:
void processOpenOwnPrivateChannel(int channelId, const std::string& name);
void processCloseChannel(int channelId);
// rule violations
void processRuleViolationChannel(int channelId);
void processRuleViolationRemove(const std::string& name);
void processRuleViolationCancel(const std::string& name);
void processRuleViolationLock();
// vip related
void processVipAdd(uint id, const std::string& name, bool online);
void processVipStateChange(uint id, bool online);
// tutorial hint
void processTutorialHint(int id);
void processAutomapFlag(const Position& pos, int icon, const std::string& message);
// outfit
void processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int>>& outfitList);
@ -209,11 +220,17 @@ public:
void editText(uint id, const std::string& text);
void editList(int listId, uint id, const std::string& text);
// reports
void reportBug(const std::string& comment);
void reportRuleVilation(const std::string& target, int reason, int action, const std::string& comment, const std::string& statement, int statementId, bool ipBanishment);
void debugReport(const std::string& a, const std::string& b, const std::string& c, const std::string& d);
// questlog related
void requestQuestLog();
void requestQuestLine(int questId);
bool canPerformGameAction();
bool canReportBugs() { return m_canReportBugs; }
bool checkBotProtection();
bool isOnline() { return !!m_localPlayer; }
@ -231,6 +248,7 @@ public:
ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
int getProtocolVersion() { return PROTOCOL; }
std::string getWorldName() { return m_worldName; }
std::vector<uint8> getGMActions() { return m_gmActions; }
private:
void setAttackingCreature(const CreaturePtr& creature);
@ -248,6 +266,8 @@ private:
Otc::FightModes m_fightMode;
Otc::ChaseModes m_chaseMode;
bool m_safeFight;
bool m_canReportBugs;
std::vector<uint8> m_gmActions;
std::string m_worldName;
};

View File

@ -144,6 +144,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction("g_game", "requestQuestLog", std::bind(&Game::requestQuestLog, &g_game));
g_lua.bindClassStaticFunction("g_game", "requestQuestLine", std::bind(&Game::requestQuestLine, &g_game, std::placeholders::_1));
g_lua.bindClassStaticFunction("g_game", "canPerformGameAction", std::bind(&Game::canPerformGameAction, &g_game));
g_lua.bindClassStaticFunction("g_game", "canReportBugs", std::bind(&Game::canReportBugs, &g_game));
g_lua.bindClassStaticFunction("g_game", "checkBotProtection", std::bind(&Game::checkBotProtection, &g_game));
g_lua.bindClassStaticFunction("g_game", "isOnline", std::bind(&Game::isOnline, &g_game));
g_lua.bindClassStaticFunction("g_game", "isDead", std::bind(&Game::isDead, &g_game));

View File

@ -69,7 +69,7 @@ namespace Proto {
enum GameServerOpts {
GameServerInitGame = 10,
GameServerGMActions = 11, // deprecated in last tibia?
GameServerGMActions = 11,
GameServerLoginError = 20,
GameServerLoginAdvice = 21,
GameServerLoginWait = 22,
@ -101,7 +101,7 @@ namespace Proto {
GameServerCloseTrade = 127,
GameServerAmbient = 130,
GameServerGraphicalEffect = 131,
GameServerTextEffect = 132, // deprecated in last tibia
GameServerTextEffect = 132,
GameServerMissleEffect = 133,
GameServerMarkCreature = 134,
GameServerTrappers = 135,
@ -118,18 +118,16 @@ namespace Proto {
GameServerPlayerSkills = 161,
GameServerPlayerState = 162,
GameServerClearTarget = 163,
#if PROTOCOL>=870
GameServerSpellDelay = 164,
GameServerSpellGroupDelay = 165,
#endif
GameServerTalk = 170,
GameServerChannels = 171,
GameServerOpenChannel = 172,
GameServerOpenPrivateChannel = 173,
GameServerRuleViolationChannel = 174, // deprecated in last tibia
GameServerRuleViolationRemove = 175, // deprecated in last tibia
GameServerRuleViolationCancel = 176, // deprecated in last tibia
GameServerRuleViolationLock = 177, // deprecated in last tibia
GameServerRuleViolationChannel = 174,
GameServerRuleViolationRemove = 175,
GameServerRuleViolationCancel = 176,
GameServerRuleViolationLock = 177,
GameServerOpenOwnChannel = 178,
GameServerCloseChannel = 179,
GameServerTextMessage = 180,
@ -216,8 +214,9 @@ namespace Proto {
#endif
ClientAddVip = 220,
ClientRemoveVip = 221,
//ClientBugReport = 230,
//ClientErrorFileEntry = 232,
ClientBugReport = 230,
ClientRuleViolation= 231,
ClientDebugReport = 232,
ClientRequestQuestLog = 240,
ClientRequestQuestLine = 241,
//ClientRuleViolationReport = 242,

View File

@ -98,6 +98,9 @@ public:
void sendChangeOutfit(const Outfit& outfit);
void sendAddVip(const std::string& name);
void sendRemoveVip(uint playerId);
void sendBugReport(const std::string& comment);
void sendRuleVilation(const std::string& target, int reason, int action, const std::string& comment, const std::string& statement, int statementId, bool ipBanishment);
void sendDebugReport(const std::string& a, const std::string& b, const std::string& c, const std::string& d);
void sendRequestQuestLog();
void sendRequestQuestLine(int questId);
@ -153,12 +156,18 @@ private:
void parsePlayerSkills(InputMessage& msg);
void parsePlayerState(InputMessage& msg);
void parsePlayerCancelAttack(InputMessage& msg);
void parseSpellDelay(InputMessage& msg);
void parseSpellGroupDelay(InputMessage& msg);
void parseCreatureSpeak(InputMessage& msg);
void parseChannelList(InputMessage& msg);
void parseOpenChannel(InputMessage& msg);
void parseOpenPrivateChannel(InputMessage& msg);
void parseOpenOwnPrivateChannel(InputMessage& msg);
void parseCloseChannel(InputMessage& msg);
void parseRuleViolationChannel(InputMessage& msg);
void parseRuleViolationRemove(InputMessage& msg);
void parseRuleViolationCancel(InputMessage& msg);
void parseRuleViolationLock(InputMessage& msg);
void parseOpenTrade(InputMessage& msg);
void parseCloseTrade(InputMessage&);
void parseTextMessage(InputMessage& msg);

View File

@ -188,10 +188,10 @@ void ProtocolGame::parseMessage(InputMessage& msg)
break;
#if PROTOCOL>=870
case Proto::GameServerSpellDelay:
parseSpellDelay(msg);
break;
case Proto::GameServerSpellGroupDelay:
msg.getU16(); // spell id
msg.getU16(); // cooldown
msg.getU8(); // unknown
parseSpellGroupDelay(msg);
break;
#endif
case Proto::GameServerTalk:
@ -207,15 +207,16 @@ void ProtocolGame::parseMessage(InputMessage& msg)
parseOpenPrivateChannel(msg);
break;
case Proto::GameServerRuleViolationChannel:
msg.getU16();
parseRuleViolationChannel(msg);
break;
case Proto::GameServerRuleViolationRemove:
msg.getString();
parseRuleViolationRemove(msg);
break;
case Proto::GameServerRuleViolationCancel:
msg.getString();
parseRuleViolationCancel(msg);
break;
case Proto::GameServerRuleViolationLock:
parseRuleViolationLock(msg);
break;
case Proto::GameServerOpenOwnChannel:
parseOpenOwnPrivateChannel(msg);
@ -277,19 +278,20 @@ void ProtocolGame::parseInitGame(InputMessage& msg)
{
uint playerId = msg.getU32();
int serverBeat = msg.getU16();
msg.getU8(); // can report bugs, ignored
bool canReportBugs = msg.getU8();
m_localPlayer = LocalPlayerPtr(new LocalPlayer);
m_localPlayer->setId(playerId);
g_game.processGameStart(m_localPlayer, serverBeat);
g_game.processGameStart(m_localPlayer, serverBeat, canReportBugs);
}
void ProtocolGame::parseGMActions(InputMessage& msg)
{
// not used
std::vector<uint8> actions;
for(int i = 0; i < Proto::NumViolationReasons; ++i)
msg.getU8();
actions.push_back(msg.getU8());
g_game.processGMActions(actions);
}
void ProtocolGame::parseLoginError(InputMessage& msg)
@ -754,19 +756,12 @@ void ProtocolGame::parsePlayerStats(InputMessage& msg)
double soul = msg.getU8();
double stamina = msg.getU16();
if(!m_localPlayer) {
logTraceError("there is no local player");
return;
}
m_localPlayer->setHealth(health, maxHealth);
m_localPlayer->setFreeCapacity(freeCapacity);
m_localPlayer->setExperience(experience);
m_localPlayer->setLevel(level, levelPercent);
m_localPlayer->setMana(mana, maxMana);
m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent);
m_localPlayer->setStamina(stamina);
m_localPlayer->setSoul(soul);
g_game.processPlayerStats(health, maxHealth,
freeCapacity, experience,
level, levelPercent,
mana, maxMana,
magicLevel, magicLevelPercent,
soul, stamina);
}
void ProtocolGame::parsePlayerSkills(InputMessage& msg)
@ -801,9 +796,25 @@ void ProtocolGame::parsePlayerCancelAttack(InputMessage& msg)
g_game.processAttackCancel();
}
void ProtocolGame::parseSpellDelay(InputMessage& msg)
{
msg.getU16(); // spell id
msg.getU16(); // cooldown
msg.getU8(); // unknown
}
void ProtocolGame::parseSpellGroupDelay(InputMessage& msg)
{
msg.getU16(); // spell id
msg.getU16(); // cooldown
msg.getU8(); // unknown
}
void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
{
msg.getU32(); // unkSpeak
msg.getU32(); // unknown
std::string name = msg.getString();
int level = msg.getU16();
int serverType = msg.getU8();
@ -888,6 +899,33 @@ void ProtocolGame::parseCloseChannel(InputMessage& msg)
g_game.processCloseChannel(channelId);
}
void ProtocolGame::parseRuleViolationChannel(InputMessage& msg)
{
int channelId = msg.getU16();
g_game.processRuleViolationChannel(channelId);
}
void ProtocolGame::parseRuleViolationRemove(InputMessage& msg)
{
std::string name = msg.getString();
g_game.processRuleViolationRemove(name);
}
void ProtocolGame::parseRuleViolationCancel(InputMessage& msg)
{
std::string name = msg.getString();
g_game.processRuleViolationCancel(name);
}
void ProtocolGame::parseRuleViolationLock(InputMessage& msg)
{
g_game.processRuleViolationLock();
}
void ProtocolGame::parseTextMessage(InputMessage& msg)
{
int type = msg.getU8();
@ -989,8 +1027,8 @@ void ProtocolGame::parseVipLogout(InputMessage& msg)
void ProtocolGame::parseTutorialHint(InputMessage& msg)
{
// ignored
msg.getU8(); // tutorial id
int id = msg.getU8(); // tutorial id
g_game.processTutorialHint(id);
}
void ProtocolGame::parseAutomapFlag(InputMessage& msg)

View File

@ -601,6 +601,39 @@ void ProtocolGame::sendRemoveVip(uint playerId)
send(msg);
}
void ProtocolGame::sendBugReport(const std::string& comment)
{
OutputMessage msg;
msg.addU8(Proto::ClientBugReport);
msg.addString(comment);
send(msg);
}
void ProtocolGame::sendRuleVilation(const std::string& target, int reason, int action, const std::string& comment, const std::string& statement, int statementId, bool ipBanishment)
{
OutputMessage msg;
msg.addU8(Proto::ClientRuleViolation);
msg.addString(target);
msg.addU8(reason);
msg.addU8(action);
msg.addString(comment);
msg.addString(statement);
msg.addU16(statementId);
msg.addU8(ipBanishment);
send(msg);
}
void ProtocolGame::sendDebugReport(const std::string& a, const std::string& b, const std::string& c, const std::string& d)
{
OutputMessage msg;
msg.addU8(Proto::ClientDebugReport);
msg.addString(a);
msg.addString(b);
msg.addString(c);
msg.addString(d);
send(msg);
}
void ProtocolGame::sendRequestQuestLog()
{
OutputMessage msg;