common: use Quake derived definitions for usercmd_t and dlight_t

This commit is contained in:
Alibek Omarov
2026-02-26 06:32:07 +05:00
parent d8e1597726
commit 26acc25018
16 changed files with 112 additions and 146 deletions

View File

@@ -1,33 +0,0 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#ifndef DLIGHT_H
#define DLIGHT_H
#include "const.h"
typedef struct dlight_s
{
vec3_t origin;
float radius;
color24 color;
float die; // stop lighting after this time
float decay; // drop this each second
float minlight; // don't add when contributing less
int key;
qboolean dark; // subtracts light instead of adding
} dlight_t;
#endif//DLIGHT_H

View File

@@ -1,35 +0,0 @@
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef KBUTTON_H
#define KBUTTON_H
// a1ba: copied from WinQuake/client.h
//
// cl_input
//
typedef struct
{
int down[2]; // key nums holding it down
int state; // low bit is down state
} kbutton_t;
STATIC_CHECK_SIZEOF( kbutton_t, 12, 12 );
#endif // KBUTTON_H

82
common/q_client.h Normal file
View File

@@ -0,0 +1,82 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// client.h -- primary header for client
#ifndef QUAKE_CLIENT_H
#define QUAKE_CLIENT_H
// Definitions originally taken from Quake, modified for binary compatibility
typedef struct usercmd_s
{
int16_t lerp_msec; // added in HL
int8_t msec; // added in QW
uint8_t pad1;
vec3_t viewangles;
// intended velocities
float forwardmove;
float sidemove;
float upmove;
uint8_t lightlevel;
uint8_t pad2;
uint16_t buttons; // added in QW
uint8_t impulse;
// added in HL
uint8_t weaponselect;
uint8_t pad3[2];
// unused HL impact stuff, left for modders
// TODO: document how to use them in delta encoding
int32_t reserved[4];
} usercmd_t;
STATIC_CHECK_SIZEOF( usercmd_t, 52, 52 );
typedef struct dlight_s
{
vec3_t origin;
float radius;
struct
{
uint8_t r, g, b;
} color;
float die; // stop lighting after this time
float decay; // drop this each second
float minlight; // don't add when contributing less
int key; // so entities can reuse same entry
qboolean dark; // subtracts light instead of adding
} dlight_t;
STATIC_CHECK_SIZEOF( dlight_t, 40, 40 );
//
// cl_input
//
typedef struct
{
int down[2]; // key nums holding it down
int state; // low bit is down state
} kbutton_t;
STATIC_CHECK_SIZEOF( kbutton_t, 12, 12 );
#endif // QUAKE_CLIENT_H

View File

