473,394 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Compiling error: local function definitions are illegal?

1
Im compiling and everytime i get this error on this line :x...can anybody help me please so much?



Expand|Select|Wrap|Line Numbers
  1. #include "r3dPCH.h"
  2. #include "r3d.h"
  3.  
  4. #include "r3dBackgroundTaskDispatcher.h"
  5.  
  6. #include "d3dfont.h"
  7.  
  8. #include "GameCommon.h"
  9. #include "Gameplay_Params.h"
  10.  
  11. #include "UI\HUD_TPSGame.h"
  12. #include "ObjectsCode/AI/AI_Player.h"
  13. #include "ObjectsCode/AI/AI_PlayerAnim.h"
  14. #include "ObjectsCode/Gameplay/BasePlayerSpawnPoint.h"
  15. #include "ObjectsCode/weapons/WeaponArmory.h"
  16.  
  17. #include "APIScaleformGfx.h"
  18.  
  19. #include "multiplayer/ClientGameLogic.h"
  20.  
  21. #include "HUDCameraEffects.h"
  22.  
  23. #include "UI\HUDDisplay.h"
  24. #include "UI\HUDPause.h"
  25. #include "UI\HUDAttachments.h"
  26. #include "UI\HUDActionUI.h"
  27. #include "UI\HUDGeneralStore.h"
  28. #include "UI\HUDVault.h"
  29.  
  30. #include "..\GameEngine\gameobjects\obj_Vehicle.h"
  31.  
  32. #include "rendering/Deffered/D3DMiscFunctions.h"
  33.  
  34. extern float GameFOV;
  35.  
  36. HUDDisplay*    hudMain = NULL;
  37. HUDPause*    hudPause = NULL;
  38. HUDAttachments*    hudAttm = NULL;
  39. HUDActionUI*    hudActionUI = NULL;
  40. HUDGeneralStore* hudGeneralStore = NULL;
  41. HUDVault* hudVault = NULL;
  42.  
  43. #define VEHICLE_CINEMATIC_MODE 0
  44.  
  45. void TPSGameHUD_AddHitEffect(GameObject* from)
  46. {
  47.     obj_Player* pl = gClientLogic().localPlayer_;
  48.     if(!pl) return;
  49.     if(pl->bDead) return;
  50.  
  51.     pl->BloodEffect = 3.0f;
  52. }
  53.  
  54.  
  55.  
  56. TPSGameHUD::TPSGameHUD()
  57. {
  58.     FPS_Acceleration.Assign(0,0,0);
  59.     FPS_vViewOrig.Assign(0,0,0);
  60.     FPS_ViewAngle.Assign(0,0,0);
  61.     FPS_vVision.Assign(0,0,0);
  62.     FPS_vRight.Assign(0,0,0);
  63.     FPS_vUp.Assign(0,0,0);
  64.     FPS_vForw.Assign(0,0,0);
  65.     cameraRayLen = 20000.0f;
  66. }
  67.  
  68. TPSGameHUD::~TPSGameHUD()
  69. {
  70. }
  71.  
  72. static bool TPSGameHud_Inited;
  73. void TPSGameHUD_OnStartGame()
  74. {
  75.     const GBGameInfo& ginfo = gClientLogic().m_gameInfo;
  76.  
  77.     hudMain = new HUDDisplay();
  78.     hudPause = new HUDPause();
  79.     hudActionUI = new HUDActionUI();
  80.     hudAttm = new HUDAttachments();
  81.     hudGeneralStore = new HUDGeneralStore();
  82.     hudVault = new HUDVault();
  83.  
  84.     hudMain->Init();
  85.     hudPause->Init();
  86.     hudActionUI->Init();
  87.     hudAttm->Init();
  88.     hudGeneralStore->Init();
  89.     hudVault->Init();
  90.  
  91.     Mouse->Hide(true);
  92.     // lock mouse to a window when playing a game
  93.     d_mouse_window_lock->SetBool(true);
  94.     Mouse->SetRange(r3dRenderer->HLibWin);
  95.  
  96.  
  97.     extern int g_CCBlackWhite;
  98.     extern float g_fCCBlackWhitePwr;
  99.     g_CCBlackWhite = false;
  100.     g_fCCBlackWhitePwr = 0.0f;
  101.  
  102.     TPSGameHud_Inited = true;
  103. }
  104.  
  105. void TPSGameHUD :: DestroyPure()
  106. {
  107.     if(TPSGameHud_Inited)
  108.     {
  109.         TPSGameHud_Inited = false;
  110.  
  111.         hudPause->Unload();
  112.         hudMain->Unload();
  113.         hudActionUI->Unload();
  114.         hudAttm->Unload();
  115.         hudGeneralStore->Unload();
  116.         hudVault->Unload();
  117.  
  118.         SAFE_DELETE(hudMain);
  119.         SAFE_DELETE(hudPause);
  120.         SAFE_DELETE(hudActionUI);
  121.         SAFE_DELETE(hudAttm);
  122.         SAFE_DELETE(hudGeneralStore);
  123.         SAFE_DELETE(hudVault);
  124.     }
  125. }
  126.  
  127. void TPSGameHUD :: SetCameraDir (r3dPoint3D vPos )
  128. {
  129.  
  130. }
  131.  
  132. r3dPoint3D TPSGameHUD :: GetCameraDir () const
  133. {
  134.     return r3dVector(1,0,0);
  135. }
  136.  
  137.  
  138. extern    PlayerStateVars_s TPSHudCameras[3][PLAYER_NUM_STATES];
  139. extern    Playerstate_e ActiveCameraRigID;
  140. extern    PlayerStateVars_s ActiveCameraRig;
  141.  
  142. extern     Playerstate_e CurrentState;
  143. extern     PlayerStateVars_s CurrentRig;
  144. extern     PlayerStateVars_s SourceRig;
  145. extern     PlayerStateVars_s TargetRig;
  146. extern     float LerpValue;
  147. extern    r3dPoint3D TPSHudCameraTarget;
  148.  
  149. extern  float    TPSCameraPointToAdj[3];
  150. extern  float   TPSCameraPointToAdjCrouch[3];
  151.  
  152. void TPSGameHUD :: InitPure()
  153. {
  154.     // reinit hud rigs based on camera mode
  155.     CurrentRig = TPSHudCameras[g_camera_mode->GetInt()][PLAYER_IDLE];
  156.     SourceRig  = CurrentRig;
  157.     TargetRig  = CurrentRig;
  158. }
  159.  
  160.  
  161. // camPos = current camera pos. target = player's head pos
  162. bool CheckCameraCollision(r3dPoint3D& camPos, const r3dPoint3D& target, bool checkCamera)
  163. {
  164.     R3DPROFILE_FUNCTION("CheckCameraCollision");
  165.  
  166.     r3dPoint3D origCamPos = camPos;
  167.     int LoopBreaker = 0;
  168.  
  169.     r3dPoint3D motion = (camPos - target);
  170.     float motionLen = motion.Length();
  171.     int MaxLoopBreaker = 10;
  172.     if(motionLen > 0.1f)
  173.     {
  174.         motion.Normalize();
  175.         MaxLoopBreaker = int(ceilf(motionLen/0.05f));
  176.  
  177.         PxSphereGeometry camSphere(0.3f);
  178.         PxTransform camPose(PxVec3(target.x, target.y, target.z), PxQuat(0,0,0,1));
  179.  
  180.         PxSweepHit sweepResults[32];
  181.         bool blockingHit;
  182.         PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_PLAYER_COLLIDABLE_MASK, 0, 0, 0), PxSceneQueryFilterFlag::eSTATIC|PxSceneQueryFilterFlag::eDYNAMIC);
  183.         while(int numRes=g_pPhysicsWorld->PhysXScene->sweepMultiple(camSphere, camPose, PxVec3(motion.x, motion.y, motion.z), motionLen, PxSceneQueryFlag::eINITIAL_OVERLAP|PxSceneQueryFlag::eNORMAL, sweepResults, 32, blockingHit, filter) && LoopBreaker<MaxLoopBreaker)
  184.         {
  185.             if(numRes == -1)
  186.             {
  187.                 r3d_assert(false);
  188.                 break;
  189.             }
  190.             /* PxVec3 collNormal = PxVec3(0,0,0);
  191.             for(int i=0; i<numRes; ++i)
  192.             {
  193.             collNormal += sweepResults[i].normal;
  194.             }
  195.  
  196.             collNormal.normalize();*/
  197.  
  198.             //r3dPoint3D tmp(collNormal.x, collNormal.y, collNormal.z);
  199.             r3dPoint3D tmp = -motion;
  200.             tmp.Normalize();
  201.             camPos += tmp * 0.05f;
  202.  
  203.             LoopBreaker++;
  204.  
  205.             motion = (camPos - target);
  206.             motionLen = motion.Length();
  207.             if(motionLen < 0.005f)
  208.             {
  209.                 LoopBreaker = MaxLoopBreaker;
  210.                 break;
  211.             }
  212.             motion.Normalize();
  213.         }
  214.     }
  215.  
  216.     if(checkCamera)
  217.     {
  218.         extern bool g_CameraInsidePlayer;
  219.         if((camPos - target).Length() < 0.6f)
  220.             g_CameraInsidePlayer = true;
  221.         else
  222.             g_CameraInsidePlayer = false;
  223.  
  224.         if(g_camera_mode->GetInt()==2) // in FPS mode this check not needed
  225.             g_CameraInsidePlayer = false;
  226.     }
  227.  
  228.     return (LoopBreaker == MaxLoopBreaker);
  229. }
  230.  
  231. float g_shootCameraShakeTimer = 0.0f;
  232. void Get_Camera_Bob(r3dPoint3D& camBob, r3dPoint3D& camUp, const obj_Player* player)
  233. {
  234.     r3d_assert(player);
  235.     camBob.Assign(0,0,0);
  236.     camUp.Assign(0,1,0);
  237.  
  238.     static float accumul = 0.0f;
  239.     accumul += r3dGetFrameTime()*1.0f*u_GetRandom(0.75f, 1.25f);
  240.  
  241.  
  242.     // only use this in FPS, but calculate out here.
  243.  
  244.     float wave = r3dSin(accumul) * g_shootCameraShakeTimer;
  245.     if(g_shootCameraShakeTimer>0)
  246.     {
  247.         g_shootCameraShakeTimer = R3D_MAX(g_shootCameraShakeTimer-r3dGetFrameTime()*3.f, 0.0f);
  248.     }
  249.  
  250.     if(g_camera_mode->GetInt()==2)
  251.     {
  252.         r3dPoint3D up(0,1,0);
  253.         r3dPoint3D rightVector = player->m_vVision.Cross( up );
  254.         up.RotateAroundVector(rightVector, wave*20.0f );
  255.  
  256.         camUp = up;
  257.  
  258.         float mStepDist = 0.1f;
  259.         r3dPoint3D mCurPos = player->GetPosition();
  260.         mCurPos -= player->oldstate.Position;
  261.         float len = mCurPos.Length();
  262.  
  263.         //BP ok, make step distance the lenth of the anim
  264.         // then len, is the current frame converted to percent :)
  265.         std::vector<r3dAnimation::r3dAnimInfo>::iterator it;
  266.         float curframe = 0;
  267.         float numframe = 0;
  268.         for(it = player->uberAnim_->anim.AnimTracks.begin(); it != player->uberAnim_->anim.AnimTracks.end(); ++it) 
  269.         {
  270.             r3dAnimation::r3dAnimInfo &ai = *it;
  271.             if(!(ai.dwStatus & ANIMSTATUS_Playing)) 
  272.                 continue;
  273.             if(!(ai.dwStatus & ANIMSTATUS_Paused)) 
  274.             {
  275.                 if(ai.pAnim && ai.pAnim->NumFrames < 60)
  276.                 {
  277.                     curframe = ai.fCurFrame;
  278.                     numframe = (float)ai.pAnim->NumFrames;
  279.                     break;
  280.                 }
  281.             }
  282.         }
  283.         if(player->PlayerState == PLAYER_MOVE_SPRINT)
  284.             mStepDist *=2;
  285.  
  286.         float mWave = 0;
  287.         bool rightlean = true;
  288.         if(numframe > 0)
  289.         {
  290.             mWave = curframe / numframe; 
  291.  
  292.             // want to go 0-1-0 at 0,50,100
  293.             // want to go 0-1-0-(-1)-0 at 0,25,50,75,100
  294.              if(mWave >= 0.5f)
  295.             {    
  296.                 mWave -= 0.5f;
  297.                 rightlean = false; 
  298.             } else 
  299.             {
  300.                 rightlean = true; 
  301.  
  302.             }
  303.  
  304.              mWave *=2;
  305.             // if greater than .5, subtract .5 to make 0.5
  306.             // now go back down to zero if > .5
  307.             if(mWave >= 0.5f)
  308.                 mWave = 1.0f - mWave;
  309.             mWave *=2;
  310.         }
  311.  
  312.         float boba = 0.1f;
  313.         float rolla = 0.2f;
  314.  
  315.         // in aim mode no bob
  316.         switch ( player->PlayerState)
  317.         {
  318.         case PLAYER_MOVE_WALK_AIM:
  319.             // crouch mode no bob
  320.         case PLAYER_MOVE_CROUCH: // intentional fallthrough
  321.         case PLAYER_MOVE_CROUCH_AIM:// intentional fallthrough
  322.         case PLAYER_MOVE_PRONE: // intentional fallthrough
  323.         case PLAYER_PRONE_AIM:// intentional fallthrough
  324.         case PLAYER_PRONE_IDLE:// intentional fallthrough
  325.         case PLAYER_IDLE:// intentional fallthrough
  326.         case PLAYER_IDLEAIM:// intentional fallthrough
  327.             // no bob if turn in place or idle
  328.             {
  329.                 mWave = 0; 
  330.                 boba = 0.0f;
  331.             }
  332.             break;
  333.         // lower bob on low speed
  334.         case PLAYER_MOVE_RUN:
  335.             {
  336.                 boba *= .6f; // yeah this doesn't do anything, it's here in case we want to tweak it. 
  337.                 rolla = 1;
  338.             }
  339.             break;
  340.         case PLAYER_MOVE_SPRINT:
  341.  
  342.             {
  343.                 boba *=1.0f; 
  344.                 rolla = 2;
  345.             }
  346.             break;
  347.         }
  348.  
  349.         //boba = 0; // disable bob
  350.         camBob.y = boba * sin(mWave * R3D_PI_2);
  351.  
  352.         r3dPoint3D p(0,1,0);
  353.  
  354.         float _angle = sin(mWave * R3D_PI_2 ) * rolla;
  355.         if(_angle < 0)
  356.             _angle += 360.0f;
  357.         else if(_angle > 360.0f)
  358.             _angle -=360.0f;
  359.  
  360.         if ( rightlean == false ) 
  361.         {
  362.             _angle = -(_angle);
  363.         }
  364.  
  365.         p.RotateAroundZ(_angle);
  366.         p.Normalize();
  367.  
  368.         // this currently will half the camUp's lean.  But the system works with this. 
  369.         camUp = camUp + p;
  370.         camUp.Normalize();
  371.     }
  372.  
  373.     return;
  374.  
  375. }
  376.  
  377. static bool g_CameraPointToAdj_HasAdjustedVec = false;
  378. static r3dPoint3D g_CameraPointToAdj_adjVec(0,0,0);
  379. static r3dPoint3D g_CameraPointToAdj_nextAdjVec(0,0,0);
  380.  
  381. float        g_CameraLeftSideSource = -0.7f;
  382. float        g_CameraLeftSideTarget = 1.0f;
  383. float        g_CameraLeftSideLerp = 1.0f;
  384.  
  385. float        getCameraLeftSide()
  386. {
  387.     return R3D_LERP(g_CameraLeftSideSource, g_CameraLeftSideTarget, g_CameraLeftSideLerp);
  388. }
  389.  
  390. void        updateCameraLeftSide()
  391. {
  392.     if(g_CameraLeftSideLerp < 1.0f)
  393.         g_CameraLeftSideLerp = R3D_CLAMP(g_CameraLeftSideLerp+r3dGetFrameTime()*5.0f, 0.0f, 1.0f);
  394. }
  395.  
  396. r3dPoint3D getAdjustedPointTo(obj_Player* pl, const r3dPoint3D& PointTo, const r3dPoint3D& CamPos)
  397. {
  398.     if(g_camera_mode->GetInt()==2)
  399.         return R3D_ZERO_VECTOR;
  400.  
  401.     static r3dPoint3D currentLookAt(0,0,0);
  402.     static float      currentLookAtDist = 0.0f;
  403.     if(LerpValue == 1.0f)
  404.     {
  405.         //r3dOutToLog("Lerp finished\n");
  406.         g_CameraPointToAdj_adjVec = g_CameraPointToAdj_nextAdjVec;
  407.     }
  408.     else if(!g_CameraPointToAdj_HasAdjustedVec)
  409.     {
  410.         {
  411.             r3dPoint3D dir;
  412.             if(pl->m_isInScope || g_camera_mode->GetInt() != 1 )
  413.                 r3dScreenTo3D(r3dRenderer->ScreenW2, r3dRenderer->ScreenH2, &dir);
  414.             else
  415.                 r3dScreenTo3D(r3dRenderer->ScreenW2, r3dRenderer->ScreenH*0.32f, &dir);
  416.  
  417.             PxRaycastHit hit;
  418.             PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK|(1<<PHYSCOLL_NETWORKPLAYER), 0, 0, 0), PxSceneQueryFilterFlag::eSTATIC|PxSceneQueryFilterFlag::eDYNAMIC);
  419.             if(g_pPhysicsWorld->raycastSingle(PxVec3(gCam.x, gCam.y, gCam.z), PxVec3(dir.x, dir.y, dir.z), 2000.0f, PxSceneQueryFlag::eIMPACT|PxSceneQueryFlag::eDISTANCE, hit, filter))
  420.             {
  421.                 currentLookAt.Assign(hit.impact.x, hit.impact.y, hit.impact.z);
  422.                 currentLookAtDist = hit.distance;
  423.             }
  424.             else
  425.             {
  426.                 currentLookAt = CamPos + dir * 1000.0f;
  427.                 currentLookAtDist = 1000.0f;
  428.             }
  429.         }
  430.  
  431.  
  432.         g_CameraPointToAdj_HasAdjustedVec = true;
  433.         r3dPoint3D DestCamPos = pl->GetPosition();
  434.         r3dPoint3D offset;
  435.         if(pl->hasScopeMode())
  436.         {
  437.             offset =  r3dPoint3D( 0, (pl->getPlayerHeightForCamera() +  TargetRig.ScopePosition.Y), 0 );
  438.             offset += pl->GetvRight() * TargetRig.ScopePosition.X;
  439.             offset += pl->m_vVision * (TargetRig.ScopePosition.Z);
  440.         }
  441.         else
  442.         {
  443.             offset =  r3dPoint3D( 0, (pl->getPlayerHeightForCamera() +  TargetRig.Position.Y), 0 );
  444.             offset += pl->GetvRight() * TargetRig.Position.X * getCameraLeftSide();
  445.             offset += pl->m_vVision * (TargetRig.Position.Z);
  446.         }
  447.  
  448.         DestCamPos += offset;
  449.  
  450.         r3dPoint3D playerPosHead = pl->GetPosition(); playerPosHead.y += pl->getPlayerHeightForCamera();
  451.         CheckCameraCollision(DestCamPos, playerPosHead, false);
  452.  
  453.         r3dPoint3D curViewVec = PointTo - CamPos;
  454.         curViewVec.Normalize();
  455.  
  456.         r3dPoint3D destViewVec = PointTo - DestCamPos;
  457.         destViewVec.Normalize();
  458.  
  459.         r3dPoint3D curLookAt = currentLookAt;
  460.         if(!pl->hasScopeMode() &&  g_camera_mode->GetInt() == 1 ) // we only need this offset in offcenter mode.
  461.         {
  462.             float fHeight = currentLookAtDist * tan(R3D_DEG2RAD(TargetRig.FOV) * 0.5f);
  463.             curLookAt.y -= fHeight * 0.35f;
  464.         }
  465.         r3dPoint3D destViewVec2 = curLookAt - DestCamPos;
  466.         destViewVec2.Normalize();
  467.  
  468.        /* float d1 = pl->m_vVision.Dot(destViewVec);
  469.         float d2 = pl->m_vVision.Dot(destViewVec2);
  470.         if(!pl->hasScopeMode())
  471.             if(d2 < 0.99f)
  472.                 destViewVec2 = destViewVec;*/
  473.  
  474.         //r3dOutToLog("Lerp=%.2f, pl_state=%d, aiming=%d\n", LerpValue, pl->PlayerState, pl->m_isAiming);
  475.  
  476.         static bool wasAiming = false;
  477.         if(pl->m_isAiming)
  478.         {
  479.             if(!wasAiming)
  480.             {
  481.                 wasAiming = true;
  482.                 if(currentLookAtDist < 5.0f && pl->hasScopeMode())
  483.                     g_CameraPointToAdj_nextAdjVec = r3dPoint3D(0,0.25f,0);
  484.                 else
  485.                     g_CameraPointToAdj_nextAdjVec = destViewVec2 - destViewVec;
  486.             }
  487.         }
  488.         else
  489.         {
  490.             wasAiming = false;
  491.             g_CameraPointToAdj_nextAdjVec = r3dPoint3D(0,0,0);
  492.         }
  493.  
  494.         //r3dOutToLog("(%d): %.2f, %.2f\n", pl->m_isAiming, d1, d2);
  495.         //r3dOutToLog("switching (%d): %.2f, %.2f, %.2f; %.2f\n", pl->m_isAiming, g_CameraPointToAdj_nextAdjVec.x, g_CameraPointToAdj_nextAdjVec.y, g_CameraPointToAdj_nextAdjVec.z, currentLookAtDist);
  496.         //r3dOutToLog("vec: %.2f, %.2f, %.2f; %.2f, %.2f, %.2f\n", destViewVec.x, destViewVec.y, destViewVec.z, destViewVec2.x, destViewVec2.y, destViewVec2.z);
  497.     }
  498.  
  499.     return R3D_LERP(g_CameraPointToAdj_adjVec, g_CameraPointToAdj_nextAdjVec, LerpValue);
  500. }
  501.  
  502. extern float DepthOfField_NearStart;
  503. extern float DepthOfField_NearEnd;
  504. extern float DepthOfField_FarStart;
  505. extern float DepthOfField_FarEnd;
  506. extern int _FAR_DOF;
  507. extern int _NEAR_DOF;
  508. extern int LevelDOF;
  509.  
  510. // runs in actual game
  511. int spectator_observingPlrIdx = 0;
  512. r3dPoint3D spectator_cameraPos(0,0,0);
  513. void TPSGameHUD :: SetCameraPure ( r3dCamera &Cam)
  514. {
  515. #ifndef FINAL_BUILD
  516.     if(d_video_spectator_mode->GetBool() || d_observer_mode->GetBool())
  517.     {
  518.         r3dPoint3D CamPos = FPS_Position;
  519.         CamPos.Y += 1.8f;
  520.         r3dPoint3D ViewPos = CamPos + FPS_vVision*10.0f;
  521.  
  522.         Cam.FOV = r_video_fov->GetFloat();
  523.         Cam.SetPosition( CamPos );
  524.         Cam.PointTo(ViewPos);
  525.  
  526.         LevelDOF = r_video_DOF_enable->GetBool();
  527.         _NEAR_DOF = 1;
  528.         _FAR_DOF = 1;
  529.         DepthOfField_NearStart = r_video_nearDOF_start->GetFloat();
  530.         DepthOfField_NearEnd = r_video_nearDOF_end->GetFloat();
  531.         DepthOfField_FarStart = r_video_farDOF_start->GetFloat();
  532.         DepthOfField_FarEnd = r_video_farDOF_end->GetFloat();
  533.  
  534.         return;
  535.     }
  536. #endif
  537.  
  538.     const ClientGameLogic& CGL = gClientLogic();
  539.     obj_Player* pl = CGL.localPlayer_;
  540.     if(pl == 0)
  541.     {
  542.         return;
  543.     }
  544.  
  545.     extern bool SetCameraPlayerVehicle(const obj_Player* pl, r3dCamera &Cam);
  546.     if(SetCameraPlayerVehicle(pl, Cam))
  547.     {
  548.         FPS_Position = Cam;
  549.         return;
  550.     }
  551.  
  552.  
  553.     // dead camera
  554.     if(pl->bDead)
  555.     {
  556.         r3dPoint3D camPos, camPointTo;
  557.         bool do_camera = false;
  558.         bool check_cam_collision = true;
  559.         {
  560.             static r3dPoint3D oldPlayerPos(0,0,0);
  561.             static r3dPoint3D camPosOffset(0,0,0);
  562.             camPointTo = pl->GetPosition();
  563.  
  564.             // find a cam position
  565.             if(!oldPlayerPos.AlmostEqual(pl->GetPosition())) // make sure to do that check only once
  566.             {
  567.                 oldPlayerPos = pl->GetPosition();
  568.                 r3dPoint3D possible_cam_offset[4] = {r3dPoint3D(-3, 5, -3), r3dPoint3D(3, 5, -3), r3dPoint3D(-3, 5, 3), r3dPoint3D(3, 5, 3)};
  569.                 int found=-1;
  570.                 for(int i=0; i<4; ++i)
  571.                 {
  572.                     r3dPoint3D raydir = ((pl->GetPosition()+possible_cam_offset[i]) - camPointTo);
  573.                     float rayLen = raydir.Length();
  574.                     if(rayLen > 0)
  575.                     {
  576.                         raydir.Normalize();
  577.                         PxRaycastHit hit;
  578.                         PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK, 0, 0, 0), PxSceneQueryFilterFlag::eSTATIC);
  579.                         if(!g_pPhysicsWorld->raycastSingle(PxVec3(camPointTo.x, camPointTo.y, camPointTo.z), PxVec3(raydir.x, raydir.y, raydir.z), rayLen, PxSceneQueryFlag::eIMPACT, hit, filter))
  580.                         {
  581.                             found = i;
  582.                             break;
  583.                         }
  584.                     }
  585.                 }
  586.                 if(found!=-1)
  587.                 {
  588.                     camPosOffset = possible_cam_offset[found];
  589.                 }
  590.                 else
  591.                 {
  592.                     camPosOffset = r3dPoint3D(-0.1f, 5, -0.1f);
  593.                 }
  594.             }
  595.  
  596.             camPos = pl->GetPosition() + camPosOffset; 
  597.             do_camera = true;
  598.             check_cam_collision = false;
  599.         }
  600.  
  601.         if(do_camera)
  602.         {
  603.             extern int g_CCBlackWhite;
  604.             extern float g_fCCBlackWhitePwr;
  605.             g_CCBlackWhite = 1;
  606.             g_fCCBlackWhitePwr = R3D_CLAMP((r3dGetTime() - pl->TimeOfDeath)/2.0f, 0.0f, 1.0f); // go to black and white while look at our dead body
  607.  
  608.             // check for collision
  609.             if(check_cam_collision)
  610.                 CheckCameraCollision(camPos, camPointTo, false);
  611.  
  612.             Cam.FOV = 60;
  613.             Cam.SetPosition( camPos );
  614.             Cam.PointTo( camPointTo );
  615.             FPS_Position = Cam;
  616.             return;
  617.         }
  618.     }
  619.  
  620.     if(pl->bDead && hudAttm->isActive())
  621.         hudAttm->Deactivate();
  622.  
  623.     if(hudPause->isActive())
  624.         return;
  625.     if(hudAttm->isActive())
  626.         return;
  627.     if(hudGeneralStore->isActive())
  628.         return;
  629.     if(hudVault->isActive())
  630.         return;
  631.  
  632.     int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY;
  633.     if(g_vertical_look->GetBool()) // invert mouse
  634.         mMY = -mMY;
  635.  
  636.     GameFOV = CurrentRig.FOV;
  637.  
  638.     float CharacterHeight = pl->getPlayerHeightForCamera();
  639.     r3dPoint3D CamPos = pl->GetPosition();
  640.     CamPos.Y +=  (CharacterHeight+  CurrentRig.Position.Y);
  641.     updateCameraLeftSide();
  642.     CamPos += pl->GetvRight() * CurrentRig.Position.X * getCameraLeftSide();
  643.     CamPos += pl->m_vVision * CurrentRig.Position.Z;
  644.  
  645.     r3dPoint3D playerPos = pl->GetPosition();
  646.     r3dPoint3D playerPosHead = playerPos; playerPosHead.y += CharacterHeight;
  647.     r3dPoint3D PointTo = playerPos;
  648.     PointTo.Y += (CharacterHeight + TPSHudCameraTarget.Y);
  649.     PointTo += pl->GetvRight() * TPSHudCameraTarget.X;
  650.  
  651.     // check for collision
  652.     {
  653.         r3dPoint3D savedCamPos = CamPos;
  654.         if(CheckCameraCollision(CamPos, playerPosHead, true) && (pl->PlayerState == PLAYER_MOVE_CROUCH || pl->PlayerState == PLAYER_MOVE_CROUCH_AIM || pl->PlayerState == PLAYER_MOVE_PRONE || pl->PlayerState == PLAYER_PRONE_AIM || pl->PlayerState == PLAYER_PRONE_IDLE)) 
  655.         {
  656.             CamPos = savedCamPos;
  657.             playerPosHead = playerPos;
  658.             playerPosHead.y += CharacterHeight-0.8f;
  659.             CheckCameraCollision(CamPos, playerPosHead, true);
  660.         }
  661.     }
  662.  
  663.     PointTo += (pl->m_vVision) * 50;//cameraRayLen;//CurrentRig.Target.Z;
  664.  
  665.     r3dPoint3D adjPointTo(0,0,0);
  666.     adjPointTo = getAdjustedPointTo(pl, PointTo, CamPos);
  667.  
  668.     r3dPoint3D camBob, camUp;
  669.     Get_Camera_Bob(camBob, camUp, pl);
  670.  
  671.     Cam.FOV = GameFOV;
  672.     Cam.SetPosition( CamPos + camBob );
  673.     Cam.PointTo(PointTo + camBob);
  674.     Cam.vUP = camUp;
  675.  
  676.     Cam.vPointTo += adjPointTo;
  677.  
  678. #ifndef FINAL_BUILD
  679.     if( g_pHUDCameraEffects )
  680.     {
  681.         g_pHUDCameraEffects->Update( &Cam, CamPos ) ;
  682.     }
  683. #endif
  684.  
  685.     FPS_Position = Cam;
  686. }  
  687.  
  688. static void DrawMenus()
  689. {
  690. #ifndef FINAL_BUILD
  691.     if(d_video_spectator_mode->GetBool() && !d_observer_mode->GetBool()) // no UI in spectator mode
  692.         return;
  693.     if(d_disable_game_hud->GetBool())
  694.         return;
  695. #endif
  696.  
  697. #if 0
  698.     typedef std::vector<std::string> stringlist_t;
  699.     extern stringlist_t currentMovies ;
  700.  
  701.     typedef std::vector< float > floats ;
  702.     extern floats movieDurations ;
  703.  
  704.     char buff[ 512 ] ;
  705.     sprintf( buff, "%d - Num Drawcalls", r3dRenderer->Stats.NumDraws );
  706.  
  707.     currentMovies.push_back( buff );
  708.     movieDurations.push_back( 0.1f );
  709.  
  710.     typedef std::vector< int > sorties ;
  711.     static sorties ss ;
  712.  
  713.     ss.resize( movieDurations.size() );
  714.  
  715.     for( int i = 0, e = movieDurations.size(); i < e; i ++ )
  716.     {
  717.         ss[ i ] = i ;
  718.     }
  719.  
  720.     for( int i = 0, e = movieDurations.size(); i < e; i ++ )
  721.     {
  722.         for( int j = 0, e = movieDurations.size() - 1 ; j < e; j ++ )
  723.         {
  724.             if( movieDurations[ ss[ j ] ] > movieDurations[ ss[ j + 1 ] ] )
  725.             {
  726.                 std::swap( ss[ j ], ss[ j + 1 ] );
  727.             }
  728.         }
  729.     }
  730.  
  731.     r3dSetFiltering( R3D_POINT );
  732.  
  733.     r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHATESTENABLE,     FALSE );
  734.     r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHAREF,            1 );
  735.  
  736.     r3dRenderer->SetMaterial(NULL);
  737.     r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA);
  738.  
  739.     for( int i = 0, e = (int)currentMovies.size(); i < e; i ++ )
  740.     {
  741.         Font_Label->PrintF(r3dRenderer->ScreenW - 330, r3dRenderer->ScreenH-e*22 - 220 + i*22,r3dColor(255,255,255), "%.1f - %s", movieDurations[ ss[ i ] ] * 1000.f, currentMovies[ ss[ i ] ].c_str() );
  742.     }
  743.  
  744.     currentMovies.clear();
  745.     movieDurations.clear();
  746.  
  747.     r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHATESTENABLE,     FALSE );
  748.     r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHAREF,            1 );
  749.  
  750.     r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA | R3D_BLEND_NZ);
  751. #endif
  752.  
  753.     if(!win::bSuspended && !hudMain->isChatInputActive() && !hudMain->isPlayersListVisible()) 
  754.     {
  755.         bool showHudPause = Keyboard->WasPressed(kbsEsc) || InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_SWITCH_MINIMAP) || InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_INVENTORY);
  756.         if(showHudPause && !hudAttm->isActive() && !hudGeneralStore->isActive() && !hudVault->isActive())
  757.         {
  758.             if(!hudPause->isActive())
  759.             {
  760.                 hudPause->Activate();
  761.                 if(InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_SWITCH_MINIMAP))
  762.                     hudPause->showMap();
  763.                 else if(InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_INVENTORY))
  764.                     hudPause->showInventory();
  765.             }
  766.             else
  767.                 hudPause->Deactivate();
  768.         }
  769.  
  770.         bool showAttachment = InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_SHOW_ATTACHMENTS);
  771.         if(showAttachment)
  772.         {
  773.             if(!hudAttm->isActive())
  774.             {
  775.                 hudAttm->Activate();
  776.             }
  777.             else
  778.                 hudAttm->Deactivate();
  779.         }
  780.  
  781.         if(hudAttm->isActive() && Keyboard->WasPressed(kbsEsc))
  782.             hudAttm->Deactivate();
  783.  
  784.         if(hudGeneralStore->isActive() && Keyboard->WasPressed(kbsEsc))
  785.             hudGeneralStore->Deactivate();
  786.  
  787.         if(hudVault->isActive() && Keyboard->WasPressed(kbsEsc))
  788.             hudVault->Deactivate();
  789.     }
  790.  
  791.     if(hudPause->isActive())
  792.     {
  793.         r3dMouse::Show(); // make sure that mouse is visible
  794.  
  795.         R3DPROFILE_START( "hudPause->" );
  796.  
  797.         hudPause->Update();
  798.         hudPause->Draw();
  799.  
  800.         R3DPROFILE_END( "hudPause->" );
  801.  
  802.         return;
  803.     }
  804.  
  805.     if(hudAttm->isActive())
  806.     {
  807.         r3dMouse::Show(); // make sure that mouse is visible
  808.  
  809.         R3DPROFILE_START( "hudAttm->" );
  810.  
  811.         hudAttm->Update();
  812.         hudAttm->Draw();
  813.  
  814.         R3DPROFILE_END( "hudAttm->" );
  815.  
  816.         return;
  817.     }
  818.  
  819.     if(hudGeneralStore->isActive())
  820.     {
  821.         r3dMouse::Show(); // make sure that mouse is visible
  822.  
  823.         R3DPROFILE_START( "hudGeneralStore->" );
  824.  
  825.         hudGeneralStore->Update();
  826.         hudGeneralStore->Draw();
  827.  
  828.         R3DPROFILE_END( "hudGeneralStore->" );
  829.  
  830.         return;
  831.     }
  832.  
  833.     if(hudVault->isActive())
  834.     {
  835.         r3dMouse::Show(); // make sure that mouse is visible
  836.  
  837.         R3DPROFILE_START( "hudVault->" );
  838.  
  839.         hudVault->Update();
  840.         hudVault->Draw();
  841.  
  842.         R3DPROFILE_END( "hudVault->" );
  843.  
  844.         return;
  845.     }
  846.  
  847.     if(hudActionUI->isActive())
  848.     {
  849.         R3DPROFILE_START( "hudActionUI->" );
  850.         hudActionUI->Update();
  851.         hudActionUI->Draw();
  852.         R3DPROFILE_END( "hudActionUI->" );
  853.     }
  854.  
  855.  
  856.     bool ChatWindowSwitch = InputMappingMngr->wasReleased(r3dInputMappingMngr::KS_CHAT);
  857.  
  858.     const ClientGameLogic& CGL = gClientLogic();
  859.     const obj_Player* pl = CGL.localPlayer_; // can be null
  860.     if(pl == NULL) // no player, we need to show respawn menu and let player enter game
  861.     {
  862.     }
  863.     else
  864.     {
  865.         // check for respawn screen
  866.         if(pl->bDead) 
  867.         {
  868.         }
  869.         else
  870.         {
  871.         }
  872.  
  873.         if(ChatWindowSwitch && hudMain && !hudMain->isChatInputActive())
  874.         {
  875.             hudMain->showChatInput();
  876.         }
  877.  
  878.         if(hudMain)
  879.         {
  880.             if(InputMappingMngr->wasReleased(r3dInputMappingMngr::KS_CHAT_CHANNEL1))
  881.                 hudMain->setChatChannel(0);
  882.             if(InputMappingMngr->wasReleased(r3dInputMappingMngr::KS_CHAT_CHANNEL2))
  883.                 hudMain->setChatChannel(1);
  884.             if(InputMappingMngr->wasReleased(r3dInputMappingMngr::KS_CHAT_CHANNEL3))
  885.                 hudMain->setChatChannel(2);
  886.         }
  887.  
  888.         if(hudMain && !hudMain->isChatInputActive())
  889.         {
  890.             bool showPlayerList = InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_SHOW_PLAYERS);
  891.             if(showPlayerList)
  892.             {
  893.                 if (!hudMain->isPlayersListVisible())
  894.                 {
  895.                     hudMain->clearPlayersList();
  896.                     int index = 0;
  897.                     for(int i=0; i<R3D_ARRAYSIZE(CGL.playerNames); i++)
  898.                     {
  899.                         if(CGL.playerNames[i].Gamertag[0])
  900.                         {
  901.                             hudMain->addPlayerToList(index++, CGL.playerNames[i].Gamertag, CGL.playerNames[i].plrRep, CGL.playerNames[i].isLegend, CGL.playerNames[i].isDev, false, false);
  902.                         }
  903.                     }
  904.                     hudMain->showPlayersList(1);
  905.                     r3dMouse::Show();
  906.                 }
  907.                 else
  908.                 {
  909.                     hudMain->showPlayersList(0);
  910.                     r3dMouse::Hide();
  911.                 }
  912.             }
  913.  
  914.             if(hudMain->isPlayersListVisible() && Keyboard->WasPressed(kbsEsc))
  915.             {
  916.                     hudMain->showPlayersList(0);
  917.                     r3dMouse::Hide();
  918.             }
  919.         }
  920.  
  921.         // render flash UI for objects
  922.  
  923.         R3DPROFILE_START( "GameWorld().Draw(rsDrawFlashUI)" );
  924.         GameWorld().Draw(rsDrawFlashUI);
  925.         R3DPROFILE_END( "GameWorld().Draw(rsDrawFlashUI)" );
  926.  
  927.         {
  928.             {
  929.                 R3DPROFILE_START( "hudMain->" );
  930.  
  931.                 hudMain->Update();
  932.                 hudMain->Draw();
  933.  
  934.                 R3DPROFILE_END( "hudMain->" );
  935.             }
  936.  
  937.             // issue d3d cheat check on some frames (will stop issuing anti cheat if caught cheat)
  938.             // wait 5 minute before doing check. after that, do check every other 2-5 minutes
  939.             if(!pl->bDead && (r3dGetTime() - pl->TimeOfLastRespawn)>300.0f && !hudAttm->isActive() &&
  940.                 !hudPause->isActive() && !hudActionUI->isActive() && !hudGeneralStore->isActive() &&
  941.                 !hudVault->isActive())
  942.             {
  943.                 static float nextCheck = r3dGetTime() + u_GetRandom(120.0f, 300.0f);
  944.                 if(r3dGetTime() > nextCheck)
  945.                 {
  946.                     issueD3DAntiCheatCodepath( ANTICHEAT_WALLHACK );
  947.                     nextCheck = r3dGetTime() + u_GetRandom(120.0f, 300.0f);
  948.                 }
  949. //                 static float nextCheck2 = r3dGetTime() + u_GetRandom(300.0f, 600.0f);
  950. //                 if(r3dGetTime() > nextCheck2)
  951. //                 {
  952. //                     issueD3DAntiCheatCodepath( ANTICHEAT_SCREEN_HELPERS2 );
  953. //                     nextCheck2 = r3dGetTime() + u_GetRandom(300.0f, 600.0f);
  954. //                 }
  955.             }
  956.         }
  957.  
  958.         if(hudMain && (hudMain->isChatInputActive() || hudMain->isPlayersListVisible())) // also checks for write note, so do not hide mouse
  959.             return;
  960.  
  961.         // draw main hud with hidden mouse
  962.         // this call is FREE if mouse was hidden already
  963.         // [denis]: do not remove for now, this is minor hack for situation when app was started inactive. 
  964.         // [pavel]: that fucks up controls, when big map is on screen, or scoreboard is, you shouldn't be able to move character, as in that mode you are actually using mouse
  965.         //            if app was started inactive, just press M twice and that's it. 
  966.         // [pavel]: ok, that should fix a problem. If non of modal windows are active, then hide mouse.
  967.         if(!win::bSuspended && !g_cursor_mode->GetInt())
  968.             r3dMouse::Hide();
  969.     }
  970. }
  971.  
  972. void TPSGameHUD :: Draw()
  973. {
  974.     if(!TPSGameHud_Inited) r3dError("!TPSGameHud_Inited");
  975.  
  976.     assert(bInited);
  977.     if ( !bInited ) return;
  978.  
  979.     R3DPROFILE_D3DSTART( D3DPROFILE_SCALEFORM ) ;
  980.  
  981.     r3dSetFiltering( R3D_POINT );
  982.  
  983.     r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHATESTENABLE,     FALSE );
  984.     r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHAREF,            1 );
  985.  
  986.     r3dRenderer->SetMaterial(NULL);
  987.     r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA | R3D_BLEND_NZ);
  988.  
  989.     DrawMenus();
  990.  
  991.     R3DPROFILE_D3DEND( D3DPROFILE_SCALEFORM ) ;
  992.  
  993.     return;  
  994. }
  995.  
  996. bool SetCameraPlayerVehicle(const obj_Player* pl, r3dCamera &Cam)
  997. {
  998.     static bool wasDrivenByPlayer = false;
  999. #if VEHICLES_ENABLED
  1000.     if ( g_pPhysicsWorld && g_pPhysicsWorld->m_VehicleManager->GetDrivenCar() && d_drive_vehicles->GetBool() == true )
  1001.     {
  1002.         obj_Vehicle* vehicle = g_pPhysicsWorld->m_VehicleManager->getRealDrivenVehicle();
  1003.         if( vehicle ) 
  1004.         {
  1005. #if    VEHICLE_CINEMATIC_MODE
  1006.             r3dVector CamPos = vehicle->GetPosition();
  1007.             CamPos += r3dPoint3D( 0, ( 5 ), 0 );
  1008.  
  1009.             int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY;
  1010.             float  glb_MouseSensAdj = CurrentRig.MouseSensetivity * g_mouse_sensitivity->GetFloat();    
  1011.  
  1012.             static float camangle = 0;
  1013.             camangle += float(-mMX) * glb_MouseSensAdj;
  1014.  
  1015.             if(camangle > 360.0f ) camangle = camangle - 360.0f;
  1016.             if(camangle < 0.0f )   camangle = camangle + 360.0f;
  1017.  
  1018.             D3DXMATRIX mr;
  1019.             D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-camangle), 0.0f, 0);
  1020.             r3dVector vehicleForwardVector = r3dVector(mr ._31, mr ._32, mr ._33);
  1021.  
  1022.             CamPos += -vehicleForwardVector * 8 ;
  1023.  
  1024.             Cam.SetPosition(CamPos);
  1025.             Cam.PointTo( CamPos + vehicleForwardVector * 3 + r3dVector ( 0, -1, 0) );
  1026.             Cam.vUP = r3dPoint3D(0, 1, 0);
  1027. #else 
  1028.             g_pPhysicsWorld->m_VehicleManager->ConfigureCamera(Cam);
  1029. #endif
  1030.             wasDrivenByPlayer = true;
  1031.         }
  1032.         else
  1033.         {
  1034.             wasDrivenByPlayer = false;
  1035.         }
  1036.     }
  1037.     else
  1038.     {
  1039.         wasDrivenByPlayer = false;
  1040.     }
  1041. #endif 
  1042.     return wasDrivenByPlayer;
  1043.  
  1044. }
  1045.  
  1046. static float g_lastAimAnimTime = -1.f;
  1047.  
  1048. void ProcessPlayerMovement(obj_Player* pl, bool editor_debug )
  1049. {
  1050.     r3d_assert(pl->NetworkLocal);
  1051.  
  1052.     // check fire weapon should be called all the time, as it will reset weapon fire in case if you are sitting on the menu, etc
  1053.     {
  1054.         R3DPROFILE_FUNCTION("update fire");
  1055.         pl->CheckFireWeapon();
  1056.     }
  1057.  
  1058.     if(InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_SWITCH_FPS_TPS) && !(hudAttm && hudAttm->isActive()) && !(hudMain && hudMain->isChatInputActive()) && !Mouse->GetMouseVisibility() && !pl->bSwim)
  1059.     {
  1060.         pl->switchFPS_TPS();
  1061.     }
  1062.  
  1063.  
  1064.     if (pl->bSwim && g_camera_mode->GetInt() == 2)
  1065.     {
  1066. pl->switchFPS_TPS();
  1067.     }
  1068.  
  1069.  
  1070.     if (pl->bSwim && g_camera_mode->GetInt() == 2)
  1071.     {
  1072. pl->switchFPS_TPS();
  1073.     }
  1074.  
  1075.     r3dPoint3D prevAccel = pl->InputAcceleration;
  1076.     pl->InputAcceleration.Assign(0, 0, 0);
  1077.  
  1078.     static int shiftWasPressed = 0;
  1079.     float movingSpeed = pl->plr_local_moving_speed * (1.0f/r3dGetFrameTime());
  1080.  
  1081.     // query mouse distance, so it will not be accumulated
  1082.     int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY;
  1083.     if(g_vertical_look->GetBool()) // invert mouse
  1084.         mMY = -mMY;
  1085.  
  1086.     bool disablePlayerRotation = false;
  1087.     bool disablePlayerMovement = false;
  1088.     if(Mouse->GetMouseVisibility() || (hudMain && hudMain->isChatInputActive())) // do not update player if we are in menu control mode!
  1089.     {    
  1090.         disablePlayerMovement = true;
  1091.         disablePlayerRotation = true;
  1092.     }
  1093.     if(pl->bDead)
  1094.         return;
  1095.  
  1096.     const Weapon* wpn = pl->m_Weapons[pl->m_SelectedWeapon];
  1097.  
  1098.     if(!Mouse->GetMouseVisibility()
  1099.         && wpn)
  1100.     {
  1101.  
  1102.         // vehicles
  1103.         if(InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_INTERACT) )
  1104.         {
  1105. #if VEHICLES_ENABLED
  1106.             obj_Vehicle* target_Vehicle = pl->canEnterVehicle();
  1107.  
  1108.             if( pl->isInVehicle() ) {
  1109.                 pl->exitVehicle();
  1110.             }
  1111.             else if ( target_Vehicle  ) // now we're going to try to use vehicles (otherwise UAV characters can't use vehicles).
  1112.             {
  1113.                 pl->enterVehicle( target_Vehicle );
  1114.             }
  1115. #endif
  1116.         }
  1117.     }
  1118.  
  1119.     if(pl->m_isFinishedAiming && !pl->m_isInScope)
  1120.     {
  1121.         if(Keyboard->WasPressed(kbsLeftShift))
  1122.         {
  1123.             R3D_SWAP(g_CameraLeftSideSource, g_CameraLeftSideTarget);
  1124.             g_CameraLeftSideLerp = 0.0f;
  1125.         }
  1126.     }
  1127.  
  1128.     bool  aiming      = pl->m_isAiming;
  1129.     int   playerState = aiming ? PLAYER_IDLEAIM : PLAYER_IDLE;
  1130.  
  1131.     if( g_lastAimAnimTime < 0 )
  1132.         g_lastAimAnimTime = r3dGetTime();
  1133.  
  1134.     float newAimTime = r3dGetTime();
  1135.     float deltaAimTime = newAimTime - g_lastAimAnimTime;
  1136.     g_lastAimAnimTime = newAimTime;
  1137.  
  1138.     const float AIM_LERP_SPEED = 8.0f;
  1139.  
  1140.     if( aiming )
  1141.     {
  1142.         r_grass_zoom_coef->SetFloat( R3D_LERP( r_grass_zoom_coef->GetFloat(), 2.0f, AIM_LERP_SPEED * deltaAimTime ) );
  1143.     }
  1144.     else
  1145.     {
  1146.         r_grass_zoom_coef->SetFloat( R3D_LERP( r_grass_zoom_coef->GetFloat(), 1.0f, AIM_LERP_SPEED * deltaAimTime ) );
  1147.     }
  1148.  
  1149.     if(!(g_camera_mode->GetInt()==2 && pl->NetworkLocal))
  1150.     {
  1151.         if(pl->IsJumpActive()) 
  1152.         {
  1153.             // in jump, keep current state  (so strafe will stay, for example) and disable movement
  1154.             playerState = pl->PlayerState;
  1155.         }
  1156.     }
  1157.  
  1158.     // not able to sprint with equipped RPG
  1159.     bool disableSprint = false;
  1160.     r3dAnimation::r3dAnimInfo* animInfo = pl->uberAnim_->anim.GetTrack(pl->uberAnim_->grenadeThrowTrackID);
  1161.     if(!(pl->uberAnim_->grenadePinPullTrackID==CUberAnim::INVALID_TRACK_ID && !(animInfo && (animInfo->GetStatus()&ANIMSTATUS_Playing))))
  1162.         disableSprint = true;
  1163.  
  1164.     if(pl->CurLoadout.Health < 10.0f)
  1165.         disableSprint = true;
  1166.  
  1167.     // check if player can straighten up, in case if there is something above his head he will not be able to stop crouching
  1168.     bool force_crouch = false;
  1169.     if(pl->bCrouch)
  1170.     {
  1171.         PxBoxGeometry bbox(0.2f, 0.9f, 0.2f);
  1172.         PxTransform pose(PxVec3(pl->GetPosition().x, pl->GetPosition().y+1.1f, pl->GetPosition().z), PxQuat(0,0,0,1));
  1173.         PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK, 0, 0, 0), PxSceneQueryFilterFlag::eSTATIC);
  1174.         PxShape* shape;
  1175.         force_crouch = g_pPhysicsWorld->PhysXScene->overlapAny(bbox, pose, shape, filter);
  1176.     }
  1177.     bool crouching = pl->bCrouch;
  1178.     if(pl->fHeightAboveGround < 0.5f)
  1179.     {
  1180.         if(g_toggle_crouch->GetBool())
  1181.         {
  1182.             if(InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_CROUCH) || Gamepad->WasReleased(gpB))
  1183.                 crouching = !crouching;
  1184.         }
  1185.         else
  1186.             crouching = InputMappingMngr->isPressed(r3dInputMappingMngr::KS_CROUCH) || Gamepad->IsPressed(gpB);
  1187.     }
  1188.     else
  1189.         crouching = false;
  1190.  
  1191.     if(disablePlayerMovement)
  1192.         crouching = false;
  1193.  
  1194.     if(force_crouch)
  1195.         crouching = true;
  1196.  
  1197.     if(crouching) 
  1198.         playerState = aiming ? PLAYER_MOVE_CROUCH_AIM : PLAYER_MOVE_CROUCH;
  1199.  
  1200.     // check if player can straighten up, in case if there is something above his head he will not be able to stop proning
  1201.     bool force_prone = false;
  1202.     if(pl->bProne)
  1203.     {
  1204.         PxBoxGeometry bbox(0.2f, 0.9f, 0.2f);
  1205.         PxTransform pose(PxVec3(pl->GetPosition().x, pl->GetPosition().y+1.1f, pl->GetPosition().z), PxQuat(0,0,0,1));
  1206.         PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK, 0, 0, 0), PxSceneQueryFilterFlag::eSTATIC);
  1207.         PxShape* shape;
  1208.         force_prone = g_pPhysicsWorld->PhysXScene->overlapAny(bbox, pose, shape, filter);
  1209.     }
  1210.     bool wasProning = pl->bProne;
  1211.     bool proning = pl->bProne;
  1212.     if(pl->fHeightAboveGround < 0.5f)
  1213.     {
  1214.         if(InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_PRONE) && !disablePlayerMovement)
  1215.             proning = !proning;
  1216.     }
  1217.     else
  1218.         proning = false;
  1219.  
  1220.     if(force_prone)
  1221.         proning = true;
  1222.  
  1223.     {
  1224.         extern float getWaterDepthAtPos(const r3dPoint3D& pos);
  1225.         float waterDepth = getWaterDepthAtPos(pl->GetPosition());
  1226.         if(waterDepth > 1.4f)
  1227.         {
  1228.             proning = false;
  1229.             crouching = false;
  1230.         }
  1231.  
  1232.     if(proning) 
  1233.     {
  1234.         if(!wasProning)
  1235.             playerState = PLAYER_PRONE_DOWN;
  1236.         else if(wasProning && pl->PlayerState == PLAYER_PRONE_DOWN) // check if we are still playing anim
  1237.         {
  1238.             bool stillPlayingAnim = false;
  1239.             std::vector<r3dAnimation::r3dAnimInfo>::iterator it;
  1240.             for(it=pl->uberAnim_->anim.AnimTracks.begin(); it!=pl->uberAnim_->anim.AnimTracks.end(); ++it) 
  1241.             {
  1242.                 const r3dAnimation::r3dAnimInfo& ai = *it;
  1243.                 if(ai.pAnim->iAnimId == pl->uberAnim_->data_->aid_.prone_down_weapon || ai.pAnim->iAnimId == pl->uberAnim_->data_->aid_.prone_down_noweapon)
  1244.                 {
  1245.                     if(!(ai.dwStatus & ANIMSTATUS_Finished))
  1246.                         stillPlayingAnim = true;
  1247.                     break;
  1248.                 }
  1249.             }
  1250.             if(stillPlayingAnim)
  1251.                 playerState = PLAYER_PRONE_DOWN;
  1252.             else
  1253.                 playerState = aiming ? PLAYER_PRONE_AIM : PLAYER_PRONE_IDLE;
  1254.         }
  1255.         else
  1256.             playerState = aiming ? PLAYER_PRONE_AIM : PLAYER_PRONE_IDLE;
  1257.     }
  1258.     else
  1259.     {
  1260.         if(wasProning)
  1261.             playerState = PLAYER_PRONE_UP;
  1262.         else if(pl->PlayerState == PLAYER_PRONE_UP) // check if we are still playing anim
  1263.         {
  1264.             bool stillPlayingAnim = false;
  1265.             std::vector<r3dAnimation::r3dAnimInfo>::iterator it;
  1266.             for(it=pl->uberAnim_->anim.AnimTracks.begin(); it!=pl->uberAnim_->anim.AnimTracks.end(); ++it) 
  1267.             {
  1268.                 const r3dAnimation::r3dAnimInfo& ai = *it;
  1269.                 if(ai.pAnim->iAnimId == pl->uberAnim_->data_->aid_.prone_up_weapon || ai.pAnim->iAnimId == pl->uberAnim_->data_->aid_.prone_up_noweapon)
  1270.                 {
  1271.                     if(!(ai.dwStatus & ANIMSTATUS_Finished))
  1272.                         stillPlayingAnim = true;
  1273.                     break;
  1274.                 }
  1275.             }
  1276.             if(stillPlayingAnim)
  1277.                 playerState = PLAYER_PRONE_UP;
  1278.         }
  1279.     }
  1280.  
  1281.     if(playerState == PLAYER_PRONE_UP || playerState == PLAYER_PRONE_DOWN)
  1282.     {
  1283.         disablePlayerMovement = true;
  1284.         disablePlayerRotation = true;
  1285.     }
  1286.  
  1287.     if(proning && aiming)
  1288.         disablePlayerMovement = true;
  1289.  
  1290.     VMPROTECT_BeginMutation("ProcessPlayerMovement_Accel");    
  1291.     {
  1292.  
  1293.         r3dPoint3D accelaration(0,0,0);
  1294.         if(!disablePlayerMovement)
  1295.         {
  1296.             // if facing a wall and cannot sprint - stop sprint
  1297.             bool canSprint = (shiftWasPressed<3) || (shiftWasPressed>=3 && movingSpeed > 1.0f);
  1298.             if(InputMappingMngr->isPressed(r3dInputMappingMngr::KS_SPRINT) || Gamepad->IsPressed(gpLeftShoulder))
  1299.                 shiftWasPressed++;
  1300.             else
  1301.                 shiftWasPressed = 0;
  1302.  
  1303.             if(aiming || pl->m_isHoldingBreath) // cannot spring and aim. also, in default key binding spring and hold breath are on the same key
  1304.                 shiftWasPressed = 0;
  1305.  
  1306.             // due to animation, firstly check left and right movement, so that if you move diagonally we will play moving forward animation
  1307.             float thumbX, thumbY;
  1308.             Gamepad->GetLeftThumb(thumbX, thumbY);
  1309.             if(InputMappingMngr->isPressed(r3dInputMappingMngr::KS_MOVE_LEFT)) 
  1310.             {
  1311.                 accelaration += (aiming)?r3dPoint3D(-GPP->AI_WALK_SPEED*GPP->AI_BASE_MOD_SIDE,0,0):r3dPoint3D(-GPP->AI_RUN_SPEED*GPP->AI_BASE_MOD_SIDE,0,0);
  1312.             }
  1313.             else if(InputMappingMngr->isPressed(r3dInputMappingMngr::KS_MOVE_RIGHT)) 
  1314.             {
  1315.                 accelaration += (aiming)?r3dPoint3D(GPP->AI_WALK_SPEED*GPP->AI_BASE_MOD_SIDE,0,0):r3dPoint3D(GPP->AI_RUN_SPEED*GPP->AI_BASE_MOD_SIDE,0,0);
  1316.             }
  1317.             else if(thumbX!=0.0f)
  1318.             {
  1319.                 accelaration += (aiming)?r3dPoint3D(GPP->AI_WALK_SPEED*GPP->AI_BASE_MOD_SIDE*thumbX,0,0):r3dPoint3D(GPP->AI_RUN_SPEED*GPP->AI_BASE_MOD_SIDE*thumbX,0,0);
  1320.             }
  1321.  
  1322.             //r3dOutToLog("sprint: %d, canSprint: %d, speed: %.3f\n", (int)shiftWasPressed, (int)canSprint, movingSpeed);
  1323.             if(shiftWasPressed && canSprint /*&& pl->bOnGround*/ && !crouching && !proning && !disableSprint && (pl->m_Stamina>0.0f) && pl->m_StaminaPenaltyTime<=0 && !pl->bSwim && waterDepth < 1.2f) 
  1324.             {
  1325.                 playerState = PLAYER_MOVE_SPRINT;
  1326.                 accelaration *= 0.5f; // half side movement when sprinting
  1327.                 accelaration += r3dPoint3D(0,0,GPP->AI_SPRINT_SPEED);
  1328.                 accelaration  = accelaration.NormalizeTo() * GPP->AI_SPRINT_SPEED;
  1329.             }
  1330.             else
  1331.             {
  1332.                 if(InputMappingMngr->isPressed(r3dInputMappingMngr::KS_MOVE_FORWARD) || shiftWasPressed) 
  1333.                 {
  1334.                     float spd = GPP->AI_BASE_MOD_FORWARD * (aiming ? GPP->AI_WALK_SPEED : GPP->AI_RUN_SPEED);
  1335.                     accelaration += r3dPoint3D(0,0,spd);
  1336.                     accelaration  = accelaration.NormalizeTo() * spd;
  1337.                 }
  1338.                 else if(InputMappingMngr->isPressed(r3dInputMappingMngr::KS_MOVE_BACKWARD))
  1339.                 {
  1340.                     float spd = GPP->AI_BASE_MOD_BACKWARD * (aiming ? GPP->AI_WALK_SPEED : GPP->AI_RUN_SPEED);
  1341.                     accelaration += r3dPoint3D(0,0,-spd);
  1342.                     accelaration  = accelaration.NormalizeTo() * spd;
  1343.                 }
  1344.                 else if(thumbY!=0.0f)
  1345.                 {
  1346.                     if(thumbY>0)
  1347.                         accelaration += (aiming)?r3dPoint3D(0,0,GPP->AI_WALK_SPEED*GPP->AI_BASE_MOD_FORWARD*thumbY):r3dPoint3D(0,0,GPP->AI_RUN_SPEED*GPP->AI_BASE_MOD_FORWARD*thumbY);
  1348.                     else
  1349.                         accelaration += (aiming)?r3dPoint3D(0,0,GPP->AI_WALK_SPEED*GPP->AI_BASE_MOD_BACKWARD*thumbY):r3dPoint3D(0,0,GPP->AI_RUN_SPEED*GPP->AI_BASE_MOD_BACKWARD*thumbY);
  1350.                 }
  1351.  
  1352.  
  1353.                 if(waterDepth > 1.4f)
  1354.         {
  1355.             pl->bSwim = true;
  1356.                 if(shiftWasPressed && canSprint && (pl->m_Stamina>0.0f) && pl->m_StaminaPenaltyTime<=0) 
  1357.             {
  1358.                 pl->bSwimShift = true;
  1359.                 accelaration *= 1.5f; // half side movement when sprinting
  1360.                 playerState = PLAYER_SWIM_F;
  1361.             }
  1362.                 else
  1363.                 {
  1364. pl->bSwimShift = false;
  1365.                 }
  1366.         }
  1367.         else if (pl->bSwim && waterDepth < 1.2f)
  1368.         {
  1369. pl->bSwim = false;
  1370.         }
  1371.  
  1372.  
  1373.                                 if (!pl->bSwim) // AomBE : Fix Bugs Stamina
  1374.                 {
  1375.                     pl->bSwimShift = false;
  1376.                 }
  1377.                     pl->SyncAnimation(true);
  1378.             }
  1379.  
  1380. if (pl->bSwim && !pl->bSwimShift)
  1381. {
  1382. playerState = PLAYER_SWIM_M;
  1383. }
  1384. else if (!pl->bSwim)
  1385.             {
  1386.             // set walk/run state
  1387.             if(playerState != PLAYER_MOVE_SPRINT && !crouching && !proning && (accelaration.x || accelaration.z))
  1388.                 playerState = aiming ? PLAYER_MOVE_WALK_AIM : PLAYER_MOVE_RUN;
  1389.             // set prone walk state
  1390.             if(playerState != PLAYER_MOVE_SPRINT && !crouching && proning && (accelaration.x || accelaration.z))
  1391.                 playerState = aiming ? PLAYER_PRONE_AIM : PLAYER_MOVE_PRONE;
  1392.             }
  1393.  
  1394.                             if((playerState == PLAYER_MOVE_RUN || playerState == PLAYER_MOVE_SPRINT) && (r3dGetTime() < pl->m_SpeedBoostTime))
  1395.             {
  1396.                 accelaration *= pl->m_SpeedBoost;
  1397.             }
  1398.  
  1399. #ifndef FINAL_BUILD
  1400.             if(gUserProfile.ProfileData.isDevAccount && Keyboard->IsPressed(kbsLeftAlt))
  1401.                 accelaration *= 5.0f;
  1402. #endif
  1403.  
  1404.             //         STORE_CATEGORIES equippedItemCat = wpn ? wpn->getCategory() : storecat_INVALID;;
  1405.             //         if(equippedItemCat == storecat_SUPPORT || equippedItemCat == storecat_MG)
  1406.             //             accelaration *= 0.8f; // 20% slow down
  1407.         }
  1408.  
  1409.  
  1410.         if(pl->CurLoadout.Health < GPP->c_fSpeedMultiplier_LowHealthLevel)
  1411.             accelaration *= GPP->c_fSpeedMultiplier_LowHealthValue;
  1412.         if(pl->CurLoadout.Thirst > GPP->c_fSpeedMultiplier_HighThirstLevel)
  1413.             accelaration *= GPP->c_fSpeedMultiplier_HighThirstValue;
  1414.         if(pl->CurLoadout.Hunger > GPP->c_fSpeedMultiplier_HighHungerLevel)
  1415.             accelaration *= GPP->c_fSpeedMultiplier_HighHungerValue;
  1416.  
  1417.         if(crouching)
  1418.             accelaration *= 0.4f;
  1419.         if(proning)
  1420.             accelaration *= 0.2f;
  1421.  
  1422.         /*if(pl->IsJumpActive()) // don't allow to change direction when jumping
  1423.         pl->InputAcceleration = prevAccel;
  1424.         else*/
  1425.         pl->InputAcceleration = accelaration;
  1426.  
  1427.         // process jump after assigning InputAcceleration, so that we can predict where player will jump
  1428.         if(!disablePlayerMovement)
  1429.         {
  1430.             if(pl->bOnGround && (InputMappingMngr->wasPressed(r3dInputMappingMngr::KS_JUMP)||Gamepad->WasPressed(gpA)) 
  1431.                 && !crouching 
  1432.                 && !proning
  1433.                 && !pl->IsJumpActive()
  1434.                 && prevAccel.z >= 0 /* prevent jump backward*/
  1435.                 )
  1436.             {
  1437.                 pl->StartJump();
  1438.             }
  1439.  
  1440.         }
  1441.  
  1442.         if(!editor_debug)
  1443.             pl->PlayerState   = playerState;
  1444.  
  1445.         pl->PlayerMoveDir = CUberData::GetMoveDirFromAcceleration(pl->InputAcceleration);
  1446.  
  1447.     } VMPROTECT_End();    
  1448.  
  1449.     // adjust player physx controller size
  1450.     // TODO: we need to adjust size only when animation blending was finished! ask Denis how.
  1451.     if(crouching != pl->bCrouch || proning!=pl->bProne)
  1452.     {
  1453.         // GetPosition()/SetPosition() to keep player on the ground.
  1454.         // because capsule controller height offset will be changed in AdjustControllerSize()
  1455.         r3dPoint3D pos = pl->PhysicsObject->GetPosition();
  1456.         if(crouching || proning)
  1457.             pl->PhysicsObject->AdjustControllerSize(0.3f, 0.2f, 0.4f);
  1458.         else
  1459.             pl->PhysicsObject->AdjustControllerSize(0.3f, 1.1f, 0.85f);
  1460.         pl->PhysicsObject->SetPosition(pos + r3dPoint3D(0, 0.01f, 0));
  1461.     }
  1462.  
  1463.     pl->bCrouch = crouching;
  1464.     pl->bProne = proning;
  1465.  
  1466.     ActiveCameraRigID = (Playerstate_e)pl->PlayerState;
  1467.     ActiveCameraRig   = TPSHudCameras[g_camera_mode->GetInt()][ActiveCameraRigID];
  1468.  
  1469.     // use this to update the camera from the options. 
  1470.     static int currentCameraMode = g_camera_mode->GetInt();
  1471.  
  1472.     // if we arn't in the correct view mode currently.   And we are not doing a aim zoom, or the previous lerp is done. 
  1473.     if ( ( CurrentState != pl->PlayerState || currentCameraMode != g_camera_mode->GetInt()) && (LerpValue >= 1.0f || ( !pl->m_isAiming) ) )
  1474.     {
  1475.         currentCameraMode = g_camera_mode->GetInt();
  1476.         //set new target
  1477.         SourceRig = CurrentRig;
  1478.         TargetRig = ActiveCameraRig;
  1479.  
  1480.         if(SourceRig.Position.AlmostEqual(TargetRig.Position) && SourceRig.ScopePosition.AlmostEqual(TargetRig.ScopePosition))
  1481.         {
  1482.             // workaround for a quickscoping and firing at the same time and causing a camera to tilt up.
  1483.             if((TPSHudCameras[g_camera_mode->GetInt()][CurrentState].allowScope && !TargetRig.allowScope) || (!TPSHudCameras[g_camera_mode->GetInt()][CurrentState].allowScope && TargetRig.allowScope))
  1484.             {
  1485.                 g_CameraPointToAdj_HasAdjustedVec = false;
  1486.             }
  1487.         }
  1488.         else
  1489.         {
  1490.             g_CameraPointToAdj_adjVec = R3D_LERP(g_CameraPointToAdj_adjVec, g_CameraPointToAdj_nextAdjVec, LerpValue);
  1491.             g_CameraPointToAdj_HasAdjustedVec = false;
  1492.         }
  1493.  
  1494.         LerpValue = 0;
  1495.  
  1496.         CurrentState = (Playerstate_e)pl->PlayerState;    
  1497.     }
  1498.     else
  1499.     {
  1500.         // just lerp
  1501.         if (LerpValue < 1.0f)
  1502.         {
  1503.             float lerpMOD = 1.0f;
  1504.             STORE_CATEGORIES equippedItemCat = wpn ? wpn->getCategory() : storecat_INVALID;;
  1505.             if(TargetRig.allowScope) // slow down aiming for those categories
  1506.                 if(equippedItemCat == storecat_MG)
  1507.                     lerpMOD = 0.5f;
  1508.  
  1509.             LerpValue += r3dGetFrameTime()*6.5f*lerpMOD;
  1510.             if (LerpValue >1.0f) LerpValue = 1.0f;
  1511.  
  1512.             CurrentRig.Lerp(pl, SourceRig, TargetRig, LerpValue);
  1513.         }
  1514.         else
  1515.             CurrentRig.Lerp(pl, SourceRig, TargetRig, 1.0f);
  1516.     }
  1517.  
  1518.     if(!disablePlayerRotation)
  1519.     {
  1520.         float  glb_MouseSensAdj = CurrentRig.MouseSensetivity * g_mouse_sensitivity->GetFloat();    
  1521.         //  Mouse controls are here
  1522.  
  1523.         float mmoveX = float(-mMX) * glb_MouseSensAdj;
  1524.         float mmoveY = float(-mMY) * glb_MouseSensAdj;
  1525.  
  1526.         // fight only vertical recoil, apply adjustment leftover to viewvector
  1527.         if(pl->RecoilViewModTarget.y > 0.01f && mmoveY < 0) {
  1528.             pl->RecoilViewModTarget.y += mmoveY;
  1529.             if(pl->RecoilViewModTarget.y < 0) {
  1530.                 mmoveY = pl->RecoilViewModTarget.y;
  1531.                 pl->RecoilViewModTarget.y = 0;
  1532.             } else {
  1533.                 mmoveY = 0;
  1534.             }
  1535.         }
  1536.  
  1537.         pl->ViewAngle.x += mmoveX;
  1538.         pl->ViewAngle.y += mmoveY;
  1539.  
  1540.         if(Gamepad->IsConnected()) // overwrite mouse
  1541.         {
  1542.             float X, Y;
  1543.             Gamepad->GetRightThumb(X, Y);
  1544.             pl->ViewAngle.x += float(-X) * glb_MouseSensAdj * r_gamepad_view_sens->GetFloat();
  1545.             pl->ViewAngle.y += float(Y) * glb_MouseSensAdj * r_gamepad_view_sens->GetFloat() * (g_vertical_look->GetBool()?-1.0f:1.0f);
  1546.         }
  1547.  
  1548.         if(pl->ViewAngle.x > 360.0f ) pl->ViewAngle.x = pl->ViewAngle.x - 360.0f;
  1549.         if(pl->ViewAngle.x < 0.0f )   pl->ViewAngle.x = pl->ViewAngle.x + 360.0f;
  1550.  
  1551.         // Player can't look too high!
  1552.         if(pl->ViewAngle.y > CurrentRig.LookUpLimit )  pl->ViewAngle.y = CurrentRig.LookUpLimit;
  1553.         if(pl->ViewAngle.y < CurrentRig.LookDownLimit) pl->ViewAngle.y = CurrentRig.LookDownLimit;
  1554.  
  1555.         // set player rotation (except when planting mines)
  1556.         pl->m_fPlayerRotationTarget = -pl->ViewAngle.x;
  1557.  
  1558.         // calculate player vision
  1559.         r3dVector FinalViewAngle = pl->ViewAngle + pl->RecoilViewMod + pl->SniperViewMod;
  1560.         if(FinalViewAngle.x > 360.0f ) FinalViewAngle.x = FinalViewAngle.x - 360.0f;
  1561.         if(FinalViewAngle.x < 0.0f )   FinalViewAngle.x = FinalViewAngle.x + 360.0f;
  1562.         // Player can't look too high!
  1563.         if(FinalViewAngle.y > CurrentRig.LookUpLimit )  FinalViewAngle.y = CurrentRig.LookUpLimit;
  1564.         if(FinalViewAngle.y < CurrentRig.LookDownLimit) FinalViewAngle.y = CurrentRig.LookDownLimit;
  1565.  
  1566.         D3DXMATRIX mr;
  1567.         D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-FinalViewAngle.x), R3D_DEG2RAD(-FinalViewAngle.y), 0);
  1568.         pl->m_vVision  = r3dVector(mr._31, mr._32, mr._33);
  1569.     }
  1570.  
  1571.     if (TargetRig.FXFunc) TargetRig.FXFunc(LerpValue);
  1572.  
  1573.     pl->UpdateLocalPlayerMovement();
  1574. }
  1575.  
  1576. //----------------------------------------------------------------
  1577. void TPSGameHUD :: Process()
  1578. {
  1579.     if(g_cursor_mode->GetInt());
  1580.     {
  1581.         imgui_Update();
  1582.         imgui2_Update();
  1583.     }
  1584.  
  1585.     {
  1586.         r3dSetAsyncLoading( 1 );
  1587.     }
  1588.  
  1589.     obj_Player* pl = gClientLogic().localPlayer_;
  1590.     if(!pl) return;
  1591.   }
  1592.  
  1593. #ifndef FINAL_BUILD
  1594.  
  1595.     bool allow_specator_mode = true;
  1596.     if(Keyboard->WasPressed(kbsF8) && allow_specator_mode)
  1597.     {
  1598.         d_video_spectator_mode->SetBool(!d_video_spectator_mode->GetBool());
  1599.         static float DOF_NS=0, DOF_NE=0, DOF_FS=0, DOF_FE=0;
  1600.         static int DOF_N=0, DOF_F=0, DOF_ENABLE=0;
  1601.         if(d_video_spectator_mode->GetBool())
  1602.         {
  1603.             FPS_vViewOrig.Assign(pl->ViewAngle);
  1604.             // save
  1605.             DOF_NS=DepthOfField_NearStart;
  1606.             DOF_NE=DepthOfField_NearEnd;
  1607.             DOF_FS=DepthOfField_FarStart;
  1608.             DOF_FE=DepthOfField_FarEnd;
  1609.             DOF_N=_NEAR_DOF;
  1610.             DOF_F=_FAR_DOF;
  1611.             DOF_ENABLE=LevelDOF;
  1612.         }
  1613.         else
  1614.         {
  1615.             // restore
  1616.             DepthOfField_NearStart=DOF_NS;
  1617.             DepthOfField_NearEnd=DOF_NE;
  1618.             DepthOfField_FarStart=DOF_FS;
  1619.             DepthOfField_FarEnd=DOF_FE;
  1620.             _NEAR_DOF=DOF_N;
  1621.             _FAR_DOF=DOF_F;
  1622.             LevelDOF=DOF_ENABLE;
  1623.         }
  1624.     }
  1625.  
  1626.     bool allow_observer_mode = true;
  1627.     allow_observer_mode = false;
  1628.  
  1629.     if(Keyboard->WasPressed(kbsF9) && allow_observer_mode)
  1630.     {
  1631.         d_observer_mode->SetBool(!d_observer_mode->GetBool());
  1632.         if(d_observer_mode->GetBool())
  1633.         {
  1634.             FPS_vViewOrig.Assign(pl->ViewAngle);
  1635.         }
  1636.     }
  1637.  
  1638.     if(d_video_spectator_mode->GetBool() || d_observer_mode->GetBool())
  1639.     {
  1640.         FPS_Acceleration.Assign(0, 0, 0);
  1641.  
  1642.         float  glb_MouseSensAdj = g_mouse_sensitivity->GetFloat();    
  1643.         // camera view
  1644.         if(Gamepad->IsConnected())
  1645.         {
  1646.             float X, Y;
  1647.             Gamepad->GetRightThumb(X, Y);
  1648.             FPS_vViewOrig.x += float(-X) * r_gamepad_view_sens->GetFloat();
  1649.             FPS_vViewOrig.y += float(Y) * r_gamepad_view_sens->GetFloat() * (g_vertical_look->GetBool()?-1.0f:1.0f);
  1650.         }
  1651.         else // mouse fallback
  1652.         {
  1653.             int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY;
  1654.  
  1655.             FPS_vViewOrig.x += float(-mMX) * glb_MouseSensAdj;
  1656.             FPS_vViewOrig.y += float(-mMY) * glb_MouseSensAdj * (g_vertical_look->GetBool()?-1.0f:1.0f);
  1657.         }
  1658.  
  1659.         if(FPS_vViewOrig.y > 85)  FPS_vViewOrig.y = 85;
  1660.         if(FPS_vViewOrig.y < -85) FPS_vViewOrig.y = -85;
  1661.  
  1662.         FPS_ViewAngle = FPS_vViewOrig;
  1663.  
  1664.         if(FPS_ViewAngle.y > 360 ) FPS_ViewAngle.y = FPS_ViewAngle.y - 360;
  1665.         if(FPS_ViewAngle.y < 0 )   FPS_ViewAngle.y = FPS_ViewAngle.y + 360;
  1666.  
  1667.  
  1668.         D3DXMATRIX mr;
  1669.  
  1670.         D3DXMatrixIdentity(&mr);
  1671.         D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-FPS_ViewAngle.x), R3D_DEG2RAD(-FPS_ViewAngle.y), 0);
  1672.  
  1673.         FPS_vVision  = r3dVector(mr._31, mr._32, mr._33);
  1674.  
  1675.         D3DXMatrixIdentity(&mr);
  1676.         D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-FPS_ViewAngle.x), 0, 0);
  1677.         FPS_vRight = r3dVector(mr._11, mr._12, mr._13);
  1678.         FPS_vUp    = r3dVector(0, 1, 0);
  1679.         FPS_vForw  = r3dVector(mr._31, mr._32, mr._33);
  1680.  
  1681.         FPS_vForw.Normalize();
  1682.         FPS_vRight.Normalize();
  1683.         FPS_vVision.Normalize();
  1684.  
  1685.         // walk
  1686.         extern float __EditorWalkSpeed;
  1687.         float fSpeed = __EditorWalkSpeed;
  1688.  
  1689.         float mult = 1;
  1690.         if(Keyboard->IsPressed(kbsLeftShift)) mult = d_spectator_fast_move_mul->GetFloat();
  1691.         if(Keyboard->IsPressed(kbsLeftControl)) mult = d_spectator_slow_move_mul->GetFloat();
  1692.  
  1693.         if(Keyboard->IsPressed(kbsW)) FPS_Acceleration.Z = fSpeed;
  1694.         if(Keyboard->IsPressed(kbsS)) FPS_Acceleration.Z = -fSpeed * 0.7f;
  1695.         if(Keyboard->IsPressed(kbsA)) FPS_Acceleration.X = -fSpeed * 0.7f;
  1696.         if(Keyboard->IsPressed(kbsD)) FPS_Acceleration.X = fSpeed * 0.7f;
  1697.         if(Keyboard->IsPressed(kbsQ)) FPS_Position.Y    += SRV_WORLD_SCALE(1.0f)* r3dGetFrameTime() * mult;
  1698.         if(Keyboard->IsPressed(kbsE)) FPS_Position.Y    -= SRV_WORLD_SCALE(1.0f)* r3dGetFrameTime() * mult;
  1699.  
  1700.         if(Gamepad->IsConnected())
  1701.         {
  1702.             float RX, RY, TL, TR;
  1703.             Gamepad->GetLeftThumb(RX, RY);
  1704.             Gamepad->GetTrigger(TL, TR);
  1705.  
  1706.             FPS_Acceleration.Z = -RY*r_gamepad_move_speed->GetFloat();
  1707.             FPS_Acceleration.Z = RY*r_gamepad_move_speed->GetFloat();
  1708.             FPS_Acceleration.X = -RX*r_gamepad_move_speed->GetFloat();
  1709.             FPS_Acceleration.X = RX*r_gamepad_move_speed->GetFloat();
  1710.             FPS_Position.Y    += r3dGetFrameTime() * TR * r_gamepad_move_speed->GetFloat();
  1711.             FPS_Position.Y    -= r3dGetFrameTime() * TL * r_gamepad_move_speed->GetFloat();
  1712.         }
  1713.  
  1714.         FPS_Position += FPS_vVision * FPS_Acceleration.Z * r3dGetFrameTime() * mult;
  1715.         FPS_Position += FPS_vRight * FPS_Acceleration.X * r3dGetFrameTime() *mult;
  1716.  
  1717.         return;
  1718.     }
  1719. #endif
  1720.     ProcessPlayerMovement(pl, false);
  1721. }
