mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
Compare commits
105 Commits
continuous
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7e84230c3 | ||
|
|
c96cf7e22d | ||
|
|
46c61660cf | ||
|
|
f6fecce52b | ||
|
|
54a5947a3c | ||
|
|
521bc675a2 | ||
|
|
845cee2578 | ||
|
|
93ceb0e4ed | ||
|
|
13aab4e59c | ||
|
|
36c2f9e9f2 | ||
|
|
514da0ffa9 | ||
|
|
37b8d5da79 | ||
|
|
b5d602d953 | ||
|
|
c926fee13c | ||
|
|
a675806c91 | ||
|
|
683c4874f8 | ||
|
|
20ced857b4 | ||
|
|
c6c86f9665 | ||
|
|
1e0107944f | ||
|
|
21797f9ac8 | ||
|
|
c800b34cd4 | ||
|
|
1612e2d669 | ||
|
|
26d229c8ca | ||
|
|
9c66e86be1 | ||
|
|
7e9f87de2d | ||
|
|
67737446ac | ||
|
|
dabed4f9eb | ||
|
|
f9b6389248 | ||
|
|
9ec1e259b4 | ||
|
|
0c2d480d89 | ||
|
|
350d8ccb7b | ||
|
|
0c512d0431 | ||
|
|
3bf55c9ea4 | ||
|
|
9994c57796 | ||
|
|
3f724b6b17 | ||
|
|
255773b4de | ||
|
|
5b73a788da | ||
|
|
748b06a00e | ||
|
|
273bccdc9a | ||
|
|
f0a2362da3 | ||
|
|
be8ade23e8 | ||
|
|
6814908d80 | ||
|
|
08dbfc45d3 | ||
|
|
89f9b3df68 | ||
|
|
40c9a2fb82 | ||
|
|
a34c22fb10 | ||
|
|
e161ff0f7a | ||
|
|
fee42eab5a | ||
|
|
2d2e03f235 | ||
|
|
4c3c3529e9 | ||
|
|
7051b844ff | ||
|
|
68377435c8 | ||
|
|
652b1804a8 | ||
|
|
e7e1677786 | ||
|
|
f330aac113 | ||
|
|
dbdd330cf7 | ||
|
|
c448c7b0b1 | ||
|
|
8d7b9c2f01 | ||
|
|
b6a235445a | ||
|
|
9fcd4baa87 | ||
|
|
fb0102eb8e | ||
|
|
9c1afaa372 | ||
|
|
1d1a6badb5 | ||
|
|
2d41c9cb15 | ||
|
|
722cbe1f02 | ||
|
|
8ac2c241c4 | ||
|
|
dd11f73951 | ||
|
|
a443547d4d | ||
|
|
7a795edeb5 | ||
|
|
a8cbfb8dda | ||
|
|
5216cccef4 | ||
|
|
a87f399e68 | ||
|
|
dd310ab851 | ||
|
|
16cc0ca0fe | ||
|
|
83d26ad233 | ||
|
|
d1f9a8f2db | ||
|
|
a2e1071808 | ||
|
|
0aa8a2891c | ||
|
|
c0ceab7513 | ||
|
|
5c90e716cb | ||
|
|
0073225549 | ||
|
|
d03a64602b | ||
|
|
d67a4234cc | ||
|
|
0d37244490 | ||
|
|
6426919cb5 | ||
|
|
0a0d63663a | ||
|
|
71b06801ef | ||
|
|
cfc7b35927 | ||
|
|
76564958d1 | ||
|
|
a464c3dd66 | ||
|
|
bd969f3594 | ||
|
|
fb87d7c0b3 | ||
|
|
a69fc87940 | ||
|
|
e481e1d73e | ||
|
|
6c0eed1b2b | ||
|
|
a6c67fdf9f | ||
|
|
03f838e37e | ||
|
|
e21fa4a910 | ||
|
|
46889ed453 | ||
|
|
882fcc152c | ||
|
|
a41902bd46 | ||
|
|
a6af32dafd | ||
|
|
d6dfb83be7 | ||
|
|
597429cf41 | ||
|
|
5ea074a1fd |
22
.cirrus.yml
22
.cirrus.yml
@@ -1,10 +1,10 @@
|
||||
task:
|
||||
name: freebsd-12-amd64
|
||||
freebsd_instance:
|
||||
image_family: freebsd-12-3
|
||||
image_family: freebsd-12-4
|
||||
setup_script:
|
||||
- pkg update
|
||||
- pkg install -y git sdl2 python fontconfig
|
||||
- pkg install -y pkgconf git sdl2 python fontconfig opus
|
||||
- git submodule update --init --recursive
|
||||
test_script:
|
||||
- ./scripts/cirrus/build_freebsd.sh dedicated
|
||||
@@ -13,10 +13,10 @@ task:
|
||||
task:
|
||||
name: freebsd-13-amd64
|
||||
freebsd_instance:
|
||||
image_family: freebsd-13-1
|
||||
image_family: freebsd-13-2
|
||||
setup_script:
|
||||
- pkg update
|
||||
- pkg install -y git sdl2 python fontconfig
|
||||
- pkg install -y pkgconf git sdl2 python fontconfig opus
|
||||
- git submodule update --init --recursive
|
||||
test_script:
|
||||
- ./scripts/cirrus/build_freebsd.sh dedicated
|
||||
@@ -28,7 +28,19 @@ task:
|
||||
image_family: freebsd-14-0-snap
|
||||
setup_script:
|
||||
- pkg update
|
||||
- pkg install -y git sdl2 python fontconfig
|
||||
- pkg install -y pkgconf git sdl2 python fontconfig opus
|
||||
- git submodule update --init --recursive
|
||||
test_script:
|
||||
- ./scripts/cirrus/build_freebsd.sh dedicated
|
||||
- ./scripts/cirrus/build_freebsd.sh full
|
||||
|
||||
task:
|
||||
name: freebsd-15-amd64
|
||||
freebsd_instance:
|
||||
image_family: freebsd-15-0-snap
|
||||
setup_script:
|
||||
- pkg update
|
||||
- pkg install -y pkgconf git sdl2 python fontconfig opus
|
||||
- git submodule update --init --recursive
|
||||
test_script:
|
||||
- ./scripts/cirrus/build_freebsd.sh dedicated
|
||||
|
||||
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: adb3e413ec...b4bb815420
2
3rdparty/vgui_support
vendored
2
3rdparty/vgui_support
vendored
Submodule 3rdparty/vgui_support updated: 521cf5cb6c...f85d64c149
24
Documentation/donate.md
Normal file
24
Documentation/donate.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Developers donation page
|
||||
|
||||
On this page you can find links where you can support each developer individually, who has provided public sponsorship information.
|
||||
|
||||
### [a1batross](https://github.com/a1batross)
|
||||
|
||||
* Initial Xash3D SDL2/Linux port author, Xash3D FWGS engine maintainer, creator of non-commercial Flying With Gauss organization.
|
||||
* Boosty page: https://boosty.to/a1ba
|
||||
|
||||
### [nekonomicon](https://github.com/nekonomicon)
|
||||
|
||||
* [hlsdk-portable](https://github.com/FWGS/hlsdk-portable), [mdldec](../utils/mdldec), [opensource-mods.md](opensource-mods.md) maintainer and Xash3D FWGS [contributor](https://github.com/FWGS/xash3d-fwgs/commits?author=nekonomicon) (*BSD/clang port, PNG support, etc).
|
||||
* Boosty page: https://boosty.to/nekonomicon
|
||||
|
||||
### [Velaron](https://github.com/Velaron)
|
||||
* [cs16-client](https://github.com/Velaron/cs16-client) & [tf15-client](https://github.com/Velaron/tf15-client) maintainer and Xash3D FWGS [contributor](https://github.com/FWGS/xash3d-fwgs/commits?author=Velaron) (Android port, voice chat, etc).
|
||||
* BuyMeACoffee page: https://www.buymeacoffee.com/velaron
|
||||
|
||||
### [SNMetamorph](https://github.com/SNMetamorph)
|
||||
* [PrimeXT](https://github.com/SNMetamorph/PrimeXT) & [GoldSrc Monitor](https://github.com/SNMetamorph/goldsrc-monitor) maintainer and Xash3D FWGS [contributor](https://github.com/FWGS/xash3d-fwgs/commits?author=SNMetamorph) (Windows port, voice chat, etc).
|
||||
* BTC: `16GAzK3qei5AwBW7sggXp3yNcFHBtdpxXj`
|
||||
* ETH (ERC20): `0xb580eeca9756e3881f9d6d026e28db28eb72a383`
|
||||
* USDT (ERC20): `0xb580eeca9756e3881f9d6d026e28db28eb72a383`
|
||||
* USDC (ERC20): `0xb580eeca9756e3881f9d6d026e28db28eb72a383`
|
||||
@@ -70,9 +70,11 @@ These strings are specific to Xash3D FWGS.
|
||||
|
||||
| Key | Type | Default value | Description |
|
||||
| ----------------------- | ---------- | ------------------------ | ----------- |
|
||||
| `animated_title` | boolean | 0 | Use animated title in main menu (WON Half-Life logo.avi imitation from Half-Life 25-th anniversary update)
|
||||
| `autosave_aged_count` | integer | 2 | Auto saves limit used in saves rotation |
|
||||
| `gamedll_linux` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 Linux (see LibraryNaming.md for details) |
|
||||
| `gamedll_osx` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 macOS (see LibraryNaming.md for details) |
|
||||
| `hd_background` | boolean | 0 | Use HD background for main menu (Half-Life 25-th anniversary update) |
|
||||
| `internal_vgui_support` | boolean | 0 | Only for programmers! Required to be set as 1 for PrimeXT!<br>When set to 1, the engine will not load vgui_support DLL, as VGUI support is done (or intentionally ignored) on the game side. |
|
||||
| `render_picbutton_text` | boolean | 0 | When set to 1, the UI will not use prerendered `btns_main.bmp` and dynamically render them instead |
|
||||
| `quicksave_aged_count` | integer | 2 | Quick saves limit used in saves rotation |
|
||||
@@ -88,6 +90,7 @@ The table below defines conversion rules from liblist.gam to gameinfo.txt. Some
|
||||
|
||||
| `liblist.gam` key | `gameinfo.txt` key | Note |
|
||||
| ----------------- | ------------------ | ---- |
|
||||
| `animated_title` | `animated_title` | |
|
||||
| `edicts` | `max_edicts` | |
|
||||
| `fallback_dir` | `fallback_dir` | |
|
||||
| `game` | `title` | |
|
||||
@@ -95,6 +98,7 @@ The table below defines conversion rules from liblist.gam to gameinfo.txt. Some
|
||||
| `gamedll` | `gamedll` | |
|
||||
| `gamedll_linux` | `gamedll_linux` | |
|
||||
| `gamedll_osx` | `gamedll_osx` | |
|
||||
| `hd_background` | `hd_background` | |
|
||||
| `icon` | `icon` | |
|
||||
| `mpentity` | `mp_entity` | |
|
||||
| `mpfilter` | `mp_filter` | |
|
||||
|
||||
@@ -228,7 +228,7 @@ Branch **caseclosed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable
|
||||
Branch **CAd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/CAd
|
||||
|
||||
## Counter Strike
|
||||
Reverse-engineered code of client part by a1batross - https://github.com/FWGS/cs16-client/tree/v1.32
|
||||
Reverse-engineered code of client part by a1batross - https://github.com/Velaron/cs16-client
|
||||
|
||||
Reverse-engineered code of server part by nagist - https://github.com/nagist/cs16nd
|
||||
|
||||
|
||||
42
README.md
42
README.md
@@ -1,33 +1,27 @@
|
||||
# Xash3D FWGS Engine
|
||||
# Xash3D FWGS Engine <img align="right" width="128" height="128" src="https://github.com/FWGS/xash3d-fwgs/raw/master/game_launch/icon-xash-material.png" alt="Xash3D FWGS icon" />
|
||||
[](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [](http://fwgsdiscord.mentality.rip/) \
|
||||
[](https://github.com/FWGS/xash3d-fwgs/releases/latest) [](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous)
|
||||
[](https://github.com/FWGS/xash3d-fwgs/releases/latest) [](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous)
|
||||
|
||||
Xash3D FWGS is a fork of Xash3D Engine by Unkle Mike with extended features and crossplatform.
|
||||
Xash3D FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
|
||||
|
||||
```
|
||||
Xash3D is a game engine, aimed to provide compatibility with Half-Life Engine,
|
||||
as well as to give game developers well known workflow and extend it.
|
||||
Read more about Xash3D on ModDB: https://www.moddb.com/engines/xash3d-engine
|
||||
```
|
||||
Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://www.moddb.com/engines/xash3d-engine) by Unkle Mike.
|
||||
|
||||
## Donate
|
||||
[](Documentation/donate.md) \
|
||||
If you like Xash3D FWGS, consider supporting individual engine maintainers. By supporting us, you help to continue developing this game engine further. The sponsorship links are available in [documentation](Documentation/donate.md).
|
||||
|
||||
## Fork features
|
||||
* HLSDK 2.4 support.
|
||||
* Crossplatform: supported x86 and ARM on Windows/Linux/BSD/Android. ([see docs for more info](Documentation/ports.md))
|
||||
* Modern compilers support: say no more to MSVC6.
|
||||
* Better multiplayer support: multiple master servers, headless dedicated server.
|
||||
* Mobility API: allows better game integration on mobile devices(vibration, touch controls)
|
||||
* Different input methods: touch, gamepad and classic mouse & keyboard.
|
||||
* Steam Half-Life (HLSDK 2.4) support.
|
||||
* Crossplatform and modern compilers support: supports Windows, Linux, BSD & Android on x86 & ARM and [many more](Documentation/ports.md).
|
||||
* Better multiplayer support: multiple master servers, headless dedicated server, voice chat and IPv6 support.
|
||||
* Multiple renderers support: OpenGL, GLESv1, GLESv2 and Software.
|
||||
* Advanced virtual filesystem: `.pk3` and `.pk3dir` support, compatibility with GoldSrc FS module, fast case-insensitivity emulation for crossplatform.
|
||||
* Mobility API: better game integration on mobile devices (vibration, touch controls)
|
||||
* Different input methods: touch and gamepad in addition to mouse & keyboard.
|
||||
* TrueType font rendering, as a part of mainui_cpp.
|
||||
* Multiple renderers support: OpenGL, GLESv1, GLESv2, Software.
|
||||
* Voice support.
|
||||
* External filesystem module like in GoldSrc engine.
|
||||
* External vgui support module.
|
||||
* PNG image format support.
|
||||
* A set of small improvements, without broken compatibility.
|
||||
|
||||
## Planned fork features
|
||||
* Virtual Reality support and game API.
|
||||
* Vulkan renderer.
|
||||
* External VGUI support module.
|
||||
* PNG & KTX2 image format support.
|
||||
* [A set of small improvements](Documentation/), without broken compatibility.
|
||||
|
||||
## Installation & Running
|
||||
0) Get Xash3D FWGS binaries: you can use [testing](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous) build or you can compile engine from source code.
|
||||
|
||||
@@ -189,4 +189,8 @@ Default build-depended cvar and constant values
|
||||
#define DEFAULT_FULLSCREEN "1" // must be a string
|
||||
#endif // DEFAULT_FULLSCREEN
|
||||
|
||||
#ifndef DEFAULT_MAX_EDICTS
|
||||
#define DEFAULT_MAX_EDICTS 1200 // was 900 before HL25
|
||||
#endif // DEFAULT_MAX_EDICTS
|
||||
|
||||
#endif // DEFAULTS_H
|
||||
|
||||
@@ -19,6 +19,8 @@ GNU General Public License for more details.
|
||||
#define GFL_NOMODELS (1<<0)
|
||||
#define GFL_NOSKILLS (1<<1)
|
||||
#define GFL_RENDER_PICBUTTON_TEXT (1<<2)
|
||||
#define GFL_HD_BACKGROUND (1<<3)
|
||||
#define GFL_ANIMATED_TITLE (1<<4)
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
@@ -229,7 +229,7 @@ typedef struct render_api_s
|
||||
void (*R_Reserved0)( void );
|
||||
|
||||
// static allocations
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
|
||||
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
|
||||
|
||||
// engine utils (not related with render API but placed here)
|
||||
|
||||
@@ -88,18 +88,21 @@ typedef uint64_t longtime_t;
|
||||
#define _format(x) __attribute__((format(printf, x, x+1)))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define NONNULL __attribute__((nonnull))
|
||||
#define ALLOC_CHECK(x) __attribute__((alloc_size(x)))
|
||||
#elif defined(_MSC_VER)
|
||||
#define EXPORT __declspec( dllexport )
|
||||
#define GAME_EXPORT
|
||||
#define _format(x)
|
||||
#define NORETURN
|
||||
#define NONNULL
|
||||
#define ALLOC_CHECK(x)
|
||||
#else
|
||||
#define EXPORT
|
||||
#define GAME_EXPORT
|
||||
#define _format(x)
|
||||
#define NORETURN
|
||||
#define NONNULL
|
||||
#define ALLOC_CHECK(x)
|
||||
#endif
|
||||
|
||||
#if ( __GNUC__ >= 3 )
|
||||
@@ -181,6 +184,7 @@ typedef struct dll_info_s
|
||||
} dll_info_t;
|
||||
|
||||
typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs );
|
||||
typedef void *(*pfnCreateInterface_t)( const char *, int * );
|
||||
|
||||
// config strings are a general means of communication from
|
||||
// the server to all connected clients.
|
||||
|
||||
@@ -85,6 +85,12 @@ void CL_PlayCDTrack_f( void )
|
||||
paused = false;
|
||||
looped = false;
|
||||
}
|
||||
else if( !Q_stricmp( command, "playfile" ))
|
||||
{
|
||||
S_StartBackgroundTrack( pszTrack, NULL, 0, true );
|
||||
paused = false;
|
||||
looped = false;
|
||||
}
|
||||
else if( !Q_stricmp( command, "loop" ))
|
||||
{
|
||||
if( Q_isdigit( pszTrack ))
|
||||
@@ -96,6 +102,12 @@ void CL_PlayCDTrack_f( void )
|
||||
paused = false;
|
||||
looped = true;
|
||||
}
|
||||
else if( !Q_stricmp( command, "loopfile" ))
|
||||
{
|
||||
S_StartBackgroundTrack( pszTrack, pszTrack, 0, true );
|
||||
paused = false;
|
||||
looped = true;
|
||||
}
|
||||
else if( !Q_stricmp( command, "pause" ))
|
||||
{
|
||||
S_StreamSetPause( true );
|
||||
|
||||
@@ -1109,12 +1109,12 @@ void CL_InitEdicts( int maxclients )
|
||||
clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos );
|
||||
}
|
||||
|
||||
ref.dllFuncs.R_ProcessEntData( true );
|
||||
ref.dllFuncs.R_ProcessEntData( true, clgame.entities, clgame.maxEntities );
|
||||
}
|
||||
|
||||
void CL_FreeEdicts( void )
|
||||
{
|
||||
ref.dllFuncs.R_ProcessEntData( false );
|
||||
ref.dllFuncs.R_ProcessEntData( false, NULL, 0 );
|
||||
|
||||
if( clgame.entities )
|
||||
Mem_Free( clgame.entities );
|
||||
@@ -1235,11 +1235,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
model_t *mod;
|
||||
int i;
|
||||
|
||||
// use high indices for client sprites
|
||||
// for GoldSrc bug-compatibility
|
||||
const int start = type != SPR_HUDSPRITE ? MAX_CLIENT_SPRITES / 2 : 0;
|
||||
int i, start;
|
||||
|
||||
if( !COM_CheckString( filename ))
|
||||
{
|
||||
@@ -1250,7 +1246,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
||||
Q_strncpy( name, filename, sizeof( name ));
|
||||
COM_FixSlashes( name );
|
||||
|
||||
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
for( i = 0, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
|
||||
{
|
||||
if( !Q_stricmp( mod->name, name ))
|
||||
{
|
||||
@@ -1267,8 +1263,15 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
||||
}
|
||||
|
||||
// find a free model slot spot
|
||||
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
if( !mod->name[0] ) break; // this is a valid spot
|
||||
// use low indices only for HUD sprites
|
||||
// for GoldSrc bug compatibility
|
||||
start = type == SPR_HUDSPRITE ? 0 : MAX_CLIENT_SPRITES / 2;
|
||||
|
||||
for( i = 0, mod = &clgame.sprites[start]; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
{
|
||||
if( !mod->name[0] )
|
||||
break; // this is a valid spot
|
||||
}
|
||||
|
||||
if( i == MAX_CLIENT_SPRITES / 2 )
|
||||
{
|
||||
@@ -1320,9 +1323,10 @@ HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags )
|
||||
=========
|
||||
pfnSPR_Load
|
||||
|
||||
function exported for support GoldSrc Monitor utility
|
||||
=========
|
||||
*/
|
||||
static HSPRITE GAME_EXPORT pfnSPR_Load( const char *szPicName )
|
||||
HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
|
||||
{
|
||||
model_t *spr;
|
||||
|
||||
@@ -1368,9 +1372,10 @@ static const model_t *CL_GetSpritePointer( HSPRITE hSprite )
|
||||
=========
|
||||
pfnSPR_Frames
|
||||
|
||||
function exported for support GoldSrc Monitor utility
|
||||
=========
|
||||
*/
|
||||
static int GAME_EXPORT pfnSPR_Frames( HSPRITE hPic )
|
||||
int EXPORT pfnSPR_Frames( HSPRITE hPic )
|
||||
{
|
||||
int numFrames = 0;
|
||||
|
||||
|
||||
@@ -414,11 +414,15 @@ static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in )
|
||||
out->gamemode = in->gamemode;
|
||||
|
||||
if( in->nomodels )
|
||||
out->flags |= GFL_NOMODELS;
|
||||
SetBits( out->flags, GFL_NOMODELS );
|
||||
if( in->noskills )
|
||||
out->flags |= GFL_NOSKILLS;
|
||||
SetBits( out->flags, GFL_NOSKILLS );
|
||||
if( in->render_picbutton_text )
|
||||
out->flags |= GFL_RENDER_PICBUTTON_TEXT;
|
||||
SetBits( out->flags, GFL_RENDER_PICBUTTON_TEXT );
|
||||
if( in->hd_background )
|
||||
SetBits( out->flags, GFL_HD_BACKGROUND );
|
||||
if( in->animated_title )
|
||||
SetBits( out->flags, GFL_ANIMATED_TITLE );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -982,7 +986,7 @@ pfnCheckGameDll
|
||||
*/
|
||||
int GAME_EXPORT pfnCheckGameDll( void )
|
||||
{
|
||||
#if XASH_INTERNAL_GAMELIBS
|
||||
#ifdef XASH_INTERNAL_GAMELIBS
|
||||
return true;
|
||||
#else
|
||||
string dllpath;
|
||||
|
||||
@@ -87,15 +87,6 @@ static int pfnDrawScaledCharacter( int x, int y, int number, int r, int g, int b
|
||||
return CL_DrawCharacter( x, y, number, color, &g_scaled_font, flags );
|
||||
}
|
||||
|
||||
static void *pfnGetNativeObject( const char *obj )
|
||||
{
|
||||
if( !obj )
|
||||
return NULL;
|
||||
|
||||
// Backend should consider that obj is case-sensitive
|
||||
return Platform_GetNativeObject( obj );
|
||||
}
|
||||
|
||||
static void pfnTouch_HideButtons( const char *name, byte state )
|
||||
{
|
||||
Touch_HideButtons( name, state, true );
|
||||
@@ -124,7 +115,7 @@ static mobile_engfuncs_t gpMobileEngfuncs =
|
||||
Touch_ResetDefaultButtons,
|
||||
pfnDrawScaledCharacter,
|
||||
Sys_Warn,
|
||||
pfnGetNativeObject,
|
||||
Sys_GetNativeObject,
|
||||
ID_SetCustomClientID,
|
||||
pfnParseFileSafe
|
||||
};
|
||||
|
||||
@@ -78,7 +78,7 @@ CL_CreateRawTextureFromPixels
|
||||
Convert texture_t struct into mstudiotexture_t prototype
|
||||
====================
|
||||
*/
|
||||
byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
|
||||
static byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
|
||||
{
|
||||
static mstudiotexture_t pin;
|
||||
byte *pal;
|
||||
@@ -111,7 +111,7 @@ CL_DuplicateTexture
|
||||
Dupliacte texture with remap pixels
|
||||
====================
|
||||
*/
|
||||
void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
static void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
{
|
||||
const char *name;
|
||||
texture_t *tx = NULL;
|
||||
@@ -154,7 +154,7 @@ CL_UpdateStudioTexture
|
||||
Update texture top and bottom colors
|
||||
====================
|
||||
*/
|
||||
void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
static void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
{
|
||||
rgbdata_t *pic;
|
||||
texture_t *tx = NULL;
|
||||
@@ -215,7 +215,7 @@ CL_UpdateAliasTexture
|
||||
Update texture top and bottom colors
|
||||
====================
|
||||
*/
|
||||
void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
|
||||
static void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
|
||||
{
|
||||
char texname[MAX_QPATH];
|
||||
rgbdata_t skin, *pic;
|
||||
@@ -247,6 +247,68 @@ void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int sk
|
||||
ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_FreeRemapInfo
|
||||
|
||||
Release remap info per entity
|
||||
====================
|
||||
*/
|
||||
static void CL_FreeRemapInfo( remap_info_t *info )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( info != NULL );
|
||||
|
||||
// release all colormap texture copies
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
|
||||
}
|
||||
|
||||
if( info->textures[i] != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
|
||||
}
|
||||
|
||||
Mem_Free( info ); // release struct
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_UpdateRemapInfo
|
||||
|
||||
Update all remaps per entity
|
||||
====================
|
||||
*/
|
||||
static void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
int i;
|
||||
|
||||
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
|
||||
info = clgame.remap_info[i];
|
||||
if( !info ) return; // no remap info
|
||||
|
||||
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
|
||||
return; // values is valid
|
||||
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
|
||||
}
|
||||
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
info->topcolor = topcolor;
|
||||
info->bottomcolor = bottomcolor;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_AllocRemapInfo
|
||||
@@ -255,7 +317,7 @@ Allocate new remap info per entity
|
||||
and make copy of remap textures
|
||||
====================
|
||||
*/
|
||||
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
|
||||
static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
studiohdr_t *phdr;
|
||||
@@ -362,68 +424,6 @@ void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int b
|
||||
info->model = model;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_UpdateRemapInfo
|
||||
|
||||
Update all remaps per entity
|
||||
====================
|
||||
*/
|
||||
void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
int i;
|
||||
|
||||
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
|
||||
info = clgame.remap_info[i];
|
||||
if( !info ) return; // no remap info
|
||||
|
||||
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
|
||||
return; // values is valid
|
||||
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
|
||||
}
|
||||
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
info->topcolor = topcolor;
|
||||
info->bottomcolor = bottomcolor;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_FreeRemapInfo
|
||||
|
||||
Release remap info per entity
|
||||
====================
|
||||
*/
|
||||
void CL_FreeRemapInfo( remap_info_t *info )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( info != NULL );
|
||||
|
||||
// release all colormap texture copies
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
|
||||
}
|
||||
|
||||
if( info->textures[i] != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
|
||||
}
|
||||
|
||||
Mem_Free( info ); // release struct
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_ClearAllRemaps
|
||||
@@ -446,3 +446,21 @@ void CL_ClearAllRemaps( void )
|
||||
}
|
||||
clgame.remap_info = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_EntitySetRemapColors
|
||||
=============
|
||||
*/
|
||||
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom )
|
||||
{
|
||||
CL_AllocRemapInfo( e, mod, top, bottom );
|
||||
|
||||
if( CL_GetRemapInfoForEntity( e ))
|
||||
{
|
||||
CL_UpdateRemapInfo( e, top, bottom );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -207,6 +207,8 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
|
||||
return pfnNumberOfEntities();
|
||||
case PARM_NUMMODELS:
|
||||
return cl.nummodels;
|
||||
case PARM_WORLD_VERSION:
|
||||
return world.version;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -2665,7 +2665,7 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
|
||||
// update flashlight endpos
|
||||
dl = CL_AllocDlight( ent->index );
|
||||
#if 1
|
||||
hit = CL_GetEntityByIndex( clgame.pmove->visents[trace.ent].info );
|
||||
hit = CL_GetEntityByIndex( clgame.pmove->physents[trace.ent].info );
|
||||
if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio ))
|
||||
VectorCopy( hit->origin, dl->origin );
|
||||
else VectorCopy( trace.endpos, dl->origin );
|
||||
|
||||
@@ -202,7 +202,6 @@ SCR_PlayCinematic
|
||||
*/
|
||||
qboolean SCR_PlayCinematic( const char *arg )
|
||||
{
|
||||
string path;
|
||||
const char *fullpath;
|
||||
|
||||
fullpath = FS_GetDiskPath( arg, false );
|
||||
|
||||
@@ -996,9 +996,7 @@ void CL_EmitEntities( void );
|
||||
// cl_remap.c
|
||||
//
|
||||
remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e );
|
||||
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
|
||||
void CL_FreeRemapInfo( remap_info_t *info );
|
||||
void CL_UpdateRemapInfo( cl_entity_t *ent, int topcolor, int bottomcolor );
|
||||
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom );
|
||||
void CL_ClearAllRemaps( void );
|
||||
|
||||
//
|
||||
|
||||
@@ -172,8 +172,6 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||
{
|
||||
if( newstate == oldstate )
|
||||
return;
|
||||
if( m_ignore.value )
|
||||
return;
|
||||
|
||||
// since SetCursorType controls cursor visibility
|
||||
// execute it first, and then check mouse grab state
|
||||
@@ -194,6 +192,10 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||
#endif
|
||||
}
|
||||
|
||||
// don't leave the user without cursor if they enabled m_ignore
|
||||
if( m_ignore.value )
|
||||
return;
|
||||
|
||||
if( oldstate == key_game )
|
||||
{
|
||||
IN_DeactivateMouse();
|
||||
|
||||
@@ -16,6 +16,7 @@ CVAR_DEFINE_AUTO( gl_msaa_samples, "0", FCVAR_GLCONFIG, "samples number for mult
|
||||
CVAR_DEFINE_AUTO( gl_clear, "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
|
||||
CVAR_DEFINE_AUTO( r_showtree, "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" );
|
||||
static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
|
||||
static CVAR_DEFINE_AUTO( r_refdll_loaded, "", FCVAR_READ_ONLY, "currently loaded renderer" );
|
||||
|
||||
void R_GetTextureParms( int *w, int *h, int texnum )
|
||||
{
|
||||
@@ -103,9 +104,9 @@ static void pfnGetPredictedOrigin( vec3_t v )
|
||||
VectorCopy( cl.simorg, v );
|
||||
}
|
||||
|
||||
static color24 *pfnCL_GetPaletteColor( int color ) // clgame.palette[color]
|
||||
static color24 *pfnCL_GetPaletteColor( void ) // clgame.palette[color]
|
||||
{
|
||||
return &clgame.palette[color];
|
||||
return clgame.palette;
|
||||
}
|
||||
|
||||
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
|
||||
@@ -157,11 +158,6 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s
|
||||
0;
|
||||
}
|
||||
|
||||
static poolhandle_t pfnImage_GetPool( void )
|
||||
{
|
||||
return host.imagepool;
|
||||
}
|
||||
|
||||
static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
|
||||
{
|
||||
return &PFDesc[idx];
|
||||
@@ -211,6 +207,11 @@ static qboolean R_Init_Video_( const int type )
|
||||
return R_Init_Video( type );
|
||||
}
|
||||
|
||||
static model_t **pfnGetModels( void )
|
||||
{
|
||||
return cl.models;
|
||||
}
|
||||
|
||||
static ref_api_t gEngfuncs =
|
||||
{
|
||||
pfnEngineGetParm,
|
||||
@@ -245,9 +246,7 @@ static ref_api_t gEngfuncs =
|
||||
Con_DrawString,
|
||||
CL_DrawCenterPrint,
|
||||
|
||||
CL_GetLocalPlayer,
|
||||
CL_GetViewModel,
|
||||
CL_GetEntityByIndex,
|
||||
R_BeamGetEntity,
|
||||
CL_GetWaterEntity,
|
||||
CL_AddVisibleEntity,
|
||||
@@ -271,12 +270,10 @@ static ref_api_t gEngfuncs =
|
||||
|
||||
Mod_ForName,
|
||||
pfnMod_Extradata,
|
||||
CL_ModelHandle,
|
||||
pfnGetModels,
|
||||
|
||||
CL_EntitySetRemapColors,
|
||||
CL_GetRemapInfoForEntity,
|
||||
CL_AllocRemapInfo,
|
||||
CL_FreeRemapInfo,
|
||||
CL_UpdateRemapInfo,
|
||||
|
||||
CL_ExtraUpdate,
|
||||
Host_Error,
|
||||
@@ -284,7 +281,6 @@ static ref_api_t gEngfuncs =
|
||||
COM_RandomFloat,
|
||||
COM_RandomLong,
|
||||
pfnRefGetScreenFade,
|
||||
CL_TextMessageGet,
|
||||
pfnGetPredictedOrigin,
|
||||
pfnCL_GetPaletteColor,
|
||||
pfnCL_GetScreenInfo,
|
||||
@@ -348,7 +344,6 @@ static ref_api_t gEngfuncs =
|
||||
FS_CopyImage,
|
||||
FS_FreeImage,
|
||||
Image_SetMDLPointer,
|
||||
pfnImage_GetPool,
|
||||
pfnImage_GetPFDesc,
|
||||
|
||||
pfnDrawNormalTriangles,
|
||||
@@ -430,7 +425,7 @@ static qboolean R_LoadProgs( const char *name )
|
||||
// make local copy of engfuncs to prevent overwrite it with user dll
|
||||
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
|
||||
|
||||
if( !GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ))
|
||||
if( GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ) != REF_API_VERSION )
|
||||
{
|
||||
COM_FreeLibrary( ref.hInstance );
|
||||
Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" );
|
||||
@@ -519,6 +514,7 @@ static qboolean R_LoadRenderer( const char *refopt )
|
||||
return false;
|
||||
}
|
||||
|
||||
Cvar_FullSet( "r_refdll_loaded", refopt, FCVAR_READ_ONLY );
|
||||
Con_Reportf( "Renderer %s initialized\n", refdll );
|
||||
|
||||
return true;
|
||||
@@ -567,6 +563,9 @@ static void R_CollectRendererNames( void )
|
||||
#if XASH_REF_GL4ES_ENABLED
|
||||
"gl4es",
|
||||
#endif
|
||||
#if XASH_REF_GLES3COMPAT_ENABLED
|
||||
"gles3compat",
|
||||
#endif
|
||||
#if XASH_REF_SOFT_ENABLED
|
||||
"soft",
|
||||
#endif
|
||||
@@ -587,6 +586,9 @@ static void R_CollectRendererNames( void )
|
||||
#if XASH_REF_GL4ES_ENABLED
|
||||
"GL4ES",
|
||||
#endif
|
||||
#if XASH_REF_GLES3COMPAT_ENABLED
|
||||
"GLES3 (gl2_shim)"
|
||||
#endif
|
||||
#if XASH_REF_SOFT_ENABLED
|
||||
"Software",
|
||||
#endif
|
||||
@@ -610,6 +612,7 @@ qboolean R_Init( void )
|
||||
Cvar_RegisterVariable( &gl_clear );
|
||||
Cvar_RegisterVariable( &r_showtree );
|
||||
Cvar_RegisterVariable( &r_refdll );
|
||||
Cvar_RegisterVariable( &r_refdll_loaded );
|
||||
|
||||
// cvars that are expected to exist
|
||||
Cvar_Get( "r_speeds", "0", FCVAR_ARCHIVE, "shows renderer speeds" );
|
||||
|
||||
@@ -381,6 +381,7 @@ typedef void (*xcommand_t)( void );
|
||||
qboolean FS_LoadProgs( void );
|
||||
void FS_Init( void );
|
||||
void FS_Shutdown( void );
|
||||
void *FS_GetNativeObject( const char *obj );
|
||||
|
||||
//
|
||||
// cmd.c
|
||||
@@ -421,8 +422,8 @@ 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 );
|
||||
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 );
|
||||
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 );
|
||||
@@ -792,7 +793,7 @@ void VID_Init( void );
|
||||
void UI_SetActiveMenu( qboolean fActive );
|
||||
void UI_ShowConnectionWarning( void );
|
||||
void Cmd_Null_f( void );
|
||||
void Rcon_Print( const char *pMsg );
|
||||
void Rcon_Print( host_redirect_t *rd, const char *pMsg );
|
||||
qboolean COM_ParseVector( char **pfile, float *v, size_t size );
|
||||
void COM_NormalizeAngles( vec3_t angles );
|
||||
int COM_FileSize( const char *filename );
|
||||
|
||||
@@ -320,7 +320,9 @@ void Sys_RestoreCrashHandler( void )
|
||||
|
||||
#elif XASH_FREEBSD || XASH_NETBSD || XASH_OPENBSD || XASH_ANDROID || XASH_LINUX
|
||||
// Posix signal handler
|
||||
#ifndef XASH_OPENBSD
|
||||
#include <ucontext.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <sys/mman.h>
|
||||
#include "library.h"
|
||||
@@ -488,7 +490,7 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
|
||||
#ifdef XASH_SDL
|
||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
||||
#endif
|
||||
MSGBOX( message );
|
||||
Platform_MessageBox( "Xash Error", message, false );
|
||||
|
||||
// log saved, now we can try to save configs and close log correctly, it may crash
|
||||
if( host.type == HOST_NORMAL )
|
||||
|
||||
@@ -1136,8 +1136,6 @@ As Cvar_Set, but also flags it as glconfig
|
||||
*/
|
||||
void Cvar_SetGL_f( void )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
if( Cmd_Argc() != 3 )
|
||||
{
|
||||
Con_Printf( S_USAGE "setgl <variable> <value>\n" );
|
||||
|
||||
@@ -23,8 +23,17 @@ GNU General Public License for more details.
|
||||
fs_api_t g_fsapi;
|
||||
fs_globals_t *FI;
|
||||
|
||||
static pfnCreateInterface_t fs_pfnCreateInterface;
|
||||
static HINSTANCE fs_hInstance;
|
||||
|
||||
void *FS_GetNativeObject( const char *obj )
|
||||
{
|
||||
if( fs_pfnCreateInterface )
|
||||
return fs_pfnCreateInterface( obj, NULL );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void FS_Rescan_f( void )
|
||||
{
|
||||
FS_Rescan();
|
||||
@@ -53,7 +62,7 @@ static fs_interface_t fs_memfuncs =
|
||||
_Mem_Realloc,
|
||||
_Mem_Free,
|
||||
|
||||
Platform_GetNativeObject,
|
||||
Sys_GetNativeObject,
|
||||
};
|
||||
|
||||
static void FS_UnloadProgs( void )
|
||||
@@ -98,6 +107,13 @@ qboolean FS_LoadProgs( void )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !( fs_pfnCreateInterface = (pfnCreateInterface_t)COM_GetProcAddress( fs_hInstance, "CreateInterface" )))
|
||||
{
|
||||
FS_UnloadProgs();
|
||||
Host_Error( "FS_LoadProgs: can't find CreateInterface entry point in %s\n", name );
|
||||
return false;
|
||||
}
|
||||
|
||||
Con_DPrintf( "FS_LoadProgs: filesystem_stdio successfully loaded\n" );
|
||||
|
||||
return true;
|
||||
|
||||
@@ -52,7 +52,7 @@ struct tests_stats_s tests_stats;
|
||||
#endif
|
||||
|
||||
CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" );
|
||||
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_CHEAT|FCVAR_FILTERABLE, "scale frame time" );
|
||||
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_FILTERABLE, "scale frame time" );
|
||||
CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" );
|
||||
|
||||
static CVAR_DEFINE_AUTO( host_serverstate, "0", FCVAR_READ_ONLY, "displays current server state" );
|
||||
@@ -62,6 +62,7 @@ CVAR_DEFINE_AUTO( host_limitlocal, "0", 0, "apply cl_cmdrate and rate to loopbac
|
||||
CVAR_DEFINE( host_maxfps, "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" );
|
||||
static CVAR_DEFINE_AUTO( host_framerate, "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" );
|
||||
static CVAR_DEFINE( host_sleeptime, "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" );
|
||||
static CVAR_DEFINE_AUTO( host_sleeptime_debug, "0", 0, "print sleeps between frames" );
|
||||
CVAR_DEFINE( con_gamemaps, "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" );
|
||||
|
||||
void Sys_PrintUsage( void )
|
||||
@@ -139,7 +140,7 @@ void Sys_PrintUsage( void )
|
||||
O("-sdl_joy_old_api ","use SDL legacy joystick API")
|
||||
O("-sdl_renderer <n>","use alternative SDL_Renderer for software")
|
||||
#endif // XASH_SDL
|
||||
#if XASH_ANDROID
|
||||
#if XASH_ANDROID && !XASH_SDL
|
||||
O("-nativeegl ","use native egl implementation. Use if screen does not update or black")
|
||||
#endif // XASH_ANDROID
|
||||
#if XASH_DOS
|
||||
@@ -618,6 +619,84 @@ double Host_CalcFPS( void )
|
||||
return fps;
|
||||
}
|
||||
|
||||
static qboolean Host_Autosleep( double dt, double scale )
|
||||
{
|
||||
double targetframetime, fps;
|
||||
int sleep;
|
||||
|
||||
fps = Host_CalcFPS();
|
||||
|
||||
if( fps <= 0 )
|
||||
return true;
|
||||
|
||||
// limit fps to withing tolerable range
|
||||
fps = bound( MIN_FPS, fps, MAX_FPS );
|
||||
|
||||
if( Host_IsDedicated( ))
|
||||
targetframetime = ( 1.0 / ( fps + 1.0 ));
|
||||
else targetframetime = ( 1.0 / fps );
|
||||
|
||||
sleep = Host_CalcSleep();
|
||||
if( sleep == 0 ) // no sleeps between frames, much simpler code
|
||||
{
|
||||
if( dt < targetframetime * scale )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
static double timewindow; // allocate a time window for sleeps
|
||||
static int counter; // for debug
|
||||
static double realsleeptime;
|
||||
const double sleeptime = sleep * 0.001;
|
||||
|
||||
if( dt < targetframetime * scale )
|
||||
{
|
||||
// if we have allocated time window, try to sleep
|
||||
if( timewindow > realsleeptime )
|
||||
{
|
||||
// Sys_Sleep isn't guaranteed to sleep an exact amount of milliseconds
|
||||
// so we measure the real sleep time and use it to decrease the window
|
||||
double t1 = Sys_DoubleTime(), t2;
|
||||
Sys_Sleep( sleep ); // in msec!
|
||||
t2 = Sys_DoubleTime();
|
||||
realsleeptime = t2 - t1;
|
||||
|
||||
timewindow -= realsleeptime;
|
||||
|
||||
if( host_sleeptime_debug.value )
|
||||
{
|
||||
counter++;
|
||||
|
||||
Con_NPrintf( counter, "%d: %.4f %.4f", counter, timewindow, realsleeptime );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// if we exhausted this time window, allocate a new one after new frame
|
||||
if( timewindow <= realsleeptime )
|
||||
{
|
||||
double targetsleeptime = targetframetime - host.pureframetime * 2;
|
||||
|
||||
if( targetsleeptime > 0 )
|
||||
timewindow = targetsleeptime;
|
||||
else timewindow = 0;
|
||||
|
||||
realsleeptime = sleeptime; // reset in case CPU was too busy
|
||||
|
||||
if( host_sleeptime_debug.value )
|
||||
{
|
||||
counter = 0;
|
||||
|
||||
Con_NPrintf( 0, "tgt = %.4f, pft = %.4f, wnd = %.4f", targetframetime, host.pureframetime, timewindow );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
Host_FilterTime
|
||||
@@ -628,55 +707,15 @@ Returns false if the time is too short to run a frame
|
||||
qboolean Host_FilterTime( float time )
|
||||
{
|
||||
static double oldtime;
|
||||
double fps, scale = sys_timescale.value;
|
||||
double dt;
|
||||
double scale = sys_timescale.value;
|
||||
|
||||
host.realtime += time * scale;
|
||||
fps = Host_CalcFPS();
|
||||
dt = host.realtime - oldtime;
|
||||
|
||||
// clamp the fps in multiplayer games
|
||||
if( fps != 0.0 )
|
||||
{
|
||||
static int sleeps;
|
||||
double targetframetime;
|
||||
int sleeptime = Host_CalcSleep();
|
||||
|
||||
// limit fps to withing tolerable range
|
||||
fps = bound( MIN_FPS, fps, MAX_FPS );
|
||||
|
||||
if( Host_IsDedicated( ))
|
||||
targetframetime = ( 1.0 / ( fps + 1.0 ));
|
||||
else targetframetime = ( 1.0 / fps );
|
||||
|
||||
if(( host.realtime - oldtime ) < targetframetime * scale )
|
||||
{
|
||||
if( sleeptime > 0 && sleeps > 0 )
|
||||
{
|
||||
Sys_Sleep( sleeptime );
|
||||
sleeps--;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( sleeptime > 0 && sleeps <= 0 )
|
||||
{
|
||||
if( host.status == HOST_FRAME )
|
||||
{
|
||||
// give few sleeps this frame with small margin
|
||||
double targetsleeptime = targetframetime - host.pureframetime * 2;
|
||||
|
||||
// don't sleep if we can't keep up with the framerate
|
||||
if( targetsleeptime > 0 )
|
||||
sleeps = targetsleeptime / ( sleeptime * 0.001 );
|
||||
else sleeps = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// always sleep at least once in minimized/nofocus state
|
||||
sleeps = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( !Host_Autosleep( dt, scale ))
|
||||
return false;
|
||||
|
||||
host.frametime = host.realtime - oldtime;
|
||||
host.realframetime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
|
||||
@@ -756,7 +795,7 @@ void GAME_EXPORT Host_Error( const char *error, ... )
|
||||
Key_SetKeyDest( key_console );
|
||||
Con_Printf( "Host_Error: %s", hosterror1 );
|
||||
}
|
||||
else MSGBOX2( hosterror1 );
|
||||
else Platform_MessageBox( "Host Error", hosterror1, true );
|
||||
}
|
||||
|
||||
// host is shutting down. don't invoke infinite loop
|
||||
@@ -1020,7 +1059,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
||||
#if TARGET_OS_IOS
|
||||
Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof( host.rootdir ));
|
||||
#elif XASH_ANDROID && XASH_SDL
|
||||
Q_strncpy( host.rootdir, SDL_AndroidGetExternalStoragePath, sizeof( host.rootdir ));
|
||||
Q_strncpy( host.rootdir, SDL_AndroidGetExternalStoragePath(), sizeof( host.rootdir ));
|
||||
#elif XASH_PSVITA
|
||||
if ( !PSVita_GetBasePath( host.rootdir, sizeof( host.rootdir )))
|
||||
{
|
||||
@@ -1181,6 +1220,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
|
||||
Cvar_RegisterVariable( &host_maxfps );
|
||||
Cvar_RegisterVariable( &host_framerate );
|
||||
Cvar_RegisterVariable( &host_sleeptime );
|
||||
Cvar_RegisterVariable( &host_sleeptime_debug );
|
||||
Cvar_RegisterVariable( &host_gameloaded );
|
||||
Cvar_RegisterVariable( &host_clientloaded );
|
||||
Cvar_RegisterVariable( &host_limitlocal );
|
||||
|
||||
@@ -87,6 +87,12 @@ static qboolean Image_KTX2Parse( const ktx2_header_t *header, const byte *buffer
|
||||
return false;
|
||||
}
|
||||
|
||||
if( header->levelCount == 0 )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: file has no mip levels\n", __FUNCTION__ );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( header->pixelDepth > 1 )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: unsupported KTX2 pixelDepth %d\n", __FUNCTION__, header->pixelDepth );
|
||||
|
||||
@@ -980,7 +980,7 @@ Mod_SampleSizeForFace
|
||||
return the current lightmap resolution per face
|
||||
==================
|
||||
*/
|
||||
int Mod_SampleSizeForFace( msurface_t *surf )
|
||||
int Mod_SampleSizeForFace( const msurface_t *surf )
|
||||
{
|
||||
if( !surf || !surf->texinfo )
|
||||
return LM_SAMPLE_SIZE;
|
||||
@@ -2012,6 +2012,20 @@ static void Mod_LoadMarkSurfaces( model_t *mod, dbspmodel_t *bmod )
|
||||
}
|
||||
}
|
||||
|
||||
static qboolean Mod_LooksLikeWaterTexture( const char *name )
|
||||
{
|
||||
if(( name[0] == '*' && Q_stricmp( name, REF_DEFAULT_TEXTURE )) || name[0] == '!' )
|
||||
return true;
|
||||
|
||||
if( !Host_IsQuakeCompatible( ))
|
||||
{
|
||||
if( !Q_strncmp( name, "water", 5 ) || !Q_strnicmp( name, "laser", 5 ))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureIndex )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
@@ -2032,6 +2046,10 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
|
||||
if( FBitSet( host.features, ENGINE_IMPROVED_LINETRACE ) && mipTex->name[0] == '{' )
|
||||
SetBits( txFlags, TF_KEEP_SOURCE ); // Paranoia2 texture alpha-tracing
|
||||
|
||||
// check if this is water to keep the source texture and expand it to RGBA (so ripple effect works)
|
||||
if( Mod_LooksLikeWaterTexture( mipTex->name ))
|
||||
SetBits( txFlags, TF_KEEP_SOURCE | TF_EXPAND_SOURCE );
|
||||
|
||||
usesCustomPalette = Mod_CalcMipTexUsesCustomPalette( mod, bmod, textureIndex );
|
||||
|
||||
// check for multi-layered sky texture (quake1 specific)
|
||||
@@ -2449,15 +2467,9 @@ static void Mod_LoadSurfaces( model_t *mod, dbspmodel_t *bmod )
|
||||
if( !Q_strncmp( tex->name, "sky", 3 ))
|
||||
SetBits( out->flags, SURF_DRAWSKY );
|
||||
|
||||
if(( tex->name[0] == '*' && Q_stricmp( tex->name, REF_DEFAULT_TEXTURE )) || tex->name[0] == '!' )
|
||||
if( Mod_LooksLikeWaterTexture( tex->name ))
|
||||
SetBits( out->flags, SURF_DRAWTURB );
|
||||
|
||||
if( !Host_IsQuakeCompatible( ))
|
||||
{
|
||||
if( !Q_strncmp( tex->name, "water", 5 ) || !Q_strnicmp( tex->name, "laser", 5 ))
|
||||
SetBits( out->flags, SURF_DRAWTURB );
|
||||
}
|
||||
|
||||
if( !Q_strncmp( tex->name, "scroll", 6 ))
|
||||
SetBits( out->flags, SURF_CONVEYOR );
|
||||
|
||||
@@ -2986,6 +2998,7 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
|
||||
|
||||
if( isworld )
|
||||
{
|
||||
world.version = bmod->version;
|
||||
#if !XASH_DEDICATED
|
||||
Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc)
|
||||
world.deluxedata = bmod->deluxedata_out; // deluxemap data pointer
|
||||
|
||||
@@ -113,6 +113,8 @@ typedef struct world_static_s
|
||||
// tree visualization stuff
|
||||
int recursion_level;
|
||||
int max_recursion;
|
||||
|
||||
uint32_t version; // BSP version
|
||||
} world_static_t;
|
||||
|
||||
#ifndef REF_DLL
|
||||
@@ -155,7 +157,7 @@ int Mod_CheckLump( const char *filename, const int lump, int *lumpsize );
|
||||
int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize );
|
||||
int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize );
|
||||
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node );
|
||||
int Mod_SampleSizeForFace( msurface_t *surf );
|
||||
int Mod_SampleSizeForFace( const msurface_t *surf );
|
||||
byte *Mod_GetPVSForPoint( const vec3_t p );
|
||||
void Mod_UnloadBrushModel( model_t *mod );
|
||||
void Mod_PrintWorldStats_f( void );
|
||||
|
||||
@@ -111,6 +111,7 @@ void Mod_FreeModel( model_t *mod )
|
||||
|
||||
if( mod->type == mod_brush && FBitSet( mod->flags, MODEL_WORLD ) )
|
||||
{
|
||||
world.version = 0;
|
||||
world.shadowdata = NULL;
|
||||
world.deluxedata = NULL;
|
||||
}
|
||||
|
||||
@@ -1087,7 +1087,6 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
||||
delta_info_t *dt = NULL;
|
||||
delta_t *pField;
|
||||
int i, countBits;
|
||||
int numChanges = 0;
|
||||
|
||||
countBits = MAX_ENTITY_BITS + 2;
|
||||
|
||||
@@ -1121,7 +1120,7 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
||||
|
||||
if( !Delta_CompareField( pField, from, to, timebase ))
|
||||
{
|
||||
// strings are handled difference
|
||||
// strings are handled differently
|
||||
if( FBitSet( pField->flags, DT_STRING ))
|
||||
countBits += Q_strlen((char *)((byte *)to + pField->offset )) * 8;
|
||||
else countBits += pField->bits;
|
||||
|
||||
@@ -2200,6 +2200,8 @@ HTTP downloader
|
||||
=================================================
|
||||
*/
|
||||
|
||||
#define MAX_HTTP_BUFFER_SIZE (BIT( 13 ))
|
||||
|
||||
typedef struct httpserver_s
|
||||
{
|
||||
char host[256];
|
||||
@@ -2240,7 +2242,7 @@ typedef struct httpfile_s
|
||||
qboolean process;
|
||||
|
||||
// query or response
|
||||
char buf[BUFSIZ+1];
|
||||
char buf[MAX_HTTP_BUFFER_SIZE+1];
|
||||
int header_size, query_length, bytes_sent;
|
||||
} httpfile_t;
|
||||
|
||||
@@ -2385,18 +2387,18 @@ process incoming data
|
||||
*/
|
||||
static qboolean HTTP_ProcessStream( httpfile_t *curfile )
|
||||
{
|
||||
char buf[BUFSIZ+1];
|
||||
char buf[sizeof( curfile->buf )];
|
||||
char *begin = 0;
|
||||
int res;
|
||||
|
||||
if( curfile->header_size >= BUFSIZ )
|
||||
if( curfile->header_size >= sizeof( buf ))
|
||||
{
|
||||
Con_Reportf( S_ERROR "Header to big\n");
|
||||
Con_Reportf( S_ERROR "Header too big, the size is %s\n", curfile->header_size );
|
||||
HTTP_FreeFile( curfile, true );
|
||||
return false;
|
||||
}
|
||||
|
||||
while( ( res = recv( curfile->socket, buf, BUFSIZ - curfile->header_size, 0 )) > 0) // if we got there, we are receiving data
|
||||
while( ( res = recv( curfile->socket, buf, sizeof( buf ) - curfile->header_size, 0 )) > 0) // if we got there, we are receiving data
|
||||
{
|
||||
curfile->blocktime = 0;
|
||||
|
||||
@@ -2409,7 +2411,7 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
|
||||
if( begin ) // Got full header
|
||||
{
|
||||
int cutheadersize = begin - curfile->buf + 4; // after that begin of data
|
||||
char *length;
|
||||
char *content_length_line;
|
||||
|
||||
Con_Reportf( "HTTP: Got response!\n" );
|
||||
|
||||
@@ -2428,10 +2430,13 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
|
||||
}
|
||||
|
||||
// print size
|
||||
length = Q_stristr( curfile->buf, "Content-Length: " );
|
||||
if( length )
|
||||
content_length_line = Q_stristr( curfile->buf, "Content-Length: " );
|
||||
if( content_length_line )
|
||||
{
|
||||
int size = Q_atoi( length += 16 );
|
||||
int size;
|
||||
|
||||
content_length_line += sizeof( "Content-Length: " ) - 1;
|
||||
size = Q_atoi( content_length_line );
|
||||
|
||||
Con_Reportf( "HTTP: File size is %d\n", size );
|
||||
|
||||
@@ -2873,6 +2878,10 @@ static void HTTP_AddCustomServer_f( void )
|
||||
{
|
||||
HTTP_AddCustomServer( Cmd_Argv( 1 ));
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf( S_USAGE "http_addcustomserver <url>\n" );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -402,7 +402,7 @@ void Sys_Warn( const char *format, ... )
|
||||
Msg( "Sys_Warn: %s\n", text );
|
||||
|
||||
if( !Host_IsDedicated() ) // dedicated server should not hang on messagebox
|
||||
MSGBOX(text);
|
||||
Platform_MessageBox( "Xash Warning", text, false );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -446,8 +446,8 @@ void Sys_Error( const char *error, ... )
|
||||
#if XASH_WIN32
|
||||
Wcon_ShowConsole( false );
|
||||
#endif
|
||||
MSGBOX( text );
|
||||
Sys_Print( text );
|
||||
Platform_MessageBox( "Xash Error", text, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -562,7 +562,7 @@ void Sys_Print( const char *pMsg )
|
||||
|
||||
Sys_PrintLog( pMsg );
|
||||
|
||||
Rcon_Print( pMsg );
|
||||
Rcon_Print( &host.rd, pMsg );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -649,3 +649,31 @@ qboolean Sys_NewInstance( const char *gamedir )
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
Sys_GetNativeObject
|
||||
|
||||
Get platform-specific native object
|
||||
==================
|
||||
*/
|
||||
void *Sys_GetNativeObject( const char *obj )
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if( !COM_CheckString( obj ))
|
||||
return NULL;
|
||||
|
||||
ptr = FS_GetNativeObject( obj );
|
||||
|
||||
if( ptr )
|
||||
return ptr;
|
||||
|
||||
// Backend should consider that obj is case-sensitive
|
||||
#if XASH_ANDROID
|
||||
ptr = Android_GetNativeObject( obj );
|
||||
#endif // XASH_ANDROID
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,6 @@ extern "C" {
|
||||
#include "crtlib.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#define MSGBOX( x ) Platform_MessageBox( "Xash Error", (x), false )
|
||||
#define MSGBOX2( x ) Platform_MessageBox( "Host Error", (x), true )
|
||||
#define MSGBOX3( x ) Platform_MessageBox( "Host Recursive Error", (x), true )
|
||||
#define ASSERT( exp ) if(!( exp )) Sys_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )
|
||||
|
||||
/*
|
||||
@@ -70,6 +67,7 @@ void Sys_InitLog( void );
|
||||
void Sys_CloseLog( void );
|
||||
void Sys_Quit( void ) NORETURN;
|
||||
qboolean Sys_NewInstance( const char *gamedir );
|
||||
void *Sys_GetNativeObject( const char *obj );
|
||||
|
||||
//
|
||||
// sys_con.c
|
||||
|
||||
@@ -632,12 +632,14 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
|
||||
else
|
||||
{
|
||||
const char* PATH = getenv("PATH");
|
||||
const char* begin;
|
||||
size_t argv0_length;
|
||||
if (!PATH)
|
||||
break;
|
||||
|
||||
size_t argv0_length = strlen(argv[0]);
|
||||
argv0_length = strlen(argv[0]);
|
||||
|
||||
const char* begin = PATH;
|
||||
begin = PATH;
|
||||
while (1)
|
||||
{
|
||||
const char* separator = strchr(begin, ':');
|
||||
|
||||
@@ -143,7 +143,7 @@ typedef struct ui_enginefuncs_s
|
||||
void *(*pfnKeyGetState)( const char *name ); // for mlook, klook etc
|
||||
|
||||
// engine memory manager
|
||||
void* (*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
|
||||
void* (*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
|
||||
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
|
||||
|
||||
// collect info from engine
|
||||
|
||||
@@ -86,7 +86,7 @@ typedef struct server_physics_api_s
|
||||
const byte *(*pfnGetTextureData)( unsigned int texnum );
|
||||
|
||||
// static allocations
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
|
||||
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
|
||||
|
||||
// trace & contents
|
||||
|
||||
@@ -32,10 +32,9 @@ struct jnimethods_s
|
||||
JNIEnv *env;
|
||||
jobject activity;
|
||||
jclass actcls;
|
||||
jmethodID getID;
|
||||
jmethodID saveID;
|
||||
jmethodID loadID;
|
||||
jmethodID getKeyboardHeight;
|
||||
jmethodID loadAndroidID;
|
||||
jmethodID getAndroidID;
|
||||
jmethodID saveAndroidID;
|
||||
} jni;
|
||||
|
||||
void Android_Init( void )
|
||||
@@ -43,10 +42,9 @@ void Android_Init( void )
|
||||
jni.env = (JNIEnv *)SDL_AndroidGetJNIEnv();
|
||||
jni.activity = (jobject)SDL_AndroidGetActivity();
|
||||
jni.actcls = (*jni.env)->GetObjectClass( jni.env, jni.activity );
|
||||
jni.loadID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "loadAndroidID", "()Ljava/lang/String;" );
|
||||
jni.getID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "getAndroidID", "()Ljava/lang/String;" );
|
||||
jni.saveID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "saveAndroidID", "(Ljava/lang/String;)V" );
|
||||
jni.getKeyboardHeight = (*jni.env)->GetMethodID( jni.env, jni.actcls, "getKeyboardHeight", "()I" );
|
||||
jni.loadAndroidID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "loadAndroidID", "()Ljava/lang/String;" );
|
||||
jni.getAndroidID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "getAndroidID", "()Ljava/lang/String;" );
|
||||
jni.saveAndroidID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "saveAndroidID", "(Ljava/lang/String;)V" );
|
||||
|
||||
SDL_SetHint( SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight" );
|
||||
SDL_SetHint( SDL_HINT_JOYSTICK_HIDAPI_STEAM, "1" );
|
||||
@@ -95,7 +93,7 @@ const char *Android_GetAndroidID( void )
|
||||
|
||||
if( COM_CheckString( id ) ) return id;
|
||||
|
||||
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getID );
|
||||
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getAndroidID );
|
||||
resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
|
||||
Q_strncpy( id, resultCStr, sizeof( id ) );
|
||||
(*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr );
|
||||
@@ -114,7 +112,7 @@ const char *Android_LoadID( void )
|
||||
jstring resultJNIStr;
|
||||
const char *resultCStr;
|
||||
|
||||
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.loadID );
|
||||
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.loadAndroidID );
|
||||
resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
|
||||
Q_strncpy( id, resultCStr, sizeof( id ) );
|
||||
(*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr );
|
||||
@@ -129,7 +127,7 @@ Android_SaveID
|
||||
*/
|
||||
void Android_SaveID( const char *id )
|
||||
{
|
||||
(*jni.env)->CallVoidMethod( jni.env, jni.activity, jni.saveID, (*jni.env)->NewStringUTF( jni.env, id ) );
|
||||
(*jni.env)->CallVoidMethod( jni.env, jni.activity, jni.saveAndroidID, (*jni.env)->NewStringUTF( jni.env, id ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -144,14 +142,4 @@ void Platform_ShellExecute( const char *path, const char *parms )
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
Android_GetKeyboardHeight
|
||||
========================
|
||||
*/
|
||||
int Android_GetKeyboardHeight( void )
|
||||
{
|
||||
return (*jni.env)->CallIntMethod( jni.env, jni.activity, jni.getKeyboardHeight );
|
||||
}
|
||||
|
||||
#endif // XASH_DEDICATED
|
||||
|
||||
@@ -63,7 +63,6 @@ const char *Android_LoadID( void );
|
||||
void Android_SaveID( const char *id );
|
||||
void Android_Init( void );
|
||||
void *Android_GetNativeObject( const char *name );
|
||||
int Android_GetKeyboardHeight( void );
|
||||
#endif
|
||||
|
||||
#if XASH_WIN32
|
||||
@@ -139,17 +138,6 @@ static inline void Platform_Shutdown( void )
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void *Platform_GetNativeObject( const char *name )
|
||||
{
|
||||
void *ptr = NULL;
|
||||
|
||||
#if XASH_ANDROID
|
||||
ptr = Android_GetNativeObject( name );
|
||||
#endif
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
@@ -158,7 +146,6 @@ static inline void *Platform_GetNativeObject( const char *name )
|
||||
==============================================================================
|
||||
*/
|
||||
void Platform_Vibrate( float life, char flags );
|
||||
void*Platform_GetNativeObject( const char *name );
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
@@ -654,9 +654,9 @@ static void VID_SetWindowIcon( SDL_Window *hWnd )
|
||||
{
|
||||
rgbdata_t *icon = NULL;
|
||||
char iconpath[MAX_STRING];
|
||||
#if XASH_WIN32 // ICO support only for Win32
|
||||
const char *localIcoPath;
|
||||
|
||||
#if XASH_WIN32 // ICO support only for Win32
|
||||
if(( localIcoPath = FS_GetDiskPath( GI->iconpath, true )))
|
||||
{
|
||||
HICON ico = (HICON)LoadImage( NULL, localIcoPath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE|LR_DEFAULTSIZE );
|
||||
|
||||
@@ -34,7 +34,11 @@ GNU General Public License for more details.
|
||||
// 2. FS functions are removed, instead we have full fs_api_t
|
||||
// 3. SlerpBones, CalcBonePosition/Quaternion calls were moved to libpublic/mathlib
|
||||
// 4. R_StudioEstimateFrame now has time argument
|
||||
#define REF_API_VERSION 4
|
||||
// 5. Removed GetSomethingByIndex calls, renderers are supposed to cache pointer values
|
||||
// Removed previously unused calls
|
||||
// Simplified remapping calls
|
||||
// GetRefAPI is now expected to return REF_API_VERSION
|
||||
#define REF_API_VERSION 5
|
||||
|
||||
|
||||
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
|
||||
@@ -257,6 +261,7 @@ typedef enum
|
||||
PARM_LOCAL_GAME = -11,
|
||||
PARM_NUMENTITIES = -12, // local game only
|
||||
PARM_NUMMODELS = -13, // cl.nummodels
|
||||
PARM_WORLD_VERSION = -14,
|
||||
} ref_parm_e;
|
||||
|
||||
typedef struct ref_api_s
|
||||
@@ -299,15 +304,13 @@ typedef struct ref_api_s
|
||||
void (*CL_DrawCenterPrint)( void );
|
||||
|
||||
// entity management
|
||||
struct cl_entity_s *(*GetLocalPlayer)( void );
|
||||
struct cl_entity_s *(*GetViewModel)( void );
|
||||
struct cl_entity_s *(*GetEntityByIndex)( int idx );
|
||||
struct cl_entity_s *(*R_BeamGetEntity)( int index );
|
||||
struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p );
|
||||
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
|
||||
|
||||
// brushes
|
||||
int (*Mod_SampleSizeForFace)( struct msurface_s *surf );
|
||||
int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
|
||||
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
||||
struct world_static_s *(*GetWorld)( void ); // returns &world
|
||||
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node );
|
||||
@@ -329,13 +332,11 @@ typedef struct ref_api_s
|
||||
// model management
|
||||
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
|
||||
void *(*Mod_Extradata)( int type, model_t *model );
|
||||
struct model_s *(*pfnGetModelByIndex)( int index ); // CL_ModelHandle
|
||||
struct model_s **(*pfnGetModels)( void );
|
||||
|
||||
// remap
|
||||
qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom );
|
||||
struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e );
|
||||
void (*CL_AllocRemapInfo)( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
|
||||
void (*CL_FreeRemapInfo)( struct remap_info_s *info );
|
||||
void (*CL_UpdateRemapInfo)( cl_entity_t *entity, int topcolor, int bottomcolor );
|
||||
|
||||
// utils
|
||||
void (*CL_ExtraUpdate)( void );
|
||||
@@ -344,9 +345,8 @@ typedef struct ref_api_s
|
||||
float (*COM_RandomFloat)( float rmin, float rmax );
|
||||
int (*COM_RandomLong)( int rmin, int rmax );
|
||||
struct screenfade_s *(*GetScreenFade)( void );
|
||||
struct client_textmessage_s *(*pfnTextMessageGet)( const char *pName );
|
||||
void (*GetPredictedOrigin)( vec3_t v );
|
||||
color24 *(*CL_GetPaletteColor)(int color); // clgame.palette[color]
|
||||
color24 *(*CL_GetPaletteColor)( void ); // clgame.palette[color]
|
||||
void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
|
||||
void (*SetLocalLightLevel)( int level ); // cl.local.light_level
|
||||
int (*Sys_CheckParm)( const char *flag );
|
||||
@@ -362,8 +362,8 @@ typedef struct ref_api_s
|
||||
// memory
|
||||
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_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 );
|
||||
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
|
||||
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
|
||||
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
||||
|
||||
// library management
|
||||
@@ -420,7 +420,6 @@ typedef struct ref_api_s
|
||||
rgbdata_t *(*FS_CopyImage)( rgbdata_t *in );
|
||||
void (*FS_FreeImage)( rgbdata_t *pack );
|
||||
void (*Image_SetMDLPointer)( byte *p );
|
||||
poolhandle_t (*Image_GetPool)( void );
|
||||
const struct bpc_desc_s *(*Image_GetPFDesc)( int idx );
|
||||
|
||||
// client exports
|
||||
@@ -449,6 +448,7 @@ typedef struct ref_interface_s
|
||||
void (*GL_InitExtensions)( void );
|
||||
void (*GL_ClearExtensions)( void );
|
||||
|
||||
// scene rendering
|
||||
void (*R_BeginFrame)( qboolean clearScene );
|
||||
void (*R_RenderScene)( void );
|
||||
void (*R_EndFrame)( void );
|
||||
@@ -463,7 +463,8 @@ typedef struct ref_interface_s
|
||||
|
||||
qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type );
|
||||
void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam );
|
||||
void (*R_ProcessEntData)( qboolean allocate );
|
||||
void (*R_ProcessEntData)( qboolean allocate, cl_entity_t *entities, unsigned int max_entities );
|
||||
void (*R_Flush)( unsigned int flush_flags );
|
||||
|
||||
// debug
|
||||
void (*R_ShowTextures)( void );
|
||||
|
||||
@@ -472,6 +472,8 @@ extern convar_t sv_userinfo_penalty_multiplier;
|
||||
extern convar_t sv_userinfo_penalty_attempts;
|
||||
extern convar_t sv_fullupdate_penalty_time;
|
||||
extern convar_t sv_log_outofband;
|
||||
extern convar_t sv_allow_autoaim;
|
||||
extern convar_t sv_aim;
|
||||
|
||||
//===========================================================
|
||||
//
|
||||
@@ -562,7 +564,7 @@ qboolean SV_IsPlayerIndex( int idx );
|
||||
int SV_CalcPing( sv_client_t *cl );
|
||||
void SV_InitClientMove( void );
|
||||
void SV_UpdateServerInfo( void );
|
||||
void SV_EndRedirect( void );
|
||||
void SV_EndRedirect( host_redirect_t *rd );
|
||||
void SV_RejectConnection( netadr_t from, const char *fmt, ... ) _format( 2 );
|
||||
void SV_GetPlayerCount( int *clients, int *bots );
|
||||
|
||||
|
||||
@@ -639,7 +639,7 @@ void SV_DropClient( sv_client_t *cl, qboolean crash )
|
||||
cl->frames = NULL;
|
||||
|
||||
if( NET_CompareBaseAdr( cl->netchan.remote_address, host.rd.address ))
|
||||
SV_EndRedirect();
|
||||
SV_EndRedirect( &host.rd );
|
||||
|
||||
// throw away any residual garbage in the channel.
|
||||
Netchan_Clear( &cl->netchan );
|
||||
@@ -676,22 +676,19 @@ SVC COMMAND REDIRECT
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
void SV_BeginRedirect( netadr_t adr, rdtype_t target, char *buffer, size_t buffersize, void (*flush))
|
||||
static void SV_BeginRedirect( host_redirect_t *rd, netadr_t adr, rdtype_t target, char *buffer, size_t buffersize, void (*flush))
|
||||
{
|
||||
if( !target || !buffer || !buffersize || !flush )
|
||||
return;
|
||||
|
||||
host.rd.target = target;
|
||||
host.rd.buffer = buffer;
|
||||
host.rd.buffersize = buffersize;
|
||||
host.rd.flush = flush;
|
||||
host.rd.address = adr;
|
||||
host.rd.buffer[0] = 0;
|
||||
if( host.rd.lines == 0 )
|
||||
host.rd.lines = -1;
|
||||
rd->target = target;
|
||||
rd->buffer = buffer;
|
||||
rd->buffersize = buffersize;
|
||||
rd->flush = flush;
|
||||
rd->address = adr;
|
||||
rd->buffer[0] = 0;
|
||||
if( rd->lines == 0 )
|
||||
rd->lines = -1;
|
||||
}
|
||||
|
||||
void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
|
||||
static void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
|
||||
{
|
||||
if( sv.current_client && FBitSet( sv.current_client->flags, FCL_FAKECLIENT ))
|
||||
return;
|
||||
@@ -712,18 +709,18 @@ void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
|
||||
}
|
||||
}
|
||||
|
||||
void SV_EndRedirect( void )
|
||||
void SV_EndRedirect( host_redirect_t *rd )
|
||||
{
|
||||
if( host.rd.lines > 0 )
|
||||
if( rd->lines > 0 )
|
||||
return;
|
||||
|
||||
if( host.rd.flush )
|
||||
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
|
||||
if( rd->flush )
|
||||
rd->flush( rd->address, rd->target, rd->buffer );
|
||||
|
||||
host.rd.target = 0;
|
||||
host.rd.buffer = NULL;
|
||||
host.rd.buffersize = 0;
|
||||
host.rd.flush = NULL;
|
||||
rd->target = RD_NONE;
|
||||
rd->buffer = NULL;
|
||||
rd->buffersize = 0;
|
||||
rd->flush = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -733,24 +730,26 @@ Rcon_Print
|
||||
Print message to rcon buffer and send to rcon redirect target
|
||||
================
|
||||
*/
|
||||
void Rcon_Print( const char *pMsg )
|
||||
void Rcon_Print( host_redirect_t *rd, const char *pMsg )
|
||||
{
|
||||
if( host.rd.target && host.rd.lines && host.rd.flush && host.rd.buffer )
|
||||
size_t len;
|
||||
|
||||
if( !rd->target || !rd->lines || !rd->flush || !rd->buffer )
|
||||
return;
|
||||
|
||||
len = Q_strncat( rd->buffer, pMsg, rd->buffersize );
|
||||
|
||||
if( len && rd->buffer[len - 1] == '\n' )
|
||||
{
|
||||
size_t len = Q_strncat( host.rd.buffer, pMsg, host.rd.buffersize );
|
||||
rd->flush( rd->address, rd->target, rd->buffer );
|
||||
|
||||
if( len && host.rd.buffer[len-1] == '\n' )
|
||||
{
|
||||
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
|
||||
if( rd->lines > 0 )
|
||||
rd->lines--;
|
||||
|
||||
if( host.rd.lines > 0 )
|
||||
host.rd.lines--;
|
||||
rd->buffer[0] = 0;
|
||||
|
||||
host.rd.buffer[0] = 0;
|
||||
|
||||
if( !host.rd.lines )
|
||||
Msg( "End of redirection!\n" );
|
||||
}
|
||||
if( !rd->lines )
|
||||
Msg( "End of redirection!\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1090,7 +1089,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
|
||||
|
||||
if( Rcon_Validate( ))
|
||||
{
|
||||
SV_BeginRedirect( from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect );
|
||||
SV_BeginRedirect( &host.rd, from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect );
|
||||
|
||||
remaining[0] = 0;
|
||||
for( i = 2; i < Cmd_Argc(); i++ )
|
||||
@@ -1101,7 +1100,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
|
||||
}
|
||||
Cmd_ExecuteString( remaining );
|
||||
|
||||
SV_EndRedirect();
|
||||
SV_EndRedirect( &host.rd );
|
||||
}
|
||||
else Con_Printf( S_ERROR "Bad rcon_password.\n" );
|
||||
}
|
||||
@@ -1772,6 +1771,9 @@ static qboolean SV_ShouldUpdateUserinfo( sv_client_t *cl )
|
||||
if( FBitSet( cl->flags, FCL_FAKECLIENT ))
|
||||
return allow;
|
||||
|
||||
if( Host_IsLocalGame( ))
|
||||
return allow;
|
||||
|
||||
// start from 1 second
|
||||
if( !cl->userinfo_penalty )
|
||||
cl->userinfo_penalty = sv_userinfo_penalty_time.value;
|
||||
|
||||
@@ -2385,7 +2385,9 @@ static void GAME_EXPORT pfnGetAimVector( edict_t* ent, float speed, float *rgflR
|
||||
|
||||
// try all possible entities
|
||||
VectorCopy( svgame.globals->v_forward, bestdir );
|
||||
bestdist = Cvar_VariableValue( "sv_aim" );
|
||||
if( sv_allow_autoaim.value )
|
||||
bestdist = sv_aim.value;
|
||||
else bestdist = 0;
|
||||
|
||||
check = EDICT_NUM( 1 ); // start at first client
|
||||
for( i = 1; i < svgame.numEntities; i++, check++ )
|
||||
@@ -4523,7 +4525,7 @@ static qboolean GAME_EXPORT pfnVoice_GetClientListening( int iReceiver, int iSen
|
||||
iReceiver -= 1;
|
||||
iSender -= 1;
|
||||
|
||||
if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender > svs.maxclients )
|
||||
if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender >= svs.maxclients )
|
||||
return false;
|
||||
|
||||
return (FBitSet( svs.clients[iSender].listeners, BIT( iReceiver )) != 0 );
|
||||
@@ -4540,7 +4542,7 @@ static qboolean GAME_EXPORT pfnVoice_SetClientListening( int iReceiver, int iSen
|
||||
iReceiver -= 1;
|
||||
iSender -= 1;
|
||||
|
||||
if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender > svs.maxclients )
|
||||
if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender >= svs.maxclients )
|
||||
return false;
|
||||
|
||||
if( bListen ) SetBits( svs.clients[iSender].listeners, BIT( iReceiver ));
|
||||
@@ -4965,12 +4967,6 @@ static qboolean SV_ParseEdict( char **pfile, edict_t *ent )
|
||||
pkvd[i].szValue = copystring( temp );
|
||||
}
|
||||
#endif
|
||||
if( !Q_strcmp( pkvd[i].szKeyName, "light" ))
|
||||
{
|
||||
Mem_Free( pkvd[i].szKeyName );
|
||||
pkvd[i].szKeyName = copystring( "light_level" );
|
||||
}
|
||||
|
||||
if( !pkvd[i].fHandled )
|
||||
{
|
||||
pkvd[i].szClassName = classname;
|
||||
|
||||
@@ -23,6 +23,7 @@ CVAR_DEFINE_AUTO( sv_lan, "0", 0, "server is a lan server ( no heartbeat, no aut
|
||||
CVAR_DEFINE_AUTO( sv_lan_rate, "20000.0", 0, "rate for lan server" );
|
||||
CVAR_DEFINE_AUTO( sv_nat, "0", 0, "enable NAT bypass for this server" );
|
||||
CVAR_DEFINE_AUTO( sv_aim, "1", FCVAR_ARCHIVE|FCVAR_SERVER, "auto aiming option" );
|
||||
CVAR_DEFINE_AUTO( sv_allow_autoaim, "0", FCVAR_ARCHIVE|FCVAR_SERVER, "auto aiming option (for HL25 compatibility)" );
|
||||
CVAR_DEFINE_AUTO( sv_unlag, "1", 0, "allow lag compensation on server-side" );
|
||||
CVAR_DEFINE_AUTO( sv_maxunlag, "0.5", 0, "max latency value which can be interpolated (by default ping should not exceed 500 units)" );
|
||||
CVAR_DEFINE_AUTO( sv_unlagpush, "0.0", 0, "interpolation bias for unlag time" );
|
||||
@@ -885,6 +886,7 @@ void SV_Init( void )
|
||||
Cvar_RegisterVariable( &sv_fps );
|
||||
Cvar_RegisterVariable( &showtriggers );
|
||||
Cvar_RegisterVariable( &sv_aim );
|
||||
Cvar_RegisterVariable( &sv_allow_autoaim );
|
||||
Cvar_RegisterVariable( &deathmatch );
|
||||
Cvar_RegisterVariable( &coop );
|
||||
Cvar_RegisterVariable( &teamplay );
|
||||
@@ -1101,7 +1103,7 @@ void SV_Shutdown( const char *finalmsg )
|
||||
Con_Printf( "%s", finalmsg );
|
||||
|
||||
// rcon will be disconnected
|
||||
SV_EndRedirect();
|
||||
SV_EndRedirect( &host.rd );
|
||||
|
||||
if( svs.clients )
|
||||
SV_FinalMessage( finalmsg, false );
|
||||
|
||||
@@ -36,7 +36,7 @@ static void SV_SourceQuery_Details( netadr_t from )
|
||||
{
|
||||
sizebuf_t buf;
|
||||
char answer[2048];
|
||||
int i, bot_count, client_count;
|
||||
int bot_count, client_count;
|
||||
int is_private = 0;
|
||||
|
||||
SV_GetPlayerCount( &client_count, &bot_count );
|
||||
|
||||
@@ -984,7 +984,10 @@ static void ParseSaveTables( SAVERESTOREDATA *pSaveData, SAVE_HEADER *pHeader, i
|
||||
InitEntityTable( pSaveData, pSaveData->tableCount );
|
||||
|
||||
for( i = 0; i < pSaveData->tableCount; i++ )
|
||||
{
|
||||
svgame.dllFuncs.pfnSaveReadFields( pSaveData, "ETABLE", &pSaveData->pTable[i], gEntityTable, ARRAYSIZE( gEntityTable ));
|
||||
pSaveData->pTable[i].pent = NULL;
|
||||
}
|
||||
|
||||
pSaveData->pBaseData = pSaveData->pCurrentData;
|
||||
pSaveData->size = 0;
|
||||
|
||||
@@ -1475,7 +1475,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
|
||||
float ds, dt, s, t;
|
||||
int sample_size;
|
||||
msurface_t *surf;
|
||||
mtexinfo_t *tex;
|
||||
mextrasurf_t *info;
|
||||
color24 *lm;
|
||||
vec3_t mid;
|
||||
@@ -1510,7 +1509,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
|
||||
{
|
||||
int smax, tmax;
|
||||
|
||||
tex = surf->texinfo;
|
||||
info = surf->info;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_DRAWTILED ))
|
||||
|
||||
@@ -49,14 +49,14 @@ def configure(conf):
|
||||
# re-enable undefined reference errors
|
||||
conf.env.CXXFLAGS += ['-Wl,--no-undefined']
|
||||
conf.env.CFLAGS += ['-Wl,--no-undefined']
|
||||
# allow the SDL2 sanity check to complete properly by linking in libstdc++ and lm normally
|
||||
conf.env.LDFLAGS += ['-lstdc++', '-lm']
|
||||
# allow the SDL2 sanity check to complete properly by linking in lm normally
|
||||
conf.env.LDFLAGS += ['-lm']
|
||||
conf.load('sdl2')
|
||||
if not conf.env.HAVE_SDL2:
|
||||
conf.fatal('SDL2 not availiable! Install switch-sdl2!')
|
||||
conf.define('XASH_SDL', 2)
|
||||
# then remove them to avoid them getting linked to shared objects
|
||||
conf.env.LDFLAGS.remove('-lstdc++')
|
||||
conf.env.LIB_SDL2.remove('stdc++') # remove libstdc++ linking from SDL2, we link it later
|
||||
conf.env.LDFLAGS.remove('-lm')
|
||||
elif conf.env.DEST_OS == 'psvita':
|
||||
# allow the SDL2 sanity check to complete properly by linking in some deps missing from the pkg-config file
|
||||
@@ -189,7 +189,7 @@ def build(bld):
|
||||
# HACK: link in the entirety of libstdc++ so that dynamic libs could use all of it without manual exporting
|
||||
# we can't do this right away because std::filesystem will complain about not having pathconf(),
|
||||
# which we have defined in sys_nswitch.c
|
||||
bld.env.LDFLAGS += ['-Wl,--whole-archive', '-lstdc++', '-Wl,--no-whole-archive', '-lm']
|
||||
bld.env.LDFLAGS += ['-v', '-Wl,--whole-archive', '-lstdc++', '-Wl,--no-whole-archive', '-lm']
|
||||
|
||||
if bld.env.DEST_OS == 'psvita':
|
||||
libs += [ 'VRTLD' ]
|
||||
|
||||
@@ -233,6 +233,13 @@ public:
|
||||
return FS_FileTime( p, false );
|
||||
}
|
||||
|
||||
long int GetFileModificationTime( const char *path )
|
||||
{
|
||||
// TODO: properly reverse-engineer this
|
||||
FixupPath( p, path );
|
||||
return FS_FileTime( p, false );
|
||||
}
|
||||
|
||||
void FileTimeToString( char *p, int size, long int time ) override
|
||||
{
|
||||
const time_t curtime = time;
|
||||
|
||||
@@ -40,8 +40,7 @@ public:
|
||||
virtual ~IBaseInterface() {}
|
||||
};
|
||||
|
||||
class IVFileSystem009 : public IBaseInterface
|
||||
{
|
||||
class IVFileSystem009 : public IBaseInterface {
|
||||
public:
|
||||
virtual void Mount() = 0; /* linkage=_ZN11IFileSystem5MountEv */
|
||||
|
||||
@@ -148,8 +147,8 @@ public:
|
||||
virtual FileHandle_t OpenFromCacheForRead(const char *, const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20OpenFromCacheForReadEPKcS1_S1_ */
|
||||
|
||||
virtual void AddSearchPathNoWrite(const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20AddSearchPathNoWriteEPKcS1_ */
|
||||
|
||||
virtual long int GetFileModificationTime(const char *) = 0; /* linkage=_ZN11IFileSystem23GetFileModificationTimeEPKc */
|
||||
};
|
||||
|
||||
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" // never change this!
|
||||
|
||||
#endif // VFILESYSTEM009_H
|
||||
|
||||
325
filesystem/android.c
Normal file
325
filesystem/android.c
Normal file
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
android.c - android support for filesystem
|
||||
Copyright (C) 2022 Velaron
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "port.h"
|
||||
|
||||
#if XASH_ANDROID
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include STDINT_H
|
||||
#include "filesystem_internal.h"
|
||||
#include "crtlib.h"
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "common/com_strings.h"
|
||||
|
||||
#include <jni.h>
|
||||
#include <android/asset_manager.h>
|
||||
#include <android/asset_manager_jni.h>
|
||||
#include <time.h>
|
||||
|
||||
struct android_assets_s
|
||||
{
|
||||
string package_name;
|
||||
qboolean engine;
|
||||
AAssetManager *asset_manager;
|
||||
AAssetDir *dir;
|
||||
};
|
||||
|
||||
struct jni_methods_s
|
||||
{
|
||||
JNIEnv *env;
|
||||
jobject activity;
|
||||
jclass activity_class;
|
||||
jmethodID getPackageName;
|
||||
jmethodID getCallingPackage;
|
||||
jmethodID getAssetsList;
|
||||
jmethodID getAssets;
|
||||
} jni;
|
||||
|
||||
static void Android_GetAssetManager( android_assets_t *assets )
|
||||
{
|
||||
jobject assetManager;
|
||||
|
||||
assetManager = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getAssets, assets->engine );
|
||||
|
||||
if( assetManager )
|
||||
assets->asset_manager = AAssetManager_fromJava( jni.env, assetManager );
|
||||
else if( assets->engine )
|
||||
Con_Reportf( S_WARN "Couldn't add engine assets!" );
|
||||
}
|
||||
|
||||
static const char *Android_GetPackageName( qboolean engine )
|
||||
{
|
||||
static string pkg;
|
||||
jstring resultJNIStr;
|
||||
const char *resultCStr;
|
||||
|
||||
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, engine ? jni.getPackageName : jni.getCallingPackage );
|
||||
|
||||
if( !resultJNIStr )
|
||||
return NULL;
|
||||
|
||||
resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
|
||||
Q_strncpy( pkg, resultCStr, sizeof( pkg ));
|
||||
(*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr );
|
||||
|
||||
return pkg;
|
||||
}
|
||||
|
||||
static void Android_ListDirectory( stringlist_t *list, const char *path, qboolean engine )
|
||||
{
|
||||
jstring JStr = (*jni.env)->NewStringUTF( jni.env, path );
|
||||
jobjectArray JNIArray = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getAssetsList, engine, JStr );
|
||||
int JNIArraySize = (*jni.env)->GetArrayLength( jni.env, JNIArray );
|
||||
|
||||
for( int i = 0; i < JNIArraySize; i++ )
|
||||
{
|
||||
jstring JNIStr = (*jni.env)->GetObjectArrayElement( jni.env, JNIArray, i );
|
||||
const char *CStr = (*jni.env)->GetStringUTFChars( jni.env, JNIStr, NULL );
|
||||
|
||||
stringlistappend( list, (char *)CStr );
|
||||
(*jni.env)->ReleaseStringUTFChars( jni.env, JNIStr, CStr );
|
||||
}
|
||||
}
|
||||
|
||||
static void FS_CloseAndroidAssets( android_assets_t *assets )
|
||||
{
|
||||
if( assets->dir )
|
||||
AAssetDir_close( assets->dir );
|
||||
|
||||
Mem_Free( assets );
|
||||
}
|
||||
|
||||
static android_assets_t *FS_LoadAndroidAssets( qboolean engine )
|
||||
{
|
||||
android_assets_t *assets = Mem_Calloc( fs_mempool, sizeof( *assets ));
|
||||
|
||||
assets->engine = engine;
|
||||
|
||||
Android_GetAssetManager( assets );
|
||||
if( !assets->asset_manager )
|
||||
{
|
||||
FS_CloseAndroidAssets( assets );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assets->dir = AAssetManager_openDir( assets->asset_manager, "" );
|
||||
if( !assets->dir )
|
||||
{
|
||||
FS_CloseAndroidAssets( assets );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return assets;
|
||||
}
|
||||
|
||||
static int FS_FileTime_AndroidAssets( searchpath_t *search, const char *filename )
|
||||
{
|
||||
static time_t time;
|
||||
|
||||
if( !time )
|
||||
{
|
||||
struct tm file_tm;
|
||||
|
||||
strptime( __DATE__ " "__TIME__, "%b %d %Y %H:%M:%S", &file_tm );
|
||||
time = mktime( &file_tm );
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
static int FS_FindFile_AndroidAssets( struct searchpath_s *search, const char *path, char *fixedname, size_t len )
|
||||
{
|
||||
AAsset *assets = AAssetManager_open( search->assets->asset_manager, path, AASSET_MODE_UNKNOWN );
|
||||
|
||||
if( assets )
|
||||
{
|
||||
AAsset_close( assets );
|
||||
|
||||
Q_strncpy( fixedname, path, len );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void FS_PrintInfo_AndroidAssets( searchpath_t *search, char *dst, size_t size )
|
||||
{
|
||||
Q_snprintf( dst, size, "%s", search->assets->package_name );
|
||||
}
|
||||
|
||||
static void FS_Close_AndroidAssets( searchpath_t *search )
|
||||
{
|
||||
FS_CloseAndroidAssets( search->assets );
|
||||
}
|
||||
|
||||
static void FS_Search_AndroidAssets( searchpath_t *search, stringlist_t *list, const char *pattern, int caseinsensitive )
|
||||
{
|
||||
string temp;
|
||||
stringlist_t dirlist;
|
||||
const char *slash, *backslash, *colon, *separator;
|
||||
int basepathlength, dirlistindex, resultlistindex;
|
||||
char *basepath;
|
||||
|
||||
slash = Q_strrchr( pattern, '/' );
|
||||
backslash = Q_strrchr( pattern, '\\' );
|
||||
colon = Q_strrchr( pattern, ':' );
|
||||
|
||||
separator = Q_max( slash, backslash );
|
||||
separator = Q_max( separator, colon );
|
||||
|
||||
basepathlength = separator ? (separator + 1 - pattern) : 0;
|
||||
basepath = Mem_Calloc( fs_mempool, basepathlength + 1 );
|
||||
if( basepathlength )
|
||||
memcpy( basepath, pattern, basepathlength );
|
||||
basepath[basepathlength] = '\0';
|
||||
|
||||
stringlistinit( &dirlist );
|
||||
Android_ListDirectory( &dirlist, basepath, search->assets->engine );
|
||||
|
||||
Q_strncpy( temp, basepath, sizeof( temp ));
|
||||
|
||||
for( dirlistindex = 0; dirlistindex < dirlist.numstrings; dirlistindex++ )
|
||||
{
|
||||
Q_strncpy( &temp[basepathlength], dirlist.strings[dirlistindex], sizeof( temp ) - basepathlength );
|
||||
|
||||
if( matchpattern( temp, (char *)pattern, true ))
|
||||
{
|
||||
for( resultlistindex = 0; resultlistindex < list->numstrings; resultlistindex++ )
|
||||
{
|
||||
if( !Q_strcmp( list->strings[resultlistindex], temp ))
|
||||
break;
|
||||
}
|
||||
|
||||
if( resultlistindex == list->numstrings )
|
||||
stringlistappend( list, temp );
|
||||
}
|
||||
}
|
||||
|
||||
stringlistfreecontents( &dirlist );
|
||||
|
||||
Mem_Free( basepath );
|
||||
}
|
||||
|
||||
static file_t *FS_OpenFile_AndroidAssets( searchpath_t *search, const char *filename, const char *mode, int pack_ind )
|
||||
{
|
||||
file_t *file = Mem_Calloc( fs_mempool, sizeof( *file ));
|
||||
AAsset *assets = AAssetManager_open( search->assets->asset_manager, filename, AASSET_MODE_RANDOM );
|
||||
|
||||
file->handle = AAsset_openFileDescriptor( assets, &file->offset, &file->real_length );
|
||||
|
||||
file->position = 0;
|
||||
file->ungetc = EOF;
|
||||
|
||||
AAsset_close( assets );
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
static byte *FS_LoadAndroidAssetsFile( searchpath_t *search, const char *path, int pack_ind, fs_offset_t *filesize )
|
||||
{
|
||||
byte *buf;
|
||||
off_t size;
|
||||
AAsset *asset;
|
||||
|
||||
if( filesize ) *filesize = 0;
|
||||
|
||||
asset = AAssetManager_open( search->assets->asset_manager, path, AASSET_MODE_RANDOM );
|
||||
if( !asset )
|
||||
return NULL;
|
||||
|
||||
size = AAsset_getLength( asset );
|
||||
|
||||
buf = (byte *)Mem_Malloc( fs_mempool, size + 1 );
|
||||
buf[size] = '\0';
|
||||
|
||||
if( AAsset_read( asset, buf, size ) < 0 )
|
||||
{
|
||||
Mem_Free( buf );
|
||||
AAsset_close( asset );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AAsset_close( asset );
|
||||
|
||||
if( filesize ) *filesize = size;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
searchpath_t *FS_AddAndroidAssets_Fullpath( const char *path, int flags )
|
||||
{
|
||||
searchpath_t *search;
|
||||
android_assets_t *assets = NULL;
|
||||
qboolean engine = true;
|
||||
|
||||
if( FBitSet( flags, FS_STATIC_PATH | FS_CUSTOM_PATH ))
|
||||
return NULL;
|
||||
|
||||
if( FBitSet( flags, FS_GAMEDIR_PATH ) && Q_stricmp( GI->basedir, GI->gamefolder ))
|
||||
engine = false;
|
||||
|
||||
assets = FS_LoadAndroidAssets( engine );
|
||||
|
||||
if( !assets )
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s: unable to load Android assets \"%s\"\n", __FUNCTION__, Android_GetPackageName( engine ));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Q_strncpy( assets->package_name, Android_GetPackageName( engine ), sizeof( assets->package_name ));
|
||||
|
||||
search = Mem_Calloc( fs_mempool, sizeof( *search ));
|
||||
|
||||
Q_strncpy( search->filename, assets->package_name, sizeof( search->filename ));
|
||||
search->assets = assets;
|
||||
search->type = SEARCHPATH_ANDROID_ASSETS;
|
||||
SetBits( search->flags, FS_NOWRITE_PATH | FS_CUSTOM_PATH );
|
||||
|
||||
search->pfnPrintInfo = FS_PrintInfo_AndroidAssets;
|
||||
search->pfnClose = FS_Close_AndroidAssets;
|
||||
search->pfnOpenFile = FS_OpenFile_AndroidAssets;
|
||||
search->pfnFileTime = FS_FileTime_AndroidAssets;
|
||||
search->pfnFindFile = FS_FindFile_AndroidAssets;
|
||||
search->pfnSearch = FS_Search_AndroidAssets;
|
||||
search->pfnLoadFile = FS_LoadAndroidAssetsFile;
|
||||
|
||||
Con_Reportf( "Adding Android assets: %s\n", assets->package_name );
|
||||
|
||||
return search;
|
||||
}
|
||||
|
||||
void FS_InitAndroid( void )
|
||||
{
|
||||
jmethodID getContext;
|
||||
|
||||
jni.env = (JNIEnv *)Sys_GetNativeObject( "JNIEnv" );
|
||||
jni.activity_class = Sys_GetNativeObject( "ActivityClass" );
|
||||
|
||||
getContext = (*jni.env)->GetStaticMethodID( jni.env, jni.activity_class, "getContext", "()Landroid/content/Context;" );
|
||||
jni.activity = (*jni.env)->CallStaticObjectMethod( jni.env, jni.activity_class, getContext );
|
||||
|
||||
jni.getPackageName = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getPackageName", "()Ljava/lang/String;" );
|
||||
jni.getCallingPackage = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getCallingPackage", "()Ljava/lang/String;" );
|
||||
jni.getAssetsList = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getAssetsList", "(ZLjava/lang/String;)[Ljava/lang/String;" );
|
||||
jni.getAssets = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getAssets", "(Z)Landroid/content/res/AssetManager;" );
|
||||
}
|
||||
|
||||
#endif // XASH_ANDROID
|
||||
@@ -449,7 +449,6 @@ static void FS_Search_DIR( searchpath_t *search, stringlist_t *list, const char
|
||||
|
||||
static int FS_FileTime_DIR( searchpath_t *search, const char *filename )
|
||||
{
|
||||
int time;
|
||||
char path[MAX_SYSPATH];
|
||||
|
||||
Q_snprintf( path, sizeof( path ), "%s%s", search->filename, filename );
|
||||
|
||||
@@ -34,6 +34,7 @@ GNU General Public License for more details.
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "port.h"
|
||||
#include "defaults.h"
|
||||
#include "const.h"
|
||||
#include "crtlib.h"
|
||||
#include "crclib.h"
|
||||
@@ -71,8 +72,10 @@ const fs_archive_t g_archives[] =
|
||||
static const fs_archive_t g_directory_archive =
|
||||
{ NULL, SEARCHPATH_PLAIN, FS_AddDir_Fullpath, false };
|
||||
|
||||
// static const fs_archive_t g_android_archive =
|
||||
// { NULL, SEARCHPATH_ANDROID, FS_AddAndroid_Fullpath, false, false };
|
||||
#ifdef XASH_ANDROID
|
||||
static const fs_archive_t g_android_archive =
|
||||
{ NULL, SEARCHPATH_ANDROID_ASSETS, FS_AddAndroidAssets_Fullpath, false };
|
||||
#endif
|
||||
|
||||
#ifdef XASH_REDUCE_FD
|
||||
static file_t *fs_last_readfile;
|
||||
@@ -154,7 +157,7 @@ void stringlistfreecontents( stringlist_t *list )
|
||||
list->strings = NULL;
|
||||
}
|
||||
|
||||
void stringlistappend( stringlist_t *list, char *text )
|
||||
void stringlistappend( stringlist_t *list, const char *text )
|
||||
{
|
||||
size_t textlen;
|
||||
|
||||
@@ -403,6 +406,10 @@ void FS_AddGameDirectory( const char *dir, uint flags )
|
||||
|
||||
stringlistfreecontents( &list );
|
||||
|
||||
#ifdef XASH_ANDROID
|
||||
FS_AddArchive_Fullpath( &g_android_archive, dir, flags );
|
||||
#endif
|
||||
|
||||
// add the directory to the search path
|
||||
// (unpacked files have the priority over packed files)
|
||||
search = FS_AddArchive_Fullpath( &g_directory_archive, dir, flags );
|
||||
@@ -596,7 +603,7 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
|
||||
}
|
||||
|
||||
if( GameInfo->noskills )
|
||||
FS_Printf( f, "noskills\t\t\"%i\"\n", GameInfo->nomodels );
|
||||
FS_Printf( f, "noskills\t\t\"%i\"\n", GameInfo->noskills );
|
||||
|
||||
#define SAVE_AGED_COUNT 2 // the default count of quick and auto saves
|
||||
if( GameInfo->quicksave_aged_count != SAVE_AGED_COUNT )
|
||||
@@ -606,6 +613,13 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
|
||||
FS_Printf( f, "autosave_aged_count\t\t%d\n", GameInfo->autosave_aged_count );
|
||||
#undef SAVE_AGED_COUNT
|
||||
|
||||
// HL25 compatibility
|
||||
if( GameInfo->animated_title )
|
||||
FS_Printf( f, "animated_title\t\t%i\n", GameInfo->animated_title );
|
||||
|
||||
if( GameInfo->hd_background )
|
||||
FS_Printf( f, "hd_background\t\t%i\n", GameInfo->hd_background );
|
||||
|
||||
// always expose our extensions :)
|
||||
FS_Printf( f, "internal_vgui_support\t\t%s\n", GameInfo->internal_vgui_support ? "1" : "0" );
|
||||
FS_Printf( f, "render_picbutton_text\t\t%s\n", GameInfo->render_picbutton_text ? "1" : "0" );
|
||||
@@ -638,7 +652,7 @@ void FS_InitGameInfo( gameinfo_t *GameInfo, const char *gamedir )
|
||||
Q_strncpy( GameInfo->sp_entity, "info_player_start", sizeof( GameInfo->sp_entity ));
|
||||
Q_strncpy( GameInfo->mp_entity, "info_player_deathmatch", sizeof( GameInfo->mp_entity ));
|
||||
|
||||
GameInfo->max_edicts = 900; // default value if not specified
|
||||
GameInfo->max_edicts = DEFAULT_MAX_EDICTS; // default value if not specified
|
||||
GameInfo->max_tents = 500;
|
||||
GameInfo->max_beams = 128;
|
||||
GameInfo->max_particles = 4096;
|
||||
@@ -783,6 +797,17 @@ void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, const qbool
|
||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||
GameInfo->max_edicts = bound( MIN_EDICTS, Q_atoi( token ), MAX_EDICTS );
|
||||
}
|
||||
// valid for both
|
||||
else if( !Q_stricmp( token, "hd_background" ))
|
||||
{
|
||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||
GameInfo->hd_background = Q_atoi( token ) ? true : false;
|
||||
}
|
||||
else if( !Q_stricmp( token, "animated_title" ))
|
||||
{
|
||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||
GameInfo->animated_title = Q_atoi( token ) ? true : false;
|
||||
}
|
||||
// only for gameinfo
|
||||
else if( isGameInfo )
|
||||
{
|
||||
@@ -1053,29 +1078,39 @@ static qboolean FS_ParseGameInfo( const char *gamedir, gameinfo_t *GameInfo )
|
||||
roGameInfoTime = FS_SysFileTime( gameinfo_ro );
|
||||
rwGameInfoTime = FS_SysFileTime( gameinfo_path );
|
||||
|
||||
// if rodir's liblist.gam newer than rwdir's gameinfo.txt, then convert it
|
||||
if( roLibListTime > rwGameInfoTime )
|
||||
{
|
||||
haveUpdate = FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_ro );
|
||||
}
|
||||
// if rodir's gameinfo.txt newer than rwdir's gameinfo.txt, just copy the file
|
||||
else if( roGameInfoTime > rwGameInfoTime )
|
||||
{
|
||||
fs_offset_t len;
|
||||
char *afile_ro = (char *)FS_LoadDirectFile( gameinfo_ro, &len );
|
||||
file_t *ro, *rw;
|
||||
fs_offset_t ro_size;
|
||||
|
||||
if( afile_ro )
|
||||
{
|
||||
Con_DPrintf( "Copy rodir %s to rwdir %s\n", gameinfo_ro, gameinfo_path );
|
||||
haveUpdate = true;
|
||||
FS_WriteFile( gameinfo_path, afile_ro, len );
|
||||
Mem_Free( afile_ro );
|
||||
}
|
||||
// read & write as binary to copy the exact file
|
||||
ro = FS_SysOpen( gameinfo_ro, "rb" );
|
||||
rw = FS_SysOpen( gameinfo_path, "wb" );
|
||||
|
||||
FS_Seek( ro, 0, SEEK_END );
|
||||
ro_size = FS_Tell( ro );
|
||||
FS_Seek( ro, 0, SEEK_SET );
|
||||
|
||||
FS_FileCopy( rw, ro, ro_size );
|
||||
|
||||
FS_Close( rw );
|
||||
FS_Close( ro );
|
||||
|
||||
haveUpdate = true;
|
||||
}
|
||||
|
||||
FS_AllowDirectPaths( false );
|
||||
}
|
||||
|
||||
// do not update gameinfo.txt, if it was just copied from rodir's
|
||||
// if user change liblist.gam update the gameinfo.txt
|
||||
if( FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false ))
|
||||
if( !haveUpdate && FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false ))
|
||||
FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_path );
|
||||
|
||||
// force to create gameinfo for specified game if missing
|
||||
@@ -1386,7 +1421,7 @@ static void _Sys_Error( const char *fmt, ... )
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
static void *_Platform_GetNativeObject_stub( const char *object )
|
||||
static void *Sys_GetNativeObject_stub( const char *object )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -1406,6 +1441,10 @@ qboolean FS_InitStdio( qboolean unused_set_to_true, const char *rootdir, const c
|
||||
|
||||
FS_InitMemory();
|
||||
|
||||
#ifdef XASH_ANDROID
|
||||
FS_InitAndroid();
|
||||
#endif
|
||||
|
||||
Q_strncpy( fs_rootdir, rootdir, sizeof( fs_rootdir ));
|
||||
Q_strncpy( fs_gamedir, gamedir, sizeof( fs_gamedir ));
|
||||
Q_strncpy( fs_basedir, basedir, sizeof( fs_basedir ));
|
||||
@@ -1638,6 +1677,9 @@ file_t *FS_SysOpen( const char *filepath, const char *mode )
|
||||
|
||||
if( file->handle < 0 )
|
||||
{
|
||||
if( errno != ENOENT )
|
||||
Con_Printf( S_ERROR "%s: can't open file %s: %s\n", __func__, filepath, strerror( errno ));
|
||||
|
||||
Mem_Free( file );
|
||||
return NULL;
|
||||
}
|
||||
@@ -2841,7 +2883,7 @@ fs_interface_t g_engfuncs =
|
||||
_Mem_Alloc,
|
||||
_Mem_Realloc,
|
||||
_Mem_Free,
|
||||
_Platform_GetNativeObject_stub
|
||||
Sys_GetNativeObject_stub
|
||||
};
|
||||
|
||||
static qboolean FS_InitInterface( int version, fs_interface_t *engfuncs )
|
||||
@@ -2883,9 +2925,9 @@ static qboolean FS_InitInterface( int version, fs_interface_t *engfuncs )
|
||||
Con_Reportf( "filesystem_stdio: custom memory allocation functions found\n" );
|
||||
}
|
||||
|
||||
if( engfuncs->_Platform_GetNativeObject )
|
||||
if( engfuncs->_Sys_GetNativeObject )
|
||||
{
|
||||
g_engfuncs._Platform_GetNativeObject = engfuncs->_Platform_GetNativeObject;
|
||||
g_engfuncs._Sys_GetNativeObject = engfuncs->_Sys_GetNativeObject;
|
||||
Con_Reportf( "filesystem_stdio: custom platform-specific functions found\n" );
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#define FS_API_VERSION 2 // not stable yet!
|
||||
#define FS_API_CREATEINTERFACE_TAG "XashFileSystem002" // follow FS_API_VERSION!!!
|
||||
#define FS_API_CREATEINTERFACE_TAG "XashFileSystem002" // follow FS_API_VERSION!!!
|
||||
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" // never change this!
|
||||
|
||||
// search path flags
|
||||
enum
|
||||
@@ -105,6 +106,10 @@ typedef struct gameinfo_s
|
||||
|
||||
int quicksave_aged_count; // min is 1, max is 99
|
||||
int autosave_aged_count; // min is 1, max is 99
|
||||
|
||||
// HL25 compatibility keys
|
||||
qboolean hd_background;
|
||||
qboolean animated_title;
|
||||
} gameinfo_t;
|
||||
|
||||
typedef enum
|
||||
@@ -205,12 +210,12 @@ typedef struct fs_interface_t
|
||||
// memory
|
||||
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_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 );
|
||||
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
|
||||
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
|
||||
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
||||
|
||||
// platform
|
||||
void *(*_Platform_GetNativeObject)( const char *object );
|
||||
void *(*_Sys_GetNativeObject)( const char *object );
|
||||
} fs_interface_t;
|
||||
|
||||
typedef int (*FSAPI)( int version, fs_api_t *api, fs_globals_t **globals, fs_interface_t *interface );
|
||||
|
||||
@@ -22,6 +22,10 @@ GNU General Public License for more details.
|
||||
#include "xash3d_types.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#if XASH_ANDROID
|
||||
#include <android/asset_manager.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
@@ -31,6 +35,10 @@ typedef struct dir_s dir_t;
|
||||
typedef struct zip_s zip_t;
|
||||
typedef struct pack_s pack_t;
|
||||
typedef struct wfile_s wfile_t;
|
||||
#if XASH_ANDROID
|
||||
typedef struct android_assets_s android_assets_t;
|
||||
// typedef struct android_saf_s android_saf_t;
|
||||
#endif
|
||||
|
||||
#define FILE_BUFF_SIZE (2048)
|
||||
|
||||
@@ -58,7 +66,8 @@ enum
|
||||
SEARCHPATH_PAK,
|
||||
SEARCHPATH_WAD,
|
||||
SEARCHPATH_ZIP,
|
||||
SEARCHPATH_PK3DIR, // it's actually a plain directory but it must behave like a ZIP archive
|
||||
SEARCHPATH_PK3DIR, // it's actually a plain directory but it must behave like a ZIP archive,
|
||||
SEARCHPATH_ANDROID_ASSETS
|
||||
};
|
||||
|
||||
typedef struct stringlist_s
|
||||
@@ -81,6 +90,9 @@ typedef struct searchpath_s
|
||||
pack_t *pack;
|
||||
wfile_t *wad;
|
||||
zip_t *zip;
|
||||
#if XASH_ANDROID
|
||||
android_assets_t *assets;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct searchpath_s *next;
|
||||
@@ -127,7 +139,7 @@ extern const fs_archive_t g_archives[];
|
||||
#define Con_DPrintf (*g_engfuncs._Con_DPrintf)
|
||||
#define Con_Reportf (*g_engfuncs._Con_Reportf)
|
||||
#define Sys_Error (*g_engfuncs._Sys_Error)
|
||||
#define Platform_GetNativeObject (*g_engfuncs._Platform_GetNativeObject)
|
||||
#define Sys_GetNativeObject (*g_engfuncs._Sys_GetNativeObject)
|
||||
|
||||
//
|
||||
// filesystem.c
|
||||
@@ -179,7 +191,7 @@ qboolean MD5_HashFile( byte digest[16], const char *pszFileName, uint seed[4] );
|
||||
// stringlist ops
|
||||
void stringlistinit( stringlist_t *list );
|
||||
void stringlistfreecontents( stringlist_t *list );
|
||||
void stringlistappend( stringlist_t *list, char *text );
|
||||
void stringlistappend( stringlist_t *list, const char *text );
|
||||
void stringlistsort( stringlist_t *list );
|
||||
void listdirectory( stringlist_t *list, const char *path );
|
||||
|
||||
@@ -225,6 +237,12 @@ searchpath_t *FS_AddDir_Fullpath( const char *path, int flags );
|
||||
qboolean FS_FixFileCase( dir_t *dir, const char *path, char *dst, const size_t len, qboolean createpath );
|
||||
void FS_InitDirectorySearchpath( searchpath_t *search, const char *path, int flags );
|
||||
|
||||
//
|
||||
// android.c
|
||||
//
|
||||
void FS_InitAndroid( void );
|
||||
searchpath_t *FS_AddAndroidAssets_Fullpath( const char *path, int flags );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -334,7 +334,7 @@ searchpath_t *FS_AddPak_Fullpath( const char *pakfile, int flags )
|
||||
{
|
||||
searchpath_t *search;
|
||||
pack_t *pak;
|
||||
int i, errorcode = PAK_LOAD_COULDNT_OPEN;
|
||||
int errorcode = PAK_LOAD_COULDNT_OPEN;
|
||||
|
||||
pak = FS_LoadPackPAK( pakfile, &errorcode );
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ typedef void *HMODULE;
|
||||
|
||||
HMODULE g_hModule;
|
||||
FSAPI g_pfnGetFSAPI;
|
||||
typedef void *(*pfnCreateInterface_t)( const char *, int * );
|
||||
pfnCreateInterface_t g_pfnCreateInterface;
|
||||
fs_api_t g_fs;
|
||||
fs_globals_t *g_nullglobals;
|
||||
|
||||
@@ -10,19 +10,19 @@ def configure(conf):
|
||||
}
|
||||
conf.env.append_unique('CXXFLAGS', conf.get_flags_by_compiler(nortti, conf.env.COMPILER_CC))
|
||||
|
||||
if conf.env.DEST_OS != 'android':
|
||||
if conf.env.cxxshlib_PATTERN.startswith('lib'):
|
||||
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:]
|
||||
if conf.env.DEST_OS == 'android':
|
||||
conf.check_cc(lib='android')
|
||||
elif conf.env.cxxshlib_PATTERN.startswith('lib'): # remove lib prefix for other systems than Android
|
||||
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:]
|
||||
|
||||
def build(bld):
|
||||
bld(name = 'filesystem_includes', export_includes = '.')
|
||||
|
||||
libs = [ 'filesystem_includes' ]
|
||||
libs = [ 'filesystem_includes', 'sdk_includes' ]
|
||||
|
||||
# on PSVita do not link any libraries that are already in the main executable, but add the includes target
|
||||
if bld.env.DEST_OS == 'psvita':
|
||||
libs += [ 'sdk_includes' ]
|
||||
else:
|
||||
libs += [ 'public' ]
|
||||
if bld.env.DEST_OS != 'psvita':
|
||||
libs += [ 'public', 'ANDROID' ]
|
||||
|
||||
bld.shlib(target = 'filesystem_stdio',
|
||||
features = 'cxx seq',
|
||||
|
||||
@@ -129,6 +129,8 @@ struct zip_s
|
||||
zipfile_t *files;
|
||||
};
|
||||
|
||||
// #define ENABLE_CRC_CHECK // known to be buggy because of possible libpublic crc32 bug, disabled
|
||||
|
||||
#ifdef XASH_REDUCE_FD
|
||||
static void FS_EnsureOpenZip( zip_t *zip )
|
||||
{
|
||||
@@ -423,12 +425,13 @@ FS_LoadZIPFile
|
||||
static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_ind, fs_offset_t *sizeptr )
|
||||
{
|
||||
zipfile_t *file;
|
||||
int index;
|
||||
byte *compressed_buffer = NULL, *decompressed_buffer = NULL;
|
||||
int zlib_result = 0;
|
||||
dword test_crc, final_crc;
|
||||
z_stream decompress_stream;
|
||||
size_t c;
|
||||
#ifdef ENABLE_CRC_CHECK
|
||||
dword test_crc, final_crc;
|
||||
#endif // ENABLE_CRC_CHECK
|
||||
|
||||
if( sizeptr ) *sizeptr = 0;
|
||||
|
||||
@@ -460,7 +463,7 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifdef ENABLE_CRC_CHECK
|
||||
CRC32_Init( &test_crc );
|
||||
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
|
||||
|
||||
@@ -472,7 +475,8 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
|
||||
Mem_Free( decompressed_buffer );
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
#endif // ENABLE_CRC_CHECK
|
||||
|
||||
if( sizeptr ) *sizeptr = file->size;
|
||||
|
||||
FS_EnsureOpenZip( NULL );
|
||||
@@ -516,7 +520,7 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
|
||||
if( zlib_result == Z_OK || zlib_result == Z_STREAM_END )
|
||||
{
|
||||
Mem_Free( compressed_buffer ); // finaly free compressed buffer
|
||||
#if 0
|
||||
#if ENABLE_CRC_CHECK
|
||||
CRC32_Init( &test_crc );
|
||||
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
|
||||
|
||||
@@ -668,7 +672,7 @@ searchpath_t *FS_AddZip_Fullpath( const char *zipfile, int flags )
|
||||
{
|
||||
searchpath_t *search;
|
||||
zip_t *zip;
|
||||
int i, errorcode = ZIP_LOAD_COULDNT_OPEN;
|
||||
int errorcode = ZIP_LOAD_COULDNT_OPEN;
|
||||
|
||||
zip = FS_LoadZip( zipfile, &errorcode );
|
||||
|
||||
|
||||
@@ -21,21 +21,19 @@ def configure(conf):
|
||||
conf.define_cond('XASH_DISABLE_MENU_CHANGEGAME', conf.options.DISABLE_MENU_CHANGEGAME)
|
||||
|
||||
def build(bld):
|
||||
libs = ['sdk_includes']
|
||||
source = ['game.cpp']
|
||||
defines = []
|
||||
|
||||
if bld.env.DEST_OS != 'win32':
|
||||
libs += [ 'DL' ]
|
||||
else:
|
||||
libs += ['USER32', 'SHELL32']
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
source += ['game.rc']
|
||||
|
||||
# Half-Life 25th anniversary update doesn't have server library explicitly linked to libm
|
||||
if bld.env.DEST_OS == 'linux':
|
||||
bld.env.LDFLAGS += ['-Wl,--no-as-needed', '-lm']
|
||||
|
||||
bld(source = source,
|
||||
target = 'xash3d', # hl.exe
|
||||
features = 'c cxx cxxprogram',
|
||||
use = libs,
|
||||
defines = defines,
|
||||
use = 'sdk_includes DL USER32 SHELL32',
|
||||
rpath = bld.env.DEFAULT_RPATH,
|
||||
install_path = bld.env.BINDIR,
|
||||
subsystem = bld.env.MSVC_SUBSYSTEM
|
||||
|
||||
@@ -438,7 +438,10 @@ uint COM_HashKey( const char *string, uint hashSize )
|
||||
unsigned char i;
|
||||
|
||||
while(( i = *string++ ))
|
||||
{
|
||||
i = Q_tolower( i );
|
||||
hashKey = ( hashKey << 5 ) + hashKey + ( i & 0xDF );
|
||||
}
|
||||
|
||||
return hashKey & ( hashSize - 1 );
|
||||
}
|
||||
|
||||
@@ -384,18 +384,6 @@ void VectorsAngles( const vec3_t forward, const vec3_t right, const vec3_t up, v
|
||||
//
|
||||
// bounds operations
|
||||
//
|
||||
/*
|
||||
=================
|
||||
ClearBounds
|
||||
=================
|
||||
*/
|
||||
void ClearBounds( vec3_t mins, vec3_t maxs )
|
||||
{
|
||||
// make bogus range
|
||||
mins[0] = mins[1] = mins[2] = 999999.0f;
|
||||
maxs[0] = maxs[1] = maxs[2] = -999999.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
AddPointToBounds
|
||||
@@ -416,7 +404,7 @@ void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs )
|
||||
|
||||
/*
|
||||
=================
|
||||
ExpandBounds
|
||||
ExpandBounds (not used anywhere?)
|
||||
=================
|
||||
*/
|
||||
void ExpandBounds( vec3_t mins, vec3_t maxs, float offset )
|
||||
@@ -429,34 +417,6 @@ void ExpandBounds( vec3_t mins, vec3_t maxs, float offset )
|
||||
maxs[2] += offset;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
BoundsIntersect
|
||||
=================
|
||||
*/
|
||||
qboolean BoundsIntersect( const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2 )
|
||||
{
|
||||
if( mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2] )
|
||||
return false;
|
||||
if( maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2] )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
BoundsAndSphereIntersect
|
||||
=================
|
||||
*/
|
||||
qboolean BoundsAndSphereIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t origin, float radius )
|
||||
{
|
||||
if( mins[0] > origin[0] + radius || mins[1] > origin[1] + radius || mins[2] > origin[2] + radius )
|
||||
return false;
|
||||
if( maxs[0] < origin[0] - radius || maxs[1] < origin[1] - radius || maxs[2] < origin[2] - radius )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
SphereIntersect
|
||||
|
||||
@@ -195,10 +195,32 @@ 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 );
|
||||
|
||||
void ClearBounds( vec3_t mins, vec3_t maxs );
|
||||
static inline void ClearBounds( vec3_t mins, vec3_t maxs )
|
||||
{
|
||||
// make bogus range
|
||||
mins[0] = mins[1] = mins[2] = 999999.0f;
|
||||
maxs[0] = maxs[1] = maxs[2] = -999999.0f;
|
||||
}
|
||||
|
||||
static inline qboolean BoundsIntersect( const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2 )
|
||||
{
|
||||
if( mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2] )
|
||||
return false;
|
||||
if( maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2] )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline qboolean BoundsAndSphereIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t origin, float radius )
|
||||
{
|
||||
if( mins[0] > origin[0] + radius || mins[1] > origin[1] + radius || mins[2] > origin[2] + radius )
|
||||
return false;
|
||||
if( maxs[0] < origin[0] - radius || maxs[1] < origin[1] - radius || maxs[2] < origin[2] - radius )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );
|
||||
qboolean BoundsIntersect( const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2 );
|
||||
qboolean BoundsAndSphereIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t origin, float radius );
|
||||
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 );
|
||||
void ExpandBounds( vec3_t mins, vec3_t maxs, float offset );
|
||||
|
||||
@@ -34,7 +34,7 @@ Limitations:
|
||||
#include "gl_local.h"
|
||||
#ifndef XASH_GL_STATIC
|
||||
#include "gl2_shim.h"
|
||||
#include <malloc.h>
|
||||
#include ALLOCA_H
|
||||
|
||||
#define MAX_SHADERLEN 4096
|
||||
// increase this when adding more attributes
|
||||
|
||||
@@ -427,7 +427,7 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height )
|
||||
skin.encode = DXT_ENCODE_DEFAULT;
|
||||
skin.numMips = 1;
|
||||
skin.buffer = data;
|
||||
skin.palette = (byte *)gEngfuncs.CL_GetPaletteColor( 0 );
|
||||
skin.palette = (byte *)tr.palette;
|
||||
skin.size = width * height;
|
||||
|
||||
if( !gEngfuncs.Image_CustomPalette() )
|
||||
@@ -1002,15 +1002,10 @@ R_AliasSetRemapColors
|
||||
|
||||
===============
|
||||
*/
|
||||
void R_AliasSetRemapColors( int newTop, int newBottom )
|
||||
static void R_AliasSetRemapColors( int newTop, int newBottom )
|
||||
{
|
||||
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom );
|
||||
|
||||
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
|
||||
{
|
||||
gEngfuncs.CL_UpdateRemapInfo( RI.currententity, newTop, newBottom );
|
||||
if( gEngfuncs.CL_EntitySetRemapColors( RI.currententity, RI.currentmodel, newTop, newBottom ))
|
||||
m_fDoRemap = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1261,7 +1256,7 @@ static void R_AliasDrawAbsBBox( cl_entity_t *e, const vec3_t absmin, const vec3_
|
||||
int i;
|
||||
|
||||
// looks ugly, skip
|
||||
if( r_drawentities->value != 5 || e == gEngfuncs.GetViewModel() )
|
||||
if( r_drawentities->value != 5 || e == tr.viewent )
|
||||
return;
|
||||
|
||||
// compute a full bounding box
|
||||
|
||||
@@ -943,7 +943,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||
model_t *model;
|
||||
vec3_t delta;
|
||||
|
||||
model = gEngfuncs.pfnGetModelByIndex( pbeam->modelIndex );
|
||||
model = CL_ModelHandle( pbeam->modelIndex );
|
||||
SetBits( pbeam->flags, FBEAM_ISACTIVE );
|
||||
|
||||
if( !model || model->type != mod_sprite )
|
||||
@@ -1146,7 +1146,7 @@ passed through this
|
||||
*/
|
||||
static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed )
|
||||
{
|
||||
model_t *sprite = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
model_t *sprite = CL_ModelHandle( modelIndex );
|
||||
|
||||
if( !sprite ) return;
|
||||
|
||||
|
||||
@@ -295,19 +295,32 @@ const byte *GL_TextureData( unsigned int texnum )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void R_ProcessEntData( qboolean allocate )
|
||||
void R_ProcessEntData( qboolean allocate, cl_entity_t *entities, unsigned int max_entities )
|
||||
{
|
||||
if( !allocate )
|
||||
{
|
||||
tr.draw_list->num_solid_entities = 0;
|
||||
tr.draw_list->num_trans_entities = 0;
|
||||
tr.draw_list->num_beam_entities = 0;
|
||||
|
||||
tr.max_entities = 0;
|
||||
tr.entities = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
tr.max_entities = max_entities;
|
||||
tr.entities = entities;
|
||||
}
|
||||
|
||||
if( gEngfuncs.drawFuncs->R_ProcessEntData )
|
||||
gEngfuncs.drawFuncs->R_ProcessEntData( allocate );
|
||||
}
|
||||
|
||||
static void GAME_EXPORT R_Flush( unsigned int flags )
|
||||
{
|
||||
// stub
|
||||
}
|
||||
|
||||
qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int offset_y, float scale_x, float scale_y )
|
||||
{
|
||||
qboolean ret = true;
|
||||
@@ -372,6 +385,7 @@ ref_interface_t gReffuncs =
|
||||
R_AddEntity,
|
||||
CL_AddCustomBeam,
|
||||
R_ProcessEntData,
|
||||
R_Flush,
|
||||
|
||||
R_ShowTextures,
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ R_CullModel
|
||||
*/
|
||||
int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax )
|
||||
{
|
||||
if( e == gEngfuncs.GetViewModel() )
|
||||
if( e == tr.viewent )
|
||||
{
|
||||
if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
|
||||
return 1;
|
||||
@@ -77,7 +77,7 @@ int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags )
|
||||
return CULL_VISIBLE;
|
||||
|
||||
// world surfaces can be culled by vis frame too
|
||||
if( RI.currententity == gEngfuncs.GetEntityByIndex( 0 ) && surf->visframe != tr.framecount )
|
||||
if( RI.currententity == CL_GetEntityByIndex( 0 ) && surf->visframe != tr.framecount )
|
||||
return CULL_VISFRAME;
|
||||
|
||||
// only static ents can be culled by frustum
|
||||
@@ -92,7 +92,7 @@ int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags )
|
||||
{
|
||||
vec3_t orthonormal;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) ) orthonormal[2] = surf->plane->normal[2];
|
||||
if( e == CL_GetEntityByIndex( 0 )) orthonormal[2] = surf->plane->normal[2];
|
||||
else Matrix4x4_VectorRotate( RI.objectMatrix, surf->plane->normal, orthonormal );
|
||||
dist = orthonormal[2];
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ GNU General Public License for more details.
|
||||
// REFTODO: rewrite in triapi
|
||||
void R_DrawWorldHull( void )
|
||||
{
|
||||
hull_model_t *hull = &WORLD->hull_models[0];
|
||||
hull_model_t *hull = &tr.world->hull_models[0];
|
||||
winding_t *poly;
|
||||
int i;
|
||||
|
||||
@@ -69,10 +69,10 @@ void R_DrawModelHull( void )
|
||||
return;
|
||||
|
||||
i = atoi( RI.currentmodel->name + 1 );
|
||||
if( i < 1 || i >= WORLD->num_hull_models )
|
||||
if( i < 1 || i >= tr.world->num_hull_models )
|
||||
return;
|
||||
|
||||
hull = &WORLD->hull_models[i];
|
||||
hull = &tr.world->hull_models[i];
|
||||
|
||||
pglPolygonOffset( 1.0f, 2.0 );
|
||||
pglEnable( GL_POLYGON_OFFSET_FILL );
|
||||
|
||||
@@ -391,30 +391,15 @@ float *R_DecalVertsClip( decal_t *pDecal, msurface_t *surf, int texture, int *pV
|
||||
// Generate lighting coordinates at each vertex for decal vertices v[] on surface psurf
|
||||
static void R_DecalVertsLight( float *v, msurface_t *surf, int vertCount )
|
||||
{
|
||||
float s, t;
|
||||
mtexinfo_t *tex;
|
||||
mextrasurf_t *info = surf->info;
|
||||
float sample_size;
|
||||
int j;
|
||||
|
||||
sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
|
||||
tex = surf->texinfo;
|
||||
|
||||
for( j = 0; j < vertCount; j++, v += VERTEXSIZE )
|
||||
{
|
||||
// lightmap texture coordinates
|
||||
s = DotProduct( v, info->lmvecs[0] ) + info->lmvecs[0][3] - info->lightmapmins[0];
|
||||
s += surf->light_s * sample_size;
|
||||
s += sample_size * 0.5f;
|
||||
s /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
|
||||
|
||||
t = DotProduct( v, info->lmvecs[1] ) + info->lmvecs[1][3] - info->lightmapmins[1];
|
||||
t += surf->light_t * sample_size;
|
||||
t += sample_size * 0.5f;
|
||||
t /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->height;
|
||||
|
||||
v[5] = s;
|
||||
v[6] = t;
|
||||
R_LightmapCoord( v, surf, sample_size, &v[5] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -765,15 +750,15 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos
|
||||
|
||||
if( entityIndex > 0 )
|
||||
{
|
||||
ent = gEngfuncs.GetEntityByIndex( entityIndex );
|
||||
ent = CL_GetEntityByIndex( entityIndex );
|
||||
|
||||
if( modelIndex > 0 ) model = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
else if( ent != NULL ) model = gEngfuncs.pfnGetModelByIndex( ent->curstate.modelindex );
|
||||
if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
|
||||
else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
|
||||
else return;
|
||||
}
|
||||
else if( modelIndex > 0 )
|
||||
model = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
else model = WORLDMODEL;
|
||||
model = CL_ModelHandle( modelIndex );
|
||||
else model = CL_ModelHandle( 1 );
|
||||
|
||||
if( !model ) return;
|
||||
|
||||
|
||||
@@ -892,6 +892,11 @@ typedef float GLmatrix[16];
|
||||
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
|
||||
#if defined( XASH_GL_STATIC ) && !defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
|
||||
#define GL_FUNCTION( name ) name
|
||||
#elif defined( XASH_GL_STATIC ) && defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
|
||||
@@ -1861,4 +1866,8 @@ APIENTRY_LINKAGE void GL_FUNCTION( glTexImage2DMultisample )(GLenum target, GLsi
|
||||
#define pglSwapInterval glSwapInterval
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif//GL_EXPORT_H
|
||||
|
||||
@@ -342,6 +342,8 @@ void R_SetTextureParameters( void )
|
||||
// change all the existing mipmapped texture objects
|
||||
for( i = 0; i < gl_numTextures; i++ )
|
||||
GL_UpdateTextureParams( i );
|
||||
|
||||
R_UpdateRippleTexParams();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1666,11 +1668,11 @@ int GL_LoadTextureArray( const char **names, int flags )
|
||||
else
|
||||
{
|
||||
// create new image
|
||||
pic = Mem_Malloc( gEngfuncs.Image_GetPool(), sizeof( rgbdata_t ));
|
||||
pic = Mem_Malloc( r_temppool, sizeof( rgbdata_t ));
|
||||
memcpy( pic, src, sizeof( rgbdata_t ));
|
||||
|
||||
// expand pic buffer for all layers
|
||||
pic->buffer = Mem_Malloc( gEngfuncs.Image_GetPool(), pic->size * numLayers );
|
||||
pic->buffer = Mem_Malloc( r_temppool, pic->size * numLayers );
|
||||
pic->depth = 0;
|
||||
}
|
||||
|
||||
@@ -2317,6 +2319,7 @@ void R_InitImages( void )
|
||||
// validate cvars
|
||||
R_SetTextureParameters();
|
||||
GL_CreateInternalTextures();
|
||||
R_InitRipples();
|
||||
|
||||
gEngfuncs.Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" );
|
||||
}
|
||||
|
||||
@@ -57,10 +57,6 @@ void VGL_ShimEndFrame( void );
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define WORLD (gEngfuncs.GetWorld())
|
||||
#define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
|
||||
#define MOVEVARS (gEngfuncs.pfnGetMoveVars())
|
||||
|
||||
// make mod_ref.h?
|
||||
#define LM_SAMPLE_SIZE 16
|
||||
|
||||
@@ -257,6 +253,16 @@ typedef struct
|
||||
vec3_t modelorg; // relative to viewpoint
|
||||
|
||||
qboolean fCustomSkybox;
|
||||
|
||||
// get from engine
|
||||
struct world_static_s *world;
|
||||
cl_entity_t *entities;
|
||||
movevars_t *movevars;
|
||||
model_t **models;
|
||||
color24 *palette;
|
||||
cl_entity_t *viewent;
|
||||
|
||||
uint max_entities;
|
||||
} gl_globals_t;
|
||||
|
||||
typedef struct
|
||||
@@ -439,6 +445,7 @@ void GL_ResetFogColor( void );
|
||||
void R_GenerateVBO( void );
|
||||
void R_ClearVBO( void );
|
||||
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 );
|
||||
|
||||
//
|
||||
// gl_rpart.c
|
||||
@@ -489,6 +496,11 @@ void R_ClearSkyBox( void );
|
||||
void R_DrawSkyBox( void );
|
||||
void R_DrawClouds( void );
|
||||
void EmitWaterPolys( msurface_t *warp, qboolean reverse );
|
||||
void R_InitRipples( void );
|
||||
void R_ResetRipples( void );
|
||||
void R_AnimateRipples( void );
|
||||
void R_UpdateRippleTexParams( void );
|
||||
void R_UploadRipples( texture_t *image );
|
||||
|
||||
//
|
||||
// gl_vgui.c
|
||||
@@ -701,7 +713,6 @@ typedef struct
|
||||
qboolean in2DMode;
|
||||
} glstate_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
qboolean initialized; // OpenGL subsystem started
|
||||
@@ -718,6 +729,21 @@ extern ref_globals_t *gpGlobals;
|
||||
#define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm)
|
||||
#define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( ( parm ), 0 )
|
||||
|
||||
//
|
||||
// helper funcs
|
||||
//
|
||||
static inline cl_entity_t *CL_GetEntityByIndex( int index )
|
||||
{
|
||||
return &tr.entities[index];
|
||||
}
|
||||
|
||||
static inline model_t *CL_ModelHandle( int index )
|
||||
{
|
||||
return tr.models[index];
|
||||
}
|
||||
|
||||
#define WORLDMODEL (tr.models[1])
|
||||
|
||||
//
|
||||
// renderer cvars
|
||||
//
|
||||
@@ -750,6 +776,9 @@ extern convar_t r_vbo;
|
||||
extern convar_t r_vbo_dlightmode;
|
||||
extern convar_t r_studio_sort_textures;
|
||||
extern convar_t r_studio_drawelements;
|
||||
extern convar_t r_ripple;
|
||||
extern convar_t r_ripple_updatetime;
|
||||
extern convar_t r_ripple_spawntime;
|
||||
|
||||
//
|
||||
// engine shared convars
|
||||
|
||||
@@ -30,6 +30,10 @@ CVAR_DEFINE_AUTO( r_traceglow, "0", FCVAR_GLCONFIG, "cull flares behind models"
|
||||
CVAR_DEFINE_AUTO( gl_round_down, "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" );
|
||||
CVAR_DEFINE( r_vbo, "gl_vbo", "0", FCVAR_ARCHIVE, "draw world using VBO (known to be glitchy)" );
|
||||
CVAR_DEFINE( r_vbo_dlightmode, "gl_vbo_dlightmode", "1", FCVAR_ARCHIVE, "vbo dlight rendering mode (0-1)" );
|
||||
CVAR_DEFINE_AUTO( r_ripple, "0", FCVAR_GLCONFIG, "enable software-like water texture ripple simulation" );
|
||||
CVAR_DEFINE_AUTO( r_ripple_updatetime, "0.05", FCVAR_GLCONFIG, "how fast ripple simulation is" );
|
||||
CVAR_DEFINE_AUTO( r_ripple_spawntime, "0.1", FCVAR_GLCONFIG, "how fast new ripples spawn" );
|
||||
|
||||
|
||||
DEFINE_ENGINE_SHARED_CVAR_LIST()
|
||||
|
||||
@@ -909,13 +913,7 @@ void GL_InitExtensionsBigGL( void )
|
||||
|
||||
// gl4es may be used system-wide
|
||||
if( Q_stristr( glConfig.renderer_string, "gl4es" ))
|
||||
{
|
||||
const char *vendor = (const char *)pglGetString( GL_VENDOR | 0x10000 );
|
||||
const char *renderer = (const char *)pglGetString( GL_RENDERER | 0x10000 );
|
||||
const char *version = (const char *)pglGetString( GL_VERSION | 0x10000 );
|
||||
const char *extensions = (const char *)pglGetString( GL_EXTENSIONS | 0x10000 );
|
||||
glConfig.wrapper = GLES_WRAPPER_GL4ES;
|
||||
}
|
||||
|
||||
// multitexture
|
||||
glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1;
|
||||
@@ -1186,6 +1184,9 @@ void GL_InitCommands( void )
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_traceglow );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_studio_drawelements );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_ripple );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_ripple_updatetime );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_ripple_spawntime );
|
||||
|
||||
gEngfuncs.Cvar_RegisterVariable( &gl_extensions );
|
||||
gEngfuncs.Cvar_RegisterVariable( &gl_texture_nearest );
|
||||
@@ -1283,6 +1284,13 @@ qboolean R_Init( void )
|
||||
return false;
|
||||
}
|
||||
|
||||
// see R_ProcessEntData for tr.entities initialization
|
||||
tr.world = gEngfuncs.GetWorld();
|
||||
tr.models = gEngfuncs.pfnGetModels();
|
||||
tr.movevars = gEngfuncs.pfnGetMoveVars();
|
||||
tr.palette = gEngfuncs.CL_GetPaletteColor();
|
||||
tr.viewent = gEngfuncs.GetViewModel();
|
||||
|
||||
GL_SetDefaults();
|
||||
R_CheckVBO();
|
||||
R_InitImages();
|
||||
|
||||
@@ -152,7 +152,7 @@ void R_PushDlights( void )
|
||||
|
||||
tr.dlightframecount = tr.framecount;
|
||||
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
|
||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||
if( RI.currententity )
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ R_GetFarClip
|
||||
static float R_GetFarClip( void )
|
||||
{
|
||||
if( WORLDMODEL && RI.drawWorld )
|
||||
return MOVEVARS->zmax * 1.73f;
|
||||
return tr.movevars->zmax * 1.73f;
|
||||
return 2048.0f;
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ void R_RotateForEntity( cl_entity_t *e )
|
||||
{
|
||||
float scale = 1.0f;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) )
|
||||
if( e == CL_GetEntityByIndex( 0 ))
|
||||
{
|
||||
R_LoadIdentity();
|
||||
return;
|
||||
@@ -455,7 +455,7 @@ void R_TranslateForEntity( cl_entity_t *e )
|
||||
{
|
||||
float scale = 1.0f;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) )
|
||||
if( e == CL_GetEntityByIndex( 0 ))
|
||||
{
|
||||
R_LoadIdentity();
|
||||
return;
|
||||
@@ -669,7 +669,7 @@ static void R_CheckFog( void )
|
||||
// quake global fog
|
||||
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
|
||||
{
|
||||
if( !MOVEVARS->fog_settings )
|
||||
if( !tr.movevars->fog_settings )
|
||||
{
|
||||
if( pglIsEnabled( GL_FOG ))
|
||||
pglDisable( GL_FOG );
|
||||
@@ -678,10 +678,10 @@ static void R_CheckFog( void )
|
||||
}
|
||||
|
||||
// quake-style global fog
|
||||
RI.fogColor[0] = ((MOVEVARS->fog_settings & 0xFF000000) >> 24) / 255.0f;
|
||||
RI.fogColor[1] = ((MOVEVARS->fog_settings & 0xFF0000) >> 16) / 255.0f;
|
||||
RI.fogColor[2] = ((MOVEVARS->fog_settings & 0xFF00) >> 8) / 255.0f;
|
||||
RI.fogDensity = ((MOVEVARS->fog_settings & 0xFF) / 255.0f) * 0.01f;
|
||||
RI.fogColor[0] = ((tr.movevars->fog_settings & 0xFF000000) >> 24) / 255.0f;
|
||||
RI.fogColor[1] = ((tr.movevars->fog_settings & 0xFF0000) >> 16) / 255.0f;
|
||||
RI.fogColor[2] = ((tr.movevars->fog_settings & 0xFF00) >> 8) / 255.0f;
|
||||
RI.fogDensity = ((tr.movevars->fog_settings & 0xFF) / 255.0f) * 0.01f;
|
||||
RI.fogStart = RI.fogEnd = 0.0f;
|
||||
RI.fogColor[3] = 1.0f;
|
||||
RI.fogCustom = false;
|
||||
@@ -969,6 +969,8 @@ void R_RenderScene( void )
|
||||
|
||||
R_MarkLeaves();
|
||||
R_DrawFog ();
|
||||
if( RI.drawWorld )
|
||||
R_AnimateRipples();
|
||||
|
||||
R_CheckGLFog();
|
||||
R_DrawWorld();
|
||||
|
||||
@@ -146,10 +146,11 @@ void R_NewMap( void )
|
||||
tx->texturechain = NULL;
|
||||
}
|
||||
|
||||
R_SetupSky( MOVEVARS->skyName );
|
||||
R_SetupSky( tr.movevars->skyName );
|
||||
|
||||
GL_BuildLightmaps ();
|
||||
R_GenerateVBO();
|
||||
R_ResetRipples();
|
||||
|
||||
if( gEngfuncs.drawFuncs->R_NewMap != NULL )
|
||||
gEngfuncs.drawFuncs->R_NewMap();
|
||||
|
||||
@@ -49,7 +49,7 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
|
||||
{
|
||||
particle_t *p;
|
||||
vec3_t right, up;
|
||||
color24 *pColor;
|
||||
color24 color;
|
||||
int alpha;
|
||||
float size;
|
||||
|
||||
@@ -85,15 +85,15 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
|
||||
VectorScale( RI.cull_vup, size, up );
|
||||
|
||||
p->color = bound( 0, p->color, 255 );
|
||||
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
|
||||
color = tr.palette[p->color];
|
||||
|
||||
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
|
||||
if( alpha > 255 || p->type == pt_static )
|
||||
alpha = 255;
|
||||
|
||||
pglColor4ub( gEngfuncs.LightToTexGamma( pColor->r ),
|
||||
gEngfuncs.LightToTexGamma( pColor->g ),
|
||||
gEngfuncs.LightToTexGamma( pColor->b ), alpha );
|
||||
pglColor4ub( gEngfuncs.LightToTexGamma( color.r ),
|
||||
gEngfuncs.LightToTexGamma( color.g ),
|
||||
gEngfuncs.LightToTexGamma( color.b ), alpha );
|
||||
|
||||
pglTexCoord2f( 0.0f, 1.0f );
|
||||
pglVertex3f( p->org[0] - right[0] + up[0], p->org[1] - right[1] + up[1], p->org[2] - right[2] + up[2] );
|
||||
@@ -188,7 +188,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
|
||||
pglDisable( GL_ALPHA_TEST );
|
||||
pglDepthMask( GL_FALSE );
|
||||
|
||||
gravity = frametime * MOVEVARS->gravity;
|
||||
gravity = frametime * tr.movevars->gravity;
|
||||
scale = 1.0 - (frametime * 0.9);
|
||||
if( scale < 0.0f ) scale = 0.0f;
|
||||
|
||||
@@ -205,7 +205,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
|
||||
{
|
||||
vec3_t verts[4], tmp2;
|
||||
vec3_t tmp, normal;
|
||||
color24 *pColor;
|
||||
color24 color;
|
||||
|
||||
// Transform point into screen space
|
||||
TriWorldToScreen( start, screen );
|
||||
@@ -235,8 +235,8 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
|
||||
p->color = 0;
|
||||
}
|
||||
|
||||
pColor = &gTracerColors[p->color];
|
||||
pglColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor );
|
||||
color = gTracerColors[p->color];
|
||||
pglColor4ub( color.r, color.g, color.b, p->packedColor );
|
||||
|
||||
pglBegin( GL_QUADS );
|
||||
pglTexCoord2f( 0.0f, 0.8f );
|
||||
|
||||
@@ -61,6 +61,52 @@ void Mod_SetOrthoBounds( const float *mins, const float *maxs )
|
||||
Vector2Subtract( maxs, world_orthocenter, world_orthohalf );
|
||||
}
|
||||
|
||||
void R_LightmapCoord( const vec3_t v, const msurface_t *surf, const float sample_size, vec2_t coords )
|
||||
{
|
||||
const mextrasurf_t *info = surf->info;
|
||||
float s, t;
|
||||
|
||||
s = DotProduct( v, info->lmvecs[0] ) + info->lmvecs[0][3] - info->lightmapmins[0];
|
||||
s += surf->light_s * sample_size;
|
||||
s += sample_size * 0.5f;
|
||||
s /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
|
||||
|
||||
t = DotProduct( v, info->lmvecs[1] ) + info->lmvecs[1][3] - info->lightmapmins[1];
|
||||
t += surf->light_t * sample_size;
|
||||
t += sample_size * 0.5f;
|
||||
t /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
|
||||
|
||||
Vector2Set( coords, s, t );
|
||||
}
|
||||
|
||||
static void R_TextureCoord( const vec3_t v, const msurface_t *surf, vec2_t coords )
|
||||
{
|
||||
const mtexinfo_t *info = surf->texinfo;
|
||||
float s, t;
|
||||
|
||||
s = DotProduct( v, info->vecs[0] );
|
||||
t = DotProduct( v, info->vecs[1] );
|
||||
|
||||
if( !FBitSet( surf->flags, SURF_DRAWTURB ))
|
||||
{
|
||||
s = ( s + info->vecs[0][3] ) / info->texture->width;
|
||||
t = ( t + info->vecs[1][3] ) / info->texture->height;
|
||||
}
|
||||
|
||||
Vector2Set( coords, s, t );
|
||||
}
|
||||
|
||||
static void R_GetEdgePosition( const model_t *mod, const msurface_t *fa, int i, vec3_t vec )
|
||||
{
|
||||
const int lindex = mod->surfedges[fa->firstedge + i];
|
||||
const medge_t *pedges = mod->edges;
|
||||
|
||||
if( lindex > 0 )
|
||||
VectorCopy( mod->vertexes[pedges[lindex].v[0]].position, vec );
|
||||
else
|
||||
VectorCopy( mod->vertexes[pedges[-lindex].v[1]].position, vec );
|
||||
}
|
||||
|
||||
static void BoundPoly( int numverts, float *verts, vec3_t mins, vec3_t maxs )
|
||||
{
|
||||
int i, j;
|
||||
@@ -81,9 +127,8 @@ static void BoundPoly( int numverts, float *verts, vec3_t mins, vec3_t maxs )
|
||||
static void SubdividePolygon_r( model_t *loadmodel, msurface_t *warpface, int numverts, float *verts )
|
||||
{
|
||||
vec3_t front[SUBDIVIDE_SIZE], back[SUBDIVIDE_SIZE];
|
||||
mextrasurf_t *warpinfo = warpface->info;
|
||||
float dist[SUBDIVIDE_SIZE];
|
||||
float m, frac, s, t, *v;
|
||||
float m, frac, *v;
|
||||
int i, j, k, f, b;
|
||||
float sample_size;
|
||||
vec3_t mins, maxs;
|
||||
@@ -160,41 +205,13 @@ static void SubdividePolygon_r( model_t *loadmodel, msurface_t *warpface, int nu
|
||||
for( i = 0; i < numverts; i++, verts += 3 )
|
||||
{
|
||||
VectorCopy( verts, poly->verts[i] );
|
||||
|
||||
if( FBitSet( warpface->flags, SURF_DRAWTURB ))
|
||||
{
|
||||
s = DotProduct( verts, warpface->texinfo->vecs[0] );
|
||||
t = DotProduct( verts, warpface->texinfo->vecs[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
s = DotProduct( verts, warpface->texinfo->vecs[0] ) + warpface->texinfo->vecs[0][3];
|
||||
t = DotProduct( verts, warpface->texinfo->vecs[1] ) + warpface->texinfo->vecs[1][3];
|
||||
s /= warpface->texinfo->texture->width;
|
||||
t /= warpface->texinfo->texture->height;
|
||||
}
|
||||
|
||||
poly->verts[i][3] = s;
|
||||
poly->verts[i][4] = t;
|
||||
R_TextureCoord( verts, warpface, &poly->verts[i][3] );
|
||||
|
||||
// for speed reasons
|
||||
if( !FBitSet( warpface->flags, SURF_DRAWTURB ))
|
||||
{
|
||||
// lightmap texture coordinates
|
||||
s = DotProduct( verts, warpinfo->lmvecs[0] ) + warpinfo->lmvecs[0][3];
|
||||
s -= warpinfo->lightmapmins[0];
|
||||
s += warpface->light_s * sample_size;
|
||||
s += sample_size * 0.5f;
|
||||
s /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
|
||||
|
||||
t = DotProduct( verts, warpinfo->lmvecs[1] ) + warpinfo->lmvecs[1][3];
|
||||
t -= warpinfo->lightmapmins[1];
|
||||
t += warpface->light_t * sample_size;
|
||||
t += sample_size * 0.5f;
|
||||
t /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->height;
|
||||
|
||||
poly->verts[i][5] = s;
|
||||
poly->verts[i][6] = t;
|
||||
R_LightmapCoord( verts, warpface, sample_size, &poly->verts[i][5] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,7 +221,7 @@ void GL_SetupFogColorForSurfaces( void )
|
||||
vec3_t fogColor;
|
||||
float factor, div;
|
||||
|
||||
if( !glState.isFogEnabled)
|
||||
if( !glState.isFogEnabled )
|
||||
return;
|
||||
|
||||
if( RI.currententity && RI.currententity->curstate.rendermode == kRenderTransTexture )
|
||||
@@ -240,26 +257,16 @@ can be done reasonably.
|
||||
void GL_SubdivideSurface( model_t *loadmodel, msurface_t *fa )
|
||||
{
|
||||
vec3_t verts[SUBDIVIDE_SIZE];
|
||||
int numverts;
|
||||
int i, lindex;
|
||||
float *vec;
|
||||
int i;
|
||||
|
||||
// convert edges back to a normal polygon
|
||||
numverts = 0;
|
||||
for( i = 0; i < fa->numedges; i++ )
|
||||
{
|
||||
lindex = loadmodel->surfedges[fa->firstedge + i];
|
||||
|
||||
if( lindex > 0 ) vec = loadmodel->vertexes[loadmodel->edges[lindex].v[0]].position;
|
||||
else vec = loadmodel->vertexes[loadmodel->edges[-lindex].v[1]].position;
|
||||
VectorCopy( vec, verts[numverts] );
|
||||
numverts++;
|
||||
}
|
||||
R_GetEdgePosition( loadmodel, fa, i, verts[i] );
|
||||
|
||||
SetBits( fa->flags, SURF_DRAWTURB_QUADS ); // predict state
|
||||
|
||||
// do subdivide
|
||||
SubdividePolygon_r( loadmodel, fa, numverts, verts[0] );
|
||||
SubdividePolygon_r( loadmodel, fa, fa->numedges, verts[0] );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -269,14 +276,10 @@ GL_BuildPolygonFromSurface
|
||||
*/
|
||||
void GL_BuildPolygonFromSurface( model_t *mod, msurface_t *fa )
|
||||
{
|
||||
int i, lindex, lnumverts;
|
||||
medge_t *pedges, *r_pedge;
|
||||
mextrasurf_t *info = fa->info;
|
||||
int i, lnumverts;
|
||||
float sample_size;
|
||||
texture_t *tex;
|
||||
gl_texture_t *glt;
|
||||
float *vec;
|
||||
float s, t;
|
||||
glpoly_t *poly;
|
||||
|
||||
if( !mod || !fa->texinfo || !fa->texinfo->texture )
|
||||
@@ -296,7 +299,6 @@ void GL_BuildPolygonFromSurface( model_t *mod, msurface_t *fa )
|
||||
sample_size = gEngfuncs.Mod_SampleSizeForFace( fa );
|
||||
|
||||
// reconstruct the polygon
|
||||
pedges = mod->edges;
|
||||
lnumverts = fa->numedges;
|
||||
|
||||
// detach if already created, reconstruct again
|
||||
@@ -312,44 +314,9 @@ void GL_BuildPolygonFromSurface( model_t *mod, msurface_t *fa )
|
||||
|
||||
for( i = 0; i < lnumverts; i++ )
|
||||
{
|
||||
lindex = mod->surfedges[fa->firstedge + i];
|
||||
|
||||
if( lindex > 0 )
|
||||
{
|
||||
r_pedge = &pedges[lindex];
|
||||
vec = mod->vertexes[r_pedge->v[0]].position;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_pedge = &pedges[-lindex];
|
||||
vec = mod->vertexes[r_pedge->v[1]].position;
|
||||
}
|
||||
|
||||
s = DotProduct( vec, fa->texinfo->vecs[0] ) + fa->texinfo->vecs[0][3];
|
||||
s /= fa->texinfo->texture->width;
|
||||
|
||||
t = DotProduct( vec, fa->texinfo->vecs[1] ) + fa->texinfo->vecs[1][3];
|
||||
t /= fa->texinfo->texture->height;
|
||||
|
||||
VectorCopy( vec, poly->verts[i] );
|
||||
poly->verts[i][3] = s;
|
||||
poly->verts[i][4] = t;
|
||||
|
||||
// lightmap texture coordinates
|
||||
s = DotProduct( vec, info->lmvecs[0] ) + info->lmvecs[0][3];
|
||||
s -= info->lightmapmins[0];
|
||||
s += fa->light_s * sample_size;
|
||||
s += sample_size * 0.5f;
|
||||
s /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
|
||||
|
||||
t = DotProduct( vec, info->lmvecs[1] ) + info->lmvecs[1][3];
|
||||
t -= info->lightmapmins[1];
|
||||
t += fa->light_t * sample_size;
|
||||
t += sample_size * 0.5f;
|
||||
t /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->height;
|
||||
|
||||
poly->verts[i][5] = s;
|
||||
poly->verts[i][6] = t;
|
||||
R_GetEdgePosition( mod, fa, i, poly->verts[i] );
|
||||
R_TextureCoord( poly->verts[i], fa, &poly->verts[i][3] );
|
||||
R_LightmapCoord( poly->verts[i], fa, sample_size, &poly->verts[i][5] );
|
||||
}
|
||||
|
||||
// remove co-linear points - Ed
|
||||
@@ -791,7 +758,7 @@ void DrawGLPoly( glpoly_t *p, float xScale, float yScale )
|
||||
float flRate, flAngle;
|
||||
gl_texture_t *texture;
|
||||
|
||||
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && RI.currententity == gEngfuncs.GetEntityByIndex( 0 ) )
|
||||
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && RI.currententity == CL_GetEntityByIndex( 0 ))
|
||||
{
|
||||
// same as doom speed
|
||||
flConveyorSpeed = -35.0f;
|
||||
@@ -1135,14 +1102,15 @@ void R_RenderBrushPoly( msurface_t *fa, int cull_type )
|
||||
|
||||
t = R_TextureAnimation( fa );
|
||||
|
||||
GL_Bind( XASH_TEXTURE0, t->gl_texturenum );
|
||||
|
||||
if( FBitSet( fa->flags, SURF_DRAWTURB ))
|
||||
{
|
||||
R_UploadRipples( t );
|
||||
|
||||
// warp texture, no lightmaps
|
||||
EmitWaterPolys( fa, (cull_type == CULL_BACKSIDE));
|
||||
return;
|
||||
}
|
||||
else GL_Bind( XASH_TEXTURE0, t->gl_texturenum );
|
||||
|
||||
if( t->fb_texturenum )
|
||||
{
|
||||
@@ -1267,7 +1235,7 @@ void R_DrawTextureChains( void )
|
||||
GL_SetupFogColorForSurfaces();
|
||||
|
||||
// restore worldmodel
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
|
||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
|
||||
if( ENGINE_GET_PARM( PARM_SKY_SPHERE ) )
|
||||
@@ -1298,7 +1266,7 @@ void R_DrawTextureChains( void )
|
||||
if( !s || ( i == tr.skytexturenum ))
|
||||
continue;
|
||||
|
||||
if(( s->flags & SURF_DRAWTURB ) && MOVEVARS->wateralpha < 1.0f )
|
||||
if(( s->flags & SURF_DRAWTURB ) && tr.movevars->wateralpha < 1.0f )
|
||||
continue; // draw translucent water later
|
||||
|
||||
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && FBitSet( s->flags, SURF_TRANSPARENT ))
|
||||
@@ -1341,7 +1309,7 @@ void R_DrawAlphaTextureChains( void )
|
||||
GL_SetupFogColorForSurfaces();
|
||||
|
||||
// restore worldmodel
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
|
||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
RI.currententity->curstate.rendermode = kRenderTransAlpha;
|
||||
draw_alpha_surfaces = false;
|
||||
@@ -1382,11 +1350,11 @@ void R_DrawWaterSurfaces( void )
|
||||
return;
|
||||
|
||||
// non-transparent water is already drawed
|
||||
if( MOVEVARS->wateralpha >= 1.0f )
|
||||
if( tr.movevars->wateralpha >= 1.0f )
|
||||
return;
|
||||
|
||||
// restore worldmodel
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
|
||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
|
||||
// go back to the world matrix
|
||||
@@ -1397,7 +1365,7 @@ void R_DrawWaterSurfaces( void )
|
||||
pglDisable( GL_ALPHA_TEST );
|
||||
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
pglColor4f( 1.0f, 1.0f, 1.0f, MOVEVARS->wateralpha );
|
||||
pglColor4f( 1.0f, 1.0f, 1.0f, tr.movevars->wateralpha );
|
||||
|
||||
for( i = 0; i < WORLDMODEL->numtextures; i++ )
|
||||
{
|
||||
@@ -1411,7 +1379,7 @@ void R_DrawWaterSurfaces( void )
|
||||
continue;
|
||||
|
||||
// set modulate mode explicitly
|
||||
GL_Bind( XASH_TEXTURE0, t->gl_texturenum );
|
||||
R_UploadRipples( t );
|
||||
|
||||
for( ; s; s = s->texturechain )
|
||||
EmitWaterPolys( s, false );
|
||||
@@ -3312,7 +3280,7 @@ void R_DrawWorld( void )
|
||||
|
||||
// paranoia issues: when gl_renderer is "0" we need have something valid for currententity
|
||||
// to prevent crashing until HeadShield drawing.
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
|
||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||
if( !RI.currententity )
|
||||
return;
|
||||
|
||||
@@ -3522,7 +3490,7 @@ void GL_RebuildLightmaps( void )
|
||||
|
||||
for( i = 0; i < ENGINE_GET_PARM( PARM_NUMMODELS ); i++ )
|
||||
{
|
||||
if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL )
|
||||
if(( m = CL_ModelHandle( i + 1 )) == NULL )
|
||||
continue;
|
||||
|
||||
if( m->name[0] == '*' || m->type != mod_brush )
|
||||
@@ -3564,7 +3532,8 @@ void GL_BuildLightmaps( void )
|
||||
memset( &RI, 0, sizeof( RI ));
|
||||
|
||||
// update the lightmap blocksize
|
||||
if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_LARGE_LIGHTMAPS ))
|
||||
if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_LARGE_LIGHTMAPS )
|
||||
|| ENGINE_GET_PARM( PARM_WORLD_VERSION ) == QBSP2_VERSION )
|
||||
tr.block_size = BLOCK_SIZE_MAX;
|
||||
else tr.block_size = BLOCK_SIZE_DEFAULT;
|
||||
|
||||
@@ -3586,7 +3555,7 @@ void GL_BuildLightmaps( void )
|
||||
|
||||
for( i = 0; i < ENGINE_GET_PARM( PARM_NUMMODELS ); i++ )
|
||||
{
|
||||
if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL )
|
||||
if(( m = CL_ModelHandle( i + 1 )) == NULL )
|
||||
continue;
|
||||
|
||||
if( m->name[0] == '*' || m->type != mod_brush )
|
||||
|
||||
@@ -826,7 +826,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
||||
{
|
||||
cl_entity_t *parent;
|
||||
|
||||
parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment );
|
||||
parent = CL_GetEntityByIndex( e->curstate.aiment );
|
||||
|
||||
if( parent && parent->model )
|
||||
{
|
||||
|
||||
@@ -196,7 +196,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e )
|
||||
{
|
||||
if( cl_righthand && cl_righthand->value > 0 )
|
||||
{
|
||||
if( e == gEngfuncs.GetViewModel() )
|
||||
if( e == tr.viewent )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ pfnGetViewEntity
|
||||
*/
|
||||
static cl_entity_t *pfnGetViewEntity( void )
|
||||
{
|
||||
return gEngfuncs.GetViewModel();
|
||||
return tr.viewent;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1851,7 +1851,7 @@ void R_StudioRenderShadow( int iSprite, float *p1, float *p2, float *p3, float *
|
||||
if( !p1 || !p2 || !p3 || !p4 )
|
||||
return;
|
||||
|
||||
if( TriSpriteTexture( gEngfuncs.pfnGetModelByIndex( iSprite ), 0 ))
|
||||
if( TriSpriteTexture( CL_ModelHandle( iSprite ), 0 ))
|
||||
{
|
||||
TriRenderMode( kRenderTransAlpha );
|
||||
TriColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
@@ -2488,7 +2488,7 @@ static void R_StudioDrawAbsBBox( void )
|
||||
int i;
|
||||
|
||||
// looks ugly, skip
|
||||
if( RI.currententity == gEngfuncs.GetViewModel() )
|
||||
if( RI.currententity == tr.viewent )
|
||||
return;
|
||||
|
||||
if( !R_StudioComputeBBox( p ))
|
||||
@@ -2624,13 +2624,8 @@ R_StudioSetRemapColors
|
||||
*/
|
||||
static void R_StudioSetRemapColors( int newTop, int newBottom )
|
||||
{
|
||||
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom );
|
||||
|
||||
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
|
||||
{
|
||||
gEngfuncs.CL_UpdateRemapInfo( RI.currententity, newTop, newBottom );
|
||||
if( gEngfuncs.CL_EntitySetRemapColors( RI.currententity, RI.currentmodel, newTop, newBottom ))
|
||||
m_fDoRemap = true;
|
||||
}
|
||||
}
|
||||
|
||||
void R_StudioResetPlayerModels( void )
|
||||
@@ -3371,7 +3366,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
||||
// copy attachments into global entity array
|
||||
if( RI.currententity->index > 0 )
|
||||
{
|
||||
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
|
||||
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
|
||||
}
|
||||
}
|
||||
@@ -3414,7 +3409,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
||||
if( pplayer->weaponmodel )
|
||||
{
|
||||
cl_entity_t saveent = *RI.currententity;
|
||||
model_t *pweaponmodel = gEngfuncs.pfnGetModelByIndex( pplayer->weaponmodel );
|
||||
model_t *pweaponmodel = CL_ModelHandle( pplayer->weaponmodel );
|
||||
|
||||
m_pStudioHeader = (studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, pweaponmodel );
|
||||
|
||||
@@ -3500,7 +3495,7 @@ static int R_StudioDrawModel( int flags )
|
||||
// copy attachments into global entity array
|
||||
if( RI.currententity->index > 0 )
|
||||
{
|
||||
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
|
||||
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
|
||||
}
|
||||
}
|
||||
@@ -3569,7 +3564,7 @@ void R_DrawStudioModel( cl_entity_t *e )
|
||||
{
|
||||
if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
|
||||
{
|
||||
cl_entity_t *parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment );
|
||||
cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment );
|
||||
|
||||
if( parent && parent->model && parent->model->type == mod_studio )
|
||||
{
|
||||
@@ -3605,7 +3600,7 @@ void R_RunViewmodelEvents( void )
|
||||
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
||||
return;
|
||||
|
||||
RI.currententity = gEngfuncs.GetViewModel();
|
||||
RI.currententity = tr.viewent;
|
||||
|
||||
if( !RI.currententity->model || RI.currententity->model->type != mod_studio )
|
||||
return;
|
||||
@@ -3627,7 +3622,7 @@ R_GatherPlayerLight
|
||||
*/
|
||||
void R_GatherPlayerLight( void )
|
||||
{
|
||||
cl_entity_t *view = gEngfuncs.GetViewModel();
|
||||
cl_entity_t *view = tr.viewent;
|
||||
colorVec c;
|
||||
|
||||
tr.ignore_lightgamma = true;
|
||||
@@ -3643,7 +3638,7 @@ R_DrawViewModel
|
||||
*/
|
||||
void R_DrawViewModel( void )
|
||||
{
|
||||
cl_entity_t *view = gEngfuncs.GetViewModel();
|
||||
cl_entity_t *view = tr.viewent;
|
||||
|
||||
R_GatherPlayerLight();
|
||||
|
||||
@@ -3828,7 +3823,9 @@ void Mod_StudioUnloadTextures( void *data )
|
||||
|
||||
static model_t *pfnModelHandle( int modelindex )
|
||||
{
|
||||
return gEngfuncs.pfnGetModelByIndex( modelindex );
|
||||
if( modelindex < 0 || modelindex >= MAX_MODELS )
|
||||
return NULL;
|
||||
return CL_ModelHandle( modelindex );
|
||||
}
|
||||
|
||||
static void *pfnMod_CacheCheck( struct cache_user_s *c )
|
||||
|
||||
227
ref/gl/gl_warp.c
227
ref/gl/gl_warp.c
@@ -62,6 +62,29 @@ static float r_turbsin[] =
|
||||
#include "warpsin.h"
|
||||
};
|
||||
|
||||
#define RIPPLES_CACHEWIDTH_BITS 7
|
||||
#define RIPPLES_CACHEWIDTH ( 1 << RIPPLES_CACHEWIDTH_BITS )
|
||||
#define RIPPLES_CACHEWIDTH_MASK (( RIPPLES_CACHEWIDTH ) - 1 )
|
||||
#define RIPPLES_TEXSIZE ( RIPPLES_CACHEWIDTH * RIPPLES_CACHEWIDTH )
|
||||
#define RIPPLES_TEXSIZE_MASK ( RIPPLES_TEXSIZE - 1 )
|
||||
|
||||
STATIC_ASSERT( RIPPLES_TEXSIZE == 0x4000, "fix the algorithm to work with custom resolution" );
|
||||
|
||||
static struct
|
||||
{
|
||||
double time;
|
||||
double oldtime;
|
||||
|
||||
short *curbuf, *oldbuf;
|
||||
short buf[2][RIPPLES_TEXSIZE];
|
||||
qboolean update;
|
||||
|
||||
uint32_t texture[RIPPLES_TEXSIZE];
|
||||
int gl_texturenum;
|
||||
int rippletexturenum;
|
||||
float texturescale; // not all textures are 128x128, scale the texcoords down
|
||||
} g_ripple;
|
||||
|
||||
static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] )
|
||||
{
|
||||
const char *skybox_ext[3] = { "dds", "tga", "bmp" };
|
||||
@@ -799,10 +822,18 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse )
|
||||
os = v[3];
|
||||
ot = v[4];
|
||||
|
||||
s = os + r_turbsin[(int)((ot * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
|
||||
s *= ( 1.0f / SUBDIVIDE_SIZE );
|
||||
if( !r_ripple.value )
|
||||
{
|
||||
s = os + r_turbsin[(int)((ot * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
|
||||
t = ot + r_turbsin[(int)((os * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
|
||||
}
|
||||
else
|
||||
{
|
||||
s = os / g_ripple.texturescale;
|
||||
t = ot / g_ripple.texturescale;
|
||||
}
|
||||
|
||||
t = ot + r_turbsin[(int)((os * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
|
||||
s *= ( 1.0f / SUBDIVIDE_SIZE );
|
||||
t *= ( 1.0f / SUBDIVIDE_SIZE );
|
||||
|
||||
pglTexCoord2f( s, t );
|
||||
@@ -822,3 +853,193 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse )
|
||||
|
||||
GL_SetupFogColorForSurfaces();
|
||||
}
|
||||
|
||||
/*
|
||||
============================================================
|
||||
|
||||
HALF-LIFE SOFTWARE WATER
|
||||
|
||||
============================================================
|
||||
*/
|
||||
void R_ResetRipples( void )
|
||||
{
|
||||
g_ripple.curbuf = g_ripple.buf[0];
|
||||
g_ripple.oldbuf = g_ripple.buf[1];
|
||||
g_ripple.time = g_ripple.oldtime = gpGlobals->time - 0.1;
|
||||
memset( g_ripple.buf, 0, sizeof( g_ripple.buf ));
|
||||
}
|
||||
|
||||
void R_InitRipples( void )
|
||||
{
|
||||
rgbdata_t pic = { 0 };
|
||||
|
||||
pic.width = pic.height = RIPPLES_CACHEWIDTH;
|
||||
pic.depth = 1;
|
||||
pic.flags = IMAGE_HAS_COLOR;
|
||||
pic.buffer = (byte *)g_ripple.texture;
|
||||
pic.type = PF_RGBA_32;
|
||||
pic.size = sizeof( g_ripple.texture );
|
||||
pic.numMips = 1;
|
||||
memset( pic.buffer, 0, pic.size );
|
||||
|
||||
g_ripple.rippletexturenum = GL_LoadTextureInternal( "*rippletex", &pic, TF_NOMIPMAP );
|
||||
}
|
||||
|
||||
static void R_SwapBufs( void )
|
||||
{
|
||||
short *tempbufp = g_ripple.curbuf;
|
||||
g_ripple.curbuf = g_ripple.oldbuf;
|
||||
g_ripple.oldbuf = tempbufp;
|
||||
}
|
||||
|
||||
static void R_SpawnNewRipple( int x, int y, short val )
|
||||
{
|
||||
#define PIXEL( x, y ) ((( x ) & RIPPLES_CACHEWIDTH_MASK ) + ((( y ) & RIPPLES_CACHEWIDTH_MASK) << 7 ))
|
||||
g_ripple.oldbuf[PIXEL( x, y )] += val;
|
||||
|
||||
val >>= 2;
|
||||
g_ripple.oldbuf[PIXEL( x + 1, y )] += val;
|
||||
g_ripple.oldbuf[PIXEL( x - 1, y )] += val;
|
||||
g_ripple.oldbuf[PIXEL( x, y + 1 )] += val;
|
||||
g_ripple.oldbuf[PIXEL( x, y - 1 )] += val;
|
||||
#undef PIXEL
|
||||
}
|
||||
|
||||
static void R_RunRipplesAnimation( const short *oldbuf, short *pbuf )
|
||||
{
|
||||
size_t i = 0;
|
||||
const int w = RIPPLES_CACHEWIDTH;
|
||||
const int m = RIPPLES_TEXSIZE_MASK;
|
||||
|
||||
for( i = w; i < m + w; i++, pbuf++ )
|
||||
{
|
||||
*pbuf = (
|
||||
( (int)oldbuf[( i - ( w * 2 )) & m]
|
||||
+ (int)oldbuf[( i - ( w + 1 )) & m]
|
||||
+ (int)oldbuf[( i - ( w - 1 )) & m]
|
||||
+ (int)oldbuf[( i ) & m]) >> 1 ) - (int)*pbuf;
|
||||
|
||||
*pbuf -= ( *pbuf >> 6 );
|
||||
}
|
||||
}
|
||||
|
||||
static int MostSignificantBit( unsigned int v )
|
||||
{
|
||||
#if __GNUC__
|
||||
return 31 - __builtin_clz( v );
|
||||
#else
|
||||
int i;
|
||||
for( i = 0, v >>= 1; v; v >>= 1, i++ );
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
|
||||
void R_AnimateRipples( void )
|
||||
{
|
||||
double frametime = gpGlobals->time - g_ripple.time;
|
||||
|
||||
g_ripple.update = r_ripple.value && frametime >= r_ripple_updatetime.value;
|
||||
|
||||
if( !g_ripple.update )
|
||||
return;
|
||||
|
||||
g_ripple.time = gpGlobals->time;
|
||||
|
||||
R_SwapBufs();
|
||||
|
||||
if( g_ripple.time - g_ripple.oldtime > r_ripple_spawntime.value )
|
||||
{
|
||||
int x, y, val;
|
||||
|
||||
g_ripple.oldtime = g_ripple.time;
|
||||
|
||||
x = rand() & 0x7fff;
|
||||
y = rand() & 0x7fff;
|
||||
val = rand() & 0x3ff;
|
||||
|
||||
R_SpawnNewRipple( x, y, val );
|
||||
}
|
||||
|
||||
R_RunRipplesAnimation( g_ripple.oldbuf, g_ripple.curbuf );
|
||||
}
|
||||
|
||||
void R_UpdateRippleTexParams( void )
|
||||
{
|
||||
gl_texture_t *tex = R_GetTexture( g_ripple.rippletexturenum );
|
||||
|
||||
GL_Bind( XASH_TEXTURE0, g_ripple.rippletexturenum );
|
||||
|
||||
if( gl_texture_nearest.value )
|
||||
{
|
||||
pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
}
|
||||
else
|
||||
{
|
||||
pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
}
|
||||
}
|
||||
|
||||
void R_UploadRipples( texture_t *image )
|
||||
{
|
||||
gl_texture_t *glt;
|
||||
uint32_t *pixels;
|
||||
int wbits, wmask, wshft;
|
||||
|
||||
// discard unuseful textures
|
||||
if( !r_ripple.value || image->width > RIPPLES_CACHEWIDTH || image->width != image->height )
|
||||
{
|
||||
GL_Bind( XASH_TEXTURE0, image->gl_texturenum );
|
||||
return;
|
||||
}
|
||||
|
||||
glt = R_GetTexture( image->gl_texturenum );
|
||||
if( !glt || !glt->original || !glt->original->buffer || !FBitSet( glt->flags, TF_EXPAND_SOURCE ))
|
||||
{
|
||||
GL_Bind( XASH_TEXTURE0, image->gl_texturenum );
|
||||
return;
|
||||
}
|
||||
|
||||
GL_Bind( XASH_TEXTURE0, g_ripple.rippletexturenum );
|
||||
|
||||
// no updates this frame
|
||||
if( !g_ripple.update && image->gl_texturenum == g_ripple.gl_texturenum )
|
||||
return;
|
||||
|
||||
g_ripple.gl_texturenum = image->gl_texturenum;
|
||||
if( r_ripple.value == 1.0f )
|
||||
{
|
||||
g_ripple.texturescale = Q_max( 1.0f, image->width / 64.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ripple.texturescale = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
pixels = (uint32_t *)glt->original->buffer;
|
||||
wbits = MostSignificantBit( image->width );
|
||||
wshft = 7 - wbits;
|
||||
wmask = image->width - 1;
|
||||
|
||||
for( int y = 0; y < image->height; y++ )
|
||||
{
|
||||
int ry = y << ( 7 + wshft );
|
||||
|
||||
for( int x = 0; x < image->width; x++ )
|
||||
{
|
||||
int rx = x << wshft;
|
||||
int val = g_ripple.curbuf[ry + rx] >> 4;
|
||||
|
||||
int py = (y - val) & wmask;
|
||||
int px = (x + val) & wmask;
|
||||
int p = ( py << wbits ) + px;
|
||||
|
||||
g_ripple.texture[(y << wbits) + x] = pixels[p];
|
||||
}
|
||||
}
|
||||
|
||||
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, image->width, image->width, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, g_ripple.texture );
|
||||
}
|
||||
|
||||
@@ -956,7 +956,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||
model_t *model;
|
||||
vec3_t delta;
|
||||
|
||||
model = gEngfuncs.pfnGetModelByIndex( pbeam->modelIndex );
|
||||
model = CL_ModelHandle( pbeam->modelIndex );
|
||||
SetBits( pbeam->flags, FBEAM_ISACTIVE );
|
||||
|
||||
if( !model || model->type != mod_sprite )
|
||||
@@ -1159,7 +1159,7 @@ passed through this
|
||||
*/
|
||||
static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed )
|
||||
{
|
||||
model_t *sprite = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
model_t *sprite = CL_ModelHandle( modelIndex );
|
||||
|
||||
if( !sprite ) return;
|
||||
|
||||
|
||||
@@ -949,7 +949,7 @@ void R_RenderWorld (void)
|
||||
c_drawnode=0;
|
||||
|
||||
// auto cycle the world frame for texture animation
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex(0);
|
||||
RI.currententity = CL_GetEntityByIndex(0);
|
||||
//RI.currententity->frame = (int)(gpGlobals->time*2);
|
||||
|
||||
VectorCopy (RI.vieworg, tr.modelorg);
|
||||
|
||||
@@ -273,9 +273,15 @@ void Mod_UnloadTextures( model_t *mod )
|
||||
}
|
||||
}
|
||||
|
||||
void GAME_EXPORT R_ProcessEntData( qboolean allocate )
|
||||
void GAME_EXPORT R_ProcessEntData( qboolean allocate, cl_entity_t *entities, unsigned int max_entities )
|
||||
{
|
||||
tr.entities = entities;
|
||||
tr.max_entities = max_entities;
|
||||
}
|
||||
|
||||
static void GAME_EXPORT R_Flush( unsigned int flags )
|
||||
{
|
||||
// stub
|
||||
}
|
||||
|
||||
// stubs
|
||||
@@ -425,6 +431,7 @@ ref_interface_t gReffuncs =
|
||||
R_AddEntity,
|
||||
CL_AddCustomBeam,
|
||||
R_ProcessEntData,
|
||||
R_Flush,
|
||||
|
||||
R_ShowTextures,
|
||||
|
||||
|
||||
@@ -774,14 +774,14 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
|
||||
|
||||
if( entityIndex > 0 )
|
||||
{
|
||||
ent = gEngfuncs.GetEntityByIndex( entityIndex );
|
||||
ent = CL_GetEntityByIndex( entityIndex );
|
||||
|
||||
if( modelIndex > 0 ) model = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
else if( ent != NULL ) model = gEngfuncs.pfnGetModelByIndex( ent->curstate.modelindex );
|
||||
if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
|
||||
else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
|
||||
else return;
|
||||
}
|
||||
else if( modelIndex > 0 )
|
||||
model = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
model = CL_ModelHandle( modelIndex );
|
||||
else model = WORLDMODEL;
|
||||
|
||||
if( !model ) return;
|
||||
|
||||
@@ -1118,7 +1118,7 @@ void D_SolidSurf (surf_t *s)
|
||||
{
|
||||
if( alphaspans )
|
||||
return;
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex(0); //r_worldentity;
|
||||
RI.currententity = CL_GetEntityByIndex(0); //r_worldentity;
|
||||
tr.modelviewIdentity = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ void R_PushDlights( void )
|
||||
|
||||
tr.dlightframecount = tr.framecount;
|
||||
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
|
||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||
if( RI.currententity )
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
|
||||
|
||||
@@ -41,14 +41,9 @@ typedef int fixed16_t;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define WORLD (gEngfuncs.GetWorld())
|
||||
#define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
|
||||
#define MOVEVARS (gEngfuncs.pfnGetMoveVars())
|
||||
|
||||
// make mod_ref.h?
|
||||
#define LM_SAMPLE_SIZE 16
|
||||
|
||||
|
||||
extern poolhandle_t r_temppool;
|
||||
|
||||
#define BLOCK_SIZE tr.block_size // lightmap blocksize
|
||||
@@ -298,6 +293,15 @@ typedef struct
|
||||
int sample_size;
|
||||
uint sample_bits;
|
||||
qboolean map_unload;
|
||||
|
||||
// get from engine
|
||||
cl_entity_t *entities;
|
||||
movevars_t *movevars;
|
||||
model_t **models;
|
||||
color24 *palette;
|
||||
cl_entity_t *viewent;
|
||||
|
||||
uint max_entities;
|
||||
} gl_globals_t;
|
||||
|
||||
typedef struct
|
||||
@@ -672,6 +676,21 @@ void TriBrightness( float brightness );
|
||||
#define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm)
|
||||
#define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( (parm), 0 )
|
||||
|
||||
//
|
||||
// helper funcs
|
||||
//
|
||||
static inline cl_entity_t *CL_GetEntityByIndex( int index )
|
||||
{
|
||||
return &tr.entities[index];
|
||||
}
|
||||
|
||||
static inline model_t *CL_ModelHandle( int index )
|
||||
{
|
||||
return tr.models[index];
|
||||
}
|
||||
|
||||
#define WORLDMODEL (tr.models[1])
|
||||
|
||||
extern ref_api_t gEngfuncs;
|
||||
extern ref_globals_t *gpGlobals;
|
||||
|
||||
|
||||
@@ -425,7 +425,7 @@ R_GetFarClip
|
||||
static float R_GetFarClip( void )
|
||||
{
|
||||
if( WORLDMODEL && RI.drawWorld )
|
||||
return MOVEVARS->zmax * 1.73f;
|
||||
return tr.movevars->zmax * 1.73f;
|
||||
return 2048.0f;
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ void R_RotateForEntity( cl_entity_t *e )
|
||||
#if 0
|
||||
float scale = 1.0f;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) )
|
||||
if( e == CL_GetEntityByIndex( 0 ) )
|
||||
{
|
||||
R_LoadIdentity();
|
||||
return;
|
||||
@@ -567,7 +567,7 @@ void R_TranslateForEntity( cl_entity_t *e )
|
||||
#if 0
|
||||
float scale = 1.0f;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) )
|
||||
if( e == CL_GetEntityByIndex( 0 ) )
|
||||
{
|
||||
R_LoadIdentity();
|
||||
return;
|
||||
@@ -784,7 +784,7 @@ void R_DrawEntitiesOnList( void )
|
||||
//d_aflatcolor = 0;
|
||||
tr.blend = 1.0f;
|
||||
// GL_CheckForErrors();
|
||||
//RI.currententity = gEngfuncs.GetEntityByIndex(0);
|
||||
//RI.currententity = CL_GetEntityByIndex(0);
|
||||
d_pdrawspans = R_PolysetFillSpans8;
|
||||
GL_SetRenderMode(kRenderNormal);
|
||||
// first draw solid entities
|
||||
@@ -815,7 +815,7 @@ void R_DrawEntitiesOnList( void )
|
||||
extern void (*d_pdrawspans)(void *);
|
||||
extern void R_PolysetFillSpans8 ( void * );
|
||||
d_pdrawspans = R_PolysetFillSpans8;
|
||||
//RI.currententity = gEngfuncs.GetEntityByIndex(0);
|
||||
//RI.currententity = CL_GetEntityByIndex(0);
|
||||
R_AliasSetUpTransform();
|
||||
image_t *image = R_GetTexture(GL_LoadTexture("gfx/env/desertbk", NULL, 0, 0));
|
||||
r_affinetridesc.pskin = image->pixels[0];
|
||||
@@ -1938,6 +1938,12 @@ qboolean GAME_EXPORT R_Init( void )
|
||||
return false;
|
||||
}
|
||||
|
||||
// see R_ProcessEntData for tr.entities initialization
|
||||
tr.models = gEngfuncs.pfnGetModels();
|
||||
tr.movevars = gEngfuncs.pfnGetMoveVars();
|
||||
tr.palette = gEngfuncs.CL_GetPaletteColor();
|
||||
tr.viewent = gEngfuncs.GetViewModel();
|
||||
|
||||
R_InitBlit( glblit );
|
||||
|
||||
R_InitImages();
|
||||
|
||||
@@ -49,7 +49,7 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
||||
{
|
||||
particle_t *p;
|
||||
vec3_t right, up;
|
||||
color24 *pColor;
|
||||
color24 color;
|
||||
int alpha;
|
||||
float size;
|
||||
|
||||
@@ -84,17 +84,17 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
||||
VectorScale( RI.cull_vup, size, up );
|
||||
|
||||
p->color = bound( 0, p->color, 255 );
|
||||
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
|
||||
color = tr.palette[p->color];
|
||||
|
||||
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
|
||||
if( alpha > 255 || p->type == pt_static )
|
||||
alpha = 255;
|
||||
|
||||
//TriColor4ub( gEngfuncs.LightToTexGamma( pColor->r ),
|
||||
// gEngfuncs.LightToTexGamma( pColor->g ),
|
||||
// gEngfuncs.LightToTexGamma( pColor->b ), alpha );
|
||||
//TriColor4ub( gEngfuncs.LightToTexGamma( color.r ),
|
||||
// gEngfuncs.LightToTexGamma( color.g ),
|
||||
// gEngfuncs.LightToTexGamma( color.b ), alpha );
|
||||
//TriBrightness( alpha / 255.0f );
|
||||
_TriColor4f(1.0f*alpha/255/255*pColor->r,1.0f*alpha/255/255*pColor->g,1.0f*alpha/255/255* pColor->b,1.0f );
|
||||
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
|
||||
|
||||
TriBegin( TRI_QUADS );
|
||||
TriTexCoord2f( 0.0f, 1.0f );
|
||||
@@ -194,7 +194,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
||||
//pglDisable( GL_ALPHA_TEST );
|
||||
//pglDepthMask( GL_FALSE );
|
||||
|
||||
gravity = frametime * MOVEVARS->gravity;
|
||||
gravity = frametime * tr.movevars->gravity;
|
||||
scale = 1.0 - (frametime * 0.9);
|
||||
if( scale < 0.0f ) scale = 0.0f;
|
||||
|
||||
@@ -211,7 +211,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
||||
{
|
||||
vec3_t verts[4], tmp2;
|
||||
vec3_t tmp, normal;
|
||||
color24 *pColor;
|
||||
color24 color;
|
||||
short alpha = p->packedColor;
|
||||
|
||||
// Transform point into screen space
|
||||
@@ -242,9 +242,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
||||
p->color = 0;
|
||||
}
|
||||
|
||||
pColor = &gTracerColors[p->color];
|
||||
//TriColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor );
|
||||
_TriColor4f(1.0f*alpha/255/255*pColor->r,1.0f*alpha/255/255*pColor->g,1.0f*alpha/255/255* pColor->b,1.0f );
|
||||
color = gTracerColors[p->color];
|
||||
//TriColor4ub( color.r, color.g, color.b, p->packedColor );
|
||||
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
|
||||
|
||||
|
||||
TriBegin( TRI_QUADS );
|
||||
|
||||
@@ -895,7 +895,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
||||
{
|
||||
cl_entity_t *parent;
|
||||
|
||||
parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment );
|
||||
parent = CL_GetEntityByIndex( e->curstate.aiment );
|
||||
|
||||
if( parent && parent->model )
|
||||
{
|
||||
|
||||
@@ -185,7 +185,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e )
|
||||
{
|
||||
if( cl_righthand && cl_righthand->value > 0 )
|
||||
{
|
||||
if( e == gEngfuncs.GetViewModel() )
|
||||
if( e == tr.viewent )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ pfnGetViewEntity
|
||||
*/
|
||||
static cl_entity_t *pfnGetViewEntity( void )
|
||||
{
|
||||
return gEngfuncs.GetViewModel();
|
||||
return tr.viewent;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1846,7 +1846,7 @@ void R_StudioRenderShadow( int iSprite, float *p1, float *p2, float *p3, float *
|
||||
if( !p1 || !p2 || !p3 || !p4 )
|
||||
return;
|
||||
|
||||
if( TriSpriteTexture( gEngfuncs.pfnGetModelByIndex( iSprite ), 0 ))
|
||||
if( TriSpriteTexture( CL_ModelHandle( iSprite ), 0 ))
|
||||
{
|
||||
TriRenderMode( kRenderTransAlpha );
|
||||
_TriColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
@@ -2246,7 +2246,7 @@ static void R_StudioDrawAbsBBox( void )
|
||||
int i;
|
||||
|
||||
// looks ugly, skip
|
||||
if( RI.currententity == gEngfuncs.GetViewModel() )
|
||||
if( RI.currententity == tr.viewent )
|
||||
return;
|
||||
|
||||
if( !R_StudioComputeBBox( p ))
|
||||
@@ -2384,13 +2384,8 @@ R_StudioSetRemapColors
|
||||
*/
|
||||
static void R_StudioSetRemapColors( int newTop, int newBottom )
|
||||
{
|
||||
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom );
|
||||
|
||||
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
|
||||
{
|
||||
gEngfuncs.CL_UpdateRemapInfo( RI.currententity, newTop, newBottom );
|
||||
if( gEngfuncs.CL_EntitySetRemapColors( RI.currententity, RI.currentmodel, newTop, newBottom ))
|
||||
m_fDoRemap = true;
|
||||
}
|
||||
}
|
||||
|
||||
void R_StudioResetPlayerModels( void )
|
||||
@@ -3137,7 +3132,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
||||
// copy attachments into global entity array
|
||||
if( RI.currententity->index > 0 )
|
||||
{
|
||||
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
|
||||
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
|
||||
}
|
||||
}
|
||||
@@ -3180,7 +3175,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
||||
if( pplayer->weaponmodel )
|
||||
{
|
||||
cl_entity_t saveent = *RI.currententity;
|
||||
model_t *pweaponmodel = gEngfuncs.pfnGetModelByIndex( pplayer->weaponmodel );
|
||||
model_t *pweaponmodel = CL_ModelHandle( pplayer->weaponmodel );
|
||||
|
||||
m_pStudioHeader = (studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, pweaponmodel );
|
||||
|
||||
@@ -3266,7 +3261,7 @@ static int R_StudioDrawModel( int flags )
|
||||
// copy attachments into global entity array
|
||||
if( RI.currententity->index > 0 )
|
||||
{
|
||||
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
|
||||
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
|
||||
}
|
||||
}
|
||||
@@ -3335,7 +3330,7 @@ void R_DrawStudioModel( cl_entity_t *e )
|
||||
{
|
||||
if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
|
||||
{
|
||||
cl_entity_t *parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment );
|
||||
cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment );
|
||||
|
||||
if( parent && parent->model && parent->model->type == mod_studio )
|
||||
{
|
||||
@@ -3371,7 +3366,7 @@ void R_RunViewmodelEvents( void )
|
||||
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
||||
return;
|
||||
|
||||
RI.currententity = gEngfuncs.GetViewModel();
|
||||
RI.currententity = tr.viewent;
|
||||
|
||||
if( !RI.currententity->model || RI.currententity->model->type != mod_studio )
|
||||
return;
|
||||
@@ -3393,7 +3388,7 @@ R_GatherPlayerLight
|
||||
*/
|
||||
void R_GatherPlayerLight( void )
|
||||
{
|
||||
cl_entity_t *view = gEngfuncs.GetViewModel();
|
||||
cl_entity_t *view = tr.viewent;
|
||||
colorVec c;
|
||||
|
||||
tr.ignore_lightgamma = true;
|
||||
@@ -3409,7 +3404,7 @@ R_DrawViewModel
|
||||
*/
|
||||
void R_DrawViewModel( void )
|
||||
{
|
||||
cl_entity_t *view = gEngfuncs.GetViewModel();
|
||||
cl_entity_t *view = tr.viewent;
|
||||
|
||||
R_GatherPlayerLight();
|
||||
|
||||
@@ -3610,7 +3605,7 @@ void Mod_StudioUnloadTextures( void *data )
|
||||
|
||||
static model_t *pfnModelHandle( int modelindex )
|
||||
{
|
||||
return gEngfuncs.pfnGetModelByIndex( modelindex );
|
||||
return CL_ModelHandle( modelindex );
|
||||
}
|
||||
|
||||
static void *pfnMod_CacheCheck( struct cache_user_s *c )
|
||||
|
||||
@@ -16,7 +16,7 @@ build_engine()
|
||||
if [ "$APP" = "xashds" ]; then
|
||||
./waf configure -T release -d --enable-tests || die_configure
|
||||
elif [ "$APP" = "xash3d-fwgs" ]; then
|
||||
./waf configure -T release --enable-stb --enable-utils --enable-gl4es --enable-gles1 --enable-gles2 --enable-tests || die_configure
|
||||
./waf configure -T release --enable-utils --enable-gl4es --enable-gles1 --enable-gles2 --enable-tests || die_configure
|
||||
else
|
||||
die
|
||||
fi
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
export ANDROID_SDK_HOME=$GITHUB_WORKSPACE/sdk
|
||||
export ANDROID_NDK_HOME=$ANDROID_SDK_HOME/ndk-bundle
|
||||
unset ANDROID_SDK_ROOT
|
||||
export JAVA_HOME=$GITHUB_WORKSPACE/jdk-17.0.7+7
|
||||
export ANDROID_HOME=$GITHUB_WORKSPACE/sdk
|
||||
export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/tools/bin
|
||||
|
||||
pushd android
|
||||
if [[ "$GH_CPU_ARCH" == "32" ]]; then
|
||||
export ARCHS="armeabi armeabi-v7a x86"
|
||||
elif [[ "$GH_CPU_ARCH" == "64" ]]; then
|
||||
export ARCHS="aarch64 x86_64"
|
||||
elif [[ "$GH_CPU_ARCH" == "32&64" ]]; then
|
||||
export ARCHS="armeabi armeabi-v7a x86 aarch64 x86_64"
|
||||
fi
|
||||
|
||||
sh compile.sh release
|
||||
./gradlew assembleContinuous
|
||||
|
||||
pushd app/build/outputs/apk/continuous
|
||||
|
||||
$ANDROID_HOME/build-tools/34.0.0/apksigner sign --ks $GITHUB_WORKSPACE/android/debug.keystore --ks-key-alias androiddebugkey \
|
||||
--ks-pass pass:android --key-pass pass:android --out app-continuous-signed.apk app-continuous-unsigned.apk
|
||||
|
||||
popd
|
||||
popd
|
||||
|
||||
mkdir -p artifacts/
|
||||
|
||||
if [[ "$GH_CPU_ARCH" == "64" ]]; then
|
||||
mv android/xashdroid.apk artifacts/xashdroid-64.apk
|
||||
else
|
||||
mv android/xashdroid.apk artifacts/xashdroid-32.apk
|
||||
fi
|
||||
mv android/app/build/outputs/apk/continuous/app-continuous-signed.apk artifacts/xash3d-fwgs-android.apk
|
||||
|
||||
@@ -41,7 +41,7 @@ make -C libsolder install || die
|
||||
echo "Building engine..."
|
||||
|
||||
./waf configure -T release --nswitch || die_configure
|
||||
./waf build install --destdir=pkgtemp/xash3d || die
|
||||
./waf build install --destdir=pkgtemp/xash3d -v || die
|
||||
|
||||
echo "Building HLSDK..."
|
||||
|
||||
|
||||
@@ -1,38 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Download HLSDK"
|
||||
|
||||
cd $GITHUB_WORKSPACE
|
||||
git clone --depth 1 --recursive https://github.com/FWGS/hlsdk-xash3d -b mobile_hacks hlsdk || exit 1
|
||||
|
||||
echo "Download and unpack Android SDK"
|
||||
echo "Download JDK 17"
|
||||
wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.7%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.7_7.tar.gz -qO jdk.tar.gz || exit 1
|
||||
tar -xzf jdk.tar.gz
|
||||
export JAVA_HOME=$GITHUB_WORKSPACE/jdk-17.0.7+7
|
||||
export PATH=$PATH:$JAVA_HOME/bin
|
||||
|
||||
echo "Download hlsdk-portable"
|
||||
git clone --depth 1 --recursive https://github.com/FWGS/hlsdk-portable -b mobile_hacks hlsdk || exit 1
|
||||
|
||||
echo "Download Android SDK"
|
||||
mkdir -p sdk || exit 1
|
||||
pushd sdk
|
||||
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip -qO sdk.zip > /dev/null || exit 1
|
||||
wget https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -qO sdk.zip || exit 1
|
||||
unzip -q sdk.zip || exit 1
|
||||
mv cmdline-tools tools
|
||||
mkdir -p cmdline-tools
|
||||
mv tools cmdline-tools/tools
|
||||
unset ANDROID_SDK_ROOT
|
||||
export ANDROID_HOME=$GITHUB_WORKSPACE/sdk
|
||||
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/tools/bin
|
||||
popd
|
||||
|
||||
echo "Download all needed tools and NDK"
|
||||
yes | sdk/tools/bin/sdkmanager --licenses > /dev/null 2>/dev/null # who even reads licenses? :)
|
||||
sdk/tools/bin/sdkmanager --install build-tools\;29.0.1 platform-tools platforms\;android-29 > /dev/null 2>/dev/null
|
||||
wget https://dl.google.com/android/repository/android-ndk-r25-linux.zip -qO ndk.zip > /dev/null || exit 1
|
||||
unzip -q ndk.zip || exit 1
|
||||
mv android-ndk-r25 sdk/ndk-bundle || exit 1
|
||||
echo "Download all needed tools and Android NDK"
|
||||
yes | sdkmanager --licenses > /dev/null 2>/dev/null # who even reads licenses? :)
|
||||
sdkmanager --install build-tools\;34.0.0 platform-tools platforms\;android-34 ndk\;26.0.10792818
|
||||
|
||||
echo "Download Xash3D FWGS Android source"
|
||||
git clone --depth 1 https://github.com/FWGS/xash3d-android-project -b waf android || exit 1
|
||||
pushd android
|
||||
echo "Download Xash3D FWGS Android source code"
|
||||
git clone --depth 1 --recursive https://github.com/Velaron/xash3d-android-project -b gradle android || exit 1
|
||||
pushd android/app/src/main/cpp
|
||||
|
||||
mv xash3d-fwgs xash3d-fwgs-sub
|
||||
ln -s $GITHUB_WORKSPACE xash3d-fwgs
|
||||
echo "Installed Xash3D FWGS source symlink"
|
||||
|
||||
mv hlsdk-xash3d hlsdk-xash3d-sub
|
||||
ln -s $GITHUB_WORKSPACE/hlsdk hlsdk-xash3d
|
||||
echo "Installed HLSDK source symlink"
|
||||
|
||||
mv xash-extras xash-extras-sub
|
||||
ln -s $GITHUB_WORKSPACE/xash-extras xash-extras
|
||||
echo "Installed xash-extras symlink"
|
||||
mv hlsdk-portable hlsdk-portable-sub
|
||||
ln -s $GITHUB_WORKSPACE/hlsdk hlsdk-portable
|
||||
echo "Installed hlsdk-portable source symlink"
|
||||
|
||||
popd
|
||||
|
||||
@@ -30,7 +30,7 @@ compiler_optimizations.CFLAGS['gottagofast'] = {
|
||||
}
|
||||
'''
|
||||
|
||||
VALID_BUILD_TYPES = ['fastnative', 'fast', 'release', 'debug', 'sanitize', 'msan', 'none']
|
||||
VALID_BUILD_TYPES = ['fastnative', 'fast', 'humanrights', 'debug', 'sanitize', 'msan', 'none']
|
||||
|
||||
LINKFLAGS = {
|
||||
'common': {
|
||||
@@ -75,7 +75,7 @@ CFLAGS = {
|
||||
'clang': ['-Ofast', '-march=native'],
|
||||
'default': ['-O3']
|
||||
},
|
||||
'release': {
|
||||
'humanrights': {
|
||||
'msvc': ['/O2', '/Zi'],
|
||||
'owcc': ['-O3', '-foptimize-sibling-calls', '-fomit-leaf-frame-pointer', '-fomit-frame-pointer', '-fschedule-insns', '-funsafe-math-optimizations', '-funroll-loops', '-frerun-optimizer', '-finline-functions', '-finline-limit=512', '-fguess-branch-probability', '-fno-strict-aliasing', '-floop-optimize'],
|
||||
'gcc': ['-O3', '-fno-semantic-interposition'],
|
||||
@@ -119,7 +119,7 @@ POLLY_CFLAGS = {
|
||||
def options(opt):
|
||||
grp = opt.add_option_group('Compiler optimization options')
|
||||
|
||||
grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default='release',
|
||||
grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default='humanrights',
|
||||
help = 'build type: debug, release or none(custom flags)')
|
||||
|
||||
grp.add_option('--enable-lto', action = 'store_true', dest = 'LTO', default = False,
|
||||
@@ -131,6 +131,11 @@ def options(opt):
|
||||
def configure(conf):
|
||||
conf.start_msg('Build type')
|
||||
|
||||
# legacy naming for default release build
|
||||
# https://chaos.social/@karolherbst/111340511652012860
|
||||
if conf.options.BUILD_TYPE == 'release':
|
||||
conf.options.BUILD_TYPE = 'humanrights'
|
||||
|
||||
if not conf.options.BUILD_TYPE in VALID_BUILD_TYPES:
|
||||
conf.end_msg(conf.options.BUILD_TYPE, color='RED')
|
||||
conf.fatal('Invalid build type. Valid are: %s' % ', '.join(VALID_BUILD_TYPES))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user