Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6753 in orxonox.OLD


Ignore:
Timestamp:
Jan 26, 2006, 1:08:23 AM (18 years ago)
Author:
patrick
Message:

trunk: merged network back to trunk

Location:
trunk/src
Files:
11 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/Makefile.am

    r5463 r6753  
    1111                           text_engine/text_engine.cc \
    1212                           text_engine/text.cc \
    13                            text_engine/font.cc
     13                           text_engine/font.cc \
     14                           effects/graphics_effect.cc \
     15                           effects/fog_effect.cc
    1416
    1517noinst_HEADERS = graphics_engine.h \
     
    2022                 text_engine/text_engine.h \
    2123                 text_engine/text.h \
    22                  text_engine/font.h
     24                 text_engine/font.h \
     25                 effects/graphics_effect.h \
     26                 effects/fog_effect.h
    2327
    2428
  • trunk/src/lib/graphics/graphics_engine.cc

    r6634 r6753  
    3535#include "globals.h"
    3636#include "texture.h"
     37
     38#include "effects/graphics_effect.h"
    3739
    3840#include "shell_command.h"
     
    653655      break;
    654656  }
    655 
    656 }
     657}
     658
     659
     660/**
     661 * loads a GraphicsEffect into the engine
     662 * @param effect the GraphicsEffect to add
     663 */
     664bool 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 */
     681bool 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  
    2222class SubString;
    2323class WorldEntity;
     24class GraphicsEffect;
    2425
    2526//! class to handle graphics
     
    8283    void process(const Event  &event);
    8384
     85    bool loadGraphicsEffect(GraphicsEffect* effect);
     86    bool unloadGraphicsEffect(GraphicsEffect* effect);
     87
     88
     89
    8490  private:
    8591    GraphicsEngine();
     
    9197
    9298  private:
    93     static GraphicsEngine*  singletonRef;       //!< Pointer to the only instance of this Class
    94     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.
    95101
    96102    // state.
    97     SDL_Surface*            screen;             //!< the screen we draw to
    98     int                     resolutionX;        //!< the X-resoultion of the screen
    99     int                     resolutionY;        //!< the Y-resolution of the screen
    100     int                     bitsPerPixel;       //!< the bits per pixels of the screen
    101     Uint32                  fullscreenFlag;     //!< if we are in fullscreen mode
    102     Uint32                  videoFlags;         //!< flags for video
    103     SDL_Rect**              videoModes;         //!< list of resolutions
     103    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
    104110
    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 particles
    109     int                     textureQuality;     //!< the quality of Textures
    110     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.
    113119
    114120    // HARDWARE-Settings:
    115     char*                   hwRenderer;         //!< HW-renderer-string
    116     char*                   hwVendor;           //!< HW-vendor-string
    117     char*                   hwVersion;          //!< HW-version-string
    118     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.
    119125
    120126    // 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
    125134
    126135#ifndef NO_TEXT
  • trunk/src/lib/network/converter.cc

    r6737 r6753  
    200200
    201201/*!
    202  * Converts a float value into a byte-array
    203  * @param x: The float which is to convert
    204  * @return: A byte-array which accords the given float
    205  */
    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   else
    222     sgn = 1;
    223 
    224   if (x == 0)
    225   {
    226     exponent = 255;
    227     mantisse = 0;
    228   }
    229   else
    230   {
    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 value
    287  * @param a: The byte-array which is to convert
    288  * @return: A float value which accords the given byte-array
    289  */
    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   else
    313     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 /*!
    334202 * Converts a float value into a byte-array and stores the result into a given byte-array
    335203 * @param x: The float which is to convert
     
    338206 * @return: The number of written bytes
    339207 */
    340 int Converter::floatToByteArray(float x, byte* a, int length)
     208int Converter::_floatToByteArray(float x, byte* a, int length)
    341209{
    342210  if (length < FLOATSIZE)
     
    452320 * @return: The number of read bytes
    453321 */
    454 int Converter::byteArrayToFloat(const byte* a, float* x)
     322int Converter::_byteArrayToFloat(const byte* a, float* x)
    455323{
    456324    //handle 0
     
    527395 * @return: The number of written bytes
    528396 */
    529 int Converter::_floatToByteArray(float x, byte* a, int length)
     397int Converter::floatToByteArray(float x, byte* a, int length)
    530398{
    531399  if ( length< FLOATSIZE )
     
    538406  for (int i = 0; i < 4; i++)
    539407    a[i] = p[i];
    540  
     408
    541409  return FLOATSIZE;
    542410}
     
    549417 * @return: The number of read bytes
    550418 */
    551 int Converter::_byteArrayToFloat(const byte* a, float* x)
     419int Converter::byteArrayToFloat(const byte* a, float* x)
    552420{
    553421  *x = *((float*)a);
     
    651519  printf("To Convert: %e\n", x);
    652520
    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   else
    664     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");
    665533}
    666534
     
    702570  //floatTest(-0.0f);
    703571  //floatTest(-5.67e-29f);
    704  
    705  
     572
     573
    706574  //floatTest(-45.7e-32f);
    707575  //floatTest(45.7e-33f);
  • trunk/src/lib/network/converter.h

    r6737 r6753  
    3131    static int byteArrayToInt(const byte* a, int* x);
    3232
    33     static int floatToByteArray(float x, byte* a, int length);
    34     static int byteArrayToFloat(const byte* a, float* x);
    35 
    3633    static int stringToByteArray(const char* s, byte* a, int length, int maxLength);
    3734    static int byteArrayToString(const byte* a, char* s, int maxLength);
     
    4138    static char* floatToBinString(float x);
    4239
    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);
    4545
    4646    static int _floatToByteArray(float x, byte* a, int length);
    4747    static int _byteArrayToFloat(const byte* a, float* x);
     48
    4849
    4950
  • trunk/src/lib/network/handshake.cc

    r6695 r6753  
    2121
    2222#include "handshake.h"
     23
     24#include <cassert>
    2325
    2426Handshake::Handshake( bool server, int clientId, int networkGameManagerId )
  • trunk/src/lib/network/synchronizeable.cc

    r6695 r6753  
    2323#include "state.h"
    2424
    25 #include "assert.h"
     25#include <cassert>
    2626
    2727#include "synchronizeable.h"
     
    3535{
    3636  this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
    37   this->owner = 0;
     37  this->owner = -1;
    3838  this->state = 0;
    3939  this->hostID = SharedNetworkData::getInstance()->getHostID();
  • trunk/src/lib/network/synchronizeable.h

    r6695 r6753  
    6262#define SYNCHELP_WRITE_INT(i) { __synchelp_write_n = \
    6363                                Converter::intToByteArray( i, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
     64                                assert( __synchelp_write_n == INTSIZE ); \
    6465                                if ( __synchelp_write_n <= 0) \
    6566{ \
     
    7172#define SYNCHELP_WRITE_FLOAT(f) { __synchelp_write_n = \
    7273                                Converter::floatToByteArray( f, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
     74                                assert( __synchelp_write_n == FLOATSIZE ); \
    7375                                if ( __synchelp_write_n <= 0) \
    7476{ \
     
    8789                                __synchelp_write_i++; \
    8890}
    89 #define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) \
     91#define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) {\
    9092                                __synchelp_write_n = \
    9193                                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 {\
    9396                                __synchelp_write_n = \
    9497                                Converter::stringToByteArray( "", data+__synchelp_write_i, strlen(""), maxLength-__synchelp_write_i ); \
     98                                assert( __synchelp_write_n == strlen("")+INTSIZE ); } \
    9599                                if ( __synchelp_write_n <= 0) \
    96100{ \
     
    116120                                      return 0; \
    117121} \
    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; \
    119125}
    120126#define SYNCHELP_READ_FLOAT(f)    { \
     
    124130                                      return 0; \
    125131} \
    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; \
    127135}
    128136#define SYNCHELP_READ_STRING(s,l)    { \
    129137                                    __synchelp_read_n = Converter::byteArrayToString( data+__synchelp_read_i, s, l );  \
     138                                    assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\
    130139                                    if ( __synchelp_read_n <0 )  \
    131140{ \
     
    137146#define SYNCHELP_READ_STRINGM(s)    { \
    138147                                    __synchelp_read_n = Converter::byteArrayToStringM( data+__synchelp_read_i, s );  \
     148                                    assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\
    139149                                    if ( __synchelp_read_n <0 )  \
    140150{ \
  • trunk/src/world_entities/projectiles/laser.cc

    r6700 r6753  
    3030#include <cassert>
    3131
    32 #include "assert.h"
     32#include <cassert>
    3333
    3434
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6737 r6753  
    289289  this->weaponAction();
    290290
    291   if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner()==this->getHostID() )
     291  if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() )
    292292   {
    293293    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
     
    555555      SYNCHELP_READ_INT( flags );
    556556
    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;
    566566
    567567    }
     
    570570    if ( b == DATA_mouse /*&& this->getHostID()!=this->getOwner()*/ )
    571571    {
    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 );
    581576    }
    582577  } while( b != 0 );
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r6737 r6753  
    217217bool WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID)
    218218{
    219   //if ( weapon == NULL )
     219  if ( weapon == NULL )
    220220    return false;
    221221
Note: See TracChangeset for help on using the changeset viewer.