Browse Source

Remove physics interface.

hl_urbicide
Andrey Akhmichin 5 years ago
parent
commit
a758e80f71
  1. 5
      dlls/crossbow.cpp
  2. 5
      dlls/h_export.cpp
  3. 33
      dlls/physcallback.h
  4. 4
      dlls/util.h
  5. 110
      dlls/world.cpp
  6. 114
      engine/physint.h

5
dlls/crossbow.cpp

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
#define BOLT_AIR_VELOCITY 2000
#define BOLT_WATER_VELOCITY 1000
extern BOOL gPhysicsInterfaceInitialized;
extern BOOL g_fIsXash3D;
// UNDONE: Save/restore this? Don't forget to set classname and LINK_ENTITY_TO_CLASS()
//
@ -169,7 +169,8 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) @@ -169,7 +169,8 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther )
pev->angles.z = RANDOM_LONG( 0, 360 );
pev->nextthink = gpGlobals->time + 10.0f;
if (gPhysicsInterfaceInitialized) {
if( g_fIsXash3D )
{
// g-cont. Setup movewith feature
pev->movetype = MOVETYPE_COMPOUND; // set movewith type
pev->aiment = ENT( pOther->pev ); // set parent

5
dlls/h_export.cpp

@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
// Holds engine functionality callbacks
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
server_physics_api_t g_physfuncs;
BOOL g_fIsXash3D;
#ifdef _WIN32
@ -54,4 +54,7 @@ extern "C" void DLLEXPORT EXPORT2 GiveFnptrsToDll( enginefuncs_t *pengfuncsFromE @@ -54,4 +54,7 @@ extern "C" void DLLEXPORT EXPORT2 GiveFnptrsToDll( enginefuncs_t *pengfuncsFromE
{
memcpy( &g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t) );
gpGlobals = pGlobals;
if( CVAR_GET_POINTER( "build" ) )
g_fIsXash3D = TRUE;
}

33
dlls/physcallback.h

@ -1,33 +0,0 @@ @@ -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.
*
****/
#pragma once
#ifndef PHYSCALLBACK_H
#define PHYSCALLBACK_H
#include "physint.h"
// Must be provided by user of this code
extern server_physics_api_t g_physfuncs;
// The actual physic callbacks
#define LINK_ENTITY (*g_physfuncs.pfnLinkEdict)
#define PHYSICS_TIME (*g_physfuncs.pfnGetServerTime)
#define HOST_FRAMETIME (*g_physfuncs.pfnGetFrameTime)
#define MODEL_HANDLE (*g_physfuncs.pfnGetModel)
#define GET_AREANODE (*g_physfuncs.pfnGetHeadnode)
#define GET_SERVER_STATE (*g_physfuncs.pfnServerState)
#define HOST_ERROR (*g_physfuncs.pfnHost_Error)
#endif //PHYSCALLBACK_H

4
dlls/util.h

@ -26,10 +26,6 @@ @@ -26,10 +26,6 @@
#include "enginecallback.h"
#endif
#ifndef PHYSCALLBACK_H
#include "physcallback.h"
#endif
#include <string.h>
#include <ctype.h>
inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ); // implementation later in this file

110
dlls/world.cpp

@ -33,7 +33,6 @@ @@ -33,7 +33,6 @@
#include "weapons.h"
#include "gamerules.h"
#include "teamplay_gamerules.h"
#include "physcallback.h"
extern CGraph WorldGraph;
extern CSoundEnt *pSoundEnt;
@ -730,112 +729,3 @@ void CWorld::KeyValue( KeyValueData *pkvd ) @@ -730,112 +729,3 @@ void CWorld::KeyValue( KeyValueData *pkvd )
CBaseEntity::KeyValue( pkvd );
}
//
// Xash3D physics interface
//
typedef void (*LINK_ENTITY_FN)( entvars_t *pev );
//
// attempt to create custom entity when default method is failed
// 0 - attempt to create, -1 - reject to create
//
int DispatchCreateEntity( edict_t *pent, const char *szName )
{
/*
#ifdef CREATE_ENTITY_TEST
// quake armor entities. we just replaced it with item_battery...
if( !strcmp( szName, "item_armor1" ) || !strcmp( szName, "item_armor2" ) )
{
LINK_ENTITY_FN SpawnEdict;
// ugly method to get acess with himself exports
SpawnEdict = (LINK_ENTITY_FN)GetProcAddress( GetModuleHandle( "hl" ), "item_battery" );
if( SpawnEdict != NULL ) // found the valid spawn
{
// BUGBUG: old classname hanging in memory
pent->v.classname = ALLOC_STRING( "item_battery" );
//ALERT( at_console, "DispatchCreateEntity: replace %s with %s\n", szName, STRING( pent->v.classname ) );
SpawnEdict( &pent->v );
return 0; // handled
}
}
#endif
*/
return -1;
}
//
// run custom physics for each entity
// return 0 to use built-in engine physic
//
int DispatchPhysicsEntity( edict_t *pEdict )
{
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pEdict );
if( !pEntity )
{
//ALERT( at_console, "skip %s [%i] without private data\n", STRING( pEdict->v.classname ), ENTINDEX( pEdict ) );
return 0; // not initialized
}
// NOTE: at this point pEntity assume to be valid
/*
#ifdef CUSTOM_PHYSICS_TEST
// test alien controller without physics, thinking only
if( FClassnameIs( pEntity->pev, "monster_alien_controller" ) )
{
float thinktime;
thinktime = pEntity->pev->nextthink;
if( thinktime <= 0.0f || thinktime > PHYSICS_TIME() + gpGlobals->frametime )
return 1;
if( thinktime < PHYSICS_TIME() )
thinktime = PHYSICS_TIME(); // don't let things stay in the past.
// it is possible to start that way
// by a trigger with a local time.
pEntity->pev->nextthink = 0.0f;
gpGlobals->time = thinktime;
DispatchThink( pEdict );
#ifdef GRAVITY_TEST
// stupid fake gravity test
pEntity->pev->origin.z -= 1;
LINK_ENTITY( pEdict, true );
#endif
return 1; // handled
}
#endif
*/
return 0;
}
static physics_interface_t gPhysicsInterface =
{
SV_PHYSICS_INTERFACE_VERSION,
DispatchCreateEntity,
DispatchPhysicsEntity,
};
BOOL gPhysicsInterfaceInitialized = FALSE;
int Server_GetPhysicsInterface( int iVersion, server_physics_api_t *pfuncsFromEngine, physics_interface_t *pFunctionTable )
{
if( !pFunctionTable || !pfuncsFromEngine || iVersion != SV_PHYSICS_INTERFACE_VERSION )
{
return FALSE;
}
// copy new physics interface
memcpy( &g_physfuncs, pfuncsFromEngine, sizeof(server_physics_api_t) );
// fill engine callbacks
memcpy( pFunctionTable, &gPhysicsInterface, sizeof(physics_interface_t) );
gPhysicsInterfaceInitialized = TRUE;
return TRUE;
}

