1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

heavily improved validation and prevented autocompletion

This commit is contained in:
Sense101 2021-05-07 13:52:05 +01:00
parent 2c465f9b2c
commit 95d2417683
2 changed files with 25 additions and 8 deletions

View File

@ -49,23 +49,26 @@ export class HUDPuzzleEditorReview extends BaseHUDPart {
// Manually simulate ticks // Manually simulate ticks
this.root.logic.clearAllBeltsAndItems(); this.root.logic.clearAllBeltsAndItems();
const ticks = const maxTicks =
this.root.gameMode.getFixedTickrate() * globalConfig.puzzleValidationDurationSeconds; this.root.gameMode.getFixedTickrate() * globalConfig.puzzleValidationDurationSeconds;
const deltaMs = this.root.dynamicTickrate.deltaMs; const deltaMs = this.root.dynamicTickrate.deltaMs;
logger.log("Simulating", ticks, "ticks, start=", this.root.time.now().toFixed(1)); logger.log("Simulating up to", maxTicks, "ticks, start=", this.root.time.now().toFixed(1));
const now = performance.now(); const now = performance.now();
for (let i = 0; i < ticks; ++i) {
if (i % Math.round((ticks - 1) / 10) === 0) {
console.log("Ticking", Math.round((i / ticks) * 100) + "%");
}
// Perform logic ticks let simulatedTicks = 0;
for (let i = 0; i < maxTicks; ++i) {
// Perform logic tick
this.root.time.performTicks(deltaMs, this.root.gameState.core.boundInternalTick); this.root.time.performTicks(deltaMs, this.root.gameState.core.boundInternalTick);
simulatedTicks++;
if (!this.validatePuzzle()) {
break;
}
} }
const duration = performance.now() - now; const duration = performance.now() - now;
logger.log( logger.log(
"Simulated", "Simulated",
ticks, simulatedTicks,
"ticks, end=", "ticks, end=",
this.root.time.now().toFixed(1), this.root.time.now().toFixed(1),
"duration=", "duration=",
@ -73,7 +76,19 @@ export class HUDPuzzleEditorReview extends BaseHUDPart {
"ms" "ms"
); );
console.log("duration: " + duration);
closeLoading(); closeLoading();
//if it took so little ticks that it must have autocompeted
if (simulatedTicks < 300) {
this.root.hud.parts.dialogs.showWarning(
T.puzzleMenu.validation.title,
T.puzzleMenu.validation.autoComplete
);
return;
}
//if we reached maximum ticks and the puzzle still isn't completed
const validationError = this.validatePuzzle(); const validationError = this.validatePuzzle();
if (validationError) { if (validationError) {
this.root.hud.parts.dialogs.showWarning(T.puzzleMenu.validation.title, validationError); this.root.hud.parts.dialogs.showWarning(T.puzzleMenu.validation.title, validationError);

View File

@ -151,6 +151,8 @@ puzzleMenu:
One or more Goal Acceptors are not getting enough items. Make sure that the indicators are green for all acceptors. One or more Goal Acceptors are not getting enough items. Make sure that the indicators are green for all acceptors.
buildingOutOfBounds: >- buildingOutOfBounds: >-
One or more buildings are outside of the buildable area. Either increase the area or remove them. One or more buildings are outside of the buildable area. Either increase the area or remove them.
autoComplete: >-
Your puzzle autocompletes itself! Please make sure your constant producers are not directly delivering to your goal acceptors.
dialogs: dialogs:
buttons: buttons: