Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move sgame trap call declarations to engine repository #1178

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/cm/cm_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Maryland 20850 USA.
#include "common/Cvar.h"
#include "common/Log.h"
#include "engine/qcommon/qcommon.h"
#include "engine/qcommon/qfiles.h"

// fake submodel handles
#define CAPSULE_MODEL_HANDLE ( MAX_SUBMODELS )
Expand Down
2 changes: 0 additions & 2 deletions src/common/cm/cm_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ Maryland 20850 USA.
*/

#include "engine/qcommon/q_shared.h"
#include "engine/qcommon/qfiles.h"
#include "engine/renderer/tr_types.h"

void CM_LoadMap(Str::StringRef name);
void CM_ClearMap();
Expand Down
112 changes: 1 addition & 111 deletions src/engine/client/cg_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/

// Definitions used in engine/cgame communication
#ifndef CGAPI_H
#define CGAPI_H


#include "engine/qcommon/q_shared.h"
#include "engine/renderer/tr_types.h"
#include "common/KeyIdentification.h"
#include "common/cm/cm_public.h"
#include "../../shared/CommonProxies.h"
#ifdef BUILD_CGAME
// TODO: find a better way that does not depend on a gamelogic file from an engine file
#include "shared/bg_public.h"
Expand All @@ -42,8 +38,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// multiple commands may be combined into a single packet, so this
// needs to be larger than PACKET_BACKUP

#define MAX_ENTITIES_IN_SNAPSHOT 512

// snapshots are a view of the server at a given time

// Snapshots are generated at regular time intervals by the server,
Expand Down Expand Up @@ -88,108 +82,4 @@ enum class MouseMode
SystemCursor, // The input is sent as positions, the cursor should be rendered by the system
};

void trap_SendClientCommand( const char *s );
void trap_UpdateScreen();
int trap_CM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );
void trap_S_StartSound( vec3_t origin, int entityNum, soundChannel_t entchannel, sfxHandle_t sfx );
void trap_S_StartLocalSound( sfxHandle_t sfx, soundChannel_t channelNum );
void trap_S_ClearLoopingSounds( bool killall );
void trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
void trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
void trap_S_StopLoopingSound( int entityNum );
void trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin );
int trap_S_GetCurrentSoundTime();

void trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[ 3 ], int inwater );
sfxHandle_t trap_S_RegisterSound( const char *sample, bool compressed );
void trap_S_StartBackgroundTrack( const char *intro, const char *loop );
void trap_R_LoadWorldMap( const char *mapname );
qhandle_t trap_R_RegisterModel( const char *name );
qhandle_t trap_R_RegisterSkin( const char *name );
qhandle_t trap_R_RegisterShader( const char *name, RegisterShaderFlags_t flags );

void trap_R_ClearScene();
void trap_R_AddRefEntityToScene( const refEntity_t *re );
void trap_R_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts );
void trap_R_AddPolysToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys );
void trap_R_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t hShader, int flags );
void trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );
void trap_R_Add2dPolysIndexedToScene( polyVert_t *polys, int numVerts, int *indexes, int numIndexes, int trans_x, int trans_y, qhandle_t shader );
void trap_R_SetMatrixTransform( const matrix_t matrix );
void trap_R_ResetMatrixTransform();
void trap_R_RenderScene( const refdef_t *fd );
void trap_R_ClearColor();
void trap_R_SetColor( const Color::Color &rgba );
void trap_R_SetClipRegion( const float *region );
void trap_R_ResetClipRegion();
void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
void trap_R_DrawRotatedPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle );
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );
int trap_R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagName, int startIndex );
void trap_R_GetTextureSize( qhandle_t handle, int *x, int *y );
qhandle_t trap_R_GenerateTexture( const byte *data, int x, int y );
void trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime );
bool trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot );
int trap_GetCurrentCmdNumber();
bool trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd );
void trap_SetUserCmdValue( int stateValue, int flags, float sensitivityScale );
int trap_Key_GetCatcher();
void trap_Key_SetCatcher( int catcher );
void trap_Key_SetBinding( Keyboard::Key key, int team, const char *cmd );
std::vector<Keyboard::Key> trap_Key_GetConsoleKeys();
void trap_Key_SetConsoleKeys(const std::vector<Keyboard::Key>& keys);
void trap_Key_ClearCmdButtons();
void trap_Key_ClearStates();
std::vector<bool> trap_Key_KeysDown( const std::vector<Keyboard::Key>& keys );
void trap_SetMouseMode( MouseMode mode );
void trap_S_StopBackgroundTrack();
void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );
bool trap_GetEntityToken( char *buffer, int bufferSize );
std::vector<std::vector<Keyboard::Key>> trap_Key_GetKeysForBinds(int team, const std::vector<std::string>& binds);
int trap_Key_GetCharForScancode( int scancode );
bool trap_R_inPVS( const vec3_t p1, const vec3_t p2 );
bool trap_R_inPVVS( const vec3_t p1, const vec3_t p2 );
bool trap_R_LoadDynamicShader( const char *shadername, const char *shadertext );
int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );

