merge and remove QDebug
authornemo
Fri, 25 Mar 2011 20:02:27 -0400
changeset 5051 7b5fa8d3c904
parent 5050 8eb096ee828e (diff)
parent 5029 97c650500991 (current diff)
child 5052 74a81c276d67
merge and remove QDebug
QTfrontend/selectWeapon.cpp
--- a/QTfrontend/drawmapscene.cpp	Fri Mar 25 23:35:04 2011 +0200
+++ b/QTfrontend/drawmapscene.cpp	Fri Mar 25 20:02:27 2011 -0400
@@ -86,7 +86,10 @@
 
 void DrawMapScene::mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent)
 {
-    Q_UNUSED(mouseEvent);
+    QPainterPath path = m_currPath->path();
+    path.lineTo(mouseEvent->scenePos());
+    paths.first().append(mouseEvent->scenePos().toPoint());
+    m_currPath->setPath(path);
 
     simplifyLast();
 
--- a/QTfrontend/hwconsts.cpp.in	Fri Mar 25 23:35:04 2011 +0200
+++ b/QTfrontend/hwconsts.cpp.in	Fri Mar 25 20:02:27 2011 -0400
@@ -38,10 +38,10 @@
 int cMinServerVersion = 0;
 
 QString * cDefaultAmmoStore = new QString(
-        "939192942219912103223511100120100000021111010101112991"
+        "939192942219912103223511100120100000021111010101111991"
         "040504054160065554655446477657666666615551010111541111"
-        "000000000000020550000004000700400000000020000000060000"
-        "131111031211111112311411111111111111121111110111112111"
+        "000000000000020550000004000700400000000022000000060000"
+        "131111031211111112311411111111111111121111110111111111"
         );
 int cAmmoNumber = cDefaultAmmoStore->size() / 4;
 
--- a/QTfrontend/selectWeapon.cpp	Fri Mar 25 23:35:04 2011 +0200
+++ b/QTfrontend/selectWeapon.cpp	Fri Mar 25 20:02:27 2011 -0400
@@ -30,7 +30,6 @@
 #include <QSettings>
 #include <QMessageBox>
 #include <QTabWidget>
-#include <QDebug>
 #include <math.h>
 
 QImage getAmmoImage(int num)
--- a/gameServer/Actions.hs	Fri Mar 25 23:35:04 2011 +0200
+++ b/gameServer/Actions.hs	Fri Mar 25 20:02:27 2011 -0400
@@ -103,7 +103,7 @@
         vars si = [
             "MOTD_NEW", serverMessage si,
             "MOTD_OLD", serverMessageForOldVersions si,
-            "LATEST_PROTO", B.pack . show $ latestReleaseVersion si
+            "LATEST_PROTO", showB $ latestReleaseVersion si
             ]
 
 
@@ -118,7 +118,7 @@
 
 processAction (NoticeMessage n) = do
     chan <- client's sendChan
-    processAction $ AnswerClients [chan] ["NOTICE", B.pack . show . fromEnum $ n]
+    processAction $ AnswerClients [chan] ["NOTICE", showB . fromEnum $ n]
 
 processAction (ByeClient msg) = do
     (Just ci) <- gets clientIndex
@@ -301,7 +301,7 @@
                     })
                 ]
     where
-        rmTeamMsg = toEngineMsg $ B.singleton 'F' `B.append` teamName
+        rmTeamMsg = toEngineMsg $ 'F' `B.cons` teamName
 
 
 processAction (RemoveClientTeams clId) = do
@@ -376,7 +376,7 @@
     modify (\s -> s{clientIndex = Just banId})
     clHost <- client's host
     currentTime <- io getCurrentTime
-    let msg = "Ban for " `B.append` (B.pack . show $ seconds) `B.append` "seconds (" `B.append` reason ` B.append` ")"
+    let msg = B.concat ["Ban for ", B.pack . show $ seconds, "seconds (", reason, ")"]
     mapM_ processAction [
         AddIP2Bans clHost msg (addUTCTime seconds currentTime)
         , KickClient banId
--- a/gameServer/ClientIO.hs	Fri Mar 25 23:35:04 2011 +0200
+++ b/gameServer/ClientIO.hs	Fri Mar 25 20:02:27 2011 -0400
@@ -2,6 +2,7 @@
 module ClientIO where
 
 import qualified Control.Exception as Exception
+import Control.Monad.State
 import Control.Concurrent.Chan
 import Control.Concurrent
 import Control.Monad
@@ -15,23 +16,19 @@
 
 
 pDelim :: B.ByteString
-pDelim = B.pack "\n\n"
+pDelim = "\n\n"
+
+bs2Packets = runState takePacks
 
-bs2Packets :: B.ByteString -> ([[B.ByteString]], B.ByteString)
-bs2Packets = unfoldrE extractPackets
-    where
-    extractPackets :: B.ByteString -> Either B.ByteString ([B.ByteString], B.ByteString)
-    extractPackets buf =
-        let buf' = until (not . B.isPrefixOf pDelim) (B.drop 2) buf in
-            let (bsPacket, bufTail) = B.breakSubstring pDelim buf' in
-                if B.null bufTail then
-                    Left bsPacket
-                    else
-                    if B.null bsPacket then 
-                        Left bufTail
-                        else
-                        Right (B.splitWith (== '\n') bsPacket, bufTail)
-
+takePacks :: State B.ByteString [[B.ByteString]]
+takePacks
+  = do modify (until (not . B.isPrefixOf pDelim) (B.drop 2))
+       packet <- state $ B.breakSubstring pDelim
+       buf <- get
+       if B.null buf then put packet >> return [] else
+        if B.null packet then  return [] else
+         do packets <- takePacks
+            return (B.splitWith (== '\n') packet : packets)
 
 listenLoop :: Socket -> Chan CoreMessage -> ClientIndex -> IO ()
 listenLoop sock chan ci = recieveWithBufferLoop B.empty
@@ -47,7 +44,10 @@
 
 clientRecvLoop :: Socket -> Chan CoreMessage -> ClientIndex -> IO ()
 clientRecvLoop s chan ci =
-        (listenLoop s chan ci >> return "Connection closed") `catch` (return . B.pack . show) >>= clientOff >> remove
+        (listenLoop s chan ci >> return "Connection closed")
+        `Exception.catch` (\(e :: ShutdownThreadException) -> return . B.pack . show $ e)
+        `Exception.catch` (\(e :: Exception.IOException) -> return . B.pack . show $ e)
+        >>= clientOff >> remove
     where
         clientOff msg = writeChan chan $ ClientMessage (ci, ["QUIT", msg])
         remove = writeChan chan $ Remove ci
@@ -59,7 +59,7 @@
     answer <- readChan chan
     Exception.handle
         (\(e :: Exception.IOException) -> unless (isQuit answer) . killReciever $ show e) $
-            sendAll s $ B.unlines answer `B.append` B.singleton '\n'
+            sendAll s $ B.unlines answer `B.snoc` '\n'
 
     if isQuit answer then
         do
--- a/gameServer/HWProtoCore.hs	Fri Mar 25 23:35:04 2011 +0200
+++ b/gameServer/HWProtoCore.hs	Fri Mar 25 20:02:27 2011 -0400
@@ -50,7 +50,7 @@
     let clRoom = room rnc roomId
     let roomMasterSign = if isMaster cl then "@" else ""
     let adminSign = if isAdministrator cl then "@" else ""
-    let roomInfo = if roomId /= lobbyId then roomMasterSign `B.append` "room " `B.append` name clRoom else adminSign `B.append` "lobby"
+    let roomInfo = if roomId /= lobbyId then B.concat [roomMasterSign, "room ", name clRoom] else adminSign `B.append` "lobby"
     let roomStatus = if gameinprogress clRoom then
             if teamsInGame cl > 0 then "(playing)" else "(spectating)"
             else
@@ -61,9 +61,9 @@
         answerClient [
             "INFO",
             nick cl,
-            "[" `B.append` host cl `B.append` "]",
+            B.concat ["[", host cl, "]"],
             protoNumber2ver $ clientProto cl,
-            "[" `B.append` roomInfo `B.append` "]" `B.append` roomStatus
+            B.concat ["[", roomInfo, "]", roomStatus]
             ]
 
 
--- a/gameServer/HWProtoInRoomState.hs	Fri Mar 25 23:35:04 2011 +0200
+++ b/gameServer/HWProtoInRoomState.hs	Fri Mar 25 20:02:27 2011 -0400
@@ -73,9 +73,7 @@
         canAddNumber r = 48 - (sum . map hhnum $ teams r)
         findTeam = find (\t -> tName == teamname t) . teams
         newTeam ci clNick r = TeamInfo ci clNick tName color grave fort voicepack flag dif (newTeamHHNum r) (hhsList hhsInfo)
-        dif = case B.readInt difStr of
-                    Just (i, t) | B.null t -> fromIntegral i
-                    _ -> 0
+        dif = readInt_ difStr
         hhsList [] = []
         hhsList [_] = error "Hedgehogs list with odd elements number"
         hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs
@@ -122,11 +120,9 @@
             []
         else
             [ModifyRoom $ modifyTeam team{hhnum = hhNumber},
-            AnswerClients others ["HH_NUM", teamName, B.pack $ show hhNumber]]
+            AnswerClients others ["HH_NUM", teamName, showB hhNumber]]
     where