@@ -26,11 +26,6 @@
#include "beamdef.h" #include "beamdef.h"
#endif #endif
// dlight_t
#if !defined ( DLIGHT_H )
#include "dlight.h"
#endif
// cl_entity_t // cl_entity_t
#if !defined( CL_ENTITY_H ) #if !defined( CL_ENTITY_H )
#include "cl_entity.h" #include "cl_entity.h"
@@ -115,6 +110,7 @@ typedef struct tempent_s
} TEMPENTITY; } TEMPENTITY;
typedef struct efx_api_s efx_api_t; typedef struct efx_api_s efx_api_t;
struct dlight_s;
struct efx_api_s struct efx_api_s
{ {
@@ -182,8 +178,8 @@ struct efx_api_s
BEAM *(*R_BeamLightning)( float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed ); BEAM *(*R_BeamLightning)( float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed );
BEAM *(*R_BeamPoints)( float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); BEAM *(*R_BeamPoints)( float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
BEAM *(*R_BeamRing)( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); BEAM *(*R_BeamRing)( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
dlight_t *(*CL_AllocDlight)( int key ); struct dlight_s *(*CL_AllocDlight)( int key );
dlight_t *(*CL_AllocElight)( int key ); struct dlight_s *(*CL_AllocElight)( int key );
TEMPENTITY *(*CL_TempEntAlloc)( const float *org, struct model_s *model ); TEMPENTITY *(*CL_TempEntAlloc)( const float *org, struct model_s *model );
TEMPENTITY *(*CL_TempEntAllocNoModel)( const float *org ); TEMPENTITY *(*CL_TempEntAllocNoModel)( const float *org );
TEMPENTITY *(*CL_TempEntAllocHigh)( const float *org, struct model_s *model ); TEMPENTITY *(*CL_TempEntAllocHigh)( const float *org, struct model_s *model );

View File

@@ -18,7 +18,6 @@ GNU General Public License for more details.
#include <stdint.h> #include <stdint.h>
#include "lightstyle.h" #include "lightstyle.h"
#include "dlight.h"
#define CL_RENDER_INTERFACE_VERSION 37 // Xash3D 1.0 #define CL_RENDER_INTERFACE_VERSION 37 // Xash3D 1.0
#define MAX_STUDIO_DECALS 4096 // + unused space of BSP decals #define MAX_STUDIO_DECALS 4096 // + unused space of BSP decals
@@ -176,6 +175,7 @@ enum movie_parms_e
struct movie_state_s; struct movie_state_s;
struct ref_viewpass_s; struct ref_viewpass_s;
struct dlight_s;
typedef struct render_api_s typedef struct render_api_s
{ {
@@ -184,8 +184,8 @@ typedef struct render_api_s
void (*GetDetailScaleForTexture)( int texture, float *xScale, float *yScale ); void (*GetDetailScaleForTexture)( int texture, float *xScale, float *yScale );
void (*GetExtraParmsForTexture)( int texture, byte *red, byte *green, byte *blue, byte *alpha ); void (*GetExtraParmsForTexture)( int texture, byte *red, byte *green, byte *blue, byte *alpha );
lightstyle_t* (*GetLightStyle)( int number ); lightstyle_t* (*GetLightStyle)( int number );
dlight_t* (*GetDynamicLight)( int number ); struct dlight_s* (*GetDynamicLight)( int number );
dlight_t* (*GetEntityLight)( int number ); struct dlight_s* (*GetEntityLight)( int number );
byte (*LightToTexGamma)( byte color ); // software gamma support byte (*LightToTexGamma)( byte color ); // software gamma support
float (*GetFrameTime)( void ); float (*GetFrameTime)( void );

View File

@@ -1,39 +0,0 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#ifndef USERCMD_H
#define USERCMD_H
typedef struct usercmd_s
{
short lerp_msec; // Interpolation time on client
byte msec; // Duration in ms of command
vec3_t viewangles; // Command view angles
// intended velocities
float forwardmove; // Forward velocity
float sidemove; // Sideways velocity
float upmove; // Upward velocity
byte lightlevel; // Light level at spot where we are standing.
unsigned short buttons; // Attack and move buttons
byte impulse; // Impulse command issued
byte weaponselect; // Current weapon id
// Experimental player impact stuff.
int impact_index;
vec3_t impact_position;
} usercmd_t;
#endif//USERCMD_H

View File

@@ -20,7 +20,6 @@ GNU General Public License for more details.
#include "pm_local.h" #include "pm_local.h"
#include "cl_tent.h" #include "cl_tent.h"
#include "studio.h" #include "studio.h"
#include "dlight.h"
#include "sound.h" #include "sound.h"
#include "input.h" #include "input.h"

View File

@@ -18,7 +18,6 @@ GNU General Public License for more details.
#include "net_encode.h" #include "net_encode.h"
#include "cl_tent.h" #include "cl_tent.h"
#include "input.h" #include "input.h"
#include "kbutton.h"
#include "vgui_draw.h" #include "vgui_draw.h"
#include "library.h" #include "library.h"
#include "vid_common.h" #include "vid_common.h"

View File

@@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "common.h" #include "common.h"
#include "client.h" #include "client.h"
#include "kbutton.h"
#if XASH_LOW_MEMORY == 0 #if XASH_LOW_MEMORY == 0
#define NET_TIMINGS 1024 #define NET_TIMINGS 1024

View File

@@ -78,8 +78,8 @@ void R_FireField( float *org, int radius, int modelIndex, int count, int flags,
void R_PlayerSprites( int client, int modelIndex, int count, int size ); void R_PlayerSprites( int client, int modelIndex, int count, int size );
void R_Sprite_WallPuff( struct tempent_s *pTemp, float scale ); void R_Sprite_WallPuff( struct tempent_s *pTemp, float scale );
void R_RicochetSound( const vec3_t pos ); void R_RicochetSound( const vec3_t pos );
struct dlight_s *CL_AllocDlight( int key ); dlight_t *CL_AllocDlight( int key );
struct dlight_s *CL_AllocElight( int key ); dlight_t *CL_AllocElight( int key );
void CL_AddEntityEffects( cl_entity_t *ent ); void CL_AddEntityEffects( cl_entity_t *ent );
void CL_AddModelEffects( cl_entity_t *ent ); void CL_AddModelEffects( cl_entity_t *ent );
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags ); void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );

View File

@@ -34,6 +34,7 @@ GNU General Public License for more details.
#include "world.h" #include "world.h"
#include "ref_common.h" #include "ref_common.h"
#include "voice.h" #include "voice.h"
#include "q_client.h"
// client sprite types // client sprite types
#define SPR_CLIENT 0 // client sprite for temp-entities or user-textures #define SPR_CLIENT 0 // client sprite for temp-entities or user-textures

View File

@@ -25,7 +25,6 @@ INPUT
*/ */
#include "keydefs.h" #include "keydefs.h"
#include "usercmd.h"
// //
// input.c // input.c

View File

@@ -16,7 +16,6 @@ GNU General Public License for more details.
#include "common.h" #include "common.h"
#include "client.h" #include "client.h"
#include "const.h" #include "const.h"
#include "kbutton.h"
#define CON_MAXCMDS 4096 // auto-complete intermediate list #define CON_MAXCMDS 4096 // auto-complete intermediate list

View File

@@ -18,7 +18,6 @@ GNU General Public License for more details.
#include "xash3d_mathlib.h" #include "xash3d_mathlib.h"
#include "net_encode.h" #include "net_encode.h"
#include "event_api.h" #include "event_api.h"
#include "usercmd.h"
#include "pm_movevars.h" #include "pm_movevars.h"
#include "entity_state.h" #include "entity_state.h"
#include "weaponinfo.h" #include "weaponinfo.h"
@@ -40,8 +39,10 @@ GNU General Public License for more details.
#define DT_SIGNED_GS BIT( 31 ) // GoldSrc-specific sign modificator #define DT_SIGNED_GS BIT( 31 ) // GoldSrc-specific sign modificator
// helper macroses // helper macroses
#define UCMD_DEF_( name, x ) #name, offsetof( usercmd_t, x ), sizeof( ((usercmd_t *)0)->x )
#define ENTS_DEF( x ) #x, offsetof( entity_state_t, x ), sizeof( ((entity_state_t *)0)->x ) #define ENTS_DEF( x ) #x, offsetof( entity_state_t, x ), sizeof( ((entity_state_t *)0)->x )
#define UCMD_DEF( x ) #x, offsetof( usercmd_t, x ), sizeof( ((usercmd_t *)0)->x ) #define UCMD_DEF( x ) UCMD_DEF_( x, x )
#define EVNT_DEF( x ) #x, offsetof( event_args_t, x ), sizeof( ((event_args_t *)0)->x ) #define EVNT_DEF( x ) #x, offsetof( event_args_t, x ), sizeof( ((event_args_t *)0)->x )
#define PHYS_DEF( x ) #x, offsetof( movevars_t, x ), sizeof( ((movevars_t *)0)->x ) #define PHYS_DEF( x ) #x, offsetof( movevars_t, x ), sizeof( ((movevars_t *)0)->x )
#define CLDT_DEF( x ) #x, offsetof( clientdata_t, x ), sizeof( ((clientdata_t *)0)->x ) #define CLDT_DEF( x ) #x, offsetof( clientdata_t, x ), sizeof( ((clientdata_t *)0)->x )
@@ -53,22 +54,22 @@ static qboolean delta_init = false;
// list of all the struct names // list of all the struct names
static const delta_field_t cmd_fields[] = static const delta_field_t cmd_fields[] =
{ {
{ UCMD_DEF( lerp_msec ) }, { UCMD_DEF( lerp_msec ) },
{ UCMD_DEF( msec ) }, { UCMD_DEF( msec ) },
{ UCMD_DEF( viewangles[0] ) }, { UCMD_DEF( viewangles[0] ) },
{ UCMD_DEF( viewangles[1] ) }, { UCMD_DEF( viewangles[1] ) },
{ UCMD_DEF( viewangles[2] ) }, { UCMD_DEF( viewangles[2] ) },
{ UCMD_DEF( forwardmove ) }, { UCMD_DEF( forwardmove ) },
{ UCMD_DEF( sidemove ) }, { UCMD_DEF( sidemove ) },
{ UCMD_DEF( upmove ) }, { UCMD_DEF( upmove ) },
{ UCMD_DEF( lightlevel ) }, { UCMD_DEF( lightlevel ) },
{ UCMD_DEF( buttons ) }, { UCMD_DEF( buttons ) },
{ UCMD_DEF( impulse ) }, { UCMD_DEF( impulse ) },
{ UCMD_DEF( weaponselect ) }, { UCMD_DEF( weaponselect ) },
{ UCMD_DEF( impact_index ) }, { UCMD_DEF_( impact_index, reserved[0] ) },
{ UCMD_DEF( impact_position[0] ) }, { UCMD_DEF_( impact_position[0], reserved[1] ) },
{ UCMD_DEF( impact_position[1] ) }, { UCMD_DEF_( impact_position[1], reserved[2] ) },
{ UCMD_DEF( impact_position[2] ) }, { UCMD_DEF_( impact_position[2], reserved[3] ) },
}; };
static const delta_field_t pm_fields[] = static const delta_field_t pm_fields[] =

View File

@@ -29,6 +29,7 @@ GNU General Public License for more details.
#include "filesystem.h" #include "filesystem.h"
#include "common/protocol.h" #include "common/protocol.h"
#include "cvardef.h" #include "cvardef.h"
#include "q_client.h"
// RefAPI changelog: // RefAPI changelog:
// 1. Initial release // 1. Initial release
@@ -399,7 +400,7 @@ typedef struct ref_api_s
void (*CL_ThinkParticle)( double frametime, particle_t *p ); void (*CL_ThinkParticle)( double frametime, particle_t *p );
void (*R_FreeDeadParticles)( particle_t **ppparticles ); void (*R_FreeDeadParticles)( particle_t **ppparticles );
particle_t *(*CL_AllocParticleFast)( void ); // unconditionally give new particle pointer from cl_free_particles particle_t *(*CL_AllocParticleFast)( void ); // unconditionally give new particle pointer from cl_free_particles
struct dlight_s *(*CL_AllocElight)( int key ); dlight_t *(*CL_AllocElight)( int key );
struct model_s *(*GetDefaultSprite)( enum ref_defaultsprite_e spr ); struct model_s *(*GetDefaultSprite)( enum ref_defaultsprite_e spr );
void (*R_StoreEfrags)( struct efrag_s **ppefrag, int framecount );// store efrags for static entities void (*R_StoreEfrags)( struct efrag_s **ppefrag, int framecount );// store efrags for static entities

View File

@@ -36,9 +36,6 @@
// PM_PlayerTrace results. // PM_PlayerTrace results.
#include "pmtrace.h" #include "pmtrace.h"
#include "usercmd.h"
// physent_t // physent_t
typedef struct physent_s typedef struct physent_s
{ {