qhandle_t trap_R_RegisterAnimation( const char *name );
int trap_R_BuildSkeleton( refSkeleton_t *skel, qhandle_t anim, int startFrame, int endFrame, float frac, bool clearOrigin );
int trap_R_BlendSkeleton( refSkeleton_t *skel, const refSkeleton_t *blend, float frac );
int trap_R_BoneIndex( qhandle_t hModel, const char *boneName );
int trap_R_AnimNumFrames( qhandle_t hAnim );
int trap_R_AnimFrameRate( qhandle_t hAnim );

void trap_CompleteCallback( const char *complete );

void trap_RegisterButtonCommands( const char *cmds );

void trap_GetClipboardData( char *, int);
void trap_QuoteString( const char *, char*, int );

void trap_notify_onTeamChange( int newTeam );

qhandle_t trap_RegisterVisTest();
void trap_AddVisTestToScene( qhandle_t hTest, const vec3_t pos,
float depthAdjust, float area );
float trap_CheckVisibility( qhandle_t hTest );
void trap_UnregisterVisTest( qhandle_t hTest );
void trap_SetColorGrading( int slot, qhandle_t hShader );
void trap_R_ScissorEnable( bool enable );
void trap_R_ScissorSet( int x, int y, int w, int h );
int trap_LAN_GetServerCount( int source );
void trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen );
int trap_LAN_GetServerPing( int source, int n );
void trap_LAN_MarkServerVisible( int source, int n, bool visible );
int trap_LAN_ServerIsVisible( int source, int n );
bool trap_LAN_UpdateVisiblePings( int source );
void trap_LAN_ResetPings( int n );
int trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen );
void trap_LAN_ResetServerStatus();
void trap_R_GetShaderNameFromHandle( const qhandle_t shader, char *out, int len );
void trap_PrepareKeyUp();
void trap_R_SetAltShaderTokens( const char * );
void trap_S_UpdateEntityVelocity( int entityNum, const vec3_t velocity );
void trap_S_SetReverb( int slotNum, const char* presetName, float ratio );
void trap_S_BeginRegistration();
void trap_S_EndRegistration();
#endif
1 change: 1 addition & 0 deletions src/engine/client/cg_msgdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define CG_MSGDEF_H

#include "cg_api.h"
#include "engine/renderer/tr_types.h"
#include "common/IPC/CommonSyscalls.h"
#include "common/KeyIdentification.h"

Expand Down
6 changes: 0 additions & 6 deletions src/engine/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ struct server_t
float ucompAve;
int ucompNum;
// -NERVE - SMF

md3Tag_t tags[ MAX_SERVER_TAGS ];
tagHeaderExt_t tagHeadersExt[ MAX_TAG_FILES ];

int num_tagheaders;
int num_tags;
};

