# HG changeset patch
# User nemo
# Date 1298847813 18000
# Node ID 98c5b7a0630a841217caf89773289ca949960e8f
# Parent 039771ae3f65ff117dd9c1fa65af56359ddeeec5# Parent ebd3dae634ca4d4e50c91dd789d4b8b712e56e19
merge
diff -r ebd3dae634ca -r 98c5b7a0630a QTfrontend/about.cpp
--- a/QTfrontend/about.cpp Tue Feb 22 18:51:22 2011 +0200
+++ b/QTfrontend/about.cpp Sun Feb 27 18:03:33 2011 -0500
@@ -127,7 +127,7 @@
"Slovak: Jose Riha
"
"Spanish: Carlos Vives <mail@carlosvives.es>
"
"Swedish: Niklas Grahn <raewolusjoon@yaoo.com>, Henrik Rostedt <henrik.rostedt@gmail.com>
"
- "Ukrainian: Eugene V. Lyubimkin <jackyf.devel@gmail.com>, Igor Paliychuk <igor-hkr@mail.ru>, Yevhen Sakara <eresid@gmail.com>"
+ "Ukrainian: Eugene V. Lyubimkin <jackyf.devel@gmail.com>, Igor Paliychuk <mansonigor@gmail.com>, Eugene Sakara <eresid@gmail.com>"
"
"
diff -r ebd3dae634ca -r 98c5b7a0630a QTfrontend/chatwidget.h
--- a/QTfrontend/chatwidget.h Tue Feb 22 18:51:22 2011 +0200
+++ b/QTfrontend/chatwidget.h Sun Feb 27 18:03:33 2011 -0500
@@ -61,6 +61,7 @@
void setShowReady(bool s);
void setShowFollow(bool enabled);
static const char* STYLE;
+ QStringList ignoreList, friendsList;
private:
void loadList(QStringList & list, const QString & file);
@@ -90,7 +91,6 @@
QGridLayout mainLayout;
QTextBrowser* chatText;
QStringList chatStrings;
- QStringList ignoreList, friendsList;
QListWidget* chatNicks;
QLineEdit* chatEditLine;
QAction * acInfo;
diff -r ebd3dae634ca -r 98c5b7a0630a QTfrontend/gameuiconfig.h
--- a/QTfrontend/gameuiconfig.h Tue Feb 22 18:51:22 2011 +0200
+++ b/QTfrontend/gameuiconfig.h Sun Feb 27 18:03:33 2011 -0500
@@ -31,6 +31,7 @@
Q_OBJECT
public:
+ HWForm * Form;
GameUIConfig(HWForm * FormWidgets, const QString & fileName);
QStringList GetTeamsList();
QRect vid_Resolution();
@@ -67,7 +68,6 @@
void SaveOptions();
private:
- HWForm * Form;
quint8 depth;
};
diff -r ebd3dae634ca -r 98c5b7a0630a QTfrontend/newnetclient.cpp
--- a/QTfrontend/newnetclient.cpp Tue Feb 22 18:51:22 2011 +0200
+++ b/QTfrontend/newnetclient.cpp Sun Feb 27 18:03:33 2011 -0500
@@ -29,6 +29,10 @@
#include "gamecfgwidget.h"
#include "teamselect.h"
#include "misc.h"
+/* only to get the ignoreList from the chat widget */
+#include "hwform.h"
+#include "pages.h"
+#include "chatwidget.h"
char delimeter='\n';
@@ -398,8 +402,15 @@
if (isChief)
emit configAsked();
}
- emit nickAdded(lst[i], isChief && (lst[i] != mynick));
- emit chatStringFromNet(tr("%1 *** %2 has joined the room").arg('\x03').arg(lst[i]));
+ if (lst[i] != mynick && isChief && config->Form->ui.pageRoomsList->chatWidget->ignoreList.contains(lst[i], Qt::CaseInsensitive) && !config->Form->ui.pageRoomsList->chatWidget->friendsList.contains(lst[i], Qt::CaseInsensitive))
+ {
+ kickPlayer(lst[i]);
+ }
+ else
+ {
+ emit nickAdded(lst[i], isChief && (lst[i] != mynick));
+ emit chatStringFromNet(tr("%1 *** %2 has joined the room").arg('\x03').arg(lst[i]));
+ }
}
return;
}
diff -r ebd3dae634ca -r 98c5b7a0630a gameServer/Actions.hs
--- a/gameServer/Actions.hs Tue Feb 22 18:51:22 2011 +0200
+++ b/gameServer/Actions.hs Sun Feb 27 18:03:33 2011 -0500
@@ -14,6 +14,7 @@
import Control.DeepSeq
import Data.Unique
import Control.Arrow
+import Control.Exception
-----------------------------
import CoreTypes
import Utils
@@ -53,6 +54,7 @@
| StatsAction
| RestartServer Bool
+
type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action]
instance NFData Action where
@@ -412,5 +414,8 @@
where
st irnc = (length $ allRooms irnc, length $ allClients irnc)
-processAction (RestartServer _) =
- return ()
\ No newline at end of file
+processAction (RestartServer force) = do
+ if force then do
+ throw RestartException
+ else
+ processAction $ ModifyServerInfo (\s -> s{restartPending=True})
diff -r ebd3dae634ca -r 98c5b7a0630a gameServer/CoreTypes.hs
--- a/gameServer/CoreTypes.hs Tue Feb 22 18:51:22 2011 +0200
+++ b/gameServer/CoreTypes.hs Sun Feb 27 18:03:33 2011 -0500
@@ -1,8 +1,7 @@
-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}
module CoreTypes where
import Control.Concurrent
-import Control.Concurrent.STM
import Data.Word
import qualified Data.Map as Map
import Data.Sequence(Seq, empty)
@@ -11,7 +10,9 @@
import Data.Function
import Data.ByteString.Char8 as B
import Data.Unique
-
+import Control.Exception
+import Data.Typeable
+-----------------------
import RoomsAndClients
type ClientChan = Chan [B.ByteString]
@@ -135,7 +136,7 @@
dbLogin :: B.ByteString,
dbPassword :: B.ByteString,
lastLogins :: [(B.ByteString, (UTCTime, B.ByteString))],
- stats :: TMVar StatisticsInfo,
+ restartPending :: Bool,
coreChan :: Chan CoreMessage,
dbQueries :: Chan DBQuery
}
@@ -143,7 +144,7 @@
instance Show ServerInfo where
show _ = "Server Info"
-newServerInfo :: TMVar StatisticsInfo -> Chan CoreMessage -> Chan DBQuery -> ServerInfo
+newServerInfo :: Chan CoreMessage -> Chan DBQuery -> ServerInfo
newServerInfo =
ServerInfo
True
@@ -156,6 +157,7 @@
""
""
[]
+ False
data AccountInfo =
HasAccount B.ByteString Bool
@@ -189,4 +191,11 @@
data Notice =
NickAlreadyInUse
| AdminLeft
- deriving Enum
\ No newline at end of file
+ deriving Enum
+
+data ShutdownException =
+ ShutdownException
+ | RestartException
+ deriving (Show, Typeable)
+
+instance Exception ShutdownException
diff -r ebd3dae634ca -r 98c5b7a0630a gameServer/Opts.hs
--- a/gameServer/Opts.hs Tue Feb 22 18:51:22 2011 +0200
+++ b/gameServer/Opts.hs Sun Feb 27 18:03:33 2011 -0500
@@ -7,10 +7,6 @@
import System.Environment
import System.Console.GetOpt
import Data.Maybe ( fromMaybe )
-#if defined(OFFICIAL_SERVER)
-import qualified Data.ByteString.Char8 as B
-import Network
-#endif
-------------------
import CoreTypes
import Utils
@@ -23,11 +19,6 @@
readListenPort
, readDedicated
-#if defined(OFFICIAL_SERVER)
- , readDbLogin
- , readDbPassword
- readDbHost
-#endif
:: String -> ServerInfo -> ServerInfo
@@ -39,12 +30,6 @@
where
readDed = fromMaybe True (maybeRead str :: Maybe Bool)
-#if defined(OFFICIAL_SERVER)
-readDbLogin str opts = opts{dbLogin = B.pack str}
-readDbPassword str opts = opts{dbPassword = B.pack str}
-readDbHost str opts = opts{dbHost = B.pack str}
-#endif
-
getOpts :: ServerInfo -> IO ServerInfo
getOpts opts = do
args <- getArgs
diff -r ebd3dae634ca -r 98c5b7a0630a gameServer/ServerCore.hs
--- a/gameServer/ServerCore.hs Tue Feb 22 18:51:22 2011 +0200
+++ b/gameServer/ServerCore.hs Sun Feb 27 18:03:33 2011 -0500
@@ -32,7 +32,7 @@
mainLoop :: StateT ServerState IO ()
mainLoop = forever $ do
- get >>= \s -> put $! s
+ -- get >>= \s -> put $! s
si <- gets serverInfo
r <- liftIO $ readChan $ coreChan si
@@ -53,11 +53,6 @@
liftIO $ debugM "Clients" $ "DeleteClient: " ++ show ci
processAction (DeleteClient ci)
- --else
- --do
- --debugM "Clients" "Message from dead client"
- --return (serverInfo, rnc)
-
ClientAccountInfo ci uid info -> do
rnc <- gets roomsClients
exists <- liftIO $ clientExists rnc ci
@@ -90,6 +85,4 @@
rnc <- newRoomsAndClients newRoom
- _ <- forkIO $ evalStateT mainLoop (ServerState Nothing si Set.empty rnc)
-
- forever $ threadDelay 3600000000 -- one hour
+ evalStateT mainLoop (ServerState Nothing si Set.empty rnc)
diff -r ebd3dae634ca -r 98c5b7a0630a gameServer/hedgewars-server.hs
--- a/gameServer/hedgewars-server.hs Tue Feb 22 18:51:22 2011 +0200
+++ b/gameServer/hedgewars-server.hs Sun Feb 27 18:03:33 2011 -0500
@@ -4,18 +4,15 @@
import Network.Socket
import Network.BSD
-import Control.Concurrent.STM
import Control.Concurrent.Chan
-import qualified Control.Exception as Exception
+import qualified Control.Exception as E
import System.Log.Logger
+import System.Process
+import Control.Monad
-----------------------------------
import Opts
import CoreTypes
import ServerCore
-#if defined(OFFICIAL_SERVER)
-import Utils
-#endif
-
#if !defined(mingw32_HOST_OS)
import System.Posix
@@ -27,6 +24,26 @@
updateGlobalLogger "Clients"
(setLevel INFO)
+
+server :: ServerInfo -> IO ()
+server si = do
+ proto <- getProtocolNumber "tcp"
+ E.bracket
+ (socket AF_INET Stream proto)
+ sClose
+ (\sock -> do
+ setSocketOption sock ReuseAddr 1
+ bindSocket sock (SockAddrInet (listenPort si) iNADDR_ANY)
+ listen sock maxListenQueue
+ startServer si sock
+ )
+
+handleRestart :: ShutdownException -> IO ()
+handleRestart ShutdownException = return ()
+handleRestart RestartException = do
+ _ <- createProcess (proc "./hedgewars-server" [])
+ return ()
+
main :: IO ()
main = withSocketsDo $ do
#if !defined(mingw32_HOST_OS)
@@ -36,28 +53,15 @@
setupLoggers
- stats' <- atomically $ newTMVar (StatisticsInfo 0 0)
dbQueriesChan <- newChan
coreChan' <- newChan
- serverInfo' <- getOpts $ newServerInfo stats' coreChan' dbQueriesChan
+ serverInfo' <- getOpts $ newServerInfo coreChan' dbQueriesChan
#if defined(OFFICIAL_SERVER)
- dbHost' <- askFromConsole "DB host: "
- dbLogin' <- askFromConsole "login: "
- dbPassword' <- askFromConsole "password: "
- let serverInfo = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'}
+ [dbHost', dbLogin', dbPassword'] <- liftM read $ readFile "hedgewars-server.ini"
+ let si = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'}
#else
- let serverInfo = serverInfo'
+ let si = serverInfo'
#endif
-
- proto <- getProtocolNumber "tcp"
- Exception.bracket
- (socket AF_INET Stream proto)
- sClose
- (\sock -> do
- setSocketOption sock ReuseAddr 1
- bindSocket sock (SockAddrInet (listenPort serverInfo) iNADDR_ANY)
- listen sock maxListenQueue
- startServer serverInfo sock
- )
+ (server si) `E.catch` handleRestart
diff -r ebd3dae634ca -r 98c5b7a0630a hedgewars/GSHandlers.inc
--- a/hedgewars/GSHandlers.inc Tue Feb 22 18:51:22 2011 +0200
+++ b/hedgewars/GSHandlers.inc Sun Feb 27 18:03:33 2011 -0500
@@ -1692,6 +1692,27 @@
else
if ((GameTicks and $3F) = 25) then
doStepFallingGear(Gear);
+ if (Gear^.Health = 0) then
+ begin
+ if not Gear^.dY.isNegative and (Gear^.dY > _0_2) and TestCollisionYwithGear(Gear, 1) then
+ inc(Gear^.Damage, hwRound(Gear^.dY * _70))
+ else if not Gear^.dX.isNegative and (Gear^.dX > _0_2) and TestCollisionXwithGear(Gear, 1) then
+ inc(Gear^.Damage, hwRound(Gear^.dX * _70))
+ else if Gear^.dY.isNegative and (Gear^.dY < -_0_2) and TestCollisionYwithGear(Gear, -1) then
+ inc(Gear^.Damage, hwRound(Gear^.dY * -_70))
+ else if Gear^.dX.isNegative and (Gear^.dX < -_0_2) and TestCollisionXwithGear(Gear, -1) then
+ inc(Gear^.Damage, hwRound(Gear^.dX * -_70));
+
+ if (Gear^.Damage > random(30)) and ((GameTicks and $FF) = 0) then
+ AddVisualGear(hwRound(Gear^.X) - 4 + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke);
+
+ if (Gear^.Damage > 35) then
+ begin
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
+ DeleteGear(Gear);
+ exit
+ end
+ end;
if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then
if ((Gear^.State and gstAttacking) = 0) then
@@ -1719,6 +1740,8 @@
vgtSmoke);
PlaySound(sndVaporize);
Gear^.Health := 0;
+ Gear^.Damage := 0;
+AddFileLog('initial mine damage:'+IntToStr(Gear^.Damage));
end;
exit
end;
@@ -2307,13 +2330,19 @@
//4: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtWaterMelon, 0, cBombsSpeed *
// Gear^.Tag, _0, 5000);
end;
- Gear^.dX := Gear^.dX + int2hwFloat(30 * Gear^.Tag)
+ Gear^.dX := Gear^.dX + int2hwFloat(30 * Gear^.Tag);
+ StopSound(Gear^.SoundChannel, 4000);
end;
if (GameTicks and $3F) = 0 then
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
- if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear)
+ if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < -1024) then
+ begin
+ // avoid to play forever (is this necessary?)
+ StopSound(Gear^.SoundChannel);
+ DeleteGear(Gear)
+ end;
end;
procedure doStepAirAttack(Gear: PGear);
@@ -2344,6 +2373,8 @@
Gear^.Health := 6;
Gear^.doStep := @doStepAirAttackWork;
+ Gear^.SoundChannel := LoopSound(sndPlane, 4000);
+
end;
////////////////////////////////////////////////////////////////////////////////
diff -r ebd3dae634ca -r 98c5b7a0630a hedgewars/SDLh.pas
--- a/hedgewars/SDLh.pas Tue Feb 22 18:51:22 2011 +0200
+++ b/hedgewars/SDLh.pas Sun Feb 27 18:03:33 2011 -0500
@@ -826,6 +826,9 @@
function Mix_ResumeMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName;
function Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName;
+function Mix_FadeInChannelTimed(channel: LongInt; chunk: PMixChunk; loops: LongInt; fadems: LongInt; ticks: LongInt): LongInt; cdecl; external SDL_MixerLibName;
+function Mix_FadeOutChannel(channel: LongInt; fadems: LongInt): LongInt; cdecl; external SDL_MixerLibName;
+
(* SDL_image *)
function IMG_Init(flags: LongInt): LongInt; cdecl; external SDL_ImageLibName;
procedure IMG_Quit; cdecl; external SDL_ImageLibName;
diff -r ebd3dae634ca -r 98c5b7a0630a hedgewars/uSound.pas
--- a/hedgewars/uSound.pas Tue Feb 22 18:51:22 2011 +0200
+++ b/hedgewars/uSound.pas Sun Feb 27 18:03:33 2011 -0500
@@ -35,13 +35,16 @@
procedure PlaySound(snd: TSound; voicepack: PVoicepack);
procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean);
function LoopSound(snd: TSound): LongInt;
+function LoopSound(snd: TSound; fadems: LongInt): LongInt;
function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt;
+function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt;
procedure PlayMusic;
procedure PauseMusic;
procedure ResumeMusic;
procedure ChangeMusic;
procedure StopSound(snd: TSound);
procedure StopSound(chn: LongInt);
+procedure StopSound(chn, fadems: LongInt);
function ChangeVolume(voldelta: LongInt): LongInt;
function AskForVoicepack(name: shortstring): Pointer;
@@ -219,7 +222,17 @@
LoopSound:= LoopSound(snd, nil)
end;
+function LoopSound(snd: TSound; fadems: LongInt): LongInt;
+begin
+ LoopSound:= LoopSound(snd, nil, fadems)
+end;
+
function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt;
+begin
+ LoopSound:= LoopSound(snd, nil, 0)
+end;
+
+function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt;
var s: shortstring;
begin
if (not isSoundEnabled) or fastUntilLag then
@@ -252,13 +265,17 @@
TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true);
WriteLnToConsole(msgOK);
end;
- LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1);
+ if fadems > 0 then
+ LoopSound:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1)
+ else
+ LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1);
end;
end;
procedure StopSound(snd: TSound);
begin
if not isSoundEnabled then exit;
+
if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then
begin
Mix_HaltChannel(lastChan[snd]);
@@ -274,6 +291,14 @@
Mix_HaltChannel(chn);
end;
+procedure StopSound(chn, fadems: LongInt);
+begin
+ if not isSoundEnabled then exit;
+
+ if (chn <> -1) and (Mix_Playing(chn) <> 0) then
+ Mix_FadeOutChannel(chn, fadems);
+end;
+
procedure PlayMusic;
var s: shortstring;
begin
diff -r ebd3dae634ca -r 98c5b7a0630a hedgewars/uTypes.pas
--- a/hedgewars/uTypes.pas Tue Feb 22 18:51:22 2011 +0200
+++ b/hedgewars/uTypes.pas Sun Feb 27 18:03:33 2011 -0500
@@ -106,7 +106,7 @@
sndPoisonCough, sndPoisonMoan, sndBirdyLay, sndWhistle, sndBeeWater,
sndPiano0, sndPiano1, sndPiano2, sndPiano3, sndPiano4, sndPiano5, sndPiano6, sndPiano7, sndPiano8,
sndSkip, sndSineGun, sndOoff1, sndOoff2, sndOoff3, sndWhack,
- sndComeonthen, sndParachute, sndBump, sndResurrector);
+ sndComeonthen, sndParachute, sndBump, sndResurrector, sndPlane);
TAmmoType = (amNothing, amGrenade, amClusterBomb, amBazooka, amBee, amShotgun, amPickHammer, // 6
amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip, // 13
diff -r ebd3dae634ca -r 98c5b7a0630a hedgewars/uVariables.pas
--- a/hedgewars/uVariables.pas Tue Feb 22 18:51:22 2011 +0200
+++ b/hedgewars/uVariables.pas Sun Feb 27 18:03:33 2011 -0500
@@ -704,7 +704,8 @@
(FileName: 'Comeonthen.ogg'; Path: ptVoices),// sndComeonthen
(FileName: 'parachute.ogg'; Path: ptSounds),// sndParachute
(FileName: 'bump.ogg'; Path: ptSounds),// sndBump
- (FileName: 'hogchant3.ogg'; Path: ptSounds) // sndResurrector
+ (FileName: 'hogchant3.ogg'; Path: ptSounds),// sndResurrector
+ (FileName: 'plane.ogg'; Path: ptSounds) // sndPlane
);
Ammoz: array [TAmmoType] of record
diff -r ebd3dae634ca -r 98c5b7a0630a share/hedgewars/Data/Graphics/Hats/NinjaFull.png
Binary file share/hedgewars/Data/Graphics/Hats/NinjaFull.png has changed
diff -r ebd3dae634ca -r 98c5b7a0630a share/hedgewars/Data/Graphics/Hats/NinjaStraight.png
Binary file share/hedgewars/Data/Graphics/Hats/NinjaStraight.png has changed
diff -r ebd3dae634ca -r 98c5b7a0630a share/hedgewars/Data/Graphics/Hats/NinjaTriangle.png
Binary file share/hedgewars/Data/Graphics/Hats/NinjaTriangle.png has changed
diff -r ebd3dae634ca -r 98c5b7a0630a share/hedgewars/Data/Graphics/Hats/NoHat.png
Binary file share/hedgewars/Data/Graphics/Hats/NoHat.png has changed
diff -r ebd3dae634ca -r 98c5b7a0630a share/hedgewars/Data/Graphics/Hats/darthvader.png
Binary file share/hedgewars/Data/Graphics/Hats/darthvader.png has changed
diff -r ebd3dae634ca -r 98c5b7a0630a share/hedgewars/Data/Graphics/Hats/mickey_ears.png
Binary file share/hedgewars/Data/Graphics/Hats/mickey_ears.png has changed
diff -r ebd3dae634ca -r 98c5b7a0630a share/hedgewars/Data/Graphics/Hats/stormtrooper.png
Binary file share/hedgewars/Data/Graphics/Hats/stormtrooper.png has changed
diff -r ebd3dae634ca -r 98c5b7a0630a share/hedgewars/Data/Locale/hedgewars_uk.ts
--- a/share/hedgewars/Data/Locale/hedgewars_uk.ts Tue Feb 22 18:51:22 2011 +0200
+++ b/share/hedgewars/Data/Locale/hedgewars_uk.ts Sun Feb 27 18:03:33 2011 -0500
@@ -9,7 +9,7 @@