Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4833 in orxonox.OLD


Ignore:
Timestamp:
Jul 11, 2005, 5:46:05 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: fight against the mighty segfault

Location:
orxonox/trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/event/key_mapper.cc

    r4759 r4833  
    5656
    5757//! this is the mapping array from names to ids: enter all orxonox.conf keys here
    58 orxKeyMapping map[] = { {&KeyMapper::PEV_UP,                   "Up"},
    59                         {&KeyMapper::PEV_DOWN,                 "Down"},
    60                         {&KeyMapper::PEV_LEFT,                 "Left"},
    61                         {&KeyMapper::PEV_RIGHT,                "Right"},
    62                         {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft"},
    63                         {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight"},
    64 
    65                         {&KeyMapper::PEV_FIRE1,                "Fire"},
    66                         {&KeyMapper::PEV_FIRE1,                "Fire1"},
    67                         {&KeyMapper::PEV_FIRE2,                "Fire2"},
    68                         {&KeyMapper::PEV_NEXT_WEAPON,          "Next"},
    69                         {&KeyMapper::PEV_PREVIOUS_WEAPON,      "Prev"},
    70 
    71 
    72                         {&KeyMapper::PEV_VIEW0,                "view0"},
    73                         {&KeyMapper::PEV_VIEW1,                "view1"},
    74                         {&KeyMapper::PEV_VIEW2,                "view2"},
    75                         {&KeyMapper::PEV_VIEW3,                "view3"},
    76                         {&KeyMapper::PEV_VIEW4,                "view4"},
    77                         {&KeyMapper::PEV_VIEW5,                "view5"},
    78 
    79                         {&KeyMapper::PEV_NEXT_WORLD,           "Next-World"},
    80                         {&KeyMapper::PEV_PREVIOUS_WORLD,       "Prev-World"},
    81 
    82                         {&KeyMapper::PEV_PAUSE,                "Pause"},
    83                         {&KeyMapper::PEV_QUIT,                 "Quit"},
    84                         {NULL, NULL}};
     58/** @todo use globals.h for this.... everything is done there for those Options,
     59 * and you do not have to care about The namings
     60 */
     61orxKeyMapping map[] = {
     62  {&KeyMapper::PEV_UP,                   "Up"},
     63  {&KeyMapper::PEV_DOWN,                 "Down"},
     64  {&KeyMapper::PEV_LEFT,                 "Left"},
     65  {&KeyMapper::PEV_RIGHT,                "Right"},
     66  {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft"},
     67  {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight"},
     68
     69  {&KeyMapper::PEV_FIRE1,                "Fire"},
     70  {&KeyMapper::PEV_FIRE1,                "Fire1"},
     71  {&KeyMapper::PEV_FIRE2,                "Fire2"},
     72  {&KeyMapper::PEV_NEXT_WEAPON,          "Next"},
     73  {&KeyMapper::PEV_PREVIOUS_WEAPON,      "Prev"},
     74
     75
     76  {&KeyMapper::PEV_VIEW0,                "view0"},
     77  {&KeyMapper::PEV_VIEW1,                "view1"},
     78  {&KeyMapper::PEV_VIEW2,                "view2"},
     79  {&KeyMapper::PEV_VIEW3,                "view3"},
     80  {&KeyMapper::PEV_VIEW4,                "view4"},
     81  {&KeyMapper::PEV_VIEW5,                "view5"},
     82
     83  {&KeyMapper::PEV_NEXT_WORLD,           "Next-World"},
     84  {&KeyMapper::PEV_PREVIOUS_WORLD,       "Prev-World"},
     85
     86  {&KeyMapper::PEV_PAUSE,                "Pause"},
     87  {&KeyMapper::PEV_QUIT,                 "Quit"},
     88  {NULL, NULL}
     89};
    8590
    8691
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4831 r4833  
    4545
    4646  this->fullscreenFlag = 0;
    47 
    48 //  this->listModes();
    49 
    50   // subscribe the resolutionChanged-event
    51   EventHandler::getInstance()->subscribe(this, ES_GAME, EV_VIDEO_RESIZE);
    52 
    5347}
    5448
     
    8579int GraphicsEngine::initFromIniFile(IniParser* iniParser)
    8680{
    87 
    8881  // looking if we are in fullscreen-mode
    8982  const char* fullscreen = iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, "0");
     
    10194
    10295  // searching for a usefull resolution
    103   SubString resolution(iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480"), 'x');
    104   this->initVideo(atoi(resolution.getString(0)), atoi(resolution.getString(1)), 16);
     96//  SubString resolution(iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480"), 'x');
     97  //resolution.debug();
     98
     99  //this->initVideo(atoi(resolution.getString(0)), atoi(resolution.getString(1)), 16);
     100  this->initVideo(640,480,16);
    105101}
    106102
     
    154150  glEnable(GL_DEPTH_TEST);
    155151
     152
     153  // subscribe the resolutionChanged-event
     154  //EventHandler::getInstance()->subscribe(this, ES_GAME, EV_VIDEO_RESIZE);
     155  //! @todo eventSystem craps up the Starting of orxonox -> see why.
     156
    156157  this->isInit = true;
    157158}
     
    247248
    248249/**
    249    \brief if Textures should be enabled
     250 * if Textures should be enabled
    250251*/
    251252bool GraphicsEngine::texturesEnabled = true;
    252253
     254
     255
     256/**
     257 *
     258 * @param show if The mouse-cursor should be visible
     259 */
     260void GraphicsEngine::showMouse(bool show)
     261{
     262  if (show)
     263    SDL_ShowCursor(SDL_ENABLE);
     264  else
     265    SDL_ShowCursor(SDL_DISABLE);
     266}
     267
     268/**
     269 *
     270 * @returns The Visinility of the mouse-cursor (true if visible, false if it is invisible)
     271 */
     272bool GraphicsEngine::isMouseVisible()
     273{
     274  if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE)
     275    return true;
     276  else
     277    return false;
     278}
     279
     280/**
     281 *
     282 * @param steal If the Winodow-Managers Events should be stolen to this app
     283 * (steals the mouse, and all WM-clicks)
     284 *
     285 * This only happens, if the HARD-Debug-level is set to 0,1,2, because otherwise a Segfault could
     286 * result in the loss of System-controll
     287 */
     288void GraphicsEngine::stealWMEvents(bool steal)
     289{
     290#if DEBUG < 3
     291   if (steal)
     292     SDL_WM_GrabInput(SDL_GRAB_ON);
     293   else SDL_WM_GrabInput(SDL_GRAB_OFF);
     294#endif
     295}
     296
     297/**
     298 *
     299 * @returns true if Events are stolen from the WM, false if not.
     300 */
     301bool GraphicsEngine::isStealingEvents()
     302{
     303   if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)
     304     return true;
     305   else
     306     return false;
     307};
    253308
    254309
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r4832 r4833  
    4949    int resolutionChanged(const SDL_ResizeEvent& resizeInfo);
    5050
    51     /** @param show if The mouse-cursor should be visible */
    52     inline static void showMouse(bool show) { (show)?SDL_ShowCursor(SDL_ENABLE):SDL_ShowCursor(SDL_DISABLE); };
    53     /** @returns The Visinility of the mouse-cursor (true if visible, false if it is invisible) */
    54     static bool isMouseVisible() { return (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE)?true:false; };
    55     /** @param steal If the Winodow-Managers Events should be stolen to this app (steals the mouse, and all WM-clicks) */
    56     static void stealWMEvents(bool steal) { (steal)?SDL_WM_GrabInput(SDL_GRAB_ON):SDL_WM_GrabInput(SDL_GRAB_OFF); };
    57     /** @returns true if Events are stolen from the WM, false if not. */
    58     static bool isStealingEvents() { if (SDL_GRAB_ON) return true; };
     51    static void showMouse(bool show);
     52    static bool isMouseVisible();
     53    static void stealWMEvents(bool steal);
     54    static bool isStealingEvents();
    5955
    6056    static void enter2DMode();
  • orxonox/trunk/src/lib/util/substring.cc

    r4830 r4833  
    2424#include "substring.h"
    2525
     26#include "debug.h"
    2627#include <string.h>
    2728#include <assert.h>
     
    9192    return NULL;
    9293}
     94
     95
     96
     97/**
     98 * Some nice debug information about this SubString
     99 */
     100void SubString::debug() const
     101{
     102  PRINT(0)("Substring-information::count=%d ::", this->splittersCount);
     103  for (int i = 0; i < this->splittersCount; i++)
     104    PRINT(0)("s%d:%s::", i, this->strings[i]);
     105  PRINT(0)("\n");
     106}
  • orxonox/trunk/src/lib/util/substring.h

    r4830 r4833  
    1717  const char* getString( int i);
    1818
     19  void debug() const;
     20
    1921 private:
    2022  char**     strings;                      //!< strings produced from a single string splitted in multiple strings
  • orxonox/trunk/src/orxonox.cc

    r4830 r4833  
    5252#include <string.h>
    5353
    54 int verbose = 4;
     54int verbose = 3;
    5555
    5656using namespace std;
     
    9999  ClassList::debug(0);
    100100
    101   PRINT(3)("===================================================\n" \
     101  PRINT(3)
     102      ("===================================================\n" \
    102103      "Thanks for playing orxonox.\n" \
    103104      "visit: http://www.orxonox.ethz.ch for new versions.\n" \
     
    127128
    128129/**
    129    \brief initialize Orxonox with command line
    130 */
     130 * initialize Orxonox with command line
     131 */
    131132int Orxonox::init (int argc, char** argv)
    132133{
     
    152153
    153154/**
    154    \brief initializes SDL and OpenGL
     155 * initializes SDL and OpenGL
    155156*/
    156157int Orxonox::initVideo()
     
    167168
    168169/**
    169    \brief initializes the sound engine
    170 */
     170 * initializes the sound engine
     171 */
    171172int Orxonox::initSound()
    172173{
     
    179180
    180181/**
    181  * @brief initializes input functions
    182 */
     182 * initializes input functions
     183 */
    183184int Orxonox::initInput()
    184185{
     
    186187
    187188  EventHandler::getInstance()->init();
    188 
    189   return 0;
    190 }
    191 
    192 
    193 /**
    194 * @brief initializes network system
    195 */
     189  EventHandler::getInstance()->subscribe(GraphicsEngine::getInstance(), ES_ALL, EV_VIDEO_RESIZE);
     190
     191
     192  return 0;
     193}
     194
     195
     196/**
     197 * initializes network system
     198 */
    196199int Orxonox::initNetworking()
    197200{
     
    204207
    205208/**
    206  * @brief initializes and loads resource files
    207  */
    208  int Orxonox::initResources()
     209 * initializes and loads resource files
     210 */
     211int Orxonox::initResources()
    209212{
    210213  PRINTF(3)("> Initializing resources\n");
     
    264267
    265268/**
    266    \brief starts the orxonox game or menu
    267 
    268    here is the central orxonox state manager. There are currently two states
    269    - menu
    270    - game-play
    271    both states manage their states themselfs again.
     269 *
     270 * @brief starts the orxonox game or menu
     271 * here is the central orxonox state manager. There are currently two states
     272 * - menu
     273 * - game-play
     274 * both states manage their states themselfs again.
    272275*/
    273276void Orxonox::start()
     
    283286
    284287/**
    285    \brief handles sprecial events from localinput
    286    \param event: an event not handled by the CommandNode
    287 */
     288 * handles sprecial events from localinput
     289 * @param event: an event not handled by the CommandNode
     290 */
    288291// void Orxonox::graphicsHandler(SDL_Event* event)
    289292// {
     
    311314**********************************/
    312315/**
    313    \brief main function
    314 
    315    here the journey begins
     316 *
     317 * @brief main function
     318 *
     319 * here the journey begins
    316320*/
    317321int main(int argc, char** argv)
  • orxonox/trunk/src/story_entities/world.cc

    r4832 r4833  
    10331033      this->dtS = (float)this->dt / 1000.0;
    10341034      this->gameTime += this->dtS;
    1035       //entity = entities->enumerate();
     1035
    10361036      tIterator<WorldEntity>* iterator = this->entities->getIterator();
    10371037      WorldEntity* entity = iterator->nextElement();
  • orxonox/trunk/src/util/track/track_manager.h

    r4746 r4833  
    2929
    3030//! The default Curve-Type to set for the whole path (if not chosen otherwise).
    31 #define TMAN_DEFAULT_CURVETYPE    CURVE_BEZIER
     31#define     TMAN_DEFAULT_CURVETYPE    CURVE_BEZIER
    3232//! A default value for the duration for each TrackElement
    33 #define TMAN_DEFAULT_DURATION     10
     33#define     TMAN_DEFAULT_DURATION     10
    3434//! A default width for the width of a TrackElement
    35 #define TMAN_DEFAULT_WIDTH        10
     35#define     TMAN_DEFAULT_WIDTH        10
    3636
    3737//! A Graph-Element, that holds the curve-structure of a Level.
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.cc

    r4832 r4833  
    3232WeaponManager::WeaponManager(int nrOfSlots)
    3333{
    34   this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
    35 
    36   for(int i = 0; i < W_MAX_CONFIGS; ++i)
    37   {
    38     this->configs[i].bUsed = false;
    39     for(int j = 0; j < W_MAX_SLOTS; ++j)
    40       this->configs[i].slots[j] = NULL;
    41   }
     34  this->init();
    4235  this->nrOfSlots = nrOfSlots;
    43   this->currConfID = W_CONFIG0;
    44 }
    45 
    46 
     36}
     37
     38
     39/**
     40 * Destroys a WeaponManager
     41 */
    4742WeaponManager::~WeaponManager()
    4843{
     
    6055}
    6156
     57void WeaponManager::init()
     58{
     59  this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
     60
     61  for(int i = 0; i < W_MAX_CONFIGS; ++i)
     62  {
     63    this->configs[i].bUsed = false;
     64    for(int j = 0; j < W_MAX_SLOTS; ++j)
     65      this->configs[i].slots[j] = NULL;
     66  }
     67  this->currConfID = W_CONFIG0;
     68
     69}
    6270
    6371/**
     
    162170 * @param second passed since last tick
    163171 */
    164 void WeaponManager::tick(float sec)
     172void WeaponManager::tick(float dt)
    165173{
    166174  Weapon* w;
     
    168176  {
    169177    w = this->configs[this->currConfID].slots[i];
    170     if( w != NULL) w->tick(sec);
     178    if( w != NULL) w->tick(dt);
    171179  }
    172180}
     
    182190  {
    183191    w = this->configs[this->currConfID].slots[i];
    184     if( w != NULL) w->draw();
     192    if( w != NULL)
     193      w->draw();
    185194  }
    186195}
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.h

    r4832 r4833  
    5656
    5757//! this is a weapon Configuration: it has up to 8 slots
    58 typedef struct weaponConfig {
     58typedef struct weaponConfig
     59{
    5960  bool           bUsed;                       //!< is set to true, if this configuration is
    6061  Weapon*        slots[8];
     
    7677
    7778    void fire();
    78     void tick(float sec);
     79    void tick(float dt);
    7980    void draw();
    8081
Note: See TracChangeset for help on using the changeset viewer.