struct clientSnapshot_t
Expand Down
3 changes: 0 additions & 3 deletions src/engine/server/sv_sgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,6 @@ Called on a map change, not on a map_restart
*/
void SV_InitGameProgs()
{
sv.num_tagheaders = 0;
sv.num_tags = 0;

// load the game module
gvm.Start();

Expand Down
1 change: 1 addition & 0 deletions src/shared/CommonProxies.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace VM {

void trap_AddCommand(const char* cmdName);
void trap_RemoveCommand(const char* cmdName);
void trap_CompleteCallback(const char* complete);
int trap_Argc();
void trap_Argv(int n, char* buffer, int bufferLength);
const Cmd::Args& trap_Args();
Expand Down
1 change: 1 addition & 0 deletions src/shared/client/cg_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <engine/client/cg_msgdef.h>
#include <shared/VMMain.h>
#include <shared/CommandBufferClient.h>
#include "cg_api.h"

IPC::CommandBufferClient cmdBuffer("cgame");

Expand Down
99 changes: 99 additions & 0 deletions src/shared/client/cg_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,110 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===========================================================================
*/

// APIs for use by the cgame VM
#ifndef SHARED_CLIENT_API_H_
#define SHARED_CLIENT_API_H_

#include "engine/qcommon/q_shared.h"
#include "engine/renderer/tr_types.h"
#include "engine/client/cg_api.h"
#include "common/KeyIdentification.h"
#include "shared/CommonProxies.h"
#include <shared/CommandBufferClient.h>

extern IPC::CommandBufferClient cmdBuffer;

void trap_SendClientCommand( const char *s );
void trap_UpdateScreen();
int trap_CM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );
void trap_S_StartSound( vec3_t origin, int entityNum, soundChannel_t entchannel, sfxHandle_t sfx );
void trap_S_StartLocalSound( sfxHandle_t sfx, soundChannel_t channelNum );
void trap_S_ClearLoopingSounds( bool killall );
void trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
void trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
void trap_S_StopLoopingSound( int entityNum );
void trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin );
void trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[ 3 ], int inwater );
sfxHandle_t trap_S_RegisterSound( const char *sample, bool compressed );
void trap_S_StartBackgroundTrack( const char *intro, const char *loop );
void trap_R_LoadWorldMap( const char *mapname );
qhandle_t trap_R_RegisterModel( const char *name );
qhandle_t trap_R_RegisterSkin( const char *name );
qhandle_t trap_R_RegisterShader( const char *name, RegisterShaderFlags_t flags );
void trap_R_ClearScene();
void trap_R_AddRefEntityToScene( const refEntity_t *re );
void trap_R_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts );
void trap_R_AddPolysToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys );
void trap_R_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t hShader, int flags );
void trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );
void trap_R_Add2dPolysIndexedToScene( polyVert_t *polys, int numVerts, int *indexes, int numIndexes, int trans_x, int trans_y, qhandle_t shader );
void trap_R_SetMatrixTransform( const matrix_t matrix );
void trap_R_ResetMatrixTransform();
void trap_R_RenderScene( const refdef_t *fd );
void trap_R_ClearColor();
void trap_R_SetColor( const Color::Color &rgba );
void trap_R_SetClipRegion( const float *region );
void trap_R_ResetClipRegion();
void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
void trap_R_DrawRotatedPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle );
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );
int trap_R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagName, int startIndex );
void trap_R_GetTextureSize( qhandle_t handle, int *x, int *y );
qhandle_t trap_R_GenerateTexture( const byte *data, int x, int y );
void trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime );
bool trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot );
int trap_GetCurrentCmdNumber();
bool trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd );
void trap_SetUserCmdValue( int stateValue, int flags, float sensitivityScale );
int trap_Key_GetCatcher();
void trap_Key_SetCatcher( int catcher );
void trap_Key_SetBinding( Keyboard::Key key, int team, const char *cmd );
std::vector<Keyboard::Key> trap_Key_GetConsoleKeys();
void trap_Key_SetConsoleKeys(const std::vector<Keyboard::Key>& keys);
void trap_Key_ClearCmdButtons();
void trap_Key_ClearStates();
std::vector<bool> trap_Key_KeysDown( const std::vector<Keyboard::Key>& keys );
void trap_SetMouseMode( MouseMode mode );
void trap_S_StopBackgroundTrack();
void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );
bool trap_GetEntityToken( char *buffer, int bufferSize );
std::vector<std::vector<Keyboard::Key>> trap_Key_GetKeysForBinds(int team, const std::vector<std::string>& binds);
int trap_Key_GetCharForScancode( int scancode );
bool trap_R_inPVS( const vec3_t p1, const vec3_t p2 );
bool trap_R_inPVVS( const vec3_t p1, const vec3_t p2 );
int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
qhandle_t trap_R_RegisterAnimation( const char *name );
int trap_R_BuildSkeleton( refSkeleton_t *skel, qhandle_t anim, int startFrame, int endFrame, float frac, bool clearOrigin );
int trap_R_BlendSkeleton( refSkeleton_t *skel, const refSkeleton_t *blend, float frac );
int trap_R_BoneIndex( qhandle_t hModel, const char *boneName );
int trap_R_AnimNumFrames( qhandle_t hAnim );
int trap_R_AnimFrameRate( qhandle_t hAnim );
void trap_RegisterButtonCommands( const char *cmds );
void trap_QuoteString( const char *, char*, int );
void trap_notify_onTeamChange( int newTeam );
qhandle_t trap_RegisterVisTest();
void trap_AddVisTestToScene( qhandle_t hTest, const vec3_t pos,
float depthAdjust, float area );
float trap_CheckVisibility( qhandle_t hTest );
void trap_UnregisterVisTest( qhandle_t hTest );
void trap_SetColorGrading( int slot, qhandle_t hShader );
void trap_R_ScissorEnable( bool enable );
void trap_R_ScissorSet( int x, int y, int w, int h );
int trap_LAN_GetServerCount( int source );
void trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen );
int trap_LAN_GetServerPing( int source, int n );
void trap_LAN_MarkServerVisible( int source, int n, bool visible );
int trap_LAN_ServerIsVisible( int source, int n );
bool trap_LAN_UpdateVisiblePings( int source );
void trap_LAN_ResetPings( int n );
int trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen );
void trap_LAN_ResetServerStatus();
void trap_R_GetShaderNameFromHandle( const qhandle_t shader, char *out, int len );
void trap_PrepareKeyUp();
void trap_R_SetAltShaderTokens( const char * );
void trap_S_UpdateEntityVelocity( int entityNum, const vec3_t velocity );
void trap_S_SetReverb( int slotNum, const char* presetName, float ratio );
void trap_S_BeginRegistration();
void trap_S_EndRegistration();

