mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 14:03:26 +02:00
Vip functionality, closes #83
This commit is contained in:
@@ -375,6 +375,7 @@ namespace Otc
|
||||
GameNewOutfitProtocol = 49,
|
||||
GamePVPMode = 50,
|
||||
GameWritableDate = 51,
|
||||
GameAdditionalVipInfo = 52,
|
||||
|
||||
LastGameFeature = 101
|
||||
};
|
||||
|
@@ -402,10 +402,10 @@ void Game::processRuleViolationLock()
|
||||
g_lua.callGlobalField("g_game", "onRuleViolationLock");
|
||||
}
|
||||
|
||||
void Game::processVipAdd(uint id, const std::string& name, uint status, int iconId, bool notifyLogin)
|
||||
void Game::processVipAdd(uint id, const std::string& name, uint status, const std::string& description, int iconId, bool notifyLogin)
|
||||
{
|
||||
m_vips[id] = Vip(name, status);
|
||||
g_lua.callGlobalField("g_game", "onAddVip", id, name, status, iconId, notifyLogin);
|
||||
m_vips[id] = Vip(name, status, description, iconId, notifyLogin);
|
||||
g_lua.callGlobalField("g_game", "onAddVip", id, name, status, description, iconId, notifyLogin);
|
||||
}
|
||||
|
||||
void Game::processVipStateChange(uint id, uint status)
|
||||
@@ -1192,6 +1192,23 @@ void Game::removeVip(int playerId)
|
||||
m_protocolGame->sendRemoveVip(playerId);
|
||||
}
|
||||
|
||||
void Game::editVip(int playerId, const std::string& description, int iconId, bool notifyLogin)
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
|
||||
auto it = m_vips.find(playerId);
|
||||
if(it == m_vips.end())
|
||||
return;
|
||||
|
||||
std::get<2>(m_vips[playerId]) = description;
|
||||
std::get<3>(m_vips[playerId]) = iconId;
|
||||
std::get<4>(m_vips[playerId]) = notifyLogin;
|
||||
|
||||
if(getFeature(Otc::GameAdditionalVipInfo))
|
||||
m_protocolGame->sendEditVip(playerId, description, iconId, notifyLogin);
|
||||
}
|
||||
|
||||
void Game::setChaseMode(Otc::ChaseModes chaseMode)
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
@@ -1521,6 +1538,10 @@ void Game::setProtocolVersion(int version)
|
||||
enableFeature(Otc::GameOfflineTrainingTime);
|
||||
}
|
||||
|
||||
if(version >= 963) {
|
||||
enableFeature(Otc::GameAdditionalVipInfo);
|
||||
}
|
||||
|
||||
if(version >= 973) {
|
||||
enableFeature(Otc::GameLoginPending);
|
||||
enableFeature(Otc::GameNewSpeedLaw);
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <bitset>
|
||||
|
||||
typedef std::tuple<std::string, uint> Vip;
|
||||
typedef std::tuple<std::string, uint, std::string, int, bool> Vip;
|
||||
|
||||
//@bindsingleton g_game
|
||||
class Game
|
||||
@@ -101,7 +101,7 @@ protected:
|
||||
void processRuleViolationLock();
|
||||
|
||||
// vip related
|
||||
void processVipAdd(uint id, const std::string& name, uint status, int iconId, bool notifyLogin);
|
||||
void processVipAdd(uint id, const std::string& name, uint status, const std::string& description, int iconId, bool notifyLogin);
|
||||
void processVipStateChange(uint id, uint status);
|
||||
|
||||
// tutorial hint
|
||||
@@ -206,6 +206,7 @@ public:
|
||||
// vip related
|
||||
void addVip(const std::string& name);
|
||||
void removeVip(int playerId);
|
||||
void editVip(int playerId, const std::string& description, int iconId, bool notifyLogin);
|
||||
|
||||
// fight modes related
|
||||
void setChaseMode(Otc::ChaseModes chaseMode);
|
||||
|
@@ -225,6 +225,7 @@ void Client::registerLuaFunctions()
|
||||
g_lua.bindSingletonFunction("g_game", "changeOutfit", &Game::changeOutfit, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "addVip", &Game::addVip, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "removeVip", &Game::removeVip, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "editVip", &Game::editVip, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "setChaseMode", &Game::setChaseMode, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "setFightMode", &Game::setFightMode, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "setPVPMode", &Game::setPVPMode, &g_game);
|
||||
|
@@ -232,6 +232,7 @@ namespace Proto {
|
||||
ClientMount = 212, // 870
|
||||
ClientAddVip = 220,
|
||||
ClientRemoveVip = 221,
|
||||
ClientEditVip = 222,
|
||||
ClientBugReport = 230,
|
||||
ClientRuleViolation = 231,
|
||||
ClientDebugReport = 232,
|
||||
|
@@ -102,6 +102,7 @@ public:
|
||||
void sendMountStatus(bool mount);
|
||||
void sendAddVip(const std::string& name);
|
||||
void sendRemoveVip(uint playerId);
|
||||
void sendEditVip(uint playerId, const std::string& description, int iconId, bool notifyLogin);
|
||||
void sendBugReport(const std::string& comment);
|
||||
void sendRuleViolation(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);
|
||||
|
@@ -1492,19 +1492,19 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg)
|
||||
void ProtocolGame::parseVipAdd(const InputMessagePtr& msg)
|
||||
{
|
||||
uint id, iconId = 0, status;
|
||||
std::string name, desc;
|
||||
std::string name, desc = "";
|
||||
bool notifyLogin = false;
|
||||
|
||||
id = msg->getU32();
|
||||
name = g_game.formatCreatureName(msg->getString());
|
||||
if(g_game.getProtocolVersion() >= 963) {
|
||||
if(g_game.getFeature(Otc::GameAdditionalVipInfo)) {
|
||||
desc = msg->getString();
|
||||
iconId = msg->getU32();
|
||||
notifyLogin = msg->getU8();
|
||||
}
|
||||
status = msg->getU8();
|
||||
|
||||
g_game.processVipAdd(id, name, status, iconId, notifyLogin);
|
||||
g_game.processVipAdd(id, name, status, desc, iconId, notifyLogin);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseVipState(const InputMessagePtr& msg)
|
||||
|
@@ -740,6 +740,17 @@ void ProtocolGame::sendRemoveVip(uint playerId)
|
||||
send(msg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendEditVip(uint playerId, const std::string& description, int iconId, bool notifyLogin)
|
||||
{
|
||||
OutputMessagePtr msg(new OutputMessage);
|
||||
msg->addU8(Proto::ClientEditVip);
|
||||
msg->addU32(playerId);
|
||||
msg->addString(description);
|
||||
msg->addU32(iconId);
|
||||
msg->addU8(notifyLogin);
|
||||
send(msg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendBugReport(const std::string& comment)
|
||||
{
|
||||
OutputMessagePtr msg(new OutputMessage);
|
||||
|
Reference in New Issue
Block a user