Пример #1
0
int EBuffer::GetMatchBrace(EPoint &M, int MinLine, int MaxLine, int show) {
    int StateLen;
    hsState *StateMap = 0;
    int Pos;
    PELine L = VLine(M.Row);
    int dir = 0;
    hsState State;
    char Ch1, Ch2;
    int CountX = 0;
    int StateRow = -1;

    M.Row = VToR(CP.Row);

    Pos = CharOffset(L, M.Col);
    if (Pos >= L->Count) return 0;
    switch (L->Chars[Pos]) {
    case '{':
        dir = + 1;
        Ch1 = '{';
        Ch2 = '}';
        break;
    case '[':
        dir = + 1;
        Ch1 = '[';
        Ch2 = ']';
        break;
    case '<':
        dir = + 1;
        Ch1 = '<';
        Ch2 = '>';
        break;
    case '(':
        dir = + 1;
        Ch1 = '(';
        Ch2 = ')';
        break;
    case '}':
        dir = -1;
        Ch1 = '}';
        Ch2 = '{';
        break;
    case ']':
        dir = -1;
        Ch1 = ']';
        Ch2 = '[';
        break;
    case '>':
        dir = -1;
        Ch1 = '>';
        Ch2 = '<';
        break;
    case ')':
        dir = -1;
        Ch1 = ')';
        Ch2 = '(';
        break;
    default:
        return 0;
    }
    StateMap = 0;
    if (GetMap(M.Row, &StateLen, &StateMap) == 0) return 0;
    State = StateMap[Pos];
    StateRow = M.Row;

    while (M.Row >= MinLine && M.Row < MaxLine) {
        while (Pos >= 0 && Pos < L->Count) {
            if (L->Chars[Pos] == Ch1 || L->Chars[Pos] == Ch2) {
                // update syntax state if needed
                if (StateRow != M.Row) {
                    free(StateMap);
                    StateMap = 0;
                    GetMap(M.Row, &StateLen, &StateMap);
                    if (StateMap == 0) return 0;
                    StateRow = M.Row;
                }
                if (StateMap[Pos] == State) {
                    if (L->Chars[Pos] == Ch1) CountX++;
                    if (L->Chars[Pos] == Ch2) CountX--;
                    if (CountX == 0) {
                        M.Col = ScreenPos(L, Pos);
                        free(StateMap);
                        return 1;
                    }
                }
            }
            Pos += dir;
        }
        M.Row += dir;
        if (M.Row >= 0 && M.Row < RCount) {
            L = RLine(M.Row);
            Pos = (dir == 1) ? 0 : (L->Count - 1);
        }
    }
    if (StateMap) free(StateMap);
    if (show)
        Msg(S_INFO, "No match (%d missing).", CountX);
    return 0;
}
Пример #2
0
static float ResponseCurveLookAccelerated( float x, int axis, float otherAxis, float dist, float frametime )
{
	float input = x;

	float flJoyDist = ( sqrt(x*x + otherAxis * otherAxis) );
	bool bIsPegged = ( flJoyDist>= joy_pegged.GetFloat() );

	// Make X positive to make arithmetic easier for the rest of this function, and
	// remember whether we have to flip it back!
	bool negative = false;
	if( x < 0.0f )
	{
		negative = true;
		x *= -1;
	}

	// Perform the two-stage mapping.
	bool bDoAcceleration = false;// Assume we won't accelerate the input

	if( bIsPegged && x > joy_accel_filter.GetFloat() )
	{
		// Accelerate this axis, since the stick is pegged and 
		// this axis is pressed farther than the acceleration filter
		// Take the lowmap value, or the input, whichever is higher, since 
		// we don't necesarily know whether this is the axis which is pegged
		x = MAX( joy_lowmap.GetFloat(), x );
		bDoAcceleration = true;
	}
	else
	{
		// Joystick is languishing in the low-end, turn off acceleration.
		controlEnvelope.envelopeScale[axis] = 0.0f;
		float factor = x / joy_lowend.GetFloat();
		x = joy_lowmap.GetFloat() * factor;
	}

	if( bDoAcceleration )
	{
		float flMax = joy_accelmax.GetFloat();
		if( controlEnvelope.envelopeScale[axis] < flMax )
		{
			float delta = x - joy_lowmap.GetFloat();
			x = joy_lowmap.GetFloat() + (delta * controlEnvelope.envelopeScale[axis]);
			controlEnvelope.envelopeScale[axis] += ( frametime * joy_accelscale.GetFloat() );

			if( controlEnvelope.envelopeScale[axis] > flMax )
			{
				controlEnvelope.envelopeScale[axis] = flMax;
			}
		}
	}

	x *= AutoAimDampening( input, axis, dist );

	if( axis == YAW && input != 0.0f && joy_display_input.GetBool() )
	{
		Msg("In:%f Out:%f Frametime:%f\n", input, x, frametime );
	}

	if( negative )
	{
		x *= -1;
	}

	return x;
}
Пример #3
0
	void OnMCFCreateComplete(gcString &strPath)
	{
		Msg("Completed creating Mcf.\n");
		g_strMcfOutPath = strPath;
		g_WaitCon.notify();
	}
Пример #4
0
HRESULT InitializeWindowlessVMR(IBaseFilter **ppVmr9)
{
    IBaseFilter* pVmr = NULL;

    if (!ppVmr9)
        return E_POINTER;
    *ppVmr9 = NULL;

    // Create the VMR and add it to the filter graph.
    HRESULT hr = CoCreateInstance(CLSID_VideoMixingRenderer9, NULL,
                     CLSCTX_INPROC, IID_IBaseFilter, (void**)&pVmr);
    if (SUCCEEDED(hr)) 
    {
        hr = pGB->AddFilter(pVmr, L"Video Mixing Renderer 9");
        if (SUCCEEDED(hr)) 
        {
            // Set the rendering mode and number of streams
            SmartPtr <IVMRFilterConfig9> pConfig;

            JIF(pVmr->QueryInterface(IID_IVMRFilterConfig9, (void**)&pConfig));
            JIF(pConfig->SetRenderingMode(VMR9Mode_Windowless));

            hr = pVmr->QueryInterface(IID_IVMRWindowlessControl9, (void**)&pWC);
            if( SUCCEEDED(hr)) 
            {
                hr = pWC->SetVideoClippingWindow(ghApp);
                hr = pWC->SetBorderColor(RGB(0,0,0));
            }

#ifndef BILINEAR_FILTERING
            // Request point filtering (instead of bilinear filtering)
            // to improve the text quality.  In general, if you are 
            // not scaling the app Image, you should use point filtering.
            // This is very important if you are doing source color keying.
            IVMRMixerControl9 *pMix;

            hr = pVmr->QueryInterface(IID_IVMRMixerControl9, (void**)&pMix);
            if( SUCCEEDED(hr)) 
            {
                DWORD dwPrefs=0;
                hr = pMix->GetMixingPrefs(&dwPrefs);

                if (SUCCEEDED(hr))
                {
                    dwPrefs |= MixerPref_PointFiltering;
                    dwPrefs &= ~(MixerPref_BiLinearFiltering);

                    hr = pMix->SetMixingPrefs(dwPrefs);
                }
                pMix->Release();
            }
#endif

            // Get alpha-blended bitmap interface
            hr = pVmr->QueryInterface(IID_IVMRMixerBitmap9, (void**)&pBMP);
        }
        else
            Msg(TEXT("Failed to add VMR to graph!  hr=0x%x\r\n"), hr);

        // Don't release the pVmr interface because we are copying it into
        // the caller's ppVmr9 pointer
        *ppVmr9 = pVmr;
    }
    else
        Msg(TEXT("Failed to create VMR!  hr=0x%x\r\n"), hr);

   return hr;
}
Пример #5
0
bool CIKFoot::GetFootStepMatrix( ik_goal_matrix &m, const Fmatrix &g_anim, const  SIKCollideData &cld, bool collide, bool rotation, bool b_make_shift/*=true*/ )const
{
	const Fmatrix global_anim = g_anim;
	Fvector	local_point;		ToePosition( local_point );													//toe position in bone[2] space
	Fvector	global_point;		global_anim.transform_tiny( global_point, local_point );						//non collided toe in global space
	Fvector foot_normal;		FootNormal( foot_normal );
	global_anim.transform_dir( foot_normal );
#ifdef DEBUG
		//if( ph_dbg_draw_mask.test( phDbgDrawIKGoal ) )
		//{
		//	DBG_DrawLine( global_point, Fvector().add( global_point, foot_normal ), D3DCOLOR_XRGB( 0, 255, 255) );
		//}
#endif
	if( cld.m_collide_point == ik_foot_geom::heel || cld.m_collide_point == ik_foot_geom::side )
	{
		Fmatrix foot;ref_bone_to_foot( foot, g_anim );
		Fvector heel;
		HeelPosition( heel );
		foot.transform_tiny(global_point, heel );
#ifdef DEBUG
		if( ph_dbg_draw_mask.test( phDbgDrawIKGoal ) )
			DBG_DrawPoint( global_point, 0.01, D3DCOLOR_XRGB( 0, 255, 255));
#endif
		Fmatrix foot_to_ref;
		ref_bone_to_foot_transform(foot_to_ref).transform_tiny(local_point, heel );
	}

	float	dtoe_tri		=-cld.m_plane.d - cld.m_plane.n.dotproduct( global_point );	
	if(  !cld.collided ||  _abs( dtoe_tri ) > collide_dist )
	{
		m.set( global_anim, ik_goal_matrix::cl_free );
		return false;
	}

	Fplane p = cld.m_plane;
	Fmatrix xm; xm.set( global_anim );
	ik_goal_matrix::e_collide_state cl_state = ik_goal_matrix::cl_undefined;
	if( rotation )//!collide || ik_allign_free_foot
		cl_state = rotate( xm, p, foot_normal, global_point, collide );

	if( b_make_shift && make_shift( xm, local_point, collide, p, cld.m_pick_dir ) )
		switch( cl_state )
		{
			case ik_goal_matrix::cl_aligned		:					break;
			case ik_goal_matrix::cl_undefined	:
			case ik_goal_matrix::cl_free		:
					cl_state = ik_goal_matrix::cl_translational;	break;
			case ik_goal_matrix::cl_rotational:
					cl_state = ik_goal_matrix::cl_mixed;			break;
			default:		NODEFAULT;
			
		}
	else if( cl_state == ik_goal_matrix::cl_undefined )
			cl_state = ik_goal_matrix::cl_free;
	

	VERIFY( _valid( xm ) );
	m.set( xm, cl_state );
#ifdef DEBUG
	if(ph_dbg_draw_mask.test( phDbgDrawIKGoal ))
	{
		DBG_DrawPoint( global_point, 0.03f, D3DCOLOR_RGBA( 255, 0, 0, 255 ) );
	}
	if(!fsimilar( _abs( DET( g_anim ) - 1.f ), _abs( DET( m.get() ) - 1.f ), 0.001f ) )
		Msg("scale g_anim: %f scale m: %f ",  DET( g_anim ) ,  DET( m.get() ) );
#endif

	return true;
}
Пример #6
0
//-----------------------------------------------------------------------------
// Purpose: 
//    NOTE: Doesn't call the base call enter vehicle on purpose!
//-----------------------------------------------------------------------------
void CPropVehicleManhack::EnterVehicle( CBaseCombatCharacter *pPassenger )
{
	if ( pPassenger == NULL )
		return;

	DevMsg("CPropVehicleManhack: EnterVehicl(...)\n");

	CBasePlayer *pPlayer = ToBasePlayer( pPassenger );
	if ( pPlayer != NULL )
	{
		// Remove any player who may be in the vehicle at the moment
		if ( m_hPlayer )
		{
			ExitVehicle( VEHICLE_ROLE_DRIVER );
		}

		m_hPlayer = pPlayer;
		m_bHadDriver = true;

		if (GetNumberOfHacks(false)>1 && m_iHintTimesShown < 2)
		{
			m_iHintTimesShown++;
			m_iHintNoSwapTimesShown++;
			UTIL_HudHintText( pPlayer, "#HLSS_Hint_ManhackSwap" );
		} else if (m_iHintNoSwapTimesShown < 2)
		{
			m_iHintNoSwapTimesShown++;
			UTIL_HudHintText( pPlayer, "#HLSS_Hint_ManhackExit" );
		}
		else UTIL_HudHintText( pPlayer, "" );
	

		pPlayer->SetViewOffset( vec3_origin );
		pPlayer->ShowCrosshair( false );


		CHL2_Player *pHL2Player = dynamic_cast<CHL2_Player*>( pPlayer );
		if ( pHL2Player )
		{
			if ( pHL2Player->IsSprinting() )
			{
				pHL2Player->StopSprinting();
			}

			if ( pHL2Player->FlashlightIsOn() )
			{
				pHL2Player->FlashlightTurnOff();
			}
		}

		CNPC_Manhack *pManhack = dynamic_cast<CNPC_Manhack*>((CBaseEntity*)m_hManhack);
		if (pManhack!=NULL)
		{
			pManhack->SetControllable(true);

			if (manhack_dont_draw.GetBool())
			{
				pManhack->AddEffects( EF_NODRAW );
				pManhack->ShowRedGlow(false);
			}

			m_vecLastEyeTarget = pManhack->GetManhackView();
			m_vecLastEyePos    = pManhack->GetManhackView();
			m_vecTargetSpeed   = pManhack->GetAbsVelocity();

			m_vecFlyingDirection = pManhack->GetAbsVelocity();
		}

		//We want to see and feel the "vehicle" in manhack mode
		//SetRenderMode(kRenderNormal);
		RemoveEffects( EF_NODRAW );
		SetSolid(SOLID_BBOX);
		RemoveSolidFlags( FSOLID_NOT_SOLID );

		if (m_bDriverDucked) 
		{
			SetCollisionBounds( Vector(-16,-16,0), Vector(16,16,45) );

			int nSequence = LookupSequence( "crouch" );

			DevMsg("Player is ducking\n");

			// Set to the desired anim, or default anim if the desired is not present
			if ( nSequence > ACTIVITY_NOT_AVAILABLE )
			{
				SetCycle( 0 );
				m_flAnimTime = gpGlobals->curtime;
				ResetSequence( nSequence );
				ResetClientsideFrame();
			}
			else 
			{
				// Not available try to get default anim
				Msg( "Manhack Controller %s: missing crouch sequence\n", GetDebugName() );
				SetSequence( 0 );
			}
		}
		else
		{
			SetCollisionBounds( Vector(-16,-16,0), Vector(16,16,72) );

			int nSequence = LookupSequence( "idle" );

			// Set to the desired anim, or default anim if the desired is not present
			if ( nSequence > ACTIVITY_NOT_AVAILABLE )
			{
				SetCycle( 0 );
				m_flAnimTime = gpGlobals->curtime;
				ResetSequence( nSequence );
				ResetClientsideFrame();
			}
		}

		// Start Thinking
		SetNextThink( gpGlobals->curtime );

	}
	else
	{
		// NPCs not yet supported - jdw
		Assert( 0 );
	}


}
Пример #7
0
HRESULT PlayMovieInWindow(LPTSTR szFile)
{
    HRESULT hr;

    // Check input string
    if (szFile == NULL)
        return E_POINTER;

    // Clear open dialog remnants before calling RenderFile()
    UpdateWindow(ghApp);

    // Get the interface for DirectShow's GraphBuilder
    JIF(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
                         IID_IGraphBuilder, (void **)&pGB));

    if(SUCCEEDED(hr))
    {
        SmartPtr <IBaseFilter> pVmr;

        // Create the Video Mixing Renderer and add it to the graph
        JIF(InitializeWindowlessVMR(&pVmr));

        // Render the file programmatically to use the VMR9 as renderer.
        // Pass TRUE to create an audio renderer also.
        if (FAILED(hr = RenderFileToVideoRenderer(pGB, szFile, TRUE)))
            return hr;

        // QueryInterface for DirectShow interfaces
        JIF(pGB->QueryInterface(IID_IMediaControl, (void **)&pMC));
        JIF(pGB->QueryInterface(IID_IMediaEventEx, (void **)&pME));
        JIF(pGB->QueryInterface(IID_IMediaSeeking, (void **)&pMS));

        // Is this an audio-only file (no video component)?
        if (CheckVideoVisibility())
        {
            JIF(InitVideoWindow(1, 1));
        }
        else
        {
            // This sample requires a video clip to be loaded
            Msg(TEXT("This sample requires media with a video component.  ")
                TEXT("Please select another file."));
            return E_FAIL;
        }

        // Have the graph signal event via window callbacks for performance
        JIF(pME->SetNotifyWindow((OAHWND)ghApp, WM_GRAPHNOTIFY, 0));

        // Add the bitmap (static image or dynamic text) to the VMR's input
        if (g_dwTickerFlags & MARK_STATIC_IMAGE)
        {
            hr = BlendApplicationImage(ghApp);
            if (FAILED(hr))
                PostMessage(ghApp, WM_CLOSE, 0, 0);

            CheckMenuItem(ghMenu, ID_TICKER_STATIC_IMAGE, MF_CHECKED);
            CheckMenuItem(ghMenu, ID_TICKER_DYNAMIC_TEXT, MF_UNCHECKED);
        }
        else                                        // MARK_DYNAMIC_TEXT
        {
            if (!g_hFont)
                g_hFont = SetTextFont(FALSE);  // Don't display the Windows Font Select dialog

            // If the initial blend fails, post a close message to exit the app
            hr = BlendApplicationText(ghApp, g_szAppText);
            if (FAILED(hr))
                PostMessage(ghApp, WM_CLOSE, 0, 0);

            CheckMenuItem(ghMenu, ID_TICKER_STATIC_IMAGE, MF_UNCHECKED);
            CheckMenuItem(ghMenu, ID_TICKER_DYNAMIC_TEXT, MF_CHECKED);
        }

        // Complete the window setup
        ShowWindow(ghApp, SW_SHOWNORMAL);
        UpdateWindow(ghApp);
        SetForegroundWindow(ghApp);
        SetFocus(ghApp);

#ifdef REGISTER_FILTERGRAPH
        if (FAILED(AddGraphToRot(pGB, &g_dwGraphRegister)))
        {
            Msg(TEXT("Failed to register filter graph with ROT!"));
            g_dwGraphRegister = 0;
        }
#endif

        // Run the graph to play the media file
        JIF(pMC->Run());

        // Start animation by default
        PostMessage(ghApp, WM_COMMAND, ID_SLIDE, 0);
    }

    return hr;
}
void CASW_Weapon_Minigun::PrimaryAttack()
{
	// can't attack until the minigun barrel has spun up
	if ( GetSpinRate() < asw_minigun_spin_rate_threshold.GetFloat() )
		return;
	
	// If my clip is empty (and I use clips) start reload
	if ( UsesClipsForAmmo1() && !m_iClip1 ) 
	{		
		Reload();
		return;
	}

	CASW_Player *pPlayer = GetCommander();
	CASW_Marine *pMarine = GetMarine();
	if ( !pMarine )
		return;

	m_bIsFiring = true;
	// MUST call sound before removing a round from the clip of a CMachineGun
	WeaponSound(SINGLE);

	if (m_iClip1 <= AmmoClickPoint())
	{
		LowAmmoSound();
	}

	// tell the marine to tell its weapon to draw the muzzle flash
	pMarine->DoMuzzleFlash();

	// sets the animation on the weapon model itself
	SendWeaponAnim( GetPrimaryAttackActivity() );

	// sets the animation on the marine holding this weapon
	//pMarine->SetAnimation( PLAYER_ATTACK1 );

#ifdef GAME_DLL	// check for turning on lag compensation
	if (pPlayer && pMarine->IsInhabited())
	{
		CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() );
	}
