コード例 #1
0
ファイル: PositionLogMgr.cpp プロジェクト: craigshaw/Meazure
void MeaPositionLogMgr::DeletePositions()
{
    ClearPositions();
    ::MessageBeep(MB_OK);

    m_modified = false;

    if (m_observer != NULL) {
        m_observer->PositionsDeleted();
    }
}
コード例 #2
0
/*
================
sdTransportPositionManager::~sdTransportPositionManager
================
*/
sdTransportPositionManager::~sdTransportPositionManager( void ) {
	ClearPositions();
}
コード例 #3
0
/*
================
sdTransportPositionManager::Init
================
*/
void sdTransportPositionManager::Init( const sdDeclVehicleScript* vehicleScript, sdTransport* other ) {
	transport = other;

	idAnimator& animator = *other->GetAnimator();

	if ( !gameLocal.isClient ) {
		EjectAllPlayers();
	}
	ClearPositions();

	playerExitTime.SetNum( MAX_CLIENTS );
	for ( int i = 0; i < playerExitTime.Num(); i++ ) {
		playerExitTime[ i ] = 0;
	}

	for( int i = 0; i < vehicleScript->positions.Num(); i++ ) {
		positionInfo_t& filePosition = vehicleScript->positions[ i ]->positionInfo;

		// FIXME: Gordon: Uh, the position should do this itself innit.

		sdVehiclePosition* positionSlot = positions.Alloc();
		if ( positionSlot == NULL ) {
			gameLocal.Error( "sdTransportPositionManager::Init - Number of positions exceeds MAX_POSITIONS" );
		}
		sdVehiclePosition& position = *positionSlot;


		position.SetPositionId( i );
		position.SetHudName( filePosition.hudname );
		position.SetName( filePosition.name );
		position.SetTransport( other );
		position.LoadData( filePosition.data );

		int j;

		for ( j = 0; j < filePosition.views.Num(); j++ ) {
			position.AddView( filePosition.views[ j ] );
		}

		for( j = 0; j < filePosition.weapons.Num(); j++ ) {
			sdVehicleWeapon* weapon = sdVehicleWeaponFactory::GetWeapon( filePosition.weapons[ j ].weaponType );
			weapon->SetPosition( NULL );
			weapon->SetBasePosition( &position );
			weapon->Setup( other, *filePosition.weapons[ j ].weaponDef, filePosition.weapons[ j ].clampYaw, filePosition.weapons[ j ].clampPitch );
			other->AddWeapon( weapon );
		}

		for( j = 0; j < filePosition.ikSystems.Num(); j++ ) {
			const char* ikSystemTypeName = filePosition.ikSystems[ j ].ikType.c_str();
			idTypeInfo* ikType = idClass::GetClass( ikSystemTypeName );
			if ( !ikType ) {
				gameLocal.Error( "sdTransportPositionManager: Invalid ikType '%s'", ikSystemTypeName );
			}
			if ( !ikType->IsType( sdVehicleIKSystem::Type ) ) {
				gameLocal.Error( "sdTransportPositionManager: ikType '%s' Is Not Of Type sdVehicleIKSystem", ikSystemTypeName );
			}

			sdVehicleIKSystem* ikSystem = reinterpret_cast< sdVehicleIKSystem* >( ikType->CreateInstance() );
			ikSystem->SetPosition( &position );
			ikSystem->Setup( other, filePosition.ikSystems[ j ].clampYaw, filePosition.ikSystems[ j ].clampPitch, filePosition.ikSystems[ j ].ikParms );

			position.AddIKSystem( ikSystem );
		}
	}

	for( int i = 0; i < vehicleScript->exits.Num(); i++ ) {
		jointHandle_t joint = animator.GetJointHandle( vehicleScript->exits[ i ]->exitInfo.joint );
		if( joint == INVALID_JOINT ) {
			gameLocal.Warning( "sdTransportPositionManager::Init Invalid Joint Name '%s' For Vehicle '%s'", vehicleScript->exits[ i ]->exitInfo.joint.c_str(), other->name.c_str() );
			continue;
		}

		jointHandle_t* jointSlot = exitJoints.Alloc();
		if ( jointSlot == NULL ) {
			gameLocal.Error( "sdTransportPositionManager::Init - Number of exit joints exceeds MAX_EXIT_JOINTS" );
		}

		*jointSlot = joint;
	}
}
コード例 #4
0
ファイル: PositionLogMgr.cpp プロジェクト: craigshaw/Meazure
bool MeaPositionLogMgr::Load(LPCTSTR pathname)
{
    // If there is a modified set of positions, ask the user if
    // they should be saved before loading a new set.
    //
    if (!SaveIfModified()) {
        return false;
    }

    if (pathname != NULL) {
        m_pathname = pathname;
    } else {
        CFileDialog *dlg = CreateLoadDialog();

        if (dlg->DoModal() != IDOK) {
            return false;
        }
        m_pathname = dlg->GetPathName();
    }

    bool status = false;
    TCHAR drive[_MAX_DRIVE];
    TCHAR dir[_MAX_DIR];

    //
    // Remember the directory for persisting.
    //
    _tsplitpath_s(m_pathname, drive, _MAX_DRIVE, dir, _MAX_DIR, NULL, 0, NULL, 0);
    m_initialDir = drive;
    m_initialDir += dir;

    //
    // Load the positions
    //
    if (Open(m_pathname, CFile::modeRead)) {
        //
        // Delete old positions.
        //
        ClearPositions();
    
        //
        // Parse the contents of the log file
        //
        MeaXMLParser parser(this, true);

        try {
            UINT numBytes;

            do {
                void *buf = parser.GetBuffer(kChunkSize);
                numBytes = m_stdioFile.Read(buf, kChunkSize);
                parser.ParseBuffer(numBytes, numBytes == 0);
            } while (numBytes > 0);

            status = true;
        } catch (MeaXMLParserException&) {
            // Handled by the parser.
        } catch (MeaLogFileException&) {
            CString msg(reinterpret_cast<LPCSTR>(IDS_MEA_INVALID_LOGFILE));
            MessageBox(*AfxGetMainWnd(), msg, NULL, MB_OK | MB_ICONERROR);
        } catch (...) {
            CString msg(reinterpret_cast<LPCSTR>(IDS_MEA_NO_POSITIONS));
            MessageBox(*AfxGetMainWnd(), msg, NULL, MB_OK | MB_ICONERROR);
        }

        Close();

        if (status) {
            //
            // Process the log file DOM
            //
            ProcessDOM(parser.GetDOM());

            m_modified = false;

            if (m_observer != NULL) {
                m_observer->LogLoaded();
            }
        }
    } else {
        m_pathname.Empty();
    }

    return status;
}