Skip to content

Commit

Permalink
Fix bug where where changing the presets temporarily changes the defa…
Browse files Browse the repository at this point in the history
…ult and remove unused code
  • Loading branch information
Heath123 committed Apr 6, 2022
1 parent 5032983 commit 645126a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
5 changes: 4 additions & 1 deletion html/mainPage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ <h3>Filtering</h3>
updateFilteringTab()" style="margin-left: 8px;">Hide all
</button>

<button onclick="sharedVars.hiddenPackets = findDefault('hiddenPackets')
<button onclick="const defaultHidden = findDefault('hiddenPackets')
sharedVars.hiddenPackets = {
serverbound: [...defaultHidden.serverbound], clientbound: [...defaultHidden.clientbound]
}
updateFilteringTab()" style="margin-left: 8px;">Defaults
</button>
</div>
Expand Down
22 changes: 6 additions & 16 deletions html/mainPage/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,6 @@ function updateFiltering () {

setInterval(updateFilterBox, 100)

/* let hiddenPackets = [
// TODO: Do this properly
// JE
'update_time', 'position', 'position', 'keep_alive', 'keep_alive', 'rel_entity_move', 'position_look', 'look', 'position_look', 'map_chunk', 'update_light', 'entity_action', 'entity_update_attributes', 'unload_chunk', 'unload_chunk', 'update_view_position', 'entity_metadata',
// BE
'network_stack_latency', 'level_chunk', 'move_player', 'player_auth_input', 'network_chunk_publisher_update', 'client_cache_blob_status', 'client_cache_miss_response', 'move_entity_delta', 'set_entity_data', 'set_time', 'set_entity_data', 'set_entity_motion', /* "add_entity", *//* 'level_event', 'level_sound_event2', 'update_attributes', 'entity_event', 'remove_entity', 'mob_armor_equipment', 'mob_equipment', 'update_block', 'player_action', 'move_entity_absolute'
] */

// let dialogOpen = false Not currently used

const defaultHiddenPackets = {
serverbound: ['position', 'position_look', 'look', 'keep_alive', 'entity_action'],
clientbound: ['keep_alive', 'update_time', 'rel_entity_move', 'entity_teleport', 'map_chunk', 'update_light', 'update_view_position', 'entity_metadata', 'entity_update_attributes', 'unload_chunk', 'entity_velocity', 'entity_move_look', 'entity_head_rotation']
}

const sharedVars = {
allPackets: [],
allPacketsHTML: [],
Expand Down Expand Up @@ -174,7 +159,12 @@ function findPreset(elem) {
const name = elem.innerText.match(/Preset: ([\w|\s]+)/i)[1].replace(/\s/g, '_')
defaultsJson.extended_presets.forEach((value) => {
if (value.hasOwnProperty(name)) {
sharedVars.hiddenPackets = value[name]
// Copy the object
// Otherwise it will be a reference and changing it will change the preset
sharedVars.hiddenPackets = {
serverbound: [...value[name].serverbound],
clientbound: [...value[name].clientbound]
}
}
})
}
Expand Down

0 comments on commit 645126a

Please sign in to comment.