--- a/hedgewars/GSHandlers.inc Fri May 11 19:33:21 2012 +0400
+++ b/hedgewars/GSHandlers.inc Fri May 11 20:01:57 2012 +0400
@@ -88,7 +88,7 @@
if (d > 1) and (not gi^.Invulnerable) and (GetRandom(2) = 0) then
begin
if (CurrentHedgehog^.Gear = gi) then
- PlaySound(sndOops, gi^.Hedgehog^.Team^.voicepack)
+ PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack)
else
begin
@@ -96,9 +96,9 @@
gi^.State := gi^.State or gstLoser;
if d > r div 2 then
- PlaySound(sndNooo, gi^.Hedgehog^.Team^.voicepack)
+ PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack)
else
- PlaySound(sndUhOh, gi^.Hedgehog^.Team^.voicepack);
+ PlaySoundV(sndUhOh, gi^.Hedgehog^.Team^.voicepack);
end;
end;
end;
@@ -779,7 +779,7 @@
AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
if nuw then
begin
Gear^.SoundChannel := LoopSound(sndBeeWater);
@@ -818,7 +818,7 @@
CheckCollision(Gear);
if ((Gear^.State and gstCollision) <> 0) then
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
for i:= 0 to 31 do
begin
@@ -846,7 +846,7 @@
begin
if nuw then
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
CheckGearDrowning(Gear);
end
else
@@ -1181,7 +1181,7 @@
or((Gear^.Message and gmDestroy) <> 0)
or((HHGear^.State and gstHHDriven) =0) then
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
DeleteGear(Gear);
AfterAttack;
doStepHedgehogMoving(HHGear); // for gfInfAttack
@@ -2453,7 +2453,7 @@
Gear^.doStep := @doStepFirePunchWork;
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5);
- PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), HHGear^.Hedgehog^.Team^.voicepack)
+ PlaySoundV(TSound(ord(sndFirePunch1) + GetRandom(6)), HHGear^.Hedgehog^.Team^.voicepack)
end;
////////////////////////////////////////////////////////////////////////////////
@@ -2543,7 +2543,7 @@
// Gear^.Tag, _0, 5000);
end;
Gear^.dX := Gear^.dX + int2hwFloat(30 * Gear^.Tag);
- StopSound(Gear^.SoundChannel, 4000);
+ StopSoundChan(Gear^.SoundChannel, 4000);
end;
if (GameTicks and $3F) = 0 then
@@ -2552,7 +2552,7 @@
if (hwRound(Gear^.X) > (LAND_WIDTH+2048)) or (hwRound(Gear^.X) < -2048) then
begin
// avoid to play forever (is this necessary?)
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
DeleteGear(Gear)
end;
end;
@@ -2921,7 +2921,7 @@
if Gear^.Timer = 0 then
begin
Gear^.Pos := 1;
- PlaySound(sndKamikaze, Gear^.Hedgehog^.Team^.voicepack);
+ PlaySoundV(sndKamikaze, Gear^.Hedgehog^.Team^.voicepack);
Gear^.doStep := @doStepKamikazeWork
end
end;
@@ -3213,7 +3213,7 @@
Gear^.Timer := 0;
inc(Gear^.Pos);
if Gear^.Pos = 5 then
- PlaySound(sndYoohoo, Gear^.Hedgehog^.Team^.voicepack)
+ PlaySoundV(sndYoohoo, Gear^.Hedgehog^.Team^.voicepack)
end;
if (Gear^.Pos = 14) and (RealTicks and $3 = 0) then
@@ -3297,7 +3297,7 @@
AddVisualGear(hwRound(Gear^.X + _20 * Gear^.dX), hwRound(Gear^.Y + _20 * Gear^.dY), vgtDust);
if (CheckGearDrowning(Gear)) then
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
exit
end
end;
@@ -3314,7 +3314,7 @@
or (not CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y), lfIndestructible)) then
begin
//out of time or exited ground
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
if (Gear^.State and gsttmpFlag) <> 0 then
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound)
else
@@ -3325,7 +3325,7 @@
else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) then
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
Gear^.Tag := 1;
Gear^.doStep := @doStepDrill
end;
@@ -3529,7 +3529,7 @@
if ((Gear^.State and gstCollision) <> 0) or CheckGearDrowning(Gear) then
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
StopSound(sndRideOfTheValkyries);
ResumeMusic;
@@ -5054,7 +5054,7 @@
if Length(graves) = 0 then
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
Gear^.Timer := 250;
Gear^.doStep := @doStepIdle;
exit;
@@ -5099,7 +5099,7 @@
hh^.Gear^.dY := _0;
hh^.Gear^.dX := _0;
doStepHedgehogMoving(hh^.Gear);
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
Gear^.Timer := 250;
Gear^.doStep := @doStepIdle;
end
@@ -5125,7 +5125,7 @@
end
else
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
Gear^.Timer := 250;
Gear^.doStep := @doStepIdle;
end
@@ -5282,7 +5282,7 @@
HH:= Gear^.Hedgehog;
if Gear^.Pos = 2 then
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
if (Gear^.Timer = 0) then
begin
if (HH^.Gear <> nil) and (HH^.Gear^.State and gstInvisible = 0) then
@@ -5326,7 +5326,7 @@
Gear^.Pos:= 2;
if (Gear^.Pos = 3) and (Gear^.Power = 0) then
begin
- StopSound(Gear^.SoundChannel);
+ StopSoundChan(Gear^.SoundChannel);
if HH^.GearHidden = nil then
begin
DeleteGear(Gear);
--- a/hedgewars/pas2c.h Fri May 11 19:33:21 2012 +0400
+++ b/hedgewars/pas2c.h Fri May 11 20:01:57 2012 +0400
@@ -63,10 +63,12 @@
#define new(a) __new((void **)&a, sizeof(*(a)))
void __new(void ** p, int size);
-
#define dispose(a) __dispose(a, sizeof(*(a)))
void __dispose(pointer p, int size);
+void * GetMem(int size);
+void FreeMem(void * p, int size);
+
#define FillChar(a, b, c) __FillChar(&(a), b, c)
void __FillChar(pointer p, int size, char fill);
@@ -93,8 +95,13 @@
void reset(int f, int size);
#define BlockRead(a, b, c, d) BlockRead_(a, &(b), c, &(d))
void BlockRead_(int f, void * p, int size, int * sizeRead);
+#define BlockWrite(a, b, c) BlockWrite_(a, &(b), c)
+void BlockWrite_(int f, void * p, int size);
void close(int f);
+bool DirectoryExists(string255 dir);
+bool FileExists(string255 filename);
+
bool odd(int i);
--- a/hedgewars/uGears.pas Fri May 11 19:33:21 2012 +0400
+++ b/hedgewars/uGears.pas Fri May 11 20:01:57 2012 +0400
@@ -193,7 +193,7 @@
StepSoundChannel:= LoopSound(sndSteps)
else if (StepSoundTimer = 0) and (StepSoundChannel > -1) then
begin
- StopSound(StepSoundChannel);
+ StopSoundChan(StepSoundChannel);
StepSoundChannel:= -1
end;
@@ -422,7 +422,7 @@
and (not PlacingHogs)
and (CurrentHedgehog^.Gear <> nil)
and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then
- PlaySound(sndHurry, CurrentTeam^.voicepack);
+ PlaySoundV(sndHurry, CurrentTeam^.voicepack);
if ReadyTimeLeft > 0 then
begin
if (ReadyTimeLeft = 2000) and (LastVoice.snd = sndNone) then
--- a/hedgewars/uGearsHedgehog.pas Fri May 11 19:33:21 2012 +0400
+++ b/hedgewars/uGearsHedgehog.pas Fri May 11 20:01:57 2012 +0400
@@ -308,7 +308,7 @@
end;
amRCPlane: begin
newGear:= AddGear(hwRound(lx), hwRound(ly), gtRCPlane, 0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0);
- newGear^.SoundChannel:= LoopSound(sndRCPlane, nil)
+ newGear^.SoundChannel:= LoopSound(sndRCPlane)
end;
amKamikaze: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0);
@@ -338,7 +338,7 @@
end;
amLaserSight: cLaserSighting:= true;
amVampiric: begin
- PlaySound(sndOw1, Team^.voicepack);
+ PlaySoundV(sndOw1, Team^.voicepack);
cVampiric:= true;
end;
amPiano: begin
@@ -526,7 +526,7 @@
Gear^.Z:= cCurrHHZ;
RemoveGearFromList(Gear);
InsertGearToList(Gear);
- PlaySound(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
+ PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
Gear^.Pos:= 0;
Gear^.Timer:= timertime
end
@@ -558,7 +558,7 @@
Gear^.Z:= cCurrHHZ;
RemoveGearFromList(Gear);
InsertGearToList(Gear);
- PlaySound(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
+ PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
PlaySound(sndWarp);
Gear^.Pos:= 0;
Gear^.Timer:= timertime
@@ -686,7 +686,7 @@
if not cArtillery then
Gear^.dX:= SignAs(_0_15, Gear^.dX);
Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
- PlaySound(sndJump1, Gear^.Hedgehog^.Team^.voicepack);
+ PlaySoundV(sndJump1, Gear^.Hedgehog^.Team^.voicepack);
exit
end;
end;
@@ -699,7 +699,7 @@
Gear^.dY:= -_0_2;
SetLittle(Gear^.dX);
Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
- PlaySound(sndJump3, Gear^.Hedgehog^.Team^.voicepack);
+ PlaySoundV(sndJump3, Gear^.Hedgehog^.Team^.voicepack);
exit
end;
@@ -1027,7 +1027,7 @@
begin
HHGear^.Message:= 0;
if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then
- PlaySound(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack);
+ PlaySoundV(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack);
inc(HHGear^.Timer);
if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then
begin
@@ -1103,7 +1103,7 @@
HHGear^.dY:= -_0_25;
if not cArtillery then
HHGear^.dX:= -SignAs(_0_02, HHGear^.dX);
- PlaySound(sndJump2, Hedgehog^.Team^.voicepack)
+ PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack)
end;
HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump));
--- a/hedgewars/uGearsUtils.pas Fri May 11 19:33:21 2012 +0400
+++ b/hedgewars/uGearsUtils.pas Fri May 11 20:01:57 2012 +0400
@@ -261,21 +261,21 @@
begin
if (Source = dsFall) or (Source = dsExplosion) then
case random(3) of
- 0: PlaySound(sndOoff1, Hedgehog^.Team^.voicepack);
- 1: PlaySound(sndOoff2, Hedgehog^.Team^.voicepack);
- 2: PlaySound(sndOoff3, Hedgehog^.Team^.voicepack);
+ 0: PlaySoundV(sndOoff1, Hedgehog^.Team^.voicepack);
+ 1: PlaySoundV(sndOoff2, Hedgehog^.Team^.voicepack);
+ 2: PlaySoundV(sndOoff3, Hedgehog^.Team^.voicepack);
end
else if (Source = dsPoison) then
case random(2) of
- 0: PlaySound(sndPoisonCough, Hedgehog^.Team^.voicepack);
- 1: PlaySound(sndPoisonMoan, Hedgehog^.Team^.voicepack);
+ 0: PlaySoundV(sndPoisonCough, Hedgehog^.Team^.voicepack);
+ 1: PlaySoundV(sndPoisonMoan, Hedgehog^.Team^.voicepack);
end
else
case random(4) of
- 0: PlaySound(sndOw1, Hedgehog^.Team^.voicepack);
- 1: PlaySound(sndOw2, Hedgehog^.Team^.voicepack);
- 2: PlaySound(sndOw3, Hedgehog^.Team^.voicepack);
- 3: PlaySound(sndOw4, Hedgehog^.Team^.voicepack);
+ 0: PlaySoundV(sndOw1, Hedgehog^.Team^.voicepack);
+ 1: PlaySoundV(sndOw2, Hedgehog^.Team^.voicepack);
+ 2: PlaySoundV(sndOw3, Hedgehog^.Team^.voicepack);
+ 3: PlaySoundV(sndOw4, Hedgehog^.Team^.voicepack);
end
end;
--- a/hedgewars/uLandObjects.pas Fri May 11 19:33:21 2012 +0400
+++ b/hedgewars/uLandObjects.pas Fri May 11 20:01:57 2012 +0400
@@ -551,7 +551,7 @@
SDWaterOpacity:= WaterOpacity
end
else if key = 'music' then
- SetMusic(Trim(s))
+ SetMusicName(Trim(s))
else if key = 'clouds' then
begin
cCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div LAND_WIDTH;
--- a/hedgewars/uSound.pas Fri May 11 19:33:21 2012 +0400
+++ b/hedgewars/uSound.pas Fri May 11 20:01:57 2012 +0400
@@ -47,7 +47,7 @@
// Obvious music commands for music track
procedure SetMusic(enabled: boolean); // Enable/disable music.
-procedure SetMusic(musicname: shortstring); // Enable/disable music and set name of musicfile to play.
+procedure SetMusicName(musicname: shortstring); // Enable/disable music and set name of musicfile to play.
procedure PlayMusic; // Play music from the start.
procedure PauseMusic; // Pause music.
procedure ResumeMusic; // Resume music from pause point.
@@ -62,21 +62,21 @@
// then the sound's playback won't be interrupted if asked to play again.
procedure PlaySound(snd: TSound);
procedure PlaySound(snd: TSound; keepPlaying: boolean);
-procedure PlaySound(snd: TSound; voicepack: PVoicepack);
-procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean);
+procedure PlaySoundV(snd: TSound; voicepack: PVoicepack);
+procedure PlaySoundV(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean);
// Plays sound snd [of voicepack] in a loop, but starts with fadems milliseconds of fade-in.
// Returns sound channel of the looped sound.
function LoopSound(snd: TSound): LongInt;
function LoopSound(snd: TSound; fadems: LongInt): LongInt;
-function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; // WTF?
-function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt;
+function LoopSoundV(snd: TSound; voicepack: PVoicepack): LongInt; // WTF?
+function LoopSoundV(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt;
// Stops the normal/looped sound of the given type/in the given channel
// [with a fade-out effect for fadems milliseconds].
procedure StopSound(snd: TSound);
-procedure StopSound(chn: LongInt);
-procedure StopSound(chn, fadems: LongInt);
+procedure StopSoundChan(chn: LongInt);
+procedure StopSoundChan(chn, fadems: LongInt);
procedure AddVoice(snd: TSound; voicepack: PVoicepack);
procedure PlayNextVoice;
@@ -233,20 +233,20 @@
procedure PlaySound(snd: TSound);
begin
- PlaySound(snd, nil, false);
+ PlaySoundV(snd, nil, false);
end;
procedure PlaySound(snd: TSound; keepPlaying: boolean);
begin
- PlaySound(snd, nil, keepPlaying);
+ PlaySoundV(snd, nil, keepPlaying);
end;
-procedure PlaySound(snd: TSound; voicepack: PVoicepack);
+procedure PlaySoundV(snd: TSound; voicepack: PVoicepack);
begin
- PlaySound(snd, voicepack, false);
+ PlaySoundV(snd, voicepack, false);
end;
-procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean);
+procedure PlaySoundV(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean);
var s:shortstring;
begin
if (not isSoundEnabled) or fastUntilLag then
@@ -325,33 +325,33 @@
LastVoice.snd:= VoiceList[i].snd;
LastVoice.voicepack:= VoiceList[i].voicepack;
VoiceList[i].snd:= sndNone;
- PlaySound(LastVoice.snd, LastVoice.voicepack)
+ PlaySoundV(LastVoice.snd, LastVoice.voicepack)
end
else LastVoice.snd:= sndNone;
end;
function LoopSound(snd: TSound): LongInt;
begin
- LoopSound:= LoopSound(snd, nil)
+ LoopSound:= LoopSoundV(snd, nil)
end;
function LoopSound(snd: TSound; fadems: LongInt): LongInt;
begin
- LoopSound:= LoopSound(snd, nil, fadems)
+ LoopSound:= LoopSoundV(snd, nil, fadems)
end;
-function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt;
+function LoopSoundV(snd: TSound; voicepack: PVoicepack): LongInt;
begin
voicepack:= voicepack; // avoid compiler hint
- LoopSound:= LoopSound(snd, nil, 0)
+ LoopSoundV:= LoopSoundV(snd, nil, 0)
end;
-function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt;
+function LoopSoundV(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt;
var s: shortstring;
begin
if (not isSoundEnabled) or fastUntilLag then
begin
- LoopSound:= -1;
+ LoopSoundV:= -1;
exit
end;
@@ -369,7 +369,7 @@
else
WriteLnToConsole(msgOK)
end;
- LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1)
+ LoopSoundV:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1)
end
else
begin
@@ -384,9 +384,9 @@
WriteLnToConsole(msgOK);
end;
if fadems > 0 then
- LoopSound:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1)
+ LoopSoundV:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1)
else
- LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1);
+ LoopSoundV:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1);
end;
end;
@@ -402,7 +402,7 @@
end;
end;
-procedure StopSound(chn: LongInt);
+procedure StopSoundChan(chn: LongInt);
begin
if not isSoundEnabled then
exit;
@@ -411,7 +411,7 @@
Mix_HaltChannel(chn);
end;
-procedure StopSound(chn, fadems: LongInt);
+procedure StopSoundChan(chn, fadems: LongInt);
begin
if not isSoundEnabled then
exit;
@@ -478,7 +478,7 @@
MusicFN:= '';
end;
-procedure SetMusic(musicname: shortstring);
+procedure SetMusicName(musicname: shortstring);
begin
isMusicEnabled:= not (musicname = '');
MusicFN:= musicname;