#endif

	FireBulletsInfo_t info;
	info.m_vecSrc	 = pMarine->Weapon_ShootPosition( );
	if ( pPlayer && pMarine->IsInhabited() )
	{
		info.m_vecDirShooting = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount());	// 45 degrees = 0.707106781187
	}
	else
	{
#ifdef CLIENT_DLL
		Msg("Error, clientside firing of a weapon that's being controlled by an AI marine\n");
#else
		info.m_vecDirShooting = pMarine->GetActualShootTrajectory( info.m_vecSrc );
#endif
	}

	// To make the firing framerate independent, we may have to fire more than one bullet here on low-framerate systems, 
	// especially if the weapon we're firing has a really fast rate of fire.
	info.m_iShots = 0;
	float fireRate = GetFireRate() * ( 1.0f / MAX( GetSpinRate(), asw_minigun_spin_rate_threshold.GetFloat() ) );
	while ( m_flNextPrimaryAttack <= gpGlobals->curtime )
	{
		m_flNextPrimaryAttack = m_flNextPrimaryAttack + fireRate;
		info.m_iShots++;
		if ( !fireRate )
			break;
	}

	// Make sure we don't fire more than the amount in the clip
	if ( UsesClipsForAmmo1() )
	{
		info.m_iShots = MIN( info.m_iShots, m_iClip1 );
		m_flPartialBullets += static_cast<float>( info.m_iShots ) * 0.5f;

		if ( m_flPartialBullets >= 1.0f )
		{
			// Subtract ammo if we've counted up a whole bullet
			int nBullets = m_flPartialBullets;
			m_iClip1 -= nBullets;
			m_flPartialBullets -= nBullets;
		}

#ifdef GAME_DLL
		CASW_Marine *pMarine = GetMarine();
		if (pMarine && m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
		{
			pMarine->OnWeaponOutOfAmmo(true);
		}
#endif
	}
	else
	{
		info.m_iShots = MIN( info.m_iShots, pMarine->GetAmmoCount( m_iPrimaryAmmoType ) );
		pMarine->RemoveAmmo( info.m_iShots, m_iPrimaryAmmoType );
	}

	info.m_flDistance = asw_weapon_max_shooting_distance.GetFloat();
	info.m_iAmmoType = m_iPrimaryAmmoType;
	info.m_iTracerFreq = 1;  // asw tracer test everytime
	info.m_flDamageForceScale = asw_weapon_force_scale.GetFloat();

	info.m_vecSpread = pMarine->GetActiveWeapon()->GetBulletSpread();
	info.m_flDamage = GetWeaponDamage();
#ifndef CLIENT_DLL
	if (asw_debug_marine_damage.GetBool())
		Msg("Weapon dmg = %f\n", info.m_flDamage);
	info.m_flDamage *= pMarine->OnFired_GetDamageScale();
	if (asw_DebugAutoAim.GetBool())
	{
		NDebugOverlay::Line(info.m_vecSrc, info.m_vecSrc + info.m_vecDirShooting * info.m_flDistance, 64, 0, 64, true, 1.0);
	}
#endif

	// fire extra shots per ammo from the minigun, so we get a nice solid spray of bullets
	//info.m_iShots = 2;
	pMarine->FireBullets( info );

	// increment shooting stats
#ifndef CLIENT_DLL
	if (pMarine && pMarine->GetMarineResource())
	{
		pMarine->GetMarineResource()->UsedWeapon(this, info.m_iShots);
		pMarine->OnWeaponFired( this, info.m_iShots );
	}
#endif
}
void xrServer::Process_event_destroy	(NET_Packet& P, ClientID sender, u32 time, u16 ID, NET_Packet* pEPack)
{
	u32								MODE = net_flags(TRUE,TRUE);
	// Parse message
	u16								id_dest	= ID;
#ifdef DEBUG
	if( dbg_net_Draw_Flags.test( dbg_destroy ) )
		Msg								("sv destroy object %s [%d]", ent_name_safe(id_dest).c_str(), Device.dwFrame);
#endif

	CSE_Abstract*					e_dest = game->get_entity_from_eid	(id_dest);	// кто должен быть уничтожен
	if (!e_dest) 
	{
#ifndef MASTER_GOLD
		Msg							("!SV:ge_destroy: [%d] not found on server",id_dest);
#endif // #ifndef MASTER_GOLD
		return;
	};

	R_ASSERT						(e_dest);
	xrClientData					*c_dest = e_dest->owner;				// клиент, чей юнит
	R_ASSERT						(c_dest);
	xrClientData					*c_from = ID_to_client(sender);	// клиент, кто прислал
	R_ASSERT						(c_dest == c_from);							// assure client ownership of event
	u16								parent_id = e_dest->ID_Parent;

#ifdef MP_LOGGING
	Msg("--- SV: Process destroy: parent [%d] item [%d][%s]", 
		parent_id, id_dest, e_dest->name());
#endif //#ifdef MP_LOGGING

	//---------------------------------------------
	NET_Packet	P2, *pEventPack = pEPack;
	P2.w_begin	(M_EVENT_PACK);
	//---------------------------------------------
	// check if we have children 
	if (!e_dest->children.empty()) {
		if (!pEventPack) pEventPack = &P2;

		while (!e_dest->children.empty())
			Process_event_destroy		(P,sender,time,*e_dest->children.begin(), pEventPack);
	};

	if (0xffff == parent_id && NULL == pEventPack) 
	{
		SendBroadcast				(BroadcastCID,P,MODE);
	}
	else 
	{
		NET_Packet	tmpP;
		if (0xffff != parent_id && Process_event_reject(P,sender,time,parent_id,ID,false)) 
		{
			game->u_EventGen(tmpP, GE_OWNERSHIP_REJECT, parent_id);
			tmpP.w_u16(id_dest);
			tmpP.w_u8(1);
		
			if (!pEventPack) pEventPack = &P2;
			
			pEventPack->w_u8(u8(tmpP.B.count));
			pEventPack->w(&tmpP.B.data, tmpP.B.count);
		};
		
 		game->u_EventGen(tmpP, GE_DESTROY, id_dest);
		
		pEventPack->w_u8(u8(tmpP.B.count));
		pEventPack->w(&tmpP.B.data, tmpP.B.count);
	};

	if (NULL == pEPack && NULL != pEventPack)
	{
		SendBroadcast				(BroadcastCID, *pEventPack, MODE);
	}

	// Everything OK, so perform entity-destroy
	if (e_dest->m_bALifeControl && ai().get_alife()) {
		game_sv_Single				*_game = smart_cast<game_sv_Single*>(game);
		VERIFY						(_game);
		if (ai().alife().objects().object(id_dest,true))
			_game->alife().release	(e_dest,false);
	}

	if (game)
		game->OnDestroyObject		(e_dest->ID);

	entity_Destroy					(e_dest);
}
Пример #10
0
CBaseEntity	* CASW_Rocket::FindPotentialTarget( void ) const
{
	float		bestdist = 0;		
	CBaseEntity	*bestent = NULL;

	Vector v_forward, v_right, v_up;
	AngleVectors( GetAbsAngles(), &v_forward, &v_right, &v_up );

	// find the aimtarget nearest us
	int count = AimTarget_ListCount();		
	if ( count )
	{
		CBaseEntity **pList = (CBaseEntity **)stackalloc( sizeof(CBaseEntity *) * count );
		AimTarget_ListCopy( pList, count );

		CTraceFilterSkipTwoEntities filter(this, GetOwnerEntity(), COLLISION_GROUP_NONE);

		for ( int i = 0; i < count; i++ )
		{
			CBaseEntity *pEntity = pList[i];

			if (!pEntity || !pEntity->IsAlive() || !pEntity->edict() || !pEntity->IsNPC() )
			{
				//Msg("not alive or not an edict, skipping\n");
				continue;
			}

			if (!pEntity || !pEntity->IsAlive() || !pEntity->edict() || !pEntity->IsNPC() )
			{
				//Msg("not alive or not an edict, skipping\n");
				continue;
			}
	
			// don't autoaim onto marines
			if (pEntity->Classify() == CLASS_ASW_MARINE)
				continue;

			if ( pEntity->Classify() == CLASS_ASW_PARASITE )
			{
				CASW_Parasite *pParasite = static_cast< CASW_Parasite* >( pEntity );
				if ( pParasite->m_bInfesting )
				{
					continue;
				}
			}

			Vector center = pEntity->BodyTarget( GetAbsOrigin() );
			Vector center_flat = center;
			center_flat.z = GetAbsOrigin().z;

			Vector dir = (center - GetAbsOrigin());
			VectorNormalize( dir );

			Vector dir_flat = (center_flat - GetAbsOrigin());
			VectorNormalize( dir_flat );

			// make sure it's in front of the rocket
			float dot = DotProduct (dir, v_forward );
			//if (dot < 0)
			//{					
			//continue;
			//}

			float dist = (pEntity->GetAbsOrigin() - GetAbsOrigin()).LengthSqr();
			if (dist > ASW_ROCKET_MAX_HOMING_RANGE)
				continue;

			// check another marine isn't between us and the target to reduce FF
			trace_t tr;
			UTIL_TraceLine(GetAbsOrigin(), pEntity->WorldSpaceCenter(), MASK_SHOT, &filter, &tr);
			if (tr.fraction < 1.0f && tr.m_pEnt != pEntity && tr.m_pEnt && tr.m_pEnt->Classify() == CLASS_ASW_MARINE)
				continue;

			// does this critter already have enough rockets to kill it?
			{ 
				CASW_DamageAllocationMgr::IndexType_t assignmentIndex = m_RocketAssigner.Find( pEntity );
				if ( m_RocketAssigner.IsValid(assignmentIndex) )
				{
					if ( m_RocketAssigner[assignmentIndex].m_flAccumulatedDamage > pEntity->GetHealth() )
					{
						continue;
					}
				}
			}


			// check another marine isn't between us and the target to reduce FF
			UTIL_TraceLine(GetAbsOrigin(), pEntity->WorldSpaceCenter(), MASK_SHOT, &filter, &tr);
			if (tr.fraction < 1.0f && tr.m_pEnt != pEntity && tr.m_pEnt && tr.m_pEnt->Classify() == CLASS_ASW_MARINE)
				continue;

			// increase distance if dot isn't towards us
			dist += (1.0f - dot) * 150;	// bias of x units when object is 90 degrees to the side
			if (bestdist == 0 || dist < bestdist)
			{
				bestdist = dist;
				bestent = pEntity;
			}
		}

		if ( bestent && asw_rocket_debug.GetBool() )
		{
			Vector center = bestent->BodyTarget( GetAbsOrigin() );
			Vector center_flat = center;
			center_flat.z = GetAbsOrigin().z;

			Vector dir = (center - GetAbsOrigin());
			VectorNormalize( dir );
			Msg( "Rocket[%d] starting homing in on %s(%d) dir = %f %f %f\n", entindex(), bestent->GetClassname(), bestent->entindex(), VectorExpand( dir ) );
		}
	}

	return bestent;
}
//---------------------------------------------------------------------------------
// Purpose: called when a client types in a command (only a subset of commands however, not CON_COMMAND's)
//---------------------------------------------------------------------------------
PLUGIN_RESULT CEmptyServerPlugin::ClientCommand( edict_t *pEntity, const CCommand &args )
{
	const char *cmd = args.Arg(0);
    const char *cmd1 = args.Arg(1);

    if (strcmp(cmd, "achievements")==0)
    {
        //int client = engine->IndexOfEdict(pEntity);
        // Create a filter and add this client to it
        //SRecipientFilter filter;
		
        //filter.AddRecipient(engine->IndexOfEdict(pEntity));

        //// Start the usermessage and get a bf_write
        //bf_write* pBuffer = engine->UserMessageBegin(&filter, 9);

        //// Send the menu
        //CreateMenu(pBuffer, "Menu Title\n---------------\n->1.Option1\n->2.Option2\n->3.Option3\n->4.Option4\n->5.Option5\n->6.Option6\n->7.Option7\n->8.Option8", 8, 10);

        //engine->MessageEnd();

		ShowMenu( pEntity, 0xffff, -1, "Menu Title\n---------------\n->1.Option1\n->2.Option2\n->3.Option3\n->4.Option4\n->5.Option5\n->6.Option6\n->7.Option7\n->8.Option8" );

        return PLUGIN_CONTINUE;
    }

    if (strcmp(cmd, "menuselect")==0)
    {
        switch(atoi(cmd1))
        {
        case 1:
            Msg("Selected Option1");
            break;
        case 2:
            Msg("Selected Option2");
            break;
        case 3:
            Msg("Selected Option3");
            break;
        case 4:
            Msg("Selected Option4");
            break;
        case 5:
            Msg("Selected Option5");
            break;
        case 6:
            Msg("Selected Option6");
            break;
        case 7:
            Msg("Selected Option7");
            break;
        case 8:
            Msg("Selected Option8");
            break;
        }
 
        return PLUGIN_CONTINUE;
    }

	return PLUGIN_CONTINUE;
}
Пример #12
0
void EmitDispLMAlphaAndNeighbors()
{
	int i;

	Msg( "Finding displacement neighbors...\n" );

	// Do lightmap alpha.
    g_DispLightmapAlpha.RemoveAll();

	// Build the CCoreDispInfos.
	CUtlVector<dface_t*> faces;

	// Create the core dispinfos and init them for use as CDispUtilsHelpers.
	g_CoreDispInfos.SetSize( nummapdispinfo );
	for ( i=0; i < nummapdispinfo; i++ )
	{
		g_CoreDispInfos[i].SetDispUtilsHelperInfo( g_CoreDispInfos.Base(), nummapdispinfo );
	}

	faces.SetSize( nummapdispinfo );

	for( i = 0; i < numfaces; i++ )
	{
        dface_t *pFace = &dfaces[i];

		if( pFace->dispinfo == -1 )
			continue;

		mapdispinfo_t *pMapDisp = &mapdispinfo[pFace->dispinfo];
		
		// Set the displacement's face index.
		ddispinfo_t *pDisp = &g_dispinfo[pFace->dispinfo];
		pDisp->m_iMapFace = i;

		// Get a CCoreDispInfo. All we need is the triangles and lightmap texture coordinates.
		CCoreDispInfo *pCoreDispInfo = &g_CoreDispInfos[pFace->dispinfo];
		DispMapToCoreDispInfo( pMapDisp, pCoreDispInfo, pFace );
		
		faces[pFace->dispinfo] = pFace;
	}

	
	// Generate and export neighbor data.
	ExportNeighborData( g_CoreDispInfos.Base(), g_dispinfo.Base(), nummapdispinfo );

	// Generate and export the active vert lists.
	ExportAllowedVertLists( g_CoreDispInfos.Base(), g_dispinfo.Base(), nummapdispinfo );

	Msg( "Finding lightmap sample positions...\n" );
	for ( i=0; i < nummapdispinfo; i++ )
	{
		dface_t *pFace = faces[i];
		ddispinfo_t *pDisp = &g_dispinfo[pFace->dispinfo];
		CCoreDispInfo *pCoreDispInfo = &g_CoreDispInfos[i];

		pDisp->m_iLightmapSamplePositionStart = g_DispLightmapSamplePositions.Count();

		CalculateLightmapSamplePositions( 
			pCoreDispInfo, 
			pFace,
			g_DispLightmapSamplePositions );
	}


	StartPacifier( "Displacement Alpha : ");

	// Build lightmap alphas.
	int dispCount = 0;	// How many we've processed.
	for( i = 0; i < nummapdispinfo; i++ )
	{
        dface_t *pFace = faces[i];

		Assert( pFace->dispinfo == i );
		mapdispinfo_t *pMapDisp = &mapdispinfo[pFace->dispinfo];
		ddispinfo_t *pDisp = &g_dispinfo[pFace->dispinfo];

		CCoreDispInfo *pCoreDispInfo = &g_CoreDispInfos[i];

		// Allocate space for the alpha values.
		pDisp->m_iLightmapAlphaStart = g_DispLightmapAlpha.Count();
		int nLuxelsToAdd = (pFace->m_LightmapTextureSizeInLuxels[0]+1) * (pFace->m_LightmapTextureSizeInLuxels[1]+1);
		g_DispLightmapAlpha.AddMultipleToTail( nLuxelsToAdd );

		DispUpdateLightmapAlpha( 
			g_CoreDispInfos.Base(),
			i,
			(float)dispCount     / g_dispinfo.Count(),
			(float)(dispCount+1) / g_dispinfo.Count(),
			pDisp, 
			pFace->m_LightmapTextureSizeInLuxels[0],
			pFace->m_LightmapTextureSizeInLuxels[1] );
	
		++dispCount;
	}

	EndPacifier();
}
Пример #13
0
HRESULT PlayMedia(LPTSTR lpszMovie, HINSTANCE hInstance)
{
    HRESULT hr = S_OK;
    BOOL bSleep=TRUE;

    if (!lpszMovie)
        return E_POINTER;

    // Allow DirectShow to create the FilterGraph for this media file
    hr = pGB->RenderFile(lpszMovie, NULL);
    if (FAILED(hr)) {
        Msg(TEXT("Failed(0x%08lx) in RenderFile(%s)!\r\n"), hr, lpszMovie);
        return hr;
    }

    // Set the message drain of the video window to point to our hidden
    // application window.  This allows keyboard input to be transferred
    // to our main window for processing.
    //
    // If this is an audio-only or MIDI file, then put_MessageDrain will fail.
    //
    hr = pVW->put_MessageDrain((OAHWND) g_hwndMain);
    if (FAILED(hr))
    {
        Msg(TEXT("Failed(0x%08lx) to set message drain for %s.\r\n\r\n")
            TEXT("This sample is designed to play videos, but the file selected ")
            TEXT("has no video component."), hr, lpszMovie);
        return hr;
    }

    // Set fullscreen
    hr = SetFullscreen();
    if (FAILED(hr)) {
        Msg(TEXT("Failed(%08lx) to set fullscreen!\r\n"), hr);
        return hr;
    }

    // Display first frame of the movie
    hr = pMC->Pause();
    if (FAILED(hr)) {
        Msg(TEXT("Failed(%08lx) in Pause()!\r\n"), hr);
        return hr;
    }

    // Start playback
    hr = pMC->Run();
    if (FAILED(hr)) {
        Msg(TEXT("Failed(%08lx) in Run()!\r\n"), hr);
        return hr;
    }

    // Update state variables
    g_bContinue = TRUE;

    // Enter a loop of checking for events and sampling keyboard input
    while (g_bContinue)
    {
        MSG msg;
        long lEventCode;
        LONG_PTR lpParam1, lpParam2;

        // Reset sleep flag
        bSleep = TRUE;

        // Has there been a media event?  Look for end of stream condition.
        if(E_ABORT != pME->GetEvent(&lEventCode, &lpParam1, 
                                    &lpParam2, 0))
        {
            // Is this the end of the movie?
            if (lEventCode == EC_COMPLETE)
            {
                g_bContinue = FALSE;
                bSleep = FALSE;
            }

            // Free the media event resources
            hr = pME->FreeEventParams(lEventCode, lpParam1, lpParam2);
            if (FAILED(hr))
            {
                Msg(TEXT("Failed(%08lx) to free event params (%s)!\r\n"),
                    hr, lpszMovie);
            }
        }

        // Give system threads time to run (and don't sample user input madly)
        if (bSleep)
            Sleep(KEYBOARD_SAMPLE_FREQ);

        // Check and process window messages (like our keystrokes)
        while (PeekMessage (&msg, g_hwndMain, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return hr;
}
Пример #14
0
int EBuffer::Find(SearchReplaceOptions &opt) {
    int slen = strlen(opt.strSearch);
    int Options = opt.Options;
    int rlen = strlen(opt.strReplace);
    RxNode *R = NULL;

    opt.resCount = -1;
    opt.lastInsertLen = 0;

    if (slen == 0) return 0;
    if (Options & SEARCH_BLOCK) {
        if (CheckBlock() == 0) return 0;
    }
    if (Options & SEARCH_RE) {
        R = RxCompile(opt.strSearch);
        if (R == 0) {
            View->MView->Win->Choice(GPC_ERROR, "Find", 1, "O&K", "Invalid regular expression.");
            return 0;
        }
    }
    if (Options & SEARCH_GLOBAL) {
        if (Options & SEARCH_BLOCK) {
            if (Options & SEARCH_BACK) {
                if (SetPosR(BE.Col, BE.Row) == 0) goto error;
            } else {
                if (SetPosR(BB.Col, BB.Row) == 0) goto error;
            }
        } else {
            if (Options & SEARCH_BACK) {
                if (RCount < 1) goto error;
                if (SetPosR(LineLen(RCount - 1), RCount - 1) == 0) goto error;
            } else {
                if (SetPosR(0, 0) == 0) goto error;
            }
        }
    }
    opt.resCount = 0;
    while (1) {
        if (Options & SEARCH_RE) {
            if (FindRx(R, opt) == 0) goto end;
        } else {
            if (FindStr(opt.strSearch, slen, opt) == 0) goto end;
        }
        opt.resCount++;

        if (opt.Options & SEARCH_REPLACE) {
            char ask = 'A';

            if (!(Options & SEARCH_NASK)) {
                char ch;

                while (1) {
                    Draw(VToR(CP.Row), 1);
                    Redraw();
                    switch (View->MView->Win->Choice(0, "Replace",
                                                     5,
                                                     "&Yes",
                                                     "&All",
                                                     "&Once",
                                                     "&Skip",
                                                     "&Cancel",
                                                     "Replace with %s?", opt.strReplace)) {
                    case 0:
                        ch = 'Y';
                        break;
                    case 1:
                        ch = 'A';
                        break;
                    case 2:
                        ch = 'O';
                        break;
                    case 3:
                        ch = 'N';
                        break;
                    case 4:
                    case -1:
                    default:
                        ch = 'Q';
                        break;
                    }
                    if (ch == 'Y') {
                        ask = 'Y';
                        goto ok_rep;
                    }
                    if (ch == 'N') {
                        ask = 'N';
                        goto ok_rep;
                    }
                    if (ch == 'Q') {
                        ask = 'Q';
                        goto ok_rep;
                    }
                    if (ch == 'A') {
                        ask = 'A';
                        goto ok_rep;
                    }
                    if (ch == 'O') {
                        ask = 'O';
                        goto ok_rep;
                    }
                }
ok_rep:
                if (ask == 'N') goto try_join;
                if (ask == 'Q') goto end;
                if (ask == 'A') Options |= SEARCH_NASK;
            }

            if (Options & SEARCH_RE) {
                PELine L = RLine(Match.Row);
                int P, R;
                char *PR = 0;
                int LR = 0;

                R = Match.Row;
                P = Match.Col;
                P = CharOffset(L, P);

                if (0 == RxReplace(opt.strReplace, L->Chars, L->Count, MatchRes, &PR, &LR)) {
                    if (DelText(R, Match.Col, MatchLen) == 0) goto error;
                    if (PR && LR > 0)
                        if (InsText(R, Match.Col, LR, PR) == 0) goto error;
                    if (PR)
                        free(PR);
                    rlen = LR;
                }
            } else {
                if (DelText(Match.Row, Match.Col, MatchLen) == 0) goto error;
                if (InsText(Match.Row, Match.Col, rlen, opt.strReplace) == 0) goto error;

                // Cursor remains at start of inserted string. If there is recursive
                // replace pattern, fte can go it infinite loop.
                // Workaround: Move cursor to end of inserted string
                opt.lastInsertLen = strlen(opt.strReplace);
            }
            if (!(Options & SEARCH_BACK)) {
                MatchLen = rlen;
                MatchCount = rlen;
            }
            if (ask == 'O')
                goto end;
        }

try_join:
        if (Options & SEARCH_JOIN) {
            char ask = 'A';

            if (!(Options & SEARCH_NASK)) {
                char ch;

                while (1) {
                    Draw(VToR(CP.Row), 1);
                    Redraw();
                    switch (View->MView->Win->Choice(0, "Join Line",
                                                     5,
                                                     "&Yes",
                                                     "&All",
                                                     "&Once",
                                                     "&Skip",
                                                     "&Cancel",
                                                     "Join lines %d and %d?", 1 + VToR(CP.Row), 1 + VToR(CP.Row) + 1)) {
                    case 0:
                        ch = 'Y';
                        break;
                    case 1:
                        ch = 'A';
                        break;
                    case 2:
                        ch = 'O';
                        break;
                    case 3:
                        ch = 'N';
                        break;
                    case 4:
                    case -1:
                    default:
                        ch = 'Q';
                        break;
                    }
                    if (ch == 'Y') {
                        ask = 'Y';
                        goto ok_join;
                    }
                    if (ch == 'N') {
                        ask = 'N';
                        goto ok_join;
                    }
                    if (ch == 'Q') {
                        ask = 'Q';
                        goto ok_join;
                    }
                    if (ch == 'A') {
                        ask = 'A';
                        goto ok_join;
                    }
                    if (ch == 'O') {
                        ask = 'O';
                        goto ok_join;
                    }
                }
ok_join:
                if (ask == 'N') goto try_split;
                if (ask == 'Q') goto end;
                if (ask == 'A') Options |= SEARCH_NASK;
            }

            if (JoinLine(Match.Row, Match.Col) == 0) goto error;

            if (ask == 'O')
                goto end;
        }

try_split:
            if (Options & SEARCH_SPLIT) {
                char ask = 'A';

                if (!(Options & SEARCH_NASK)) {
                    char ch;

                    while (1) {
                        Draw(VToR(CP.Row), 1);
                        Redraw();
                        switch(View->MView->Win->Choice(0, "Split Line",
                                                        5,
                                                        "&Yes",
                                                        "&All",
                                                        "&Once",
                                                        "&Skip",
                                                        "&Cancel",
                                                        "Split line %d?", VToR(CP.Row)))
                        {
                        case 0:
                            ch = 'Y';
                            break;

                        case 1:
                            ch = 'A';
                            break;

                        case 2:
                            ch = 'O';
                            break;

                        case 3:
                            ch = 'S';
                            break;

                        case 4:
                        case -1:
                        default:
                            ch = 'Q';
                            break;
                        }

                        if (ch == 'Y') {
                            ask = 'Y';
                            goto ok_split;
                        }
                        else if (ch == 'N') {
                            ask = 'N';
                            goto ok_split;
                        }
                        else if (ch == 'Q') {
                            ask = 'Q';
                            goto ok_split;
                        }
                        else if (ch == 'A') {
                            ask = 'A';
                            goto ok_split;
                        }
                        else if (ch == 'O') {
                            ask = 'O';
                            goto ok_split;
                        }
                    }
ok_split:
                    if (ask == 'N') goto try_delete;
                    if (ask == 'Q') goto end;
                    if (ask == 'A') Options |= SEARCH_NASK;
                }

                if (SplitLine(Match.Row, Match.Col + strlen(opt.strReplace)) == 0)
                    goto error;

                if (ask == 'O')
                    goto end;
            }

try_delete:
            if (Options & SEARCH_DELETE) {
                char ask = 'A';

            if (!(Options & SEARCH_NASK)) {
                char ch;

                while (1) {
                    Draw(VToR(CP.Row), 1);
                    Redraw();
                    switch (View->MView->Win->Choice(0, "Delete Line",
                                                     5,
                                                     "&Yes",
                                                     "&All",
                                                     "&Once",
                                                     "&Skip",
                                                     "&Cancel",
                                                     "Delete line %d?", VToR(CP.Row))) {
                    case 0:
                        ch = 'Y';
                        break;
                    case 1:
                        ch = 'A';
                        break;
                    case 2:
                        ch = 'O';
                        break;
                    case 3:
                        ch = 'N';
                        break;
                    case 4:
                    case -1:
                    default:
                        ch = 'Q';
                        break;
                    }
                    if (ch == 'Y') {
                        ask = 'Y';
                        goto ok_delete;
                    }
                    if (ch == 'N') {
                        ask = 'N';
                        goto ok_delete;
                    }
                    if (ch == 'Q') {
                        ask = 'Q';
                        goto ok_delete;
                    }
                    if (ch == 'A') {
                        ask = 'A';
                        goto ok_delete;
                    }
                    if (ch == 'O') {
                        ask = 'O';
                        goto ok_delete;
                    }
                }
ok_delete:
                if (ask == 'N') goto next;
                if (ask == 'Q') goto end;
                if (ask == 'A') Options |= SEARCH_NASK;
            }

            if (Match.Row == RCount - 1) {
                if (DelText(Match.Row, 0, LineLen()) == 0) goto error;
            } else
                if (DelLine(Match.Row) == 0) goto error;

            if (ask == 'O')
                goto end;
            if (!(Options & SEARCH_ALL))
                break;
            goto last;
        }
next:
        if (!(Options & SEARCH_ALL))
            break;
        Options |= SEARCH_NEXT;
last:
        ;
    }
end:
    // end of search
    if (R)
        RxFree(R);

    if (Options & SEARCH_ALL)
        Msg(S_INFO, "%d match(es) found.", opt.resCount);
    else {
        if (opt.resCount == 0) {
            Msg(S_INFO, "[%s] not found", opt.strSearch);
            return 0;
        }
    }
    return 1;
error:

    if (R) {
        RxFree(R);
    }
    View->MView->Win->Choice(GPC_ERROR, "Find", 1, "O&K", "Error in search/replace.");
    return 0;
}
Пример #15
0
// Print Data Functions
void
V3SvrBoolector::printInfo() const {
   Msg(MSG_IFO) << "#Ref = " << boolector_get_refs(_Solver) << ", "
                << "#SV = " << totalSolves() << ", AccT = " << totalTime();
}
void CASW_Mission_Chooser_Source_Local::AddToSavedCampaignList(const char *szSaveName)
{
	// find out what campaign this save is for
	char szFullFileName[256];
	Q_snprintf(szFullFileName, sizeof(szFullFileName), "save/%s", szSaveName);
	KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, szFullFileName))
	{
		const char *pCampaignName = pSaveKeyValues->GetString("CampaignName");
		// check the campaign exists
		char tempfile[MAX_PATH];
		Q_snprintf( tempfile, sizeof( tempfile ), "resource/campaigns/%s.txt", pCampaignName );
		if (g_pFullFileSystem->FileExists(tempfile))
		{
			ASW_Mission_Chooser_Saved_Campaign item;
			Q_snprintf(item.m_szSaveName, sizeof(item.m_szSaveName), "%s", szSaveName);
			Q_snprintf(item.m_szCampaignName, sizeof(item.m_szCampaignName), "%s", pCampaignName);
			Q_snprintf(item.m_szDateTime, sizeof(item.m_szDateTime), "%s", pSaveKeyValues->GetString("DateTime"));
			//Msg("save %s multiplayer %d\n", szSaveName, pSaveKeyValues->GetInt("Multiplayer"));
			item.m_bMultiplayer = (pSaveKeyValues->GetInt("Multiplayer") > 0);
			//Msg("item multiplayer = %d\n", item.m_bMultiplayer);

			// check subsections for player names and player IDs, concat them into two strings
			char namebuffer[256];
			char idbuffer[512];
			namebuffer[0] = '\0';
			idbuffer[0] = '\0';
			int namepos = 0;
			int idpos = 0;
			KeyValues *pkvSubSection = pSaveKeyValues->GetFirstSubKey();
			while ( pkvSubSection )
			{
				if ((Q_stricmp(pkvSubSection->GetName(), "PLAYER")==0) && namepos < 253)
				{
					const char *pName = pkvSubSection->GetString("PlayerName");
					if (pName && pName[0] != '\0')
					{
						int namelength = Q_strlen(pName);
						for (int charcopy=0; charcopy<namelength && namepos<253; charcopy++)
						{
							namebuffer[namepos] = pName[charcopy];
							namepos++;
						}
						namebuffer[namepos] = ' '; namepos++;
						namebuffer[namepos] = '\0';
					}
				}
				if ((Q_stricmp(pkvSubSection->GetName(), "DATA")==0) && idpos < 253)
				{
					const char *pID = pkvSubSection->GetString("DataBlock");
					if (pID && pID[0] != '\0')
					{
						int idlength = Q_strlen(pID);
						for (int charcopy=0; charcopy<idlength && idpos<253; charcopy++)
						{
							idbuffer[idpos] = pID[charcopy];
							idpos++;
						}
						idbuffer[idpos] = ' '; idpos++;
						idbuffer[idpos] = '\0';
					}
				}
				pkvSubSection = pkvSubSection->GetNextKey();
			}
			Q_snprintf(item.m_szPlayerNames, sizeof(item.m_szPlayerNames), "%s", namebuffer);
			Q_snprintf(item.m_szPlayerIDs, sizeof(item.m_szPlayerIDs), "%s", idbuffer);
			item.m_iMissionsComplete = pSaveKeyValues->GetInt("NumMissionsComplete");
			m_SavedCampaignList.Insert( item );
		}
	}
	pSaveKeyValues->deleteThis();

	// check if there's now too many save games
	int iNumMultiplayer = GetNumSavedCampaigns(true, NULL);
	if (iNumMultiplayer > asw_max_saves.GetInt())
	{
		// find the oldest one
		ASW_Mission_Chooser_Saved_Campaign* pChosen = false;
		int iChosen = -1;
		for (int i=m_SavedCampaignList.Count()-1; i>=0; i--)
		{
			if (m_SavedCampaignList[i].m_bMultiplayer)
			{
				pChosen = &m_SavedCampaignList[i];
				iChosen = i;
				break;
			}			
		}
		// delete if found
		if (iChosen != -1 && pChosen)
		{
			char buffer[MAX_PATH];
			Q_snprintf(buffer, sizeof(buffer), "save/%s", pChosen->m_szSaveName);
			Msg("Deleting save %s as we have too many\n", buffer);
			g_pFullFileSystem->RemoveFile( buffer, "GAME" );
			m_SavedCampaignList.Remove(iChosen);
		}
	}
}
Пример #17
0
void FindConPrintf(void)
{
	ConCommandBase *pBase = NULL;
	unsigned char *ptr = NULL;

#ifdef GAME_ORANGE
	FnCommandCallback_t callback = NULL;
#else
	FnCommandCallback callback = NULL;
#endif

	int offs = 0;

#if !defined ( GAME_CSGO )
	pBase = g_pCVar->GetCommands();
	while (pBase)
	{
		if ( strcmp(pBase->GetName(), "echo") == 0 )
		{
			//callback = //*((FnCommandCallback *)((char *)pBase + offsetof(ConCommand, m_fnCommandCallback)));
			callback = ((ConCommand *)pBase)->m_fnCommandCallback;
			ptr = (unsigned char *)callback;
			if (vcmp(ptr, ENGINE486_SIG, SIGLEN))
			{
				offs = ENGINE486_OFFS;
			} else if (vcmp(ptr, ENGINE686_SIG, SIGLEN)) {
				offs = ENGINE686_OFFS;
			} else if (vcmp(ptr, ENGINEAMD_SIG, SIGLEN)) {
				offs = ENGINEAMD_OFFS;
			} else if (vcmp(ptr, ENGINEW32_SIG, SIGLEN)) {
				offs = ENGINEW32_OFFS;
			}
			if (!offs || ptr[offs-1] != IA32_CALL)
			{
				return;
			}
			//get the relative offset
			MMsg = *((CONPRINTF_FUNC *)(ptr + offs));
			//add the base offset, to the ip (which is the address+offset + 4 bytes for next instruction)
			MMsg = (CONPRINTF_FUNC)((unsigned long)MMsg + (unsigned long)(ptr + offs) + 4);
			Msg("Using conprintf\n");
			return;
		}
		pBase = const_cast<ConCommandBase *>(pBase->GetNext());
	}
#else
	pBase = g_pCVar->FindCommand("echo");
	callback = ((ConCommand *)pBase)->m_fnCommandCallback;
	ptr = (unsigned char *)callback;
	if (vcmp(ptr, ENGINE486_SIG, SIGLEN))
	{
		offs = ENGINE486_OFFS;
	} else if (vcmp(ptr, ENGINE686_SIG, SIGLEN)) {
		offs = ENGINE686_OFFS;
	} else if (vcmp(ptr, ENGINEAMD_SIG, SIGLEN)) {
		offs = ENGINEAMD_OFFS;
	} else if (vcmp(ptr, ENGINEW32_SIG, SIGLEN)) {
		offs = ENGINEW32_OFFS;
	}
	if (!offs || ptr[offs-1] != IA32_CALL)
	{
		return;
	}
	//get the relative offset
	MMsg = *((CONPRINTF_FUNC *)(ptr + offs));
	//add the base offset, to the ip (which is the address+offset + 4 bytes for next instruction)
	MMsg = (CONPRINTF_FUNC)((unsigned long)MMsg + (unsigned long)(ptr + offs) + 4);
	Msg("Using conprintf\n");
	return;

#endif

	Msg("Using Msg()\n");
	MMsg = (CONPRINTF_FUNC)Msg;
	return;

}
bool CASW_Mission_Chooser_Source_Local::ASW_Campaign_CreateNewSaveGame(char *szFileName, int iFileNameMaxLen, const char *szCampaignName, bool bMultiplayerGame, const char *szStartingMission)	// szFileName arg is the desired filename or NULL for an autogenerated one.  Function sets szFileName with the filename used.
{
	if (!szFileName)
		return false;

	char stripped[MAX_PATH];
	V_StripExtension( szCampaignName, stripped, MAX_PATH );

	char szStartingMissionStripped[64];
	if ( szStartingMission )
	{
		V_StripExtension( szStartingMission, szStartingMissionStripped, sizeof( szStartingMissionStripped ) );
	}
	else
	{
		szStartingMissionStripped[0] = 0;
	}

	// check the campaign file exists
	char campbuffer[MAX_PATH];
	Q_snprintf(campbuffer, sizeof(campbuffer), "resource/campaigns/%s.txt", stripped);
	if (!g_pFullFileSystem->FileExists(campbuffer))
	{
		Msg("No such campaign: %s\n", campbuffer);
		return false;
	}

	// Get the current time and date as a string
	char szDateTime[256];
	int year, month, dayOfWeek, day, hour, minute, second;
	ASW_System_GetCurrentTimeAndDate(&year, &month, &dayOfWeek, &day, &hour, &minute, &second);
	Q_snprintf(szDateTime, sizeof(szDateTime), "%02d/%02d/%02d %02d:%02d", month, day, year, hour, minute);

	if (szFileName[0] == '\0')
	{
		// autogenerate a filename based on the current time and date
		Q_snprintf(szFileName, iFileNameMaxLen, "%s_save_%02d_%02d_%02d_%02d_%02d_%02d", stripped, year, month, day, hour, minute, second);
	}

	// make sure the path and extension are correct
	Q_SetExtension( szFileName, ".campaignsave", iFileNameMaxLen );
	char tempbuffer[256];
	Q_snprintf(tempbuffer, sizeof(tempbuffer), "%s", szFileName);
	const char *pszNoPathName = Q_UnqualifiedFileName(tempbuffer);
	Msg("Unqualified = %s\n", pszNoPathName);
	char szFullFileName[256];
	Q_snprintf(szFullFileName, sizeof(szFullFileName), "save/%s", pszNoPathName);
	Msg("Creating new save with filename: %s\n", szFullFileName);

	KeyValues *pSaveKeyValues = new KeyValues( pszNoPathName );

	int nMissionsComplete = 0;
	if ( szStartingMission && szStartingMission[0] )
	{
		KeyValues *pCampaignDetails = GetCampaignDetails( stripped );
		if ( pCampaignDetails )
		{
			int nMissionSections = 0;
			for ( KeyValues *pMission = pCampaignDetails->GetFirstSubKey(); pMission; pMission = pMission->GetNextKey() )
			{
				if ( !Q_stricmp( pMission->GetName(), "MISSION" ) )
				{
					if ( !Q_stricmp( pMission->GetString( "MapName", "" ), szStartingMissionStripped ) )
					{
						nMissionsComplete = nMissionSections - 1;		// skip first dummy mission
						break;
					}
					nMissionSections++;
				}
			}
		}
	}
	
	pSaveKeyValues->SetInt("Version", ASW_CURRENT_SAVE_VERSION);
	pSaveKeyValues->SetString("CampaignName", stripped);
	pSaveKeyValues->SetInt("CurrentPosition", nMissionsComplete + 1);		// position squad on the first uncompleted mission
	pSaveKeyValues->SetInt("NumMissionsComplete", nMissionsComplete);
	pSaveKeyValues->SetInt("InitialNumMissionsComplete", nMissionsComplete);
	pSaveKeyValues->SetInt("Multiplayer", bMultiplayerGame ? 1 : 0);
	pSaveKeyValues->SetString("DateTime", szDateTime);
	pSaveKeyValues->SetInt("NumPlayers", 0);	
	
	// write out each mission's status
	KeyValues *pSubSection;
	for (int i=0; i<ASW_MAX_MISSIONS_PER_CAMPAIGN; i++)
	{
		pSubSection = new KeyValues("MISSION");
		pSubSection->SetInt("MissionID", i);
		bool bComplete = ( i != 0 ) && ( i <= nMissionsComplete );
		pSubSection->SetInt("MissionComplete", bComplete ? 1 : 0 );
		pSaveKeyValues->AddSubKey(pSubSection);
	}

	const int nInitialSkillPoints = 0;

	// write out each marine's stats
	for (int i=0; i<ASW_NUM_MARINE_PROFILES; i++)
	{
		pSubSection = new KeyValues("MARINE");
		pSubSection->SetInt("MarineID", i);
		pSubSection->SetInt("SkillSlot0", 0);
		pSubSection->SetInt("SkillSlot1", 0);
		pSubSection->SetInt("SkillSlot2", 0);
		pSubSection->SetInt("SkillSlot3", 0);
		pSubSection->SetInt("SkillSlot4", 0);
		
		pSubSection->SetInt("SkillSlotSpare", nInitialSkillPoints + nMissionsComplete * ASW_SKILL_POINTS_PER_MISSION );

		pSubSection->SetInt("UndoSkillSlot0", 0);
		pSubSection->SetInt("UndoSkillSlot1", 0);
		pSubSection->SetInt("UndoSkillSlot2", 0);
		pSubSection->SetInt("UndoSkillSlot3", 0);
		pSubSection->SetInt("UndoSkillSlot4", 0);
		
		pSubSection->SetInt("UndoSkillSlotSpare", nInitialSkillPoints + nMissionsComplete * ASW_SKILL_POINTS_PER_MISSION );
		pSubSection->SetString("MissionsCompleted", "");
		pSubSection->SetString("Medals", "");
		pSubSection->SetInt("Wounded", 0);
		pSubSection->SetInt("Dead", 0);
		pSubSection->SetInt("ParasitesKilled", 0);
		pSaveKeyValues->AddSubKey(pSubSection);
	}
	// players section is empty at first 

	// Create the save sub-directory
	if (!g_pFullFileSystem->IsDirectory( "save", "MOD" ))
	{
		g_pFullFileSystem->CreateDirHierarchy( "save", "MOD" );
	}

	// save it
	if (pSaveKeyValues->SaveToFile(g_pFullFileSystem, szFullFileName))
	{
		// make sure our save summary list adds this to it, if needed
		Msg("New save created: %s\n", szFullFileName);
		NotifyNewSave(pszNoPathName);
		return true;
	}
	Msg("Save to file failed. Filename=%s\n", szFullFileName);
	return false;
}
Пример #19
0
//-----------------------------------------------------------------------------
// Generates a single suggestion
//-----------------------------------------------------------------------------
bool CAI_PlaneSolver::GenerateCircleObstacleSuggestion( const CircleObstacles_t &obstacle, 
	const AILocalMoveGoal_t &moveGoal, float probeDist, const Vector& npcLoc, float radiusNpc )
{
	CBaseEntity *pObstacleEntity = NULL;

	float zDistTooFar;
	if ( obstacle.hEntity && obstacle.hEntity->CollisionProp() )
	{
		pObstacleEntity = obstacle.hEntity.Get();

		// HEY! I'm trying to avoid the very thing I'm trying to get to. This will make we wobble like a drunk as I approach. Don't do it.
		if( pObstacleEntity == moveGoal.pMoveTarget && (pObstacleEntity->IsNPC() || pObstacleEntity->IsPlayer()) )
			return false;

		Vector mins, maxs;
		pObstacleEntity->CollisionProp()->WorldSpaceSurroundingBounds( &mins, &maxs );
		zDistTooFar = ( maxs.z - mins.z ) * 0.5 + GetNpc()->GetHullHeight() * 0.5;
	}
	else
	{
		zDistTooFar = GetNpc()->GetHullHeight();
	}

	if ( fabs( obstacle.center.z - npcLoc.z ) > zDistTooFar )
		return false;

	Vector vecToNpc = npcLoc - obstacle.center;
	vecToNpc.z = 0;
	float distToObstacleSq = sq(vecToNpc.x) + sq(vecToNpc.y);
	float radius = obstacle.radius + radiusNpc;

	if ( distToObstacleSq <= 0.001 || distToObstacleSq >= sq( radius + probeDist ) )
		return false;

	Vector vecToObstacle = vecToNpc * -1;
	float distToObstacle = VectorNormalize( vecToObstacle );
	float weight;
	float arc;
	float radiusSq = sq(radius);

	float flDot = DotProduct( vecToObstacle, moveGoal.dir );

	// Don't steer around to avoid obstacles we've already passed, unless we're right up against them.
	// That is, do this computation without the probeDist added in.
	if( flDot < 0.0f && distToObstacleSq > radiusSq )
		return false;

	if ( radiusSq < distToObstacleSq )
	{
		Vector vecTangent;
		float distToTangent = FastSqrt( distToObstacleSq - radiusSq );

		float oneOverDistToObstacleSq = 1 / distToObstacleSq;

		vecTangent.x = ( -distToTangent * vecToNpc.x + radius * vecToNpc.y ) * oneOverDistToObstacleSq;
		vecTangent.y = ( -distToTangent * vecToNpc.y - radius * vecToNpc.x ) * oneOverDistToObstacleSq;
		vecTangent.z = 0;

		float cosHalfArc = vecToObstacle.Dot( vecTangent );
		arc = RAD2DEG(acosf( cosHalfArc )) * 2.0;
		weight = 1.0 - (distToObstacle - radius) / probeDist;
		if ( weight > 0.75 )
		{
			arc += (arc * 0.5) * (weight - 0.75) / 0.25;
		}

		Assert( weight >= 0.0 && weight <= 1.0 );

#if DEBUG_OBSTACLES
		// -------------------------
		Msg( "Adding arc %f, w %f\n", arc, weight );

		Vector pointTangent = npcLoc + ( vecTangent * distToTangent );

		NDebugOverlay::Line( npcLoc - Vector( 0, 0, 64 ), npcLoc + Vector(0,0,64), 0,255,0, false, 0.1 );
		NDebugOverlay::Line( center - Vector( 0, 0, 64 ), center + Vector(0,0,64), 0,255,0, false, 0.1 );
		NDebugOverlay::Line( pointTangent - Vector( 0, 0, 64 ), pointTangent + Vector(0,0,64), 0,255,0, false, 0.1 );

		NDebugOverlay::Line( npcLoc + Vector(0,0,64), center + Vector(0,0,64), 0,0,255, false, 0.1 );
		NDebugOverlay::Line( center + Vector(0,0,64), pointTangent + Vector(0,0,64), 0,0,255, false, 0.1 );
		NDebugOverlay::Line( pointTangent + Vector(0,0,64), npcLoc + Vector(0,0,64), 0,0,255, false, 0.1 );
#endif
	}
	else
	{
		arc = 210;
		weight = 1.0;
	}

	if ( obstacle.hEntity != NULL )
	{
		weight = AdjustRegulationWeight( obstacle.hEntity, weight );
	}

	AI_MoveSuggestion_t suggestion( obstacle.type, weight, UTIL_VecToYaw(vecToObstacle), arc );
	m_Solver.AddRegulation( suggestion );
	return true;
}
Пример #20
0
//-----------------------------------------------------------------------------
// Purpose: Upon touching a non-filtered entity, CTriggerPortal teleports them to it's
//			remote portal location.
// Input  : *pOther - 
//-----------------------------------------------------------------------------
void CTriggerPortal::Touch( CBaseEntity *pOther )
{
	// If we are enabled, and allowed to react to the touched entity
	if ( PassesTriggerFilters(pOther) )
	{
		// If we somehow lost our pointer to the remote portal, get a new one
		if ( m_hRemotePortal == NULL )
		{
			Disable();
			return;
		}

		bool bDebug = portal_debug.GetBool();
		if ( bDebug )
		{
			Msg("%s TOUCH: for %s\n", GetDebugName(), pOther->GetDebugName() );
		}

		// Don't touch entities that came through us and haven't left us yet.
		EHANDLE hHandle;
		hHandle = pOther;
		if ( m_hDisabledForEntities.Find(hHandle) != m_hDisabledForEntities.InvalidIndex() )
		{
			Msg("    IGNORED\n", GetDebugName(), pOther->GetDebugName() );
			return;
		}

		Pickup_ForcePlayerToDropThisObject( pOther );

		// de-ground this entity
        pOther->SetGroundEntity( NULL );

		// Build a this --> remote transformation
		VMatrix matMyModelToWorld, matMyInverse;
		matMyModelToWorld = this->EntityToWorldTransform();
		MatrixInverseGeneral ( matMyModelToWorld, matMyInverse );

		// Teleport our object
		VMatrix matRemotePortalTransform = m_hRemotePortal->EntityToWorldTransform();
		Vector ptNewOrigin, vLook, vRight, vUp, vNewLook;
		pOther->GetVectors( &vLook, &vRight, &vUp );

		// Move origin
		ptNewOrigin = matMyInverse * pOther->GetAbsOrigin();
		ptNewOrigin = matRemotePortalTransform * Vector( ptNewOrigin.x, -ptNewOrigin.y, ptNewOrigin.z );

		// Re-aim camera
		vNewLook	= matMyInverse.ApplyRotation( vLook );
		vNewLook	= matRemotePortalTransform.ApplyRotation( Vector( -vNewLook.x, -vNewLook.y, vNewLook.z ) );

		// Reorient the physics
	 	Vector vVelocity, vOldVelocity;
		pOther->GetVelocity( &vOldVelocity );
		vVelocity = matMyInverse.ApplyRotation( vOldVelocity );
		vVelocity = matRemotePortalTransform.ApplyRotation( Vector( -vVelocity.x, -vVelocity.y, vVelocity.z ) );

		QAngle qNewAngles;
		VectorAngles( vNewLook, qNewAngles );
		
		if ( pOther->IsPlayer() )
		{
			((CBasePlayer*)pOther)->SnapEyeAngles(qNewAngles);
		}

		Vector vecOldPos = pOther->WorldSpaceCenter();
		if ( bDebug )
		{
			NDebugOverlay::Box( pOther->GetAbsOrigin(), pOther->WorldAlignMins(), pOther->WorldAlignMaxs(), 255,0,0, 8, 20 );
			NDebugOverlay::Axis( pOther->GetAbsOrigin(), pOther->GetAbsAngles(), 10.0f, true, 50 );
		}

		// place player at the new destination
		CTriggerPortal *pPortal = m_hRemotePortal.Get();
		pPortal->DisableForIncomingEntity( pOther );
		pOther->Teleport( &ptNewOrigin, &qNewAngles, &vVelocity );

		if ( bDebug )
		{
			NDebugOverlay::Box( pOther->GetAbsOrigin(), pOther->WorldAlignMins(), pOther->WorldAlignMaxs(), 0,255,0, 8, 20 );
			NDebugOverlay::Line( vecOldPos, pOther->WorldSpaceCenter(), 0,255,0, true, 20 );
			NDebugOverlay::Axis( pOther->GetAbsOrigin(), pOther->GetAbsAngles(), 10.0f, true, 50 );

			Msg("%s TELEPORTED: %s\n", GetDebugName(), pOther->GetDebugName() );
		}

		// test collision on the new teleport location
		Vector vMin, vMax, vCenter;
		pOther->CollisionProp()->WorldSpaceAABB( &vMin, &vMax );
		vCenter = (vMin + vMax) * 0.5f;
		vMin -= vCenter;
		vMax -= vCenter;

		Vector vStart, vEnd;
		vStart	= ptNewOrigin;
		vEnd	= ptNewOrigin;

		Ray_t ray;
		ray.Init( vStart, vEnd, vMin, vMax );
		trace_t tr;
		pPortal->TestCollision( ray, pOther->PhysicsSolidMaskForEntity(), tr );

		// Teleportation caused us to hit something, deal with it.
		if ( tr.DidHit() )
		{
			
		}

		
	}
}
Пример #21
0
int PASCAL wWinMain(HINSTANCE hInstC, HINSTANCE hInstP, wchar_t * lpCmdLine, int nCmdShow)
{
    MSG msg={0};
    WNDCLASS wc;

    // Initialize COM
    if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
    {
        Msg(TEXT("CoInitialize Failed!\r\n"));
        return FALSE;
    }

    // Verify that the VMR is present on this system
    if(!VerifyVMR9())
        return FALSE;

    // Was a filename specified on the command line?
    if(lpCmdLine[0] != '\0')
    {
        (void)StringCchCopy(g_szFileName, NUMELMS(g_szFileName), lpCmdLine);        
    }

    // Register the window class
    ZeroMemory(&wc, sizeof wc);
    ghInst = wc.hInstance = hInstC;
    wc.lpfnWndProc   = WndMainProc;
    wc.lpszClassName = CLASSNAME;
    wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hIcon         = NULL;
    if(!RegisterClass(&wc))
    {
        Msg(TEXT("RegisterClass Failed! Error=0x%x\r\n"), GetLastError());
        CoUninitialize();
        exit(1);
    }

    // Create the main window.  The WS_CLIPCHILDREN style is required.
    ghApp = CreateWindow(CLASSNAME, APPLICATIONNAME,
                         WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE,
                         CW_USEDEFAULT, CW_USEDEFAULT,
                         DEFAULT_PLAYER_WIDTH, DEFAULT_PLAYER_HEIGHT,
                         0, 0, ghInst, 0);

    if(ghApp)
    {
        // Save menu handle for later use
        ghMenu = GetMenu(ghApp);
        EnableTickerMenu(FALSE);

        // Set default dynamic text if user wants to display dynamic text
        // instead of a static bitmap image
        (void)StringCchCopy(g_szAppText, NUMELMS(g_szAppText), BLEND_TEXT);
        g_dwTickerFlags = DEFAULT_MARK;

        // If a media file was specified on the command line, open it now.
        // (If the first character in the string isn't NULL, post an open clip message.)
        if (g_szFileName[0] != 0)
            PostMessage(ghApp, WM_COMMAND, ID_FILE_INITCLIP, 0);

        // Main message loop
        while(GetMessage(&msg,NULL,0,0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    else
    {
        Msg(TEXT("Failed to create the main window! Error=0x%x\r\n"), GetLastError());
    }

    // Finished with COM
    CoUninitialize();

    return (int) msg.wParam;
}
Пример #22
0
int main(int argc, char *argv[]){
	// Window Main(argc, argv);
	Json Settings("../settings/heatmap.json");
	Message Msg("en");

	int i, j, k, m;
	char drop, buf[3];
	char string[1000];
	FILE *open;
	struct one_pixel *rawdata;
	struct {
		int byte_per_line;
		int block;
		int byte_per_pixel[2];
		char theme[100];
		struct rgb base;
	}setting;

	struct specification{
		long code;
		struct rgb color;
	};

	struct range{
		long begin;
		long end;
		struct rgb color;
	};

	struct {
		int num;
		struct specification *list;
	}specification_data;

	struct {
		int num;
		struct range *list;
	}range_data;

	// Loading Setting
	setting.byte_per_line = atoi( Settings.get("settings.block_per_line")->value );
	setting.block = atoi( Settings.get("settings.block")->value );

	setting.byte_per_pixel[0] = atoi( Settings.get("settings.block_per_pixel.width")->value );
	setting.byte_per_pixel[1] = atoi( Settings.get("settings.block_per_pixel.height")->value );

	strcpy( setting.theme, Settings.get("settings.default_theme")->value );
	color( &setting.base, Settings.get("settings.campus_color")->value );

	// Loading Theme
	sprintf(string, "../themes/%s.json", setting.theme);
	open = fopen(string, "r");
	if(!open){
		Msg.show(2);
		sprintf(string, "../themes/%s.json", setting.theme);
	}else{
		fclose(open);
	}

	Json Theme(string);

	// Default
	struct rgb theme_default;
	color( &theme_default, Theme.get("default")->value );

	// Specification
	specification_data.num = Theme.array_range("specification");

	specification_data.list = (struct specification *)calloc(specification_data.num, sizeof(struct specification));
	if(!specification_data.list)
		Msg.show(3);

	for(i=0; i<specification_data.num; i++){
		// Clear Buffer
		for(j=0; j<1000; j++)
			string[j] = 0x00;

		color( &specification_data.list[i].color, gcat(&Msg, Theme.get( gstr(string, "specification", i, "color") ))->value );
		specification_data.list[i].code = strtol( gcat(&Msg, Theme.get( gstr(string, "specification", i, "addr") ))->value, NULL, 16 );
	}

	// Range
	range_data.num = Theme.array_range("range");
	range_data.list = (struct range *)calloc(range_data.num, sizeof(struct range));
	if(!range_data.list)
		Msg.show(3);

	for(i=0; i<range_data.num; i++){
		// Clear Buffer
		for(j=0; j<1000; j++)
			string[j] = 0x00;

		color( &range_data.list[i].color, gcat(&Msg, Theme.get( gstr(string, "range", i, "color") ))->value );
		range_data.list[i].begin = strtol( Theme.get( gstr(string, "range", i, "begin") )->value, NULL, 16 );
		range_data.list[i].end = strtol( Theme.get( gstr(string, "range", i, "end") )->value, NULL, 16 );
	}

	// Prepare
	long buffer;
	int image_width = setting.byte_per_pixel[0] * setting.byte_per_line;
	int image_size = -1, image_height;

	open = fopen("../bin/main", "rb");
	if(!open)
		Msg.show(5);

	while(!feof(open)){
		fread(&buffer, (size_t)setting.block , (size_t)1, open);
		image_size++;
	}

	image_height = setting.byte_per_pixel[1] * ((image_size / setting.byte_per_line) + 1);

	rawdata = (struct one_pixel *)calloc(image_width * image_height, sizeof(struct one_pixel));
	if(!rawdata)
		Msg.show(3);


	rewind( open );

	struct rgb *line;
	line = (struct rgb *)calloc(setting.byte_per_line, sizeof(struct rgb));
	if(!line)
		Msg.show(3);

	int cur_line = 0;
	long size_pointer = 0;

	for(j=0; j<setting.byte_per_line; j++)
		line[j] = setting.base;

	int debug = 0;
	bool break_flag = false;
	while(!feof(open)){
		buffer = 0x20;
		if(fread(&buffer, (size_t)setting.block, (size_t)1, open) != 1)
			break_flag = true;

		if(!break_flag){
			// printf("%d (%d) %s\n", debug, cur_line, "Write!");
			debug++;

			// Default Color
			line[cur_line] = theme_default;

			// Range
			for(j=0; j<range_data.num; j++){
				if(buffer >= range_data.list[j].begin && buffer <= range_data.list[j].end){
					line[cur_line] = range_data.list[j].color;
					break;
				}
			}

			// Specification
			for(j=0; j<specification_data.num; j++){
				if( buffer == specification_data.list[j].code ){
					line[cur_line] = specification_data.list[j].color;
					break;
				}
			}
		}

		if(cur_line >= setting.byte_per_line - 1 || break_flag){
			// Height
			for(j=0; j<setting.byte_per_pixel[1]; j++){
				// Dots
				for(m=0; m<setting.byte_per_line; m++){
					for(k=0; k<setting.byte_per_pixel[0]; k++){
						rgb_one_pixel(&line[m], &rawdata[size_pointer]);
						size_pointer++;
					}
				}
			}

			for(j=0; j<setting.byte_per_line; j++)
				line[j] = setting.base;

			cur_line = 0;
		}else{
			cur_line++;
		}
	}

	fclose( open );

	Window Main(argc, argv, image_width, image_height, 24, rawdata);	
	Bitmap Img(&Msg, "../test_2.bmp", image_width, image_height, 24, rawdata);

	// char drop;

	struct color_set{
		char key;
	};

	// while(TRUE){
	// 	scanf("%c", &drop);

	// 	printf("%c", drop);
	// }

	return 0;
}
void CASW_Flamer_Projectile::CollideThink()
{
	if (gpGlobals->curtime >= m_fDieTime)
	{
		SUB_Remove();
		return;
	}

	SetNextThink( gpGlobals->curtime + 0.1f );

	if (m_vecOldPos == vec3_origin)
		m_vecOldPos = GetAbsOrigin();

	trace_t tr;
	UTIL_TraceLine(GetAbsOrigin(), m_vecOldPos, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );
	bool bHit = false;
	if (tr.fraction != 1.0)
	{
		if (tr.m_pEnt && !dynamic_cast<CASW_Flamer_Projectile*>(tr.m_pEnt))
		{
			//Msg("Flamer projectile CollideThinked %s\n", tr.m_pEnt->GetClassname());		
			FlameHit(tr.m_pEnt, tr.endpos, false);
			bHit = true;

			if (asw_flamer_debug.GetBool())
				NDebugOverlay::Cross3D(tr.endpos, 10, 0, 0, 255, true, 10.0f);
		}
	}
	// scan for setting on fire nearby NPCs
	if (!bHit)
	{
		trace_t tr;
		Ray_t ray;
		CTraceFilterAliensEggsGoo filter( this, COLLISION_GROUP_NONE );				
		//UTIL_TraceHull(GetAbsOrigin(), GetAbsOrigin() + Vector(0,0,1), ASW_FLAMER_HULL_MINS, ASW_FLAMER_HULL_MAXS, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr); 
		float size_scale = 0.5f + 0.5f * (1.0f - clamp<float>(m_fDieTime - gpGlobals->curtime, 0.0f, 1.0f));	// NOTE: assumes 1.0 lifetime
		ray.Init( GetAbsOrigin(), m_vecOldPos, ASW_FLAMER_HULL_MINS * size_scale, ASW_FLAMER_HULL_MAXS * size_scale );
		enginetrace->TraceRay( ray, MASK_SOLID, &filter, &tr );
		if ( tr.m_pEnt )
		{						
			FlameHit(tr.m_pEnt, tr.endpos, !m_bHurtIgnited);
			//NDebugOverlay::Cross3D(tr.endpos, 10, 255, 0, 0, true, 10.0f);
			if (asw_flamer_debug.GetBool())
			{
				Msg("Flame hit %d %s\n", tr.m_pEnt->entindex(), tr.m_pEnt->GetClassname());
				NDebugOverlay::SweptBox(GetAbsOrigin(), m_vecOldPos, ASW_FLAMER_HULL_MINS * size_scale, ASW_FLAMER_HULL_MAXS * size_scale, vec3_angle, 255, 255, 0, 0 ,0.1f);
				NDebugOverlay::Line(GetAbsOrigin(), tr.m_pEnt->GetAbsOrigin(), 255, 255, 0, false, 0.1f );
			}
		}
		else if (tr.allsolid || tr.startsolid)
		{
			if (asw_flamer_debug.GetBool())
				NDebugOverlay::Box(GetAbsOrigin(), ASW_FLAMER_HULL_MINS * size_scale, ASW_FLAMER_HULL_MAXS * size_scale, 0, 0, 255, 0 ,0.1f);
		}
		else
		{
			if (asw_flamer_debug.GetBool())
				NDebugOverlay::Box(GetAbsOrigin(), ASW_FLAMER_HULL_MINS * size_scale, ASW_FLAMER_HULL_MAXS * size_scale, 255, 0, 0, 0 ,0.1f);
		}
	}
	m_vecOldPos = GetAbsOrigin();
}
Пример #24
0
/*
 * this will be called twice:
 * 1) rcfilename = "/etc/screenrc"
 * 2) rcfilename = RcFileName
 */
int StartRc(char *rcfilename, int nopanic)
{
	int argc, len;
	char *p, *cp;
	char buf[2048];
	char *args[MAXARGS];
	int argl[MAXARGS];
	FILE *fp;
	char *oldrc_name = rc_name;

	/* always fix termcap/info capabilities */
	extra_incap = CatExtra("TF", extra_incap);

	/* Special settings for vt100 and others */
	if (display && (!strncmp(D_termname, "vt", 2) || !strncmp(D_termname, "xterm", 5)))
		extra_incap =
		    CatExtra
		    ("xn:f0=\033Op:f1=\033Oq:f2=\033Or:f3=\033Os:f4=\033Ot:f5=\033Ou:f6=\033Ov:f7=\033Ow:f8=\033Ox:f9=\033Oy:f.=\033On:f,=\033Ol:fe=\033OM:f+=\033Ok:f-=\033Om:f*=\033Oj:f/=\033Oo:fq=\033OX",
		     extra_incap);

	rc_name = findrcfile(rcfilename);

	if (rc_name == NULL || (fp = secfopen(rc_name, "r")) == NULL) {
		const char *rc_nonnull = rc_name ? rc_name : rcfilename;
		if (!rc_recursion && RcFileName && !strcmp(RcFileName, rc_nonnull)) {
			/*
			 * User explicitly gave us that name,
			 * this is the only case, where we get angry, if we can't read
			 * the file.
			 */
			if (!nopanic)
				Panic(0, "Unable to open \"%s\".", rc_nonnull);
			/* possibly NOTREACHED */
		}
		if (rc_name)
			Free(rc_name);
		rc_name = oldrc_name;
		return 1;
	}
	while (fgets(buf, ARRAY_SIZE(buf), fp) != NULL) {
		if ((p = strrchr(buf, '\n')) != NULL)
			*p = '\0';
		if ((argc = Parse(buf, ARRAY_SIZE(buf), args, argl)) == 0)
			continue;
		if (strcmp(args[0], "echo") == 0) {
			if (!display)
				continue;
			if (argc < 2 || (argc == 3 && strcmp(args[1], "-n")) || argc > 3) {
				Msg(0, "%s: 'echo [-n] \"string\"' expected.", rc_name);
				continue;
			}
			AddStr(args[argc - 1]);
			if (argc != 3) {
				AddStr("\r\n");
				Flush(0);
			}
		} else if (strcmp(args[0], "sleep") == 0) {
			if (!display)
				continue;
			if (argc != 2) {
				Msg(0, "%s: sleep: one numeric argument expected.", rc_name);
				continue;
			}
			DisplaySleep1000(1000 * atoi(args[1]), 1);
		}
		else if (!strcmp(args[0], "termcapinfo") || !strcmp(args[0], "terminfo"))
		{
			if (!display)
				continue;
			if (argc < 3 || argc > 4) {
				Msg(0, "%s: %s: incorrect number of arguments.", rc_name, args[0]);
				continue;
			}
			for (p = args[1]; p && *p; p = cp) {
				if ((cp = strchr(p, '|')) != NULL)
					*cp++ = '\0';
				len = strlen(p);
				if (p[len - 1] == '*') {
					if (!(len - 1) || !strncmp(p, D_termname, len - 1))
						break;
				} else if (!strcmp(p, D_termname))
					break;
			}
			if (!(p && *p))
				continue;
			extra_incap = CatExtra(args[2], extra_incap);
			if (argc == 4)
				extra_outcap = CatExtra(args[3], extra_outcap);
		} else if (!strcmp(args[0], "source")) {
			if (rc_recursion <= 10) {
				rc_recursion++;
				(void)StartRc(args[1], 0);
				rc_recursion--;
			}
		}
	}
	fclose(fp);
	Free(rc_name);
	rc_name = oldrc_name;
	return 0;
}
Пример #25
0
static float ResponseCurveLookDefault( float x, int axis, float otherAxis, float dist, float frametime )
{
	float input = x;

	bool bStickIsPhysicallyPegged = ( dist >= joy_pegged.GetFloat() );

	// Make X positive to make things easier, just remember whether we have to flip it back!
	bool negative = false;
	if( x < 0.0f )
	{
		negative = true;
		x *= -1;
	}

	if( axis == YAW && joy_virtual_peg.GetBool() )
	{
		if( x >= 0.95f )
		{
			// User has pegged the stick
			controlEnvelope.peggedAxis[axis] = true;
			controlEnvelope.axisPeggedDir[axis] = negative;
		}
		
		if( controlEnvelope.peggedAxis[axis] == true )
		{
			// User doesn't have the stick pegged on this axis, but they used to. 
			// If the stick is physically pegged, pretend this axis is still pegged.
			if( bStickIsPhysicallyPegged && negative == controlEnvelope.axisPeggedDir[axis] )
			{
				// If the user still has the stick physically pegged and hasn't changed direction on
				// this axis, keep pretending they have the stick pegged on this axis.
				x = 1.0f;
			}
			else
			{
				controlEnvelope.peggedAxis[axis] = false;
			}
		}
	}

	// Perform the two-stage mapping.
	if( x > joy_lowend.GetFloat() )
	{
		float highmap = 1.0f - joy_lowmap.GetFloat();
		float xNormal = x - joy_lowend.GetFloat();

		float factor = xNormal / ( 1.0f - joy_lowend.GetFloat() );
		x = joy_lowmap.GetFloat() + (highmap * factor);

		// Accelerate.
		if( controlEnvelope.envelopeScale[axis] < 1.0f )
		{
			controlEnvelope.envelopeScale[axis] += ( frametime * joy_accelscale.GetFloat() );
			if( controlEnvelope.envelopeScale[axis] > 1.0f )
			{
				controlEnvelope.envelopeScale[axis] = 1.0f;
			}
		}

		float delta = x - joy_lowmap.GetFloat();
		x = joy_lowmap.GetFloat() + (delta * controlEnvelope.envelopeScale[axis]);
	}
	else
	{
		// Shut off acceleration
		controlEnvelope.envelopeScale[axis] = 0.0f;
		float factor = x / joy_lowend.GetFloat();
		x = joy_lowmap.GetFloat() * factor;
	}

	x *= AutoAimDampening( input, axis, dist );

	if( axis == YAW && x > 0.0f && joy_display_input.GetBool() )
	{
		Msg("In:%f Out:%f Frametime:%f\n", input, x, frametime );
	}

	if( negative )
	{
		x *= -1;
	}

	return x;
}
Пример #26
0
///玩家走棋判断
int  CUpGradeGameLogic::PlayerPlaneFly(BYTE bDeskStation ,BYTE cbDiceValue ,int inDex ,PlaneFlyStruct PlaneActiveTrack[])
{
	if(bDeskStation <0 ||bDeskStation >=PLAY_COUNT)
	{
		return 0 ; 
	}

	int iActivePlaneCount = 0 ; //需要激活的飞机的数量 0号为指定的自己的飞机

	if(inDex < 0 ||inDex >=PLAYER_PLANE_NUM )
	{
		return 0 ; 
	}
	switch(m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState)
	{
	case  emStandby:
		{
			int  iComeByCount = 0 ;       ///需要移动的步数

			if(cbDiceValue == 6 ) ///只有6点可以起飞
			{
				PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_HOME ;
				PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_TAKEOFF ;
				PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 

				PlaneActiveTrack[iActivePlaneCount].cbSide   = bDeskStation ;
				PlaneActiveTrack[iActivePlaneCount].cbIndex   = inDex ;  
				PlaneActiveTrack[iActivePlaneCount].cbOperateType = emTakeOfFActive ; 
				iActivePlaneCount ++ ; 
				m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emTakeoff ;
				m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = STEP_TAKEOFF ; 
			}
			return iActivePlaneCount ; 
		}
	case  emTakeoff :
	case  emFlying:
		{
			bool   bNeedBack  = false ;     ///是否需要回退  
			bool   bCanFly    = false ;        ///是否可以飞行
			int    iComeByCount = 0 ;       ///需要移动的步数
			int    cbTempStep = -1 ;       ///有迭子的位置
			int    cbStartPos ;         ///起始位置

			int    iMyselfCount = 0 ;

			PLANE  planeIndex[8] ;
			PLANE  mySelfIndex[4] ; //自己的飞机架数
			memset(planeIndex , 0 , sizeof(planeIndex)) ; 
			memset(mySelfIndex , 0 , sizeof(mySelfIndex)) ; 

			if(m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState == emTakeoff)
			{
				cbStartPos     = -1 ;
				iMyselfCount   = 1 ;
				mySelfIndex[0] = m_PlayerSerInfo[bDeskStation].Plane[inDex] ;

				PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_TAKEOFF ; 
			}
			else
			{
				cbStartPos = m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep ; 
				PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = cbStartPos ; 

				iMyselfCount = GetMyselfInStepCount(bDeskStation ,cbStartPos ,mySelfIndex) ; 
			}

			PlaneActiveTrack[iActivePlaneCount].cbSide = bDeskStation ; 
			PlaneActiveTrack[iActivePlaneCount].cbIndex = inDex ; 

			for(int i = cbStartPos + 1 ; i < cbStartPos + cbDiceValue  ; i++) ///暂不考虑走最后一步(最后一步可能有飞棋)
			{
				PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = i ;

				if(GetEnemyInStepCount(bDeskStation,i ,planeIndex) >iMyselfCount)  ///1点时不会到这里来
				{
					bNeedBack = true ; 
					cbTempStep = i ;                ///到这里就不能再走了
					break;
				}
			}

			if(bNeedBack == true) ///敌方有迭子的情况(这种状况下没有撞机的)
			{
				int iEndPos = 2*cbTempStep - cbDiceValue - cbStartPos; 

				if( iEndPos >=0)
				{
					for(int j = cbTempStep - 1 ; j >= iEndPos ; j-- )
					{
						PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] =  j ;
					}

					PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 

					m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = iEndPos ;
					m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ; 
				}
				else
				{
					for(int j = cbTempStep - 1 ; j>=0 ; j-- )
					{
						PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] =  j ;
					}

					PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_TAKEOFF ;
					PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 

					m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = STEP_TAKEOFF ;
					m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emTakeoff ;  ///重新回到起飞位置
				}

				PlaneActiveTrack[iActivePlaneCount].cbOperateType = emBackActive ; 
				iActivePlaneCount ++ ;
				
			}
			else  ///走棋过程中没有迭子,检测最后一步
			{
				int  iEnemyPlaneCount =  GetEnemyInStepCount(bDeskStation ,cbDiceValue + cbStartPos ,planeIndex) ;
				Msg("wysoutfxqlogic开始检测飞机的最后一步检测的步cbDiceValue==%d ,cbStartPos==%d ,%d ,敌方飞机的个数==%d",cbDiceValue , cbStartPos ,cbDiceValue + cbStartPos ,iEnemyPlaneCount); 
			
				if(iEnemyPlaneCount >0 ) ///最后一步有敌机不会再走了
				{
					if(iEnemyPlaneCount <=iMyselfCount) ///如果自己的飞机大于等于敌方的飞机
					{
						PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = cbDiceValue + cbStartPos;
						PlaneActiveTrack[iActivePlaneCount].cbOperateType = emFlyingActive ; 

						m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = cbDiceValue + cbStartPos ;
						m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ;

						m_iPlayerfight[bDeskStation%2] += iEnemyPlaneCount ;
					}
					else
					{
						PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = cbDiceValue + cbStartPos;
						PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_HOME;
						PlaneActiveTrack[iActivePlaneCount].cbOperateType = emHomeActive ; 

						m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = STEP_HOME ;
						m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emStandby  ; ///回家了

						//m_iPlayerfight[(bDeskStation+1)%2] += iMyselfCount ; 
					}

					PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 

					for(int i = 0 ; i <iEnemyPlaneCount ; i++) ///处理敌方的飞机
					{
						iActivePlaneCount ++ ;
						iComeByCount = 0 ;  ///后面是其他飞机的处理
						int   bOtherDesk  = planeIndex[i].emSide ;
						int   bOtherIndex = planeIndex[i].cbLandPos ;  
						BYTE  cbStartStep =planeIndex[i].cbStep; 

						PlaneActiveTrack[iActivePlaneCount].cbSide = bOtherDesk ; 
						PlaneActiveTrack[iActivePlaneCount].cbIndex = bOtherIndex ; 

						PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = cbStartStep ; 
						PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_HOME ;
						PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 
						PlaneActiveTrack[iActivePlaneCount].cbOperateType = emHomeActive ; 

						m_PlayerSerInfo[bOtherDesk].Plane[bOtherIndex].cbStep = STEP_HOME ;
						m_PlayerSerInfo[bOtherDesk].Plane[bOtherIndex].emPlaneState = emStandby ; 

						//m_iPlayerfight[bDeskStation%2] ++ ; 
					}

					iActivePlaneCount ++ ; 

				}
				else ///最后一步没有敌方的飞机
				{
					if(IsCanShortCut(bDeskStation ,cbDiceValue + cbStartPos))  ///是否可以飞翔
					{
						int  iOtherStepCount = GetEnemyInStepCount(bDeskStation ,SHORTCUT_OTHER_STEP ,planeIndex) ;  

						if( iOtherStepCount== iMyselfCount)  //相等的情况下打掉敌方的飞机
						{
							PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = cbDiceValue + cbStartPos ;
							PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_OTHER_STEP;

							PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 
							PlaneActiveTrack[iActivePlaneCount].cbOperateType = emShortCutActive ; 

							m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = SHORTCUT_OTHER_STEP ;
							m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ; 

							iActivePlaneCount ++ ; 

							for(int  i = 0 ; i < iOtherStepCount ; i++)
							{
								iComeByCount = 0 ; 

								PlaneActiveTrack[iActivePlaneCount].cbSide = planeIndex[i].emSide ; 
								PlaneActiveTrack[iActivePlaneCount].cbIndex = planeIndex[i].cbLandPos ; 

								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_OTHER_STEP ; 
								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_HOME ; 

								PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 

								m_PlayerSerInfo[planeIndex[i].emSide].Plane[planeIndex[i].cbLandPos].cbStep = STEP_HOME ;
								m_PlayerSerInfo[planeIndex[i].emSide].Plane[planeIndex[i].cbLandPos].emPlaneState = emStandby ; 

								m_iPlayerfight[bDeskStation%2] ++ ; 

								iActivePlaneCount ++ ; 
							}
						}
						else if(iOtherStepCount <iMyselfCount)
						{
							bCanFly = true ; 
							int inDexEnemy = 0 ; 
							for(int  i = SHORTCUT_OTHER_STEP;i<SHORTCUT_OTHER_STEP +4 ; i++ )
							{
								if(GetEnemyInStepCount(bDeskStation ,i,planeIndex) >iMyselfCount)
								{
									bCanFly = false ;
									i = inDexEnemy ; 
									break;
								}
							}

							if(bCanFly == true) ///可以再飞一次
							{
								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_STEP_VALUE ;
								for(int  i = SHORTCUT_OTHER_STEP;i<SHORTCUT_OTHER_STEP +5 ; i++ )
								{
									PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = i ;
								}
								PlaneActiveTrack[iActivePlaneCount].cbOperateType = emShortCutActive ; 
								PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 

								m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = SHORTCUT_OTHER_STEP +4 ;
								m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ;

								iActivePlaneCount ++ ; 
								
							}
							else  //不再飞行
							{
								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_STEP_VALUE ;
								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_OTHER_STEP ;

								PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount  ; 

								m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = SHORTCUT_OTHER_STEP ;
								m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ;

								iActivePlaneCount ++ ; 
							}
						}

						if(iOtherStepCount <=iMyselfCount)  ///这两种情况先考虑完
						{
							BYTE  iSpecifySide    = m_PlayerSerInfo[bDeskStation].Plane[inDex].emSide ; 
							BYTE  iSpecifyStation = m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState ; 
							BYTE  iSpecifyStep    =  m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep ; 

							///看一下自己的飞机有多少架
							for(int  i = 0 ; i <iMyselfCount ; i++)   ///拷贝本玩家同一位置飞机的路径
							{
								BYTE  cbMyTempside = mySelfIndex[i].emSide ; 
								BYTE  cbMyInDex    = mySelfIndex[i].cbLandPos ;

								if(cbMyInDex == inDex)
								{
									continue;
								}

								PlaneActiveTrack[iActivePlaneCount] = PlaneActiveTrack[0] ; 

								PlaneActiveTrack[iActivePlaneCount].cbSide  = cbMyTempside ;
								PlaneActiveTrack[iActivePlaneCount].cbIndex = cbMyInDex ; 

								m_PlayerSerInfo[cbMyTempside].Plane[cbMyInDex].cbStep = iSpecifyStep ;
								m_PlayerSerInfo[cbMyTempside].Plane[cbMyInDex].emPlaneState = iSpecifyStation ; 

								iActivePlaneCount ++ ; 
							}

							return iActivePlaneCount ; 
						}
					}

					if(IsCanFly(bDeskStation , cbDiceValue + cbStartPos )) ///(到了自己的格子)
					{
						bCanFly = true ; 
						for(int  i = cbDiceValue + cbStartPos;i<cbDiceValue + cbStartPos +4 ; i++ )
						{
							if(GetEnemyInStepCount(bDeskStation ,i,planeIndex) >iMyselfCount)
							{
								bCanFly = false ; 
								break;
							}
						}
					}

					if(bCanFly == true) ///需要再走4步 加上最后一步
					{
						for(int  i = 0 ; i<5 ; i++)
						{
							PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = cbDiceValue + i + cbStartPos ;
						}

						PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 
						PlaneActiveTrack[iActivePlaneCount].cbOperateType = emFlyingActive ;

						m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = cbDiceValue + cbStartPos + 4 ;
						m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ;
					}
					else  ///断定这里不可能有回退的可能
					{
						PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = cbDiceValue + cbStartPos ;
						
						PlaneActiveTrack[iActivePlaneCount].cbOperateType = emFlyingActive ; 

						m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = cbDiceValue + cbStartPos ;

						if((cbDiceValue + cbStartPos) >=50 && (cbDiceValue + cbStartPos) < (FINISH_PATH_STEP - 1))
						{
							m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emLanding ;
						}
						else if(cbDiceValue + cbStartPos == FINISH_PATH_STEP - 1)
						{
							PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_HOME ;

							PlaneActiveTrack[iActivePlaneCount].cbOperateType = emArriveHome ; 

							m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emStop ;
							m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep  = STEP_HOME ; 
						}
						else
						{
							m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ;
						}

						PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 
						
					}

					if(IsCanShortCut(bDeskStation ,m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep)) //可以走捷径
					{
						memset(planeIndex , 0 , sizeof(planeIndex)) ; 

						int  iLastStepEnemyCount = GetEnemyInStepCount(bDeskStation ,SHORTCUT_OTHER_STEP ,planeIndex) ; 

						if( iLastStepEnemyCount <iMyselfCount)
						{
							PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_STEP_VALUE ;
							PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_OTHER_STEP ;

							PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount  ;
							PlaneActiveTrack[iActivePlaneCount].cbOperateType = emShortCutActive ; 

							m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = SHORTCUT_OTHER_STEP ;
							m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ;

						}
						else if(iLastStepEnemyCount == iMyselfCount)
						{
							PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_STEP_VALUE ;
							PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_OTHER_STEP ;

							PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount  ; 
							PlaneActiveTrack[iActivePlaneCount].cbOperateType = emShortCutActive ; 

							m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = SHORTCUT_OTHER_STEP ;
							m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ;
							
							iActivePlaneCount ++ ; 

							for(int  i = 0 ; i < iLastStepEnemyCount ; i++)
							{
								iComeByCount = 0 ; 

								PlaneActiveTrack[iActivePlaneCount].cbSide = planeIndex[i].emSide ; 
								PlaneActiveTrack[iActivePlaneCount].cbIndex = planeIndex[i].cbLandPos ; 

								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = SHORTCUT_OTHER_STEP ; 
								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_HOME ; 

								PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 

								m_PlayerSerInfo[planeIndex[i].emSide].Plane[planeIndex[i].cbLandPos].cbStep = STEP_HOME ;
								m_PlayerSerInfo[planeIndex[i].emSide].Plane[planeIndex[i].cbLandPos].emPlaneState = emStandby ; 

								m_iPlayerfight[bDeskStation%2] ++ ; 

								iActivePlaneCount ++ ; 
							}
						}
					}

					BYTE cbTermalStep = m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep ; 

					if(cbTermalStep>=0 &&cbTermalStep<50)
					{
						///检测真实的最后一步是否有飞机
						memset(planeIndex , 0 ,sizeof(planeIndex)) ; 

						Msg("wysoutfxqlogic开始检测飞机的最后一步检测的步cbDiceValue==%d ,cbStartPos==%d ",cbDiceValue , cbStartPos); 

						int  iEnemyPlaneCount =  GetEnemyInStepCount(bDeskStation ,cbTermalStep ,planeIndex) ;

						if(iEnemyPlaneCount >0 ) ///最后一步有敌机不会再走了
						{
							if(iEnemyPlaneCount <=iMyselfCount) ///打了一架飞机回家了
							{
								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] =  cbTermalStep;
								PlaneActiveTrack[iActivePlaneCount].cbOperateType = emFlyingActive ; 

								m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = cbTermalStep ;
								m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emFlying ;
								m_iPlayerfight[bDeskStation%2]+= iEnemyPlaneCount ;
							}
							else
							{
								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_HOME;
								PlaneActiveTrack[iActivePlaneCount].cbOperateType = emHomeActive ; 

								m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = STEP_HOME ;
								m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emStandby  ; ///回家了

								//m_iPlayerfight[(bDeskStation + 1)%2] += iMyselfCount;
							}

							PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 

							for(int i = 0 ; i <iEnemyPlaneCount ; i++) ///处理敌方的飞机
							{
								iActivePlaneCount ++ ;
								iComeByCount = 0 ;  ///后面是其他飞机的处理
								int   bOtherDesk  = planeIndex[i].emSide ;
								int   bOtherIndex = planeIndex[i].cbLandPos ;  
								BYTE  cbStartStep =planeIndex[i].cbStep; 

								PlaneActiveTrack[iActivePlaneCount].cbSide = bOtherDesk ; 
								PlaneActiveTrack[iActivePlaneCount].cbIndex = bOtherIndex ; 

								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = cbTermalStep ; 
								PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = STEP_HOME ;
								PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 
								PlaneActiveTrack[iActivePlaneCount].cbOperateType = emHomeActive ; 

								m_PlayerSerInfo[bOtherDesk].Plane[bOtherIndex].cbStep = STEP_HOME ;
								m_PlayerSerInfo[bOtherDesk].Plane[bOtherIndex].emPlaneState = emStandby ;

								//m_iPlayerfight[bDeskStation%2] ++ ;
							}
						}
					}

					iActivePlaneCount ++ ; 
				}
			}

			BYTE  iSpecifySide    = m_PlayerSerInfo[bDeskStation].Plane[inDex].emSide ; 
			BYTE  iSpecifyStation = m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState ; 
			BYTE  iSpecifyStep    =  m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep ; 

			///看一下自己的飞机有多少架
			for(int  i = 0 ; i <iMyselfCount ; i++)   ///拷贝本玩家同一位置飞机的路径
			{
				BYTE  cbMyTempside = mySelfIndex[i].emSide ; 
				BYTE  cbMyInDex    = mySelfIndex[i].cbLandPos ;

				if(cbMyInDex == inDex)
				{
					continue;
				}

				PlaneActiveTrack[iActivePlaneCount] = PlaneActiveTrack[0] ; 

				PlaneActiveTrack[iActivePlaneCount].cbSide  = cbMyTempside ;
				PlaneActiveTrack[iActivePlaneCount].cbIndex = cbMyInDex ; 

				m_PlayerSerInfo[cbMyTempside].Plane[cbMyInDex].cbStep = iSpecifyStep ;
				m_PlayerSerInfo[cbMyTempside].Plane[cbMyInDex].emPlaneState = iSpecifyStation ; 

				iActivePlaneCount ++ ; 
			}
			return iActivePlaneCount ; 
		}
	case  emLanding:
		{
			int    iComeByCount = 0 ;       ///需要移动的步数
			int   cbStartPos = m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep ; 

			PLANE   mySelfIndex[PLAY_COUNT] ;
			memset(mySelfIndex , 0 , sizeof(mySelfIndex)) ; 

			int  iMyselfCount = GetMyselfInStepCount(bDeskStation ,cbStartPos ,mySelfIndex) ; 

			PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = cbStartPos ; 
			PlaneActiveTrack[iActivePlaneCount].cbSide = bDeskStation ; 
			PlaneActiveTrack[iActivePlaneCount].cbIndex = inDex ; 

			if(cbStartPos + cbDiceValue == FINISH_PATH_STEP -1) ///飞机完成飞行任务
			{
				for(int i = cbStartPos + 1; i<= cbStartPos + cbDiceValue  ; i++)
				{
					PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = i;
				}

				PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++]  = STEP_HOME ;
				PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 
				PlaneActiveTrack[iActivePlaneCount].cbOperateType = emArriveHome ; 

				m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = STEP_HOME ; 
				m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState = emStop ; 
				
			}
			else if(cbStartPos + cbDiceValue >FINISH_PATH_STEP -1) ///需要后退
			{
				for(int i = cbStartPos + 1; i<  FINISH_PATH_STEP   ; i++)
				{
					PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = i;
				}
				for(int i =  FINISH_PATH_STEP - 2 ; i>= 2*(FINISH_PATH_STEP-1) - cbStartPos- cbDiceValue ; i--)
				{
					PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = i;
				}

				PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 
				PlaneActiveTrack[iActivePlaneCount].cbOperateType = emBackActive ; 

				m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = 2*(FINISH_PATH_STEP-1) - cbStartPos- cbDiceValue;
			}
			else
			{
				for(int i = cbStartPos + 1; i<=  cbStartPos + cbDiceValue   ; i++)
				{
					PlaneActiveTrack[iActivePlaneCount].cbComeByStepIndex[iComeByCount ++] = i;
				}

				PlaneActiveTrack[iActivePlaneCount].cbStepCount = iComeByCount ; 
				PlaneActiveTrack[iActivePlaneCount].cbOperateType = emFlyingActive ; 

				m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep = cbStartPos + cbDiceValue;
			}

			iActivePlaneCount ++ ; 

			BYTE  iSpecifySide    = m_PlayerSerInfo[bDeskStation].Plane[inDex].emSide ; 
			BYTE  iSpecifyStation = m_PlayerSerInfo[bDeskStation].Plane[inDex].emPlaneState ; 
			BYTE  iSpecifyStep    =  m_PlayerSerInfo[bDeskStation].Plane[inDex].cbStep ; 

			///看一下自己的飞机有多少架
			for(int  i = 0 ; i <iMyselfCount ; i++)   ///拷贝本玩家同一位置飞机的路径
			{
				BYTE  cbMyTempside = mySelfIndex[i].emSide ; 
				BYTE  cbMyInDex    = mySelfIndex[i].cbLandPos ;

				if(cbMyInDex == inDex)
				{
					continue;
				}

				PlaneActiveTrack[iActivePlaneCount] = PlaneActiveTrack[0] ; 

				PlaneActiveTrack[iActivePlaneCount].cbSide  = cbMyTempside ;
				PlaneActiveTrack[iActivePlaneCount].cbIndex = cbMyInDex ; 

				m_PlayerSerInfo[cbMyTempside].Plane[cbMyInDex].cbStep = iSpecifyStep ;
				m_PlayerSerInfo[cbMyTempside].Plane[cbMyInDex].emPlaneState = iSpecifyStation ; 

				iActivePlaneCount ++ ; 
			}

			return iActivePlaneCount ; 
		}
		break ;
	case  emStop:
	case  emError:
		{
			return  0; 
		}
	}
	return  iActivePlaneCount ;
}
Пример #27
0
//-----------------------------------------------------------------------------
// Purpose: Advanced joystick setup
//-----------------------------------------------------------------------------
void CInput::Joystick_Advanced(void)
{
	// called whenever an update is needed
	int	i;
	DWORD dwTemp;

	if ( IsX360() )
	{
		// Xbox always uses a joystick
		in_joystick.SetValue( 1 );
	}

	// Initialize all the maps
	for ( i = 0; i < MAX_JOYSTICK_AXES; i++ )
	{
		m_rgAxes[i].AxisMap = GAME_AXIS_NONE;
		m_rgAxes[i].ControlMap = JOY_ABSOLUTE_AXIS;
	}

	if ( !joy_advanced.GetBool() )
	{
		// default joystick initialization
		// 2 axes only with joystick control
		m_rgAxes[JOY_AXIS_X].AxisMap = GAME_AXIS_YAW;
		m_rgAxes[JOY_AXIS_Y].AxisMap = GAME_AXIS_FORWARD;
	}
	else
	{
		if ( Q_stricmp( joy_name.GetString(), "joystick") != 0 )
		{
			// notify user of advanced controller
			Msg( "Using joystick '%s' configuration\n", joy_name.GetString() );
		}

		// advanced initialization here
		// data supplied by user via joy_axisn cvars
		dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisu.GetInt() : (DWORD)joy_advaxisx.GetInt();
		m_rgAxes[JOY_AXIS_X].AxisMap = dwTemp & 0x0000000f;
		m_rgAxes[JOY_AXIS_X].ControlMap = dwTemp & JOY_RELATIVE_AXIS;

		DescribeJoystickAxis( "JOY_AXIS_X", &m_rgAxes[JOY_AXIS_X] );

		dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisr.GetInt() : (DWORD)joy_advaxisy.GetInt();
		m_rgAxes[JOY_AXIS_Y].AxisMap = dwTemp & 0x0000000f;
		m_rgAxes[JOY_AXIS_Y].ControlMap = dwTemp & JOY_RELATIVE_AXIS;

		DescribeJoystickAxis( "JOY_AXIS_Y", &m_rgAxes[JOY_AXIS_Y] );

		dwTemp = (DWORD)joy_advaxisz.GetInt();
		m_rgAxes[JOY_AXIS_Z].AxisMap = dwTemp & 0x0000000f;
		m_rgAxes[JOY_AXIS_Z].ControlMap = dwTemp & JOY_RELATIVE_AXIS;

		DescribeJoystickAxis( "JOY_AXIS_Z", &m_rgAxes[JOY_AXIS_Z] );

		dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisy.GetInt() : (DWORD)joy_advaxisr.GetInt();
		m_rgAxes[JOY_AXIS_R].AxisMap = dwTemp & 0x0000000f;
		m_rgAxes[JOY_AXIS_R].ControlMap = dwTemp & JOY_RELATIVE_AXIS;

		DescribeJoystickAxis( "JOY_AXIS_R", &m_rgAxes[JOY_AXIS_R] );

		dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisx.GetInt() : (DWORD)joy_advaxisu.GetInt();
		m_rgAxes[JOY_AXIS_U].AxisMap = dwTemp & 0x0000000f;
		m_rgAxes[JOY_AXIS_U].ControlMap = dwTemp & JOY_RELATIVE_AXIS;

		DescribeJoystickAxis( "JOY_AXIS_U", &m_rgAxes[JOY_AXIS_U] );

		dwTemp = (DWORD)joy_advaxisv.GetInt();
		m_rgAxes[JOY_AXIS_V].AxisMap = dwTemp & 0x0000000f;
		m_rgAxes[JOY_AXIS_V].ControlMap = dwTemp & JOY_RELATIVE_AXIS;

		DescribeJoystickAxis( "JOY_AXIS_V", &m_rgAxes[JOY_AXIS_V] );

		Msg( "Advanced Joystick settings initialized\n" );
	}

	// If we have an xcontroller, load the cfg file if it hasn't been loaded.
	static ConVarRef var( "joy_xcontroller_found" );
	if ( var.IsValid() && var.GetBool() && in_joystick.GetBool() )
	{
		if ( joy_xcontroller_cfg_loaded.GetInt() < 2 )
		{
			engine->ClientCmd_Unrestricted( "exec 360controller.cfg" );
			if ( IsLinux () )
			{
				engine->ClientCmd_Unrestricted( "exec 360controller-linux.cfg" );
			}
			joy_xcontroller_cfg_loaded.SetValue( 2 );
		}
	}
	else if ( joy_xcontroller_cfg_loaded.GetInt() > 0 )
	{
		engine->ClientCmd_Unrestricted( "exec undo360controller.cfg" );
		joy_xcontroller_cfg_loaded.SetValue( 0 );
	}
}
Пример #28
0
void xrBuildNodes()
{
	// begin
	XRC.box_options	(CDB::OPT_FULL_TEST);
	XRC.ray_options	(CDB::OPT_CULL | CDB::OPT_ONLYNEAREST);
	g_nodes.reserve	(1024*1024);

	// Initialize hash
	hash_Initialize ();

	for (u32 em=0; em<Emitters.size(); em++) 
	{
		// Align emitter
		Fvector			Pos = Emitters[em];
		SnapXZ			(Pos);
		Pos.y			+=1;
		Fvector			Dir; Dir.set(0,-1,0);
		
		XRC.ray_query	(&Level,Pos,Dir,3);
		if (XRC.r_count()==0) {
			Msg		("Can't align emitter");
			abort	();
		} else {
			CDB::RESULT& R = *XRC.r_begin();
			Pos.y = Pos.y - R.range;
		}
		
		// Build first node
		int oldcount = g_nodes.size();
		int start = BuildNode		(Pos,Pos);
		if (start==InvalidNode)		continue;
		if (start<oldcount)			continue;

		// Estimate nodes
		Fvector	LevelSize;
		LevelBB.getsize				(LevelSize);
		u32	estimated_nodes		= iFloor(LevelSize.x/g_params.fPatchSize)*iFloor(LevelSize.z/g_params.fPatchSize);
		
		// General cycle
		for (u32 i=0; i<g_nodes.size(); i++)
		{
			// left 
			if (g_nodes[i].n1==UnkonnectedNode)
			{
				Pos.set			(g_nodes[i].Pos);
				Pos.x			-=	g_params.fPatchSize;
				int	id			=	BuildNode(g_nodes[i].Pos,Pos);
				g_nodes[i].n1	=	id;
			}
			// fwd
			if (g_nodes[i].n2==UnkonnectedNode)
			{
				Pos.set			(g_nodes[i].Pos);
				Pos.z			+=	g_params.fPatchSize;
				int id			=	BuildNode(g_nodes[i].Pos,Pos);
				g_nodes[i].n2	=	id;
			}
			// right
			if (g_nodes[i].n3==UnkonnectedNode)
			{
				Pos.set			(g_nodes[i].Pos);
				Pos.x			+=	g_params.fPatchSize;
				int id			=	BuildNode(g_nodes[i].Pos,Pos);
				g_nodes[i].n3	=	id;
			}
			// back
			if (g_nodes[i].n4==UnkonnectedNode)
			{
				Pos.set			(g_nodes[i].Pos);
				Pos.z			-=	g_params.fPatchSize;
				int	id			=	BuildNode(g_nodes[i].Pos,Pos);
				g_nodes[i].n4	=	id;
			}
			if (i%512==0) {
				Status("%d / %d nodes created.",g_nodes.size()-i,g_nodes.size());

				float	p1	= float(i)/float(g_nodes.size());
				float	p2	= float(g_nodes.size())/estimated_nodes;
				float	p	= 0.1f*p1+0.9f*p2;

				clamp	(p,0.f,1.f);
				Progress(p);
			}
		}
	}
	Msg("Freeing memory...");
	hash_Destroy	();
}
Пример #29
0
	void OnUploadComplete(uint32& status)
	{
		Msg("Upload complete\n");
		g_bUploadDone = true;
		g_WaitCon.notify();
	}
