change validPetPoses bit order, add dims to blob
This commit is contained in:
parent
01c6cbcfdb
commit
6757775fec
4 changed files with 9 additions and 8 deletions
|
@ -12,4 +12,3 @@ Tech/detail improvements:
|
|||
* Use react-virtualized instead of our own scroller, but we need total count known, and we need another solution for the CSS transitions in the outfit case
|
||||
* Restore good download behavior: use crossOrigin for everything, and remove cache-buster in the URL we use for canvas
|
||||
* Undo the local linking we did for @chakra-ui/core, react, and react-dom on Matchu's machine 😅
|
||||
* validPetPoses should declare its own dimensions, so that misaligned caches won't misalign the data
|
||||
|
|
|
@ -65,7 +65,7 @@ function SpeciesColorPicker({ outfitState, dispatchToOutfit }) {
|
|||
const onChangeColor = (e) => {
|
||||
const speciesId = outfitState.speciesId;
|
||||
const colorId = e.target.value;
|
||||
if (pairIsValid(valids, meta, speciesId, colorId)) {
|
||||
if (pairIsValid(valids, speciesId, colorId)) {
|
||||
dispatchToOutfit({ type: "changeColor", colorId: e.target.value });
|
||||
} else {
|
||||
const species = allSpecies.find((s) => s.id === speciesId);
|
||||
|
@ -82,7 +82,7 @@ function SpeciesColorPicker({ outfitState, dispatchToOutfit }) {
|
|||
const onChangeSpecies = (e) => {
|
||||
const colorId = outfitState.colorId;
|
||||
const speciesId = e.target.value;
|
||||
if (pairIsValid(valids, meta, speciesId, colorId)) {
|
||||
if (pairIsValid(valids, speciesId, colorId)) {
|
||||
dispatchToOutfit({ type: "changeSpecies", speciesId: e.target.value });
|
||||
} else {
|
||||
const species = allSpecies.find((s) => s.id === speciesId);
|
||||
|
@ -133,12 +133,12 @@ function SpeciesColorPicker({ outfitState, dispatchToOutfit }) {
|
|||
);
|
||||
}
|
||||
|
||||
function pairIsValid(valids, meta, speciesId, colorId) {
|
||||
function pairIsValid(valids, speciesId, colorId) {
|
||||
// Reading a bit table, owo!
|
||||
const speciesIndex = speciesId - 1;
|
||||
const colorIndex = colorId - 1;
|
||||
const numColors = meta.allColors.length;
|
||||
const pairByteIndex = speciesIndex * numColors + colorIndex;
|
||||
const numColors = valids.getUint8(1);
|
||||
const pairByteIndex = speciesIndex * numColors + colorIndex + 2;
|
||||
const pairByte = valids.getUint8(pairByteIndex);
|
||||
return pairByte !== 0;
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -30,7 +30,9 @@ export default async function getValidPetPoses() {
|
|||
}
|
||||
|
||||
const numPairs = numSpecies * numColors;
|
||||
const buffer = Buffer.alloc(numPairs);
|
||||
const buffer = Buffer.alloc(numPairs + 2);
|
||||
buffer.writeUInt8(numSpecies, 0);
|
||||
buffer.writeUInt8(numColors, 1);
|
||||
|
||||
for (let speciesId = 1; speciesId <= numSpecies; speciesId++) {
|
||||
const speciesIndex = speciesId - 1;
|
||||
|
@ -53,7 +55,7 @@ export default async function getValidPetPoses() {
|
|||
byte <<= 1;
|
||||
byte += hasPose(speciesId, colorId, "HAPPY", "MASCULINE") ? 1 : 0;
|
||||
|
||||
buffer.writeUInt8(byte, speciesIndex * numColors + colorIndex);
|
||||
buffer.writeUInt8(byte, speciesIndex * numColors + colorIndex + 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue