Don't agressively select voicepack language automatically, must be now enabled explicitly with _qau suffix
authorWuzzy <Wuzzy2@mail.ru>
Mon, 13 May 2019 22:51:31 +0200
changeset 14936 ba5fd934f49b
parent 14935 632538406573
child 14937 ff4003a90ff8
Don't agressively select voicepack language automatically, must be now enabled explicitly with _qau suffix See code comments for more infos
ChangeLog.txt
QTfrontend/game.cpp
hedgewars/uSound.pas
hedgewars/uTeams.pas
share/hedgewars/Data/Scripts/SimpleMission.lua
--- a/ChangeLog.txt	Mon May 13 21:31:50 2019 +0200
+++ b/ChangeLog.txt	Mon May 13 22:51:31 2019 +0200
@@ -114,6 +114,7 @@
  + sndYoohoo has been split to sndYoohoo and sndKiss
  + Voice files sndPoisonCough and sndPoisonMoan are now optional (fall back to Default voicepack)
  + Tweak some taunts: sndFirstBlood, sndLeaveMeAlone, sndCutItOut
+ * Fix English voicepack selection of team being overwritten when playing in non-English locale
 
 Lua API:
  + New call: SaveMissionVar(varname, value): Save value to mission variable (variable for non-campaign mission)
--- a/QTfrontend/game.cpp	Mon May 13 21:31:50 2019 +0200
+++ b/QTfrontend/game.cpp	Mon May 13 22:51:31 2019 +0200
@@ -156,7 +156,7 @@
     team1.setColor(0);
     team1.setNumHedgehogs(4);
     HWNamegen::teamRandomEverything(team1);
-    team1.setVoicepack("Default");
+    team1.setVoicepack("Default_qau");
     HWProto::addStringListToBuffer(teamscfg,
                                    team1.teamGameConfig(100));
 
@@ -167,7 +167,7 @@
     do
         HWNamegen::teamRandomEverything(team2);
     while(!team2.name().compare(team1.name()) || !team2.hedgehog(0).Hat.compare(team1.hedgehog(0).Hat));
-    team2.setVoicepack("Default");
+    team2.setVoicepack("Default_qau");
     HWProto::addStringListToBuffer(teamscfg,
                                    team2.teamGameConfig(100));
 
--- a/hedgewars/uSound.pas	Mon May 13 21:31:50 2019 +0200
+++ b/hedgewars/uSound.pas	Mon May 13 22:51:31 2019 +0200
@@ -336,12 +336,21 @@
 
 function  AskForVoicepack(name: shortstring): Pointer;
 var i: Longword;
-    langName, path: shortstring;
+    tmp, langName, path: shortstring;
 begin
     i:= 0;
 
-    // Adjust voicepack name if there's a localised version version of the voice
-    if cLanguage <> 'en' then
+    { Adjust for language suffix: Voicepacks can have an optional language suffix.
+    It's an underscore followed by an ISO 639-1 or ISO 639-2 language code.
+    The suffix “_qau” is special, it will enable automatic language selection
+    of this voicepack. For example, if team has set Default_qau as voicepack,
+    and the player language is Russian, the actual voicepack will be Default_ru,
+    provided it can be found on the disk.
+    “qau” is a valid ISO 639-2 language code reserved for local use. }
+    tmp:= Copy(name, Length(name) - 3, 4);
+    if (tmp = '_qau') then
+        name:= Copy(name, 1, Length(name) - 4);
+    if (cLanguage <> 'en') and (tmp = '_qau') then
         begin
         langName:= name+'_'+cLanguage;
         path:= cPathz[ptVoices] + '/' + langName;
@@ -1029,7 +1038,7 @@
     isSEBackup:= isSoundEnabled;
     Volume:= 0;
     SoundTimerTicks:= 0;
-    defVoicepack:= AskForVoicepack('Default');
+    defVoicepack:= AskForVoicepack('Default_qau');
     LastVoiceFailed:= false;
 
     for i:= Low(TSound) to High(TSound) do
--- a/hedgewars/uTeams.pas	Mon May 13 21:31:50 2019 +0200
+++ b/hedgewars/uTeams.pas	Mon May 13 22:51:31 2019 +0200
@@ -852,7 +852,7 @@
         if GameType in [gmtDemo, gmtSave, gmtRecord] then
             CurrentTeam^.ExtDriven:= true;
 
-        CurrentTeam^.voicepack:= AskForVoicepack('Default')
+        CurrentTeam^.voicepack:= AskForVoicepack('Default_qau')
         end
     end
 end;
@@ -874,7 +874,7 @@
         CurrentTeam^.TeamName:= ts;
         CurrentTeam^.PlayerHash:= s;
         loadTeamBinds(ts);
-        CurrentTeam^.voicepack:= AskForVoicepack('Default')
+        CurrentTeam^.voicepack:= AskForVoicepack('Default_qau')
         end
     end
 end;
--- a/share/hedgewars/Data/Scripts/SimpleMission.lua	Mon May 13 21:31:50 2019 +0200
+++ b/share/hedgewars/Data/Scripts/SimpleMission.lua	Mon May 13 22:51:31 2019 +0200
@@ -655,7 +655,7 @@
 			else
 				grave = def(teamData.grave, defaultGraves[math.min(teamID, 8)])
 				fort = def(teamData.fort, "Castle")
-				voice = def(teamData.voice, "Default")
+				voice = def(teamData.voice, "Default_qau")
 				flag = def(teamData.flag, defaultFlags[math.min(teamID, 8)])
 
 				realName = AddTeam(name, -(clanID+1), grave, fort, voice, flag)