Skip to content

Commit

Permalink
Fixed minor packet error in GroupInviterData, the ID in there should …
Browse files Browse the repository at this point in the history
…be the object ID for the CREO that sent the invitation and not the object ID for the GRUP
  • Loading branch information
madsboddum committed Jul 8, 2022
1 parent fa9c4cf commit 630b80a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import com.projectswg.common.encoding.Encodable
import com.projectswg.common.network.NetBuffer
import com.projectswg.holocore.resources.support.global.player.Player

class GroupInviterData(var id: Long, var sender: Player?, private var counter: Long) : Encodable {
class GroupInviterData(var senderId: Long, var sender: Player?, private var counter: Long, var groupId: Long) : Encodable {
override fun decode(data: NetBuffer?) {
id = data!!.long
senderId = data!!.long
counter = data.long
}

override fun encode(): ByteArray {
val data = NetBuffer.allocate(length)
data.addLong(id)
data.addLong(senderId)
data.addLong(counter)
return data.array()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CreatureObjectSharedNP implements MongoPersistable {

private final CreatureObject obj;

private transient GroupInviterData inviterData = new GroupInviterData(-1, null, 0);
private transient GroupInviterData inviterData = new GroupInviterData(0, null, 0, 0);
private transient long groupId = 0;

private short level = 1;
Expand Down Expand Up @@ -179,7 +179,12 @@ public void setCostume(String costume) {

public void updateGroupInviteData(Player sender, long groupId) {
inviterData.setSender(sender);
inviterData.setId(groupId);
if (sender != null) {
inviterData.setSenderId(sender.getCreatureObject().getObjectId());
} else {
inviterData.setSenderId(0); // Makes the invite window go away
}
inviterData.setGroupId(groupId);
inviterData.incrementCounter();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class GroupService(private val groups: MutableMap<Long, GroupObject> = Concurren
sendSystemMessage(inviter, "full")
return false
}
if (target.inviterData.id != 0L) {
if (target.inviterData.id != inviter.creatureObject.groupId) {
if (target.inviterData.groupId != 0L) {
if (target.inviterData.groupId != inviter.creatureObject.groupId) {
sendSystemMessage(inviter, "considering_other_group", "TT", target.objectId)
} else {
sendSystemMessage(inviter, "considering_your_group", "TT", target.objectId)
Expand Down Expand Up @@ -183,15 +183,14 @@ class GroupService(private val groups: MutableMap<Long, GroupObject> = Concurren
sendSystemMessage(player, "must_be_invited")
return
}
var groupId = creature.inviterData.id
if (groupId == -1L) {
groupId = sender.creatureObject.groupId
if (groupId == 0L) groupId = -1 // Client wants -1 for default
}
if (groupId == -1L) { // Group doesn't exist yet
createGroup(sender, player)
} else { // Group already exists

val groupId = creature.inviterData.groupId
val groupAlreadyExists = groups.containsKey(groupId)

if (groupAlreadyExists) {
joinGroup(sender.creatureObject, creature, groupId)
} else {
createGroup(sender, player)
}
} finally {
clearInviteData(creature)
Expand Down Expand Up @@ -337,12 +336,7 @@ class GroupService(private val groups: MutableMap<Long, GroupObject> = Concurren
private fun sendInvite(groupLeader: Player, invitee: CreatureObject, groupId: Long) {
sendSystemMessage(invitee.owner, "invite_target", "TT", groupLeader.characterName)
sendSystemMessage(groupLeader, "invite_leader", "TT", invitee.objectName)

if (groupId == 0L) {
invitee.updateGroupInviteData(groupLeader, -1) // Client wants -1 for default
} else {
invitee.updateGroupInviteData(groupLeader, groupId)
}
invitee.updateGroupInviteData(groupLeader, groupId)
}

private fun sendGroupSystemMessage(group: GroupObject?, id: String) {
Expand Down

0 comments on commit 630b80a

Please sign in to comment.