Esempio n. 1
0
bool Career::getAcrobaticsSkill(Acrobatics skill)
{
    GameData* gameData = getGameData( actobaticsGameData );
    if( !gameData )
    {
        // create gamedata for acrobatics and reset its contents
        gameData = new GameData( sizeof(unsigned int) );
        memset( gameData->getData(), 0, gameData->getSize() );
        addGameData( actobaticsGameData, gameData );
    }
    unsigned int bitset = *reinterpret_cast<unsigned int*>( gameData->getData() );
    return ( bitset & skill ) != 0;
}
Esempio n. 2
0
void Career::setAcrobaticsSkill(Acrobatics skill, bool isLearned)
{
    GameData* gameData = getGameData( actobaticsGameData );
    if( !gameData )
    {
        // create gamedata for acrobatics and reset its contents
        gameData = new GameData( sizeof(unsigned int) );
        memset( gameData->getData(), 0, gameData->getSize() );
        addGameData( actobaticsGameData, gameData );
    }

    // modify flag
    unsigned int bitset = *reinterpret_cast<unsigned int*>( gameData->getData() );
    if( isLearned ) bitset = bitset | skill; else bitset = bitset & ~skill;
    memcpy( gameData->getData(), &bitset, sizeof(unsigned int) );
}
Esempio n. 3
0
void Career::initializeWalkthroughMeter(void)
{
    // for all tournaments...
    for( unsigned int i=0; i<database::TournamentInfo::getNumRecords(); i++ )
    {
        // except for demo tournament
        if( i == database::TournamentInfo::getDemoTournament() ) continue;

        // retrieve tournament record
        database::TournamentInfo* tournamentInfo = database::TournamentInfo::getRecord( i );
        assert( tournamentInfo->gameData );

        // check there is gamedata record for "tournament walkthrough"
        GameData* gameData = getGameData( tournamentInfo->gameData );
        if( !gameData )
        {
            // create gamedata for tournament & reset its content
            gameData = new GameData( sizeof( Bitfield32 ) );
            memset( gameData->getData(), 0, gameData->getSize() );
            addGameData( tournamentInfo->gameData, gameData );
        }
    }
}
Esempio n. 4
0
Career::Career(TiXmlElement* node)
{
    assert( strcmp( node->Value(), "career" ) == 0 );

    _name = node->Attribute( "name" );

    _isHomeDefined = false;
    _homeX = _homeY = 0;
    _eventCallback = NULL;
    _eventCallbackData = NULL;

    TiXmlNode* child = node->FirstChild(); assert( child );
    if( child != NULL ) do 
    {
        if( child->Type() == TiXmlNode::ELEMENT && strcmp( child->Value(), "virtues" ) == 0 )
        {
            int cs;
            static_cast<TiXmlElement*>( child )->Attribute( "checksum", &cs );
            std::string data = static_cast<TiXmlElement*>( child )->Attribute( "data" );
			if (!decrypt( &_virtues, sizeof(Virtues), data, _name.c_str() )) {

				VirtuesLegacy virtuesL;
				decrypt( &virtuesL, sizeof(VirtuesLegacy), data, _name.c_str() );
				
				_virtues.loadLegacy(virtuesL);
				//Virtues *a = NULL;a->appearance.face = 1;
			}
            if( cs != checksum( &_virtues, sizeof(Virtues) ) )
            {
                throw ccor::Exception( "User database entry corrupted: \"%s\"! Cheating not allowed!", _name.c_str() );
            }
        }
        else if( child->Type() == TiXmlNode::ELEMENT && strcmp( child->Value(), "gears" ) == 0 )
        {
            TiXmlNode* gearNode = child->FirstChild();
            if( gearNode ) do
            {
                assert( gearNode->Type() == TiXmlNode::ELEMENT && strcmp( gearNode->Value(), "gear" ) == 0 );
                int cs;
                static_cast<TiXmlElement*>( gearNode )->Attribute( "checksum", &cs );
                std::string data = static_cast<TiXmlElement*>( gearNode )->Attribute( "data" );
                Gear gear;
                decrypt( &gear, sizeof(Gear), data, _name.c_str() );
                if( cs != checksum( &gear, sizeof(Gear) ) )
                {
                    throw ccor::Exception( "User database entry corrupted: \"%s\"! Cheating not allowed!", _name.c_str() );
                }
                addGear( gear );
                gearNode = gearNode->NextSibling();
            }
            while( gearNode != NULL );
        }
        else if( child->Type() == TiXmlNode::ELEMENT && strcmp( child->Value(), "home" ) == 0 )
        {
            _isHomeDefined = true;
            static_cast<TiXmlElement*>( child )->Attribute( "x", &_homeX );
            static_cast<TiXmlElement*>( child )->Attribute( "y", &_homeY );
        }
        else if( child->Type() == TiXmlNode::ELEMENT && strcmp( child->Value(), "events" ) == 0 )
        {
            TiXmlNode* eventNode = child->FirstChild();
            if( eventNode ) do
            {
                if( eventNode->Type() == TiXmlNode::ELEMENT && strcmp( eventNode->Value(), "event" ) == 0 )
                {
                    Event* event = Event::createFromXml( this, static_cast<TiXmlElement*>( eventNode ) );
                    assert( event );
                    _events.push_back( event );
                }
                eventNode = eventNode->NextSibling();
            }
            while( eventNode != NULL );
        }        
        else if( child->Type() == TiXmlNode::ELEMENT && strcmp( child->Value(), "gamedata" ) == 0 )
        {
            TiXmlNode* entryNode = child->FirstChild();
            if( entryNode ) do
            {
                if( entryNode->Type() == TiXmlNode::ELEMENT && strcmp( entryNode->Value(), "entry" ) == 0 )
                {
                    std::string name = static_cast<TiXmlElement*>( entryNode )->Attribute( "name" );
                    std::string data = static_cast<TiXmlElement*>( entryNode )->Attribute( "data" );
                    int cs;
                    static_cast<TiXmlElement*>( entryNode )->Attribute( "checksum", &cs );
                    GameData* gameData = new GameData( data.length() / 2 );
                    ::decrypt( gameData->getData(), gameData->getSize(), data, _name.c_str() );
                    if( ::checksum( gameData->getData(), gameData->getSize() ) != cs )
                    {
                        throw ccor::Exception( "User database entry corrupted: \"%s\"! Cheating not allowed!", _name.c_str() );
                    }
                    _gameDataM.insert( GameDataT( name, gameData ) );
                }
                entryNode = entryNode->NextSibling();
            }
            while( entryNode != NULL );
        }
        child = child->NextSibling();
    }
    while( child != NULL );

    // TEST_MODE( enable acrobatics )
    
    //setAcrobaticsSkill( acroJumpFromRun, true );
    //setAcrobaticsSkill( acroFreeflyFlip, true );
    //setAcrobaticsSkill( acroFreeflySitfly, true );
    //setAcrobaticsSkill( acroFrontFlip, true );
    //setAcrobaticsSkill( acroFrontBackFlip, true );
    //setAcrobaticsSkill( acroBackFlip, true );
    //setAcrobaticsSkill( acroBackFrontFlip, true );
    

    // initialize game walk-through meter
    initializeWalkthroughMeter();
}