mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-11-16 23:10:09 +00:00
Explicitly update buddy records in DB
this should fix the bug where removing a buddy while they're offline won't take you off their list until you disconnect
This commit is contained in:
@@ -521,7 +521,7 @@ void Database::updatePlayer(Player *player) {
|
||||
updateInventory(player);
|
||||
updateNanos(player);
|
||||
updateQuests(player);
|
||||
updateBuddies(player);
|
||||
//updateBuddies(player); we add/remove buddies explicitly now
|
||||
}
|
||||
|
||||
void Database::updateInventory(Player *player){
|
||||
@@ -634,6 +634,7 @@ void Database::updateQuests(Player* player) {
|
||||
db.commit();
|
||||
}
|
||||
|
||||
// note: do not use. explicitly add/remove records instead.
|
||||
void Database::updateBuddies(Player* player) {
|
||||
db.begin_transaction();
|
||||
|
||||
@@ -766,6 +767,37 @@ int Database::getNumBuddies(Player* player) {
|
||||
return buddies.size() > 50 ? 50 : buddies.size();
|
||||
}
|
||||
|
||||
// buddies
|
||||
void Database::addBuddyship(int playerA, int playerB) {
|
||||
std::lock_guard<std::mutex> lock(dbCrit);
|
||||
|
||||
db.begin_transaction();
|
||||
|
||||
Buddyship record;
|
||||
record.PlayerAId = playerA;
|
||||
record.PlayerBId = playerB;
|
||||
record.Status = 0; // blocking ???
|
||||
db.insert(record);
|
||||
|
||||
db.commit();
|
||||
}
|
||||
|
||||
void Database::removeBuddyship(int playerA, int playerB) {
|
||||
std::lock_guard<std::mutex> lock(dbCrit);
|
||||
|
||||
db.begin_transaction();
|
||||
|
||||
db.remove_all<Buddyship>(
|
||||
where(c(&Buddyship::PlayerAId) == playerA && c(&Buddyship::PlayerBId) == playerB)
|
||||
);
|
||||
|
||||
db.remove_all<Buddyship>( // the pair could be in either position
|
||||
where(c(&Buddyship::PlayerAId) == playerB && c(&Buddyship::PlayerBId) == playerA)
|
||||
);
|
||||
|
||||
db.commit();
|
||||
}
|
||||
|
||||
// email
|
||||
int Database::getUnreadEmailCount(int playerID) {
|
||||
std::lock_guard<std::mutex> lock(dbCrit);
|
||||
|
||||
Reference in New Issue
Block a user