RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.net.packet.out.SendPlayerUpdate Class Reference
Inheritance diagram for com.runehive.net.packet.out.SendPlayerUpdate:
Collaboration diagram for com.runehive.net.packet.out.SendPlayerUpdate:

Classes

enum  UpdateState

Public Member Functions

boolean encode (Player player)
 SendPlayerUpdate ()
Public Member Functions inherited from com.runehive.net.packet.OutgoingPacket
void execute (Player player)
 OutgoingPacket (int opcode, int capacity)
 OutgoingPacket (int opcode, PacketType type)
 OutgoingPacket (int opcode, PacketType type, int size)

Static Private Member Functions

static void addNewPlayer (PacketBuilder packetBuf, Player player, Player other)
static void appendAnimationMask (Player other, PacketBuilder maskBuf)
static void appendAppearanceMask (Player other, PacketBuilder blockBuf)
static void appendChatMask (PacketBuilder blockBuf, Player other)
static void appendFaceCoordinteMask (Player other, PacketBuilder blockBuf)
static void appendFaceEntityMask (Player other, PacketBuilder blockBuf)
static void appendForceChatMask (Player other, PacketBuilder blockBuf)
static void appendForceMovementMask (Player player, Player other, PacketBuilder blockBuf)
static void appendGraphicMask (Player other, PacketBuilder blockBuf)
static void appendHitMask (final Player player, final PacketBuilder blockBuf)
static void appendSecondHitMask (final Player player, final PacketBuilder blockBuf)
static void updateMovement (Player player, PacketBuilder packetBuf)
static void updatePlayer (PacketBuilder blockBuf, Player player, Player other, UpdateState state)

Static Private Attributes

static final Logger logger = LogManager.getLogger(SendPlayerUpdate.class)

Additional Inherited Members

Protected Attributes inherited from com.runehive.net.packet.OutgoingPacket
final PacketBuilder builder

Detailed Description

Definition at line 34 of file SendPlayerUpdate.java.

Constructor & Destructor Documentation

◆ SendPlayerUpdate()

com.runehive.net.packet.out.SendPlayerUpdate.SendPlayerUpdate ( )

Definition at line 38 of file SendPlayerUpdate.java.

38 {
39 super(81, PacketType.VAR_SHORT);
40 }

References com.runehive.net.packet.PacketType.VAR_SHORT.

Member Function Documentation

◆ addNewPlayer()

void com.runehive.net.packet.out.SendPlayerUpdate.addNewPlayer ( PacketBuilder packetBuf,
Player player,
Player other )
staticprivate

Definition at line 110 of file SendPlayerUpdate.java.

110 {
111 packetBuf.writeBits(11, other.getIndex())
112 .writeBit(true) // isUpdateRequired
113 .writeBit(true) // discardWalkingQueue
114 .writeBits(5, other.getY() - player.getY())
115 .writeBits(5, other.getX() - player.getX());
116 }

References com.runehive.game.world.entity.Entity.getIndex(), com.runehive.game.world.entity.Entity.getX(), com.runehive.game.world.entity.Entity.getY(), com.runehive.net.packet.PacketBuilder.writeBit(), and com.runehive.net.packet.PacketBuilder.writeBits().

Referenced by encode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendAnimationMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendAnimationMask ( Player other,
PacketBuilder maskBuf )
staticprivate

Definition at line 241 of file SendPlayerUpdate.java.

241 {
242 Animation anim = other.getAnimation().orElse(Animation.RESET);
243 maskBuf.writeShort(anim.getId(), ByteOrder.LE);
244 maskBuf.writeByte(anim.getDelay(), ByteModification.NEG);
245 }

References com.runehive.game.world.entity.mob.Mob.getAnimation(), com.runehive.game.Animation.getDelay(), com.runehive.game.Animation.getId(), com.runehive.net.codec.ByteOrder.LE, com.runehive.net.codec.ByteModification.NEG, com.runehive.game.Animation.RESET, com.runehive.net.packet.PacketBuilder.writeByte(), and com.runehive.net.packet.PacketBuilder.writeShort().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendAppearanceMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendAppearanceMask ( Player other,
PacketBuilder blockBuf )
staticprivate

Definition at line 263 of file SendPlayerUpdate.java.

