- Timestamp:
- Jun 14, 2006, 10:08:41 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 50 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_reaction/collision_handle.cc
r8190 r8362 24 24 25 25 #include "cr_object_damage.h" 26 27 #include "debug.h" 26 28 27 29 using namespace std; -
trunk/src/lib/collision_reaction/cr_engine.cc
r8190 r8362 24 24 25 25 #include "cr_engine.h" 26 27 #include "debug.h" 26 28 27 29 using namespace std; -
trunk/src/lib/collision_reaction/cr_object_damage.cc
r8190 r8362 23 23 #include "world_entity.h" 24 24 #include "cr_object_damage.h" 25 26 #include "debug.h" 25 27 26 28 using namespace std; -
trunk/src/lib/graphics/effects/fog_effect.cc
r8316 r8362 17 17 #include "util/loading/load_param.h" 18 18 #include "util/loading/factory.h" 19 20 #include "glincl.h"21 19 22 20 #include "shell_command.h" -
trunk/src/lib/graphics/effects/fog_effect.h
r8255 r8362 9 9 10 10 #include "weather_effect.h" 11 #include "glincl.h" 12 11 13 12 14 class FogEffect : public WeatherEffect … … 43 45 GLfloat fogFadeDuration; 44 46 float localTimer; 45 47 46 48 GLint fogMode; 47 49 GLfloat fogDensity; -
trunk/src/lib/graphics/effects/lense_flare.cc
r8316 r8362 22 22 #include "util/loading/factory.h" 23 23 24 #include "glincl.h"25 24 #include "texture.h" 26 25 -
trunk/src/lib/graphics/effects/lense_flare.h
r7844 r8362 13 13 #include "vector2D.h" 14 14 #include "plane.h" 15 #include "glincl.h" 15 16 16 17 -
trunk/src/lib/graphics/effects/volfog_effect.cc
r8316 r8362 21 21 #include "state.h" 22 22 23 #include "glincl.h"24 //#include "shell_command.h"25 23 26 24 #define GLX_GLXEXT_PROTOTYPES -
trunk/src/lib/graphics/effects/volfog_effect.h
r7810 r8362 9 9 10 10 #include "weather_effect.h" 11 #include "glincl.h" 11 12 12 13 class VolFogEffect : public WeatherEffect -
trunk/src/lib/graphics/importer/material.cc
r8316 r8362 21 21 #include "texture.h" 22 22 #include "debug.h" 23 #include "compiler.h" 23 24 #include "util/loading/resource_manager.h" 24 25 -
trunk/src/lib/graphics/importer/static_model.cc
r8316 r8362 20 20 #include "static_model.h" 21 21 22 #include " stdlibincl.h"22 #include "debug.h" 23 23 #include <stdarg.h> 24 24 -
trunk/src/lib/graphics/importer/vertex_array_model.cc
r7194 r8362 18 18 #include "vertex_array_model.h" 19 19 20 #include "stdlibincl.h"21 20 #include <stdarg.h> 21 #include "debug.h" 22 22 23 23 #include "tc.h" -
trunk/src/lib/gui/gui_saveable.cc
r7661 r8362 19 19 #include "gui.h" 20 20 #include "preferences.h" 21 22 #include "debug.h" 21 23 22 24 namespace OrxGui -
trunk/src/lib/gui/qt/gui_video.cc
r8145 r8362 30 30 #include "globals.h" 31 31 #include "debug.h" 32 33 #include "sdlincl.h" 32 34 33 35 #include "qt_gui_elements.h" -
trunk/src/lib/lang/base_object.h
r8350 r8362 11 11 12 12 #include "class_id.h" 13 #include "debug.h"14 13 #include <string> 15 16 #include "stdincl.h"17 14 18 15 class TiXmlNode; -
trunk/src/lib/network/connection_monitor.h
r8068 r8362 11 11 12 12 #include <map> 13 #include <list> 13 14 14 15 #define N_PACKETS_FOR_PING 20 … … 24 25 void processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId ); 25 26 void processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState ); 26 27 27 28 void processZippedOutgoingPacket( int tick, byte * data, int length, int stateId ); 28 29 void processZippedIncomingPacket( int tick, byte * data, int length ); 29 30 30 31 void calculatePing(); 31 32 32 33 bool hasTimedOut(); 33 34 34 35 void printStatis(); 35 36 36 37 private: 37 38 float calculateBandWidth( std::map<int,int> packetHistory, int tick ); 38 39 int userId; //!< user's id 39 40 int userId; //!< user's id 40 41 41 42 std::map<int,int> sentStateTicks; 42 43 43 44 std::map<int,int> incomingUnzippedPacketHistory; 44 45 std::map<int,int> outgoingUnzippedPacketHistory; 45 46 46 47 std::map<int,int> incomingZippedPacketHistory; 47 48 std::map<int,int> outgoingZippedPacketHistory; 48 49 49 50 std::list<int> ackDelay; 50 51 int ping; … … 52 53 float incomingUnzippedBandWidth; 53 54 float outgoingUnzippedBandWidth; 54 55 55 56 float incomingZippedBandWidth; 56 57 float outgoingZippedBandWidth; 57 58 58 59 int nIncomingPackets; 59 60 int nOutgoingPackets; 60 61 61 62 int nZIncomingPackets; 62 63 int nZOutgoingPackets; 63 64 64 65 int lastPacketTick; 65 66 66 67 int lastPrintTick; 67 68 }; -
trunk/src/lib/network/converter.cc
r7954 r8362 23 23 #include "converter.h" 24 24 #include "shell_command.h" 25 25 #include "debug.h" 26 26 #include <limits> 27 27 … … 489 489 { 490 490 PRINTF(1)("something went wrong length > remaining bytes in buffer\n" ); 491 491 492 492 //TODO remove this 493 493 for ( int i = -1000; i < 1001; i++ ) … … 499 499 } 500 500 printf("\n"); 501 501 502 502 s = ""; 503 503 return -1; -
trunk/src/lib/network/handshake.cc
r7954 r8362 23 23 24 24 #include <cassert> 25 #include "debug.h" 25 26 26 27 Handshake::Handshake( bool server, int clientId, int networkGameManagerId, int messageManagerId ) … … 31 32 32 33 this->setIsServer(server); 33 34 34 35 orxId_handler = registerVarId( new SynchronizeableInt( &localState.orxId, &remoteState.orxId, "orxonoxId", PERMISSION_ALL ) ); 35 36 version_handler = registerVarId( new SynchronizeableInt( &localState.version, &remoteState.version, "version", PERMISSION_ALL ) ); … … 40 41 error_handler = registerVarId( new SynchronizeableInt( &localState.error, &remoteState.error, "error", PERMISSION_ALL ) ); 41 42 errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString", PERMISSION_ALL ) ); 42 43 43 44 candel_id = registerVarId( new SynchronizeableInt( &localState.canDel, &remoteState.canDel, "canDel", PERMISSION_ALL ) ); 44 45 45 46 localState.completed = 0; 46 47 localState.error = 0; … … 52 53 localState.version = _ORXONOX_VERSION; 53 54 localState.canDel = 0; 54 55 55 56 remoteState.completed = 0; 56 57 remoteState.error = 0; … … 86 87 87 88 } 88 89 89 90 if ( *it == version_handler ) 90 91 { … … 98 99 99 100 } 100 101 101 102 if ( *it == candel_id ) 102 103 { 103 104 PRINTF(0)("handshake finished candel changed\n"); 104 105 } 105 106 106 107 } 107 108 108 109 if ( 109 110 remoteState.orxId == _ORXONOX_ID && -
trunk/src/lib/network/network_game_manager.cc
r8228 r8362 39 39 #include "network_game_manager.h" 40 40 41 #include "debug.h" 42 41 43 42 44 /* using namespace std is default, this needs to be here */ … … 57 59 58 60 this->setSynchronized(true); 59 61 60 62 MessageManager::getInstance()->registerMessageHandler( MSGID_DELETESYNCHRONIZEABLE, delSynchronizeableHandler, NULL ); 61 63 MessageManager::getInstance()->registerMessageHandler( MSGID_PREFEREDTEAM, preferedTeamHandler, NULL ); 62 64 63 65 this->gameState = 0; 64 66 registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState" ) ); … … 75 77 /** 76 78 * insert new player into game 77 * @param userId 78 * @return 79 * @param userId 80 * @return 79 81 */ 80 82 bool NetworkGameManager::signalNewPlayer( int userId ) … … 83 85 assert( State::getGameRules() ); 84 86 assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) ); 85 87 86 88 NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); 87 89 88 90 int team = rules.getTeamForNewUser(); 89 91 ClassID playableClassId = rules.getPlayableClassId( userId, team ); 90 92 std::string playableModel = rules.getPlayableModelFileName( userId, team, playableClassId ); 91 93 92 94 BaseObject * bo = Factory::fabricate( playableClassId ); 93 95 94 96 assert( bo != NULL ); 95 97 assert( bo->isA( CL_PLAYABLE ) ); 96 98 97 99 Playable & playable = *(dynamic_cast<Playable*>(bo)); 98 100 99 101 playable.loadModel( playableModel ); 100 102 playable.setOwner( userId ); 101 103 playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); 102 104 playable.setSynchronized( true ); 103 105 104 106 PlayerStats * stats = rules.getNewPlayerStats( userId ); 105 107 106 108 stats->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); 107 109 stats->setSynchronized( true ); 108 110 stats->setOwner( getHostID() ); 109 111 110 112 stats->setTeamId( team ); 111 113 stats->setPlayableClassId( playableClassId ); 112 114 stats->setPlayableUniqueId( playable.getUniqueID() ); 113 115 stats->setModelFileName( playableModel ); 114 116 115 117 return true; 116 118 } … … 119 121 /** 120 122 * remove player from game 121 * @param userID 122 * @return 123 * @param userID 124 * @return 123 125 */ 124 126 bool NetworkGameManager::signalLeftPlayer(int userID) … … 130 132 delete PlayerStats::getStats( userID ); 131 133 } 132 134 133 135 return true; 134 136 } … … 138 140 /** 139 141 * handler for remove synchronizeable messages 140 * @param messageId 141 * @param data 142 * @param dataLength 143 * @param someData 144 * @param userId 142 * @param messageId 143 * @param data 144 * @param dataLength 145 * @param someData 146 * @param userId 145 147 * @return true on successfull handling else handler will be called again 146 148 */ … … 152 154 return true; 153 155 } 154 156 155 157 int uniqueId = 0; 156 158 int len = Converter::byteArrayToInt( data, &uniqueId ); 157 159 158 160 if ( len != dataLength ) 159 161 { … … 161 163 return true; 162 164 } 163 165 164 166 const std::list<BaseObject*> * list = ClassList::getList( CL_SYNCHRONIZEABLE ); 165 167 166 168 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 167 169 { … … 173 175 return true; 174 176 } 175 177 176 178 delete dynamic_cast<Synchronizeable*>(*it); 177 179 return true; 178 180 } 179 181 } 180 182 181 183 return true; 182 184 } … … 189 191 { 190 192 byte buf[INTSIZE]; 191 193 192 194 assert( Converter::intToByteArray( uniqueId, buf, INTSIZE ) == INTSIZE ); 193 195 194 196 MessageManager::getInstance()->sendMessage( MSGID_DELETESYNCHRONIZEABLE, buf, INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH ); 195 197 } … … 199 201 /** 200 202 * handler for MSGID_PREFEREDTEAM message 201 * @param messageId 202 * @param data 203 * @param dataLength 204 * @param someData 205 * @param userId 206 * @return 203 * @param messageId 204 * @param data 205 * @param dataLength 206 * @param someData 207 * @param userId 208 * @return 207 209 */ 208 210 bool NetworkGameManager::preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 209 211 { 210 212 assert( NetworkGameManager::getInstance()->isServer() ); 211 213 212 214 int teamId = 0; 213 215 int len = Converter::byteArrayToInt( data, &teamId ); 214 216 215 217 if ( len != dataLength ) 216 218 { … … 218 220 return true; 219 221 } 220 222 221 223 NetworkGameManager::getInstance()->setPreferedTeam( userId, teamId ); 222 224 223 225 return true; 224 226 } … … 228 230 if ( !PlayerStats::getStats( userId ) ) 229 231 return; 230 232 231 233 PlayerStats & stats = *(PlayerStats::getStats( userId )); 232 234 233 235 stats.setPreferedTeamId( teamId ); 234 236 } … … 236 238 /** 237 239 * set prefered team for this host 238 * @param teamId 240 * @param teamId 239 241 */ 240 242 void NetworkGameManager::prefereTeam( int teamId ) … … 245 247 { 246 248 byte buf[INTSIZE]; 247 249 248 250 assert( Converter::intToByteArray( teamId, buf, INTSIZE) == INTSIZE ); 249 251 250 252 MessageManager::getInstance()->sendMessage( MSGID_PREFEREDTEAM, buf, INTSIZE, RT_USER, 0, MP_HIGHBANDWIDTH ); 251 253 } -
trunk/src/lib/network/player_stats.cc
r8228 r8362 23 23 #include "shared_network_data.h" 24 24 25 #include "debug.h" 26 25 27 26 28 CREATE_FACTORY(PlayerStats, CL_PLAYER_STATS); … … 32 34 { 33 35 init(); 34 36 35 37 this->userId = userId; 36 38 } … … 54 56 this->playableClassId = 0; 55 57 this->modelFileName = ""; 56 58 57 59 userId_handle = registerVarId( new SynchronizeableInt( &userId, &userId, "userId" ) ); 58 60 teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) ); … … 62 64 playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId" ) ); 63 65 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) ); 64 66 65 67 PRINTF(0)("PlayerStats created\n"); 66 68 } … … 85 87 { 86 88 this->setPlayableUniqueId( this->playableUniqueId ); 87 89 88 90 PRINTF(0)("uniqueID changed %d %d %d\n", userId, getHostID(), getUniqueID()); 89 91 } … … 98 100 { 99 101 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 100 102 101 103 if ( !list ) 102 104 { 103 105 return NULL; 104 106 } 105 107 106 108 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 107 109 { … … 111 113 } 112 114 } 113 115 114 116 return NULL; 115 117 } … … 121 123 { 122 124 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 123 125 124 126 if ( !list ) 125 127 { … … 127 129 return; 128 130 } 129 131 130 132 this->playable = NULL; 131 133 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) … … 139 141 } 140 142 } 141 143 142 144 if ( this->playable && userId == getHostID() ) 143 145 { 144 146 State::getPlayer()->setPlayable( this->playable ); 145 147 } 146 148 147 149 this->playableUniqueId = uniqueId; 148 150 } … … 156 158 if ( playable ) 157 159 return playable; 158 160 159 161 assert( playableUniqueId > 0 ); 160 162 161 163 setPlayableUniqueId( playableUniqueId ); 162 164 163 165 assert( playable ); 164 166 165 167 return playable; 166 168 } -
trunk/src/lib/network/udp_server_socket.cc
r8228 r8362 15 15 16 16 #include "udp_server_socket.h" 17 #include "debug.h" 17 18 18 19 … … 20 21 /** 21 22 * constructor 22 * @param port port to listen on 23 * @param port port to listen on 23 24 */ 24 25 UdpServerSocket::UdpServerSocket( int port ) : ServerSocket( port ) 25 26 { 26 27 packet = SDLNet_AllocPacket( UDP_PACKET_SIZE ); 27 28 28 29 if ( !packet ) 29 30 { 30 31 PRINTF(1)("SDLNet_AllocPacket: %s\n", SDLNet_GetError()); 31 32 32 33 assert( false ); 33 34 bOk = false; 34 35 } 35 36 36 37 memset( packet->data, 0, UDP_PACKET_SIZE ); 37 38 38 39 listen( port ); 39 40 } … … 46 47 for ( int i = 0; i < (int)packetBuffer.size(); i++ ) 47 48 removeUserPackets( i ); 48 49 49 50 if ( packet ) 50 51 SDLNet_FreePacket( packet ); 51 52 52 53 if ( socket ) 53 54 SDLNet_UDP_Close( socket ); … … 62 63 { 63 64 socket = SDLNet_UDP_Open( port ); 64 65 65 66 PRINTF(0)("listening on port: %d\n", port); 66 67 67 68 if ( !socket ) 68 69 { 69 70 70 71 bOk = false; 71 72 return false; 72 73 } 73 74 74 75 return true; 75 76 } … … 82 83 { 83 84 NetworkSocket * result = NULL; 84 85 85 86 if ( newSocketList.size() > 0 ) 86 87 { 87 88 result = newSocketList.front(); 88 89 89 90 newSocketList.pop_front(); 90 91 } 91 92 92 93 return result; 93 94 } … … 98 99 void UdpServerSocket::close( ) 99 100 { 100 101 101 102 for ( int i = 0; i < (int)packetBuffer.size(); i++ ) 102 103 removeUserPackets( i ); 103 104 104 105 packetBuffer.clear(); 105 106 userList.clear(); 106 107 107 108 SDLNet_UDP_Close( socket ); 108 109 socket = NULL; … … 117 118 if ( userId >= (int)packetBuffer.size() ) 118 119 return; 119 120 120 121 for ( NetworkPacketList::iterator it = packetBuffer[userId].begin(); it!=packetBuffer[userId].end(); it++ ) 121 122 { … … 126 127 } 127 128 } 128 129 129 130 packetBuffer[userId].clear(); 130 131 } … … 140 141 res.data = NULL; 141 142 res.length = 0; 142 143 143 144 if ( (int)packetBuffer.size() > userId && (int)packetBuffer[userId].size() > 0 ) 144 145 { … … 146 147 res.length = packetBuffer[userId].front().length; 147 148 packetBuffer[userId].pop_front(); 148 149 149 150 if ( res.length == 0 ) 150 151 res.length = -1; 151 152 } 152 153 153 154 return res; 154 155 } … … 163 164 if ( userId >= (int)packetBuffer.size() ) 164 165 return -1; 165 166 166 167 return packetBuffer[userId].size(); 167 168 } 168 169 169 170 /** 170 * will set user state 171 * will set user state 171 172 * @param userId users id 172 173 * @param ip users host / port … … 175 176 { 176 177 int channel = SDLNet_UDP_Bind( socket, userId, &ip ); 177 if( channel != userId ) 178 if( channel != userId ) 178 179 { 179 180 PRINTF(1)("SDLNet_UDP_Bind: %s\n", SDLNet_GetError()); … … 181 182 return; 182 183 } 183 184 184 185 if ( userId < (int)packetBuffer.size() ) 185 186 removeUserPackets( userId ); 186 187 187 188 if ( (int)packetBuffer.size() <= userId ) 188 189 packetBuffer.resize( userId + 1 ); 189 190 190 191 if ( (int)userList.size() <= userId ) 191 192 userList.resize( userId + 1 ); 192 193 193 194 userList[ userId ] = ip; 194 195 } … … 201 202 { 202 203 removeUserPackets( userId ); 203 204 204 205 if ( userId >= (int)userList.size() ) 205 206 return; 206 207 207 208 userList[userId].host = 0; 208 209 userList[userId].port = 0; 209 210 210 211 SDLNet_UDP_Unbind( socket, userId ); 211 212 } … … 220 221 { 221 222 assert( networkPacket.length <= UDP_PACKET_SIZE ); 222 223 223 224 memcpy( packet->data, networkPacket.data, networkPacket.length ); 224 225 packet->len = networkPacket.length; 225 226 packet->channel = -1; 226 227 227 228 if ( SDLNet_UDP_Send( socket, userId, packet ) == 0 ) 228 229 { … … 230 231 return false; 231 232 } 232 233 233 234 return true; 234 235 } … … 241 242 int res; 242 243 int newConn = 0; 243 244 244 245 for ( res = SDLNet_UDP_Recv( socket, packet ); res == 1; res = SDLNet_UDP_Recv( socket, packet ) ) 245 246 { 246 247 int userId; 247 248 bool isNewConnection = false; 248 249 249 250 for ( userId =0; userId < (int)userList.size(); userId++ ) 250 251 if ( userList[userId].host == packet->address.host && userList[userId].port == packet->address.port ) 251 252 break; 252 253 253 254 if ( userId >= (int)userList.size() ) 254 255 { 255 256 256 257 newConn++; 257 258 isNewConnection = true; 258 259 259 260 if ( newConn > MAX_NEW_CONNECTIONS ) 260 261 { … … 262 263 continue; 263 264 } 264 265 265 266 for ( userId =0; userId < (int)userList.size(); userId++ ) 266 267 if ( userList[userId].host == 0 && userList[userId].port == 0 ) 267 268 break; 268 269 269 270 initUser( userId, packet->address ); 270 271 UdpSocket * sock = new UdpSocket( this, packet->address, userId ); … … 272 273 PRINTF(0)("NEW CONNECTION %x\n", packet->address.host ); 273 274 } 274 275 275 276 //add new packet to packetbuffer 276 277 … … 290 291 291 292 } 292 293 293 294 assert( res == 0 ); 294 295 } -
trunk/src/lib/network/udp_socket.cc
r8228 r8362 16 16 #include "udp_socket.h" 17 17 #include "udp_server_socket.h" 18 #include "debug.h" 18 19 19 20 … … 36 37 init(); 37 38 this->packet = SDLNet_AllocPacket( UDP_PACKET_SIZE ); 38 39 39 40 assert( this->packet ); 40 41 41 42 memset( packet->data, 0, UDP_PACKET_SIZE ); 42 43 PRINTF(0)("PACKET DATA: %x\n", packet->data); 43 44 44 45 this->connectToServer( host, port ); 45 46 } … … 52 53 this->init(); 53 54 this->packet = SDLNet_AllocPacket( UDP_PACKET_SIZE ); 54 55 55 56 if ( !packet ) 56 57 { 57 58 PRINTF(1)("SDLNet_AllocPacket: %s\n", SDLNet_GetError()); 58 59 59 60 assert( false ); 60 61 bOk = false; 61 62 } 62 63 63 64 } 64 65 … … 82 83 { 83 84 this->disconnectServer(); 84 85 85 86 if ( serverSocket ) 86 87 serverSocket->removeUser( userId ); … … 88 89 if ( this->packet ) 89 90 SDLNet_FreePacket( this->packet ); 90 91 91 92 if ( socket ) 92 93 SDLNet_UDP_Close( socket ); … … 101 102 { 102 103 assert( serverSocket == NULL ); 103 104 104 105 IPaddress ip; 105 106 106 107 PRINTF(0)("connect to server %s on port %d\n", host.c_str(), port); 107 108 108 109 if ( SDLNet_ResolveHost( &ip, host.c_str(), port ) != 0 ) 109 110 { … … 112 113 return; 113 114 } 114 115 115 116 socket = SDLNet_UDP_Open(0); 116 117 if ( !socket ) … … 120 121 return; 121 122 } 122 123 123 124 int channel = SDLNet_UDP_Bind(socket, 1, &ip); 124 if ( channel == -1 ) 125 if ( channel == -1 ) 125 126 { 126 127 PRINTF(1)("SDLNet_UDP_Bind: %s\n", SDLNet_GetError()); … … 167 168 { 168 169 assert( length <= packet->maxlen ); 169 170 170 171 memcpy( packet->data, data, length ); 171 172 packet->len = length; 172 173 173 174 if ( socket && SDLNet_UDP_Send( socket, 1, packet) == 0 ) 174 175 { … … 177 178 return false; 178 179 } 179 180 180 181 return true; 181 182 } … … 191 192 { 192 193 assert( maxLength <= UDP_PACKET_SIZE ); 193 194 194 195 if ( serverSocket ) 195 196 { 196 197 NetworkPacket networkPacket = serverSocket->getPacket( this->userId ); 197 198 198 199 if ( networkPacket.length == -1 ) 199 200 { … … 201 202 return 0; 202 203 } 203 204 204 205 if ( networkPacket.length > 0 ) 205 206 { 206 207 assert( maxLength > networkPacket.length ); 207 208 208 209 memcpy( data, networkPacket.data, networkPacket.length ); 209 210 } 210 211 211 212 if ( networkPacket.data ) 212 213 { … … 214 215 networkPacket.data = NULL; 215 216 } 216 217 217 218 return networkPacket.length; 218 219 } … … 220 221 { 221 222 int numrecv = SDLNet_UDP_Recv( socket, packet); 222 if ( numrecv > 0) 223 if ( numrecv > 0) 223 224 { 224 225 assert( packet->len <= maxLength ); 225 226 226 227 if ( packet->len == 0 ) 227 228 { … … 229 230 return 0; 230 231 } 231 232 232 233 memcpy( data, packet->data, packet->len ); 233 234 return packet->len; … … 244 245 } 245 246 } 246 247 247 248 return 0; 248 249 } -
trunk/src/lib/network/zip.cc
r7954 r8362 17 17 18 18 #include "src/lib/util/loading/resource_manager.h" 19 #include "debug.h" 19 20 20 21 /** … … 54 55 fileName = fileName + "/dicts/" + name; 55 56 //PRINTF(0)("filename: %s\n", fileName.c_str()); 56 57 57 58 FILE * f = fopen( fileName.c_str(), "r" ); 58 59 59 60 if ( !f ) 60 61 { … … 62 63 return false; 63 64 } 64 65 65 66 byte buf[1024]; 66 67 67 68 int nBytesRead = 0; 68 69 69 70 while ( !feof( f ) ) 70 71 { 71 72 nBytesRead += fread( buf, 1, sizeof(buf), f ); 72 73 } 73 74 74 75 DictionaryEntry entry; 75 76 76 77 entry.dictLen = nBytesRead; 77 78 entry.dict = new Byte[nBytesRead]; 78 79 79 80 fseek( f, 0, SEEK_SET ); 80 81 81 82 assert( fread( entry.dict, 1, nBytesRead, f ) == nBytesRead ); 82 83 83 84 entry.adler = adler32( adler32( 0L, Z_NULL, 0 ), entry.dict, nBytesRead ); 84 85 85 86 dicts.push_back( entry ); 86 87 87 88 PRINTF(3)("Loaded dictionary '%s' with adler = %d\n", name.c_str(), entry.adler ); 88 89 89 90 return true; 90 91 } … … 106 107 return -1; 107 108 } 108 109 109 110 int res; 110 111 … … 124 125 125 126 res = deflateSetDictionary( &strm, (Bytef*)(dicts[dict].dict), dicts[dict].dictLen ); 126 127 127 128 if ( res != Z_OK ) 128 129 { … … 139 140 140 141 res = deflate( &strm, Z_FINISH ); 141 142 142 143 if ( res != Z_STREAM_END ) 143 144 { … … 152 153 153 154 res = deflateEnd( &strm ); 154 155 155 156 if ( res != Z_OK ) 156 157 { … … 161 162 else 162 163 PRINTF(1)("deflateEnd error: dont know\n"); 163 164 return -1; 165 } 166 164 165 return -1; 166 } 167 167 168 return zippedlen; 168 169 … … 181 182 z_stream strm; 182 183 int res = 0; 183 184 184 185 strm.zalloc = Z_NULL; 185 186 strm.zfree = Z_NULL; … … 193 194 return -1; 194 195 } 195 196 196 197 strm.next_out = (Bytef*)to; 197 198 strm.avail_out = maxLength; … … 202 203 203 204 assert( inflate( &strm, Z_NO_FLUSH ) == Z_NEED_DICT ); 204 205 205 206 int dictId = -1; 206 207 207 208 for ( int i = 0; i < dicts.size(); i++ ) 208 209 { … … 213 214 } 214 215 } 215 216 216 217 if ( dictId == -1 ) 217 218 { … … 219 220 return -1; 220 221 } 221 222 222 223 res = inflateSetDictionary( &strm, (Bytef*)dicts[dictId].dict, dicts[dictId].dictLen ); 223 224 224 225 if ( res != Z_OK ) 225 226 { … … 230 231 231 232 res = inflate( &strm, Z_FINISH ); 232 233 233 234 if ( res != Z_STREAM_END ) 234 235 { … … 243 244 244 245 res = inflateEnd( &strm ); 245 246 246 247 if ( res != Z_OK ) 247 248 { … … 249 250 return -1; 250 251 } 251 252 252 253 return unzippedlen; 253 254 } -
trunk/src/lib/script_engine/script.h
r8271 r8362 5 5 #include "base_object.h" 6 6 7 #include <list> 7 8 8 9 struct lua_State; … … 19 20 Script(const TiXmlElement* root = NULL); 20 21 ~Script(); 21 22 22 23 /// LOADING 23 24 void loadParams(const TiXmlElement* root); … … 26 27 bool loadFile(const std::string& filename); 27 28 void addObject(const std::string& className, const std::string& objectName); 28 29 29 30 /// QUERRYING 30 31 /** @returns fileName */ … … 33 34 34 35 35 36 36 37 /// EXECUTING 37 38 // first select function … … 45 46 // Execute the Function 46 47 bool executeFunction(); 47 48 48 49 // get returned values the last return value in lua is the first in c. TODO: change order of return 49 50 int getReturnedInt(); … … 65 66 int argumentCount; //!< Number of arguments for the current function 66 67 int returnCount; //!< Number of return values of the current function 67 68 68 69 std::list<WorldObject> registeredObjects; //!< The list of all the objects and their type that have been registered with this script 69 70 -
trunk/src/lib/shell/shell.cc
r7919 r8362 26 26 #include "material.h" 27 27 #include "event_handler.h" 28 #include "debug.h" 28 29 29 30 namespace OrxShell -
trunk/src/lib/shell/shell_command_class.h
r7743 r8362 9 9 #include "base_object.h" 10 10 #include <vector> 11 #include <list> 11 12 12 13 namespace OrxShell -
trunk/src/lib/sound/ogg_player.cc
r8350 r8362 31 31 32 32 #include "debug.h" 33 #include "compiler.h" 33 34 34 35 #ifdef HAVE_SDL_SDL_H -
trunk/src/lib/sound/sound_buffer.cc
r8293 r8362 22 22 #include "sdlincl.h" 23 23 #include <cassert> 24 #include "debug.h" 25 24 26 #ifdef HAVE_SDL_SDL_H 25 27 #include <SDL/SDL.h> … … 81 83 } 82 84 #endif 83 alBufferData(this->bufferID, SoundBuffer::sdlAudioSpecToAlFormat(&wavSpec), 85 alBufferData(this->bufferID, SoundBuffer::sdlAudioSpecToAlFormat(&wavSpec), 84 86 wavBuffer, wavLength, wavSpec.freq); 85 87 86 88 SDL_FreeWAV(wavBuffer); 87 89 if (SoundEngine::checkError("Could not load Wave file", __LINE__)) -
trunk/src/lib/sound/sound_source.cc
r8350 r8362 21 21 #include "alincl.h" 22 22 #include "compiler.h" 23 #include "debug.h" 23 24 24 25 namespace OrxSound -
trunk/src/lib/util/executor/executor_xml.h
r8271 r8362 9 9 #include "executor.h" 10 10 #include "compiler.h" 11 #include "debug.h" 11 12 12 13 #include "parser/tinyxml/tinyxml.h" -
trunk/src/lib/util/loading/dynamic_loader.cc
r8316 r8362 17 17 18 18 #include "dynamic_loader.h" 19 #include "debug.h" 19 20 20 21 #ifndef __WIN32__ -
trunk/src/lib/util/loading/factory.cc
r8148 r8362 16 16 17 17 #include "util/loading/factory.h" 18 18 #include "debug.h" 19 19 //#include "shell_command.h" 20 20 -
trunk/src/lib/util/loading/load_param_description.cc
r8316 r8362 18 18 #include "multi_type.h" 19 19 #include <stdarg.h> 20 #include "stdlibincl.h" 20 #include "debug.h" 21 21 22 /** 22 23 * @param paramName the name of the parameter to load -
trunk/src/lib/util/preferences.cc
r7661 r8362 18 18 #include "preferences.h" 19 19 #include "lib/parser/ini_parser/ini_parser.h" 20 #include "debug.h" 20 21 21 22 -
trunk/src/lib/util/preferences.h
r7661 r8362 9 9 #include "base_object.h" 10 10 #include "multi_type.h" 11 #include <list> 11 12 12 13 // FORWARD DECLARATION -
trunk/src/util/game_rules.cc
r7488 r8362 22 22 #include "util/mission_goal.h" 23 23 24 #include "debug.h" 24 25 25 26 … … 79 80 } 80 81 82 /** 83 * adding a kill event to the kill list 84 * @param kill the kill object containing all infos 85 */ 86 void GameRules::registerKill(const Kill& kill) 87 { 88 PRINTF(0)("Received Event: Kill\n"); 89 this->killList.push_back(kill); 90 } 91 -
trunk/src/util/game_rules.h
r7488 r8362 34 34 inline void addMissionGoal(MissionGoal* missionGoal) { this->missionList.push_back(missionGoal); } 35 35 /** adding a kill event to the kill list @param kill the kill object containing all infos */ 36 inline void registerKill(const Kill& kill) { PRINTF(0)("Received Event: Kill\n"); this->killList.push_back(kill); }36 void registerKill(const Kill& kill); 37 37 38 38 virtual void onPlayerSpawn() {} -
trunk/src/util/object_manager.cc
r8037 r8362 23 23 #include "shell_command.h" 24 24 25 #include <assert.h> 25 #include <cassert> 26 #include "debug.h" 26 27 27 28 using namespace std; -
trunk/src/world_entities/creatures/md2_creature.cc
r7868 r8362 35 35 #include "graphics_engine.h" 36 36 37 using namespace std; 37 #include "debug.h" 38 38 39 39 CREATE_FACTORY(MD2Creature, CL_MD2_CREATURE); -
trunk/src/world_entities/player.cc
r8316 r8362 24 24 #include "util/hud.h" 25 25 26 using namespace std; 26 #include "debug.h" 27 27 28 28 … … 107 107 if (objectList != NULL) 108 108 { 109 list<BaseObject*>::const_iterator node;109 std::list<BaseObject*>::const_iterator node; 110 110 for (node = objectList->begin(); node != objectList->end(); node++) 111 111 if (this->playable != (*node) && (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < 10.0) -
trunk/src/world_entities/projectiles/bomb.cc
r8316 r8362 23 23 #include "particle_system.h" 24 24 25 using namespace std; 25 #include "debug.h" 26 26 27 27 CREATE_FAST_FACTORY_STATIC(Bomb, CL_BOMB); -
trunk/src/world_entities/projectiles/guided_missile.cc
r8316 r8362 24 24 #include "sprite_particles.h" 25 25 26 using namespace std; 26 #include "debug.h" 27 27 28 28 CREATE_FAST_FACTORY_STATIC(GuidedMissile, CL_GUIDED_MISSILE); -
trunk/src/world_entities/projectiles/hyperblast.cc
r8316 r8362 24 24 #include "spark_particles.h" 25 25 26 27 using namespace std; 26 #include "debug.h" 28 27 29 28 CREATE_FAST_FACTORY_STATIC(Hyperblast, CL_HYPERBLAST); -
trunk/src/world_entities/projectiles/laser.cc
r7193 r8362 17 17 18 18 #include "laser.h" 19 #include <cassert>20 19 21 20 #include "state.h" … … 27 26 28 27 #include <cassert> 28 #include "debug.h" 29 29 30 30 using namespace std; -
trunk/src/world_entities/projectiles/projectile.cc
r8190 r8362 24 24 #include "util/loading/resource_manager.h" 25 25 26 using namespace std; 26 #include "debug.h" 27 27 28 28 -
trunk/src/world_entities/projectiles/rocket.cc
r8316 r8362 24 24 #include "sprite_particles.h" 25 25 26 27 using namespace std; 26 #include "debug.h" 28 27 29 28 CREATE_FAST_FACTORY_STATIC(Rocket, CL_ROCKET); -
trunk/src/world_entities/projectiles/test_bullet.cc
r8316 r8362 23 23 #include "dot_emitter.h" 24 24 #include "sprite_particles.h" 25 26 using namespace std; 25 #include "debug.h" 27 26 28 27 CREATE_FAST_FACTORY_STATIC(TestBullet, CL_TEST_BULLET); -
trunk/src/world_entities/space_ships/helicopter.cc
r8255 r8362 32 32 #include "graphics_engine.h" 33 33 34 using namespace std; 34 #include "debug.h" 35 35 36 36 CREATE_FACTORY(Helicopter, CL_HELICOPTER); -
trunk/src/world_entities/space_ships/hover.cc
r8316 r8362 30 30 #include "graphics_engine.h" 31 31 32 using namespace std; 32 #include "debug.h" 33 33 34 34 CREATE_FACTORY(Hover, CL_HOVER); -
trunk/src/world_entities/space_ships/turbine_hover.cc
r8316 r8362 31 31 #include "dot_emitter.h" 32 32 #include "sprite_particles.h" 33 34 #include "debug.h" 33 35 34 36 CREATE_FACTORY(TurbineHover, CL_TURBINE_HOVER);
Note: See TracChangeset
for help on using the changeset viewer.