Merge pull request #28 from LocutusOfBorg/lua-fix
Find lua 5.1 on fedora machines (taken from fedora hw git)
--- a/.travis.yml Mon Jan 05 13:28:13 2015 +0100
+++ b/.travis.yml Mon Jan 05 14:05:09 2015 +0100
@@ -11,13 +11,13 @@
# Debug build
- BUILD_ARGS="-DCMAKE_BUILD_TYPE=Debug"
# Everything that's optional
+ - BUILD_ARGS="-DBUILD_ENGINE_C=1"
- BUILD_ARGS="-DNOPNG=1"
- BUILD_ARGS="-DNOVIDEOREC=1"
- BUILD_ARGS="-DNOSERVER=1"
- BUILD_ARGS="-DLUA_SYSTEM=0"
- BUILD_ARGS="-DPHYSFS_SYSTEM=0"
- BUILD_ARGS="-DGL2=1"
- - BUILD_ARGS="-DBUILD_ENGINE_C=1"
matrix:
allow_failures:
# Failures we expect here
@@ -27,10 +27,12 @@
script:
- mkdir build && cd build && cmake $BUILD_ARGS .. && make VERBOSE=1 && make test_verbose
notifications:
+ email: false
irc:
channels:
- "chat.freenode.net#hedgewars"
template:
- "hw-build #%{build_number} (%{commit} by %{author}): %{message}"
- "See details at %{build_url}"
- email: false
+ on_success: change
+ on_failure: always
--- a/CMakeLists.txt Mon Jan 05 13:28:13 2015 +0100
+++ b/CMakeLists.txt Mon Jan 05 14:05:09 2015 +0100
@@ -51,8 +51,8 @@
#versioning
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 9)
-set(CPACK_PACKAGE_VERSION_PATCH 21)
-set(HEDGEWARS_PROTO_VER 48)
+set(CPACK_PACKAGE_VERSION_PATCH 22)
+set(HEDGEWARS_PROTO_VER 50)
set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
include(${CMAKE_MODULE_PATH}/revinfo.cmake)
--- a/QTfrontend/hwform.cpp Mon Jan 05 13:28:13 2015 +0100
+++ b/QTfrontend/hwform.cpp Mon Jan 05 14:05:09 2015 +0100
@@ -1832,7 +1832,7 @@
if (hwnet)
{
NetAmmoSchemeModel * netAmmo = new NetAmmoSchemeModel(hwnet);
- connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), netAmmo, SLOT(setNetSchemeConfig(QStringList &)));
+ connect(hwnet, SIGNAL(netSchemeConfig(QStringList)), netAmmo, SLOT(setNetSchemeConfig(QStringList)));
ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo);
--- a/QTfrontend/model/ammoSchemeModel.cpp Mon Jan 05 13:28:13 2015 +0100
+++ b/QTfrontend/model/ammoSchemeModel.cpp Mon Jan 05 14:05:09 2015 +0100
@@ -845,7 +845,7 @@
return netScheme[index.column()];
}
-void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg)
+void NetAmmoSchemeModel::setNetSchemeConfig(QStringList cfg)
{
if(cfg.size() != netScheme.size())
{
--- a/QTfrontend/model/ammoSchemeModel.h Mon Jan 05 13:28:13 2015 +0100
+++ b/QTfrontend/model/ammoSchemeModel.h Mon Jan 05 14:05:09 2015 +0100
@@ -70,7 +70,7 @@
QVariant data(const QModelIndex &index, int role) const;
public slots:
- void setNetSchemeConfig(QStringList & cfg);
+ void setNetSchemeConfig(QStringList cfg);
private:
QList<QVariant> netScheme;
--- a/QTfrontend/net/newnetclient.h Mon Jan 05 13:28:13 2015 +0100
+++ b/QTfrontend/net/newnetclient.h Mon Jan 05 14:05:09 2015 +0100
@@ -111,7 +111,7 @@
void roomNameUpdated(const QString & name);
void askForRoomPassword();
- void netSchemeConfig(QStringList &);
+ void netSchemeConfig(QStringList);
void paramChanged(const QString & param, const QStringList & value);
void configAsked();
--- a/QTfrontend/res/html/about.html Mon Jan 05 13:28:13 2015 +0100
+++ b/QTfrontend/res/html/about.html Mon Jan 05 14:05:09 2015 +0100
@@ -76,7 +76,7 @@
French: Antoine Turmel <<a href="mailto:geekshadow@gmail.com">geekshadow@gmail.com</a>>, Clement Woitrain <<a href="mailto:sphrixclement@gmail.com">sphrixclement@gmail.com</a>>, Matisumi<br>
German: Peter Hüwe <<a href="mailto:PeterHuewe@gmx.de">PeterHuewe@gmx.de</a>>, Mario Liebisch <<a href="mailto:mario.liebisch@gmail.com">mario.liebisch@gmail.com</a>>, Richard Karolyi <<a href="mailto:sheepluva@ercatec.net">sheepluva@ercatec.net</a>>, Wuzzy <<a href="mailto:almikes@aol.com">almikes@aol.com</a>><br>
Greek: <<a href="mailto:talos_kriti@yahoo.gr">talos_kriti@yahoo.gr</a>><br>
- Italian: Luca Bonora <<a href="mailto:bonora.luca@gmail.com">bonora.luca@gmail.com</a>>, Marco Bresciani <<a href="mailto:m.bresciani@email.it">m.bresciani@email.it</a>><br>
+ Italian: Luca Bonora <<a href="mailto:bonora.luca@gmail.com">bonora.luca@gmail.com</a>>, Marco Bresciani <<a href="mailto:m.bresciani@email.it">m.bresciani@email.it</a>>, Gianfranco Costamagna <<a href="mailto:costamagnagianfranco@yahoo.it">costamagnagianfranco@yahoo.it</a>><br>
Japanese: ADAM Etienne <<a href="mailto:etienne.adam@gmail.com">etienne.adam@gmail.com</a>>, Marco Bresciani <<a href="mailto:m.bresciani@email.it">m.bresciani@email.it</a>><br>
Korean: Anthony Bellew <<a href="mailto:anthonyreflected@gmail.com">anthonyreflected@gmail.com</a>><br>
Lithuanian: Lukas Urbonas <<a href="mailto:lukasu08@gmail.com">lukasu08@gmail.com</a>><br>
--- a/cmake_modules/CheckHaskellModuleExists.cmake Mon Jan 05 13:28:13 2015 +0100
+++ b/cmake_modules/CheckHaskellModuleExists.cmake Mon Jan 05 14:05:09 2015 +0100
@@ -30,11 +30,11 @@
"-DPARAMETERS=${PARAMETERS}"
-cpp
-c "${CMAKE_MODULE_PATH}/checkModule.hs"
+ RESULT_VARIABLE COMMAND_RESULT
ERROR_VARIABLE BUILD_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
-
- if("${BUILD_ERROR}" STREQUAL "")
+ if(${COMMAND_RESULT} EQUAL 0)
message(STATUS "Looking for ${FUNCTION} in ${MODULE} - found")
set(${VARIABLE} 1 CACHE INTERNAL "Have module ${MODULE}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
--- a/gameServer/Actions.hs Mon Jan 05 13:28:13 2015 +0100
+++ b/gameServer/Actions.hs Mon Jan 05 14:05:09 2015 +0100
@@ -415,11 +415,12 @@
processAction RemoveClientTeams = do
(Just ci) <- gets clientIndex
rnc <- gets roomsClients
+ n <- client's nick
removeTeamActions <- io $ do
rId <- clientRoomM rnc ci
roomTeams <- room'sM rnc teams rId
- return . Prelude.map (RemoveTeam . teamname) . Prelude.filter (\t -> teamownerId t == ci) $ roomTeams
+ return . Prelude.map (RemoveTeam . teamname) . Prelude.filter (\t -> teamowner t == n) $ roomTeams
mapM_ processAction removeTeamActions
--- a/gameServer/CoreTypes.hs Mon Jan 05 13:28:13 2015 +0100
+++ b/gameServer/CoreTypes.hs Mon Jan 05 14:05:09 2015 +0100
@@ -162,7 +162,6 @@
data TeamInfo =
TeamInfo
{
- teamownerId :: ClientIndex,
teamowner :: B.ByteString,
teamname :: B.ByteString,
teamcolor :: B.ByteString,
@@ -170,6 +169,7 @@
teamfort :: B.ByteString,
teamvoicepack :: B.ByteString,
teamflag :: B.ByteString,
+ isOwnerRegistered :: Bool,
difficulty :: Int,
hhnum :: Int,
hedgehogs :: [HedgehogInfo]
--- a/gameServer/EngineInteraction.hs Mon Jan 05 13:28:13 2015 +0100
+++ b/gameServer/EngineInteraction.hs Mon Jan 05 14:05:09 2015 +0100
@@ -102,7 +102,9 @@
, [eml ["eseed ", mParams Map.! "SEED"]]
, [eml ["e$gmflags ", showB gameFlags]]
, schemeFlags
+ , schemeAdditional
, [eml ["e$template_filter ", mParams Map.! "TEMPLATE"]]
+ , [eml ["e$feature_size ", mParams Map.! "FEATURE_SIZE"]]
, [eml ["e$mapgen ", mapgen]]
, mapgenSpecific
, concatMap teamSetup ti
@@ -111,11 +113,11 @@
]
where
keys1, keys2 :: Set.Set B.ByteString
- keys1 = Set.fromList ["MAP", "MAPGEN", "MAZE_SIZE", "SEED", "TEMPLATE"]
+ keys1 = Set.fromList ["FEATURE_SIZE", "MAP", "MAPGEN", "MAZE_SIZE", "SEED", "TEMPLATE"]
keys2 = Set.fromList ["AMMO", "SCHEME", "SCRIPT", "THEME"]
sane = Set.null (keys1 Set.\\ Map.keysSet mParams)
&& Set.null (keys2 Set.\\ Map.keysSet prms)
- && (not . null . drop 27 $ scheme)
+ && (not . null . drop 40 $ scheme)
&& (not . null . tail $ prms Map.! "AMMO")
mapGenTypes = ["+rnd+", "+maze+", "+drawn+"]
maybeScript = let s = head . fromMaybe ["Normal"] $ Map.lookup "SCRIPT" prms in if s == "Normal" then [] else [eml ["escript Scripts/Multiplayer/", s, ".lua"]]
@@ -131,6 +133,7 @@
schemeFlags = map (\(v, (n, m)) -> eml [n, " ", showB $ (readInt_ v) * m])
$ filter (\(_, (n, _)) -> not $ B.null n)
$ zip (drop (length gameFlagConsts) scheme) schemeParams
+ schemeAdditional = let scriptParam = B.tail $ scheme !! 41 in [eml ["e$scriptparam ", scriptParam] | not $ B.null scriptParam]
ammoStr :: B.ByteString
ammoStr = head . tail $ prms Map.! "AMMO"
ammo = let l = B.length ammoStr `div` 4; ((a, b), (c, d)) = (B.splitAt l . fst &&& B.splitAt l . snd) . B.splitAt (l * 2) $ ammoStr in
@@ -184,6 +187,7 @@
, ("e$healthdec", 1)
, ("e$ropepct", 1)
, ("e$getawaytime", 1)
+ , ("e$worldedge", 1)
]
--- a/gameServer/HWProtoInRoomState.hs Mon Jan 05 13:28:13 2015 +0100
+++ b/gameServer/HWProtoInRoomState.hs Mon Jan 05 14:05:09 2015 +0100
@@ -41,7 +41,7 @@
chans <- roomClientsChans
let nicks = map (nick . client rnc) . roomClients rnc $ clientRoom rnc ci
- let allPlayersRegistered = all ((<) 0 . B.length . webPassword . client rnc . teamownerId) $ teams rm
+ let allPlayersRegistered = all isOwnerRegistered $ teams rm
if (playersIn rm == readyPlayers rm || clientProto cl > 43) && not (isJust $ gameInfo rm) then
if enoughClans rm then
@@ -87,15 +87,19 @@
return [Warning $ loc "Restricted"]
else if isMaster cl then
return [
- ModifyRoom f,
+ ModifyRoom $ f (clientProto cl),
AnswerClients chans ("CFG" : paramName : paramStrs)]
else
return [ProtocolError $ loc "Not room master"]
where
- f r = if paramName `Map.member` (mapParams r) then
+ f clproto r = if paramName `Map.member` (mapParams r) then
r{mapParams = Map.insert paramName (head paramStrs) (mapParams r)}
else
- r{params = Map.insert paramName paramStrs (params r)}
+ r{params = Map.insert paramName (fixedParamStr clproto) (params r)}
+ fixedParamStr clproto
+ | clproto /= 49 = paramStrs
+ | paramName /= "SCHEME" = paramStrs
+ | otherwise = L.init paramStrs ++ [B.replicate 50 'X' `B.append` L.last paramStrs]
handleCmd_inRoom ("ADD_TEAM" : tName : color : grave : fort : voicepack : flag : difStr : hhsInfo)
@@ -103,11 +107,13 @@
| otherwise = do
(ci, _) <- ask
rm <- thisRoom
+ cl <- thisClient
clNick <- clientNick
clChan <- thisClientChans
othChans <- roomOthersChans
roomChans <- roomClientsChans
cl <- thisClient
+ let isRegistered = (<) 0 . B.length . webPassword $ cl
teamColor <-
if clientProto cl < 42 then
return color
@@ -115,7 +121,7 @@
liftM (head . (L.\\) (map B.singleton ['0'..]) . map teamcolor . teams) thisRoom
let roomTeams = teams rm
let hhNum = let p = if not $ null roomTeams then minimum [hhnum $ head roomTeams, canAddNumber roomTeams] else 4 in newTeamHHNum roomTeams p
- let newTeam = clNick `seq` TeamInfo ci clNick tName teamColor grave fort voicepack flag dif hhNum (hhsList hhsInfo)
+ let newTeam = clNick `seq` TeamInfo clNick tName teamColor grave fort voicepack flag isRegistered dif hhNum (hhsList hhsInfo)
return $
if not . null . drop (maxTeams rm - 1) $ roomTeams then
[Warning $ loc "too many teams"]
@@ -152,6 +158,7 @@
handleCmd_inRoom ["REMOVE_TEAM", tName] = do
(ci, _) <- ask
r <- thisRoom
+ clNick <- clientNick
let maybeTeam = findTeam r
let team = fromJust maybeTeam
@@ -159,18 +166,18 @@
return $
if isNothing $ maybeTeam then
[Warning $ loc "REMOVE_TEAM: no such team"]
- else if ci /= teamownerId team then
+ else if clNick /= teamowner team then
[ProtocolError $ loc "Not team owner!"]
else
[RemoveTeam tName,
ModifyClient
(\c -> c{
teamsInGame = teamsInGame c - 1,
- clientClan = if teamsInGame c == 1 then Nothing else Just $ anotherTeamClan ci team r
+ clientClan = if teamsInGame c == 1 then Nothing else Just $ anotherTeamClan clNick team r
})
]
where
- anotherTeamClan ci team = teamcolor . fromMaybe (error "CHECKPOINT 011") . find (\t -> (teamownerId t == ci) && (t /= team)) . teams
+ anotherTeamClan clNick team = teamcolor . fromMaybe (error "CHECKPOINT 011") . find (\t -> (teamowner t == clNick) && (t /= team)) . teams
findTeam = find (\t -> tName == teamname t) . teams
@@ -207,16 +214,18 @@
let maybeTeam = findTeam r
let team = fromJust maybeTeam
+ maybeClientId <- clientByNick $ teamowner team
+ let teamOwnerId = fromJust maybeClientId
return $
if not $ isMaster cl then
[ProtocolError $ loc "Not room master"]
- else if isNothing maybeTeam then
+ else if isNothing maybeTeam || isNothing maybeClientId then
[]
else
[ModifyRoom $ modifyTeam team{teamcolor = newColor},
AnswerClients others ["TEAM_COLOR", teamName, newColor],
- ModifyClient2 (teamownerId team) (\c -> c{clientClan = Just newColor})]
+ ModifyClient2 teamOwnerId (\c -> c{clientClan = Just newColor})]
where
findTeam = find (\t -> teamName == teamname t) . teams
--- a/gameServer/HWProtoLobbyState.hs Mon Jan 05 13:28:13 2015 +0100
+++ b/gameServer/HWProtoLobbyState.hs Mon Jan 05 14:05:09 2015 +0100
@@ -105,7 +105,7 @@
: AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl]
: [(AnswerClients [sendChan cl] $ "JOINED" : nicks) | not $ null nicks]
)
- ++ [ModifyRoom (\r -> let (t', g') = moveTeams clTeams . fromJust $ gameInfo r in r{gameInfo = Just g', teams = t'}) | not $ null clTeams]
+ -- ++ [ModifyRoom (\r -> let (t', g') = moveTeams clTeams . fromJust $ gameInfo r in r{gameInfo = Just g', teams = t'}) | not $ null clTeams]
++ [AnswerClients [sendChan cl] ["CLIENT_FLAGS", "+h", nick $ fromJust owner] | isJust owner]
++ [sendStateFlags cl jRoomClients | not $ null jRoomClients]
++ answerFullConfig cl jRoom
--- a/gameServer/OfficialServer/checker.hs Mon Jan 05 13:28:13 2015 +0100
+++ b/gameServer/OfficialServer/checker.hs Mon Jan 05 14:05:09 2015 +0100
@@ -54,7 +54,7 @@
deriving Show
serverAddress = "netserver.hedgewars.org"
-protocolNumber = "47"
+protocolNumber = "49"
getLines :: Handle -> IO [B.ByteString]
getLines h = g
@@ -87,18 +87,18 @@
"ACHIEVEMENT" : typ : teamname : location : value : ps bs
ps _ = []
-checkReplay :: Chan Message -> [B.ByteString] -> IO ()
-checkReplay coreChan msgs = do
+checkReplay :: String -> String -> String -> Chan Message -> [B.ByteString] -> IO ()
+checkReplay home exe prefix coreChan msgs = do
tempDir <- getTemporaryDirectory
(fileName, h) <- openBinaryTempFile tempDir "checker-demo"
B.hPut h . BW.pack . concat . map (fromMaybe [] . Base64.decode . B.unpack) $ msgs
hFlush h
hClose h
- (_, _, Just hOut, _) <- createProcess (proc "/usr/home/unC0Rr/Sources/Hedgewars/Releases/0.9.20/bin/hwengine"
+ (_, _, Just hOut, _) <- createProcess (proc exe
[fileName
- , "--user-prefix", "/usr/home/unC0Rr/.hedgewars"
- , "--prefix", "/usr/home/unC0Rr/Sources/Hedgewars/Releases/0.9.20/share/hedgewars/Data"
+ , "--user-prefix", home
+ , "--prefix", prefix
, "--nomusic"
, "--nosound"
, "--stats-only"
@@ -139,8 +139,8 @@
sendPacket packet = writeChan chan $ Packet packet
-session :: B.ByteString -> B.ByteString -> Socket -> IO ()
-session l p s = do
+session :: B.ByteString -> B.ByteString -> String -> String -> String -> Socket -> IO ()
+session l p home exe prefix s = do
noticeM "Core" "Connected"
coreChan <- newChan
forkIO $ recvLoop s coreChan
@@ -169,7 +169,7 @@
onPacket _ ["PING"] = answer ["PONG"]
onPacket _ ["LOGONPASSED"] = answer ["READY"]
onPacket chan ("REPLAY":msgs) = do
- checkReplay chan msgs
+ checkReplay home exe prefix chan msgs
warningM "Check" "Started check"
onPacket _ ("BYE" : xs) = error $ show xs
onPacket _ _ = return ()
@@ -187,18 +187,24 @@
updateGlobalLogger "Check" (setLevel DEBUG)
updateGlobalLogger "Engine" (setLevel DEBUG)
+ d <- getHomeDirectory
Right (login, password) <- runErrorT $ do
- d <- liftIO $ getHomeDirectory
conf <- join . liftIO . CF.readfile CF.emptyCP $ d ++ "/.hedgewars/settings.ini"
l <- CF.get conf "net" "nick"
p <- CF.get conf "net" "passwordhash"
return (B.pack l, B.pack p)
+ Right (exeFullname, dataPrefix) <- runErrorT $ do
+ conf <- join . liftIO . CF.readfile CF.emptyCP $ d ++ "/.hedgewars/checker.ini"
+ l <- CF.get conf "engine" "exe"
+ p <- CF.get conf "engine" "prefix"
+ return (l, p)
+
Exception.bracket
setupConnection
(\s -> noticeM "Core" "Shutting down" >> sClose s)
- (session login password)
+ (session login password (d ++ "/.hedgewars") exeFullname dataPrefix)
where
setupConnection = do
noticeM "Core" "Connecting to the server..."
--- a/hedgewars/uGearsHandlersMess.pas Mon Jan 05 13:28:13 2015 +0100
+++ b/hedgewars/uGearsHandlersMess.pas Mon Jan 05 14:05:09 2015 +0100
@@ -804,6 +804,8 @@
move:= true
else if (xx > snowRight) or (xx < snowLeft) then
move:=true
+ else if (cGravity < _0) and (yy < LAND_HEIGHT-1200) then
+ move:=true
// Solid pixel encountered
else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] <> 0) then
begin
@@ -920,7 +922,9 @@
end;
Gear^.Pos:= 0;
Gear^.X:= int2hwFloat(LongInt(GetRandom(snowRight - snowLeft)) + snowLeft);
- Gear^.Y:= int2hwFloat(LAND_HEIGHT + LongInt(GetRandom(50)) - 1325);
+ if (cGravity < _0) and (yy < LAND_HEIGHT-1200) then
+ Gear^.Y:= int2hwFloat(LAND_HEIGHT - 50 - LongInt(GetRandom(50)))
+ else Gear^.Y:= int2hwFloat(LAND_HEIGHT + LongInt(GetRandom(50)) - 1250);
Gear^.State:= Gear^.State or gstInvisible;
end
end;
--- a/hedgewars/uStore.pas Mon Jan 05 13:28:13 2015 +0100
+++ b/hedgewars/uStore.pas Mon Jan 05 14:05:09 2015 +0100
@@ -611,17 +611,17 @@
// loading failed
if tmpsurf = nil then
begin
-
- // anounce that loading failed
- OutError(msgFailed, false);
-
// output sdl error if loading failed when data source was available
if rwops <> nil then
begin
+ // anounce that loading failed
+ OutError(msgFailed, false);
+
SDLTry(false, (imageFlags and ifCritical) <> 0);
// rwops was already freed by IMG_Load_RW
rwops:= nil;
- end;
+ end else
+ OutError(msgFailed, (imageFlags and ifCritical) <> 0);
exit;
end;
--- a/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua Mon Jan 05 13:28:13 2015 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua Mon Jan 05 14:05:09 2015 +0100
@@ -17,7 +17,12 @@
function grav_onNewTurn()
- SetGravity(gravity)
+ if delta ~= nil and period == nil then
+ SetGravity(gravity)
+ else
+ SetGravity(div(gravity, mln))
+ end
+
wdGameTicks = GameTime
if script2_onNewTurn ~= nil then
@@ -36,7 +41,7 @@
if delta == nil then
if periodtimer == 0 then
periodtimer = period * 2
- SetGravity(div(GetRandom(maxgravity - mingravity) + mingravity, mln))
+ SetGravity(div(GetRandom(maxgravity - mingravity + 1) + mingravity, mln))
else
periodtimer = periodtimer - 1
end