Skip to content

Commit

Permalink
flush the logs at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Jan 8, 2024
1 parent c9f00fd commit 5c3ac03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/main/java/opendota/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.rmi.server.Operation;
import java.util.LinkedHashMap;
import java.util.Map;

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/opendota/Parse.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public UnknownAbilityFoundException(String message) {
boolean init = false;
int gameStartTime = 0;
boolean postGame = false; // true when ancient destroyed
boolean epilogue = false;
private Gson g = new Gson();
HashMap<String, Integer> name_to_slot = new HashMap<String, Integer>();
HashMap<String, Integer> abilities_tracking = new HashMap<String, Integer>();
Expand Down Expand Up @@ -208,7 +209,7 @@ public Parse(InputStream input, OutputStream output) throws IOException {

public void output(Entry e) {
try {
if (gameStartTime == 0 && logBuffer != null) {
if (!epilogue && gameStartTime == 0 && logBuffer != null) {
logBuffer.add(e);
} else {
e.time -= gameStartTime;
Expand Down Expand Up @@ -398,6 +399,9 @@ public void onFileInfo(Context ctx, CDemoFileInfo message) {
epilogueEntry.type = "epilogue";
epilogueEntry.key = new Gson().toJson(message);
output(epilogueEntry);
epilogue = true;
// Some replays don't have a game start time and we never flush, so just do it now
flushLogBuffer();
}

@OnCombatLogEntry
Expand Down

0 comments on commit 5c3ac03

Please sign in to comment.