-        hhNumber = case B.readInt numberStr of
-                           Just (i, t) | B.null t -> fromIntegral i
-                           _ -> 0
+        hhNumber = readInt_ numberStr
         findTeam = find (\t -> teamName == teamname t) . teams
         canAddNumber = (-) 48 . sum . map hhnum . teams
 
@@ -261,6 +257,6 @@
     chans <- roomSameClanChans
     return [AnswerClients chans ["EM", engineMsg cl]]
     where
-        engineMsg cl = toEngineMsg $ "b" `B.append` nick cl `B.append` "(team): " `B.append` msg `B.append` "\x20\x20"
+        engineMsg cl = toEngineMsg $ B.concat ["b", nick cl, "(team): ", msg, "\x20\x20"]
 
 handleCmd_inRoom _ = return [ProtocolError "Incorrect command (state: in room)"]
--- a/gameServer/HWProtoLobbyState.hs	Fri Mar 25 23:35:04 2011 +0200
+++ b/gameServer/HWProtoLobbyState.hs	Fri Mar 25 20:02:27 2011 -0400
@@ -22,7 +22,7 @@
         toAnswer team =
             [AnswerClients [clChan] $ teamToNet team,
             AnswerClients [clChan] ["TEAM_COLOR", teamname team, teamcolor team],
-            AnswerClients [clChan] ["HH_NUM", teamname team, B.pack . show $ hhnum team]]
+            AnswerClients [clChan] ["HH_NUM", teamname team, showB $ hhnum team]]
 
 handleCmd_lobby :: CmdHandler
 
@@ -169,10 +169,8 @@
     cl <- thisClient
     return [ModifyServerInfo (\si -> si{latestReleaseVersion = readNum}) | isAdministrator cl && readNum > 0]
     where
-        readNum = case B.readInt protoNum of
-                       Just (i, t) | B.null t -> fromIntegral i
-                       _ -> 0
-
+        readNum = readInt_ protoNum
+ 
 handleCmd_lobby ["GET_SERVER_VAR"] = do
     cl <- thisClient
     return [SendServerVars | isAdministrator cl]
--- a/gameServer/HWProtoNEState.hs	Fri Mar 25 23:35:04 2011 +0200
+++ b/gameServer/HWProtoNEState.hs	Fri Mar 25 20:02:27 2011 -0400
@@ -32,7 +32,7 @@
             else
             return $
                 ModifyClient (\c -> c{clientProto = parsedProto}) :
-                AnswerClients [sendChan cl] ["PROTO", B.pack $ show parsedProto] :
+                AnswerClients [sendChan cl] ["PROTO", showB parsedProto] :
                 [CheckRegistered | not . B.null $ nick cl]
     where
         parsedProto = case B.readInt protoNum of
--- a/gameServer/Utils.hs	Fri Mar 25 23:35:04 2011 +0200
+++ b/gameServer/Utils.hs	Fri Mar 25 20:02:27 2011 -0400
@@ -11,6 +11,8 @@
 import qualified Data.List as List
 import Control.Monad
 import qualified Codec.Binary.Base64 as Base64
+import qualified Data.ByteString.Lazy as BL
+import qualified Text.Show.ByteString as BS
 import qualified Data.ByteString.Char8 as B
 import qualified Data.ByteString as BW
 -------------------------------------------------
@@ -34,11 +36,12 @@
         removeLength _ = Nothing
 
 checkNetCmd :: B.ByteString -> (Bool, Bool)
-checkNetCmd = check . liftM B.unpack . fromEngineMsg
+checkNetCmd msg = check decoded
     where
+        decoded = fromEngineMsg msg
         check Nothing = (False, False)
-        check (Just (m:_)) = (m `Set.member` legalMessages, m == '+')
-        check _ = (False, False)
+        check (Just ms) | B.length ms > 0 = let m = B.head ms in (m `Set.member` legalMessages, m == '+')
+                        | otherwise        = (False, False)
         legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sFNpPwtghbc12345" ++ slotMessages
         slotMessages = "\128\129\130\131\132\133\134\135\136\137\138"
 
@@ -56,7 +59,7 @@
         : teamvoicepack team
         : teamflag team
         : teamowner team
-        : (B.pack . show $ difficulty team)
+        : (showB . difficulty $ team)
         : hhsInfo
     where
         hhsInfo = concatMap (\(HedgehogInfo n hat) -> [n, hat]) $ hedgehogs team
@@ -72,9 +75,7 @@
             t : replaceTeam tm ts
 
 illegalName :: B.ByteString -> Bool
