Skip to content

Commit

Permalink
Merge pull request #118 from ctrlaltdavid/fix/skip-complex-trait
Browse files Browse the repository at this point in the history
Fix skipping deleting an instanced trait
  • Loading branch information
ctrlaltdavid committed Jun 27, 2022
2 parents 941f375 + 2672a80 commit 6b757dd
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
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
3 changes: 1 addition & 2 deletions tests/domain/networking/packets/BulkAvatarData.unit.test.js
Expand Up @@ -93,7 +93,7 @@ describe("BulkAvatarData - unit tests", () => {
expect(bulkAvatarDetail.localOrientation.w).toBeCloseTo(-0.995859, 3);
});

test("Can read a BulkAvtarData message that has avatar scale data", () => {
test("Can read a BulkAvatarData message that has avatar scale data", () => {
// eslint-disable-next-line max-len
const RECEIVED_MESSAGE = "5cd7b12c15bb44bb96048d7dcf3828e7ff317e250339c3bcb23f414a44bf8328933ec529873f8328933e40b6fb3bf0ced5bd402df03cbfff8c743fff091390ad61443438633f52e7ffc600bfff8c743fffe7057cfe0239e86549be424a44bff00400000000000000000000000000000000ffff5800f0ffffffffffffffffffa20fc11340a43ebddcd4387f4684e73836284e3ed6d83205478cb1e52d2f478cb1e52d2f43e1da7947a435d7ec604a6d2efbcd6c491733e4a8734f7533e4a8734f75a97dbfaf4044ab03bf6a4024ac8abf234003b70ec0314108c518c09d3fc741dd8a983eb541dd8a983eb53f678a9240f93f678a9240f9c1640a693e35c1640a693e35bfb90a68411bbfb90a68411bc479d4213e5bc479d4213e5bc479d4213e5bc479d4213e5bed3069785b630375d8f9431457f80c73473252b71c274fd13aa92b31543c37a32eac56b34515327c5af24515327c5af2505f1a345c3f4c9218f96900487917f4707a487917f4707a52e019f55dda4c6b173769b2465c16477727465c1647772751f91a7b58ca4e6418b667d548cf177771dd48cf177771dd54ea1c0653f052361a355e2e525d1a315f12525d1a315f120e4f62b220b627b474754b3e2c9176c046892f1b787f4a7a44976e9750834a8871e54c6140d46fd452c740d46fd452c732b879585d107879c54117f370dfbd150d3070dfbd150d302e587a095cbd774bc86e19fa6f2dbff40e226f2dbff40e22311f797358a6784ec5f6183271e1bd730fda71e1bd730fda2c17788150d037467ac0624e7827c5b618567827c5b6185600b00400000000000000006677b8423700004081e30cf8b5ff00000000c41d0000f407b5ff000058ff0f000000000000000000ff4ffbffffffffffffffff";
const MESSAGE_START = 0;
Expand All @@ -114,7 +114,6 @@ describe("BulkAvatarData - unit tests", () => {
});

test("Can read a BulkAvatarData message that has joint default flags", () => {

// eslint-disable-next-line max-len
const RECEIVED_MESSAGE = "7cd12a580e0d45b6a1e6aad6ab0c84bfff31e292abbf89a6ac3f967a15c06b9d8e3e7dfd823f6b9d8e3ec0f0f33b1035cfbdf0c2e83cbfff3fff2ccf7212d12951c6d38a0d4099a6e94600bfff3fff2ccfb805e392abbf80ba47be777a15c0f00400000000000000000000000000000000ffff5800f0ffffffffffffffffffa267c0ce40043e55db873899462ce6cc36544d5ed4ed337f475dafcb2ee5475dafcb2ee543b6d91648993631eaa44b1f2ed0c9c44a363431a4f950893431a4f95089a9bdbf2d408dab3dbedc409cacbfbe8940abb75dc0053f60c546c0433e5f42558a78401642558a7840163fde8a6b42583fde8a6b4258c2400a883f61c2400a883f61c0950a954246c0950a954246c546c0433e5fc546c0433e5fc546c0433e5fc546c0433e5fee5c6aa25aa8034cd77e445156220d7d489d510a1f0c524438972dde56dc358e315e5945430535985d0d430535985d0d4f2d1d645eb94bec1c636b7948341b6d72f948341b6d72f951c41d3960404bdf1a9f6c34468419cb799c468419cb799c50a71d9a5b3f4db61c206a4548a11af6745648a11af6745653641f13564d511a1d796096514a1d7b6177514a1d7b61770e02639d20df25b2763a4b9429e677a047a52ce97ac34c8b42d171f052144881754a4d9b3f20730954713f20730954717ad1ceae213874bcc62d16c46cf6bd710c926cf6bd710c927926d310216c737dc97b18bb6b2ac0660d7b6b2ac0660d7b2f837bca5a7a748dc6e616ff6dfdbdfa0f346dfdbdfa0f342a2e7aab52ed7767c9ec1c497465c6a917277465c6a9172702b0040000000000000000b8981344302c00401af52500f80991fbc2fef5ff00000000a60400003e01f5ff000058ff0f000000000000000000fd4ffbffffffffffffffff";
const MESSAGE_START = 0;
Expand Down
36 changes: 36 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.

0 comments on commit 6b757dd

Please sign in to comment.