Koenvh1 / ets2-local-radio

Radio from wherever you are in ETS2/ATS
https://koenvh.nl/projects/ets2-local-radio
Mozilla Public License 2.0
234 stars 40 forks source link

custom.js - problems adding a new country #212

Open Xuth1 opened 1 year ago

Xuth1 commented 1 year ago

Hi! I've attempted to customise my own set-up to include the nations and cities featured in the ETS2 mod 'SFIGC 0.7.2.' (Shetland, Faroe Isles, Greenland, Canada) which adds small parts of the aforementioned areas to the game.

Unfortunately, while the server and web UI loads fine with my custom.js - none of these new stations are appearing. I've 'expanded all' to check - and the last stations in the list are still the Japanese ones.

Anything I've not done right?

In Custom.js I have added:

var country_properties = {
    "canada": {
        name: "Canada",
        name_english: "Canada",
        code: "ca",
        relative_radius: 1.0,
    },
    "greenland": {
        name: "Kalaallit Nunaat",
        name_english: "Greenland",
        code: "gl",
        relative_radius: 1.0,
    },
    "piere": {
        name: "Saint-Pierre et Miquelon",
        name_english: "Saint Pierre and Miquelon",
        code: "pm",
        relative_radius: 0.5,
    },
};

Followed by:

var cities_sfigc = [
{
      "gameName": "apex",
      "realName": "Apex",
      "country": "canada",
      "x": "-143773",
      "y": "78.9414",
      "z": "-164438"
    },
    {
      "gameName": "brae",
      "realName": "Brae",
      "country": "shetland",
      "x": "-30042.6",
      "y": "110.156",
      "z": "-77273.3"
    },
    {
      "gameName": "frodsba",
      "realName": "Froðba",
      "country": "faroe",
      "x": "-50049.9",
      "y": "63.5",
      "z": "-74259.3"
    },
    {
      "gameName": "gloup",
      "realName": "Gloup",
      "country": "shetland",
      "x": "-27987.1",
      "y": "112.031",
      "z": "-79729.1"
    },
    {
      "gameName": "grutness",
      "realName": "Grutness",
      "country": "shetland",
      "x": "-30587.2",
      "y": "111.48",
      "z": "-74008.4"
    },
    {
      "gameName": "gutcher",
      "realName": "Gutcher",
      "country": "shetland",
      "x": "-27780.6",
      "y": "112.066",
      "z": "-78965.4"
    },
    {
      "gameName": "ham",
      "realName": "Ham",
      "country": "shetland",
      "x": "-1689.94",
      "y": "68.8906",
      "z": "-16335.5"
    },
    {
      "gameName": "husavik",
      "realName": "Húsavík",
      "country": "faroe",
      "x": "-50004",
      "y": "65.3125",
      "z": "-77415.1"
    },
    {
      "gameName": "hvalba",
      "realName": "Hvalba",
      "country": "faroe",
      "x": "-51457.1",
      "y": "62.5547",
      "z": "-74777.6"
    },
    {
      "gameName": "iqaluit",
      "realName": "Iqaluit",
      "country": "canada",
      "x": "-142938",
      "y": "80.7539",
      "z": "-165314"
    },
    {
      "gameName": "itorqomt",
      "realName": "Ittoqqortoormiit",
      "country": "greenland",
      "x": "-57436",
      "y": "77.7695",
      "z": "-133975"
    },
    {
      "gameName": "kimmirut",
      "realName": "Kimmirut",
      "country": "canada",
      "x": "-146408",
      "y": "115.156",
      "z": "-161605"
    },
    {
      "gameName": "kulusuk",
      "realName": "Kulusuk",
      "country": "greenland",
      "x": "-105671",
      "y": "77.7578",
      "z": "-127630"
    },
    {
      "gameName": "kuummiit",
      "realName": "Kuummiit",
      "country": "greenland",
      "x": "-102635",
      "y": "77.7578",
      "z": "-129714"
    },
    {
      "gameName": "lerwick",
      "realName": "Lerwick",
      "country": "shetland",
      "x": "-30340.7",
      "y": "114.809",
      "z": "-75768.8"
    },
    {
      "gameName": "lopra",
      "realName": "Lopra",
      "country": "faroe",
      "x": "-50078.6",
      "y": "62.5938",
      "z": "-73401.9"
    },
    {
      "gameName": "mid_yell",
      "realName": "Mid Yell",
      "country": "sheland",
      "x": "-28458.5",
      "y": "112.09",
      "z": "-78792.1"
    },
    {
      "gameName": "nanortalik",
      "realName": "Nanortalik",
      "country": "greenland",
      "x": "-146921",
      "y": "81.2266",
      "z": "-120920"
    },
    {
      "gameName": "nuuk",
      "realName": "Nuuk",
      "country": "greenland",
      "x": "-131546",
      "y": "122.25",
      "z": "-166845"
    },
    {
      "gameName": "porkeri",
      "realName": "Porkeri",
      "country": "faroe",
      "x": "-50361.8",
      "y": "62.5938",
      "z": "-73891.5"
    },
    {
      "gameName": "qaqortoq",
      "realName": "Qaqortoq",
      "country": "greenland",
      "x": "-146287",
      "y": "66.4531",
      "z": "-126701"
    },
    {
      "gameName": "saint_pier",
      "realName": "Saint-Pierre",
      "country": "piere",
      "x": "-171711",
      "y": "77.7617",
      "z": "-154523"
    },
    {
      "gameName": "sandness",
      "realName": "Sandness",
      "country": "shetland",
      "x": "-31367.5",
      "y": "112.867",
      "z": "-76735.5"
    },
    {
      "gameName": "sandvik",
      "realName": "Sandvík",
      "country": "faroe",
      "x": "-51610.9",
      "y": "62.5938",
      "z": "-75068.9"
    },
    {
      "gameName": "skopun",
      "realName": "Skopun",
      "country": "faroe",
      "x": "-50518.8",
      "y": "64.6836",
      "z": "-77959.7"
    },
    {
      "gameName": "sumba",
      "realName": "Sumba",
      "country": "faroe",
      "x": "-49992.4",
      "y": "62.5938",
      "z": "-72949.9"
    },
    {
      "gameName": "tasiilaq",
      "realName": "Tasiilaq",
      "country": "greenland",
      "x": "-106817",
      "y": "77.7578",
      "z": "-129127"
    },
    {
      "gameName": "tasiusaq",
      "realName": "Tasiusaq",
      "country": "greenland",
      "x": "-144541",
      "y": "136.609",
      "z": "-119165"
    },
    {
      "gameName": "toft",
      "realName": "Toft",
      "country": "shetland",
      "x": "-29770.1",
      "y": "110.156",
      "z": "-77601.4"
    },
    {
      "gameName": "trongisva",
      "realName": "Trongisvágur",
      "country": "faroe",
      "x": "-50705.1",
      "y": "63.4766",
      "z": "-74347.7"
    },
    {
      "gameName": "ulsta",
      "realName": "Ulsta",
      "country": "shetland",
      "x": "-28782.6",
      "y": "112.91",
      "z": "-77981.6"
    },
    {
      "gameName": "vagur",
      "realName": "Vágur",
      "country": "faroe",
      "x": "-50382.8",
      "y": "62.5938",
      "z": "-73500.2"
    }
];