-illegalName b = null s || all isSpace s || isSpace (head s) || isSpace (last s)
-    where
-        s = B.unpack b
+illegalName s = B.null s || B.all isSpace s || isSpace (B.head s) || isSpace (B.last s)
 
 protoNumber2ver :: Word16 -> B.ByteString
 protoNumber2ver v = Map.findWithDefault "Unknown" v vermap
@@ -115,5 +116,11 @@
         Right (a, new_b) -> let (a', b') = unfoldrE f new_b in (a : a', b')
         Left new_b       -> ([], new_b)
 
-showB :: Show a => a -> B.ByteString
-showB = B.pack .show
+showB :: (BS.Show a) => a -> B.ByteString
+showB = B.concat . BL.toChunks . BS.show
+
+readInt_ :: (Num a) => B.ByteString -> a
+readInt_ str =
+  case B.readInt str of
+       Just (i, t) | B.null t -> fromIntegral i
+       _                      -> 0 
--- a/gameServer/hedgewars-server.cabal	Fri Mar 25 23:35:04 2011 +0200
+++ b/gameServer/hedgewars-server.cabal	Fri Mar 25 20:02:27 2011 -0400
@@ -20,11 +20,12 @@
     containers,
     array,
     bytestring,
+    bytestring-show,
     network-bytestring,
     network,
     time,
     stm,
-    mtl,
+    mtl >= 2,
     dataenc,
     hslogger,
     process,
--- a/hedgewars/GSHandlers.inc	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/GSHandlers.inc	Fri Mar 25 20:02:27 2011 -0400
@@ -680,13 +680,13 @@
                         if (cReducedQuality and rqBlurryLand) = 0 then
                             begin
                             if gun then
-                                LandPixels[yy + py, xx + px]:= (cExplosionBorderColor and $00FFFFFF) or (p^[px] and $FF000000)
+                                LandPixels[yy + py, xx + px]:= (cExplosionBorderColor and not AMask) or (p^[px] and AMask)
                             else LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], p^[px]);
                             end
                         else
                             begin
                             if gun then
-                                LandPixels[(yy + py) div 2, (xx + px) div 2]:= (cExplosionBorderColor and $00FFFFFF) or (p^[px] and $FF000000)
+                                LandPixels[(yy + py) div 2, (xx + px) div 2]:= (cExplosionBorderColor and not AMask) or (p^[px] and AMask)
                             else LandPixels[(yy + py) div 2, (xx + px) div 2]:= addBgColor(LandPixels[(yy + py) div 2, (xx + px) div 2], p^[px]);
                             end;
                         end
@@ -3679,6 +3679,7 @@
 var 
     iterator, conPortal: PGear;
     s, r, nx, ny, ox, oy, poffs, noffs, pspeed, nspeed: hwFloat;
+    o_x,o_y,r_x,r_y,rr_x,rr_y: LongInt;
     hasdxy, isbullet, iscake: Boolean;
 begin
     doPortalColorSwitch();
@@ -3750,6 +3751,61 @@
            or (iterator^.Y > Gear^.Y + r) then
             continue;
 
+        //Will if fit through?
+        //set r to be portal distance
+        r := Int2hwFloat(Gear^.Radius +1);
+
+        o_x := hwRound(conPortal^.X + conPortal^.dX);
+        o_y := hwRound(conPortal^.Y + conPortal^.dY);
+        r_x := hwRound(conPortal^.X+r*conPortal^.dX);
+        r_y := hwRound(conPortal^.Y+r*conPortal^.dY);
+        rr_x := hwRound(conPortal^.X+r*conPortal^.dX*2);
+        rr_y := hwRound(conPortal^.Y+r*conPortal^.dY*2);
+
+        //check outer edge
+        if (((rr_y and LAND_HEIGHT_MASK) <> 0) or ((rr_x and LAND_WIDTH_MASK) <> 0)) then
+            begin
+            if hasBorder then continue;
+            end
+        else
+            if ((Land[rr_y,rr_x] and $FF00) <> 0) then
+                continue;
+        //check middle bound
+        if (((r_y and LAND_HEIGHT_MASK) <> 0) or ((r_x and LAND_WIDTH_MASK) <> 0)) then
+            begin
+            if hasBorder then continue;
+            end
+        else
+        if ((Land[r_y, r_x] and $FF00) <> 0) then
+                continue;
+        //check inner bound
+        if (((o_y and LAND_HEIGHT_MASK) <> 0) or ((o_x and LAND_WIDTH_MASK) <> 0)) then
+            begin
+            if hasBorder then continue;
+            end
+        else
+        if ((Land[o_y, o_x] and $FF00) <> 0) then
+                continue;
+        //check left bound
+        if (((rr_y and LAND_HEIGHT_MASK) <> 0) or ((o_x and LAND_WIDTH_MASK) <> 0)) then
+            begin
+            if hasBorder then continue;
+            end
+        else
+        if ((Land[rr_y, o_x] and $FF00) <> 0) then
+                continue;
+        //Check Right Bound
+        if (((o_y and LAND_HEIGHT_MASK) <> 0) or ((rr_x and LAND_WIDTH_MASK) <> 0)) then
+            begin
+            if hasBorder then continue;
+            end
+        else
+        if ((Land[o_y, rr_x] and $FF00) <> 0) then
+                continue;
+
+        //Okay reset r in case something uses it
+        r := Int2hwFloat(iterator^.Radius+Gear^.Radius);
+
         hasdxy := (((iterator^.dX.QWordValue <> 0) or (iterator^.dY.QWordValue <> 0))
                     or ((iterator^.State or gstMoving) = 0));
 
--- a/hedgewars/HHHandlers.inc	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/HHHandlers.inc	Fri Mar 25 20:02:27 2011 -0400
@@ -90,7 +90,14 @@
         if i <= cMaxSlotAmmoIndex then ammoidx:= i
         else ammoidx:= -1
         end;
