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"
#endif
// dlight_t
#if !defined ( DLIGHT_H )
#include "dlight.h"
#endif
// cl_entity_t
#if !defined( CL_ENTITY_H )
#include "cl_entity.h"
@@ -115,6 +110,7 @@ typedef struct tempent_s
} TEMPENTITY;
typedef struct efx_api_s efx_api_t;
struct dlight_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_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 );
dlight_t *(*CL_AllocDlight)( int key );
dlight_t *(*CL_AllocElight)( int key );
struct dlight_s *(*CL_AllocDlight)( int key );
struct dlight_s *(*CL_AllocElight)( int key );
TEMPENTITY *(*CL_TempEntAlloc)( const float *org, struct model_s *model );
TEMPENTITY *(*CL_TempEntAllocNoModel)( const float *org );
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 "lightstyle.h"
#include "dlight.h"
#define CL_RENDER_INTERFACE_VERSION 37 // Xash3D 1.0
#define MAX_STUDIO_DECALS 4096 // + unused space of BSP decals
@@ -176,6 +175,7 @@ enum movie_parms_e
struct movie_state_s;
struct ref_viewpass_s;
struct dlight_s;
typedef struct render_api_s
{
@@ -184,8 +184,8 @@ typedef struct render_api_s
void (*GetDetailScaleForTexture)( int texture, float *xScale, float *yScale );
void (*GetExtraParmsForTexture)( int texture, byte *red, byte *green, byte *blue, byte *alpha );
lightstyle_t* (*GetLightStyle)( int number );
dlight_t* (*GetDynamicLight)( int number );
dlight_t* (*GetEntityLight)( int number );
struct dlight_s* (*GetDynamicLight)( int number );
struct dlight_s* (*GetEntityLight)( int number );
byte (*LightToTexGamma)( byte color ); // software gamma support
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