Skip to content

Commit

Permalink
game: rework GetClientGroundSurfaceMaterialName
Browse files Browse the repository at this point in the history
TODO: GroundSurface is incorrectly unset
  • Loading branch information
0lvin committed Dec 7, 2024
1 parent e1729ea commit b0d4062
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 59 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,6 @@ PLAYER_OBJS_ = \
src/game/common/h2vector.o \
src/game/common/h2rand.o \
src/common/shared/shared.o \
src/game/player/library/surfaceprops.o \
src/game/player/library/p_actions.o \
src/game/player/library/p_animactor.o \
src/game/player/library/p_anim_branch.o \
Expand Down
6 changes: 3 additions & 3 deletions src/game/player/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3658,9 +3658,9 @@ ClientThink(edict_t *ent, usercmd_t *ucmd)
client->playerinfo.velocity[2] = ent->velocity[2] = pm.velocity[2] * 0.125;
// jmarshall end

client->playerinfo.GroundSurface=pm.GroundSurface;
memcpy(&client->playerinfo.GroundPlane,&pm.GroundPlane,sizeof(cplane_t));
client->playerinfo.GroundContents=*pm.GroundContents;
client->playerinfo.GroundSurface = pm.GroundSurface;
memcpy(&client->playerinfo.GroundPlane, &pm.GroundPlane, sizeof(cplane_t));
client->playerinfo.GroundContents =* pm.GroundContents;

// If we're move-locked, don't update the edict's origin and velocity, otherwise copy the
// origin and velocity from playerinfo (which have been written by Pmove()) into the edict's
Expand Down
25 changes: 20 additions & 5 deletions src/game/player/library/p_actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "p_weapon.h"
#include "p_weapon.h"
#include "../../header/g_items.h"
#include "surfaceprops.h"
#include "../../monster/misc/player.h"
#include "../../common/fx.h"
#include "../../common/h2rand.h"
Expand Down Expand Up @@ -1465,6 +1464,20 @@ void PlayerActionBowTrailEnd(playerinfo_t *playerinfo, float value)
playerinfo->effects &= ~EF_TRAILS_ENABLED;
}

const char *
GetClientGroundSurfaceMaterialName(playerinfo_t *playerinfo)
{
csurface_t *groundSurface;

groundSurface = playerinfo->GroundSurface;
if (groundSurface && groundSurface->material[0])
{
return groundSurface->material;
}

return NULL;
}

/*-----------------------------------------------
PlayerActionFootstep
-----------------------------------------------*/
Expand Down Expand Up @@ -1513,9 +1526,9 @@ void PlayerActionFootstep(playerinfo_t *playerinfo, float value)
}
else
{
char *material;
const char *material;

material=GetClientGroundSurfaceMaterialName(playerinfo);
material = GetClientGroundSurfaceMaterialName(playerinfo);

if (!material)
return;
Expand Down Expand Up @@ -2896,12 +2909,14 @@ void PlayerActionIdleSound(playerinfo_t *playerinfo, float value)
void PlayerActionVaultSound(playerinfo_t *playerinfo, float value)
{
char VaultSound[64];
char *Material=NULL;
char *Material = NULL;

Material=GetClientGroundSurfaceMaterialName(playerinfo);
Material = GetClientGroundSurfaceMaterialName(playerinfo);

if(!Material)
{
return;
}

strcpy(VaultSound,"player/");
strcat(VaultSound, Material);
Expand Down
3 changes: 1 addition & 2 deletions src/game/player/library/p_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "p_anims.h"
#include "p_ctrl.h"
#include "p_main.h"
#include "surfaceprops.h"
#include "../../common/h2rand.h"
#include "../../common/fx.h"

Expand Down Expand Up @@ -243,7 +242,7 @@ void PlayerIntLand(playerinfo_t *playerinfo, float landspeed)

// Don't do dust in the water!

if(playerinfo->waterlevel==0)
if(playerinfo->waterlevel == 0)
if(!playerinfo->isclient)
playerinfo->G_CreateEffect(EFFECT_PRED_ID15,
playerinfo->G_GetEntityStatePtr(playerinfo->self),
Expand Down
1 change: 1 addition & 0 deletions src/game/player/library/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,6 @@ void Weapon_EquipBow(playerinfo_t* playerinfo, gitem_t* Weapon);
void Weapon_EquipArmor(playerinfo_t* playerinfo, gitem_t* Weapon);
int Weapon_CurrentShotsLeft(playerinfo_t* playerinfo);
int Defence_CurrentShotsLeft(playerinfo_t* playerinfo, int intent);
const char *GetClientGroundSurfaceMaterialName(playerinfo_t *playerinfo);

#endif // PLAYER_H
29 changes: 0 additions & 29 deletions src/game/player/library/surfaceprops.c

This file was deleted.

19 changes: 0 additions & 19 deletions src/game/player/library/surfaceprops.h

This file was deleted.

0 comments on commit b0d4062

Please sign in to comment.