-        if ammoidx >= 0 then CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
+        if ammoidx >= 0 then 
+            begin
+            CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
+            if (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
+                ShowCrosshair:= (Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0
+            else
+                ShowCrosshair:= (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0;
+            end
     end
 end;
 
@@ -382,7 +389,10 @@
             if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and ((GameFlags and gfInfAttack) = 0) then
                 begin
                 if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft;
-                TurnTimeLeft:=round(Ammoz[a].TimeAfterTurn * (cGetAwayTime / 100));
+                TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100;
+                if (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
+                    ShowCrosshair:= (Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0
+                else ShowCrosshair:= false;
                 end;
             if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) then State:= State or gstAttacked;
             if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then ApplyAmmoChanges(CurrentHedgehog^)
--- a/hedgewars/SDLh.pas	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/SDLh.pas	Fri Mar 25 20:02:27 2011 -0400
@@ -93,46 +93,52 @@
 /////////////////////  CONSTANT DEFINITIONS /////////////////////
 /////////////////////////////////////////////////////////////////
 
-    SDL_INIT_TIMER    = $00000001;
-    SDL_INIT_AUDIO    = $00000010;
-    SDL_INIT_VIDEO    = $00000020;
-    SDL_INIT_JOYSTICK = $00000200;
+    // SDL_Init() flags
+    SDL_INIT_TIMER       = $00000001;
+    SDL_INIT_AUDIO       = $00000010;
+    SDL_INIT_VIDEO       = $00000020;
+    SDL_INIT_JOYSTICK    = $00000200;
 {$IFDEF SDL13}
-    SDL_INIT_HAPTIC   = $00001000;
+    SDL_INIT_HAPTIC      = $00001000;
 {$ELSE}
-    SDL_INIT_CDROM    = $00000100;
+    SDL_INIT_CDROM       = $00000100;
+    SDL_INIT_EVENTTHREAD = $01000000;
 {$ENDIF}
     SDL_INIT_NOPARACHUTE = $00100000;
-    SDL_INIT_EVENTTHREAD = $01000000;
     SDL_INIT_EVERYTHING  = $0000FFFF;
 
-    SDL_APPINPUTFOCUS    = 2;
+    SDL_APPINPUTFOCUS    = $02;
     SDL_BUTTON_WHEELUP   = 4;
     SDL_BUTTON_WHEELDOWN = 5;
 
 {$IFDEF SDL13}
     // SDL_Event types
-    SDL_FIRSTEVENT      = 0;
-    SDL_QUITEV          = $100;
-    SDL_WINDOWEVENT     = $200;
-    SDL_SYSWMEVENT      = $201;
-    SDL_KEYDOWN         = $300;
-    SDL_KEYUP           = $301;
-    SDL_TEXTEDITING     = $302;
-    SDL_TEXTINPUT       = $303;
-    SDL_MOUSEMOTION     = $400;
-    SDL_MOUSEBUTTONDOWN = $401;
-    SDL_MOUSEBUTTONUP   = $402;
-    SDL_MOUSEWHEEL      = $403;
-    SDL_PROXIMITYIN     = $500;
-    SDL_PROXIMITYOUT    = $501;
-    SDL_JOYAXISMOTION   = $600;
-    SDL_JOYBALLMOTION   = $601;
-    SDL_JOYHATMOTION    = $602;
-    SDL_JOYBUTTONDOWN   = $603;
-    SDL_JOYBUTTONUP     = $604;
-    SDL_USEREVENT       = $8000;
-    SDL_LASTEVENT       = $FFFF;
+    SDL_FIRSTEVENT        = 0;
+    SDL_QUITEV            = $100;
+    SDL_WINDOWEVENT       = $200;
+    SDL_SYSWMEVENT        = $201;
+    SDL_KEYDOWN           = $300;
+    SDL_KEYUP             = $301;
+    SDL_TEXTEDITING       = $302;
+    SDL_TEXTINPUT         = $303;
+    SDL_MOUSEMOTION       = $400;
+    SDL_MOUSEBUTTONDOWN   = $401;
+    SDL_MOUSEBUTTONUP     = $402;
+    SDL_MOUSEWHEEL        = $403;
+    SDL_INPUTMOTION       = $500;
+    SDL_INPUTBUTTONDOWN   = $501;
+    SDL_INPUTBUTTONUP     = $502;
+    SDL_INPUTWHEEL        = $503;
+    SDL_INPUTPROXIMITYIN  = $504;
+    SDL_INPUTPROXIMITYOUT = $505;
+    SDL_JOYAXISMOTION     = $600;
+    SDL_JOYBALLMOTION     = $601;
+    SDL_JOYHATMOTION      = $602;
+    SDL_JOYBUTTONDOWN     = $603;
+    SDL_JOYBUTTONUP       = $604;
+    //TODO: implement otheer event types
+    SDL_USEREVENT         = $8000;
+    SDL_LASTEVENT         = $FFFF;
 
     // SDL_Surface flags
     SDL_SWSURFACE   = $00000000;  //*< Not used */
@@ -153,15 +159,20 @@
     SDL_RLEACCELOK  = $08000000;  //*< Not used */
     SDL_HWACCEL     = $08000000;  //*< Not used */
 
+    // SDL_Renderer flags
+    SDL_RENDERER_SOFTWARE     = $00000001;     //*< The renderer is a software fallback */
+    SDL_RENDERER_ACCELERATED  = $00000002;     //*< The renderer uses hardware acceleration */
+    SDL_RENDERER_PRESENTVSYNC = $00000004;
+
     // SDL_WindowFlags (enum)
     SDL_WINDOW_FULLSCREEN    = $00000001;      //*< fullscreen window, implies borderless */
     SDL_WINDOW_OPENGL        = $00000002;      //*< window usable with OpenGL context */
     SDL_WINDOW_SHOWN         = $00000004;      //*< window is visible */
-//  SDL_WINDOW_HIDDEN        = $00000008;      //*< window is not visible */
-    SDL_WINDOW_BORDERLESS    = $00000008;      //*< no window decoration */
-    SDL_WINDOW_RESIZABLE     = $00000010;      //*< window can be resized */
-    SDL_WINDOW_MINIMIZED     = $00000020;      //*< window is minimized */
-    SDL_WINDOW_MAXIMIZED     = $00000040;      //*< window is maximized */
+    SDL_WINDOW_HIDDEN        = $00000008;      //*< window is not visible */
+    SDL_WINDOW_BORDERLESS    = $00000010;      //*< no window decoration */
+    SDL_WINDOW_RESIZABLE     = $00000020;      //*< window can be resized */
+    SDL_WINDOW_MINIMIZED     = $00000040;      //*< window is minimized */
+    SDL_WINDOW_MAXIMIZED     = $00000080;      //*< window is maximized */
     SDL_WINDOW_INPUT_GRABBED = $00000100;      //*< window has grabbed input focus */
     SDL_WINDOW_INPUT_FOCUS   = $00000200;      //*< window has input focus */
     SDL_WINDOW_MOUSE_FOCUS   = $00000400;      //*< window has mouse focus */
@@ -176,17 +187,15 @@
     SDL_WINDOWEVENT_EXPOSED      = 3;    //*< Window has been exposed and should be redrawn
     SDL_WINDOWEVENT_MOVED        = 4;    //*< Window has been moved to data1, data2
     SDL_WINDOWEVENT_RESIZED      = 5;    //*< Window size changed to data1xdata2
-    SDL_WINDOWEVENT_MINIMIZED    = 6;    //*< Window has been minimized
-    SDL_WINDOWEVENT_MAXIMIZED    = 7;    //*< Window has been maximized
-    SDL_WINDOWEVENT_RESTORED     = 8;    //*< Window has been restored to normal size and position
-    SDL_WINDOWEVENT_ENTER        = 9;    //*< Window has gained mouse focus
-    SDL_WINDOWEVENT_LEAVE        = 10;   //*< Window has lost mouse focus
-    SDL_WINDOWEVENT_FOCUS_GAINED = 11;   //*< Window has gained keyboard focus
-    SDL_WINDOWEVENT_FOCUS_LOST   = 12;   //*< Window has lost keyboard focus
-    SDL_WINDOWEVENT_CLOSE        = 13;   //*< The window manager requests that the window be closed */
-
-    SDL_RENDERER_ACCELERATED  = $00000001;   //*< The renderer uses hardware acceleration
-    SDL_RENDERER_PRESENTVSYNC = $00000002;   //*< Present is synchronized with the refresh rate
+    SDL_WINDOWEVENT_SIZE_CHANGED = 6;    //*< The window size has changed, [...] */
+    SDL_WINDOWEVENT_MINIMIZED    = 7;    //*< Window has been minimized
+    SDL_WINDOWEVENT_MAXIMIZED    = 8;    //*< Window has been maximized
+    SDL_WINDOWEVENT_RESTORED     = 9;    //*< Window has been restored to normal size and position
+    SDL_WINDOWEVENT_ENTER        = 10;   //*< Window has gained mouse focus
+    SDL_WINDOWEVENT_LEAVE        = 11;   //*< Window has lost mouse focus
+    SDL_WINDOWEVENT_FOCUS_GAINED = 12;   //*< Window has gained keyboard focus
+    SDL_WINDOWEVENT_FOCUS_LOST   = 13;   //*< Window has lost keyboard focus
+    SDL_WINDOWEVENT_CLOSE        = 14;   //*< The window manager requests that the window be closed */
 {$ELSE}
     // SDL_Event types
     SDL_NOEVENT         = 0;
@@ -226,11 +235,19 @@
     GMask = $0000FF00;
     BMask = $00FF0000;
     AMask = $FF000000;
+    RShift = 0;
+    GShift = 8;
+    BShift = 16;
+    AShift = 24;
 {$ELSE}
     RMask = $FF000000;
     GMask = $00FF0000;
     BMask = $0000FF00;
     AMask = $000000FF;
+    RShift = 24;
+    GShift = 16;
+    BShift = 8;
+    AShift = 0;
 {$ENDIF}
 
     {* SDL_mixer *}
@@ -266,6 +283,12 @@
 /////////////////////////////////////////////////////////////////
 
 type
+{$IFDEF SDL13}
+    PSDL_Window   = Pointer;
+    PSDL_Renderer = Pointer;
+    PSDL_Texture  = Pointer;
+{$ENDIF}
+
     PSDL_Rect = ^TSDL_Rect;
     TSDL_Rect = record
 {$IFDEF SDL13}
@@ -277,15 +300,32 @@
         end;
 
     TPoint = record
-        X: LongInt;
-        Y: LongInt;
+        X, Y: LongInt;
         end;
 
     PSDL_PixelFormat = ^TSDL_PixelFormat;
     TSDL_PixelFormat = record
 {$IFDEF SDL13}
         format: Longword;
-{$ENDIF}
+        palette: Pointer;   // actually it is a PSDL_Palette
+        BitsPerPixel : Byte;
+        BytesPerPixel: Byte;
+        padding: array[0..1] of Byte;
+        RMask : Longword;
+        GMask : Longword;
+        BMask : Longword;
+        AMask : Longword;
+        Rloss : Byte;
+        Gloss : Byte;
+        Bloss : Byte;
+        Aloss : Byte;
+        Rshift: Byte;
+        Gshift: Byte;
+        Bshift: Byte;
+        Ashift: Byte;
+        refcount: LongInt;
+        next: PSDL_PixelFormat;
+{$ELSE}
         palette: Pointer;
         BitsPerPixel : Byte;
         BytesPerPixel: Byte;
@@ -301,10 +341,6 @@
         GMask : Longword;
         BMask : Longword;
         AMask : Longword;
-{$IFDEF SDL13}
-        refcount: LongInt;
-        next: Pointer;
-{$ELSE}
         colorkey: Longword;
         alpha: Byte;
 {$ENDIF}
@@ -319,18 +355,25 @@
         pitch : Word;
         pixels: Pointer;
         offset: LongInt;
+{$IFDEF SDL13}
+        userdata: Pointer;
+        locked: LongInt;
+        lock_data: Pointer;
+        clip_rect: TSDL_Rect;
+        map: Pointer;
+        refcount: LongInt;
+{$ENDIF}
         end;
 
 
     PSDL_Color = ^TSDL_Color;
     TSDL_Color = record
         case byte of
-            0: (    r: Byte;
-                g: Byte;
-                b: Byte;
-                unused: Byte;
-               );
-            1: (    value: Longword);
+            0: ( r: Byte;
+                 g: Byte;
+                 b: Byte;
+                 unused: Byte; );
+            1: ( value: Longword; );
         end;
 
 
@@ -341,7 +384,7 @@
     TClose = function( context: PSDL_RWops ): LongInt; cdecl;
 
     TStdio = record
-        autoclose: LongInt;
+        autoclose: {$IFDEF SDL13}boolean{$ELSE}LongInt{$ENDIF};
         fp: pointer;
         end;
 
@@ -371,9 +414,12 @@
 {* SDL_Event type definition *}
 
 {$IFDEF SDL13}
-    PSDL_Window = pointer;
-    PSDL_Renderer = pointer;
-    PSDL_Texture = pointer;
+    TSDL_KeySym = record
+        scancode: LongInt;
+        sym: LongInt;
+        modifier: Smallint;
+        unicode: LongInt;
+        end;
 
     TSDL_WindowEvent = record
         type_: LongInt;
@@ -382,15 +428,6 @@
         padding1, padding2, padding3: byte;
         data1, data2: LongInt;
         end;
-
-    TSDL_KeySym = record
-        scancode,
-        sym,
-        modifier,
-        unicode: LongInt;
-        end;
-
-// implement SDL_TextEditingEvent + SDL_TextInputEvent for sdl13
 {$ELSE}
     TSDL_KeySym = record
         scancode: Byte;
@@ -413,6 +450,22 @@
         end;
 {$ENDIF}
 
+    TSDL_KeyboardEvent = record
+{$IFDEF SDL13}
+        type_: LongInt;
+        windowID: LongInt;
+        state, repeat_, padding2, padding3: byte;
+{$ELSE}
+        type_: byte;
+        which: byte;
+        state: byte;
+{$ENDIF}
+        keysym: TSDL_KeySym;
+        end;
+
+//TODO: implement SDL_TextEditingEvent + SDL_TextInputEvent for sdl13
+
+    // this structure is wrong but the correct version makes the game hang
     TSDL_MouseMotionEvent = record
         which: byte;
         state: byte;
@@ -429,27 +482,14 @@
 {$ENDIF}
         end;
 
-    TSDL_KeyboardEvent = record
+    TSDL_MouseButtonEvent = record
 {$IFDEF SDL13}
         type_: LongInt;
         windowID: LongInt;
-        padding1, padding2: byte;
-{$ELSE}
-        type_: byte;
-{$ENDIF}
-        which: byte;
-        state: byte;
-        keysym: TSDL_KeySym;
-        end;
-
-    TSDL_MouseButtonEvent = record
-{$IFDEF SDL13}
-        _type: LongInt;
-        windowID: LongInt;
         x, y: LongInt;
         padding1: byte;
 {$ELSE}
-        _type,
+        type_,
         which,
         button,
         state: byte;
@@ -463,21 +503,17 @@
         windowID: LongInt;
         which: Byte;
         x, y: LongInt;
-        padding1, padding2, padding3: byte;
         end;
 
-    // implement SDL_ProximityEvent
+//TODO: implement SDL_ProximityEvent
 {$ENDIF}
 
     TSDL_JoyAxisEvent = record
-{$IFDEF SDL13}
-        type_: LongInt;
-{$ELSE}
-        type_: Byte;
-{$ENDIF}
+        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
         which: Byte;
         axis: Byte;
 {$IFDEF SDL13}
+        padding1, padding2: Byte;
         value: LongInt;
 {$ELSE}
         value: Smallint;
@@ -485,45 +521,41 @@
         end;
 
     TSDL_JoyBallEvent = record
+        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
         which: Byte;
         ball: Byte;
 {$IFDEF SDL13}
-        type_: LongInt;
+        padding1, padding2: Byte;
         xrel, yrel: LongInt;
 {$ELSE}
-        type_: Byte;
         xrel, yrel: Smallint;
 {$ENDIF}
         end;
 
     TSDL_JoyHatEvent = record
-{$IFDEF SDL13}
-        type_: LongInt;
-{$ELSE}
-        type_: Byte;
-{$ENDIF}
+        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
         which: Byte;
         hat: Byte;
         value: Byte;
+{$IFDEF SDL13}
+        padding1: Byte;
+{$ENDIF}
         end;
 
     TSDL_JoyButtonEvent = record
-{$IFDEF SDL13}
-        type_: LongInt;
-{$ELSE}
-        type_: Byte;
-{$ENDIF}
+        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
         which: Byte;
         button: Byte;
         state: Byte;
+{$IFDEF SDL13}
+        padding1: Byte;
+{$ENDIF}
         end;
 
+//TODO: implement SDL_TouchButtonEvent, SDL_MultiGestureEvent, SDL_DollarGestureEvent
+
     TSDL_QuitEvent = record
-{$IFDEF SDL13}
-        type_: LongInt;
-{$ELSE}
-        type_: Byte;
-{$ENDIF}
+        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
         end;
 
     TSDL_UserEvent = record
@@ -542,7 +574,6 @@
 {$IFDEF SDL13}
         case LongInt of
             SDL_FIRSTEVENT: (type_: LongInt);
-            SDL_QUITEV: (quit: TSDL_QuitEvent);
             SDL_WINDOWEVENT: (wevent: TSDL_WindowEvent);
             SDL_KEYDOWN,
             SDL_KEYUP: (key: TSDL_KeyboardEvent);
@@ -557,7 +588,9 @@
             SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
             SDL_JOYBUTTONDOWN,
             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
+            SDL_QUITEV: (quit: TSDL_QuitEvent);
             SDL_USEREVENT: (user: TSDL_UserEvent);
+            //TODO: implement other events
 {$ELSE}
         case Byte of
             SDL_NOEVENT: (type_: byte);
@@ -749,12 +782,19 @@
 
 function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat; cdecl; external SDLLibName;
 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); cdecl; external SDLLibName;
+procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
+
+procedure SDL_WarpMouse(x, y: Word);
+{$ELSE}
+procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
+
+function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat;
+//procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat);
 {$ENDIF}
 
 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
 function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
-procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
 
 procedure SDL_PumpEvents; cdecl; external SDLLibName;
 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
@@ -852,7 +892,7 @@
 function  IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
 function  IMG_Load_RW(rwop: PSDL_RWops; freesrc: LongInt): PSDL_Surface; cdecl; external SDL_ImageLibName;
 function  IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
-function  IMG_LoadTyped_RW(rwop: PSDL_RWops; freesrc: LongInt; _type: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
+function  IMG_LoadTyped_RW(rwop: PSDL_RWops; freesrc: LongInt; type_: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
 
 (*  SDL_net  *)
 function  SDLNet_Init: LongInt; cdecl; external SDL_NetLibName;
@@ -876,6 +916,31 @@
 function  SDLNet_Read32(buf: pointer): LongWord;
 
 implementation
+uses uVariables;
+
+{$IFDEF SDL13}
+procedure SDL_WarpMouse(x, y: Word);
+begin
+    SDL_WarpMouseInWindow(SDLwindow, x, y);
+end;
+{$ELSE}
+function SDL_AllocFormat(format: Longword): PSDL_PixelFormat;
+const conversionFormat: TSDL_PixelFormat = (
+        palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
+        Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
+        Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
+        RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
+        colorkey: 0; alpha: 255);
+begin
+    format:= format;
+    exit(@conversionFormat);
+end;
+
+procedure SDL_FreeFormat;
+begin
+    // yay free space
+end;
+{$ENDIF}
 
 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
 begin
--- a/hedgewars/options.inc	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/options.inc	Fri Mar 25 20:02:27 2011 -0400
@@ -41,4 +41,4 @@
   {  $DEFINE COUNTTICKS}
 {$ENDIF}
 
-//also available LUA_DISABLED
\ No newline at end of file
+//also available LUA_DISABLED
--- a/hedgewars/uAmmos.pas	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/uAmmos.pas	Fri Mar 25 20:02:27 2011 -0400
@@ -295,6 +295,10 @@
         end;
     TryDo(slot <= cMaxSlotIndex, 'Ammo slot index overflow', true);
     CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
+    if (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
+        ShowCrosshair:= (Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0
+    else
+        ShowCrosshair:= (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0;
     end
 end;
 
@@ -333,10 +337,6 @@
             Gear^.State:= Gear^.State and not gstHHChooseTarget;
             isCursorVisible:= false
             end;
-        if (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
-            ShowCrosshair:= (Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0
-        else
-            ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0;
         end
     end;
 end;
--- a/hedgewars/uGears.pas	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/uGears.pas	Fri Mar 25 20:02:27 2011 -0400
@@ -583,7 +583,10 @@
 
         team:= Gear^.Hedgehog^.Team;
         if CurrentHedgehog^.Gear = Gear then
+            begin
             FreeActionsList; // to avoid ThinkThread on drawned gear
+            if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (CurrentHedgehog^.MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^);
+            end;
 
         Gear^.Hedgehog^.Gear:= nil;
         if Gear^.Hedgehog^.King then
--- a/hedgewars/uGearsRender.pas	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/uGearsRender.pas	Fri Mar 25 20:02:27 2011 -0400
@@ -21,7 +21,7 @@
 unit uGearsRender;
 
 interface
-uses uTypes, uConsts, GLunit, uFloat;
+uses uTypes, uConsts, GLunit, uFloat, SDLh;
 
 procedure RenderGear(Gear: PGear; x, y: LongInt);
 
@@ -259,8 +259,8 @@
     if (Gear^.State and gstHHDriven) <> 0 then
         begin
         if ((Gear^.State and gstHHThinking) = 0) and
-        (ShowCrosshair  or ((CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtRope))) and
-        ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then
+        ShowCrosshair and
+        ((Gear^.State and gstAnimation) = 0) then
             begin
     (* These calculations are a little complex for a few reasons:
     1: I need to draw the laser from weapon origin to nearest land
@@ -1041,7 +1041,10 @@
            gtFlake: if (Gear^.State and gstTmpFlag) <> 0 then
                         //DrawRotatedTextureF(SpritesData[sprSnowBall].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle)
                         begin
-                        Tint(cExplosionBorderColor);
+                        Tint((cExplosionBorderColor shr RShift) and $FF, 
+                             (cExplosionBorderColor shr GShift) and $FF, 
+                             (cExplosionBorderColor shr BShift) and $FF, 
+                             (cExplosionBorderColor shr AShift) and $FF);
                         //DrawRotated(sprSnow, x, y, 0, Gear^.DirAngle);
                         // Needs a nicer white texture to tint
                         DrawTexture(x, y, SpritesData[sprVampiric].Texture, 0.1);
--- a/hedgewars/uLandGraphics.pas	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/uLandGraphics.pas	Fri Mar 25 20:02:27 2011 -0400
@@ -49,15 +49,15 @@
     oRed, oBlue, oGreen, oAlpha, nRed, nBlue, nGreen, nAlpha: Byte;
 begin
     // Get colors
-    oAlpha := (OldColor shr 24) and $FF;
-    oRed   := (OldColor shr 16) and $FF;
-    oGreen := (OldColor shr 8) and $FF;
-    oBlue  := (OldColor) and $FF;
+    oAlpha := (OldColor shr AShift) and $FF;
+    oRed   := (OldColor shr RShift) and $FF;
+    oGreen := (OldColor shr GShift) and $FF;
+    oBlue  := (OldColor shr BShift) and $FF;
 
-    nAlpha := (NewColor shr 24) and $FF;
-    nRed   := (NewColor shr 16) and $FF;
-    nGreen := (NewColor shr 8) and $FF;
-    nBlue  := (NewColor) and $FF;
+    nAlpha := (NewColor shr AShift) and $FF;
+    nRed   := (NewColor shr RShift) and $FF;
+    nGreen := (NewColor shr GShift) and $FF;
+    nBlue  := (NewColor shr BShift) and $FF;
 
     // Mix colors
     nAlpha := min(255, oAlpha + nAlpha);
@@ -65,7 +65,7 @@
     nGreen := ((oGreen * oAlpha) + (nGreen * (255-oAlpha))) div 255;
     nBlue  := ((oBlue * oAlpha) + (nBlue * (255-oAlpha))) div 255;
 
-    addBgColor := (nAlpha shl 24) or (nRed shl 16) or (nGreen shl 8) or (nBlue);
+    addBgColor := (nAlpha shl AShift) or (nRed shl RShift) or (nGreen shl GShift) or (nBlue shl BShift);
 end;
 
 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
--- a/hedgewars/uMisc.pas	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/uMisc.pas	Fri Mar 25 20:02:27 2011 -0400
@@ -118,21 +118,12 @@
 
 // http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
-const conversionFormat: TSDL_PixelFormat = (
-{$IFDEF SDL13}format: 0;{$ENDIF}
-        palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
-        Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
-{$IFDEF ENDIAN_LITTLE}Rshift: 0; Gshift: 8; Bshift: 16; Ashift: 24;
-{$ELSE} Rshift: 24; Gshift: 16; Bshift: 8; Ashift: 0;{$ENDIF}
-        RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
-{$IFDEF SDL13}refcount: 0; next: nil;
-{$ELSE} colorkey: 0; alpha: 255{$ENDIF});
 var convertedSurf: PSDL_Surface;
 begin
     if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
        (tmpsurf^.format^.bitsperpixel = 24) then
         begin
-        convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat, SDL_SWSURFACE);
+        convertedSurf:= SDL_ConvertSurface(tmpsurf, conversionFormat, SDL_SWSURFACE);
         SDL_FreeSurface(tmpsurf);
         exit(convertedSurf);
         end;
@@ -150,11 +141,16 @@
 
 procedure initModule;
 begin
+    // SDL_PIXELFORMAT_RGB8888
+    conversionFormat:= SDL_AllocFormat($86462004);
 end;
 
 procedure freeModule;
 begin
     recordFileName:= '';
+{$IFDEF SDL13}
+    SDL_FreeFormat(conversionFormat);
+{$ENDIF}
 end;
 
 end.
--- a/hedgewars/uStore.pas	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/uStore.pas	Fri Mar 25 20:02:27 2011 -0400
@@ -627,7 +627,7 @@
     // enable alpha blending
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    // disable/lower perspective correction (won't need it anyway)
+    // disable/lower perspective correction (will not need it anyway)
     glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
     // disable dithering
     glDisable(GL_DITHER);
@@ -687,9 +687,10 @@
 
     DrawFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
 
-    SDL_GL_SwapBuffers();
 {$IFDEF SDL13}
     SDL_RenderPresent(SDLrender);
+{$ELSE}
+    SDL_GL_SwapBuffers();
 {$ENDIF}
     inc(Step);
 
@@ -870,7 +871,7 @@
 
 procedure FreeWeaponTooltip;
 begin
-// free the existing texture (if there's any)
+// free the existing texture (if there is any)
 if WeaponTooltipTex = nil then
     exit;
 FreeTexture(WeaponTooltipTex);
@@ -925,9 +926,10 @@
 {$IFDEF SDL13}
     if SDLwindow = nil then
     begin
-        // on ipad, when second monitor is attached, display window in second monitor always
-        x:= {$IFDEF IPHONEOS}(SDL_WINDOWPOS_CENTERED_MASK or (SDL_GetNumVideoDisplays() - 1)){$ELSE}0{$ENDIF};
-        y:= {$IFDEF IPHONEOS}(SDL_WINDOWPOS_CENTERED_MASK or (SDL_GetNumVideoDisplays() - 1)){$ELSE}0{$ENDIF};
+        // the values in x and y make the window appear in the center
+        // on ios, make the sdl window appear on the second monitor when present
+        x:= (SDL_WINDOWPOS_CENTERED_MASK or {$IFDEF IPHONEOS}SDL_GetNumVideoDisplays() - 1){$ELSE}0{$ENDIF});
+        y:= (SDL_WINDOWPOS_CENTERED_MASK or {$IFDEF IPHONEOS}SDL_GetNumVideoDisplays() - 1){$ELSE}0{$ENDIF});
         SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN
                         {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS {$ENDIF});
         SDLrender:= SDL_CreateRenderer(SDLwindow, -1, SDL_RENDERER_ACCELERATED or SDL_RENDERER_PRESENTVSYNC);
@@ -936,10 +938,13 @@
     SDL_SetRenderDrawColor(SDLrender, 0, 0, 0, 255);
     SDL_RenderClear(SDLrender);
     SDL_RenderPresent(SDLrender);
+
+    // we need to reset the gl context from the one created by SDL as we have our own drawing system
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
 {$ELSE}
     SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
     SDLTry(SDLPrimSurface <> nil, true);
-    PixelFormat:= SDLPrimSurface^.format;
 {$ENDIF}
 
     AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')');
@@ -952,7 +957,6 @@
 begin
     RegisterVariable('fullscr', vtCommand, @chFullScr, true);
 
-    PixelFormat:= nil;
     SDLPrimSurface:= nil;
 
 {$IFNDEF IPHONEOS}
--- a/hedgewars/uVariables.pas	Fri Mar 25 23:35:04 2011 +0200
+++ b/hedgewars/uVariables.pas	Fri Mar 25 20:02:27 2011 -0400
@@ -158,6 +158,7 @@
 
     Theme           : shortstring;
     disableLandBack : boolean;
+    conversionFormat: PSDL_PixelFormat;
 
 {$IFDEF SDL13}
     SDLwindow       : PSDL_Window;
@@ -2166,7 +2167,6 @@
     bAFRRight: Boolean;
 
 
-    PixelFormat: PSDL_PixelFormat;
     SDLPrimSurface: PSDL_Surface;
     PauseTexture,
     SyncTexture,
--- a/share/hedgewars/Data/Locale/el.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/el.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -97,7 +97,7 @@
 02:00=Ο %1 έζησε μια καλή ζωή!
 02:00=Ο %1 απέτυχε οικτρά...
 02:00=Καψερέ μου %1, τι σου έμελλε να πάθεις!
-02:00=Ο %1 προτιμά να παίζει Wormux!
+02:00=Ο %1 προτιμά να παίζει Warmux!
 02:00=Ο %1 σταμάταγε τις σφαίρες με τη φάτσα του!
 02:00=Ο %1 πήγε να συναντήσει τους προγόνους του!
 02:00=Ο %1 βρήκε τη θέση του στον παράδεισο!
--- a/share/hedgewars/Data/Locale/es.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/es.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -101,7 +101,7 @@
 02:00=%1 se ha picado
 02:00=%1 falló
 02:00=Pobrecito %1...
-02:00=%1 prefiere Wormux
+02:00=%1 prefiere Warmux
 02:00=%1 intentó parar las balas con su cara
 02:00=%1 es un héroe entre los hom... digo.. erizos
 02:00=%1 encontró el camino al Valhala
--- a/share/hedgewars/Data/Locale/fi.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/fi.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -99,7 +99,7 @@
 02:00=%1 raivopoistui elämästä
 02:00=%1 ei vain osaa
 02:00=Voi %1 parkaa...
-02:00=%1 pitää enemmän Wormuxista
+02:00=%1 pitää enemmän Warmuxista
 02:00=%1 on pysäyttänyt luoteja kasvoillaan
 02:00=%1 on sankari ih...siilien joukossa
 02:00=%1 löytää paikkansa Valhallasta
--- a/share/hedgewars/Data/Locale/fr.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/fr.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -92,7 +92,7 @@
 02:00=%1 est mauvais joueur !
 02:00=%1 a échoué
 02:00=Pauvre %1...
-02:00=%1 préfère Wormux
+02:00=%1 préfère Warmux
 02:00=%1 a bloqué les balles avec sa tête
 02:00=%1 s'en va à la façon des dinosaures
 02:00=%1 fait avancer les hérissons d'un pas vers l'extinction
--- a/share/hedgewars/Data/Locale/gl.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/gl.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -244,4 +244,4 @@
 02:10=É un paxaro? É un avión?
 02:10=Zas! En toda a boca!
 02:10=Iso debe de doer...
-02:10=Arranxoulle a cara...
\ No newline at end of file
+02:10=Arranxoulle a cara...
--- a/share/hedgewars/Data/Locale/it.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/it.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -113,7 +113,7 @@
 02:00=%1 è spirato
 02:00=%1 riposa in pace
 02:00=Dottore, chiami un dottore!
-02:00=%1 preferisce giocare a Wormux
+02:00=%1 preferisce giocare a Warmux
 02:00=%1 ha perso la sua partita!
 02:00=%1 è morto con (poco) onore!
 02:00=%1 va verso il Giudizio Universale!
--- a/share/hedgewars/Data/Locale/pl.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/pl.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -100,7 +100,7 @@
 02:00=%1 przytupnął nóżką i umarł
 02:00=%1 poniósł całkowitą klęskę.
 02:00=Biedny %1 ...
-02:00=%1 woli grać w Wormux
+02:00=%1 woli grać w Warmux
 02:00=%1 blokuje strzały własną twarzą
 02:00=%1 znajduje miejsce w Valhalli
 02:00=%1 opuścił budynek
--- a/share/hedgewars/Data/Locale/pt_PT.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/pt_PT.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -104,7 +104,7 @@
 02:00=%1 desligou-se da vida
 02:00=%1 falhou
 02:00=Pobrezinho do %1...
-02:00=%1 prefere Wormux
+02:00=%1 prefere Warmux
 02:00=%1 esteve a bloquear tiros com a tromba
 02:00=%1 é um herói agora... no céu
 02:00=%1 encontrou o seu descanso
--- a/share/hedgewars/Data/Locale/ru.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/ru.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -67,7 +67,7 @@
 02:00=%1 ушёл поиграть в лучшую игру
 02:00=%1 вышел из строя
 02:00=Бедный, бедный %1...
-02:00=%1 предпочитает Wormux
+02:00=%1 предпочитает Warmux
 02:00=%1 идёт по пути динозавров
 02:00=%1 ведёт ежей по пути вымирания
 02:00=%1 выдавил слезу из моих глаз
--- a/share/hedgewars/Data/Locale/uk.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/uk.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -85,7 +85,7 @@
 02:00=%1 пішов пограти в кращу гру
 02:00=%1 вийшов з ладу
 02:00=Бідний, бідний %1...
-02:00=%1 віддає перевагу Wormux
+02:00=%1 віддає перевагу Warmux
 02:00=%1 пішов шляхом динозаврів
 02:00=%1 веде їжаків до вимирання
 02:00=%1 змусив мене плакати
--- a/share/hedgewars/Data/Locale/zh_CN.txt	Fri Mar 25 23:35:04 2011 +0200
+++ b/share/hedgewars/Data/Locale/zh_CN.txt	Fri Mar 25 20:02:27 2011 -0400
@@ -132,7 +132,7 @@
 ; 02:00=Poor poor %1...
 02:00=可怜的 %1...
 ; 02:00=%1 prefers wormux
-02:00=%1 更喜欢 Wormux
+02:00=%1 更喜欢 Warmux
 ; 02:00=%1 has been blocking shots with his face
 02:00=%1 勇于面对,结果相当惨烈
 ; 02:00=%1 is a hero amongst me...err..hogs