There is the full code help me please guys :D
Mar 23 '14 #1
1 2010
weaknessforcats
9,208 Expert Mod 8TB
I'm not saying this is the problem. But it is a problem anyhow:

Expand|Select|Wrap|Line Numbers
  1. if(g_cursor_mode->GetInt()); <<<<<!!!!
  2.      {
  3.          imgui_Update();
  4.          imgui2_Update();
  5.      }
  6.  
That semi-colon terminates your if statement leaving these function calls in an anonymous code block:

Expand|Select|Wrap|Line Numbers
  1. {
  2.          imgui_Update();
  3.          imgui2_Update();
  4.      }
  5.  
so they get called if the if is true or false.

The "local functions" means you have a function definition inside another function definition. Like the semi-colon above, a missing or mismatched brace somewhere can do this. Be sure all your braces are matched correctly. This includes all your header files.
Mar 24 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: murphy | last post by:
Hi, I've been seeing two symptoms with my asp.net site that have started recently after a long period of smooth running. As others on our team make changes to referenced dll's I find that I...
8
by: Olov Johansson | last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7 and Konqueror 3.5) has support not only for standard function definitions, function expressions (lambdas) and Function...
15
by: unknownbomb | last post by:
Hey all i really hope you can help me out. Im compiling a project and im getting 2 errors which are saying local function definitions are illegal. Anyone know what this mean? And especially...
1
by: kaygee | last post by:
Hi ppl can anyone tell me what this error means? error C2601: 'meanData' : local function definitions are illegal
2
by: dheerajkoli | last post by:
hello friends , i m getting a problem on when i compiling a my project in vc++6.0 error C2274: 'function-style cast' : illegal as right side of '.' operator. please help me . if any hint...
3
by: MrHenry007 | last post by:
Hello! I'm fairly new to c++ but I have been following tutorials and have created functions before, but not one using a string. I can't work out what the problem is here. The function is supposed...
5
by: kirayamato1992 | last post by:
i wrote some codes for my assignments. then it came out several problems involving illegal local function definition. #include <iostream> using namespace std; void system_module(); void...
1
by: martinezgeno199 | last post by:
Been at this for a while now. Can't for the life of me figure it out... All help is very much appreciated. #include "Menu2.h" #include <iostream> //additional includes using namespace std; ...
7
by: paulo bagon | last post by:
#include <iostream> using namespace std; int x,detA,detB,detC,detD,detM; void main() {
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.