mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Fix belts being too slow sometimes, closes #999
This commit is contained in:
parent
edc52a9271
commit
8e2efb0756
@ -3,6 +3,7 @@ export const CHANGELOG = [
|
||||
version: "1.2.2",
|
||||
date: "07.12.2020",
|
||||
entries: [
|
||||
"Fix item readers and some other buildings slowing up belts, especially if they stalled (inspired by Keterr's fix)",
|
||||
"Added the ability to edit constant signals by left clicking them",
|
||||
"You can now add markers in the wire layer (partially by daanbreur)",
|
||||
"Allow to cycle backwards in the toolbar with SHIFT + Tab (idea by EmeraldBlock)",
|
||||
|
@ -1085,6 +1085,9 @@ export class BeltPath extends BasicSerializableObject {
|
||||
// Reduce the spacing
|
||||
nextDistanceAndItem[_nextDistance] -= clampedProgress;
|
||||
|
||||
// Advance all items behind by the progress we made
|
||||
this.spacingToFirstItem += clampedProgress;
|
||||
|
||||
// If the last item can be ejected, eject it and reduce the spacing, because otherwise
|
||||
// we lose velocity
|
||||
if (isFirstItemProcessed && nextDistanceAndItem[_nextDistance] < 1e-7) {
|
||||
@ -1097,6 +1100,24 @@ export class BeltPath extends BasicSerializableObject {
|
||||
if (this.tryHandOverItem(nextDistanceAndItem[_item], excessVelocity)) {
|
||||
this.items.pop();
|
||||
|
||||
const itemBehind = this.items[lastItemProcessed - 1];
|
||||
if (itemBehind && this.numCompressedItemsAfterFirstItem > 0) {
|
||||
// So, with the next tick we will skip this item, but it actually has the potential
|
||||
// to process farther -> If we don't advance here, we loose a tiny bit of progress
|
||||
// every tick which causes the belt to be slower than it actually is.
|
||||
// Also see #999
|
||||
const fixupProgress = Math.max(
|
||||
0,
|
||||
Math.min(remainingVelocity, itemBehind[_nextDistance])
|
||||
);
|
||||
|
||||
// See above
|
||||
itemBehind[_nextDistance] -= fixupProgress;
|
||||
remainingVelocity -= fixupProgress;
|
||||
this.spacingToFirstItem += fixupProgress;
|
||||
}
|
||||
|
||||
// Reduce the number of compressed items since the first item no longer exists
|
||||
this.numCompressedItemsAfterFirstItem = Math.max(
|
||||
0,
|
||||
this.numCompressedItemsAfterFirstItem - 1
|
||||
@ -1110,7 +1131,6 @@ export class BeltPath extends BasicSerializableObject {
|
||||
}
|
||||
|
||||
isFirstItemProcessed = false;
|
||||
this.spacingToFirstItem += clampedProgress;
|
||||
if (remainingVelocity < 1e-7) {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user