- Timestamp:
- Jan 26, 2006, 1:08:23 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/Makefile.am
r5463 r6753 11 11 text_engine/text_engine.cc \ 12 12 text_engine/text.cc \ 13 text_engine/font.cc 13 text_engine/font.cc \ 14 effects/graphics_effect.cc \ 15 effects/fog_effect.cc 14 16 15 17 noinst_HEADERS = graphics_engine.h \ … … 20 22 text_engine/text_engine.h \ 21 23 text_engine/text.h \ 22 text_engine/font.h 24 text_engine/font.h \ 25 effects/graphics_effect.h \ 26 effects/fog_effect.h 23 27 24 28 -
trunk/src/lib/graphics/graphics_engine.cc
r6634 r6753 35 35 #include "globals.h" 36 36 #include "texture.h" 37 38 #include "effects/graphics_effect.h" 37 39 38 40 #include "shell_command.h" … … 653 655 break; 654 656 } 655 656 } 657 } 658 659 660 /** 661 * loads a GraphicsEffect into the engine 662 * @param effect the GraphicsEffect to add 663 */ 664 bool GraphicsEngine::loadGraphicsEffect(GraphicsEffect* effect) 665 { 666 list<GraphicsEffect*>::iterator it; 667 for (it = this->graphicsEffects.begin(); it != this->graphicsEffects.end(); it++) 668 if( (*it) == effect) 669 return false; 670 671 this->graphicsEffects.push_back(effect); 672 673 return true; 674 } 675 676 677 /** 678 * unloads a GraphicsEffect from the engine 679 * @param effect the GraphicsEffect to remove 680 */ 681 bool GraphicsEngine::unloadGraphicsEffect(GraphicsEffect* effect) 682 { 683 list<GraphicsEffect*>::iterator it; 684 for (it = this->graphicsEffects.begin(); it != this->graphicsEffects.end(); it++) 685 { 686 if( (*it) == effect) 687 { 688 this->graphicsEffects.erase(it); 689 return true; 690 } 691 } 692 693 return false; 694 } 695 -
trunk/src/lib/graphics/graphics_engine.h
r6522 r6753 22 22 class SubString; 23 23 class WorldEntity; 24 class GraphicsEffect; 24 25 25 26 //! class to handle graphics … … 82 83 void process(const Event &event); 83 84 85 bool loadGraphicsEffect(GraphicsEffect* effect); 86 bool unloadGraphicsEffect(GraphicsEffect* effect); 87 88 89 84 90 private: 85 91 GraphicsEngine(); … … 91 97 92 98 private: 93 static GraphicsEngine* singletonRef; //!< Pointer to the only instance of this Class94 bool isInit; //!< if the GraphicsEngine is initialized.99 static GraphicsEngine* singletonRef; //!< Pointer to the only instance of this Class 100 bool isInit; //!< if the GraphicsEngine is initialized. 95 101 96 102 // state. 97 SDL_Surface* screen; //!< the screen we draw to98 int resolutionX; //!< the X-resoultion of the screen99 int resolutionY; //!< the Y-resolution of the screen100 int bitsPerPixel; //!< the bits per pixels of the screen101 Uint32 fullscreenFlag; //!< if we are in fullscreen mode102 Uint32 videoFlags; //!< flags for video103 SDL_Rect** videoModes; //!< list of resolutions103 SDL_Surface* screen; //!< the screen we draw to 104 int resolutionX; //!< the X-resoultion of the screen 105 int resolutionY; //!< the Y-resolution of the screen 106 int bitsPerPixel; //!< the bits per pixels of the screen 107 Uint32 fullscreenFlag; //!< if we are in fullscreen mode 108 Uint32 videoFlags; //!< flags for video 109 SDL_Rect** videoModes; //!< list of resolutions 104 110 105 bool fogEnabled; //!< If Fog should be enabled.106 bool shadowsEnabled; //!< If Shadows should be enabled.107 bool particlesEnabled; //!< If particles should be enabled.108 int particlesValue; //!< How many particles109 int textureQuality; //!< the quality of Textures110 int filteringMethod; //!< The filtering Method of textures.111 int modelQuality; //!< The quality of the Models loaded.112 int antialiasingDepth; //!< the Depth of the AntiAlias-Filter.111 bool fogEnabled; //!< If Fog should be enabled. 112 bool shadowsEnabled; //!< If Shadows should be enabled. 113 bool particlesEnabled; //!< If particles should be enabled. 114 int particlesValue; //!< How many particles 115 int textureQuality; //!< the quality of Textures 116 int filteringMethod; //!< The filtering Method of textures. 117 int modelQuality; //!< The quality of the Models loaded. 118 int antialiasingDepth; //!< the Depth of the AntiAlias-Filter. 113 119 114 120 // HARDWARE-Settings: 115 char* hwRenderer; //!< HW-renderer-string116 char* hwVendor; //!< HW-vendor-string117 char* hwVersion; //!< HW-version-string118 SubString* hwExtensions; //!< All suported Extensions.121 char* hwRenderer; //!< HW-renderer-string 122 char* hwVendor; //!< HW-vendor-string 123 char* hwVersion; //!< HW-version-string 124 SubString* hwExtensions; //!< All suported Extensions. 119 125 120 126 // FPS-related 121 bool bDisplayFPS; //!< is true if the fps should be displayed 122 float currentFPS; //!< the current frame rate: frames per seconds 123 float maxFPS; //!< maximal frame rate we ever got since start of the game 124 float minFPS; //!< minimal frame rate we ever got since start. 127 bool bDisplayFPS; //!< is true if the fps should be displayed 128 float currentFPS; //!< the current frame rate: frames per seconds 129 float maxFPS; //!< maximal frame rate we ever got since start of the game 130 float minFPS; //!< minimal frame rate we ever got since start. 131 132 std::list<GraphicsEffect*> graphicsEffects; //!< list of graphics effects 133 125 134 126 135 #ifndef NO_TEXT -
trunk/src/lib/network/converter.cc
r6737 r6753 200 200 201 201 /*! 202 * Converts a float value into a byte-array203 * @param x: The float which is to convert204 * @return: A byte-array which accords the given float205 */206 byte* Converter::floatToByteArray(float x)207 {208 byte* result = new byte[4];209 floatToByteArray(x, result, 4);210 return result;211 /*212 int mantisse = 0;213 int exponent = 128;214 215 int sgn;216 if (x < 0)217 {218 x = -x;219 sgn = -1;220 }221 else222 sgn = 1;223 224 if (x == 0)225 {226 exponent = 255;227 mantisse = 0;228 }229 else230 {231 //if (x < getDenormConst())232 // printf("Denormalisiert!\n");233 //printf("DenormConst = %e", getDenormConst());234 235 float sub = 1;236 while (sub < x)237 {238 sub *= 2;239 exponent++;240 }241 242 while (x > 0)243 {244 if (x >= sub)245 {246 mantisse += 1;247 x -= sub;248 }249 250 mantisse *= 2;251 exponent--;252 sub /= 2;253 }254 exponent++;255 mantisse /= 2;256 257 printf("Conv: mantisse = %i exponent = %i \n", mantisse, exponent);258 259 260 if (mantisse != 0)261 {262 while (mantisse < expmult)263 {264 mantisse *= 2;265 exponent--;266 }267 268 mantisse -= expmult;269 }270 }271 272 printf("Conv: mantisse = %i exponent = %i \n", mantisse, exponent);273 274 275 int hx = mantisse + expmult * exponent;276 byte* result = intToByteArray(hx);277 if (sgn == -1)278 result[3] += sgnadd;279 280 return result;281 */282 }283 284 285 /*!286 * Converts a byte-array into a float value287 * @param a: The byte-array which is to convert288 * @return: A float value which accords the given byte-array289 */290 float Converter::byteArrayToFloat(byte* a)291 {292 byte* h = new byte[4];293 float result = 0.0f;294 byteArrayToFloat(a, &result);295 return result;296 /*297 int hexp = a[2] + a[3] * 256;298 int exponent = (hexp / 128) % 256;299 300 int hmant = a[0] + a[1] * 256 + a[2] * 65536;301 int mantisse = hmant % expmult;302 if (mantisse == 0 && exponent == 255)303 return 0;304 305 mantisse += expmult;306 exponent -= 128;307 308 309 int sgn;310 if (a[3] >= sgnadd)311 sgn = -1;312 else313 sgn = 1;314 315 printf("ReConv: mantisse = %i exponent = %i \n", mantisse, exponent);316 317 float emult = 1;318 if (exponent > 0)319 for (int i = 0; i < exponent; i++)320 emult *= 2;321 else if (exponent < 0)322 for (int i = 0; i > exponent; i--)323 emult /= 2;324 325 float result = mantisse * emult;326 if (sgn == -1)327 result = -result;328 329 return result;330 */331 }332 333 /*!334 202 * Converts a float value into a byte-array and stores the result into a given byte-array 335 203 * @param x: The float which is to convert … … 338 206 * @return: The number of written bytes 339 207 */ 340 int Converter:: floatToByteArray(float x, byte* a, int length)208 int Converter::_floatToByteArray(float x, byte* a, int length) 341 209 { 342 210 if (length < FLOATSIZE) … … 452 320 * @return: The number of read bytes 453 321 */ 454 int Converter:: byteArrayToFloat(const byte* a, float* x)322 int Converter::_byteArrayToFloat(const byte* a, float* x) 455 323 { 456 324 //handle 0 … … 527 395 * @return: The number of written bytes 528 396 */ 529 int Converter:: _floatToByteArray(float x, byte* a, int length)397 int Converter::floatToByteArray(float x, byte* a, int length) 530 398 { 531 399 if ( length< FLOATSIZE ) … … 538 406 for (int i = 0; i < 4; i++) 539 407 a[i] = p[i]; 540 408 541 409 return FLOATSIZE; 542 410 } … … 549 417 * @return: The number of read bytes 550 418 */ 551 int Converter:: _byteArrayToFloat(const byte* a, float* x)419 int Converter::byteArrayToFloat(const byte* a, float* x) 552 420 { 553 421 *x = *((float*)a); … … 651 519 printf("To Convert: %e\n", x); 652 520 653 byte* res = floatToByteArray(x);654 for (int i = 0; i < 4; i++)655 printf("%i ", res[i]);656 printf("\n");657 658 float y = byteArrayToFloat(res);659 printf("ReConvert: %e\n", y);660 661 if (x == y)662 printf("equal\n");663 else664 printf("different\n");521 // byte* res = floatToByteArray(x); 522 // for (int i = 0; i < 4; i++) 523 // printf("%i ", res[i]); 524 // printf("\n"); 525 526 // float y = byteArrayToFloat(res); 527 // printf("ReConvert: %e\n", y); 528 529 // if (x == y) 530 // printf("equal\n"); 531 // else 532 // printf("different\n"); 665 533 } 666 534 … … 702 570 //floatTest(-0.0f); 703 571 //floatTest(-5.67e-29f); 704 705 572 573 706 574 //floatTest(-45.7e-32f); 707 575 //floatTest(45.7e-33f); -
trunk/src/lib/network/converter.h
r6737 r6753 31 31 static int byteArrayToInt(const byte* a, int* x); 32 32 33 static int floatToByteArray(float x, byte* a, int length);34 static int byteArrayToFloat(const byte* a, float* x);35 36 33 static int stringToByteArray(const char* s, byte* a, int length, int maxLength); 37 34 static int byteArrayToString(const byte* a, char* s, int maxLength); … … 41 38 static char* floatToBinString(float x); 42 39 43 static byte* floatToByteArray(float x); 44 static float byteArrayToFloat(byte* a); 40 // static byte* floatToByteArray(float x); 41 // static float byteArrayToFloat(byte* a); 42 43 static int floatToByteArray(float x, byte* a, int length); 44 static int byteArrayToFloat(const byte* a, float* x); 45 45 46 46 static int _floatToByteArray(float x, byte* a, int length); 47 47 static int _byteArrayToFloat(const byte* a, float* x); 48 48 49 49 50 -
trunk/src/lib/network/handshake.cc
r6695 r6753 21 21 22 22 #include "handshake.h" 23 24 #include <cassert> 23 25 24 26 Handshake::Handshake( bool server, int clientId, int networkGameManagerId ) -
trunk/src/lib/network/synchronizeable.cc
r6695 r6753 23 23 #include "state.h" 24 24 25 #include "assert.h"25 #include <cassert> 26 26 27 27 #include "synchronizeable.h" … … 35 35 { 36 36 this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable"); 37 this->owner = 0;37 this->owner = -1; 38 38 this->state = 0; 39 39 this->hostID = SharedNetworkData::getInstance()->getHostID(); -
trunk/src/lib/network/synchronizeable.h
r6695 r6753 62 62 #define SYNCHELP_WRITE_INT(i) { __synchelp_write_n = \ 63 63 Converter::intToByteArray( i, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \ 64 assert( __synchelp_write_n == INTSIZE ); \ 64 65 if ( __synchelp_write_n <= 0) \ 65 66 { \ … … 71 72 #define SYNCHELP_WRITE_FLOAT(f) { __synchelp_write_n = \ 72 73 Converter::floatToByteArray( f, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \ 74 assert( __synchelp_write_n == FLOATSIZE ); \ 73 75 if ( __synchelp_write_n <= 0) \ 74 76 { \ … … 87 89 __synchelp_write_i++; \ 88 90 } 89 #define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) \91 #define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) {\ 90 92 __synchelp_write_n = \ 91 93 Converter::stringToByteArray( s, data+__synchelp_write_i, strlen(s), maxLength-__synchelp_write_i ); \ 92 else \ 94 assert( __synchelp_write_n == strlen(s)+INTSIZE ); \ 95 } else {\ 93 96 __synchelp_write_n = \ 94 97 Converter::stringToByteArray( "", data+__synchelp_write_i, strlen(""), maxLength-__synchelp_write_i ); \ 98 assert( __synchelp_write_n == strlen("")+INTSIZE ); } \ 95 99 if ( __synchelp_write_n <= 0) \ 96 100 { \ … … 116 120 return 0; \ 117 121 } \ 118 __synchelp_read_i += Converter::byteArrayToInt( data+__synchelp_read_i, &i ); \ 122 __synchelp_read_n = Converter::byteArrayToInt( data+__synchelp_read_i, &i ); \ 123 assert( __synchelp_read_n == INTSIZE ); \ 124 __synchelp_read_i += __synchelp_read_n; \ 119 125 } 120 126 #define SYNCHELP_READ_FLOAT(f) { \ … … 124 130 return 0; \ 125 131 } \ 126 __synchelp_read_i += Converter::byteArrayToFloat( data+__synchelp_read_i, &f ); \ 132 __synchelp_read_n = Converter::byteArrayToFloat( data+__synchelp_read_i, &f ); \ 133 assert( __synchelp_read_n == FLOATSIZE ) ;\ 134 __synchelp_read_i += __synchelp_read_n; \ 127 135 } 128 136 #define SYNCHELP_READ_STRING(s,l) { \ 129 137 __synchelp_read_n = Converter::byteArrayToString( data+__synchelp_read_i, s, l ); \ 138 assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\ 130 139 if ( __synchelp_read_n <0 ) \ 131 140 { \ … … 137 146 #define SYNCHELP_READ_STRINGM(s) { \ 138 147 __synchelp_read_n = Converter::byteArrayToStringM( data+__synchelp_read_i, s ); \ 148 assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\ 139 149 if ( __synchelp_read_n <0 ) \ 140 150 { \ -
trunk/src/world_entities/projectiles/laser.cc
r6700 r6753 30 30 #include <cassert> 31 31 32 #include "assert.h"32 #include <cassert> 33 33 34 34 -
trunk/src/world_entities/space_ships/space_ship.cc
r6737 r6753 289 289 this->weaponAction(); 290 290 291 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() ==this->getHostID() )291 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() ) 292 292 { 293 293 if (xMouse > controlVelocityX) xMouse = controlVelocityX; … … 555 555 SYNCHELP_READ_INT( flags ); 556 556 557 //bUp = (flags & MASK_bUp) != 0;558 //bDown = (flags & MASK_bDown) != 0;559 //bLeft = (flags & MASK_bLeft) != 0;560 //bRight = (flags & MASK_bRight) != 0;561 //bAscend = (flags & MASK_bAscend) != 0;562 //bDescend = (flags & MASK_bDescend) != 0;563 //bFire = (flags & MASK_bFire) != 0;564 //bRollL = (flags & MASK_bRollL) != 0;565 //bRollR = (flags & MASK_bRollR) != 0;557 bUp = (flags & MASK_bUp) != 0; 558 bDown = (flags & MASK_bDown) != 0; 559 bLeft = (flags & MASK_bLeft) != 0; 560 bRight = (flags & MASK_bRight) != 0; 561 bAscend = (flags & MASK_bAscend) != 0; 562 bDescend = (flags & MASK_bDescend) != 0; 563 bFire = (flags & MASK_bFire) != 0; 564 bRollL = (flags & MASK_bRollL) != 0; 565 bRollR = (flags & MASK_bRollR) != 0; 566 566 567 567 } … … 570 570 if ( b == DATA_mouse /*&& this->getHostID()!=this->getOwner()*/ ) 571 571 { 572 float asdf; 573 SYNCHELP_READ_FLOAT( asdf ); 574 SYNCHELP_READ_FLOAT( asdf ); 575 SYNCHELP_READ_FLOAT( asdf ); 576 SYNCHELP_READ_FLOAT( asdf ); 577 //SYNCHELP_READ_FLOAT( mouseDir.w ); 578 //SYNCHELP_READ_FLOAT( mouseDir.v.x ); 579 //SYNCHELP_READ_FLOAT( mouseDir.v.y ); 580 //SYNCHELP_READ_FLOAT( mouseDir.v.z ); 572 SYNCHELP_READ_FLOAT( mouseDir.w ); 573 SYNCHELP_READ_FLOAT( mouseDir.v.x ); 574 SYNCHELP_READ_FLOAT( mouseDir.v.y ); 575 SYNCHELP_READ_FLOAT( mouseDir.v.z ); 581 576 } 582 577 } while( b != 0 ); -
trunk/src/world_entities/weapons/weapon_manager.cc
r6737 r6753 217 217 bool WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 218 218 { 219 //if ( weapon == NULL )219 if ( weapon == NULL ) 220 220 return false; 221 221
Note: See TracChangeset
for help on using the changeset viewer.