Index: /code/branches/presentation/data/levels/spaceRace.oxw
===================================================================
--- /code/branches/presentation/data/levels/spaceRace.oxw	(revision 8631)
+++ /code/branches/presentation/data/levels/spaceRace.oxw	(revision 8631)
@@ -0,0 +1,474 @@
+<?lua
+  include("HUDTemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceshipAssff.oxt")
+  include("templates/lodInformation.oxt")
+?>
+
+<LevelInfo
+ name = "Space Race"
+ description = "Test level for the gametype Space Race."
+ tags = "test"
+/>
+
+<?lua
+  include("stats.oxo")
+  include("HUDTemplates3.oxo")
+  include("templates/lodInformation.oxt")
+?>
+
+<?lua
+  include("templates/spaceshipAssff.oxt")
+  include("templates/spaceshipPirate.oxt")
+?>
+
+<Level
+ name         = "Space Race"
+ description  = "Test level for the gametype Space Race."
+ gametype     = SpaceRace
+>
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+
+  <Scene
+    ambientlight = "0.8, 0.8, 0.8"
+    skybox       = "Orxonox/skyBoxMoreNebula"
+  >
+
+    <?lua math.randomseed(98) ?>
+
+    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+
+    <SimpleNotification message="Reach the last check point within 150 seconds!!" />
+
+    <!-- ------------------SpawnPoint----------------- -->
+    <SpawnPoint position="0,-2100,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="true" >
+      <events>
+        <activity>
+          <EventTrigger invert="true">
+            <events>
+                <trigger>
+                    <EventListener event="checkpoint2" />
+                </trigger>
+            </events>
+          </EventTrigger>
+        </activity>
+      </events>
+    </SpawnPoint>
+    
+    <!-- ------------------CheckPoints----------------- -->
+    <RaceCheckPoint name="checkpoint1" position="0,-2000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="false">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <RaceCheckPoint name="checkpoint2" position="0,-900,2300" stayActive="true" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+            <SpawnPoint position="0,0,0" lookat="0,1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+                <events>
+                <activity>
+                    <Trigger mode="xor" invert="true" >
+                        <EventTrigger>
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint2" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                        <EventTrigger invert="true">
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint3" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                    </Trigger>
+                </activity>
+                </events>
+            </SpawnPoint>
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <RaceCheckPoint name="checkpoint3" position="0,700,2700" stayActive="true" direction="0,0,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+            <SpawnPoint position="0,0,0" lookat="0,1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+                <events>
+                <activity>
+                    <Trigger mode="xor" invert="true" >
+                        <EventTrigger>
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint3" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                        <EventTrigger invert="true">
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint4" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                    </Trigger>
+                </activity>
+                </events>
+            </SpawnPoint>
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <RaceCheckPoint name="checkpoint4" position="0,2100,2300" stayActive="true" direction="0,1,1" collisionType="static" scale="1" distance="40" checkpointindex="3" islast="false">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+            <DistanceTrigger name="trigger3" position="0,0,0" distance=40 stayActive="true" />
+            <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+                <events>
+                <activity>
+                    <Trigger mode="xor" invert="true" >
+                        <EventTrigger>
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint4" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                        <EventTrigger invert="true">
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint5" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                    </Trigger>
+                </activity>
+                </events>
+            </SpawnPoint>
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <RaceCheckPoint name="checkpoint5" position="0,2200,500" stayActive="true" direction="0,1,0" collisionType="static" scale="1" distance="40" checkpointindex="4" islast="false">
+        <attached>
+        <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+        <DistanceTrigger name="trigger4" position="0,0,0" distance=40 stayActive="true" />
+        <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+            <events>
+            <activity>
+                <Trigger mode="xor" invert="true" >
+                    <EventTrigger>
+                        <events>
+                            <trigger>
+                                <EventListener event="checkpoint5" />
+                            </trigger>
+                        </events>
+                    </EventTrigger>
+                    <EventTrigger invert="true">
+                        <events>
+                            <trigger>
+                                <EventListener event="checkpoint6" />
+                            </trigger>
+                        </events>
+                    </EventTrigger>
+                </Trigger>
+            </activity>
+            </events>
+        </SpawnPoint>
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <RaceCheckPoint name="checkpoint6" position="0,1500,-800" stayActive="true" direction="0,1,-1" collisionType="static" scale="1" distance="40" checkpointindex="5" islast="false">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+            <DistanceTrigger name="trigger5" position="0,0,0" distance=40 stayActive="true" />
+            <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+                <events>
+                <activity>
+                    <Trigger mode="xor" invert="true" >
+                        <EventTrigger>
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint6" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                        <EventTrigger invert="true">
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint7" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                    </Trigger>
+                </activity>
+                </events>
+            </SpawnPoint>
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <RaceCheckPoint name="checkpoint7" position="0,200,-1900" stayActive="true" collisionType="static" scale="1" distance="40" checkpointindex="6" islast="false">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+            <DistanceTrigger name="trigger6" position="0,0,0" distance=40 stayActive="true" />
+            <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+                <events>
+                <activity>
+                    <Trigger mode="xor" invert="true" >
+                        <EventTrigger>
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint7" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                        <EventTrigger invert="true">
+                            <events>
+                                <trigger>
+                                    <EventListener event="checkpoint8" />
+                                </trigger>
+                            </events>
+                        </EventTrigger>
+                    </Trigger>
+                </activity>
+                </events>
+            </SpawnPoint>
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <RaceCheckPoint name="checkpoint8" position="0,-700,-1400" stayActive="true" direction="0,-1,-1" collisionType="static" scale="1" distance="40" checkpointindex="7" islast="false">
+        <attached>
+        <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+        <DistanceTrigger name="trigger7" position="0,0,0" distance=40 stayActive="true" />
+        <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+            <events>
+            <activity>
+                <Trigger mode="xor" invert="true" >
+                    <EventTrigger>
+                        <events>
+                            <trigger>
+                                <EventListener event="checkpoint8" />
+                            </trigger>
+                        </events>
+                    </EventTrigger>
+                    <EventTrigger invert="true">
+                        <events>
+                            <trigger>
+                                <EventListener event="checkpoint9" />
+                            </trigger>
+                        </events>
+                    </EventTrigger>
+                </Trigger>
+            </activity>
+            </events>
+        </SpawnPoint>
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <RaceCheckPoint name="checkpoint9" position="0,-1300,-800" stayActive="true" collisionType="static" scale="1" distance="40" checkpointindex="8" islast="false">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+            <DistanceTrigger name="trigger8" position="0,0,0" distance=40 stayActive="true" />
+            <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+                <events>
+                <activity>
+                    <EventTrigger>
+                        <events>
+                            <trigger>
+                                <EventListener event="checkpoint9" />
+                            </trigger>
+                        </events>
+                    </EventTrigger>
+                </activity>
+                </events>
+            </SpawnPoint>
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <RaceCheckPoint name="checkpoint10" position="0,-2100,0" collisionType="static" scale="1" distance="40" checkpointindex="9" islast="true" timelimit="150">
+        <attached>
+        <   Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+    <!-- ------------------Planet----------------- -->
+    <Planet position="0,0,0" scale=300 pitch=-90 mesh="iceplanet.mesh" atmosphere="atmosphere1" rotationaxis="8,1,0" rotationrate="1" atmospheresize=224.0f imagesize=1024.0f />
+    <StaticEntity position="0,0,0" collisionType=static>
+        <collisionShapes>
+            <SphereCollisionShape radius="399" />
+        </collisionShapes>
+    </StaticEntity>
+
+    <!-- ---------------asteroid ellypse----------------- -->
+    <?lua
+    max = 20
+    for i = 0, max, 1
+    do
+    y = math.sin(i/max*6)*2000
+    z = math.cos(i/max*6)*2500
+    x = 0
+    ?>
+    <?lua
+    for k = 1, 15, 1
+    do
+    j = math.random()
+    ?>
+
+    <MovableEntity
+      position = "<?lua print(x + math.random() * 500) ?>,<?lua print(y + math.random() * 500) ?>,<?lua print(z + math.random() * 1000) ?>"
+      collisionType = "dynamic"
+      linearDamping = "0.5"
+      angularDamping = "0.01"
+      collisiondamage = "0.01"
+      enablecollisiondamage = "true"
+      scale="<?lua print(j * 5) ?>" >
+      <attached>
+        <Model position="0,0,0" scale="<?lua print(j * 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh">
+      <?lua if k == 5 then ?><attached><!-- ---------asteroid fog----- -->
+            <ParticleEmitter position="0,0,0" source="Orxonox/Steam" />
+          </attached> <?lua end ?>
+        </Model>
+      </attached>
+      <collisionShapes>
+        <SphereCollisionShape radius="<?lua print(j * 80) ?>" />
+      </collisionShapes>
+    </MovableEntity>
+    <?lua
+    end
+    ?>
+    <?lua end ?>
+
+    <!-- ---------------ForceFields----------------- -->
+    <ForceField position="0,-700,2700" direction="0,1,0" diameter=500 velocity=2000 length=600 />
+        <MovableEntity position="0,-400,2700">
+            <attached>
+                <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.5,0,0" scale=2/>
+                <?lua for i=0,15,1 do ?>
+                    <Billboard position="-200,<?lua print(i*40) ?>,0" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                    <Billboard position="200,<?lua print(i*40) ?>,0" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                <?lua end ?>
+                </attached>
+        </MovableEntity>
+
+     <ForceField position="0,2500,2000" direction="0,0,-1" diameter=250 velocity=2000 length=600 />
+        <MovableEntity position="0,2500,2000">
+            <attached>
+                <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.5,0,0" scale=2/>
+                <?lua for i=0,15,1 do ?>
+                    <Billboard position="-100,0,-<?lua print(i*40) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                    <Billboard position="100,0,-<?lua print(i*40) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                <?lua end ?>
+                </attached>
+        </MovableEntity>
+
+    <ForceField position="0,1300,-800" direction="0,-1,-1" diameter=250 velocity=2000 length=800 />
+        <MovableEntity position="0,1300,-800">
+            <attached>
+                <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.5,0,0" scale=2/>
+                <?lua for i=0,20,1 do ?>
+                    <Billboard position="-100,<?lua print(-i*40*0.7071) ?>,<?lua print(-i*40*0.7071) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                    <Billboard position="100,<?lua print(-i*40*0.7071) ?>,<?lua print(-i*40*0.7071) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                <?lua end ?>
+                </attached>
+        </MovableEntity>
+
+    <ForceField position="0,-1400,-700" direction="0,-1,1" diameter=250 velocity=2000 length=600 />
+        <MovableEntity position="0,-1400,-700">
+            <attached>
+                <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.5,0,0" scale=2/>
+                <?lua for i=0,15,1 do ?>
+                    <Billboard position="-100,<?lua print(-i*40*0.7071) ?>,<?lua print(i*40*0.7071) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                    <Billboard position="100,<?lua print(-i*40*0.7071) ?>,<?lua print(i*40*0.7071) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                <?lua end ?>
+                </attached>
+        </MovableEntity>
+
+    <!-- ---------------SpaceShips----------------- -->
+    <SpaceShip position="0,2000,2000" lookat="0,0,0" team=1 >
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+         <WaypointPatrolController alertnessradius=1500 team=0 >
+            <waypoints>
+                <Model scale=0 position="0,2000,2000" />
+            </waypoints>
+         </WaypointPatrolController>
+      </controller>
+    </SpaceShip>
+
+    <SpaceShip position="0,2000,-2000" lookat="0,0,0" team=1 >
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WaypointPatrolController alertnessradius=1500 team=0 >
+            <waypoints>
+                <Model scale=0 position="0,2000,-2000" />
+            </waypoints>
+        </WaypointPatrolController>
+      </controller>
+    </SpaceShip>
+
+  </Scene>
+</Level>
Index: /code/branches/presentation/src/modules/CMakeLists.txt
===================================================================
--- /code/branches/presentation/src/modules/CMakeLists.txt	(revision 8630)
+++ /code/branches/presentation/src/modules/CMakeLists.txt	(revision 8631)
@@ -27,4 +27,5 @@
 
 ADD_SUBDIRECTORY(designtools)
