Skip to content

Commit fdbf7a1

Browse files
author
Builder
committed
Merge branch 'fix-warning-spam' into 'master'
#[FIX][SDK] don't spam the user with warnings See merge request codingame/game-engine!131
2 parents b7d664d + 5ef030e commit fdbf7a1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

engine/core/src/main/java/com/codingame/gameengine/core/GameManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ abstract public class GameManager<T extends AbstractPlayer> {
6868
private int totalViewDataBytesSent = 0;
6969
private int totalGameSummaryBytes = 0;
7070

71+
private boolean viewWarning, summaryWarning;
72+
7173
/**
7274
* GameManager main loop.
7375
*
@@ -241,8 +243,9 @@ private void dumpView() {
241243
totalViewDataBytesSent += viewData.length();
242244
if (totalViewDataBytesSent > VIEW_DATA_TOTAL_HARD_QUOTA) {
243245
throw new RuntimeException("The amount of data sent to the viewer is too big!");
244-
} else if (totalViewDataBytesSent > VIEW_DATA_TOTAL_SOFT_QUOTA) {
246+
} else if (totalViewDataBytesSent > VIEW_DATA_TOTAL_SOFT_QUOTA && !viewWarning) {
245247
log.warn("Warning: the amount of data sent to the viewer is too big.\nPlease try to optimize your code to send less data (try replacing some commitEntityStates by a commitWorldState).");
248+
viewWarning = true;
246249
}
247250

248251
log.info(viewData);
@@ -479,8 +482,9 @@ public void addToGameSummary(String summary) {
479482
if (total < GAME_SUMMARY_PER_TURN_HARD_QUOTA && total + totalGameSummaryBytes < GAME_SUMMARY_TOTAL_HARD_QUOTA) {
480483
this.currentGameSummary.add(summary);
481484
totalGameSummaryBytes += total;
482-
} else {
485+
} else if (!summaryWarning) {
483486
log.warn("Warning: the game summary is full. Please try to send less data.");
487+
summaryWarning = true;
484488
}
485489
}
486490

0 commit comments

Comments
 (0)