263 {
264 final PacketBuilder tempBuf = PacketBuilder.alloc();
265 final var overrides = other.overrides;
266 try {
267 tempBuf.writeByte(other.appearance.getGender().ordinal())
268 .writeByte(other.headIcon)
269 .writeByte(other.skulling.getHeadIconType().getCode())
270 .writeByte(other.valueIcon);
271
272 if (other.id != -1) {
273 tempBuf.writeShort(-1);
274 tempBuf.writeShort(other.id);
275 } else {
276 Item helm = other.equipment.get(Equipment.HEAD_SLOT);
277 if (overrides.hasOverride(Equipment.HEAD_SLOT)) {
278 tempBuf.writeShort(0x200 + overrides.get(Equipment.HELM_SLOT).getId());
279 } else if (helm != null && helm.getId() > 1) {
280 tempBuf.writeShort(0x200 + other.equipment.get(Equipment.HELM_SLOT).getId());
281 } else {
282 tempBuf.writeByte(0);
283 }
284
285 if (overrides.hasOverride(Equipment.CAPE_SLOT)) {
286 tempBuf.writeShort(0x200 + overrides.get(Equipment.CAPE_SLOT).getId());
287 } else if (other.equipment.get(Equipment.CAPE_SLOT) != null) {
288 tempBuf.writeShort(0x200 + other.equipment.get(Equipment.CAPE_SLOT).getId());
289 } else {
290 tempBuf.writeByte(0);
291 }
292
293 if (overrides.hasOverride(Equipment.AMULET_SLOT)) {
294 tempBuf.writeShort(0x200 + overrides.get(Equipment.AMULET_SLOT).getId());
295 } else if (other.equipment.get(Equipment.AMULET_SLOT) != null) {
296 tempBuf.writeShort(0x200 + other.equipment.get(Equipment.AMULET_SLOT).getId());
297 } else {
298 tempBuf.writeByte(0);
299 }
300
301 if (overrides.hasOverride(Equipment.WEAPON_SLOT)) {
302 tempBuf.writeShort(0x200 + overrides.get(Equipment.WEAPON_SLOT).getId());
303 } else if (other.equipment.get(Equipment.WEAPON_SLOT) != null) {
304 tempBuf.writeShort(0x200 + other.equipment.get(Equipment.WEAPON_SLOT).getId());
305 } else {
306 tempBuf.writeByte(0);
307 }
308
309 Item torso = other.equipment.get(Equipment.CHEST_SLOT);
310 if (overrides.hasOverride(Equipment.CHEST_SLOT)) {
311 tempBuf.writeShort(0x200 + overrides.get(Equipment.CHEST_SLOT).getId());
312 } else if (torso != null && torso.getId() > 1) {
313 tempBuf.writeShort(0x200 + other.equipment.get(Equipment.CHEST_SLOT).getId());
314 } else {
315 tempBuf.writeShort(0x100 + other.appearance.getTorso());
316 }
317
318 if (overrides.hasOverride(Equipment.SHIELD_SLOT)) {
319 tempBuf.writeShort(0x200 + overrides.get(Equipment.SHIELD_SLOT).getId());
320 } else if (other.equipment.get(Equipment.SHIELD_SLOT) != null) {
321 if (overrides.hasOverride(Equipment.WEAPON_SLOT) && overrides.get(Equipment.WEAPON_SLOT).isTwoHanded()) {
322 tempBuf.writeByte(0);
323 } else {
324 tempBuf.writeShort(0x200 + other.equipment.get(Equipment.SHIELD_SLOT).getId());
325 }
326 } else {
327 tempBuf.writeByte(0);
328 }
329
330 if (torso != null && torso.getId() > 1 && torso.getEquipmentType().equals(EquipmentType.BODY) ||
331 overrides.hasOverride(Equipment.CHEST_SLOT) && overrides.get(Equipment.CHEST_SLOT).getEquipmentType().equals(EquipmentType.BODY)) {
332 tempBuf.writeByte(0);
333 } else {
334 tempBuf.writeShort(0x100 + other.appearance.getArms());
335 }
336
337 if (overrides.hasOverride(Equipment.LEGS_SLOT)) {
338 tempBuf.writeShort(0x200 + overrides.get(Equipment.LEGS_SLOT).getId());
339 } else if (other.equipment.get(Equipment.LEGS_SLOT) != null) {
340 tempBuf.writeShort(0x200 + other.equipment.get(Equipment.LEGS_SLOT).getId());
341 } else {
342 tempBuf.writeShort(0x100 + other.appearance.getLegs());
343 }
344
345 boolean head = true;
346 boolean beard = true;
347
348 if (helm != null && helm.getId() > 1) {
349 EquipmentType type = helm.getEquipmentType();
350 head = type.equals(EquipmentType.MASK) || type.equals(EquipmentType.HAT);
351 beard = type.equals(EquipmentType.FACE) || type.equals(EquipmentType.HAT);
352 }
353
354 if (overrides.hasOverride(Equipment.HEAD_SLOT)) {
355 final var override = overrides.get(Equipment.HEAD_SLOT).getEquipmentType();
356 head = override.equals(EquipmentType.MASK) || override.equals(EquipmentType.HAT);
357 beard = override.equals(EquipmentType.FACE) || override.equals(EquipmentType.HAT);
358 }
359
360 if (head) {
361 tempBuf.writeShort(0x100 + other.appearance.getHead());
362 } else {
363 tempBuf.writeByte(0);
364 }
365
366 if (overrides.hasOverride(Equipment.HANDS_SLOT)) {
367 tempBuf.writeShort(0x200 + overrides.get(Equipment.HANDS_SLOT).getId());
368 } else if (other.equipment.get(Equipment.HANDS_SLOT) != null) {
369 tempBuf.writeShort(0x200 + other.equipment.get(Equipment.HANDS_SLOT).getId());
370 } else {
371 tempBuf.writeShort(0x100 + other.appearance.getHands());
372 }
373
374 if (overrides.hasOverride(Equipment.FEET_SLOT)) {
375 tempBuf.writeShort(0x200 + overrides.get(Equipment.FEET_SLOT).getId());
376 } else if (other.equipment.get(Equipment.FEET_SLOT) != null) {
377 tempBuf.writeShort(0x200 + other.equipment.get(Equipment.FEET_SLOT).getId());
378 } else {
379 tempBuf.writeShort(0x100 + other.appearance.getFeet());
380 }
381
382 if (other.appearance.getGender().equals(Gender.MALE)) {
383 if (beard) {
384 tempBuf.writeShort(0x100 + other.appearance.getBeard());
385 } else {
386 tempBuf.writeByte(0);
387 }
388 } else {
389 tempBuf.writeByte(0);
390 }
391 }
392
393 tempBuf
394 .writeByte(other.appearance.getHairColor())
395 .writeByte(other.appearance.getTorsoColor())
396 .writeByte(other.appearance.getLegsColor())
397 .writeByte(other.appearance.getFeetColor())
398 .writeByte(other.appearance.getSkinColor())
399 .writeShort(other.mobAnimation.getStand())
400 .writeShort(other.mobAnimation.getTurn())
401 .writeShort(other.mobAnimation.getWalk())
402 .writeShort(other.mobAnimation.getTurn180())
403 .writeShort(other.mobAnimation.getTurn90CW())
404 .writeShort(other.mobAnimation.getTurn90CCW())
405 .writeShort(other.mobAnimation.getRun())
406 .writeLong(Utility.hash(other.getName()))
407 .writeString(other.playerTitle.getTitle())
408 .writeInt(other.playerTitle.getColor())
409 .writeString(other.clanChannel == null ? "" : other.clanChannel.getOwner())
410 .writeString(other.clanTag)
411 .writeString(other.clanTagColor)
412 .writeLong(Double.doubleToLongBits(other.skills.getCombatLevel()))
413 .writeByte(other.right.getCrown())
414 .writeShort(0);
415 blockBuf.writeByte(tempBuf.content().writerIndex(), ByteModification.NEG);
416 blockBuf.writeBytes(tempBuf.content());
417 } finally {
418 tempBuf.release();
419 }
420 }

