ソースを参照

Moved the spell sounds into a json file.

Frank Zago 14 年 前
コミット
3519cca2c9
3 ファイル変更251 行追加84 行削除
  1. 9 19
      client/CMusicHandler.cpp
  2. 242 0
      config/sp_sounds.json
  3. 0 65
      config/sp_sounds.txt

+ 9 - 19
client/CMusicHandler.cpp

@@ -231,32 +231,22 @@ void CSoundHandler::initCreaturesSounds(const std::vector<ConstTransitivePtr< CC
 
 void CSoundHandler::initSpellsSounds(const std::vector< ConstTransitivePtr<CSpell> > &spells)
 {
-	tlog5 << "\t\tReading config/sp_sounds.txt" << std::endl;
-	std::ifstream ifs(DATA_DIR "/config/sp_sounds.txt");
-	std::string line;
+	class JsonNode config(DATA_DIR "/config/sp_sounds.json");
 
-	while(getline(ifs, line))
-	{
-		int spellid;
-		std::string soundfile="";
-		std::istringstream str(line);
-
-		str >> spellid >> soundfile;
-
-		if (str.good() || (str.eof() && soundfile != ""))
-		{
+	if (!config["spell_sounds"].isNull()) {
+		const JsonVector &vector = config["spell_sounds"].Vector();
+	
+		for (JsonVector::const_iterator it = vector.begin(); it!=vector.end(); ++it) {
+			const JsonNode &node = *it;
+			int spellid = node["id"].Float();
 			const CSpell *s = CGI->spellh->spells[spellid];
 
 			if (vstd::contains(spellSounds, s))
-			{
 				tlog1 << "Spell << " << spellid << " already has a sound" << std::endl;
-			}
-			
-			spellSounds[s] = getSoundID(soundfile);
+
+			spellSounds[s] = getSoundID(node["soundfile"].String());
 		}
 	}
-	ifs.close();
-	ifs.clear();
 }
 
 // Plays a sound, and return its channel so we can fade it out later

+ 242 - 0
config/sp_sounds.json

@@ -0,0 +1,242 @@
+// Sounds associated with spells
+// "name" is not currently used in game
+
+{
+	"spell_sounds": 
+	[
+		{
+			"id": 15,
+			"soundfile": "MAGICBLT.wav",
+			"name": "magic arrow"
+		},
+		{
+			"id": 16,
+			"soundfile": "ICERAY.wav",
+			"name": "ice bolt"
+		},
+		{
+			"id": 17,
+			"soundfile": "LIGHTBLT.wav",
+			"name": "lightning bolt"
+		},
+		{
+			"id": 20,
+			"soundfile": "FROSTING.wav",
+			"name": "frost ring"
+		},
+		{
+			"id": 21,
+			"soundfile": "FIREBALL.wav",
+			"name": "fireball"
+		},
+		{
+			"id": 23,
+			"soundfile": "METEOR.wav",
+			"name": "meteor shower"
+		},
+		{
+			"id": 24,
+			"soundfile": "DEATHRIP.wav",
+			"name": "death ripple"
+		},
+		{
+			"id": 26,
+			"soundfile": "ARMGEDN.wav",
+			"name": "armageddon"
+		},
+		{
+			"id": 27,
+			"soundfile": "SHIELD.wav",
+			"name": "shield "
+		},
+		{
+			"id": 28,
+			"soundfile": "AIRSHELD.wav",
+			"name": "air shield"
+		},
+		{
+			"id": 30,
+			"soundfile": "PROTECTA.wav",
+			"name": "protection from air"
+		},
+		{
+			"id": 31,
+			"soundfile": "PROTECTF.wav",
+			"name": "protection from fire"
+		},
+		{
+			"id": 32,
+			"soundfile": "PROTECTW.wav",
+			"name": "protection from water"
+		},
+		{
+			"id": 33,
+			"soundfile": "PROTECTE.wav",
+			"name": "protection from earth"
+		},
+		{
+			"id": 35,
+			"soundfile": "DISPELL.wav",
+			"name": "dispell"
+		},
+		{
+			"id": 41,
+			"soundfile": "BLESS.wav",
+			"name": "bless"
+		},
+		{
+			"id": 42,
+			"soundfile": "CURSE.wav",
+			"name": "curse"
+		},
+		{
+			"id": 43,
+			"soundfile": "BLOODLUS.wav",
+			"name": "bloodlust"
+		},
+		{
+			"id": 44,
+			"soundfile": "PRECISON.wav",
+			"name": "precision"
+		},
+		{
+			"id": 45,
+			"soundfile": "WEAKNESS.wav",
+			"name": "weakness"
+		},
+		{
+			"id": 46,
+			"soundfile": "TUFFSKIN.wav",
+			"name": "stone skin"
+		},
+		{
+			"id": 47,
+			"soundfile": "DISRUPTR.wav",
+			"name": "disrupting ray"
+		},
+		{
+			"id": 48,
+			"soundfile": "PRAYER.wav",
+			"name": "prayer"
+		},
+		{
+			"id": 49,
+			"soundfile": "MIRTH.wav",
+			"name": "mirth"
+		},
+		{
+			"id": 50,
+			"soundfile": "SORROW.wav",
+			"name": "sorrow"
+		},
+		{
+			"id": 51,
+			"soundfile": "FORTUNE.wav",
+			"name": "fortune"
+		},
+		{
+			"id": 52,
+			"soundfile": "MISFORT.wav",
+			"name": "misfortune"
+		},
+		{
+			"id": 53,
+			"soundfile": "HASTE.wav",
+			"name": "haste"
+		},
+		{
+			"id": 54,
+			"soundfile": "MUCKMIRE.wav",
+			"name": "slow"
+		},
+		{
+			"id": 55,
+			"soundfile": "SLAYER.wav",
+			"name": "slayer"
+		},
+		{
+			"id": 56,
+			"soundfile": "FRENZY.wav",
+			"name": "frenzy"
+		},
+		{
+			"id": 61,
+			"soundfile": "FORGET.wav",
+			"name": "forgetfulness"
+		},
+		{
+			"id": 70,
+			"soundfile": "PARALYZE.wav",
+			"name": "stone gaze - not sure"
+		},
+		{
+			"id": 71,
+			"soundfile": "POISON.wav",
+			"name": "poison"
+		},
+		{
+			"id": 72,
+			"soundfile": "BIND.wav",
+			"name": " bind"
+		},
+		{
+			"id": 73,
+			"soundfile": "DISEASE.wav",
+			"name": ""
+		},
+		{
+			"id": 74,
+			"soundfile": "PARALYZE.wav",
+			"name": ""
+		},
+		{
+			"id": 75,
+			"soundfile": "AGE.wav",
+			"name": "aging - already used (?)"
+		},
+
+		{
+			"id": 6,
+			"soundfile": "DEATHCLD.wav",
+			"name": "death cloud"
+		},
+		{
+			"id": 77,
+			"soundfile": "LIGHTBLT.wav",
+			"name": "thunder"
+		},
+		{
+			"id": 78,
+			"soundfile": "DISPELL.wav",
+			"name": "dispell helpful spells"
+		},
+		{
+			"id": 79,
+			"soundfile": "DEATHSTR.wav",
+			"name": "Death Stare"
+		},
+		{
+			"id": 80,
+			"soundfile": "ACID.wav",
+			"name": " Acid breath / defence piercing"
+		}
+	]
+}
+
+// Missing:
+// 18 	# implosion
+// 22 	# inferno
+// 25	# destroy undead
+// BLIND.wav
+// CURE.wav
+// HYPNOTIZ.wav
+// DEATHBLO.wav
+// DRAINLIF.wav
+// DRGNSLAY.wav
+// DISGUISE.wav
+// QUIKSAND.wav
+// FIRESHIE.wav fireshield when cast
+// FIRESHLD.wav fireshield effect
+// ANIMDEAD.wav
+// ANTIMAGK.wav
+

+ 0 - 65
config/sp_sounds.txt

@@ -1,65 +0,0 @@
-# Sounds associated with spells
-# Format is <spell number> <sound file name>
- 
-15 MAGICBLT.wav # magic arrow
-16 ICERAY.wav	# ice bolt
-17 LIGHTBLT.wav # lightning bolt
-#18 	# implosion
-20 FROSTING.wav	# frost ring
-21 FIREBALL.wav	# fireball
-#22 	# inferno
-23 METEOR.wav	# meteor shower
-24 DEATHRIP.wav	# death ripple
-#25		# destroy undead
-26 ARMGEDN.wav	# armageddon
-27 SHIELD.wav	# shield 
-28 AIRSHELD.wav	# air shield
-30 PROTECTA.wav	# protection from air
-31 PROTECTF.wav	# protection from fire
-32 PROTECTW.wav	# protection from water
-33 PROTECTE.wav	# protection from earth
-35 DISPELL.wav	# dispell
-41 BLESS.wav	# bless
-42 CURSE.wav	# curse
-43 BLOODLUS.wav	# bloodlust
-44 PRECISON.wav	# precision
-45 WEAKNESS.wav	# weakness
-46 TUFFSKIN.wav	# stone skin
-47 DISRUPTR.wav	# disrupting ray
-48 PRAYER.wav	# prayer
-49 MIRTH.wav	# mirth
-50 SORROW.wav	# sorrow
-51 FORTUNE.wav	# fortune
-52 MISFORT.wav	# misfortune
-53 HASTE.wav	# haste
-54 MUCKMIRE.wav	# slow
-55 SLAYER.wav	# slayer
-56 FRENZY.wav	# frenzy
-61 FORGET.wav	# forgetfulness
-70 PARALYZE.wav	# stone gaze - not sure
-71 POISON.wav	# poison
-72 BIND.wav		# bind
-73 DISEASE.wav	#
-74 PARALYZE.wav	#
-75 AGE.wav		# aging - already used (?)
-76 DEATHCLD.wav # death cloud
-77 LIGHTBLT.wav # thunder
-78 DISPELL.wav	# dispell helpful spells
-79 DEATHSTR.wav # Death Stare
-80 ACID.wav		# Acid breath / defence piercing
-
-
-
-#BLIND.wav
-#CURE.wav
-#HYPNOTIZ.wav
-#DEATHBLO.wav
-#DRAINLIF.wav
-#DRGNSLAY.wav
-#DISGUISE.wav
-#QUIKSAND.wav
-#FIRESHIE.wav fireshield when cast
-#FIRESHLD.wav fireshield effect
-#ANIMDEAD.wav
-#ANTIMAGK.wav
-