mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-08 21:31:46 +08:00
Compare commits
54 Commits
continuous
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef0fc46ed8 | ||
|
|
138b4fa247 | ||
|
|
47d1f3459c | ||
|
|
4712aae834 | ||
|
|
2900ee1cde | ||
|
|
c6c4178dd2 | ||
|
|
a3ce0e6b1b | ||
|
|
0b1ad3b7f0 | ||
|
|
37fb46f092 | ||
|
|
bc8bf9a9fb | ||
|
|
9e28c98911 | ||
|
|
0a1269d52d | ||
|
|
2e5bc31c9e | ||
|
|
1b335fd945 | ||
|
|
0c8b2d007a | ||
|
|
9ee1b32e2d | ||
|
|
953ad98a16 | ||
|
|
1357057bd8 | ||
|
|
35c9323de6 | ||
|
|
13a0afef06 | ||
|
|
c7ad8e4bf6 | ||
|
|
f1754bdd5f | ||
|
|
c462a1c500 | ||
|
|
0bba184994 | ||
|
|
178602ea1f | ||
|
|
2eb8f88a20 | ||
|
|
96d11df06c | ||
|
|
950d210ec5 | ||
|
|
55c1bddac5 | ||
|
|
ac50c762d7 | ||
|
|
5c2ab150b3 | ||
|
|
0870536405 | ||
|
|
b47ede477a | ||
|
|
eef5cc17b3 | ||
|
|
ad2191333d | ||
|
|
a85cac497d | ||
|
|
e0c69d7df5 | ||
|
|
ff3d91ceb4 | ||
|
|
5777431577 | ||
|
|
cd86f80203 | ||
|
|
8c885d3f37 | ||
|
|
dddb46a6d0 | ||
|
|
6b0f378c5b | ||
|
|
9dd7f37d42 | ||
|
|
9f10fb6472 | ||
|
|
64dbccb9bd | ||
|
|
9a432a5a13 | ||
|
|
842e494fa6 | ||
|
|
7fc9ee154a | ||
|
|
5f84010c2a | ||
|
|
3dcd6cb80b | ||
|
|
79e94bf766 | ||
|
|
3de370f3d5 | ||
|
|
c84d2f4624 |
2
.github/workflows/c-cpp.yml
vendored
2
.github/workflows/c-cpp.yml
vendored
@@ -60,6 +60,8 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bash scripts/gha/deps_${{ matrix.targetos }}.sh
|
run: bash scripts/gha/deps_${{ matrix.targetos }}.sh
|
||||||
- name: Build engine
|
- name: Build engine
|
||||||
|
env:
|
||||||
|
FWGS_PFX_PASSWORD: ${{ secrets.FWGS_PFX_PASSWORD }}
|
||||||
run: bash scripts/gha/build_${{ matrix.targetos }}.sh
|
run: bash scripts/gha/build_${{ matrix.targetos }}.sh
|
||||||
- name: Upload engine (artifacts)
|
- name: Upload engine (artifacts)
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: ad333f6152...b7edbaf2de
@@ -14,3 +14,4 @@ When `-bugcomp` is specified with argument, it interpreted as flags separated wi
|
|||||||
| ------- | ----------- | ---------------------------- |
|
| ------- | ----------- | ---------------------------- |
|
||||||
| `peoei` | Reverts `pfnPEntityOfEntIndex` behavior to GoldSrc, where it returns NULL for last player due to incorrect player index comparison | * Counter-Strike: Condition Zero - Deleted Scenes |
|
| `peoei` | Reverts `pfnPEntityOfEntIndex` behavior to GoldSrc, where it returns NULL for last player due to incorrect player index comparison | * Counter-Strike: Condition Zero - Deleted Scenes |
|
||||||
| `gsmrf` | Rewrites message at the moment when Game DLL attempts to write an internal engine message, usually specific to GoldSrc protocol. Right now only supports `svc_spawnstaticsound`, more messages added by request. | * MetaMod/AMXModX based mods |
|
| `gsmrf` | Rewrites message at the moment when Game DLL attempts to write an internal engine message, usually specific to GoldSrc protocol. Right now only supports `svc_spawnstaticsound`, more messages added by request. | * MetaMod/AMXModX based mods |
|
||||||
|
| `sp_attn_none` | Makes sounds with attenuation zero spatialized, i.e. have a stereo effect. | Possibly, every game that was made for GoldSrc. |
|
||||||
|
|||||||
@@ -543,14 +543,8 @@ typedef struct
|
|||||||
#define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client)
|
#define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client)
|
||||||
#define MAX_REQUESTS 64
|
#define MAX_REQUESTS 64
|
||||||
|
|
||||||
#if ! XASH_64BIT
|
STATIC_CHECK_SIZEOF( mextrasurf_t, 324, 496 );
|
||||||
STATIC_ASSERT( sizeof( mextrasurf_t ) == 324, "mextrasurf_t unexpected size" );
|
STATIC_CHECK_SIZEOF( decal_t, 60, 88 );
|
||||||
STATIC_ASSERT( sizeof( decal_t ) == 60, "decal_t unexpected size");
|
STATIC_CHECK_SIZEOF( mfaceinfo_t, 176, 304 );
|
||||||
STATIC_ASSERT( sizeof( mfaceinfo_t ) == 176, "mfaceinfo_t unexpected size");
|
|
||||||
#else
|
|
||||||
STATIC_ASSERT( sizeof( mextrasurf_t) == 496, "mextrasurf_t unexpected size");
|
|
||||||
STATIC_ASSERT( sizeof( decal_t ) == 88, "decal_t unexpected size");
|
|
||||||
STATIC_ASSERT( sizeof( mfaceinfo_t ) == 304, "mfaceinfo_t unexpected size");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//COM_MODEL_H
|
#endif//COM_MODEL_H
|
||||||
|
|||||||
159
common/cvardef.h
159
common/cvardef.h
@@ -1,49 +1,122 @@
|
|||||||
/***
|
/*
|
||||||
*
|
cvardef.h - quake cvar definition
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
Copyright (C) 1997-2001 Id Software, Inc.
|
||||||
*
|
Copyright (C) 2024 Alibek Omarov
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
#ifndef CVARDEF_H
|
|
||||||
#define CVARDEF_H
|
|
||||||
|
|
||||||
#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc
|
This program is free software; you can redistribute it and/or
|
||||||
#define FCVAR_USERINFO (1<<1) // changes the client's info string
|
modify it under the terms of the GNU General Public License
|
||||||
#define FCVAR_SERVER (1<<2) // notifies players when changed
|
as published by the Free Software Foundation; either version 2
|
||||||
#define FCVAR_EXTDLL (1<<3) // defined by external DLL
|
of the License, or (at your option) any later version.
|
||||||
#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll
|
|
||||||
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
|
|
||||||
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
|
|
||||||
#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
|
|
||||||
#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
|
|
||||||
#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar
|
|
||||||
#define FCVAR_PRIVILEGED (1<<10) // only available in privileged mode
|
|
||||||
#define FCVAR_FILTERABLE (1<<11) // filtered in unprivileged mode if cl_filterstuffcmd is 1
|
|
||||||
|
|
||||||
// Xash3D extensions
|
This program is distributed in the hope that it will be useful,
|
||||||
#define FCVAR_GLCONFIG (1<<12) // write it into <renderer>.cfg(see RefAPI)
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
#define FCVAR_CHANGED (1<<13) // set each time the cvar is changed
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
#define FCVAR_GAMEUIDLL (1<<14) // defined by the menu DLL
|
|
||||||
#define FCVAR_CHEAT (1<<15) // can not be changed if cheats are disabled
|
|
||||||
|
|
||||||
// a1ba: let's reuse higher bits for flags extensions from now on
|
See the GNU General Public License for more details.
|
||||||
#define FCVAR_LATCH (1<<30) // notify client what this cvar will be applied only after server restart (but don't does more nothing)
|
|
||||||
|
|
||||||
typedef struct cvar_s
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
#ifndef CVAR
|
||||||
|
#define CVAR
|
||||||
|
|
||||||
|
#include STDINT_H
|
||||||
|
#include "xash3d_types.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
cvar_t variables are used to hold scalar or string variables that can be changed
|
||||||
|
or displayed at the console or prog code as well as accessed directly
|
||||||
|
in C code.
|
||||||
|
|
||||||
|
The user can access cvars from the console in three ways:
|
||||||
|
r_draworder prints the current value
|
||||||
|
r_draworder 0 sets the current value to 0
|
||||||
|
set r_draworder 0 as above, but creates the cvar if not present
|
||||||
|
|
||||||
|
Cvars are restricted from having the same names as commands to keep this
|
||||||
|
interface from being ambiguous.
|
||||||
|
|
||||||
|
The are also occasionally used to communicated information between different
|
||||||
|
modules of the program.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum
|
||||||
{
|
{
|
||||||
char *name;
|
// GoldSrc compatibility flags
|
||||||
char *string;
|
FCVAR_ARCHIVE = 1 << 0, // set to cause it to be saved to vars.rc
|
||||||
int flags;
|
FCVAR_USERINFO = 1 << 1, // added to userinfo when changed
|
||||||
float value;
|
FCVAR_SERVER = 1 << 2, // added to serverinfo when changed, will notify clients by default
|
||||||
struct cvar_s *next;
|
FCVAR_EXTDLL = 1 << 3, // defined by server.dll
|
||||||
} cvar_t;
|
FCVAR_CLIENTDLL = 1 << 4, // defined by client.dll
|
||||||
|
FCVAR_PROTECTED = 1 << 5, // private server cvar
|
||||||
|
FCVAR_SPONLY = 1 << 6, // can be set only in singleplayer
|
||||||
|
FCVAR_PRINTABLEONLY = 1 << 7, // only allows printable characters
|
||||||
|
FCVAR_UNLOGGED = 1 << 8, // disables notifying client about server cvar change
|
||||||
|
FCVAR_NOEXTRAWHITESPACE = 1 << 9, // removes space characters from the beginning and the end of the string
|
||||||
|
FCVAR_PRIVILEGED = 1 << 10, // only available in privileged mode
|
||||||
|
FCVAR_FILTERABLE = 1 << 11, // treated as privileged if cl_filterstuffcmd is 1, otherwise ignored
|
||||||
|
|
||||||
#endif//CVARDEF_H
|
// Xash3D public flags
|
||||||
|
// FCVAR_LATCH = 1 << 11, // deprecated Xash3D flag, conflicts with FCVAR_FILTERABLE. Use another FCVAR_LATCH!
|
||||||
|
FCVAR_GLCONFIG = 1 << 12, // set to cause it to be saved to <renderer>.cfg (see RefAPI)
|
||||||
|
FCVAR_CHANGED = 1 << 13, // set each time the cvar changed
|
||||||
|
FCVAR_GAMEUIDLL = 1 << 14, // defined by menu.dll
|
||||||
|
FCVAR_CHEAT = 1 << 15, // cannot be changed if sv_cheats is 0
|
||||||
|
|
||||||
|
#if REF_DLL || ENGINE_DLL // Xash3D internal flags, MUST NOT be used outside of engine
|
||||||
|
FCVAR_RENDERINFO = 1 << 16, // set to cause it to be saved to video.cfg
|
||||||
|
FCVAR_READ_ONLY = 1 << 17, // display only, cannot be set by user at all
|
||||||
|
FCVAR_EXTENDED = 1 << 18, // extended cvar structure
|
||||||
|
FCVAR_ALLOCATED = 1 << 19, // allocated by the engine, must be freed with Mem_Free
|
||||||
|
FCVAR_VIDRESTART = 1 << 20, // triggers video subsystem to recreate/modify window parameters
|
||||||
|
FCVAR_TEMPORARY = 1 << 21, // only used to temporarly hold some value, can be unlinked
|
||||||
|
FCVAR_MOVEVARS = 1 << 22, // access to movevars_t structure, synchornized between client and server
|
||||||
|
FCVAR_USER_CREATED = 1 << 23, // created by a set command
|
||||||
|
|
||||||
|
FCVAR_REFDLL = 1 << 29, // (Xash3D FWGS internal flag) defined by the renderer DLL
|
||||||
|
#endif // REF_DLL || ENGINE_DLL
|
||||||
|
|
||||||
|
FCVAR_LATCH = 1 << 30, // (Xash3D FWGS public flag, was FCVAR_FILTERABLE in Xash3D) save changes until server restart
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cvar_s {
|
||||||
|
char *name;
|
||||||
|
char *string;
|
||||||
|
uint32_t flags;
|
||||||
|
float value;
|
||||||
|
struct cvar_s *next;
|
||||||
|
};
|
||||||
|
typedef struct cvar_s cvar_t;
|
||||||
|
|
||||||
|
STATIC_CHECK_SIZEOF( struct cvar_s, 20, 32 );
|
||||||
|
|
||||||
|
#if REF_DLL || ENGINE_DLL // Xash3D internal cvar format, MUST NOT be used outside of engine
|
||||||
|
struct convar_s {
|
||||||
|
char *name;
|
||||||
|
char *string;
|
||||||
|
uint32_t flags;
|
||||||
|
float value;
|
||||||
|
struct convar_s *next;
|
||||||
|
char *desc;
|
||||||
|
char *def_string;
|
||||||
|
};
|
||||||
|
typedef struct convar_s convar_t;
|
||||||
|
|
||||||
|
#if XASH_64BIT
|
||||||
|
#define CVAR_SENTINEL (uintptr_t)0xDEADBEEFDEADBEEF
|
||||||
|
#else
|
||||||
|
#define CVAR_SENTINEL (uintptr_t)0xDEADBEEF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CVAR_CHECK_SENTINEL( cv ) ((uintptr_t)(cv)->next == CVAR_SENTINEL)
|
||||||
|
|
||||||
|
#define CVAR_DEFINE( cv, cvname, cvstr, cvflags, cvdesc ) \
|
||||||
|
convar_t cv = { (char*)cvname, (char*)cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, (char*)cvdesc, NULL }
|
||||||
|
|
||||||
|
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) CVAR_DEFINE( cv, #cv, cvstr, cvflags, cvdesc )
|
||||||
|
#endif // REF_DLL || ENGINE_DLL
|
||||||
|
|
||||||
|
#endif // CVAR
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ typedef struct
|
|||||||
int state; // low bit is down state
|
int state; // low bit is down state
|
||||||
} kbutton_t;
|
} kbutton_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( kbutton_t ) == 12, "kbutton_t isn't 12 bytes!" );
|
STATIC_CHECK_SIZEOF( kbutton_t, 12, 12 );
|
||||||
|
|
||||||
#endif // KBUTTON_H
|
#endif // KBUTTON_H
|
||||||
|
|||||||
@@ -69,6 +69,6 @@ typedef struct netadr_s
|
|||||||
} netadr_t;
|
} netadr_t;
|
||||||
#pragma pack( pop )
|
#pragma pack( pop )
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( netadr_t ) == 20, "netadr_t isn't 20 bytes!" );
|
STATIC_CHECK_SIZEOF( netadr_t, 20, 20 );
|
||||||
|
|
||||||
#endif // NET_ADR_H
|
#endif // NET_ADR_H
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ color24 gTracerColors[] =
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define TRACER_COLORINDEX_DEFAULT 4
|
||||||
|
|
||||||
// Temporary entity array
|
// Temporary entity array
|
||||||
#define TENTPRIORITY_LOW 0
|
#define TENTPRIORITY_LOW 0
|
||||||
#define TENTPRIORITY_HIGH 1
|
#define TENTPRIORITY_HIGH 1
|
||||||
|
|||||||
@@ -79,11 +79,22 @@ typedef uint64_t longtime_t;
|
|||||||
#define GAME_EXPORT
|
#define GAME_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MALLOC __attribute__(( malloc ))
|
||||||
|
|
||||||
|
// added in GCC 11
|
||||||
|
#if __GNUC__ >= 11
|
||||||
|
// might want to set noclone due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116893
|
||||||
|
// but it's easier to not force mismatched-dealloc to error yet
|
||||||
|
#define MALLOC_LIKE( x, y ) __attribute__(( malloc( x, y )))
|
||||||
|
#else
|
||||||
|
#define MALLOC_LIKE( x, y ) MALLOC
|
||||||
|
#endif
|
||||||
#define NORETURN __attribute__(( noreturn ))
|
#define NORETURN __attribute__(( noreturn ))
|
||||||
#define NONNULL __attribute__(( nonnull ))
|
#define NONNULL __attribute__(( nonnull ))
|
||||||
#define _format( x ) __attribute__(( format( printf, x, x + 1 )))
|
#define _format( x ) __attribute__(( format( printf, x, x + 1 )))
|
||||||
#define ALLOC_CHECK( x ) __attribute__(( alloc_size( x )))
|
#define ALLOC_CHECK( x ) __attribute__(( alloc_size( x )))
|
||||||
#define NO_ASAN __attribute__(( no_sanitize( "address" )))
|
#define NO_ASAN __attribute__(( no_sanitize( "address" )))
|
||||||
|
#define WARN_UNUSED_RESULT __attribute__(( warn_unused_result ))
|
||||||
#define RENAME_SYMBOL( x ) asm( x )
|
#define RENAME_SYMBOL( x ) asm( x )
|
||||||
#else
|
#else
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
@@ -99,6 +110,9 @@ typedef uint64_t longtime_t;
|
|||||||
#define _format( x )
|
#define _format( x )
|
||||||
#define ALLOC_CHECK( x )
|
#define ALLOC_CHECK( x )
|
||||||
#define RENAME_SYMBOL( x )
|
#define RENAME_SYMBOL( x )
|
||||||
|
#define MALLOC
|
||||||
|
#define MALLOC_LIKE( x, y )
|
||||||
|
#define WARN_UNUSED_RESULT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __GNUC__ >= 3
|
#if __GNUC__ >= 3
|
||||||
@@ -130,6 +144,15 @@ typedef uint64_t longtime_t;
|
|||||||
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_2( __LINE__, x, y )
|
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_2( __LINE__, x, y )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// at least, statically check size of some public structures
|
||||||
|
#if XASH_64BIT
|
||||||
|
#define STATIC_CHECK_SIZEOF( type, size32, size64 ) \
|
||||||
|
STATIC_ASSERT( sizeof( type ) == size64, #type " unexpected size" )
|
||||||
|
#else
|
||||||
|
#define STATIC_CHECK_SIZEOF( type, size32, size64 ) \
|
||||||
|
STATIC_ASSERT( sizeof( type ) == size32, #type " unexpected size" )
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined( __cplusplus ) && __STDC_VERSION__ >= 199101L // not C++ and C99 or newer
|
#if !defined( __cplusplus ) && __STDC_VERSION__ >= 199101L // not C++ and C99 or newer
|
||||||
#define XASH_RESTRICT restrict
|
#define XASH_RESTRICT restrict
|
||||||
#elif _MSC_VER || __GNUC__ || __clang__ // compiler-specific extensions
|
#elif _MSC_VER || __GNUC__ || __clang__ // compiler-specific extensions
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ typedef struct
|
|||||||
float size;
|
float size;
|
||||||
} daliashdr_t;
|
} daliashdr_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( daliashdr_t ) == 84, "invalid daliashdr_t size" );
|
STATIC_CHECK_SIZEOF( daliashdr_t, 84, 84 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,7 @@ typedef struct
|
|||||||
int32_t t;
|
int32_t t;
|
||||||
} stvert_t;
|
} stvert_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( stvert_t ) == 12, "invalid stvert_t size" );
|
STATIC_CHECK_SIZEOF( stvert_t, 12, 12 );
|
||||||
|
|
||||||
typedef struct dtriangle_s
|
typedef struct dtriangle_s
|
||||||
{
|
{
|
||||||
@@ -91,7 +91,7 @@ typedef struct dtriangle_s
|
|||||||
int32_t vertindex[3];
|
int32_t vertindex[3];
|
||||||
} dtriangle_t;
|
} dtriangle_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( dtriangle_t ) == 16, "invalid dtriangle_t size" );
|
STATIC_CHECK_SIZEOF( dtriangle_t, 16, 16 );
|
||||||
|
|
||||||
#define DT_FACES_FRONT 0x0010
|
#define DT_FACES_FRONT 0x0010
|
||||||
#define ALIAS_ONSEAM 0x0020
|
#define ALIAS_ONSEAM 0x0020
|
||||||
@@ -103,7 +103,7 @@ typedef struct
|
|||||||
char name[16]; // frame name from grabbing
|
char name[16]; // frame name from grabbing
|
||||||
} daliasframe_t;
|
} daliasframe_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( daliasframe_t ) == 24, "invalid daliasframe_t size" );
|
STATIC_CHECK_SIZEOF( daliasframe_t, 24, 24 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -112,41 +112,41 @@ typedef struct
|
|||||||
trivertex_t bboxmax; // lightnormal isn't used
|
trivertex_t bboxmax; // lightnormal isn't used
|
||||||
} daliasgroup_t;
|
} daliasgroup_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( daliasgroup_t ) == 12, "invalid daliasgrou_t size" );
|
STATIC_CHECK_SIZEOF( daliasgroup_t, 12, 12 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int32_t numskins;
|
int32_t numskins;
|
||||||
} daliasskingroup_t;
|
} daliasskingroup_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( daliasskingroup_t ) == 4, "invalid daliasskingroup_t size" );
|
STATIC_CHECK_SIZEOF( daliasskingroup_t, 4, 4 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float interval;
|
float interval;
|
||||||
} daliasinterval_t;
|
} daliasinterval_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( daliasinterval_t ) == 4, "invalid daliasinterval_t size" );
|
STATIC_CHECK_SIZEOF( daliasinterval_t, 4, 4 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float interval;
|
float interval;
|
||||||
} daliasskininterval_t;
|
} daliasskininterval_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( daliasskininterval_t ) == 4, "invalid daliasskininterval_t size" );
|
STATIC_CHECK_SIZEOF( daliasskininterval_t, 4, 4 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t type; // was aliasframetype_t
|
uint32_t type; // was aliasframetype_t
|
||||||
} daliasframetype_t;
|
} daliasframetype_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( daliasframetype_t ) == 4, "invalid daliasframetype_t size" );
|
STATIC_CHECK_SIZEOF( daliasframetype_t, 4, 4 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t type; // was aliasskintype_t
|
uint32_t type; // was aliasskintype_t
|
||||||
} daliasskintype_t;
|
} daliasskintype_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( daliasskintype_t ) == 4, "invalid daliasskintype_t size" );
|
STATIC_CHECK_SIZEOF( daliasskintype_t, 4, 4 );
|
||||||
|
|
||||||
#endif//ALIAS_H
|
#endif//ALIAS_H
|
||||||
|
|||||||
@@ -274,6 +274,13 @@ void CL_GenericShot_f( void )
|
|||||||
string checkname;
|
string checkname;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
// allow overriding screenshot by users request
|
||||||
|
if( Cmd_Argc() > 1 )
|
||||||
|
{
|
||||||
|
Q_strncpy( cls.shotname, Cmd_Argv( 1 ), sizeof( cls.shotname ));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if( type == scrshot_snapshot )
|
if( type == scrshot_snapshot )
|
||||||
{
|
{
|
||||||
fmt = "../%s_%04d.png";
|
fmt = "../%s_%04d.png";
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ static particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life
|
|||||||
VectorCopy( vel, p->vel );
|
VectorCopy( vel, p->vel );
|
||||||
p->die = cl.time + life;
|
p->die = cl.time + life;
|
||||||
p->ramp = tracerlength.value;
|
p->ramp = tracerlength.value;
|
||||||
p->color = 4; // select custom color
|
p->color = TRACER_COLORINDEX_DEFAULT; // select custom color
|
||||||
p->packedColor = 255; // alpha
|
p->packedColor = 255; // alpha
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
@@ -388,7 +388,6 @@ void CL_ParseStaticDecal( sizebuf_t *msg )
|
|||||||
{
|
{
|
||||||
vec3_t origin;
|
vec3_t origin;
|
||||||
int decalIndex, entityIndex, modelIndex;
|
int decalIndex, entityIndex, modelIndex;
|
||||||
cl_entity_t *ent = NULL;
|
|
||||||
float scale;
|
float scale;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
@@ -1181,17 +1180,16 @@ CL_ParseBaseline
|
|||||||
*/
|
*/
|
||||||
void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
|
void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
|
||||||
{
|
{
|
||||||
int i, newnum;
|
const entity_state_t nullstate = { 0 };
|
||||||
entity_state_t nullstate;
|
|
||||||
qboolean player;
|
|
||||||
cl_entity_t *ent;
|
|
||||||
|
|
||||||
Delta_InitClient (); // finalize client delta's
|
Delta_InitClient (); // finalize client delta's
|
||||||
|
|
||||||
memset( &nullstate, 0, sizeof( nullstate ));
|
|
||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
|
cl_entity_t *ent;
|
||||||
|
qboolean player;
|
||||||
|
int newnum;
|
||||||
|
|
||||||
if( legacy )
|
if( legacy )
|
||||||
{
|
{
|
||||||
newnum = MSG_ReadWord( msg );
|
newnum = MSG_ReadWord( msg );
|
||||||
@@ -1207,10 +1205,10 @@ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
|
|||||||
Host_Error( "%s: no free edicts\n", __func__ );
|
Host_Error( "%s: no free edicts\n", __func__ );
|
||||||
|
|
||||||
ent = CL_EDICT_NUM( newnum );
|
ent = CL_EDICT_NUM( newnum );
|
||||||
memset( &ent->prevstate, 0, sizeof( ent->prevstate ));
|
ent->prevstate = nullstate;
|
||||||
ent->index = newnum;
|
ent->index = newnum;
|
||||||
|
|
||||||
MSG_ReadDeltaEntity( msg, &ent->prevstate, &ent->baseline, newnum, player, 1.0f );
|
MSG_ReadDeltaEntity( msg, &nullstate, &ent->baseline, newnum, player, 1.0f );
|
||||||
|
|
||||||
if( legacy )
|
if( legacy )
|
||||||
{
|
{
|
||||||
@@ -1220,11 +1218,13 @@ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
|
|||||||
|
|
||||||
if( !legacy )
|
if( !legacy )
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
cl.instanced_baseline_count = MSG_ReadUBitLong( msg, 6 );
|
cl.instanced_baseline_count = MSG_ReadUBitLong( msg, 6 );
|
||||||
|
|
||||||
for( i = 0; i < cl.instanced_baseline_count; i++ )
|
for( i = 0; i < cl.instanced_baseline_count; i++ )
|
||||||
{
|
{
|
||||||
newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
|
int newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
|
||||||
MSG_ReadDeltaEntity( msg, &nullstate, &cl.instanced_baseline[i], newnum, false, 1.0f );
|
MSG_ReadDeltaEntity( msg, &nullstate, &cl.instanced_baseline[i], newnum, false, 1.0f );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1269,6 +1269,73 @@ void GAME_EXPORT R_Sprite_Smoke( TEMPENTITY *pTemp, float scale )
|
|||||||
pTemp->entity.curstate.scale = scale;
|
pTemp->entity.curstate.scale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void R_Spray_Generic( const char *func, const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int spread, int rendermode, qboolean sprite_spray )
|
||||||
|
{
|
||||||
|
model_t *mod = CL_ModelHandle( modelIndex );
|
||||||
|
float noise = spread / 100.0f;
|
||||||
|
float znoise = noise * 1.5f;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
znoise = Q_min( 1.0f, znoise );
|
||||||
|
|
||||||
|
if( !mod )
|
||||||
|
{
|
||||||
|
Con_Reportf( "%s: No model %d!\n", func, modelIndex );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
TEMPENTITY *tent = CL_TempEntAlloc( pos, mod );
|
||||||
|
float rand_speed;
|
||||||
|
vec3_t noise_vec, vout;
|
||||||
|
|
||||||
|
if( !tent )
|
||||||
|
break;
|
||||||
|
|
||||||
|
tent->flags |= FTENT_SLOWGRAVITY;
|
||||||
|
tent->entity.curstate.rendermode = rendermode;
|
||||||
|
tent->entity.curstate.renderamt = 255;
|
||||||
|
tent->entity.baseline.renderamt = 255;
|
||||||
|
tent->entity.curstate.renderfx = kRenderFxNoDissipation;
|
||||||
|
|
||||||
|
noise_vec[0] = COM_RandomFloat( -noise, noise );
|
||||||
|
noise_vec[1] = COM_RandomFloat( -noise, noise );
|
||||||
|
noise_vec[2] = COM_RandomFloat( 0.0f, znoise );
|
||||||
|
rand_speed = COM_RandomFloat( speed * 0.8f, speed * 1.2f );
|
||||||
|
|
||||||
|
VectorAdd( dir, noise_vec, vout );
|
||||||
|
VectorScale( vout, rand_speed, tent->entity.baseline.origin );
|
||||||
|
|
||||||
|
if( sprite_spray ) // if TE_SPRITE_SPRAY
|
||||||
|
{
|
||||||
|
tent->flags |= FTENT_FADEOUT;
|
||||||
|
tent->fadeSpeed = 2.0f;
|
||||||
|
|
||||||
|
tent->entity.curstate.framerate = 0.5f;
|
||||||
|
tent->die = cl.time + 0.35;
|
||||||
|
tent->entity.curstate.frame = COM_RandomLong( 0, tent->frameMax ); // frameMax inclusive
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tent->flags |= FTENT_COLLIDEWORLD;
|
||||||
|
|
||||||
|
if( tent->frameMax > 1 )
|
||||||
|
{
|
||||||
|
tent->flags |= FTENT_SPRANIMATE;
|
||||||
|
tent->entity.curstate.framerate = 10.0f;
|
||||||
|
tent->die = cl.time + tent->frameMax * 0.1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tent->entity.curstate.framerate = 1.0f;
|
||||||
|
tent->die = cl.time + 0.35;
|
||||||
|
}
|
||||||
|
tent->entity.curstate.frame = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
R_Spray
|
R_Spray
|
||||||
@@ -1278,61 +1345,7 @@ Throws a shower of sprites or models
|
|||||||
*/
|
*/
|
||||||
void GAME_EXPORT R_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int spread, int rendermode )
|
void GAME_EXPORT R_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int spread, int rendermode )
|
||||||
{
|
{
|
||||||
TEMPENTITY *pTemp;
|
R_Spray_Generic( __func__, pos, dir, modelIndex, count, speed, spread, rendermode, false );
|
||||||
float noise;
|
|
||||||
float znoise;
|
|
||||||
model_t *pmodel;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if(( pmodel = CL_ModelHandle( modelIndex )) == NULL )
|
|
||||||
{
|
|
||||||
Con_Reportf( "No model %d!\n", modelIndex );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
noise = (float)spread / 100.0f;
|
|
||||||
|
|
||||||
// more vertical displacement
|
|
||||||
znoise = Q_min( 1.0f, noise * 1.5f );
|
|
||||||
|
|
||||||
for( i = 0; i < count; i++ )
|
|
||||||
{
|
|
||||||
pTemp = CL_TempEntAlloc( pos, pmodel );
|
|
||||||
if( !pTemp ) return;
|
|
||||||
|
|
||||||
pTemp->entity.curstate.rendermode = rendermode;
|
|
||||||
pTemp->entity.baseline.renderamt = pTemp->entity.curstate.renderamt = 255;
|
|
||||||
pTemp->entity.curstate.renderfx = kRenderFxNoDissipation;
|
|
||||||
|
|
||||||
if( rendermode != kRenderGlow )
|
|
||||||
{
|
|
||||||
// spray
|
|
||||||
pTemp->flags |= FTENT_COLLIDEWORLD | FTENT_SLOWGRAVITY;
|
|
||||||
|
|
||||||
if( pTemp->frameMax > 1 )
|
|
||||||
{
|
|
||||||
pTemp->flags |= FTENT_COLLIDEWORLD | FTENT_SLOWGRAVITY | FTENT_SPRANIMATE;
|
|
||||||
pTemp->die = cl.time + (pTemp->frameMax * 0.1f);
|
|
||||||
pTemp->entity.curstate.framerate = 10;
|
|
||||||
}
|
|
||||||
else pTemp->die = cl.time + 0.35f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// sprite spray
|
|
||||||
pTemp->entity.curstate.frame = COM_RandomLong( 0, pTemp->frameMax );
|
|
||||||
pTemp->flags |= FTENT_FADEOUT | FTENT_SLOWGRAVITY;
|
|
||||||
pTemp->entity.curstate.framerate = 0.5;
|
|
||||||
pTemp->die = cl.time + 0.35f;
|
|
||||||
pTemp->fadeSpeed = 2.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make the spittle fly the direction indicated, but mix in some noise.
|
|
||||||
pTemp->entity.baseline.origin[0] = dir[0] + COM_RandomFloat( -noise, noise );
|
|
||||||
pTemp->entity.baseline.origin[1] = dir[1] + COM_RandomFloat( -noise, noise );
|
|
||||||
pTemp->entity.baseline.origin[2] = dir[2] + COM_RandomFloat( 0, znoise );
|
|
||||||
VectorScale( pTemp->entity.baseline.origin, COM_RandomFloat(( speed * 0.8f ), ( speed * 1.2f )), pTemp->entity.baseline.origin );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1344,7 +1357,7 @@ Spray of alpha sprites
|
|||||||
*/
|
*/
|
||||||
void GAME_EXPORT R_Sprite_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int spread )
|
void GAME_EXPORT R_Sprite_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int spread )
|
||||||
{
|
{
|
||||||
R_Spray( pos, dir, modelIndex, count, speed, spread, kRenderGlow );
|
R_Spray_Generic( __func__, pos, dir, modelIndex, count, speed, spread, kRenderTransAlpha, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3113,4 +3126,3 @@ void CL_ClearEffects( void )
|
|||||||
CL_ClearParticles ();
|
CL_ClearParticles ();
|
||||||
CL_ClearLightStyles ();
|
CL_ClearLightStyles ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,22 @@ static intptr_t pfnEngineGetParm( int parm, int arg )
|
|||||||
return CL_RenderGetParm( parm, arg, false ); // prevent recursion
|
return CL_RenderGetParm( parm, arg, false ); // prevent recursion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cvar_t *pfnCvar_Get( const char *szName, const char *szValue, int flags, const char *description )
|
||||||
|
{
|
||||||
|
return (cvar_t *)Cvar_Get( szName, szValue, flags | FCVAR_REFDLL, description );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pfnCvar_RegisterVariable( convar_t *var )
|
||||||
|
{
|
||||||
|
SetBits( var->flags, FCVAR_REFDLL );
|
||||||
|
Cvar_RegisterVariable( var );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pfnCvar_FullSet( const char *var_name, const char *value, int flags )
|
||||||
|
{
|
||||||
|
Cvar_FullSet( var_name, value, flags | FCVAR_REFDLL );
|
||||||
|
}
|
||||||
|
|
||||||
static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
|
static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
|
||||||
{
|
{
|
||||||
clgame.dllFuncs.pfnStudioEvent( event, e );
|
clgame.dllFuncs.pfnStudioEvent( event, e );
|
||||||
@@ -289,14 +305,14 @@ static const ref_api_t gEngfuncs =
|
|||||||
{
|
{
|
||||||
pfnEngineGetParm,
|
pfnEngineGetParm,
|
||||||
|
|
||||||
(void*)Cvar_Get,
|
pfnCvar_Get,
|
||||||
(void*)Cvar_FindVarExt,
|
(void*)Cvar_FindVarExt,
|
||||||
Cvar_VariableValue,
|
Cvar_VariableValue,
|
||||||
Cvar_VariableString,
|
Cvar_VariableString,
|
||||||
Cvar_SetValue,
|
Cvar_SetValue,
|
||||||
Cvar_Set,
|
Cvar_Set,
|
||||||
Cvar_RegisterVariable,
|
pfnCvar_RegisterVariable,
|
||||||
Cvar_FullSet,
|
pfnCvar_FullSet,
|
||||||
|
|
||||||
Cmd_AddRefCommand,
|
Cmd_AddRefCommand,
|
||||||
Cmd_RemoveCommand,
|
Cmd_RemoveCommand,
|
||||||
@@ -431,7 +447,7 @@ static void R_UnloadProgs( void )
|
|||||||
|
|
||||||
Cvar_FullSet( "host_refloaded", "0", FCVAR_READ_ONLY );
|
Cvar_FullSet( "host_refloaded", "0", FCVAR_READ_ONLY );
|
||||||
|
|
||||||
Cvar_Unlink( FCVAR_RENDERINFO | FCVAR_GLCONFIG );
|
Cvar_Unlink( FCVAR_RENDERINFO | FCVAR_GLCONFIG | FCVAR_REFDLL );
|
||||||
Cmd_Unlink( CMD_REFDLL );
|
Cmd_Unlink( CMD_REFDLL );
|
||||||
|
|
||||||
COM_FreeLibrary( ref.hInstance );
|
COM_FreeLibrary( ref.hInstance );
|
||||||
@@ -473,7 +489,7 @@ static qboolean R_LoadProgs( const char *name )
|
|||||||
if( ref.hInstance ) R_UnloadProgs();
|
if( ref.hInstance ) R_UnloadProgs();
|
||||||
|
|
||||||
FS_AllowDirectPaths( true );
|
FS_AllowDirectPaths( true );
|
||||||
if( !(ref.hInstance = COM_LoadLibrary( name, false, true ) ))
|
if( !( ref.hInstance = COM_LoadLibrary( name, false, true )))
|
||||||
{
|
{
|
||||||
FS_AllowDirectPaths( false );
|
FS_AllowDirectPaths( false );
|
||||||
Con_Reportf( "%s: can't load renderer library %s: %s\n", __func__, name, COM_GetLibraryError() );
|
Con_Reportf( "%s: can't load renderer library %s: %s\n", __func__, name, COM_GetLibraryError() );
|
||||||
@@ -482,11 +498,9 @@ static qboolean R_LoadProgs( const char *name )
|
|||||||
|
|
||||||
FS_AllowDirectPaths( false );
|
FS_AllowDirectPaths( false );
|
||||||
|
|
||||||
if( !( GetRefAPI = (REFAPI)COM_GetProcAddress( ref.hInstance, GET_REF_API )) )
|
if( !( GetRefAPI = (REFAPI)COM_GetProcAddress( ref.hInstance, GET_REF_API )))
|
||||||
{
|
{
|
||||||
COM_FreeLibrary( ref.hInstance );
|
|
||||||
Con_Reportf( "%s: can't find GetRefAPI entry point in %s\n", __func__, name );
|
Con_Reportf( "%s: can't find GetRefAPI entry point in %s\n", __func__, name );
|
||||||
ref.hInstance = NULL;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,19 +509,15 @@ static qboolean R_LoadProgs( const char *name )
|
|||||||
|
|
||||||
if( GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ) != REF_API_VERSION )
|
if( GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ) != REF_API_VERSION )
|
||||||
{
|
{
|
||||||
COM_FreeLibrary( ref.hInstance );
|
|
||||||
Con_Reportf( "%s: can't init renderer API: wrong version\n", __func__ );
|
Con_Reportf( "%s: can't init renderer API: wrong version\n", __func__ );
|
||||||
ref.hInstance = NULL;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
refState.developer = host_developer.value;
|
refState.developer = host_developer.value;
|
||||||
|
|
||||||
if( !ref.dllFuncs.R_Init( ) )
|
if( !ref.dllFuncs.R_Init( ))
|
||||||
{
|
{
|
||||||
COM_FreeLibrary( ref.hInstance );
|
|
||||||
Con_Reportf( "%s: can't init renderer!\n", __func__ ); //, ref.dllFuncs.R_GetInitError() );
|
Con_Reportf( "%s: can't init renderer!\n", __func__ ); //, ref.dllFuncs.R_GetInitError() );
|
||||||
ref.hInstance = NULL;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,9 +644,6 @@ static void R_CollectRendererNames( void )
|
|||||||
#endif
|
#endif
|
||||||
#if XASH_REF_SOFT_ENABLED
|
#if XASH_REF_SOFT_ENABLED
|
||||||
"soft",
|
"soft",
|
||||||
#endif
|
|
||||||
#if XASH_REF_NULL_ENABLED
|
|
||||||
"null",
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -660,9 +667,6 @@ static void R_CollectRendererNames( void )
|
|||||||
#endif
|
#endif
|
||||||
#if XASH_REF_SOFT_ENABLED
|
#if XASH_REF_SOFT_ENABLED
|
||||||
"Software",
|
"Software",
|
||||||
#endif
|
|
||||||
#if XASH_REF_NULL_ENABLED
|
|
||||||
"Null Renderer",
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -674,7 +678,8 @@ static void R_CollectRendererNames( void )
|
|||||||
qboolean R_Init( void )
|
qboolean R_Init( void )
|
||||||
{
|
{
|
||||||
qboolean success = false;
|
qboolean success = false;
|
||||||
string requested;
|
string requested_cmdline;
|
||||||
|
string requested_cvar;
|
||||||
|
|
||||||
Cvar_RegisterVariable( &gl_vsync );
|
Cvar_RegisterVariable( &gl_vsync );
|
||||||
Cvar_RegisterVariable( &r_showtextures );
|
Cvar_RegisterVariable( &r_showtextures );
|
||||||
@@ -724,15 +729,16 @@ qboolean R_Init( void )
|
|||||||
// 1. Command line `-ref` argument.
|
// 1. Command line `-ref` argument.
|
||||||
// 2. `ref_dll` cvar.
|
// 2. `ref_dll` cvar.
|
||||||
// 3. Detected renderers in `DEFAULT_RENDERERS` order.
|
// 3. Detected renderers in `DEFAULT_RENDERERS` order.
|
||||||
requested[0] = 0;
|
requested_cmdline[0] = 0;
|
||||||
|
requested_cvar[0] = 0;
|
||||||
|
|
||||||
if( !success && Sys_GetParmFromCmdLine( "-ref", requested ))
|
if( Sys_GetParmFromCmdLine( "-ref", requested_cmdline ))
|
||||||
success = R_LoadRenderer( requested );
|
success = R_LoadRenderer( requested_cmdline );
|
||||||
|
|
||||||
if( !success && COM_CheckString( r_refdll.string ))
|
if( !success && COM_CheckString( r_refdll.string ) && Q_stricmp( requested_cmdline, r_refdll.string ))
|
||||||
{
|
{
|
||||||
Q_strncpy( requested, r_refdll.string, sizeof( requested ));
|
Q_strncpy( requested_cvar, r_refdll.string, sizeof( requested_cvar ));
|
||||||
success = R_LoadRenderer( requested );
|
success = R_LoadRenderer( requested_cvar );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !success )
|
if( !success )
|
||||||
@@ -742,7 +748,10 @@ qboolean R_Init( void )
|
|||||||
for( i = 0; i < ref.numRenderers && !success; i++ )
|
for( i = 0; i < ref.numRenderers && !success; i++ )
|
||||||
{
|
{
|
||||||
// skip renderer that was requested but failed to load
|
// skip renderer that was requested but failed to load
|
||||||
if( !Q_strcmp( requested, ref.shortNames[i] ))
|
if( !Q_strcmp( requested_cmdline, ref.shortNames[i] ))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( !Q_strcmp( requested_cvar, ref.shortNames[i] ))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
success = R_LoadRenderer( ref.shortNames[i] );
|
success = R_LoadRenderer( ref.shortNames[i] );
|
||||||
@@ -751,7 +760,7 @@ qboolean R_Init( void )
|
|||||||
|
|
||||||
if( !success )
|
if( !success )
|
||||||
{
|
{
|
||||||
Host_Error( "Can't initialize any renderer. Check your video drivers!\n" );
|
Sys_Error( "Can't initialize any renderer. Check your video drivers!\n" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -524,8 +524,11 @@ static void SND_Spatialize( channel_t *ch )
|
|||||||
dist = VectorNormalizeLength( source_vec );
|
dist = VectorNormalizeLength( source_vec );
|
||||||
dot = DotProduct( s_listener.right, source_vec );
|
dot = DotProduct( s_listener.right, source_vec );
|
||||||
|
|
||||||
// don't pan sounds with no attenuation
|
if( !FBitSet( host.bugcomp, BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE ))
|
||||||
if( ch->dist_mult <= 0.0f ) dot = 0.0f;
|
{
|
||||||
|
// don't pan sounds with no attenuation
|
||||||
|
if( ch->dist_mult <= 0.0f ) dot = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// fill out channel volumes for single location
|
// fill out channel volumes for single location
|
||||||
S_SpatializeChannel( &ch->leftvol, &ch->rightvol, ch->master_vol, gain, dot, dist * ch->dist_mult );
|
S_SpatializeChannel( &ch->leftvol, &ch->rightvol, ch->master_vol, gain, dot, dist * ch->dist_mult );
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ static void Cmd_Echo_f( void )
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for( i = 1; i < Cmd_Argc(); i++ )
|
for( i = 1; i < Cmd_Argc(); i++ )
|
||||||
Con_Printf( "%s", Cmd_Argv( i ));
|
Con_Printf( "%s ", Cmd_Argv( i ));
|
||||||
Con_Printf( "\n" );
|
Con_Printf( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ typedef enum
|
|||||||
#include "con_nprint.h"
|
#include "con_nprint.h"
|
||||||
#include "crclib.h"
|
#include "crclib.h"
|
||||||
#include "ref_api.h"
|
#include "ref_api.h"
|
||||||
|
#define FSCALLBACK_OVERRIDE_OPEN
|
||||||
|
#define FSCALLBACK_OVERRIDE_LOADFILE
|
||||||
|
#define FSCALLBACK_OVERRIDE_MALLOC_LIKE
|
||||||
#include "fscallback.h"
|
#include "fscallback.h"
|
||||||
|
|
||||||
// PERFORMANCE INFO
|
// PERFORMANCE INFO
|
||||||
@@ -273,6 +276,9 @@ typedef enum bugcomp_e
|
|||||||
// rewrites mod's attempts to write GoldSrc-specific messages into Xash protocol
|
// rewrites mod's attempts to write GoldSrc-specific messages into Xash protocol
|
||||||
// (new wrappers are added by request)
|
// (new wrappers are added by request)
|
||||||
BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG = BIT( 1 ),
|
BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG = BIT( 1 ),
|
||||||
|
|
||||||
|
// makes sound with no attenuation spatialized, like in GoldSrc
|
||||||
|
BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE = BIT( 2 ),
|
||||||
} bugcomp_t;
|
} bugcomp_t;
|
||||||
|
|
||||||
typedef struct host_parm_s
|
typedef struct host_parm_s
|
||||||
@@ -359,12 +365,49 @@ extern host_parm_t host;
|
|||||||
|
|
||||||
typedef void (*xcommand_t)( void );
|
typedef void (*xcommand_t)( void );
|
||||||
|
|
||||||
|
//
|
||||||
|
// zone.c
|
||||||
|
//
|
||||||
|
void Memory_Init( void );
|
||||||
|
void _Mem_Free( void *data, const char *filename, int fileline );
|
||||||
|
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
ALLOC_CHECK( 3 ) WARN_UNUSED_RESULT;
|
||||||
|
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
ALLOC_CHECK( 2 ) MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline )
|
||||||
|
WARN_UNUSED_RESULT;
|
||||||
|
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||||
|
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
|
||||||
|
void _Mem_Check( const char *filename, int fileline );
|
||||||
|
qboolean Mem_IsAllocatedExt( poolhandle_t poolptr, void *data );
|
||||||
|
void Mem_PrintList( size_t minallocationsize );
|
||||||
|
void Mem_PrintStats( void );
|
||||||
|
|
||||||
|
#define Mem_Malloc( pool, size ) _Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
||||||
|
#define Mem_Calloc( pool, size ) _Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
||||||
|
#define Mem_Realloc( pool, ptr, size ) _Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
||||||
|
#define Mem_Free( mem ) _Mem_Free( mem, __FILE__, __LINE__ )
|
||||||
|
#define Mem_AllocPool( name ) _Mem_AllocPool( name, __FILE__, __LINE__ )
|
||||||
|
#define Mem_FreePool( pool ) _Mem_FreePool( pool, __FILE__, __LINE__ )
|
||||||
|
#define Mem_EmptyPool( pool ) _Mem_EmptyPool( pool, __FILE__, __LINE__ )
|
||||||
|
#define Mem_IsAllocated( mem ) Mem_IsAllocatedExt( NULL, mem )
|
||||||
|
#define Mem_Check() _Mem_Check( __FILE__, __LINE__ )
|
||||||
|
|
||||||
//
|
//
|
||||||
// filesystem_engine.c
|
// filesystem_engine.c
|
||||||
//
|
//
|
||||||
void FS_Init( const char *basedir );
|
void FS_Init( const char *basedir );
|
||||||
void FS_Shutdown( void );
|
void FS_Shutdown( void );
|
||||||
void *FS_GetNativeObject( const char *obj );
|
void *FS_GetNativeObject( const char *obj );
|
||||||
|
int FS_Close( file_t *file );
|
||||||
|
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||||
|
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly )
|
||||||
|
MALLOC_LIKE( FS_Close, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
||||||
|
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr )
|
||||||
|
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
//
|
//
|
||||||
// cmd.c
|
// cmd.c
|
||||||
@@ -397,30 +440,6 @@ void Cmd_ExecuteString( const char *text );
|
|||||||
void Cmd_ForwardToServer( void );
|
void Cmd_ForwardToServer( void );
|
||||||
void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
|
void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
|
||||||
|
|
||||||
//
|
|
||||||
// zone.c
|
|
||||||
//
|
|
||||||
void Memory_Init( void );
|
|
||||||
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
|
|
||||||
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
|
|
||||||
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline );
|
|
||||||
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
|
|
||||||
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
|
|
||||||
void _Mem_Free( void *data, const char *filename, int fileline );
|
|
||||||
void _Mem_Check( const char *filename, int fileline );
|
|
||||||
qboolean Mem_IsAllocatedExt( poolhandle_t poolptr, void *data );
|
|
||||||
void Mem_PrintList( size_t minallocationsize );
|
|
||||||
void Mem_PrintStats( void );
|
|
||||||
|
|
||||||
#define Mem_Malloc( pool, size ) _Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
|
||||||
#define Mem_Calloc( pool, size ) _Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
|
||||||
#define Mem_Realloc( pool, ptr, size ) _Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
|
||||||
#define Mem_Free( mem ) _Mem_Free( mem, __FILE__, __LINE__ )
|
|
||||||
#define Mem_AllocPool( name ) _Mem_AllocPool( name, __FILE__, __LINE__ )
|
|
||||||
#define Mem_FreePool( pool ) _Mem_FreePool( pool, __FILE__, __LINE__ )
|
|
||||||
#define Mem_EmptyPool( pool ) _Mem_EmptyPool( pool, __FILE__, __LINE__ )
|
|
||||||
#define Mem_IsAllocated( mem ) Mem_IsAllocatedExt( NULL, mem )
|
|
||||||
#define Mem_Check() _Mem_Check( __FILE__, __LINE__ )
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// imagelib
|
// imagelib
|
||||||
@@ -431,10 +450,10 @@ void Image_Setup( void );
|
|||||||
void Image_Init( void );
|
void Image_Init( void );
|
||||||
void Image_Shutdown( void );
|
void Image_Shutdown( void );
|
||||||
void Image_AddCmdFlags( uint flags );
|
void Image_AddCmdFlags( uint flags );
|
||||||
rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size );
|
|
||||||
qboolean FS_SaveImage( const char *filename, rgbdata_t *pix );
|
|
||||||
rgbdata_t *FS_CopyImage( rgbdata_t *in );
|
|
||||||
void FS_FreeImage( rgbdata_t *pack );
|
void FS_FreeImage( rgbdata_t *pack );
|
||||||
|
rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size ) MALLOC_LIKE( FS_FreeImage, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
qboolean FS_SaveImage( const char *filename, rgbdata_t *pix );
|
||||||
|
rgbdata_t *FS_CopyImage( rgbdata_t *in ) MALLOC_LIKE( FS_FreeImage, 1 ) WARN_UNUSED_RESULT;
|
||||||
extern const bpc_desc_t PFDesc[]; // image get pixelformat
|
extern const bpc_desc_t PFDesc[]; // image get pixelformat
|
||||||
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float reserved );
|
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float reserved );
|
||||||
void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int pal_size );
|
void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int pal_size );
|
||||||
@@ -489,14 +508,14 @@ typedef struct
|
|||||||
//
|
//
|
||||||
void Sound_Init( void );
|
void Sound_Init( void );
|
||||||
void Sound_Shutdown( void );
|
void Sound_Shutdown( void );
|
||||||
wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size );
|
|
||||||
void FS_FreeSound( wavdata_t *pack );
|
void FS_FreeSound( wavdata_t *pack );
|
||||||
stream_t *FS_OpenStream( const char *filename );
|
void FS_FreeStream( stream_t *stream );
|
||||||
|
wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size ) MALLOC_LIKE( FS_FreeSound, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
stream_t *FS_OpenStream( const char *filename ) MALLOC_LIKE( FS_FreeStream, 1 ) WARN_UNUSED_RESULT;
|
||||||
wavdata_t *FS_StreamInfo( stream_t *stream );
|
wavdata_t *FS_StreamInfo( stream_t *stream );
|
||||||
int FS_ReadStream( stream_t *stream, int bytes, void *buffer );
|
int FS_ReadStream( stream_t *stream, int bytes, void *buffer );
|
||||||
int FS_SetStreamPos( stream_t *stream, int newpos );
|
int FS_SetStreamPos( stream_t *stream, int newpos );
|
||||||
int FS_GetStreamPos( stream_t *stream );
|
int FS_GetStreamPos( stream_t *stream );
|
||||||
void FS_FreeStream( stream_t *stream );
|
|
||||||
qboolean Sound_Process( wavdata_t **wav, int rate, int width, int channels, uint flags );
|
qboolean Sound_Process( wavdata_t **wav, int rate, int width, int channels, uint flags );
|
||||||
uint Sound_GetApproxWavePlayLen( const char *filepath );
|
uint Sound_GetApproxWavePlayLen( const char *filepath );
|
||||||
qboolean Sound_SupportedFileFormat( const char *fileext );
|
qboolean Sound_SupportedFileFormat( const char *fileext );
|
||||||
@@ -561,7 +580,7 @@ qboolean SV_Active( void );
|
|||||||
char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize );
|
char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize );
|
||||||
void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput );
|
void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput );
|
||||||
int COM_SaveFile( const char *filename, const void *data, int len );
|
int COM_SaveFile( const char *filename, const void *data, int len );
|
||||||
byte* COM_LoadFileForMe( const char *filename, int *pLength );
|
byte *COM_LoadFileForMe( const char *filename, int *pLength ) MALLOC_LIKE( free, 1 );
|
||||||
qboolean COM_IsSafeFileToDownload( const char *filename );
|
qboolean COM_IsSafeFileToDownload( const char *filename );
|
||||||
cvar_t *pfnCVarGetPointer( const char *szVarName );
|
cvar_t *pfnCVarGetPointer( const char *szVarName );
|
||||||
int pfnDrawConsoleString( int x, int y, char *string );
|
int pfnDrawConsoleString( int x, int y, char *string );
|
||||||
@@ -664,7 +683,7 @@ char *CL_Userinfo( void );
|
|||||||
void CL_LegacyUpdateInfo( void );
|
void CL_LegacyUpdateInfo( void );
|
||||||
void CL_CharEvent( int key );
|
void CL_CharEvent( int key );
|
||||||
qboolean CL_DisableVisibility( void );
|
qboolean CL_DisableVisibility( void );
|
||||||
byte *COM_LoadFile( const char *filename, int usehunk, int *pLength );
|
byte *COM_LoadFile( const char *filename, int usehunk, int *pLength ) MALLOC_LIKE( free, 1 );
|
||||||
struct cmd_s *Cmd_GetFirstFunctionHandle( void );
|
struct cmd_s *Cmd_GetFirstFunctionHandle( void );
|
||||||
struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd );
|
struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd );
|
||||||
struct cmdalias_s *Cmd_AliasGetList( void );
|
struct cmdalias_s *Cmd_AliasGetList( void );
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ static const char *Cvar_ValidateString( convar_t *var, const char *value )
|
|||||||
if( !COM_CheckStringEmpty( szNew ) ) Q_strncpy( szNew, "empty", sizeof( szNew ));
|
if( !COM_CheckStringEmpty( szNew ) ) Q_strncpy( szNew, "empty", sizeof( szNew ));
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FBitSet( var->flags, FCVAR_NOEXTRAWHITEPACE ))
|
if( FBitSet( var->flags, FCVAR_NOEXTRAWHITESPACE ))
|
||||||
{
|
{
|
||||||
char *szVal = szNew;
|
char *szVal = szNew;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|||||||
@@ -18,45 +18,6 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
#include "cvardef.h"
|
#include "cvardef.h"
|
||||||
|
|
||||||
#ifdef XASH_64BIT
|
|
||||||
#define CVAR_SENTINEL 0xDEADBEEFDEADBEEF
|
|
||||||
#else
|
|
||||||
#define CVAR_SENTINEL 0xDEADBEEF
|
|
||||||
#endif
|
|
||||||
#define CVAR_CHECK_SENTINEL( cv ) ((uintptr_t)(cv)->next == CVAR_SENTINEL)
|
|
||||||
|
|
||||||
// NOTE: if this is changed, it must be changed in cvardef.h too
|
|
||||||
typedef struct convar_s
|
|
||||||
{
|
|
||||||
// this part shared with cvar_t
|
|
||||||
char *name;
|
|
||||||
char *string;
|
|
||||||
int flags;
|
|
||||||
float value;
|
|
||||||
struct convar_s *next;
|
|
||||||
|
|
||||||
// this part unique for convar_t
|
|
||||||
char *desc; // variable descrition info
|
|
||||||
char *def_string; // keep pointer to initial value
|
|
||||||
} convar_t;
|
|
||||||
|
|
||||||
// cvar internal flags
|
|
||||||
#define FCVAR_RENDERINFO (1<<16) // save to a seperate config called video.cfg
|
|
||||||
#define FCVAR_READ_ONLY (1<<17) // cannot be set by user at all, and can't be requested by CvarGetPointer from game dlls
|
|
||||||
#define FCVAR_EXTENDED (1<<18) // this is convar_t (sets on registration)
|
|
||||||
#define FCVAR_ALLOCATED (1<<19) // this convar_t is fully dynamic allocated (include description)
|
|
||||||
#define FCVAR_VIDRESTART (1<<20) // recreate the window is cvar with this flag was changed
|
|
||||||
#define FCVAR_TEMPORARY (1<<21) // these cvars holds their values and can be unlink in any time
|
|
||||||
#define FCVAR_MOVEVARS (1<<22) // this cvar is a part of movevars_t struct that shared between client and server
|
|
||||||
#define FCVAR_USER_CREATED (1<<23) // created by a set command (dll's used)
|
|
||||||
|
|
||||||
#define CVAR_DEFINE( cv, cvname, cvstr, cvflags, cvdesc ) \
|
|
||||||
convar_t cv = { (char*)cvname, (char*)cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, (char*)cvdesc, NULL }
|
|
||||||
|
|
||||||
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) \
|
|
||||||
CVAR_DEFINE( cv, #cv, cvstr, cvflags, cvdesc )
|
|
||||||
|
|
||||||
#ifndef REF_DLL
|
|
||||||
cvar_t *Cvar_GetList( void );
|
cvar_t *Cvar_GetList( void );
|
||||||
#define Cvar_FindVar( name ) Cvar_FindVarExt( name, 0 )
|
#define Cvar_FindVar( name ) Cvar_FindVarExt( name, 0 )
|
||||||
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group );
|
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group );
|
||||||
@@ -81,6 +42,5 @@ qboolean Cvar_CommandWithPrivilegeCheck( convar_t *v, qboolean isPrivileged );
|
|||||||
void Cvar_Init( void );
|
void Cvar_Init( void );
|
||||||
void Cvar_PostFSInit( void );
|
void Cvar_PostFSInit( void );
|
||||||
void Cvar_Unlink( int group );
|
void Cvar_Unlink( int group );
|
||||||
#endif // REF_DLL
|
|
||||||
|
|
||||||
#endif//CVAR_H
|
#endif//CVAR_H
|
||||||
|
|||||||
@@ -27,6 +27,31 @@ fs_globals_t *FI;
|
|||||||
static pfnCreateInterface_t fs_pfnCreateInterface;
|
static pfnCreateInterface_t fs_pfnCreateInterface;
|
||||||
static HINSTANCE fs_hInstance;
|
static HINSTANCE fs_hInstance;
|
||||||
|
|
||||||
|
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||||
|
{
|
||||||
|
return g_fsapi.Search( pattern, caseinsensitive, gamedironly );
|
||||||
|
}
|
||||||
|
|
||||||
|
int FS_Close( file_t *file )
|
||||||
|
{
|
||||||
|
return g_fsapi.Close( file );
|
||||||
|
}
|
||||||
|
|
||||||
|
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly )
|
||||||
|
{
|
||||||
|
return g_fsapi.Open( filepath, mode, gamedironly );
|
||||||
|
}
|
||||||
|
|
||||||
|
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
||||||
|
{
|
||||||
|
return g_fsapi.LoadFile( path, filesizeptr, gamedironly );
|
||||||
|
}
|
||||||
|
|
||||||
|
byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr )
|
||||||
|
{
|
||||||
|
return g_fsapi.LoadDirectFile( path, filesizeptr );
|
||||||
|
}
|
||||||
|
|
||||||
static void COM_StripDirectorySlash( char *pname )
|
static void COM_StripDirectorySlash( char *pname )
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ static feature_message_t bugcomp_features[] =
|
|||||||
{
|
{
|
||||||
{ BUGCOMP_PENTITYOFENTINDEX_FLAG, "pfnPEntityOfEntIndex bugfix revert", "peoei" },
|
{ BUGCOMP_PENTITYOFENTINDEX_FLAG, "pfnPEntityOfEntIndex bugfix revert", "peoei" },
|
||||||
{ BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG, "GoldSrc Message Rewrite Facility", "gsmrf" },
|
{ BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG, "GoldSrc Message Rewrite Facility", "gsmrf" },
|
||||||
|
{ BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE, "spatialize sounds with zero attenuation", "sp_attn_none" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static feature_message_t engine_features[] =
|
static feature_message_t engine_features[] =
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ typedef struct dresource_s
|
|||||||
} dresource_t;
|
} dresource_t;
|
||||||
#pragma pack( pop )
|
#pragma pack( pop )
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( dresource_t ) == 136, "invalid dresource_t size, HPAKs won't be compatible (no custom logo in multiplayer!)" );
|
STATIC_CHECK_SIZEOF( dresource_t, 136, 136 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -76,7 +76,7 @@ typedef struct
|
|||||||
int infotableofs;
|
int infotableofs;
|
||||||
} hpak_header_t;
|
} hpak_header_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( hpak_header_t ) == 12, "invalid hpak_header_t size" );
|
STATIC_CHECK_SIZEOF( hpak_header_t, 12, 12 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -85,7 +85,7 @@ typedef struct
|
|||||||
int disksize;
|
int disksize;
|
||||||
} hpak_lump_t;
|
} hpak_lump_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( hpak_lump_t ) == 144, "invalid hpak_lump_t size" );
|
STATIC_CHECK_SIZEOF( hpak_lump_t, 144, 144 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ void Image_Reset( void )
|
|||||||
image.size = 0;
|
image.size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static rgbdata_t *ImagePack( void )
|
static MALLOC_LIKE( FS_FreeImage, 1 ) rgbdata_t *ImagePack( void )
|
||||||
{
|
{
|
||||||
rgbdata_t *pack;
|
rgbdata_t *pack;
|
||||||
|
|
||||||
@@ -547,7 +547,7 @@ static void Test_CheckImage( const char *name, rgbdata_t *rgb )
|
|||||||
TASSERT( load->size == rgb->size )
|
TASSERT( load->size == rgb->size )
|
||||||
TASSERT( memcmp(load->buffer, rgb->buffer, rgb->size ) == 0 )
|
TASSERT( memcmp(load->buffer, rgb->buffer, rgb->size ) == 0 )
|
||||||
|
|
||||||
Mem_Free( load );
|
FS_FreeImage( load );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_RunImagelib( void )
|
void Test_RunImagelib( void )
|
||||||
|
|||||||
@@ -420,7 +420,8 @@ void NET_InitMasters( void )
|
|||||||
// keep main master always there
|
// keep main master always there
|
||||||
NET_AddMaster( MASTERSERVER_ADR, false );
|
NET_AddMaster( MASTERSERVER_ADR, false );
|
||||||
NET_AddMaster( "aaaa.mentality.rip:27010", false ); // IPv6-only
|
NET_AddMaster( "aaaa.mentality.rip:27010", false ); // IPv6-only
|
||||||
NET_AddMaster( "mentality.rip:27011", false );
|
NET_AddMaster( "mentality.rip:27011", false ); // testing server, might be offline
|
||||||
|
NET_AddMaster( "aaaa.mentality.rip:27011", false ); // IPv6-only, testing server, might be offline
|
||||||
|
|
||||||
NET_LoadMasters( );
|
NET_LoadMasters( );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,6 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
#define MIPTEX_CUSTOM_PALETTE_SIZE_BYTES ( sizeof( int16_t ) + 768 )
|
#define MIPTEX_CUSTOM_PALETTE_SIZE_BYTES ( sizeof( int16_t ) + 768 )
|
||||||
|
|
||||||
typedef struct wadlist_s
|
|
||||||
{
|
|
||||||
char wadnames[MAX_MAP_WADS][32];
|
|
||||||
int wadusage[MAX_MAP_WADS];
|
|
||||||
int count;
|
|
||||||
} wadlist_t;
|
|
||||||
|
|
||||||
typedef struct leaflist_s
|
typedef struct leaflist_s
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
@@ -136,7 +129,6 @@ typedef struct
|
|||||||
dclipnode32_t *clipnodes_out; // temporary 32-bit array to hold clipnodes
|
dclipnode32_t *clipnodes_out; // temporary 32-bit array to hold clipnodes
|
||||||
|
|
||||||
// misc stuff
|
// misc stuff
|
||||||
wadlist_t wadlist;
|
|
||||||
int lightmap_samples; // samples per lightmap (1 or 3)
|
int lightmap_samples; // samples per lightmap (1 or 3)
|
||||||
int version; // model version
|
int version; // model version
|
||||||
qboolean isworld;
|
qboolean isworld;
|
||||||
@@ -1835,7 +1827,7 @@ static void Mod_LoadEntities( model_t *mod, dbspmodel_t *bmod )
|
|||||||
world.generator[0] = '\0';
|
world.generator[0] = '\0';
|
||||||
world.compiler[0] = '\0';
|
world.compiler[0] = '\0';
|
||||||
world.message[0] = '\0';
|
world.message[0] = '\0';
|
||||||
bmod->wadlist.count = 0;
|
world.wadlist.count = 0;
|
||||||
|
|
||||||
// parse all the wads for loading textures in right ordering
|
// parse all the wads for loading textures in right ordering
|
||||||
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
|
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
|
||||||
@@ -1878,12 +1870,12 @@ static void Mod_LoadEntities( model_t *mod, dbspmodel_t *bmod )
|
|||||||
// make sure that wad is really exist
|
// make sure that wad is really exist
|
||||||
if( FS_FileExists( va( "%s.wad", token ), false ))
|
if( FS_FileExists( va( "%s.wad", token ), false ))
|
||||||
{
|
{
|
||||||
int num = bmod->wadlist.count++;
|
int num = world.wadlist.count++;
|
||||||
Q_strncpy( bmod->wadlist.wadnames[num], token, sizeof( bmod->wadlist.wadnames[0] ));
|
Q_strncpy( world.wadlist.wadnames[num], token, sizeof( world.wadlist.wadnames[0] ));
|
||||||
bmod->wadlist.wadusage[num] = 0;
|
world.wadlist.wadusage[num] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( bmod->wadlist.count >= MAX_MAP_WADS )
|
if( world.wadlist.count >= MAX_MAP_WADS )
|
||||||
break; // too many wads...
|
break; // too many wads...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2030,24 +2022,35 @@ static void Mod_LoadMarkSurfaces( model_t *mod, dbspmodel_t *bmod )
|
|||||||
|
|
||||||
if( bmod->version == QBSP2_VERSION )
|
if( bmod->version == QBSP2_VERSION )
|
||||||
{
|
{
|
||||||
dmarkface32_t *in = bmod->markfaces32;
|
const dmarkface32_t *in = bmod->markfaces32;
|
||||||
|
|
||||||
for( i = 0; i < bmod->nummarkfaces; i++, in++ )
|
for( i = 0; i < bmod->nummarkfaces; i++ )
|
||||||
{
|
{
|
||||||
if( *in < 0 || *in >= mod->numsurfaces )
|
if( in[i] < 0 || in[i] >= mod->numsurfaces )
|
||||||
Host_Error( "%s: bad surface number in '%s'\n", __func__, mod->name );
|
Host_Error( "%s: bad surface number %i at %i (max %i) in '%s'\n", __func__, in[i], i, mod->numsurfaces, mod->name );
|
||||||
out[i] = mod->surfaces + *in;
|
out[i] = mod->surfaces + in[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dmarkface_t *in = bmod->markfaces;
|
const dmarkface_t *in = bmod->markfaces;
|
||||||
|
|
||||||
for( i = 0; i < bmod->nummarkfaces; i++, in++ )
|
for( i = 0; i < bmod->nummarkfaces; i++ )
|
||||||
{
|
{
|
||||||
if( *in < 0 || *in >= mod->numsurfaces )
|
// NOTE: some of the buggy compilers have written a broken BSP file
|
||||||
Host_Error( "%s: bad surface number in '%s'\n", __func__, mod->name );
|
// with marksurface pointing at negative surface, for example darkf6.bsp
|
||||||
out[i] = mod->surfaces + *in;
|
// and darkf26.bsp in darkfuture mod. GoldSrc straight up writes
|
||||||
|
// invalid pointer to a surface. Try to fix up these cases...
|
||||||
|
if( mod->numsurfaces <= INT16_MAX && (int16_t)in[i] < 0 )
|
||||||
|
{
|
||||||
|
Con_Printf( S_WARN "%s: fixing up bad surface number %i at %i (max %i) in '%s'\n", __func__, in[i], i, mod->numsurfaces, mod->name );
|
||||||
|
out[i] = mod->surfaces;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( in[i] < 0 || in[i] >= mod->numsurfaces )
|
||||||
|
Host_Error( "%s: bad surface number %i at %i (max %i) in '%s'\n", __func__, in[i], i, mod->numsurfaces, mod->name );
|
||||||
|
out[i] = mod->surfaces + in[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2309,9 +2312,9 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try WAD texture (force while r_wadtextures is 1)
|
// Try WAD texture (force while r_wadtextures is 1)
|
||||||
if( !texture->gl_texturenum && (( r_wadtextures.value && bmod->wadlist.count > 0 ) || mipTex->offsets[0] <= 0 ))
|
if( !texture->gl_texturenum && (( r_wadtextures.value && world.wadlist.count > 0 ) || mipTex->offsets[0] <= 0 ))
|
||||||
{
|
{
|
||||||
int wadIndex = Mod_FindTextureInWadList( &bmod->wadlist, mipTex->name, texpath, sizeof( texpath ));
|
int wadIndex = Mod_FindTextureInWadList( &world.wadlist, mipTex->name, texpath, sizeof( texpath ));
|
||||||
|
|
||||||
if( wadIndex >= 0 )
|
if( wadIndex >= 0 )
|
||||||
{
|
{
|
||||||
@@ -2319,7 +2322,7 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
|
|||||||
if( !Host_IsDedicated( ))
|
if( !Host_IsDedicated( ))
|
||||||
texture->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texpath, NULL, 0, txFlags );
|
texture->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texpath, NULL, 0, txFlags );
|
||||||
#endif // !XASH_DEDICATED
|
#endif // !XASH_DEDICATED
|
||||||
bmod->wadlist.wadusage[wadIndex]++;
|
world.wadlist.wadusage[wadIndex]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2377,12 +2380,12 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
|
|||||||
// doesn't exist there. The original texture is already loaded, but cannot be modified.
|
// doesn't exist there. The original texture is already loaded, but cannot be modified.
|
||||||
// Instead, load the original texture again and convert it to luma.
|
// Instead, load the original texture again and convert it to luma.
|
||||||
|
|
||||||
wadIndex = Mod_FindTextureInWadList( &bmod->wadlist, texture->name, texpath, sizeof( texpath ));
|
wadIndex = Mod_FindTextureInWadList( &world.wadlist, texture->name, texpath, sizeof( texpath ));
|
||||||
|
|
||||||
if( wadIndex >= 0 )
|
if( wadIndex >= 0 )
|
||||||
{
|
{
|
||||||
src = FS_LoadFile( texpath, &srcSize, false );
|
src = FS_LoadFile( texpath, &srcSize, false );
|
||||||
bmod->wadlist.wadusage[wadIndex]++;
|
world.wadlist.wadusage[wadIndex]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OK, loading it from wad or hi-res version
|
// OK, loading it from wad or hi-res version
|
||||||
@@ -3415,18 +3418,14 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
|
|||||||
Mod_CalcPHS( mod );
|
Mod_CalcPHS( mod );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i = 0; i < bmod->wadlist.count; i++ )
|
for( i = 0; i < world.wadlist.count; i++ )
|
||||||
{
|
{
|
||||||
string wadname;
|
string wadname;
|
||||||
|
|
||||||
if( !bmod->wadlist.wadusage[i] )
|
if( !world.wadlist.wadusage[i] )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Q_snprintf( wadname, sizeof( wadname ), "%s.wad", bmod->wadlist.wadnames[i] );
|
Q_snprintf( wadname, sizeof( wadname ), "%s.wad", world.wadlist.wadnames[i] );
|
||||||
|
|
||||||
// a1ba: automatically precache used wad files so client will download it
|
|
||||||
if( SV_Active( ))
|
|
||||||
SV_GenericIndex( wadname );
|
|
||||||
|
|
||||||
if( !wadlist_warn )
|
if( !wadlist_warn )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,6 +83,12 @@ typedef struct
|
|||||||
uint num_polys;
|
uint num_polys;
|
||||||
} hull_model_t;
|
} hull_model_t;
|
||||||
|
|
||||||
|
typedef struct wadlist_s
|
||||||
|
{
|
||||||
|
char wadnames[MAX_MAP_WADS][32];
|
||||||
|
int wadusage[MAX_MAP_WADS];
|
||||||
|
int count;
|
||||||
|
} wadlist_t;
|
||||||
|
|
||||||
typedef struct world_static_s
|
typedef struct world_static_s
|
||||||
{
|
{
|
||||||
@@ -119,6 +125,8 @@ typedef struct world_static_s
|
|||||||
// Potentially Hearable Set
|
// Potentially Hearable Set
|
||||||
byte *compressed_phs;
|
byte *compressed_phs;
|
||||||
size_t *phsofs;
|
size_t *phsofs;
|
||||||
|
|
||||||
|
wadlist_t wadlist;
|
||||||
} world_static_t;
|
} world_static_t;
|
||||||
|
|
||||||
#ifndef REF_DLL
|
#ifndef REF_DLL
|
||||||
|
|||||||
@@ -160,17 +160,6 @@ void MSG_InitMasks( void )
|
|||||||
ExtraMasks[maskBit] = (uint)BIT( maskBit ) - 1;
|
ExtraMasks[maskBit] = (uint)BIT( maskBit ) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteOneBit( sizebuf_t *sb, int nValue )
|
|
||||||
{
|
|
||||||
if( !MSG_Overflow( sb, 1 ))
|
|
||||||
{
|
|
||||||
if( nValue ) sb->pData[sb->iCurBit>>3] |= BIT( sb->iCurBit & 7 );
|
|
||||||
else sb->pData[sb->iCurBit>>3] &= ~BIT( sb->iCurBit & 7 );
|
|
||||||
|
|
||||||
sb->iCurBit++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits )
|
void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits )
|
||||||
{
|
{
|
||||||
Assert( numbits >= 0 && numbits <= 32 );
|
Assert( numbits >= 0 && numbits <= 32 );
|
||||||
|
|||||||
@@ -173,7 +173,17 @@ void MSG_InitMasks( void ); // called once at startup engine
|
|||||||
void MSG_ExciseBits( sizebuf_t *sb, int startbit, int bitstoremove );
|
void MSG_ExciseBits( sizebuf_t *sb, int startbit, int bitstoremove );
|
||||||
|
|
||||||
// Bit-write functions
|
// Bit-write functions
|
||||||
void MSG_WriteOneBit( sizebuf_t *sb, int nValue );
|
static inline void MSG_WriteOneBit( sizebuf_t *sb, int nValue )
|
||||||
|
{
|
||||||
|
if( !MSG_Overflow( sb, 1 ))
|
||||||
|
{
|
||||||
|
if( nValue ) sb->pData[sb->iCurBit>>3] |= BIT( sb->iCurBit & 7 );
|
||||||
|
else sb->pData[sb->iCurBit>>3] &= ~BIT( sb->iCurBit & 7 );
|
||||||
|
|
||||||
|
sb->iCurBit++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NO_ASAN void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits );
|
NO_ASAN void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits );
|
||||||
void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits );
|
void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits );
|
||||||
void MSG_WriteBitLong( sizebuf_t *sb, uint data, int numbits, qboolean bSigned );
|
void MSG_WriteBitLong( sizebuf_t *sb, uint data, int numbits, qboolean bSigned );
|
||||||
|
|||||||
@@ -988,7 +988,7 @@ compare fields by offsets
|
|||||||
assume from and to is valid
|
assume from and to is valid
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
static qboolean Delta_CompareField( delta_t *pField, void *from, void *to, double timebase )
|
static qboolean Delta_CompareField( delta_t *pField, const void *from, const void *to )
|
||||||
{
|
{
|
||||||
int signbit = ( pField->flags & DT_SIGNED ) ? 1 : 0;
|
int signbit = ( pField->flags & DT_SIGNED ) ? 1 : 0;
|
||||||
float val_a, val_b;
|
float val_a, val_b;
|
||||||
@@ -1109,7 +1109,7 @@ Delta_TestBaseline
|
|||||||
compare baselines to find optimal
|
compare baselines to find optimal
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean player, double timebase )
|
int Delta_TestBaseline( const entity_state_t *from, const entity_state_t *to, qboolean player, double timebase )
|
||||||
{
|
{
|
||||||
delta_info_t *dt = NULL;
|
delta_info_t *dt = NULL;
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
@@ -1145,7 +1145,7 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
|||||||
// flag about field change (sets always)
|
// flag about field change (sets always)
|
||||||
countBits++;
|
countBits++;
|
||||||
|
|
||||||
if( !Delta_CompareField( pField, from, to, timebase ))
|
if( !Delta_CompareField( pField, from, to ))
|
||||||
{
|
{
|
||||||
// strings are handled differently
|
// strings are handled differently
|
||||||
if( FBitSet( pField->flags, DT_STRING ))
|
if( FBitSet( pField->flags, DT_STRING ))
|
||||||
@@ -1166,7 +1166,7 @@ write fields by offsets
|
|||||||
assume from and to is valid
|
assume from and to is valid
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to, double timebase )
|
static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, const void *from, const void *to, double timebase )
|
||||||
{
|
{
|
||||||
int signbit = FBitSet( pField->flags, DT_SIGNED ) ? 1 : 0;
|
int signbit = FBitSet( pField->flags, DT_SIGNED ) ? 1 : 0;
|
||||||
float flValue, flAngle;
|
float flValue, flAngle;
|
||||||
@@ -1174,7 +1174,7 @@ static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, v
|
|||||||
int dt;
|
int dt;
|
||||||
const char *pStr;
|
const char *pStr;
|
||||||
|
|
||||||
if( Delta_CompareField( pField, from, to, timebase ))
|
if( Delta_CompareField( pField, from, to ))
|
||||||
{
|
{
|
||||||
MSG_WriteOneBit( msg, 0 ); // unchanged
|
MSG_WriteOneBit( msg, 0 ); // unchanged
|
||||||
return false;
|
return false;
|
||||||
@@ -1264,7 +1264,7 @@ Delta_CopyField
|
|||||||
|
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
static void Delta_CopyField( delta_t *pField, void *from, void *to, double timebase )
|
static void Delta_CopyField( delta_t *pField, const void *from, void *to, double timebase )
|
||||||
{
|
{
|
||||||
qboolean bSigned = FBitSet( pField->flags, DT_SIGNED );
|
qboolean bSigned = FBitSet( pField->flags, DT_SIGNED );
|
||||||
uint8_t *to_field = (uint8_t *)to + pField->offset;
|
uint8_t *to_field = (uint8_t *)to + pField->offset;
|
||||||
@@ -1313,7 +1313,7 @@ read fields by offsets
|
|||||||
assume 'from' and 'to' is valid
|
assume 'from' and 'to' is valid
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
static qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to, double timebase )
|
static qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, const void *from, void *to, double timebase )
|
||||||
{
|
{
|
||||||
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false;
|
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false;
|
||||||
float flValue, flAngle, flTime;
|
float flValue, flAngle, flTime;
|
||||||
@@ -1425,7 +1425,7 @@ usercmd_t communication
|
|||||||
MSG_WriteDeltaUsercmd
|
MSG_WriteDeltaUsercmd
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to )
|
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, const usercmd_t *from, const usercmd_t *to )
|
||||||
{
|
{
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
delta_info_t *dt;
|
delta_info_t *dt;
|
||||||
@@ -1452,7 +1452,7 @@ void MSG_WriteDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to )
|
|||||||
MSG_ReadDeltaUsercmd
|
MSG_ReadDeltaUsercmd
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to )
|
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, const usercmd_t *from, usercmd_t *to )
|
||||||
{
|
{
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
delta_info_t *dt;
|
delta_info_t *dt;
|
||||||
@@ -1487,7 +1487,7 @@ event_args_t communication
|
|||||||
MSG_WriteDeltaEvent
|
MSG_WriteDeltaEvent
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
void MSG_WriteDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to )
|
void MSG_WriteDeltaEvent( sizebuf_t *msg, const event_args_t *from, const event_args_t *to )
|
||||||
{
|
{
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
delta_info_t *dt;
|
delta_info_t *dt;
|
||||||
@@ -1514,7 +1514,7 @@ void MSG_WriteDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to )
|
|||||||
MSG_ReadDeltaEvent
|
MSG_ReadDeltaEvent
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
void MSG_ReadDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to )
|
void MSG_ReadDeltaEvent( sizebuf_t *msg, const event_args_t *from, event_args_t *to )
|
||||||
{
|
{
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
delta_info_t *dt;
|
delta_info_t *dt;
|
||||||
@@ -1542,7 +1542,7 @@ movevars_t communication
|
|||||||
|
|
||||||
=============================================================================
|
=============================================================================
|
||||||
*/
|
*/
|
||||||
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to )
|
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, const movevars_t *from, const movevars_t *to )
|
||||||
{
|
{
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
delta_info_t *dt;
|
delta_info_t *dt;
|
||||||
@@ -1578,7 +1578,7 @@ qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *t
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_ReadDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to )
|
void MSG_ReadDeltaMovevars( sizebuf_t *msg, const movevars_t *from, movevars_t *to )
|
||||||
{
|
{
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
delta_info_t *dt;
|
delta_info_t *dt;
|
||||||
@@ -1614,7 +1614,7 @@ Writes current client data only for local client
|
|||||||
Other clients can grab the client state from entity_state_t
|
Other clients can grab the client state from entity_state_t
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void MSG_WriteClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, double timebase )
|
void MSG_WriteClientData( sizebuf_t *msg, const clientdata_t *from, const clientdata_t *to, double timebase )
|
||||||
{
|
{
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
delta_info_t *dt;
|
delta_info_t *dt;
|
||||||
@@ -1654,7 +1654,7 @@ MSG_ReadClientData
|
|||||||
Read the clientdata
|
Read the clientdata
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, double timebase )
|
void MSG_ReadClientData( sizebuf_t *msg, const clientdata_t *from, clientdata_t *to, double timebase )
|
||||||
{
|
{
|
||||||
#if !XASH_DEDICATED
|
#if !XASH_DEDICATED
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
@@ -1695,7 +1695,7 @@ Writes current client data only for local client
|
|||||||
Other clients can grab the client state from entity_state_t
|
Other clients can grab the client state from entity_state_t
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void MSG_WriteWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, double timebase, int index )
|
void MSG_WriteWeaponData( sizebuf_t *msg, const weapon_data_t *from, const weapon_data_t *to, double timebase, int index )
|
||||||
{
|
{
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
delta_info_t *dt;
|
delta_info_t *dt;
|
||||||
@@ -1734,7 +1734,7 @@ MSG_ReadWeaponData
|
|||||||
Read the clientdata
|
Read the clientdata
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, double timebase )
|
void MSG_ReadWeaponData( sizebuf_t *msg, const weapon_data_t *from, weapon_data_t *to, double timebase )
|
||||||
{
|
{
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
delta_info_t *dt;
|
delta_info_t *dt;
|
||||||
@@ -1771,7 +1771,7 @@ If force is not set, then nothing at all will be generated if the entity is
|
|||||||
identical, under the assumption that the in-order delta code will catch it.
|
identical, under the assumption that the in-order delta code will catch it.
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, int delta_type, double timebase, int baseline )
|
void MSG_WriteDeltaEntity( const entity_state_t *from, const entity_state_t *to, sizebuf_t *msg, qboolean force, int delta_type, double timebase, int baseline )
|
||||||
{
|
{
|
||||||
delta_info_t *dt = NULL;
|
delta_info_t *dt = NULL;
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
@@ -1873,7 +1873,7 @@ If the delta removes the entity, entity_state_t->number will be set to MAX_EDICT
|
|||||||
Can go from either a baseline or a previous packet_entity
|
Can go from either a baseline or a previous packet_entity
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int number, int delta_type, double timebase )
|
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const entity_state_t *from, entity_state_t *to, int number, int delta_type, double timebase )
|
||||||
{
|
{
|
||||||
#if !XASH_DEDICATED
|
#if !XASH_DEDICATED
|
||||||
delta_info_t *dt = NULL;
|
delta_info_t *dt = NULL;
|
||||||
|
|||||||
@@ -96,18 +96,18 @@ struct event_args_s;
|
|||||||
struct movevars_s;
|
struct movevars_s;
|
||||||
struct clientdata_s;
|
struct clientdata_s;
|
||||||
struct weapon_data_s;
|
struct weapon_data_s;
|
||||||
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, struct usercmd_s *from, struct usercmd_s *to );
|
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, const struct usercmd_s *from, const struct usercmd_s *to );
|
||||||
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, struct usercmd_s *from, struct usercmd_s *to );
|
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, const struct usercmd_s *from, struct usercmd_s *to );
|
||||||
void MSG_WriteDeltaEvent( sizebuf_t *msg, struct event_args_s *from, struct event_args_s *to );
|
void MSG_WriteDeltaEvent( sizebuf_t *msg, const struct event_args_s *from, const struct event_args_s *to );
|
||||||
void MSG_ReadDeltaEvent( sizebuf_t *msg, struct event_args_s *from, struct event_args_s *to );
|
void MSG_ReadDeltaEvent( sizebuf_t *msg, const struct event_args_s *from, struct event_args_s *to );
|
||||||
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, struct movevars_s *from, struct movevars_s *to );
|
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, const struct movevars_s *from, const struct movevars_s *to );
|
||||||
void MSG_ReadDeltaMovevars( sizebuf_t *msg, struct movevars_s *from, struct movevars_s *to );
|
void MSG_ReadDeltaMovevars( sizebuf_t *msg, const struct movevars_s *from, struct movevars_s *to );
|
||||||
void MSG_WriteClientData( sizebuf_t *msg, struct clientdata_s *from, struct clientdata_s *to, double timebase );
|
void MSG_WriteClientData( sizebuf_t *msg, const struct clientdata_s *from, const struct clientdata_s *to, double timebase );
|
||||||
void MSG_ReadClientData( sizebuf_t *msg, struct clientdata_s *from, struct clientdata_s *to, double timebase );
|
void MSG_ReadClientData( sizebuf_t *msg, const struct clientdata_s *from, struct clientdata_s *to, double timebase );
|
||||||
void MSG_WriteWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, double timebase, int index );
|
void MSG_WriteWeaponData( sizebuf_t *msg, const struct weapon_data_s *from, const struct weapon_data_s *to, double timebase, int index );
|
||||||
void MSG_ReadWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, double timebase );
|
void MSG_ReadWeaponData( sizebuf_t *msg, const struct weapon_data_s *from, struct weapon_data_s *to, double timebase );
|
||||||
void MSG_WriteDeltaEntity( struct entity_state_s *from, struct entity_state_s *to, sizebuf_t *msg, qboolean force, int type, double timebase, int ofs );
|
void MSG_WriteDeltaEntity( const struct entity_state_s *from, const struct entity_state_s *to, sizebuf_t *msg, qboolean force, int type, double timebase, int ofs );
|
||||||
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, struct entity_state_s *from, struct entity_state_s *to, int num, int type, double timebase );
|
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const struct entity_state_s *from, struct entity_state_s *to, int num, int type, double timebase );
|
||||||
int Delta_TestBaseline( struct entity_state_s *from, struct entity_state_s *to, qboolean player, double timebase );
|
int Delta_TestBaseline( const struct entity_state_s *from, const struct entity_state_s *to, qboolean player, double timebase );
|
||||||
|
|
||||||
#endif//NET_ENCODE_H
|
#endif//NET_ENCODE_H
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ GNU General Public License for more details.
|
|||||||
static const struct in6_addr in6addr_any;
|
static const struct in6_addr in6addr_any;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if XASH_SDL == 2
|
||||||
|
#include <SDL_thread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NET_USE_FRAGMENTS
|
#define NET_USE_FRAGMENTS
|
||||||
|
|
||||||
#define MAX_LOOPBACK 4
|
#define MAX_LOOPBACK 4
|
||||||
@@ -363,27 +367,44 @@ static qboolean NET_GetHostByName( const char *hostname, int family, struct sock
|
|||||||
#ifdef CAN_ASYNC_NS_RESOLVE
|
#ifdef CAN_ASYNC_NS_RESOLVE
|
||||||
static void NET_ResolveThread( void );
|
static void NET_ResolveThread( void );
|
||||||
|
|
||||||
#if !XASH_WIN32
|
#if XASH_SDL == 2
|
||||||
|
#define mutex_create( x ) (( x ) = SDL_CreateMutex() )
|
||||||
|
#define mutex_destroy( x ) SDL_DestroyMutex(( x ))
|
||||||
|
#define mutex_lock( x ) SDL_LockMutex(( x ))
|
||||||
|
#define mutex_unlock( x ) SDL_UnlockMutex(( x ))
|
||||||
|
#define create_thread( thread, pfn ) (( thread ) = SDL_CreateThread(( pfn ), "DNS resolver thread", NULL ))
|
||||||
|
#define detach_thread( x ) SDL_DetachThread(( x ))
|
||||||
|
typedef SDL_mutex *mutex_t;
|
||||||
|
typedef SDL_Thread *thread_t;
|
||||||
|
static int NET_ThreadStart( void *ununsed )
|
||||||
|
{
|
||||||
|
NET_ResolveThread();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#elif !XASH_WIN32
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#define mutex_lock pthread_mutex_lock
|
#define mutex_create( x ) pthread_mutex_init( &( x ), NULL )
|
||||||
#define mutex_unlock pthread_mutex_unlock
|
#define mutex_destroy( x ) pthread_mutex_destroy( &( x ))
|
||||||
#define exit_thread( x ) pthread_exit(x)
|
#define mutex_lock( x ) pthread_mutex_lock( &( x ))
|
||||||
#define create_thread( pfn ) !pthread_create( &nsthread.thread, NULL, (pfn), NULL )
|
#define mutex_unlock( x ) pthread_mutex_unlock( &( x ))
|
||||||
#define detach_thread( x ) pthread_detach(x)
|
#define create_thread( thread, pfn ) !pthread_create( &( thread ), NULL, ( pfn ), NULL )
|
||||||
#define mutex_t pthread_mutex_t
|
#define detach_thread( x ) pthread_detach( x )
|
||||||
#define thread_t pthread_t
|
typedef pthread_mutex_t mutex_t;
|
||||||
|
typedef pthread_t thread_t;
|
||||||
static void *NET_ThreadStart( void *unused )
|
static void *NET_ThreadStart( void *unused )
|
||||||
{
|
{
|
||||||
NET_ResolveThread();
|
NET_ResolveThread();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else // WIN32
|
#else // WIN32
|
||||||
#define mutex_lock EnterCriticalSection
|
#define mutex_create( x ) InitializeCriticalSection( &( x ))
|
||||||
#define mutex_unlock LeaveCriticalSection
|
#define mutex_destroy( x ) DeleteCriticalSection( &( x ))
|
||||||
#define detach_thread( x ) CloseHandle(x)
|
#define mutex_lock( x ) EnterCriticalSection( &( x ))
|
||||||
#define create_thread( pfn ) ( nsthread.thread = CreateThread( NULL, 0, pfn, NULL, 0, NULL ))
|
#define mutex_unlock( x ) LeaveCriticalSection( &( x ))
|
||||||
#define mutex_t CRITICAL_SECTION
|
#define create_thread( thread, pfn ) (( thread ) = CreateThread( NULL, 0, ( pfn ), NULL, 0, NULL ))
|
||||||
#define thread_t HANDLE
|
#define detach_thread( x ) CloseHandle(( x ))
|
||||||
|
typedef CRITICAL_SECTION mutex_t;
|
||||||
|
typedef HANDLE thread_t;
|
||||||
DWORD WINAPI NET_ThreadStart( LPVOID unused )
|
DWORD WINAPI NET_ThreadStart( LPVOID unused )
|
||||||
{
|
{
|
||||||
NET_ResolveThread();
|
NET_ResolveThread();
|
||||||
@@ -400,27 +421,30 @@ DWORD WINAPI NET_ThreadStart( LPVOID unused )
|
|||||||
|
|
||||||
static struct nsthread_s
|
static struct nsthread_s
|
||||||
{
|
{
|
||||||
mutex_t mutexns;
|
mutex_t mutexns;
|
||||||
mutex_t mutexres;
|
mutex_t mutexres;
|
||||||
thread_t thread;
|
thread_t thread;
|
||||||
int result;
|
int result;
|
||||||
string hostname;
|
string hostname;
|
||||||
int family;
|
int family;
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
qboolean busy;
|
qboolean busy;
|
||||||
} nsthread
|
} nsthread;
|
||||||
#if !XASH_WIN32
|
|
||||||
= { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER }
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
static void NET_InitializeCriticalSections( void )
|
static void NET_InitializeCriticalSections( void )
|
||||||
{
|
{
|
||||||
net.threads_initialized = true;
|
net.threads_initialized = true;
|
||||||
#if XASH_WIN32
|
|
||||||
InitializeCriticalSection( &nsthread.mutexns );
|
mutex_create( nsthread.mutexns );
|
||||||
InitializeCriticalSection( &nsthread.mutexres );
|
mutex_create( nsthread.mutexres );
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
static void NET_DeleteCriticalSections( void )
|
||||||
|
{
|
||||||
|
net.threads_initialized = false;
|
||||||
|
|
||||||
|
mutex_destroy( nsthread.mutexns );
|
||||||
|
mutex_destroy( nsthread.mutexres );
|
||||||
}
|
}
|
||||||
|
|
||||||
void NET_ResolveThread( void )
|
void NET_ResolveThread( void )
|
||||||
@@ -440,12 +464,12 @@ void NET_ResolveThread( void )
|
|||||||
RESOLVE_DBG( "[resolve thread] success\n" );
|
RESOLVE_DBG( "[resolve thread] success\n" );
|
||||||
else
|
else
|
||||||
RESOLVE_DBG( "[resolve thread] failed\n" );
|
RESOLVE_DBG( "[resolve thread] failed\n" );
|
||||||
mutex_lock( &nsthread.mutexres );
|
mutex_lock( nsthread.mutexres );
|
||||||
nsthread.addr = addr;
|
nsthread.addr = addr;
|
||||||
nsthread.busy = false;
|
nsthread.busy = false;
|
||||||
nsthread.result = res ? NET_EAI_OK : NET_EAI_NONAME;
|
nsthread.result = res ? NET_EAI_OK : NET_EAI_NONAME;
|
||||||
RESOLVE_DBG( "[resolve thread] returning result\n" );
|
RESOLVE_DBG( "[resolve thread] returning result\n" );
|
||||||
mutex_unlock( &nsthread.mutexres );
|
mutex_unlock( nsthread.mutexres );
|
||||||
RESOLVE_DBG( "[resolve thread] exiting thread\n" );
|
RESOLVE_DBG( "[resolve thread] exiting thread\n" );
|
||||||
}
|
}
|
||||||
#endif // CAN_ASYNC_NS_RESOLVE
|
#endif // CAN_ASYNC_NS_RESOLVE
|
||||||
@@ -510,11 +534,11 @@ static net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_stor
|
|||||||
#ifdef CAN_ASYNC_NS_RESOLVE
|
#ifdef CAN_ASYNC_NS_RESOLVE
|
||||||
if( net.threads_initialized && nonblocking )
|
if( net.threads_initialized && nonblocking )
|
||||||
{
|
{
|
||||||
mutex_lock( &nsthread.mutexres );
|
mutex_lock( nsthread.mutexres );
|
||||||
|
|
||||||
if( nsthread.busy )
|
if( nsthread.busy )
|
||||||
{
|
{
|
||||||
mutex_unlock( &nsthread.mutexres );
|
mutex_unlock( nsthread.mutexres );
|
||||||
return NET_EAI_AGAIN;
|
return NET_EAI_AGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,9 +559,9 @@ static net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_stor
|
|||||||
Q_strncpy( nsthread.hostname, copy, sizeof( nsthread.hostname ));
|
Q_strncpy( nsthread.hostname, copy, sizeof( nsthread.hostname ));
|
||||||
nsthread.family = family;
|
nsthread.family = family;
|
||||||
nsthread.busy = true;
|
nsthread.busy = true;
|
||||||
mutex_unlock( &nsthread.mutexres );
|
mutex_unlock( nsthread.mutexres );
|
||||||
|
|
||||||
if( create_thread( NET_ThreadStart ))
|
if( create_thread( nsthread.thread, NET_ThreadStart ))
|
||||||
{
|
{
|
||||||
asyncfailed = false;
|
asyncfailed = false;
|
||||||
return NET_EAI_AGAIN;
|
return NET_EAI_AGAIN;
|
||||||
@@ -549,7 +573,7 @@ static net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_stor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock( &nsthread.mutexres );
|
mutex_unlock( nsthread.mutexres );
|
||||||
}
|
}
|
||||||
#endif // CAN_ASYNC_NS_RESOLVE
|
#endif // CAN_ASYNC_NS_RESOLVE
|
||||||
|
|
||||||
@@ -2167,6 +2191,11 @@ void NET_Shutdown( void )
|
|||||||
NET_ClearLagData( true, true );
|
NET_ClearLagData( true, true );
|
||||||
|
|
||||||
NET_Config( false, false );
|
NET_Config( false, false );
|
||||||
|
|
||||||
|
#ifdef CAN_ASYNC_NS_RESOLVE
|
||||||
|
NET_DeleteCriticalSections();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if XASH_WIN32
|
#if XASH_WIN32
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ static void Sound_Reset( void )
|
|||||||
sound.size = 0;
|
sound.size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wavdata_t *SoundPack( void )
|
static MALLOC_LIKE( FS_FreeSound, 1 ) wavdata_t *SoundPack( void )
|
||||||
{
|
{
|
||||||
wavdata_t *pack = Mem_Calloc( host.soundpool, sizeof( wavdata_t ));
|
wavdata_t *pack = Mem_Calloc( host.soundpool, sizeof( wavdata_t ));
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ typedef struct did3v2_header_s
|
|||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint32_t length; // size of extended header, padding and frames
|
uint32_t length; // size of extended header, padding and frames
|
||||||
} did3v2_header_t;
|
} did3v2_header_t;
|
||||||
STATIC_ASSERT( sizeof( did3v2_header_t ) == 10,
|
STATIC_CHECK_SIZEOF( did3v2_header_t, 10, 10 );
|
||||||
"invalid did3v2_header_t size" );
|
|
||||||
|
|
||||||
typedef struct did3v2_extended_header_s
|
typedef struct did3v2_extended_header_s
|
||||||
{
|
{
|
||||||
@@ -34,8 +33,7 @@ typedef struct did3v2_extended_header_s
|
|||||||
uint8_t flags_length;
|
uint8_t flags_length;
|
||||||
uint8_t flags[1];
|
uint8_t flags[1];
|
||||||
} did3v2_extended_header_t;
|
} did3v2_extended_header_t;
|
||||||
STATIC_ASSERT( sizeof( did3v2_extended_header_t ) == 6,
|
STATIC_CHECK_SIZEOF( did3v2_extended_header_t, 6, 6 );
|
||||||
"invalid did3v2_extended_header_t size" );
|
|
||||||
|
|
||||||
typedef struct did3v2_frame_s
|
typedef struct did3v2_frame_s
|
||||||
{
|
{
|
||||||
@@ -43,8 +41,7 @@ typedef struct did3v2_frame_s
|
|||||||
uint32_t length;
|
uint32_t length;
|
||||||
uint8_t flags[2];
|
uint8_t flags[2];
|
||||||
} did3v2_frame_t;
|
} did3v2_frame_t;
|
||||||
STATIC_ASSERT( sizeof( did3v2_frame_t ) == 10,
|
STATIC_CHECK_SIZEOF( did3v2_frame_t, 10, 10 );
|
||||||
"invalid did3v2_frame_t size" );
|
|
||||||
#pragma pack( pop )
|
#pragma pack( pop )
|
||||||
|
|
||||||
typedef enum did3v2_header_flags_e
|
typedef enum did3v2_header_flags_e
|
||||||
|
|||||||
@@ -230,13 +230,20 @@ static void Sys_PrintLogfile( const int fd, const char *logtime, const char *msg
|
|||||||
|
|
||||||
if( p == NULL )
|
if( p == NULL )
|
||||||
{
|
{
|
||||||
write( fd, msg, Q_strlen( msg ));
|
if( write( fd, msg, Q_strlen( msg )) < 0 )
|
||||||
|
{
|
||||||
|
// don't call engine Msg, might cause recursion
|
||||||
|
fprintf( stderr, "%s: write failed: %s\n", __func__, strerror( errno ));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( IsColorString( p ))
|
else if( IsColorString( p ))
|
||||||
{
|
{
|
||||||
if( p != msg )
|
if( p != msg )
|
||||||
write( fd, msg, p - msg );
|
{
|
||||||
|
if( write( fd, msg, p - msg ) < 0 )
|
||||||
|
fprintf( stderr, "%s: write failed: %s\n", __func__, strerror( errno ));
|
||||||
|
}
|
||||||
msg = p + 2;
|
msg = p + 2;
|
||||||
|
|
||||||
if( colorize )
|
if( colorize )
|
||||||
@@ -244,7 +251,8 @@ static void Sys_PrintLogfile( const int fd, const char *logtime, const char *msg
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write( fd, msg, p - msg + 1 );
|
if( write( fd, msg, p - msg + 1 ) < 0 )
|
||||||
|
fprintf( stderr, "%s: write failed: %s\n", __func__, strerror( errno ));
|
||||||
msg = p + 1;
|
msg = p + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,12 +95,7 @@ typedef struct customization_s
|
|||||||
#define FCUST_WIPEDATA ( 1<<1 )
|
#define FCUST_WIPEDATA ( 1<<1 )
|
||||||
#define FCUST_IGNOREINIT ( 1<<2 )
|
#define FCUST_IGNOREINIT ( 1<<2 )
|
||||||
|
|
||||||
#if !XASH_64BIT
|
STATIC_CHECK_SIZEOF( customization_t, 164, 192 );
|
||||||
STATIC_ASSERT( sizeof( customization_t ) == 164, "invalid customization_t size, broken API" );
|
STATIC_CHECK_SIZEOF( resource_t, 136, 144 );
|
||||||
STATIC_ASSERT( sizeof( resource_t ) == 136, "invalid resource_t size, broken API" );
|
|
||||||
#else
|
|
||||||
STATIC_ASSERT( sizeof( customization_t ) == 192, "invalid customization_t size, broken API" );
|
|
||||||
STATIC_ASSERT( sizeof( resource_t ) == 144, "invalid resource_t size, broken API" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CUSTOM_H
|
#endif // CUSTOM_H
|
||||||
|
|||||||
@@ -1015,9 +1015,10 @@ qboolean R_Init_Video( const int type )
|
|||||||
{
|
{
|
||||||
string safe;
|
string safe;
|
||||||
qboolean retval;
|
qboolean retval;
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
|
||||||
SDL_DisplayMode displayMode;
|
SDL_DisplayMode displayMode;
|
||||||
SDL_GetCurrentDisplayMode(0, &displayMode);
|
SDL_GetCurrentDisplayMode( 0, &displayMode );
|
||||||
refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format );
|
refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format );
|
||||||
#else
|
#else
|
||||||
refState.desktopBitsPixel = 16;
|
refState.desktopBitsPixel = 16;
|
||||||
@@ -1095,7 +1096,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mod
|
|||||||
|
|
||||||
if( SDL_GetCurrentDisplayMode( 0, &displayMode ) < 0 )
|
if( SDL_GetCurrentDisplayMode( 0, &displayMode ) < 0 )
|
||||||
{
|
{
|
||||||
Con_Printf( S_ERROR "SDL_GetCurrentDisplayMode: %s", SDL_GetError( ));
|
Con_Printf( S_ERROR "SDL_GetCurrentDisplayMode: %s\n", SDL_GetError( ));
|
||||||
return rserr_invalid_mode;
|
return rserr_invalid_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1239,10 +1240,6 @@ void R_Free_Video( void )
|
|||||||
R_FreeVideoModes();
|
R_FreeVideoModes();
|
||||||
|
|
||||||
ref.dllFuncs.GL_ClearExtensions();
|
ref.dllFuncs.GL_ClearExtensions();
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
|
|
||||||
SDL_VideoQuit();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XASH_DEDICATED
|
#endif // XASH_DEDICATED
|
||||||
|
|||||||
@@ -389,10 +389,13 @@ typedef struct ref_api_s
|
|||||||
int (*pfnGetStudioModelInterface)( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
|
int (*pfnGetStudioModelInterface)( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
|
||||||
|
|
||||||
// memory
|
// memory
|
||||||
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
|
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline )
|
||||||
|
WARN_UNUSED_RESULT;
|
||||||
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
|
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||||
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
|
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
|
ALLOC_CHECK( 2 ) WARN_UNUSED_RESULT;
|
||||||
|
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
ALLOC_CHECK( 3 ) WARN_UNUSED_RESULT;
|
||||||
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
||||||
|
|
||||||
// library management
|
// library management
|
||||||
|
|||||||
@@ -3064,7 +3064,7 @@ void SV_SetStringArrayMode( qboolean dynamic )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if XASH_64BIT && !XASH_WIN32 && !XASH_APPLE && !XASH_NSWITCH && !XASH_ANDROID
|
#if XASH_AMD64 && XASH_LINUX && !XASH_ANDROID
|
||||||
#define USE_MMAP
|
#define USE_MMAP
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ loads external resource list
|
|||||||
static void SV_CreateGenericResources( void )
|
static void SV_CreateGenericResources( void )
|
||||||
{
|
{
|
||||||
string filename;
|
string filename;
|
||||||
|
int i;
|
||||||
|
|
||||||
Q_strncpy( filename, sv.model_precache[1], sizeof( filename ));
|
Q_strncpy( filename, sv.model_precache[1], sizeof( filename ));
|
||||||
COM_ReplaceExtension( filename, ".res", sizeof( filename ));
|
COM_ReplaceExtension( filename, ".res", sizeof( filename ));
|
||||||
@@ -370,6 +371,16 @@ static void SV_CreateGenericResources( void )
|
|||||||
|
|
||||||
SV_ReadResourceList( filename );
|
SV_ReadResourceList( filename );
|
||||||
SV_ReadResourceList( "reslist.txt" );
|
SV_ReadResourceList( "reslist.txt" );
|
||||||
|
|
||||||
|
for( i = 0; i < world.wadlist.count; i++ )
|
||||||
|
{
|
||||||
|
if( world.wadlist.wadusage[i] > 0 )
|
||||||
|
{
|
||||||
|
string wadname;
|
||||||
|
Q_snprintf( wadname, sizeof( wadname ), "%s.wad", world.wadlist.wadnames[i] );
|
||||||
|
SV_GenericIndex( wadname );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ typedef struct
|
|||||||
int32_t version; // current version 2
|
int32_t version; // current version 2
|
||||||
} dsprite_t;
|
} dsprite_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( dsprite_t ) == 8, "invalid dsprite_t size" );
|
STATIC_CHECK_SIZEOF( dsprite_t, 8, 8 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -86,7 +86,7 @@ typedef struct
|
|||||||
uint32_t synctype; // animation synctype, was synctype_t
|
uint32_t synctype; // animation synctype, was synctype_t
|
||||||
} dsprite_q1_t;
|
} dsprite_q1_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( dsprite_q1_t ) == 36, "invalid dsprite_q1_t size" );
|
STATIC_CHECK_SIZEOF( dsprite_q1_t, 36, 36 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ typedef struct
|
|||||||
uint32_t synctype; // animation synctype, was synctype_t
|
uint32_t synctype; // animation synctype, was synctype_t
|
||||||
} dsprite_hl_t;
|
} dsprite_hl_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( dsprite_hl_t ) == 40, "invalid dsprite_hl_t size" );
|
STATIC_CHECK_SIZEOF( dsprite_hl_t, 40, 40 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -110,27 +110,27 @@ typedef struct
|
|||||||
int32_t height;
|
int32_t height;
|
||||||
} dspriteframe_t;
|
} dspriteframe_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( dspriteframe_t ) == 16, "invalid dspriteframe_t size" );
|
STATIC_CHECK_SIZEOF( dspriteframe_t, 16, 16 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int32_t numframes;
|
int32_t numframes;
|
||||||
} dspritegroup_t;
|
} dspritegroup_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( dspritegroup_t ) == 4, "invalid dspritegroup_t size" );
|
STATIC_CHECK_SIZEOF( dspritegroup_t, 4, 4 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float interval;
|
float interval;
|
||||||
} dspriteinterval_t;
|
} dspriteinterval_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( dspriteinterval_t ) == 4, "invalid dspriteinterval_t size" );
|
STATIC_CHECK_SIZEOF( dspriteinterval_t, 4, 4 );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t type; // was frametype_t
|
uint32_t type; // was frametype_t
|
||||||
} dframetype_t;
|
} dframetype_t;
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( dframetype_t ) == 4, "invalid dframetype_t size" );
|
STATIC_CHECK_SIZEOF( dframetype_t, 4, 4 );
|
||||||
|
|
||||||
#endif//SPRITE_H
|
#endif//SPRITE_H
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ def configure(conf):
|
|||||||
conf.env.append_unique('CFLAGS', '-fsanitize=fuzzer-no-link')
|
conf.env.append_unique('CFLAGS', '-fsanitize=fuzzer-no-link')
|
||||||
conf.env.append_unique('LINKFLAGS', '-fsanitize=fuzzer')
|
conf.env.append_unique('LINKFLAGS', '-fsanitize=fuzzer')
|
||||||
|
|
||||||
|
conf.define('ENGINE_DLL', 1)
|
||||||
|
|
||||||
conf.define_cond('XASH_ENGINE_TESTS', conf.env.ENGINE_TESTS)
|
conf.define_cond('XASH_ENGINE_TESTS', conf.env.ENGINE_TESTS)
|
||||||
conf.define_cond('XASH_STATIC_LIBS', conf.env.STATIC_LINKING)
|
conf.define_cond('XASH_STATIC_LIBS', conf.env.STATIC_LINKING)
|
||||||
conf.define_cond('XASH_CUSTOM_SWAP', conf.options.CUSTOM_SWAP)
|
conf.define_cond('XASH_CUSTOM_SWAP', conf.options.CUSTOM_SWAP)
|
||||||
|
|||||||
@@ -125,6 +125,16 @@ static void FS_BackupFileName( file_t *file, const char *path, uint options ) {}
|
|||||||
static void FS_InitMemory( void );
|
static void FS_InitMemory( void );
|
||||||
static void FS_Purge( file_t* file );
|
static void FS_Purge( file_t* file );
|
||||||
|
|
||||||
|
void _Mem_Free( void *data, const char *filename, int fileline )
|
||||||
|
{
|
||||||
|
g_engfuncs._Mem_Free( data, filename, fileline );
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
{
|
||||||
|
return g_engfuncs._Mem_Alloc( poolptr, size, clear, filename, fileline );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============================================================================
|
=============================================================================
|
||||||
|
|
||||||
@@ -1412,34 +1422,34 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline )
|
static poolhandle_t Mem_AllocPoolStub( const char *name, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
return (poolhandle_t)0xDEADC0DE;
|
return (poolhandle_t)0xDEADC0DE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline )
|
static void Mem_FreePoolStub( poolhandle_t *poolptr, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
// stub
|
// stub
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
static void *Mem_AllocStub( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
void *ptr = malloc( size );
|
void *ptr = malloc( size );
|
||||||
if( clear ) memset( ptr, 0, size );
|
if( clear ) memset( ptr, 0, size );
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
static void *Mem_ReallocStub( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
return realloc( memptr, size );
|
return realloc( memptr, size );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _Mem_Free( void *data, const char *filename, int fileline )
|
static void Mem_FreeStub( void *data, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
free( data );
|
free( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _Con_Printf( const char *fmt, ... )
|
static void Con_PrintfStub( const char *fmt, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -1448,7 +1458,7 @@ static void _Con_Printf( const char *fmt, ... )
|
|||||||
va_end( ap );
|
va_end( ap );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _Sys_Error( const char *fmt, ... )
|
static void Sys_ErrorStub( const char *fmt, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -1459,7 +1469,7 @@ static void _Sys_Error( const char *fmt, ... )
|
|||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *Sys_GetNativeObject_stub( const char *object )
|
static void *Sys_GetNativeObjectStub( const char *object )
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -2524,7 +2534,7 @@ byte *FS_LoadFileMalloc( const char *path, fs_offset_t *filesizeptr, qboolean ga
|
|||||||
|
|
||||||
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
||||||
{
|
{
|
||||||
return FS_LoadFile_( path, filesizeptr, gamedironly, g_engfuncs._Mem_Alloc != _Mem_Alloc );
|
return FS_LoadFile_( path, filesizeptr, gamedironly, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean CRC32_File( dword *crcvalue, const char *filename )
|
qboolean CRC32_File( dword *crcvalue, const char *filename )
|
||||||
@@ -2936,14 +2946,6 @@ search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
|||||||
return search;
|
return search;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *FS_ArchivePath( file_t *f )
|
|
||||||
{
|
|
||||||
if( f->searchpath )
|
|
||||||
return f->searchpath->filename;
|
|
||||||
|
|
||||||
return "plain";
|
|
||||||
}
|
|
||||||
|
|
||||||
static qboolean FS_IsArchiveExtensionSupported( const char *ext, uint flags )
|
static qboolean FS_IsArchiveExtensionSupported( const char *ext, uint flags )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -2971,16 +2973,16 @@ void FS_InitMemory( void )
|
|||||||
|
|
||||||
fs_interface_t g_engfuncs =
|
fs_interface_t g_engfuncs =
|
||||||
{
|
{
|
||||||
_Con_Printf,
|
Con_PrintfStub,
|
||||||
_Con_Printf,
|
Con_PrintfStub,
|
||||||
_Con_Printf,
|
Con_PrintfStub,
|
||||||
_Sys_Error,
|
Sys_ErrorStub,
|
||||||
_Mem_AllocPool,
|
Mem_AllocPoolStub,
|
||||||
_Mem_FreePool,
|
Mem_FreePoolStub,
|
||||||
_Mem_Alloc,
|
Mem_AllocStub,
|
||||||
_Mem_Realloc,
|
Mem_ReallocStub,
|
||||||
_Mem_Free,
|
Mem_FreeStub,
|
||||||
Sys_GetNativeObject_stub
|
Sys_GetNativeObjectStub,
|
||||||
};
|
};
|
||||||
|
|
||||||
static qboolean FS_InitInterface( int version, const fs_interface_t *engfuncs )
|
static qboolean FS_InitInterface( int version, const fs_interface_t *engfuncs )
|
||||||
|
|||||||
@@ -217,8 +217,10 @@ typedef struct fs_interface_t
|
|||||||
// memory
|
// memory
|
||||||
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
|
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
|
||||||
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
|
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||||
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
|
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
|
ALLOC_CHECK( 2 ) WARN_UNUSED_RESULT;
|
||||||
|
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
ALLOC_CHECK( 3 ) WARN_UNUSED_RESULT;
|
||||||
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
||||||
|
|
||||||
// platform
|
// platform
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ GNU General Public License for more details.
|
|||||||
#ifndef FILESYSTEM_INTERNAL_H
|
#ifndef FILESYSTEM_INTERNAL_H
|
||||||
#define FILESYSTEM_INTERNAL_H
|
#define FILESYSTEM_INTERNAL_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include "xash3d_types.h"
|
#include "xash3d_types.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
|
||||||
@@ -129,10 +130,10 @@ extern const fs_archive_t g_archives[];
|
|||||||
|
|
||||||
#define GI FI.GameInfo
|
#define GI FI.GameInfo
|
||||||
|
|
||||||
#define Mem_Malloc( pool, size ) g_engfuncs._Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
#define Mem_Malloc( pool, size ) _Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
||||||
#define Mem_Calloc( pool, size ) g_engfuncs._Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
#define Mem_Calloc( pool, size ) _Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
||||||
#define Mem_Realloc( pool, ptr, size ) g_engfuncs._Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
#define Mem_Realloc( pool, ptr, size ) g_engfuncs._Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
||||||
#define Mem_Free( mem ) g_engfuncs._Mem_Free( mem, __FILE__, __LINE__ )
|
#define Mem_Free( mem ) _Mem_Free( mem, __FILE__, __LINE__ )
|
||||||
#define Mem_AllocPool( name ) g_engfuncs._Mem_AllocPool( name, __FILE__, __LINE__ )
|
#define Mem_AllocPool( name ) g_engfuncs._Mem_AllocPool( name, __FILE__, __LINE__ )
|
||||||
#define Mem_FreePool( pool ) g_engfuncs._Mem_FreePool( pool, __FILE__, __LINE__ )
|
#define Mem_FreePool( pool ) g_engfuncs._Mem_FreePool( pool, __FILE__, __LINE__ )
|
||||||
|
|
||||||
@@ -148,6 +149,9 @@ extern const fs_archive_t g_archives[];
|
|||||||
qboolean FS_InitStdio( qboolean caseinsensitive, const char *rootdir, const char *basedir, const char *gamedir, const char *rodir );
|
qboolean FS_InitStdio( qboolean caseinsensitive, const char *rootdir, const char *basedir, const char *gamedir, const char *rodir );
|
||||||
void FS_ShutdownStdio( void );
|
void FS_ShutdownStdio( void );
|
||||||
searchpath_t *FS_AddArchive_Fullpath( const fs_archive_t *archive, const char *file, int flags );
|
searchpath_t *FS_AddArchive_Fullpath( const fs_archive_t *archive, const char *file, int flags );
|
||||||
|
void _Mem_Free( void *data, const char *filename, int fileline );
|
||||||
|
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
ALLOC_CHECK( 2 ) MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
// search path utils
|
// search path utils
|
||||||
void FS_Rescan( void );
|
void FS_Rescan( void );
|
||||||
@@ -155,7 +159,8 @@ void FS_ClearSearchPath( void );
|
|||||||
void FS_AllowDirectPaths( qboolean enable );
|
void FS_AllowDirectPaths( qboolean enable );
|
||||||
void FS_AddGameDirectory( const char *dir, uint flags );
|
void FS_AddGameDirectory( const char *dir, uint flags );
|
||||||
void FS_AddGameHierarchy( const char *dir, uint flags );
|
void FS_AddGameHierarchy( const char *dir, uint flags );
|
||||||
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly );
|
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||||
|
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
int FS_SetCurrentDirectory( const char *path );
|
int FS_SetCurrentDirectory( const char *path );
|
||||||
void FS_Path_f( void );
|
void FS_Path_f( void );
|
||||||
|
|
||||||
@@ -163,14 +168,15 @@ void FS_Path_f( void );
|
|||||||
void FS_LoadGameInfo( const char *rootfolder );
|
void FS_LoadGameInfo( const char *rootfolder );
|
||||||
|
|
||||||
// file ops
|
// file ops
|
||||||
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly );
|
int FS_Close( file_t *file );
|
||||||
|
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly )
|
||||||
|
MALLOC_LIKE( FS_Close, 1 ) WARN_UNUSED_RESULT;
|
||||||
fs_offset_t FS_Write( file_t *file, const void *data, size_t datasize );
|
fs_offset_t FS_Write( file_t *file, const void *data, size_t datasize );
|
||||||
fs_offset_t FS_Read( file_t *file, void *buffer, size_t buffersize );
|
fs_offset_t FS_Read( file_t *file, void *buffer, size_t buffersize );
|
||||||
int FS_Seek( file_t *file, fs_offset_t offset, int whence );
|
int FS_Seek( file_t *file, fs_offset_t offset, int whence );
|
||||||
fs_offset_t FS_Tell( file_t *file );
|
fs_offset_t FS_Tell( file_t *file );
|
||||||
qboolean FS_Eof( file_t *file );
|
qboolean FS_Eof( file_t *file );
|
||||||
int FS_Flush( file_t *file );
|
int FS_Flush( file_t *file );
|
||||||
int FS_Close( file_t *file );
|
|
||||||
int FS_Gets( file_t *file, char *string, size_t bufsize );
|
int FS_Gets( file_t *file, char *string, size_t bufsize );
|
||||||
int FS_UnGetc( file_t *file, char c );
|
int FS_UnGetc( file_t *file, char c );
|
||||||
int FS_Getc( file_t *file );
|
int FS_Getc( file_t *file );
|
||||||
@@ -181,9 +187,12 @@ fs_offset_t FS_FileLength( file_t *f );
|
|||||||
qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
|
qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
|
||||||
|
|
||||||
// file buffer ops
|
// file buffer ops
|
||||||
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
|
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
||||||
byte *FS_LoadFileMalloc( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
|
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr );
|
byte *FS_LoadFileMalloc( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
||||||
|
MALLOC_LIKE( free, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr )
|
||||||
|
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
qboolean FS_WriteFile( const char *filename, const void *data, fs_offset_t len );
|
qboolean FS_WriteFile( const char *filename, const void *data, fs_offset_t len );
|
||||||
|
|
||||||
// file hashing
|
// file hashing
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ extern fs_globals_t *FI;
|
|||||||
#define FS_AllowDirectPaths (*g_fsapi.AllowDirectPaths)
|
#define FS_AllowDirectPaths (*g_fsapi.AllowDirectPaths)
|
||||||
#define FS_AddGameDirectory (*g_fsapi.AddGameDirectory)
|
#define FS_AddGameDirectory (*g_fsapi.AddGameDirectory)
|
||||||
#define FS_AddGameHierarchy (*g_fsapi.AddGameHierarchy)
|
#define FS_AddGameHierarchy (*g_fsapi.AddGameHierarchy)
|
||||||
|
#ifndef FSCALLBACK_OVERRIDE_MALLOC_LIKE
|
||||||
#define FS_Search (*g_fsapi.Search)
|
#define FS_Search (*g_fsapi.Search)
|
||||||
|
#endif
|
||||||
#define FS_SetCurrentDirectory (*g_fsapi.SetCurrentDirectory)
|
#define FS_SetCurrentDirectory (*g_fsapi.SetCurrentDirectory)
|
||||||
#define FS_Path_f (*g_fsapi.Path_f)
|
#define FS_Path_f (*g_fsapi.Path_f)
|
||||||
|
|
||||||
@@ -44,14 +46,16 @@ extern fs_globals_t *FI;
|
|||||||
#define FS_LoadGameInfo (*g_fsapi.LoadGameInfo)
|
#define FS_LoadGameInfo (*g_fsapi.LoadGameInfo)
|
||||||
|
|
||||||
// file ops
|
// file ops
|
||||||
|
#ifndef FSCALLBACK_OVERRIDE_MALLOC_LIKE
|
||||||
#define FS_Open (*g_fsapi.Open)
|
#define FS_Open (*g_fsapi.Open)
|
||||||
|
#define FS_Close (*g_fsapi.Close)
|
||||||
|
#endif
|
||||||
#define FS_Write (*g_fsapi.Write)
|
#define FS_Write (*g_fsapi.Write)
|
||||||
#define FS_Read (*g_fsapi.Read)
|
#define FS_Read (*g_fsapi.Read)
|
||||||
#define FS_Seek (*g_fsapi.Seek)
|
#define FS_Seek (*g_fsapi.Seek)
|
||||||
#define FS_Tell (*g_fsapi.Tell)
|
#define FS_Tell (*g_fsapi.Tell)
|
||||||
#define FS_Eof (*g_fsapi.Eof)
|
#define FS_Eof (*g_fsapi.Eof)
|
||||||
#define FS_Flush (*g_fsapi.Flush)
|
#define FS_Flush (*g_fsapi.Flush)
|
||||||
#define FS_Close (*g_fsapi.Close)
|
|
||||||
#define FS_Gets (*g_fsapi.Gets)
|
#define FS_Gets (*g_fsapi.Gets)
|
||||||
#define FS_UnGetc (*g_fsapi.UnGetc)
|
#define FS_UnGetc (*g_fsapi.UnGetc)
|
||||||
#define FS_Getc (*g_fsapi.Getc)
|
#define FS_Getc (*g_fsapi.Getc)
|
||||||
@@ -62,8 +66,10 @@ extern fs_globals_t *FI;
|
|||||||
#define FS_FileCopy (*g_fsapi.FileCopy)
|
#define FS_FileCopy (*g_fsapi.FileCopy)
|
||||||
|
|
||||||
// file buffer ops
|
// file buffer ops
|
||||||
|
#ifndef FSCALLBACK_OVERRIDE_MALLOC_LIKE
|
||||||
#define FS_LoadFile (*g_fsapi.LoadFile)
|
#define FS_LoadFile (*g_fsapi.LoadFile)
|
||||||
#define FS_LoadDirectFile (*g_fsapi.LoadDirectFile)
|
#define FS_LoadDirectFile (*g_fsapi.LoadDirectFile)
|
||||||
|
#endif
|
||||||
#define FS_WriteFile (*g_fsapi.WriteFile)
|
#define FS_WriteFile (*g_fsapi.WriteFile)
|
||||||
|
|
||||||
// file hashing
|
// file hashing
|
||||||
|
|||||||
@@ -299,7 +299,6 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
|||||||
if( error )
|
if( error )
|
||||||
*error = ZIP_LOAD_BAD_HEADER;
|
*error = ZIP_LOAD_BAD_HEADER;
|
||||||
|
|
||||||
Mem_Free( info );
|
|
||||||
FS_CloseZIP( zip );
|
FS_CloseZIP( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -316,7 +315,6 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
|||||||
if( error )
|
if( error )
|
||||||
*error = ZIP_LOAD_CORRUPTED;
|
*error = ZIP_LOAD_CORRUPTED;
|
||||||
|
|
||||||
Mem_Free( info );
|
|
||||||
FS_CloseZIP( zip );
|
FS_CloseZIP( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -364,7 +362,6 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
|||||||
if( error )
|
if( error )
|
||||||
*error = ZIP_LOAD_CORRUPTED;
|
*error = ZIP_LOAD_CORRUPTED;
|
||||||
|
|
||||||
Mem_Free( info );
|
|
||||||
FS_CloseZIP( zip );
|
FS_CloseZIP( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,6 @@ GNU General Public License for more details.
|
|||||||
#include "com_model.h"
|
#include "com_model.h"
|
||||||
#include "xash3d_mathlib.h"
|
#include "xash3d_mathlib.h"
|
||||||
|
|
||||||
const matrix3x4 m_matrix3x4_identity =
|
|
||||||
{
|
|
||||||
{ 1, 0, 0, 0 }, // PITCH [forward], org[0]
|
|
||||||
{ 0, 1, 0, 0 }, // YAW [right] , org[1]
|
|
||||||
{ 0, 0, 1, 0 }, // ROLL [up] , org[2]
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
========================================================================
|
========================================================================
|
||||||
|
|
||||||
@@ -225,14 +218,6 @@ void Matrix3x4_TransformAABB( const matrix3x4 world, const vec3_t mins, const ve
|
|||||||
VectorAdd( worldCenter, worldExtents, absmax );
|
VectorAdd( worldCenter, worldExtents, absmax );
|
||||||
}
|
}
|
||||||
|
|
||||||
const matrix4x4 m_matrix4x4_identity =
|
|
||||||
{
|
|
||||||
{ 1, 0, 0, 0 }, // PITCH
|
|
||||||
{ 0, 1, 0, 0 }, // YAW
|
|
||||||
{ 0, 0, 1, 0 }, // ROLL
|
|
||||||
{ 0, 0, 0, 1 }, // ORIGIN
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
========================================================================
|
========================================================================
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "crtlib.h"
|
#include "crtlib.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int Test_ExtractFilePath( void )
|
static int Test_ExtractFilePath( void )
|
||||||
{
|
{
|
||||||
char dst[64];
|
char dst[64];
|
||||||
const char *strings[] =
|
const char *strings[] =
|
||||||
|
|||||||
@@ -18,15 +18,14 @@ GNU General Public License for more details.
|
|||||||
#include "com_model.h"
|
#include "com_model.h"
|
||||||
#include "xash3d_mathlib.h"
|
#include "xash3d_mathlib.h"
|
||||||
#include "eiface.h"
|
#include "eiface.h"
|
||||||
|
#include "studio.h"
|
||||||
|
|
||||||
#define NUM_HULL_ROUNDS ARRAYSIZE( hull_table )
|
#define NUM_HULL_ROUNDS ARRAYSIZE( hull_table )
|
||||||
#define HULL_PRECISION 4
|
#define HULL_PRECISION 4
|
||||||
|
|
||||||
vec3_t vec3_origin = { 0, 0, 0 };
|
static const word hull_table[] = { 2, 4, 6, 8, 12, 16, 18, 24, 28, 32, 36, 40, 48, 54, 56, 60, 64, 72, 80, 112, 120, 128, 140, 176 };
|
||||||
|
|
||||||
static word hull_table[] = { 2, 4, 6, 8, 12, 16, 18, 24, 28, 32, 36, 40, 48, 54, 56, 60, 64, 72, 80, 112, 120, 128, 140, 176 };
|
const int boxpnt[6][4] =
|
||||||
|
|
||||||
int boxpnt[6][4] =
|
|
||||||
{
|
{
|
||||||
{ 0, 4, 6, 2 }, // +X
|
{ 0, 4, 6, 2 }, // +X
|
||||||
{ 0, 1, 5, 4 }, // +Y
|
{ 0, 1, 5, 4 }, // +Y
|
||||||
@@ -42,18 +41,7 @@ const float m_bytenormals[NUMVERTEXNORMALS][3] =
|
|||||||
#include "anorms.h"
|
#include "anorms.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
uint16_t FloatToHalf( float v )
|
||||||
=================
|
|
||||||
anglemod
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
float anglemod( float a )
|
|
||||||
{
|
|
||||||
a = (360.0f / 65536) * ((int)(a*(65536/360.0f)) & 65535);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
word FloatToHalf( float v )
|
|
||||||
{
|
{
|
||||||
unsigned int i = FloatAsUint( v );
|
unsigned int i = FloatAsUint( v );
|
||||||
unsigned int e = (i >> 23) & 0x00ff;
|
unsigned int e = (i >> 23) & 0x00ff;
|
||||||
@@ -69,7 +57,7 @@ word FloatToHalf( float v )
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
float HalfToFloat( word h )
|
float HalfToFloat( uint16_t h )
|
||||||
{
|
{
|
||||||
unsigned int f = (h << 16) & 0x80000000;
|
unsigned int f = (h << 16) & 0x80000000;
|
||||||
unsigned int em = h & 0x7fff;
|
unsigned int em = h & 0x7fff;
|
||||||
@@ -151,57 +139,6 @@ void RoundUpHullSize( vec3_t size )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
SignbitsForPlane
|
|
||||||
|
|
||||||
fast box on planeside test
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
int SignbitsForPlane( const vec3_t normal )
|
|
||||||
{
|
|
||||||
int bits, i;
|
|
||||||
|
|
||||||
for( bits = i = 0; i < 3; i++ )
|
|
||||||
if( normal[i] < 0.0f ) bits |= 1<<i;
|
|
||||||
return bits;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
PlaneTypeForNormal
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
int PlaneTypeForNormal( const vec3_t normal )
|
|
||||||
{
|
|
||||||
if( normal[0] == 1.0f )
|
|
||||||
return PLANE_X;
|
|
||||||
if( normal[1] == 1.0f )
|
|
||||||
return PLANE_Y;
|
|
||||||
if( normal[2] == 1.0f )
|
|
||||||
return PLANE_Z;
|
|
||||||
return PLANE_NONAXIAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
NearestPOW
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
int NearestPOW( int value, qboolean roundDown )
|
|
||||||
{
|
|
||||||
int n = 1;
|
|
||||||
|
|
||||||
if( value <= 0 ) return 1;
|
|
||||||
while( n < value ) n <<= 1;
|
|
||||||
|
|
||||||
if( roundDown )
|
|
||||||
{
|
|
||||||
if( n > value ) n >>= 1;
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
rsqrt
|
rsqrt
|
||||||
@@ -224,43 +161,6 @@ float rsqrt( float number )
|
|||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
VectorCompareEpsilon
|
|
||||||
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
qboolean VectorCompareEpsilon( const vec3_t vec1, const vec3_t vec2, vec_t epsilon )
|
|
||||||
{
|
|
||||||
vec_t ax, ay, az;
|
|
||||||
|
|
||||||
ax = fabs( vec1[0] - vec2[0] );
|
|
||||||
ay = fabs( vec1[1] - vec2[1] );
|
|
||||||
az = fabs( vec1[2] - vec2[2] );
|
|
||||||
|
|
||||||
if(( ax <= epsilon ) && ( ay <= epsilon ) && ( az <= epsilon ))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
float VectorNormalizeLength2( const vec3_t v, vec3_t out )
|
|
||||||
{
|
|
||||||
float length, ilength;
|
|
||||||
|
|
||||||
length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
|
|
||||||
length = sqrt( length );
|
|
||||||
|
|
||||||
if( length )
|
|
||||||
{
|
|
||||||
ilength = 1.0f / length;
|
|
||||||
out[0] = v[0] * ilength;
|
|
||||||
out[1] = v[1] * ilength;
|
|
||||||
out[2] = v[2] * ilength;
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up )
|
void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up )
|
||||||
{
|
{
|
||||||
float d;
|
float d;
|
||||||
@@ -276,42 +176,6 @@ void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up )
|
|||||||
VectorNormalize( up );
|
VectorNormalize( up );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
AngleVectors
|
|
||||||
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void GAME_EXPORT AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up )
|
|
||||||
{
|
|
||||||
float sr, sp, sy, cr, cp, cy;
|
|
||||||
|
|
||||||
SinCos( DEG2RAD( angles[YAW] ), &sy, &cy );
|
|
||||||
SinCos( DEG2RAD( angles[PITCH] ), &sp, &cp );
|
|
||||||
SinCos( DEG2RAD( angles[ROLL] ), &sr, &cr );
|
|
||||||
|
|
||||||
if( forward )
|
|
||||||
{
|
|
||||||
forward[0] = cp * cy;
|
|
||||||
forward[1] = cp * sy;
|
|
||||||
forward[2] = -sp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( right )
|
|
||||||
{
|
|
||||||
right[0] = (-1.0f * sr * sp * cy + -1.0f * cr * -sy );
|
|
||||||
right[1] = (-1.0f * sr * sp * sy + -1.0f * cr * cy );
|
|
||||||
right[2] = (-1.0f * sr * cp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( up )
|
|
||||||
{
|
|
||||||
up[0] = (cr * sp * cy + -sr * -sy );
|
|
||||||
up[1] = (cr * sp * sy + -sr * cy );
|
|
||||||
up[2] = (cr * cp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
VectorAngles
|
VectorAngles
|
||||||
@@ -384,39 +248,6 @@ void VectorsAngles( const vec3_t forward, const vec3_t right, const vec3_t up, v
|
|||||||
//
|
//
|
||||||
// bounds operations
|
// bounds operations
|
||||||
//
|
//
|
||||||
/*
|
|
||||||
=================
|
|
||||||
AddPointToBounds
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs )
|
|
||||||
{
|
|
||||||
float val;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for( i = 0; i < 3; i++ )
|
|
||||||
{
|
|
||||||
val = v[i];
|
|
||||||
if( val < mins[i] ) mins[i] = val;
|
|
||||||
if( val > maxs[i] ) maxs[i] = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
ExpandBounds (not used anywhere?)
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void ExpandBounds( vec3_t mins, vec3_t maxs, float offset )
|
|
||||||
{
|
|
||||||
mins[0] -= offset;
|
|
||||||
mins[1] -= offset;
|
|
||||||
mins[2] -= offset;
|
|
||||||
maxs[0] += offset;
|
|
||||||
maxs[1] += offset;
|
|
||||||
maxs[2] += offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
SphereIntersect
|
SphereIntersect
|
||||||
@@ -457,67 +288,9 @@ void PlaneIntersect( const mplane_t *plane, const vec3_t p0, const vec3_t p1, ve
|
|||||||
VectorMA( p0, sect, p1, out );
|
VectorMA( p0, sect, p1, out );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
RadiusFromBounds
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
float RadiusFromBounds( const vec3_t mins, const vec3_t maxs )
|
|
||||||
{
|
|
||||||
vec3_t corner;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for( i = 0; i < 3; i++ )
|
|
||||||
{
|
|
||||||
corner[i] = fabs( mins[i] ) > fabs( maxs[i] ) ? fabs( mins[i] ) : fabs( maxs[i] );
|
|
||||||
}
|
|
||||||
return VectorLength( corner );
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// studio utils
|
// studio utils
|
||||||
//
|
//
|
||||||
/*
|
|
||||||
====================
|
|
||||||
AngleQuaternion
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void AngleQuaternion( const vec3_t angles, vec4_t q, qboolean studio )
|
|
||||||
{
|
|
||||||
float sr, sp, sy, cr, cp, cy;
|
|
||||||
|
|
||||||
if( studio )
|
|
||||||
{
|
|
||||||
SinCos( angles[ROLL] * 0.5f, &sy, &cy );
|
|
||||||
SinCos( angles[YAW] * 0.5f, &sp, &cp );
|
|
||||||
SinCos( angles[PITCH] * 0.5f, &sr, &cr );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SinCos( DEG2RAD( angles[YAW] ) * 0.5f, &sy, &cy );
|
|
||||||
SinCos( DEG2RAD( angles[PITCH] ) * 0.5f, &sp, &cp );
|
|
||||||
SinCos( DEG2RAD( angles[ROLL] ) * 0.5f, &sr, &cr );
|
|
||||||
}
|
|
||||||
|
|
||||||
q[0] = sr * cp * cy - cr * sp * sy; // X
|
|
||||||
q[1] = cr * sp * cy + sr * cp * sy; // Y
|
|
||||||
q[2] = cr * cp * sy - sr * sp * cy; // Z
|
|
||||||
q[3] = cr * cp * cy + sr * sp * sy; // W
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
QuaternionAngle
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void QuaternionAngle( const vec4_t q, vec3_t angles )
|
|
||||||
{
|
|
||||||
matrix3x4 mat;
|
|
||||||
Matrix3x4_FromOriginQuat( mat, q, vec3_origin );
|
|
||||||
Matrix3x4_AnglesFromMatrix( mat, angles );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
@@ -680,25 +453,6 @@ int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p )
|
|||||||
return sides;
|
return sides;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
StudioSlerpBones
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void R_StudioSlerpBones( int numbones, vec4_t q1[], float pos1[][3], const vec4_t q2[], const float pos2[][3], float s )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
s = bound( 0.0f, s, 1.0f );
|
|
||||||
|
|
||||||
for( i = 0; i < numbones; i++ )
|
|
||||||
{
|
|
||||||
QuaternionSlerp( q1[i], q2[i], s, q1[i] );
|
|
||||||
VectorLerp( pos1[i], s, pos2[i], pos1[i] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
StudioCalcBoneQuaternion
|
StudioCalcBoneQuaternion
|
||||||
|
|||||||
@@ -23,74 +23,65 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "xash3d_types.h"
|
#include "xash3d_types.h"
|
||||||
#include "const.h"
|
|
||||||
#include "com_model.h"
|
/*
|
||||||
#include "studio.h"
|
===========================
|
||||||
|
|
||||||
|
CONSTANTS AND HELPER MACROS
|
||||||
|
|
||||||
|
===========================
|
||||||
|
*/
|
||||||
|
|
||||||
// euler angle order
|
// euler angle order
|
||||||
#define PITCH 0
|
#define PITCH 0
|
||||||
#define YAW 1
|
#define YAW 1
|
||||||
#define ROLL 2
|
#define ROLL 2
|
||||||
|
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
#define M_PI (double)3.14159265358979323846
|
#define M_PI (double)3.14159265358979323846
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef M_PI2
|
#define M_PI2 ((double)(M_PI * 2))
|
||||||
#define M_PI2 ((double)(M_PI * 2))
|
#define M_PI_F ((float)(M_PI))
|
||||||
#endif
|
#define M_PI2_F ((float)(M_PI2))
|
||||||
|
|
||||||
#define M_PI_F ((float)(M_PI))
|
#define RAD2DEG( x ) ((double)(x) * (double)(180.0 / M_PI))
|
||||||
#define M_PI2_F ((float)(M_PI2))
|
#define DEG2RAD( x ) ((double)(x) * (double)(M_PI / 180.0))
|
||||||
|
|
||||||
#define RAD2DEG( x ) ((double)(x) * (double)(180.0 / M_PI))
|
#define NUMVERTEXNORMALS 162
|
||||||
#define DEG2RAD( x ) ((double)(x) * (double)(M_PI / 180.0))
|
|
||||||
|
|
||||||
#define NUMVERTEXNORMALS 162
|
#define BOGUS_RANGE ((vec_t)114032.64) // world.size * 1.74
|
||||||
|
|
||||||
#define BOGUS_RANGE ((vec_t)114032.64) // world.size * 1.74
|
#define SIDE_FRONT 0
|
||||||
|
#define SIDE_BACK 1
|
||||||
|
#define SIDE_ON 2
|
||||||
|
#define SIDE_CROSS -2
|
||||||
|
|
||||||
#define SIDE_FRONT 0
|
#define PLANE_X 0 // 0 - 2 are axial planes
|
||||||
#define SIDE_BACK 1
|
#define PLANE_Y 1 // 3 needs alternate calc
|
||||||
#define SIDE_ON 2
|
#define PLANE_Z 2
|
||||||
#define SIDE_CROSS -2
|
#define PLANE_NONAXIAL 3
|
||||||
|
|
||||||
#define PLANE_X 0 // 0 - 2 are axial planes
|
#define EQUAL_EPSILON 0.001f
|
||||||
#define PLANE_Y 1 // 3 needs alternate calc
|
#define STOP_EPSILON 0.1f
|
||||||
#define PLANE_Z 2
|
#define ON_EPSILON 0.1f
|
||||||
#define PLANE_NONAXIAL 3
|
|
||||||
|
|
||||||
#define EQUAL_EPSILON 0.001f
|
#define RAD_TO_STUDIO (32768.0 / M_PI)
|
||||||
#define STOP_EPSILON 0.1f
|
#define STUDIO_TO_RAD (M_PI / 32768.0)
|
||||||
#define ON_EPSILON 0.1f
|
|
||||||
|
|
||||||
#define RAD_TO_STUDIO (32768.0 / M_PI)
|
#define INV127F ( 1.0f / 127.0f )
|
||||||
#define STUDIO_TO_RAD (M_PI / 32768.0)
|
#define INV255F ( 1.0f / 255.0f )
|
||||||
|
#define MAKE_SIGNED( x ) ((( x ) * INV127F ) - 1.0f )
|
||||||
|
|
||||||
#define INV127F ( 1.0f / 127.0f )
|
#define Q_min( a, b ) (((a) < (b)) ? (a) : (b))
|
||||||
#define INV255F ( 1.0f / 255.0f )
|
#define Q_max( a, b ) (((a) > (b)) ? (a) : (b))
|
||||||
#define MAKE_SIGNED( x ) ((( x ) * INV127F ) - 1.0f )
|
|
||||||
|
|
||||||
#define Q_min( a, b ) (((a) < (b)) ? (a) : (b))
|
|
||||||
#define Q_max( a, b ) (((a) > (b)) ? (a) : (b))
|
|
||||||
#define Q_equal_e( a, b, e ) (((a) >= ((b) - (e))) && ((a) <= ((b) + (e))))
|
#define Q_equal_e( a, b, e ) (((a) >= ((b) - (e))) && ((a) <= ((b) + (e))))
|
||||||
#define Q_equal( a, b ) Q_equal_e( a, b, EQUAL_EPSILON )
|
#define Q_equal( a, b ) Q_equal_e( a, b, EQUAL_EPSILON )
|
||||||
#define Q_recip( a ) ((float)(1.0f / (float)(a)))
|
#define Q_floor( a ) ((float)(int)(a))
|
||||||
#define Q_floor( a ) ((float)(int)(a))
|
#define Q_ceil( a ) ((float)(int)((a) + 1))
|
||||||
#define Q_ceil( a ) ((float)(int)((a) + 1))
|
#define Q_round( x, y ) (floor( x / y + 0.5f ) * y )
|
||||||
#define Q_round( x, y ) (floor( x / y + 0.5f ) * y )
|
#define Q_rint(x) ((x) < 0.0f ? ((int)((x)-0.5f)) : ((int)((x)+0.5f)))
|
||||||
#define Q_rint(x) ((x) < 0.0f ? ((int)((x)-0.5f)) : ((int)((x)+0.5f)))
|
#define ALIGN( x, a ) ((( x ) + (( size_t )( a ) - 1 )) & ~(( size_t )( a ) - 1 ))
|
||||||
|
|
||||||
#ifdef XASH_IRIX
|
|
||||||
#undef isnan
|
|
||||||
#endif
|
|
||||||
#ifdef isnan // check for C99 isnan
|
|
||||||
#define IS_NAN isnan
|
|
||||||
#else
|
|
||||||
#define IS_NAN(x) (((*(int *)&x) & (255<<23)) == (255<<23))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ALIGN( x, a ) ((( x ) + (( size_t )( a ) - 1 )) & ~(( size_t )( a ) - 1 ))
|
|
||||||
|
|
||||||
#define VectorIsNAN(v) (IS_NAN(v[0]) || IS_NAN(v[1]) || IS_NAN(v[2]))
|
#define VectorIsNAN(v) (IS_NAN(v[0]) || IS_NAN(v[1]) || IS_NAN(v[2]))
|
||||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
||||||
@@ -118,8 +109,11 @@ GNU General Public License for more details.
|
|||||||
#define Vector2Average(a,b,o) ((o)[0]=((a)[0]+(b)[0])*0.5f,(o)[1]=((a)[1]+(b)[1])*0.5f)
|
#define Vector2Average(a,b,o) ((o)[0]=((a)[0]+(b)[0])*0.5f,(o)[1]=((a)[1]+(b)[1])*0.5f)
|
||||||
#define VectorAverage(a,b,o) ((o)[0]=((a)[0]+(b)[0])*0.5f,(o)[1]=((a)[1]+(b)[1])*0.5f,(o)[2]=((a)[2]+(b)[2])*0.5f)
|
#define VectorAverage(a,b,o) ((o)[0]=((a)[0]+(b)[0])*0.5f,(o)[1]=((a)[1]+(b)[1])*0.5f,(o)[2]=((a)[2]+(b)[2])*0.5f)
|
||||||
#define Vector2Set(v, x, y) ((v)[0]=(x),(v)[1]=(y))
|
#define Vector2Set(v, x, y) ((v)[0]=(x),(v)[1]=(y))
|
||||||
|
#define Vector2Unpack(v, x, y) ((x)=(v)[0],(y)=(v)[1])
|
||||||
#define VectorSet(v, x, y, z) ((v)[0]=(x),(v)[1]=(y),(v)[2]=(z))
|
#define VectorSet(v, x, y, z) ((v)[0]=(x),(v)[1]=(y),(v)[2]=(z))
|
||||||
#define Vector4Set(v, a, b, c, d) ((v)[0]=(a),(v)[1]=(b),(v)[2]=(c),(v)[3] = (d))
|
#define VectorUnpack(v, x, y, z) ((x)=(v)[0],(y)=(v)[1],(z)=(v)[2])
|
||||||
|
#define Vector4Set(v, a, b, c, d) ((v)[0]=(a),(v)[1]=(b),(v)[2]=(c),(v)[3]=(d))
|
||||||
|
#define Vector4Unpack(v, a, b, c, d) ((a)=(v)[0],(b)=(v)[1],(c)=(v)[2],(d)=(v)[3])
|
||||||
#define VectorClear(x) ((x)[0]=(x)[1]=(x)[2]=0)
|
#define VectorClear(x) ((x)[0]=(x)[1]=(x)[2]=0)
|
||||||
#define Vector2Lerp( v1, lerp, v2, c ) ((c)[0] = (v1)[0] + (lerp) * ((v2)[0] - (v1)[0]), (c)[1] = (v1)[1] + (lerp) * ((v2)[1] - (v1)[1]))
|
#define Vector2Lerp( v1, lerp, v2, c ) ((c)[0] = (v1)[0] + (lerp) * ((v2)[0] - (v1)[0]), (c)[1] = (v1)[1] + (lerp) * ((v2)[1] - (v1)[1]))
|
||||||
#define VectorLerp( v1, lerp, v2, c ) ((c)[0] = (v1)[0] + (lerp) * ((v2)[0] - (v1)[0]), (c)[1] = (v1)[1] + (lerp) * ((v2)[1] - (v1)[1]), (c)[2] = (v1)[2] + (lerp) * ((v2)[2] - (v1)[2]))
|
#define VectorLerp( v1, lerp, v2, c ) ((c)[0] = (v1)[0] + (lerp) * ((v2)[0] - (v1)[0]), (c)[1] = (v1)[1] + (lerp) * ((v2)[1] - (v1)[1]), (c)[2] = (v1)[2] + (lerp) * ((v2)[2] - (v1)[2]))
|
||||||
@@ -138,9 +132,95 @@ GNU General Public License for more details.
|
|||||||
#define PlaneDiff(point,plane) (((plane)->type < 3 ? (point)[(plane)->type] : DotProduct((point), (plane)->normal)) - (plane)->dist)
|
#define PlaneDiff(point,plane) (((plane)->type < 3 ? (point)[(plane)->type] : DotProduct((point), (plane)->normal)) - (plane)->dist)
|
||||||
#define bound( min, num, max ) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))
|
#define bound( min, num, max ) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))
|
||||||
|
|
||||||
|
/*
|
||||||
|
===========================
|
||||||
|
|
||||||
|
CONSTANTS GLOBALS
|
||||||
|
|
||||||
|
===========================
|
||||||
|
*/
|
||||||
|
// a1ba: we never return pointers to these globals
|
||||||
|
// so help compiler optimize constants away
|
||||||
|
#define vec3_origin ((vec3_t){ 0.0f, 0.0f, 0.0f })
|
||||||
|
#define m_matrix3x4_identity ((matrix3x4) { \
|
||||||
|
{ 1.0f, 0.0f, 0.0f, 0.0f }, \
|
||||||
|
{ 0.0f, 1.0f, 0.0f, 0.0f }, \
|
||||||
|
{ 0.0f, 0.0f, 1.0f, 0.0f }} )
|
||||||
|
#define m_matrix4x4_identity ((matrix4x4) { \
|
||||||
|
{ 1.0f, 0.0f, 0.0f, 0.0f }, \
|
||||||
|
{ 0.0f, 1.0f, 0.0f, 0.0f }, \
|
||||||
|
{ 0.0f, 0.0f, 1.0f, 0.0f }, \
|
||||||
|
{ 0.0f, 0.0f, 0.0f, 1.0f }} )
|
||||||
|
|
||||||
|
extern const int boxpnt[6][4];
|
||||||
|
extern const float m_bytenormals[NUMVERTEXNORMALS][3];
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
===========================
|
||||||
|
|
||||||
|
MATH FUNCTIONS
|
||||||
|
|
||||||
|
===========================
|
||||||
|
*/
|
||||||
|
typedef struct mplane_s mplane_t;
|
||||||
|
typedef struct mstudiobone_s mstudiobone_t;
|
||||||
|
typedef struct mstudioanim_s mstudioanim_t;
|
||||||
|
|
||||||
|
float rsqrt( float number );
|
||||||
|
uint16_t FloatToHalf( float v );
|
||||||
|
float HalfToFloat( uint16_t h );
|
||||||
|
void RoundUpHullSize( vec3_t size );
|
||||||
|
void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up );
|
||||||
|
void VectorAngles( const float *forward, float *angles );
|
||||||
|
void VectorsAngles( const vec3_t forward, const vec3_t right, const vec3_t up, vec3_t angles );
|
||||||
|
void PlaneIntersect( const mplane_t *plane, const vec3_t p0, const vec3_t p1, vec3_t out );
|
||||||
|
qboolean SphereIntersect( const vec3_t vSphereCenter, float fSphereRadiusSquared, const vec3_t vLinePt, const vec3_t vLineDir );
|
||||||
|
void QuaternionSlerp( const vec4_t p, const vec4_t q, float t, vec4_t qt );
|
||||||
|
void R_StudioCalcBoneQuaternion( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const float *adj, vec4_t q );
|
||||||
|
void R_StudioCalcBonePosition( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const vec3_t adj, vec3_t pos );
|
||||||
|
int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p );
|
||||||
|
#define BOX_ON_PLANE_SIDE( emins, emaxs, p ) \
|
||||||
|
((( p )->type < 3 ) ? \
|
||||||
|
( \
|
||||||
|
((p)->dist <= (emins)[(p)->type]) ? 1 : \
|
||||||
|
( \
|
||||||
|
((p)->dist >= (emaxs)[(p)->type] ) ? 2 : 3 \
|
||||||
|
) \
|
||||||
|
) : BoxOnPlaneSide(( emins ), ( emaxs ), ( p )))
|
||||||
|
|
||||||
|
//
|
||||||
|
// matrixlib.c
|
||||||
|
//
|
||||||
|
#define Matrix3x4_LoadIdentity( mat ) Matrix3x4_Copy( mat, m_matrix3x4_identity )
|
||||||
|
#define Matrix3x4_Copy( out, in ) memcpy( out, in, sizeof( matrix3x4 ))
|
||||||
|
void Matrix3x4_VectorTransform( const matrix3x4 in, const float v[3], float out[3] );
|
||||||
|
void Matrix3x4_VectorITransform( const matrix3x4 in, const float v[3], float out[3] );
|
||||||
|
void Matrix3x4_VectorRotate( const matrix3x4 in, const float v[3], float out[3] );
|
||||||
|
void Matrix3x4_VectorIRotate( const matrix3x4 in, const float v[3], float out[3] );
|
||||||
|
void Matrix3x4_ConcatTransforms( matrix3x4 out, const matrix3x4 in1, const matrix3x4 in2 );
|
||||||
|
void Matrix3x4_FromOriginQuat( matrix3x4 out, const vec4_t quaternion, const vec3_t origin );
|
||||||
|
void Matrix3x4_CreateFromEntity( matrix3x4 out, const vec3_t angles, const vec3_t origin, float scale );
|
||||||
|
void Matrix3x4_TransformAABB( const matrix3x4 world, const vec3_t mins, const vec3_t maxs, vec3_t absmin, vec3_t absmax );
|
||||||
|
void Matrix3x4_AnglesFromMatrix( const matrix3x4 in, vec3_t out );
|
||||||
|
|
||||||
|
#define Matrix4x4_LoadIdentity( mat ) Matrix4x4_Copy( mat, m_matrix4x4_identity )
|
||||||
|
#define Matrix4x4_Copy( out, in ) memcpy( out, in, sizeof( matrix4x4 ))
|
||||||
|
void Matrix4x4_VectorTransform( const matrix4x4 in, const float v[3], float out[3] );
|
||||||
|
void Matrix4x4_VectorITransform( const matrix4x4 in, const float v[3], float out[3] );
|
||||||
|
void Matrix4x4_VectorRotate( const matrix4x4 in, const float v[3], float out[3] );
|
||||||
|
void Matrix4x4_VectorIRotate( const matrix4x4 in, const float v[3], float out[3] );
|
||||||
|
void Matrix4x4_ConcatTransforms( matrix4x4 out, const matrix4x4 in1, const matrix4x4 in2 );
|
||||||
|
void Matrix4x4_CreateFromEntity( matrix4x4 out, const vec3_t angles, const vec3_t origin, float scale );
|
||||||
|
void Matrix4x4_TransformPositivePlane( const matrix4x4 in, const vec3_t normal, float d, vec3_t out, float *dist );
|
||||||
|
void Matrix4x4_ConvertToEntity( const matrix4x4 in, vec3_t angles, vec3_t origin );
|
||||||
|
void Matrix4x4_Invert_Simple( matrix4x4 out, const matrix4x4 in1 );
|
||||||
|
qboolean Matrix4x4_Invert_Full( matrix4x4 out, const matrix4x4 in1 );
|
||||||
|
|
||||||
// horrible cast but helps not breaking strict aliasing in mathlib
|
// horrible cast but helps not breaking strict aliasing in mathlib
|
||||||
// as union type punning should be fine in C but not in C++
|
// as union type punning should be fine in C but not in C++
|
||||||
// so don't carry over this to C++ code
|
// so don't carry over this to C++ code
|
||||||
|
#ifndef __cplusplus
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
float fl;
|
float fl;
|
||||||
@@ -173,28 +253,98 @@ static inline float UintAsFloat( uint32_t u )
|
|||||||
bits.u = u;
|
bits.u = u;
|
||||||
return bits.fl;
|
return bits.fl;
|
||||||
}
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
// isnan implementation is broken on IRIX as reported in https://github.com/FWGS/xash3d-fwgs/pull/1211
|
||||||
|
#if defined( XASH_IRIX ) || !defined( isnan )
|
||||||
|
static inline int IS_NAN( float x )
|
||||||
|
{
|
||||||
|
int32_t i = FloatAsInt( x ); // only C
|
||||||
|
return i & ( 255 << 23 ) == ( 255 << 23 );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define IS_NAN isnan
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline float anglemod( float a )
|
||||||
|
{
|
||||||
|
a = (360.0f / 65536) * ((int)(a*(65536/360.0f)) & 65535);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void SinCos( float radians, float *sine, float *cosine )
|
static inline void SinCos( float radians, float *sine, float *cosine )
|
||||||
{
|
{
|
||||||
*sine = sin(radians);
|
*sine = sin( radians );
|
||||||
*cosine = cos(radians);
|
*cosine = cos( radians );
|
||||||
}
|
}
|
||||||
|
|
||||||
float rsqrt( float number );
|
static inline int NearestPOW( int value, qboolean roundDown )
|
||||||
float anglemod( float a );
|
{
|
||||||
word FloatToHalf( float v );
|
int n = 1;
|
||||||
float HalfToFloat( word h );
|
|
||||||
void RoundUpHullSize( vec3_t size );
|
if( value <= 0 ) return 1;
|
||||||
int SignbitsForPlane( const vec3_t normal );
|
while( n < value ) n <<= 1;
|
||||||
int PlaneTypeForNormal( const vec3_t normal );
|
|
||||||
int NearestPOW( int value, qboolean roundDown );
|
if( roundDown )
|
||||||
float VectorNormalizeLength2( const vec3_t v, vec3_t out );
|
{
|
||||||
qboolean VectorCompareEpsilon( const vec3_t vec1, const vec3_t vec2, vec_t epsilon );
|
if( n > value ) n >>= 1;
|
||||||
void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up );
|
}
|
||||||
void VectorAngles( const float *forward, float *angles );
|
return n;
|
||||||
void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up );
|
}
|
||||||
void VectorsAngles( const vec3_t forward, const vec3_t right, const vec3_t up, vec3_t angles );
|
|
||||||
void PlaneIntersect( const struct mplane_s *plane, const vec3_t p0, const vec3_t p1, vec3_t out );
|
static inline qboolean VectorCompareEpsilon( const vec3_t vec1, const vec3_t vec2, vec_t epsilon )
|
||||||
|
{
|
||||||
|
vec_t ax = fabs( vec1[0] - vec2[0] );
|
||||||
|
vec_t ay = fabs( vec1[1] - vec2[1] );
|
||||||
|
vec_t az = fabs( vec1[2] - vec2[2] );
|
||||||
|
|
||||||
|
return ( ax <= epsilon ) && ( ay <= epsilon ) && ( az <= epsilon ) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float VectorNormalizeLength2( const vec3_t v, vec3_t out )
|
||||||
|
{
|
||||||
|
float length = VectorLength( v );
|
||||||
|
|
||||||
|
if( length )
|
||||||
|
{
|
||||||
|
float ilength = 1.0f / length;
|
||||||
|
out[0] = v[0] * ilength;
|
||||||
|
out[1] = v[1] * ilength;
|
||||||
|
out[2] = v[2] * ilength;
|
||||||
|
}
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void GAME_EXPORT AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up )
|
||||||
|
{
|
||||||
|
float sr, sp, sy, cr, cp, cy;
|
||||||
|
|
||||||
|
SinCos( DEG2RAD( angles[YAW] ), &sy, &cy );
|
||||||
|
SinCos( DEG2RAD( angles[PITCH] ), &sp, &cp );
|
||||||
|
SinCos( DEG2RAD( angles[ROLL] ), &sr, &cr );
|
||||||
|
|
||||||
|
if( forward )
|
||||||
|
{
|
||||||
|
forward[0] = cp * cy;
|
||||||
|
forward[1] = cp * sy;
|
||||||
|
forward[2] = -sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( right )
|
||||||
|
{
|
||||||
|
right[0] = (-1.0f * sr * sp * cy + -1.0f * cr * -sy );
|
||||||
|
right[1] = (-1.0f * sr * sp * sy + -1.0f * cr * cy );
|
||||||
|
right[2] = (-1.0f * sr * cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( up )
|
||||||
|
{
|
||||||
|
up[0] = (cr * sp * cy + -sr * -sy );
|
||||||
|
up[1] = (cr * sp * sy + -sr * cy );
|
||||||
|
up[2] = (cr * cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline void ClearBounds( vec3_t mins, vec3_t maxs )
|
static inline void ClearBounds( vec3_t mins, vec3_t maxs )
|
||||||
{
|
{
|
||||||
@@ -221,20 +371,85 @@ static inline qboolean BoundsAndSphereIntersect( const vec3_t mins, const vec3_t
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );
|
static inline float RadiusFromBounds( const vec3_t mins, const vec3_t maxs )
|
||||||
qboolean SphereIntersect( const vec3_t vSphereCenter, float fSphereRadiusSquared, const vec3_t vLinePt, const vec3_t vLineDir );
|
{
|
||||||
float RadiusFromBounds( const vec3_t mins, const vec3_t maxs );
|
vec3_t corner;
|
||||||
void ExpandBounds( vec3_t mins, vec3_t maxs, float offset );
|
int i;
|
||||||
|
|
||||||
void AngleQuaternion( const vec3_t angles, vec4_t q, qboolean studio );
|
for( i = 0; i < 3; i++ )
|
||||||
void QuaternionAngle( const vec4_t q, vec3_t angles );
|
{
|
||||||
void QuaternionSlerp( const vec4_t p, const vec4_t q, float t, vec4_t qt );
|
float a = fabs( mins[i] );
|
||||||
|
float b = fabs( maxs[i] );
|
||||||
|
corner[i] = Q_max( a, b );
|
||||||
|
}
|
||||||
|
|
||||||
//
|
return VectorLength( corner );
|
||||||
// matrixlib.c
|
}
|
||||||
//
|
|
||||||
#define Matrix3x4_LoadIdentity( mat ) Matrix3x4_Copy( mat, m_matrix3x4_identity )
|
static inline void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs )
|
||||||
#define Matrix3x4_Copy( out, in ) memcpy( out, in, sizeof( matrix3x4 ))
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; i < 3; i++ )
|
||||||
|
{
|
||||||
|
float val = v[i];
|
||||||
|
if( val < mins[i] ) mins[i] = val;
|
||||||
|
if( val > maxs[i] ) maxs[i] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void ExpandBounds( vec3_t mins, vec3_t maxs, float offset )
|
||||||
|
{
|
||||||
|
mins[0] -= offset;
|
||||||
|
mins[1] -= offset;
|
||||||
|
mins[2] -= offset;
|
||||||
|
maxs[0] += offset;
|
||||||
|
maxs[1] += offset;
|
||||||
|
maxs[2] += offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int SignbitsForPlane( const vec3_t normal )
|
||||||
|
{
|
||||||
|
int bits, i;
|
||||||
|
|
||||||
|
for( bits = i = 0; i < 3; i++ )
|
||||||
|
if( normal[i] < 0.0f ) bits |= 1<<i;
|
||||||
|
return bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int PlaneTypeForNormal( const vec3_t normal )
|
||||||
|
{
|
||||||
|
if( normal[0] == 1.0f )
|
||||||
|
return PLANE_X;
|
||||||
|
if( normal[1] == 1.0f )
|
||||||
|
return PLANE_Y;
|
||||||
|
if( normal[2] == 1.0f )
|
||||||
|
return PLANE_Z;
|
||||||
|
return PLANE_NONAXIAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void AngleQuaternion( const vec3_t angles, vec4_t q, qboolean studio )
|
||||||
|
{
|
||||||
|
float sr, sp, sy, cr, cp, cy;
|
||||||
|
|
||||||
|
if( studio )
|
||||||
|
{
|
||||||
|
SinCos( angles[ROLL] * 0.5f, &sy, &cy );
|
||||||
|
SinCos( angles[YAW] * 0.5f, &sp, &cp );
|
||||||
|
SinCos( angles[PITCH] * 0.5f, &sr, &cr );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SinCos( DEG2RAD( angles[YAW] ) * 0.5f, &sy, &cy );
|
||||||
|
SinCos( DEG2RAD( angles[PITCH] ) * 0.5f, &sp, &cp );
|
||||||
|
SinCos( DEG2RAD( angles[ROLL] ) * 0.5f, &sr, &cr );
|
||||||
|
}
|
||||||
|
|
||||||
|
q[0] = sr * cp * cy - cr * sp * sy; // X
|
||||||
|
q[1] = cr * sp * cy + sr * cp * sy; // Y
|
||||||
|
q[2] = cr * cp * sy - sr * sp * cy; // Z
|
||||||
|
q[3] = cr * cp * cy + sr * sp * sy; // W
|
||||||
|
}
|
||||||
|
|
||||||
static inline void Matrix3x4_SetOrigin( matrix3x4 out, float x, float y, float z )
|
static inline void Matrix3x4_SetOrigin( matrix3x4 out, float x, float y, float z )
|
||||||
{
|
{
|
||||||
@@ -250,56 +465,23 @@ static inline void Matrix3x4_OriginFromMatrix( const matrix3x4 in, float *out )
|
|||||||
out[2] = in[2][3];
|
out[2] = in[2][3];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix3x4_VectorTransform( const matrix3x4 in, const float v[3], float out[3] );
|
static inline void QuaternionAngle( const vec4_t q, vec3_t angles )
|
||||||
void Matrix3x4_VectorITransform( const matrix3x4 in, const float v[3], float out[3] );
|
{
|
||||||
void Matrix3x4_VectorRotate( const matrix3x4 in, const float v[3], float out[3] );
|
matrix3x4 mat;
|
||||||
void Matrix3x4_VectorIRotate( const matrix3x4 in, const float v[3], float out[3] );
|
Matrix3x4_FromOriginQuat( mat, q, vec3_origin );
|
||||||
void Matrix3x4_ConcatTransforms( matrix3x4 out, const matrix3x4 in1, const matrix3x4 in2 );
|
Matrix3x4_AnglesFromMatrix( mat, angles );
|
||||||
void Matrix3x4_FromOriginQuat( matrix3x4 out, const vec4_t quaternion, const vec3_t origin );
|
}
|
||||||
void Matrix3x4_CreateFromEntity( matrix3x4 out, const vec3_t angles, const vec3_t origin, float scale );
|
|
||||||
void Matrix3x4_TransformAABB( const matrix3x4 world, const vec3_t mins, const vec3_t maxs, vec3_t absmin, vec3_t absmax );
|
|
||||||
void Matrix3x4_AnglesFromMatrix( const matrix3x4 in, vec3_t out );
|
|
||||||
|
|
||||||
#define Matrix4x4_LoadIdentity( mat ) Matrix4x4_Copy( mat, m_matrix4x4_identity )
|
static inline void R_StudioSlerpBones( int numbones, vec4_t q1[], float pos1[][3], const vec4_t q2[], const float pos2[][3], float s )
|
||||||
#define Matrix4x4_Copy( out, in ) memcpy( out, in, sizeof( matrix4x4 ))
|
{
|
||||||
|
int i;
|
||||||
|
s = bound( 0.0f, s, 1.0f );
|
||||||
|
|
||||||
void Matrix4x4_VectorTransform( const matrix4x4 in, const float v[3], float out[3] );
|
for( i = 0; i < numbones; i++ )
|
||||||
void Matrix4x4_VectorITransform( const matrix4x4 in, const float v[3], float out[3] );
|
{
|
||||||
void Matrix4x4_VectorRotate( const matrix4x4 in, const float v[3], float out[3] );
|
QuaternionSlerp( q1[i], q2[i], s, q1[i] );
|
||||||
void Matrix4x4_VectorIRotate( const matrix4x4 in, const float v[3], float out[3] );
|
VectorLerp( pos1[i], s, pos2[i], pos1[i] );
|
||||||
void Matrix4x4_ConcatTransforms( matrix4x4 out, const matrix4x4 in1, const matrix4x4 in2 );
|
}
|
||||||
void Matrix4x4_CreateFromEntity( matrix4x4 out, const vec3_t angles, const vec3_t origin, float scale );
|
}
|
||||||
void Matrix4x4_TransformPositivePlane( const matrix4x4 in, const vec3_t normal, float d, vec3_t out, float *dist );
|
|
||||||
void Matrix4x4_ConvertToEntity( const matrix4x4 in, vec3_t angles, vec3_t origin );
|
|
||||||
void Matrix4x4_Invert_Simple( matrix4x4 out, const matrix4x4 in1 );
|
|
||||||
qboolean Matrix4x4_Invert_Full( matrix4x4 out, const matrix4x4 in1 );
|
|
||||||
|
|
||||||
void R_StudioSlerpBones( int numbones, vec4_t q1[], float pos1[][3], const vec4_t q2[], const float pos2[][3], float s );
|
|
||||||
void R_StudioCalcBoneQuaternion( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const float *adj, vec4_t q );
|
|
||||||
void R_StudioCalcBonePosition( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const vec3_t adj, vec3_t pos );
|
|
||||||
|
|
||||||
int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p );
|
|
||||||
#define BOX_ON_PLANE_SIDE( emins, emaxs, p ) \
|
|
||||||
((( p )->type < 3 ) ? \
|
|
||||||
( \
|
|
||||||
((p)->dist <= (emins)[(p)->type]) ? \
|
|
||||||
1 \
|
|
||||||
: \
|
|
||||||
( \
|
|
||||||
((p)->dist >= (emaxs)[(p)->type]) ? \
|
|
||||||
2 \
|
|
||||||
: \
|
|
||||||
3 \
|
|
||||||
) \
|
|
||||||
) \
|
|
||||||
: \
|
|
||||||
BoxOnPlaneSide(( emins ), ( emaxs ), ( p )))
|
|
||||||
|
|
||||||
extern vec3_t vec3_origin;
|
|
||||||
extern int boxpnt[6][4];
|
|
||||||
extern const matrix3x4 m_matrix3x4_identity;
|
|
||||||
extern const matrix4x4 m_matrix4x4_identity;
|
|
||||||
extern const float m_bytenormals[NUMVERTEXNORMALS][3];
|
|
||||||
|
|
||||||
#endif // XASH3D_MATHLIB_H
|
#endif // XASH3D_MATHLIB_H
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,16 @@ ref_globals_t *gpGlobals;
|
|||||||
ref_client_t *gp_cl;
|
ref_client_t *gp_cl;
|
||||||
ref_host_t *gp_host;
|
ref_host_t *gp_host;
|
||||||
|
|
||||||
|
void _Mem_Free( void *data, const char *filename, int fileline )
|
||||||
|
{
|
||||||
|
gEngfuncs._Mem_Free( data, filename, fileline );
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
{
|
||||||
|
return gEngfuncs._Mem_Alloc( poolptr, size, clear, filename, fileline );
|
||||||
|
}
|
||||||
|
|
||||||
static void R_ClearScreen( void )
|
static void R_ClearScreen( void )
|
||||||
{
|
{
|
||||||
pglClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
|
pglClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ GNU General Public License for more details.
|
|||||||
#include "enginefeatures.h"
|
#include "enginefeatures.h"
|
||||||
#include "com_strings.h"
|
#include "com_strings.h"
|
||||||
#include "pm_movevars.h"
|
#include "pm_movevars.h"
|
||||||
#include "common/cvar.h"
|
#include "cvardef.h"
|
||||||
#include "gl_export.h"
|
#include "gl_export.h"
|
||||||
#include "wadfile.h"
|
#include "wadfile.h"
|
||||||
#include "common/mod_local.h"
|
#include "common/mod_local.h"
|
||||||
@@ -445,6 +445,9 @@ void R_GenerateVBO( void );
|
|||||||
void R_ClearVBO( void );
|
void R_ClearVBO( void );
|
||||||
void R_AddDecalVBO( decal_t *pdecal, msurface_t *surf );
|
void R_AddDecalVBO( decal_t *pdecal, msurface_t *surf );
|
||||||
void R_LightmapCoord( const vec3_t v, const msurface_t *surf, const float sample_size, vec2_t coords );
|
void R_LightmapCoord( const vec3_t v, const msurface_t *surf, const float sample_size, vec2_t coords );
|
||||||
|
qboolean R_HasGeneratedVBO( void );
|
||||||
|
void R_EnableVBO( qboolean enable );
|
||||||
|
qboolean R_HasEnabledVBO( void );
|
||||||
|
|
||||||
//
|
//
|
||||||
// gl_rpart.c
|
// gl_rpart.c
|
||||||
@@ -779,10 +782,14 @@ DECLARE_ENGINE_SHARED_CVAR_LIST()
|
|||||||
//
|
//
|
||||||
#include "crtlib.h"
|
#include "crtlib.h"
|
||||||
|
|
||||||
#define Mem_Malloc( pool, size ) gEngfuncs._Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
void _Mem_Free( void *data, const char *filename, int fileline );
|
||||||
#define Mem_Calloc( pool, size ) gEngfuncs._Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
ALLOC_CHECK( 2 ) MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
#define Mem_Malloc( pool, size ) _Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
||||||
|
#define Mem_Calloc( pool, size ) _Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
||||||
#define Mem_Realloc( pool, ptr, size ) gEngfuncs._Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
#define Mem_Realloc( pool, ptr, size ) gEngfuncs._Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
||||||
#define Mem_Free( mem ) gEngfuncs._Mem_Free( mem, __FILE__, __LINE__ )
|
#define Mem_Free( mem ) _Mem_Free( mem, __FILE__, __LINE__ )
|
||||||
#define Mem_AllocPool( name ) gEngfuncs._Mem_AllocPool( name, __FILE__, __LINE__ )
|
#define Mem_AllocPool( name ) gEngfuncs._Mem_AllocPool( name, __FILE__, __LINE__ )
|
||||||
#define Mem_FreePool( pool ) gEngfuncs._Mem_FreePool( pool, __FILE__, __LINE__ )
|
#define Mem_FreePool( pool ) gEngfuncs._Mem_FreePool( pool, __FILE__, __LINE__ )
|
||||||
#define Mem_EmptyPool( pool ) gEngfuncs._Mem_EmptyPool( pool, __FILE__, __LINE__ )
|
#define Mem_EmptyPool( pool ) gEngfuncs._Mem_EmptyPool( pool, __FILE__, __LINE__ )
|
||||||
|
|||||||
@@ -742,10 +742,8 @@ static void R_RenderInfo_f( void )
|
|||||||
gEngfuncs.Con_Printf( "GL4ES_VERSION: %s\n", version );
|
gEngfuncs.Con_Printf( "GL4ES_VERSION: %s\n", version );
|
||||||
if( extensions )
|
if( extensions )
|
||||||
gEngfuncs.Con_Reportf( "GL4ES_EXTENSIONS: %s\n", extensions );
|
gEngfuncs.Con_Reportf( "GL4ES_EXTENSIONS: %s\n", extensions );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gEngfuncs.Con_Printf( "GL_MAX_TEXTURE_SIZE: %i\n", glConfig.max_2d_texture_size );
|
gEngfuncs.Con_Printf( "GL_MAX_TEXTURE_SIZE: %i\n", glConfig.max_2d_texture_size );
|
||||||
|
|
||||||
if( GL_Support( GL_ARB_MULTITEXTURE ))
|
if( GL_Support( GL_ARB_MULTITEXTURE ))
|
||||||
@@ -1150,6 +1148,10 @@ void GL_InitExtensions( void )
|
|||||||
gEngfuncs.Cvar_SetValue( "gl_finish", 1 );
|
gEngfuncs.Cvar_SetValue( "gl_finish", 1 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// we do not want to write vbo code that does not use multitexture
|
||||||
|
if( !GL_Support( GL_ARB_VERTEX_BUFFER_OBJECT_EXT ) || !GL_Support( GL_ARB_MULTITEXTURE ) || glConfig.max_texture_units < 2 )
|
||||||
|
gEngfuncs.Cvar_FullSet( "gl_vbo", "0", FCVAR_READ_ONLY );
|
||||||
|
|
||||||
R_RenderInfo_f();
|
R_RenderInfo_f();
|
||||||
|
|
||||||
tr.framecount = tr.visframecount = 1;
|
tr.framecount = tr.visframecount = 1;
|
||||||
|
|||||||
@@ -1010,21 +1010,32 @@ void R_GammaChanged( qboolean do_reset_gamma )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void R_CheckGamma( void )
|
static void R_CheckCvars( void )
|
||||||
{
|
{
|
||||||
qboolean rebuild = false;
|
qboolean rebuild = false;
|
||||||
|
|
||||||
if( FBitSet( gl_overbright.flags, FCVAR_CHANGED ))
|
if( FBitSet( gl_overbright.flags, FCVAR_CHANGED ))
|
||||||
{
|
{
|
||||||
rebuild = true;
|
|
||||||
ClearBits( gl_overbright.flags, FCVAR_CHANGED );
|
ClearBits( gl_overbright.flags, FCVAR_CHANGED );
|
||||||
|
rebuild = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( gl_overbright.value && ( FBitSet( r_vbo.flags, FCVAR_CHANGED ) || FBitSet( r_vbo_overbrightmode.flags, FCVAR_CHANGED ) ) )
|
if( FBitSet( r_vbo.flags, FCVAR_CHANGED ))
|
||||||
{
|
{
|
||||||
rebuild = true;
|
|
||||||
ClearBits( r_vbo.flags, FCVAR_CHANGED );
|
ClearBits( r_vbo.flags, FCVAR_CHANGED );
|
||||||
|
|
||||||
|
R_EnableVBO( r_vbo.value ? true : false );
|
||||||
|
if( R_HasEnabledVBO( ))
|
||||||
|
R_GenerateVBO();
|
||||||
|
|
||||||
|
if( gl_overbright.value )
|
||||||
|
rebuild = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( FBitSet( r_vbo_overbrightmode.flags, FCVAR_CHANGED ) && gl_overbright.value )
|
||||||
|
{
|
||||||
ClearBits( r_vbo_overbrightmode.flags, FCVAR_CHANGED );
|
ClearBits( r_vbo_overbrightmode.flags, FCVAR_CHANGED );
|
||||||
|
rebuild = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rebuild )
|
if( rebuild )
|
||||||
@@ -1046,7 +1057,7 @@ void R_BeginFrame( qboolean clearScene )
|
|||||||
pglClear( GL_COLOR_BUFFER_BIT );
|
pglClear( GL_COLOR_BUFFER_BIT );
|
||||||
}
|
}
|
||||||
|
|
||||||
R_CheckGamma();
|
R_CheckCvars();
|
||||||
|
|
||||||
R_Set2DMode( true );
|
R_Set2DMode( true );
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,10 @@ void R_NewMap( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
GL_BuildLightmaps ();
|
GL_BuildLightmaps ();
|
||||||
R_GenerateVBO();
|
|
||||||
|
R_ClearVBO();
|
||||||
|
if( R_HasEnabledVBO( ))
|
||||||
|
R_GenerateVBO();
|
||||||
R_ResetRipples();
|
R_ResetRipples();
|
||||||
|
|
||||||
if( gEngfuncs.drawFuncs->R_NewMap != NULL )
|
if( gEngfuncs.drawFuncs->R_NewMap != NULL )
|
||||||
|
|||||||
@@ -229,10 +229,9 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
|
|||||||
VectorAdd( verts[0], delta, verts[2] );
|
VectorAdd( verts[0], delta, verts[2] );
|
||||||
VectorAdd( verts[1], delta, verts[3] );
|
VectorAdd( verts[1], delta, verts[3] );
|
||||||
|
|
||||||
if( p->color > sizeof( gTracerColors ) / sizeof( gTracerColors[0] ))
|
if( p->color < 0 || p->color > sizeof( gTracerColors ) / sizeof( gTracerColors[0] ))
|
||||||
{
|
{
|
||||||
gEngfuncs.Con_Printf( S_ERROR "UserTracer with color(%d) > %zu\n", p->color, sizeof( gTracerColors ) / sizeof( gTracerColors[0] ));
|
p->color = TRACER_COLORINDEX_DEFAULT;
|
||||||
p->color = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
color = gTracerColors[p->color];
|
color = gTracerColors[p->color];
|
||||||
|
|||||||
@@ -718,7 +718,7 @@ static void R_BuildLightMap( msurface_t *surf, byte *dest, int stride, qboolean
|
|||||||
tmax = ( info->lightextents[1] / sample_size ) + 1;
|
tmax = ( info->lightextents[1] / sample_size ) + 1;
|
||||||
size = smax * tmax;
|
size = smax * tmax;
|
||||||
if( gl_overbright.value )
|
if( gl_overbright.value )
|
||||||
lightscale = (r_vbo.value && !r_vbo_overbrightmode.value) ? 171 : 256;
|
lightscale = ( R_HasEnabledVBO() && !r_vbo_overbrightmode.value) ? 171 : 256;
|
||||||
else lightscale = ( pow( 2.0f, 1.0f / v_lightgamma->value ) * 256 ) + 0.5;
|
else lightscale = ( pow( 2.0f, 1.0f / v_lightgamma->value ) * 256 ) + 0.5;
|
||||||
|
|
||||||
lm = surf->samples;
|
lm = surf->samples;
|
||||||
@@ -927,7 +927,7 @@ static void R_BlendLightmaps( void )
|
|||||||
if( gl_overbright.value )
|
if( gl_overbright.value )
|
||||||
{
|
{
|
||||||
pglBlendFunc( GL_DST_COLOR, GL_SRC_COLOR );
|
pglBlendFunc( GL_DST_COLOR, GL_SRC_COLOR );
|
||||||
if(!( r_vbo.value && !r_vbo_overbrightmode.value ))
|
if(!( R_HasEnabledVBO() && !r_vbo_overbrightmode.value ))
|
||||||
pglColor4f( 128.0f / 192.0f, 128.0f / 192.0f, 128.0f / 192.0f, 1.0f );
|
pglColor4f( 128.0f / 192.0f, 128.0f / 192.0f, 128.0f / 192.0f, 1.0f );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1135,6 +1135,148 @@ static void R_RenderDetails( int passes )
|
|||||||
GL_ResetFogColor();
|
GL_ResetFogColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void R_RenderFullbrightForSurface( msurface_t *fa, texture_t *t )
|
||||||
|
{
|
||||||
|
if( !t->fb_texturenum )
|
||||||
|
return;
|
||||||
|
|
||||||
|
fa->info->lumachain = fullbright_surfaces[t->fb_texturenum];
|
||||||
|
fullbright_surfaces[t->fb_texturenum] = fa->info;
|
||||||
|
draw_fullbrights = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_RenderDetailsForSurface( msurface_t *fa, texture_t *t )
|
||||||
|
{
|
||||||
|
if( !r_detailtextures.value )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( glState.isFogEnabled )
|
||||||
|
{
|
||||||
|
// don't apply detail textures for windows in the fog
|
||||||
|
if( RI.currententity->curstate.rendermode != kRenderTransTexture )
|
||||||
|
{
|
||||||
|
if( t->dt_texturenum )
|
||||||
|
{
|
||||||
|
fa->info->detailchain = detail_surfaces[t->dt_texturenum];
|
||||||
|
detail_surfaces[t->dt_texturenum] = fa->info;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// draw stub detail texture for underwater surfaces
|
||||||
|
fa->info->detailchain = detail_surfaces[tr.grayTexture];
|
||||||
|
detail_surfaces[tr.grayTexture] = fa->info;
|
||||||
|
}
|
||||||
|
draw_details = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( t->dt_texturenum )
|
||||||
|
{
|
||||||
|
fa->info->detailchain = detail_surfaces[t->dt_texturenum];
|
||||||
|
detail_surfaces[t->dt_texturenum] = fa->info;
|
||||||
|
draw_details = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_RenderDecalsForSurface( msurface_t *fa, int cull_type )
|
||||||
|
{
|
||||||
|
if( RI.currententity->curstate.rendermode == kRenderNormal )
|
||||||
|
{
|
||||||
|
// batch decals to draw later
|
||||||
|
if( tr.num_draw_decals < MAX_DECAL_SURFS && fa->pdecals )
|
||||||
|
tr.draw_decals[tr.num_draw_decals++] = fa;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if rendermode != kRenderNormal draw decals sequentially
|
||||||
|
DrawSurfaceDecals( fa, true, (cull_type == CULL_BACKSIDE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static qboolean R_CheckLightMap( msurface_t *fa )
|
||||||
|
{
|
||||||
|
qboolean is_dynamic = false;
|
||||||
|
int maps;
|
||||||
|
|
||||||
|
// check for lightmap modification
|
||||||
|
for( maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++ )
|
||||||
|
{
|
||||||
|
if( tr.lightstylevalue[fa->styles[maps]] != fa->cached_light[maps] )
|
||||||
|
goto dynamic;
|
||||||
|
}
|
||||||
|
|
||||||
|
// dynamic this frame or dynamic previously
|
||||||
|
if( fa->dlightframe == tr.framecount )
|
||||||
|
{
|
||||||
|
dynamic:
|
||||||
|
// NOTE: at this point we have only valid textures
|
||||||
|
if( r_dynamic->value )
|
||||||
|
is_dynamic = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( is_dynamic )
|
||||||
|
{
|
||||||
|
const int style = fa->styles[maps];
|
||||||
|
|
||||||
|
if( maps < MAXLIGHTMAPS && ( style >= 32 || style == 0 || style == 20 ) && fa->dlightframe != tr.framecount )
|
||||||
|
{
|
||||||
|
byte temp[132*132*4];
|
||||||
|
mextrasurf_t *info = fa->info;
|
||||||
|
int sample_size;
|
||||||
|
int smax, tmax;
|
||||||
|
|
||||||
|
sample_size = gEngfuncs.Mod_SampleSizeForFace( fa );
|
||||||
|
smax = ( info->lightextents[0] / sample_size ) + 1;
|
||||||
|
tmax = ( info->lightextents[1] / sample_size ) + 1;
|
||||||
|
|
||||||
|
if( smax < 132 && tmax < 132 )
|
||||||
|
R_BuildLightMap( fa, temp, smax * 4, true );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
smax = Q_min( smax, 132 );
|
||||||
|
tmax = Q_min( tmax, 132 );
|
||||||
|
memset( temp, 255, sizeof( temp ));
|
||||||
|
//Host_MapDesignError( "%s: bad surface extents: %d %d", __func__, fa->extents[0], fa->extents[1] );
|
||||||
|
}
|
||||||
|
|
||||||
|
R_SetCacheState( fa );
|
||||||
|
|
||||||
|
#ifdef XASH_WES
|
||||||
|
GL_Bind( XASH_TEXTURE1, tr.lightmapTextures[fa->lightmaptexturenum] );
|
||||||
|
pglTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE );
|
||||||
|
#else
|
||||||
|
GL_Bind( XASH_TEXTURE0, tr.lightmapTextures[fa->lightmaptexturenum] );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pglTexSubImage2D( GL_TEXTURE_2D, 0, fa->light_s, fa->light_t, smax, tmax, GL_RGBA, GL_UNSIGNED_BYTE, temp );
|
||||||
|
|
||||||
|
#ifdef XASH_WES
|
||||||
|
GL_SelectTexture( XASH_TEXTURE0 );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true; // add to dynamic chain
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // updated
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_RenderLightmapForSurface( msurface_t *fa )
|
||||||
|
{
|
||||||
|
if( !fa->polys || FBitSet( fa->flags, SURF_DRAWTILED ))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( R_CheckLightMap( fa ))
|
||||||
|
{
|
||||||
|
fa->info->lightmapchain = gl_lms.dynamic_surfaces;
|
||||||
|
gl_lms.dynamic_surfaces = fa;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fa->info->lightmapchain = gl_lms.lightmap_surfaces[fa->lightmaptexturenum];
|
||||||
|
gl_lms.lightmap_surfaces[fa->lightmaptexturenum] = fa;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
R_RenderBrushPoly
|
R_RenderBrushPoly
|
||||||
@@ -1142,8 +1284,6 @@ R_RenderBrushPoly
|
|||||||
*/
|
*/
|
||||||
static void R_RenderBrushPoly( msurface_t *fa, int cull_type )
|
static void R_RenderBrushPoly( msurface_t *fa, int cull_type )
|
||||||
{
|
{
|
||||||
qboolean is_dynamic = false;
|
|
||||||
int maps;
|
|
||||||
texture_t *t;
|
texture_t *t;
|
||||||
|
|
||||||
r_stats.c_world_polys++;
|
r_stats.c_world_polys++;
|
||||||
@@ -1163,109 +1303,11 @@ static void R_RenderBrushPoly( msurface_t *fa, int cull_type )
|
|||||||
}
|
}
|
||||||
else GL_Bind( XASH_TEXTURE0, t->gl_texturenum );
|
else GL_Bind( XASH_TEXTURE0, t->gl_texturenum );
|
||||||
|
|
||||||
if( t->fb_texturenum )
|
R_RenderFullbrightForSurface( fa, t );
|
||||||
{
|
R_RenderDetailsForSurface( fa, t );
|
||||||
fa->info->lumachain = fullbright_surfaces[t->fb_texturenum];
|
|
||||||
fullbright_surfaces[t->fb_texturenum] = fa->info;
|
|
||||||
draw_fullbrights = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( r_detailtextures.value )
|
|
||||||
{
|
|
||||||
if( glState.isFogEnabled )
|
|
||||||
{
|
|
||||||
// don't apply detail textures for windows in the fog
|
|
||||||
if( RI.currententity->curstate.rendermode != kRenderTransTexture )
|
|
||||||
{
|
|
||||||
if( t->dt_texturenum )
|
|
||||||
{
|
|
||||||
fa->info->detailchain = detail_surfaces[t->dt_texturenum];
|
|
||||||
detail_surfaces[t->dt_texturenum] = fa->info;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// draw stub detail texture for underwater surfaces
|
|
||||||
fa->info->detailchain = detail_surfaces[tr.grayTexture];
|
|
||||||
detail_surfaces[tr.grayTexture] = fa->info;
|
|
||||||
}
|
|
||||||
draw_details = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( t->dt_texturenum )
|
|
||||||
{
|
|
||||||
fa->info->detailchain = detail_surfaces[t->dt_texturenum];
|
|
||||||
detail_surfaces[t->dt_texturenum] = fa->info;
|
|
||||||
draw_details = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawGLPoly( fa->polys, 0.0f, 0.0f );
|
DrawGLPoly( fa->polys, 0.0f, 0.0f );
|
||||||
|
R_RenderDecalsForSurface( fa, cull_type );
|
||||||
if( RI.currententity->curstate.rendermode == kRenderNormal )
|
R_RenderLightmapForSurface( fa );
|
||||||
{
|
|
||||||
// batch decals to draw later
|
|
||||||
if( tr.num_draw_decals < MAX_DECAL_SURFS && fa->pdecals )
|
|
||||||
tr.draw_decals[tr.num_draw_decals++] = fa;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// if rendermode != kRenderNormal draw decals sequentially
|
|
||||||
DrawSurfaceDecals( fa, true, (cull_type == CULL_BACKSIDE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if( FBitSet( fa->flags, SURF_DRAWTILED ))
|
|
||||||
return; // no lightmaps anyway
|
|
||||||
|
|
||||||
// check for lightmap modification
|
|
||||||
for( maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++ )
|
|
||||||
{
|
|
||||||
if( tr.lightstylevalue[fa->styles[maps]] != fa->cached_light[maps] )
|
|
||||||
goto dynamic;
|
|
||||||
}
|
|
||||||
|
|
||||||
// dynamic this frame or dynamic previously
|
|
||||||
if( fa->dlightframe == tr.framecount )
|
|
||||||
{
|
|
||||||
dynamic:
|
|
||||||
// NOTE: at this point we have only valid textures
|
|
||||||
if( r_dynamic->value ) is_dynamic = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( is_dynamic )
|
|
||||||
{
|
|
||||||
if(( maps < MAXLIGHTMAPS ) && ( fa->styles[maps] >= 32 || fa->styles[maps] == 0 || fa->styles[maps] == 20 ) && ( fa->dlightframe != tr.framecount ))
|
|
||||||
{
|
|
||||||
byte temp[132*132*4];
|
|
||||||
mextrasurf_t *info = fa->info;
|
|
||||||
int sample_size;
|
|
||||||
int smax, tmax;
|
|
||||||
|
|
||||||
sample_size = gEngfuncs.Mod_SampleSizeForFace( fa );
|
|
||||||
smax = ( info->lightextents[0] / sample_size ) + 1;
|
|
||||||
tmax = ( info->lightextents[1] / sample_size ) + 1;
|
|
||||||
|
|
||||||
R_BuildLightMap( fa, temp, smax * 4, true );
|
|
||||||
R_SetCacheState( fa );
|
|
||||||
|
|
||||||
GL_Bind( XASH_TEXTURE0, tr.lightmapTextures[fa->lightmaptexturenum] );
|
|
||||||
|
|
||||||
pglTexSubImage2D( GL_TEXTURE_2D, 0, fa->light_s, fa->light_t, smax, tmax,
|
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, temp );
|
|
||||||
|
|
||||||
fa->info->lightmapchain = gl_lms.lightmap_surfaces[fa->lightmaptexturenum];
|
|
||||||
gl_lms.lightmap_surfaces[fa->lightmaptexturenum] = fa;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fa->info->lightmapchain = gl_lms.dynamic_surfaces;
|
|
||||||
gl_lms.dynamic_surfaces = fa;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fa->info->lightmapchain = gl_lms.lightmap_surfaces[fa->lightmaptexturenum];
|
|
||||||
gl_lms.lightmap_surfaces[fa->lightmaptexturenum] = fa;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1541,7 +1583,7 @@ void R_DrawBrushModel( cl_entity_t *e )
|
|||||||
model_t *clmodel;
|
model_t *clmodel;
|
||||||
qboolean rotated;
|
qboolean rotated;
|
||||||
dlight_t *l;
|
dlight_t *l;
|
||||||
qboolean allow_vbo = r_vbo.value;
|
qboolean allow_vbo = R_HasEnabledVBO();
|
||||||
|
|
||||||
if( !RI.drawWorld ) return;
|
if( !RI.drawWorld ) return;
|
||||||
|
|
||||||
@@ -1791,6 +1833,10 @@ struct vbo_static_s
|
|||||||
int maxarraysplit_tex;
|
int maxarraysplit_tex;
|
||||||
int minarraysplit_lm;
|
int minarraysplit_lm;
|
||||||
int maxarraysplit_lm;
|
int maxarraysplit_lm;
|
||||||
|
|
||||||
|
// cvar state potentially might be changed during frame
|
||||||
|
// so only enable VBO at the beginning of frame
|
||||||
|
qboolean enabled;
|
||||||
} vbos;
|
} vbos;
|
||||||
|
|
||||||
struct multitexturestate_s
|
struct multitexturestate_s
|
||||||
@@ -1827,7 +1873,6 @@ enum lightmap_state_e
|
|||||||
VBO_LIGHTMAP_DYNAMIC
|
VBO_LIGHTMAP_DYNAMIC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static struct arraystate_s
|
static struct arraystate_s
|
||||||
{
|
{
|
||||||
enum array_state_e astate;
|
enum array_state_e astate;
|
||||||
@@ -1837,6 +1882,20 @@ static struct arraystate_s
|
|||||||
qboolean decal_mode;
|
qboolean decal_mode;
|
||||||
} vboarray;
|
} vboarray;
|
||||||
|
|
||||||
|
qboolean R_HasGeneratedVBO( void )
|
||||||
|
{
|
||||||
|
return vbos.mempool != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void R_EnableVBO( qboolean enable )
|
||||||
|
{
|
||||||
|
vbos.enabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
qboolean R_HasEnabledVBO( void )
|
||||||
|
{
|
||||||
|
return vbos.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
@@ -1848,29 +1907,23 @@ Allocate memory for arrays, fill it with vertex attribs and upload to GPU
|
|||||||
void R_GenerateVBO( void )
|
void R_GenerateVBO( void )
|
||||||
{
|
{
|
||||||
model_t *world = WORLDMODEL;
|
model_t *world = WORLDMODEL;
|
||||||
msurface_t *surfaces = world->surfaces;
|
msurface_t *surfaces;
|
||||||
int numsurfaces = world->numsurfaces;
|
int numsurfaces;
|
||||||
int numtextures = world->numtextures;
|
int numtextures;
|
||||||
int numlightmaps = gl_lms.current_lightmap_texture;
|
const int numlightmaps = gl_lms.current_lightmap_texture;
|
||||||
int k, len = 0;
|
int k, len = 0;
|
||||||
vboarray_t *vbo;
|
vboarray_t *vbo;
|
||||||
uint maxindex = 0;
|
uint maxindex = 0;
|
||||||
double t1, t2, t3;
|
double t1, t2, t3;
|
||||||
|
|
||||||
R_ClearVBO();
|
if( R_HasGeneratedVBO() || !world || !world->surfaces )
|
||||||
|
|
||||||
// we do not want to write vbo code that does not use multitexture
|
|
||||||
if( !GL_Support( GL_ARB_VERTEX_BUFFER_OBJECT_EXT ) || !GL_Support( GL_ARB_MULTITEXTURE ) || glConfig.max_texture_units < 2 )
|
|
||||||
{
|
|
||||||
gEngfuncs.Cvar_FullSet( "gl_vbo", "0", FCVAR_READ_ONLY );
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
t1 = gEngfuncs.pfnTime();
|
t1 = gEngfuncs.pfnTime();
|
||||||
|
|
||||||
// save in config if enabled manually
|
surfaces = world->surfaces;
|
||||||
if( r_vbo.value )
|
numsurfaces = world->numsurfaces;
|
||||||
r_vbo.flags |= FCVAR_ARCHIVE;
|
numtextures = world->numtextures;
|
||||||
|
|
||||||
vbos.mempool = Mem_AllocPool("Render VBO Zone");
|
vbos.mempool = Mem_AllocPool("Render VBO Zone");
|
||||||
|
|
||||||
@@ -3021,14 +3074,14 @@ void R_DrawVBO( qboolean drawlightmap, qboolean drawtextures )
|
|||||||
int k;
|
int k;
|
||||||
vboarray_t *vbo = vbos.arraylist;
|
vboarray_t *vbo = vbos.arraylist;
|
||||||
|
|
||||||
if( !r_vbo.value )
|
if( !R_HasGeneratedVBO() || !R_HasEnabledVBO() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GL_SetupFogColorForSurfacesEx( 1, 0.5f, false );
|
GL_SetupFogColorForSurfacesEx( 1, 0.5f, false );
|
||||||
|
|
||||||
R_SetupVBOArrayStatic( vbo, drawlightmap, drawtextures );
|
R_SetupVBOArrayStatic( vbo, drawlightmap, drawtextures );
|
||||||
mtst.skiptexture = !drawtextures;
|
mtst.skiptexture = !drawtextures;
|
||||||
mtst.tmu_dt = glConfig.max_texture_units > 2 && r_vbo_detail.value == 2? XASH_TEXTURE2:-1;
|
mtst.tmu_dt = glConfig.max_texture_units > 2 && r_vbo_detail.value == 2 ? XASH_TEXTURE2 : -1;
|
||||||
|
|
||||||
// setup limits
|
// setup limits
|
||||||
if( vbos.minlightmap > vbos.minarraysplit_lm )
|
if( vbos.minlightmap > vbos.minarraysplit_lm )
|
||||||
@@ -3122,171 +3175,71 @@ void R_DrawVBO( qboolean drawlightmap, qboolean drawtextures )
|
|||||||
vbos.maxtexture = 0;
|
vbos.maxtexture = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
R_CheckLightMap
|
|
||||||
|
|
||||||
update surface's lightmap if needed and return true if it is dynamic
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
static qboolean R_CheckLightMap( msurface_t *fa )
|
|
||||||
{
|
|
||||||
int maps;
|
|
||||||
qboolean is_dynamic = false;
|
|
||||||
|
|
||||||
// check for lightmap modification
|
|
||||||
for( maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++ )
|
|
||||||
{
|
|
||||||
if( tr.lightstylevalue[fa->styles[maps]] != fa->cached_light[maps] )
|
|
||||||
{
|
|
||||||
is_dynamic = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// already up to date
|
|
||||||
if( !is_dynamic && ( fa->dlightframe != tr.framecount ))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// build lightmap
|
|
||||||
if(( maps < MAXLIGHTMAPS ) && ( fa->styles[maps] >= 32 || fa->styles[maps] == 0 ) && ( fa->dlightframe != tr.framecount ))
|
|
||||||
{
|
|
||||||
byte temp[132*132*4];
|
|
||||||
int smax, tmax;
|
|
||||||
int sample_size;
|
|
||||||
mextrasurf_t *info;
|
|
||||||
|
|
||||||
info = fa->info;
|
|
||||||
sample_size = gEngfuncs.Mod_SampleSizeForFace( fa );
|
|
||||||
smax = ( info->lightextents[0] / sample_size ) + 1;
|
|
||||||
tmax = ( info->lightextents[1] / sample_size ) + 1;
|
|
||||||
|
|
||||||
if( smax < 132 && tmax < 132 )
|
|
||||||
{
|
|
||||||
R_BuildLightMap( fa, temp, smax * 4, true );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
smax = Q_min( smax, 132 );
|
|
||||||
tmax = Q_min( tmax, 132 );
|
|
||||||
//Host_MapDesignError( "R_RenderBrushPoly: bad surface extents: %d %d", fa->extents[0], fa->extents[1] );
|
|
||||||
memset( temp, 255, sizeof( temp ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
R_SetCacheState( fa );
|
|
||||||
#ifdef XASH_WES
|
|
||||||
GL_Bind( XASH_TEXTURE1, tr.lightmapTextures[fa->lightmaptexturenum] );
|
|
||||||
|
|
||||||
pglTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE );
|
|
||||||
#else
|
|
||||||
GL_Bind( XASH_TEXTURE0, tr.lightmapTextures[fa->lightmaptexturenum] );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pglTexSubImage2D( GL_TEXTURE_2D, 0, fa->light_s, fa->light_t, smax, tmax,
|
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, temp );
|
|
||||||
#ifdef XASH_WES
|
|
||||||
GL_SelectTexture( XASH_TEXTURE0 );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
// add to dynamic chain
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// updated
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
qboolean R_AddSurfToVBO( msurface_t *surf, qboolean buildlightmap )
|
qboolean R_AddSurfToVBO( msurface_t *surf, qboolean buildlightmap )
|
||||||
{
|
{
|
||||||
if( r_vbo.value && vbos.surfdata[surf - WORLDMODEL->surfaces].vbotexture )
|
const int idx = surf - WORLDMODEL->surfaces;
|
||||||
{
|
vbotexture_t *vbotex;
|
||||||
// find vbotexture_t assotiated with this surface
|
int texturenum;
|
||||||
int idx = surf - WORLDMODEL->surfaces;
|
|
||||||
vbotexture_t *vbotex = vbos.surfdata[idx].vbotexture;
|
|
||||||
int texturenum = vbos.surfdata[idx].texturenum;
|
|
||||||
|
|
||||||
if( !surf->polys )
|
if( !R_HasGeneratedVBO() || !R_HasEnabledVBO( ))
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
if( vbos.maxlightmap < surf->lightmaptexturenum + 1 )
|
// find vbotexture_t assotiated with this surface
|
||||||
vbos.maxlightmap = surf->lightmaptexturenum + 1;
|
vbotex = vbos.surfdata[idx].vbotexture;
|
||||||
if( vbos.minlightmap > surf->lightmaptexturenum )
|
texturenum = vbos.surfdata[idx].texturenum;
|
||||||
vbos.minlightmap = surf->lightmaptexturenum;
|
|
||||||
if( vbos.maxtexture < texturenum + 1 )
|
|
||||||
vbos.maxtexture = texturenum + 1;
|
|
||||||
if( vbos.mintexture > texturenum )
|
|
||||||
vbos.mintexture = texturenum;
|
|
||||||
|
|
||||||
buildlightmap &= !r_fullbright->value && !!WORLDMODEL->lightdata;
|
if( !vbotex )
|
||||||
|
return false;
|
||||||
/* draw details in regular way */
|
|
||||||
if( r_vbo_detail.value == 0 )
|
|
||||||
{
|
|
||||||
if( r_detailtextures.value && surf->texinfo && surf->texinfo )
|
|
||||||
{
|
|
||||||
texture_t *t = surf->texinfo->texture;
|
|
||||||
|
|
||||||
if( glState.isFogEnabled )
|
|
||||||
{
|
|
||||||
// don't apply detail textures for windows in the fog
|
|
||||||
if( RI.currententity->curstate.rendermode != kRenderTransTexture )
|
|
||||||
{
|
|
||||||
if( t->dt_texturenum )
|
|
||||||
{
|
|
||||||
surf->info->detailchain = detail_surfaces[t->dt_texturenum];
|
|
||||||
detail_surfaces[t->dt_texturenum] = surf->info;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// draw stub detail texture for underwater surfaces
|
|
||||||
surf->info->detailchain = detail_surfaces[tr.grayTexture];
|
|
||||||
detail_surfaces[tr.grayTexture] = surf->info;
|
|
||||||
}
|
|
||||||
draw_details = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( t->dt_texturenum )
|
|
||||||
{
|
|
||||||
surf->info->detailchain = detail_surfaces[t->dt_texturenum];
|
|
||||||
detail_surfaces[t->dt_texturenum] = surf->info;
|
|
||||||
draw_details = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( buildlightmap && R_CheckLightMap( surf ) )
|
|
||||||
{
|
|
||||||
// every vbotex has own lightmap chain (as we sorted if by textures to use multitexture)
|
|
||||||
surf->info->lightmapchain = vbotex->dlightchain;
|
|
||||||
vbotex->dlightchain = surf;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uint indexbase = vbos.surfdata[idx].startindex;
|
|
||||||
uint index;
|
|
||||||
|
|
||||||
// GL_TRIANGLE_FAN: 0 1 2 0 2 3 0 3 4 ...
|
|
||||||
for( index = indexbase + 2; index < indexbase + surf->polys->numverts; index++ )
|
|
||||||
{
|
|
||||||
vbotex->indexarray[vbotex->curindex++] = indexbase;
|
|
||||||
vbotex->indexarray[vbotex->curindex++] = index - 1;
|
|
||||||
vbotex->indexarray[vbotex->curindex++] = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if surface has decals, add it to decal lightmapchain
|
|
||||||
if( surf->pdecals )
|
|
||||||
{
|
|
||||||
surf->info->lightmapchain = vbos.decaldata->lm[vbotex->lightmaptexturenum];
|
|
||||||
vbos.decaldata->lm[vbotex->lightmaptexturenum] = surf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// now this path does not draw wapred surfaces, so count it as one poly
|
|
||||||
r_stats.c_world_polys++;
|
|
||||||
|
|
||||||
|
if( !surf->polys )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if( vbos.maxlightmap < surf->lightmaptexturenum + 1 )
|
||||||
|
vbos.maxlightmap = surf->lightmaptexturenum + 1;
|
||||||
|
if( vbos.minlightmap > surf->lightmaptexturenum )
|
||||||
|
vbos.minlightmap = surf->lightmaptexturenum;
|
||||||
|
if( vbos.maxtexture < texturenum + 1 )
|
||||||
|
vbos.maxtexture = texturenum + 1;
|
||||||
|
if( vbos.mintexture > texturenum )
|
||||||
|
vbos.mintexture = texturenum;
|
||||||
|
|
||||||
|
buildlightmap &= !r_fullbright->value && !!WORLDMODEL->lightdata;
|
||||||
|
|
||||||
|
// draw details in regular way
|
||||||
|
if( r_vbo_detail.value == 0 && surf->texinfo )
|
||||||
|
R_RenderDetailsForSurface( surf, surf->texinfo->texture );
|
||||||
|
|
||||||
|
if( buildlightmap && R_CheckLightMap( surf ))
|
||||||
|
{
|
||||||
|
// every vbotex has own lightmap chain (as we sorted if by textures to use multitexture)
|
||||||
|
surf->info->lightmapchain = vbotex->dlightchain;
|
||||||
|
vbotex->dlightchain = surf;
|
||||||
}
|
}
|
||||||
return false;
|
else
|
||||||
|
{
|
||||||
|
uint indexbase = vbos.surfdata[idx].startindex;
|
||||||
|
uint index;
|
||||||
|
|
||||||
|
// GL_TRIANGLE_FAN: 0 1 2 0 2 3 0 3 4 ...
|
||||||
|
for( index = indexbase + 2; index < indexbase + surf->polys->numverts; index++ )
|
||||||
|
{
|
||||||
|
vbotex->indexarray[vbotex->curindex++] = indexbase;
|
||||||
|
vbotex->indexarray[vbotex->curindex++] = index - 1;
|
||||||
|
vbotex->indexarray[vbotex->curindex++] = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if surface has decals, add it to decal lightmapchain
|
||||||
|
if( surf->pdecals )
|
||||||
|
{
|
||||||
|
surf->info->lightmapchain = vbos.decaldata->lm[vbotex->lightmaptexturenum];
|
||||||
|
vbos.decaldata->lm[vbotex->lightmaptexturenum] = surf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// now this path does not draw wapred surfaces, so count it as one poly
|
||||||
|
r_stats.c_world_polys++;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3624,7 +3577,7 @@ void R_DrawWorld( void )
|
|||||||
GL_ResetFogColor();
|
GL_ResetFogColor();
|
||||||
R_BlendLightmaps();
|
R_BlendLightmaps();
|
||||||
R_RenderFullbrights();
|
R_RenderFullbrights();
|
||||||
R_RenderDetails( r_vbo.value? 2 : 3 );
|
R_RenderDetails( R_HasEnabledVBO() ? 2 : 3 );
|
||||||
|
|
||||||
if( skychain )
|
if( skychain )
|
||||||
R_DrawSkyBox();
|
R_DrawSkyBox();
|
||||||
|
|||||||
@@ -23,6 +23,17 @@ gl_globals_t tr;
|
|||||||
ref_speeds_t r_stats;
|
ref_speeds_t r_stats;
|
||||||
poolhandle_t r_temppool;
|
poolhandle_t r_temppool;
|
||||||
viddef_t vid;
|
viddef_t vid;
|
||||||
|
|
||||||
|
void _Mem_Free( void *data, const char *filename, int fileline )
|
||||||
|
{
|
||||||
|
gEngfuncs._Mem_Free( data, filename, fileline );
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
{
|
||||||
|
return gEngfuncs._Mem_Alloc( poolptr, size, clear, filename, fileline );
|
||||||
|
}
|
||||||
|
|
||||||
static void GAME_EXPORT R_ClearScreen( void )
|
static void GAME_EXPORT R_ClearScreen( void )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ GNU General Public License for more details.
|
|||||||
#include "enginefeatures.h"
|
#include "enginefeatures.h"
|
||||||
#include "com_strings.h"
|
#include "com_strings.h"
|
||||||
#include "pm_movevars.h"
|
#include "pm_movevars.h"
|
||||||
#include "common/cvar.h"
|
#include "cvardef.h"
|
||||||
typedef struct mip_s mip_t;
|
typedef struct mip_s mip_t;
|
||||||
|
|
||||||
typedef int fixed8_t;
|
typedef int fixed8_t;
|
||||||
@@ -1237,10 +1237,14 @@ void R_SetUpWorldTransform (void);
|
|||||||
#include "crtlib.h"
|
#include "crtlib.h"
|
||||||
#include "crclib.h"
|
#include "crclib.h"
|
||||||
#if 1
|
#if 1
|
||||||
#define Mem_Malloc( pool, size ) gEngfuncs._Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
void _Mem_Free( void *data, const char *filename, int fileline );
|
||||||
#define Mem_Calloc( pool, size ) gEngfuncs._Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
|
ALLOC_CHECK( 2 ) MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
#define Mem_Malloc( pool, size ) _Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
||||||
|
#define Mem_Calloc( pool, size ) _Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
||||||
#define Mem_Realloc( pool, ptr, size ) gEngfuncs._Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
#define Mem_Realloc( pool, ptr, size ) gEngfuncs._Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
||||||
#define Mem_Free( mem ) gEngfuncs._Mem_Free( mem, __FILE__, __LINE__ )
|
#define Mem_Free( mem ) _Mem_Free( mem, __FILE__, __LINE__ )
|
||||||
#define Mem_AllocPool( name ) gEngfuncs._Mem_AllocPool( name, __FILE__, __LINE__ )
|
#define Mem_AllocPool( name ) gEngfuncs._Mem_AllocPool( name, __FILE__, __LINE__ )
|
||||||
#define Mem_FreePool( pool ) gEngfuncs._Mem_FreePool( pool, __FILE__, __LINE__ )
|
#define Mem_FreePool( pool ) gEngfuncs._Mem_FreePool( pool, __FILE__, __LINE__ )
|
||||||
#define Mem_EmptyPool( pool ) gEngfuncs._Mem_EmptyPool( pool, __FILE__, __LINE__ )
|
#define Mem_EmptyPool( pool ) gEngfuncs._Mem_EmptyPool( pool, __FILE__, __LINE__ )
|
||||||
|
|||||||
@@ -236,10 +236,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
|||||||
VectorAdd( verts[0], delta, verts[2] );
|
VectorAdd( verts[0], delta, verts[2] );
|
||||||
VectorAdd( verts[1], delta, verts[3] );
|
VectorAdd( verts[1], delta, verts[3] );
|
||||||
|
|
||||||
if( p->color > sizeof( gTracerColors ) / sizeof( gTracerColors[0] ))
|
if( p->color < 0 || p->color > sizeof( gTracerColors ) / sizeof( gTracerColors[0] ))
|
||||||
{
|
{
|
||||||
gEngfuncs.Con_Printf( S_ERROR "UserTracer with color(%d) > %zu\n", p->color, sizeof( gTracerColors ) / sizeof( gTracerColors[0] ));
|
p->color = TRACER_COLORINDEX_DEFAULT;
|
||||||
p->color = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
color = gTracerColors[p->color];
|
color = gTracerColors[p->color];
|
||||||
|
|||||||
@@ -17,13 +17,22 @@ fi
|
|||||||
|
|
||||||
if [ "$ARCH" = "i386" ]; then
|
if [ "$ARCH" = "i386" ]; then
|
||||||
cp SDL2_VC/lib/x86/SDL2.dll . # Install SDL2
|
cp SDL2_VC/lib/x86/SDL2.dll . # Install SDL2
|
||||||
cp 3rdparty/vgui_support/vgui-dev/lib/win32_vc6/vgui.dll .
|
|
||||||
elif [ "$ARCH" = "amd64" ]; then
|
elif [ "$ARCH" = "amd64" ]; then
|
||||||
cp SDL2_VC/lib/x64/SDL2.dll .
|
cp SDL2_VC/lib/x64/SDL2.dll .
|
||||||
else
|
else
|
||||||
die
|
die
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
WINSDK_LATEST=$(ls -1 "C:/Program Files (x86)/Windows Kits/10/bin" | grep -E '^10' | sort -rV | head -n1)
|
||||||
|
echo "Latest installed Windows SDK is $WINSDK_LATEST"
|
||||||
|
|
||||||
|
"C:/Program Files (x86)/Windows Kits/10/bin/$WINSDK_LATEST/x64/signtool.exe" \
|
||||||
|
sign //f scripts/fwgs.pfx //fd SHA256 //p "$FWGS_PFX_PASSWORD" *.dll *.exe
|
||||||
|
|
||||||
|
if [ "$ARCH" = "i386" ]; then # VGUI is already signed
|
||||||
|
cp 3rdparty/vgui_support/vgui-dev/lib/win32_vc6/vgui.dll .
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p artifacts/
|
mkdir -p artifacts/
|
||||||
7z a -t7z artifacts/xash3d-fwgs-win32-$ARCH.7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on \
|
7z a -t7z artifacts/xash3d-fwgs-win32-$ARCH.7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on \
|
||||||
*.dll *.exe *.pdb activities.txt \
|
*.dll *.exe *.pdb activities.txt \
|
||||||
|
|||||||
14
wscript
14
wscript
@@ -81,6 +81,7 @@ SUBDIRS = [
|
|||||||
Subproject('ref/null', lambda x: not x.env.DEDICATED and x.env.NULL),
|
Subproject('ref/null', lambda x: not x.env.DEDICATED and x.env.NULL),
|
||||||
Subproject('3rdparty/mainui', lambda x: not x.env.DEDICATED),
|
Subproject('3rdparty/mainui', lambda x: not x.env.DEDICATED),
|
||||||
Subproject('3rdparty/vgui_support', lambda x: not x.env.DEDICATED),
|
Subproject('3rdparty/vgui_support', lambda x: not x.env.DEDICATED),
|
||||||
|
# Subproject('3rdparty/freevgui', lambda x: not x.env.DEDICATED),
|
||||||
Subproject('stub/client', lambda x: not x.env.DEDICATED),
|
Subproject('stub/client', lambda x: not x.env.DEDICATED),
|
||||||
Subproject('game_launch', lambda x: not x.env.DISABLE_LAUNCHER),
|
Subproject('game_launch', lambda x: not x.env.DISABLE_LAUNCHER),
|
||||||
|
|
||||||
@@ -172,7 +173,12 @@ def options(opt):
|
|||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
conf.load('fwgslib reconfigure compiler_optimizations')
|
conf.load('fwgslib reconfigure compiler_optimizations')
|
||||||
conf.env.MSVC_TARGETS = ['x86' if not conf.options.ALLOW64 else 'x64']
|
if conf.options.ALLOW64:
|
||||||
|
conf.env.MSVC_TARGETS = ['x64']
|
||||||
|
elif sys.maxsize > 2 ** 32:
|
||||||
|
conf.env.MSVC_TARGETS = ['amd64_x86', 'x86']
|
||||||
|
else:
|
||||||
|
conf.env.MSVC_TARGETS = ['x86']
|
||||||
|
|
||||||
# Load compilers early
|
# Load compilers early
|
||||||
conf.load('xshlib xcompile compiler_c compiler_cxx cmake gccdeps')
|
conf.load('xshlib xcompile compiler_c compiler_cxx cmake gccdeps')
|
||||||
@@ -222,12 +228,10 @@ def configure(conf):
|
|||||||
elif conf.env.DEST_OS == 'nswitch':
|
elif conf.env.DEST_OS == 'nswitch':
|
||||||
conf.options.NO_VGUI = True
|
conf.options.NO_VGUI = True
|
||||||
conf.options.GL = True
|
conf.options.GL = True
|
||||||
conf.options.NO_ASYNC_RESOLVE = True
|
|
||||||
conf.options.USE_STBTT = True
|
conf.options.USE_STBTT = True
|
||||||
elif conf.env.DEST_OS == 'psvita':
|
elif conf.env.DEST_OS == 'psvita':
|
||||||
conf.options.NO_VGUI = True
|
conf.options.NO_VGUI = True
|
||||||
conf.options.GL = True
|
conf.options.GL = True
|
||||||
conf.options.NO_ASYNC_RESOLVE = True
|
|
||||||
conf.options.USE_STBTT = True
|
conf.options.USE_STBTT = True
|
||||||
# we'll specify -fPIC by hand for shared libraries only
|
# we'll specify -fPIC by hand for shared libraries only
|
||||||
enforce_pic = False
|
enforce_pic = False
|
||||||
@@ -302,9 +306,10 @@ def configure(conf):
|
|||||||
'-Werror=alloc-size',
|
'-Werror=alloc-size',
|
||||||
'-Werror=bool-compare',
|
'-Werror=bool-compare',
|
||||||
'-Werror=bool-operation',
|
'-Werror=bool-operation',
|
||||||
'-Werror=cast-align=strict',
|
# '-Werror=cast-align=strict',
|
||||||
'-Werror=duplicated-cond',
|
'-Werror=duplicated-cond',
|
||||||
'-Werror=format-extra-args',
|
'-Werror=format-extra-args',
|
||||||
|
'-Werror=free-nonheap-object',
|
||||||
'-Werror=implicit-fallthrough=2',
|
'-Werror=implicit-fallthrough=2',
|
||||||
'-Werror=logical-op',
|
'-Werror=logical-op',
|
||||||
'-Werror=nonnull',
|
'-Werror=nonnull',
|
||||||
@@ -329,6 +334,7 @@ def configure(conf):
|
|||||||
'-Wformat=2',
|
'-Wformat=2',
|
||||||
'-Winit-self',
|
'-Winit-self',
|
||||||
'-Wmisleading-indentation',
|
'-Wmisleading-indentation',
|
||||||
|
'-Wmismatched-dealloc',
|
||||||
'-Wstringop-overflow',
|
'-Wstringop-overflow',
|
||||||
'-Wunintialized',
|
'-Wunintialized',
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user