Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9441


Ignore:
Timestamp:
Nov 12, 2012, 4:13:27 PM (12 years ago)
Author:
purgham
Message:

BUG 12.11.2012 Error if create Bots after start

Location:
code/branches/Racingbot/src/modules/gametypes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc

    r9432 r9441  
    4343    CreateFactory(RaceCheckPoint);
    4444
    45     RaceCheckPoint::RaceCheckPoint(BaseObject* creator) :
    46         DistanceMultiTrigger(creator), RadarViewable(creator,
    47                 static_cast<WorldEntity*> (this))
     45    RaceCheckPoint::RaceCheckPoint(BaseObject* creator) : DistanceMultiTrigger(creator),
     46            RadarViewable(creator, static_cast<WorldEntity*> (this))
    4847    {
    49         RegisterObject(RaceCheckPoint)
    50 ;        this->setDistance(100);
     48        RegisterObject(RaceCheckPoint);
     49        this->setDistance(100);
    5150        this->setBeaconMode("off");
    5251        this->setBroadcast(false);
     
    6261        this->timeLimit_ = 0;
    6362        //this->players_ = vector<PlayerInfo*>();
     63
     64        myPosition_= this->getPosition();
     65        orxout(user_status) << "test" << std::endl;
     66
    6467    }
    6568
     
    8790            ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator);
    8891            if (entity)
    89             this->players_.push_back(entity->getPlayer());
     92                this->players_.push_back(entity->getPlayer());
    9093        }
    9194    }
  • code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h

    r9412 r9441  
    104104            float timeLimit_; ///< The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
    105105            std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint
     106            Vector3 myPosition_;
    106107    };
    107108}
  • code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc

    r9436 r9441  
    2323 *      Author: purgham
    2424 */
    25 
     25 /**
     26  * Conventions:
     27  * -first Checkpoint has index 0
     28  *
     29  */
    2630#include <gametypes/SpaceRaceController.h>
    2731#include "core/CoreIncludes.h"
     
    2933#include "gametypes/SpaceRaceManager.h"
    3034
    31 // WEnn RAcer nach start erstellt wird fehler in Tick
    32 // Fuer beide Spieler wird next point angezeigt
     35
     36
     37
    3338namespace orxonox
    3439{
     
    5055
    5156        OrxAssert(!checkpoints.empty(), "No Checkpoints in Level");
     57        //OrxAssert(1==2, "Orxassert test");
    5258        checkpoints_=checkpoints;
    5359        staticRacePoints_ = findStaticCheckpoints(checkpoints);
     60        for (int i=0; true; i++){
     61            if(checkpoints_[i]->getCheckpointIndex()==0){
     62                nextRaceCheckpoint_=checkpoints_[i];
     63                break;
     64            }
     65        }
    5466
    5567    }
     
    6678    RaceCheckPoint* SpaceRaceController::nextPointFind(RaceCheckPoint* raceCheckpoint)
    6779    {
    68         int distances[] =
    69         {   -1, -1, -1};
     80        int distances[] ={   -1, -1, -1};
    7081        int temp_i = 0;
    7182        for (std::set<int>::iterator it =raceCheckpoint->getNextCheckpoints().begin(); it!= raceCheckpoint->getNextCheckpoints().end(); ++it)
    7283        {
    73             distances[temp_i] = recCalculateDistance(raceCheckpoint,this->getControllableEntity()->getPosition());
     84            distances[temp_i] = recCalculateDistance(raceCheckpoint, this->getControllableEntity()->getPosition());
    7485            temp_i++;
    7586        }
     
    119130    int SpaceRaceController::recCalculateDistance(RaceCheckPoint* currentCheckPoint, Vector3 currentPosition)
    120131    {
     132        orxout()<< "rec Aufruf" << endl;
    121133        // if ( staticCheckPoint was reached)
    122134        if (std::find(staticRacePoints_.begin(), staticRacePoints_.end(),currentCheckPoint) != staticRacePoints_.end())
     
    127139        {
    128140            int minimum = std::numeric_limits<int>::max();
     141            int temp=0;
    129142            for (std::set<int>::iterator it = currentCheckPoint->getNextCheckpoints().begin(); it!= currentCheckPoint->getNextCheckpoints().end(); ++it)
    130             {
    131                 minimum= std::min(minimum,(int) (currentPosition- currentCheckPoint->getPosition()).length() + recCalculateDistance(checkpoints_[(*it)], currentCheckPoint->getPosition()));
    132             }//TODO: fix cast
     143            { //temp++;
     144                WorldEntity* ttt= dynamic_cast<WorldEntity*> (currentCheckPoint);
     145                OrxAssert(!(ttt==NULL), "WorldEntity null");
     146                OrxAssert(!(ttt->getNode()==NULL), "Node of WorldEntity is null");
     147
     148                //orxout()<< temp <<endl;
     149                //if(temp==1){orxout()<<currentCheckPoint << " == null?  => "<<(currentCheckPoint==NULL)<<currentPosition<<endl;}
     150                Vector3 t=(currentPosition- ttt->getPosition()); //TODO: Find Crash Reason. Why can't currentCheck access node.
     151                int tt=static_cast<int>(t.length());
     152                //OrxAssert(!currentCheckPoint.empty(), "currentCheckPoint == null");
     153                //OrxAssert(!(it == currentCheckPoint->getNextCheckpoints().end()), "it is null");
     154                minimum= std::min(minimum, tt+ recCalculateDistance(checkpoints_[(*it)], currentCheckPoint->getPosition()));
     155                // minimum of distanz from 'currentPosition' to the next static Checkpoint
     156            }//Error tritt manchmal auf
    133157            return minimum;
    134158        }
     
    204228    void SpaceRaceController::tick(float dt)
    205229    {
    206         if (this->getControllableEntity() ==  NULL || this->getControllableEntity()->getPlayer() == NULL ){orxout()<<this->getControllableEntity()<<endl; return;}
     230        if (this->getControllableEntity() ==  NULL || this->getControllableEntity()->getPlayer() == NULL ){orxout()<<this->getControllableEntity()<< " in tick"<<endl; return;}
    207231        if (nextRaceCheckpoint_->playerWasHere(this->getControllableEntity()->getPlayer()))
    208232        {//Checkpoint erreicht
  • code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h

    r9432 r9441  
    4040        private:
    4141            std::vector<RaceCheckPoint*> staticRacePoints_;
    42             RaceCheckPoint* nextRaceCheckpoint_;
    43             RaceCheckPoint* currentRaceCheckpoint_;
     42            RaceCheckPoint* nextRaceCheckpoint_;    // checkpoint that should be reached
     43            RaceCheckPoint* currentRaceCheckpoint_; // last checkPoint (already reached)
    4444            std::vector<RaceCheckPoint*> checkpoints_;
    4545            int lastDistance;
Note: See TracChangeset for help on using the changeset viewer.