#endif
5 changes: 0 additions & 5 deletions src/shared/server/sg_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ void trap_GetTimeString(char *buffer, int size, const char *format, const qtime_
Q_strncpyz(buffer, text.c_str(), size);
}

void trap_QuoteString(const char *str, char *buffer, int size)
{
Q_strncpyz(buffer, Cmd::Escape(str).c_str(), size);
}

int trap_BotAllocateClient()
{
int res;
Expand Down
19 changes: 19 additions & 0 deletions src/shared/server/sg_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,23 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

extern IPC::SharedMemory shmRegion;

void trap_LocateGameData( int numGEntities, int sizeofGEntity_t, int sizeofGClient );
void trap_DropClient( int clientNum, const char *reason );
void trap_SendServerCommand( int clientNum, const char *text );
void trap_SetConfigstring( int num, const char *string );
void trap_SetConfigstringRestrictions( int num, const clientList_t *clientList );
void trap_GetConfigstring( int num, char *buffer, int bufferSize );
void trap_SetUserinfo( int num, const char *buffer );
void trap_GetUserinfo( int num, char *buffer, int bufferSize );
void trap_GetServerinfo( char *buffer, int bufferSize );
int trap_BotAllocateClient();
void trap_BotFreeClient( int clientNum );
void trap_GetUsercmd( int clientNum, usercmd_t *cmd );
bool trap_GetEntityToken( char *buffer, int bufferSize );
int trap_BotGetServerCommand( int clientNum, char *message, int size );
int trap_RSA_GenerateMessage( const char *public_key, char *cleartext, char *encrypted );
void trap_GenFingerprint( const char *pubkey, int size, char *buffer, int bufsize );
void trap_GetPlayerPubkey( int clientNum, char *pubkey, int size );
void trap_GetTimeString( char *buffer, int size, const char *format, const qtime_t *tm );

#endif