gameServer/stresstest2.hs
author smxx
Thu, 04 Feb 2010 20:45:03 +0000
changeset 2747 7889a3a9724f
parent 2352 7eaf82cf0890
child 2948 3f21a9dc93d0
permissions -rw-r--r--
Server: * Added support for flags (this still needs further adjustments to restore compatibility with older versions (team datasets)!) Engine: * Added support for flags * Added weapon tooltips * Moved SplitBySpace to uMisc * Set file operations to readonly to avoid conflicts running multiple copies networked and synced on one (fast) machine * Flash active team while green arrow is shown (waiting for input or camera centered on active hog) * Updated English locale Frontend: * Added support for flags * Added flag selection to edit team page * Added checkbox for weapon tooltips in options * "Random team" button may now be translated * Disabled "official server" button till protocol is handled for all versions (see above; nemo's server is updated to new protocol) Graphics: * Added basic set of example flags
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     1
{-# LANGUAGE CPP #-}
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     2
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     3
module Main where
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     4
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     5
import IO
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     6
import System.IO
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     7
import Control.Concurrent
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     8
import Network
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     9
import Control.Exception
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    10
import Control.Monad
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    11
import System.Random
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    12
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    13
#if !defined(mingw32_HOST_OS)
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    14
import System.Posix
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    15
#endif
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    16
2352
7eaf82cf0890 Fixes suggested by hlint tool
unc0rr
parents: 1804
diff changeset
    17
testing = Control.Exception.handle print $ do
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    18
	delay <- randomRIO (100::Int, 300)
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    19
	threadDelay delay
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    20
	sock <- connectTo "127.0.0.1" (PortNumber 46631)
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    21
	hClose sock
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    22
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    23
forks i = do
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    24
	delay <- randomRIO (50::Int, 190)
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    25
	if i `mod` 10 == 0 then putStr (show i) else putStr "."
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    26
	hFlush stdout
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    27
	threadDelay delay
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    28
	forkIO testing
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    29
	forks (i + 1)
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    30
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    31
main = withSocketsDo $ do
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    32
#if !defined(mingw32_HOST_OS)
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    33
	installHandler sigPIPE Ignore Nothing;
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    34
#endif
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    35
	forks 1