# HG changeset patch # User unc0rr # Date 1231796950 0 # Node ID 9cfa6f23e76782565e6b2d8db03a01ced1295a5e # Parent 34c1d1e3f04e435b16d79221004c2077b6652640 Start voicepacks implementation diff -r 34c1d1e3f04e -r 9cfa6f23e767 hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Mon Jan 12 18:51:37 2009 +0000 +++ b/hedgewars/CCHandlers.inc Mon Jan 12 21:49:10 2009 +0000 @@ -74,7 +74,9 @@ AddTeam(Color); CurrentTeam^.TeamName:= ts; - if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true + if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true; + + CurrentTeam^.voicepack:= AskForVoicepack('Default') end end; @@ -101,6 +103,14 @@ CurrentTeam^.FortName:= s end; +procedure chVoicepack(var s: shortstring); +begin +if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/voicepack"', true); +if s[1]='"' then Delete(s, 1, 1); +if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); +CurrentTeam^.voicepack:= AskForVoicepack(s) +end; + procedure chAddHH(var id: shortstring); var s: shortstring; Gear: PGear; diff -r 34c1d1e3f04e -r 9cfa6f23e767 hedgewars/uConsole.pas --- a/hedgewars/uConsole.pas Mon Jan 12 18:51:37 2009 +0000 +++ b/hedgewars/uConsole.pas Mon Jan 12 21:49:10 2009 +0000 @@ -35,7 +35,7 @@ implementation {$J+} uses uMisc, uStore, Types, uConsts, uGears, uTeams, uIO, uKeys, uWorld, uLand, - uRandom, uAmmos, uTriggers, uStats, uGame, uChat, SDLh; + uRandom, uAmmos, uTriggers, uStats, uGame, uChat, SDLh, uSound; const cLineWidth: LongInt = 0; cLinesCount = 256; @@ -243,6 +243,7 @@ RegisterVariable('gmflags' , vtLongInt, @GameFlags , false); RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false); RegisterVariable('fort' , vtCommand, @chFort , false); +RegisterVariable('voicepack',vtCommand, @chVoicepack , false); RegisterVariable('grave' , vtCommand, @chGrave , false); RegisterVariable('bind' , vtCommand, @chBind , true ); RegisterVariable('addhh' , vtCommand, @chAddHH , false); diff -r 34c1d1e3f04e -r 9cfa6f23e767 hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Mon Jan 12 18:51:37 2009 +0000 +++ b/hedgewars/uConsts.pas Mon Jan 12 21:49:10 2009 +0000 @@ -474,54 +474,53 @@ FileName: String[19]; Path : TPathType; id : PMixChunk; - lastChan: LongInt; end = ( - (FileName: 'grenadeimpact.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndGrenadeImpact - (FileName: 'explosion.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndExplosion - (FileName: 'throwpowerup.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndThrowPowerUp - (FileName: 'throwrelease.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndThrowRelease - (FileName: 'splash.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndSplash - (FileName: 'shotgunreload.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndShotgunReload - (FileName: 'shotgunfire.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndShotgunFire - (FileName: 'graveimpact.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndGraveImpact - (FileName: 'minetick.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndMineTicks - (FileName: 'pickhammer.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndPickhammer - (FileName: 'gun.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndGun - (FileName: 'ufo.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndUFO - (FileName: 'Jump1.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndJump1 - (FileName: 'Jump2.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndJump2 - (FileName: 'Jump3.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndJump3 - (FileName: 'Yessir.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndYesSir - (FileName: 'Laugh.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndLaugh - (FileName: 'Illgetyou.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndIllGetYou - (FileName: 'Incoming.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndIncoming - (FileName: 'Missed.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndMissed - (FileName: 'Stupid.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndStupid - (FileName: 'Firstblood.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndFirstBlood - (FileName: 'Boring.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndBoring - (FileName: 'Byebye.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndByeBye - (FileName: 'Sameteam.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndSameTeam - (FileName: 'Nutter.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndNutter - (FileName:'Reinforcements.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndReinforce - (FileName: 'Traitor.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndTraitor - (FileName:'Youllregretthat.ogg';Path: ptVoices; id: nil; lastChan: 0),// sndRegret - (FileName: 'Enemydown.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndEnemyDown - (FileName: 'Coward.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndCoward - (FileName: 'Hurry.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndHurry - (FileName: 'Watchit.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndWatchIt - (FileName: 'Kamikaze.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndKamikaze - (FileName: 'cake2.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndCake - (FileName: 'Ow1.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndOw1 - (FileName: 'Ow4.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndOw4 - (FileName: 'Firepunch1.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndFirepunch1 - (FileName: 'Firepunch2.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndFirepunch2 - (FileName: 'Firepunch3.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndFirepunch3 - (FileName: 'Firepunch4.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndFirepunch4 - (FileName: 'Firepunch5.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndFirepunch5 - (FileName: 'Firepunch6.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndFirepunch6 - (FileName: 'Melon.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndMelon - (FileName: 'Hellish.ogg'; Path: ptSounds; id: nil; lastChan: 0),// sndHellish - (FileName: 'Yoohoo.ogg'; Path: ptSounds; id: nil; lastChan: 0) // sndYoohoo + (FileName: 'grenadeimpact.ogg'; Path: ptSounds; id: nil),// sndGrenadeImpact + (FileName: 'explosion.ogg'; Path: ptSounds; id: nil),// sndExplosion + (FileName: 'throwpowerup.ogg'; Path: ptSounds; id: nil),// sndThrowPowerUp + (FileName: 'throwrelease.ogg'; Path: ptSounds; id: nil),// sndThrowRelease + (FileName: 'splash.ogg'; Path: ptSounds; id: nil),// sndSplash + (FileName: 'shotgunreload.ogg'; Path: ptSounds; id: nil),// sndShotgunReload + (FileName: 'shotgunfire.ogg'; Path: ptSounds; id: nil),// sndShotgunFire + (FileName: 'graveimpact.ogg'; Path: ptSounds; id: nil),// sndGraveImpact + (FileName: 'minetick.ogg'; Path: ptSounds; id: nil),// sndMineTicks + (FileName: 'pickhammer.ogg'; Path: ptSounds; id: nil),// sndPickhammer + (FileName: 'gun.ogg'; Path: ptSounds; id: nil),// sndGun + (FileName: 'ufo.ogg'; Path: ptSounds; id: nil),// sndUFO + (FileName: 'Jump1.ogg'; Path: ptVoices; id: nil),// sndJump1 + (FileName: 'Jump2.ogg'; Path: ptVoices; id: nil),// sndJump2 + (FileName: 'Jump3.ogg'; Path: ptVoices; id: nil),// sndJump3 + (FileName: 'Yessir.ogg'; Path: ptVoices; id: nil),// sndYesSir + (FileName: 'Laugh.ogg'; Path: ptVoices; id: nil),// sndLaugh + (FileName: 'Illgetyou.ogg'; Path: ptVoices; id: nil),// sndIllGetYou + (FileName: 'Incoming.ogg'; Path: ptVoices; id: nil),// sndIncoming + (FileName: 'Missed.ogg'; Path: ptVoices; id: nil),// sndMissed + (FileName: 'Stupid.ogg'; Path: ptVoices; id: nil),// sndStupid + (FileName: 'Firstblood.ogg'; Path: ptVoices; id: nil),// sndFirstBlood + (FileName: 'Boring.ogg'; Path: ptVoices; id: nil),// sndBoring + (FileName: 'Byebye.ogg'; Path: ptVoices; id: nil),// sndByeBye + (FileName: 'Sameteam.ogg'; Path: ptVoices; id: nil),// sndSameTeam + (FileName: 'Nutter.ogg'; Path: ptVoices; id: nil),// sndNutter + (FileName:'Reinforcements.ogg'; Path: ptVoices; id: nil),// sndReinforce + (FileName: 'Traitor.ogg'; Path: ptVoices; id: nil),// sndTraitor + (FileName:'Youllregretthat.ogg';Path: ptVoices; id: nil),// sndRegret + (FileName: 'Enemydown.ogg'; Path: ptVoices; id: nil),// sndEnemyDown + (FileName: 'Coward.ogg'; Path: ptVoices; id: nil),// sndCoward + (FileName: 'Hurry.ogg'; Path: ptVoices; id: nil),// sndHurry + (FileName: 'Watchit.ogg'; Path: ptVoices; id: nil),// sndWatchIt + (FileName: 'Kamikaze.ogg'; Path: ptVoices; id: nil),// sndKamikaze + (FileName: 'cake2.ogg'; Path: ptSounds; id: nil),// sndCake + (FileName: 'Ow1.ogg'; Path: ptVoices; id: nil),// sndOw1 + (FileName: 'Ow4.ogg'; Path: ptVoices; id: nil),// sndOw4 + (FileName: 'Firepunch1.ogg'; Path: ptSounds; id: nil),// sndFirepunch1 + (FileName: 'Firepunch2.ogg'; Path: ptSounds; id: nil),// sndFirepunch2 + (FileName: 'Firepunch3.ogg'; Path: ptSounds; id: nil),// sndFirepunch3 + (FileName: 'Firepunch4.ogg'; Path: ptSounds; id: nil),// sndFirepunch4 + (FileName: 'Firepunch5.ogg'; Path: ptSounds; id: nil),// sndFirepunch5 + (FileName: 'Firepunch6.ogg'; Path: ptSounds; id: nil),// sndFirepunch6 + (FileName: 'Melon.ogg'; Path: ptSounds; id: nil),// sndMelon + (FileName: 'Hellish.ogg'; Path: ptSounds; id: nil),// sndHellish + (FileName: 'Yoohoo.ogg'; Path: ptSounds; id: nil) // sndYoohoo ); Ammoz: array [TAmmoType] of record diff -r 34c1d1e3f04e -r 9cfa6f23e767 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Mon Jan 12 18:51:37 2009 +0000 +++ b/hedgewars/uSound.pas Mon Jan 12 21:49:10 2009 +0000 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005, 2007 Andrey Korotaev + * Copyright (c) 2005, 2007, 2009 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,12 @@ uses SDLh, uConsts; {$INCLUDE options.inc} +type PVoicepack = ^TVoicepack; + TVoicepack = record + name: shortstring; + chunks: array [TSound] of PMixChunk; + end; + procedure InitSound; procedure ReleaseSound; procedure SoundLoad; @@ -28,6 +34,7 @@ procedure PlayMusic; procedure StopSound(snd: TSound); function ChangeVolume(voldelta: LongInt): LongInt; +function AskForVoicepack(name: shortstring): Pointer; var MusicFN: shortstring = ''; @@ -36,7 +43,23 @@ const chanTPU = 12; var Mus: PMixMusic = nil; - Volume: LongInt; + Volume: LongInt; + lastChan: array [TSound] of LongInt; + voicepacks: array[0..cMaxTeams] of TVoicepack; + +function AskForVoicepack(name: shortstring): Pointer; +var i: Longword; +begin +i:= 0; +while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do + begin + inc(i); + TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) + end; + +voicepacks[i].name:= name; +AskForVoicepack:= @voicepacks[i] +end; procedure InitSound; begin @@ -70,14 +93,16 @@ s: shortstring; begin if not isSoundEnabled then exit; +AskForVoicepack('Default'); + for i:= Low(TSound) to High(TSound) do - begin - s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; - WriteToConsole(msgLoading + s + ' '); - Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); - TryDo(Soundz[i].id <> nil, msgFailed, true); - WriteLnToConsole(msgOK); - end; + begin + s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; + WriteToConsole(msgLoading + s + ' '); + Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); + TryDo(Soundz[i].id <> nil, msgFailed, true); + WriteLnToConsole(msgOK); + end; end; procedure PlaySound(snd: TSound; infinite: boolean); @@ -85,14 +110,14 @@ begin if (not isSoundEnabled) or fastUntilLag then exit; if infinite then loops:= -1 else loops:= 0; -Soundz[snd].lastChan:= Mix_PlayChannelTimed(-1, Soundz[snd].id, loops, -1) +lastChan[snd]:= Mix_PlayChannelTimed(-1, Soundz[snd].id, loops, -1) end; procedure StopSound(snd: TSound); begin if not isSoundEnabled then exit; -if Mix_Playing(Soundz[snd].lastChan) <> 0 then - Mix_HaltChannel(Soundz[snd].lastChan) +if Mix_Playing(lastChan[snd]) <> 0 then + Mix_HaltChannel(lastChan[snd]) end; procedure PlayMusic; @@ -115,7 +140,7 @@ function ChangeVolume(voldelta: LongInt): LongInt; begin if not isSoundEnabled then - exit(0); + exit(0); inc(Volume, voldelta); if Volume < 0 then Volume:= 0; diff -r 34c1d1e3f04e -r 9cfa6f23e767 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Mon Jan 12 18:51:37 2009 +0000 +++ b/hedgewars/uTeams.pas Mon Jan 12 21:49:10 2009 +0000 @@ -18,7 +18,7 @@ unit uTeams; interface -uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, GL; +uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, GL, uSound; {$INCLUDE options.inc} type PHHAmmo = ^THHAmmo; @@ -66,6 +66,7 @@ AttackBar: LongWord; HedgehogsNumber: Longword; hasGone: boolean; + voicepack: PVoicepack; end; TClan = record @@ -97,7 +98,7 @@ procedure TeamGone(s: shortstring); implementation -uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uSound, uChat; +uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uChat; const MaxTeamHealth: LongInt = 0; procedure FreeTeamsList; forward;