--- a/CMakeLists.txt Mon Jun 21 22:18:53 2010 +0200
+++ b/CMakeLists.txt Mon Jun 21 22:45:52 2010 +0200
@@ -184,6 +184,7 @@
add_subdirectory(misc/liblua)
add_subdirectory(hedgewars)
+add_subdirectory(misc/libopenalbridge)
if(NOT BUILD_ENGINE_LIBRARY)
add_subdirectory(bin)
add_subdirectory(QTfrontend)
--- a/gameServer/Actions.hs Mon Jun 21 22:18:53 2010 +0200
+++ b/gameServer/Actions.hs Mon Jun 21 22:45:52 2010 +0200
@@ -23,7 +23,7 @@
| SendServerMessage
| SendServerVars
| MoveToRoom RoomIndex
- | RoomRemoveThisClient B.ByteString
+ | MoveToLobby B.ByteString
| RemoveTeam B.ByteString
| RemoveRoom
| UnreadyRoomClients
@@ -97,7 +97,7 @@
rnc <- gets roomsClients
ri <- clientRoomA
when (ri /= lobbyId) $ do
- processAction $ RoomRemoveThisClient ("quit: " `B.append` msg)
+ processAction $ MoveToLobby ("quit: " `B.append` msg)
return ()
chan <- client's sendChan
@@ -156,23 +156,29 @@
-}
-processAction (MoveToRoom rId) = do
+processAction (MoveToRoom ri) = do
(Just ci) <- gets clientIndex
rnc <- gets roomsClients
liftIO $ do
modifyClient rnc (\cl -> cl{teamsInGame = 0}) ci
- modifyRoom rnc (\r -> r{playersIn = (playersIn r) + 1}) rId
-
- chans <- liftM (map sendChan) $ roomClientsS rId
- liftio movetoroom
+ modifyRoom rnc (\r -> r{playersIn = (playersIn r) + 1}) ri
+
+ liftIO $ moveClientToRoom rnc ri ci
+
+ chans <- liftM (map sendChan) $ roomClientsS ri
clNick <- client's nick
processAction $ AnswerClients chans ["JOINED", clNick]
+processAction (MoveToLobby msg) = do
+ (Just ci) <- gets clientIndex
+ --ri <- clientRoomA
+ rnc <- gets roomsClients
+
+ liftIO $ moveClientToLobby rnc ci
+
{-
-processAction (clID, serverInfo, rnc) (RoomRemoveThisClient msg) = do
(_, _, newClients, newRooms) <-
- if roomID client /= 0 then
if isMaster client then
if (gameinprogress room) && (playersIn room > 1) then
(changeMaster >>= (\state -> foldM processAction state
@@ -187,8 +193,7 @@
(clID, serverInfo, rnc)
[AnswerOthersInRoom ["LEFT", nick client, msg],
RemoveClientTeams clID]
- else -- in lobby
- return (clID, serverInfo, rnc)
+
return (
clID,
--- a/gameServer/HWProtoInRoomState.hs Mon Jun 21 22:18:53 2010 +0200
+++ b/gameServer/HWProtoInRoomState.hs Mon Jun 21 22:45:52 2010 +0200
@@ -6,6 +6,7 @@
import Data.Sequence(Seq, (|>), (><), fromList, empty)
import Data.List
import Maybe
+import qualified Data.ByteString.Char8 as B
--------------------------------------
import CoreTypes
import Actions
@@ -20,12 +21,10 @@
s <- roomOthersChans
return [AnswerClients s ["CHAT", n, msg]]
+handleCmd_inRoom ["PART"] = return [MoveToLobby "part"]
+handleCmd_inRoom ["PART", msg] = return [MoveToLobby $ "part: " `B.append` msg]
+
{-
-handleCmd_inRoom clID clients rooms ["PART"] =
- [RoomRemoveThisClient "part"]
- where
- client = clients IntMap.! clID
-
handleCmd_inRoom clID clients rooms ("CFG" : paramName : paramStrs)
| null paramStrs = [ProtocolError "Empty config entry"]
@@ -194,6 +193,5 @@
where
client = clients IntMap.! clID
engineMsg = toEngineMsg $ 'b' : ((nick client) ++ "(team): " ++ msg ++ "\x20\x20")
-
-handleCmd_inRoom clID _ _ _ = [ProtocolError "Incorrect command (state: in room)"]
--}
\ No newline at end of file
+-}
+handleCmd_inRoom _ = return [ProtocolError "Incorrect command (state: in room)"]
--- a/hedgewars/CMakeLists.txt Mon Jun 21 22:18:53 2010 +0200
+++ b/hedgewars/CMakeLists.txt Mon Jun 21 22:45:52 2010 +0200
@@ -61,7 +61,7 @@
uMisc.pas
uRandom.pas
uScript.pas
- uSHA.pas
+ adler32.pas
uSound.pas
uStats.pas
uStore.pas
@@ -76,6 +76,7 @@
SinTable.inc
options.inc
${CMAKE_CURRENT_BINARY_DIR}/config.inc
+ openalbridge
)
if(BUILD_ENGINE_LIBRARY)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/adler32.pas Mon Jun 21 22:45:52 2010 +0200
@@ -0,0 +1,152 @@
+unit Adler32;
+
+{ZLib - Adler32 checksum function}
+
+
+interface
+
+(*************************************************************************
+
+ DESCRIPTION : ZLib - Adler32 checksum function
+
+ REQUIREMENTS : TP5-7, D1-D7/D9-D10/D12, FPC, VP
+
+ EXTERNAL DATA : ---
+
+ MEMORY USAGE : ---
+
+ DISPLAY MODE : ---
+
+ REFERENCES : RFC 1950 (http://tools.ietf.org/html/rfc1950)
+
+
+ Version Date Author Modification
+ ------- -------- ------- ------------------------------------------
+ 0.10 30.08.03 W.Ehrhardt Initial version based on MD5 layout
+ 2.10 30.08.03 we Common vers., XL versions for Win32
+ 2.20 27.09.03 we FPC/go32v2
+ 2.30 05.10.03 we STD.INC, TP5.0
+ 2.40 10.10.03 we common version, english comments
+ 3.00 01.12.03 we Common version 3.0
+ 3.01 22.05.05 we Adler32UpdateXL (i,n: integer)
+ 3.02 17.12.05 we Force $I- in Adler32File
+ 3.03 07.08.06 we $ifdef BIT32: (const fname: shortstring...)
+ 3.04 10.02.07 we Adler32File: no eof, XL and filemode via $ifdef
+ 3.05 04.07.07 we BASM16: speed-up factor 15
+ 3.06 12.11.08 we uses BTypes, Ptr2Inc and/or Str255
+ 3.07 25.04.09 we updated RFC URL(s)
+ 3.08 19.07.09 we D12 fix: assign with typecast string(fname)
+**************************************************************************)
+
+(*-------------------------------------------------------------------------
+ (C) Copyright 2002-2009 Wolfgang Ehrhardt
+
+ This software is provided 'as-is', without any express or implied warranty.
+ In no event will the authors be held liable for any damages arising from
+ the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software in
+ a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source distribution.
+----------------------------------------------------------------------------*)
+
+(*
+As per the license above, noting that this implementation of adler32 was stripped of everything we didn't need.
+That means no btypes, file loading, and the assembly version disabled.
+*)
+
+procedure Adler32Update(var adler: longint; Msg: pointer; Len: longint);
+
+implementation
+
+(*
+$ifdef BASM16
+
+procedure Adler32Update(var adler: longint; Msg: pointer; Len: longint);
+ //-update Adler32 with Msg data
+const
+ BASE = 65521; // max. prime < 65536
+ NMAX = 5552; // max. n with 255n(n+1)/2 + (n+1)(BASE-1) < 2^32
+type
+ LH = packed record
+ L,H: word;
+ end;
+var
+ s1,s2: longint;
+ n: integer;
+begin
+ s1 := LH(adler).L;
+ s2 := LH(adler).H;
+ while Len > 0 do begin
+ if Len<NMAX then n := Len else n := NMAX;
+ //BASM increases speed from about 52 cyc/byte to about 3.7 cyc/byte
+ asm
+ mov cx,[n]
+ db $66; mov ax,word ptr [s1]
+ db $66; mov di,word ptr [s2]
+ les si,[msg]
+ @@1: db $66, $26, $0f, $b6, $1c // movzx ebx,es:[si]
+ inc si
+ db $66; add ax,bx // inc(s1, pByte(Msg)^)
+ db $66; add di,ax // inc(s2, s1
+ dec cx
+ jnz @@1
+ db $66; sub cx,cx
+ mov cx,BASE
+ db $66; sub dx,dx
+ db $66; div cx
+ db $66; mov word ptr [s1],dx // s1 := s1 mod BASE
+ db $66; sub dx,dx
+ db $66; mov ax,di
+ db $66; div cx
+ db $66; mov word ptr [s2],dx // s2 := s2 mod BASE
+ mov word ptr [msg],si // save offset for next chunk
+ end;
+ dec(len, n);
+ end;
+ LH(adler).L := word(s1);
+ LH(adler).H := word(s2);
+end;
+*)
+
+procedure Adler32Update(var adler: longint; Msg: pointer; Len: longint);
+ {-update Adler32 with Msg data}
+const
+ BASE = 65521; {max. prime < 65536 }
+ NMAX = 3854; {max. n with 255n(n+1)/2 + (n+1)(BASE-1) < 2^31}
+type
+ LH = packed record
+ L,H: word;
+ end;
+var
+ s1,s2: longint;
+ i,n: integer;
+begin
+ s1 := LH(adler).L;
+ s2 := LH(adler).H;
+ while Len > 0 do begin
+ if Len<NMAX then n := Len else n := NMAX;
+ for i:=1 to n do begin
+ inc(s1, pByte(Msg)^);
+ inc(Msg);
+ inc(s2, s1);
+ end;
+ s1 := s1 mod BASE;
+ s2 := s2 mod BASE;
+ dec(len, n);
+ end;
+ LH(adler).L := word(s1);
+ LH(adler).H := word(s2);
+end;
+
+end.
--- a/hedgewars/uConsts.pas Mon Jun 21 22:18:53 2010 +0200
+++ b/hedgewars/uConsts.pas Mon Jun 21 22:45:52 2010 +0200
@@ -249,6 +249,7 @@
{$ENDIF}
// To allow these to layer, going to treat them as masks. The bottom byte is reserved for objects
+// TODO - set lfBasic for all solid land, ensure all uses of the flags can handle multiple flag bits
lfBasic = $8000; // white
lfIndestructible = $4000; // red
lfObject = $2000; // no idea
--- a/hedgewars/uLand.pas Mon Jun 21 22:18:53 2010 +0200
+++ b/hedgewars/uLand.pas Mon Jun 21 22:45:52 2010 +0200
@@ -57,7 +57,7 @@
function LandBackPixel(x, y: LongInt): LongWord;
implementation
-uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, uSHA, uIO, uLandTexture;
+uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, Adler32, uIO, uLandTexture;
operator=(const a, b: direction) c: Boolean;
begin
@@ -70,20 +70,13 @@
end;
procedure LogLandDigest;
-var ctx: TSHA1Context;
- dig: TSHA1Digest;
- s: shortstring;
+var s: shortstring;
+ adler: LongInt;
begin
-{$HINTS OFF}
-SHA1Init(ctx);
-{$HINTS ON}
-SHA1UpdateLongwords(ctx, @Land, sizeof(Land));
-dig:= SHA1Final(ctx);
-s:='M{'+inttostr(dig[0])+':'
- +inttostr(dig[1])+':'
- +inttostr(dig[2])+':'
- +inttostr(dig[3])+':'
- +inttostr(dig[4])+'}';
+adler:= 1;
+Adler32Update(adler, @Land, sizeof(Land));
+s:= 'M'+inttostr(adler);
+
CheckLandDigest(s);
SendIPCRaw(@s[0], Length(s) + 1)
end;
--- a/hedgewars/uLandObjects.pas Mon Jun 21 22:18:53 2010 +0200
+++ b/hedgewars/uLandObjects.pas Mon Jun 21 22:45:52 2010 +0200
@@ -211,27 +211,31 @@
end;
function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean;
-var i, tmpx, tmpy, bx, by: LongInt;
+var tmpx, tmpx2, tmpy, tmpy2, bx, by: LongInt;
bRes: boolean = true;
begin
inc(rect.x, dX);
inc(rect.y, dY);
bx:= rect.x + rect.w;
by:= rect.y + rect.h;
-i:= 0;
{$WARNINGS OFF}
tmpx:= rect.x;
-while (tmpx <= bx) and bRes do
+tmpx2:= bx;
+while (tmpx <= bx - rect.w div 2 - 1) and bRes do
begin
- bRes:= (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color);
- inc(tmpx)
+ bRes:= (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color) and
+ (Land[rect.y, tmpx2] = Color) and (Land[by, tmpx2] = Color);
+ inc(tmpx);
+ dec(tmpx2)
end;
-i:= 0;
-tmpy:= rect.y;
-while (tmpy <= by) and bRes do
+tmpy:= rect.y+1;
+tmpy2:= by-1;
+while (tmpy <= by - rect.h div 2 - 1) and bRes do
begin
- bRes:= (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color);
- inc(tmpy)
+ bRes:= (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color) and
+ (Land[tmpy2, rect.x] = Color) and (Land[tmpy2, bx] = Color);
+ inc(tmpy);
+ dec(tmpy2)
end;
{$WARNINGS ON}
CheckLand:= bRes;
--- a/hedgewars/uSound.pas Mon Jun 21 22:18:53 2010 +0200
+++ b/hedgewars/uSound.pas Mon Jun 21 22:45:52 2010 +0200
@@ -40,8 +40,8 @@
procedure PlaySound(snd: TSound; keepPlaying: boolean);
procedure PlaySound(snd: TSound; voicepack: PVoicepack);
procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean);
-function LoopSound(snd: TSound): LongInt;
-function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt;
+function LoopSound(snd: TSound): LongInt;
+function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt;
procedure PlayMusic;
procedure PauseMusic;
procedure ResumeMusic;
@@ -65,14 +65,14 @@
var i: Longword;
begin
i:= 0;
-while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do
+ while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do
begin
- inc(i);
- TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true)
+ inc(i);
+ TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true)
end;
-voicepacks[i].name:= name;
-AskForVoicepack:= @voicepacks[i]
+ voicepacks[i].name:= name;
+ AskForVoicepack:= @voicepacks[i]
end;
procedure InitSound;
@@ -110,22 +110,22 @@
var i: TSound;
t: Longword;
begin
-for t:= 0 to cMaxTeams do
- if voicepacks[t].name <> '' then
- for i:= Low(TSound) to High(TSound) do
- if voicepacks[t].chunks[i] <> nil then
- Mix_FreeChunk(voicepacks[t].chunks[i]);
+ for t:= 0 to cMaxTeams do
+ if voicepacks[t].name <> '' then
+ for i:= Low(TSound) to High(TSound) do
+ if voicepacks[t].chunks[i] <> nil then
+ Mix_FreeChunk(voicepacks[t].chunks[i]);
-if Mus <> nil then
- Mix_FreeMusic(Mus);
+ if Mus <> nil then
+ Mix_FreeMusic(Mus);
{$IFDEF SDL_MIXER_NEWER}
-// make sure all instances of sdl_mixer are unloaded before continuing
-while Mix_Init(0) <> 0 do
- Mix_Quit();
+ // make sure all instances of sdl_mixer are unloaded before continuing
+ while Mix_Init(0) <> 0 do
+ Mix_Quit();
{$ENDIF}
-Mix_CloseAudio();
+ Mix_CloseAudio();
end;
procedure SoundLoad;
@@ -137,28 +137,28 @@
defVoicepack:= AskForVoicepack('Default');
-for i:= Low(TSound) to High(TSound) do
- if (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then
+ for i:= Low(TSound) to High(TSound) do
+ if (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then
begin
- s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName;
- WriteToConsole(msgLoading + s + ' ');
- defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1);
- TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true);
- WriteLnToConsole(msgOK);
+ s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName;
+ WriteToConsole(msgLoading + s + ' ');
+ defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1);
+ TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true);
+ WriteLnToConsole(msgOK);
end;
-for t:= 0 to cMaxTeams do
- if voicepacks[t].name <> '' then
- for i:= Low(TSound) to High(TSound) do
- if (Soundz[i].Path = ptVoices) and (Soundz[i].FileName <> '') then
+ for t:= 0 to cMaxTeams do
+ if voicepacks[t].name <> '' then
+ for i:= Low(TSound) to High(TSound) do
+ if (Soundz[i].Path = ptVoices) and (Soundz[i].FileName <> '') then
begin
- s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName;
- WriteToConsole(msgLoading + s + ' ');
- voicepacks[t].chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1);
- if voicepacks[t].chunks[i] = nil then
- WriteLnToConsole(msgFailed)
- else
- WriteLnToConsole(msgOK)
+ s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName;
+ WriteToConsole(msgLoading + s + ' ');
+ voicepacks[t].chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1);
+ if voicepacks[t].chunks[i] = nil then
+ WriteLnToConsole(msgFailed)
+ else
+ WriteLnToConsole(msgOK)
end;
end;
@@ -179,15 +179,16 @@
procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean);
begin
-if (not isSoundEnabled) or fastUntilLag then exit;
-
-if keepPlaying and (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then
- exit;
+ if (not isSoundEnabled) or fastUntilLag then
+ exit;
-if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then
- lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], 0, -1)
-else
- lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1)
+ if keepPlaying and (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then
+ exit;
+
+ if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then
+ lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], 0, -1)
+ else
+ lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1)
end;
function LoopSound(snd: TSound): LongInt;
@@ -197,76 +198,79 @@
function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt;
begin
-if (not isSoundEnabled) or fastUntilLag then
+ if (not isSoundEnabled) or fastUntilLag then
begin
- LoopSound:= -1;
- exit
+ LoopSound:= -1;
+ exit
end;
-if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then
- LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1)
-else
- LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1)
+ if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then
+ LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1)
+ else
+ LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1)
end;
procedure StopSound(snd: TSound);
begin
-if not isSoundEnabled then exit;
-if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then
+ if not isSoundEnabled then exit;
+ if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then
begin
- Mix_HaltChannel(lastChan[snd]);
- lastChan[snd]:= -1;
+ Mix_HaltChannel(lastChan[snd]);
+ lastChan[snd]:= -1;
end;
end;
procedure StopSound(chn: LongInt);
begin
-if not isSoundEnabled then exit;
-if (chn <> -1) and (Mix_Playing(chn) <> 0) then Mix_HaltChannel(chn);
+ if not isSoundEnabled then exit;
+
+ if (chn <> -1) and (Mix_Playing(chn) <> 0) then
+ Mix_HaltChannel(chn);
end;
procedure PlayMusic;
var s: shortstring;
begin
-if (not isSoundEnabled)
- or (MusicFN = '')
- or (not isMusicEnabled) then exit;
+ if (not isSoundEnabled) or (MusicFN = '') or (not isMusicEnabled) then
+ exit;
+
+ s:= PathPrefix + '/Music/' + MusicFN;
+ WriteToConsole(msgLoading + s + ' ');
-s:= PathPrefix + '/Music/' + MusicFN;
-WriteToConsole(msgLoading + s + ' ');
+ Mus:= Mix_LoadMUS(Str2PChar(s));
+ TryDo(Mus <> nil, msgFailed, false);
+ WriteLnToConsole(msgOK);
-Mus:= Mix_LoadMUS(Str2PChar(s));
-TryDo(Mus <> nil, msgFailed, false);
-WriteLnToConsole(msgOK);
-
-SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false)
+ SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false)
end;
function ChangeVolume(voldelta: LongInt): LongInt;
begin
-if not isSoundEnabled then
- exit(0);
+ if not isSoundEnabled then
+ exit(0);
-inc(Volume, voldelta);
-if Volume < 0 then Volume:= 0;
-Mix_Volume(-1, Volume);
-Volume:= Mix_Volume(-1, -1);
-if isMusicEnabled then Mix_VolumeMusic(Volume * 4 div 8);
-ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME
+ inc(Volume, voldelta);
+ if Volume < 0 then Volume:= 0;
+ Mix_Volume(-1, Volume);
+ Volume:= Mix_Volume(-1, -1);
+ if isMusicEnabled then Mix_VolumeMusic(Volume * 4 div 8);
+ ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME
end;
procedure PauseMusic;
begin
-if (MusicFN = '') or (not isMusicEnabled) then exit;
+ if (MusicFN = '') or (not isMusicEnabled) then
+ exit;
-Mix_PauseMusic(Mus);
+ Mix_PauseMusic(Mus);
end;
procedure ResumeMusic;
begin
-if (MusicFN = '') or (not isMusicEnabled) then exit;
+ if (MusicFN = '') or (not isMusicEnabled) then
+ exit;
-Mix_ResumeMusic(Mus);
+ Mix_ResumeMusic(Mus);
end;
procedure initModule;
--- a/misc/libopenalbridge/CMakeLists.txt Mon Jun 21 22:18:53 2010 +0200
+++ b/misc/libopenalbridge/CMakeLists.txt Mon Jun 21 22:45:52 2010 +0200
@@ -7,9 +7,7 @@
set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
#list of source files for libraries
-set(openal_src
- openalbridge.c loaders.c wrappers.c errlib.c
-)
+set(openal_src openalbridge.c loaders.c wrappers.c commands.c)
#build a static library for human systems
set (build_type STATIC)
@@ -17,9 +15,7 @@
#visualstudio and windows in general don't like static linking, so we're building the library in shared mode
if(WIN32)
#workaround for visualstudio (wants headers in the source list)
- set(openal_src
- openalbridge.h openalbridge_t.h loaders.h wrappers.h globals.h oggvorbis.h errlib.h ${openal_src}
- )
+ set(openal_src *.h ${openal_src})
#deps for the shared library
link_libraries(${VORBISFILE_LIBRARY})
link_libraries(${VORBIS_LIBRARY})
@@ -39,3 +35,8 @@
#install it in the executable directory
install(TARGETS openalbridge DESTINATION bin)
endif(WIN32)
+
+#type make openalbridge_test to get a small executable test
+add_executable(openalbridge_test "${hedgewars_SOURCE_DIR}/misc/libopenalbridge/tester.c")
+target_link_libraries(openalbridge_test openalbridge ${OPENAL_LIBRARY} ${OGGVORBIS_LIBRARIES})
+
--- a/misc/libopenalbridge/commands.c Mon Jun 21 22:18:53 2010 +0200
+++ b/misc/libopenalbridge/commands.c Mon Jun 21 22:45:52 2010 +0200
@@ -92,8 +92,6 @@
fprintf(stderr,"(Bridge Warning) - failed to play sound %d\n", index);
return;
}
-
- the_sounds[index].stats++;
}
}
--- a/misc/libopenalbridge/openalbridge.c Mon Jun 21 22:18:53 2010 +0200
+++ b/misc/libopenalbridge/openalbridge.c Mon Jun 21 22:45:52 2010 +0200
@@ -34,22 +34,14 @@
// Initialize an OpenAL contex and allocate memory space for data and buffers
// It can be called twice to increase the cache size
-int openal_init (int memorysize) {
+int openal_init (void) {
ALCcontext *context;
ALCdevice *device;
int i;
// reuse old context and resize the existing
if (openal_ready() == AL_TRUE) {
- cache_size += memorysize;
- fprintf(stderr,"(Bridge Info) - already initialized, resizing cache to %d\n", cache_size);
- the_sounds = (al_sound_t *)Realloc (the_sounds, sizeof(al_sound_t) * cache_size);
- for (i = cache_size - memorysize; i < cache_size; i++) {
- the_sounds[i].filename = NULL;
- the_sounds[i].buffer = -1;
- the_sounds[i].source_index = -1;
- the_sounds[i].stats = 0;
- }
+ fprintf(stderr,"(Bridge Info) - already initialized\n");
instances_number++;
return AL_TRUE;
}
@@ -57,12 +49,9 @@
cache_pointer = 0;
instances_number++;
- // set the memory dimentsion and the increment width when reallocating
- if (memorysize <= 0)
- cache_size = 50;
- else
- cache_size = memorysize;
-
+ // initial memory size
+ cache_size = 50;
+
// open hardware device if present
device = alcOpenDevice(NULL);
sources_number = 16;
@@ -110,12 +99,8 @@
}
the_sounds = (al_sound_t *)Malloc (sizeof(al_sound_t) * cache_size);
- for (i = 0; i < cache_size; i++) {
- the_sounds[i].filename = NULL;
- the_sounds[i].buffer = -1;
- the_sounds[i].source_index = -1;
- the_sounds[i].stats = 0;
- }
+ for (i = 0; i < cache_size; i++)
+ the_sounds[i] = new_sound_el();
alGetError();
return AL_TRUE;
@@ -135,15 +120,16 @@
instances_number--;
if (instances_number > 0) {
+ // release memory only when last session ends
return;
}
- //TODO: free other stuff also
- for (i = 0; i < cache_size; i++)
- alDeleteBuffers (1, &the_sounds[i].buffer);
+ for (i = 0; i < cache_size; i++) {
+ openal_unloadfile(i);
+ }
free(the_sounds);
- alSourceStopv (sources_number, Sources);
+ alSourceStopv (sources_number, Sources);
alDeleteSources (sources_number, Sources);
free(Sources);
@@ -174,8 +160,8 @@
ALenum format, error;
ALsizei bitsize, freq;
uint32_t fileformat;
- al_sound_t soundData;
- int len, i;
+ al_sound_t sound_data;
+ int len, i, index = -1;
char *data;
FILE *fp;
@@ -193,16 +179,24 @@
#endif
return i;
}
+ // if we don't have memory available search for a free element
+ if (cache_pointer >= cache_size)
+ if (the_sounds[i].is_used == AL_FALSE)
+ index = i;
}
- if (cache_pointer >= cache_size) {
- fprintf(stderr,"(Bridge ERROR) - Cache size limit reached; consider allocating more space\n", filename);
- return -2;
- }
+ if (index == -1 && cache_pointer >= cache_size) {
+ fprintf(stderr,"(Bridge Info) - No free spots found; doubling cache size\n", filename);
+ cache_size *= 2;
+ the_sounds = (al_sound_t *)Realloc (the_sounds, sizeof(al_sound_t) * cache_size);
+ for (i = cache_size - 50; i < cache_size; i++)
+ the_sounds[i] = new_sound_el();
+ } else
+ index = ++cache_pointer;
+
// detect the file format, as written in the first 4 bytes of the header
fp = Fopen (filename, "rb");
-
if (fp == NULL) {
fprintf(stderr,"(Bridge ERROR) - File %s not loaded\n", filename);
return -3;
@@ -210,7 +204,6 @@
error = fread (&fileformat, sizeof(uint32_t), 1, fp);
fclose (fp);
-
if (error < 0) {
fprintf(stderr,"(Bridge ERROR) - File %s is too short\n", filename);
return -4;
@@ -231,26 +224,26 @@
if (error != 0) {
fprintf(stderr,"(Bridge ERROR) - error loading file %s\n", filename);
- free(data);
+ if(data)
+ free(data);
return -6;
}
- alGenBuffers(1, &soundData.buffer);
- soundData.filename = filename;
- soundData.source_index = -1;
- soundData.stats = 0;
+ // alGenBuffers happens here
+ sound_data = init_sound_el(filename);
if (AL_NO_ERROR != alGetError()) {
- fprintf(stderr,"(Bridge ERROR) - Failed to allocate memory for buffers\n");
+ fprintf(stderr,"(Bridge ERROR) - Failed to allocate memory for buffer %d\n", index);
+ free(data);
return -5;
}
// copy pcm data in one buffer and free it
- alBufferData(soundData.buffer, format, data, bitsize, freq);
+ alBufferData(sound_data.buffer, format, data, bitsize, freq);
free(data);
if (AL_NO_ERROR != alGetError()) {
- fprintf(stderr,"(Bridge ERROR) - Failed to write data to buffers\n");
+ fprintf(stderr,"(Bridge ERROR) - Failed to write data to buffer %d\n", index);
return -8;
}
@@ -260,6 +253,21 @@
fprintf(stderr,"(Bridge Info) - successfully loaded %s\n", filename);
// returns the index of the source you just loaded, increments it and exits
- the_sounds[cache_pointer] = soundData;
- return cache_pointer++;
+ the_sounds[index] = sound_data;
+ return index;
}
+
+
+void openal_unloadfile (uint32_t index) {
+ ALint state;
+
+ if (openal_ready() == AL_TRUE && index < cache_size && the_sounds[index].is_used == AL_TRUE) {
+ alGetSourcei (Sources[the_sounds[index].source_index], AL_SOURCE_STATE, &state);
+ if (state == AL_PLAYING || state == AL_PAUSED)
+ openal_stopsound(index);
+
+ // free memory and
+ alDeleteBuffers (1, &the_sounds[index].buffer);
+ the_sounds[index] = new_sound_el();
+ }
+}
\ No newline at end of file
--- a/misc/libopenalbridge/openalbridge.h Mon Jun 21 22:18:53 2010 +0200
+++ b/misc/libopenalbridge/openalbridge.h Mon Jun 21 22:45:52 2010 +0200
@@ -27,7 +27,7 @@
#endif
// init audio context and allocate memory
- int openal_init (int memorysize);
+ int openal_init (void);
// close audio subsytem and free memory
void openal_close (void);
@@ -38,7 +38,9 @@
// load an audio file into memory and map it to abuffer
int openal_loadfile (const char *filename);
-
+ // unloads data from memory and marks a free spot
+ int openal_unloadfile (unsigned int index)
+
/******* other functions continue in commands.h *******/
#ifdef __CPLUSPLUS
--- a/misc/libopenalbridge/openalbridge_t.h Mon Jun 21 22:18:53 2010 +0200
+++ b/misc/libopenalbridge/openalbridge_t.h Mon Jun 21 22:45:52 2010 +0200
@@ -32,7 +32,7 @@
const char *filename; // name of the sound file
ALuint buffer; // actual sound content
uint32_t source_index; // index of the associated source
- uint32_t stats; // number of times the sound has been played
+ ALboolean is_used; // tells if the element can be overwritten
} al_sound_t;
#pragma pack()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/libopenalbridge/tester.c Mon Jun 21 22:45:52 2010 +0200
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include "openalbridge.h"
+
+int main (int argc, int **argv) {
+
+ openal_init();
+
+ openal_close();
+
+ return 0;
+}
\ No newline at end of file
--- a/misc/libopenalbridge/wrappers.c Mon Jun 21 22:18:53 2010 +0200
+++ b/misc/libopenalbridge/wrappers.c Mon Jun 21 22:45:52 2010 +0200
@@ -44,7 +44,7 @@
}
-FILE *Fopen (const char *fname, char *mode) {
+FILE *Fopen (const char *fname, char *mode) {
FILE *fp;
fp = fopen(fname,mode);
@@ -55,3 +55,24 @@
}
+al_sound_t new_sound_el (void) {
+ al_sound_t sound;
+
+ sound.filename = NULL;
+ sound.buffer = -1;
+ sound.source_index = -1;
+ sound.is_used = AL_FALSE;
+
+ return sound;
+}
+
+al_sound_t init_sound_el (const char *str) {
+ al_sound_t sound;
+
+ sound.filename = str;
+ sound.source_index = -1;
+ sound.is_used = AL_TRUE;
+ alGenBuffers(1, &sound.buffer);
+
+ return sound;
+}
--- a/misc/libopenalbridge/wrappers.h Mon Jun 21 22:18:53 2010 +0200
+++ b/misc/libopenalbridge/wrappers.h Mon Jun 21 22:45:52 2010 +0200
@@ -26,5 +26,7 @@
void *Realloc (void *aptr, size_t nbytes);
FILE *Fopen (const char *fname, char *mode);
void helper_fade (void *tmp);
+al_sound_t new_sound_el (void);
+al_sound_t init_sound_el (const char *str);
#endif /*_OALB_WRAPPERS_H*/
--- a/project_files/HedgewarsMobile/Classes/VoicesViewController.m Mon Jun 21 22:18:53 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/VoicesViewController.m Mon Jun 21 22:45:52 2010 +0200
@@ -26,7 +26,7 @@
[super viewDidLoad];
srandom(time(NULL));
- openal_init(20);
+ openal_init();
voiceBeingPlayed = -1;
// load all the voices names and store them into voiceArray
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Mon Jun 21 22:18:53 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Mon Jun 21 22:45:52 2010 +0200
@@ -125,7 +125,6 @@
61798832114AA34C00BA94A9 /* uLocale.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798804114AA34C00BA94A9 /* uLocale.pas */; };
61798833114AA34C00BA94A9 /* uMisc.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798805114AA34C00BA94A9 /* uMisc.pas */; };
61798834114AA34C00BA94A9 /* uRandom.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798806114AA34C00BA94A9 /* uRandom.pas */; };
- 61798836114AA34C00BA94A9 /* uSHA.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798808114AA34C00BA94A9 /* uSHA.pas */; };
61798837114AA34C00BA94A9 /* uSound.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798809114AA34C00BA94A9 /* uSound.pas */; };
61798838114AA34C00BA94A9 /* uStats.pas in Sources */ = {isa = PBXBuildFile; fileRef = 6179880A114AA34C00BA94A9 /* uStats.pas */; };
61798839114AA34C00BA94A9 /* uStore.pas in Sources */ = {isa = PBXBuildFile; fileRef = 6179880B114AA34C00BA94A9 /* uStore.pas */; };
@@ -148,6 +147,7 @@
61C3255B1179A384001E70B1 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61C3255A1179A384001E70B1 /* OpenAL.framework */; };
61C325901179A732001E70B1 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61C3255A1179A384001E70B1 /* OpenAL.framework */; };
61C325A31179A7AD001E70B1 /* libopenalbridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61C3251D1179A300001E70B1 /* libopenalbridge.a */; };
+ 61E1F4F811D004240016A5AA /* adler32.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61E1F4F711D004240016A5AA /* adler32.pas */; };
922F64900F10F53100DC6EC0 /* libfpc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 928301170F10CAFC00CC5A3C /* libfpc.a */; };
/* End PBXBuildFile section */
@@ -362,7 +362,6 @@
61798804114AA34C00BA94A9 /* uLocale.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uLocale.pas; path = ../../hedgewars/uLocale.pas; sourceTree = SOURCE_ROOT; };
61798805114AA34C00BA94A9 /* uMisc.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uMisc.pas; path = ../../hedgewars/uMisc.pas; sourceTree = SOURCE_ROOT; };
61798806114AA34C00BA94A9 /* uRandom.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uRandom.pas; path = ../../hedgewars/uRandom.pas; sourceTree = SOURCE_ROOT; };
- 61798808114AA34C00BA94A9 /* uSHA.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uSHA.pas; path = ../../hedgewars/uSHA.pas; sourceTree = SOURCE_ROOT; };
61798809114AA34C00BA94A9 /* uSound.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uSound.pas; path = ../../hedgewars/uSound.pas; sourceTree = SOURCE_ROOT; };
6179880A114AA34C00BA94A9 /* uStats.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uStats.pas; path = ../../hedgewars/uStats.pas; sourceTree = SOURCE_ROOT; };
6179880B114AA34C00BA94A9 /* uStore.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uStore.pas; path = ../../hedgewars/uStore.pas; sourceTree = SOURCE_ROOT; };
@@ -383,6 +382,7 @@
61A117FE1168322700359010 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
61C3251D1179A300001E70B1 /* libopenalbridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libopenalbridge.a; sourceTree = BUILT_PRODUCTS_DIR; };
61C3255A1179A384001E70B1 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
+ 61E1F4F711D004240016A5AA /* adler32.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = adler32.pas; path = ../../hedgewars/adler32.pas; sourceTree = SOURCE_ROOT; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
928301170F10CAFC00CC5A3C /* libfpc.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libfpc.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -754,6 +754,7 @@
isa = PBXGroup;
children = (
61798892114AA56300BA94A9 /* inc */,
+ 61E1F4F711D004240016A5AA /* adler32.pas */,
617987E7114AA34C00BA94A9 /* hwengine.pas */,
617987E9114AA34C00BA94A9 /* hwLibrary.pas */,
617987EC114AA34C00BA94A9 /* PascalExports.pas */,
@@ -781,7 +782,6 @@
61798805114AA34C00BA94A9 /* uMisc.pas */,
61798806114AA34C00BA94A9 /* uRandom.pas */,
611F4D4A11B27A9900F9759A /* uScript.pas */,
- 61798808114AA34C00BA94A9 /* uSHA.pas */,
61798809114AA34C00BA94A9 /* uSound.pas */,
6179880A114AA34C00BA94A9 /* uStats.pas */,
6179880B114AA34C00BA94A9 /* uStore.pas */,
@@ -1071,7 +1071,6 @@
61798832114AA34C00BA94A9 /* uLocale.pas in Sources */,
61798833114AA34C00BA94A9 /* uMisc.pas in Sources */,
61798834114AA34C00BA94A9 /* uRandom.pas in Sources */,
- 61798836114AA34C00BA94A9 /* uSHA.pas in Sources */,
61798837114AA34C00BA94A9 /* uSound.pas in Sources */,
61798838114AA34C00BA94A9 /* uStats.pas in Sources */,
61798839114AA34C00BA94A9 /* uStore.pas in Sources */,
@@ -1109,6 +1108,7 @@
6165923211CA9BD500D6E256 /* UIImageExtra.m in Sources */,
6165929E11CA9E2F00D6E256 /* SDL_uikitappdelegate.m in Sources */,
6163EE7E11CC2600001C0453 /* SingleWeaponViewController.m in Sources */,
+ 61E1F4F811D004240016A5AA /* adler32.pas in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- a/share/hedgewars/Data/Locale/CMakeLists.txt Mon Jun 21 22:18:53 2010 +0200
+++ b/share/hedgewars/Data/Locale/CMakeLists.txt Mon Jun 21 22:45:52 2010 +0200
@@ -1,9 +1,12 @@
file(GLOB txttrans2 ??.txt)
file(GLOB txttrans5 ?????.txt)
-file(GLOB qmtrans hedgewars_*.qm)
+
+set(ts_files *.ts)
+QT4_CREATE_TRANSLATION(qm_files ts_files)
+#file(GLOB qmtrans hedgewars_*.qm)
install(FILES
${txttrans2}
${txttrans5}
- ${qmtrans}
+ ${qm_files}
DESTINATION ${SHAREPATH}Data/Locale)
Binary file share/hedgewars/Data/Locale/hedgewars_bg.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_cs.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_de.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_en.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_es.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_fi.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_fr.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_it.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_ja.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_pl.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_pt_BR.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_pt_PT.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_ru.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_sk.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_sv.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_tr_TR.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_uk.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_zh_CN.qm has changed
Binary file share/hedgewars/Data/Locale/hedgewars_zh_TW.qm has changed