+ADD_SUBDIRECTORY(gametypes)
 ADD_SUBDIRECTORY(notifications)
 ADD_SUBDIRECTORY(objects)
Index: /code/branches/presentation/src/modules/gametypes/CMakeLists.txt
===================================================================
--- /code/branches/presentation/src/modules/gametypes/CMakeLists.txt	(revision 8631)
+++ /code/branches/presentation/src/modules/gametypes/CMakeLists.txt	(revision 8631)
@@ -0,0 +1,16 @@
+SET_SOURCE_FILES(GAMETYPES_SRC_FILES
+  SpaceRace.cc
+  RaceCheckPoint.cc
+)
+
+ORXONOX_ADD_LIBRARY(gametypes
+  MODULE
+  FIND_HEADER_FILES
+  TOLUA_FILES
+  PCH_FILE
+    GametypesPrecompiledHeaders.h
+  LINK_LIBRARIES
+    orxonox
+    objects
+  SOURCE_FILES ${GAMETYPES_SRC_FILES}
+)
Index: /code/branches/presentation/src/modules/gametypes/GametypesPrecompiledHeaders.h
===================================================================
--- /code/branches/presentation/src/modules/gametypes/GametypesPrecompiledHeaders.h	(revision 8631)
+++ /code/branches/presentation/src/modules/gametypes/GametypesPrecompiledHeaders.h	(revision 8631)
@@ -0,0 +1,53 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+*/
+
+#include "OrxonoxConfig.h"
+
+///////////////////////////////////////////
+/////          Stable Headers         /////
+///////////////////////////////////////////
+
+#include <LinearMath/btTransform.h>
+
+///////////////////////////////////////////
+/////       All Rebuild Headers       /////
+///////////////////////////////////////////
+
+#include "core/BaseObject.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+
+// Just in case some header included windows.h
+#undef min
+#undef max
Index: /code/branches/presentation/src/modules/gametypes/GametypesPrereqs.h
===================================================================
--- /code/branches/presentation/src/modules/gametypes/GametypesPrereqs.h	(revision 8631)
+++ /code/branches/presentation/src/modules/gametypes/GametypesPrereqs.h	(revision 8631)
@@ -0,0 +1,70 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Shared library macros, enums, constants and forward declarations for the questsystem module
+*/
+
+#ifndef _GametypesPrereqs_H__
+#define _GametypesPrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(Gametypes_STATIC_BUILD)
+#  ifdef Gametypes_SHARED_BUILD
+#    define _GametypesExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _GametypesExport
+#    else
+#      define _GametypesExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _GametypesExport  __attribute__ ((visibility("default")))
+#else
+#  define _GametypesExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+    class SpaceRace;
+}
+
+#endif /* _GametypesPrereqs_H__ */
Index: /code/branches/presentation/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- /code/branches/presentation/src/modules/gametypes/RaceCheckPoint.cc	(revision 8631)
+++ /code/branches/presentation/src/modules/gametypes/RaceCheckPoint.cc	(revision 8631)
@@ -0,0 +1,118 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Mauro Salomon
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "RaceCheckPoint.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "SpaceRace.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    CreateFactory(RaceCheckPoint);
+    
+    RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
+    {
+        RegisterObject(RaceCheckPoint);
+
+        this->bCheckpointIndex_ = 0;
+        this->bIsLast_ = false;
+        this->bTimeLimit_ = 0;
+
+        this->setRadarObjectColour(ColourValue::Blue);
+        this->setRadarObjectShape(RadarViewable::Triangle);
+        this->setRadarVisibility(false);
+    }
+    
+    RaceCheckPoint::~RaceCheckPoint()
+    {
+    }
+    
+    void RaceCheckPoint::tick(float dt)
+    {
+        SUPER(RaceCheckPoint, tick, dt);
+
+        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        if (this->getCheckpointIndex() == gametype->getCheckpointsReached())
+            this->setRadarVisibility(true);
+        else
+            this->setRadarVisibility(false);
+    }
+
+    
+    void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(RaceCheckPoint, XMLPort, xmlelement, mode);
+
+        XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0);
+        XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false);
+        XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
+    }
+    
+    void RaceCheckPoint::triggered(bool bIsTriggered)
+    {
+        DistanceTrigger::triggered(bIsTriggered);
+
+        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        if (gametype && this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered)
+        {
+            gametype->clock_.capture();
+            float time = gametype->clock_.getSecondsPrecise();
+            if (this->bTimeLimit_!=0 && time > this->bTimeLimit_)
+            {
+                gametype->timeIsUp();
+                gametype->end();
+            }
+            else if (this->getLast())
+                gametype->end();
+            else
+            {
+                gametype->newCheckpointReached();
+                this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
+            }
+        }
+    }
+    
+    void RaceCheckPoint::setTimelimit(float timeLimit)
+    {
+        this->bTimeLimit_ = timeLimit;
+        if (this->bTimeLimit_ != 0)
+        {
+            SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+            if (gametype)
+            {
+                const std::string& message =  "You have " + multi_cast<std::string>(this->bTimeLimit_)
+                            + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1) + "\n";
+                COUT(3) << message;
+                const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message);
+            }
+        }
+    }
+    
+}
Index: /code/branches/presentation/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- /code/branches/presentation/src/modules/gametypes/RaceCheckPoint.h	(revision 8631)
+++ /code/branches/presentation/src/modules/gametypes/RaceCheckPoint.h	(revision 8631)
@@ -0,0 +1,78 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Mauro Salomon
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _RaceCheckPoint_H__
+#define _RaceCheckPoint_H__
+
+#include "objects/ObjectsPrereqs.h"
+
+#include "objects/triggers/DistanceTrigger.h"
+#include "interfaces/RadarViewable.h"
+//#include <boost/concept_check.hpp>
+
+namespace orxonox
+{
+  /**
+  @brief
+    The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
+    !!! Don't forget to control the indexes of your check points and to set one last check point!!!
+  */
+    class _ObjectsExport RaceCheckPoint : public DistanceTrigger, public RadarViewable
+    {
+        public:
+            RaceCheckPoint(BaseObject* creator);
+            virtual ~RaceCheckPoint();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+
+            protected:
+            virtual void triggered(bool bIsTriggered);
+            inline void setLast(bool isLast)
+                { this->bIsLast_ = isLast; }
+            inline bool getLast()
+                { return this->bIsLast_; }
+            inline void setCheckpointIndex(int checkpointIndex)
+                { this->bCheckpointIndex_ = checkpointIndex; }
+            inline int getCheckpointIndex()
+                { return this->bCheckpointIndex_; }
+            virtual void setTimelimit(float timeLimit);
+            inline float getTimeLimit()
+                { return this->bTimeLimit_;}
+            inline const WorldEntity* getWorldEntity() const
+                { return this; }
+
+        private:
+            int bCheckpointIndex_; //The index of this check point. This value will be compared with the number of check points reached in the level. The check points must be indexed in ascending order beginning from zero and without any jumps between the indexes.
+            bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
+            float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
+      
+    };
+}
+
+#endif /* _RaceCheckPoint_H__ */
Index: /code/branches/presentation/src/modules/gametypes/SpaceRace.cc
===================================================================
--- /code/branches/presentation/src/modules/gametypes/SpaceRace.cc	(revision 8631)
+++ /code/branches/presentation/src/modules/gametypes/SpaceRace.cc	(revision 8631)
@@ -0,0 +1,106 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *     Mauro Salomon
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "SpaceRace.h"
+
+#include "core/CoreIncludes.h"
+#include "network/Host.h"
+#include <util/Clock.h>
+#include <util/Math.h>
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    CreateUnloadableFactory(SpaceRace);
+    
+    SpaceRace::SpaceRace(BaseObject* creator) : Gametype(creator)
+    {
+        RegisterObject(SpaceRace);
+        this->bCheckpointsReached_ = 0;
+        this->bTimeIsUp_ = false;
+        this->numberOfBots_ = 0;
+    }
+    
+    void SpaceRace::end()
+    {
+        this->Gametype::end();
+          
+        if (this->bTimeIsUp_)
+        {
+            this->clock_.capture();
+            int s = this->clock_.getSeconds();
+            int ms = this->clock_.getMilliseconds()-1000*s;
+            const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
+                        + "You didn't reach the check point " + multi_cast<std::string>(this->bCheckpointsReached_+1)
+                        + " before the time limit. You lose!";
+            COUT(3) << message;
+            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+            Host::Broadcast(message);
+        }
+        else
+        {
+            this->clock_.capture();
+            int s = this->clock_.getSeconds();
+            int ms = this->clock_.getMilliseconds()-1000*s;
+            const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
+                        + "." + multi_cast<std::string>(ms) + " seconds.";
+            COUT(3) << message << std::endl;
+            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+            Host::Broadcast(message);
+            float time = this->clock_.getSecondsPrecise();
+            this->scores_.insert(time);
+            std::set<float>::iterator it;
+            for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
+            COUT(3) <<  multi_cast<std::string>(*it) << std::endl;
+        }
+    }
+
+    void SpaceRace::start()
+    {
+        Gametype::start();
+
+        std::string message("The match has started! Reach the check points as quickly as possible!");
+        COUT(3) << message << std::endl;
+        Host::Broadcast(message);
+    }
+    
+    void SpaceRace::newCheckpointReached()
+    {
+        this->bCheckpointsReached_++;
+        this->clock_.capture();
+        int s = this->clock_.getSeconds();
+        int ms = this->clock_.getMilliseconds()-1000*s;
+        const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
+                        + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
+                        + " seconds.\n";
+        COUT(3) << message;
+        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+        Host::Broadcast(message);
+    }
+
+}
Index: /code/branches/presentation/src/modules/gametypes/SpaceRace.h
===================================================================
--- /code/branches/presentation/src/modules/gametypes/SpaceRace.h	(revision 8631)
+++ /code/branches/presentation/src/modules/gametypes/SpaceRace.h	(revision 8631)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Mauro Salomon
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _SpaceRace_H__
+#define _SpaceRace_H__
+
+#include "gametypes/Gametype.h"
+#include "gametypes/GametypesPrereqs.h"
+#include "RaceCheckPoint.h"
+#include <boost/concept_check.hpp>
+#include <util/Clock.h>
+#include <string.h>
+#include <set>
+
+namespace orxonox
+{
+  /**
+  @brief
+    The SpaceRace class enables the creation of a space race level, where the player has to reach check points in a given order.
+  */
+    class _OrxonoxExport SpaceRace : public Gametype
+    {
+        friend class RaceCheckPoint;
+        
+        public:
+            SpaceRace(BaseObject* creator);
+            virtual ~SpaceRace() {}
+
+            virtual void start();
+                virtual void end();
+
+            virtual void newCheckpointReached();
+
+            inline void setCheckpointsReached(int n)
+            { this->bCheckpointsReached_ = n;}
+            inline int getCheckpointsReached()
+            { return this->bCheckpointsReached_; }
+            inline void timeIsUp()
+            { this->bTimeIsUp_ = true;}
+
+        protected:
+
+        private:
+            int bCheckpointsReached_; //The current number of check points reached by the player.
+            std::set<float> scores_; //The times of the players are saved in a set.
+            bool bTimeIsUp_; //True if one of the check points is reached too late.
+            Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
+    };
+}
+
+#endif /* _SpaceRace_H__ */
Index: /code/branches/presentation/src/orxonox/gametypes/Gametype.cc
===================================================================
--- /code/branches/presentation/src/orxonox/gametypes/Gametype.cc	(revision 8630)
+++ /code/branches/presentation/src/orxonox/gametypes/Gametype.cc	(revision 8631)
@@ -306,10 +306,12 @@
     SpawnPoint* Gametype::getBestSpawnPoint(PlayerInfo* player) const
     {
+        // If there is at least one SpawnPoint.
         if (this->spawnpoints_.size() > 0)
         {
+            // Fallback spawn point if there is no active one, choose a random one.
             SpawnPoint* fallbackSpawnPoint = NULL;
             unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
             unsigned int index = 0;
-            std::set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_;
+            std::vector<SpawnPoint*> activeSpawnPoints;
             for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)
             {
@@ -317,20 +319,17 @@
                     fallbackSpawnPoint = (*it);
 
-                if (!(*it)->isActive())
-                    activeSpawnPoints.erase(*it);
+                if (*it != NULL && (*it)->isActive())
+                    activeSpawnPoints.push_back(*it);
 
                 ++index;
             }
 
-            randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
-            index = 0;
-            for (std::set<SpawnPoint*>::const_iterator it = activeSpawnPoints.begin(); it != activeSpawnPoints.end(); ++it)
-            {
-                if (index == randomspawn)
-                    return (*it);
-
-                ++index;
-            }
-
+            if(activeSpawnPoints.size() > 0)
+            {
+                randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(activeSpawnPoints.size())));
+                return activeSpawnPoints[randomspawn];
+            }
+
+            COUT(2) << "Warning: Fallback SpawnPoint was used, because there were no active SpawnPoints." << endl;
             return fallbackSpawnPoint;
         }
