Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Convert player movement code to C++
Browse files Browse the repository at this point in the history
  • Loading branch information
hammermaps committed May 17, 2019
1 parent bcae16f commit e0e42e1
Show file tree
Hide file tree
Showing 18 changed files with 800 additions and 812 deletions.
3 changes: 0 additions & 3 deletions cl_dll/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
#include "netadr.h"
#include "vgui_schememanager.h"

extern "C"
{
#include "pm_shared.h"
}

#include <string.h>
#include "hud_servers.h"
Expand Down
6 changes: 3 additions & 3 deletions cl_dll/cl_dll.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
<ClCompile Include="..\game_shared\voice_banmgr.cpp" />
<ClCompile Include="..\game_shared\voice_status.cpp" />
<ClCompile Include="..\game_shared\voice_vgui_tweakdlg.cpp" />
<ClCompile Include="..\pm_shared\pm_debug.c" />
<ClCompile Include="..\pm_shared\pm_math.c" />
<ClCompile Include="..\pm_shared\pm_shared.c" />
<ClCompile Include="..\pm_shared\pm_debug.cpp" />
<ClCompile Include="..\pm_shared\pm_math.cpp" />
<ClCompile Include="..\pm_shared\pm_shared.cpp" />
<ClCompile Include="ammo.cpp" />
<ClCompile Include="ammohistory.cpp" />
<ClCompile Include="ammo_secondary.cpp" />
Expand Down
10 changes: 5 additions & 5 deletions cl_dll/cl_dll.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,19 @@
<ClCompile Include="..\game_shared\vgui_helpers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\pm_shared\pm_debug.c">
<ClCompile Include="..\game_shared\vgui_loadtga.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\pm_shared\pm_math.c">
<ClCompile Include="..\game_shared\vgui_listbox.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\pm_shared\pm_shared.c">
<ClCompile Include="..\pm_shared\pm_debug.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\game_shared\vgui_loadtga.cpp">
<ClCompile Include="..\pm_shared\pm_math.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\game_shared\vgui_listbox.cpp">
<ClCompile Include="..\pm_shared\pm_shared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion cl_dll/ev_hldm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "eventscripts.h"
#include "ev_hldm.h"

#include "pm_shared.h"

#include "r_efx.h"
#include "event_api.h"
#include "event_args.h"
Expand All @@ -40,7 +42,7 @@ extern engine_studio_api_t IEngineStudio;

static int tracerCount[ 32 ];

extern "C" char PM_FindTextureType( char *name );
extern char PM_FindTextureType( char *name );

void V_PunchAxis( int axis, float punch );
void VectorAngles( const float *forward, float *angles );
Expand Down
8 changes: 4 additions & 4 deletions cl_dll/hud_spectator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@

#pragma warning(disable: 4244)

extern "C" int iJumpSpectator;
extern "C" float vJumpOrigin[3];
extern "C" float vJumpAngles[3];
extern int iJumpSpectator;
extern float vJumpOrigin[3];
extern float vJumpAngles[3];


extern void V_GetInEyePos(int entity, float * origin, float * angles );
extern void V_ResetChaseCam();
extern void V_GetChasePos(cl_entity_t *ent, float *cl_angles, float *origin, float *angles);
extern void VectorAngles( const float *forward, float *angles );
extern "C" void NormalizeAngles( float *angles );
extern void NormalizeAngles(float* angles);
extern float * GetClientColor( int clientIndex );

extern vec3_t v_origin; // last view origin
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern int g_weaponselect;
extern cl_enginefunc_t gEngfuncs;

// Defined in pm_math.c
extern "C" float anglemod( float a );
extern float anglemod( float a );

void IN_Init (void);
void IN_Move ( float frametime, usercmd_t *cmd);
Expand Down
43 changes: 17 additions & 26 deletions cl_dll/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,32 @@
#include "hltv.h"
#include "studio.h"

// Spectator Mode
extern "C"
{
float vecNewViewAngles[3];
int iHasNewViewAngles;
float vecNewViewOrigin[3];
int iHasNewViewOrigin;
int iIsSpectator;
}

#ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif

extern "C"
extern "C"
{
int CL_IsThirdPerson( void );
void CL_CameraOffset( float *ofs );
int CL_IsThirdPerson(void);
void CL_CameraOffset(float *ofs);

void DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams );
void DLLEXPORT V_CalcRefdef(struct ref_params_s *pparams);

void PM_ParticleLine( float *start, float *end, int pcolor, float life, float vert);
int PM_GetVisEntInfo( int ent );
int PM_GetPhysEntInfo( int ent );
void InterpolateAngles( float * start, float * end, float * output, float frac );
void NormalizeAngles( float * angles );
float Distance(const float * v1, const float * v2);
float AngleBetweenVectors( const float * v1, const float * v2 );

float vJumpOrigin[3];
float vJumpAngles[3];
void PM_ParticleLine(float *start, float *end, int pcolor, float life, float vert);
}

void V_DropPunchAngle ( float frametime, float *ev_punchangle );
void VectorAngles( const float *forward, float *angles );
extern float AngleBetweenVectors(const float* v1, const float* v2);
extern void NormalizeAngles(float* angles);
extern void InterpolateAngles(float* start, float* end, float* output, float frac);
extern int PM_GetVisEntInfo(int ent);
extern int PM_GetPhysEntInfo(int ent);
extern float Distance(const float * v1, const float * v2);