114
engine/physint.h

@ -1,114 +0,0 @@ @@ -1,114 +0,0 @@
/*
physint.h - Server Physics Interface
Copyright (C) 2011 Uncle Mike
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 3 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.
*/
#pragma once
#ifndef PHYSINT_H
#define PHYSINT_H
#define SV_PHYSICS_INTERFACE_VERSION 6
#define STRUCT_FROM_LINK( l, t, m ) ((t *)((byte *)l - (int)&(((t *)0)->m)))
#define EDICT_FROM_AREA( l ) STRUCT_FROM_LINK( l, edict_t, area )
// values that can be returned with pfnServerState
#define SERVER_DEAD 0
#define SERVER_LOADING 1
#define SERVER_ACTIVE 2
typedef struct areanode_s
{
int axis; // -1 = leaf node
float dist;
struct areanode_s *children[2];
link_t trigger_edicts;
link_t solid_edicts;
link_t water_edicts; // func water
} areanode_t;
typedef struct server_physics_api_s
{
// unlink edict from old position and link onto new
void ( *pfnLinkEdict) ( edict_t *ent, qboolean touch_triggers );
double ( *pfnGetServerTime )( void ); // unclamped
double ( *pfnGetFrameTime )( void ); // unclamped
void* ( *pfnGetModel )( int modelindex );
areanode_t* ( *pfnGetHeadnode )( void ); // BSP tree for all physic entities
int ( *pfnServerState )( void );
void ( *pfnHost_Error )( const char *error, ... ); // cause Host Error
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 6
struct triangleapi_s *pTriAPI; // draw coliisions etc. Only for local system
// draw debug messages (must be called from DrawOrthoTriangles). Only for local system
int ( *pfnDrawConsoleString )( int x, int y, char *string );
void ( *pfnDrawSetTextColor )( float r, float g, float b );
void ( *pfnDrawConsoleStringLen )( const char *string, int *length, int *height );
void ( *Con_NPrintf )( int pos, char *fmt, ... );
void ( *Con_NXPrintf )( struct con_nprint_s *info, char *fmt, ... );
const char *( *pfnGetLightStyle )( int style ); // read custom appreance for selected lightstyle
void ( *pfnUpdateFogSettings )( unsigned int packed_fog );
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly );
struct msurface_s *(*pfnTraceSurface)( edict_t *pTextureEntity, const float *v1, const float *v2 );
const byte *(*pfnGetTextureData)( unsigned int texnum );
// static allocations
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
} server_physics_api_t;
// physic callbacks
typedef struct physics_interface_s
{
int version;
// passed through pfnCreate (0 is attempt to create, -1 is reject)
int ( *SV_CreateEntity )( edict_t *pent, const char *szName );
// run custom physics for each entity (return 0 to use built-in engine physic)
int ( *SV_PhysicsEntity )( edict_t *pEntity );
// spawn entities with internal mod function e.g. for re-arrange spawn order (0 - use engine parser, 1 - use mod parser)
int ( *SV_LoadEntities )( const char *mapname, char *entities );
// update conveyor belt for clients
void ( *SV_UpdatePlayerBaseVelocity )( edict_t *ent );
// The game .dll should return 1 if save game should be allowed
int ( *SV_AllowSaveGame )( void );
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 6
// override trigger area checking and touching
int ( *SV_TriggerTouch )( edict_t *pent, edict_t *trigger );
// some engine features can be enabled only through this function
unsigned int ( *SV_CheckFeatures )( void );
// used for draw debug collisions for custom physic engine etc
void ( *DrawDebugTriangles )( void );
// used for draw debug overlay (textured)
void ( *DrawNormalTriangles )( void );
// used for draw debug messages (2d mode)
void ( *DrawOrthoTriangles )( void );
// tracing entities with SOLID_CUSTOM mode on a server (not used by pmove code)
void ( *ClipMoveToEntity)( edict_t *ent, const float *start, float *mins, float *maxs, const float *end, trace_t *trace );
// tracing entities with SOLID_CUSTOM mode on a server (only used by pmove code)
void ( *ClipPMoveToEntity)( struct physent_s *pe, const float *start, float *mins, float *maxs, const float *end, struct pmtrace_s *tr );
// called at end the frame of SV_Physics call
void ( *SV_EndFrame )( void );
// called through save\restore process
void (*pfnCreateEntitiesInTransitionList)( SAVERESTOREDATA*, int levelMask );
// called through save\restore process
void (*pfnCreateEntitiesInRestoreList)( SAVERESTOREDATA*, int createPlayers );
// allocate custom string (e.g. using user implementation of stringtable, not engine strings)
string_t (*pfnAllocString)( const char *szValue );
// make custom string (e.g. using user implementation of stringtable, not engine strings)
string_t (*pfnMakeString)( const char *szValue );
// read custom string (e.g. using user implementation of stringtable, not engine strings)
const char* (*pfnGetString)( string_t iString );
// helper for restore custom decals that have custom message (e.g. Paranoia)
int (*pfnRestoreDecal)( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
} physics_interface_t;
#endif//PHYSINT_H
Loading…
Cancel
Save