Skip to content

Commit

Permalink
Merge pull request #57 from builder-247/fix-ids
Browse files Browse the repository at this point in the history
Fix assigning playerslot
  • Loading branch information
howardchung authored Apr 7, 2022
2 parents 904d0f2 + 9f2df8f commit 4e1299d
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/main/java/opendota/Parse.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public UnknownAbilityFoundException(String message) {
int gameStartTime = 0;
boolean postGame = false; // true when ancient destroyed
private Gson g = new Gson();
HashMap<String, Integer> unit_to_slot = new HashMap<String, Integer>();
HashMap<String, Integer> name_to_slot = new HashMap<String, Integer>();
HashMap<String, Integer> abilities_tracking = new HashMap<String, Integer>();
List<Ability> abilities;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4e1299d

Please sign in to comment.