Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 29, 2011, 6:44:45 PM (14 years ago)
Author:
dafrick
Message:

Possible fix for segfaults due to player being NULL.

Location:
code/branches/presentation/src/modules
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/modules/docking/Dock.cc

    r8645 r8667  
    8484    {
    8585        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    86         Pawn* pawn = NULL;
     86        PlayerInfo* player = NULL;
    8787
    8888        // Check whether it is a player trigger and extract pawn from it
     
    9393                return false;
    9494            }
    95             pawn = pTrigger->getTriggeringPlayer();
     95            player = pTrigger->getTriggeringPlayer();
    9696        }
    9797        else
     
    100100            return false;
    101101        }
    102         if(pawn == NULL)
    103         {
    104             COUT(4) << "Docking::execute Can't retrieve Pawn from Trigger. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    105             return false;
    106         }
    107 
    108         // Extract the PlayerInfo from the Pawn.
    109         PlayerInfo* player = pawn->getPlayer();
    110102        if(player == NULL)
    111103        {
    112             COUT(2) << "Docking::execute The PlayerInfo* is NULL." << std::endl;
     104            COUT(4) << "Docking::execute Can't retrieve PlayerInfo from Trigger. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    113105            return false;
    114106        }
  • code/branches/presentation/src/modules/notifications/NotificationDispatcher.cc

    r8666 r8667  
    140140
    141141        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    142         Pawn* pawn = NULL;
     142        PlayerInfo* player = NULL;
    143143
    144144        // If the trigger is a PlayerTrigger.
     
    148148                return false;
    149149            else
    150                 pawn = pTrigger->getTriggeringPlayer();
     150                player = pTrigger->getTriggeringPlayer();
    151151        }
    152152        else
    153153            return false;
    154154
    155         if(pawn == NULL)
     155        if(player == NULL)
    156156        {
    157157            COUT(4) << "The NotificationDispatcher was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
     
    159159        }
    160160
    161         // Extract the PlayerInfo from the Pawn.
    162         PlayerInfo* player = pawn->getPlayer();
    163 
    164         if(player == NULL)
    165         {
    166             CCOUT(3) << "The PlayerInfo* is NULL." << std::endl;
    167             return false;
    168         }
    169 
    170         // HACK fix. Resolve this issue another way...
    171         if(GameMode::isStandalone())
    172             this->dispatch(0);
    173         else
    174             this->dispatch(player->getClientID());
     161        this->dispatch(player->getClientID());
    175162
    176163        return true;
  • code/branches/presentation/src/modules/objects/Script.cc

    r7493 r8667  
    140140
    141141        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    142         Pawn* pawn = NULL;
     142        PlayerInfo* player = NULL;
    143143
    144144        // If the trigger is a PlayerTrigger.
     
    148148                return false;
    149149            else
    150                 pawn = pTrigger->getTriggeringPlayer();
     150                player = pTrigger->getTriggeringPlayer();
    151151        }
    152152        else
    153153            return false;
    154154
    155         if(pawn == NULL)  //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.
     155        if(player == NULL)  //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.
    156156        {
    157157            COUT(4) << "The Script was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    158             return false;
    159         }
    160 
    161         // Extract the PlayerInfo from the Pawn.
    162         PlayerInfo* player = pawn->getPlayer();
    163 
    164         if(player == NULL)
    165         {
    166             COUT(3) << "The PlayerInfo* is NULL." << std::endl;
    167158            return false;
    168159        }
  • code/branches/presentation/src/modules/objects/triggers/DistanceTrigger.cc

    r8637 r8667  
    205205                        entity = entity->getParent();
    206206
    207                     Pawn* player = orxonox_cast<Pawn*>(entity);
    208                     this->setTriggeringPlayer(player);
     207                    Pawn* pawn = orxonox_cast<Pawn*>(entity);
     208                    if(pawn != NULL)
     209                        this->setTriggeringPawn(pawn);
     210                    else
     211                        CCOUT(2) << "Pawn was NULL." << endl;
    209212                }
    210213               
  • code/branches/presentation/src/modules/objects/triggers/MultiTriggerContainer.cc

    r7601 r8667  
    7373        {
    7474            this->setForPlayer(true);
    75             this->setTriggeringPlayer(pawn);
     75            this->setTriggeringPawn(pawn);
    7676        }
    7777    }
  • code/branches/presentation/src/modules/questsystem/QuestEffectBeacon.cc

    r8351 r8667  
    113113
    114114        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    115         Pawn* pawn = NULL;
     115        PlayerInfo* player = NULL;
    116116
    117117        // If the trigger is a PlayerTrigger.
     
    121121                return false;
    122122            else
    123                 pawn = pTrigger->getTriggeringPlayer();
     123                player = pTrigger->getTriggeringPlayer();
    124124        }
    125125        else
    126126            return false;
    127127
    128         if(pawn == NULL)
     128        if(player == NULL)
    129129        {
    130130            COUT(4) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    131             return false;
    132         }
    133 
    134         // Extract the PlayerInfo from the Pawn.
    135         PlayerInfo* player = pawn->getPlayer();
    136 
    137         if(player == NULL)
    138         {
    139             COUT(3) << "The PlayerInfo* is NULL." << std::endl;
    140131            return false;
    141132        }
Note: See TracChangeset for help on using the changeset viewer.