References com.runehive.net.packet.PacketBuilder.alloc(), com.runehive.game.world.items.containers.equipment.Equipment.AMULET_SLOT, com.runehive.game.world.entity.mob.player.Player.appearance, com.runehive.game.world.items.containers.equipment.EquipmentType.BODY, com.runehive.game.world.items.containers.equipment.Equipment.CAPE_SLOT, com.runehive.game.world.items.containers.equipment.Equipment.CHEST_SLOT, com.runehive.game.world.entity.mob.player.Player.clanChannel, com.runehive.game.world.entity.mob.player.Player.clanTag, com.runehive.game.world.entity.mob.player.Player.clanTagColor, com.runehive.game.world.entity.mob.player.Player.equipment, com.runehive.game.world.items.containers.equipment.EquipmentType.FACE, com.runehive.game.world.items.containers.equipment.Equipment.FEET_SLOT, com.runehive.game.world.items.containers.ItemContainer.get(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getArms(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getBeard(), com.runehive.content.combat.SkullHeadIconType.getCode(), com.runehive.content.tittle.PlayerTitle.getColor(), com.runehive.game.world.entity.skill.SkillManager.getCombatLevel(), com.runehive.game.world.entity.mob.player.PlayerRight.getCrown(), com.runehive.game.world.items.Item.getEquipmentType(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getFeet(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getFeetColor(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getGender(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getHairColor(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getHands(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getHead(), com.runehive.content.combat.Skulling.getHeadIconType(), com.runehive.game.world.items.Item.getId(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getLegs(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getLegsColor(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.content.clanchannel.channel.ClanChannel.getOwner(), com.runehive.game.world.entity.mob.MobAnimation.getRun(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getSkinColor(), com.runehive.game.world.entity.mob.MobAnimation.getStand(), com.runehive.content.tittle.PlayerTitle.getTitle(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getTorso(), com.runehive.game.world.entity.mob.player.appearance.Appearance.getTorsoColor(), com.runehive.game.world.entity.mob.MobAnimation.getTurn(), com.runehive.game.world.entity.mob.MobAnimation.getTurn180(), com.runehive.game.world.entity.mob.MobAnimation.getTurn90CCW(), com.runehive.game.world.entity.mob.MobAnimation.getTurn90CW(), com.runehive.game.world.entity.mob.MobAnimation.getWalk(), com.runehive.game.world.items.containers.equipment.Equipment.HANDS_SLOT, com.runehive.util.Utility.hash(), com.runehive.game.world.items.containers.equipment.EquipmentType.HAT, com.runehive.game.world.items.containers.equipment.Equipment.HEAD_SLOT, com.runehive.game.world.entity.mob.player.Player.headIcon, com.runehive.game.world.items.containers.equipment.Equipment.HELM_SLOT, com.runehive.game.world.entity.mob.Mob.id, com.runehive.game.world.items.containers.equipment.Equipment.LEGS_SLOT, com.runehive.game.world.entity.mob.player.appearance.Gender.MALE, com.runehive.game.world.items.containers.equipment.EquipmentType.MASK, com.runehive.game.world.entity.mob.Mob.mobAnimation, com.runehive.net.codec.ByteModification.NEG, com.runehive.game.world.entity.mob.player.Player.overrides, com.runehive.game.world.entity.mob.player.Player.playerTitle, com.runehive.game.world.entity.mob.player.Player.right, com.runehive.game.world.items.containers.equipment.Equipment.SHIELD_SLOT, com.runehive.game.world.entity.mob.Mob.skills, com.runehive.game.world.entity.mob.player.Player.skulling, com.runehive.net.packet.OutgoingPacket.type, com.runehive.game.world.entity.mob.player.Player.valueIcon, com.runehive.game.world.items.containers.equipment.Equipment.WEAPON_SLOT, com.runehive.net.packet.PacketBuilder.writeByte(), com.runehive.net.packet.PacketBuilder.writeBytes(), com.runehive.net.packet.PacketBuilder.writeInt(), com.runehive.net.packet.PacketBuilder.writeLong(), com.runehive.net.packet.PacketBuilder.writeShort(), and com.runehive.net.packet.PacketBuilder.writeString().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendChatMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendChatMask ( PacketBuilder blockBuf,
Player other )
staticprivate

Definition at line 253 of file SendPlayerUpdate.java.

253 {
254 final ChatMessage message = other.getChatMessage().orElse(ChatMessage.create("Cabbage"));
255
256 final byte[] encoded = message.getEncoded();
257 blockBuf.writeShort(((message.getColor().getCode() & 0xFF) << 8) | (message.getEffect().getCode() & 0xFF), ByteOrder.LE)
258 .writeByte(other.right.getCrown())
259 .writeByte(encoded.length, ByteModification.NEG)
260 .writeBytesReverse(encoded);
261 }

References com.runehive.game.world.entity.mob.player.relations.ChatMessage.create(), com.runehive.game.world.entity.mob.player.Player.getChatMessage(), com.runehive.game.world.entity.mob.player.relations.ChatColor.getCode(), com.runehive.game.world.entity.mob.player.relations.ChatEffect.getCode(), com.runehive.game.world.entity.mob.player.relations.ChatMessage.getColor(), com.runehive.game.world.entity.mob.player.PlayerRight.getCrown(), com.runehive.game.world.entity.mob.player.relations.ChatMessage.getEffect(), com.runehive.game.world.entity.mob.player.relations.ChatMessage.getEncoded(), com.runehive.net.codec.ByteOrder.LE, com.runehive.net.codec.ByteModification.NEG, com.runehive.game.world.entity.mob.player.Player.right, com.runehive.net.packet.PacketBuilder.writeByte(), com.runehive.net.packet.PacketBuilder.writeBytesReverse(), and com.runehive.net.packet.PacketBuilder.writeShort().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendFaceCoordinteMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendFaceCoordinteMask ( Player other,
PacketBuilder blockBuf )
staticprivate

Definition at line 227 of file SendPlayerUpdate.java.

227 {
228 Position loc = other.facePosition;
229
230 if (loc == null) {
231 Position currentPos = other.getPosition();
232 Direction currentDir = other.movement.lastDirection;
233 blockBuf.writeShort(((currentPos.getX() + currentDir.getDirectionX()) << 1), ByteModification.ADD, ByteOrder.LE)
234 .writeShort(((currentPos.getY() + currentDir.getDirectionY()) << 1) + 1, ByteOrder.LE);
235 } else {
236 blockBuf.writeShort((loc.getX() << 1) + 1, ByteModification.ADD, ByteOrder.LE)
237 .writeShort((loc.getY() << 1) + 1, ByteOrder.LE);
238 }
239 }

References com.runehive.net.codec.ByteModification.ADD, com.runehive.game.world.entity.mob.Mob.facePosition, com.runehive.game.world.entity.mob.Direction.getDirectionX(), com.runehive.game.world.entity.mob.Direction.getDirectionY(), com.runehive.game.world.entity.Entity.getPosition(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.position.Position.getY(), com.runehive.game.world.entity.mob.movement.Movement.lastDirection, com.runehive.net.codec.ByteOrder.LE, com.runehive.game.world.entity.mob.Mob.movement, and com.runehive.net.packet.PacketBuilder.writeShort().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendFaceEntityMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendFaceEntityMask ( Player other,
PacketBuilder blockBuf )
staticprivate

Definition at line 214 of file SendPlayerUpdate.java.

214 {
215 Mob mob = other.interactingWith;
216 if (mob != null) {
217 int index = mob.getIndex();
218 if (mob.isPlayer()) {
219 index += -32768;
220 }
221 blockBuf.writeShort(index, ByteOrder.LE);
222 } else {
223 blockBuf.writeShort(65535, ByteOrder.LE);
224 }
225 }
val index

References com.runehive.game.world.entity.Entity.getIndex(), com.runehive.game.world.entity.mob.Mob.interactingWith, com.runehive.game.world.entity.mob.Mob.isPlayer(), com.runehive.net.codec.ByteOrder.LE, and com.runehive.net.packet.PacketBuilder.writeShort().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendForceChatMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendForceChatMask ( Player other,
PacketBuilder blockBuf )
staticprivate

Definition at line 210 of file SendPlayerUpdate.java.

210 {
211 blockBuf.writeString(other.forceChat);
212 }

References com.runehive.game.world.entity.mob.Mob.forceChat, and com.runehive.net.packet.PacketBuilder.writeString().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendForceMovementMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendForceMovementMask ( Player player,
Player other,
PacketBuilder blockBuf )
staticprivate

Definition at line 189 of file SendPlayerUpdate.java.

189 {
190 final ForceMovement fm = other.getForceMovement();
191
192 final Position lastPosition = player.lastPosition;
193 final Position otherPosition = other.getPosition();
194 final int startX = otherPosition.getLocalX(lastPosition);
195 final int startY = otherPosition.getLocalY(lastPosition);
196
197 final Position end = fm.getEnd();
198 final int endX = end.getX();
199 final int endY = end.getY();
200
201 blockBuf.writeByte(startX, ByteModification.SUB)
202 .writeByte(startY, ByteModification.SUB)
203 .writeByte(startX + endX, ByteModification.SUB)
204 .writeByte(startY + endY, ByteModification.SUB)
205 .writeShort(fm.getSpeed(), ByteModification.ADD, ByteOrder.LE)
206 .writeShort(fm.getReverseSpeed(), ByteModification.ADD)
207 .writeByte(fm.getDirection(), ByteModification.SUB);
208 }

References com.runehive.net.codec.ByteModification.ADD, com.runehive.game.world.entity.mob.player.ForceMovement.getDirection(), com.runehive.game.world.entity.mob.player.ForceMovement.getEnd(), com.runehive.game.world.entity.mob.Mob.getForceMovement(), com.runehive.game.world.position.Position.getLocalX(), com.runehive.game.world.position.Position.getLocalY(), com.runehive.game.world.entity.Entity.getPosition(), com.runehive.game.world.entity.mob.player.ForceMovement.getReverseSpeed(), com.runehive.game.world.entity.mob.player.ForceMovement.getSpeed(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.position.Position.getY(), com.runehive.game.world.entity.mob.Mob.lastPosition, com.runehive.net.codec.ByteOrder.LE, com.runehive.net.codec.ByteModification.SUB, com.runehive.net.packet.PacketBuilder.writeByte(), and com.runehive.net.packet.PacketBuilder.writeShort().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendGraphicMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendGraphicMask ( Player other,
PacketBuilder blockBuf )
staticprivate

Definition at line 247 of file SendPlayerUpdate.java.

247 {
248 Graphic graphic = other.getGraphic().orElse(Graphic.RESET);
249 blockBuf.writeShort(graphic.getId(), ByteOrder.LE)
250 .writeInt(graphic.getDelay() | graphic.getHeight());
251 }

References com.runehive.game.Graphic.getDelay(), com.runehive.game.world.entity.mob.Mob.getGraphic(), com.runehive.game.Graphic.getHeight(), com.runehive.game.Graphic.getId(), com.runehive.net.codec.ByteOrder.LE, com.runehive.game.Graphic.RESET, com.runehive.net.packet.PacketBuilder.writeInt(), and com.runehive.net.packet.PacketBuilder.writeShort().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendHitMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendHitMask ( final Player player,
final PacketBuilder blockBuf )
staticprivate

Definition at line 422 of file SendPlayerUpdate.java.

422 {
423 Hit hit = player.firstHit;
424
425 boolean multipleHits = hit.getMultipleHits() != null;
426 blockBuf.writeByte(multipleHits ? 1 : 0);
427
428
429 int max = player.getMaximumHealth() >= 500 ? 200 : 100;
430 int health = player.getCurrentHealth() * max / player.getMaximumHealth();
431 if (health > max) health = max;
432
433 if(multipleHits) {
434 blockBuf.writeByte(hit.getMultipleHits().length);
435
436 for(int index = 0; index < hit.getMultipleHits().length; index++) {
437 Hit currentHit = hit.getMultipleHits()[index];
438
439 int id = currentHit.getHitsplat().getId();
440
441 if (currentHit.getHitsplat() == Hitsplat.NORMAL && currentHit.getDamage() > 0) {
442 id++;
443 }
444
445 blockBuf.writeByte(currentHit.getDamage());
446 blockBuf.writeByte(id, ByteModification.ADD);
447 blockBuf.writeByte(currentHit.getHitIcon().getId());
448 }
449
450 } else {
451
452 int id = hit.getHitsplat().getId();
453
454 if (hit.getHitsplat() == Hitsplat.NORMAL && hit.getDamage() > 0) {
455 id++;
456 }
457
458 blockBuf.writeByte(hit.getDamage());
459 blockBuf.writeByte(id, ByteModification.ADD);
460 blockBuf.writeByte(hit.getHitIcon().getId());
461 }
462
463 blockBuf.writeByte(health);
464 blockBuf.writeByte(max, ByteModification.NEG);
465 }

References com.runehive.net.codec.ByteModification.ADD, com.runehive.game.world.entity.mob.Mob.firstHit, com.runehive.game.world.entity.mob.Mob.getCurrentHealth(), com.runehive.game.world.entity.combat.hit.Hit.getDamage(), com.runehive.game.world.entity.combat.hit.Hit.getHitIcon(), com.runehive.game.world.entity.combat.hit.Hit.getHitsplat(), com.runehive.game.world.entity.combat.hit.HitIcon.getId(), com.runehive.game.world.entity.combat.hit.Hitsplat.getId(), com.runehive.game.world.entity.mob.Mob.getMaximumHealth(), com.runehive.game.world.entity.combat.hit.Hit.getMultipleHits(), com.runehive.net.codec.ByteModification.NEG, com.runehive.game.world.entity.combat.hit.Hitsplat.NORMAL, and com.runehive.net.packet.PacketBuilder.writeByte().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendSecondHitMask()

void com.runehive.net.packet.out.SendPlayerUpdate.appendSecondHitMask ( final Player player,
final PacketBuilder blockBuf )
staticprivate

Definition at line 467 of file SendPlayerUpdate.java.

467 {
468 Hit hit = player.secondHit;
469
470 boolean multipleHits = hit.getMultipleHits() != null;
471 blockBuf.writeByte(multipleHits ? 1 : 0);
472
473 int max = player.getMaximumHealth() >= 500 ? 200 : 100;
474 int health = player.getCurrentHealth() * max / player.getMaximumHealth();
475 if (health > max) health = max;
476
477 if(multipleHits) {
478 blockBuf.writeByte(hit.getMultipleHits().length);
479
480 for(int index = 0; index < hit.getMultipleHits().length; index++) {
481 Hit currentHit = hit.getMultipleHits()[index];
482
483 int id = currentHit.getHitsplat().getId();
484
485 if (currentHit.getHitsplat() == Hitsplat.NORMAL && currentHit.getDamage() > 0) {
486 id++;
487 }
488
489 blockBuf.writeByte(currentHit.getDamage());
490 blockBuf.writeByte(id, ByteModification.ADD);
491 blockBuf.writeByte(currentHit.getHitIcon().getId());
492 }
493 } else {
494 int id = hit.getHitsplat().getId();
495
496 if (hit.getHitsplat() == Hitsplat.NORMAL && hit.getDamage() > 0) {
497 id++;
498 }
499
500 blockBuf.writeByte(hit.getDamage());
501 blockBuf.writeByte(id, ByteModification.SUB);
502 blockBuf.writeByte(hit.getHitIcon().getId());
503 }
504
505 blockBuf.writeByte(health);
506 blockBuf.writeByte(max, ByteModification.NEG);
507 }

References com.runehive.net.codec.ByteModification.ADD, com.runehive.game.world.entity.mob.Mob.getCurrentHealth(), com.runehive.game.world.entity.combat.hit.Hit.getDamage(), com.runehive.game.world.entity.combat.hit.Hit.getHitIcon(), com.runehive.game.world.entity.combat.hit.Hit.getHitsplat(), com.runehive.game.world.entity.combat.hit.HitIcon.getId(), com.runehive.game.world.entity.combat.hit.Hitsplat.getId(), com.runehive.game.world.entity.mob.Mob.getMaximumHealth(), com.runehive.game.world.entity.combat.hit.Hit.getMultipleHits(), com.runehive.net.codec.ByteModification.NEG, com.runehive.game.world.entity.combat.hit.Hitsplat.NORMAL, com.runehive.game.world.entity.mob.Mob.secondHit, com.runehive.net.codec.ByteModification.SUB, and com.runehive.net.packet.PacketBuilder.writeByte().

Referenced by updatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ encode()

boolean com.runehive.net.packet.out.SendPlayerUpdate.encode ( Player player)

Reimplemented from com.runehive.net.packet.OutgoingPacket.

Definition at line 43 of file SendPlayerUpdate.java.

43 {
44 if (player.regionChange) {
45 player.send(new SendMapRegion());
46 }
47
48 final PacketBuilder blockBuf = PacketBuilder.alloc();
49 try {
50 builder.initializeAccess(AccessType.BIT);
51
52 updateMovement(player, builder);
53
54 if (player.isUpdateRequired()) {
55 updatePlayer(blockBuf, player, player, UpdateState.UPDATE_SELF);
56 }
57
58 final Collection<Player> localPlayers = World.getRegions().getLocalPlayers(player);
59
60 builder.writeBits(8, player.viewport.getPlayersInViewport().size());
61
62 for (Iterator<Player> itr = player.viewport.getPlayersInViewport().iterator(); itr.hasNext();) {
63 Player other = itr.next();
64
65 if (player.viewport.shouldRemove(other)) {
66 builder.writeBit(true);
67 builder.writeBits(2, 3);
68 itr.remove();
69 } else {
70 updateMovement(other, builder);
71
72 if (other.isUpdateRequired()) {
73 updatePlayer(blockBuf, player, other, UpdateState.UPDATE_LOCAL);
74 }
75 }
76
77 }
78
79 int added = 0;
80
81 for (Player localPlayer : localPlayers) {
82
83 if (player.viewport.getPlayersInViewport().size() >= Viewport.CAPACITY || added >= Viewport.ADD_THRESHOLD) {
84 break;
85 }
86
87 if (player.viewport.add(localPlayer)) {
88 added++;
89 addNewPlayer(builder, player, localPlayer);
90 updatePlayer(blockBuf, player, localPlayer, UpdateState.ADD_LOCAL);
91 }
92
93 }
94
95 if (blockBuf.content().readableBytes() > 0) {
96 builder.writeBits(11, 2047);
97 builder.initializeAccess(AccessType.BYTE);
98 builder.writeBuffer(blockBuf.content());
99 } else {
100 builder.initializeAccess(AccessType.BYTE);
101 }
102 } catch (Exception ex) {
103 logger.error(String.format("error updating player=%s", player), ex);
104 } finally {
105 blockBuf.release();
106 }
107 return true;
108 }

References com.runehive.game.world.entity.mob.Viewport.add(), com.runehive.net.packet.out.SendPlayerUpdate.UpdateState.ADD_LOCAL, com.runehive.game.world.entity.mob.Viewport.ADD_THRESHOLD, addNewPlayer(), com.runehive.net.packet.PacketBuilder.alloc(), com.runehive.net.codec.AccessType.BIT, com.runehive.net.packet.OutgoingPacket.builder, com.runehive.net.codec.AccessType.BYTE, com.runehive.game.world.entity.mob.Viewport.CAPACITY, com.runehive.game.world.region.RegionManager.getLocalPlayers(), com.runehive.game.world.entity.mob.Viewport.getPlayersInViewport(), com.runehive.game.world.World.getRegions(), com.runehive.game.world.entity.mob.Mob.isUpdateRequired(), logger, com.runehive.game.world.entity.mob.Mob.regionChange, com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.mob.Viewport.shouldRemove(), com.runehive.net.packet.out.SendPlayerUpdate.UpdateState.UPDATE_LOCAL, com.runehive.net.packet.out.SendPlayerUpdate.UpdateState.UPDATE_SELF, updateMovement(), updatePlayer(), and com.runehive.game.world.entity.mob.player.Player.viewport.

Here is the call graph for this function:

◆ updateMovement()

void com.runehive.net.packet.out.SendPlayerUpdate.updateMovement ( Player player,
PacketBuilder packetBuf )
staticprivate

Definition at line 509 of file SendPlayerUpdate.java.

509 {
510 final boolean teleported = player.positionChange || player.teleportRegion;
511 final boolean updateRequired = player.isUpdateRequired();
512 if (teleported) {
513 packetBuf.writeBit(true)
514 .writeBits(2, 3)
515 .writeBits(2, player.getHeight())
516 .writeBits(1, player.regionChange ? 0 : 1)
517 .writeBit(updateRequired)
518 .writeBits(7, player.getPosition().getLocalY(player.lastPosition))
519 .writeBits(7, player.getPosition().getLocalX(player.lastPosition));
520 } else if (player.movement.getRunningDirection() != -1) {
521 packetBuf.writeBit(true)
522 .writeBits(2, 2)
523 .writeBits(3, player.movement.getWalkingDirection())
524 .writeBits(3, player.movement.getRunningDirection())
525 .writeBit(player.isUpdateRequired());
526 } else if (player.movement.getWalkingDirection() != -1) {
527 packetBuf.writeBit(true)
528 .writeBits(2, 1)
529 .writeBits(3, player.movement.getWalkingDirection())
530 .writeBit(player.isUpdateRequired());
531 } else {
532 if (updateRequired) {
533 packetBuf.writeBit(true)
534 .writeBits(2, 0);
535 } else {
536 packetBuf.writeBit(false);
537 }
538 }
539 }

References com.runehive.game.world.entity.Entity.getHeight(), com.runehive.game.world.position.Position.getLocalX(), com.runehive.game.world.position.Position.getLocalY(), com.runehive.game.world.entity.Entity.getPosition(), com.runehive.game.world.entity.mob.movement.Movement.getRunningDirection(), com.runehive.game.world.entity.mob.movement.Movement.getWalkingDirection(), com.runehive.game.world.entity.mob.Mob.isUpdateRequired(), com.runehive.game.world.entity.mob.Mob.lastPosition, com.runehive.game.world.entity.mob.Mob.movement, com.runehive.game.world.entity.mob.Mob.regionChange, com.runehive.game.world.entity.mob.Mob.teleportRegion, com.runehive.net.packet.PacketBuilder.writeBit(), and com.runehive.net.packet.PacketBuilder.writeBits().

Referenced by encode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updatePlayer()

void com.runehive.net.packet.out.SendPlayerUpdate.updatePlayer ( PacketBuilder blockBuf,
Player player,
Player other,
UpdateState state )
staticprivate

Definition at line 118 of file SendPlayerUpdate.java.

118 {
119 if (!other.isUpdateRequired()) {
120 return;
121 }
122
123 int mask = 0;
124
125 final EnumSet<UpdateFlag> updateFlags = other.updateFlags;
126 for (UpdateFlag flag : UpdateFlag.playerOrder) {
127 if (updateFlags.contains(flag) && flag.canApply(player, other, state)) {
128 mask |= flag.playerMask;
129 }
130 }
131
132 if (mask >= 0x100) {
133 mask |= 0x40;
134 blockBuf.writeByte(mask & 0xFF);
135 blockBuf.writeByte(mask >> 8);
136 } else {
137 blockBuf.writeByte(mask);
138 }
139
140 // TODO replace the checks.
141 /* for (UpdateFlag flag : UpdateFlag.playerOrder) {
142 if (UpdateFlag.containsPlayer(mask, flag)) {
143
144 }
145 }*/
146
147 if (UpdateFlag.containsPlayer(mask, UpdateFlag.FORCE_MOVEMENT)) {
148 appendForceMovementMask(player, other, blockBuf);
149 }
150
151 if (UpdateFlag.containsPlayer(mask, UpdateFlag.GRAPHICS)) {
152 appendGraphicMask(other, blockBuf);
153 }
154
155 if (UpdateFlag.containsPlayer(mask, UpdateFlag.ANIMATION)) {
156 appendAnimationMask(other, blockBuf);
157 }
158
159 if (UpdateFlag.containsPlayer(mask, UpdateFlag.FORCED_CHAT)) {
160 appendForceChatMask(other, blockBuf);
161 }
162
163 if (UpdateFlag.containsPlayer(mask, UpdateFlag.CHAT)) {
164 appendChatMask(blockBuf, other);
165 }
166
167 if (UpdateFlag.containsPlayer(mask, UpdateFlag.INTERACT)) {
168 appendFaceEntityMask(other, blockBuf);
169 }
170
171 if (UpdateFlag.containsPlayer(mask, UpdateFlag.APPEARANCE)) {
172 appendAppearanceMask(other, blockBuf);
173 }
174
175 if (UpdateFlag.containsPlayer(mask, UpdateFlag.FACE_COORDINATE)) {
176 appendFaceCoordinteMask(other, blockBuf);
177 }
178
179 if (UpdateFlag.containsPlayer(mask, UpdateFlag.FIRST_HIT)) {
180 appendHitMask(other, blockBuf);
181 }
182
183 if (UpdateFlag.containsPlayer(mask, UpdateFlag.SECOND_HIT)) {
184 appendSecondHitMask(other, blockBuf);
185 }
186
187 }

References com.runehive.game.world.entity.mob.UpdateFlag.ANIMATION, com.runehive.game.world.entity.mob.UpdateFlag.APPEARANCE, appendAnimationMask(), appendAppearanceMask(), appendChatMask(), appendFaceCoordinteMask(), appendFaceEntityMask(), appendForceChatMask(), appendForceMovementMask(), appendGraphicMask(), appendHitMask(), appendSecondHitMask(), com.runehive.game.world.entity.mob.UpdateFlag.canApply(), com.runehive.game.world.entity.mob.UpdateFlag.CHAT, com.runehive.game.world.entity.mob.UpdateFlag.containsPlayer(), com.runehive.game.world.entity.mob.UpdateFlag.FACE_COORDINATE, com.runehive.game.world.entity.mob.UpdateFlag.FIRST_HIT, com.runehive.game.world.entity.mob.UpdateFlag.FORCE_MOVEMENT, com.runehive.game.world.entity.mob.UpdateFlag.FORCED_CHAT, com.runehive.game.world.entity.mob.UpdateFlag.GRAPHICS, com.runehive.game.world.entity.mob.UpdateFlag.INTERACT, com.runehive.game.world.entity.mob.Mob.isUpdateRequired(), com.runehive.game.world.entity.mob.UpdateFlag.playerMask, com.runehive.game.world.entity.mob.UpdateFlag.playerOrder, com.runehive.game.world.entity.mob.UpdateFlag.SECOND_HIT, com.runehive.game.world.entity.mob.Mob.updateFlags, and com.runehive.net.packet.PacketBuilder.writeByte().

Referenced by encode().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ logger

final Logger com.runehive.net.packet.out.SendPlayerUpdate.logger = LogManager.getLogger(SendPlayerUpdate.class)
staticprivate

Definition at line 36 of file SendPlayerUpdate.java.

Referenced by encode().


The documentation for this class was generated from the following file: