Azgaar / Fantasy-Map-Generator

Web application generating interactive and highly customizable maps
https://azgaar.github.io/Fantasy-Map-Generator
Other
4.61k stars 663 forks source link

Bug with special characters and namebases #424

Closed Tazshelby2016 closed 4 years ago

Tazshelby2016 commented 4 years ago

Description

Cyrillic and Japanese unicode characters break the namebase generator preview, forcing all generated strings to be truncated at 2 characters. This may extend to other scripts, but that has not been tested.

Steps to reproduce

Azgaar commented 4 years ago

Thanks for the report, do you know how to fix it?

Tazshelby2016 commented 4 years ago

No.

Tazshelby2016 commented 4 years ago

I've thought of some things that may impact this or help its bug fixing:

Azgaar commented 4 years ago

Yes, it can be done pretty easily.

Tazshelby2016 commented 4 years ago

I haven't programmed in Javascript in over 2 years, so I won't be able to do much programmatically.

Tazshelby2016 commented 4 years ago

It seems to impact some other characters. This list and settings suffers from it, just not all the time. In Hungarian list, replace text with:

Aba,Abádszalók,Abony,Adony,Ajak,Albertirsa,Aldebrő,Alsózsolca,Aszód,Bábolna,Bácsalmás,Baktalórántháza,Balassagyarmat,Balatonalmádi,Balatonboglár,Balatonfüred,Balatonfűzfő,Balkány,Balmazújváros,Barcs,Bátaszék,Bátonyterenye,Battonya,Békés,Berettyóújfalu,Berhida,Besenyőtelek,Biatorbágy,Bicske,Biharkeresztes,Bodajk,Bóly,Bonyhád,Budakalász,Budakeszi,Celldömölk,Csákvár,Csenger,Csongrád,Csorna,Csorvás,Csurgó,Dabas,Dég,Demecser,Derecske,Dévaványa,Devecser,Dombóvár,Dombrád,Dormánd,Dunaföldvár,Dunaharaszti,Dunavarsány,Dunavecse,Edelény,Egerfarmos,Elek,Emőd,Encs,Enying,Ercsi,Fegyvernek,Fehérgyarmat,Felsőzsolca,Fertőszentmiklós,Fonyód,Fót,Füzesabony,Füzesgyarmat,Gárdony,Göd,Gyál,Gyomaendrőd,Gyömrő,Hajdudorog,Hajdúhadház,Hajdúnánás,Hajdúsámson,Hajdúszoboszló,Halásztelek,Harkány,Hatvan,Heves,Hévíz,Ibrány,Isaszeg,Izsák,Jánoshalma,Jánossomorja,Jászapáti,Jászárokszállás,Jászfényszaru,Jászkisér,Kaba,Kalocsa,Kapuvár,Karcag,Kecel,Kemecse,Kenderes,Kerekegyháza,Kerepes,Keszthely,Kisbér,Kiskőrös,Kiskunmajsa,Kistarcsa,Kistelek,Kisújszállás,Kisvárda,Komádi,Komárom,Komló,Kormend,Korosladany,Koszeg,Kozarmisleny,Kunhegyes,Kunszentmarton,Kunszentmiklos,Labatlan,Lajosmizse,Lenti,Letavertes,Letenye,Lorinci,Maglod,Mako,Mandok,Marcali,Martfu,Martonvasar,Mateszalka,Melykut,Mezobereny,Mezocsat,Mezohegyes,Mezokeresztes,Mezokovacshaza,Mezokovesd,Mezotur,Mindszent,Mohacs,Monor,Mor,Morahalom,Nadudvar,Nagyatad,Nagyecsed,Nagyhalasz,Nagykallo,Nagykata,Nagykoros,Nagymaros,Nyekladhaza,Nyergesujfalu,Nyiradony,Nyirbator,Nyirmada,Nyirtelek,Ocsa,Orkeny,Oroszlany,Paks,Pannonhalma,Paszto,Pecel,Pecsvarad,Pilis,Pilisvorosvar,Polgar,Polgardi,Pomaz,Puspokladany,Pusztaszabolcs,Putnok,Racalmas,Rackeve,Rakamaz,Rakoczifalva,Sajoszentpeter,Sandorfalva,Sarbogard,Sarkad,Sarospatak,Sarvar,Satoraljaujhely,Siklos,Simontornya,Solt,Soltvadkert,Sumeg,Szabadszallas,Szarvas,Szazhalombatta,Szecseny,Szeghalom,Szendro,Szentgotthard,Szentlorinc,Szerencs,Szigethalom,Szigetvar,Szikszo,Tab,Tamasi,Tapioszele,Tapolca,Tat,Tata,Teglas,Tet,Tiszacsege,Tiszafoldvar,Tiszafured,Tiszakecske,Tiszalok,Tiszaujvaros,Tiszavasvari,Tokaj,Tokol,Tolna,Tompa,Torokbalint,Torokszentmiklos,Totkomlos,Tura,Turkeve,Ujkigyos,ujszasz,Vamospercs,Varpalota,Vasarosnameny,Vasvar,Vecses,Velence,Veresegyhaz,Verpelet,Veszto,Zahony,Zalaszentgrot,Zirc,Zsambek

