Commit 839780bb authored by Grant's avatar Grant
Browse files

Fix race condition with low pixel cooldown setups (fixes #163)

parent 616e262b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -124,9 +124,19 @@ export class User {
  async modifyStack(modifyBy: number): Promise<any> {
    const CONFIG = ClientConfigService.getConfig();

    await this.update(true);

    let new_date = new Date();
    if (modifyBy > 0) {
      let cooldown_to_add = 0.0;

      if (this.pixelStack + modifyBy > CONFIG.canvas.pixel.maxStack) {
        Logger.debug(
          `${this.sub} attempted to claim another pixel, but would go over the max stack`
        );
        return;
      }

      for (let i = 0; i < modifyBy; i++) {
        cooldown_to_add += CanvasLib.getPixelCooldown(
          this.pixelStack + i + 1,