Skip to content

Commit

Permalink
round positions in processor, move key gen
Browse files Browse the repository at this point in the history
i moved the key generation out of the backend (looks like this was already partially happening in the processor JS anyway) and update the processor to round position values
  • Loading branch information
thot-experiment committed May 17, 2024
1 parent d3bbc1e commit dab5fee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 6 additions & 1 deletion processors/processExpand.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ function processExpand(entries, meta) {
* Place a copy of the entry in the output
* */
function expand(e) {
//if there are cooridnates, round to one decimal point
e.x?e.x=parseFloat(e.x.toFixed(1)):null
e.y?e.y=parseFloat(e.y.toFixed(1)):null
e.z?e.z=parseFloat(e.z.toFixed(1)):null
//generate "key" for entries with x/y and no key
if (!e.key && e.x && e.y) e.key = JSON.stringify([e.x,e.y])
// set slot and player_slot
const slot = 'slot' in e ? e.slot : meta.hero_to_slot[e.unit];
output.push({ ...e, slot, player_slot: meta.slot_to_playerslot[slot] });
Expand Down Expand Up @@ -588,7 +594,6 @@ function processExpand(entries, meta) {
time: e.time,
slot: e.slot,
type: 'lane_pos',
key: JSON.stringify([e.x, e.y]),
posData: true,
});
}
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/opendota/Parse.java
Original file line number Diff line number Diff line change
Expand Up @@ -975,20 +975,14 @@ private Entry buildWardEntry(Context ctx, Entity e) {
Float vy = getEntityProperty(e, "CBodyComponent.m_vecY", null);
Float vz = getEntityProperty(e, "CBodyComponent.m_vecZ", null);

Float x = getPreciseLocation(cx,vx);
Float y = getPreciseLocation(cy,vy);
Float z = getPreciseLocation(cz,vz);

Integer life_state = getEntityProperty(e, "m_lifeState", null);
Float[] pos = { x, y };

entry.x = x;
entry.y = y;
entry.z = z;
entry.x = getPreciseLocation(cx,vx);
entry.y = getPreciseLocation(cy,vy);
entry.z = getPreciseLocation(cz,vz);

entry.type = isObserver ? "obs" : "sen";
entry.entityleft = life_state == 1;
entry.key = Arrays.toString(pos);
entry.ehandle = e.getHandle();

if (entry.entityleft) {
Expand Down

0 comments on commit dab5fee

Please sign in to comment.