Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#5602 closed defect (fixed)

ProductionQueue WARNING: Invalid command: can't train 0 units

Reported by: elexis Owned by: elexis
Priority: Nice to Have Milestone: Alpha 24
Component: UI – In-game Keywords:
Cc: Patch:

Description

In this match with r22951, nani somehow managed to send a command from the UI where 0 units were ordered to be trained at a kennel:

turn 6181 500
cmd 8 {"type":"returnresource","entities":[9978,9998,12158,12159,12160,12851,12887,12902,12903,13500,13501,13502,13503,13579,13609,13619],"target":10731,"queued":false}
cmd 8 {"type":"gather","entities":[9978,9998,12158,12159,12160,12851,12887,12902,12903,13500,13501,13502,13503,13579,13609,13619],"target":5766,"queued":true}
cmd 2 {"type":"train","entities":[10077,10092,10105],"template":"units/brit_war_dog_b","count":2}
cmd 2 {"type":"train","entities":[10118],"template":"units/brit_war_dog_b","count":0}
end

In the replay / for all players:

Turn 6181 (500)...
WARNING: Invalid command: can't train 0 units

So there must be some kind of way to trigger this command from the UI, but that should not be possible to send it, i.e. should be fixed in the UI as well, not only simulation.

Attachments (1)

commands.zip (389.0 KB ) - added by elexis 5 years ago.

Download all attachments as: .zip

Change History (5)

by elexis, 5 years ago

Attachment: commands.zip added

comment:1 by elexis, 4 years ago

faction02 reported the way to reproduce the bug:

  1. build 3 kennels
  2. train 28 dogs (limit is 30)
  3. reduce batchcount size to 1
  4. Shift+click on the button to train a dog

Then 2 dogs + 1 JS GUI warning is pushed.

The relevant code would be in addTrainingToQueue, flushTrainingBatch of input.js.

Last edited 4 years ago by elexis (previous) (diff)

comment:2 by elexis, 4 years ago

Keywords: simple removed
Milestone: BacklogAlpha 24
  • Reproduced with n in {3, 4, 5} kennels, where limit - (n-1) dogs had been trained, batchSize = 1 and then flushing one batch
  • Reproduced with batchsize=3 too:
    WARNING: batchedSize 3
    WARNING: appropriateBuildings.length 5
    WARNING: g_BatchTrainingEntityAllowedCount 12
    WARNING: buildingsCountToTrainFullBatch 4
    WARNING: Invalid command: can't train 0 units
    
  • It's the remainer part of flushTrainingBatch.
  • g_BatchTrainingEntityAllowedCount % batchedSize is only negative if g_BatchTrainingEntityAllowedCount is negative, see specs
  • g_BatchTrainingEntityAllowedCount is at least 0, see line ret.canBeAddedCount = Math.max(ret.entLimit - ret.entCount, 0);
  • So capturing 0 is sufficient to cover all these reproduced cases.
  • batchedSize is at least 1*
  • So this non-0 check is sufficient for all "train" commands to capture all ways to trigger this error*

(* (unless there is a bug where g_NumberOfBatches could be 0 and this code called))

comment:3 by elexis, 4 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 23192:

Fix warning about attempted empty batch train occurring if g_BatchTrainingEntityAllowedCount % batchedSize == 0, refs #1432, #4059, rP12832, rP18421, rP19826, fixes #5602, reported by nani, reproduced by faction02.

comment:4 by Stan, 4 years ago

Summary: ProudctionQueue WARNING: Invalid command: can't train 0 unitsProductionQueue WARNING: Invalid command: can't train 0 units
Note: See TracTickets for help on using tickets.