Browse Source

Prevent duplicate party members

- Addresses the issue in the client and server.
- Keep track of which players (by name) are added to the party UI in
  `onGetParty()' to prevent duplicate frames for a player.
- On the server side, don't add a player ID to the party if already
  present.
tags/v0.1.2^2
Paul Holden 7 years ago
committed by Paul Holden
parent
commit
553e28fb5b
2 changed files with 22 additions and 1 deletions
  1. +14
    -0
      src/client/ui/templates/party/party.js
  2. +8
    -1
      src/server/components/social.js

+ 14
- 0
src/client/ui/templates/party/party.js View File

@@ -100,6 +100,12 @@ define([
},

onGetParty: function(party) {
// Destroy invite frame if you join a party
if (this.invite) {
this.invite.el.remove();
this.invite = null;
}

var container = this.find('.party .list')
.empty();

@@ -107,6 +113,8 @@ define([
if (!party)
return;

var members = {};

party.forEach(function(p) {
if (p == window.player.serverId)
return;
@@ -117,6 +125,10 @@ define([
var name = player ? player.name : 'unknown';
var level = 'level: ' + (player ? player.level : '?');

// Disallow duplicate frames for players in the party
if (members[name])
return;

var html = templatePartyMember
.replace('$NAME$', name)
.replace('$LEVEL$', level);
@@ -135,6 +147,8 @@ define([
});
if ((memberObj) && (memberObj.stats))
this.onGetPartyStats(p, memberObj.stats.values);

members[name] = 1;
}, this);
},



+ 8
- 1
src/server/components/social.js View File

@@ -181,7 +181,14 @@ define([
this.updatePartyOnThread();
}

this.party.push(sourceId);
// Only add if not yet in party
if (!this.party.find(function (id) {
return id === sourceId;
})
) {
this.party.push(sourceId);
}

this.updatePartyOnThread();

this.party.forEach(function(p) {


Loading…
Cancel
Save