Skip to content

Commit

Permalink
* init
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Dec 23, 2024
1 parent d5c35d2 commit 86f40e8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
15 changes: 11 additions & 4 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2796,13 +2796,19 @@ int32_t Player::getIdleTime() const {
}

void Player::setTraining(bool value) {
if (isExerciseTraining() == value) {
return;
}

exerciseTraining = value;
VipStatus_t newStatus = exerciseTraining ? VipStatus_t::TRAINING : VipStatus_t::ONLINE;
for (const auto &[key, player] : g_game().getPlayers()) {
if (!this->isInGhostMode() || player->isAccessPlayer()) {
player->vip()->notifyStatusChange(static_self_cast<Player>(), value ? VipStatus_t::TRAINING : VipStatus_t::ONLINE, false);
player->vip()->notifyStatusChange(static_self_cast<Player>(), newStatus, false);
}
}
vip()->setStatus(VipStatus_t::TRAINING);
setExerciseTraining(value);

setExerciseTraining(exerciseTraining);
}

void Player::addItemImbuementStats(const Imbuement* imbuement) {
Expand Down Expand Up @@ -3876,7 +3882,8 @@ void Player::removeList() {

void Player::addList() {
for (const auto &[key, player] : g_game().getPlayers()) {
player->vip()->notifyStatusChange(static_self_cast<Player>(), vip()->getStatus());
VipStatus_t status = player->isExerciseTraining() ? VipStatus_t::TRAINING : VipStatus_t::ONLINE;
player->vip()->notifyStatusChange(static_self_cast<Player>(), status, false);
}

g_game().addPlayer(static_self_cast<Player>());
Expand Down
4 changes: 0 additions & 4 deletions src/creatures/players/vip/player_vip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ class PlayerVIP {
size_t getMaxEntries() const;
uint8_t getMaxGroupEntries() const;

VipStatus_t getStatus() const {
return status;
}

void setStatus(VipStatus_t newStatus) {
status = newStatus;
}
Expand Down
4 changes: 3 additions & 1 deletion src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5990,7 +5990,9 @@ void Game::playerRequestAddVip(uint32_t playerId, const std::string &name) {
}

if (!vipPlayer->isInGhostMode() || player->isAccessPlayer()) {
player->vip()->add(vipPlayer->getGUID(), vipPlayer->getName(), vipPlayer->vip()->getStatus());
player->vip()->add(vipPlayer->getGUID(), vipPlayer->getName(), VipStatus_t::ONLINE);
} else if (vipPlayer->isExerciseTraining()) {
player->vip()->add(vipPlayer->getGUID(), vipPlayer->getName(), VipStatus_t::TRAINING);
} else {
player->vip()->add(vipPlayer->getGUID(), vipPlayer->getName(), VipStatus_t::OFFLINE);
}
Expand Down
3 changes: 2 additions & 1 deletion src/lua/functions/creatures/player/player_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3447,7 +3447,8 @@ int PlayerFunctions::luaPlayerSetGhostMode(lua_State* L) {
} else {
for (const auto &it : g_game().getPlayers()) {
if (!it.second->isAccessPlayer()) {
it.second->vip()->notifyStatusChange(player, player->vip()->getStatus());
VipStatus_t status = it.second->isExerciseTraining() ? VipStatus_t::TRAINING : VipStatus_t::ONLINE;
it.second->vip()->notifyStatusChange(player, status);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6890,26 +6890,26 @@ void ProtocolGame::sendAddCreature(const std::shared_ptr<Creature> &creature, co

if (player->isAccessPlayer()) {
for (const VIPEntry &entry : vipEntries) {
VipStatus_t vipStatus;
VipStatus_t vipStatus = VipStatus_t::ONLINE;

std::shared_ptr<Player> vipPlayer = g_game().getPlayerByGUID(entry.guid);
if (!vipPlayer) {
vipStatus = VipStatus_t::OFFLINE;
} else {
vipStatus = vipPlayer->vip()->getStatus();
} else if (vipPlayer->isExerciseTraining()) {
vipStatus = VipStatus_t::TRAINING;
}

sendVIP(entry.guid, entry.name, entry.description, entry.icon, entry.notify, vipStatus);
}
} else {
for (const VIPEntry &entry : vipEntries) {
VipStatus_t vipStatus;
VipStatus_t vipStatus = VipStatus_t::ONLINE;

std::shared_ptr<Player> vipPlayer = g_game().getPlayerByGUID(entry.guid);
if (!vipPlayer || vipPlayer->isInGhostMode()) {
vipStatus = VipStatus_t::OFFLINE;
} else {
vipStatus = vipPlayer->vip()->getStatus();
} else if (vipPlayer->isExerciseTraining()) {
vipStatus = VipStatus_t::TRAINING;
}

sendVIP(entry.guid, entry.name, entry.description, entry.icon, entry.notify, vipStatus);
Expand Down

0 comments on commit 86f40e8

Please sign in to comment.