Merge pull request #727 from Josh-Larson/bugfix/Holocore-666-afk-not-showing

Fixed Holocore-666 "AFK not showing"
This commit is contained in:
Josh Larson
2022-07-30 16:42:17 -05:00
committed by GitHub
2 changed files with 12 additions and 7 deletions
@@ -29,14 +29,13 @@ package com.projectswg.holocore.resources.support.data.collections;
import com.projectswg.common.encoding.Encodable;
import com.projectswg.common.network.NetBuffer;
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.BitSet;
public class SWGFlag extends BitSet implements Encodable {
private static final long serialVersionUID = 2L;
private final int view;
private final int updateType;
@@ -55,12 +54,12 @@ public class SWGFlag extends BitSet implements Encodable {
}
@Override
public byte[] encode() {
public byte @NotNull [] encode() {
byte [] encoded = toByteArray();
int length = (int) Math.ceil(encoded.length / 4.0);
int resultingInts = (encoded.length + 3) / 4; // rounds up
NetBuffer buffer = NetBuffer.allocate((length + 1) * 4);
buffer.addInt(length);
NetBuffer buffer = NetBuffer.allocate(4 + resultingInts * 4);
buffer.addInt(resultingInts);
buffer.addRawArray(encoded);
return buffer.array();
}
@@ -52,7 +52,13 @@ public enum PlayerFlags {
/** Display the Faction Rank */
FACTIONRANK (9),
/** Display the player's location in the matchmaking search */
DISPLAY_LOCATION_IN_SEARCH (10);
DISPLAY_LOCATION_IN_SEARCH (10),
/** Out of Character */
OUT_OF_CHARACTER (11),
/** Looking For Work */
LOOKING_FOR_WORK (13),
/** Anonymous */
ANONYMOUS (127);
private static final PlayerFlags [] FLAGS = values();