From 9f2df8f399e1c75d54fdd63a3a0f3ca10734bf6d Mon Sep 17 00:00:00 2001 From: builder_247 <14019974+builder-247@users.noreply.github.com> Date: Wed, 6 Apr 2022 16:19:02 +0300 Subject: [PATCH] fix assigning playerslot --- src/main/java/opendota/Parse.java | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/opendota/Parse.java b/src/main/java/opendota/Parse.java index 4ed41f4b..20e96176 100644 --- a/src/main/java/opendota/Parse.java +++ b/src/main/java/opendota/Parse.java @@ -163,7 +163,6 @@ public UnknownAbilityFoundException(String message) { int gameStartTime = 0; boolean postGame = false; // true when ancient destroyed private Gson g = new Gson(); - HashMap unit_to_slot = new HashMap(); HashMap name_to_slot = new HashMap(); HashMap abilities_tracking = new HashMap(); List abilities; @@ -255,18 +254,15 @@ public void onDotaMatch(Context ctx, CMsgDOTAMatch message) public Integer getPlayerSlotFromEntity(Context ctx, Entity e) { if (e == null) return null; - // Try pre 7.31 method - Integer slot = getEntityProperty(e, "m_iPlayerID", null); - if (slot != null) { - return slot; + Integer slot = getEntityProperty(e, "m_nPlayerID", null); + // Sentry wards still use pre 7.31 property for storing new ID + if (slot == null) { + slot = getEntityProperty(e, "m_iPlayerID", null); } - String heroName = null; - Entity heroEnt = ctx.getProcessor(Entities.class).getByHandle(e.getProperty("m_hAssignedHero")); - if (heroEnt != null) { - heroName = heroEnt.getDtClass().getDtName(); - return unit_to_slot.get(heroName); + if (slot != null) { + slot /= 2; } - return null; + return slot; } @OnMessage(CDOTAUserMsg_SpectatorPlayerUnitOrders.class) @@ -360,7 +356,7 @@ public void onAllChatS2(Context ctx, CUserMessageSayText2 message) { entry.unit = String.valueOf(message.getParam1()); entry.key = String.valueOf(message.getParam2()); Entity e = ctx.getProcessor(Entities.class).getByIndex(message.getEntityindex()); - entry.slot = getEntityProperty(e, "m_iPlayerID", null); + entry.slot = getPlayerSlotFromEntity(ctx, e); entry.type = "chat"; output(entry); } @@ -701,7 +697,6 @@ public void onTickStart(Context ctx, boolean synthetic) { //populate for combat log mapping name_to_slot.put(combatLogName, entry.slot); name_to_slot.put(combatLogName2, entry.slot); - unit_to_slot.put(unit, entry.slot); abilities = getHeroAbilities(ctx, e); for (Ability ability : abilities) {