Пример #30
0
int EBuffer::ShowPosition() {
    int CLine, NLines;
    int CAct, NAct;
    int CColumn, NColumns;
    int CCharPos, NChars;
#ifdef HEAPWALK
    unsigned long MemUsed = 0, MemFree = 0, BlkUsed = 0, BlkFree = 0, BigFree = 0, BigUsed = 0;
#endif

    if (!View)
        return 0;

    CLine = CP.Row + 1;
    NLines = VCount;
    CAct = VToR(CP.Row) + 1;
    NAct = RCount;
    CColumn = CP.Col + 1;
    NColumns = LineLen(CP.Row);
    CCharPos = CharOffset(VLine(CP.Row), CP.Col) + 1;
    NChars = VLine(CP.Row)->Count;

#ifdef HEAPWALK
    if (_heapchk() != _HEAPOK) {
        MemUsed = -1;
    } else {
        _HEAPINFO hi;

        hi._pentry = NULL;
        while (_heapwalk(&hi) == _HEAPOK) {
            if (hi._useflag == _USEDENTRY) {
                BlkUsed++;
                MemUsed += hi._size;
                if (hi._size > BigUsed)
                    BigUsed = hi._size;
                //fprintf(stderr, "USED %d\n", hi._size);
            } else {
                BlkFree++;
                MemFree += hi._size;
                if (hi._size > BigFree)
                    BigFree = hi._size;
                //fprintf(stderr, "FREE %d\n", hi._size);
            }
        }
    }
#endif

    int NN = -1;
    if (US.UndoPtr > 0)
        NN = US.Top[US.UndoPtr - 1];
    Msg(S_INFO,
#ifdef HEAPWALK
        "M%ld,%ld B%ld,%ld S%ld,%ld"
#endif
        "L%d/%d G%d/%d/%d A%d/%d C%d/%d P%d/%d "
        "U%d/%d/%d "
        "H%d/%d/%d",
#ifdef HEAPWALK
        MemUsed, MemFree, BlkUsed, BlkFree, BigUsed, BigFree,
#endif
        CLine, NLines,
        RGap, RCount, RAllocated,
        CAct, NAct,
        CColumn, NColumns,
        CCharPos, NChars,
        US.UndoPtr, US.Num, NN,
        StartHilit, MinRedraw, MaxRedraw);
    return 1;
}