mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-07 04:40:43 +08:00
Compare commits
6 Commits
continuous
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c9b62cb03 | ||
|
|
9ff6eed0bf | ||
|
|
b6196c3c95 | ||
|
|
1ee2186f72 | ||
|
|
6099d5eadd | ||
|
|
3d68e13585 |
29
.github/workflows/c-cpp.yml
vendored
29
.github/workflows/c-cpp.yml
vendored
@@ -6,21 +6,8 @@ jobs:
|
||||
# steps:
|
||||
# - name: Cleanup
|
||||
# run: rm -rf .* || true
|
||||
get_prev_runid:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
value: ${{ steps.do.outputs.value }}
|
||||
steps:
|
||||
- id: do
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
value=$(gh run -R ${{ github.repository }} list -b${{ github.ref_name }} -ssuccess -L1 --json databaseId -q'.[0].databaseId')
|
||||
echo "Last run ID is $value"
|
||||
echo "value=$value" >> "$GITHUB_OUTPUT"
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: get_prev_runid
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -79,22 +66,14 @@ jobs:
|
||||
targetos: apple
|
||||
targetarch: amd64
|
||||
env:
|
||||
SDL_VERSION: 2.30.11
|
||||
SDL_VERSION: 2.30.10
|
||||
GH_CPU_ARCH: ${{ matrix.targetarch }}
|
||||
GH_CROSSCOMPILING: ${{ matrix.cross }}
|
||||
WAFCACHE: ${{ github.workspace }}/wafcache/
|
||||
WAFCACHE_EVICT_MAX_BYTES: 1000000 # github only gives 10gb for the whole repository
|
||||
WAFCACHE_STATS: 1 # enable statistics in build log
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Restore cache
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
key: ${{ runner.os }}-${{ matrix.targetos }}-${{ matrix.targetarch }}-${{ needs.get_prev_runid.outputs.value }}
|
||||
path: ${{ github.workspace }}/wafcache/
|
||||
- name: Install dependencies
|
||||
run: bash scripts/gha/deps_${{ matrix.targetos }}.sh
|
||||
- name: Build engine
|
||||
@@ -106,12 +85,6 @@ jobs:
|
||||
with:
|
||||
name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }}
|
||||
path: artifacts/*
|
||||
- name: Save cache
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ github.workspace }}/wafcache/
|
||||
key: ${{ runner.os }}-${{ matrix.targetos }}-${{ matrix.targetarch }}-${{ github.run_id }}
|
||||
|
||||
flatpak:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
[](https://builds.sr.ht/~a1batross/xash3d-fwgs?) [](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [](http://fwgsdiscord.mentality.rip/) \
|
||||
[](https://github.com/FWGS/xash3d-fwgs/releases/latest) [](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous)
|
||||
|
||||
Xash3D ([pronounced](https://ipa-reader.com/?text=ks%C9%91%CA%82) `[ksɑʂ]`) FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
|
||||
Xash3D (pronounced `[ksɑʂ]`) FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
|
||||
|
||||
Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://www.moddb.com/engines/xash3d-engine) by Unkle Mike.
|
||||
|
||||
|
||||
@@ -30,18 +30,6 @@ public class XashActivity extends SDLActivity {
|
||||
AndroidBug5497Workaround.assistActivity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
|
||||
// Now that we don't exit from native code, we need to exit here, resetting
|
||||
// application state (actually global variables that we don't cleanup on exit)
|
||||
//
|
||||
// When the issue with global variables will be resolved, remove that exit() call
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getLibraries() {
|
||||
return new String[]{"SDL2", "xash"};
|
||||
|
||||
@@ -16,6 +16,8 @@ GNU General Public License for more details.
|
||||
#ifndef BSPFILE_H
|
||||
#define BSPFILE_H
|
||||
|
||||
//#define SUPPORT_BSP2_FORMAT // allow to loading Darkplaces BSP2 maps (with broke binary compatibility)
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
@@ -63,6 +65,7 @@ BRUSH MODELS
|
||||
#define MAX_MAP_CLIPNODES_BSP2 524288
|
||||
|
||||
// these limis not using by modelloader but only for displaying 'mapstats' correctly
|
||||
#ifdef SUPPORT_BSP2_FORMAT
|
||||
#define MAX_MAP_MODELS 2048 // embedded models
|
||||
#define MAX_MAP_ENTSTRING 0x200000 // 2 Mb should be enough
|
||||
#define MAX_MAP_PLANES 131072 // can be increased without problems
|
||||
@@ -72,6 +75,18 @@ BRUSH MODELS
|
||||
#define MAX_MAP_VERTS 524288 // can be increased without problems
|
||||
#define MAX_MAP_FACES 262144 // can be increased without problems
|
||||
#define MAX_MAP_MARKSURFACES 524288 // can be increased without problems
|
||||
#else
|
||||
// increased to match PrimeXT compilers
|
||||
#define MAX_MAP_MODELS 1024 // embedded models
|
||||
#define MAX_MAP_ENTSTRING 0x100000 // 1 Mb should be enough
|
||||
#define MAX_MAP_PLANES 65536 // can be increased without problems
|
||||
#define MAX_MAP_NODES 32767 // because negative shorts are leafs
|
||||
#define MAX_MAP_CLIPNODES MAX_MAP_CLIPNODES_HLBSP // because negative shorts are contents
|
||||
#define MAX_MAP_LEAFS 32767 // signed short limit
|
||||
#define MAX_MAP_VERTS 65535 // unsigned short limit
|
||||
#define MAX_MAP_FACES 65535 // unsigned short limit
|
||||
#define MAX_MAP_MARKSURFACES 65535 // unsigned short limit
|
||||
#endif
|
||||
|
||||
#define MAX_MAP_ENTITIES 8192 // network limit
|
||||
#define MAX_MAP_TEXINFO MAX_MAP_FACES // in theory each face may have personal texinfo
|
||||
|
||||
@@ -60,29 +60,26 @@ typedef struct
|
||||
vec3_t position;
|
||||
} mvertex_t;
|
||||
|
||||
typedef struct mclipnode32_s
|
||||
typedef struct
|
||||
{
|
||||
int planenum;
|
||||
int children[2]; // negative numbers are contents
|
||||
} mclipnode32_t;
|
||||
|
||||
typedef struct mclipnode16_s
|
||||
{
|
||||
int planenum;
|
||||
short children[2]; // negative numbers are contents
|
||||
} mclipnode16_t;
|
||||
int planenum;
|
||||
#ifdef SUPPORT_BSP2_FORMAT
|
||||
int children[2]; // negative numbers are contents
|
||||
#else
|
||||
short children[2]; // negative numbers are contents
|
||||
#endif
|
||||
} mclipnode_t;
|
||||
|
||||
// size is matched but representation is not
|
||||
typedef struct medge32_s
|
||||
typedef struct
|
||||
{
|
||||
#ifdef SUPPORT_BSP2_FORMAT
|
||||
unsigned int v[2];
|
||||
} medge32_t;
|
||||
|
||||
typedef struct medge16_s
|
||||
{
|
||||
#else
|
||||
unsigned short v[2];
|
||||
unsigned int cachededgeoffset;
|
||||
} medge16_t;
|
||||
#endif
|
||||
} medge_t;
|
||||
|
||||
typedef struct texture_s
|
||||
{
|
||||
@@ -159,31 +156,13 @@ typedef struct mnode_s
|
||||
|
||||
// node specific
|
||||
mplane_t *plane;
|
||||
|
||||
#if !XASH_64BIT
|
||||
union
|
||||
{
|
||||
struct mnode_s *children_[2];
|
||||
struct
|
||||
{
|
||||
// the ordering is important
|
||||
int child_0_leaf : 1;
|
||||
int child_0_off : 23;
|
||||
int firstsurface_1 : 8;
|
||||
int child_1_leaf : 1;
|
||||
int child_1_off : 23;
|
||||
int numsurfaces_1 : 8;
|
||||
};
|
||||
};
|
||||
unsigned short firstsurface_0;
|
||||
unsigned short numsurfaces_0;
|
||||
struct mnode_s *children[2];
|
||||
#ifdef SUPPORT_BSP2_FORMAT
|
||||
int firstsurface;
|
||||
int numsurfaces;
|
||||
#else
|
||||
// in 64-bit ABI this struct has 4 more bytes of padding, let's use it!
|
||||
struct mnode_s *children_[2];
|
||||
unsigned short firstsurface_0;
|
||||
unsigned short numsurfaces_0;
|
||||
unsigned short firstsurface_1;
|
||||
unsigned short numsurfaces_1;
|
||||
unsigned short firstsurface;
|
||||
unsigned short numsurfaces;
|
||||
#endif
|
||||
} mnode_t;
|
||||
|
||||
@@ -224,6 +203,7 @@ typedef struct mleaf_s
|
||||
int nummarksurfaces;
|
||||
int cluster; // helper to acess to uncompressed visdata
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
|
||||
} mleaf_t;
|
||||
|
||||
// surface extradata
|
||||
@@ -311,11 +291,7 @@ struct msurface_s
|
||||
|
||||
typedef struct hull_s
|
||||
{
|
||||
union
|
||||
{
|
||||
mclipnode16_t *clipnodes16;
|
||||
mclipnode32_t *clipnodes32;
|
||||
};
|
||||
mclipnode_t *clipnodes;
|
||||
mplane_t *planes;
|
||||
int firstclipnode;
|
||||
int lastclipnode;
|
||||
@@ -365,12 +341,7 @@ typedef struct model_s
|
||||
mvertex_t *vertexes;
|
||||
|
||||
int numedges;
|
||||
union
|
||||
{
|
||||
medge16_t *edges16;
|
||||
medge32_t *edges32;
|
||||
};
|
||||
|
||||
medge_t *edges;
|
||||
|
||||
int numnodes;
|
||||
mnode_t *nodes;
|
||||
@@ -385,11 +356,7 @@ typedef struct model_s
|
||||
int *surfedges;
|
||||
|
||||
int numclipnodes;
|
||||
union
|
||||
{
|
||||
mclipnode16_t *clipnodes16;
|
||||
mclipnode32_t *clipnodes32;
|
||||
};
|
||||
mclipnode_t *clipnodes;
|
||||
|
||||
int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
@@ -583,68 +550,16 @@ typedef struct
|
||||
#define ANIM_CYCLE 2
|
||||
#define MOD_FRAMES 20
|
||||
|
||||
|
||||
|
||||
#define MAX_DEMOS 32
|
||||
#define MAX_MOVIES 8
|
||||
#define MAX_CDTRACKS 32
|
||||
#define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client)
|
||||
#define MAX_REQUESTS 64
|
||||
|
||||
STATIC_CHECK_SIZEOF( mnode_t, 52, 72 );
|
||||
STATIC_CHECK_SIZEOF( mextrasurf_t, 324, 496 );
|
||||
STATIC_CHECK_SIZEOF( decal_t, 60, 88 );
|
||||
STATIC_CHECK_SIZEOF( mfaceinfo_t, 176, 304 );
|
||||
|
||||
// model flags (stored in model_t->flags)
|
||||
#define MODEL_QBSP2 BIT( 28 ) // uses 32-bit types
|
||||
|
||||
// access functions
|
||||
static inline mnode_t *node_child( const mnode_t *n, int side, const model_t *mod )
|
||||
{
|
||||
#if !XASH_64BIT
|
||||
if( unlikely( mod->flags & MODEL_QBSP2 )) // MODEL_QBSP2
|
||||
{
|
||||
if( side == 0 )
|
||||
{
|
||||
if( n->child_0_leaf )
|
||||
return (mnode_t *)(mod->leafs + n->child_0_off);
|
||||
else
|
||||
return (mnode_t *)(mod->nodes + n->child_0_off);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( n->child_1_leaf )
|
||||
return (mnode_t *)(mod->leafs + n->child_1_off);
|
||||
else
|
||||
return (mnode_t *)(mod->nodes + n->child_1_off);
|
||||
}
|
||||
}
|
||||
|
||||
return n->children_[side];
|
||||
#else
|
||||
return n->children_[side];
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void node_children( mnode_t *children[2], const mnode_t *n, const model_t *mod )
|
||||
{
|
||||
children[0] = node_child( n, 0, mod );
|
||||
children[1] = node_child( n, 1, mod );
|
||||
}
|
||||
|
||||
static inline int node_firstsurface( const mnode_t *n, const model_t *mod )
|
||||
{
|
||||
if( mod->flags & MODEL_QBSP2 )
|
||||
return n->firstsurface_0 + ( n->firstsurface_1 << 16 );
|
||||
else
|
||||
return n->firstsurface_0;
|
||||
}
|
||||
|
||||
static inline int node_numsurfaces( const mnode_t *n, const model_t *mod )
|
||||
{
|
||||
if( mod->flags & MODEL_QBSP2 )
|
||||
return n->numsurfaces_0 + ( n->numsurfaces_1 << 16 );
|
||||
else
|
||||
return n->numsurfaces_0;
|
||||
}
|
||||
|
||||
#endif//COM_MODEL_H
|
||||
|
||||
@@ -127,10 +127,8 @@ static void R_SplitEntityOnNode( mnode_t *node )
|
||||
}
|
||||
|
||||
// recurse down the contacted sides
|
||||
if( sides & 1 )
|
||||
R_SplitEntityOnNode( node_child( node, 0, cl.worldmodel ));
|
||||
if( sides & 2 )
|
||||
R_SplitEntityOnNode( node_child( node, 1, cl.worldmodel ));
|
||||
if( sides & 1 ) R_SplitEntityOnNode( node->children[0] );
|
||||
if( sides & 2 ) R_SplitEntityOnNode( node->children[1] );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -2408,8 +2408,9 @@ CL_FindModelIndex
|
||||
*/
|
||||
static int GAME_EXPORT CL_FindModelIndex( const char *m )
|
||||
{
|
||||
char filepath[MAX_QPATH];
|
||||
int i;
|
||||
char filepath[MAX_QPATH];
|
||||
static float lasttimewarn;
|
||||
int i;
|
||||
|
||||
if( !COM_CheckString( m ))
|
||||
return 0;
|
||||
@@ -2426,6 +2427,13 @@ static int GAME_EXPORT CL_FindModelIndex( const char *m )
|
||||
return i+1;
|
||||
}
|
||||
|
||||
if( lasttimewarn < host.realtime )
|
||||
{
|
||||
// tell user about problem (but don't spam console)
|
||||
Con_DPrintf( S_ERROR "Could not find index for model %s: not precached\n", filepath );
|
||||
lasttimewarn = host.realtime + 1.0f;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1761,8 +1761,8 @@ static size_t NONNULL CL_BuildMasterServerScanRequest( char *buf, size_t size, u
|
||||
// let master know about client version
|
||||
Info_SetValueForKey( info, "clver", XASH_VERSION, remaining );
|
||||
Info_SetValueForKey( info, "nat", nat ? "1" : "0", remaining );
|
||||
Info_SetValueForKey( info, "commit", g_buildcommit, remaining );
|
||||
Info_SetValueForKey( info, "branch", g_buildbranch, remaining );
|
||||
Info_SetValueForKey( info, "commit", Q_buildcommit(), remaining );
|
||||
Info_SetValueForKey( info, "branch", Q_buildbranch(), remaining );
|
||||
Info_SetValueForKey( info, "os", Q_buildos(), remaining );
|
||||
Info_SetValueForKey( info, "arch", Q_buildarch(), remaining );
|
||||
|
||||
|
||||
@@ -138,7 +138,10 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
|
||||
switch( parm )
|
||||
{
|
||||
case PARM_BSP2_SUPPORTED:
|
||||
#ifdef SUPPORT_BSP2_FORMAT
|
||||
return 1;
|
||||
#endif
|
||||
return 0;
|
||||
case PARAM_GAMEPAUSED:
|
||||
return cl.paused;
|
||||
case PARM_CLIENT_INGAME:
|
||||
|
||||
@@ -567,54 +567,57 @@ R_FizzEffect
|
||||
Create a fizz effect
|
||||
==============
|
||||
*/
|
||||
void GAME_EXPORT R_FizzEffect( cl_entity_t *ent, int modelIndex, int density )
|
||||
void GAME_EXPORT R_FizzEffect( cl_entity_t *pent, int modelIndex, int density )
|
||||
{
|
||||
const float base_time = cl.time - 0.1f;
|
||||
model_t *mod = CL_ModelHandle( modelIndex );
|
||||
vec3_t volume, mins, maxs;
|
||||
vec2_t speed;
|
||||
int i;
|
||||
TEMPENTITY *pTemp;
|
||||
int i, width, depth;
|
||||
float angle, maxHeight, speed;
|
||||
float xspeed, yspeed, zspeed;
|
||||
vec3_t origin;
|
||||
model_t *mod;
|
||||
|
||||
if( !ent || !ent->model || !modelIndex || !mod )
|
||||
if( !pent || !pent->model || !modelIndex )
|
||||
return;
|
||||
|
||||
VectorCopy( ent->model->mins, mins );
|
||||
VectorCopy( ent->model->maxs, maxs );
|
||||
if(( mod = CL_ModelHandle( modelIndex )) == NULL )
|
||||
return;
|
||||
|
||||
if( ent->angles[1] != 0.0f )
|
||||
{
|
||||
const float base_speed = ( ent->curstate.rendercolor.b ? -1.0f : 1.0f ) * ( ent->curstate.rendercolor.r * 256.0f + ent->curstate.rendercolor.g );
|
||||
SinCos( DEG2RAD( ent->angles[1] ), &speed[1], &speed[0] );
|
||||
speed[0] *= base_speed;
|
||||
speed[1] *= base_speed;
|
||||
}
|
||||
else speed[0] = speed[1] = 0.0f;
|
||||
maxHeight = pent->model->maxs[2] - pent->model->mins[2];
|
||||
width = pent->model->maxs[0] - pent->model->mins[0];
|
||||
depth = pent->model->maxs[1] - pent->model->mins[1];
|
||||
|
||||
VectorSubtract( maxs, mins, volume );
|
||||
speed = ( pent->curstate.rendercolor.r<<8 | pent->curstate.rendercolor.g );
|
||||
if( pent->curstate.rendercolor.b )
|
||||
speed = -speed;
|
||||
|
||||
angle = DEG2RAD( pent->angles[YAW] );
|
||||
SinCos( angle, &yspeed, &xspeed );
|
||||
|
||||
xspeed *= speed;
|
||||
yspeed *= speed;
|
||||
|
||||
for( i = 0; i <= density; i++ )
|
||||
{
|
||||
TEMPENTITY *tent;
|
||||
vec3_t origin;
|
||||
origin[0] = mod->mins[0] + COM_RandomLong( 0, width - 1 );
|
||||
origin[1] = mod->mins[1] + COM_RandomLong( 0, depth - 1 );
|
||||
origin[2] = mod->mins[2];
|
||||
pTemp = CL_TempEntAlloc( origin, mod );
|
||||
|
||||
VectorCopy( mins, origin );
|
||||
origin[0] += COM_RandomLong( 0, (int)volume[0] - 1 );
|
||||
origin[1] += COM_RandomLong( 0, (int)volume[1] - 1 );
|
||||
if ( !pTemp ) return;
|
||||
|
||||
if( !( tent = CL_TempEntAlloc( origin, mod )))
|
||||
return;
|
||||
pTemp->flags |= FTENT_SINEWAVE;
|
||||
|
||||
tent->x = origin[0];
|
||||
tent->y = origin[1];
|
||||
tent->die = base_time;
|
||||
tent->flags |= FTENT_SINEWAVE;
|
||||
tent->entity.curstate.rendermode = kRenderTransAlpha;
|
||||
Vector2Copy( speed, tent->entity.baseline.origin );
|
||||
pTemp->x = origin[0];
|
||||
pTemp->y = origin[1];
|
||||
|
||||
tent->entity.baseline.origin[2] = COM_RandomLong( 80, 140 );
|
||||
tent->die += volume[2] / tent->entity.baseline.origin[2];
|
||||
tent->entity.curstate.frame = COM_RandomLong( 0, tent->frameMax );
|
||||
tent->entity.curstate.scale = 1.0f / COM_RandomFloat( 2.0f, 5.0f );
|
||||
zspeed = COM_RandomLong( 80, 140 );
|
||||
VectorSet( pTemp->entity.baseline.origin, xspeed, yspeed, zspeed );
|
||||
pTemp->die = cl.time + ( maxHeight / zspeed ) - 0.1f;
|
||||
pTemp->entity.curstate.frame = COM_RandomLong( 0, pTemp->frameMax );
|
||||
// Set sprite scale
|
||||
pTemp->entity.curstate.scale = 1.0f / COM_RandomFloat( 2.0f, 5.0f );
|
||||
pTemp->entity.curstate.rendermode = kRenderTransAlpha;
|
||||
pTemp->entity.curstate.renderamt = 255;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -466,8 +466,8 @@ static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int show
|
||||
R_DrawNodeConnection( x, y, x + scale, y + scale );
|
||||
}
|
||||
|
||||
R_ShowTree_r( node_child( node, 1, cl.worldmodel ), x - scale, y + scale, downScale, shownodes, viewleaf );
|
||||
R_ShowTree_r( node_child( node, 0, cl.worldmodel ), x + scale, y + scale, downScale, shownodes, viewleaf );
|
||||
R_ShowTree_r( node->children[1], x - scale, y + scale, downScale, shownodes, viewleaf );
|
||||
R_ShowTree_r( node->children[0], x + scale, y + scale, downScale, shownodes, viewleaf );
|
||||
|
||||
world.recursion_level--;
|
||||
}
|
||||
@@ -482,7 +482,7 @@ static void R_ShowTree( void )
|
||||
return;
|
||||
|
||||
world.recursion_level = 0;
|
||||
viewleaf = Mod_PointInLeaf( refState.vieworg, cl.worldmodel->nodes, cl.worldmodel );
|
||||
viewleaf = Mod_PointInLeaf( refState.vieworg, cl.worldmodel->nodes );
|
||||
|
||||
ref.dllFuncs.TriRenderMode( kRenderTransTexture );
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ static qboolean Touch_DumpConfig( const char *name, const char *profilename )
|
||||
}
|
||||
|
||||
FS_Printf( f, "//=======================================================================\n");
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\t\t\ttouchscreen config\n" );
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
FS_Printf( f, "\ntouch_config_file \"%s\"\n", profilename );
|
||||
|
||||
@@ -470,16 +470,16 @@ out_free:
|
||||
* This is a stack of the clipnodes we have traversed
|
||||
* "sides" indicates which side we went down each time
|
||||
*/
|
||||
static int node_stack[MAX_CLIPNODE_DEPTH];
|
||||
static mclipnode_t *node_stack[MAX_CLIPNODE_DEPTH];
|
||||
static int side_stack[MAX_CLIPNODE_DEPTH];
|
||||
static uint node_stack_depth;
|
||||
|
||||
static void push_node( int nodenum, int side )
|
||||
static void push_node( mclipnode_t *node, int side )
|
||||
{
|
||||
if( node_stack_depth == MAX_CLIPNODE_DEPTH )
|
||||
Host_Error( "node stack overflow\n" );
|
||||
|
||||
node_stack[node_stack_depth] = nodenum;
|
||||
node_stack[node_stack_depth] = node;
|
||||
side_stack[node_stack_depth] = side;
|
||||
node_stack_depth++;
|
||||
}
|
||||
@@ -502,27 +502,22 @@ static void free_hull_polys( hullnode_t *hull_polys )
|
||||
}
|
||||
}
|
||||
|
||||
static void hull_windings_r( hull_t *hull, int nodenum, hullnode_t *polys, hull_model_t *model );
|
||||
static void hull_windings_r( hull_t *hull, mclipnode_t *node, hullnode_t *polys, hull_model_t *model );
|
||||
|
||||
static void do_hull_recursion( hull_t *hull, int nodenum, int side, hullnode_t *polys, hull_model_t *model )
|
||||
static void do_hull_recursion( hull_t *hull, mclipnode_t *node, int side, hullnode_t *polys, hull_model_t *model )
|
||||
{
|
||||
winding_t *w, *next;
|
||||
int childnum;
|
||||
|
||||
if( world.version == QBSP2_VERSION )
|
||||
childnum = hull->clipnodes32[nodenum].children[side];
|
||||
else
|
||||
childnum = hull->clipnodes16[nodenum].children[side];
|
||||
|
||||
if( childnum >= 0 )
|
||||
if( node->children[side] >= 0 )
|
||||
{
|
||||
push_node( nodenum, side );
|
||||
hull_windings_r( hull, childnum, polys, model );
|
||||
mclipnode_t *child = hull->clipnodes + node->children[side];
|
||||
push_node( node, side );
|
||||
hull_windings_r( hull, child, polys, model );
|
||||
pop_node();
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( childnum )
|
||||
switch( node->children[side] )
|
||||
{
|
||||
case CONTENTS_EMPTY:
|
||||
case CONTENTS_WATER:
|
||||
@@ -547,25 +542,20 @@ static void do_hull_recursion( hull_t *hull, int nodenum, int side, hullnode_t *
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Host_Error( "bad contents: %i\n", childnum );
|
||||
Host_Error( "bad contents: %i\n", node->children[side] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void hull_windings_r( hull_t *hull, int nodenum, hullnode_t *polys, hull_model_t *model )
|
||||
static void hull_windings_r( hull_t *hull, mclipnode_t *node, hullnode_t *polys, hull_model_t *model )
|
||||
{
|
||||
mplane_t *plane;
|
||||
mplane_t *plane = hull->planes + node->planenum;
|
||||
hullnode_t frontlist = LIST_HEAD_INIT( frontlist );
|
||||
hullnode_t backlist = LIST_HEAD_INIT( backlist );
|
||||
winding_t *w, *next, *front, *back;
|
||||
int i;
|
||||
|
||||
if( world.version == QBSP2_VERSION )
|
||||
plane = hull->planes + hull->clipnodes32[nodenum].planenum;
|
||||
else
|
||||
plane = hull->planes + hull->clipnodes16[nodenum].planenum;
|
||||
|
||||
list_for_each_entry_safe( w, next, polys, chain )
|
||||
{
|
||||
// PARANIOA - PAIR CHECK
|
||||
@@ -611,13 +601,7 @@ static void hull_windings_r( hull_t *hull, int nodenum, hullnode_t *polys, hull_
|
||||
|
||||
for( i = 0; w && i < node_stack_depth; i++ )
|
||||
{
|
||||
mplane_t *p;
|
||||
|
||||
if( world.version == QBSP2_VERSION )
|
||||
p = hull->planes + hull->clipnodes32[node_stack[i]].planenum;
|
||||
else
|
||||
p = hull->planes + hull->clipnodes16[node_stack[i]].planenum;
|
||||
|
||||
mplane_t *p = hull->planes + node_stack[i]->planenum;
|
||||
w = winding_clip( w, p, false, side_stack[i], 0.00001 );
|
||||
}
|
||||
|
||||
@@ -641,8 +625,8 @@ static void hull_windings_r( hull_t *hull, int nodenum, hullnode_t *polys, hull_
|
||||
Con_Printf( S_WARN "new winding was clipped away!\n" );
|
||||
}
|
||||
|
||||
do_hull_recursion( hull, nodenum, 0, &frontlist, model );
|
||||
do_hull_recursion( hull, nodenum, 1, &backlist, model );
|
||||
do_hull_recursion( hull, node, 0, &frontlist, model );
|
||||
do_hull_recursion( hull, node, 1, &backlist, model );
|
||||
}
|
||||
|
||||
static void remove_paired_polys( hull_model_t *model )
|
||||
@@ -671,7 +655,7 @@ static void make_hull_windings( hull_t *hull, hull_model_t *model )
|
||||
|
||||
if( hull->planes != NULL )
|
||||
{
|
||||
hull_windings_r( hull, hull->firstclipnode, &head, model );
|
||||
hull_windings_r( hull, hull->clipnodes + hull->firstclipnode, &head, model );
|
||||
remove_paired_polys( model );
|
||||
}
|
||||
Con_Reportf( "%i hull polys\n", model->num_polys );
|
||||
|
||||
@@ -300,12 +300,6 @@ static qboolean R_Init_Video_( const int type )
|
||||
return R_Init_Video( type );
|
||||
}
|
||||
|
||||
static mleaf_t *pfnMod_PointInLeaf( const vec3_t p, mnode_t *node )
|
||||
{
|
||||
// FIXME: get rid of this on next RefAPI update
|
||||
return Mod_PointInLeaf( p, node, cl.models[1] );
|
||||
}
|
||||
|
||||
static const ref_api_t gEngfuncs =
|
||||
{
|
||||
pfnEngineGetParm,
|
||||
@@ -346,7 +340,7 @@ static const ref_api_t gEngfuncs =
|
||||
|
||||
Mod_SampleSizeForFace,
|
||||
Mod_BoxVisible,
|
||||
pfnMod_PointInLeaf,
|
||||
Mod_PointInLeaf,
|
||||
R_DrawWorldHull,
|
||||
R_DrawModelHull,
|
||||
|
||||
|
||||
@@ -996,7 +996,7 @@ static void S_UpdateAmbientSounds( void )
|
||||
// calc ambient sound levels
|
||||
if( !cl.worldmodel ) return;
|
||||
|
||||
leaf = Mod_PointInLeaf( s_listener.origin, cl.worldmodel->nodes, cl.worldmodel );
|
||||
leaf = Mod_PointInLeaf( s_listener.origin, cl.worldmodel->nodes );
|
||||
|
||||
if( !leaf || !s_ambient_level.value )
|
||||
{
|
||||
|
||||
@@ -72,6 +72,8 @@ GNU General Public License for more details.
|
||||
|
||||
#define CVAR_GLCONFIG_DESCRIPTION "enable or disable %s"
|
||||
|
||||
#define DEFAULT_BSP_BUILD_ERROR "%s can't be loaded in this build. Please rebuild engine with enabled SUPPORT_BSP2_FORMAT\n"
|
||||
|
||||
#define DEFAULT_UPDATE_PAGE "https://github.com/FWGS/xash3d-fwgs/releases/latest"
|
||||
|
||||
#define XASH_ENGINE_NAME "Xash3D FWGS"
|
||||
|
||||
@@ -301,6 +301,7 @@ typedef struct host_parm_s
|
||||
poolhandle_t mempool; // static mempool for misc allocations
|
||||
poolhandle_t imagepool; // imagelib mempool
|
||||
poolhandle_t soundpool; // soundlib mempool
|
||||
string finalmsg; // server shutdown final message
|
||||
string downloadfile; // filename to be downloading
|
||||
int downloadcount; // how many files remain to downloading
|
||||
char deferred_cmd[128];// deferred commands
|
||||
@@ -559,7 +560,6 @@ void Host_Error( const char *error, ... ) FORMAT_CHECK( 1 );
|
||||
void Host_ValidateEngineFeatures( uint32_t mask, uint32_t features );
|
||||
void Host_Frame( double time );
|
||||
void Host_Credits( void );
|
||||
void Host_ExitInMain( void );
|
||||
|
||||
//
|
||||
// host_state.c
|
||||
|
||||
@@ -1395,7 +1395,7 @@ void Host_WriteConfig( void )
|
||||
{
|
||||
Con_Reportf( "%s()\n", __func__ );
|
||||
FS_Printf( f, "//=======================================================================\n");
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\t\tconfig.cfg - archive of cvars\n" );
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
Key_WriteBindings( f );
|
||||
@@ -1443,7 +1443,7 @@ void GAME_EXPORT Host_WriteServerConfig( const char *name )
|
||||
if(( f = FS_Open( newconfigfile, "w", false )) != NULL )
|
||||
{
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\t\tgame.cfg - multiplayer server temporare config\n" );
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
|
||||
@@ -1478,7 +1478,7 @@ void Host_WriteOpenGLConfig( void )
|
||||
{
|
||||
Con_Reportf( "%s()\n", __func__ );
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\t\t%s - archive of renderer implementation cvars\n", name );
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
FS_Printf( f, "\n" );
|
||||
@@ -1508,7 +1508,7 @@ void Host_WriteVideoConfig( void )
|
||||
{
|
||||
Con_Reportf( "%s()\n", __func__ );
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\t\tvideo.cfg - archive of renderer variables\n");
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
Cvar_WriteVariables( f, FCVAR_RENDERINFO );
|
||||
@@ -1534,7 +1534,7 @@ void Key_EnumCmds_f( void )
|
||||
if( f )
|
||||
{
|
||||
FS_Printf( f, "//=======================================================================\n");
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
|
||||
FS_Printf( f, "//\t\thelp.txt - xash commands and console variables\n");
|
||||
FS_Printf( f, "//=======================================================================\n");
|
||||
|
||||
|
||||
@@ -43,27 +43,6 @@ GNU General Public License for more details.
|
||||
static pfnChangeGame pChangeGame = NULL;
|
||||
host_parm_t host; // host parms
|
||||
|
||||
#if XASH_ANDROID
|
||||
static jmp_buf return_from_main_buf;
|
||||
|
||||
/*
|
||||
===============
|
||||
Host_ExitInMain
|
||||
|
||||
On some platforms (e.g. Android) we can't exit with exit(3) as calling it would
|
||||
kill wrapper process (e.g. app_process) too early, before all resources would
|
||||
be freed, contexts released, files closed, etc, etc...
|
||||
|
||||
To fix this, we create jmp_buf in Host_Main function, when jumping into with
|
||||
non-zero value will immediately return from it with `error_on_exit`.
|
||||
===============
|
||||
*/
|
||||
void Host_ExitInMain( void )
|
||||
{
|
||||
longjmp( return_from_main_buf, 1 );
|
||||
}
|
||||
#endif // XASH_ANDROID
|
||||
|
||||
#ifdef XASH_ENGINE_TESTS
|
||||
struct tests_stats_s tests_stats;
|
||||
#endif
|
||||
@@ -383,8 +362,9 @@ static void Host_NewInstance( const char *name, const char *finalmsg )
|
||||
if( !pChangeGame ) return;
|
||||
|
||||
host.change_game = true;
|
||||
Q_strncpy( host.finalmsg, finalmsg, sizeof( host.finalmsg ));
|
||||
|
||||
if( !Sys_NewInstance( name, finalmsg ))
|
||||
if( !Sys_NewInstance( name ))
|
||||
pChangeGame( name ); // call from hl.exe
|
||||
}
|
||||
|
||||
@@ -858,6 +838,7 @@ void GAME_EXPORT Host_Error( const char *error, ... )
|
||||
recursive = true;
|
||||
Q_strncpy( hosterror2, hosterror1, sizeof( hosterror2 ));
|
||||
host.errorframe = host.framecount; // to avoid multply calls per frame
|
||||
Q_snprintf( host.finalmsg, sizeof( host.finalmsg ), "Server crashed: %s", hosterror1 );
|
||||
|
||||
// clearing cmd buffer to prevent execute any commands
|
||||
COM_InitHostState();
|
||||
@@ -1233,7 +1214,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
|
||||
|
||||
Cvar_Getf( "buildnum", FCVAR_READ_ONLY, "returns a current build number", "%i", Q_buildnum_compat());
|
||||
Cvar_Getf( "ver", FCVAR_READ_ONLY, "shows an engine version", "%i/%s (hw build %i)", PROTOCOL_VERSION, XASH_COMPAT_VERSION, Q_buildnum_compat());
|
||||
Cvar_Getf( "host_ver", FCVAR_READ_ONLY, "detailed info about this build", "%i " XASH_VERSION " %s %s %s", Q_buildnum(), Q_buildos(), Q_buildarch(), g_buildcommit);
|
||||
Cvar_Getf( "host_ver", FCVAR_READ_ONLY, "detailed info about this build", "%i " XASH_VERSION " %s %s %s", Q_buildnum(), Q_buildos(), Q_buildarch(), Q_buildcommit());
|
||||
Cvar_Getf( "host_lowmemorymode", FCVAR_READ_ONLY, "indicates if engine compiled for low RAM consumption (0 - normal, 1 - low engine limits, 2 - low protocol limits)", "%i", XASH_LOW_MEMORY );
|
||||
|
||||
Mod_Init();
|
||||
@@ -1340,11 +1321,6 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
|
||||
// check after all configs were executed
|
||||
HPAK_CheckIntegrity( hpk_custom_file.string );
|
||||
|
||||
#if XASH_ANDROID
|
||||
if( setjmp( return_from_main_buf ))
|
||||
return error_on_exit;
|
||||
#endif // XASH_ANDROID
|
||||
|
||||
// main window message loop
|
||||
while( !host.crashed )
|
||||
{
|
||||
@@ -1383,6 +1359,9 @@ void Host_ShutdownWithReason( const char *reason )
|
||||
if( host.status != HOST_ERR_FATAL )
|
||||
host.status = HOST_SHUTDOWN; // prepare host to normal shutdown
|
||||
|
||||
if( !host.change_game )
|
||||
Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg ));
|
||||
|
||||
#if !XASH_DEDICATED
|
||||
if( host.type == HOST_NORMAL && !error )
|
||||
Host_WriteConfig();
|
||||
@@ -1405,5 +1384,5 @@ void Host_ShutdownWithReason( const char *reason )
|
||||
|
||||
// restore filter
|
||||
Sys_RestoreCrashHandler();
|
||||
Sys_CloseLog( reason );
|
||||
Sys_CloseLog();
|
||||
}
|
||||
|
||||
@@ -385,35 +385,6 @@ static const mlumpinfo_t extlumps[EXTRA_LUMPS] =
|
||||
},
|
||||
};
|
||||
|
||||
#define BOX_CLIPNODES_INITIALIZER \
|
||||
{ \
|
||||
.planenum = 0, \
|
||||
.children = { CONTENTS_EMPTY, 1 }, \
|
||||
}, \
|
||||
{ \
|
||||
.planenum = 1, \
|
||||
.children = { 2, CONTENTS_EMPTY }, \
|
||||
}, \
|
||||
{ \
|
||||
.planenum = 2, \
|
||||
.children = { CONTENTS_EMPTY, 3 }, \
|
||||
}, \
|
||||
{ \
|
||||
.planenum = 3, \
|
||||
.children = { 4, CONTENTS_EMPTY }, \
|
||||
}, \
|
||||
{ \
|
||||
.planenum = 4, \
|
||||
.children = { CONTENTS_EMPTY, 5 }, \
|
||||
}, \
|
||||
{ \
|
||||
.planenum = 5, \
|
||||
.children = { CONTENTS_SOLID, CONTENTS_EMPTY }, \
|
||||
}, \
|
||||
|
||||
const mclipnode16_t box_clipnodes16[6] = { BOX_CLIPNODES_INITIALIZER };
|
||||
const mclipnode32_t box_clipnodes32[6] = { BOX_CLIPNODES_INITIALIZER };
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
@@ -885,7 +856,7 @@ Mod_PointInLeaf
|
||||
|
||||
==================
|
||||
*/
|
||||
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node, model_t *mod )
|
||||
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node )
|
||||
{
|
||||
Assert( node != NULL );
|
||||
|
||||
@@ -893,7 +864,7 @@ mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node, model_t *mod )
|
||||
{
|
||||
if( node->contents < 0 )
|
||||
return (mleaf_t *)node;
|
||||
node = node_child( node, PlaneDiff( p, node->plane ) <= 0, mod );
|
||||
node = node->children[PlaneDiff( p, node->plane ) <= 0];
|
||||
}
|
||||
|
||||
// never reached
|
||||
@@ -914,7 +885,7 @@ byte *Mod_GetPVSForPoint( const vec3_t p )
|
||||
|
||||
ASSERT( worldmodel != NULL );
|
||||
|
||||
leaf = Mod_PointInLeaf( p, worldmodel->nodes, worldmodel );
|
||||
leaf = Mod_PointInLeaf( p, worldmodel->nodes );
|
||||
|
||||
if( leaf && leaf->cluster >= 0 )
|
||||
return Mod_DecompressPVS( leaf->compressed_vis, world.visbytes );
|
||||
@@ -934,14 +905,14 @@ static void Mod_FatPVS_RecursiveBSPNode( const vec3_t org, float radius, byte *v
|
||||
float d = PlaneDiff( org, node->plane );
|
||||
|
||||
if( d > radius )
|
||||
node = node_child( node, 0, worldmodel );
|
||||
node = node->children[0];
|
||||
else if( d < -radius )
|
||||
node = node_child( node, 1, worldmodel );
|
||||
node = node->children[1];
|
||||
else
|
||||
{
|
||||
// go down both sides
|
||||
Mod_FatPVS_RecursiveBSPNode( org, radius, visbuffer, visbytes, node_child( node, 0, worldmodel ), phs );
|
||||
node = node_child( node, 1, worldmodel );
|
||||
Mod_FatPVS_RecursiveBSPNode( org, radius, visbuffer, visbytes, node->children[0], phs );
|
||||
node = node->children[1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -979,7 +950,7 @@ int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, q
|
||||
|
||||
ASSERT( worldmodel != NULL );
|
||||
|
||||
leaf = Mod_PointInLeaf( org, worldmodel->nodes, worldmodel );
|
||||
leaf = Mod_PointInLeaf( org, worldmodel->nodes );
|
||||
bytes = Q_min( bytes, visbytes );
|
||||
|
||||
// enable full visibility for some reasons
|
||||
@@ -1038,16 +1009,20 @@ static void Mod_BoxLeafnums_r( leaflist_t *ll, mnode_t *node )
|
||||
sides = BOX_ON_PLANE_SIDE( ll->mins, ll->maxs, node->plane );
|
||||
|
||||
if( sides == 1 )
|
||||
node = node_child( node, 0, worldmodel );
|
||||
{
|
||||
node = node->children[0];
|
||||
}
|
||||
else if( sides == 2 )
|
||||
node = node_child( node, 1, worldmodel );
|
||||
{
|
||||
node = node->children[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// go down both
|
||||
if( ll->topnode == -1 )
|
||||
ll->topnode = node - worldmodel->nodes;
|
||||
Mod_BoxLeafnums_r( ll, node_child( node, 0, worldmodel ));
|
||||
node = node_child( node, 1, worldmodel );
|
||||
Mod_BoxLeafnums_r( ll, node->children[0] );
|
||||
node = node->children[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1104,6 +1079,35 @@ qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbi
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Mod_HeadnodeVisible
|
||||
=============
|
||||
*/
|
||||
qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, int *lastleaf )
|
||||
{
|
||||
if( !node || node->contents == CONTENTS_SOLID )
|
||||
return false;
|
||||
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
if( !CHECKVISBIT( visbits, ((mleaf_t *)node)->cluster ))
|
||||
return false;
|
||||
|
||||
if( lastleaf )
|
||||
*lastleaf = ((mleaf_t *)node)->cluster;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( Mod_HeadnodeVisible( node->children[0], visbits, lastleaf ))
|
||||
return true;
|
||||
|
||||
if( Mod_HeadnodeVisible( node->children[1], visbits, lastleaf ))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_FindModelOrigin
|
||||
@@ -1260,35 +1264,22 @@ Mod_GetFaceContents
|
||||
determine face contents by name
|
||||
==================
|
||||
*/
|
||||
static mvertex_t *Mod_GetVertexByNumber( model_t *mod, int surfedge, const dbspmodel_t *bmod )
|
||||
static mvertex_t *Mod_GetVertexByNumber( model_t *mod, int surfedge )
|
||||
{
|
||||
int lindex = mod->surfedges[surfedge];
|
||||
int lindex;
|
||||
medge_t *edge;
|
||||
|
||||
if( bmod->version == QBSP2_VERSION )
|
||||
lindex = mod->surfedges[surfedge];
|
||||
|
||||
if( lindex > 0 )
|
||||
{
|
||||
if( lindex > 0 )
|
||||
{
|
||||
medge32_t *edge = &mod->edges32[lindex];
|
||||
return &mod->vertexes[edge->v[0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
medge32_t *edge = &mod->edges32[-lindex];
|
||||
return &mod->vertexes[edge->v[1]];
|
||||
}
|
||||
edge = &mod->edges[lindex];
|
||||
return &mod->vertexes[edge->v[0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
if( lindex > 0 )
|
||||
{
|
||||
medge16_t *edge = &mod->edges16[lindex];
|
||||
return &mod->vertexes[edge->v[0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
medge16_t *edge = &mod->edges16[-lindex];
|
||||
return &mod->vertexes[edge->v[1]];
|
||||
}
|
||||
edge = &mod->edges[-lindex];
|
||||
return &mod->vertexes[edge->v[1]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1373,7 +1364,7 @@ Mod_CalcSurfaceExtents
|
||||
Fills in surf->texturemins[] and surf->extents[]
|
||||
=================
|
||||
*/
|
||||
static void Mod_CalcSurfaceExtents( model_t *mod, msurface_t *surf, const dbspmodel_t *bmod )
|
||||
static void Mod_CalcSurfaceExtents( model_t *mod, msurface_t *surf )
|
||||
{
|
||||
// this place is VERY critical to precision
|
||||
// keep it as float, don't use double, because it causes issues with lightmap
|
||||
@@ -1400,16 +1391,8 @@ static void Mod_CalcSurfaceExtents( model_t *mod, msurface_t *surf, const dbspmo
|
||||
if( e >= mod->numedges || e <= -mod->numedges )
|
||||
Host_Error( "%s: bad edge\n", __func__ );
|
||||
|
||||
if( bmod->version == QBSP2_VERSION )
|
||||
{
|
||||
if( e >= 0 ) v = &mod->vertexes[mod->edges32[e].v[0]];
|
||||
else v = &mod->vertexes[mod->edges32[-e].v[1]];
|
||||
}
|
||||
else
|
||||
{
|
||||
if( e >= 0 ) v = &mod->vertexes[mod->edges16[e].v[0]];
|
||||
else v = &mod->vertexes[mod->edges16[-e].v[1]];
|
||||
}
|
||||
if( e >= 0 ) v = &mod->vertexes[mod->edges[e].v[0]];
|
||||
else v = &mod->vertexes[mod->edges[-e].v[1]];
|
||||
|
||||
for( j = 0; j < 2; j++ )
|
||||
{
|
||||
@@ -1463,7 +1446,7 @@ Mod_CalcSurfaceBounds
|
||||
fills in surf->mins and surf->maxs
|
||||
=================
|
||||
*/
|
||||
static void Mod_CalcSurfaceBounds( model_t *mod, msurface_t *surf, const dbspmodel_t *bmod )
|
||||
static void Mod_CalcSurfaceBounds( model_t *mod, msurface_t *surf )
|
||||
{
|
||||
int i, e;
|
||||
mvertex_t *v;
|
||||
@@ -1477,16 +1460,8 @@ static void Mod_CalcSurfaceBounds( model_t *mod, msurface_t *surf, const dbspmod
|
||||
if( e >= mod->numedges || e <= -mod->numedges )
|
||||
Host_Error( "%s: bad edge\n", __func__ );
|
||||
|
||||
if( bmod->version == QBSP2_VERSION )
|
||||
{
|
||||
if( e >= 0 ) v = &mod->vertexes[mod->edges32[e].v[0]];
|
||||
else v = &mod->vertexes[mod->edges32[-e].v[1]];
|
||||
}
|
||||
else
|
||||
{
|
||||
if( e >= 0 ) v = &mod->vertexes[mod->edges16[e].v[0]];
|
||||
else v = &mod->vertexes[mod->edges16[-e].v[1]];
|
||||
}
|
||||
if( e >= 0 ) v = &mod->vertexes[mod->edges[e].v[0]];
|
||||
else v = &mod->vertexes[mod->edges[-e].v[1]];
|
||||
AddPointToBounds( v->position, surf->info->mins, surf->info->maxs );
|
||||
}
|
||||
|
||||
@@ -1498,7 +1473,7 @@ static void Mod_CalcSurfaceBounds( model_t *mod, msurface_t *surf, const dbspmod
|
||||
Mod_CreateFaceBevels
|
||||
=================
|
||||
*/
|
||||
static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf, const dbspmodel_t *bmod )
|
||||
static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf )
|
||||
{
|
||||
vec3_t delta, edgevec;
|
||||
byte *facebevel;
|
||||
@@ -1531,8 +1506,8 @@ static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf, const dbspmode
|
||||
{
|
||||
mplane_t *dest = &fb->edges[i];
|
||||
|
||||
v0 = Mod_GetVertexByNumber( mod, surf->firstedge + i, bmod );
|
||||
v1 = Mod_GetVertexByNumber( mod, surf->firstedge + (i + 1) % surf->numedges, bmod );
|
||||
v0 = Mod_GetVertexByNumber( mod, surf->firstedge + i );
|
||||
v1 = Mod_GetVertexByNumber( mod, surf->firstedge + (i + 1) % surf->numedges );
|
||||
VectorSubtract( v1->position, v0->position, edgevec );
|
||||
CrossProduct( faceNormal, edgevec, dest->normal );
|
||||
VectorNormalize( dest->normal );
|
||||
@@ -1546,7 +1521,7 @@ static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf, const dbspmode
|
||||
// compute face radius
|
||||
for( i = 0; i < surf->numedges; i++ )
|
||||
{
|
||||
v0 = Mod_GetVertexByNumber( mod, surf->firstedge + i, bmod );
|
||||
v0 = Mod_GetVertexByNumber( mod, surf->firstedge + i );
|
||||
VectorSubtract( v0->position, fb->origin, delta );
|
||||
radius = DotProduct( delta, delta );
|
||||
fb->radius = Q_max( radius, fb->radius );
|
||||
@@ -1558,15 +1533,13 @@ static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf, const dbspmode
|
||||
Mod_SetParent
|
||||
=================
|
||||
*/
|
||||
static void Mod_SetParent( model_t *mod, mnode_t *node, mnode_t *parent )
|
||||
static void Mod_SetParent( mnode_t *node, mnode_t *parent )
|
||||
{
|
||||
node->parent = parent;
|
||||
|
||||
if( node->contents < 0 )
|
||||
return; // it's leaf
|
||||
|
||||
Mod_SetParent( mod, node_child( node, 0, mod ), node );
|
||||
Mod_SetParent( mod, node_child( node, 1, mod ), node );
|
||||
if( node->contents < 0 ) return; // it's leaf
|
||||
Mod_SetParent( node->children[0], node );
|
||||
Mod_SetParent( node->children[1], node );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1574,7 +1547,7 @@ static void Mod_SetParent( model_t *mod, mnode_t *node, mnode_t *parent )
|
||||
CountClipNodes_r
|
||||
==================
|
||||
*/
|
||||
static void CountClipNodes16_r( mclipnode16_t *src, hull_t *hull, int nodenum )
|
||||
static void CountClipNodes_r( mclipnode_t *src, hull_t *hull, int nodenum )
|
||||
{
|
||||
// leaf?
|
||||
if( nodenum < 0 ) return;
|
||||
@@ -1583,11 +1556,16 @@ static void CountClipNodes16_r( mclipnode16_t *src, hull_t *hull, int nodenum )
|
||||
Host_Error( "MAX_MAP_CLIPNODES limit exceeded\n" );
|
||||
hull->lastclipnode++;
|
||||
|
||||
CountClipNodes16_r( src, hull, src[nodenum].children[0] );
|
||||
CountClipNodes16_r( src, hull, src[nodenum].children[1] );
|
||||
CountClipNodes_r( src, hull, src[nodenum].children[0] );
|
||||
CountClipNodes_r( src, hull, src[nodenum].children[1] );
|
||||
}
|
||||
|
||||
static void CountClipNodes32_r( mclipnode32_t *src, hull_t *hull, int nodenum )
|
||||
/*
|
||||
==================
|
||||
CountClipNodes32_r
|
||||
==================
|
||||
*/
|
||||
static void CountClipNodes32_r( dclipnode32_t *src, hull_t *hull, int nodenum )
|
||||
{
|
||||
// leaf?
|
||||
if( nodenum < 0 ) return;
|
||||
@@ -1600,27 +1578,15 @@ static void CountClipNodes32_r( mclipnode32_t *src, hull_t *hull, int nodenum )
|
||||
CountClipNodes32_r( src, hull, src[nodenum].children[1] );
|
||||
}
|
||||
|
||||
static void CountDClipNodes_r( dclipnode32_t *src, hull_t *hull, int nodenum )
|
||||
{
|
||||
// leaf?
|
||||
if( nodenum < 0 ) return;
|
||||
|
||||
if( hull->lastclipnode == MAX_MAP_CLIPNODES )
|
||||
Host_Error( "MAX_MAP_CLIPNODES limit exceeded\n" );
|
||||
hull->lastclipnode++;
|
||||
|
||||
CountDClipNodes_r( src, hull, src[nodenum].children[0] );
|
||||
CountDClipNodes_r( src, hull, src[nodenum].children[1] );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
RemapClipNodes_r
|
||||
==================
|
||||
*/
|
||||
static int RemapClipNodes_r( dbspmodel_t *bmod, dclipnode32_t *srcnodes, hull_t *hull, int nodenum )
|
||||
static int RemapClipNodes_r( dclipnode32_t *srcnodes, hull_t *hull, int nodenum )
|
||||
{
|
||||
dclipnode32_t *src;
|
||||
dclipnode32_t *src;
|
||||
mclipnode_t *out;
|
||||
int i, c;
|
||||
|
||||
// leaf?
|
||||
@@ -1633,22 +1599,13 @@ static int RemapClipNodes_r( dbspmodel_t *bmod, dclipnode32_t *srcnodes, hull_t
|
||||
src = srcnodes + nodenum;
|
||||
|
||||
c = hull->lastclipnode;
|
||||
out = &hull->clipnodes[c];
|
||||
hull->lastclipnode++;
|
||||
|
||||
if( bmod->version == QBSP2_VERSION )
|
||||
{
|
||||
mclipnode32_t *out = &hull->clipnodes32[c];
|
||||
out->planenum = src->planenum;
|
||||
for( i = 0; i < 2; i++ )
|
||||
out->children[i] = RemapClipNodes_r( bmod, srcnodes, hull, src->children[i] );
|
||||
}
|
||||
else
|
||||
{
|
||||
mclipnode16_t *out = &hull->clipnodes16[c];
|
||||
out->planenum = src->planenum;
|
||||
for( i = 0; i < 2; i++ )
|
||||
out->children[i] = RemapClipNodes_r( bmod, srcnodes, hull, src->children[i] );
|
||||
}
|
||||
out->planenum = src->planenum;
|
||||
|
||||
for( i = 0; i < 2; i++ )
|
||||
out->children[i] = RemapClipNodes_r( srcnodes, hull, src->children[i] );
|
||||
|
||||
return c;
|
||||
}
|
||||
@@ -1660,64 +1617,34 @@ Mod_MakeHull0
|
||||
Duplicate the drawing hull structure as a clipping hull
|
||||
=================
|
||||
*/
|
||||
static void Mod_MakeHull0( model_t *mod, const dbspmodel_t *bmod )
|
||||
static void Mod_MakeHull0( model_t *mod )
|
||||
{
|
||||
hull_t *hull = &mod->hulls[0];
|
||||
int i;
|
||||
mnode_t *in, *child;
|
||||
mclipnode_t *out;
|
||||
hull_t *hull;
|
||||
int i, j;
|
||||
|
||||
hull = &mod->hulls[0];
|
||||
hull->clipnodes = out = Mem_Malloc( mod->mempool, mod->numnodes * sizeof( *out ));
|
||||
in = mod->nodes;
|
||||
|
||||
hull->firstclipnode = 0;
|
||||
hull->lastclipnode = mod->numnodes - 1;
|
||||
hull->planes = mod->planes;
|
||||
|
||||
if( bmod->version == QBSP2_VERSION )
|
||||
for( i = 0; i < mod->numnodes; i++, out++, in++ )
|
||||
{
|
||||
mclipnode32_t *out;
|
||||
mnode_t *in = mod->nodes;
|
||||
out->planenum = in->plane - mod->planes;
|
||||
|
||||
hull->clipnodes32 = out = Mem_Malloc( mod->mempool, mod->numnodes * sizeof( *hull->clipnodes32 ));
|
||||
|
||||
for( i = 0; i < mod->numnodes; i++, out++, in++ )
|
||||
for( j = 0; j < 2; j++ )
|
||||
{
|
||||
int j;
|
||||
child = in->children[j];
|
||||
|
||||
out->planenum = in->plane - mod->planes;
|
||||
|
||||
for( j = 0; j < 2; j++ )
|
||||
{
|
||||
mnode_t *child = node_child( in, j, mod );
|
||||
|
||||
if( child->contents < 0 )
|
||||
out->children[j] = child->contents;
|
||||
else
|
||||
out->children[j] = child - mod->nodes;
|
||||
}
|
||||
if( child->contents < 0 )
|
||||
out->children[j] = child->contents;
|
||||
else out->children[j] = child - mod->nodes;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mclipnode16_t *out;
|
||||
mnode_t *in = mod->nodes;
|
||||
|
||||
hull->clipnodes16 = out = Mem_Malloc( mod->mempool, mod->numnodes * sizeof( *hull->clipnodes16 ));
|
||||
|
||||
for( i = 0; i < mod->numnodes; i++, out++, in++ )
|
||||
{
|
||||
int j;
|
||||
|
||||
out->planenum = in->plane - mod->planes;
|
||||
|
||||
for( j = 0; j < 2; j++ )
|
||||
{
|
||||
mnode_t *child = node_child( in, j, mod );
|
||||
|
||||
if( child->contents < 0 )
|
||||
out->children[j] = child->contents;
|
||||
else
|
||||
out->children[j] = child - mod->nodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1761,18 +1688,15 @@ static void Mod_SetupHull( dbspmodel_t *bmod, model_t *mod, poolhandle_t mempool
|
||||
if( VectorIsNull( hull->clip_mins ) && VectorIsNull( hull->clip_maxs ))
|
||||
return; // no hull specified
|
||||
|
||||
CountDClipNodes_r( bmod->clipnodes_out, hull, headnode );
|
||||
CountClipNodes32_r( bmod->clipnodes_out, hull, headnode );
|
||||
|
||||
// fit array to real count
|
||||
if( bmod->version == QBSP2_VERSION )
|
||||
hull->clipnodes32 = Mem_Malloc( mempool, sizeof( *hull->clipnodes32 ) * hull->lastclipnode );
|
||||
else
|
||||
hull->clipnodes16 = Mem_Malloc( mempool, sizeof( *hull->clipnodes16 ) * hull->lastclipnode );
|
||||
|
||||
hull->clipnodes = (mclipnode_t *)Mem_Malloc( mempool, sizeof( mclipnode_t ) * hull->lastclipnode );
|
||||
hull->planes = mod->planes; // share planes
|
||||
hull->lastclipnode = 0; // restart counting
|
||||
|
||||
RemapClipNodes_r( bmod, bmod->clipnodes_out, hull, headnode ); // remap clipnodes to 16-bit indexes
|
||||
// remap clipnodes to 16-bit indexes
|
||||
RemapClipNodes_r( bmod->clipnodes_out, hull, headnode );
|
||||
}
|
||||
|
||||
static qboolean Mod_LoadLitfile( model_t *mod, const char *ext, size_t expected_size, color24 **out, size_t *outsize )
|
||||
@@ -1780,8 +1704,7 @@ static qboolean Mod_LoadLitfile( model_t *mod, const char *ext, size_t expected_
|
||||
char modelname[64], path[64];
|
||||
int iCompare;
|
||||
fs_offset_t datasize;
|
||||
file_t *f;
|
||||
uint hdr[2];
|
||||
byte *in;
|
||||
|
||||
COM_FileBase( mod->name, modelname, sizeof( modelname ));
|
||||
Q_snprintf( path, sizeof( path ), "maps/%s.%s", modelname, ext );
|
||||
@@ -1792,15 +1715,31 @@ static qboolean Mod_LoadLitfile( model_t *mod, const char *ext, size_t expected_
|
||||
if( iCompare < 0 ) // this may happens if level-designer used -onlyents key for hlcsg
|
||||
Con_Printf( S_WARN "%s probably is out of date\n", path );
|
||||
|
||||
f = FS_Open( path, "rb", false );
|
||||
in = FS_LoadFile( path, &datasize, false );
|
||||
|
||||
if( !f )
|
||||
if( !in )
|
||||
{
|
||||
Con_Printf( S_ERROR "couldn't load %s\n", path );
|
||||
return false;
|
||||
}
|
||||
|
||||
datasize = FS_FileLength( f );
|
||||
if( datasize <= 8 ) // header + version
|
||||
{
|
||||
Con_Printf( S_ERROR "%s is too short\n", path );
|
||||
goto cleanup_and_error;
|
||||
}
|
||||
|
||||
if( LittleLong( ((uint *)in)[0] ) != IDDELUXEMAPHEADER )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s is corrupted\n", path );
|
||||
goto cleanup_and_error;
|
||||
}
|
||||
|
||||
if( LittleLong( ((uint *)in)[1] ) != DELUXEMAP_VERSION )
|
||||
{
|
||||
Con_Printf( S_ERROR "has %s mismatched version (%u should be %u)\n", path, LittleLong( ((uint *)in)[1] ), DELUXEMAP_VERSION );
|
||||
goto cleanup_and_error;
|
||||
}
|
||||
|
||||
// skip header bytes
|
||||
datasize -= 8;
|
||||
@@ -1811,33 +1750,14 @@ static qboolean Mod_LoadLitfile( model_t *mod, const char *ext, size_t expected_
|
||||
goto cleanup_and_error;
|
||||
}
|
||||
|
||||
if( FS_Read( f, hdr, sizeof( hdr )) != sizeof( hdr ))
|
||||
{
|
||||
Con_Printf( S_ERROR "failed reading header from %s\n", path );
|
||||
goto cleanup_and_error;
|
||||
}
|
||||
|
||||
if( LittleLong( hdr[0] ) != IDDELUXEMAPHEADER )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s is corrupted\n", path );
|
||||
goto cleanup_and_error;
|
||||
}
|
||||
|
||||
if( LittleLong( hdr[1] ) != DELUXEMAP_VERSION )
|
||||
{
|
||||
Con_Printf( S_ERROR "has %s mismatched version (%u should be %u)\n", path, LittleLong( hdr[1] ), DELUXEMAP_VERSION );
|
||||
goto cleanup_and_error;
|
||||
}
|
||||
|
||||
*out = Mem_Malloc( mod->mempool, datasize );
|
||||
memcpy( *out, in + 8, datasize );
|
||||
*outsize = datasize;
|
||||
|
||||
FS_Read( f, *out, datasize );
|
||||
FS_Close( f );
|
||||
Mem_Free( in );
|
||||
return true;
|
||||
|
||||
cleanup_and_error:
|
||||
FS_Close( f );
|
||||
Mem_Free( in );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1852,7 +1772,6 @@ for embedded submodels
|
||||
static void Mod_SetupSubmodels( model_t *mod, dbspmodel_t *bmod )
|
||||
{
|
||||
qboolean colored = false;
|
||||
qboolean qbsp2 = false;
|
||||
poolhandle_t mempool;
|
||||
char *ents;
|
||||
dmodel_t *bm;
|
||||
@@ -1864,9 +1783,6 @@ static void Mod_SetupSubmodels( model_t *mod, dbspmodel_t *bmod )
|
||||
if( FBitSet( mod->flags, MODEL_COLORED_LIGHTING ))
|
||||
colored = true;
|
||||
|
||||
if( FBitSet( mod->flags, MODEL_QBSP2 ))
|
||||
qbsp2 = true;
|
||||
|
||||
mod->numframes = 2; // regular and alternate animation
|
||||
|
||||
// set up the submodels
|
||||
@@ -1879,10 +1795,7 @@ static void Mod_SetupSubmodels( model_t *mod, dbspmodel_t *bmod )
|
||||
mod->hulls[0].lastclipnode = bm->headnode[0]; // need to be real count
|
||||
|
||||
// counting a real number of clipnodes per each submodel
|
||||
if( bmod->version == QBSP2_VERSION )
|
||||
CountClipNodes32_r( mod->hulls[0].clipnodes32, &mod->hulls[0], bm->headnode[0] );
|
||||
else
|
||||
CountClipNodes16_r( mod->hulls[0].clipnodes16, &mod->hulls[0], bm->headnode[0] );
|
||||
CountClipNodes_r( mod->hulls[0].clipnodes, &mod->hulls[0], bm->headnode[0] );
|
||||
|
||||
// but hulls1-3 is build individually for a each given submodel
|
||||
for( j = 1; j < MAX_MAP_HULLS; j++ )
|
||||
@@ -1900,7 +1813,6 @@ static void Mod_SetupSubmodels( model_t *mod, dbspmodel_t *bmod )
|
||||
|
||||
// this bit will be shared between all the submodels include worldmodel
|
||||
if( colored ) SetBits( mod->flags, MODEL_COLORED_LIGHTING );
|
||||
if( qbsp2 ) SetBits( mod->flags, MODEL_QBSP2 );
|
||||
|
||||
if( i != 0 )
|
||||
{
|
||||
@@ -2223,15 +2135,15 @@ Mod_LoadEdges
|
||||
*/
|
||||
static void Mod_LoadEdges( model_t *mod, dbspmodel_t *bmod )
|
||||
{
|
||||
medge_t *out;
|
||||
int i;
|
||||
|
||||
mod->edges = out = Mem_Malloc( mod->mempool, bmod->numedges * sizeof( medge_t ));
|
||||
mod->numedges = bmod->numedges;
|
||||
|
||||
if( bmod->version == QBSP2_VERSION )
|
||||
{
|
||||
dedge32_t *in = bmod->edges32;
|
||||
medge32_t *out;
|
||||
mod->edges32 = out = Mem_Malloc( mod->mempool, bmod->numedges * sizeof( *out ));
|
||||
dedge32_t *in = (dedge32_t *)bmod->edges32;
|
||||
|
||||
for( i = 0; i < bmod->numedges; i++, in++, out++ )
|
||||
{
|
||||
@@ -2241,9 +2153,7 @@ static void Mod_LoadEdges( model_t *mod, dbspmodel_t *bmod )
|
||||
}
|
||||
else
|
||||
{
|
||||
dedge_t *in = bmod->edges;
|
||||
medge16_t *out;
|
||||
mod->edges16 = out = Mem_Malloc( mod->mempool, bmod->numedges * sizeof( *out ));
|
||||
dedge_t *in = (dedge_t *)bmod->edges;
|
||||
|
||||
for( i = 0; i < bmod->numedges; i++, in++, out++ )
|
||||
{
|
||||
@@ -3003,9 +2913,9 @@ static void Mod_LoadSurfaces( model_t *mod, dbspmodel_t *bmod )
|
||||
if( FBitSet( out->texinfo->flags, TEX_SPECIAL ))
|
||||
SetBits( out->flags, SURF_DRAWTILED );
|
||||
|
||||
Mod_CalcSurfaceBounds( mod, out, bmod );
|
||||
Mod_CalcSurfaceExtents( mod, out, bmod );
|
||||
Mod_CreateFaceBevels( mod, out, bmod );
|
||||
Mod_CalcSurfaceBounds( mod, out );
|
||||
Mod_CalcSurfaceExtents( mod, out );
|
||||
Mod_CreateFaceBevels( mod, out );
|
||||
|
||||
// grab the second sample to detect colored lighting
|
||||
if( test_lightsize > 0 && lightofs != -1 )
|
||||
@@ -3052,6 +2962,7 @@ static void Mod_LoadSurfaces( model_t *mod, dbspmodel_t *bmod )
|
||||
if( samples == 1 || samples == 3 )
|
||||
{
|
||||
bmod->lightmap_samples = (int)samples;
|
||||
Con_Reportf( "lighting: %s\n", (bmod->lightmap_samples == 1) ? "monochrome" : "colored" );
|
||||
bmod->lightmap_samples = Q_max( bmod->lightmap_samples, 1 ); // avoid division by zero
|
||||
}
|
||||
else Con_DPrintf( S_WARN "lighting invalid samplecount: %g, defaulting to %i\n", samples, bmod->lightmap_samples );
|
||||
@@ -3083,62 +2994,16 @@ static void Mod_LoadNodes( model_t *mod, dbspmodel_t *bmod )
|
||||
out->minmaxs[j+3] = in->maxs[j];
|
||||
}
|
||||
|
||||
#if !XASH_64BIT
|
||||
if( in->firstface >= BIT( 24 ))
|
||||
{
|
||||
Host_Error( "%s: face index limit exceeded on node %i\n", __func__, i );
|
||||
return;
|
||||
}
|
||||
|
||||
if( in->numfaces >= BIT( 24 ))
|
||||
{
|
||||
Host_Error( "%s: face count limit exceeded on node %i\n", __func__, i );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
p = in->planenum;
|
||||
out->plane = mod->planes + p;
|
||||
out->firstsurface_0 = in->firstface & 0xFFFF;
|
||||
out->numsurfaces_0 = in->numfaces & 0xFFFF;
|
||||
|
||||
out->firstsurface_1 = in->firstface >> 16;
|
||||
out->numsurfaces_1 = in->numfaces >> 16;
|
||||
out->firstsurface = in->firstface;
|
||||
out->numsurfaces = in->numfaces;
|
||||
|
||||
for( j = 0; j < 2; j++ )
|
||||
{
|
||||
p = in->children[j];
|
||||
#if XASH_64BIT
|
||||
if( p >= 0 ) out->children_[j] = mod->nodes + p;
|
||||
else out->children_[j] = (mnode_t *)(mod->leafs + ( -1 - p ));
|
||||
#else
|
||||
if( j == 0 )
|
||||
{
|
||||
if( p >= 0 )
|
||||
{
|
||||
out->child_0_leaf = 0;
|
||||
out->child_0_off = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->child_0_leaf = 1;
|
||||
out->child_0_off = -1 - p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( p >= 0 )
|
||||
{
|
||||
out->child_1_leaf = 0;
|
||||
out->child_1_off = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->child_1_leaf = 1;
|
||||
out->child_1_off = -1 - p;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if( p >= 0 ) out->children[j] = mod->nodes + p;
|
||||
else out->children[j] = (mnode_t *)(mod->leafs + ( -1 - p ));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3153,20 +3018,20 @@ static void Mod_LoadNodes( model_t *mod, dbspmodel_t *bmod )
|
||||
|
||||
p = in->planenum;
|
||||
out->plane = mod->planes + p;
|
||||
out->firstsurface_0 = in->firstface;
|
||||
out->numsurfaces_0 = in->numfaces;
|
||||
out->firstsurface = in->firstface;
|
||||
out->numsurfaces = in->numfaces;
|
||||
|
||||
for( j = 0; j < 2; j++ )
|
||||
{
|
||||
p = in->children[j];
|
||||
if( p >= 0 ) out->children_[j] = mod->nodes + p;
|
||||
else out->children_[j] = (mnode_t *)(mod->leafs + ( -1 - p ));
|
||||
if( p >= 0 ) out->children[j] = mod->nodes + p;
|
||||
else out->children[j] = (mnode_t *)(mod->leafs + ( -1 - p ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sets nodes and leafs
|
||||
Mod_SetParent( mod, mod->nodes, NULL );
|
||||
Mod_SetParent( mod->nodes, NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3548,8 +3413,6 @@ static void Mod_LoadLighting( model_t *mod, dbspmodel_t *bmod )
|
||||
break;
|
||||
}
|
||||
|
||||
Con_Reportf( "lighting: %s\n", FBitSet( mod->flags, MODEL_COLORED_LIGHTING ) ? "colored" : "monochrome" );
|
||||
|
||||
// not supposed to be load ?
|
||||
if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ))
|
||||
{
|
||||
@@ -3628,6 +3491,13 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
|
||||
Q_strncpy( loadstat.name, mod->name, sizeof( loadstat.name ));
|
||||
wadvalue[0] = '\0';
|
||||
|
||||
#ifndef SUPPORT_BSP2_FORMAT
|
||||
if( header->version == QBSP2_VERSION )
|
||||
{
|
||||
Con_Printf( S_ERROR DEFAULT_BSP_BUILD_ERROR, mod->name );
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
switch( header->version )
|
||||
{
|
||||
case HLBSP_VERSION:
|
||||
@@ -3650,9 +3520,6 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
|
||||
// everything else
|
||||
srclumps[0].lumpnumber = LUMP_ENTITIES;
|
||||
srclumps[1].lumpnumber = LUMP_PLANES;
|
||||
|
||||
if( header->version == QBSP2_VERSION )
|
||||
SetBits( mod->flags, MODEL_QBSP2 );
|
||||
break;
|
||||
default:
|
||||
Con_Printf( S_ERROR "%s has wrong version number (%i should be %i)\n", mod->name, header->version, HLBSP_VERSION );
|
||||
@@ -3703,7 +3570,7 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
|
||||
Mod_LoadClipnodes( mod, bmod );
|
||||
|
||||
// preform some post-initalization
|
||||
Mod_MakeHull0( mod, bmod );
|
||||
Mod_MakeHull0( mod );
|
||||
Mod_SetupSubmodels( mod, bmod );
|
||||
|
||||
if( isworld )
|
||||
@@ -3793,6 +3660,15 @@ qboolean Mod_TestBmodelLumps( file_t *f, const char *name, const byte *mod_base,
|
||||
if( silent )
|
||||
SetBits( flags, LUMP_SILENT );
|
||||
|
||||
#ifndef SUPPORT_BSP2_FORMAT
|
||||
if( header->version == QBSP2_VERSION )
|
||||
{
|
||||
if( !FBitSet( flags, LUMP_SILENT ))
|
||||
Con_Printf( S_ERROR DEFAULT_BSP_BUILD_ERROR, name );
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch( header->version )
|
||||
{
|
||||
case HLBSP_VERSION:
|
||||
|
||||
@@ -135,8 +135,6 @@ extern poolhandle_t com_studiocache;
|
||||
extern convar_t mod_studiocache;
|
||||
extern convar_t r_wadtextures;
|
||||
extern convar_t r_showhull;
|
||||
extern const mclipnode16_t box_clipnodes16[6];
|
||||
extern const mclipnode32_t box_clipnodes32[6];
|
||||
|
||||
//
|
||||
// model.c
|
||||
@@ -169,12 +167,13 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded );
|
||||
//
|
||||
void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded );
|
||||
qboolean Mod_TestBmodelLumps( file_t *f, const char *name, const byte *mod_base, qboolean silent, dlump_t *entities );
|
||||
qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, int *lastleaf );
|
||||
int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, qboolean merge, qboolean fullvis, qboolean false );
|
||||
qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
||||
int Mod_CheckLump( const char *filename, const int lump, int *lumpsize );
|
||||
int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize );
|
||||
int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize );
|
||||
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node, model_t *mod );
|
||||
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node );
|
||||
int Mod_SampleSizeForFace( const msurface_t *surf );
|
||||
byte *Mod_GetPVSForPoint( const vec3_t p );
|
||||
void Mod_UnloadBrushModel( model_t *mod );
|
||||
|
||||
@@ -50,8 +50,9 @@ static matrix3x4 studio_bones[MAXSTUDIOBONES];
|
||||
static uint studio_hull_hitgroup[MAXSTUDIOBONES];
|
||||
static uint cache_hull_hitgroup[MAXSTUDIOBONES];
|
||||
static mstudiocache_t cache_studio[STUDIO_CACHESIZE];
|
||||
static mplane_t studio_planes[MAXSTUDIOBONES * 6];
|
||||
static mplane_t cache_planes[MAXSTUDIOBONES * 6];
|
||||
static mclipnode_t studio_clipnodes[6];
|
||||
static mplane_t studio_planes[768];
|
||||
static mplane_t cache_planes[768];
|
||||
|
||||
// current cache state
|
||||
static int cache_current;
|
||||
@@ -65,14 +66,25 @@ Mod_InitStudioHull
|
||||
*/
|
||||
void Mod_InitStudioHull( void )
|
||||
{
|
||||
int i;
|
||||
int i, side;
|
||||
|
||||
if( studio_hull[0].planes != NULL )
|
||||
return; // already initailized
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
studio_clipnodes[i].planenum = i;
|
||||
|
||||
side = i & 1;
|
||||
|
||||
studio_clipnodes[i].children[side] = CONTENTS_EMPTY;
|
||||
if( i != 5 ) studio_clipnodes[i].children[side^1] = i + 1;
|
||||
else studio_clipnodes[i].children[side^1] = CONTENTS_SOLID;
|
||||
}
|
||||
|
||||
for( i = 0; i < MAXSTUDIOBONES; i++ )
|
||||
{
|
||||
studio_hull[i].clipnodes16 = (mclipnode16_t *)box_clipnodes16;
|
||||
studio_hull[i].clipnodes = studio_clipnodes;
|
||||
studio_hull[i].planes = &studio_planes[i*6];
|
||||
studio_hull[i].firstclipnode = 0;
|
||||
studio_hull[i].lastclipnode = 5;
|
||||
@@ -258,11 +270,6 @@ hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t ang
|
||||
|
||||
for( i = j = 0; i < mod_studiohdr->numhitboxes; i++, j += 6 )
|
||||
{
|
||||
if( world.version == QBSP2_VERSION )
|
||||
studio_hull[i].clipnodes32 = (mclipnode32_t *)box_clipnodes32;
|
||||
else
|
||||
studio_hull[i].clipnodes16 = (mclipnode16_t *)box_clipnodes16;
|
||||
|
||||
if( bSkipShield && i == 21 )
|
||||
continue; // CS stuff
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ static int HTTP_FileConnect( httpfile_t *file )
|
||||
if( !COM_CheckStringEmpty( http_useragent.string ) || !Q_strcmp( http_useragent.string, "xash3d" ))
|
||||
{
|
||||
Q_snprintf( useragent, sizeof( useragent ), "%s/%s (%s-%s; build %d; %s)",
|
||||
XASH_ENGINE_NAME, XASH_VERSION, Q_buildos( ), Q_buildarch( ), Q_buildnum( ), g_buildcommit );
|
||||
XASH_ENGINE_NAME, XASH_VERSION, Q_buildos( ), Q_buildarch( ), Q_buildnum( ), Q_buildcommit( ));
|
||||
}
|
||||
else Q_strncpy( useragent, http_useragent.string, sizeof( useragent ));
|
||||
|
||||
|
||||
@@ -112,9 +112,6 @@ msurface_t *PM_RecursiveSurfCheck( model_t *mod, mnode_t *node, vec3_t p1, vec3_
|
||||
int i, side;
|
||||
msurface_t *surf;
|
||||
vec3_t mid;
|
||||
mnode_t *children[2];
|
||||
int numsurfaces, firstsurface;
|
||||
|
||||
loc0:
|
||||
if( node->contents < 0 )
|
||||
return NULL;
|
||||
@@ -122,17 +119,15 @@ loc0:
|
||||
t1 = PlaneDiff( p1, node->plane );
|
||||
t2 = PlaneDiff( p2, node->plane );
|
||||
|
||||
node_children( children, node, mod );
|
||||
|
||||
if( t1 >= -FRAC_EPSILON && t2 >= -FRAC_EPSILON )
|
||||
{
|
||||
node = children[0];
|
||||
node = node->children[0];
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
if( t1 < FRAC_EPSILON && t2 < FRAC_EPSILON )
|
||||
{
|
||||
node = children[1];
|
||||
node = node->children[1];
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
@@ -142,15 +137,13 @@ loc0:
|
||||
|
||||
VectorLerp( p1, frac, p2, mid );
|
||||
|
||||
if(( surf = PM_RecursiveSurfCheck( mod, children[side], p1, mid )) != NULL )
|
||||
if(( surf = PM_RecursiveSurfCheck( mod, node->children[side], p1, mid )) != NULL )
|
||||
return surf;
|
||||
|
||||
// walk through real faces
|
||||
numsurfaces = node_numsurfaces( node, mod );
|
||||
firstsurface = node_firstsurface( node, mod );
|
||||
for( i = 0; i < numsurfaces; i++ )
|
||||
for( i = 0; i < node->numsurfaces; i++ )
|
||||
{
|
||||
msurface_t *surf = &mod->surfaces[firstsurface + i];
|
||||
msurface_t *surf = &mod->surfaces[node->firstsurface + i];
|
||||
mextrasurf_t *info = surf->info;
|
||||
mfacebevel_t *fb = info->bevel;
|
||||
int j, contents;
|
||||
@@ -179,7 +172,7 @@ loc0:
|
||||
return NULL; // through the fence
|
||||
}
|
||||
|
||||
return PM_RecursiveSurfCheck( mod, children[side^1], mid, p2 );
|
||||
return PM_RecursiveSurfCheck( mod, node->children[side^1], mid, p2 );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -234,9 +227,6 @@ static int PM_TestLine_r( model_t *mod, mnode_t *node, vec_t p1f, vec_t p2f, con
|
||||
float frac, midf;
|
||||
int i, r, side;
|
||||
vec3_t mid;
|
||||
mnode_t *children[2];
|
||||
int numsurfaces, firstsurface;
|
||||
|
||||
loc0:
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
@@ -252,17 +242,15 @@ loc0:
|
||||
front = PlaneDiff( start, node->plane );
|
||||
back = PlaneDiff( stop, node->plane );
|
||||
|
||||
node_children( children, node, mod );
|
||||
|
||||
if( front >= -FRAC_EPSILON && back >= -FRAC_EPSILON )
|
||||
{
|
||||
node = children[0];
|
||||
node = node->children[0];
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
if( front < FRAC_EPSILON && back < FRAC_EPSILON )
|
||||
{
|
||||
node = children[1];
|
||||
node = node->children[1];
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
@@ -273,7 +261,7 @@ loc0:
|
||||
VectorLerp( start, frac, stop, mid );
|
||||
midf = p1f + ( p2f - p1f ) * frac;
|
||||
|
||||
r = PM_TestLine_r( mod, children[side], p1f, midf, start, mid, trace );
|
||||
r = PM_TestLine_r( mod, node->children[side], p1f, midf, start, mid, trace );
|
||||
|
||||
if( r != CONTENTS_EMPTY )
|
||||
{
|
||||
@@ -284,11 +272,9 @@ loc0:
|
||||
}
|
||||
|
||||
// walk through real faces
|
||||
numsurfaces = node_numsurfaces( node, mod );
|
||||
firstsurface = node_firstsurface( node, mod );
|
||||
for( i = 0; i < numsurfaces; i++ )
|
||||
for( i = 0; i < node->numsurfaces; i++ )
|
||||
{
|
||||
msurface_t *surf = &mod->surfaces[firstsurface + i];
|
||||
msurface_t *surf = &mod->surfaces[node->firstsurface + i];
|
||||
mextrasurf_t *info = surf->info;
|
||||
mfacebevel_t *fb = info->bevel;
|
||||
int j, contents;
|
||||
@@ -322,7 +308,7 @@ loc0:
|
||||
return contents;
|
||||
}
|
||||
|
||||
return PM_TestLine_r( mod, children[!side], midf, p2f, mid, stop, trace );
|
||||
return PM_TestLine_r( mod, node->children[!side], midf, p2f, mid, stop, trace );
|
||||
}
|
||||
|
||||
int PM_TestLineExt( playermove_t *pmove, physent_t *ents, int numents, const vec3_t start, const vec3_t end, int flags )
|
||||
|
||||
@@ -25,7 +25,8 @@ GNU General Public License for more details.
|
||||
#define PM_AllowHitBoxTrace( model, hull ) ( model && model->type == mod_studio && ( FBitSet( model->flags, STUDIO_TRACE_HITBOX ) || hull == 2 ))
|
||||
|
||||
static mplane_t pm_boxplanes[6];
|
||||
static hull_t pm_boxhull;
|
||||
static mclipnode_t pm_boxclipnodes[6];
|
||||
static hull_t pm_boxhull;
|
||||
|
||||
// default hullmins
|
||||
static const vec3_t pm_hullmins[MAX_MAP_HULLS] =
|
||||
@@ -64,15 +65,23 @@ can just be stored out and get a proper hull_t structure.
|
||||
*/
|
||||
void PM_InitBoxHull( void )
|
||||
{
|
||||
int i;
|
||||
int i, side;
|
||||
|
||||
pm_boxhull.clipnodes16 = (mclipnode16_t *)box_clipnodes16;
|
||||
pm_boxhull.clipnodes = pm_boxclipnodes;
|
||||
pm_boxhull.planes = pm_boxplanes;
|
||||
pm_boxhull.firstclipnode = 0;
|
||||
pm_boxhull.lastclipnode = 5;
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
pm_boxclipnodes[i].planenum = i;
|
||||
|
||||
side = i & 1;
|
||||
|
||||
pm_boxclipnodes[i].children[side] = CONTENTS_EMPTY;
|
||||
if( i != 5 ) pm_boxclipnodes[i].children[side^1] = i + 1;
|
||||
else pm_boxclipnodes[i].children[side^1] = CONTENTS_SOLID;
|
||||
|
||||
pm_boxplanes[i].type = i>>1;
|
||||
pm_boxplanes[i].normal[i>>1] = 1.0f;
|
||||
pm_boxplanes[i].signbits = 0;
|
||||
@@ -97,11 +106,6 @@ static hull_t *PM_HullForBox( const vec3_t mins, const vec3_t maxs )
|
||||
pm_boxplanes[4].dist = maxs[2];
|
||||
pm_boxplanes[5].dist = mins[2];
|
||||
|
||||
if( world.version == QBSP2_VERSION )
|
||||
pm_boxhull.clipnodes32 = (mclipnode32_t *)box_clipnodes32;
|
||||
else
|
||||
pm_boxhull.clipnodes16 = (mclipnode16_t *)box_clipnodes16;
|
||||
|
||||
return &pm_boxhull;
|
||||
}
|
||||
|
||||
@@ -118,21 +122,10 @@ int GAME_EXPORT PM_HullPointContents( hull_t *hull, int num, const vec3_t p )
|
||||
if( !hull || !hull->planes ) // fantom bmodels?
|
||||
return CONTENTS_NONE;
|
||||
|
||||
if( world.version == QBSP2_VERSION )
|
||||
while( num >= 0 )
|
||||
{
|
||||
while( num >= 0 )
|
||||
{
|
||||
plane = &hull->planes[hull->clipnodes32[num].planenum];
|
||||
num = hull->clipnodes32[num].children[PlaneDiff( p, plane ) < 0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( num >= 0 )
|
||||
{
|
||||
plane = &hull->planes[hull->clipnodes16[num].planenum];
|
||||
num = hull->clipnodes16[num].children[PlaneDiff( p, plane ) < 0];
|
||||
}
|
||||
plane = &hull->planes[hull->clipnodes[num].planenum];
|
||||
num = hull->clipnodes[num].children[PlaneDiff( p, plane ) < 0];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
@@ -200,7 +193,7 @@ PM_RecursiveHullCheck
|
||||
*/
|
||||
qboolean PM_RecursiveHullCheck( hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, pmtrace_t *trace )
|
||||
{
|
||||
int children[2];
|
||||
mclipnode_t *node;
|
||||
mplane_t *plane;
|
||||
float t1, t2;
|
||||
float frac, midf;
|
||||
@@ -233,31 +226,21 @@ loc0:
|
||||
Host_Error( "%s: bad node number %i\n", __func__, num );
|
||||
|
||||
// find the point distances
|
||||
if( world.version == QBSP2_VERSION )
|
||||
{
|
||||
children[0] = hull->clipnodes32[num].children[0];
|
||||
children[1] = hull->clipnodes32[num].children[1];
|
||||
plane = hull->planes + hull->clipnodes32[num].planenum;
|
||||
}
|
||||
else
|
||||
{
|
||||
children[0] = hull->clipnodes16[num].children[0];
|
||||
children[1] = hull->clipnodes16[num].children[1];
|
||||
plane = hull->planes + hull->clipnodes16[num].planenum;
|
||||
}
|
||||
node = hull->clipnodes + num;
|
||||
plane = hull->planes + node->planenum;
|
||||
|
||||
t1 = PlaneDiff( p1, plane );
|
||||
t2 = PlaneDiff( p2, plane );
|
||||
|
||||
if( t1 >= 0.0f && t2 >= 0.0f )
|
||||
{
|
||||
num = children[0];
|
||||
num = node->children[0];
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
if( t1 < 0.0f && t2 < 0.0f )
|
||||
{
|
||||
num = children[1];
|
||||
num = node->children[1];
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
@@ -274,14 +257,14 @@ loc0:
|
||||
VectorLerp( p1, frac, p2, mid );
|
||||
|
||||
// move up to the node
|
||||
if( !PM_RecursiveHullCheck( hull, children[side], p1f, midf, p1, mid, trace ))
|
||||
if( !PM_RecursiveHullCheck( hull, node->children[side], p1f, midf, p1, mid, trace ))
|
||||
return false;
|
||||
|
||||
// this recursion can not be optimized because mid would need to be duplicated on a stack
|
||||
if( PM_HullPointContents( hull, children[side^1], mid ) != CONTENTS_SOLID )
|
||||
if( PM_HullPointContents( hull, node->children[side^1], mid ) != CONTENTS_SOLID )
|
||||
{
|
||||
// go past the node
|
||||
return PM_RecursiveHullCheck( hull, children[side^1], midf, p2f, mid, p2, trace );
|
||||
return PM_RecursiveHullCheck( hull, node->children[side^1], midf, p2f, mid, p2, trace );
|
||||
}
|
||||
|
||||
// never got out of the solid area
|
||||
|
||||
@@ -109,44 +109,44 @@ void Sys_InitLog( void )
|
||||
|
||||
// fit to 80 columns for easier read on standard terminal
|
||||
fputs( "================================================================================\n", s_ld.logfile );
|
||||
fprintf( s_ld.logfile, "%s (%i, %s, %s, %s-%s)\n", s_ld.title, Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
|
||||
fprintf( s_ld.logfile, "%s (%i, %s, %s, %s-%s)\n", s_ld.title, Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
|
||||
fprintf( s_ld.logfile, "Game started at %s\n", Q_timestamp( TIME_FULL ));
|
||||
fputs( "================================================================================\n", s_ld.logfile );
|
||||
fflush( s_ld.logfile );
|
||||
}
|
||||
}
|
||||
|
||||
void Sys_CloseLog( const char *finalmsg )
|
||||
void Sys_CloseLog( void )
|
||||
{
|
||||
Sys_FlushStdout(); // flush to stdout to ensure all data was written
|
||||
|
||||
if( !s_ld.logfile )
|
||||
return;
|
||||
char event_name[64];
|
||||
|
||||
// continue logged
|
||||
if( !finalmsg )
|
||||
switch( host.status )
|
||||
{
|
||||
switch( host.status )
|
||||
{
|
||||
case HOST_CRASHED:
|
||||
finalmsg = "crashed";
|
||||
break;
|
||||
case HOST_ERR_FATAL:
|
||||
finalmsg = "stopped with error";
|
||||
break;
|
||||
default:
|
||||
finalmsg = "stopped";
|
||||
break;
|
||||
}
|
||||
case HOST_CRASHED:
|
||||
Q_strncpy( event_name, "crashed", sizeof( event_name ));
|
||||
break;
|
||||
case HOST_ERR_FATAL:
|
||||
Q_strncpy( event_name, "stopped with error", sizeof( event_name ));
|
||||
break;
|
||||
default:
|
||||
if( !host.change_game ) Q_strncpy( event_name, "stopped", sizeof( event_name ));
|
||||
else Q_strncpy( event_name, host.finalmsg, sizeof( event_name ));
|
||||
break;
|
||||
}
|
||||
|
||||
fputc( '\n', s_ld.logfile );
|
||||
fputs( "================================================================================\n", s_ld.logfile );
|
||||
fprintf( s_ld.logfile, "%s (%i, %s, %s, %s-%s)\n", s_ld.title, Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
|
||||
fprintf( s_ld.logfile, "Stopped with reason \"%s\" at %s\n", finalmsg, Q_timestamp( TIME_FULL ));
|
||||
fputs( "================================================================================\n", s_ld.logfile );
|
||||
fclose( s_ld.logfile );
|
||||
s_ld.logfile = NULL;
|
||||
Sys_FlushStdout(); // flush to stdout to ensure all data was written
|
||||
|
||||
if( s_ld.logfile )
|
||||
{
|
||||
fputc( '\n', s_ld.logfile );
|
||||
fputs( "================================================================================\n", s_ld.logfile );
|
||||
fprintf( s_ld.logfile, "%s (%i, %s, %s, %s-%s)\n", s_ld.title, Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
|
||||
fprintf( s_ld.logfile, "Stopped with reason \"%s\" at %s\n", event_name, Q_timestamp( TIME_FULL ));
|
||||
fputs( "================================================================================\n", s_ld.logfile );
|
||||
fclose( s_ld.logfile );
|
||||
s_ld.logfile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#if XASH_COLORIZE_CONSOLE
|
||||
|
||||
@@ -420,12 +420,6 @@ void Sys_Error( const char *error, ... )
|
||||
_exit->_Exit->asm._exit->_exit
|
||||
As we do not need atexit(), just throw hidden exception
|
||||
*/
|
||||
|
||||
// Hey, you, making an Emscripten port!
|
||||
// What if we're not supposed to use exit() on Emscripten and instead we should
|
||||
// exit from the main() function? Would this fix this bug? Test this case, pls.
|
||||
#error "Read the comment above"
|
||||
|
||||
#include <emscripten.h>
|
||||
#define exit my_exit
|
||||
void my_exit(int ret)
|
||||
@@ -444,11 +438,7 @@ Sys_Quit
|
||||
void Sys_Quit( const char *reason )
|
||||
{
|
||||
Host_ShutdownWithReason( reason );
|
||||
#if XASH_ANDROID
|
||||
Host_ExitInMain();
|
||||
#else
|
||||
exit( error_on_exit );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -539,7 +529,7 @@ but since engine will be unloaded during this call
|
||||
it explicitly doesn't use internal allocation or string copy utils
|
||||
==================
|
||||
*/
|
||||
qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
|
||||
qboolean Sys_NewInstance( const char *gamedir )
|
||||
{
|
||||
#if XASH_NSWITCH
|
||||
char newargs[4096];
|
||||
@@ -550,7 +540,7 @@ qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
|
||||
// just restart the entire thing
|
||||
printf( "envSetNextLoad exe: `%s`\n", exe );
|
||||
printf( "envSetNextLoad argv:\n`%s`\n", newargs );
|
||||
Host_ShutdownWithReason( finalmsg );
|
||||
Host_ShutdownWithReason( "changing game" );
|
||||
envSetNextLoad( exe, newargs );
|
||||
exit( 0 );
|
||||
#else
|
||||
@@ -588,7 +578,7 @@ qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
|
||||
#if XASH_PSVITA
|
||||
// under normal circumstances it's always going to be the same path
|
||||
exe = strdup( "app0:/eboot.bin" );
|
||||
Host_ShutdownWithReason( finalmsg );
|
||||
Host_ShutdownWithReason( "changing game" );
|
||||
sceAppMgrLoadExec( exe, newargs, NULL );
|
||||
#else
|
||||
exelen = wai_getExecutablePath( NULL, 0, NULL );
|
||||
@@ -596,7 +586,7 @@ qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
|
||||
wai_getExecutablePath( exe, exelen, NULL );
|
||||
exe[exelen] = 0;
|
||||
|
||||
Host_ShutdownWithReason( finalmsg );
|
||||
Host_ShutdownWithReason( "changing game" );
|
||||
|
||||
execv( exe, newargs );
|
||||
#endif
|
||||
|
||||
@@ -56,8 +56,11 @@ void Sys_DebugBreak( void );
|
||||
qboolean _Sys_GetParmFromCmdLine( const char *parm, char *out, size_t size );
|
||||
qboolean Sys_GetIntFromCmdLine( const char *parm, int *out );
|
||||
void Sys_Print( const char *pMsg );
|
||||
void Sys_PrintLog( const char *pMsg );
|
||||
void Sys_InitLog( void );
|
||||
void Sys_CloseLog( void );
|
||||
void Sys_Quit( const char *reason ) NORETURN;
|
||||
qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg );
|
||||
qboolean Sys_NewInstance( const char *gamedir );
|
||||
void *Sys_GetNativeObject( const char *obj );
|
||||
|
||||
//
|
||||
@@ -65,7 +68,7 @@ void *Sys_GetNativeObject( const char *obj );
|
||||
//
|
||||
char *Sys_Input( void );
|
||||
void Sys_DestroyConsole( void );
|
||||
void Sys_CloseLog( const char *finalmsg );
|
||||
void Sys_CloseLog( void );
|
||||
void Sys_InitLog( void );
|
||||
void Sys_PrintLog( const char *pMsg );
|
||||
int Sys_LogFileNo( void );
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
#ifndef EDICT_H
|
||||
#define EDICT_H
|
||||
|
||||
#define MAX_ENT_LEAFS_32 24 // Orignally was 16
|
||||
#define MAX_ENT_LEAFS_16 48
|
||||
#ifdef SUPPORT_BSP2_FORMAT
|
||||
#define MAX_ENT_LEAFS 24 // Orignally was 16
|
||||
#else
|
||||
#define MAX_ENT_LEAFS 48
|
||||
#endif
|
||||
|
||||
#include "progdefs.h"
|
||||
|
||||
@@ -30,12 +33,11 @@ struct edict_s
|
||||
int headnode; // -1 to use normal leaf check
|
||||
|
||||
int num_leafs;
|
||||
union
|
||||
{
|
||||
int leafnums32[MAX_ENT_LEAFS_32];
|
||||
short leafnums16[MAX_ENT_LEAFS_16];
|
||||
};
|
||||
|
||||
#ifdef SUPPORT_BSP2_FORMAT
|
||||
int leafnums[MAX_ENT_LEAFS];
|
||||
#else
|
||||
short leafnums[MAX_ENT_LEAFS];
|
||||
#endif
|
||||
float freetime; // sv.time when the object was freed
|
||||
|
||||
void* pvPrivateData; // Alloced and freed by engine, used by DLLs
|
||||
|
||||
@@ -113,7 +113,7 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
|
||||
|
||||
// safe actions first, stack and memory may be corrupted
|
||||
len = Q_snprintf( message, sizeof( message ), "Ver: " XASH_ENGINE_NAME " " XASH_VERSION " (build %i-%s, %s-%s)\n",
|
||||
Q_buildnum(), g_buildcommit, Q_buildos(), Q_buildarch() );
|
||||
Q_buildnum(), Q_buildcommit(), Q_buildos(), Q_buildarch() );
|
||||
|
||||
#if !XASH_FREEBSD && !XASH_NETBSD && !XASH_OPENBSD
|
||||
len += Q_snprintf( message + len, sizeof( message ) - len, "Crash: signal %d errno %d with code %d at %p %p\n", signal, si->si_errno, si->si_code, si->si_addr, si->si_ptr );
|
||||
|
||||
@@ -41,54 +41,8 @@ void Platform_MessageBox( const char *title, const char *message, qboolean paren
|
||||
}
|
||||
#endif // XASH_MESSAGEBOX == MSGBOX_SDL
|
||||
|
||||
static const char *SDLash_CategoryToString( int category )
|
||||
{
|
||||
switch( category )
|
||||
{
|
||||
case SDL_LOG_CATEGORY_APPLICATION: return "App";
|
||||
case SDL_LOG_CATEGORY_ERROR: return "Error";
|
||||
case SDL_LOG_CATEGORY_ASSERT: return "Assert";
|
||||
case SDL_LOG_CATEGORY_SYSTEM: return "System";
|
||||
case SDL_LOG_CATEGORY_AUDIO: return "Audio";
|
||||
case SDL_LOG_CATEGORY_VIDEO: return "Video";
|
||||
case SDL_LOG_CATEGORY_RENDER: return "Render";
|
||||
case SDL_LOG_CATEGORY_INPUT: return "Input";
|
||||
case SDL_LOG_CATEGORY_TEST: return "Test";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static void SDLCALL SDLash_LogOutputFunction( void *userdata, int category, SDL_LogPriority priority, const char *message )
|
||||
{
|
||||
switch( priority )
|
||||
{
|
||||
case SDL_LOG_PRIORITY_CRITICAL:
|
||||
case SDL_LOG_PRIORITY_ERROR:
|
||||
Con_Printf( S_ERROR S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", SDLash_CategoryToString( category ), message );
|
||||
break;
|
||||
case SDL_LOG_PRIORITY_WARN:
|
||||
Con_DPrintf( S_WARN S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", SDLash_CategoryToString( category ), message );
|
||||
break;
|
||||
case SDL_LOG_PRIORITY_INFO:
|
||||
Con_Reportf( S_NOTE S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", SDLash_CategoryToString( category ), message );
|
||||
break;
|
||||
default:
|
||||
Con_Reportf( S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", SDLash_CategoryToString( category ), message );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SDLash_Init( void )
|
||||
{
|
||||
SDL_LogSetOutputFunction( SDLash_LogOutputFunction, NULL );
|
||||
|
||||
if( host_developer.value >= 2 )
|
||||
SDL_LogSetAllPriority( SDL_LOG_PRIORITY_VERBOSE );
|
||||
else if( host_developer.value >= 1 )
|
||||
SDL_LogSetAllPriority( SDL_LOG_PRIORITY_WARN );
|
||||
else
|
||||
SDL_LogSetAllPriority( SDL_LOG_PRIORITY_ERROR );
|
||||
|
||||
#ifndef SDL_INIT_EVENTS
|
||||
#define SDL_INIT_EVENTS 0
|
||||
#endif
|
||||
|
||||
@@ -588,7 +588,7 @@ void Wcon_DestroyConsole( void )
|
||||
// last text message into console or log
|
||||
Con_Reportf( "%s: Unloading xash.dll\n", __func__ );
|
||||
|
||||
Sys_CloseLog( NULL );
|
||||
Sys_CloseLog();
|
||||
|
||||
if( !s_wcd.attached )
|
||||
{
|
||||
|
||||
@@ -138,7 +138,7 @@ static void Sys_StackTrace( PEXCEPTION_POINTERS pInfo )
|
||||
#endif
|
||||
|
||||
len = Q_snprintf( message, sizeof( message ), "Ver: " XASH_ENGINE_NAME " " XASH_VERSION " (build %i-%s, %s-%s)\n",
|
||||
Q_buildnum(), g_buildcommit, Q_buildos(), Q_buildarch() );
|
||||
Q_buildnum(), Q_buildcommit(), Q_buildos(), Q_buildarch() );
|
||||
|
||||
len += Q_snprintf( message + len, 1024 - len, "Sys_Crash: address %p, code %p\n",
|
||||
pInfo->ExceptionRecord->ExceptionAddress, (void*)pInfo->ExceptionRecord->ExceptionCode );
|
||||
@@ -213,14 +213,14 @@ static void Sys_GetMinidumpFileName( const char *processName, char *mdmpFileName
|
||||
struct tm *currentLocalTime = localtime( ¤tUtcTime );
|
||||
|
||||
Q_snprintf( mdmpFileName, bufferSize, "%s_%s_crash_%d%.2d%.2d_%.2d%.2d%.2d.mdmp",
|
||||
processName,
|
||||
g_buildcommit,
|
||||
currentLocalTime->tm_year + 1900,
|
||||
currentLocalTime->tm_mon + 1,
|
||||
currentLocalTime->tm_mday,
|
||||
currentLocalTime->tm_hour,
|
||||
currentLocalTime->tm_min,
|
||||
currentLocalTime->tm_sec );
|
||||
processName,
|
||||
Q_buildcommit(),
|
||||
currentLocalTime->tm_year + 1900,
|
||||
currentLocalTime->tm_mon + 1,
|
||||
currentLocalTime->tm_mday,
|
||||
currentLocalTime->tm_hour,
|
||||
currentLocalTime->tm_min,
|
||||
currentLocalTime->tm_sec);
|
||||
}
|
||||
|
||||
static qboolean Sys_WriteMinidump(PEXCEPTION_POINTERS exceptionInfo, MINIDUMP_TYPE minidumpType)
|
||||
|
||||
@@ -80,7 +80,6 @@ GNU General Public License for more details.
|
||||
#define MODEL_LIQUID BIT( 2 ) // model has only point hull
|
||||
#define MODEL_TRANSPARENT BIT( 3 ) // have transparent surfaces
|
||||
#define MODEL_COLORED_LIGHTING BIT( 4 ) // lightmaps stored as RGB
|
||||
|
||||
#define MODEL_WORLD BIT( 29 ) // it's a worldmodel
|
||||
#define MODEL_CLIENT BIT( 30 ) // client sprite
|
||||
|
||||
|
||||
@@ -67,8 +67,6 @@ extern int SV_UPDATE_BACKUP;
|
||||
#define MAX_PUSHED_ENTS 256
|
||||
#define MAX_VIEWENTS 128
|
||||
|
||||
#define MAX_ENT_LEAFS( ext ) (( ext ) ? MAX_ENT_LEAFS_32 : MAX_ENT_LEAFS_16 )
|
||||
|
||||
#define FCL_RESEND_USERINFO BIT( 0 )
|
||||
#define FCL_RESEND_MOVEVARS BIT( 1 )
|
||||
#define FCL_SKIP_NET_MESSAGE BIT( 2 )
|
||||
|
||||
@@ -2226,7 +2226,7 @@ SV_SendBuildInfo_f
|
||||
static qboolean SV_SendBuildInfo_f( sv_client_t *cl )
|
||||
{
|
||||
SV_ClientPrintf( cl, "Server running " XASH_ENGINE_NAME " " XASH_VERSION " (build %i-%s, %s-%s)\n",
|
||||
Q_buildnum(), g_buildcommit, Q_buildos(), Q_buildarch() );
|
||||
Q_buildnum(), Q_buildcommit(), Q_buildos(), Q_buildarch() );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ static qboolean SV_CheckClientVisiblity( sv_client_t *cl, const byte *mask )
|
||||
else
|
||||
VectorCopy( cl->edict->v.origin, vieworg );
|
||||
|
||||
leaf = Mod_PointInLeaf( vieworg, sv.worldmodel->nodes, sv.worldmodel );
|
||||
leaf = Mod_PointInLeaf( vieworg, sv.worldmodel->nodes );
|
||||
|
||||
if( CHECKVISBIT( mask, leaf->cluster ))
|
||||
return true; // visible from player view or camera view
|
||||
@@ -342,7 +342,7 @@ static qboolean SV_CheckClientVisiblity( sv_client_t *cl, const byte *mask )
|
||||
continue;
|
||||
|
||||
VectorAdd( view->v.origin, view->v.view_ofs, vieworg );
|
||||
leaf = Mod_PointInLeaf( vieworg, sv.worldmodel->nodes, sv.worldmodel );
|
||||
leaf = Mod_PointInLeaf( vieworg, sv.worldmodel->nodes );
|
||||
|
||||
if( CHECKVISBIT( mask, leaf->cluster ))
|
||||
return true; // visible from portal camera view
|
||||
@@ -1732,7 +1732,7 @@ static edict_t* GAME_EXPORT pfnFindClientInPVS( edict_t *pEdict )
|
||||
VectorAdd( pEdict->v.origin, pEdict->v.view_ofs, view );
|
||||
}
|
||||
|
||||
leaf = Mod_PointInLeaf( view, sv.worldmodel->nodes, sv.worldmodel );
|
||||
leaf = Mod_PointInLeaf( view, sv.worldmodel->nodes );
|
||||
|
||||
if( CHECKVISBIT( clientpvs, leaf->cluster ))
|
||||
return pClient; // client which currently in PVS
|
||||
@@ -4291,35 +4291,6 @@ static byte *GAME_EXPORT pfnSetFatPAS( const float *org )
|
||||
return fatphs;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Mod_HeadnodeVisible
|
||||
=============
|
||||
*/
|
||||
static qboolean Mod_HeadnodeVisible( model_t *mod, mnode_t *node, const byte *visbits, int *lastleaf )
|
||||
{
|
||||
if( !node || node->contents == CONTENTS_SOLID )
|
||||
return false;
|
||||
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
if( !CHECKVISBIT( visbits, ((mleaf_t *)node)->cluster ))
|
||||
return false;
|
||||
|
||||
if( lastleaf )
|
||||
*lastleaf = ((mleaf_t *)node)->cluster;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( Mod_HeadnodeVisible( mod, node_child( node, 0, mod ), visbits, lastleaf ))
|
||||
return true;
|
||||
|
||||
if( Mod_HeadnodeVisible( mod, node_child( node, 1, mod ), visbits, lastleaf ))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
pfnCheckVisibility
|
||||
@@ -4329,7 +4300,6 @@ pfnCheckVisibility
|
||||
static int GAME_EXPORT pfnCheckVisibility( const edict_t *ent, byte *pset )
|
||||
{
|
||||
int i, leafnum;
|
||||
qboolean large_leafs = FBitSet( sv.worldmodel->flags, MODEL_QBSP2 );
|
||||
|
||||
if( !SV_IsValidEdict( ent ))
|
||||
return 0;
|
||||
@@ -4345,28 +4315,17 @@ static int GAME_EXPORT pfnCheckVisibility( const edict_t *ent, byte *pset )
|
||||
// check individual leafs
|
||||
for( i = 0; i < ent->num_leafs; i++ )
|
||||
{
|
||||
if( large_leafs )
|
||||
{
|
||||
if( CHECKVISBIT( pset, ent->leafnums32[i] ))
|
||||
return 1; // visible passed by leaf
|
||||
}
|
||||
else
|
||||
{
|
||||
if( CHECKVISBIT( pset, ent->leafnums16[i] ))
|
||||
return 1; // visible passed by leaf
|
||||
}
|
||||
if( CHECKVISBIT( pset, ent->leafnums[i] ))
|
||||
return 1; // visible passed by leaf
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < MAX_ENT_LEAFS( large_leafs ); i++ )
|
||||
for( i = 0; i < MAX_ENT_LEAFS; i++ )
|
||||
{
|
||||
if( large_leafs )
|
||||
leafnum = ent->leafnums32[i];
|
||||
else
|
||||
leafnum = ent->leafnums16[i];
|
||||
leafnum = ent->leafnums[i];
|
||||
if( leafnum == -1 ) break;
|
||||
|
||||
if( CHECKVISBIT( pset, leafnum ))
|
||||
@@ -4374,15 +4333,11 @@ static int GAME_EXPORT pfnCheckVisibility( const edict_t *ent, byte *pset )
|
||||
}
|
||||
|
||||
// too many leafs for individual check, go by headnode
|
||||
if( !Mod_HeadnodeVisible( sv.worldmodel, &sv.worldmodel->nodes[ent->headnode], pset, &leafnum ))
|
||||
if( !Mod_HeadnodeVisible( &sv.worldmodel->nodes[ent->headnode], pset, &leafnum ))
|
||||
return 0;
|
||||
|
||||
if( large_leafs )
|
||||
((edict_t *)ent)->leafnums32[ent->num_leafs] = leafnum;
|
||||
else
|
||||
((edict_t *)ent)->leafnums16[ent->num_leafs] = leafnum;
|
||||
|
||||
((edict_t *)ent)->num_leafs = (ent->num_leafs + 1) % MAX_ENT_LEAFS( large_leafs );
|
||||
((edict_t *)ent)->leafnums[ent->num_leafs] = leafnum;
|
||||
((edict_t *)ent)->num_leafs = (ent->num_leafs + 1) % MAX_ENT_LEAFS;
|
||||
|
||||
return 2; // visible passed by headnode
|
||||
}
|
||||
|
||||
@@ -970,7 +970,7 @@ void SV_Init( void )
|
||||
MSG_Init( &net_message, "NetMessage", net_message_buffer, sizeof( net_message_buffer ));
|
||||
|
||||
Q_snprintf( versionString, sizeof( versionString ), XASH_ENGINE_NAME ": " XASH_VERSION "-%s(%s-%s),%i,%i",
|
||||
g_buildcommit, Q_buildos(), Q_buildarch(), PROTOCOL_VERSION, Q_buildnum() );
|
||||
Q_buildcommit(), Q_buildos(), Q_buildarch(), PROTOCOL_VERSION, Q_buildnum() );
|
||||
|
||||
Cvar_FullSet( "sv_version", versionString, FCVAR_READ_ONLY );
|
||||
|
||||
|
||||
@@ -40,8 +40,9 @@ HULL BOXES
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
static hull_t box_hull;
|
||||
static mplane_t box_planes[6];
|
||||
static hull_t box_hull;
|
||||
static mclipnode_t box_clipnodes[6];
|
||||
static mplane_t box_planes[6];
|
||||
|
||||
/*
|
||||
===================
|
||||
@@ -53,15 +54,23 @@ can just be stored out and get a proper hull_t structure.
|
||||
*/
|
||||
static void SV_InitBoxHull( void )
|
||||
{
|
||||
int i;
|
||||
int i, side;
|
||||
|
||||
box_hull.clipnodes16 = (mclipnode16_t *)box_clipnodes16;
|
||||
box_hull.clipnodes = box_clipnodes;
|
||||
box_hull.planes = box_planes;
|
||||
box_hull.firstclipnode = 0;
|
||||
box_hull.lastclipnode = 5;
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
box_clipnodes[i].planenum = i;
|
||||
|
||||
side = i & 1;
|
||||
|
||||
box_clipnodes[i].children[side] = CONTENTS_EMPTY;
|
||||
if( i != 5 ) box_clipnodes[i].children[side^1] = i + 1;
|
||||
else box_clipnodes[i].children[side^1] = CONTENTS_SOLID;
|
||||
|
||||
box_planes[i].type = i>>1;
|
||||
box_planes[i].normal[i>>1] = 1;
|
||||
box_planes[i].signbits = 0;
|
||||
@@ -158,11 +167,6 @@ static hull_t *SV_HullForBox( const vec3_t mins, const vec3_t maxs )
|
||||
box_planes[4].dist = maxs[2];
|
||||
box_planes[5].dist = mins[2];
|
||||
|
||||
if( world.version == QBSP2_VERSION )
|
||||
box_hull.clipnodes32 = (mclipnode32_t *)box_clipnodes32;
|
||||
else
|
||||
box_hull.clipnodes16 = (mclipnode16_t *)box_clipnodes16;
|
||||
|
||||
return &box_hull;
|
||||
}
|
||||
|
||||
@@ -590,7 +594,7 @@ SV_FindTouchedLeafs
|
||||
|
||||
===============
|
||||
*/
|
||||
static void SV_FindTouchedLeafs( edict_t *ent, model_t *mod, mnode_t *node, int *headnode )
|
||||
static void SV_FindTouchedLeafs( edict_t *ent, mnode_t *node, int *headnode )
|
||||
{
|
||||
int sides;
|
||||
mleaf_t *leaf;
|
||||
@@ -601,19 +605,16 @@ static void SV_FindTouchedLeafs( edict_t *ent, model_t *mod, mnode_t *node, int
|
||||
// add an efrag if the node is a leaf
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
if( ent->num_leafs > MAX_ENT_LEAFS( FBitSet( mod->flags, MODEL_QBSP2 )))
|
||||
if( ent->num_leafs > ( MAX_ENT_LEAFS - 1 ))
|
||||
{
|
||||
// continue counting leafs,
|
||||
// so we know how many it's overrun
|
||||
ent->num_leafs = (MAX_ENT_LEAFS( FBitSet( mod->flags, MODEL_QBSP2 )) + 1);
|
||||
ent->num_leafs = (MAX_ENT_LEAFS + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
leaf = (mleaf_t *)node;
|
||||
if( FBitSet( mod->flags, MODEL_QBSP2 ))
|
||||
ent->leafnums32[ent->num_leafs] = leaf->cluster;
|
||||
else
|
||||
ent->leafnums16[ent->num_leafs] = leaf->cluster;
|
||||
ent->leafnums[ent->num_leafs] = leaf->cluster;
|
||||
ent->num_leafs++;
|
||||
}
|
||||
return;
|
||||
@@ -623,13 +624,11 @@ static void SV_FindTouchedLeafs( edict_t *ent, model_t *mod, mnode_t *node, int
|
||||
sides = BOX_ON_PLANE_SIDE( ent->v.absmin, ent->v.absmax, node->plane );
|
||||
|
||||
if(( sides == 3 ) && ( *headnode == -1 ))
|
||||
*headnode = node - mod->nodes;
|
||||
*headnode = node - sv.worldmodel->nodes;
|
||||
|
||||
// recurse down the contacted sides
|
||||
if( sides & 1 )
|
||||
SV_FindTouchedLeafs( ent, mod, node_child( node, 0, mod ), headnode );
|
||||
if( sides & 2 )
|
||||
SV_FindTouchedLeafs( ent, mod, node_child( node, 1, mod ), headnode );
|
||||
if( sides & 1 ) SV_FindTouchedLeafs( ent, node->children[0], headnode );
|
||||
if( sides & 2 ) SV_FindTouchedLeafs( ent, node->children[1], headnode );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -651,7 +650,7 @@ void GAME_EXPORT SV_LinkEdict( edict_t *ent, qboolean touch_triggers )
|
||||
|
||||
if( ent->v.movetype == MOVETYPE_FOLLOW && SV_IsValidEdict( ent->v.aiment ))
|
||||
{
|
||||
memcpy( ent->leafnums32, ent->v.aiment->leafnums32, sizeof( ent->leafnums32 ));
|
||||
memcpy( ent->leafnums, ent->v.aiment->leafnums, sizeof( ent->leafnums ));
|
||||
ent->num_leafs = ent->v.aiment->num_leafs;
|
||||
ent->headnode = ent->v.aiment->headnode;
|
||||
}
|
||||
@@ -663,11 +662,11 @@ void GAME_EXPORT SV_LinkEdict( edict_t *ent, qboolean touch_triggers )
|
||||
headnode = -1;
|
||||
|
||||
if( ent->v.modelindex )
|
||||
SV_FindTouchedLeafs( ent, sv.worldmodel, sv.worldmodel->nodes, &headnode );
|
||||
SV_FindTouchedLeafs( ent, sv.worldmodel->nodes, &headnode );
|
||||
|
||||
if( ent->num_leafs > MAX_ENT_LEAFS( FBitSet( sv.worldmodel->flags, MODEL_QBSP2 )))
|
||||
if( ent->num_leafs > MAX_ENT_LEAFS )
|
||||
{
|
||||
memset( ent->leafnums32, -1, sizeof( ent->leafnums32 ));
|
||||
memset( ent->leafnums, -1, sizeof( ent->leafnums ));
|
||||
ent->num_leafs = 0; // so we use headnode instead
|
||||
ent->headnode = headnode;
|
||||
}
|
||||
@@ -1519,8 +1518,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
|
||||
float front, back, frac;
|
||||
int i, side;
|
||||
vec3_t mid;
|
||||
mnode_t *children[2];
|
||||
int numsurfaces, firstsurface;
|
||||
|
||||
// didn't hit anything
|
||||
if( !node || node->contents < 0 )
|
||||
@@ -1530,29 +1527,25 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
|
||||
front = PlaneDiff( start, node->plane );
|
||||
back = PlaneDiff( end, node->plane );
|
||||
|
||||
node_children( children, node, model );
|
||||
|
||||
side = front < 0.0f;
|
||||
if(( back < 0.0f ) == side )
|
||||
return SV_RecursiveLightPoint( model, children[side], start, end, point_color );
|
||||
return SV_RecursiveLightPoint( model, node->children[side], start, end, point_color );
|
||||
|
||||
frac = front / ( front - back );
|
||||
|
||||
VectorLerp( start, frac, end, mid );
|
||||
|
||||
// co down front side
|
||||
if( SV_RecursiveLightPoint( model, children[side], start, mid, point_color ))
|
||||
if( SV_RecursiveLightPoint( model, node->children[side], start, mid, point_color ))
|
||||
return true; // hit something
|
||||
|
||||
if(( back < 0.0f ) == side )
|
||||
return false; // didn't hit anything
|
||||
|
||||
// check for impact on this node
|
||||
numsurfaces = node_numsurfaces( node, model );
|
||||
firstsurface = node_firstsurface( node, model );
|
||||
for( i = 0; i < numsurfaces; i++ )
|
||||
for( i = 0; i < node->numsurfaces; i++ )
|
||||
{
|
||||
const msurface_t *surf = &model->surfaces[firstsurface + i];
|
||||
const msurface_t *surf = &model->surfaces[node->firstsurface + i];
|
||||
const mextrasurf_t *info = surf->info;
|
||||
int smax, tmax, map, size;
|
||||
int sample_size;
|
||||
@@ -1603,7 +1596,7 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
|
||||
}
|
||||
|
||||
// go down back side
|
||||
return SV_RecursiveLightPoint( model, children[!side], mid, end, point_color );
|
||||
return SV_RecursiveLightPoint( model, node->children[!side], mid, end, point_color );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -57,12 +57,6 @@ static qboolean Platform_GetDirectoryCaseSensitivity( const char *dir )
|
||||
{
|
||||
#if XASH_WIN32 || XASH_PSVITA || XASH_NSWITCH
|
||||
return false;
|
||||
#elif XASH_ANDROID
|
||||
// on Android, doing code below causes crash in MediaProviderGoogle.apk!libfuse_jni.so
|
||||
// which in turn makes vold (Android's Volume Daemon) to umount /storage/emulated/0
|
||||
// and because you can't unmount a filesystem when there is file descriptors open
|
||||
// it has no other choice but to terminate and then kill our program
|
||||
return true;
|
||||
#elif XASH_LINUX && defined( FS_IOC_GETFLAGS )
|
||||
int flags = 0;
|
||||
int fd;
|
||||
@@ -72,10 +66,7 @@ static qboolean Platform_GetDirectoryCaseSensitivity( const char *dir )
|
||||
return true;
|
||||
|
||||
if( ioctl( fd, FS_IOC_GETFLAGS, &flags ) < 0 )
|
||||
{
|
||||
close( fd );
|
||||
return true;
|
||||
}
|
||||
|
||||
close( fd );
|
||||
|
||||
|
||||
@@ -529,7 +529,7 @@ static qboolean FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
|
||||
if( !f )
|
||||
return false;
|
||||
|
||||
FS_Printf( f, "// generated by " XASH_ENGINE_NAME " " XASH_VERSION "-%s (%s-%s)\n\n\n", g_buildcommit, Q_buildos(), Q_buildarch() );
|
||||
FS_Printf( f, "// generated by " XASH_ENGINE_NAME " " XASH_VERSION "-%s (%s-%s)\n\n\n", Q_buildcommit(), Q_buildos(), Q_buildarch() );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->basedir ) )
|
||||
FS_Printf( f, "basedir\t\t\"%s\"\n", GameInfo->basedir );
|
||||
|
||||
@@ -239,3 +239,29 @@ const char *Q_buildarch( void )
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Q_buildcommit
|
||||
|
||||
Returns a short hash of current commit in VCS as string
|
||||
XASH_BUILD_COMMIT must be passed in quotes
|
||||
=============
|
||||
*/
|
||||
const char *Q_buildcommit( void )
|
||||
{
|
||||
return XASH_BUILD_COMMIT;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Q_buildbranch
|
||||
|
||||
Returns current branch name in VCS as string
|
||||
XASH_BUILD_BRANCH must be passed in quotes
|
||||
=============
|
||||
*/
|
||||
const char *Q_buildbranch( void )
|
||||
{
|
||||
return XASH_BUILD_BRANCH;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
build_vcs.c - info from VCS
|
||||
Copyright (C) 2025 Alibek Omarov
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
const char *g_buildcommit = XASH_BUILD_COMMIT;
|
||||
const char *g_buildbranch = XASH_BUILD_BRANCH;
|
||||
|
||||
@@ -62,8 +62,8 @@ const char *Q_PlatformStringByID( const int platform );
|
||||
const char *Q_buildos( void );
|
||||
const char *Q_ArchitectureStringByID( const int arch, const uint abi, const int endianness, const qboolean is64 );
|
||||
const char *Q_buildarch( void );
|
||||
extern const char *g_buildcommit;
|
||||
extern const char *g_buildbranch;
|
||||
const char *Q_buildcommit( void );
|
||||
const char *Q_buildbranch( void );
|
||||
|
||||
//
|
||||
// crtlib.c
|
||||
|
||||
@@ -67,6 +67,8 @@ def options(opt):
|
||||
def configure(conf):
|
||||
# private to libpublic
|
||||
conf.load('gitversion')
|
||||
conf.define('XASH_BUILD_COMMIT', conf.env.GIT_VERSION if conf.env.GIT_VERSION else 'unknown-commit')
|
||||
conf.define('XASH_BUILD_BRANCH', conf.env.GIT_BRANCH if conf.env.GIT_BRANCH else 'unknown-branch')
|
||||
conf.env.VALIDATE_TARGET = conf.options.VALIDATE_TARGET
|
||||
|
||||
# need to expose it for everyone using libpublic headers
|
||||
@@ -118,14 +120,9 @@ def build(bld):
|
||||
export_includes = '. ../common ../pm_shared ../engine',
|
||||
export_defines = bld.env.EXPORT_DEFINES_LIST)
|
||||
|
||||
# build it separately to slightly improve rebuild times
|
||||
bld.stlib(source = 'build_vcs.c',
|
||||
target = 'build_vcs',
|
||||
defines = ['XASH_BUILD_COMMIT=\"%s\"' % bld.env.GIT_VERSION, 'XASH_BUILD_BRANCH=\"%s\"' % bld.env.GIT_BRANCH])
|
||||
|
||||
bld.stlib(source = bld.path.ant_glob('*.c', excl='build_vcs.c'),
|
||||
target = 'public',
|
||||
use = 'sdk_includes werror build_vcs')
|
||||
bld.stlib(source = bld.path.ant_glob('*.c'),
|
||||
target = 'public',
|
||||
use = 'sdk_includes werror')
|
||||
|
||||
if bld.env.TESTS:
|
||||
if bld.env.VALIDATE_TARGET:
|
||||
|
||||
@@ -670,14 +670,10 @@ static void R_DecalNodeSurfaces( model_t *model, mnode_t *node, decalinfo_t *dec
|
||||
// iterate over all surfaces in the node
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
int firstsurface, numsurfaces;
|
||||
|
||||
firstsurface = node_firstsurface( node, model );
|
||||
numsurfaces = node_numsurfaces( node, model );
|
||||
surf = model->surfaces + node->firstsurface;
|
||||
|
||||
surf = model->surfaces + firstsurface;
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, surf++ )
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
// never apply decals on the water or sky surfaces
|
||||
if( surf->flags & (SURF_DRAWTURB|SURF_DRAWSKY|SURF_CONVEYOR))
|
||||
@@ -699,7 +695,6 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
float dist;
|
||||
mnode_t *children[2];
|
||||
|
||||
Assert( node != NULL );
|
||||
|
||||
@@ -711,7 +706,6 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
|
||||
splitplane = node->plane;
|
||||
dist = DotProduct( decalinfo->m_Position, splitplane->normal ) - splitplane->dist;
|
||||
node_children( children, node, model );
|
||||
|
||||
// This is arbitrarily set to 10 right now. In an ideal world we'd have the
|
||||
// exact surface but we don't so, this tells me which planes are "sort of
|
||||
@@ -723,19 +717,19 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
// have a surface normal
|
||||
if( dist > decalinfo->m_Size )
|
||||
{
|
||||
R_DecalNode( model, children[0], decalinfo );
|
||||
R_DecalNode( model, node->children[0], decalinfo );
|
||||
}
|
||||
else if( dist < -decalinfo->m_Size )
|
||||
{
|
||||
R_DecalNode( model, children[1], decalinfo );
|
||||
R_DecalNode( model, node->children[1], decalinfo );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dist < DECAL_DISTANCE && dist > -DECAL_DISTANCE )
|
||||
R_DecalNodeSurfaces( model, node, decalinfo );
|
||||
|
||||
R_DecalNode( model, children[0], decalinfo );
|
||||
R_DecalNode( model, children[1], decalinfo );
|
||||
R_DecalNode( model, node->children[0], decalinfo );
|
||||
R_DecalNode( model, node->children[1], decalinfo );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,33 +104,27 @@ void R_MarkLights( dlight_t *light, int bit, mnode_t *node )
|
||||
float dist;
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
mnode_t *children[2];
|
||||
int firstsurface, numsurfaces;
|
||||
|
||||
if( !node || node->contents < 0 )
|
||||
return;
|
||||
|
||||
dist = PlaneDiff( light->origin, node->plane );
|
||||
|
||||
node_children( children, node, RI.currentmodel );
|
||||
firstsurface = node_firstsurface( node, RI.currentmodel );
|
||||
numsurfaces = node_numsurfaces( node, RI.currentmodel );
|
||||
|
||||
if( dist > light->radius )
|
||||
{
|
||||
R_MarkLights( light, bit, children[0] );
|
||||
R_MarkLights( light, bit, node->children[0] );
|
||||
return;
|
||||
}
|
||||
if( dist < -light->radius )
|
||||
{
|
||||
R_MarkLights( light, bit, children[1] );
|
||||
R_MarkLights( light, bit, node->children[1] );
|
||||
return;
|
||||
}
|
||||
|
||||
// mark the polygons
|
||||
surf = RI.currentmodel->surfaces + firstsurface;
|
||||
surf = RI.currentmodel->surfaces + node->firstsurface;
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, surf++ )
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
if( !BoundsAndSphereIntersect( surf->info->mins, surf->info->maxs, light->origin, light->radius ))
|
||||
continue; // no intersection
|
||||
@@ -143,8 +137,8 @@ void R_MarkLights( dlight_t *light, int bit, mnode_t *node )
|
||||
surf->dlightbits |= bit;
|
||||
}
|
||||
|
||||
R_MarkLights( light, bit, children[0] );
|
||||
R_MarkLights( light, bit, children[1] );
|
||||
R_MarkLights( light, bit, node->children[0] );
|
||||
R_MarkLights( light, bit, node->children[1] );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -208,8 +202,6 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
mtexinfo_t *tex;
|
||||
matrix3x4 tbn;
|
||||
vec3_t mid;
|
||||
mnode_t *children[2];
|
||||
int firstsurface, numsurfaces;
|
||||
|
||||
// didn't hit anything
|
||||
if( !node || node->contents < 0 )
|
||||
@@ -218,17 +210,13 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
return false;
|
||||
}
|
||||
|
||||
node_children( children, node, model );
|
||||
firstsurface = node_firstsurface( node, model );
|
||||
numsurfaces = node_numsurfaces( node, model );
|
||||
|
||||
// calculate mid point
|
||||
front = PlaneDiff( start, node->plane );
|
||||
back = PlaneDiff( end, node->plane );
|
||||
|
||||
side = front < 0;
|
||||
if(( back < 0 ) == side )
|
||||
return R_RecursiveLightPoint( model, children[side], p1f, p2f, cv, start, end );
|
||||
return R_RecursiveLightPoint( model, node->children[side], p1f, p2f, cv, start, end );
|
||||
|
||||
frac = front / ( front - back );
|
||||
|
||||
@@ -236,7 +224,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
midf = p1f + ( p2f - p1f ) * frac;
|
||||
|
||||
// co down front side
|
||||
if( R_RecursiveLightPoint( model, children[side], p1f, midf, cv, start, mid ))
|
||||
if( R_RecursiveLightPoint( model, node->children[side], p1f, midf, cv, start, mid ))
|
||||
return true; // hit something
|
||||
|
||||
if(( back < 0 ) == side )
|
||||
@@ -246,10 +234,10 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
}
|
||||
|
||||
// check for impact on this node
|
||||
surf = model->surfaces + firstsurface;
|
||||
surf = model->surfaces + node->firstsurface;
|
||||
VectorCopy( mid, g_trace_lightspot );
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, surf++ )
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
int smax, tmax;
|
||||
|
||||
@@ -338,7 +326,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
}
|
||||
|
||||
// go down back side
|
||||
return R_RecursiveLightPoint( model, children[!side], midf, p2f, cv, mid, end );
|
||||
return R_RecursiveLightPoint( model, node->children[!side], midf, p2f, cv, mid, end );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -600,7 +600,6 @@ watertexture to grab fog values from it
|
||||
static gl_texture_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mnode_t *ignore, qboolean down )
|
||||
{
|
||||
gl_texture_t *tex = NULL;
|
||||
mnode_t *children[2];
|
||||
|
||||
// assure the initial node is not null
|
||||
// we could check it here, but we would rather check it
|
||||
@@ -638,17 +637,15 @@ static gl_texture_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mno
|
||||
|
||||
// this is a regular node
|
||||
// traverse children
|
||||
node_children( children, node, WORLDMODEL );
|
||||
|
||||
if( children[0] && ( children[0] != ignore ))
|
||||
if( node->children[0] && ( node->children[0] != ignore ))
|
||||
{
|
||||
tex = R_RecursiveFindWaterTexture( children[0], node, true );
|
||||
tex = R_RecursiveFindWaterTexture( node->children[0], node, true );
|
||||
if( tex ) return tex;
|
||||
}
|
||||
|
||||
if( children[1] && ( children[1] != ignore ))
|
||||
if( node->children[1] && ( node->children[1] != ignore ))
|
||||
{
|
||||
tex = R_RecursiveFindWaterTexture( children[1], node, true );
|
||||
tex = R_RecursiveFindWaterTexture( node->children[1], node, true );
|
||||
if( tex ) return tex;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,25 +125,12 @@ static void R_TextureCoord( const vec3_t v, const msurface_t *surf, vec2_t coord
|
||||
static void R_GetEdgePosition( const model_t *mod, const msurface_t *fa, int i, vec3_t vec )
|
||||
{
|
||||
const int lindex = mod->surfedges[fa->firstedge + i];
|
||||
const medge_t *pedges = mod->edges;
|
||||
|
||||
if( FBitSet( mod->flags, MODEL_QBSP2 ))
|
||||
{
|
||||
const medge32_t *pedges = mod->edges32;
|
||||
|
||||
if( lindex > 0 )
|
||||
VectorCopy( mod->vertexes[pedges[lindex].v[0]].position, vec );
|
||||
else
|
||||
VectorCopy( mod->vertexes[pedges[-lindex].v[1]].position, vec );
|
||||
}
|
||||
if( lindex > 0 )
|
||||
VectorCopy( mod->vertexes[pedges[lindex].v[0]].position, vec );
|
||||
else
|
||||
{
|
||||
const medge16_t *pedges = mod->edges16;
|
||||
|
||||
if( lindex > 0 )
|
||||
VectorCopy( mod->vertexes[pedges[lindex].v[0]].position, vec );
|
||||
else
|
||||
VectorCopy( mod->vertexes[pedges[-lindex].v[1]].position, vec );
|
||||
}
|
||||
VectorCopy( mod->vertexes[pedges[-lindex].v[1]].position, vec );
|
||||
}
|
||||
|
||||
static void BoundPoly( int numverts, float *verts, vec3_t mins, vec3_t maxs )
|
||||
@@ -3319,9 +3306,6 @@ static void R_RecursiveWorldNode( mnode_t *node, uint clipflags )
|
||||
mleaf_t *pleaf;
|
||||
int c, side;
|
||||
float dot;
|
||||
mnode_t *children[2];
|
||||
int numsurfaces, firstsurface;
|
||||
|
||||
loc0:
|
||||
if( node->contents == CONTENTS_SOLID )
|
||||
return; // hit a solid leaf
|
||||
@@ -3376,14 +3360,10 @@ loc0:
|
||||
side = (dot >= 0.0f) ? 0 : 1;
|
||||
|
||||
// recurse down the children, front side first
|
||||
node_children( children, node, WORLDMODEL );
|
||||
R_RecursiveWorldNode( children[side], clipflags );
|
||||
|
||||
firstsurface = node_firstsurface( node, WORLDMODEL );
|
||||
numsurfaces = node_numsurfaces( node, WORLDMODEL );
|
||||
R_RecursiveWorldNode( node->children[side], clipflags );
|
||||
|
||||
// draw stuff
|
||||
for( c = numsurfaces, surf = WORLDMODEL->surfaces + firstsurface; c; c--, surf++ )
|
||||
for( c = node->numsurfaces, surf = WORLDMODEL->surfaces + node->firstsurface; c; c--, surf++ )
|
||||
{
|
||||
if( R_CullSurface( surf, &RI.frustum, clipflags ))
|
||||
continue;
|
||||
@@ -3402,7 +3382,7 @@ loc0:
|
||||
}
|
||||
|
||||
// recurse down the back side
|
||||
node = children[!side];
|
||||
node = node->children[!side];
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
@@ -3478,9 +3458,6 @@ static void R_DrawWorldTopView( mnode_t *node, uint clipflags )
|
||||
|
||||
do
|
||||
{
|
||||
mnode_t *children[2];
|
||||
int numsurfaces, firstsurface;
|
||||
|
||||
if( node->contents == CONTENTS_SOLID )
|
||||
return; // hit a solid leaf
|
||||
|
||||
@@ -3514,10 +3491,7 @@ static void R_DrawWorldTopView( mnode_t *node, uint clipflags )
|
||||
}
|
||||
|
||||
// draw stuff
|
||||
numsurfaces = node_numsurfaces( node, WORLDMODEL );
|
||||
firstsurface = node_firstsurface( node, WORLDMODEL );
|
||||
|
||||
for( c = numsurfaces, surf = WORLDMODEL->surfaces + firstsurface; c; c--, surf++ )
|
||||
for( c = node->numsurfaces, surf = WORLDMODEL->surfaces + node->firstsurface; c; c--, surf++ )
|
||||
{
|
||||
// don't process the same surface twice
|
||||
if( surf->visframe == tr.framecount )
|
||||
@@ -3536,9 +3510,9 @@ static void R_DrawWorldTopView( mnode_t *node, uint clipflags )
|
||||
}
|
||||
|
||||
// recurse down both children, we don't care the order...
|
||||
node_children( children, node, WORLDMODEL );
|
||||
R_DrawWorldTopView( children[0], clipflags );
|
||||
node = children[1];
|
||||
R_DrawWorldTopView( node->children[0], clipflags );
|
||||
node = node->children[1];
|
||||
|
||||
} while( node );
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ void R_RotateBmodel( void )
|
||||
R_RecursiveClipBPoly
|
||||
================
|
||||
*/
|
||||
static void R_RecursiveClipBPoly( model_t *mod, bedge_t *pedges, mnode_t *pnode, msurface_t *psurf )
|
||||
static void R_RecursiveClipBPoly( bedge_t *pedges, mnode_t *pnode, msurface_t *psurf )
|
||||
{
|
||||
bedge_t *psideedges[2], *pnextedge, *ptedge;
|
||||
int i, side, lastside;
|
||||
@@ -316,7 +316,7 @@ static void R_RecursiveClipBPoly( model_t *mod, bedge_t *pedges, mnode_t *pnode,
|
||||
{
|
||||
// draw if we've reached a non-solid leaf, done if all that's left is a
|
||||
// solid leaf, and continue down the tree if it's not a leaf
|
||||
pn = node_child( pnode, i, mod );
|
||||
pn = pnode->children[i];
|
||||
|
||||
// we're done with this branch if the node or leaf isn't in the PVS
|
||||
if( pn->visframe == tr.visframecount )
|
||||
@@ -332,7 +332,8 @@ static void R_RecursiveClipBPoly( model_t *mod, bedge_t *pedges, mnode_t *pnode,
|
||||
}
|
||||
else
|
||||
{
|
||||
R_RecursiveClipBPoly( mod, psideedges[i], pn, psurf );
|
||||
R_RecursiveClipBPoly( psideedges[i], pnode->children[i],
|
||||
psurf );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,13 +356,13 @@ void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode )
|
||||
mplane_t *pplane;
|
||||
mvertex_t bverts[MAX_BMODEL_VERTS];
|
||||
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
|
||||
medge16_t *pedge, *pedges;
|
||||
medge_t *pedge, *pedges;
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
pedges = pmodel->edges16;
|
||||
pedges = pmodel->edges;
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, psurf++ )
|
||||
{
|
||||
@@ -418,7 +419,7 @@ void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode )
|
||||
pbedge[j - 1].pnext = NULL; // mark end of edges
|
||||
|
||||
// if ( !( psurf->texinfo->flags & ( SURF_TRANS66 | SURF_TRANS33 ) ) )
|
||||
R_RecursiveClipBPoly( pmodel, pbedge, topnode, psurf );
|
||||
R_RecursiveClipBPoly( pbedge, topnode, psurf );
|
||||
// else
|
||||
// R_RenderBmodelFace( pbedge, psurf );
|
||||
}
|
||||
@@ -565,9 +566,6 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
}
|
||||
else
|
||||
{
|
||||
mnode_t *children[2];
|
||||
int firstsurface;
|
||||
|
||||
// node is just a decision point, so go down the apropriate sides
|
||||
|
||||
// find which side of the node we are on
|
||||
@@ -595,16 +593,14 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
side = 1;
|
||||
|
||||
// recurse down the children, front side first
|
||||
node_children( children, node, WORLDMODEL );
|
||||
R_RecursiveWorldNode( children[side], clipflags );
|
||||
R_RecursiveWorldNode( node->children[side], clipflags );
|
||||
|
||||
// draw stuff
|
||||
c = node_numsurfaces( node, WORLDMODEL );
|
||||
firstsurface = node_firstsurface( node, WORLDMODEL );
|
||||
c = node->numsurfaces;
|
||||
|
||||
if( c )
|
||||
{
|
||||
surf = WORLDMODEL->surfaces + firstsurface;
|
||||
surf = WORLDMODEL->surfaces + node->firstsurface;
|
||||
|
||||
if( dot < -BACKFACE_EPSILON )
|
||||
{
|
||||
@@ -640,7 +636,7 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
}
|
||||
|
||||
// recurse down the back side
|
||||
R_RecursiveWorldNode( children[!side], clipflags );
|
||||
R_RecursiveWorldNode( node->children[!side], clipflags );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -679,24 +679,23 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
|
||||
static void R_DecalNodeSurfaces( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
{
|
||||
// iterate over all surfaces in the node
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
int firstsurface, numsurfaces;
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
|
||||
firstsurface = node_firstsurface( node, model );
|
||||
numsurfaces = node_numsurfaces( node, model );
|
||||
surf = model->surfaces + node->firstsurface;
|
||||
|
||||
surf = model->surfaces + firstsurface;
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, surf++ )
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
// never apply decals on the water or sky surfaces
|
||||
if( surf->flags & (SURF_DRAWTURB|SURF_DRAWSKY|SURF_CONVEYOR))
|
||||
if( surf->flags & ( SURF_DRAWTURB | SURF_DRAWSKY | SURF_CONVEYOR ))
|
||||
continue;
|
||||
|
||||
// we can implement alpha testing without stencil
|
||||
// if( surf->flags & SURF_TRANSPARENT && !glState.stencilEnabled )
|
||||
// continue;
|
||||
|
||||
R_DecalSurface( surf, decalinfo );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -708,7 +707,6 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
float dist;
|
||||
mnode_t *children[2];
|
||||
|
||||
Assert( node != NULL );
|
||||
|
||||
@@ -720,7 +718,6 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
|
||||
splitplane = node->plane;
|
||||
dist = DotProduct( decalinfo->m_Position, splitplane->normal ) - splitplane->dist;
|
||||
node_children( children, node, model );
|
||||
|
||||
// This is arbitrarily set to 10 right now. In an ideal world we'd have the
|
||||
// exact surface but we don't so, this tells me which planes are "sort of
|
||||
@@ -732,19 +729,19 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
// have a surface normal
|
||||
if( dist > decalinfo->m_Size )
|
||||
{
|
||||
R_DecalNode( model, children[0], decalinfo );
|
||||
R_DecalNode( model, node->children[0], decalinfo );
|
||||
}
|
||||
else if( dist < -decalinfo->m_Size )
|
||||
{
|
||||
R_DecalNode( model, children[1], decalinfo );
|
||||
R_DecalNode( model, node->children[1], decalinfo );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dist < DECAL_DISTANCE && dist > -DECAL_DISTANCE )
|
||||
R_DecalNodeSurfaces( model, node, decalinfo );
|
||||
|
||||
R_DecalNode( model, children[0], decalinfo );
|
||||
R_DecalNode( model, children[1], decalinfo );
|
||||
R_DecalNode( model, node->children[0], decalinfo );
|
||||
R_DecalNode( model, node->children[1], decalinfo );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,50 +104,44 @@ R_MarkLights
|
||||
*/
|
||||
void R_MarkLights( dlight_t *light, int bit, mnode_t *node )
|
||||
{
|
||||
float dist;
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
mnode_t *children[2];
|
||||
int firstsurface, numsurfaces;
|
||||
float dist;
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
|
||||
if( !node || node->contents < 0 )
|
||||
return;
|
||||
|
||||
dist = PlaneDiff( light->origin, node->plane );
|
||||
|
||||
node_children( children, node, RI.currentmodel );
|
||||
firstsurface = node_firstsurface( node, RI.currentmodel );
|
||||
numsurfaces = node_numsurfaces( node, RI.currentmodel );
|
||||
|
||||
if( dist > light->radius )
|
||||
{
|
||||
R_MarkLights( light, bit, children[0] );
|
||||
R_MarkLights( light, bit, node->children[0] );
|
||||
return;
|
||||
}
|
||||
if( dist < -light->radius )
|
||||
{
|
||||
R_MarkLights( light, bit, children[1] );
|
||||
R_MarkLights( light, bit, node->children[1] );
|
||||
return;
|
||||
}
|
||||
|
||||
// mark the polygons
|
||||
surf = RI.currentmodel->surfaces + firstsurface;
|
||||
surf = RI.currentmodel->surfaces + node->firstsurface;
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, surf++ )
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
if( !BoundsAndSphereIntersect( surf->info->mins, surf->info->maxs, light->origin, light->radius ))
|
||||
continue; // no intersection
|
||||
continue; // no intersection
|
||||
|
||||
if( surf->dlightframe != tr.dlightframecount )
|
||||
if( surf->dlightframe != tr.framecount ) // tr.dlightframecount )
|
||||
{
|
||||
surf->dlightbits = 0;
|
||||
surf->dlightframe = tr.dlightframecount;
|
||||
surf->dlightframe = tr.framecount; // tr.dlightframecount;
|
||||
}
|
||||
surf->dlightbits |= bit;
|
||||
}
|
||||
|
||||
R_MarkLights( light, bit, children[0] );
|
||||
R_MarkLights( light, bit, children[1] );
|
||||
R_MarkLights( light, bit, node->children[0] );
|
||||
R_MarkLights( light, bit, node->children[1] );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -211,8 +205,6 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
mtexinfo_t *tex;
|
||||
matrix3x4 tbn;
|
||||
vec3_t mid;
|
||||
mnode_t *children[2];
|
||||
int firstsurface, numsurfaces;
|
||||
|
||||
// didn't hit anything
|
||||
if( !node || node->contents < 0 )
|
||||
@@ -221,17 +213,13 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
return false;
|
||||
}
|
||||
|
||||
node_children( children, node, model );
|
||||
firstsurface = node_firstsurface( node, model );
|
||||
numsurfaces = node_numsurfaces( node, model );
|
||||
|
||||
// calculate mid point
|
||||
front = PlaneDiff( start, node->plane );
|
||||
back = PlaneDiff( end, node->plane );
|
||||
|
||||
side = front < 0;
|
||||
if(( back < 0 ) == side )
|
||||
return R_RecursiveLightPoint( model, children[side], p1f, p2f, cv, start, end );
|
||||
return R_RecursiveLightPoint( model, node->children[side], p1f, p2f, cv, start, end );
|
||||
|
||||
frac = front / ( front - back );
|
||||
|
||||
@@ -239,7 +227,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
midf = p1f + ( p2f - p1f ) * frac;
|
||||
|
||||
// co down front side
|
||||
if( R_RecursiveLightPoint( model, children[side], p1f, midf, cv, start, mid ))
|
||||
if( R_RecursiveLightPoint( model, node->children[side], p1f, midf, cv, start, mid ))
|
||||
return true; // hit something
|
||||
|
||||
if(( back < 0 ) == side )
|
||||
@@ -249,10 +237,10 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
}
|
||||
|
||||
// check for impact on this node
|
||||
surf = model->surfaces + firstsurface;
|
||||
surf = model->surfaces + node->firstsurface;
|
||||
VectorCopy( mid, g_trace_lightspot );
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, surf++ )
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
int smax, tmax;
|
||||
|
||||
@@ -342,7 +330,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
||||
}
|
||||
|
||||
// go down back side
|
||||
return R_RecursiveLightPoint( model, children[!side], midf, p2f, cv, mid, end );
|
||||
return R_RecursiveLightPoint( model, node->children[!side], midf, p2f, cv, mid, end );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -933,7 +933,7 @@ typedef struct edge_s
|
||||
unsigned short surfs[2];
|
||||
struct edge_s *nextremove;
|
||||
float nearzi;
|
||||
medge16_t *owner;
|
||||
medge_t *owner;
|
||||
} edge_t;
|
||||
|
||||
|
||||
|
||||
@@ -524,7 +524,6 @@ watertexture to grab fog values from it
|
||||
static image_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mnode_t *ignore, qboolean down )
|
||||
{
|
||||
image_t *tex = NULL;
|
||||
mnode_t *children[2];
|
||||
|
||||
// assure the initial node is not null
|
||||
// we could check it here, but we would rather check it
|
||||
@@ -562,18 +561,18 @@ static image_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mnode_t
|
||||
|
||||
// this is a regular node
|
||||
// traverse children
|
||||
node_children( children, node, WORLDMODEL );
|
||||
|
||||
if( children[0] && ( children[0] != ignore ))
|
||||
if( node->children[0] && ( node->children[0] != ignore ))
|
||||
{
|
||||
tex = R_RecursiveFindWaterTexture( children[0], node, true );
|
||||
if( tex ) return tex;
|
||||
tex = R_RecursiveFindWaterTexture( node->children[0], node, true );
|
||||
if( tex )
|
||||
return tex;
|
||||
}
|
||||
|
||||
if( children[1] && ( children[1] != ignore ))
|
||||
if( node->children[1] && ( node->children[1] != ignore ))
|
||||
{
|
||||
tex = R_RecursiveFindWaterTexture( children[1], node, true );
|
||||
if( tex ) return tex;
|
||||
tex = R_RecursiveFindWaterTexture( node->children[1], node, true );
|
||||
if( tex )
|
||||
return tex;
|
||||
}
|
||||
|
||||
// for down recursion, return immediately
|
||||
@@ -797,9 +796,9 @@ static mnode_t *R_FindTopnode( vec3_t mins, vec3_t maxs )
|
||||
|
||||
// not split yet; recurse down the contacted side
|
||||
if( sides & 1 )
|
||||
node = node_child( node, 0, WORLDMODEL );
|
||||
node = node->children[0];
|
||||
else
|
||||
node = node_child( node, 1, WORLDMODEL );
|
||||
node = node->children[1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1393,12 +1392,6 @@ void GAME_EXPORT R_NewMap( void )
|
||||
R_ClearDecals(); // clear all level decals
|
||||
R_StudioResetPlayerModels();
|
||||
|
||||
if( FBitSet( world->flags, MODEL_QBSP2 ))
|
||||
{
|
||||
gEngfuncs.Host_Error( "Sorry, ref_soft can't load maps in BSP2 format.\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
r_cnumsurfs = sw_maxsurfs.value;
|
||||
|
||||
if( r_cnumsurfs <= MINSURFACES )
|
||||
|
||||
@@ -37,7 +37,7 @@ int c_faceclip; // numbe
|
||||
clipplane_t *entity_clipplanes;
|
||||
clipplane_t world_clipplanes[16];
|
||||
|
||||
medge16_t *r_pedge;
|
||||
medge_t *r_pedge;
|
||||
|
||||
qboolean r_leftclipped, r_rightclipped;
|
||||
static qboolean makeleftedge, makerightedge;
|
||||
@@ -68,7 +68,7 @@ msurface_t *r_skyfaces;
|
||||
mplane_t r_skyplanes[6];
|
||||
mtexinfo_t r_skytexinfo[6];
|
||||
mvertex_t *r_skyverts;
|
||||
medge16_t *r_skyedges;
|
||||
medge_t *r_skyedges;
|
||||
int *r_skysurfedges;
|
||||
|
||||
// I just copied this data from a box map...
|
||||
@@ -438,7 +438,7 @@ void R_RenderFace( msurface_t *fa, int clipflags )
|
||||
mplane_t *pplane;
|
||||
float distinv;
|
||||
vec3_t p_normal;
|
||||
medge16_t *pedges, tedge;
|
||||
medge_t *pedges, tedge;
|
||||
clipplane_t *pclip;
|
||||
|
||||
// translucent surfaces are not drawn by the edge renderer
|
||||
@@ -490,7 +490,7 @@ void R_RenderFace( msurface_t *fa, int clipflags )
|
||||
r_nearzi = 0;
|
||||
r_nearzionly = false;
|
||||
makeleftedge = makerightedge = false;
|
||||
pedges = RI.currentmodel->edges16;
|
||||
pedges = RI.currentmodel->edges;
|
||||
r_lastvertvalid = false;
|
||||
|
||||
for( i = 0; i < fa->numedges; i++ )
|
||||
@@ -560,7 +560,7 @@ void R_RenderFace( msurface_t *fa, int clipflags )
|
||||
else
|
||||
{
|
||||
// it's cached if the cached edge is valid and is owned
|
||||
// by this medge16_t
|
||||
// by this medge_t
|
||||
if((((uintptr_t)edge_p - (uintptr_t)r_edges )
|
||||
> r_pedge->cachededgeoffset )
|
||||
&& (((edge_t *)((uintptr_t)r_edges
|
||||
@@ -651,7 +651,7 @@ void R_RenderBmodelFace( bedge_t *pedges, msurface_t *psurf )
|
||||
mplane_t *pplane;
|
||||
float distinv;
|
||||
vec3_t p_normal;
|
||||
medge16_t tedge;
|
||||
medge_t tedge;
|
||||
clipplane_t *pclip;
|
||||
|
||||
/*if (psurf->texinfo->flags & (SURF_TRANS33|SURF_TRANS66))
|
||||
|
||||
@@ -8,7 +8,7 @@ pushd hlsdk || die
|
||||
./waf configure build install --destdir=../bin || die
|
||||
popd
|
||||
|
||||
./waf configure --enable-utils --enable-tests --enable-lto --enable-wafcache build --zones=wafcache install --destdir=bin || die_configure
|
||||
./waf configure --enable-utils --enable-tests --enable-lto build install --destdir=bin || die_configure
|
||||
|
||||
cp -vr /Library/Frameworks/SDL2.framework bin
|
||||
|
||||
|
||||
@@ -61,14 +61,14 @@ build_engine()
|
||||
fi
|
||||
|
||||
if [ "$1" = "dedicated" ]; then
|
||||
./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -d --enable-wafcache || die_configure
|
||||
./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -d || die_configure
|
||||
elif [ "$1" = "full" ]; then
|
||||
./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -s SDL2_linux --enable-stb --enable-utils --enable-wafcache || die_configure
|
||||
./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -s SDL2_linux --enable-stb --enable-utils || die_configure
|
||||
else
|
||||
die
|
||||
fi
|
||||
|
||||
./waf build --zones=wafcache || die_configure
|
||||
./waf build || die_configure
|
||||
}
|
||||
|
||||
deploy_engine()
|
||||
|
||||
@@ -12,7 +12,7 @@ pushd hlsdk || die
|
||||
./waf configure -T fast --enable-magx --enable-simple-mod-hacks build install --destdir=../Xash || die
|
||||
popd
|
||||
|
||||
./waf configure -T fast --enable-magx --enable-wafcache build install --destdir=Xash/ || die
|
||||
./waf configure -T fast --enable-magx build install --destdir=Xash/ || die
|
||||
|
||||
cat > Xash/run.sh << 'EOF'
|
||||
mypath=${0%/*}
|
||||
|
||||
@@ -11,7 +11,7 @@ mkdir -p artifacts/ || die
|
||||
|
||||
echo "Running build script in Docker container..."
|
||||
|
||||
docker run --name xash-build --rm -v `pwd`:`pwd` -v $HOME/.cache:$HOME/.cache -w `pwd` devkitpro/devkita64:latest bash ./scripts/gha/build_nswitch_docker.sh || die
|
||||
docker run --name xash-build --rm -v `pwd`:`pwd` -w `pwd` devkitpro/devkita64:latest bash ./scripts/gha/build_nswitch_docker.sh || die
|
||||
|
||||
echo "Packaging artifacts..."
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ make -C libsolder install || die
|
||||
|
||||
echo "Building engine..."
|
||||
|
||||
./waf configure -T release --nswitch --enable-wafcache || die_configure
|
||||
./waf configure -T release --nswitch || die_configure
|
||||
./waf build install --destdir=pkgtemp/xash3d -v || die
|
||||
|
||||
echo "Building HLSDK..."
|
||||
|
||||
@@ -44,8 +44,8 @@ popd
|
||||
|
||||
echo "Building engine..."
|
||||
|
||||
./waf configure -T release --psvita --enable-wafcache || die_configure
|
||||
./waf build install --destdir=pkgtemp/data/xash3d || die
|
||||
./waf configure -T release --psvita || die_configure
|
||||
./waf build install --destdir=pkgtemp/data/xash3d -v || die
|
||||
cp build/engine/xash.vpk pkgtemp/
|
||||
|
||||
echo "Building HLSDK..."
|
||||
|
||||
@@ -11,9 +11,8 @@ fi
|
||||
|
||||
# NOTE: to build with other version use --msvc_version during configuration
|
||||
# NOTE: sometimes you may need to add WinSDK to %PATH%
|
||||
# NOTE: --enable-msvcdeps only used for CI builds, enabling it non-English versions of MSVC causes useless console spam
|
||||
./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto --enable-msvcdeps --enable-wafcache $AMD64 || die_configure
|
||||
./waf.bat build --zones=wafcache || die
|
||||
./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto $AMD64 || die_configure
|
||||
./waf.bat build || die
|
||||
./waf.bat install --destdir=. || die
|
||||
|
||||
if [ "$ARCH" = "i386" ]; then
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
cd $GITHUB_WORKSPACE
|
||||
|
||||
wget https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION.dmg -O SDL2.dmg
|
||||
wget http://libsdl.org/release/SDL2-$SDL_VERSION.dmg -O SDL2.dmg
|
||||
hdiutil mount SDL2.dmg
|
||||
sudo cp -vr /Volumes/SDL2/SDL2.framework /Library/Frameworks
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
curl -L https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-devel-$SDL_VERSION-VC.zip -o SDL2.zip
|
||||
curl http://libsdl.org/release/SDL2-devel-$SDL_VERSION-VC.zip -o SDL2.zip
|
||||
unzip -q SDL2.zip
|
||||
mv SDL2-$SDL_VERSION SDL2_VC
|
||||
|
||||
22
wscript
22
wscript
@@ -91,7 +91,7 @@ SUBDIRS = [
|
||||
Subproject('3rdparty/gl-wes-v2', lambda x: not x.env.DEDICATED and x.env.GLWES),
|
||||
Subproject('3rdparty/gl4es', lambda x: not x.env.DEDICATED and x.env.GL4ES),
|
||||
Subproject('ref/gl', lambda x: not x.env.DEDICATED and (x.env.GL or x.env.NANOGL or x.env.GLWES or x.env.GL4ES)),
|
||||
Subproject('ref/soft', lambda x: not x.env.DEDICATED and x.env.SOFT),
|
||||
Subproject('ref/soft', lambda x: not x.env.DEDICATED and not x.env.SUPPORT_BSP2_FORMAT and x.env.SOFT),
|
||||
Subproject('ref/null', lambda x: not x.env.DEDICATED and x.env.NULL),
|
||||
Subproject('3rdparty/bzip2', lambda x: not x.env.DEDICATED and not x.env.HAVE_SYSTEM_BZ2),
|
||||
Subproject('3rdparty/opus', lambda x: not x.env.DEDICATED and not x.env.HAVE_SYSTEM_OPUS),
|
||||
@@ -128,9 +128,6 @@ REFDLLS = [
|
||||
def options(opt):
|
||||
opt.load('reconfigure compiler_optimizations xshlib xcompile compiler_cxx compiler_c sdl2 clang_compilation_database strip_on_install waf_unit_test msdev msvs subproject cmake')
|
||||
|
||||
opt.add_option('--enable-wafcache', action = 'store_false', dest = 'enable_gccdeps', default = True,
|
||||
help = 'enable usage of wafcache tool, disables gccdeps')
|
||||
|
||||
grp = opt.add_option_group('Common options')
|
||||
|
||||
grp.add_option('-d', '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False,
|
||||
@@ -151,6 +148,9 @@ def options(opt):
|
||||
grp.add_option('--enable-bundled-deps', action = 'store_true', dest = 'BUILD_BUNDLED_DEPS', default = False,
|
||||
help = 'prefer to build bundled dependencies (like opus) instead of relying on system provided')
|
||||
|
||||
grp.add_option('--enable-bsp2', action = 'store_true', dest = 'SUPPORT_BSP2_FORMAT', default = False,
|
||||
help = 'build engine and renderers with BSP2 map support(recommended for Quake, breaks compatibility!) [default: %(default)s]')
|
||||
|
||||
grp.add_option('--enable-hl25-extended-structs', action = 'store_true', dest = 'SUPPORT_HL25_EXTENDED_STRUCTS', default = False,
|
||||
help = 'build engine and renderers with HL25 extended structs compatibility (might be required for some mods) [default: %(default)s]')
|
||||
|
||||
@@ -165,7 +165,6 @@ def options(opt):
|
||||
|
||||
# a1ba: special option for me
|
||||
grp.add_option('--debug-all-servers', action='store_true', dest='ALL_SERVERS', default=False, help='')
|
||||
grp.add_option('--enable-msvcdeps', action='store_true', dest='MSVCDEPS', default=False, help='')
|
||||
|
||||
grp = opt.add_option_group('Renderers options')
|
||||
|
||||
@@ -204,12 +203,6 @@ def configure(conf):
|
||||
# Load compilers early
|
||||
conf.load('xshlib xcompile compiler_c compiler_cxx gccdeps')
|
||||
|
||||
if conf.options.MSVCDEPS:
|
||||
conf.load('msvcdeps')
|
||||
|
||||
if not conf.options.enable_gccdeps:
|
||||
conf.env.ENABLE_WAFCACHE = True
|
||||
|
||||
if conf.options.NSWITCH:
|
||||
conf.load('nswitch')
|
||||
|
||||
@@ -223,7 +216,7 @@ def configure(conf):
|
||||
if conf.env.COMPILER_CC == 'msvc':
|
||||
conf.load('msvc_pdb')
|
||||
|
||||
conf.load('msvs msdev subproject clang_compilation_database strip_on_install waf_unit_test enforce_pic force_32bit')
|
||||
conf.load('msvs msdev subproject clang_compilation_database strip_on_install waf_unit_test enforce_pic cmake force_32bit')
|
||||
|
||||
if conf.env.MSVC_TARGETS[0] == 'amd64_x86' or conf.env.MSVC_TARGETS[0] == 'x86':
|
||||
conf.env.MSVC_SUBSYSTEM = 'WINDOWS,5.01'
|
||||
@@ -402,7 +395,9 @@ def configure(conf):
|
||||
conf.env.ENABLE_XAR = conf.options.ENABLE_XAR
|
||||
conf.env.ENABLE_FUZZER = conf.options.ENABLE_FUZZER
|
||||
conf.env.DEDICATED = conf.options.DEDICATED
|
||||
conf.env.SUPPORT_BSP2_FORMAT = conf.options.SUPPORT_BSP2_FORMAT
|
||||
|
||||
conf.define_cond('SUPPORT_BSP2_FORMAT', conf.options.SUPPORT_BSP2_FORMAT)
|
||||
conf.define_cond('SUPPORT_HL25_EXTENDED_STRUCTS', conf.options.SUPPORT_HL25_EXTENDED_STRUCTS)
|
||||
|
||||
# disable game_launch compiling on platform where it's not needed
|
||||
@@ -509,9 +504,6 @@ int main(void) { return (int)BZ2_bzlibVersion(); }'''
|
||||
conf.add_subproject(i.name)
|
||||
|
||||
def build(bld):
|
||||
if bld.env.ENABLE_WAFCACHE:
|
||||
bld.load('wafcache')
|
||||
|
||||
# guard rails to not let install to root
|
||||
if bld.is_install and not bld.options.PACKAGING and not bld.options.destdir:
|
||||
bld.fatal('Set the install destination directory using --destdir option')
|
||||
|
||||
Reference in New Issue
Block a user