cities = cities.concat(cities_sfigc); //Shetland Faroe Island Greenland Canada (SFIGC 0.7.2) Map

And then the new stations (note, I also tried using var stations_custom method, but that also didn't work for me. The image locations are actually set to a local folder now as well, but still no luck.

stations["canada"].push({
            name: "CBC Music 88.3",
            logo: "stations/images-europe/canada/CBC Music.png",
            url: "https://playerservices.streamtheworld.com/api/livestream-redirect/CBH_CBC_SC"
        },
        {
            name: "CBC Radio One 91.1",
            logo: "stations/images-europe/canada/CBC Radio One.png",
            url: "https://playerservices.streamtheworld.com/api/livestream-redirect/CBGAM_CBC_SC"
        },
        {
            name: "CKIQ Ice FM",
            logo: "stations/images-europe/canada/Ice FM.png",
            url: "http://ca7.rcast.net:8020/stream"
        },
        {
            name: "CKGC Capital FM",
            logo: "stations/images-europe/canada/Capital FM.png",
            url: "http://ca2.rcast.net:8018/stream;"
        });

stations["greenland"].push({
        {
            name: "Kalaallit Nunaata Radioa",
            logo: "stations/images-europe/greenland/KNR.png",
            url: "http://radio.knr.gl:8000/"
        },
        {
            name: "Ice FM",
            logo: "stations/images-europe/greenland/Ice FM.png",
            url: "http://ca7.rcast.net:8020/stream"
        },
        {
            name: "DR P1",
            logo: "stations/images-europe/denmark/DR P1.png",
            url: "http://live-icy.gslb01.dr.dk/A/A03H.mp3"
        },
        {
            name: "DR P2",
            logo: "stations/images-europe/denmark/DR P2.png",
            url: "http://live-icy.gss.dr.dk/A/A04L.mp"
        },
        {
            name: "Nanoq FM",
            logo: "stations/images-europe/greenland/Nanoq FM.png",
            url: "http://getnanoq.retro-radio.dk/Nanoq-TX-1"
        });

stations["piere"].push({
        {
            name: "Radio Atlantique",
            logo: "stations/images-europe/canada/Radio Atlantique.png",
            url: "https://s7.voscast.com:10433/stream.mp3"
        },
        {
            name: "Radio France Internationale",
            logo: "stations/images-europe/canada/RFI.png",
            url: "https://rfimonde64k.ice.infomaniak.ch/rfimonde-64.mp3"
        },
        {
            name: "Saint-Pierre et Miquelon la 1ère",
            logo: "stations/images-europe/canada/SPM1ere.png",
            url: "https://saint-pierreetmiquelon.ice.infomaniak.ch/saint-pierreetmiquelon-128.mp3"
        },
        {
            name: "Radio Archipel FM",
            logo: "stations/images-europe/canada/Radio Archipel.png",
            url: "http://radioarchipelfm.ice.infomaniak.ch/radioarchipelfm-64.mp3"
        });
Xuth1 commented 1 year ago

I can confirm that what seems to be breaking everything is var country_properties. I have been able to add a new town and a radio station to (the existing) Shetland just fine by simplifying it to the below - but as soon as I attempt to add a new country it all breaks.

Working config:

var cities_sfigc = [
    {
      "gameName": "sandness",
      "realName": "Sandness",
      "country": "shetland",
      "x": "-31367.5",
      "y": "112.867",
      "z": "-76735.5"
    },]

cities = cities.concat(cities_sfigc);

//New Custom Stations for SFIGC Compatibility

 stations["shetland"].push({
            name: "CBC Music 88.3",
            logo: "https://cdn-profiles.tunein.com/s25274/images/logog.png",
            url: "https://playerservices.streamtheworld.com/api/livestream-redirect/CBH_CBC_SC"
        });

And by breaking, it undoes any other custom configurations - for example I've been using cities = cities.concat(cities_open_spaces); as a bit of a Canary and it works with any configuration except when a new country is added, at which point all of the Open Spaces cities disappear too.

For example, I created a new country (canada) and 'moved' that same city and station from above, which worked under Shetland, over to Canada - and it breaks custom.js so that none of the changes append:

Broken simplified Config:

var country_properties = {
    "canada": {
        name: "Canada",
        name_english: "Canada",
        code: "ca",
        relative_radius: 1,
    },}

var cities_sfigc = [
    {
      "gameName": "sandness",
      "realName": "Sandness",
      "country": "canada",
      "x": "-31367.5",
      "y": "112.867",
      "z": "-76735.5"
    },]

    cities = cities.concat(cities_sfigc);
    cities = cities.concat(cities_open_spaces); //Open Spaces

//New Custom Stations for SFIGC Compatibility

 stations["canada"].push({
            name: "CBC Music 88.3",
            logo: "https://cdn-profiles.tunein.com/s25274/images/logog.png",
            url: "https://playerservices.streamtheworld.com/api/livestream-redirect/CBH_CBC_SC"
        });

I've provided my custom.js and logos if anyone is kind enough to help. In the meantime I'll continue playing around... I feel l like it's close!

stations.zip custom.js.txt

Xuth1 commented 1 year ago

Final update from me, apologies to potentially spam but I wanted to log this final piece of the puzzle:

From further experimentation I've now discovered that I can get a new nation to show up - but only in a very hacky way - if I fill custom.js with the entire list of var country_properties from the primary cities-ets2.js and then enter the new country alphabetically within that list. Effectively replacing the original list wholesale.

By doing this ETS2 Local Radio will now do three things for me that it wasn't before:

  1. It now shows the new city in the new country on the map screen, filterable to the new country.
  2. It correctly detects this new city/country combo as the nearest city when traveling there in game.
  3. Other variables entered into custom.js start working in parallel.

Unfortunately - any new radio stations for the country still fail to show in the list. When you travel there (or expand all) that nation has no entries and it won't play anything. These are custom radio stations that work correctly if the country is changed to any of the existing ones.