LNK2001 ERROR!!! need help

This is a discussion on LNK2001 ERROR!!! need help within the C++ Programming forums, part of the General Programming Boards category; Ok im creating a mod at the moment for half life 2 episode 2 engine. im new to this so ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    6

    LNK2001 ERROR!!! need help

    Ok im creating a mod at the moment for half life 2 episode 2 engine. im new to this so please bear with me and any help will be greatly appreciated. Im trying to set up the the in_camera.cpp to make it possible for players to switch from first person to third person. i thought i had everything to work out. starting out with 28 errors and eliminated all untill i get the same 8 i cant fix. here is the error report.
    --------------------------------------------------------------------------------------------------------------------
    > Creating library .\Release_hl2mp/Client.lib and object .\Release_hl2mp/Client.exp
    1>LINK : warning LNK4199: /DELAYLOAD:OleAcc.dll ignored; no imports found from OleAcc.dll
    1>in_joystick.obj : error LNK2001: unresolved external symbol "class ConVar cam_idealyaw" (?cam_idealyaw@@3VConVar@@A)
    1>in_main.obj : error LNK2001: unresolved external symbol "class ConVar cam_idealyaw" (?cam_idealyaw@@3VConVar@@A)
    1>in_mouse.obj : error LNK2001: unresolved external symbol "class ConVar cam_idealyaw" (?cam_idealyaw@@3VConVar@@A)
    1>in_joystick.obj : error LNK2001: unresolved external symbol "class ConVar cam_idealpitch" (?cam_idealpitch@@3VConVar@@A)
    1>in_mouse.obj : error LNK2001: unresolved external symbol "class ConVar cam_idealpitch" (?cam_idealpitch@@3VConVar@@A)
    1>in_main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CInput::CAM_SetCameraThirdData(struct CameraThirdData_t *,class QAngle const &)" (?CAM_SetCameraThirdData@CInput@@UAEXPAUCameraThir dData_t@@ABVQAngle@@@Z)
    1>hl_in_main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CInput::CAM_SetCameraThirdData(struct CameraThirdData_t *,class QAngle const &)" (?CAM_SetCameraThirdData@CInput@@UAEXPAUCameraThir dData_t@@ABVQAngle@@@Z)
    1>.\Release_hl2mp/Client.dll : fatal error LNK1120: 3 unresolved externals
    --------------------------------------------------------------------------------------------------------------------

    as for the the code here it is.......
    Code:
    --------------------------------------------------------------------------------------------------------------------
    
    //========= Copyright  1996-2005, Valve Corporation, All rights reserved. ============//
    //
    // Purpose: 
    //
    // $NoKeywords: $
    //=============================================================================//
    
    
    #include "cbase.h"
    #include "hud.h"
    #include "kbutton.h"
    #include "input.h"
    
    #include <vgui/IInput.h>
    #include "vgui_controls/controls.h"
    #include "tier0/vprof.h"
    
    // memdbgon must be the last include file in a .cpp file!!!
    #include "tier0/memdbgon.h"
    #include "memdbgon.h"
    
    //-------------------------------------------------- Constants
    
    // #define CAM_MIN_DIST 30.0
    #define CAM_ANGLE_MOVE .5
    #define MAX_ANGLE_DIFF 10.0
    #define PITCH_MAX 90.0
    #define PITCH_MIN 0
    #define YAW_MAX  135.0
    #define YAW_MIN	 -135.0
    #define CAM_MIN_DIST		8.0 // Don't let the camera get any closer than ...
    #define CAM_MAX_DIST		96.0 // ... or any farther away than ...
    #define CAM_SWITCH_DIST		96.0 // the default camera distance when switching 1st to 3rd person
    #define CAM_HULL_OFFSET		6.0  // the size of the bounding hull used for collision checking
    #define START_TRANS_DIST	40.0 // how close to player when it starts making model translucent
    #define TRANS_DELTA	        1.9921875 // Set to 255 / START_TRANS_DIST
    #define	dist	 2
    #define DIST 2
    #define CAM_ANGLE_SPEED 10
    #define CAM_ANGLE_DELTA 2.5
    #define CAM_DIST_DELTA 1.0
    #define camAngle 1
    
    
    
    static Vector CAM_HULL_MIN(-CAM_HULL_OFFSET,-CAM_HULL_OFFSET,-CAM_HULL_OFFSET);
    static Vector CAM_HULL_MAX( CAM_HULL_OFFSET, CAM_HULL_OFFSET, CAM_HULL_OFFSET);
    
    
    //-------------------------------------------------- Global Variables
    
    static ConVar cam_command( "cam_command", "0", FCVAR_CHEAT );	 // tells camera to go to thirdperson
    static ConVar cam_snapto( "cam_snapto", "0", FCVAR_ARCHIVE );	 // snap to thirdperson view
    static ConVar cam_ideallag( "cam_ideallag", "4.0", FCVAR_ARCHIVE, "Amount of lag used when matching offset to ideal angles in thirdperson view" );
    static ConVar cam_idealdelta( "cam_idealdelta", "4.0", FCVAR_ARCHIVE, "Controls the speed when matching offset to ideal angles in thirdperson view" );
    static ConVar cam_idealyaw( "cam_idealyaw", "0", FCVAR_ARCHIVE );	 // thirdperson yaw
    static ConVar cam_idealpitch( "cam_idealpitch", "0", FCVAR_ARCHIVE );	 // thirperson pitch
    static ConVar cam_idealdist( "cam_idealdist", "150", FCVAR_ARCHIVE );	 // thirdperson distance
    static ConVar cam_collision( "cam_collision", "1", FCVAR_ARCHIVE, "When in thirdperson and cam_collision is set to 1, an attempt is made to keep the camera from passing though walls." );
    static ConVar cam_showangles( "cam_showangles", "0", FCVAR_CHEAT, "When in thirdperson, print viewangles/idealAngle/cameraoffsets to the console." );
    static ConVar c_maxpitch( "c_maxpitch", "90", FCVAR_ARCHIVE );
    static ConVar c_minpitch( "c_minpitch", "0", FCVAR_ARCHIVE );
    static ConVar c_maxyaw( "c_maxyaw",   "135", FCVAR_ARCHIVE );
    static ConVar c_minyaw( "c_minyaw",   "-135", FCVAR_ARCHIVE );
    static ConVar c_maxdistance( "c_maxdistance",   "200", FCVAR_ARCHIVE );
    static ConVar c_mindistance( "c_mindistance",   "30", FCVAR_ARCHIVE );
    static ConVar c_orthowidth( "c_orthowidth",   "100", FCVAR_ARCHIVE );
    static ConVar c_orthoheight( "c_orthoheight",   "100", FCVAR_ARCHIVE );
    
    static kbutton_t cam_pitchup, cam_pitchdown, cam_yawleft, cam_yawright;
    static kbutton_t cam_in, cam_out, cam_move; // -- "cam_move" is unused
    float mf_NextSwitch;
    
    extern const ConVar *sv_cheats;
    
    // API Wrappers
    
    /*
    ==============================
    CAM_ToThirdPerson
    
    ==============================
    */
    void CAM_ToThirdPerson(void)
    {
    	input->CAM_ToThirdPerson();
    
    	// Let the local player know
    	C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer();
    	if ( localPlayer )
    	{
    		localPlayer->ThirdPersonSwitch( true );
    	}
    }
    
    /*
    ==============================
    CAM_ToThirdPerson_MayaMode
    
    ==============================
    */
    static bool & Is_CAM_ThirdPerson_MayaMode(void)
    {
    	static bool s_b_CAM_ThirdPerson_MayaMode = false;
    	return s_b_CAM_ThirdPerson_MayaMode;
    }
    void CAM_ToThirdPerson_MayaMode(void)
    {
    	bool &rb = Is_CAM_ThirdPerson_MayaMode();
    	rb = !rb;
    }
    
    /*
    ==============================
    CAM_ToFirstPerson
    
    ==============================
    */
    void CAM_ToFirstPerson(void) 
    { 
    	input->CAM_ToFirstPerson();
    
    	// Let the local player know
    	C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer();
    	if ( localPlayer )
    	{
    		localPlayer->ThirdPersonSwitch( false );
    	}
    }
    
    /*
    ==============================
    CAM_ToOrthographic
    
    ==============================
    */
    void CAM_ToOrthographic(void) 
    { 
    	input->CAM_ToOrthographic();
    }
    
    /*
    ==============================
    CAM_StartMouseMove
    
    ==============================
    */
    void CAM_StartMouseMove( void )
    {
    	input->CAM_StartMouseMove();
    }
    
    /*
    ==============================
    CAM_EndMouseMove
    
    ==============================
    */
    void CAM_EndMouseMove( void )
    {
    	input->CAM_EndMouseMove();
    }
    
    /*
    ==============================
    CAM_StartDistance
    
    ==============================
    */
    void CAM_StartDistance( void )
    {
    	input->CAM_StartDistance();
    }
    
    /*
    ==============================
    CAM_EndDistance
    
    ==============================
    */
    void CAM_EndDistance( void )
    {
    	input->CAM_EndDistance();
    }
    
    /*
    ==============================
    CAM_ToggleSnapto
    
    ==============================
    */
    void CAM_ToggleSnapto( void )
    { 
    	cam_snapto.SetValue( !cam_snapto.GetInt() );
    }
    
    
    /*
    ==============================
    MoveToward
    
    ==============================
    */
    float MoveToward( float cur, float goal, float lag )
    {
    	if( cur != goal )
    	{
    		if( abs( cur - goal ) > 180.0 )
    		{
    			if( cur < goal )
    				cur += 360.0;
    			else
    				cur -= 360.0;
    		}
    
    		if( cur < goal )
    		{
    			if( cur < goal - 1.0 )
    				cur += ( goal - cur ) / lag;
    			else
    				cur = goal;
    		}
    		else
    		{
    			if( cur > goal + 1.0 )
    				cur -= ( cur - goal ) / lag;
    			else
    				cur = goal;
    		}
    	}
    
    
    	// bring cur back into range
    	if( cur < 0 )
    		cur += 360.0;
    	else if( cur >= 360 )
    		cur -= 360;
    
    	return cur;
    }
    
    /*
    ==============================
    CAM_Think
    
    ==============================
    */
    void CInput::CAM_Think( void )
    {
    	VPROF("CAM_Think");
    	//
    	if ( m_pCameraThirdData )
    	{
    		return CAM_CameraThirdThink();
    	}
    
    	Vector idealAngle;
    	Vector camOffset;
    	float flSensitivity;
    	QAngle viewangles;
    	
    	switch( cam_command.GetInt() )
    	{
    	case CAM_COMMAND_TOTHIRDPERSON:
    		CAM_ToThirdPerson();
    		break;
    		
    	case CAM_COMMAND_TOFIRSTPERSON:
    		CAM_ToFirstPerson();
    		break;
    		
    	case CAM_COMMAND_NONE:
    	default:
    		break;
    	}
    	
    	// Toggle first/3rd person, check every 0.5 seconds
    if(gpGlobals->curtime >= mf_NextSwitch) {
    	if(input->KeyState(&in_camchange))
    	{
    		mf_NextSwitch = gpGlobals->curtime + 0.5; /* Check if the key has been pressed every
                                                                 0.5 seconds */
    		if(!m_fCameraInThirdPerson)
    		{
    			CAM_ToThirdPerson();
    		} else {
    			CAM_ToFirstPerson();
    		}
    	}
    }
    
    if( !m_fCameraInThirdPerson )
    {
    	// If in FP mode, transparent
    	// This is sort of a hack since when the map first loads you ARE transparent...
    	// This is for when you switch from 3rd to 1st.
    	if(C_BasePlayer::GetLocalPlayer() ) {
    		C_BasePlayer::GetLocalPlayer()->SetRenderMode( kRenderTransColor );
    		C_BasePlayer::GetLocalPlayer()->SetRenderColorA(0);
    	}
    
    	return;
        }
    
    	if ( !sv_cheats )
    	{
    		sv_cheats = cvar->FindVar( "sv_cheats" );
    	}
    
    	// If cheats have been disabled, pull us back out of third-person view.
    	/*if ( sv_cheats && !sv_cheats->GetBool() )
    	{
    		CAM_ToFirstPerson();
    		return;
    	}*/
    
    	// In Maya-mode
    	if ( Is_CAM_ThirdPerson_MayaMode() )
    	{
    		// Unless explicitly moving the camera, don't move it
    		m_fCameraInterceptingMouse = m_fCameraMovingWithMouse =
    			vgui::input()->IsKeyDown( KEY_LALT ) || vgui::input()->IsKeyDown( KEY_RALT );
    		if ( !m_fCameraMovingWithMouse )
    			return;
    
    		// Zero-out camera-control kbutton_t structures
    		memset( &cam_pitchup, 0, sizeof( cam_pitchup ) );
    		memset( &cam_pitchdown, 0, sizeof( cam_pitchdown ) );
    		memset( &cam_yawleft, 0, sizeof( cam_yawleft ) );
    		memset( &cam_yawright, 0, sizeof( cam_yawright ) );
    		memset( &cam_in, 0, sizeof( cam_in ) );
    		memset( &cam_out, 0, sizeof( cam_out ) );
    
    		// Unless left or right mouse button is down, don't do anything
    #ifndef _XBOX
    		if ( /* Left+Middle Button Down */ vgui::input()->IsMouseDown( MOUSE_LEFT ) && vgui::input()->IsMouseDown( MOUSE_MIDDLE ) )
    		{
    			// Do only zoom in/out camera adjustment
    			m_fCameraDistanceMove = true;
    		}
    		else if ( /* Left Button Down */ vgui::input()->IsMouseDown( MOUSE_LEFT ) )
    		{
    			// Do only rotational camera movement
    			m_fCameraDistanceMove = false;
    		}
    		else if ( /* Right Button Down */ vgui::input()->IsMouseDown( MOUSE_RIGHT ) )
    		{
    			// Do only zoom in/out camera adjustment
    			m_fCameraDistanceMove = true;
    		}
    		else
    		{
    			// Neither left or right buttons down, don't do anything
    			ResetMouse();
    			return;
    		}
    #endif
    	}
    	
    	idealAngle[ PITCH ] = cam_idealpitch.GetFloat();
    	idealAngle[ YAW ]   = cam_idealyaw.GetFloat();
    	idealAngle[ DIST ]  = cam_idealdist.GetFloat();
    
    	//
    	//movement of the camera with the mouse
    	//
    	if ( m_fCameraMovingWithMouse )
    	{
    		int cpx, cpy;
    #ifndef _XBOX		
    		//get windows cursor position
    		GetMousePos (cpx, cpy);
    #else
    		//xboxfixme
    		cpx = cpy = 0;
    #endif
    		
    		m_nCameraX = cpx;
    		m_nCameraY = cpy;
    		
    		//check for X delta values and adjust accordingly
    		//eventually adjust YAW based on amount of movement
    		//don't do any movement of the cam using YAW/PITCH if we are zooming in/out the camera	
    		if (!m_fCameraDistanceMove)
    		{
    			int x, y;
    			GetWindowCenter( x,  y );
    			
    			//keep the camera within certain limits around the player (ie avoid certain bad viewing angles)  
    			if (m_nCameraX>x)
    			{
    				//if ((idealAngle[YAW]>=225.0)||(idealAngle[YAW]<135.0))
    				if (idealAngle[YAW]<c_maxyaw.GetFloat())
    				{
    					idealAngle[ YAW ] += (CAM_ANGLE_MOVE)*((m_nCameraX-x)/2);
    				}
    				if (idealAngle[YAW]>c_maxyaw.GetFloat())
    				{
    					
    					idealAngle[YAW]=c_maxyaw.GetFloat();
    				}
    			}
    			else if (m_nCameraX<x)
    			{
    				//if ((idealAngle[YAW]<=135.0)||(idealAngle[YAW]>225.0))
    				if (idealAngle[YAW]>c_minyaw.GetFloat())
    				{
    					idealAngle[ YAW ] -= (CAM_ANGLE_MOVE)* ((x-m_nCameraX)/2);
    					
    				}
    				if (idealAngle[YAW]<c_minyaw.GetFloat())
    				{
    					idealAngle[YAW]=c_minyaw.GetFloat();
    					
    				}
    			}
    			
    			//check for y delta values and adjust accordingly
    			//eventually adjust PITCH based on amount of movement
    			//also make sure camera is within bounds
    			if (m_nCameraY > y)
    			{
    				if(idealAngle[PITCH]<c_maxpitch.GetFloat())
    				{
    					idealAngle[PITCH] +=(CAM_ANGLE_MOVE)* ((m_nCameraY-y)/2);
    				}
    				if (idealAngle[PITCH]>c_maxpitch.GetFloat())
    				{
    					idealAngle[PITCH]=c_maxpitch.GetFloat();
    				}
    			}
    			else if (m_nCameraY<y)
    			{
    				if (idealAngle[PITCH]>c_minpitch.GetFloat())
    				{
    					idealAngle[PITCH] -= (CAM_ANGLE_MOVE)*((y-m_nCameraY)/2);
    				}
    				if (idealAngle[PITCH]<c_minpitch.GetFloat())
    				{
    					idealAngle[PITCH]=c_minpitch.GetFloat();
    				}
    			}
    			
    			//set old mouse coordinates to current mouse coordinates
    			//since we are done with the mouse
    			
    			if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
    			{
    				m_nCameraOldX=m_nCameraX*flSensitivity;
    				m_nCameraOldY=m_nCameraY*flSensitivity;
    			}
    			else
    			{
    				m_nCameraOldX=m_nCameraX;
    				m_nCameraOldY=m_nCameraY;
    			}
    #ifndef _XBOX
    			ResetMouse();
    #endif
    		}
    	}
    	
    	//Nathan code here
    	if( input->KeyState( &cam_pitchup ) )
    		idealAngle[ PITCH ] += cam_idealdelta.GetFloat();
    	else if( input->KeyState( &cam_pitchdown ) )
    		idealAngle[ PITCH ] -= cam_idealdelta.GetFloat();
    	
    	if( input->KeyState( &cam_yawleft ) )
    		idealAngle[ YAW ] -= cam_idealdelta.GetFloat();
    	else if( input->KeyState( &cam_yawright ) )
    		idealAngle[ YAW ] += cam_idealdelta.GetFloat();
    	
    	if( input->KeyState( &cam_in ) )
    	{
    		idealAngle[ DIST ] -= 2*cam_idealdelta.GetFloat();
    		if( idealAngle[ DIST ] < CAM_MIN_DIST )
    		{
    			// If we go back into first person, reset the angle
    			idealAngle[ PITCH ] = 0;
    			idealAngle[ YAW ] = 0;
    			idealAngle[ DIST ] = 0;
    		}
    		
    	}
    	else if( input->KeyState( &cam_out ) )
    		idealAngle[ 2 ] += 2*cam_idealdelta.GetFloat(); // Prevent the cam_out from going any further
    		// NOTE: Without this, it _appears_ it's not moving, but
    		// the transparency changes so it is... this fixes it.
    		if( dist > CAM_MAX_DIST )
    			dist == CAM_MIN_DIST;
    	
    	if (m_fCameraDistanceMove)
    	{
    		int x, y;
    		GetWindowCenter( x, y );
    
    		if (m_nCameraY>y)
    		{
    			if(idealAngle[ DIST ]<c_maxdistance.GetFloat())
    			{
    				idealAngle[ DIST ] +=cam_idealdelta.GetFloat() * ((m_nCameraY-y)/2);
    			}
    			if (idealAngle[ DIST ]>c_maxdistance.GetFloat())
    			{
    				idealAngle[ DIST ]=c_maxdistance.GetFloat();
    			}
    		}
    		else if (m_nCameraY<y)
    		{
    			if (idealAngle[ DIST ]>c_mindistance.GetFloat())
    			{
    				idealAngle[ DIST ] -= (cam_idealdelta.GetFloat())*((y-m_nCameraY)/2);
    			}
    			if (idealAngle[ DIST ]<c_mindistance.GetFloat())
    			{
    				idealAngle[ DIST ]=c_mindistance.GetFloat();
    			}
    		}
    		//set old mouse coordinates to current mouse coordinates
    		//since we are done with the mouse
    		m_nCameraOldX=m_nCameraX*gHUD.GetSensitivity();
    		m_nCameraOldY=m_nCameraY*gHUD.GetSensitivity();
    #ifndef _XBOX
    		ResetMouse();
    #endif
    	}
    
    	// Obtain engine view angles and if they popped while the camera was static,
    	// fix the camera angles as well
    	engine->GetViewAngles( viewangles );
    	static QAngle s_oldAngles = viewangles;
    	if ( Is_CAM_ThirdPerson_MayaMode() && ( s_oldAngles != viewangles ) )
    	{
    		idealAngle[ PITCH ] += s_oldAngles[ PITCH ] - viewangles[ PITCH ];
    		idealAngle[  YAW  ] += s_oldAngles[  YAW  ] - viewangles[  YAW  ];
    		s_oldAngles = viewangles;
    	}
    
    	// bring the pitch values back into a range that MoveToward can handle
    	if ( idealAngle[ PITCH ] > 180 )
    		idealAngle[ PITCH ] -= 360;
    	else if ( idealAngle[ PITCH ] < -180 )
    		idealAngle[ PITCH ] += 360;
    
    	// bring the yaw values back into a range that MoveToward can handle
    	// --
    	// Vitaliy: going with >= 180 and <= -180.
    	// This introduces a potential discontinuity when looking directly at model face
    	// as camera yaw will be jumping from +180 to -180 and back, but when working with
    	// the camera allows smooth rotational transitions from left to right and back.
    	// Otherwise one of the transitions that has ">"-comparison will be locked.
    	// --
    	if ( idealAngle[ YAW ] >= 180 )
    		idealAngle[ YAW ] -= 360;
    	else if ( idealAngle[ YAW ] <= -180 )
    		idealAngle[ YAW ] += 360;
    
    	// clamp pitch, yaw and dist...
    	idealAngle[ PITCH ] = clamp( idealAngle[ PITCH ], c_minpitch.GetFloat(), c_maxpitch.GetFloat() );
    	idealAngle[ YAW ]   = clamp( idealAngle[ YAW ], c_minyaw.GetFloat(), c_maxyaw.GetFloat() );
    	idealAngle[ DIST ]  = clamp( idealAngle[ DIST ], c_mindistance.GetFloat(), c_maxdistance.GetFloat() );
    
    	// update ideal angles
    	cam_idealpitch.SetValue( idealAngle[ PITCH ] );
    	cam_idealyaw.SetValue( idealAngle[ YAW ] );
    	cam_idealdist.SetValue( idealAngle[ DIST ] );
    	
    	// Move the CameraOffset "towards" the idealAngle
    	// Note: CameraOffset = viewangle + idealAngle
    	VectorCopy( m_vecCameraOffset, idealAngle );
    	
    	if( cam_snapto.GetInt() )
    {
    	idealAngle [ YAW ] = cam_idealyaw.GetFloat() + viewangles[ YAW ];
    	idealAngle [ PITCH ] = cam_idealpitch.GetFloat() + viewangles[ PITCH ];
    	idealAngle [ DIST ] = cam_idealdist.GetFloat();
    }
    else
    {
    	if( idealAngle[ YAW ] - viewangles[ YAW ] != cam_idealyaw.GetFloat() )
    		idealAngle[ YAW ] = MoveToward( idealAngle[ YAW ],
    					       cam_idealyaw.GetFloat() + viewangles[ YAW ],
                                                   CAM_ANGLE_SPEED );
     
            if( idealAngle[ PITCH ] - viewangles[ PITCH ] != cam_idealpitch.GetFloat() )
                idealAngle[ PITCH ] = MoveToward( idealAngle[ PITCH ],
                                                 cam_idealpitch.GetFloat() + viewangles[ PITCH ],
                                                 CAM_ANGLE_SPEED );
     
            if( !C_BasePlayer::GetLocalPlayer() ) {
                // this code can be hit from the main menu, where it will crash
                idealAngle[ 2 ] = dist; // if there's no localplayer to calc from
            }
            else {
                trace_t tr;
                float adjDist = dist;
                C_BasePlayer* localPlayer = C_BasePlayer::GetLocalPlayer();
    
                Vector origin = localPlayer->GetLocalOrigin(); // find our player's origin
                origin += localPlayer->GetViewOffset(); // and from there, his eye position
    
                AngleVectors( QAngle(idealAngle.x, idealAngle.y, idealAngle.z),
                             &idealAngle, NULL, NULL ); // get the forward vector
    
                UTIL_TraceHull( origin, origin - (idealAngle * dist),
                                CAM_HULL_MIN, CAM_HULL_MAX,
                                MASK_SOLID, NULL, &tr ); /* use our previously #defined hull to
                                                            collision trace */
    
                if( tr.fraction < 1.0 ) {
                    adjDist = dist * tr.fraction; // move the camera closer if it hit something
                }
                else {
                    adjDist = dist; // no trace hit, use cam_idealdist without adjusting it
                }
    
    	    if ( adjDist < START_TRANS_DIST ) {
    	        localPlayer->SetRenderMode( kRenderTransColor ); // make him translucent
    		localPlayer->SetRenderColorA( (byte)(adjDist * TRANS_DELTA) ); // closer=less opacity
    	    }
    
                if( adjDist < CAM_MIN_DIST )
                    adjDist = CAM_MIN_DIST; // clamp up to minimum
    
                if( adjDist > CAM_MAX_DIST )
                    adjDist = CAM_MAX_DIST; // clamp down to maximum
    
                idealAngle[ 2 ] = adjDist;
            }
        }
    
    	if ( cam_showangles.GetInt() )
    	{
    		engine->Con_NPrintf( 4, "Pitch: %6.1f   Yaw: %6.1f %38s", viewangles[ PITCH ], viewangles[ YAW ], "view angles" );
    		engine->Con_NPrintf( 6, "Pitch: %6.1f   Yaw: %6.1f   Dist: %6.1f %19s", cam_idealpitch.GetFloat(), cam_idealyaw.GetFloat(), cam_idealdist.GetFloat(), "ideal angles" );
    		engine->Con_NPrintf( 8, "Pitch: %6.1f   Yaw: %6.1f   Dist: %6.1f %16s", m_vecCameraOffset[ PITCH ], m_vecCameraOffset[ YAW ], m_vecCameraOffset[ DIST ], "camera offset" );
    	}
    
    	m_vecCameraOffset[ PITCH ] = camOffset[ PITCH ];
    	m_vecCameraOffset[ YAW ]   = camOffset[ YAW ];
    	m_vecCameraOffset[ DIST ]  = camOffset[ DIST ];
    }
    
    //------------------------------------------------------------------------------
    // Purpose:
    //------------------------------------------------------------------------------
    void ClampRange180( float &value )
    {
    	if ( value >= 180.0f )
    	{
    		value -= 360.0f;
    	}
    	else if ( value <= -180.0f )
    	{
    		value += 360.0f;
    	}
    }
    
    
    //------------------------------------------------------------------------------
    // Purpose:
    //------------------------------------------------------------------------------
    void CInput::CAM_CameraThirdThink( void )
    {
    	// Verify data.
    	if ( !m_pCameraThirdData )
    		return;
    
    	// Verify that we are in third person mode.
    	if( !m_fCameraInThirdPerson )
    		return;
    
    	// Obtain engine view angles and if they popped while the camera was static, fix the camera angles as well.
    	QAngle angView;
    	engine->GetViewAngles( angView );
    
    	// Move the CameraOffset "towards" the idealAngle, Note: CameraOffset = viewangle + idealAngle
    	Vector vecCamOffset;
    	VectorCopy( m_vecCameraOffset, vecCamOffset );
    
    	// Move the camera.
    	float flLag = max( 1, 1 + m_pCameraThirdData->m_flLag );
    	if( vecCamOffset[PITCH] - angView[PITCH] != m_pCameraThirdData->m_flPitch )
    	{
    		vecCamOffset[PITCH] = MoveToward( vecCamOffset[PITCH], ( m_pCameraThirdData->m_flPitch + angView[PITCH] ), flLag );
    	}
    	if( vecCamOffset[YAW] - angView[YAW] != m_pCameraThirdData->m_flYaw )
    	{
    		vecCamOffset[YAW] = MoveToward( vecCamOffset[YAW], ( m_pCameraThirdData->m_flYaw + angView[YAW] ), flLag );
    	}
    	if( abs( vecCamOffset[DIST] - m_pCameraThirdData->m_flDist ) < 2.0 )
    	{
    		vecCamOffset[DIST] = m_pCameraThirdData->m_flDist;
    	}
    	else
    	{
    		vecCamOffset[DIST] += ( m_pCameraThirdData->m_flDist - vecCamOffset[DIST] ) / flLag;
    	}
    
    	C_BasePlayer* pLocalPlayer = C_BasePlayer::GetLocalPlayer();
    	if ( pLocalPlayer )
    	{
    		Vector vecForward;
    
    		// Find our player's origin, and from there, the eye position.
    		Vector vecOrigin = pLocalPlayer->GetLocalOrigin();
    		vecOrigin += pLocalPlayer->GetViewOffset();
    
    		// Get the forward vector
    		AngleVectors( QAngle( vecCamOffset[PITCH], vecCamOffset[YAW], 0 ), &vecForward, NULL, NULL );
    
    		// Collision trace and move the camera closer if we hit something.
    		trace_t trace;
    		UTIL_TraceHull( vecOrigin, vecOrigin - ( vecForward * vecCamOffset[DIST] ), m_pCameraThirdData->m_vecHullMin, 
    			m_pCameraThirdData->m_vecHullMax,	MASK_SOLID, pLocalPlayer, 
    			COLLISION_GROUP_NONE, &trace );
    
    		if( trace.fraction < 1.0 )
    		{
    			vecCamOffset[DIST] *= trace.fraction;
    		}
    	}
    
    	ClampRange180( vecCamOffset[PITCH] );
    	ClampRange180( vecCamOffset[YAW] );
    
    	m_vecCameraOffset[PITCH] = vecCamOffset[PITCH];
    	m_vecCameraOffset[YAW] = vecCamOffset[YAW];
    	m_vecCameraOffset[DIST] = vecCamOffset[DIST];
    }
    
    void CAM_PitchUpDown( const CCommand &args ) { KeyDown( &cam_pitchup, args[1] ); }
    void CAM_PitchUpUp( const CCommand &args ) { KeyUp( &cam_pitchup, args[1] ); }
    void CAM_PitchDownDown( const CCommand &args ) { KeyDown( &cam_pitchdown, args[1] ); }
    void CAM_PitchDownUp( const CCommand &args ) { KeyUp( &cam_pitchdown, args[1] ); }
    void CAM_YawLeftDown( const CCommand &args ) { KeyDown( &cam_yawleft, args[1] ); }
    void CAM_YawLeftUp( const CCommand &args ) { KeyUp( &cam_yawleft, args[1] ); }
    void CAM_YawRightDown( const CCommand &args ) { KeyDown( &cam_yawright, args[1] ); }
    void CAM_YawRightUp( const CCommand &args ) { KeyUp( &cam_yawright, args[1] ); }
    void CAM_InDown( const CCommand &args ) { KeyDown( &cam_in, args[1] ); }
    void CAM_InUp( const CCommand &args ) { KeyUp( &cam_in, args[1] ); }
    void CAM_OutDown( const CCommand &args ) { KeyDown( &cam_out, args[1] ); }
    void CAM_OutUp( const CCommand &args ) { KeyUp( &cam_out, args[1] ); }
    
    /*
    ==============================
    CAM_ToThirdPerson
    
    ==============================
    */
    void CInput::CAM_ToThirdPerson(void)
    { 
    	QAngle viewangles;
    
    	engine->GetViewAngles( viewangles );
    
    	if( !m_fCameraInThirdPerson )
    	{
    		m_fCameraInThirdPerson = true; 
    		
    		m_vecCameraOffset[ YAW ] = viewangles[ YAW ]; 
    		m_vecCameraOffset[ PITCH ] = viewangles[ PITCH ]; 
    		m_vecCameraOffset[ 2 ] = CAM_SWITCH_DIST;
    // Set model to 'player' because when a map first loads
    		// it doesn't set the model... sort of a hack.
    		C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
    		pPlayer->SetModel("player");
    	}
    
    	cam_command.SetValue( 0 );
    }
    
    /*
    ==============================
    CAM_ToFirstPerson
    
    ==============================
    */
    void CInput::CAM_ToFirstPerson(void)
    {
    	m_fCameraInThirdPerson = false;
    	cam_command.SetValue( 0 );
    }
    
    /*
    ==============================
    CAM_ToFirstPerson
    
    ==============================
    */
    bool CInput::CAM_IsOrthographic(void) const
    {
    	return m_CameraIsOrthographic;
    }
    
    
    /*
    ==============================
    CAM_ToFirstPerson
    
    ==============================
    */
    void CInput::CAM_OrthographicSize(float& w, float& h) const
    {
    	w = c_orthowidth.GetFloat(); h = c_orthoheight.GetFloat();
    }
    
    
    /*
    ==============================
    CAM_ToFirstPerson
    
    ==============================
    */
    void CInput::CAM_ToOrthographic(void)
    {
    	m_fCameraInThirdPerson = false;
    	m_CameraIsOrthographic = true;
    	cam_command.SetValue( 0 );
    }
    
    /*
    ==============================
    CAM_StartMouseMove
    
    ==============================
    */
    void CInput::CAM_StartMouseMove(void)
    {
    	float flSensitivity;
    		
    	//only move the cam with mouse if we are in third person.
    	if ( m_fCameraInThirdPerson )
    	{
    		//set appropriate flags and initialize the old mouse position
    		//variables for mouse camera movement
    		if (!m_fCameraMovingWithMouse)
    		{
    			int cpx, cpy;
    
    			m_fCameraMovingWithMouse=true;
    			m_fCameraInterceptingMouse=true;
    #ifndef _XBOX			
    			GetMousePos(cpx, cpy);
    #else
    			// xboxfixme
    			cpx = cpy = 0;
    #endif
    			m_nCameraX = cpx;
    			m_nCameraY = cpy;
    
    			if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
    			{
    				m_nCameraOldX=m_nCameraX*flSensitivity;
    				m_nCameraOldY=m_nCameraY*flSensitivity;
    			}
    			else
    			{
    				m_nCameraOldX=m_nCameraX;
    				m_nCameraOldY=m_nCameraY;
    			}
    		}
    	}
    	//we are not in 3rd person view..therefore do not allow camera movement
    	else
    	{   
    		m_fCameraMovingWithMouse=false;
    		m_fCameraInterceptingMouse=false;
    	}
    }
    
    /*
    ==============================
    CAM_EndMouseMove
    
    the key has been released for camera movement
    tell the engine that mouse camera movement is off
    ==============================
    */
    void CInput::CAM_EndMouseMove(void)
    {
       m_fCameraMovingWithMouse=false;
       m_fCameraInterceptingMouse=false;
    }
    
    /*
    ==============================
    CAM_StartDistance
    
    routines to start the process of moving the cam in or out 
    using the mouse
    ==============================
    */
    void CInput::CAM_StartDistance(void)
    {
    	//only move the cam with mouse if we are in third person.
    	if ( m_fCameraInThirdPerson )
    	{
    	  //set appropriate flags and initialize the old mouse position
    	  //variables for mouse camera movement
    	  if (!m_fCameraDistanceMove)
    	  {
    		  int cpx, cpy;
    
    		  m_fCameraDistanceMove=true;
    		  m_fCameraMovingWithMouse=true;
    		  m_fCameraInterceptingMouse=true;
    #ifndef _XBOX
    		  GetMousePos(cpx, cpy);
    #else
    		  // xboxfixme
    		  cpx = cpy = 0;
    #endif
    
    		  m_nCameraX = cpx;
    		  m_nCameraY = cpy;
    
    		  m_nCameraOldX=m_nCameraX*gHUD.GetSensitivity();
    		  m_nCameraOldY=m_nCameraY*gHUD.GetSensitivity();
    	  }
    	}
    	//we are not in 3rd person view..therefore do not allow camera movement
    	else
    	{   
    		m_fCameraDistanceMove=false;
    		m_fCameraMovingWithMouse=false;
    		m_fCameraInterceptingMouse=false;
    	}
    }
    
    /*
    ==============================
    CAM_EndDistance
    
    the key has been released for camera movement
    tell the engine that mouse camera movement is off
    ==============================
    */
    void CInput::CAM_EndDistance(void)
    {
       m_fCameraDistanceMove=false;
       m_fCameraMovingWithMouse=false;
       m_fCameraInterceptingMouse=false;
    }
    
    /*
    ==============================
    CAM_IsThirdPerson
    
    ==============================
    */
    int CInput::CAM_IsThirdPerson( void )
    {
    	return m_fCameraInThirdPerson;
    }
    
    /*
    ==============================
    CAM_GetCameraOffset
    
    ==============================
    */
    void CInput::CAM_GetCameraOffset( Vector& ofs )
    {
    	VectorCopy( m_vecCameraOffset, ofs );
    }
    
    /*
    ==============================
    CAM_InterceptingMouse
    
    ==============================
    */
    int CInput::CAM_InterceptingMouse( void )
    {
    	return m_fCameraInterceptingMouse;
    }
    
    static ConCommand startpitchup( "+campitchup", CAM_PitchUpDown );
    static ConCommand endpitcup( "-campitchup", CAM_PitchUpUp );
    static ConCommand startpitchdown( "+campitchdown", CAM_PitchDownDown );
    static ConCommand endpitchdown( "-campitchdown", CAM_PitchDownUp );
    static ConCommand startcamyawleft( "+camyawleft", CAM_YawLeftDown );
    static ConCommand endcamyawleft( "-camyawleft", CAM_YawLeftUp );
    static ConCommand startcamyawright( "+camyawright", CAM_YawRightDown );
    static ConCommand endcamyawright( "-camyawright", CAM_YawRightUp );
    static ConCommand startcamin( "+camin", CAM_InDown );
    static ConCommand endcamin( "-camin", CAM_InUp );
    static ConCommand startcamout( "+camout", CAM_OutDown );
    static ConCommand camout( "-camout", CAM_OutUp );
    static ConCommand thirdperson( "thirdperson", ::CAM_ToThirdPerson, "Switch to thirdperson camera.", FCVAR_CHEAT );
    static ConCommand thirdperson_mayamode( "thirdperson_mayamode", ::CAM_ToThirdPerson_MayaMode, "Switch to thirdperson Maya-like camera controls.", FCVAR_CHEAT );
    static ConCommand firstperson( "firstperson", ::CAM_ToFirstPerson, "Switch to firstperson camera." );
    static ConCommand camortho( "camortho", ::CAM_ToOrthographic, "Switch to orthographic camera.", FCVAR_CHEAT );
    static ConCommand startcammousemove( "+cammousemove",::CAM_StartMouseMove);
    static ConCommand endcammousemove( "-cammousemove",::CAM_EndMouseMove);
    static ConCommand startcamdistance( "+camdistance", ::CAM_StartDistance );
    static ConCommand endcamdistance( "-camdistance", ::CAM_EndDistance );
    static ConCommand snapto( "snapto", CAM_ToggleSnapto );
    /*
    ==============================
    Init_Camera
    
    ==============================
    */
    void CInput::Init_Camera( void )
    {
    	m_CameraIsOrthographic = false;
    }
    --------------------------------------------------------------------------------------------------------------------

    please help im learning as i go basically doing small stuff and learning what errors mean what but this has me stumped.

    thanks in advance

  2. #2
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    I'm really not going to read all that code, but are all functions defined which have been declared?

    Maybe the static functions have not been implemented but used...

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    6
    i cant find any undefined functions. basically everything compiled right except this function:

    else if( input->KeyState( &cam_out ) )
    idealAngle[ 2 ] += 2*cam_idealdelta.GetFloat(); // Prevent the cam_out from going any further
    // NOTE: Without this, it _appears_ it's not moving, but
    // the transparency changes so it is... this fixes it.
    if( dist > CAM_MAX_DIST )
    dist = CAM_MIN_DIST;

    and i basically just did this off another forum idea and then i came to the next set of errors

    else if( input->KeyState( &cam_out ) )
    idealAngle[ 2 ] += 2*cam_idealdelta.GetFloat(); // Prevent the cam_out from going any further
    // NOTE: Without this, it _appears_ it's not moving, but
    // the transparency changes so it is... this fixes it.
    if( dist > CAM_MAX_DIST )
    dist == CAM_MIN_DIST;

    am i right to think this is the culprit?

  4. #4
    Registered User
    Join Date
    May 2008
    Posts
    53
    Perhaps the real problem was in the errors you "fixed". Were all those ConVar's at the top of your code really static? It looks like other object files are also referring to them.

    --
    Computer Programming: An Introduction for the Scientifically Inclined

  5. #5
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    Did you really write all that code?

    It looks very proffesional. Odd that the copyright date is old thought, and I think this needs to be in the Game Programming forum.
    I'm just trying to be a better person - My Name Is Earl

  6. #6
    Registered User
    Join Date
    May 2008
    Posts
    6
    no i didnt write that code it was an existing script that i am trying to modify.


    thanks for pointing me in the right direction. i eliminated the static from the pitch and yaw convars and it canceled out the errors so im down to two errors now.

    Creating library .\Release_hl2mp/Client.lib and object .\Release_hl2mp/Client.exp
    1>hud_lcd.obj : error LNK2019: unresolved external symbol __imp__LoadImageA@24 referenced in function "private: void __thiscall CLCD::ParseIconMappings(class KeyValues *)" (?ParseIconMappings@CLCD@@AAEXPAVKeyValues@@@Z)
    1>in_mouse.obj : error LNK2019: unresolved external symbol __imp__SystemParametersInfoA@16 referenced in function "public: virtual void __thiscall CInput::ActivateMouse(void)" (?ActivateMouse@CInput@@UAEXXZ)
    1>.\Release_hl2mp/Client.dll : fatal error LNK1120: 2 unresolved externals

    now ive gone thru every script ive modified and cant seem to find a solution as far as removing statics from new code entries. Because the LNK number is different does this mean the error is in a different script?

    any help is greatly appreciated.
    Last edited by lifeafterdeath; 05-27-2008 at 10:02 AM.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    You must link against user32.lib.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    May 2008
    Posts
    6
    it is linked to user32.lib, both server and client.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with OpenGL tutorial
    By 2Biaz in forum Windows Programming
    Replies: 18
    Last Post: 09-16-2004, 11:02 AM
  2. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 02:01 PM
  3. Book's code: Problematic
    By RoD in forum Game Programming
    Replies: 14
    Last Post: 01-21-2003, 08:08 AM
  4. Help with error
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 04-17-2002, 09:36 AM
  5. Compiler errors
    By BellosX in forum C Programming
    Replies: 2
    Last Post: 09-21-2001, 03:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21