Skip to content

Remove slave pool indices and move slave pools to Map objects

In my testing (#5518) this doesn't change the performance much in FCHost or Firefox

Closes #5518

Changes

  • Note: Since I am writing this during my final code review the order may be strange as I am making note of the changes as I come along them in tree view order
  • Added extensions to the built in Map prototype bringing some of the functionality of Arrays to Maps
    • Added: filter, randomKey, randomValue, randomEntry, pluck, map (type defs for this one still need a little work), find, atIndex, every, some, and asArray
    • The definitions for these additions are here and the additions themselves are here
  • Removed V.slaveIndices, V.cribsIndices, and V.incubator.tankIndices
  • Moved V.slaves, V.cribs, and V.incubator.tanks from Arrays to Maps
  • Release id bump
  • Removed App.Verify.I.indices() and all calls to it as it is no longer needed
  • Removed all direct calls to the slave pools with the exception of legacy BC
  • Moved slaves2indices() to App.Update.slaves2indices() and physically moved it to src/data/backwardsCompatibility/backwardsCompatibility.js as it no longer serves a purpose other than in BC
  • Replaced all calls to getSlaves() and friends in backwardsCompatibility.js with direct accesses to the slave pools because getSlaves() and friends no longer return arrays as BC expects, but the old non BCed game state will be an array and needs to go through BC correctly
  • Removed App.Facilities.Nursery.cribsToIndices() and moved its functionality into backwardsCompatibility.js
  • Modified patch.js to handle both the old arrays and the new maps
  • Removed App.Debug.slaveSummaryText() as it isn't used anywhere
  • Added missing type defs and fixed formatting
  • Lots and lots of refactoring to best use the fact that our pools are now Maps and the get*() functions now spit out a Map instead of an Array
  • Added missing eye side to getGeneticEyeColor() call in src/events/scheduled/seCustomSlaveDelivery.js
  • Added logic in src/facilities/nursery/utils/nurseryUtils.js to stop it from potentially setting child.eye.origColor to undefined
  • Removed App.Facilities.Nursery.cribsToIndices(), App.Facilities.Nursery.childIndexForID(), and App.Facilities.Nursery.removeChild()
  • Removed App.Debug.slavesConsistency() and its file as it is no longer needed
  • Added hasSlave(), addSlave(), slaveCount(), hasInfant(), addInfant(), infantCount(), hasTankSlave(), addTankSlave(), tankSlaveCount(), and allSlaveCount()
  • Added some checks into setEyeColor(), setEyeColorFull(), and setGeneticEyeColor()

TODO

  • Remove array functions
  • Slave Sorting
  • Handle and test slave ID change in NGP
  • Cleanup
  • Extensive testing
    • AI image archiving (Arcology & Individual)
      • Should be working but testing was skipped because image archiving is currently broken. See #5574
    • Adding and removing slaves
    • Conception and birth
    • Slave death
    • New game
    • Very old save
    • Recent save
    • NGP
  • Final code review and change log
Edited by Frankly George

Merge request reports

Loading