Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix skipping deleting an instanced trait when reading BulkAvatarTraits message. #118

Merged
merged 3 commits into from Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/domain/avatars/AvatarTraits.ts
Expand Up @@ -91,6 +91,8 @@ type AvatarTraitsValues = {
* @property {AvatarTraits.TraitType} TotalTraitTypes=4 - The number of trait types. <em>Read-only.</em>
* @property {AvatarTraits.TraitType} NUM_SIMPLE_TRAITS=2 - The number of simple traits. <em>Read-only.</em>
* @property {number} DEFAULT_TRAIT_VERSION=0 - The default trait version sequence number. <em>Read-only.</em>
* @property {number} DELETED_TRAIT_SIZE=-1 - The nominal trait binary size for deleting an instanced trait.
* <em>Read-only.</em>
*/
const AvatarTraits = new class {
// C++ namespace AvatarTraits
Expand Down Expand Up @@ -150,6 +152,7 @@ const AvatarTraits = new class {
readonly NUM_SIMPLE_TRAITS = TraitType.FirstInstancedTrait;

readonly DEFAULT_TRAIT_VERSION = 0;
readonly DELETED_TRAIT_SIZE = -1;


/*@devdoc
Expand Down
4 changes: 3 additions & 1 deletion src/domain/networking/packets/BulkAvatarTraits.ts
Expand Up @@ -102,7 +102,9 @@ const BulkAvatarTraits = new class {
this.#_haveWarnedComplexTraits = true;
}

dataPosition += traitBinarySize;
if (traitBinarySize > AvatarTraits.DELETED_TRAIT_SIZE) {
dataPosition += traitBinarySize;
}
}

// Read the next trait type, which is Null Trait if there are no more traits for this avatar.
Expand Down
1 change: 1 addition & 0 deletions tests/domain/avatars/AvatarTraits.unit.test.js
Expand Up @@ -19,6 +19,7 @@ describe("AvatarTraits - unit tests", () => {
expect(AvatarTraits.SkeletonModelURL).toBe(0);
expect(AvatarTraits.TotalTraitTypes).toBe(AvatarTraits.Grab + 1);
expect(AvatarTraits.DEFAULT_TRAIT_VERSION).toBe(0);
expect(AvatarTraits.DELETED_TRAIT_SIZE).toBe(-1);
});

test("Can check whether a trait is a simple trait type", () => {
Expand Down
32 changes: 32 additions & 0 deletions tests/domain/networking/packets/BulkAvatarTraits.unit.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.