diff --git a/scripts/test.sh b/scripts/test.sh index 6381c0d0..8b85b36b 100644 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1 +1,2 @@ - curl localhost:5600 --data-binary "@./7359804449_987225713.dem" \ No newline at end of file +#curl localhost:5600 --data-binary "@/datadrive/odota-parser/7355186741_1742953546.dem" +curl localhost:5600 --data-binary "@/datadrive/odota-parser/7437280975_580771917.dem" \ No newline at end of file diff --git a/src/main/java/opendota/Parse.java b/src/main/java/opendota/Parse.java index cb9b81ee..b52d0e6b 100644 --- a/src/main/java/opendota/Parse.java +++ b/src/main/java/opendota/Parse.java @@ -207,7 +207,7 @@ public Parse(InputStream input, OutputStream output) throws IOException public void output(Entry e) { try { - if (gameStartTime == 0) { + if (gameStartTime == 0 && logBuffer != null) { logBuffer.add(e); } else { e.time -= gameStartTime; @@ -221,6 +221,9 @@ public void output(Entry e) { } public void flushLogBuffer() { + if (logBuffer == null) { + return; + } for (Entry e : logBuffer) { output(e); } @@ -441,8 +444,7 @@ else if (cle.getType() == DOTA_COMBATLOG_TYPES.DOTA_COMBATLOG_XP) { postGame = true; } if (combatLogEntry.type.equals("DOTA_COMBATLOG_GAME_STATE") && combatLogEntry.value == 5) { - //alternate to combat log for getting game zero time (looks like this is set at the same time as the game start, so it's not any better for streaming) - // int currGameStartTime = Math.round( (float) grp.getProperty("m_pGameRules.m_flGameStartTime")); + // See alternative gameStartTime from grp if (gameStartTime == 0) { gameStartTime = combatLogEntry.time; flushLogBuffer(); @@ -528,7 +530,13 @@ public void onTickStart(Context ctx, boolean synthetic) { } else { time = Math.round(oldTime); } - //draft timings + // alternate to combat log for getting game zero time (looks like this is set at the same time as the game start, so it's not any better for streaming) + // Some replays don't have the combat log event for some reason so also do this here + int currGameStartTime = Math.round( (float) grp.getProperty("m_pGameRules.m_flGameStartTime")); + if (gameStartTime == 0 && currGameStartTime != 0) { + gameStartTime = currGameStartTime; + flushLogBuffer(); + } if(draftStage == 2) { //determine the time the draftings start