Set the settings to: Name: Hungarian Length: 3 20 Double: lnst Multi: 0

There should be no 2 letter words generated.

Tazshelby2016 commented 4 years ago

Mondoland Namesbase Jan13 17-49.txt Rozoia Namesbase Jan11 22-56.txt Ponia Namesbase Jan1 22-15.txt Chouxia Namesbase Dec29 23-35.txt Chouxia Namesbase Dec29 21-10.txt Chouxia Namesbase Dec29 21-05.txt Chouxia Namesbase Dec29 21-00 (1).txt Chouxia Namesbase Dec29 21-00.txt Chouxia Namesbase Dec29 20-57.txt Chouxia Namesbase Dec29 20-48.txt Chouxia Namesbase Dec29 20-22.txt Cevaland Namesbase Apr2 15-56.txt Miveia Namesbase Apr1 21-17.txt Asresland Namesbase Apr1 18-19.txt Asresland Namesbase Apr1 18-18.txt Asresland Namesbase Apr1 18-17 (1).txt Asresland Namesbase Apr1 18-17.txt Asresland Namesbase Apr1 15-30.txt Asresland Namesbase Apr1 15-02.txt Beria Namesbase Mar12 22-34.txt Beria Namesbase Mar12 21-29.txt Ailia Namesbase Mar12 18-11.txt Loria Namesbase Feb17 16-05.txt Pan-Yia Namesbase Feb16 18-19.txt Beia Namesbase Feb16 18-13.txt Moconia Namesbase Jan24 23-12.txt Motia Namesbase Jan18 21-49.txt Févia Namesbase Jan18 18-06.txt Févia Namesbase Jan18 16-55.txt Févia Namesbase Jan18 15-38.txt Févia Namesbase Jan18 15-33.txt Guidgeland Namesbase Jan18 13-05.txt Bamilia Namesbase Jan16 17-48.txt Bamilia Namesbase Jan16 17-41.txt Bamilia Namesbase Jan16 17-11.txt Bamilia Namesbase Jan16 17-07.txt Ninaisia Namesbase Jan15 13-51.txt Thouxyia Namesbase Jan14 21-25.txt Thouxyia Namesbase Jan14 21-23.txt Thouxyia Namesbase Jan14 21-19.txt Vigne At Namesbase Jan14 21-15.txt Vigne At Namesbase Jan14 20-52.txt Vigne At Namesbase Jan14 20-03.txt Mondoland Namesbase Jan13 22-25.txt Mondoland Namesbase Jan13 21-27.txt Mondoland Namesbase Jan13 21-19.txt Mondoland Namesbase Jan13 18-34.txt

Cevaland is the most recent. This namebase suffers from this bad. It's the one all my problems occurs with, and includes the namebase text I had mentioned. Check German, Hungarian, Japanese, and Italian. French and English do not seem to be effected, and the French include special characters.

Tazshelby2016 commented 4 years ago

This may impact your Trello card "Translations: basic support". It seems only French and English can be included in the namebase without problems.

Tazshelby2016 commented 4 years ago

I have a feeling this entire section is the cause. It seems to be a bit destructive, especially with the ae=>e, which definitely causes part of the issue.

    let name = [...w].reduce(function(r, c, i, d) {
      if (c === d[i+1] && !dupl.includes(c)) return r; // duplication is not allowed
      if (!r.length) return c.toUpperCase();
      if (r.slice(-1) === "-" && c === " ") return r; // remove space after hyphen
      if (r.slice(-1) === " ") return r + c.toUpperCase(); // capitalize letter after space
      if (r.slice(-1) === "-") return r + c.toUpperCase(); // capitalize letter after hyphen
      if (c === "a" && d[i+1] === "e") return r; // "ae" => "e"
      if (i+1 < d.length && !vowel(c) && !vowel(d[i-1]) && !vowel(d[i+1])) return r; // remove consonant between 2 consonants
      if (i+2 < d.length && c === d[i+1] && c === d[i+2]) return r; // remove tree same letters in a row
      return r + c;
    }, "");

    // join the word if any part has only 1 letter
    if (name.split(" ").some(part => part.length < 2)) name = name.split(" ").map((p,i) => i ? p.toLowerCase() : p).join("");

    if (name.length < 2) {
      console.error("Name is too short! Random name to be selected");
      name = ra(nameBases[base].b.split(","));
Tazshelby2016 commented 4 years ago

Does the generator depend on vowels? If it does, that will cause this issue when the characters are not vowels.

Azgaar commented 4 years ago

Yes, probably, as for now it works fine with basic Latin only.

Azgaar commented 4 years ago

Fixed in dev, to be deployed together with the next version

Tazshelby2016 commented 4 years ago

Same as #423.

Tazshelby2016 commented 4 years ago

Fixed!