From 7ebf2556ba3d8c6dc80c45efc6a90bbb1e27f5d0 Mon Sep 17 00:00:00 2001 From: Pyro Nicampt <81565698+PyroNicampt@users.noreply.github.com> Date: Wed, 25 Jun 2025 23:07:21 -0500 Subject: [PATCH] Fix bugs with location mod integration. - Connect button behavior incorrect. - Wrong value saved for host IP. - Cars stayed when disconnecting. --- js/mapdata.js | 1 + legend.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/js/mapdata.js b/js/mapdata.js index b77dc8e..1e577bc 100644 --- a/js/mapdata.js +++ b/js/mapdata.js @@ -694,6 +694,7 @@ export function connectPlayerLocation(address, status){ let started = false; const endConnect = () => { locationData = null; + dynamicMarkers = []; status.value = 'Connect'; playerMarker.hidden = true; view.dynDirty = true; diff --git a/legend.js b/legend.js index ec41f1b..2419fd2 100644 --- a/legend.js +++ b/legend.js @@ -196,9 +196,12 @@ let settingEntries = [ label: 'Location Host', id: 'field_locationHost', state: 'localhost:9090', + placeholder: 'localhost:9090', saveState: true, - button: 'Wait', + button: 'Connect', func: state =>{ + if(state == '') state = 'localhost:9090'; + document.getElementById('field_locationHost').value = state; let button = document.getElementById('field_locationHost').nextSibling; if(button.value.startsWith('Connect')){ MapData.connectPlayerLocation(state, button); @@ -368,6 +371,7 @@ function addSettingEntry(thisSetting, parent, indent=0){ thisSetting.inputElement = document.createElement('input'); thisSetting.inputElement.type = 'text'; thisSetting.inputElement.value = thisSetting.state; + if(thisSetting.placeholder) thisSetting.inputElement.placeholder = thisSetting.placeholder; if(thisSetting.button){ thisSetting.buttonElement = document.createElement('input'); thisSetting.buttonElement.type = 'button'; @@ -375,7 +379,7 @@ function addSettingEntry(thisSetting, parent, indent=0){ if(thisSetting.func){ thisSetting.buttonElement.addEventListener('click', e => { thisSetting.func(thisSetting.inputElement.value); - if(thisSetting.saveState) saveSetting(thisSetting.id, e.target.value); + if(thisSetting.saveState) saveSetting(thisSetting.id, thisSetting.inputElement.value); }); } } @@ -458,7 +462,7 @@ function resetSettingEntry(entry){ } function saveSetting(name, value){ - //console.log(`saving 'setting_${name}=${encodeURIComponent(value)};'`); + //console.trace(`saving 'setting_${name}=${encodeURIComponent(value)};'`); if(value == null){ resetSetting(name); }else{ @@ -472,6 +476,7 @@ function loadSetting(name, defaultValue){ if(cookie.startsWith('setting_'+name+'=')){ let result = cookie.split('='); //console.log(`Loading setting_${name}=${decodeURIComponent(result[1])}`); + if(result[1] == '') return defaultValue; return autocast(decodeURIComponent(result[1])); } }