- Timestamp:
- Oct 4, 2015, 3:45:56 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 5 deleted
- 59 edited
- 39 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/data/defaultConfig/keybindings.ini
r10281 r10622 142 142 KeyWebStop= 143 143 KeyX="selectClosest" 144 KeyY= 144 KeyY="onpress fire 4" 145 145 KeyYen= 146 146 KeyZ="selectNext" -
code/trunk/data/gui/scripts/MultiplayerMenu.lua
r8858 r10622 70 70 if choice then 71 71 local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID() 72 destination = P.serverList[index][ 2]72 destination = P.serverList[index][1] 73 73 else 74 74 return … … 93 93 local servername = "" 94 94 local serverip = "" 95 local serverrtt = "" 96 local playernumber = "" 95 97 while true do 96 98 servername = discovery:getServerListItemName(index) … … 102 104 break 103 105 end 104 table.insert(P.serverList, {servername, serverip}) 106 --serverrtt = discovery:getServerListItemRTT(index) 107 playernumber = discovery:getServerListItemPlayerNumber(index) 108 109 table.insert(P.serverList, {serverip, servername, playernumber}) 105 110 index = index + 1 106 111 end 107 112 index = 1 108 113 for k,v in pairs(P.serverList) do 109 local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2])114 local item = CEGUI.createListboxTextItem("IP: " .. v[1] .. " Name: " .. v[2] .. " Players: " .. v[3]) 110 115 item:setID(index) 111 116 index = index + 1 … … 125 130 local servername = "" 126 131 local serverip = "" 132 local serverrtt = "" 133 local playernumber = "" 127 134 while true do 128 135 servername = discovery:getServerListItemName(index) … … 134 141 break 135 142 end 136 table.insert(P.serverList, {servername, serverip}) 143 --serverrtt = discovery:getServerListItemRTT(index) 144 playernumber = discovery:getServerListItemPlayerNumber(index) 145 146 table.insert(P.serverList, {serverip, servername, playernumber}) 137 147 index = index + 1 138 148 end 139 149 index = 1 140 150 for k,v in pairs(P.serverList) do 141 local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2])151 local item = CEGUI.createListboxTextItem("IP: " .. v[1] .. " Name: " .. v[2] .. " Players: " .. v[3]) 142 152 item:setID(index) 143 153 index = index + 1 … … 150 160 151 161 return P 152 -
code/trunk/data/gui/scripts/testscript.lua
r10262 r10622 22 22 -- If it worked, call its "movetoposition" function 23 23 if ctrl ~= nil then 24 -- Move to the starting point at (xl+3000,yl,zl) while looking25 -- at xl,yl,zl over the time span of 3 seconds26 ctrl:eventScheduler("mal", xl+3000,yl,zl, xl,yl,zl, 1, 0)27 24 28 -- From there, perform a rotation around the harvester placed there 29 -- in 100 steps 30 dt = math.pi/100 31 for t = 0,math.pi,dt do 32 xt = math.cos(t) 33 yt = math.sin(t) 34 35 ctrl:eventScheduler("mal", xl+3000*xt, yl+3000*yt, zl, xl, yl, zl, dt, t+0.9) 36 end 37 38 39 -- Update absolute time 40 Tabs = math.pi + 0.9 41 42 43 44 -- Move away again, still looking at the station 45 ctrl:eventScheduler("mal", 0,0,1000, xl,yl,zl, 3, Tabs+0.4) 46 47 48 49 -- Update absolute time 50 Tabs = Tabs + 0.4 + 3 51 52 53 54 55 56 -- Transition the look from (xl,yl,zl) to (3500,0,0) in 3 seconds 57 ctrl:eventScheduler("chl", xl, yl, zl, xr, yr, zr, 2, Tabs+0.2) 58 59 Tabs = Tabs + 2 + 0.2 60 61 ctrl:eventScheduler("mal", xr + 600,yr,zr, xr,yr,zr, 4, Tabs+0) 62 63 Tabs = Tabs + 4 64 65 for t = 0,math.pi,dt do 66 xt = math.cos(t) 67 zt = math.sin(t) 68 69 ctrl:eventScheduler("mal", xr+600*xt, yr, zr+600*zt, xr, yr, zr, dt, Tabs+t) 70 end 71 72 Tabs = Tabs + math.pi 73 74 ctrl:eventScheduler("chl", xr, yr, zr, xl, yl, zl, 3, Tabs+0.2) 75 76 Tabs = Tabs + 3 + 0.2 77 78 ctrl:eventScheduler("mal", xm,ym,zm, xl,yl,zl, 4, Tabs+2.5) 79 25 ctrl:eventScheduler("mal", xl,yl,zl, xl,yl,zl, 2) 26 ctrl:eventScheduler("idle", 1) 27 ctrl:eventScheduler("ral", xl, yl, zl, 3, 3000, 0, math.pi) 28 ctrl:eventScheduler("idle", 1) 29 ctrl:eventScheduler("mal", 0,0,1000, xl,yl,zl, 3) 30 ctrl:eventScheduler("idle", 1) 31 ctrl:eventScheduler("chl", xl, yl, zl, xr, yr, zr, 2) 32 ctrl:eventScheduler("idle", 1) 33 ctrl:eventScheduler("mal", xr + 600,yr,zr, xr,yr,zr, 4) 34 ctrl:eventScheduler("idle", 1) 35 ctrl:eventScheduler("chl", xr, yr, zr, xl, yl, zl, 3) 36 ctrl:eventScheduler("idle", 1) 37 ctrl:eventScheduler("spi", xm,ym,zm, 0,0,0, 4) 38 ctrl:eventScheduler("idle", 1) 80 39 81 40 end 82 83 84 85 -- Output the newctrlid variable we set from the C++ code86 if newctrlid ~= nil then87 orxonox.execute("orxout message test " .. newctrlid)88 end89 90 --orxonox.execute("setPause 1")91 92 -
code/trunk/data/levels/includes/weaponSettingsAssff.oxi
r8868 r10622 25 25 </attached> 26 26 <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" /> 27 <EnergyDrink mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" muzzleoffset="2,-0.2,-1" /> 27 28 <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-1.6, 1.3,-2" /> 28 29 <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20 /> … … 39 40 </Weapon> 40 41 <Weapon> 41 <SimpleRocketFire mode=2 muzzleoffset="0,0,0" damage=30 shielddamage=20 />42 <SimpleRocketFire mode=2 muzzleoffset="0,0,0" damage=30 healthdamage=50 shielddamage=20 /> 42 43 <RocketFire mode=3 muzzleoffset="0,0,0" damage=30 healthdamage=50 shielddamage=20 /> 43 44 </Weapon> -
code/trunk/data/levels/scriptController.oxw
r10262 r10622 1 1 <!-- First levelFile of mkronig and samuezu. It was copied from dockingToASpaceStation.oxw and modified a little bit --> 2 2 <LevelInfo 3 name = " Fancy orxout tests"4 description = " Docking into a spacestation."3 name = "Scriptable Controller" 4 description = "Showcase for Scriptable Controller" 5 5 tags = "showcase" 6 6 screenshot = "emptylevel.png" … … 11 11 include("HUDTemplates3.oxo") 12 12 include("templates/lodInformation.oxt") 13 include("templates/pickupRepresentationTemplates.oxt")14 13 ?> 15 14 16 15 <?lua 17 include("templates/spaceshipAssff.oxt")18 include("templates/spaceshipPirate.oxt")19 16 include("templates/spaceshipEscort.oxt") 20 include("templates/bigship.oxt")21 include("templates/spaceshipTurret.oxt")22 include("templates/spaceshipCollateralDamage.oxt")23 include("templates/FPS.oxt")24 17 ?> 25 18 … … 40 33 > 41 34 42 <?lua 43 include("includes/pickups.oxi") 44 ?> 35 <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0,1.0,1.0,0.5" specular="1.0, 0.9, 0.9, 1.0"/> 45 36 46 <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0,1.0,1.0,0.5" specular="1.0, 0.9, 0.9, 1.0"/>47 37 <SpawnPoint team=0 position="3200,0,0" lookat="2800,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort /> 48 38 49 <StaticEntity position = "2800,0,0" mass=10000 collisionType=static > 39 <Billboard position="2500,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=10 /> 40 <DistanceTrigger position="2500,0,0" distance="200" target="Pawn" 41 beaconMode="exclude" targetname="bcnDestroyer" name="takeControl" 42 /> 43 44 <StaticEntity position = "2000,500,2000" mass=10000 collisionType=static > 50 45 <attached> 51 <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale= 50 />46 <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale=10 /> 52 47 </attached> 53 <collisionShapes>54 <BoxCollisionShape position="-560,0,0" halfExtents="115,100,245" /><!-- Three lower boxes -->55 <BoxCollisionShape position="290,0,-480" halfExtents="115,100,245" yaw=-120 />56 <BoxCollisionShape position="290,0,480" halfExtents="115,100,245" yaw=-240 />57 <BoxCollisionShape position="-280,0,0" halfExtents="163,50,50" /><!-- Three lower connections -->58 <BoxCollisionShape position="140,0,-240" halfExtents="163,50,50" yaw=-120 />59 <BoxCollisionShape position="140,0,240" halfExtents="163,50,50" yaw=-240 />60 <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" /><!-- Upper Tower -->61 <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" yaw=-120 />62 <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" yaw=-240 />63 <BoxCollisionShape position="0,400,0" halfExtents="43,110,26" yaw=-30 /><!-- Middle one-->64 <BoxCollisionShape position="-200,100,0" halfExtents="26,50,43" /><!--Three lower legs -->65 <BoxCollisionShape position="100,100,-173" halfExtents="43,50,26" yaw=-30 />66 <BoxCollisionShape position="100,100,-173" halfExtents="43,50,26" yaw=30 />67 <BoxCollisionShape position="-100,264,0" halfExtents="26,105,43" roll=-49 /><!--Three upper legs -->68 <BoxCollisionShape position="50,264,-87" halfExtents="26,105,43" roll=-49 yaw=-120 />69 <BoxCollisionShape position="50,264,87" halfExtents="26,105,43" roll=-49 yaw=-240 />70 </collisionShapes>71 48 </StaticEntity> 72 49 73 <!-- Docking -->74 <Dock position="2830,20,50" roll=0 yaw=0>75 < animations>76 <MoveToDockingTarget target="destroyer" />77 </animations>78 <effects> 79 <DockToShip target="spaceShip" />80 </effects>50 <StaticEntity position = "-1000,3000,-1000" mass=10000 collisionType=static > 51 <attached> 52 <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale=80 /> 53 </attached> 54 </StaticEntity> 55 56 <!-- ControllerDirector waits for the event takeControl to attach a new Controller --> 57 <ControllerDirector position="0,0,0" scriptname="presentation"> 81 58 <events> 82 <execute> 83 <EventListener event="dockMe" /> 84 </execute> 85 86 <undocking> 87 <EventListener event="undockMe" /> 88 </undocking> 89 90 <activity> 91 <EventListener event=notGameEnd /> 92 </activity> 59 <takeControl> 60 <EventListener event="takeControl" /> 61 </takeControl> 93 62 </events> 94 <attached> 95 <!-- Trigger for docking with billboard --> 96 97 <!-- removed --> 98 99 <!-- Trigger for undocking with billboard --> 100 <!-- <Billboard position="-2630,-19970,150" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=1 /> --> 101 <DistanceTrigger position="-2630,-19970,150" distance="50" target="Pawn" 102 beaconMode="identify" targetname="bcnDestroyer" name="undockMe" 103 /> 104 </attached> 105 </Dock> 106 107 <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=100 /> 108 <DistanceTrigger position="0,0,0" distance="200" target="Pawn" 109 beaconMode="exclude" targetname="bcnDestroyer" name="dockMe" 110 /> 111 112 113 <!-- Object, which orxouts the message "hello Universe!". EVENT NOT WORKING --> 114 <ScriptController position="0,0,0"> 115 <events> 116 <party> 117 <EventListener event="dockMe" /> 118 </party> 119 120 </events> 121 122 </ScriptController> 123 124 125 <!-- FPS Player as destination of the dock --> 126 <FpsPlayer template = "fps" radarname = "First Person Player" position = "0,-19900,0" > 127 <attached> 128 <DockingTarget name="spaceShip" /> 129 <DistanceTriggerBeacon name="bcnDestroyer" /> 130 <DockingTarget name="destroyer" /> 131 </attached> 132 </FpsPlayer> 133 134 135 <!-- Cube as test SpaceStation 136 137 The station can either be hidden outside of the skybox, within the hull of the space station if it is big enough or within a planet. 138 Complex spacestations can be placed very far away from the spaceship so it is rendered at low resolution while the player uses the space ship. 139 140 --> 141 <StaticEntity position="0,-20000,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01 > 142 <attached> 143 <Model position="0,0,0" mesh="crate.mesh" scale3D="80,80,5" /> 144 </attached> 145 <collisionShapes> 146 <BoxCollisionShape position="0,0,0" halfExtents="400,400,25" /> 147 </collisionShapes> 148 </StaticEntity> 149 150 <!-- Homogenous gravitationfield to simulate local gravity (activating the normal gravity will affect the spaceship terribly) --> 151 <ForceField position="0,-20000,0" mode="homogen" diameter="2000" forcedirection = "0,-500,0" /> 152 153 154 <!-- Some more stuff --> 155 156 <!-- triple large belt around the planet --> 157 <?lua 158 dofile("includes/asteroidField.lua") 159 asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 7190, 7800, 250, 1) 160 ?> 161 <?lua 162 dofile("includes/asteroidField.lua") 163 asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 10000, 11000, 300, 1) 164 ?> 165 <?lua 166 dofile("includes/asteroidField.lua") 167 asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 14000, 15000, 350, 1) 168 ?> 169 170 <Planet 171 position="15000,0,-1000" 172 scale="5000" 173 collisionType="dynamic" 174 linearDamping="0.8" 175 angularDamping="0" 176 mass="10000000" 177 pitch="0" 178 mesh="planets/ganymede.mesh" 179 atmosphere="atmosphere1" 180 rotationaxis="1,0,0" 181 rotationrate="1.0" 182 atmospheresize="80.0f" 183 imagesize="1024.0f" 184 collisiondamage = 2 185 enablecollisiondamage = true 186 > 187 <attached> 188 <ForceField position="5000,0,0" mode="sphere" diameter="10000" velocity="-50" /> 189 </attached> 190 <collisionShapes> 191 <SphereCollisionShape radius="5000" position="0,0,0" /> 192 </collisionShapes> 193 </Planet> 63 </ControllerDirector> 194 64 195 65 </Scene> 196 197 66 </Level> 198 67 -
code/trunk/data/levels/templates/enemytowerdefense.oxt
r10262 r10622 167 167 maxhealth = 200 168 168 initialhealth = 100 169 169 170 170 shieldhealth = 30 171 171 initialshieldhealth = 30 -
code/trunk/data/levels/towerDefense.oxw
r10258 r10622 20 20 include("templates/spaceshipAssff.oxt") 21 21 include("templates/spaceshipPirate.oxt") 22 include("templates/tower .oxt")22 include("templates/towerdefensetower.oxt") 23 23 include("templates/enemytowerdefense.oxt") 24 24 include("templates/standardTurret.oxt") 25 25 ?> 26 26 27 <!-- Specify the position of the camera --> 28 <Template name= centerpointmarkcameradefaults=0>29 < Pawn team=1>27 28 <Template name=selectercameras defaults=0> 29 <TowerDefenseSelecter> 30 30 <camerapositions> 31 <CameraPosition position="0,0,1 500"/>31 <CameraPosition position="0,0,1400" lookat="0,0,0" absolute=true /> 32 32 </camerapositions> 33 </ Pawn>33 </TowerDefenseSelecter> 34 34 </Template> 35 35 36 <!-- Loads a mesh to mark the center--> 37 <Template name=centerpointmark> 38 <Pawn team=1 camerapositiontemplate=centerpointmarkcamera> 36 <Template name=selectertemplate> 37 <TowerDefenseSelecter team=0 camerapositiontemplate=selectercameras> 39 38 <attached> 40 <Model p osition="0,0,0" mesh="cylinder.mesh" scale3D="1,1,1" /> <!-- the camera is attached to this -->39 <Model pitch=90 position="0,0,-30" mesh="TD_Selection.mesh" scale=30 /> 41 40 </attached> 42 </ Pawn>41 </TowerDefenseSelecter> 43 42 </Template> 44 45 46 <!-- Template for a tower EDIT: new towertemplate is included with "templates/tower" -->47 <!--Template name=towertemplate>48 <Tower>49 <attached>50 <Model position="0,0,0" scale=0.25 mesh="Tower_ME.mesh" />51 </attached>52 </Tower>53 </Template-->54 55 43 56 44 … … 72 60 73 61 <!-- Spawns the camera, attached to a crate --> 74 <SpawnPoint team=1 position="0,0,0" spawnclass=Pawn pawndesign=centerpointmark /> 75 <!--TeamSpawnPoint team=1 position="-7,7,4" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /--> 76 77 <!--SpawnPoint team=1 position="0,0,10" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /--> 78 <!--SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /--> 79 80 81 82 83 <!--invisible entity to attach towers to, since playfield is static and towers are dynamic--> 84 <StaticEntity team =1 position=0,0,0> 85 86 <attached> 87 <Model position="-50,-50,0" mesh="Playfield_ME.mesh" scale=80 /> 88 <!-- Base --> 89 <Model position="500,700,100" mesh="sphere.mesh" scale=80 /> 90 <!--Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" /--> <!-- Only temporary needed to help align the collisionshape --> 91 <!-- This was used to mark the playfield, let's let it be here for now --> 92 <!--Model position="-8,8,0" mesh="crate.mesh" scale3D="0.3,0.3,0.3" /--> 93 <!--Model position="-8,-8,0" mesh="crate.mesh" scale3D="0.3,0.3,0.3" /--> 94 <!--Model position="8,-8,0" mesh="crate.mesh" scale3D="0.3,0.3,0.3" /--> 95 <!--Model position="8,8,0" mesh="crate.mesh" scale3D="0.3,0.3,0.3" /--> 96 </attached> 97 <collisionShapes> <!-- The collisionshape forbids other worldentities that have a collisionShape to fly through it. 98 99 TODO: Find correct size for the collisionshape; since a collisionShape is invisible 100 I added the crate wich currently has the same dimensions as the collisionshape. 101 You have to adjust the crate's scale3D as well as the collisionshape's halfExtens to 102 find the proper shape. --> 103 <BoxCollisionShape position="0,0,0" halfExtents="400,400,100" /> 104 </collisionShapes> 105 </StaticEntity> 106 107 108 62 <SpawnPoint team=0 position="0,0,0"/> 109 63 110 64 <!-- PlayField --> 111 65 <TowerDefenseCenterpoint 112 66 name=towerdefensecenter 67 68 selecterTemplate=selectertemplate 69 113 70 width=16 114 71 height=16 115 72 tileScale=100 116 towerTemplate=tower117 73 position="0,0,0" 118 74 direction="0,0,0" 119 75 collisionType=dynamic 120 76 mass=100000 121 team=1 122 /> 77 > 78 <attached> 79 <Model position="-50,-50,0" mesh="Playfield_ME.mesh" scale=80 /> 80 <Model position="500,700,100" mesh="sphere.mesh" scale=80 /> 81 </attached> 82 <camerapositions> 83 <CameraPosition position="0,0,1500" lookat="0,0,0" absolute=true/> 84 </camerapositions> 85 </TowerDefenseCenterpoint> 123 86 124 87 </Scene> -
code/trunk/src/libraries/network/GamestateManager.h
r8402 r10622 1 /*1 /* 2 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 3 * > www.orxonox.net < … … 78 78 std::map< uint32_t, packet::Gamestate* > gamestates; 79 79 }; 80 80 81 81 public: 82 82 83 83 GamestateManager(); 84 84 ~GamestateManager(); … … 88 88 virtual uint32_t getLastReceivedGamestateID( unsigned int peerID ); 89 89 virtual uint32_t getCurrentGamestateID(){ if( currentGamestate_) return currentGamestate_->getID(); else return GAMESTATEID_INITIAL; } 90 90 91 91 bool processGamestates(); 92 92 bool sendAck(unsigned int gamestateID, uint32_t peerID); -
code/trunk/src/libraries/network/LANDiscoverable.cc
r8858 r10622 35 35 #include "util/Output.h" 36 36 #include "packet/ServerInformation.h" 37 #include "core/config/ConfigValueIncludes.h" 38 #include "core/CoreIncludes.h" 39 37 40 38 41 namespace orxonox … … 43 46 LANDiscoverable::LANDiscoverable() 44 47 { 48 /* register object in orxonox */ 49 RegisterObject(LANDiscoverable); 50 51 this->setConfigValues(); 52 // this->setActivity(true); 45 53 this->host_ = 0; 46 54 this->bActive_ = false; 47 // this->setActivity(true); 55 } 56 57 void LANDiscoverable::setConfigValues() 58 { 59 /* update ownName string from orxonox.ini config file, if it 60 * has changed. 61 */ 62 SetConfigValueExternal(ownName, "Discovery", "ownName", "OrxServer"); 48 63 } 49 64 … … 61 76 if( bActive == this->bActive_ ) // no change 62 77 return; 63 78 64 79 if( bActive ) 65 80 { … … 84 99 { 85 100 ENetEvent event; 86 101 87 102 if( this->bActive_==false ) 88 103 return; 89 104 assert(this->host_); 90 105 91 106 while( enet_host_service( this->host_, &event, 0 ) > 0 ) 92 107 { … … 104 119 orxout(internal_info, context::network) << "Received LAN discovery message from client " << event.peer->host->receivedAddress << endl; 105 120 packet::ServerInformation info; 106 info.setServerName("Orxonox Server"); 121 info.setServerName(this->ownName); 122 info.setClientNumber(this->clientNumber); 107 123 info.send(event.peer); 108 124 // ENetPacket* packet = enet_packet_create( LAN_DISCOVERY_ACK, strlen(LAN_DISCOVERY_ACK)+1, ENET_PACKET_FLAG_RELIABLE ); -
code/trunk/src/libraries/network/LANDiscoverable.h
r8351 r10622 31 31 32 32 #include "NetworkPrereqs.h" 33 #include "core/config/Configurable.h" 33 34 34 35 namespace orxonox 35 36 { 36 37 37 class LANDiscoverable 38 class LANDiscoverable: public Configurable 38 39 { 39 40 public: … … 42 43 void setActivity( bool bActive ); 43 44 void update(); 45 void updateClientNumber(int clientNumber) {this->clientNumber = clientNumber;} 46 ; 47 /** Function used for the configuration file parameter update */ 48 void setConfigValues(); 44 49 45 50 private: 46 51 bool bActive_; 47 52 ENetHost* host_; 53 std::string ownName; 54 int clientNumber; 48 55 }; 49 56 -
code/trunk/src/libraries/network/LANDiscovery.cc
r8858 r10622 89 89 { 90 90 packet::ServerInformation info(&event); 91 orxout(internal_info, context::network) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl; 91 std::string payload = info.getServerName(); 92 info.setServerName(payload.substr(0,payload.length()-2)); 93 info.setClientNumber( Ogre::StringConverter::parseInt(payload.substr(payload.length()-1))); 94 orxout(internal_info, context::network) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", Players: " << info.getClientNumber() << ", RTT: " << info.getServerRTT() << endl; 92 95 std::vector<packet::ServerInformation>::iterator it; 93 96 for( it=this->servers_.begin(); it!=this->servers_.end(); ++it ) … … 124 127 } 125 128 129 std::string LANDiscovery::getServerListItemRTT(unsigned int index) 130 { 131 if( index >= this->servers_.size() ) 132 return BLANKSTRING; 133 else{ 134 uint32_t serverrtt = this->servers_[index].getServerRTT(); 135 return Ogre::StringConverter::toString(serverrtt); 136 } 137 } 126 138 139 std::string LANDiscovery::getServerListItemPlayerNumber(unsigned int index) 140 { 141 if( index >= this->servers_.size() ) 142 return BLANKSTRING; 143 else{ 144 int playerNumber = this->servers_[index].getClientNumber(); 145 return Ogre::StringConverter::toString(playerNumber); 146 } 147 } 127 148 } // namespace orxonox -
code/trunk/src/libraries/network/LANDiscovery.h
r8858 r10622 33 33 #include "packet/ServerInformation.h" 34 34 #include "util/Singleton.h" 35 #include <OgreStringConverter.h> 35 36 36 37 #include <vector> … … 51 52 std::string getServerListItemName( unsigned int index ); // tolua_export 52 53 std::string getServerListItemIP( unsigned int index ); // tolua_export 54 std::string getServerListItemRTT( unsigned int index ); // tolua_export 55 std::string getServerListItemPlayerNumber( unsigned int index ); // tolua_export 53 56 static LANDiscovery& getInstance(){ return Singleton<LANDiscovery>::getInstance(); } // tolua_export 54 57 55 58 private: 56 59 static LANDiscovery* singletonPtr_s; -
code/trunk/src/libraries/network/MasterServer.cc
r8952 r10622 34 34 #include "util/Output.h" 35 35 36 namespace orxonox 36 namespace orxonox 37 37 { 38 38 /*** MACROS ***/ … … 45 45 MasterServer *MasterServer::instance = NULL; 46 46 47 48 49 50 47 /* command: list servers */ 51 void 48 void 52 49 MasterServer::listServers( void ) 53 50 { … … 59 56 60 57 /* loop through list elements */ 61 for( i = MasterServer::getInstance()->mainlist.serverlist.begin(); 62 i != MasterServer::getInstance()->mainlist.serverlist.end(); ++i ) 58 for( i = MasterServer::getInstance()->mainlist.serverlist.begin(); 59 i != MasterServer::getInstance()->mainlist.serverlist.end(); ++i ) 63 60 { 64 61 orxout(user_info) << " " << (*i).ServerInfo.getServerIP() << std::endl; … … 70 67 } 71 68 72 void 69 void 73 70 MasterServer::delServer( std::string todeladdr ) 74 71 { 75 72 /* tell the user we're now removing the entry from the server list */ 76 orxout(user_info) << "MS: Deleting server \"" << todeladdr << "\"..." 73 orxout(user_info) << "MS: Deleting server \"" << todeladdr << "\"..." 77 74 << std::endl; 78 75 79 76 /* see if we actually have that server on our list */ 80 ServerListSearchResult shandle = 77 ServerListSearchResult shandle = 81 78 MasterServer::getInstance()->mainlist.findServerByAddress(todeladdr); 82 79 … … 86 83 } 87 84 88 /* force-disconnect the server */ 85 /* force-disconnect the server */ 89 86 enet_peer_disconnect( shandle.result.peer, 0 ); 90 87 … … 98 95 99 96 /* helpers */ 100 static void 97 static void 101 98 helper_output_debug( ENetEvent *event, char *addrconv ) 102 99 { 103 100 orxout(verbose, context::master_server) 104 << "A packet of length" 101 << "A packet of length" 105 102 << event->packet->dataLength 106 103 << " containing " 107 104 << (const char*)event->packet->data 108 105 << " was received from " 109 << addrconv 106 << addrconv 110 107 << " on channel " 111 108 << event->channelID << endl; … … 122 119 123 120 /* loop through list elements */ 124 for( i = mainlist.serverlist.begin(); i 125 != mainlist.serverlist.end(); ++i ) 121 for( i = mainlist.serverlist.begin(); i 122 != mainlist.serverlist.end(); ++i ) 126 123 { 127 124 /* send this particular server */ 128 125 /* build reply string */ 129 char *tosend = (char *)calloc( (*i).ServerInfo.getServerIP().length()130 + MSPROTO_SERVERLIST_ITEM_LEN + 2,1 );131 if( !tosend ) 126 int packetlen = MSPROTO_SERVERLIST_ITEM_LEN + 1 + (*i).ServerInfo.getServerIP().length() + 1 + (*i).ServerInfo.getServerName().length() + 1 + sizeof((*i).ServerInfo.getClientNumber()) + 1; 127 char *tosend = (char *)calloc(packetlen ,1 ); 128 if( !tosend ) 132 129 { orxout(internal_warning, context::master_server) << "Masterserver.cc: Memory allocation failed." << endl; 133 130 continue; 134 } 135 sprintf( tosend, "%s %s ", MSPROTO_SERVERLIST_ITEM,136 (*i).ServerInfo.getServerIP().c_str() 131 } 132 sprintf( tosend, "%s %s %s %u", MSPROTO_SERVERLIST_ITEM, 133 (*i).ServerInfo.getServerIP().c_str(), (*i).ServerInfo.getServerName().c_str(), (*i).ServerInfo.getClientNumber()); 137 134 138 135 /* create packet from it */ 139 136 reply = enet_packet_create( tosend, 140 strlen( tosend ) + 1, 137 strlen( tosend ) + 1, 141 138 ENET_PACKET_FLAG_RELIABLE); 142 139 … … 149 146 /* free the tosend buffer */ 150 147 free( tosend ); 151 } 148 } 152 149 153 150 /* create end-of-list packet */ … … 163 160 } 164 161 165 /* maybe the two methods below can be merged into one and 166 * made to use ENet's RTT functionality to check for disconnected 162 /* maybe the two methods below can be merged into one and 163 * made to use ENet's RTT functionality to check for disconnected 167 164 * servers. 168 165 */ 169 void 166 void 170 167 MasterServer::helper_cleanupServers( void ) 171 168 { 172 169 /* get an iterator */ 173 170 std::list<ServerListElem>::iterator i; 174 171 175 172 if( mainlist.serverlist.size() == 0 ) 176 173 return; 177 174 178 175 /* loop through list elements */ 179 for( i = mainlist.serverlist.begin(); i 180 != mainlist.serverlist.end(); ++i ) 176 for( i = mainlist.serverlist.begin(); i 177 != mainlist.serverlist.end(); ++i ) 181 178 { /* see if we have a disconnected peer */ 182 if( (*i).peer && 179 if( (*i).peer && 183 180 ((*i).peer->state == ENET_PEER_STATE_DISCONNECTED || 184 181 (*i).peer->state == ENET_PEER_STATE_ZOMBIE )) 185 { 182 { 186 183 /* Remove it from the list */ 187 184 orxout(internal_warning) << (char*)(*i).peer->data << " timed out.\n"; … … 190 187 /* stop iterating, we manipulated the list */ 191 188 /* TODO note: this only removes one dead server per loop 192 * iteration. not beautiful, but one iteration is ~100ms, 189 * iteration. not beautiful, but one iteration is ~100ms, 193 190 * so not really relevant for the moment. 194 191 */ … … 196 193 } 197 194 } 198 195 199 196 } 200 197 … … 204 201 /***** EVENTS *****/ 205 202 /* connect event */ 206 int 203 int 207 204 MasterServer::eventConnect( ENetEvent *event ) 208 205 { /* check for bad parameters */ … … 217 214 218 215 /* output debug info */ 219 orxout(verbose, context::master_server) << "A new client connected from " 220 << addrconv 221 << " on port " 216 orxout(verbose, context::master_server) << "A new client connected from " 217 << addrconv 218 << " on port " 222 219 << event->peer->address.port << endl; 223 220 224 221 /* store string form of address here */ 225 event->peer->data = addrconv; 222 event->peer->data = addrconv; 226 223 227 224 /* all fine. */ … … 230 227 231 228 /* disconnect event */ 232 int 229 int 233 230 MasterServer::eventDisconnect( ENetEvent *event ) 234 231 { /* check for bad parameters */ … … 255 252 256 253 /* data event */ 257 int 254 int 258 255 MasterServer::eventData( ENetEvent *event ) 259 256 { /* validate packet */ … … 262 259 return -1; 263 260 } 264 261 265 262 /* generate address in readable form */ 266 263 char *addrconv = (char *) calloc( 50, 1 ); 267 264 enet_address_get_host_ip( &(event->peer->address), addrconv, 49 ); 265 /* convert to string */ 266 std::string ip = std::string( addrconv ); 267 /* delete addrconv */ 268 if( addrconv ) free( addrconv ); 269 270 /* pointer to full packet data */ 271 char * packetdata = (char *)event->packet->data; 268 272 269 273 /* output debug info about the data that has come */ … … 271 275 272 276 /* GAME SERVER OR CLIENT CONNECTION? */ 273 if( !strncmp( (char *)event->packet->data, MSPROTO_GAME_SERVER, 274 MSPROTO_GAME_SERVER_LEN ) ) 277 if( !strncmp(packetdata, MSPROTO_GAME_SERVER, MSPROTO_GAME_SERVER_LEN ) ) 275 278 { /* Game server */ 276 279 277 if( !strncmp( (char *)event->packet->data 278 + MSPROTO_GAME_SERVER_LEN+1, 279 MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) ) 280 if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) ) 280 281 { /* register new server */ 281 mainlist.addServer( packet::ServerInformation( event ), 282 event->peer ); 283 282 mainlist.addServer( packet::ServerInformation( event ), event->peer ); 283 284 284 /* tell people we did so */ 285 orxout(internal_info, context::master_server) << "Added new server to list: " << 285 orxout(internal_info, context::master_server) << "Added new server to list: " << 286 286 packet::ServerInformation( event ).getServerIP() << endl; 287 287 } 288 288 289 else if( !strncmp( (char *)event->packet->data 290 + MSPROTO_GAME_SERVER_LEN+1, 291 MSPROTO_SERVERDC, MSPROTO_SERVERDC_LEN ) ) 292 { 289 else if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_SERVERDC, MSPROTO_SERVERDC_LEN ) ) 290 { /* disconnect server */ 291 292 /* remove the server from the list it belongs to */ 293 this->mainlist.delServerByAddress( ip ); 294 295 /* tell the user */ 296 orxout(internal_info, context::master_server) << "Removed server " << ip << " from list." << endl; 297 } 298 /* TODO add hook for disconnect here */ 299 300 else if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_SET_NAME, MSPROTO_SET_NAME_LEN ) ) 301 { /* save server name */ 293 302 /* create string from peer data */ 294 std::string name = std::string( addrconv ); 303 std::string data (event->packet->data,event->packet->data + event->packet->dataLength ); 304 std::string name = data.substr(MSPROTO_GAME_SERVER_LEN+1 + MSPROTO_SET_NAME_LEN + 1); 295 305 296 306 /* remove the server from the list it belongs to */ 297 this->mainlist. delServerByAddress(name );307 this->mainlist.setNameByAddress( ip, name ); 298 308 299 309 /* tell the user */ 300 orxout(internal_info, context::master_server) << "Removed server " << name << " from list." << endl; 301 } 302 303 /* TODO add hook for disconnect here */ 304 } 305 else if( !strncmp( (char *)event->packet->data, MSPROTO_CLIENT, 306 MSPROTO_CLIENT_LEN) ) 310 orxout(internal_info, context::master_server) << "Updated server " << ip << " with new name " << name << endl; 311 } 312 313 else if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_SET_CLIENTS, MSPROTO_SET_CLIENTS_LEN ) ) 314 { /* save client count from server */ 315 /* create string from peer data */ 316 std::string data (event->packet->data,event->packet->data + event->packet->dataLength ); 317 std::string textform= data.substr(MSPROTO_GAME_SERVER_LEN + 1 + MSPROTO_SET_CLIENTS_LEN + 1); 318 int clientNumber = Ogre::StringConverter::parseInt(textform); 319 320 this->mainlist.setClientsByAddress( ip, clientNumber); 321 322 /* tell the user */ 323 orxout(internal_info, context::master_server) << "Updated server " << ip << " with new client number " << clientNumber << endl; 324 } 325 } 326 else if( !strncmp( packetdata, MSPROTO_CLIENT, MSPROTO_CLIENT_LEN) ) 307 327 { /* client */ 308 if( !strncmp( (char *)event->packet->data + MSPROTO_CLIENT_LEN+1, 309 MSPROTO_REQ_LIST, MSPROTO_REQ_LIST_LEN ) ) 328 if( !strncmp( packetdata + MSPROTO_CLIENT_LEN+1, MSPROTO_REQ_LIST, MSPROTO_REQ_LIST_LEN ) ) 310 329 /* send server list */ 311 330 helper_sendlist( event ); 312 331 } 313 332 else 314 { /* bad message, don't do anything. */ } 315 316 /* delete addrconv */ 317 if( addrconv ) free( addrconv ); 333 { /* bad message, don't do anything. */ } 318 334 319 335 /* Clean up the packet now that we're done using it. */ … … 324 340 325 341 /**** MAIN ROUTINE *****/ 326 int 342 int 327 343 MasterServer::run() 328 344 { … … 330 346 ENetEvent *event = (ENetEvent *)calloc(sizeof(ENetEvent), sizeof(char)); 331 347 if( event == NULL ) 332 { 348 { 333 349 orxout(user_error, context::master_server) << "Could not create ENetEvent structure, exiting." << endl; 334 350 exit( EXIT_FAILURE ); … … 345 361 switch (event->type) 346 362 { /* new connection */ 347 case ENET_EVENT_TYPE_CONNECT: 363 case ENET_EVENT_TYPE_CONNECT: 348 364 eventConnect( event ); break; 349 365 350 366 /* disconnect */ 351 case ENET_EVENT_TYPE_DISCONNECT: 367 case ENET_EVENT_TYPE_DISCONNECT: 352 368 eventDisconnect( event ); break; 353 369 … … 358 374 359 375 /* done */ 376 free(event); 360 377 return 0; 361 } 378 } 362 379 363 380 /* constructor */ … … 380 397 this->address.port = ORX_MSERVER_PORT; 381 398 382 /* create a host with the above settings (the last two 0 mean: accept 399 /* create a host with the above settings (the last two 0 mean: accept 383 400 * any input/output bandwidth */ 384 this->server = enet_host_create( &this->address, ORX_MSERVER_MAXCONNS, 401 this->server = enet_host_create( &this->address, ORX_MSERVER_MAXCONNS, 385 402 ORX_MSERVER_MAXCHANS, 0, 0 ); 386 403 assert(this->server); … … 388 405 /* see if creation worked */ 389 406 if( !this->server ) 390 { orxout(user_error, context::master_server) << 407 { orxout(user_error, context::master_server) << 391 408 "An error occurred while trying to create an ENet server host." << endl; 392 409 exit( EXIT_FAILURE ); -
code/trunk/src/libraries/network/MasterServer.h
r8937 r10622 49 49 #include <cstdio> 50 50 51 namespace orxonox 51 #include <OgreStringConverter.h> 52 53 54 namespace orxonox 52 55 { 53 56 /* singleton */ … … 63 66 /* static pointer for commands */ 64 67 static MasterServer *instance; 65 static MasterServer *getInstance() 68 static MasterServer *getInstance() 66 69 { return instance; } 67 static void setInstance( MasterServer *setto ) 70 static void setInstance( MasterServer *setto ) 68 71 { instance = setto; } 69 72 70 73 /* functions for commands */ 71 74 static void listServers( void ); -
code/trunk/src/libraries/network/MasterServerProtocol.h
r8351 r10622 37 37 /* Client token (shows that the party sending data is a client */ 38 38 #define MSPROTO_CLIENT "CL" 39 #define MSPROTO_CLIENT_LEN 2 39 #define MSPROTO_CLIENT_LEN 2 40 40 41 41 /* Request: Serverlist (requiest made from client to master server */ 42 42 #define MSPROTO_REQ_LIST "REQ:LIST" 43 43 #define MSPROTO_REQ_LIST_LEN 8 44 45 46 44 47 45 … … 67 65 /* ping request from server */ 68 66 #define MSPROTO_PING_GAMESERVER "PING" 69 #define MSPROTO_PING_GAMESERVER_LEN 4 67 #define MSPROTO_PING_GAMESERVER_LEN 4 70 68 71 69 /* server disconnect */ … … 75 73 /* ping reply */ 76 74 #define MSPROTO_ACK "ACK" 77 #define MSPROTO_ACK_LEN 3 75 #define MSPROTO_ACK_LEN 3 78 76 77 /* server name */ 78 #define MSPROTO_SET_NAME "NAM" 79 #define MSPROTO_SET_NAME_LEN 3 79 80 81 /* server number of clients */ 82 #define MSPROTO_SET_CLIENTS "CLI" 83 #define MSPROTO_SET_CLIENTS_LEN 3 84 85 #define SERVER_NAME_MAXLEN 7 80 86 81 87 /* default master server port */ -
code/trunk/src/libraries/network/PeerList.cc
r8858 r10622 38 38 PeerList::~PeerList() { } 39 39 40 int 40 int 41 41 PeerList::addPeer( ENetPeer *toadd ) 42 42 { /* error correction */ 43 if( toadd == NULL ) 43 if( toadd == NULL ) 44 44 { orxout(internal_error, context::master_server) << "PeerList::addPeer: empty peer given." << endl; 45 45 return -1; … … 52 52 53 53 bool sub_compAddr( ENetAddress addr1, ENetAddress addr2 ) 54 { 54 { 55 55 for( int i = 0; i < 16; ++i ) 56 56 if( addr1.host.addr[i] < addr2.host.addr[i] ) … … 61 61 return 0; 62 62 } 63 63 64 64 65 65 bool … … 69 69 70 70 /* loop through list elements */ 71 for( i = peerlist.begin(); i != peerlist.end(); ++i ) 71 for( i = peerlist.begin(); i != peerlist.end(); ++i ) 72 72 if( !sub_compAddr((*i)->address, addr ) ) 73 73 { /* found this name, remove and quit */ … … 86 86 87 87 /* loop through list elements */ 88 for( i = peerlist.begin(); i != peerlist.end(); ++i ) 88 for( i = peerlist.begin(); i != peerlist.end(); ++i ) 89 89 if( !sub_compAddr((*i)->address, addr ) ) 90 90 /* found this name, remove and quit */ … … 95 95 } 96 96 97 int 98 PeerList::count(){ 99 return this->peerlist.size(); 100 } 101 97 102 } 98 -
code/trunk/src/libraries/network/PeerList.h
r8351 r10622 35 35 36 36 /* peer list */ 37 namespace orxonox 37 namespace orxonox 38 38 { 39 /** This class keeps a list of open connections 39 /** This class keeps a list of open connections 40 40 * and some info about them. 41 41 */ 42 class PeerList 42 class PeerList 43 43 { public: 44 44 /** constructor */ … … 50 50 /** \param toadd The peer to add 51 51 * \return 0 for success, -1 for error. 52 * 53 * Add new peer to list 52 * 53 * Add new peer to list 54 54 */ 55 55 int addPeer( ENetPeer *toadd ); … … 57 57 /** \param addr Address to look for 58 58 * \return if the peer was found or not 59 * 60 * Remove peer from list by address 59 * 60 * Remove peer from list by address 61 61 */ 62 62 bool remPeerByAddr( ENetAddress addr ); 63 63 64 64 /** \param addr The address to find by 65 * 66 * Find a connection by address */ 65 * 66 * Find a connection by address 67 */ 67 68 ENetPeer *findPeerByAddr( ENetAddress addr ); 68 69 69 /* NOTE: making this list public so it can easily 70 /** 71 * Count current peers 72 */ 73 int count(); 74 75 /* NOTE: making this list public so it can easily 70 76 * be iterated. This makes sense since iterating it 71 77 * will happen all the time, and using getter methods -
code/trunk/src/libraries/network/Server.cc
r9667 r10622 77 77 this->timeSinceLastUpdate_=0; 78 78 } 79 79 /* 80 Server::Server(int port, const std::string name) 81 { 82 this->setPort( port ); 83 this->timeSinceLastUpdate_=0; 84 this->serverName_=name; 85 }*/ 80 86 /** 81 87 * Constructor … … 108 114 /* make discoverable on LAN */ 109 115 LANDiscoverable::setActivity(true); 116 LANDiscoverable::updateClientNumber(0); 110 117 111 118 /* make discoverable on WAN */ 112 119 WANDiscoverable::setActivity(true); 120 WANDiscoverable::updateClientNumber(0); 113 121 114 122 /* done */ … … 283 291 // inform all the listeners 284 292 this->clientIDs_.push_back(peerID); 293 WANDiscoverable::updateClientNumber(this->clientIDs_.size()); 294 LANDiscoverable::updateClientNumber(this->clientIDs_.size()); 295 285 296 ClientConnectionListener::broadcastClientConnected(peerID); 286 297 GamestateManager::addPeer(peerID); … … 289 300 290 301 orxout(internal_info, context::network) << "Server: added client id: " << peerID << endl; 302 291 303 createClient(peerID); 292 304 } … … 309 321 } 310 322 } 323 WANDiscoverable::updateClientNumber(this->clientIDs_.size()); 324 LANDiscoverable::updateClientNumber(this->clientIDs_.size()); 325 311 326 ClientConnectionListener::broadcastClientDisconnected(peerID); 312 327 GamestateManager::removePeer(peerID); -
code/trunk/src/libraries/network/Server.h
r8858 r10622 67 67 virtual void printRTT(); 68 68 float getPacketLoss(unsigned int clientID); 69 int getClientCount() { return this->clientIDs_.size();} 70 std::string getServerName() { return this->serverName_;} 71 69 72 protected: 70 73 void updateGamestate(); … … 89 92 std::deque<packet::Packet*> packetQueue_; 90 93 std::vector<uint32_t> clientIDs_; 94 std::string serverName_; 91 95 }; 92 96 -
code/trunk/src/libraries/network/ServerList.cc
r8937 r10622 30 30 31 31 namespace orxonox 32 { 32 { 33 33 ServerList::ServerList() 34 34 { /* create a new list */ } … … 39 39 } 40 40 41 int 41 int 42 42 ServerList::addServer( packet::ServerInformation toadd, 43 43 ENetPeer *peer ) 44 { 44 { 45 45 ServerListElem toAdd; 46 46 toAdd.ServerInfo = toadd; 47 47 toAdd.peer = peer; 48 48 49 this->serverlist.push_back( toAdd ); 49 this->serverlist.push_back( toAdd ); 50 50 return 0; 51 51 } 52 52 53 bool 53 bool 54 54 ServerList::delServerByName( std::string name ) 55 { 55 { 56 56 /* get an iterator */ 57 57 std::list<ServerListElem>::iterator i; 58 58 59 59 /* loop through list elements */ 60 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 60 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 61 61 if( (*i).ServerInfo.getServerName() == name ) 62 62 { /* found this name, remove and quit */ … … 68 68 69 69 bool ServerList::delServerByAddress( std::string address ) 70 { 70 { 71 71 /* get an iterator */ 72 72 std::list<ServerListElem>::iterator i; 73 73 74 74 /* loop through list elements */ 75 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 75 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 76 76 if( (*i).ServerInfo.getServerIP() == address ) 77 77 { /* found this name, remove and quit */ … … 90 90 91 91 /* loop through list elements */ 92 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 92 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 93 93 if( (*i).ServerInfo.getServerIP() == address ) 94 94 { /* found the target, return it */ … … 110 110 /* iterate, return when name found */ 111 111 /* loop through list elements */ 112 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 112 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 113 113 if( (*i).ServerInfo.getServerName() == name ) 114 { 114 { 115 115 ServerListSearchResult res = { (*i), true }; 116 116 return res; … … 124 124 /* SORTING */ 125 125 /* sort by name */ 126 bool sub_compare_names( ServerListElem no1, 126 bool sub_compare_names( ServerListElem no1, 127 127 ServerListElem no2 ) 128 128 { return no1.ServerInfo.getServerName() > no2.ServerInfo.getServerName(); } 129 129 130 130 void ServerList::sortByName() 131 { 132 this->serverlist.sort( sub_compare_names ); 131 { 132 this->serverlist.sort( sub_compare_names ); 133 133 } 134 134 135 135 /* sort by ping */ 136 bool sub_compare_pings( ServerListElem no1, 136 bool sub_compare_pings( ServerListElem no1, 137 137 ServerListElem no2 ) 138 { 139 return no1.ServerInfo.getServer Name() > no2.ServerInfo.getServerName();138 { 139 return no1.ServerInfo.getServerRTT() > no2.ServerInfo.getServerRTT(); 140 140 } 141 141 142 142 void ServerList::sortByPing() 143 143 { 144 this->serverlist.sort( sub_compare_pings ); 144 this->serverlist.sort( sub_compare_pings ); 145 145 } 146 146 147 bool ServerList::setNameByAddress( std::string address, std::string name ){ 148 /* get an iterator */ 149 std::list<ServerListElem>::iterator i; 150 151 /* loop through list elements */ 152 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 153 if( (*i).ServerInfo.getServerIP() == address ) 154 { /* found this adress, rename and quit */ 155 (*i).ServerInfo.setServerName( name ); 156 return true; 157 } 158 return false; 159 }; 160 161 bool ServerList::setClientsByAddress( std::string address, int clientNumber ){ 162 /* get an iterator */ 163 std::list<ServerListElem>::iterator i; 164 165 /* loop through list elements */ 166 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 167 if( (*i).ServerInfo.getServerIP() == address ) 168 { /* found this adress, rename and quit */ 169 (*i).ServerInfo.setClientNumber( clientNumber ); 170 return true; 171 } 172 return false; 173 }; 174 147 175 } -
code/trunk/src/libraries/network/ServerList.h
r8937 r10622 35 35 36 36 /* methods necessary */ 37 namespace orxonox 38 { 37 namespace orxonox 38 { 39 39 /* HELPER STRUCTURES */ 40 struct ServerListElem 40 struct ServerListElem 41 41 { 42 42 /* server information (name, IP, etc) */ … … 63 63 * and some info about them. 64 64 */ 65 class ServerList 65 class ServerList 66 66 { public: 67 67 /** constructor */ … … 74 74 /* BASIC MANIPULATION */ 75 75 /** \param toadd the server to add. 76 * 76 * 77 77 * Add server to the game server list 78 78 */ … … 81 81 82 82 /** \param name Name of the server to remove 83 * 84 * Remove server by name 83 * 84 * Remove server by name 85 85 */ 86 86 bool delServerByName( std::string name ); 87 87 88 88 /** \param address IP address of the server to remove 89 * 89 * 90 90 * Remove server by address 91 91 */ 92 92 bool delServerByAddress( std::string address ); 93 93 94 bool setNameByAddress( std::string address, std::string name ); 94 95 95 96 bool setClientsByAddress( std::string address, int clientNumber ); 96 97 97 98 /* SEARCHING */ 98 /* \param address The address of the server that is to be 99 /* \param address The address of the server that is to be 99 100 * found 100 101 * \return A struct containing a result of the search and a boolean 101 102 * that is only true if the search was successful 102 * 103 * 103 104 * Find and return the list handle of a given address. 104 105 */ … … 107 108 108 109 109 /* \param name The name of the server that is to be 110 /* \param name The name of the server that is to be 110 111 * found 111 112 * \return The struct containing the list entry of the server 112 * 113 * 113 114 * Find and return the list handle of a given name. 114 115 */ … … 120 121 /** sort by name */ 121 122 void sortByName(); 122 123 123 124 /** sort by ping */ 124 125 void sortByPing(); -
code/trunk/src/libraries/network/WANDiscoverable.cc
r9667 r10622 44 44 /* debugging output */ 45 45 orxout(verbose, context::master_server) << "Creating WANDiscoverable." << endl; 46 46 47 47 /* register object in orxonox */ 48 48 RegisterObject(WANDiscoverable); … … 50 50 /* check for the masterserver address option in orxonox.ini */ 51 51 this->setConfigValues(); 52 52 53 53 } 54 54 55 55 void WANDiscoverable::setConfigValues() 56 56 { 57 /* update msaddress string from orxonox.ini config file, if it 58 * has changed. 57 /* update msaddress string from orxonox.ini config file, if it 58 * has changed. 59 59 */ 60 SetConfigValueExternal(msaddress, " WANDiscovery", "msaddress", "orxonox.net");61 // SetConfigValue( msaddress, "orxonox.net");62 } 60 SetConfigValueExternal(msaddress, "Discovery", "msaddress", "orxonox.net"); 61 SetConfigValueExternal(ownName, "Discovery", "ownName", "OrxServer"); 62 } 63 63 64 64 WANDiscoverable::~WANDiscoverable() … … 67 67 this->disconnect(); 68 68 } 69 69 70 70 void WANDiscoverable::setActivity(bool bActive) 71 71 { 72 72 if( bActive==this->bActive_ ) 73 73 return; 74 74 75 75 if( bActive ) 76 76 { … … 84 84 } 85 85 } 86 86 87 87 bool WANDiscoverable::connect() 88 88 { … … 93 93 return false; 94 94 } 95 95 96 96 /* connect and see if it worked */ 97 97 if( msc.connect( this->msaddress.c_str(), ORX_MSERVER_PORT ) ) 98 98 { 99 orxout(internal_error, context::master_server) << "Could not connect to master server at " 99 orxout(internal_error, context::master_server) << "Could not connect to master server at " 100 100 << this->msaddress << endl; 101 101 return false; 102 102 } 103 103 104 104 /* debugging output */ 105 105 orxout(verbose, context::master_server) << "Initialization of WANDiscoverable complete." << endl; 106 107 106 108 107 // Now register the server at the master server 109 108 this->msc.sendRequest( MSPROTO_GAME_SERVER " " MSPROTO_REGISTER_SERVER ); 110 109 110 std::string request = MSPROTO_GAME_SERVER " " MSPROTO_SET_NAME " "; 111 request += this->ownName; 112 this->msc.sendRequest( request ); 113 111 114 return true; 112 115 } … … 118 121 } 119 122 123 void WANDiscoverable::updateClientNumber(int clientNumber) 124 { 125 orxout(verbose, context::master_server) << "Sending new number of clients: " << clientNumber << endl; 126 std::string request = MSPROTO_GAME_SERVER " " MSPROTO_SET_CLIENTS " "; 127 request += Ogre::StringConverter::toString(clientNumber); 128 129 this->msc.sendRequest( request ); 130 } 120 131 121 132 122 133 134 123 135 } // namespace orxonox -
code/trunk/src/libraries/network/WANDiscoverable.h
r9667 r10622 32 32 #include "core/config/Configurable.h" 33 33 #include "MasterServerComm.h" 34 #include <OgreStringConverter.h> 34 35 35 36 namespace orxonox … … 46 47 47 48 /** \return Address of the master server 48 * 49 * Get the master server address 49 * 50 * Get the master server address 50 51 */ 51 52 std::string getMSAddress() … … 54 55 /** Function used for the configuration file parameter update */ 55 56 void setConfigValues(); 56 57 57 58 /** Function used to set the activity/discoverability */ 58 59 void setActivity( bool bActive ); 59 60 61 void updateClientNumber(int clientNumber); 62 60 63 /** Master server communications object */ 61 64 MasterServerComm msc; 62 65 63 66 private: 64 67 /** Function used to connect to the master server */ 65 68 bool connect(); 66 69 67 70 /** Function used to disconnect from the master server */ 68 71 void disconnect(); 69 72 70 73 /** master server address */ 71 74 std::string msaddress; 75 std::string ownName; 72 76 bool bActive_; 73 77 -
code/trunk/src/libraries/network/WANDiscovery.cc
r8858 r10622 41 41 /* debugging output */ 42 42 orxout(verbose, context::master_server) << "Creating WANDiscovery." << endl; 43 43 44 44 /* register object in orxonox */ 45 45 RegisterObject(WANDiscovery); … … 54 54 /* connect and see if it worked */ 55 55 if( msc.connect( this->msaddress.c_str(), ORX_MSERVER_PORT ) ) 56 orxout(internal_error, context::master_server) << "Could not connect to master server at " 56 orxout(internal_error, context::master_server) << "Could not connect to master server at " 57 57 << this->msaddress << endl; 58 58 … … 63 63 void WANDiscovery::setConfigValues() 64 64 { 65 /* update msaddress string from orxonox.ini config file, if it 66 * has changed. 65 /* update msaddress string from orxonox.ini config file, if it 66 * has changed. 67 67 */ 68 68 SetConfigValue( msaddress, "master.orxonox.net"); 69 } 69 } 70 70 71 71 WANDiscovery::~WANDiscovery() 72 { 72 { 73 73 /* clear server list */ 74 this->servers_.clear(); 74 this->servers_.clear(); 75 75 } 76 76 77 77 /* callback for the network reply poller */ 78 78 int WANDiscovery::rhandler( char *addr, ENetEvent *ev ) 79 { 79 { 80 80 /* error recognition */ 81 81 if( !ev || !ev->packet || !ev->packet->data ) … … 88 88 if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_ITEM, 89 89 MSPROTO_SERVERLIST_ITEM_LEN ) ) 90 { 90 { 91 91 /* create server structure from that item */ 92 92 packet::ServerInformation toadd; 93 93 94 94 /* fill in data, -1 for the index: index should be length -1 */ 95 toadd.setServerName( std::string((char*)ev->packet->data + 96 MSPROTO_SERVERLIST_ITEM_LEN+1) ); 97 toadd.setServerIP( std::string((char*)ev->packet->data + 98 MSPROTO_SERVERLIST_ITEM_LEN+1) ); 95 std::string datastr = std::string((char*)ev->packet->data + MSPROTO_SERVERLIST_ITEM_LEN+1); 96 int separator = datastr.find(" "); 97 toadd.setServerIP(datastr.substr(0,separator)); 98 int secondsep = datastr.find(" ", separator + 1); 99 toadd.setServerName(datastr.substr(separator + 1, secondsep - separator - 1)); 100 toadd.setClientNumber(Ogre::StringConverter::parseInt(datastr.substr(secondsep+1))); 101 102 orxout(internal_info, context::network) << "Received WAN discovery server information; Name: " << toadd.getServerName() << ", Address: " << toadd.getServerIP() << ", Players: " << toadd.getClientNumber() << ", RTT: " << toadd.getServerRTT() << endl; 99 103 100 104 /* add to list */ … … 103 107 else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END, 104 108 MSPROTO_SERVERLIST_END_LEN ) ) 105 { 109 { 106 110 /* this is the only case where 2 should be returned, 107 111 * as 1 is used to signal that we're done receiving 108 112 * the list 109 113 */ 110 return 2; 114 return 2; 111 115 } 112 116 … … 114 118 return 1; 115 119 } 116 120 117 121 void WANDiscovery::discover() 118 122 { … … 131 135 { case 0: /* no event occured, decrease timeout */ 132 136 --i; break; 133 case 1: /* got a list element, continue */ 137 case 1: /* got a list element, continue */ 134 138 break; 135 139 case 2: /* done. */ … … 159 163 } 160 164 165 std::string WANDiscovery::getServerListItemRTT(unsigned int index) 166 { 167 if( index >= this->servers_.size() ) 168 return BLANKSTRING; 169 else{ 170 uint32_t serverrtt = this->servers_[index].getServerRTT(); 171 return Ogre::StringConverter::toString(serverrtt); 172 } 173 174 } 175 std::string WANDiscovery::getServerListItemPlayerNumber(unsigned int index) 176 { 177 if( index >= this->servers_.size() ) 178 return BLANKSTRING; 179 else{ 180 int playerNumber = this->servers_[index].getClientNumber(); 181 return Ogre::StringConverter::toString(playerNumber); 182 } 183 } 161 184 162 185 } // namespace orxonox -
code/trunk/src/libraries/network/WANDiscovery.h
r9667 r10622 35 35 #include "MasterServerComm.h" 36 36 #include "MasterServerProtocol.h" 37 #include <OgreStringConverter.h> 37 38 38 39 #include <vector> … … 56 57 57 58 /** \return Address of the master server 58 * 59 * Get the master server address 59 * 60 * Get the master server address 60 61 */ 61 62 std::string getMSAddress() … … 65 66 void discover(); // tolua_export 66 67 67 /** \param index Index to get the name of 68 /** \param index Index to get the name of 68 69 * \return The name of the server 69 * 70 * Get the name of the server at index index. 70 * 71 * Get the name of the server at index index. 71 72 */ 72 73 std::string getServerListItemName( unsigned int index ); // tolua_export 73 74 74 /** \param index Index to get the IP of 75 /** \param index Index to get the IP of 75 76 * \return The IP of the server 76 * 77 * Get the IP of the server at index index. 77 * 78 * Get the IP of the server at index index. 78 79 */ 79 80 std::string getServerListItemIP( unsigned int index ); // tolua_export 80 81 82 /** \param index Index to get the RTT of 83 * \return The RTT of the server 84 * 85 * Get the RTT of the server at index index. 86 */ 87 std::string getServerListItemRTT( unsigned int index ); // tolua_export 88 89 /** \param index Index to get the RTT of 90 * \return The number of players on the server 91 * 92 * Get the number of players on the server 93 */ 94 std::string getServerListItemPlayerNumber( unsigned int index ); // tolua_export 95 81 96 /* todo: might make this private and use getter/setter methods 82 * at some later time. 97 * at some later time. 83 98 */ 84 99 /** game server list */ … … 92 107 93 108 int rhandler( char *addr, ENetEvent *ev ); 94 109 95 110 private: 96 111 /** master server address */ -
code/trunk/src/libraries/network/packet/ServerInformation.cc
r8351 r10622 39 39 namespace packet 40 40 { 41 41 42 42 ServerInformation::ServerInformation() 43 43 { 44 45 44 } 46 45 47 46 ServerInformation::ServerInformation(ENetEvent* event) 48 47 { … … 69 68 ServerInformation::~ServerInformation() 70 69 { 71 70 72 71 } 73 72 74 73 void ServerInformation::send(ENetPeer* peer) 75 74 { 76 uint32_t size = returnSize((char*&)LAN_DISCOVERY_ACK) + returnSize(this->serverName_); 75 std::string payload = this->serverName_ + Ogre::StringConverter::toString(this->clientNumber_); 76 uint32_t size = returnSize((char*&)LAN_DISCOVERY_ACK) + returnSize(payload); 77 77 uint8_t* temp = new uint8_t[size]; 78 78 uint8_t* temp2 = temp; 79 79 saveAndIncrease((char*&)LAN_DISCOVERY_ACK, temp2); 80 saveAndIncrease( this->serverName_, temp2);80 saveAndIncrease(payload, temp2); 81 81 ENetPacket* packet = enet_packet_create( temp, size, 0 ); 82 82 enet_peer_send(peer, 0, packet); 83 83 84 84 delete[] temp; 85 85 } 86 86 87 87 } // namespace packet 88 88 … … 95 95 } 96 96 } // namespace orxonox 97 -
code/trunk/src/libraries/network/packet/ServerInformation.h
r8351 r10622 30 30 31 31 #include <string> 32 #include <OgreStringConverter.h> 33 32 34 33 35 #ifndef SERVERINFORMATION_H … … 45 47 ServerInformation(ENetEvent* event); 46 48 ~ServerInformation(); 47 49 48 50 void send( ENetPeer* peer ); 51 void setServerName(std::string name) { this->serverName_ = name; } 52 std::string getServerName() { return this->serverName_; } 53 void setServerIP( std::string IP ) { this->serverIP_ = IP; } 49 54 std::string getServerIP() { return this->serverIP_; } 50 std::string getServerName() { return this->serverName_; } 51 void setServerName(std::string name) { this->serverName_ = name; } 52 void setServerIP( std::string IP ) { this->serverIP_ = IP; } 55 void setClientNumber( int clientNumber ) { this->clientNumber_ = clientNumber; } 56 int getClientNumber() { return this->clientNumber_; } 53 57 uint32_t getServerRTT() { return this->serverRTT_; } 54 58 55 59 private: 56 60 std::string serverName_; 61 int clientNumber_; 57 62 std::string serverIP_; 58 63 uint32_t serverRTT_; -
code/trunk/src/modules/objects/ForceField.h
r9939 r10622 160 160 const std::string& getMode(void); //!< Get the mode of the ForceField. 161 161 162 private:163 162 //! Strings to represent the modes. 164 163 static const std::string modeTube_s; … … 166 165 static const std::string modeInvertedSphere_s; 167 166 static const std::string modeNewtonianGravity_s; 168 169 167 static const std::string modeHomogen_s; 170 168 169 private: 171 170 float velocity_; //!< The velocity of the ForceField. 172 171 float radius_; //!< The radius of the ForceField. -
code/trunk/src/modules/objects/Turret.cc
r10262 r10622 223 223 XMLPortParam(Turret, "maxYaw", setMaxYaw, getMaxYaw, xmlelement, mode); 224 224 XMLPortParam(Turret, "maxPitch", setMaxPitch, getMaxPitch, xmlelement, mode); 225 XMLPortParam(Turret, "rotationThrust", setRotationThrust, getRotationThrust, xmlelement, mode); 225 226 } 226 227 -
code/trunk/src/modules/objects/Turret.h
r10262 r10622 102 102 { return this->maxYaw_; } 103 103 104 inline void setRotationThrust(float rotationthrust) 105 { this->rotationThrust_ = rotationthrust; } 106 107 inline float getRotationThrust() 108 { return this->rotationThrust_; } 109 104 110 protected: 105 111 Vector3 startDir_; //!< The initial facing direction, in local coordinates. -
code/trunk/src/modules/objects/controllers/TurretController.cc
r10262 r10622 104 104 { 105 105 Pawn* entity = orxonox_cast<Pawn*>(*it); 106 if (!entity || FormationController::sameTeam(t his->getControllableEntity(), entity, this->getGametype()))106 if (!entity || FormationController::sameTeam(turret, entity, this->getGametype())) 107 107 continue; 108 108 tempScore = turret->isInRange(entity); … … 196 196 if(this->isLookingAtTargetNew(Degree(5).valueRadians())) 197 197 { 198 198 199 this->getControllableEntity()->fire(0); 199 200 } -
code/trunk/src/modules/tetris/Tetris.h
r9833 r10622 90 90 void clearRow(unsigned int row); 91 91 92 93 92 PlayerInfo* player_; 94 93 -
code/trunk/src/modules/towerdefense/CMakeLists.txt
r10258 r10622 2 2 TowerDefense.cc 3 3 TowerDefenseTower.cc 4 TowerTurret.cc5 4 TowerDefenseCenterpoint.cc 6 5 TowerDefenseHUDController.cc … … 8 7 TDCoordinate.cc 9 8 TowerDefenseEnemy.cc 10 9 TowerDefenseSelecter.cc 11 10 ) 12 11 … … 17 16 orxonox 18 17 overlays 18 objects 19 19 SOURCE_FILES ${TOWERDEFENSE_SRC_FILES} 20 20 ) -
code/trunk/src/modules/towerdefense/TDCoordinate.cc
r10258 r10622 17 17 { 18 18 //RegisterObject(TDCoordinate); 19 x=0; 20 y=0; 19 Set(0,0); 21 20 22 21 } 23 22 24 23 TDCoordinate::TDCoordinate(int x, int y) 25 { 26 this->x=x; 27 this->y=y; 24 { 25 Set(x,y); 26 } 27 28 void TDCoordinate::Set(int x, int y) 29 { 30 if (x < 0) 31 { 32 _x = 0; 33 } 34 else if (x > 15) 35 { 36 _x = 15; 37 } 38 else 39 { 40 _x = x; 41 } 42 43 if (y < 0) 44 { 45 _y = 0; 46 } 47 else if (y > 15) 48 { 49 _y = 15; 50 } 51 else 52 { 53 _y = y; 54 } 55 } 56 57 int TDCoordinate::GetX() 58 { 59 return _x; 60 } 61 62 int TDCoordinate::GetY() 63 { 64 return _y; 28 65 } 29 66 … … 34 71 35 72 Vector3 *coord = new Vector3(); 36 coord->x= ( x-8) * tileScale;37 coord->y= ( y-8) * tileScale;73 coord->x= (_x-8) * tileScale; 74 coord->y= (_y-8) * tileScale; 38 75 coord->z=100; 39 76 -
code/trunk/src/modules/towerdefense/TDCoordinate.h
r10258 r10622 16 16 { 17 17 public: 18 int x; 19 int y; 18 TDCoordinate(); 19 TDCoordinate(int x, int y); 20 virtual ~TDCoordinate() {}; 21 virtual void Set(int x, int y); 22 virtual int GetX(); 23 virtual int GetY(); 24 virtual Vector3 get3dcoordinate(); 20 25 21 TDCoordinate(); 22 23 Vector3 get3dcoordinate(); 24 25 virtual ~TDCoordinate() {}; 26 27 TDCoordinate(int x, int y); 26 private: 27 int _x; 28 int _y; 28 29 }; 29 30 -
code/trunk/src/modules/towerdefense/TowerDefense.cc
r10258 r10622 37 37 * 38 38 * 39 *40 39 *TIPP: Eclipse hilft euch schnell auf bereits vorhanden Funktionen zuzugreifen: 41 40 * einfach "this->" eingeben und kurz warten. Dann tauch eine Liste mit Vorschlägen auf. Wenn ihr jetzt weiter … … 77 76 #include "TowerDefenseCenterpoint.h" 78 77 //#include "TDCoordinate.h" 79 #include "TowerTurret.h"80 78 #include "worldentities/SpawnPoint.h" 81 79 #include "worldentities/pawns/Pawn.h" … … 88 86 /* Part of a temporary hack to allow the player to add towers */ 89 87 #include "core/command/ConsoleCommand.h" 88 #include <cmath> 89 90 90 91 91 namespace orxonox 92 92 { 93 static const std::string __CC_addTower_name = "addTower"; 94 static const std::string __CC_upgradeTower_name = "upgradeTower"; 95 static const int upgradeCost = 20; 96 static const int towerCost = 20; 97 unsigned int maxspaceships = 30; 98 int maxspaceshipsstandard = 30; 99 100 101 102 SetConsoleCommand("TowerDefense", __CC_addTower_name, &TowerDefense::addTower ).addShortcut().defaultValues(1); 103 SetConsoleCommand("TowerDefense", __CC_upgradeTower_name, &TowerDefense::upgradeTower).addShortcut().defaultValues(0); 104 93 105 RegisterUnloadableClass(TowerDefense); 94 106 95 TowerDefense::TowerDefense(Context* context) : Deathmatch(context)107 TowerDefense::TowerDefense(Context* context) : TeamDeathmatch(context) 96 108 { 97 109 RegisterObject(TowerDefense); … … 103 115 }*/ 104 116 117 //Timer for the waves (10 seconds between the waves) 118 selecter = NULL; 119 this->player_ = NULL; 105 120 this->setHUDTemplate("TowerDefenseHUD"); 106 107 //this->stats_ = new TowerDefensePlayerStats(); 108 109 /* Temporary hack to allow the player to add towers and upgrade them */ 110 this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) ); 111 this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) ); 121 this->nextwaveTimer_.setTimer(10, false, createExecutor(createFunctor(&TowerDefense::nextwave, this))); 122 this->nextwaveTimer_.stopTimer(); 123 this->waves_ = 0; 124 this->time = 0; 125 this->credit_ = 0; 126 this->lifes_ = 0; 127 this->timeSetTower_ = 0; 128 spaceships =15; 129 eggs=3; 130 ufos=7; 131 randomships=5; 132 133 134 ModifyConsoleCommand(__CC_addTower_name).setObject(this); 135 ModifyConsoleCommand(__CC_upgradeTower_name).setObject(this); 112 136 } 113 137 … … 117 141 if (this->isInitialized()) 118 142 { 119 if( this->dedicatedAddTower_ )120 delete this->dedicatedAddTower_;143 ModifyConsoleCommand(__CC_addTower_name).setObject(NULL); 144 ModifyConsoleCommand(__CC_upgradeTower_name).setObject(NULL); 121 145 } 122 146 } … … 131 155 void TowerDefense::start() 132 156 { 133 134 Deathmatch::start(); 135 136 // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path 137 for (int i=0; i < 16 ; i++){ 138 for (int j = 0; j< 16 ; j++){ 139 towermatrix[i][j] = false; 157 if (center_ != NULL) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place. 158 { 159 if (selecter == NULL) 160 { 161 selecter = new TowerDefenseSelecter(this->center_->getContext()); 140 162 } 141 } 142 163 selecter->addTemplate(center_->getSelecterTemplate()); 164 center_->attach(selecter); 165 } 166 else // If no centerpoint was specified, an error is thrown and the level is exited. 167 { 168 orxout(internal_error) << "Jump: No Centerpoint specified." << endl; 169 return; 170 } 171 172 TeamDeathmatch::start(); 173 174 // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path 175 for (int i=0; i < 16 ; i++) 176 { 177 for (int j = 0; j< 16 ; j++) 178 { 179 towerModelMatrix[i][j] = NULL; 180 towerTurretMatrix[i][j] = NULL; 181 } 182 } 183 184 185 186 if (player_ != NULL) 187 { 188 //this->player_->startControl(selecter); 189 } 190 else 191 { 192 orxout() << "player=NULL" << endl; 193 } 194 195 196 Model* dummyModel = new Model(this->center_->getContext()); 197 198 //the path of the spacehips has to be blocked, so that no towers can be build there 143 199 for (int k=0; k<3; k++) 144 tower matrix[1][k]=true;200 towerModelMatrix[1][k]=dummyModel; 145 201 for (int l=1; l<11; l++) 146 towermatrix[l][3]=true;202 towerModelMatrix[l][3]=dummyModel; 147 203 for (int m=3; m<12; m++) 148 towermatrix[10][m]=true;204 towerModelMatrix[10][m]=dummyModel; 149 205 for (int n=10; n<14; n++) 150 towermatrix[n][11]=true;206 towerModelMatrix[n][11]=dummyModel; 151 207 for (int o=13; o<16; o++) 152 towermatrix[13][o]=true; 208 towerModelMatrix[13][o]=dummyModel; 209 153 210 154 211 //set initial credits, lifes and WaveNumber 155 this->setCredit( 200);156 this->setLifes( 50);212 this->setCredit(100); 213 this->setLifes(100); 157 214 this->setWaveNumber(0); 158 215 time=0.0; 159 216 217 /* 160 218 //adds initial towers 161 219 for (int i=0; i <7; i++){ 162 220 addTower(i+3,4); 163 }/* 164 for (int j=0; j < 7; j++){ 165 addTower(9,j+5); 166 }*/ 221 } 222 */ 167 223 } 168 224 … … 178 234 en1->addTemplate("enemytowerdefense1"); 179 235 en1->setScale(3); 180 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 236 en1->lookAt(Vector3(0,0,100000)); 237 en1->setHealth(en1->getHealth() +50 + this->getWaveNumber()*4); 181 238 break; 182 239 … … 184 241 en1->addTemplate("enemytowerdefense2"); 185 242 en1->setScale(2); 186 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 243 en1->lookAt(Vector3(0,0,100000)); 244 en1->roll(Degree(120)); 245 en1->setHealth(en1->getHealth() -30 + this->getWaveNumber()*4); 187 246 // en1->setShieldHealth(en1->getShield() = this->getWaveNumber()*2)) 188 247 break; … … 191 250 en1->addTemplate("enemytowerdefense3"); 192 251 en1->setScale(1); 193 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 252 en1->lookAt(Vector3(0,0,100000)); 253 en1->roll(Degree(120)); 254 en1->setHealth(en1->getHealth() -10 + this->getWaveNumber()*4); 194 255 break; 195 256 } 196 257 258 en1->setTeam(2); 197 259 en1->getController(); 198 en1->setPosition(path.at(0)->get3dcoordinate()); 260 en1->setPosition(path.at(0)->get3dcoordinate()); 199 261 TowerDefenseEnemyvector.push_back(en1); 200 262 … … 209 271 { 210 272 211 Deathmatch::end();273 TeamDeathmatch::end(); 212 274 ChatManager::message("Match is over! Gameover!"); 213 275 276 } 277 278 void TowerDefense::spawnPlayer(PlayerInfo* player) 279 { 280 assert(player); 281 this->player_ = player; 282 283 if (selecter->getPlayer() == NULL) 284 { 285 this->player_ = player; 286 player->startControl(selecter); 287 players_[player].state_ = PlayerState::Alive; 288 } 289 } 290 291 /** 292 @brief 293 Get the player. 294 @return 295 Returns a pointer to the player. If there is no player, NULL is returned. 296 */ 297 PlayerInfo* TowerDefense::getPlayer(void) const 298 { 299 return this->player_; 214 300 } 215 301 216 302 //not working yet 217 303 void TowerDefense::upgradeTower(int x,int y) 218 {/* 219 const int upgradeCost = 20; 304 { 305 TDCoordinate* coord = new TDCoordinate(x,y); 306 x = coord->GetX(); 307 y = coord->GetY(); 308 220 309 221 310 if (!this->hasEnoughCreditForTower(upgradeCost)) … … 225 314 } 226 315 227 if (towermatrix [x][y] == NULL) 316 317 Model* dummyModel2 = new Model(this->center_->getContext()); 318 319 if (towerModelMatrix [x][y] == NULL || (towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource()) 228 320 { 229 321 orxout() << "no tower on this position" << endl; … … 233 325 else 234 326 { 235 (towermatrix [x][y])->upgradeTower(); 236 }*/ 327 (towerTurretMatrix [x][y])->upgradeTower(); 328 switch(towerTurretMatrix[x][y]->upgrade) 329 { 330 case 1 : 331 towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh"); 332 break; 333 334 case 2 : 335 towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh"); 336 break; 337 case 3 : 338 towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh"); 339 break; 340 case 4 : 341 towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh"); 342 break; 343 344 } 345 346 this->buyTower(upgradeCost); 347 } 237 348 } 238 349 239 350 /*adds Tower at Position (x,y) and reduces credit and adds the point to the towermatrix. template ("towerturret") 240 351 so towers have ability if the turrets 241 242 352 */ 353 243 354 void TowerDefense::addTower(int x, int y) 244 { 245 const int towerCost = 20; 355 { 356 TDCoordinate* coord = new TDCoordinate(x,y); 357 x = coord->GetX(); 358 y = coord->GetY(); 359 246 360 247 361 if (!this->hasEnoughCreditForTower(towerCost)) … … 251 365 } 252 366 253 if (tower matrix [x][y]==true)367 if (towerModelMatrix [x][y]!=NULL) 254 368 { 255 369 orxout() << "not possible to put tower here!!" << endl; … … 264 378 int tileScale = (int) this->center_->getTileScale(); 265 379 266 if (x > 15 || y > 15 || x < 0 || y < 0)380 /*if (x > 15 || y > 15 || x < 0 || y < 0) 267 381 { 268 382 //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet) 269 383 orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl; 270 384 return; 271 } 272 273 orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl; 274 275 //Reduce credit 276 this->buyTower(towerCost); 277 towermatrix [x][y]=true; 385 }*/ 386 387 //orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl; 388 orxout() << "Will add tower at (" << x << "," << y << ")" << endl; 389 390 391 //Create Model 392 Model* newTowerModel = new Model(this->center_->getContext()); 393 newTowerModel->setMeshSource("TD_T1.mesh"); 394 newTowerModel->setScale(30); 395 newTowerModel->pitch(Degree(90)); 396 newTowerModel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 80); 278 397 279 398 //Creates tower 280 399 TowerDefenseTower* towernew = new TowerDefenseTower(this->center_->getContext()); 281 towernew->addTemplate("towerturret"); 282 towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75); 400 towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 275); 283 401 towernew->setGame(this); 284 } 402 towernew->setTeam(1); 403 404 //Reduce credit 405 this->buyTower(towerCost); 406 towerModelMatrix [x][y]= newTowerModel; 407 towerTurretMatrix [x][y]= towernew; 408 } 285 409 286 410 bool TowerDefense::hasEnoughCreditForTower(int towerCost) … … 296 420 297 421 422 void TowerDefense::nextwave() 423 { 424 425 orxout() << "newwave" << endl; 426 TowerDefenseEnemyvector.clear(); 427 waves_++; 428 //maxspaceships = round(maxspaceshipsstandard + 0.25*(waves_)); 429 time=0; 430 431 int helpnumber = 40 -(waves_); 432 if(helpnumber <= 0) {helpnumber =1;} 433 float numSpaceships = std::abs((rand() % 100)*5.0f*(helpnumber)); 434 float numEggs = std::abs((rand() % 100)*1.0f*(waves_)); 435 float numUfos = std::abs((rand() % 100)*1.5f*(0.5f*(waves_))) ; 436 437 float totalnumber = (numSpaceships + numEggs + numUfos)*1.3f; 438 439 int newspaceships = (int)(maxspaceships* numSpaceships / totalnumber); 440 int neweggs = (int)(maxspaceships*numEggs / totalnumber); 441 int newufos = (int)(maxspaceships*numUfos / totalnumber); 442 int newrandomships = maxspaceships -newspaceships - neweggs - newufos; 443 spaceships =newspaceships; 444 eggs=neweggs; 445 ufos=newufos; 446 randomships=newrandomships; 447 448 orxout() << spaceships << endl; 449 orxout() << eggs << endl; 450 orxout() << ufos << endl; 451 orxout() << randomships << endl; 452 453 454 455 456 457 } 458 298 459 void TowerDefense::tick(float dt) 299 460 { 300 461 SUPER(TowerDefense, tick, dt); 301 462 time +=dt; 463 timeSetTower_ +=dt; 464 465 //Check if tower has to be set (because TowerDefenseSelecter asks for it) 466 if(timeSetTower_ >= 0.25) 467 { 468 timeSetTower_ =0; 469 if(selecter != NULL && selecter->firePressed_) 470 { 471 472 int x = selecter->selectedPos_->GetX(); 473 int y = selecter->selectedPos_->GetY(); 474 Model* dummyModel2 = new Model(this->center_->getContext()); 475 476 477 478 if(towerModelMatrix[x][y] == NULL) 479 { 480 addTower(x,y); 481 } 482 else 483 { 484 if(!((towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource())) 485 { 486 towerTurretMatrix[x][y]->upgradeTower(); 487 if(towerTurretMatrix[x][y]->upgrade < towerTurretMatrix[x][y]->upgradeMax) 488 { 489 int specificupgradecost = (int)(upgradeCost*(std::pow(1.5,towerTurretMatrix[x][y]->upgrade))); 490 if(this->credit_ >= specificupgradecost) 491 { 492 this->buyTower(specificupgradecost); 493 switch(towerTurretMatrix[x][y]->upgrade) 494 { 495 case 1 : 496 towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh"); 497 break; 498 499 case 2 : 500 towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh"); 501 break; 502 case 3 : 503 towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh"); 504 break; 505 case 4 : 506 towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh"); 507 break; 508 509 } 510 } 511 512 513 } 514 } 515 } 516 selecter->firePressed_ = false; 517 } 518 } 302 519 303 520 TDCoordinate* coord1 = new TDCoordinate(1,1); 304 521 std::vector<TDCoordinate*> path; 305 522 path.push_back(coord1); 306 if(time>1 && TowerDefenseEnemyvector.size() < 30) 307 { 308 //adds different types of enemys depending on the WaveNumber 309 addTowerDefenseEnemy(path, this->getWaveNumber() % 3 +1 ); 310 time = time-1; 311 } 523 524 525 526 527 528 if(time>=TowerDefenseEnemyvector.size() && TowerDefenseEnemyvector.size() < maxspaceships) 529 { 530 531 //adds different types of enemys depending on the WaveNumber progressively making the combination of enemys more difficult 532 if(spaceships>0) 533 { 534 addTowerDefenseEnemy(path, 1); 535 spaceships--; 536 537 }else if(ufos>0) 538 { 539 addTowerDefenseEnemy(path, 3); 540 ufos--; 541 }else if(eggs>0) 542 { 543 addTowerDefenseEnemy(path, 2); 544 eggs--; 545 }else if(randomships>0) 546 { 547 addTowerDefenseEnemy(path, rand() % 3 +1); 548 randomships--; 549 550 } 551 552 } 553 312 554 313 555 Vector3* endpoint = new Vector3(500, 700, 150); … … 317 559 if(TowerDefenseEnemyvector.at(i) != NULL && TowerDefenseEnemyvector.at(i)->isAlive()) 318 560 { 319 //destroys enemys at the end of t ehpath and reduces the life by 1. no credits gifted561 //destroys enemys at the end of the path and reduces the life by 1. no credits gifted 320 562 321 563 Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition(); … … 333 575 } 334 576 } 577 335 578 //goes thorugh vector to see if an enemy is still alive. if not next wave is launched 336 579 int count= 0; … … 343 586 } 344 587 588 if (count == 0 && !this->nextwaveTimer_.isActive()) 589 this->nextwaveTimer_.startTimer(); 590 591 /* time2 +=dt; 345 592 if(count== 0) 346 593 { 347 time2 +=dt;348 594 if(time2 > 10) 349 595 { … … 354 600 } 355 601 } 356 357 358 } 602 */ 603 604 } 605 359 606 360 607 // Function to test if we can add waypoints using code only. Doesn't work yet … … 399 646 void TowerDefense::playerEntered(PlayerInfo* player) 400 647 { 401 Deathmatch::playerEntered(player);648 TeamDeathmatch::playerEntered(player); 402 649 403 650 const std::string& message = player->getName() + " entered the game"; … … 407 654 bool TowerDefense::playerLeft(PlayerInfo* player) 408 655 { 409 bool valid_player = Deathmatch::playerLeft(player);656 bool valid_player = TeamDeathmatch::playerLeft(player); 410 657 411 658 if (valid_player) … … 437 684 } 438 685 439 Deathmatch::pawnKilled(victim, killer);686 TeamDeathmatch::pawnKilled(victim, killer); 440 687 } 441 688 -
code/trunk/src/modules/towerdefense/TowerDefense.h
r10258 r10622 38 38 #define _TowerDefense_H__ 39 39 #include "TDCoordinate.h" 40 #include "TowerDefenseSelecter.h" 40 41 #include "towerdefense/TowerDefensePrereqs.h" 41 #include "gametypes/ Deathmatch.h"42 #include "gametypes/TeamDeathmatch.h" 42 43 #include "TowerDefenseEnemy.h" 43 44 #include "util/Output.h" 44 45 #include "core/object/WeakPtr.h" 46 #include "TowerDefenseSelecter.h" 47 #include "graphics/Camera.h" 48 45 49 46 50 namespace orxonox 47 51 { 48 class _TowerDefenseExport TowerDefense : public Deathmatch52 class _TowerDefenseExport TowerDefense : public TeamDeathmatch 49 53 { 50 54 public: … … 53 57 54 58 std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector; 55 bool towermatrix[16][16]; 59 Model* towerModelMatrix[16][16]; 60 TowerDefenseTower* towerTurretMatrix[16][16]; 56 61 void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr); 57 62 virtual void start(); //<! The function is called when the gametype starts 58 63 virtual void end(); 59 64 virtual void tick(float dt); 60 //virtual void playerEntered(PlayerInfo* player); 61 //virtual bool playerLeft(PlayerInfo* player); 62 //Player Stats (set,get, reduce) 65 virtual void spawnPlayer(PlayerInfo* player); 66 PlayerInfo* getPlayer(void) const; 63 67 int getCredit(){ return this->credit_; } 64 68 int getLifes(){ return this->lifes_; } … … 69 73 void buyTower(int cost){ credit_ -= cost;} 70 74 void addCredit(int credit) { credit_+=credit; } 71 void nextwave() { waves_++;}75 void nextwave(); 72 76 int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; } 77 TowerDefenseSelecter* selecter; 78 int spaceships; 79 int eggs; 80 int ufos; 81 int randomships; 82 73 83 74 84 //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); … … 83 93 /* Adds a tower at x, y in the playfield */ 84 94 void addTower(int x, int y); 85 86 95 void upgradeTower(int x, int y); 87 /* Part of a temporary hack to allow the player to add towers */88 ConsoleCommand* dedicatedAddTower_;89 ConsoleCommand* dedicatedUpgradeTower_;90 96 91 97 //TODO: void spawnNewWave() … … 96 102 private: 97 103 TowerDefenseCenterpoint *center_; 104 PlayerInfo* player_; 98 105 float time; 99 float time2; 106 float timeSetTower_; 107 // float time2; 100 108 int credit_; 101 109 int waves_; 102 110 int lifes_; 111 Timer nextwaveTimer_; 103 112 104 113 /* handles stats */ 105 114 bool hasEnoughCreditForTower(int towerCost); 106 115 bool hasEnoughCreditForUpgrade(); 107 108 109 110 std::vector<TowerTurret*> towers_;111 116 }; 112 117 } -
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc
r9667 r10622 53 53 this->width_ = 15; 54 54 this->height_ = 15; 55 this->towerTemplate_ = "";56 55 57 56 //this->setCollisionType(Static); … … 72 71 XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, getHeight, xmlelement, mode); 73 72 XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode); 74 XMLPortParam(TowerDefenseCenterpoint, " towerTemplate", setTowerTemplate, getTowerTemplate, xmlelement, mode);73 XMLPortParam(TowerDefenseCenterpoint, "selecterTemplate", setSelecterTemplate, getSelecterTemplate, xmlelement, mode); 75 74 76 75 //TODO: add XMLPortObject(TowerDefenseCenterpoint, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode); -
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h
r9667 r10622 60 60 void setWidth(unsigned int width) 61 61 { this->width_ = width; } 62 63 62 unsigned int getWidth(void) const 64 63 { return this->width_; } 65 66 64 void setHeight(unsigned int height) 67 65 { this->height_ = height; } 68 69 66 unsigned int getHeight(void) const 70 67 { return this->height_; } 71 68 void setSelecterTemplate(const std::string& newTemplate) 69 { this->selecterTemplate_ = newTemplate; } 70 const std::string& getSelecterTemplate() const 71 { return this->selecterTemplate_; } 72 72 /** 73 73 @brief How to convert to world coordinates, e.g. that 0,15 is not at -8,-8 but at -80,-80 (if scale would be 10) … … 79 79 { return this->tileScale_; } 80 80 81 /**82 @brief Set the template for the towers.83 @param template The template name to be applied to each tower.84 */85 void setTowerTemplate(const std::string& templateName)86 { this->towerTemplate_ = templateName; }87 88 const std::string& getTowerTemplate(void) const89 { return this->towerTemplate_; }90 91 81 private: 92 82 void checkGametype(); 93 83 84 std::string selecterTemplate_; 94 85 unsigned int width_; 95 86 unsigned int height_; 96 87 unsigned int tileScale_; 97 98 std::string towerTemplate_;99 88 }; 100 89 } -
code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
r10258 r10622 35 35 //add credit if enemy is destroyed 36 36 TowerDefenseEnemy::~TowerDefenseEnemy(){ 37 //this->td->addCredit(1); 37 38 if (this->isInitialized()) 39 { 40 getGame()->addCredit(1); 41 } 38 42 } 39 43 … … 64 68 if (getGame() && once_ == false && getHealth() <= 0) 65 69 { 70 orxout() << "damagefunctionIF" << endl; 66 71 getGame()->addCredit(1); 67 72 once_ = true; 68 73 } 74 orxout() << "damagefunction" << endl; 75 69 76 } 77 70 78 /* 71 79 void TowerDefenseEnemy::popWaypoint() -
code/trunk/src/modules/towerdefense/TowerDefenseTower.cc
r10258 r10622 22 22 Constructor. Registers and initializes the object. 23 23 */ 24 TowerDefenseTower::TowerDefenseTower(Context* context) : Pawn(context)24 TowerDefenseTower::TowerDefenseTower(Context* context) : Turret(context) 25 25 { 26 26 RegisterObject(TowerDefenseTower); 27 game_ =NULL; 28 this->setCollisionType(WorldEntity::None); 29 upgrade = 0; 30 this->addTemplate("towerdefensetower"); 27 31 28 this->setCollisionType(WorldEntity::Dynamic);29 upgrade = 0; 32 upgradeMax = 5; 33 30 34 31 35 //this->removeAllEngines(); … … 38 42 } 39 43 44 /* 40 45 void TowerDefenseTower::setOrientation(const Quaternion& orientation) 41 46 { … … 53 58 { 54 59 } 60 */ 55 61 56 62 bool TowerDefenseTower::upgradeTower() 57 63 { 58 if(upgrade < 3)64 if(upgrade < upgradeMax) 59 65 { 60 66 upgrade++; 61 67 float reloadrate = getReloadRate(); 62 68 float reloadwaittime = getReloadWaitTime(); 63 this->setDamageMultiplier( 5000);64 65 reloadrate = 0. 5f*reloadrate;66 reloadwaittime = 0. 5f*reloadwaittime;69 this->setDamageMultiplier((upgrade+1)*1.5f); 70 this->setRotationThrust(2*this->getRotationThrust()); 71 reloadrate = 0.7f*reloadrate; 72 reloadwaittime = 0.7f*reloadwaittime; 67 73 setReloadRate(reloadrate); 68 74 setReloadWaitTime(reloadwaittime); 69 this->addTemplate("towerturret1");75 //this->addTemplate("towerturret1"); 70 76 } 71 77 else -
code/trunk/src/modules/towerdefense/TowerDefenseTower.h
r10258 r10622 20 20 #include "towerdefense/TowerDefensePrereqs.h" 21 21 #include "worldentities/pawns/SpaceShip.h" 22 #include "objects/Turret.h" 22 23 23 24 24 25 namespace orxonox 25 26 { 26 class _TowerDefenseExport TowerDefenseTower : public Pawn27 class _TowerDefenseExport TowerDefenseTower : public Turret 27 28 { 28 29 public: … … 37 38 38 39 // Overriding these to stop TowerDefenseTowers from spasing out 40 /* 39 41 void setOrientation(const Quaternion& orientation); 40 42 virtual void rotateYaw(const Vector2& value); 41 43 virtual void rotatePitch(const Vector2& value); 42 44 virtual void rotateRoll(const Vector2& value); 45 */ 43 46 virtual bool upgradeTower(); 44 47 … … 46 49 void setGame(TowerDefense* Towerdefense) 47 50 { assert(Towerdefense); game_ = Towerdefense; } 51 int upgrade; 52 int upgradeMax; 48 53 private: 49 54 TowerDefense* game_; 50 int upgrade; 55 51 56 }; 52 57 } -
code/trunk/src/modules/weapons/WeaponsPrereqs.h
r8855 r10622 75 75 class ReplenishingMunition; 76 76 class RocketMunition; 77 class GravityBombMuntion; 77 78 78 79 // projectiles … … 82 83 class Projectile; 83 84 class Rocket; 85 class RocketOld; 84 86 class SimpleRocket; 87 class GravityBomb; 85 88 86 89 // weaponmodes … … 91 94 class LightningGun; 92 95 class RocketFire; 96 class RocketFireOld; 93 97 class SimpleRocketFire; 98 class GravityBombFire; 94 99 } 95 100 -
code/trunk/src/modules/weapons/munitions/CMakeLists.txt
r7846 r10622 4 4 FusionMunition.cc 5 5 RocketMunition.cc 6 GravityBombMunition.cc 6 7 ) -
code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
r8855 r10622 6 6 LightningGunProjectile.cc 7 7 Rocket.cc 8 RocketOld.cc 8 9 SimpleRocket.cc 10 GravityBomb.cc 11 GravityBombField.cc 9 12 ) -
code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc
r9667 r10622 47 47 48 48 this->textureIndex_ = 1; 49 this->setMass(2); 50 this->setCollisionType(Dynamic); 49 51 this->maxTextureIndex_ = 8; 50 52 this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this))); -
code/trunk/src/modules/weapons/projectiles/Rocket.cc
r10216 r10622 48 48 #include "worldentities/CameraPosition.h" 49 49 #include "worldentities/pawns/Pawn.h" 50 //#include "particleuniverse/include/ParticleUniverseSystemManager.h" 50 51 51 52 namespace orxonox … … 83 84 fire->setOrientation(this->getOrientation()); 84 85 fire->setSource("Orxonox/rocketfire"); 86 87 // Add Particle Universe Effects 88 //ParticleUniverse::ParticleSystemManager* pManager = ParticleUniverse::ParticleSystemManager::getSingletonPtr(); 89 //ParticleUniverse::ParticleSystem* pSys1 = pManager->createParticleSystem("pSys1", "bubbles", this->getScene()->getSceneManager()); 90 //this->attachOgreObject(pSys1); 85 91 86 92 this->enableCollisionCallback(); … … 223 229 void Rocket::destructionEffect() 224 230 { 225 ParticleSpawner *effect1, *effect2 ;231 ParticleSpawner *effect1, *effect2, *effect3, *effect4, *effect5; 226 232 if(this->getShooter()) 227 233 { 228 234 effect1 = new ParticleSpawner(this->getShooter()->getContext()); 229 235 effect2 = new ParticleSpawner(this->getShooter()->getContext()); 236 effect3 = new ParticleSpawner(this->getShooter()->getContext()); 237 effect4 = new ParticleSpawner(this->getShooter()->getContext()); 238 effect5 = new ParticleSpawner(this->getShooter()->getContext()); 230 239 } 231 240 else … … 233 242 effect1 = new ParticleSpawner(this->getContext()); 234 243 effect2 = new ParticleSpawner(this->getContext()); 244 effect3 = new ParticleSpawner(this->getContext()); 245 effect4 = new ParticleSpawner(this->getContext()); 246 effect5 = new ParticleSpawner(this->getContext()); 235 247 } 236 248 … … 238 250 effect1->setOrientation(this->getOrientation()); 239 251 effect1->setDestroyAfterLife(true); 240 effect1->setSource(" Orxonox/explosion4");252 effect1->setSource("orxonox/explosion_flash"); 241 253 effect1->setLifetime(2.0f); 242 254 … … 244 256 effect2->setOrientation(this->getOrientation()); 245 257 effect2->setDestroyAfterLife(true); 246 effect2->setSource(" Orxonox/smoke4");258 effect2->setSource("orxonox/explosion_flame"); 247 259 effect2->setLifetime(3.0f); 260 261 effect3->setPosition(this->getPosition()); 262 effect3->setOrientation(this->getOrientation()); 263 effect3->setDestroyAfterLife(true); 264 effect3->setSource("orxonox/explosion_shockwave"); 265 effect3->setLifetime(3.0f); 266 267 effect4->setPosition(this->getPosition()); 268 effect4->setOrientation(this->getOrientation()); 269 effect4->setDestroyAfterLife(true); 270 effect4->setSource("orxonox/explosion_sparks"); 271 effect4->setLifetime(3.0f); 272 273 effect5->setPosition(this->getPosition()); 274 effect5->setOrientation(this->getOrientation()); 275 effect5->setDestroyAfterLife(true); 276 effect5->setSource("orxonox/explosion_streak1"); 277 effect5->setLifetime(3.0f); 248 278 } 249 279 -
code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt
r7163 r10622 6 6 LightningGun.cc 7 7 RocketFire.cc 8 RocketFireOld.cc 8 9 SimpleRocketFire.cc 10 GravityBombFire.cc 9 11 ) -
code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc
r10296 r10622 108 108 model->setScale(5); 109 109 110 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 110 111 projectile->setOrientation(this->getMuzzleOrientation()); 111 112 projectile->setPosition(this->getMuzzlePosition()); -
code/trunk/src/modules/weapons/weaponmodes/FusionFire.cc
r10296 r10622 68 68 BillboardProjectile* projectile = new BillboardProjectile(this->getContext()); 69 69 70 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 70 71 projectile->setOrientation(this->getMuzzleOrientation()); 71 72 projectile->setPosition(this->getMuzzlePosition()); -
code/trunk/src/modules/weapons/weaponmodes/LaserFire.cc
r10296 r10622 66 66 ParticleProjectile* projectile = new ParticleProjectile(this->getContext()); 67 67 68 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 68 69 projectile->setOrientation(this->getMuzzleOrientation()); 69 70 projectile->setPosition(this->getMuzzlePosition()); -
code/trunk/src/orxonox/controllers/ControllerDirector.cc
r10262 r10622 41 41 { 42 42 SUPER(ControllerDirector, XMLPort, xmlelement, mode); 43 XMLPortParam(ControllerDirector, "scriptname", setScriptName, getScriptName, xmlelement, mode).defaultValues("testscript"); 43 44 44 45 orxout(verbose)<< "ControllerDirector::XMLPort " … … 83 84 else 84 85 return; 85 86 86 87 /* Set up a luastate to use for running the scripts */ 87 88 LuaState * ls = new LuaState(); … … 98 99 * variable "newctrlid" defined, which means it can make use of it. 99 100 */ 100 101 ls->doFile( "testscript.lua");101 std::string scr = this->scriptname_ + ".lua"; 102 ls->doFile(scr); 102 103 103 104 /* Increase the controller ID so we have a different one for -
code/trunk/src/orxonox/controllers/ControllerDirector.h
r10262 r10622 47 47 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 48 48 49 inline void setScriptName(const std::string& name) { this->scriptname_ = name; } 50 inline const std::string& getScriptName() const { return this->scriptname_; } 51 49 52 50 53 /* Take over control of a given object */ … … 55 58 //void setNewController(Controller * controller); 56 59 57 private: 60 protected: 61 std::string scriptname_; 58 62 PlayerInfo* player_; 59 63 ControllableEntity* entity_; -
code/trunk/src/orxonox/controllers/FormationController.cc
r10290 r10622 955 955 bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 956 956 { 957 958 957 959 if (entity1 == entity2) 958 960 return true; … … 984 986 } 985 987 986 Team Deathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);988 TeamGametype* tdm = orxonox_cast<TeamGametype*>(gametype); 987 989 if (tdm) 988 990 { … … 992 994 if (entity2->getPlayer()) 993 995 team2 = tdm->getTeam(entity2->getPlayer()); 994 }995 996 Mission* miss = orxonox_cast<Mission*>(gametype);997 if (miss)998 {999 if (entity1->getPlayer())1000 team1 = miss->getTeam(entity1->getPlayer());1001 1002 if (entity2->getPlayer())1003 team2 = miss->getTeam(entity2->getPlayer());1004 996 } 1005 997 -
code/trunk/src/orxonox/controllers/ScriptController.cc
r10262 r10622 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * ... 24 24 * Co-authors: 25 25 * ... 26 26 * 27 27 */ 28 29 /* 30 * Currently available lua commands: 31 * 32 * IMPORTANT: ALL COMMANDS DO REQUIRE 7 PARAMETERS TO BE PROVIDED. FILL UP WITH ZEROES IN UNIMPORTANT PLACES. 33 * 34 * Command | Abbreviation | Parameter 1 | '' 2 | '' 3 | '' 4 | '' 5 | '' 6 | '' 7 35 * 36 * "Move And Look" | mal | GoTo X Coordinate | '' Y '' | '' Z '' | LookAt X Coordinate | '' Y '' | '' Y '' | Duration 37 * "Rotate And Look" | ral | GoTo X Coordinate | '' Y '' | '' Z '' | Axis (1=x, 2=z, 3=z) | - | - | Duration 38 * "Spiral" | spi | GoTo X Coordinate | '' Y '' | '' Z '' | - | - | - | Duration 39 * "Transition Look" | chl | From X Coordinate | '' Y '' | '' Z '' | To X Coordinate | '' Y '' | '' Y '' | Duration 40 * "Idle (Do nothing)" | idle | Duration 41 */ 28 42 29 43 #include "ScriptController.h" … … 32 46 #include "worldentities/ControllableEntity.h" 33 47 #include "core/LuaState.h" 34 #include <cmath> 48 #include "core/LuaState.h" 49 #include "util/Math.h" 35 50 36 51 namespace orxonox … … 66 81 this->eventno = 0; 67 82 83 /* - First "previous event" scheduled at t=0 */ 84 /* - Needed for automatically updating event times */ 85 this->prevEventTime = 0; 68 86 } 69 87 … … 178 196 179 197 /* Get a variable that specifies how far along the trajectory 180 * we are 198 * we are currently. 181 199 */ 182 200 float dl = eventTime / currentEvent.duration; 183 201 184 /* Depending */202 /* Depending on command */ 185 203 /* Do some moving */ 186 204 if( this->processing ) 187 { 188 if( this->currentEvent.fctName == "mal" ) 205 { 206 // Abbreviation for "spiral" (rotation + translation) 207 if (this->currentEvent.fctName == "spi") { 208 209 // Need to know a perpendicular basis to the translation vector: 210 // Given (a, b, c) we chose (b, -a, 0)norm and (0, c, -b)norm 211 // Currently we set a fix rotational radius of 400 212 // TODO: Add an option to adjust radius of spiral movement 213 Vector3 direction = this->currentEvent.v1 - startpos; 214 215 Vector3* ortho1 = new Vector3(direction.y, -direction.x, 0); 216 float absOrtho1 = sqrt(direction.y * direction.y + direction.x * direction.x); 217 *ortho1 = 400 * cos(2 * math::pi * dl) * (*ortho1)/absOrtho1; 218 219 Vector3* ortho2 = new Vector3(0, direction.z, -direction.y); 220 float absOrtho2 = sqrt(direction.y * direction.y + direction.z * direction.z); 221 *ortho2 = 400 * sin(2 * math::pi * dl) * (*ortho2)/absOrtho2; 222 223 this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1 + *ortho1 + *ortho2); 224 225 delete ortho1; 226 delete ortho2; 227 } 228 229 // Abbreviation for "rotate and look" 230 if (this->currentEvent.fctName == "ral") 231 { 232 // Specify the axis 233 Vector3* a; 234 switch ((int) currentEvent.d) { 235 case 3: 236 a = new Vector3(this->currentEvent.v1.x + this->currentEvent.e*cos(2*math::pi*dl), 237 this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl), 238 this->currentEvent.v1.z); 239 break; 240 case 2: 241 a = new Vector3(this->currentEvent.v1.x + this->currentEvent.e*sin(2*math::pi*dl), 242 this->currentEvent.v1.y, 243 this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl)); 244 break; 245 case 1: 246 a = new Vector3(this->currentEvent.v1.x, 247 this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl), 248 this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl)); 249 break; 250 } 251 252 this->entity_->setPosition(*a); 253 254 /* Look at the specified position */ 255 this->entity_->lookAt(this->currentEvent.v1); 256 } 257 else if( this->currentEvent.fctName == "mal" ) 189 258 { 190 259 /* Set the position to the correct place in the trajectory */ … … 193 262 /* Look at the specified position */ 194 263 this->entity_->lookAt(this->currentEvent.v2); 195 196 /* Update look at position */197 //this->lookAtPosition = this->currentEvent.v2;198 264 } 199 265 else if( this->currentEvent.fctName == "chl" ) … … 224 290 /* Fill the structure with all the provided information */ 225 291 tmp.fctName = instruction; 292 226 293 //tmp.x1 = x1; tmp.y1 = y1; tmp.z1 = z1; 227 294 //tmp.x2 = x2; tmp.y2 = y2; tmp.z2 = z2; 228 295 tmp.v1 = Vector3(x1,y1,z1); 229 296 tmp.v2 = Vector3(x2,y2,z2); 297 298 // the parameters are not required to be vector coordinates! 299 // for convenience they are however stored twice if they have some kind of different meaning 300 tmp.a = x1; 301 tmp.b = y1; 302 tmp.c = z1; 303 tmp.d = x2; 304 tmp.e = y2; 305 tmp.f = z2; 306 230 307 tmp.duration = duration; 231 tmp.eventTime = executionTime; 232 233 orxout(verbose) << tmp.fctName << endl; 308 309 /* This is kind of a hack. If we hit the function idle all we want to do is 310 advance event execution time, not schedule anything */ 311 if (instruction == "idle") { 312 tmp.eventTime = this->prevEventTime; 313 this->prevEventTime += x1; 314 return; 315 } else { 316 tmp.eventTime = this->prevEventTime; 317 this->prevEventTime += duration; 318 } 234 319 235 320 /* Add the created event to the event list */ -
code/trunk/src/orxonox/controllers/ScriptController.h
r10262 r10622 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * ... 24 24 * Co-authors: 25 25 * ... … … 45 45 std::string fctName; 46 46 47 /** Final position we want to be at **/ 47 48 Vector3 v1; 49 50 /** Where we are looking **/ 48 51 Vector3 v2; 52 53 /** The parameters are additionally stored as a set of 6 numerical values **/ 54 float a, b, c, d, e, f; 49 55 50 56 /** Time span of the event */ … … 69 75 // LUA interface 70 76 // tolua_begin 71 void eventScheduler(std::string instruction ,72 float x1 , float y1, float z1,73 float x2 , float y2, float z2,74 float duration , float executionTime);77 void eventScheduler(std::string instruction = "", 78 float x1 = 0, float y1 = 0, float z1 = 0, 79 float x2 = 0, float y2 = 0, float z2 = 0, 80 float duration = 0, float executionTime = 0); 75 81 76 82 static ScriptController* getScriptController(); … … 116 122 Vector3 startpos; 117 123 124 /* Time of the previously scheduled event */ 125 float prevEventTime; 126 118 127 /* - Position to look at during that transition */ 119 128 //Vector3 lookAtPosition; -
code/trunk/src/orxonox/controllers/testscript.lua
r10262 r10622 1 print 1 print ('1: Hello World') -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r10216 r10622 367 367 if (GameMode::isMaster()) 368 368 { 369 // this->deathEffect();369 this->deatheffect(); 370 370 this->goWithStyle(); 371 371 } … … 387 387 { 388 388 // play death effect 389 {389 /*{ 390 390 ParticleSpawner* effect = new ParticleSpawner(this->getContext()); 391 391 effect->setPosition(this->getPosition()); … … 410 410 effect->setSource("Orxonox/sparks"); 411 411 effect->setLifetime(4.0f); 412 } 412 }*/ 413 414 415 { 416 ParticleSpawner* effect = new ParticleSpawner(this->getContext()); 417 effect->setPosition(this->getPosition()); 418 effect->setOrientation(this->getOrientation()); 419 effect->setDestroyAfterLife(true); 420 effect->setSource("orxonox/explosion_flash2"); 421 effect->setLifetime(5.0f); 422 } 423 { 424 ParticleSpawner* effect = new ParticleSpawner(this->getContext()); 425 effect->setPosition(this->getPosition()); 426 effect->setOrientation(this->getOrientation()); 427 effect->setDestroyAfterLife(true); 428 effect->setSource("orxonox/explosion_flame2"); 429 effect->setLifetime(5.0f); 430 } 431 { 432 ParticleSpawner* effect = new ParticleSpawner(this->getContext()); 433 effect->setPosition(this->getPosition()); 434 effect->setOrientation(this->getOrientation()); 435 effect->setDestroyAfterLife(true); 436 effect->setSource("orxonox/explosion_shockwave2"); 437 effect->scale(20); 438 effect->setLifetime(5.0f); 439 }{ 440 ParticleSpawner* effect = new ParticleSpawner(this->getContext()); 441 effect->setPosition(this->getPosition()); 442 effect->setOrientation(this->getOrientation()); 443 effect->setDestroyAfterLife(true); 444 effect->setSource("orxonox/explosion_sparks2"); 445 effect->setLifetime(5.0f); 446 } 447 { 448 ParticleSpawner* effect = new ParticleSpawner(this->getContext()); 449 effect->setPosition(this->getPosition()); 450 effect->setOrientation(this->getOrientation()); 451 effect->setDestroyAfterLife(true); 452 effect->setSource("orxonox/explosion_streak2"); 453 effect->setLifetime(5.0f); 454 } 455 { 456 ParticleSpawner* effect = new ParticleSpawner(this->getContext()); 457 effect->setPosition(this->getPosition()); 458 effect->setOrientation(this->getOrientation()); 459 effect->setDestroyAfterLife(true); 460 effect->setSource("orxonox/explosion_afterglow"); 461 effect->scale(20); 462 effect->setLifetime(5.0f); 463 } 464 465 413 466 for (unsigned int i = 0; i < this->numexplosionchunks_; ++i) 414 467 {
Note: See TracChangeset
for help on using the changeset viewer.