SteamWar/BauSystem2.0
Archiviert
12
0

trace/trace-del-and-trace-share-fix #239

Zusammengeführt
YoyoNow hat 3 Commits von trace/trace-del-and-trace-share-fix nach master 2024-04-22 22:57:11 +02:00 zusammengeführt
3 geänderte Dateien mit 3 neuen und 15 gelöschten Zeilen
Nur Änderungen aus Commit e8eeeb729a werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -132,11 +132,6 @@ public class TraceManager implements Listener {
* @param trace the trace to be removed * @param trace the trace to be removed
*/ */
public boolean remove(Trace trace) { public boolean remove(Trace trace) {
Optional<Trace> activeTrace = TraceRecorder.instance.getActiveTraceForRegion(trace.getRegion());
if (activeTrace.isPresent() && activeTrace.get() == trace) {
TraceRecorder.instance.stopRecording(trace.getRegion());
}
Map<Integer, Trace> traces = tracesByRegion.getOrDefault(trace.getRegion(), Collections.emptyMap()); Map<Integer, Trace> traces = tracesByRegion.getOrDefault(trace.getRegion(), Collections.emptyMap());
Integer traceId = traces.entrySet().stream() Integer traceId = traces.entrySet().stream()
.filter(entry -> entry.getValue() == trace) .filter(entry -> entry.getValue() == trace)
@ -153,7 +148,6 @@ public class TraceManager implements Listener {
* Clears all traces * Clears all traces
*/ */
public void clear(Region region) { public void clear(Region region) {
TraceRecorder.instance.stopRecording(region);
showDataPerRegionPerPlayer.getOrDefault(region, new HashMap<>()) showDataPerRegionPerPlayer.getOrDefault(region, new HashMap<>())
.keySet() .keySet()
.forEach(player -> { .forEach(player -> {

Datei anzeigen

@ -104,14 +104,11 @@ public class TraceRecorder implements Listener {
* *
* @param region region to be recorded * @param region region to be recorded
*/ */
public int startRecording(Region region) { public void startRecording(Region region) {
if (activeTraces.containsKey(region)) { if (activeTraces.containsKey(region)) return;
return -1;
}
TraceRecordingWrapper wrappedTrace = new TraceRecordingWrapper(region); TraceRecordingWrapper wrappedTrace = new TraceRecordingWrapper(region);
activeTraces.put(region, wrappedTrace); activeTraces.put(region, wrappedTrace);
return TraceManager.instance.add(wrappedTrace.getTrace());
} }
/** /**

Datei anzeigen

@ -89,9 +89,6 @@ public class TraceRecordingWrapper {
protected void finalizeRecording() { protected void finalizeRecording() {
recordsOutputStream.flush(); recordsOutputStream.flush();
recordsOutputStream.close(); recordsOutputStream.close();
TraceManager.instance.add(trace);
if (trace.getRecords().isEmpty()) {
TraceManager.instance.remove(trace);
}
} }
} }