mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
Works for online players now
This commit is contained in:
parent
d193fe61be
commit
12ea2dfb2e
@ -28,6 +28,11 @@ void ChatIgnoreList::GetIgnoreList(Packet* packet) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!receiver->ignoredPlayers.empty()) {
|
||||||
|
LOG_DEBUG("Player %llu already has an ignore list", playerId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto ignoreList = Database::Get()->GetIgnoreList(static_cast<uint32_t>(playerId));
|
auto ignoreList = Database::Get()->GetIgnoreList(static_cast<uint32_t>(playerId));
|
||||||
if (ignoreList.empty()) {
|
if (ignoreList.empty()) {
|
||||||
LOG_DEBUG("Player %llu has no ignores", playerId);
|
LOG_DEBUG("Player %llu has no ignores", playerId);
|
||||||
@ -104,16 +109,21 @@ void ChatIgnoreList::AddIgnore(Packet* packet) {
|
|||||||
|
|
||||||
bitStream.Write(IgnoreResponse::ALREADY_IGNORED);
|
bitStream.Write(IgnoreResponse::ALREADY_IGNORED);
|
||||||
} else {
|
} else {
|
||||||
|
// Get the playerId falling back to query if not online
|
||||||
auto* playerData = Game::playerContainer.GetPlayerData(toIgnoreStr);
|
auto* playerData = Game::playerContainer.GetPlayerData(toIgnoreStr);
|
||||||
if (!playerData) {
|
if (!playerData) {
|
||||||
// Fall back to query
|
// Fall back to query
|
||||||
auto player = Database::Get()->GetCharacterInfo(toIgnoreStr);
|
auto player = Database::Get()->GetCharacterInfo(toIgnoreStr);
|
||||||
if (!player || player->name != toIgnoreStr) {
|
if (!player || player->name != toIgnoreStr) {
|
||||||
LOG_DEBUG("Player %s not found", toIgnoreStr.c_str());
|
LOG_DEBUG("Player %s not found", toIgnoreStr.c_str());
|
||||||
|
|
||||||
bitStream.Write(IgnoreResponse::PLAYER_NOT_FOUND);
|
|
||||||
} else {
|
} else {
|
||||||
ignoredPlayerId = player->id;
|
ignoredPlayerId = player->id;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ignoredPlayerId = playerData->playerID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ignoredPlayerId != LWOOBJID_EMPTY) {
|
||||||
Database::Get()->AddIgnore(static_cast<uint32_t>(playerId), static_cast<uint32_t>(ignoredPlayerId));
|
Database::Get()->AddIgnore(static_cast<uint32_t>(playerId), static_cast<uint32_t>(ignoredPlayerId));
|
||||||
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::CHARACTER);
|
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::CHARACTER);
|
||||||
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::PERSISTENT);
|
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::PERSISTENT);
|
||||||
@ -122,7 +132,8 @@ void ChatIgnoreList::AddIgnore(Packet* packet) {
|
|||||||
LOG_DEBUG("Player %llu is ignoring %s", playerId, toIgnoreStr.c_str());
|
LOG_DEBUG("Player %llu is ignoring %s", playerId, toIgnoreStr.c_str());
|
||||||
|
|
||||||
bitStream.Write(IgnoreResponse::SUCCESS);
|
bitStream.Write(IgnoreResponse::SUCCESS);
|
||||||
}
|
} else {
|
||||||
|
bitStream.Write(IgnoreResponse::PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ std::vector<IIgnoreList::Info> MySQLDatabase::GetIgnoreList(const uint32_t playe
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MySQLDatabase::AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
void MySQLDatabase::AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||||
ExecuteInsert("INSERT INTO ignore_list (player_id, ignored_player_id) VALUES (?, ?)", playerId, ignoredPlayerId);
|
ExecuteInsert("INSERT IGNORE INTO ignore_list (player_id, ignored_player_id) VALUES (?, ?)", playerId, ignoredPlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MySQLDatabase::RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
void MySQLDatabase::RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user