1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-04 09:04:13 +02:00

sort props when encoding

This commit is contained in:
Robin Appelman 2017-09-30 12:15:05 +02:00
commit 6462480cbb

View file

@ -26,6 +26,13 @@ export function getEntityUpdate(sendTable: SendTable, stream: BitStream): SendPr
export function encodeEntityUpdate(props: SendProp[], sendTable: SendTable, stream: BitStream) { export function encodeEntityUpdate(props: SendProp[], sendTable: SendTable, stream: BitStream) {
const allProps = sendTable.flattenedProps; const allProps = sendTable.flattenedProps;
props.sort((propA, propB) => {
const indexA = allProps.findIndex((propDef) => propDef.fullName === propA.definition.fullName);
const indexB = allProps.findIndex((propDef) => propDef.fullName === propB.definition.fullName);
return indexA - indexB;
});
let lastIndex = -1; let lastIndex = -1;
for (const prop of props) { for (const prop of props) {
stream.writeBoolean(true); stream.writeBoolean(true);