extern float vJumpOrigin[3];
extern float vJumpAngles[3];

void V_DropPunchAngle(float frametime, float *ev_punchangle);
void VectorAngles(const float *forward, float *angles);

#include "r_studioint.h"
#include "com_model.h"
Expand Down
7 changes: 3 additions & 4 deletions common/mathlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ void AngleMatrix (const vec3_t angles, float (*matrix)[4] );
void AngleIMatrix (const vec3_t angles, float (*matrix)[4] );
void VectorTransform (const vec3_t in1, float in2[3][4], vec3_t out);

void NormalizeAngles( vec3_t angles );
void InterpolateAngles( vec3_t start, vec3_t end, vec3_t output, float frac );
float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 );

void NormalizeAngles( float* angles );
void InterpolateAngles( float* start, float* end, float* output, float frac );
float AngleBetweenVectors( const float* v1, const float* v2 );

void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up);
void VectorAngles( const vec3_t forward, vec3_t angles );
Expand Down
6 changes: 3 additions & 3 deletions dlls/cbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

void EntvarsKeyvalue(entvars_t *pev, KeyValueData *pkvd);

extern "C" void PM_Move(struct playermove_s *ppmove, int server);
extern "C" void PM_Init(struct playermove_s *ppmove);
extern "C" char PM_FindTextureType(char *name);
extern void PM_Move(struct playermove_s *ppmove, int server);
extern void PM_Init(struct playermove_s *ppmove);
extern char PM_FindTextureType(char *name);

extern Vector VecBModelOrigin(entvars_t* pevBModel);
extern DLL_GLOBAL Vector g_vecAttackDir;
Expand Down
3 changes: 2 additions & 1 deletion dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ void GameDLLInit(void)
REGISTER_SKILL_CVARS(player_leg);

// END REGISTER CVARS FOR SKILL LEVEL STUFF

SERVER_COMMAND("exec skill.cfg\n");
SERVER_COMMAND("exec skill_opfor.cfg\n"); // Opposing-Force
SERVER_COMMAND("exec skill_hitgroups.cfg\n"); // Hitgroups
}

6 changes: 3 additions & 3 deletions dlls/hl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\game_shared\voice_gamemgr.cpp" />
<ClCompile Include="..\pm_shared\pm_debug.c" />
<ClCompile Include="..\pm_shared\pm_math.c" />
<ClCompile Include="..\pm_shared\pm_shared.c" />
<ClCompile Include="..\pm_shared\pm_debug.cpp" />
<ClCompile Include="..\pm_shared\pm_math.cpp" />
<ClCompile Include="..\pm_shared\pm_shared.cpp" />
<ClCompile Include="aflock.cpp" />
<ClCompile Include="agrunt.cpp" />
<ClCompile Include="airtank.cpp" />
Expand Down
14 changes: 7 additions & 7 deletions dlls/hl.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,20 @@
<ClCompile Include="xen.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\pm_shared\pm_shared.c">
<ClCompile Include="..\game_shared\voice_gamemgr.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\pm_shared\pm_debug.c">
<Filter>Source Files</Filter>
<ClCompile Include="monster_zombie.cpp">
<Filter>Source Files\NPCs</Filter>
</ClCompile>
<ClCompile Include="..\pm_shared\pm_math.c">
<ClCompile Include="..\pm_shared\pm_debug.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\game_shared\voice_gamemgr.cpp">
<ClCompile Include="..\pm_shared\pm_math.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="monster_zombie.cpp">
<Filter>Source Files\NPCs</Filter>
<ClCompile Include="..\pm_shared\pm_shared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion dlls/monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern DLL_GLOBAL BOOL g_fDrawLines;
extern DLL_GLOBAL short g_sModelIndexLaser;// holds the index for the laser beam
extern DLL_GLOBAL short g_sModelIndexLaserDot;// holds the index for the laser beam dot

extern "C" char PM_FindTextureType(char *name);
extern char PM_FindTextureType(char *name);

extern CGraph WorldGraph;// the world node graph

Expand Down
6 changes: 3 additions & 3 deletions dlls/plats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ static void PlatSpawnInsideTrigger(entvars_t* pevPlatform);
// No idea why windows does not pick that up, in fact
// MSVC will complain it's not delcared if you use extern...
#ifdef _WIN32
int nanmask = 255 << 23;
int nanmask_dll = 255 << 23;
#define IS_NAN(x) (((*(int *)&x)&nanmask_dll)==nanmask_dll)
#else
extern int nanmask;
#endif

#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
#endif

static float Fix(float angle)
{
Expand Down
6 changes: 2 additions & 4 deletions dlls/skill.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@

struct skilldata_t
{

int iSkillLevel; // game skill level

// Monster Health & Damage
float agruntHealth;
float agruntHealth;
float agruntDmgPunch;

float apacheHealth;
Expand Down Expand Up @@ -101,7 +100,6 @@ struct skilldata_t
float miniturretHealth;
float sentryHealth;


// Player Weapons
float plrDmgCrowbar;
float plrDmg9MM;
Expand Down Expand Up @@ -156,4 +154,4 @@ extern DLL_GLOBAL int g_iSkillLevel;

#define SKILL_EASY 1
#define SKILL_MEDIUM 2
#define SKILL_HARD 3
#define SKILL_HARD 3
Loading

0 comments on commit e0e42e1

Please sign in to comment.