Compare commits

..

6 Commits

Author SHA1 Message Date
Alibek Omarov
8c9b62cb03 Documentation: gameinfo: add a note about liblist.gam and gameinfo.txt changes 2025-01-07 10:10:25 +03:00
Alibek Omarov
9ff6eed0bf filesystem: wscript: check d_type field in struct dirent, as this is an extension and some supported ports (like psvita) don't have it 2025-01-07 10:10:18 +03:00
Alibek Omarov
b6196c3c95 filesystem: re-enable folder check for array returned by listdirectory with dirs_only set to true
According to glibc manual, not all filesystems support it and some might return DT_UNKNOWN.
2025-01-07 10:10:18 +03:00
Alibek Omarov
1ee2186f72 filesystem: massively rework how scanning game directories work
* No more conversion from liblist.gam to gameinfo.txt. We are using liblist.gam directly now.
  gameinfo.txt being native format to Xash3D not only remains, it takes priority over liblist.gam.
* Quake game directories now don't receive autogenerated gameinfo.txt.
* Empty directories don't get gameinfo.txt either, finally making it easier to support HD addon folders.
* If user still wishes to generate gameinfo.txt, there is now command fs_make_gameinfo that creates
  gameinfo.txt for currently running game.
* No more creating empty folders for RoDir. They are now created on demand.
2025-01-07 10:10:18 +03:00
Alibek Omarov
6099d5eadd wscript: fix bsp2 build bruh 2025-01-07 08:34:43 +03:00
Alibek Omarov
3d68e13585 filesystem: add utility function FS_CheckForQuakePak that parses Quake PAK file and looks for specific files in it's root
Used to properly detect Quake game dirs.
2025-01-07 07:55:43 +03:00
73 changed files with 763 additions and 1570 deletions

View File

@@ -66,7 +66,7 @@ jobs:
targetos: apple
targetarch: amd64
env:
SDL_VERSION: 2.30.11
SDL_VERSION: 2.30.10
GH_CPU_ARCH: ${{ matrix.targetarch }}
GH_CROSSCOMPILING: ${{ matrix.cross }}
steps:

View File

@@ -1,5 +0,0 @@
# Welcome to the GoldSource API docs
This documentation is an attempt on explaining inner workings of Valve's Half-Life (R) engine, also known as GoldSource, from programmer's perspective. A deep knowledge of Quake (NQ, QW and Q2) engines is required.
Everything discussed here is it's author assumption based on studying Xash3D source code and reverse engineering Half-Life mods. Xash3D API extensions is out of scope of this document and will be explained separately.

View File

@@ -1,20 +0,0 @@
# Initializing client.dll
`client.dll` has got multiple ways of initialization during it's life but we will go through the simplest and the most common route here.
Here we expect that reader has knowledge of loading dynamic shared objects on their platform. On Windows it's done through `LoadLibrary`/`GetProcAddress`/`FreeLibrary` functions, on POSIX-complaint systems it's done through `dlopen`/`dlsym`/`dlclose` functions.
## client.dll lifetime
`client.dll` is expected to be loaded during client initialization and unloaded on client shutdown. Essentially, in non-dedicated builds, it always exists during the engine lifetime. Judging by the API, it might look like `client.dll` might be safely unloaded and loaded again, for example for implementing classic `Change Game` functionality from WON versions of Half-Life, but in practice it's nearly impossible to do this clean in standard and portable manner. If you want to implement changing games, consider using `execv`-like functions.
## client.dll exported functions
The first thing you should do, is to acquire pointers to all exported functions, which you can find in the next chapter. Some of them are optional, and might not present in the `client.dll`, and will be labeled as such.
## client.dll initialization process
1. The first function you call is `Initialize` function, which lets `client.dll` to store a copy of an engine API functions.
2. Since SDK 2.0, `client.dll` have player movement code in it, which you must initialize through `HUD_PlayerMoveInit` function. `client.dll` might want to override player hulls, which can be grabbed with `HUD_GetHullBounds` function.
3. HUD functionality must be started up with `HUD_Init` function and can be de-initialized with `HUD_Shutdown` export function.
4. And finally, SDK 2.1 brings studio model renderer, which has separate set of API functions, which must be initialized with `HUD_GetStudioModelInterface` function.

View File

@@ -1,286 +0,0 @@
# List of client.dll exported functions
### `int Initialize( cl_enginefuncs_t *enginefuncs, int version )`
> [!IMPORTANT]
> This function is only called once.
Called after loading DLL and exports engine API to the `client.dll`.
* `enginefuncs` must be set to a pointer to a struct filled with engine function pointers, it will be described in next chapters.
* `version` must be always set to `7`. (HLSDK 1.0 uses version `6`, and is binary incompatible with `7`).
Return value: `0` on error, otherwise success.
### `void HUD_PlayerMoveInit( struct playermove_s *ppmove, int server )`
> [!IMPORTANT]
> This function is only called once.
Called on player movement prediction initialization, before HUD. In GoldSrc, engine only runs prediction loop, the players physics are implemented in `client.dll`.
* `ppmove` must be set to a pointer to a client instance of player movement structure, which also exports it's own API and will be discussed in the next chapters.
* `server` must be always set to `0` on client side.
This function is called only once.
### `void HUD_Init( void )`
> [!IMPORTANT]
> This function is only called once.
Called to initialize the HUD. At this moment engine should be ready to register new commands, console variables and user messages. No rendering or loading graphics done at this moment.
### `int HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )`
> [!IMPORTANT]
> This function is only called once.
This function is called after initializing HUD and exports studio model interface to the `client.dll`.
* `version` must be always set to `1`.
* `ppinterface` will be set by `client.dll` to a pointer to `r_studio_interface_s` structure.
* `pstudio` must be set to a pointer to `engine_studio_api_s` structure. The studio model interface will be discussed in the next chapters.
Return value: `0` on error, otherwise success.
### `void HUD_Shutdown( void )`
> [!IMPORTANT]
> This function is only called once.
Called at client shutdown.
### `int HUD_GetHullBounds( int hull, vec3_t mins, vec3_t maxs )`
> [!IMPORTANT]
> This function is only called once.
Called by the engine after `HUD_PlayerMoveInit` to let `client.dll` override hull bounds used for in player movement prediction.
* `hull` is the hull index (0: player standing, 1: player crouched, 2: point hull, 3: large hull).
* `mins` will contain hull mins.
* `maxs` will contain hull maxs.
Return value: if 0, don't override this hull and stop reading, non-zero means hull is valid _and_ there is more.
> [!NOTE]
> This function is broken in most implementations. It might return non-zero value, but don't write anything to the `mins` and `maxs` vectors, so be prepared to have some default values.
### `int HUD_VidInit( void )`
Called when client receives `svc_serverdata` message. It is called before any parsing of that message is done, thus the state is preserved from the previous connection. It lets `client.dll` to re-initialize graphics, if required. At this point, engine is expected to have video subsystem running, but no rendering is done here.
### `int HUD_Redraw( float flTime, int intermission )`
Called each frame to redraw the HUD. Only 2D is drawn here.
* `flTime` must be set to `cl.time`, i.e. synchronized with server.
* `intermission` must be set to `1` during intermission (set through `svc_intermission` message), otherwise it's set to `0`.
Return value: ignored.
### `void HUD_Reset( void )`
Called on demo recording or playback start and stop.
### `int HUD_UpdateClientData( client_data_t *cdata, float flTime )`
Called each frame after taking input.
* `cdata` contains pointer to `client_data_t` structure, populated by engine.
* `flTime` must be set to `cl.time`, i.e. synchronized with server.
Return value: if non-zero, will override engine viewangles and FOV value.
### `void HUD_PlayerMove( struct playermove_s *pmove, int server )`
When prediction is enabled, use this function to run player movement prediction. Note that this correlates to QW/Q2's prediction mechanism. It does not include weapon prediction.
* `pmove` is a pointer to playermove object
* `server` must be always set to `0`
### `char HUD_PlayerMoveTexture( char *name )`
Not used in the engine.
### `int HUD_ConnectionlessPacket( const netadr_t *from, const char *args, char *response_buffer, int *response_buffer_size )`
Called by the engine on unknown connectionless packets. Lets `client.dll` and `server.dll` have custom query protocol.
* `from` is set to network address where this packet is coming from.
* `args` raw network buffer, minus the connectionless packet header (0xFFFFFFFF).
* `response_buffer` set by `client.dll` if there is a response.
* `response_buffer_size` is initialized by the engine with buffer maximum size. Set by `client.dll` if there is a response.
Return value: non-zero if handled.
### `void HUD_Frame( double time )`
Called each frame after sending command to the remote server. No rendering is normally done in this function.
* `time` is the local delta time between previous and this frame (i.e. `host.frametime`)
### `void HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, usercmd_t *cmd, int runfuncs, double time, unsigned int random_seed )`
Always called after `HUD_PlayerMove`, even if movement prediction is disabled. Used for weapon prediction stuff.
* `from` is a pointer to `local_state_s` object of the previous predicted frame
* `to` is a pointer to `local_state_s` object of this current frame
* `cmd` is current user command
* `runfuncs` is set to `1` if this frame was never predicted before, and to `0` if it is being predicted again
* `random_seed` is set to `incoming_acknowledged` plus number of predicted frames starting with `1`. This way it's synchronized between client and server.
### `int HUD_Key_Event( int down, int key, const char *current_binding )`
Called on keyboard event.
* `down` is set to `1` if key is being pressed or set to `0` on being released.
* `key` is set to the key number. The key IDs are predefined.
* `current_binding` is set to a null-terminated string with commands bound to this key
Return value: `0` if `client.dll` wants engine to ignore that key.
### `int HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname )`
Called before adding entity to the rendering list.
* `type` is set to an entity type, see `entity_state_t::entityType`
* `ent` is a pointer to `cl_entity_t` object.
* `modelname` is a null-terminated string with that entity model name.
Return value: `0` if `client.dll` wants engine to not draw this entity.
### `void HUD_CreateEntities( void )`
Called each frame after all network entities (including players) are linked to let `client.dll` spawn client-side entities.
### `void HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *ent )`
Studio models have events tied to the frame, on which engine calls this function.
* `event` is a pointer to a studio event object
* `ent` is a pointer to a client entity object
### `void HUD_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client )`
When client processes entity updates, for local client it might be truncated, don't have enough precision, miss some critical info, so engine calls this function as `client.dll` might choose to use client data came from `svc_clientdata` message. Note that it is called on raw, non-interpolated networked entity state.
* `state` is a pointer to the local client entity state coming from the network
* `client` is a pointer to local client data object
### `void HUD_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src )`
When client processes entity updates, it calls this function for player entities as `client.dll` might want to override some data or fill the missing parts, but usually it just copies from `src` to `dst`.
* `src` is a target pointer to the player entity data (stored in frames, for example)
* `dst` is a source pointer to the player entity data coming from network
### `void HUD_TxferPredictionData( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const weapon_data_s *pwd )`
When client receives `svc_clientdata` message, this function is called before any parsing is done, so that the `client.dll` fills in data from prediction.
* `ps`, `pcd`, `wd` are pointers to current network frame data.
* `pps`, `ppcd`, `pwd` are pointers to predicted frame data.
### `void HUD_TempEntUpdate( double frametime, double client_time, double cl_gravity, TEMPENTITY **ppTempEntFree, TEMPENTITY **ppTempEntActive, int ( *AddVisibleEntity )( cl_entity_t *pEntity ), void ( *TempEntPlaySound)( TEMPENTITY *pTemp, float damp ))`
Called each frame after network entities are processed and after `HUD_CreateEntities`, to let `client.dll` process temporary entities logic.
* `frametime` is the delta between `cl.time` and `cl.oldtime`, i.e. server time.
* `client_time` is `cl.time`
* `gravity` is the synchronized gravity value from the server
* `ppTempEntFree` is a pointer to the head of linked list of free temp entities
* `ppTempEntActive` is a pointer to the head of linked list of active temp entities
* `AddVisibleEntity` is a pointer to function that lets `client.dll` add this entity to the rendering list.
* `TempEntPlaySound` is a pointer to function that's called by `client.dll` when temp entity needs to play predefined hit sound. The `damp` argument of this argument only makes sound to NOT play, if it's zero or negative.
### `void HUD_DrawNormalTriangles( void )`
Called each rendering frame to let `client.dll` draw custom solid triangles through TriAPI or direct OpenGL calls.
### `void HUD_DrawTransparentTriangles( void )`
Called each rendering frame to let `client.dll` draw custom transparent triangles through TriAPI or direct OpenGL calls.
### `struct cl_entity_s *HUD_GetUserEntity( int index )`
Called by engine when beam start/end indices are negative, thus allowing attaching beams to a temporary or client-only entity.
* `index` is the fixed up entity index, as beam start/end indices encode real entity index in low 12 bits (i.e. `beament_start & 0xFFF`).
### `void Demo_ReadBuffer( int size, unsigned char *buffer )`
Called by engine on demo playback, if `client.dll` saved some custom data on demo recording prior.
* `size` is the size of buffer in bytes
* `buffer` is the pointer to custom data stored by `client.dll` in demo
### `void CAM_Think( void )`
Called each frame before rendering starts to let `client.dll` run custom camera logic, like advanced thirdperson follow camera for example.
### `int CL_IsThirdPerson( void )`
Returns non-zero value if camera is in thirdperson mode, lets engine figure out whether add local client entity to the rendering list or not.
### `void CL_CameraOffset( vec3_t offset )`
Not used in the engine.
### `void CL_CreateMove( float frametime, usercmd_t *cmd, int active )`
Called when `usercmd_t` is being created to let `client.dll` record user commands before they are being sent over the network.
* `frametime` is the delta time between previous and current frames.
* `cmd` is the pointer to `usercmd_t` object, where player's intentions and impulses are added.
* `active` is set to `1` when client is finished signing on to the server (as movement commands are being sent even if client is not fully spawned yet).
### `void IN_ActivateMouse( void )`
Called from similarly named NQ/QW function.
### `void IN_DeactivateMouse( void )`
Called from similarly named NQ/QW function.
### `void IN_MouseEvent( int mstate )`
Called from similarly named NQ/QW function.
### `void IN_Accumulate( void )`
Called from similarly named NQ/QW function.
### `void IN_ClearStates( void )`
Called from similarly named NQ/QW function.
### `void V_CalcRefdef( struct ref_params_s *params )`
Called each frame before rendering starts. This is close to the similarly named function found in NQ/QW and lets `client.dll` to run custom view logic.
* `params` is the refdef parameters object. It is also used as return value and might request from the engine to not draw anything (by `onlyClientDraws` field) or to run this multiple times (by `nextview` field)
### `kbutton_t *KB_Find( const char *name )`
Called by engine to find extra keys and their state.
Only few are really used by the engine:
* `in_mlook` for mouse look
* `in_jlook` for joystick look
* `in_graph` for net_graph toggle
Return value: returns pointer to `kbutton_t` if found. `kbutton_t` structure matches the same structure that can be found in NQ and QW.
### `void HUD_DirectorMessage( int size, void *buf )`
> [!IMPORTANT]
> This function is optional.
Called to notify `client.dll` about an `svc_director` message. This feature is used for HLTV, though mods use it to spawn text messages or execute commands (bypassing `svc_stufftext` filter in old `client.dll`) but `svc_director` message structure isn't enforced by engine, so it in theory mods might modify it for their own needs.
* `size` is the size of the payload
* `buf` raw `svc_director` payload
### `void HUD_VoiceStatus( int entindex, qboolean talking )`
> [!IMPORTANT]
> This function is optional.
Called to notify `client.dll` about a client status of using voice chat.
* `entindex` an entity index (client index plus one, because zero is always world). When set to -1, notifies `client.dll` about local client recording. When set to -2, notifies `client.dll` about a loopback (i.e. local client's voice message was sent to server and received back)
* `talking` if true, this client is talking
### `void HUD_ChatInputPosition( int *x, int *y )`
> [!IMPORTANT]
> This function is optional.
When called, returns desired X and Y positions of chat box.

View File

@@ -1,9 +0,0 @@
# What is client.dll in GoldSource?
One of technical differences a programmer working with Quake engine might notice is the client.dll file. Historically, it appeared somewhere in between Alpha 0.52 and NetTest1 development and judging by Half-Life SDK 1.0 was meant to handle HUD rendering. The time moved forward, SDK 2.0 finalized `client.dll` API at version 7, added an in-game UI, custom input processing, player movement and weapon prediction, very basic rendering through TriAPI. SDK 2.1 added ability to re-define studio model rendering, and so on.
It somewhat resembles `cgame` module from Quake 3, but more crudely designed and sometimes feels like an afterthought, considering how many engine internal structures it exposes and the main point of incompatibilities with mods, which these days sometimes use `client.dll` as a way to inject custom rendering into the game.
In this document I will try to go through each step, letting you, dear reader, implement your own GoldSrc compatible API in your Quake fork, targetting vanilla Half-Life `client.dll` from latest update, which at the time of writing, is 25-th anniversary update.
Despite that we call it `client.dll`, since SDK 2.4 (unofficial naming, it's the first SDK Valve published on GitHub) it is considered portable and only has SDL2 and VGUI libraries in it's external dependences. It's only called this way to avoid possible misunderstandings with engine developers, who might interpret client as `cl_` prefixed part of Quake engine.

View File

@@ -1,120 +0,0 @@
# `client.dll` shared structs and enums
GoldSource exposes a lot of structs to `client.dll`. Some of them are specific to `client.dll` and only used for passing data between engine and client, some of them are used in the engine everywhere, but still exposed in the public SDK. However, many mods rely on internal structs as well, and I will try to shed light on them as well.
When implementing them in C, consider the default to 32-bit systems alignment of 4 bytes and ILP32 data type model.
This file won't have API structs, for that, there should be separate chapters.
## Enums
### Entity types enum
This enum has no real name.
| Value | Description |
|-------|-----------------|
| `0` | Normal entities |
| `1` | Players |
| `2` | Temp entities |
| `3` | Beams |
| `4` | Fragmented entities. |
### edict->solid
It matches QuakeWorld definition.
## `client_data_t`
Used only to pass data to `client.dll` through `HUD_UpdateClientData`.
| Type | Name | Description |
|----------|---------------|--------------------------------------------------------------|
| `vec3_t` | `origin` | Local client origin. Cannot be changed by `client.dll` here. |
| `vec3_t` | `viewangles` | Local client viewangles. This and next fields can be changed by `client.dll` |
| `int` | `iWeaponBits` | Bit vector of weapons held by client. |
| `float` | `fov` | Local client's field of view. |
## `netadr_t`
Matches Quake-2 structure with the similar name.
## `local_state_t`
Only consists of another structs. All of these structs are used to store prediction data, so one `local_state_t` for each predicted frame.
| Type | Name | Description |
|---------------------|---------------|--------------------------------------|
| `entity_state_t` | `playerstate` | Contains local player's entity state |
| `clientdata_t` | `client` | Additional information about local client. _Do not get confused with `client_data_t`, note the underscore._ |
| `weapon_data_t[64]` | `weapondata` | Array of 64 predictable weapons. |
## `entity_state_t`
This structure is similar to the one that can be found in QW, but contains much more data, though most of these fields are not used by the engine, but might be used by mods.
| Type | Name | Description |
|-------------|----------------|------------------------------------------------------|
| `int` | `entityType` | Entity type (see entity type enum above) |
| `int` | `number` | Index of this entity on the server |
| `float` | `msg_time` | Server time at which this entity had been updated |
| `int` | `messagenum` | `parsecount` at which this entity had been updated |
| `vec3_t` | `origin` | Non-interpolated entity position |
| `vec3_t` | `angles` | Non-interpolated entity angles |
| `int` | `modelindex` | Server model index |
| `int` | `sequence` | Model animation sequence |
| `int` | `frame` | Model animation frame |
| `int` | `colormap` | Texture's top and bottom colors, like Quake |
| `short` | `skin` | Texture number |
| `short` | `solid` | `edict->solid` enum |
| `int` | `effects` | Bitmask of entity effects |
| `float` | `scale` | Entity scale value |
| `byte` | `eflags` | |
| `int` | `eflags` | |
| `int` | `eflags` | |
| `color24` | `eflags` | |
| `int` | `eflags` | |
| `int` | `eflags` | |
| `float` | `eflags` | |
| `float` | `eflags` | |
| `int` | `eflags` | |
| `byte[4]` | `eflags` | |
| `byte[4]` | `eflags` | |
| `vec3_t` | `eflags` | |
| `vec3_t` | `eflags` | |
| `vec3_t` | `eflags` | |
| `vec3_t` | `maxs` | |
| `int` | `eflags` | |
| `int` | `eflags` | |
| `float` | `eflags` | |
| `float` | `eflags` | |
| `int` | `eflags` | |
| `int` | `eflags` | |
| `int` | `eflags` | |
| `qboolean` | `eflags` | |
| `int` | `eflags` | |
| `int` | `eflags` | |
| `vec3_t` | `eflags` | |
| `int` | `eflags` | |
| `int` | `eflags` | |
| `int` | `eflags` | |
| `int` | `eflags` | |
| `float` | `eflags` | |
| `float` | `eflags` | |
| `int` | `eflags` | |
| `vec3_t` | `eflags` | |
| `vec3_t` | `eflags` | |
| `float` | `eflags` | |
| `float` | `eflags` | |
| `int` | `iuser1` | Few more extra fields for mods |
| `int` | `iuser2` | |
| `int` | `iuser3` | |
| `int` | `iuser4` | |
| `float` | `fuser1` | |
| `float` | `fuser2` | |
| `float` | `fuser3` | |
| `float` | `fuser4` | |
| `vec3_t` | `vuser1` | |
| `vec3_t` | `vuser2` | |
| `vec3_t` | `vuser3` | |
| `vec3_t` | `vuser4` | |

View File

@@ -2,7 +2,7 @@
[![builds.sr.ht status](https://builds.sr.ht/~a1batross/xash3d-fwgs.svg)](https://builds.sr.ht/~a1batross/xash3d-fwgs?) [![GitHub Actions Status](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [![FreeBSD Build Status](https://img.shields.io/cirrus/github/FWGS/xash3d-fwgs?label=freebsd%20build)](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](http://fwgsdiscord.mentality.rip/) \
[![Download Stable](https://img.shields.io/badge/download-stable-yellow)](https://github.com/FWGS/xash3d-fwgs/releases/latest) [![Download Testing](https://img.shields.io/badge/downloads-testing-orange)](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous)
Xash3D ([pronounced](https://ipa-reader.com/?text=ks%C9%91%CA%82) `[ksɑʂ]`) FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
Xash3D (pronounced `[ksɑʂ]`) FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://www.moddb.com/engines/xash3d-engine) by Unkle Mike.

View File

@@ -30,18 +30,6 @@ public class XashActivity extends SDLActivity {
AndroidBug5497Workaround.assistActivity(this);
}
@Override
public void onDestroy()
{
super.onDestroy();
// Now that we don't exit from native code, we need to exit here, resetting
// application state (actually global variables that we don't cleanup on exit)
//
// When the issue with global variables will be resolved, remove that exit() call
System.exit(0);
}
@Override
protected String[] getLibraries() {
return new String[]{"SDL2", "xash"};

View File

@@ -16,6 +16,8 @@ GNU General Public License for more details.
#ifndef BSPFILE_H
#define BSPFILE_H
//#define SUPPORT_BSP2_FORMAT // allow to loading Darkplaces BSP2 maps (with broke binary compatibility)
/*
==============================================================================
@@ -63,6 +65,7 @@ BRUSH MODELS
#define MAX_MAP_CLIPNODES_BSP2 524288
// these limis not using by modelloader but only for displaying 'mapstats' correctly
#ifdef SUPPORT_BSP2_FORMAT
#define MAX_MAP_MODELS 2048 // embedded models
#define MAX_MAP_ENTSTRING 0x200000 // 2 Mb should be enough
#define MAX_MAP_PLANES 131072 // can be increased without problems
@@ -72,6 +75,18 @@ BRUSH MODELS
#define MAX_MAP_VERTS 524288 // can be increased without problems
#define MAX_MAP_FACES 262144 // can be increased without problems
#define MAX_MAP_MARKSURFACES 524288 // can be increased without problems
#else
// increased to match PrimeXT compilers
#define MAX_MAP_MODELS 1024 // embedded models
#define MAX_MAP_ENTSTRING 0x100000 // 1 Mb should be enough
#define MAX_MAP_PLANES 65536 // can be increased without problems
#define MAX_MAP_NODES 32767 // because negative shorts are leafs
#define MAX_MAP_CLIPNODES MAX_MAP_CLIPNODES_HLBSP // because negative shorts are contents
#define MAX_MAP_LEAFS 32767 // signed short limit
#define MAX_MAP_VERTS 65535 // unsigned short limit
#define MAX_MAP_FACES 65535 // unsigned short limit
#define MAX_MAP_MARKSURFACES 65535 // unsigned short limit
#endif
#define MAX_MAP_ENTITIES 8192 // network limit
#define MAX_MAP_TEXINFO MAX_MAP_FACES // in theory each face may have personal texinfo

View File

@@ -60,29 +60,26 @@ typedef struct
vec3_t position;
} mvertex_t;
typedef struct mclipnode32_s
typedef struct
{
int planenum;
int children[2]; // negative numbers are contents
} mclipnode32_t;
typedef struct mclipnode16_s
{
int planenum;
short children[2]; // negative numbers are contents
} mclipnode16_t;
int planenum;
#ifdef SUPPORT_BSP2_FORMAT
int children[2]; // negative numbers are contents
#else
short children[2]; // negative numbers are contents
#endif
} mclipnode_t;
// size is matched but representation is not
typedef struct medge32_s
typedef struct
{
#ifdef SUPPORT_BSP2_FORMAT
unsigned int v[2];
} medge32_t;
typedef struct medge16_s
{
#else
unsigned short v[2];
unsigned int cachededgeoffset;
} medge16_t;
#endif
} medge_t;
typedef struct texture_s
{
@@ -159,31 +156,13 @@ typedef struct mnode_s
// node specific
mplane_t *plane;
#if !XASH_64BIT
union
{
struct mnode_s *children_[2];
struct
{
// the ordering is important
int child_0_leaf : 1;
int child_0_off : 23;
int firstsurface_1 : 8;
int child_1_leaf : 1;
int child_1_off : 23;
int numsurfaces_1 : 8;
};
};
unsigned short firstsurface_0;
unsigned short numsurfaces_0;
struct mnode_s *children[2];
#ifdef SUPPORT_BSP2_FORMAT
int firstsurface;
int numsurfaces;
#else
// in 64-bit ABI this struct has 4 more bytes of padding, let's use it!
struct mnode_s *children_[2];
unsigned short firstsurface_0;
unsigned short numsurfaces_0;
unsigned short firstsurface_1;
unsigned short numsurfaces_1;
unsigned short firstsurface;
unsigned short numsurfaces;
#endif
} mnode_t;
@@ -224,6 +203,7 @@ typedef struct mleaf_s
int nummarksurfaces;
int cluster; // helper to acess to uncompressed visdata
byte ambient_sound_level[NUM_AMBIENTS];
} mleaf_t;
// surface extradata
@@ -311,11 +291,7 @@ struct msurface_s
typedef struct hull_s
{
union
{
mclipnode16_t *clipnodes16;
mclipnode32_t *clipnodes32;
};
mclipnode_t *clipnodes;
mplane_t *planes;
int firstclipnode;
int lastclipnode;
@@ -365,12 +341,7 @@ typedef struct model_s
mvertex_t *vertexes;
int numedges;
union
{
medge16_t *edges16;
medge32_t *edges32;
};
medge_t *edges;
int numnodes;
mnode_t *nodes;
@@ -385,11 +356,7 @@ typedef struct model_s
int *surfedges;
int numclipnodes;
union
{
mclipnode16_t *clipnodes16;
mclipnode32_t *clipnodes32;
};
mclipnode_t *clipnodes;
int nummarksurfaces;
msurface_t **marksurfaces;
@@ -583,68 +550,16 @@ typedef struct
#define ANIM_CYCLE 2
#define MOD_FRAMES 20
#define MAX_DEMOS 32
#define MAX_MOVIES 8
#define MAX_CDTRACKS 32
#define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client)
#define MAX_REQUESTS 64
STATIC_CHECK_SIZEOF( mnode_t, 52, 72 );
STATIC_CHECK_SIZEOF( mextrasurf_t, 324, 496 );
STATIC_CHECK_SIZEOF( decal_t, 60, 88 );
STATIC_CHECK_SIZEOF( mfaceinfo_t, 176, 304 );
// model flags (stored in model_t->flags)
#define MODEL_QBSP2 BIT( 28 ) // uses 32-bit types
// access functions
static inline mnode_t *node_child( const mnode_t *n, int side, const model_t *mod )
{
#if !XASH_64BIT
if( unlikely( mod->flags & MODEL_QBSP2 )) // MODEL_QBSP2
{
if( side == 0 )
{
if( n->child_0_leaf )
return (mnode_t *)(mod->leafs + n->child_0_off);
else
return (mnode_t *)(mod->nodes + n->child_0_off);
}
else
{
if( n->child_1_leaf )
return (mnode_t *)(mod->leafs + n->child_1_off);
else
return (mnode_t *)(mod->nodes + n->child_1_off);
}
}
return n->children_[side];
#else
return n->children_[side];
#endif
}
static inline void node_children( mnode_t *children[2], const mnode_t *n, const model_t *mod )
{
children[0] = node_child( n, 0, mod );
children[1] = node_child( n, 1, mod );
}
static inline int node_firstsurface( const mnode_t *n, const model_t *mod )
{
if( mod->flags & MODEL_QBSP2 )
return n->firstsurface_0 + ( n->firstsurface_1 << 16 );
else
return n->firstsurface_0;
}
static inline int node_numsurfaces( const mnode_t *n, const model_t *mod )
{
if( mod->flags & MODEL_QBSP2 )
return n->numsurfaces_0 + ( n->numsurfaces_1 << 16 );
else
return n->numsurfaces_0;
}
#endif//COM_MODEL_H

View File

@@ -153,7 +153,6 @@ static void CL_WriteErrorMessage( int current_count, sizebuf_t *msg )
FS_Write( fp, &cls.starting_count, sizeof( int ));
FS_Write( fp, &current_count, sizeof( int ));
FS_Write( fp, &cls.legacymode, sizeof( cls.legacymode ));
FS_Write( fp, MSG_GetData( msg ), MSG_GetMaxBytes( msg ));
FS_Close( fp );
@@ -169,7 +168,7 @@ list last 32 messages for debugging net troubleshooting
*/
void CL_WriteMessageHistory( void )
{
oldcmd_t *old;
oldcmd_t *old, *failcommand;
sizebuf_t *msg = &net_message;
int i, thecmd;
@@ -193,8 +192,9 @@ void CL_WriteMessageHistory( void )
thecmd++;
}
old = &cls_message_debug.oldcmd[thecmd];
Con_Printf( S_RED "BAD: " S_DEFAULT "%i %04i %s\n", old->frame_number, old->starting_offset, CL_MsgInfo( old->command ));
CL_WriteErrorMessage( old->starting_offset, msg );
failcommand = &cls_message_debug.oldcmd[thecmd];
Con_Printf( "BAD: %3i:%s\n", MSG_GetNumBytesRead( msg ) - 1, CL_MsgInfo( failcommand->command ));
if( host_developer.value >= DEV_EXTENDED )
CL_WriteErrorMessage( MSG_GetNumBytesRead( msg ) - 1, msg );
cls_message_debug.parsing = false;
}

View File

@@ -624,10 +624,11 @@ static void CL_ReadDemoUserCmd( qboolean discard )
if( !discard )
{
const usercmd_t nullcmd = { 0 };
usercmd_t nullcmd;
sizebuf_t buf;
demoangle_t *a;
memset( &nullcmd, 0, sizeof( nullcmd ));
MSG_Init( &buf, "UserCmd", data, sizeof( data ));
// a1ba: I have no proper explanation why

View File

@@ -127,10 +127,8 @@ static void R_SplitEntityOnNode( mnode_t *node )
}
// recurse down the contacted sides
if( sides & 1 )
R_SplitEntityOnNode( node_child( node, 0, cl.worldmodel ));
if( sides & 2 )
R_SplitEntityOnNode( node_child( node, 1, cl.worldmodel ));
if( sides & 1 ) R_SplitEntityOnNode( node->children[0] );
if( sides & 2 ) R_SplitEntityOnNode( node->children[1] );
}
/*

View File

@@ -2408,8 +2408,9 @@ CL_FindModelIndex
*/
static int GAME_EXPORT CL_FindModelIndex( const char *m )
{
char filepath[MAX_QPATH];
int i;
char filepath[MAX_QPATH];
static float lasttimewarn;
int i;
if( !COM_CheckString( m ))
return 0;
@@ -2426,6 +2427,13 @@ static int GAME_EXPORT CL_FindModelIndex( const char *m )
return i+1;
}
if( lasttimewarn < host.realtime )
{
// tell user about problem (but don't spam console)
Con_DPrintf( S_ERROR "Could not find index for model %s: not precached\n", filepath );
lasttimewarn = host.realtime + 1.0f;
}
return 0;
}

View File

@@ -147,6 +147,11 @@ qboolean CL_IsRecordDemo( void )
return cls.demorecording;
}
qboolean CL_IsTimeDemo( void )
{
return cls.timedemo;
}
qboolean CL_DisableVisibility( void )
{
return cls.envshot_disable_vis;
@@ -593,7 +598,7 @@ CL_CreateCmd
*/
static void CL_CreateCmd( void )
{
usercmd_t nullcmd = { 0 }, *cmd;
usercmd_t nullcmd, *cmd;
runcmd_t *pcmd;
qboolean active;
double accurate_ms;
@@ -645,6 +650,7 @@ static void CL_CreateCmd( void )
}
else
{
memset( &nullcmd, 0, sizeof( nullcmd ));
cmd = &nullcmd;
}
@@ -819,7 +825,7 @@ static void CL_WritePacket( void )
buf.pData[key] = CRC32_BlockSequence( &buf.pData[key + 1], size, cls.netchan.outgoing_sequence );
COM_Munge( &buf.pData[key + 1], Q_min( size, 255 ), cls.netchan.outgoing_sequence );
}
else if( !Host_IsLocalClient( ))
else
{
int size = MSG_GetRealBytesWritten( &buf ) - key - 1;
buf.pData[key] = CRC32_BlockSequence( &buf.pData[key + 1], size, cls.netchan.outgoing_sequence );
@@ -1755,8 +1761,8 @@ static size_t NONNULL CL_BuildMasterServerScanRequest( char *buf, size_t size, u
// let master know about client version
Info_SetValueForKey( info, "clver", XASH_VERSION, remaining );
Info_SetValueForKey( info, "nat", nat ? "1" : "0", remaining );
Info_SetValueForKey( info, "commit", g_buildcommit, remaining );
Info_SetValueForKey( info, "branch", g_buildbranch, remaining );
Info_SetValueForKey( info, "commit", Q_buildcommit(), remaining );
Info_SetValueForKey( info, "branch", Q_buildbranch(), remaining );
Info_SetValueForKey( info, "os", Q_buildos(), remaining );
Info_SetValueForKey( info, "arch", Q_buildarch(), remaining );

View File

@@ -534,7 +534,7 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
{
if( MSG_CheckOverflow( msg ))
{
Host_Error( "%s: overflow!\n", __func__ );
Host_Error( "CL_ParseServerMessage: overflow!\n" );
return;
}

View File

@@ -138,7 +138,10 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
switch( parm )
{
case PARM_BSP2_SUPPORTED:
#ifdef SUPPORT_BSP2_FORMAT
return 1;
#endif
return 0;
case PARAM_GAMEPAUSED:
return cl.paused;
case PARM_CLIENT_INGAME:

View File

@@ -567,54 +567,57 @@ R_FizzEffect
Create a fizz effect
==============
*/
void GAME_EXPORT R_FizzEffect( cl_entity_t *ent, int modelIndex, int density )
void GAME_EXPORT R_FizzEffect( cl_entity_t *pent, int modelIndex, int density )
{
const float base_time = cl.time - 0.1f;
model_t *mod = CL_ModelHandle( modelIndex );
vec3_t volume, mins, maxs;
vec2_t speed;
int i;
TEMPENTITY *pTemp;
int i, width, depth;
float angle, maxHeight, speed;
float xspeed, yspeed, zspeed;
vec3_t origin;
model_t *mod;
if( !ent || !ent->model || !modelIndex || !mod )
if( !pent || !pent->model || !modelIndex )
return;
VectorCopy( ent->model->mins, mins );
VectorCopy( ent->model->maxs, maxs );
if(( mod = CL_ModelHandle( modelIndex )) == NULL )
return;
if( ent->angles[1] != 0.0f )
{
const float base_speed = ( ent->curstate.rendercolor.b ? -1.0f : 1.0f ) * ( ent->curstate.rendercolor.r * 256.0f + ent->curstate.rendercolor.g );
SinCos( DEG2RAD( ent->angles[1] ), &speed[1], &speed[0] );
speed[0] *= base_speed;
speed[1] *= base_speed;
}
else speed[0] = speed[1] = 0.0f;
maxHeight = pent->model->maxs[2] - pent->model->mins[2];
width = pent->model->maxs[0] - pent->model->mins[0];
depth = pent->model->maxs[1] - pent->model->mins[1];
VectorSubtract( maxs, mins, volume );
speed = ( pent->curstate.rendercolor.r<<8 | pent->curstate.rendercolor.g );
if( pent->curstate.rendercolor.b )
speed = -speed;
angle = DEG2RAD( pent->angles[YAW] );
SinCos( angle, &yspeed, &xspeed );
xspeed *= speed;
yspeed *= speed;
for( i = 0; i <= density; i++ )
{
TEMPENTITY *tent;
vec3_t origin;
origin[0] = mod->mins[0] + COM_RandomLong( 0, width - 1 );
origin[1] = mod->mins[1] + COM_RandomLong( 0, depth - 1 );
origin[2] = mod->mins[2];
pTemp = CL_TempEntAlloc( origin, mod );
VectorCopy( mins, origin );
origin[0] += COM_RandomLong( 0, (int)volume[0] - 1 );
origin[1] += COM_RandomLong( 0, (int)volume[1] - 1 );
if ( !pTemp ) return;
if( !( tent = CL_TempEntAlloc( origin, mod )))
return;
pTemp->flags |= FTENT_SINEWAVE;
tent->x = origin[0];
tent->y = origin[1];
tent->die = base_time;
tent->flags |= FTENT_SINEWAVE;
tent->entity.curstate.rendermode = kRenderTransAlpha;
Vector2Copy( speed, tent->entity.baseline.origin );
pTemp->x = origin[0];
pTemp->y = origin[1];
tent->entity.baseline.origin[2] = COM_RandomLong( 80, 140 );
tent->die += volume[2] / tent->entity.baseline.origin[2];
tent->entity.curstate.frame = COM_RandomLong( 0, tent->frameMax );
tent->entity.curstate.scale = 1.0f / COM_RandomFloat( 2.0f, 5.0f );
zspeed = COM_RandomLong( 80, 140 );
VectorSet( pTemp->entity.baseline.origin, xspeed, yspeed, zspeed );
pTemp->die = cl.time + ( maxHeight / zspeed ) - 0.1f;
pTemp->entity.curstate.frame = COM_RandomLong( 0, pTemp->frameMax );
// Set sprite scale
pTemp->entity.curstate.scale = 1.0f / COM_RandomFloat( 2.0f, 5.0f );
pTemp->entity.curstate.rendermode = kRenderTransAlpha;
pTemp->entity.curstate.renderamt = 255;
}
}

View File

@@ -466,8 +466,8 @@ static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int show
R_DrawNodeConnection( x, y, x + scale, y + scale );
}
R_ShowTree_r( node_child( node, 1, cl.worldmodel ), x - scale, y + scale, downScale, shownodes, viewleaf );
R_ShowTree_r( node_child( node, 0, cl.worldmodel ), x + scale, y + scale, downScale, shownodes, viewleaf );
R_ShowTree_r( node->children[1], x - scale, y + scale, downScale, shownodes, viewleaf );
R_ShowTree_r( node->children[0], x + scale, y + scale, downScale, shownodes, viewleaf );
world.recursion_level--;
}
@@ -482,7 +482,7 @@ static void R_ShowTree( void )
return;
world.recursion_level = 0;
viewleaf = Mod_PointInLeaf( refState.vieworg, cl.worldmodel->nodes, cl.worldmodel );
viewleaf = Mod_PointInLeaf( refState.vieworg, cl.worldmodel->nodes );
ref.dllFuncs.TriRenderMode( kRenderTransTexture );

View File

@@ -266,7 +266,7 @@ static qboolean Touch_DumpConfig( const char *name, const char *profilename )
}
FS_Printf( f, "//=======================================================================\n");
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
FS_Printf( f, "//\t\t\ttouchscreen config\n" );
FS_Printf( f, "//=======================================================================\n" );
FS_Printf( f, "\ntouch_config_file \"%s\"\n", profilename );

View File

@@ -470,16 +470,16 @@ out_free:
* This is a stack of the clipnodes we have traversed
* "sides" indicates which side we went down each time
*/
static int node_stack[MAX_CLIPNODE_DEPTH];
static mclipnode_t *node_stack[MAX_CLIPNODE_DEPTH];
static int side_stack[MAX_CLIPNODE_DEPTH];
static uint node_stack_depth;
static void push_node( int nodenum, int side )
static void push_node( mclipnode_t *node, int side )
{
if( node_stack_depth == MAX_CLIPNODE_DEPTH )
Host_Error( "node stack overflow\n" );
node_stack[node_stack_depth] = nodenum;
node_stack[node_stack_depth] = node;
side_stack[node_stack_depth] = side;
node_stack_depth++;
}
@@ -502,27 +502,22 @@ static void free_hull_polys( hullnode_t *hull_polys )
}
}
static void hull_windings_r( hull_t *hull, int nodenum, hullnode_t *polys, hull_model_t *model );
static void hull_windings_r( hull_t *hull, mclipnode_t *node, hullnode_t *polys, hull_model_t *model );
static void do_hull_recursion( hull_t *hull, int nodenum, int side, hullnode_t *polys, hull_model_t *model )
static void do_hull_recursion( hull_t *hull, mclipnode_t *node, int side, hullnode_t *polys, hull_model_t *model )
{
winding_t *w, *next;
int childnum;
if( world.version == QBSP2_VERSION )
childnum = hull->clipnodes32[nodenum].children[side];
else
childnum = hull->clipnodes16[nodenum].children[side];
if( childnum >= 0 )
if( node->children[side] >= 0 )
{
push_node( nodenum, side );
hull_windings_r( hull, childnum, polys, model );
mclipnode_t *child = hull->clipnodes + node->children[side];
push_node( node, side );
hull_windings_r( hull, child, polys, model );
pop_node();
}
else
{
switch( childnum )
switch( node->children[side] )
{
case CONTENTS_EMPTY:
case CONTENTS_WATER:
@@ -547,25 +542,20 @@ static void do_hull_recursion( hull_t *hull, int nodenum, int side, hullnode_t *
}
break;
default:
Host_Error( "bad contents: %i\n", childnum );
Host_Error( "bad contents: %i\n", node->children[side] );
break;
}
}
}
static void hull_windings_r( hull_t *hull, int nodenum, hullnode_t *polys, hull_model_t *model )
static void hull_windings_r( hull_t *hull, mclipnode_t *node, hullnode_t *polys, hull_model_t *model )
{
mplane_t *plane;
mplane_t *plane = hull->planes + node->planenum;
hullnode_t frontlist = LIST_HEAD_INIT( frontlist );
hullnode_t backlist = LIST_HEAD_INIT( backlist );
winding_t *w, *next, *front, *back;
int i;
if( world.version == QBSP2_VERSION )
plane = hull->planes + hull->clipnodes32[nodenum].planenum;
else
plane = hull->planes + hull->clipnodes16[nodenum].planenum;
list_for_each_entry_safe( w, next, polys, chain )
{
// PARANIOA - PAIR CHECK
@@ -611,13 +601,7 @@ static void hull_windings_r( hull_t *hull, int nodenum, hullnode_t *polys, hull_
for( i = 0; w && i < node_stack_depth; i++ )
{
mplane_t *p;
if( world.version == QBSP2_VERSION )
p = hull->planes + hull->clipnodes32[node_stack[i]].planenum;
else
p = hull->planes + hull->clipnodes16[node_stack[i]].planenum;
mplane_t *p = hull->planes + node_stack[i]->planenum;
w = winding_clip( w, p, false, side_stack[i], 0.00001 );
}
@@ -641,8 +625,8 @@ static void hull_windings_r( hull_t *hull, int nodenum, hullnode_t *polys, hull_
Con_Printf( S_WARN "new winding was clipped away!\n" );
}
do_hull_recursion( hull, nodenum, 0, &frontlist, model );
do_hull_recursion( hull, nodenum, 1, &backlist, model );
do_hull_recursion( hull, node, 0, &frontlist, model );
do_hull_recursion( hull, node, 1, &backlist, model );
}
static void remove_paired_polys( hull_model_t *model )
@@ -671,7 +655,7 @@ static void make_hull_windings( hull_t *hull, hull_model_t *model )
if( hull->planes != NULL )
{
hull_windings_r( hull, hull->firstclipnode, &head, model );
hull_windings_r( hull, hull->clipnodes + hull->firstclipnode, &head, model );
remove_paired_polys( model );
}
Con_Reportf( "%i hull polys\n", model->num_polys );

View File

@@ -300,12 +300,6 @@ static qboolean R_Init_Video_( const int type )
return R_Init_Video( type );
}
static mleaf_t *pfnMod_PointInLeaf( const vec3_t p, mnode_t *node )
{
// FIXME: get rid of this on next RefAPI update
return Mod_PointInLeaf( p, node, cl.models[1] );
}
static const ref_api_t gEngfuncs =
{
pfnEngineGetParm,
@@ -346,7 +340,7 @@ static const ref_api_t gEngfuncs =
Mod_SampleSizeForFace,
Mod_BoxVisible,
pfnMod_PointInLeaf,
Mod_PointInLeaf,
R_DrawWorldHull,
R_DrawModelHull,

View File

@@ -996,7 +996,7 @@ static void S_UpdateAmbientSounds( void )
// calc ambient sound levels
if( !cl.worldmodel ) return;
leaf = Mod_PointInLeaf( s_listener.origin, cl.worldmodel->nodes, cl.worldmodel );
leaf = Mod_PointInLeaf( s_listener.origin, cl.worldmodel->nodes );
if( !leaf || !s_ambient_level.value )
{

View File

@@ -72,6 +72,8 @@ GNU General Public License for more details.
#define CVAR_GLCONFIG_DESCRIPTION "enable or disable %s"
#define DEFAULT_BSP_BUILD_ERROR "%s can't be loaded in this build. Please rebuild engine with enabled SUPPORT_BSP2_FORMAT\n"
#define DEFAULT_UPDATE_PAGE "https://github.com/FWGS/xash3d-fwgs/releases/latest"
#define XASH_ENGINE_NAME "Xash3D FWGS"

View File

@@ -301,6 +301,7 @@ typedef struct host_parm_s
poolhandle_t mempool; // static mempool for misc allocations
poolhandle_t imagepool; // imagelib mempool
poolhandle_t soundpool; // soundlib mempool
string finalmsg; // server shutdown final message
string downloadfile; // filename to be downloading
int downloadcount; // how many files remain to downloading
char deferred_cmd[128];// deferred commands
@@ -559,7 +560,6 @@ void Host_Error( const char *error, ... ) FORMAT_CHECK( 1 );
void Host_ValidateEngineFeatures( uint32_t mask, uint32_t features );
void Host_Frame( double time );
void Host_Credits( void );
void Host_ExitInMain( void );
//
// host_state.c
@@ -578,19 +578,11 @@ CLIENT / SERVER SYSTEMS
==============================================================
*/
#if !XASH_DEDICATED
void CL_Init( void );
void CL_Shutdown( void );
void Host_ClientBegin( void );
void Host_ClientFrame( void );
int CL_Active( void );
#else
static inline void CL_Init( void ) { }
static inline void CL_Shutdown( void ) { }
static inline void Host_ClientBegin( void ) { Cbuf_Execute(); }
static inline void Host_ClientFrame( void ) { }
static inline int CL_Active( void ) { return 0; }
#endif
void SV_Init( void );
void SV_Shutdown( const char *finalmsg );
@@ -711,32 +703,13 @@ typedef enum connprotocol_e
struct physent_s;
struct sv_client_s;
typedef struct sizebuf_s sizebuf_t;
int SV_GetMaxClients( void );
#if !XASH_DEDICATED
qboolean CL_Initialized( void );
qboolean CL_IsInGame( void );
qboolean CL_IsInConsole( void );
qboolean CL_IsIntermission( void );
qboolean CL_DisableVisibility( void );
qboolean CL_IsRecordDemo( void );
qboolean CL_IsPlaybackDemo( void );
qboolean UI_CreditsActive( void );
int CL_GetMaxClients( void );
#else
static inline qboolean CL_Initialized( void ) { return false; }
static inline qboolean CL_IsInGame( void ) { return false; }
static inline qboolean CL_IsInConsole( void ) { return false; }
static inline qboolean CL_IsIntermission( void ) { return false; }
static inline qboolean CL_DisableVisibility( void ) { return false; }
static inline qboolean CL_IsRecordDemo( void ) { return false; }
static inline qboolean CL_IsPlaybackDemo( void ) { return false; }
static inline qboolean UI_CreditsActive( void ) { return false; }
static inline int CL_GetMaxClients( void ) { return SV_GetMaxClients(); }
#endif
qboolean CL_Initialized( void );
char *CL_Userinfo( void );
void CL_CharEvent( int key );
qboolean CL_DisableVisibility( void );
byte *COM_LoadFile( const char *filename, int usehunk, int *pLength ) MALLOC_LIKE( free, 1 );
struct cmd_s *Cmd_GetFirstFunctionHandle( void );
struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd );
@@ -754,7 +727,13 @@ const char *CL_MsgInfo( int cmd );
void SV_DrawDebugTriangles( void );
void SV_DrawOrthoTriangles( void );
double CL_GetDemoFramerate( void );
qboolean UI_CreditsActive( void );
void CL_StopPlayback( void );
int CL_GetMaxClients( void );
int SV_GetMaxClients( void );
qboolean CL_IsRecordDemo( void );
qboolean CL_IsTimeDemo( void );
qboolean CL_IsPlaybackDemo( void );
qboolean SV_Initialized( void );
void CL_ProcessFile( qboolean successfully_received, const char *filename );
int SV_GetSaveComment( const char *savename, char *comment );

View File

@@ -1395,7 +1395,7 @@ void Host_WriteConfig( void )
{
Con_Reportf( "%s()\n", __func__ );
FS_Printf( f, "//=======================================================================\n");
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
FS_Printf( f, "//\t\tconfig.cfg - archive of cvars\n" );
FS_Printf( f, "//=======================================================================\n" );
Key_WriteBindings( f );
@@ -1443,7 +1443,7 @@ void GAME_EXPORT Host_WriteServerConfig( const char *name )
if(( f = FS_Open( newconfigfile, "w", false )) != NULL )
{
FS_Printf( f, "//=======================================================================\n" );
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
FS_Printf( f, "//\t\tgame.cfg - multiplayer server temporare config\n" );
FS_Printf( f, "//=======================================================================\n" );
@@ -1478,7 +1478,7 @@ void Host_WriteOpenGLConfig( void )
{
Con_Reportf( "%s()\n", __func__ );
FS_Printf( f, "//=======================================================================\n" );
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
FS_Printf( f, "//\t\t%s - archive of renderer implementation cvars\n", name );
FS_Printf( f, "//=======================================================================\n" );
FS_Printf( f, "\n" );
@@ -1508,7 +1508,7 @@ void Host_WriteVideoConfig( void )
{
Con_Reportf( "%s()\n", __func__ );
FS_Printf( f, "//=======================================================================\n" );
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
FS_Printf( f, "//\t\tvideo.cfg - archive of renderer variables\n");
FS_Printf( f, "//=======================================================================\n" );
Cvar_WriteVariables( f, FCVAR_RENDERINFO );
@@ -1534,7 +1534,7 @@ void Key_EnumCmds_f( void )
if( f )
{
FS_Printf( f, "//=======================================================================\n");
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
FS_Printf( f, "//\tGenerated by "XASH_ENGINE_NAME" (%i, %s, %s, %s-%s)\n", Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
FS_Printf( f, "//\t\thelp.txt - xash commands and console variables\n");
FS_Printf( f, "//=======================================================================\n");

View File

@@ -49,6 +49,52 @@ const char *CL_MsgInfo( int cmd )
return sz;
}
int GAME_EXPORT CL_Active( void )
{
return false;
}
qboolean CL_Initialized( void )
{
return false;
}
qboolean CL_IsInGame( void )
{
return true; // always active for dedicated servers
}
qboolean CL_IsInConsole( void )
{
return false;
}
qboolean CL_IsIntermission( void )
{
return false;
}
qboolean CL_IsPlaybackDemo( void )
{
return false;
}
qboolean CL_IsRecordDemo( void )
{
return false;
}
qboolean CL_DisableVisibility( void )
{
return false;
}
void CL_Init( void )
{
}
void Key_Init( void )
{
@@ -84,6 +130,16 @@ void CL_WriteMessageHistory( void )
}
void Host_ClientBegin( void )
{
Cbuf_Execute();
}
void Host_ClientFrame( void )
{
}
void Host_InputFrame( void )
{
}
@@ -103,6 +159,11 @@ void GAME_EXPORT S_StopSound(int entnum, int channel, const char *soundname)
}
int GAME_EXPORT CL_GetMaxClients( void )
{
return 0;
}
void IN_TouchInitConfig( void )
{
@@ -113,6 +174,11 @@ void CL_Disconnect( void )
}
void CL_Shutdown( void )
{
}
void R_ClearStaticEntities( void )
{
@@ -123,6 +189,11 @@ void Host_Credits( void )
}
qboolean UI_CreditsActive( void )
{
return false;
}
void S_StopBackgroundTrack( void )
{
@@ -133,6 +204,11 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
}
int S_GetCurrentDynamicSounds( soundlist_t *pout, int size )
{
return 0;
}
void S_StopAllSounds( qboolean ambient )
{

View File

@@ -43,27 +43,6 @@ GNU General Public License for more details.
static pfnChangeGame pChangeGame = NULL;
host_parm_t host; // host parms
#if XASH_ANDROID
static jmp_buf return_from_main_buf;
/*
===============
Host_ExitInMain
On some platforms (e.g. Android) we can't exit with exit(3) as calling it would
kill wrapper process (e.g. app_process) too early, before all resources would
be freed, contexts released, files closed, etc, etc...
To fix this, we create jmp_buf in Host_Main function, when jumping into with
non-zero value will immediately return from it with `error_on_exit`.
===============
*/
void Host_ExitInMain( void )
{
longjmp( return_from_main_buf, 1 );
}
#endif // XASH_ANDROID
#ifdef XASH_ENGINE_TESTS
struct tests_stats_s tests_stats;
#endif
@@ -383,8 +362,9 @@ static void Host_NewInstance( const char *name, const char *finalmsg )
if( !pChangeGame ) return;
host.change_game = true;
Q_strncpy( host.finalmsg, finalmsg, sizeof( host.finalmsg ));
if( !Sys_NewInstance( name, finalmsg ))
if( !Sys_NewInstance( name ))
pChangeGame( name ); // call from hl.exe
}
@@ -858,6 +838,7 @@ void GAME_EXPORT Host_Error( const char *error, ... )
recursive = true;
Q_strncpy( hosterror2, hosterror1, sizeof( hosterror2 ));
host.errorframe = host.framecount; // to avoid multply calls per frame
Q_snprintf( host.finalmsg, sizeof( host.finalmsg ), "Server crashed: %s", hosterror1 );
// clearing cmd buffer to prevent execute any commands
COM_InitHostState();
@@ -1233,7 +1214,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
Cvar_Getf( "buildnum", FCVAR_READ_ONLY, "returns a current build number", "%i", Q_buildnum_compat());
Cvar_Getf( "ver", FCVAR_READ_ONLY, "shows an engine version", "%i/%s (hw build %i)", PROTOCOL_VERSION, XASH_COMPAT_VERSION, Q_buildnum_compat());
Cvar_Getf( "host_ver", FCVAR_READ_ONLY, "detailed info about this build", "%i " XASH_VERSION " %s %s %s", Q_buildnum(), Q_buildos(), Q_buildarch(), g_buildcommit);
Cvar_Getf( "host_ver", FCVAR_READ_ONLY, "detailed info about this build", "%i " XASH_VERSION " %s %s %s", Q_buildnum(), Q_buildos(), Q_buildarch(), Q_buildcommit());
Cvar_Getf( "host_lowmemorymode", FCVAR_READ_ONLY, "indicates if engine compiled for low RAM consumption (0 - normal, 1 - low engine limits, 2 - low protocol limits)", "%i", XASH_LOW_MEMORY );
Mod_Init();
@@ -1340,11 +1321,6 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
// check after all configs were executed
HPAK_CheckIntegrity( hpk_custom_file.string );
#if XASH_ANDROID
if( setjmp( return_from_main_buf ))
return error_on_exit;
#endif // XASH_ANDROID
// main window message loop
while( !host.crashed )
{
@@ -1383,6 +1359,9 @@ void Host_ShutdownWithReason( const char *reason )
if( host.status != HOST_ERR_FATAL )
host.status = HOST_SHUTDOWN; // prepare host to normal shutdown
if( !host.change_game )
Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg ));
#if !XASH_DEDICATED
if( host.type == HOST_NORMAL && !error )
Host_WriteConfig();
@@ -1405,5 +1384,5 @@ void Host_ShutdownWithReason( const char *reason )
// restore filter
Sys_RestoreCrashHandler();
Sys_CloseLog( reason );
Sys_CloseLog();
}

View File

@@ -104,7 +104,7 @@ static void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *p
string pakname;
byte md5[16];
file_t *fout;
MD5Context_t ctx = { 0 };
MD5Context_t ctx;
if( !COM_CheckString( filename ))
return;
@@ -125,6 +125,7 @@ static void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *p
}
// let's hash it.
memset( &ctx, 0, sizeof( MD5Context_t ));
MD5Init( &ctx );
if( pData == NULL )
@@ -213,7 +214,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
file_t *file_src;
file_t *file_dst;
byte md5[16];
MD5Context_t ctx = { 0 };
MD5Context_t ctx;
if( pData == NULL && pFile == NULL )
return;
@@ -225,6 +226,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
}
// hash it
memset( &ctx, 0, sizeof( MD5Context_t ));
MD5Init( &ctx );
if( !pData )

View File

@@ -611,7 +611,7 @@ void GAME_EXPORT ID_SetCustomClientID( const char *id )
void ID_Init( void )
{
MD5Context_t hash = { 0 };
MD5Context_t hash = {0};
byte md5[16];
int i;

View File

@@ -385,35 +385,6 @@ static const mlumpinfo_t extlumps[EXTRA_LUMPS] =
},
};
#define BOX_CLIPNODES_INITIALIZER \
{ \
.planenum = 0, \
.children = { CONTENTS_EMPTY, 1 }, \
}, \
{ \
.planenum = 1, \
.children = { 2, CONTENTS_EMPTY }, \
}, \
{ \
.planenum = 2, \
.children = { CONTENTS_EMPTY, 3 }, \
}, \
{ \
.planenum = 3, \
.children = { 4, CONTENTS_EMPTY }, \
}, \
{ \
.planenum = 4, \
.children = { CONTENTS_EMPTY, 5 }, \
}, \
{ \
.planenum = 5, \
.children = { CONTENTS_SOLID, CONTENTS_EMPTY }, \
}, \
const mclipnode16_t box_clipnodes16[6] = { BOX_CLIPNODES_INITIALIZER };
const mclipnode32_t box_clipnodes32[6] = { BOX_CLIPNODES_INITIALIZER };
/*
===============================================================================
@@ -885,7 +856,7 @@ Mod_PointInLeaf
==================
*/
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node, model_t *mod )
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node )
{
Assert( node != NULL );
@@ -893,7 +864,7 @@ mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node, model_t *mod )
{
if( node->contents < 0 )
return (mleaf_t *)node;
node = node_child( node, PlaneDiff( p, node->plane ) <= 0, mod );
node = node->children[PlaneDiff( p, node->plane ) <= 0];
}
// never reached
@@ -914,7 +885,7 @@ byte *Mod_GetPVSForPoint( const vec3_t p )
ASSERT( worldmodel != NULL );
leaf = Mod_PointInLeaf( p, worldmodel->nodes, worldmodel );
leaf = Mod_PointInLeaf( p, worldmodel->nodes );
if( leaf && leaf->cluster >= 0 )
return Mod_DecompressPVS( leaf->compressed_vis, world.visbytes );
@@ -934,14 +905,14 @@ static void Mod_FatPVS_RecursiveBSPNode( const vec3_t org, float radius, byte *v
float d = PlaneDiff( org, node->plane );
if( d > radius )
node = node_child( node, 0, worldmodel );
node = node->children[0];
else if( d < -radius )
node = node_child( node, 1, worldmodel );
node = node->children[1];
else
{
// go down both sides
Mod_FatPVS_RecursiveBSPNode( org, radius, visbuffer, visbytes, node_child( node, 0, worldmodel ), phs );
node = node_child( node, 1, worldmodel );
Mod_FatPVS_RecursiveBSPNode( org, radius, visbuffer, visbytes, node->children[0], phs );
node = node->children[1];
}
}
@@ -979,7 +950,7 @@ int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, q
ASSERT( worldmodel != NULL );
leaf = Mod_PointInLeaf( org, worldmodel->nodes, worldmodel );
leaf = Mod_PointInLeaf( org, worldmodel->nodes );
bytes = Q_min( bytes, visbytes );
// enable full visibility for some reasons
@@ -1038,16 +1009,20 @@ static void Mod_BoxLeafnums_r( leaflist_t *ll, mnode_t *node )
sides = BOX_ON_PLANE_SIDE( ll->mins, ll->maxs, node->plane );
if( sides == 1 )
node = node_child( node, 0, worldmodel );
{
node = node->children[0];
}
else if( sides == 2 )
node = node_child( node, 1, worldmodel );
{
node = node->children[1];
}
else
{
// go down both
if( ll->topnode == -1 )
ll->topnode = node - worldmodel->nodes;
Mod_BoxLeafnums_r( ll, node_child( node, 0, worldmodel ));
node = node_child( node, 1, worldmodel );
Mod_BoxLeafnums_r( ll, node->children[0] );
node = node->children[1];
}
}
}
@@ -1104,6 +1079,35 @@ qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbi
return false;
}
/*
=============
Mod_HeadnodeVisible
=============
*/
qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, int *lastleaf )
{
if( !node || node->contents == CONTENTS_SOLID )
return false;
if( node->contents < 0 )
{
if( !CHECKVISBIT( visbits, ((mleaf_t *)node)->cluster ))
return false;
if( lastleaf )
*lastleaf = ((mleaf_t *)node)->cluster;
return true;
}
if( Mod_HeadnodeVisible( node->children[0], visbits, lastleaf ))
return true;
if( Mod_HeadnodeVisible( node->children[1], visbits, lastleaf ))
return true;
return false;
}
/*
=================
Mod_FindModelOrigin
@@ -1260,35 +1264,22 @@ Mod_GetFaceContents
determine face contents by name
==================
*/
static mvertex_t *Mod_GetVertexByNumber( model_t *mod, int surfedge, const dbspmodel_t *bmod )
static mvertex_t *Mod_GetVertexByNumber( model_t *mod, int surfedge )
{
int lindex = mod->surfedges[surfedge];
int lindex;
medge_t *edge;
if( bmod->version == QBSP2_VERSION )
lindex = mod->surfedges[surfedge];
if( lindex > 0 )
{
if( lindex > 0 )
{
medge32_t *edge = &mod->edges32[lindex];
return &mod->vertexes[edge->v[0]];
}
else
{
medge32_t *edge = &mod->edges32[-lindex];
return &mod->vertexes[edge->v[1]];
}
edge = &mod->edges[lindex];
return &mod->vertexes[edge->v[0]];
}
else
{
if( lindex > 0 )
{
medge16_t *edge = &mod->edges16[lindex];
return &mod->vertexes[edge->v[0]];
}
else
{
medge16_t *edge = &mod->edges16[-lindex];
return &mod->vertexes[edge->v[1]];
}
edge = &mod->edges[-lindex];
return &mod->vertexes[edge->v[1]];
}
}
@@ -1373,7 +1364,7 @@ Mod_CalcSurfaceExtents
Fills in surf->texturemins[] and surf->extents[]
=================
*/
static void Mod_CalcSurfaceExtents( model_t *mod, msurface_t *surf, const dbspmodel_t *bmod )
static void Mod_CalcSurfaceExtents( model_t *mod, msurface_t *surf )
{
// this place is VERY critical to precision
// keep it as float, don't use double, because it causes issues with lightmap
@@ -1400,16 +1391,8 @@ static void Mod_CalcSurfaceExtents( model_t *mod, msurface_t *surf, const dbspmo
if( e >= mod->numedges || e <= -mod->numedges )
Host_Error( "%s: bad edge\n", __func__ );
if( bmod->version == QBSP2_VERSION )
{
if( e >= 0 ) v = &mod->vertexes[mod->edges32[e].v[0]];
else v = &mod->vertexes[mod->edges32[-e].v[1]];
}
else
{
if( e >= 0 ) v = &mod->vertexes[mod->edges16[e].v[0]];
else v = &mod->vertexes[mod->edges16[-e].v[1]];
}
if( e >= 0 ) v = &mod->vertexes[mod->edges[e].v[0]];
else v = &mod->vertexes[mod->edges[-e].v[1]];
for( j = 0; j < 2; j++ )
{
@@ -1463,7 +1446,7 @@ Mod_CalcSurfaceBounds
fills in surf->mins and surf->maxs
=================
*/
static void Mod_CalcSurfaceBounds( model_t *mod, msurface_t *surf, const dbspmodel_t *bmod )
static void Mod_CalcSurfaceBounds( model_t *mod, msurface_t *surf )
{
int i, e;
mvertex_t *v;
@@ -1477,16 +1460,8 @@ static void Mod_CalcSurfaceBounds( model_t *mod, msurface_t *surf, const dbspmod
if( e >= mod->numedges || e <= -mod->numedges )
Host_Error( "%s: bad edge\n", __func__ );
if( bmod->version == QBSP2_VERSION )
{
if( e >= 0 ) v = &mod->vertexes[mod->edges32[e].v[0]];
else v = &mod->vertexes[mod->edges32[-e].v[1]];
}
else
{
if( e >= 0 ) v = &mod->vertexes[mod->edges16[e].v[0]];
else v = &mod->vertexes[mod->edges16[-e].v[1]];
}
if( e >= 0 ) v = &mod->vertexes[mod->edges[e].v[0]];
else v = &mod->vertexes[mod->edges[-e].v[1]];
AddPointToBounds( v->position, surf->info->mins, surf->info->maxs );
}
@@ -1498,7 +1473,7 @@ static void Mod_CalcSurfaceBounds( model_t *mod, msurface_t *surf, const dbspmod
Mod_CreateFaceBevels
=================
*/
static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf, const dbspmodel_t *bmod )
static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf )
{
vec3_t delta, edgevec;
byte *facebevel;
@@ -1531,8 +1506,8 @@ static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf, const dbspmode
{
mplane_t *dest = &fb->edges[i];
v0 = Mod_GetVertexByNumber( mod, surf->firstedge + i, bmod );
v1 = Mod_GetVertexByNumber( mod, surf->firstedge + (i + 1) % surf->numedges, bmod );
v0 = Mod_GetVertexByNumber( mod, surf->firstedge + i );
v1 = Mod_GetVertexByNumber( mod, surf->firstedge + (i + 1) % surf->numedges );
VectorSubtract( v1->position, v0->position, edgevec );
CrossProduct( faceNormal, edgevec, dest->normal );
VectorNormalize( dest->normal );
@@ -1546,7 +1521,7 @@ static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf, const dbspmode
// compute face radius
for( i = 0; i < surf->numedges; i++ )
{
v0 = Mod_GetVertexByNumber( mod, surf->firstedge + i, bmod );
v0 = Mod_GetVertexByNumber( mod, surf->firstedge + i );
VectorSubtract( v0->position, fb->origin, delta );
radius = DotProduct( delta, delta );
fb->radius = Q_max( radius, fb->radius );
@@ -1558,15 +1533,13 @@ static void Mod_CreateFaceBevels( model_t *mod, msurface_t *surf, const dbspmode
Mod_SetParent
=================
*/
static void Mod_SetParent( model_t *mod, mnode_t *node, mnode_t *parent )
static void Mod_SetParent( mnode_t *node, mnode_t *parent )
{
node->parent = parent;
if( node->contents < 0 )
return; // it's leaf
Mod_SetParent( mod, node_child( node, 0, mod ), node );
Mod_SetParent( mod, node_child( node, 1, mod ), node );
if( node->contents < 0 ) return; // it's leaf
Mod_SetParent( node->children[0], node );
Mod_SetParent( node->children[1], node );
}
/*
@@ -1574,7 +1547,7 @@ static void Mod_SetParent( model_t *mod, mnode_t *node, mnode_t *parent )
CountClipNodes_r
==================
*/
static void CountClipNodes16_r( mclipnode16_t *src, hull_t *hull, int nodenum )
static void CountClipNodes_r( mclipnode_t *src, hull_t *hull, int nodenum )
{
// leaf?
if( nodenum < 0 ) return;
@@ -1583,11 +1556,16 @@ static void CountClipNodes16_r( mclipnode16_t *src, hull_t *hull, int nodenum )
Host_Error( "MAX_MAP_CLIPNODES limit exceeded\n" );
hull->lastclipnode++;
CountClipNodes16_r( src, hull, src[nodenum].children[0] );
CountClipNodes16_r( src, hull, src[nodenum].children[1] );
CountClipNodes_r( src, hull, src[nodenum].children[0] );
CountClipNodes_r( src, hull, src[nodenum].children[1] );
}
static void CountClipNodes32_r( mclipnode32_t *src, hull_t *hull, int nodenum )
/*
==================
CountClipNodes32_r
==================
*/
static void CountClipNodes32_r( dclipnode32_t *src, hull_t *hull, int nodenum )
{
// leaf?
if( nodenum < 0 ) return;
@@ -1600,27 +1578,15 @@ static void CountClipNodes32_r( mclipnode32_t *src, hull_t *hull, int nodenum )
CountClipNodes32_r( src, hull, src[nodenum].children[1] );
}
static void CountDClipNodes_r( dclipnode32_t *src, hull_t *hull, int nodenum )
{
// leaf?
if( nodenum < 0 ) return;
if( hull->lastclipnode == MAX_MAP_CLIPNODES )
Host_Error( "MAX_MAP_CLIPNODES limit exceeded\n" );
hull->lastclipnode++;
CountDClipNodes_r( src, hull, src[nodenum].children[0] );
CountDClipNodes_r( src, hull, src[nodenum].children[1] );
}
/*
==================
RemapClipNodes_r
==================
*/
static int RemapClipNodes_r( dbspmodel_t *bmod, dclipnode32_t *srcnodes, hull_t *hull, int nodenum )
static int RemapClipNodes_r( dclipnode32_t *srcnodes, hull_t *hull, int nodenum )
{
dclipnode32_t *src;
dclipnode32_t *src;
mclipnode_t *out;
int i, c;
// leaf?
@@ -1633,22 +1599,13 @@ static int RemapClipNodes_r( dbspmodel_t *bmod, dclipnode32_t *srcnodes, hull_t
src = srcnodes + nodenum;
c = hull->lastclipnode;
out = &hull->clipnodes[c];
hull->lastclipnode++;
if( bmod->version == QBSP2_VERSION )
{
mclipnode32_t *out = &hull->clipnodes32[c];
out->planenum = src->planenum;
for( i = 0; i < 2; i++ )
out->children[i] = RemapClipNodes_r( bmod, srcnodes, hull, src->children[i] );
}
else
{
mclipnode16_t *out = &hull->clipnodes16[c];
out->planenum = src->planenum;
for( i = 0; i < 2; i++ )
out->children[i] = RemapClipNodes_r( bmod, srcnodes, hull, src->children[i] );
}
out->planenum = src->planenum;
for( i = 0; i < 2; i++ )
out->children[i] = RemapClipNodes_r( srcnodes, hull, src->children[i] );
return c;
}
@@ -1660,64 +1617,34 @@ Mod_MakeHull0
Duplicate the drawing hull structure as a clipping hull
=================
*/
static void Mod_MakeHull0( model_t *mod, const dbspmodel_t *bmod )
static void Mod_MakeHull0( model_t *mod )
{
hull_t *hull = &mod->hulls[0];
int i;
mnode_t *in, *child;
mclipnode_t *out;
hull_t *hull;
int i, j;
hull = &mod->hulls[0];
hull->clipnodes = out = Mem_Malloc( mod->mempool, mod->numnodes * sizeof( *out ));
in = mod->nodes;
hull->firstclipnode = 0;
hull->lastclipnode = mod->numnodes - 1;
hull->planes = mod->planes;
if( bmod->version == QBSP2_VERSION )
for( i = 0; i < mod->numnodes; i++, out++, in++ )
{
mclipnode32_t *out;
mnode_t *in = mod->nodes;
out->planenum = in->plane - mod->planes;
hull->clipnodes32 = out = Mem_Malloc( mod->mempool, mod->numnodes * sizeof( *hull->clipnodes32 ));
for( i = 0; i < mod->numnodes; i++, out++, in++ )
for( j = 0; j < 2; j++ )
{
int j;
child = in->children[j];
out->planenum = in->plane - mod->planes;
for( j = 0; j < 2; j++ )
{
mnode_t *child = node_child( in, j, mod );
if( child->contents < 0 )
out->children[j] = child->contents;
else
out->children[j] = child - mod->nodes;
}
if( child->contents < 0 )
out->children[j] = child->contents;
else out->children[j] = child - mod->nodes;
}
}
else
{
mclipnode16_t *out;
mnode_t *in = mod->nodes;
hull->clipnodes16 = out = Mem_Malloc( mod->mempool, mod->numnodes * sizeof( *hull->clipnodes16 ));
for( i = 0; i < mod->numnodes; i++, out++, in++ )
{
int j;
out->planenum = in->plane - mod->planes;
for( j = 0; j < 2; j++ )
{
mnode_t *child = node_child( in, j, mod );
if( child->contents < 0 )
out->children[j] = child->contents;
else
out->children[j] = child - mod->nodes;
}
}
}
}
/*
@@ -1761,18 +1688,15 @@ static void Mod_SetupHull( dbspmodel_t *bmod, model_t *mod, poolhandle_t mempool
if( VectorIsNull( hull->clip_mins ) && VectorIsNull( hull->clip_maxs ))
return; // no hull specified
CountDClipNodes_r( bmod->clipnodes_out, hull, headnode );
CountClipNodes32_r( bmod->clipnodes_out, hull, headnode );
// fit array to real count
if( bmod->version == QBSP2_VERSION )
hull->clipnodes32 = Mem_Malloc( mempool, sizeof( *hull->clipnodes32 ) * hull->lastclipnode );
else
hull->clipnodes16 = Mem_Malloc( mempool, sizeof( *hull->clipnodes16 ) * hull->lastclipnode );
hull->clipnodes = (mclipnode_t *)Mem_Malloc( mempool, sizeof( mclipnode_t ) * hull->lastclipnode );
hull->planes = mod->planes; // share planes
hull->lastclipnode = 0; // restart counting
RemapClipNodes_r( bmod, bmod->clipnodes_out, hull, headnode ); // remap clipnodes to 16-bit indexes
// remap clipnodes to 16-bit indexes
RemapClipNodes_r( bmod->clipnodes_out, hull, headnode );
}
static qboolean Mod_LoadLitfile( model_t *mod, const char *ext, size_t expected_size, color24 **out, size_t *outsize )
@@ -1780,8 +1704,7 @@ static qboolean Mod_LoadLitfile( model_t *mod, const char *ext, size_t expected_
char modelname[64], path[64];
int iCompare;
fs_offset_t datasize;
file_t *f;
uint hdr[2];
byte *in;
COM_FileBase( mod->name, modelname, sizeof( modelname ));
Q_snprintf( path, sizeof( path ), "maps/%s.%s", modelname, ext );
@@ -1792,15 +1715,31 @@ static qboolean Mod_LoadLitfile( model_t *mod, const char *ext, size_t expected_
if( iCompare < 0 ) // this may happens if level-designer used -onlyents key for hlcsg
Con_Printf( S_WARN "%s probably is out of date\n", path );
f = FS_Open( path, "rb", false );
in = FS_LoadFile( path, &datasize, false );
if( !f )
if( !in )
{
Con_Printf( S_ERROR "couldn't load %s\n", path );
return false;
}
datasize = FS_FileLength( f );
if( datasize <= 8 ) // header + version
{
Con_Printf( S_ERROR "%s is too short\n", path );
goto cleanup_and_error;
}
if( LittleLong( ((uint *)in)[0] ) != IDDELUXEMAPHEADER )
{
Con_Printf( S_ERROR "%s is corrupted\n", path );
goto cleanup_and_error;
}
if( LittleLong( ((uint *)in)[1] ) != DELUXEMAP_VERSION )
{
Con_Printf( S_ERROR "has %s mismatched version (%u should be %u)\n", path, LittleLong( ((uint *)in)[1] ), DELUXEMAP_VERSION );
goto cleanup_and_error;
}
// skip header bytes
datasize -= 8;
@@ -1811,33 +1750,14 @@ static qboolean Mod_LoadLitfile( model_t *mod, const char *ext, size_t expected_
goto cleanup_and_error;
}
if( FS_Read( f, hdr, sizeof( hdr )) != sizeof( hdr ))
{
Con_Printf( S_ERROR "failed reading header from %s\n", path );
goto cleanup_and_error;
}
if( LittleLong( hdr[0] ) != IDDELUXEMAPHEADER )
{
Con_Printf( S_ERROR "%s is corrupted\n", path );
goto cleanup_and_error;
}
if( LittleLong( hdr[1] ) != DELUXEMAP_VERSION )
{
Con_Printf( S_ERROR "has %s mismatched version (%u should be %u)\n", path, LittleLong( hdr[1] ), DELUXEMAP_VERSION );
goto cleanup_and_error;
}
*out = Mem_Malloc( mod->mempool, datasize );
memcpy( *out, in + 8, datasize );
*outsize = datasize;
FS_Read( f, *out, datasize );
FS_Close( f );
Mem_Free( in );
return true;
cleanup_and_error:
FS_Close( f );
Mem_Free( in );
return false;
}
@@ -1852,7 +1772,6 @@ for embedded submodels
static void Mod_SetupSubmodels( model_t *mod, dbspmodel_t *bmod )
{
qboolean colored = false;
qboolean qbsp2 = false;
poolhandle_t mempool;
char *ents;
dmodel_t *bm;
@@ -1864,9 +1783,6 @@ static void Mod_SetupSubmodels( model_t *mod, dbspmodel_t *bmod )
if( FBitSet( mod->flags, MODEL_COLORED_LIGHTING ))
colored = true;
if( FBitSet( mod->flags, MODEL_QBSP2 ))
qbsp2 = true;
mod->numframes = 2; // regular and alternate animation
// set up the submodels
@@ -1879,10 +1795,7 @@ static void Mod_SetupSubmodels( model_t *mod, dbspmodel_t *bmod )
mod->hulls[0].lastclipnode = bm->headnode[0]; // need to be real count
// counting a real number of clipnodes per each submodel
if( bmod->version == QBSP2_VERSION )
CountClipNodes32_r( mod->hulls[0].clipnodes32, &mod->hulls[0], bm->headnode[0] );
else
CountClipNodes16_r( mod->hulls[0].clipnodes16, &mod->hulls[0], bm->headnode[0] );
CountClipNodes_r( mod->hulls[0].clipnodes, &mod->hulls[0], bm->headnode[0] );
// but hulls1-3 is build individually for a each given submodel
for( j = 1; j < MAX_MAP_HULLS; j++ )
@@ -1900,7 +1813,6 @@ static void Mod_SetupSubmodels( model_t *mod, dbspmodel_t *bmod )
// this bit will be shared between all the submodels include worldmodel
if( colored ) SetBits( mod->flags, MODEL_COLORED_LIGHTING );
if( qbsp2 ) SetBits( mod->flags, MODEL_QBSP2 );
if( i != 0 )
{
@@ -2223,15 +2135,15 @@ Mod_LoadEdges
*/
static void Mod_LoadEdges( model_t *mod, dbspmodel_t *bmod )
{
medge_t *out;
int i;
mod->edges = out = Mem_Malloc( mod->mempool, bmod->numedges * sizeof( medge_t ));
mod->numedges = bmod->numedges;
if( bmod->version == QBSP2_VERSION )
{
dedge32_t *in = bmod->edges32;
medge32_t *out;
mod->edges32 = out = Mem_Malloc( mod->mempool, bmod->numedges * sizeof( *out ));
dedge32_t *in = (dedge32_t *)bmod->edges32;
for( i = 0; i < bmod->numedges; i++, in++, out++ )
{
@@ -2241,9 +2153,7 @@ static void Mod_LoadEdges( model_t *mod, dbspmodel_t *bmod )
}
else
{
dedge_t *in = bmod->edges;
medge16_t *out;
mod->edges16 = out = Mem_Malloc( mod->mempool, bmod->numedges * sizeof( *out ));
dedge_t *in = (dedge_t *)bmod->edges;
for( i = 0; i < bmod->numedges; i++, in++, out++ )
{
@@ -3003,9 +2913,9 @@ static void Mod_LoadSurfaces( model_t *mod, dbspmodel_t *bmod )
if( FBitSet( out->texinfo->flags, TEX_SPECIAL ))
SetBits( out->flags, SURF_DRAWTILED );
Mod_CalcSurfaceBounds( mod, out, bmod );
Mod_CalcSurfaceExtents( mod, out, bmod );
Mod_CreateFaceBevels( mod, out, bmod );
Mod_CalcSurfaceBounds( mod, out );
Mod_CalcSurfaceExtents( mod, out );
Mod_CreateFaceBevels( mod, out );
// grab the second sample to detect colored lighting
if( test_lightsize > 0 && lightofs != -1 )
@@ -3052,6 +2962,7 @@ static void Mod_LoadSurfaces( model_t *mod, dbspmodel_t *bmod )
if( samples == 1 || samples == 3 )
{
bmod->lightmap_samples = (int)samples;
Con_Reportf( "lighting: %s\n", (bmod->lightmap_samples == 1) ? "monochrome" : "colored" );
bmod->lightmap_samples = Q_max( bmod->lightmap_samples, 1 ); // avoid division by zero
}
else Con_DPrintf( S_WARN "lighting invalid samplecount: %g, defaulting to %i\n", samples, bmod->lightmap_samples );
@@ -3083,62 +2994,16 @@ static void Mod_LoadNodes( model_t *mod, dbspmodel_t *bmod )
out->minmaxs[j+3] = in->maxs[j];
}
#if !XASH_64BIT
if( in->firstface >= BIT( 24 ))
{
Host_Error( "%s: face index limit exceeded on node %i\n", __func__, i );
return;
}
if( in->numfaces >= BIT( 24 ))
{
Host_Error( "%s: face count limit exceeded on node %i\n", __func__, i );
return;
}
#endif
p = in->planenum;
out->plane = mod->planes + p;
out->firstsurface_0 = in->firstface & 0xFFFF;
out->numsurfaces_0 = in->numfaces & 0xFFFF;
out->firstsurface_1 = in->firstface >> 16;
out->numsurfaces_1 = in->numfaces >> 16;
out->firstsurface = in->firstface;
out->numsurfaces = in->numfaces;
for( j = 0; j < 2; j++ )
{
p = in->children[j];
#if XASH_64BIT
if( p >= 0 ) out->children_[j] = mod->nodes + p;
else out->children_[j] = (mnode_t *)(mod->leafs + ( -1 - p ));
#else
if( j == 0 )
{
if( p >= 0 )
{
out->child_0_leaf = 0;
out->child_0_off = p;
}
else
{
out->child_0_leaf = 1;
out->child_0_off = -1 - p;
}
}
else
{
if( p >= 0 )
{
out->child_1_leaf = 0;
out->child_1_off = p;
}
else
{
out->child_1_leaf = 1;
out->child_1_off = -1 - p;
}
}
#endif
if( p >= 0 ) out->children[j] = mod->nodes + p;
else out->children[j] = (mnode_t *)(mod->leafs + ( -1 - p ));
}
}
else
@@ -3153,20 +3018,20 @@ static void Mod_LoadNodes( model_t *mod, dbspmodel_t *bmod )
p = in->planenum;
out->plane = mod->planes + p;
out->firstsurface_0 = in->firstface;
out->numsurfaces_0 = in->numfaces;
out->firstsurface = in->firstface;
out->numsurfaces = in->numfaces;
for( j = 0; j < 2; j++ )
{
p = in->children[j];
if( p >= 0 ) out->children_[j] = mod->nodes + p;
else out->children_[j] = (mnode_t *)(mod->leafs + ( -1 - p ));
if( p >= 0 ) out->children[j] = mod->nodes + p;
else out->children[j] = (mnode_t *)(mod->leafs + ( -1 - p ));
}
}
}
// sets nodes and leafs
Mod_SetParent( mod, mod->nodes, NULL );
Mod_SetParent( mod->nodes, NULL );
}
/*
@@ -3548,8 +3413,6 @@ static void Mod_LoadLighting( model_t *mod, dbspmodel_t *bmod )
break;
}
Con_Reportf( "lighting: %s\n", FBitSet( mod->flags, MODEL_COLORED_LIGHTING ) ? "colored" : "monochrome" );
// not supposed to be load ?
if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ))
{
@@ -3628,6 +3491,13 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
Q_strncpy( loadstat.name, mod->name, sizeof( loadstat.name ));
wadvalue[0] = '\0';
#ifndef SUPPORT_BSP2_FORMAT
if( header->version == QBSP2_VERSION )
{
Con_Printf( S_ERROR DEFAULT_BSP_BUILD_ERROR, mod->name );
return false;
}
#endif
switch( header->version )
{
case HLBSP_VERSION:
@@ -3650,9 +3520,6 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
// everything else
srclumps[0].lumpnumber = LUMP_ENTITIES;
srclumps[1].lumpnumber = LUMP_PLANES;
if( header->version == QBSP2_VERSION )
SetBits( mod->flags, MODEL_QBSP2 );
break;
default:
Con_Printf( S_ERROR "%s has wrong version number (%i should be %i)\n", mod->name, header->version, HLBSP_VERSION );
@@ -3703,7 +3570,7 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
Mod_LoadClipnodes( mod, bmod );
// preform some post-initalization
Mod_MakeHull0( mod, bmod );
Mod_MakeHull0( mod );
Mod_SetupSubmodels( mod, bmod );
if( isworld )
@@ -3793,6 +3660,15 @@ qboolean Mod_TestBmodelLumps( file_t *f, const char *name, const byte *mod_base,
if( silent )
SetBits( flags, LUMP_SILENT );
#ifndef SUPPORT_BSP2_FORMAT
if( header->version == QBSP2_VERSION )
{
if( !FBitSet( flags, LUMP_SILENT ))
Con_Printf( S_ERROR DEFAULT_BSP_BUILD_ERROR, name );
return false;
}
#endif
switch( header->version )
{
case HLBSP_VERSION:

View File

@@ -135,8 +135,6 @@ extern poolhandle_t com_studiocache;
extern convar_t mod_studiocache;
extern convar_t r_wadtextures;
extern convar_t r_showhull;
extern const mclipnode16_t box_clipnodes16[6];
extern const mclipnode32_t box_clipnodes32[6];
//
// model.c
@@ -169,12 +167,13 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded );
//
void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded );
qboolean Mod_TestBmodelLumps( file_t *f, const char *name, const byte *mod_base, qboolean silent, dlump_t *entities );
qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, int *lastleaf );
int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, qboolean merge, qboolean fullvis, qboolean false );
qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits );
int Mod_CheckLump( const char *filename, const int lump, int *lumpsize );
int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize );
int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize );
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node, model_t *mod );
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node );
int Mod_SampleSizeForFace( const msurface_t *surf );
byte *Mod_GetPVSForPoint( const vec3_t p );
void Mod_UnloadBrushModel( model_t *mod );

View File

@@ -50,8 +50,9 @@ static matrix3x4 studio_bones[MAXSTUDIOBONES];
static uint studio_hull_hitgroup[MAXSTUDIOBONES];
static uint cache_hull_hitgroup[MAXSTUDIOBONES];
static mstudiocache_t cache_studio[STUDIO_CACHESIZE];
static mplane_t studio_planes[MAXSTUDIOBONES * 6];
static mplane_t cache_planes[MAXSTUDIOBONES * 6];
static mclipnode_t studio_clipnodes[6];
static mplane_t studio_planes[768];
static mplane_t cache_planes[768];
// current cache state
static int cache_current;
@@ -65,14 +66,25 @@ Mod_InitStudioHull
*/
void Mod_InitStudioHull( void )
{
int i;
int i, side;
if( studio_hull[0].planes != NULL )
return; // already initailized
for( i = 0; i < 6; i++ )
{
studio_clipnodes[i].planenum = i;
side = i & 1;
studio_clipnodes[i].children[side] = CONTENTS_EMPTY;
if( i != 5 ) studio_clipnodes[i].children[side^1] = i + 1;
else studio_clipnodes[i].children[side^1] = CONTENTS_SOLID;
}
for( i = 0; i < MAXSTUDIOBONES; i++ )
{
studio_hull[i].clipnodes16 = (mclipnode16_t *)box_clipnodes16;
studio_hull[i].clipnodes = studio_clipnodes;
studio_hull[i].planes = &studio_planes[i*6];
studio_hull[i].firstclipnode = 0;
studio_hull[i].lastclipnode = 5;
@@ -258,11 +270,6 @@ hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t ang
for( i = j = 0; i < mod_studiohdr->numhitboxes; i++, j += 6 )
{
if( world.version == QBSP2_VERSION )
studio_hull[i].clipnodes32 = (mclipnode32_t *)box_clipnodes32;
else
studio_hull[i].clipnodes16 = (mclipnode16_t *)box_clipnodes16;
if( bSkipShield && i == 21 )
continue; // CS stuff

View File

@@ -326,7 +326,7 @@ static int HTTP_FileConnect( httpfile_t *file )
if( !COM_CheckStringEmpty( http_useragent.string ) || !Q_strcmp( http_useragent.string, "xash3d" ))
{
Q_snprintf( useragent, sizeof( useragent ), "%s/%s (%s-%s; build %d; %s)",
XASH_ENGINE_NAME, XASH_VERSION, Q_buildos( ), Q_buildarch( ), Q_buildnum( ), g_buildcommit );
XASH_ENGINE_NAME, XASH_VERSION, Q_buildos( ), Q_buildarch( ), Q_buildnum( ), Q_buildcommit( ));
}
else Q_strncpy( useragent, http_useragent.string, sizeof( useragent ));

View File

@@ -112,9 +112,6 @@ msurface_t *PM_RecursiveSurfCheck( model_t *mod, mnode_t *node, vec3_t p1, vec3_
int i, side;
msurface_t *surf;
vec3_t mid;
mnode_t *children[2];
int numsurfaces, firstsurface;
loc0:
if( node->contents < 0 )
return NULL;
@@ -122,17 +119,15 @@ loc0:
t1 = PlaneDiff( p1, node->plane );
t2 = PlaneDiff( p2, node->plane );
node_children( children, node, mod );
if( t1 >= -FRAC_EPSILON && t2 >= -FRAC_EPSILON )
{
node = children[0];
node = node->children[0];
goto loc0;
}
if( t1 < FRAC_EPSILON && t2 < FRAC_EPSILON )
{
node = children[1];
node = node->children[1];
goto loc0;
}
@@ -142,15 +137,13 @@ loc0:
VectorLerp( p1, frac, p2, mid );
if(( surf = PM_RecursiveSurfCheck( mod, children[side], p1, mid )) != NULL )
if(( surf = PM_RecursiveSurfCheck( mod, node->children[side], p1, mid )) != NULL )
return surf;
// walk through real faces
numsurfaces = node_numsurfaces( node, mod );
firstsurface = node_firstsurface( node, mod );
for( i = 0; i < numsurfaces; i++ )
for( i = 0; i < node->numsurfaces; i++ )
{
msurface_t *surf = &mod->surfaces[firstsurface + i];
msurface_t *surf = &mod->surfaces[node->firstsurface + i];
mextrasurf_t *info = surf->info;
mfacebevel_t *fb = info->bevel;
int j, contents;
@@ -179,7 +172,7 @@ loc0:
return NULL; // through the fence
}
return PM_RecursiveSurfCheck( mod, children[side^1], mid, p2 );
return PM_RecursiveSurfCheck( mod, node->children[side^1], mid, p2 );
}
/*
@@ -234,9 +227,6 @@ static int PM_TestLine_r( model_t *mod, mnode_t *node, vec_t p1f, vec_t p2f, con
float frac, midf;
int i, r, side;
vec3_t mid;
mnode_t *children[2];
int numsurfaces, firstsurface;
loc0:
if( node->contents < 0 )
{
@@ -252,17 +242,15 @@ loc0:
front = PlaneDiff( start, node->plane );
back = PlaneDiff( stop, node->plane );
node_children( children, node, mod );
if( front >= -FRAC_EPSILON && back >= -FRAC_EPSILON )
{
node = children[0];
node = node->children[0];
goto loc0;
}
if( front < FRAC_EPSILON && back < FRAC_EPSILON )
{
node = children[1];
node = node->children[1];
goto loc0;
}
@@ -273,7 +261,7 @@ loc0:
VectorLerp( start, frac, stop, mid );
midf = p1f + ( p2f - p1f ) * frac;
r = PM_TestLine_r( mod, children[side], p1f, midf, start, mid, trace );
r = PM_TestLine_r( mod, node->children[side], p1f, midf, start, mid, trace );
if( r != CONTENTS_EMPTY )
{
@@ -284,11 +272,9 @@ loc0:
}
// walk through real faces
numsurfaces = node_numsurfaces( node, mod );
firstsurface = node_firstsurface( node, mod );
for( i = 0; i < numsurfaces; i++ )
for( i = 0; i < node->numsurfaces; i++ )
{
msurface_t *surf = &mod->surfaces[firstsurface + i];
msurface_t *surf = &mod->surfaces[node->firstsurface + i];
mextrasurf_t *info = surf->info;
mfacebevel_t *fb = info->bevel;
int j, contents;
@@ -322,7 +308,7 @@ loc0:
return contents;
}
return PM_TestLine_r( mod, children[!side], midf, p2f, mid, stop, trace );
return PM_TestLine_r( mod, node->children[!side], midf, p2f, mid, stop, trace );
}
int PM_TestLineExt( playermove_t *pmove, physent_t *ents, int numents, const vec3_t start, const vec3_t end, int flags )

View File

@@ -25,7 +25,8 @@ GNU General Public License for more details.
#define PM_AllowHitBoxTrace( model, hull ) ( model && model->type == mod_studio && ( FBitSet( model->flags, STUDIO_TRACE_HITBOX ) || hull == 2 ))
static mplane_t pm_boxplanes[6];
static hull_t pm_boxhull;
static mclipnode_t pm_boxclipnodes[6];
static hull_t pm_boxhull;
// default hullmins
static const vec3_t pm_hullmins[MAX_MAP_HULLS] =
@@ -64,15 +65,23 @@ can just be stored out and get a proper hull_t structure.
*/
void PM_InitBoxHull( void )
{
int i;
int i, side;
pm_boxhull.clipnodes16 = (mclipnode16_t *)box_clipnodes16;
pm_boxhull.clipnodes = pm_boxclipnodes;
pm_boxhull.planes = pm_boxplanes;
pm_boxhull.firstclipnode = 0;
pm_boxhull.lastclipnode = 5;
for( i = 0; i < 6; i++ )
{
pm_boxclipnodes[i].planenum = i;
side = i & 1;
pm_boxclipnodes[i].children[side] = CONTENTS_EMPTY;
if( i != 5 ) pm_boxclipnodes[i].children[side^1] = i + 1;
else pm_boxclipnodes[i].children[side^1] = CONTENTS_SOLID;
pm_boxplanes[i].type = i>>1;
pm_boxplanes[i].normal[i>>1] = 1.0f;
pm_boxplanes[i].signbits = 0;
@@ -97,11 +106,6 @@ static hull_t *PM_HullForBox( const vec3_t mins, const vec3_t maxs )
pm_boxplanes[4].dist = maxs[2];
pm_boxplanes[5].dist = mins[2];
if( world.version == QBSP2_VERSION )
pm_boxhull.clipnodes32 = (mclipnode32_t *)box_clipnodes32;
else
pm_boxhull.clipnodes16 = (mclipnode16_t *)box_clipnodes16;
return &pm_boxhull;
}
@@ -118,21 +122,10 @@ int GAME_EXPORT PM_HullPointContents( hull_t *hull, int num, const vec3_t p )
if( !hull || !hull->planes ) // fantom bmodels?
return CONTENTS_NONE;
if( world.version == QBSP2_VERSION )
while( num >= 0 )
{
while( num >= 0 )
{
plane = &hull->planes[hull->clipnodes32[num].planenum];
num = hull->clipnodes32[num].children[PlaneDiff( p, plane ) < 0];
}
}
else
{
while( num >= 0 )
{
plane = &hull->planes[hull->clipnodes16[num].planenum];
num = hull->clipnodes16[num].children[PlaneDiff( p, plane ) < 0];
}
plane = &hull->planes[hull->clipnodes[num].planenum];
num = hull->clipnodes[num].children[PlaneDiff( p, plane ) < 0];
}
return num;
}
@@ -200,7 +193,7 @@ PM_RecursiveHullCheck
*/
qboolean PM_RecursiveHullCheck( hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, pmtrace_t *trace )
{
int children[2];
mclipnode_t *node;
mplane_t *plane;
float t1, t2;
float frac, midf;
@@ -233,31 +226,21 @@ loc0:
Host_Error( "%s: bad node number %i\n", __func__, num );
// find the point distances
if( world.version == QBSP2_VERSION )
{
children[0] = hull->clipnodes32[num].children[0];
children[1] = hull->clipnodes32[num].children[1];
plane = hull->planes + hull->clipnodes32[num].planenum;
}
else
{
children[0] = hull->clipnodes16[num].children[0];
children[1] = hull->clipnodes16[num].children[1];
plane = hull->planes + hull->clipnodes16[num].planenum;
}
node = hull->clipnodes + num;
plane = hull->planes + node->planenum;
t1 = PlaneDiff( p1, plane );
t2 = PlaneDiff( p2, plane );
if( t1 >= 0.0f && t2 >= 0.0f )
{
num = children[0];
num = node->children[0];
goto loc0;
}
if( t1 < 0.0f && t2 < 0.0f )
{
num = children[1];
num = node->children[1];
goto loc0;
}
@@ -274,14 +257,14 @@ loc0:
VectorLerp( p1, frac, p2, mid );
// move up to the node
if( !PM_RecursiveHullCheck( hull, children[side], p1f, midf, p1, mid, trace ))
if( !PM_RecursiveHullCheck( hull, node->children[side], p1f, midf, p1, mid, trace ))
return false;
// this recursion can not be optimized because mid would need to be duplicated on a stack
if( PM_HullPointContents( hull, children[side^1], mid ) != CONTENTS_SOLID )
if( PM_HullPointContents( hull, node->children[side^1], mid ) != CONTENTS_SOLID )
{
// go past the node
return PM_RecursiveHullCheck( hull, children[side^1], midf, p2f, mid, p2, trace );
return PM_RecursiveHullCheck( hull, node->children[side^1], midf, p2f, mid, p2, trace );
}
// never got out of the solid area

View File

@@ -109,44 +109,44 @@ void Sys_InitLog( void )
// fit to 80 columns for easier read on standard terminal
fputs( "================================================================================\n", s_ld.logfile );
fprintf( s_ld.logfile, "%s (%i, %s, %s, %s-%s)\n", s_ld.title, Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
fprintf( s_ld.logfile, "%s (%i, %s, %s, %s-%s)\n", s_ld.title, Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
fprintf( s_ld.logfile, "Game started at %s\n", Q_timestamp( TIME_FULL ));
fputs( "================================================================================\n", s_ld.logfile );
fflush( s_ld.logfile );
}
}
void Sys_CloseLog( const char *finalmsg )
void Sys_CloseLog( void )
{
Sys_FlushStdout(); // flush to stdout to ensure all data was written
if( !s_ld.logfile )
return;
char event_name[64];
// continue logged
if( !finalmsg )
switch( host.status )
{
switch( host.status )
{
case HOST_CRASHED:
finalmsg = "crashed";
break;
case HOST_ERR_FATAL:
finalmsg = "stopped with error";
break;
default:
finalmsg = "stopped";
break;
}
case HOST_CRASHED:
Q_strncpy( event_name, "crashed", sizeof( event_name ));
break;
case HOST_ERR_FATAL:
Q_strncpy( event_name, "stopped with error", sizeof( event_name ));
break;
default:
if( !host.change_game ) Q_strncpy( event_name, "stopped", sizeof( event_name ));
else Q_strncpy( event_name, host.finalmsg, sizeof( event_name ));
break;
}
fputc( '\n', s_ld.logfile );
fputs( "================================================================================\n", s_ld.logfile );
fprintf( s_ld.logfile, "%s (%i, %s, %s, %s-%s)\n", s_ld.title, Q_buildnum(), g_buildcommit, g_buildbranch, Q_buildos(), Q_buildarch());
fprintf( s_ld.logfile, "Stopped with reason \"%s\" at %s\n", finalmsg, Q_timestamp( TIME_FULL ));
fputs( "================================================================================\n", s_ld.logfile );
fclose( s_ld.logfile );
s_ld.logfile = NULL;
Sys_FlushStdout(); // flush to stdout to ensure all data was written
if( s_ld.logfile )
{
fputc( '\n', s_ld.logfile );
fputs( "================================================================================\n", s_ld.logfile );
fprintf( s_ld.logfile, "%s (%i, %s, %s, %s-%s)\n", s_ld.title, Q_buildnum(), Q_buildcommit(), Q_buildbranch(), Q_buildos(), Q_buildarch());
fprintf( s_ld.logfile, "Stopped with reason \"%s\" at %s\n", event_name, Q_timestamp( TIME_FULL ));
fputs( "================================================================================\n", s_ld.logfile );
fclose( s_ld.logfile );
s_ld.logfile = NULL;
}
}
#if XASH_COLORIZE_CONSOLE

View File

@@ -420,12 +420,6 @@ void Sys_Error( const char *error, ... )
_exit->_Exit->asm._exit->_exit
As we do not need atexit(), just throw hidden exception
*/
// Hey, you, making an Emscripten port!
// What if we're not supposed to use exit() on Emscripten and instead we should
// exit from the main() function? Would this fix this bug? Test this case, pls.
#error "Read the comment above"
#include <emscripten.h>
#define exit my_exit
void my_exit(int ret)
@@ -444,11 +438,7 @@ Sys_Quit
void Sys_Quit( const char *reason )
{
Host_ShutdownWithReason( reason );
#if XASH_ANDROID
Host_ExitInMain();
#else
exit( error_on_exit );
#endif
}
/*
@@ -539,7 +529,7 @@ but since engine will be unloaded during this call
it explicitly doesn't use internal allocation or string copy utils
==================
*/
qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
qboolean Sys_NewInstance( const char *gamedir )
{
#if XASH_NSWITCH
char newargs[4096];
@@ -550,7 +540,7 @@ qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
// just restart the entire thing
printf( "envSetNextLoad exe: `%s`\n", exe );
printf( "envSetNextLoad argv:\n`%s`\n", newargs );
Host_ShutdownWithReason( finalmsg );
Host_ShutdownWithReason( "changing game" );
envSetNextLoad( exe, newargs );
exit( 0 );
#else
@@ -588,7 +578,7 @@ qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
#if XASH_PSVITA
// under normal circumstances it's always going to be the same path
exe = strdup( "app0:/eboot.bin" );
Host_ShutdownWithReason( finalmsg );
Host_ShutdownWithReason( "changing game" );
sceAppMgrLoadExec( exe, newargs, NULL );
#else
exelen = wai_getExecutablePath( NULL, 0, NULL );
@@ -596,7 +586,7 @@ qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
wai_getExecutablePath( exe, exelen, NULL );
exe[exelen] = 0;
Host_ShutdownWithReason( finalmsg );
Host_ShutdownWithReason( "changing game" );
execv( exe, newargs );
#endif

View File

@@ -56,8 +56,11 @@ void Sys_DebugBreak( void );
qboolean _Sys_GetParmFromCmdLine( const char *parm, char *out, size_t size );
qboolean Sys_GetIntFromCmdLine( const char *parm, int *out );
void Sys_Print( const char *pMsg );
void Sys_PrintLog( const char *pMsg );
void Sys_InitLog( void );
void Sys_CloseLog( void );
void Sys_Quit( const char *reason ) NORETURN;
qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg );
qboolean Sys_NewInstance( const char *gamedir );
void *Sys_GetNativeObject( const char *obj );
//
@@ -65,7 +68,7 @@ void *Sys_GetNativeObject( const char *obj );
//
char *Sys_Input( void );
void Sys_DestroyConsole( void );
void Sys_CloseLog( const char *finalmsg );
void Sys_CloseLog( void );
void Sys_InitLog( void );
void Sys_PrintLog( const char *pMsg );
int Sys_LogFileNo( void );

View File

@@ -16,8 +16,11 @@
#ifndef EDICT_H
#define EDICT_H
#define MAX_ENT_LEAFS_32 24 // Orignally was 16
#define MAX_ENT_LEAFS_16 48
#ifdef SUPPORT_BSP2_FORMAT
#define MAX_ENT_LEAFS 24 // Orignally was 16
#else
#define MAX_ENT_LEAFS 48
#endif
#include "progdefs.h"
@@ -30,12 +33,11 @@ struct edict_s
int headnode; // -1 to use normal leaf check
int num_leafs;
union
{
int leafnums32[MAX_ENT_LEAFS_32];
short leafnums16[MAX_ENT_LEAFS_16];
};
#ifdef SUPPORT_BSP2_FORMAT
int leafnums[MAX_ENT_LEAFS];
#else
short leafnums[MAX_ENT_LEAFS];
#endif
float freetime; // sv.time when the object was freed
void* pvPrivateData; // Alloced and freed by engine, used by DLLs

View File

@@ -113,7 +113,7 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
// safe actions first, stack and memory may be corrupted
len = Q_snprintf( message, sizeof( message ), "Ver: " XASH_ENGINE_NAME " " XASH_VERSION " (build %i-%s, %s-%s)\n",
Q_buildnum(), g_buildcommit, Q_buildos(), Q_buildarch() );
Q_buildnum(), Q_buildcommit(), Q_buildos(), Q_buildarch() );
#if !XASH_FREEBSD && !XASH_NETBSD && !XASH_OPENBSD
len += Q_snprintf( message + len, sizeof( message ) - len, "Crash: signal %d errno %d with code %d at %p %p\n", signal, si->si_errno, si->si_code, si->si_addr, si->si_ptr );

View File

@@ -41,54 +41,8 @@ void Platform_MessageBox( const char *title, const char *message, qboolean paren
}
#endif // XASH_MESSAGEBOX == MSGBOX_SDL
static const char *SDLash_CategoryToString( int category )
{
switch( category )
{
case SDL_LOG_CATEGORY_APPLICATION: return "App";
case SDL_LOG_CATEGORY_ERROR: return "Error";
case SDL_LOG_CATEGORY_ASSERT: return "Assert";
case SDL_LOG_CATEGORY_SYSTEM: return "System";
case SDL_LOG_CATEGORY_AUDIO: return "Audio";
case SDL_LOG_CATEGORY_VIDEO: return "Video";
case SDL_LOG_CATEGORY_RENDER: return "Render";
case SDL_LOG_CATEGORY_INPUT: return "Input";
case SDL_LOG_CATEGORY_TEST: return "Test";
default: return "Unknown";
}
}
static void SDLCALL SDLash_LogOutputFunction( void *userdata, int category, SDL_LogPriority priority, const char *message )
{
switch( priority )
{
case SDL_LOG_PRIORITY_CRITICAL:
case SDL_LOG_PRIORITY_ERROR:
Con_Printf( S_ERROR S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", SDLash_CategoryToString( category ), message );
break;
case SDL_LOG_PRIORITY_WARN:
Con_DPrintf( S_WARN S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", SDLash_CategoryToString( category ), message );
break;
case SDL_LOG_PRIORITY_INFO:
Con_Reportf( S_NOTE S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", SDLash_CategoryToString( category ), message );
break;
default:
Con_Reportf( S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", SDLash_CategoryToString( category ), message );
break;
}
}
void SDLash_Init( void )
{
SDL_LogSetOutputFunction( SDLash_LogOutputFunction, NULL );
if( host_developer.value >= 2 )
SDL_LogSetAllPriority( SDL_LOG_PRIORITY_VERBOSE );
else if( host_developer.value >= 1 )
SDL_LogSetAllPriority( SDL_LOG_PRIORITY_WARN );
else
SDL_LogSetAllPriority( SDL_LOG_PRIORITY_ERROR );
#ifndef SDL_INIT_EVENTS
#define SDL_INIT_EVENTS 0
#endif

View File

@@ -588,7 +588,7 @@ void Wcon_DestroyConsole( void )
// last text message into console or log
Con_Reportf( "%s: Unloading xash.dll\n", __func__ );
Sys_CloseLog( NULL );
Sys_CloseLog();
if( !s_wcd.attached )
{

View File

@@ -138,7 +138,7 @@ static void Sys_StackTrace( PEXCEPTION_POINTERS pInfo )
#endif
len = Q_snprintf( message, sizeof( message ), "Ver: " XASH_ENGINE_NAME " " XASH_VERSION " (build %i-%s, %s-%s)\n",
Q_buildnum(), g_buildcommit, Q_buildos(), Q_buildarch() );
Q_buildnum(), Q_buildcommit(), Q_buildos(), Q_buildarch() );
len += Q_snprintf( message + len, 1024 - len, "Sys_Crash: address %p, code %p\n",
pInfo->ExceptionRecord->ExceptionAddress, (void*)pInfo->ExceptionRecord->ExceptionCode );
@@ -213,14 +213,14 @@ static void Sys_GetMinidumpFileName( const char *processName, char *mdmpFileName
struct tm *currentLocalTime = localtime( &currentUtcTime );
Q_snprintf( mdmpFileName, bufferSize, "%s_%s_crash_%d%.2d%.2d_%.2d%.2d%.2d.mdmp",
processName,
g_buildcommit,
currentLocalTime->tm_year + 1900,
currentLocalTime->tm_mon + 1,
currentLocalTime->tm_mday,
currentLocalTime->tm_hour,
currentLocalTime->tm_min,
currentLocalTime->tm_sec );
processName,
Q_buildcommit(),
currentLocalTime->tm_year + 1900,
currentLocalTime->tm_mon + 1,
currentLocalTime->tm_mday,
currentLocalTime->tm_hour,
currentLocalTime->tm_min,
currentLocalTime->tm_sec);
}
static qboolean Sys_WriteMinidump(PEXCEPTION_POINTERS exceptionInfo, MINIDUMP_TYPE minidumpType)

View File

@@ -80,7 +80,6 @@ GNU General Public License for more details.
#define MODEL_LIQUID BIT( 2 ) // model has only point hull
#define MODEL_TRANSPARENT BIT( 3 ) // have transparent surfaces
#define MODEL_COLORED_LIGHTING BIT( 4 ) // lightmaps stored as RGB
#define MODEL_WORLD BIT( 29 ) // it's a worldmodel
#define MODEL_CLIENT BIT( 30 ) // client sprite

View File

@@ -67,8 +67,6 @@ extern int SV_UPDATE_BACKUP;
#define MAX_PUSHED_ENTS 256
#define MAX_VIEWENTS 128
#define MAX_ENT_LEAFS( ext ) (( ext ) ? MAX_ENT_LEAFS_32 : MAX_ENT_LEAFS_16 )
#define FCL_RESEND_USERINFO BIT( 0 )
#define FCL_RESEND_MOVEVARS BIT( 1 )
#define FCL_SKIP_NET_MESSAGE BIT( 2 )
@@ -498,24 +496,10 @@ qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent );
qboolean SV_InitGame( void );
void SV_ActivateServer( int runPhysics );
qboolean SV_SpawnServer( const char *server, const char *startspot, qboolean background );
model_t *SV_ModelHandle( int modelindex );
void SV_DeactivateServer( void );
void SV_FreeTestPacket( void );
/*
================
SV_ModelHandle
get model by handle
================
*/
static inline model_t *GAME_EXPORT SV_ModelHandle( int modelindex )
{
if( modelindex < 0 || modelindex >= MAX_MODELS )
return NULL;
return sv.models[modelindex];
}
//
// sv_phys.c
//
@@ -687,6 +671,7 @@ void SV_ClearGameState( void );
// sv_pmove.c
//
void SV_InitClientMove( void );
qboolean SV_PlayerIsFrozen( edict_t *pClient );
void SV_RunCmd( sv_client_t *cl, usercmd_t *ucmd, int random_seed );
//

View File

@@ -477,7 +477,7 @@ static void SV_ConnectClient( netadr_t from )
// reset stats
newcl->next_checkpingtime = -1.0;
newcl->packet_loss = 0;
newcl->packet_loss = 0.0f;
// if this was the first client on the server, or the last client
// the server can hold, send a heartbeat to the master.
@@ -1170,7 +1170,7 @@ SV_EstablishTimeBase
Finangles latency and the like.
===================
*/
static void SV_EstablishTimeBase( sv_client_t *cl, const usercmd_t *cmds, int dropped, int numbackup, int numcmds )
static void SV_EstablishTimeBase( sv_client_t *cl, usercmd_t *cmds, int dropped, int numbackup, int numcmds )
{
double runcmd_time = 0.0;
int i, cmdnum = dropped;
@@ -2226,7 +2226,7 @@ SV_SendBuildInfo_f
static qboolean SV_SendBuildInfo_f( sv_client_t *cl )
{
SV_ClientPrintf( cl, "Server running " XASH_ENGINE_NAME " " XASH_VERSION " (build %i-%s, %s-%s)\n",
Q_buildnum(), g_buildcommit, Q_buildos(), Q_buildarch() );
Q_buildnum(), Q_buildcommit(), Q_buildos(), Q_buildarch() );
return true;
}
@@ -3212,20 +3212,6 @@ void SV_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
}
}
static qboolean SV_PlayerIsFrozen( const edict_t *pClient )
{
if( sv_background_freeze.value && sv.background )
return true;
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
return false;
if( FBitSet( pClient->v.flags, FL_FROZEN ))
return true;
return false;
}
/*
==================
SV_ParseClientMove
@@ -3240,20 +3226,29 @@ each of the backup packets.
*/
static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg )
{
const usercmd_t nullcmd = { 0 }, *from = &nullcmd; // first cmd are starting from null-compressed usercmd_t
client_frame_t *frame = &cl->frames[cl->netchan.incoming_acknowledged & SV_UPDATE_MASK];
usercmd_t cmds[CMD_BACKUP] = { 0 }, *to;
edict_t *player = cl->edict;
model_t *model;
client_frame_t *frame;
int key, size, checksum1, checksum2;
int i, numbackup, totalcmds, numcmds;
usercmd_t nullcmd, *to, *from;
usercmd_t cmds[CMD_BACKUP];
float packet_loss;
edict_t *player;
model_t *model;
int key = MSG_GetRealBytesRead( msg );
int checksum1 = MSG_ReadByte( msg );
int packet_loss = MSG_ReadByte( msg );
int numbackup = MSG_ReadByte( msg );
int numcmds = MSG_ReadByte( msg );
int totalcmds = numcmds + numbackup;
int i;
player = cl->edict;
frame = &cl->frames[cl->netchan.incoming_acknowledged & SV_UPDATE_MASK];
memset( &nullcmd, 0, sizeof( usercmd_t ));
memset( cmds, 0, sizeof( cmds ));
key = MSG_GetRealBytesRead( msg );
checksum1 = MSG_ReadByte( msg );
packet_loss = MSG_ReadByte( msg );
numbackup = MSG_ReadByte( msg );
numcmds = MSG_ReadByte( msg );
totalcmds = numcmds + numbackup;
net_drop -= (numcmds - 1);
if( totalcmds < 0 || totalcmds >= CMD_MASK )
@@ -3263,6 +3258,8 @@ static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg )
return;
}
from = &nullcmd; // first cmd are starting from null-compressed usercmd_t
for( i = totalcmds - 1; i >= 0; i-- )
{
to = &cmds[i];
@@ -3273,17 +3270,14 @@ static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg )
if( cl->state != cs_spawned )
return;
if( !Host_IsLocalClient( ))
{
// if the checksum fails, ignore the rest of the packet
int size = MSG_GetRealBytesRead( msg ) - key - 1;
int checksum2 = CRC32_BlockSequence( msg->pData + key + 1, size, cl->netchan.incoming_sequence );
// if the checksum fails, ignore the rest of the packet
size = MSG_GetRealBytesRead( msg ) - key - 1;
checksum2 = CRC32_BlockSequence( msg->pData + key + 1, size, cl->netchan.incoming_sequence );
if( checksum2 != checksum1 )
{
Con_Reportf( S_ERROR "%s: failed command checksum for %s (%d != %d)\n", __func__, cl->name, checksum2, checksum1 );
return;
}
if( checksum2 != checksum1 )
{
Con_Reportf( S_ERROR "%s: failed command checksum for %s (%d != %d)\n", __func__, cl->name, checksum2, checksum1 );
return;
}
cl->packet_loss = packet_loss;

View File

@@ -492,15 +492,14 @@ SV_EmitPings
*/
static void SV_EmitPings( sizebuf_t *msg )
{
sv_client_t *cl;
int i;
sv_client_t *cl;
int packet_loss;
int i, ping;
MSG_BeginServerCmd( msg, svc_pings );
for( i = 0, cl = svs.clients; i < svs.maxclients; i++, cl++ )
{
int packet_loss, ping;
if( cl->state != cs_spawned )
continue;

View File

@@ -328,7 +328,7 @@ static qboolean SV_CheckClientVisiblity( sv_client_t *cl, const byte *mask )
else
VectorCopy( cl->edict->v.origin, vieworg );
leaf = Mod_PointInLeaf( vieworg, sv.worldmodel->nodes, sv.worldmodel );
leaf = Mod_PointInLeaf( vieworg, sv.worldmodel->nodes );
if( CHECKVISBIT( mask, leaf->cluster ))
return true; // visible from player view or camera view
@@ -342,7 +342,7 @@ static qboolean SV_CheckClientVisiblity( sv_client_t *cl, const byte *mask )
continue;
VectorAdd( view->v.origin, view->v.view_ofs, vieworg );
leaf = Mod_PointInLeaf( vieworg, sv.worldmodel->nodes, sv.worldmodel );
leaf = Mod_PointInLeaf( vieworg, sv.worldmodel->nodes );
if( CHECKVISBIT( mask, leaf->cluster ))
return true; // visible from portal camera view
@@ -1732,7 +1732,7 @@ static edict_t* GAME_EXPORT pfnFindClientInPVS( edict_t *pEdict )
VectorAdd( pEdict->v.origin, pEdict->v.view_ofs, view );
}
leaf = Mod_PointInLeaf( view, sv.worldmodel->nodes, sv.worldmodel );
leaf = Mod_PointInLeaf( view, sv.worldmodel->nodes );
if( CHECKVISBIT( clientpvs, leaf->cluster ))
return pClient; // client which currently in PVS
@@ -4291,35 +4291,6 @@ static byte *GAME_EXPORT pfnSetFatPAS( const float *org )
return fatphs;
}
/*
=============
Mod_HeadnodeVisible
=============
*/
static qboolean Mod_HeadnodeVisible( model_t *mod, mnode_t *node, const byte *visbits, int *lastleaf )
{
if( !node || node->contents == CONTENTS_SOLID )
return false;
if( node->contents < 0 )
{
if( !CHECKVISBIT( visbits, ((mleaf_t *)node)->cluster ))
return false;
if( lastleaf )
*lastleaf = ((mleaf_t *)node)->cluster;
return true;
}
if( Mod_HeadnodeVisible( mod, node_child( node, 0, mod ), visbits, lastleaf ))
return true;
if( Mod_HeadnodeVisible( mod, node_child( node, 1, mod ), visbits, lastleaf ))
return true;
return false;
}
/*
=============
pfnCheckVisibility
@@ -4329,7 +4300,6 @@ pfnCheckVisibility
static int GAME_EXPORT pfnCheckVisibility( const edict_t *ent, byte *pset )
{
int i, leafnum;
qboolean large_leafs = FBitSet( sv.worldmodel->flags, MODEL_QBSP2 );
if( !SV_IsValidEdict( ent ))
return 0;
@@ -4345,28 +4315,17 @@ static int GAME_EXPORT pfnCheckVisibility( const edict_t *ent, byte *pset )
// check individual leafs
for( i = 0; i < ent->num_leafs; i++ )
{
if( large_leafs )
{
if( CHECKVISBIT( pset, ent->leafnums32[i] ))
return 1; // visible passed by leaf
}
else
{
if( CHECKVISBIT( pset, ent->leafnums16[i] ))
return 1; // visible passed by leaf
}
if( CHECKVISBIT( pset, ent->leafnums[i] ))
return 1; // visible passed by leaf
}
return 0;
}
else
{
for( i = 0; i < MAX_ENT_LEAFS( large_leafs ); i++ )
for( i = 0; i < MAX_ENT_LEAFS; i++ )
{
if( large_leafs )
leafnum = ent->leafnums32[i];
else
leafnum = ent->leafnums16[i];
leafnum = ent->leafnums[i];
if( leafnum == -1 ) break;
if( CHECKVISBIT( pset, leafnum ))
@@ -4374,15 +4333,11 @@ static int GAME_EXPORT pfnCheckVisibility( const edict_t *ent, byte *pset )
}
// too many leafs for individual check, go by headnode
if( !Mod_HeadnodeVisible( sv.worldmodel, &sv.worldmodel->nodes[ent->headnode], pset, &leafnum ))
if( !Mod_HeadnodeVisible( &sv.worldmodel->nodes[ent->headnode], pset, &leafnum ))
return 0;
if( large_leafs )
((edict_t *)ent)->leafnums32[ent->num_leafs] = leafnum;
else
((edict_t *)ent)->leafnums16[ent->num_leafs] = leafnum;
((edict_t *)ent)->num_leafs = (ent->num_leafs + 1) % MAX_ENT_LEAFS( large_leafs );
((edict_t *)ent)->leafnums[ent->num_leafs] = leafnum;
((edict_t *)ent)->num_leafs = (ent->num_leafs + 1) % MAX_ENT_LEAFS;
return 2; // visible passed by headnode
}

View File

@@ -273,6 +273,20 @@ int GAME_EXPORT SV_GenericIndex( const char *filename )
return i;
}
/*
================
SV_ModelHandle
get model by handle
================
*/
model_t *GAME_EXPORT SV_ModelHandle( int modelindex )
{
if( modelindex < 0 || modelindex >= MAX_MODELS )
return NULL;
return sv.models[modelindex];
}
static resourcetype_t SV_DetermineResourceType( const char *filename )
{
if( !Q_strncmp( filename, DEFAULT_SOUNDPATH, sizeof( DEFAULT_SOUNDPATH ) - 1 ) && Sound_SupportedFileFormat( COM_FileExtension( filename )))

View File

@@ -970,7 +970,7 @@ void SV_Init( void )
MSG_Init( &net_message, "NetMessage", net_message_buffer, sizeof( net_message_buffer ));
Q_snprintf( versionString, sizeof( versionString ), XASH_ENGINE_NAME ": " XASH_VERSION "-%s(%s-%s),%i,%i",
g_buildcommit, Q_buildos(), Q_buildarch(), PROTOCOL_VERSION, Q_buildnum() );
Q_buildcommit(), Q_buildos(), Q_buildarch(), PROTOCOL_VERSION, Q_buildnum() );
Cvar_FullSet( "sv_version", versionString, FCVAR_READ_ONLY );

View File

@@ -23,6 +23,19 @@ GNU General Public License for more details.
static qboolean has_update = false;
static void SV_GetTrueOrigin( sv_client_t *cl, int edictnum, vec3_t origin );
qboolean SV_PlayerIsFrozen( edict_t *pClient )
{
if( sv_background_freeze.value && sv.background )
return true;
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
return false;
if( FBitSet( pClient->v.flags, FL_FROZEN ))
return true;
return false;
}
void SV_ClipPMoveToEntity( physent_t *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, pmtrace_t *tr )
{
Assert( tr != NULL );

View File

@@ -40,8 +40,9 @@ HULL BOXES
===============================================================================
*/
static hull_t box_hull;
static mplane_t box_planes[6];
static hull_t box_hull;
static mclipnode_t box_clipnodes[6];
static mplane_t box_planes[6];
/*
===================
@@ -53,15 +54,23 @@ can just be stored out and get a proper hull_t structure.
*/
static void SV_InitBoxHull( void )
{
int i;
int i, side;
box_hull.clipnodes16 = (mclipnode16_t *)box_clipnodes16;
box_hull.clipnodes = box_clipnodes;
box_hull.planes = box_planes;
box_hull.firstclipnode = 0;
box_hull.lastclipnode = 5;
for( i = 0; i < 6; i++ )
{
box_clipnodes[i].planenum = i;
side = i & 1;
box_clipnodes[i].children[side] = CONTENTS_EMPTY;
if( i != 5 ) box_clipnodes[i].children[side^1] = i + 1;
else box_clipnodes[i].children[side^1] = CONTENTS_SOLID;
box_planes[i].type = i>>1;
box_planes[i].normal[i>>1] = 1;
box_planes[i].signbits = 0;
@@ -158,11 +167,6 @@ static hull_t *SV_HullForBox( const vec3_t mins, const vec3_t maxs )
box_planes[4].dist = maxs[2];
box_planes[5].dist = mins[2];
if( world.version == QBSP2_VERSION )
box_hull.clipnodes32 = (mclipnode32_t *)box_clipnodes32;
else
box_hull.clipnodes16 = (mclipnode16_t *)box_clipnodes16;
return &box_hull;
}
@@ -590,7 +594,7 @@ SV_FindTouchedLeafs
===============
*/
static void SV_FindTouchedLeafs( edict_t *ent, model_t *mod, mnode_t *node, int *headnode )
static void SV_FindTouchedLeafs( edict_t *ent, mnode_t *node, int *headnode )
{
int sides;
mleaf_t *leaf;
@@ -601,19 +605,16 @@ static void SV_FindTouchedLeafs( edict_t *ent, model_t *mod, mnode_t *node, int
// add an efrag if the node is a leaf
if( node->contents < 0 )
{
if( ent->num_leafs > MAX_ENT_LEAFS( FBitSet( mod->flags, MODEL_QBSP2 )))
if( ent->num_leafs > ( MAX_ENT_LEAFS - 1 ))
{
// continue counting leafs,
// so we know how many it's overrun
ent->num_leafs = (MAX_ENT_LEAFS( FBitSet( mod->flags, MODEL_QBSP2 )) + 1);
ent->num_leafs = (MAX_ENT_LEAFS + 1);
}
else
{
leaf = (mleaf_t *)node;
if( FBitSet( mod->flags, MODEL_QBSP2 ))
ent->leafnums32[ent->num_leafs] = leaf->cluster;
else
ent->leafnums16[ent->num_leafs] = leaf->cluster;
ent->leafnums[ent->num_leafs] = leaf->cluster;
ent->num_leafs++;
}
return;
@@ -623,13 +624,11 @@ static void SV_FindTouchedLeafs( edict_t *ent, model_t *mod, mnode_t *node, int
sides = BOX_ON_PLANE_SIDE( ent->v.absmin, ent->v.absmax, node->plane );
if(( sides == 3 ) && ( *headnode == -1 ))
*headnode = node - mod->nodes;
*headnode = node - sv.worldmodel->nodes;
// recurse down the contacted sides
if( sides & 1 )
SV_FindTouchedLeafs( ent, mod, node_child( node, 0, mod ), headnode );
if( sides & 2 )
SV_FindTouchedLeafs( ent, mod, node_child( node, 1, mod ), headnode );
if( sides & 1 ) SV_FindTouchedLeafs( ent, node->children[0], headnode );
if( sides & 2 ) SV_FindTouchedLeafs( ent, node->children[1], headnode );
}
/*
@@ -651,7 +650,7 @@ void GAME_EXPORT SV_LinkEdict( edict_t *ent, qboolean touch_triggers )
if( ent->v.movetype == MOVETYPE_FOLLOW && SV_IsValidEdict( ent->v.aiment ))
{
memcpy( ent->leafnums32, ent->v.aiment->leafnums32, sizeof( ent->leafnums32 ));
memcpy( ent->leafnums, ent->v.aiment->leafnums, sizeof( ent->leafnums ));
ent->num_leafs = ent->v.aiment->num_leafs;
ent->headnode = ent->v.aiment->headnode;
}
@@ -663,11 +662,11 @@ void GAME_EXPORT SV_LinkEdict( edict_t *ent, qboolean touch_triggers )
headnode = -1;
if( ent->v.modelindex )
SV_FindTouchedLeafs( ent, sv.worldmodel, sv.worldmodel->nodes, &headnode );
SV_FindTouchedLeafs( ent, sv.worldmodel->nodes, &headnode );
if( ent->num_leafs > MAX_ENT_LEAFS( FBitSet( sv.worldmodel->flags, MODEL_QBSP2 )))
if( ent->num_leafs > MAX_ENT_LEAFS )
{
memset( ent->leafnums32, -1, sizeof( ent->leafnums32 ));
memset( ent->leafnums, -1, sizeof( ent->leafnums ));
ent->num_leafs = 0; // so we use headnode instead
ent->headnode = headnode;
}
@@ -1519,8 +1518,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
float front, back, frac;
int i, side;
vec3_t mid;
mnode_t *children[2];
int numsurfaces, firstsurface;
// didn't hit anything
if( !node || node->contents < 0 )
@@ -1530,29 +1527,25 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
front = PlaneDiff( start, node->plane );
back = PlaneDiff( end, node->plane );
node_children( children, node, model );
side = front < 0.0f;
if(( back < 0.0f ) == side )
return SV_RecursiveLightPoint( model, children[side], start, end, point_color );
return SV_RecursiveLightPoint( model, node->children[side], start, end, point_color );
frac = front / ( front - back );
VectorLerp( start, frac, end, mid );
// co down front side
if( SV_RecursiveLightPoint( model, children[side], start, mid, point_color ))
if( SV_RecursiveLightPoint( model, node->children[side], start, mid, point_color ))
return true; // hit something
if(( back < 0.0f ) == side )
return false; // didn't hit anything
// check for impact on this node
numsurfaces = node_numsurfaces( node, model );
firstsurface = node_firstsurface( node, model );
for( i = 0; i < numsurfaces; i++ )
for( i = 0; i < node->numsurfaces; i++ )
{
const msurface_t *surf = &model->surfaces[firstsurface + i];
const msurface_t *surf = &model->surfaces[node->firstsurface + i];
const mextrasurf_t *info = surf->info;
int smax, tmax, map, size;
int sample_size;
@@ -1603,7 +1596,7 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
}
// go down back side
return SV_RecursiveLightPoint( model, children[!side], mid, end, point_color );
return SV_RecursiveLightPoint( model, node->children[!side], mid, end, point_color );
}
/*

View File

@@ -57,12 +57,6 @@ static qboolean Platform_GetDirectoryCaseSensitivity( const char *dir )
{
#if XASH_WIN32 || XASH_PSVITA || XASH_NSWITCH
return false;
#elif XASH_ANDROID
// on Android, doing code below causes crash in MediaProviderGoogle.apk!libfuse_jni.so
// which in turn makes vold (Android's Volume Daemon) to umount /storage/emulated/0
// and because you can't unmount a filesystem when there is file descriptors open
// it has no other choice but to terminate and then kill our program
return true;
#elif XASH_LINUX && defined( FS_IOC_GETFLAGS )
int flags = 0;
int fd;
@@ -72,10 +66,7 @@ static qboolean Platform_GetDirectoryCaseSensitivity( const char *dir )
return true;
if( ioctl( fd, FS_IOC_GETFLAGS, &flags ) < 0 )
{
close( fd );
return true;
}
close( fd );

View File

@@ -529,7 +529,7 @@ static qboolean FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
if( !f )
return false;
FS_Printf( f, "// generated by " XASH_ENGINE_NAME " " XASH_VERSION "-%s (%s-%s)\n\n\n", g_buildcommit, Q_buildos(), Q_buildarch() );
FS_Printf( f, "// generated by " XASH_ENGINE_NAME " " XASH_VERSION "-%s (%s-%s)\n\n\n", Q_buildcommit(), Q_buildos(), Q_buildarch() );
if( COM_CheckStringEmpty( GameInfo->basedir ) )
FS_Printf( f, "basedir\t\t\"%s\"\n", GameInfo->basedir );
@@ -2705,20 +2705,25 @@ qboolean CRC32_File( dword *crcvalue, const char *filename )
qboolean MD5_HashFile( byte digest[16], const char *pszFileName, uint seed[4] )
{
file_t *file;
MD5Context_t MD5_Hash = { 0 };
byte buffer[1024];
MD5Context_t MD5_Hash;
int bytes;
if(( file = FS_Open( pszFileName, "rb", false )) == NULL )
return false;
memset( &MD5_Hash, 0, sizeof( MD5Context_t ));
MD5Init( &MD5_Hash );
if( seed )
{
MD5Update( &MD5_Hash, (const byte *)seed, 16 );
}
while( 1 )
{
byte buffer[1024];
int bytes = FS_Read( file, buffer, sizeof( buffer ));
bytes = FS_Read( file, buffer, sizeof( buffer ));
if( bytes > 0 )
MD5Update( &MD5_Hash, buffer, bytes );

View File

@@ -239,3 +239,29 @@ const char *Q_buildarch( void )
);
}
/*
=============
Q_buildcommit
Returns a short hash of current commit in VCS as string
XASH_BUILD_COMMIT must be passed in quotes
=============
*/
const char *Q_buildcommit( void )
{
return XASH_BUILD_COMMIT;
}
/*
=============
Q_buildbranch
Returns current branch name in VCS as string
XASH_BUILD_BRANCH must be passed in quotes
=============
*/
const char *Q_buildbranch( void )
{
return XASH_BUILD_BRANCH;
}

View File

@@ -1,18 +0,0 @@
/*
build_vcs.c - info from VCS
Copyright (C) 2025 Alibek Omarov
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
const char *g_buildcommit = XASH_BUILD_COMMIT;
const char *g_buildbranch = XASH_BUILD_BRANCH;

View File

@@ -62,8 +62,8 @@ const char *Q_PlatformStringByID( const int platform );
const char *Q_buildos( void );
const char *Q_ArchitectureStringByID( const int arch, const uint abi, const int endianness, const qboolean is64 );
const char *Q_buildarch( void );
extern const char *g_buildcommit;
extern const char *g_buildbranch;
const char *Q_buildcommit( void );
const char *Q_buildbranch( void );
//
// crtlib.c

View File

@@ -67,6 +67,8 @@ def options(opt):
def configure(conf):
# private to libpublic
conf.load('gitversion')
conf.define('XASH_BUILD_COMMIT', conf.env.GIT_VERSION if conf.env.GIT_VERSION else 'unknown-commit')
conf.define('XASH_BUILD_BRANCH', conf.env.GIT_BRANCH if conf.env.GIT_BRANCH else 'unknown-branch')
conf.env.VALIDATE_TARGET = conf.options.VALIDATE_TARGET
# need to expose it for everyone using libpublic headers
@@ -118,14 +120,9 @@ def build(bld):
export_includes = '. ../common ../pm_shared ../engine',
export_defines = bld.env.EXPORT_DEFINES_LIST)
# build it separately to slightly improve rebuild times
bld.stlib(source = 'build_vcs.c',
target = 'build_vcs',
defines = ['XASH_BUILD_COMMIT=\"%s\"' % bld.env.GIT_VERSION, 'XASH_BUILD_BRANCH=\"%s\"' % bld.env.GIT_BRANCH])
bld.stlib(source = bld.path.ant_glob('*.c', excl='build_vcs.c'),
target = 'public',
use = 'sdk_includes werror build_vcs')
bld.stlib(source = bld.path.ant_glob('*.c'),
target = 'public',
use = 'sdk_includes werror')
if bld.env.TESTS:
if bld.env.VALIDATE_TARGET:

View File

@@ -670,14 +670,10 @@ static void R_DecalNodeSurfaces( model_t *model, mnode_t *node, decalinfo_t *dec
// iterate over all surfaces in the node
msurface_t *surf;
int i;
int firstsurface, numsurfaces;
firstsurface = node_firstsurface( node, model );
numsurfaces = node_numsurfaces( node, model );
surf = model->surfaces + node->firstsurface;
surf = model->surfaces + firstsurface;
for( i = 0; i < numsurfaces; i++, surf++ )
for( i = 0; i < node->numsurfaces; i++, surf++ )
{
// never apply decals on the water or sky surfaces
if( surf->flags & (SURF_DRAWTURB|SURF_DRAWSKY|SURF_CONVEYOR))
@@ -699,7 +695,6 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
{
mplane_t *splitplane;
float dist;
mnode_t *children[2];
Assert( node != NULL );
@@ -711,7 +706,6 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
splitplane = node->plane;
dist = DotProduct( decalinfo->m_Position, splitplane->normal ) - splitplane->dist;
node_children( children, node, model );
// This is arbitrarily set to 10 right now. In an ideal world we'd have the
// exact surface but we don't so, this tells me which planes are "sort of
@@ -723,19 +717,19 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
// have a surface normal
if( dist > decalinfo->m_Size )
{
R_DecalNode( model, children[0], decalinfo );
R_DecalNode( model, node->children[0], decalinfo );
}
else if( dist < -decalinfo->m_Size )
{
R_DecalNode( model, children[1], decalinfo );
R_DecalNode( model, node->children[1], decalinfo );
}
else
{
if( dist < DECAL_DISTANCE && dist > -DECAL_DISTANCE )
R_DecalNodeSurfaces( model, node, decalinfo );
R_DecalNode( model, children[0], decalinfo );
R_DecalNode( model, children[1], decalinfo );
R_DecalNode( model, node->children[0], decalinfo );
R_DecalNode( model, node->children[1], decalinfo );
}
}

View File

@@ -104,33 +104,27 @@ void R_MarkLights( dlight_t *light, int bit, mnode_t *node )
float dist;
msurface_t *surf;
int i;
mnode_t *children[2];
int firstsurface, numsurfaces;
if( !node || node->contents < 0 )
return;
dist = PlaneDiff( light->origin, node->plane );
node_children( children, node, RI.currentmodel );
firstsurface = node_firstsurface( node, RI.currentmodel );
numsurfaces = node_numsurfaces( node, RI.currentmodel );
if( dist > light->radius )
{
R_MarkLights( light, bit, children[0] );
R_MarkLights( light, bit, node->children[0] );
return;
}
if( dist < -light->radius )
{
R_MarkLights( light, bit, children[1] );
R_MarkLights( light, bit, node->children[1] );
return;
}
// mark the polygons
surf = RI.currentmodel->surfaces + firstsurface;
surf = RI.currentmodel->surfaces + node->firstsurface;
for( i = 0; i < numsurfaces; i++, surf++ )
for( i = 0; i < node->numsurfaces; i++, surf++ )
{
if( !BoundsAndSphereIntersect( surf->info->mins, surf->info->maxs, light->origin, light->radius ))
continue; // no intersection
@@ -143,8 +137,8 @@ void R_MarkLights( dlight_t *light, int bit, mnode_t *node )
surf->dlightbits |= bit;
}
R_MarkLights( light, bit, children[0] );
R_MarkLights( light, bit, children[1] );
R_MarkLights( light, bit, node->children[0] );
R_MarkLights( light, bit, node->children[1] );
}
/*
@@ -208,8 +202,6 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
mtexinfo_t *tex;
matrix3x4 tbn;
vec3_t mid;
mnode_t *children[2];
int firstsurface, numsurfaces;
// didn't hit anything
if( !node || node->contents < 0 )
@@ -218,17 +210,13 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
return false;
}
node_children( children, node, model );
firstsurface = node_firstsurface( node, model );
numsurfaces = node_numsurfaces( node, model );
// calculate mid point
front = PlaneDiff( start, node->plane );
back = PlaneDiff( end, node->plane );
side = front < 0;
if(( back < 0 ) == side )
return R_RecursiveLightPoint( model, children[side], p1f, p2f, cv, start, end );
return R_RecursiveLightPoint( model, node->children[side], p1f, p2f, cv, start, end );
frac = front / ( front - back );
@@ -236,7 +224,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
midf = p1f + ( p2f - p1f ) * frac;
// co down front side
if( R_RecursiveLightPoint( model, children[side], p1f, midf, cv, start, mid ))
if( R_RecursiveLightPoint( model, node->children[side], p1f, midf, cv, start, mid ))
return true; // hit something
if(( back < 0 ) == side )
@@ -246,10 +234,10 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
}
// check for impact on this node
surf = model->surfaces + firstsurface;
surf = model->surfaces + node->firstsurface;
VectorCopy( mid, g_trace_lightspot );
for( i = 0; i < numsurfaces; i++, surf++ )
for( i = 0; i < node->numsurfaces; i++, surf++ )
{
int smax, tmax;
@@ -338,7 +326,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
}
// go down back side
return R_RecursiveLightPoint( model, children[!side], midf, p2f, cv, mid, end );
return R_RecursiveLightPoint( model, node->children[!side], midf, p2f, cv, mid, end );
}
/*

View File

@@ -600,7 +600,6 @@ watertexture to grab fog values from it
static gl_texture_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mnode_t *ignore, qboolean down )
{
gl_texture_t *tex = NULL;
mnode_t *children[2];
// assure the initial node is not null
// we could check it here, but we would rather check it
@@ -638,17 +637,15 @@ static gl_texture_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mno
// this is a regular node
// traverse children
node_children( children, node, WORLDMODEL );
if( children[0] && ( children[0] != ignore ))
if( node->children[0] && ( node->children[0] != ignore ))
{
tex = R_RecursiveFindWaterTexture( children[0], node, true );
tex = R_RecursiveFindWaterTexture( node->children[0], node, true );
if( tex ) return tex;
}
if( children[1] && ( children[1] != ignore ))
if( node->children[1] && ( node->children[1] != ignore ))
{
tex = R_RecursiveFindWaterTexture( children[1], node, true );
tex = R_RecursiveFindWaterTexture( node->children[1], node, true );
if( tex ) return tex;
}

View File

@@ -125,25 +125,12 @@ static void R_TextureCoord( const vec3_t v, const msurface_t *surf, vec2_t coord
static void R_GetEdgePosition( const model_t *mod, const msurface_t *fa, int i, vec3_t vec )
{
const int lindex = mod->surfedges[fa->firstedge + i];
const medge_t *pedges = mod->edges;
if( FBitSet( mod->flags, MODEL_QBSP2 ))
{
const medge32_t *pedges = mod->edges32;
if( lindex > 0 )
VectorCopy( mod->vertexes[pedges[lindex].v[0]].position, vec );
else
VectorCopy( mod->vertexes[pedges[-lindex].v[1]].position, vec );
}
if( lindex > 0 )
VectorCopy( mod->vertexes[pedges[lindex].v[0]].position, vec );
else
{
const medge16_t *pedges = mod->edges16;
if( lindex > 0 )
VectorCopy( mod->vertexes[pedges[lindex].v[0]].position, vec );
else
VectorCopy( mod->vertexes[pedges[-lindex].v[1]].position, vec );
}
VectorCopy( mod->vertexes[pedges[-lindex].v[1]].position, vec );
}
static void BoundPoly( int numverts, float *verts, vec3_t mins, vec3_t maxs )
@@ -1855,7 +1842,7 @@ typedef struct vbodecaldata_s
// gl_decals.c
extern decal_t gDecalPool[MAX_RENDER_DECALS];
static struct vbo_static_s
struct vbo_static_s
{
// quickly free all allocations on map change
poolhandle_t mempool;
@@ -1891,7 +1878,7 @@ static struct vbo_static_s
qboolean enabled;
} vbos;
static struct multitexturestate_s
struct multitexturestate_s
{
int tmu_gl; // texture tmu
int tmu_dt; // detail tmu
@@ -3319,9 +3306,6 @@ static void R_RecursiveWorldNode( mnode_t *node, uint clipflags )
mleaf_t *pleaf;
int c, side;
float dot;
mnode_t *children[2];
int numsurfaces, firstsurface;
loc0:
if( node->contents == CONTENTS_SOLID )
return; // hit a solid leaf
@@ -3376,14 +3360,10 @@ loc0:
side = (dot >= 0.0f) ? 0 : 1;
// recurse down the children, front side first
node_children( children, node, WORLDMODEL );
R_RecursiveWorldNode( children[side], clipflags );
firstsurface = node_firstsurface( node, WORLDMODEL );
numsurfaces = node_numsurfaces( node, WORLDMODEL );
R_RecursiveWorldNode( node->children[side], clipflags );
// draw stuff
for( c = numsurfaces, surf = WORLDMODEL->surfaces + firstsurface; c; c--, surf++ )
for( c = node->numsurfaces, surf = WORLDMODEL->surfaces + node->firstsurface; c; c--, surf++ )
{
if( R_CullSurface( surf, &RI.frustum, clipflags ))
continue;
@@ -3402,7 +3382,7 @@ loc0:
}
// recurse down the back side
node = children[!side];
node = node->children[!side];
goto loc0;
}
@@ -3478,9 +3458,6 @@ static void R_DrawWorldTopView( mnode_t *node, uint clipflags )
do
{
mnode_t *children[2];
int numsurfaces, firstsurface;
if( node->contents == CONTENTS_SOLID )
return; // hit a solid leaf
@@ -3514,10 +3491,7 @@ static void R_DrawWorldTopView( mnode_t *node, uint clipflags )
}
// draw stuff
numsurfaces = node_numsurfaces( node, WORLDMODEL );
firstsurface = node_firstsurface( node, WORLDMODEL );
for( c = numsurfaces, surf = WORLDMODEL->surfaces + firstsurface; c; c--, surf++ )
for( c = node->numsurfaces, surf = WORLDMODEL->surfaces + node->firstsurface; c; c--, surf++ )
{
// don't process the same surface twice
if( surf->visframe == tr.framecount )
@@ -3536,9 +3510,9 @@ static void R_DrawWorldTopView( mnode_t *node, uint clipflags )
}
// recurse down both children, we don't care the order...
node_children( children, node, WORLDMODEL );
R_DrawWorldTopView( children[0], clipflags );
node = children[1];
R_DrawWorldTopView( node->children[0], clipflags );
node = node->children[1];
} while( node );
}

View File

@@ -175,7 +175,7 @@ void R_RotateBmodel( void )
R_RecursiveClipBPoly
================
*/
static void R_RecursiveClipBPoly( model_t *mod, bedge_t *pedges, mnode_t *pnode, msurface_t *psurf )
static void R_RecursiveClipBPoly( bedge_t *pedges, mnode_t *pnode, msurface_t *psurf )
{
bedge_t *psideedges[2], *pnextedge, *ptedge;
int i, side, lastside;
@@ -316,7 +316,7 @@ static void R_RecursiveClipBPoly( model_t *mod, bedge_t *pedges, mnode_t *pnode,
{
// draw if we've reached a non-solid leaf, done if all that's left is a
// solid leaf, and continue down the tree if it's not a leaf
pn = node_child( pnode, i, mod );
pn = pnode->children[i];
// we're done with this branch if the node or leaf isn't in the PVS
if( pn->visframe == tr.visframecount )
@@ -332,7 +332,8 @@ static void R_RecursiveClipBPoly( model_t *mod, bedge_t *pedges, mnode_t *pnode,
}
else
{
R_RecursiveClipBPoly( mod, psideedges[i], pn, psurf );
R_RecursiveClipBPoly( psideedges[i], pnode->children[i],
psurf );
}
}
}
@@ -355,13 +356,13 @@ void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode )
mplane_t *pplane;
mvertex_t bverts[MAX_BMODEL_VERTS];
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
medge16_t *pedge, *pedges;
medge_t *pedge, *pedges;
// FIXME: use bounding-box-based frustum clipping info?
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
numsurfaces = pmodel->nummodelsurfaces;
pedges = pmodel->edges16;
pedges = pmodel->edges;
for( i = 0; i < numsurfaces; i++, psurf++ )
{
@@ -418,7 +419,7 @@ void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode )
pbedge[j - 1].pnext = NULL; // mark end of edges
// if ( !( psurf->texinfo->flags & ( SURF_TRANS66 | SURF_TRANS33 ) ) )
R_RecursiveClipBPoly( pmodel, pbedge, topnode, psurf );
R_RecursiveClipBPoly( pbedge, topnode, psurf );
// else
// R_RenderBmodelFace( pbedge, psurf );
}
@@ -565,9 +566,6 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
}
else
{
mnode_t *children[2];
int firstsurface;
// node is just a decision point, so go down the apropriate sides
// find which side of the node we are on
@@ -595,16 +593,14 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
side = 1;
// recurse down the children, front side first
node_children( children, node, WORLDMODEL );
R_RecursiveWorldNode( children[side], clipflags );
R_RecursiveWorldNode( node->children[side], clipflags );
// draw stuff
c = node_numsurfaces( node, WORLDMODEL );
firstsurface = node_firstsurface( node, WORLDMODEL );
c = node->numsurfaces;
if( c )
{
surf = WORLDMODEL->surfaces + firstsurface;
surf = WORLDMODEL->surfaces + node->firstsurface;
if( dot < -BACKFACE_EPSILON )
{
@@ -640,7 +636,7 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
}
// recurse down the back side
R_RecursiveWorldNode( children[!side], clipflags );
R_RecursiveWorldNode( node->children[!side], clipflags );
}
}

View File

@@ -679,24 +679,23 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
static void R_DecalNodeSurfaces( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
{
// iterate over all surfaces in the node
msurface_t *surf;
int i;
int firstsurface, numsurfaces;
msurface_t *surf;
int i;
firstsurface = node_firstsurface( node, model );
numsurfaces = node_numsurfaces( node, model );
surf = model->surfaces + node->firstsurface;
surf = model->surfaces + firstsurface;
for( i = 0; i < numsurfaces; i++, surf++ )
for( i = 0; i < node->numsurfaces; i++, surf++ )
{
// never apply decals on the water or sky surfaces
if( surf->flags & (SURF_DRAWTURB|SURF_DRAWSKY|SURF_CONVEYOR))
if( surf->flags & ( SURF_DRAWTURB | SURF_DRAWSKY | SURF_CONVEYOR ))
continue;
// we can implement alpha testing without stencil
// if( surf->flags & SURF_TRANSPARENT && !glState.stencilEnabled )
// continue;
R_DecalSurface( surf, decalinfo );
}
}
// -----------------------------------------------------------------------------
@@ -708,7 +707,6 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
{
mplane_t *splitplane;
float dist;
mnode_t *children[2];
Assert( node != NULL );
@@ -720,7 +718,6 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
splitplane = node->plane;
dist = DotProduct( decalinfo->m_Position, splitplane->normal ) - splitplane->dist;
node_children( children, node, model );
// This is arbitrarily set to 10 right now. In an ideal world we'd have the
// exact surface but we don't so, this tells me which planes are "sort of
@@ -732,19 +729,19 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
// have a surface normal
if( dist > decalinfo->m_Size )
{
R_DecalNode( model, children[0], decalinfo );
R_DecalNode( model, node->children[0], decalinfo );
}
else if( dist < -decalinfo->m_Size )
{
R_DecalNode( model, children[1], decalinfo );
R_DecalNode( model, node->children[1], decalinfo );
}
else
{
if( dist < DECAL_DISTANCE && dist > -DECAL_DISTANCE )
R_DecalNodeSurfaces( model, node, decalinfo );
R_DecalNode( model, children[0], decalinfo );
R_DecalNode( model, children[1], decalinfo );
R_DecalNode( model, node->children[0], decalinfo );
R_DecalNode( model, node->children[1], decalinfo );
}
}

View File

@@ -104,50 +104,44 @@ R_MarkLights
*/
void R_MarkLights( dlight_t *light, int bit, mnode_t *node )
{
float dist;
msurface_t *surf;
int i;
mnode_t *children[2];
int firstsurface, numsurfaces;
float dist;
msurface_t *surf;
int i;
if( !node || node->contents < 0 )
return;
dist = PlaneDiff( light->origin, node->plane );
node_children( children, node, RI.currentmodel );
firstsurface = node_firstsurface( node, RI.currentmodel );
numsurfaces = node_numsurfaces( node, RI.currentmodel );
if( dist > light->radius )
{
R_MarkLights( light, bit, children[0] );
R_MarkLights( light, bit, node->children[0] );
return;
}
if( dist < -light->radius )
{
R_MarkLights( light, bit, children[1] );
R_MarkLights( light, bit, node->children[1] );
return;
}
// mark the polygons
surf = RI.currentmodel->surfaces + firstsurface;
surf = RI.currentmodel->surfaces + node->firstsurface;
for( i = 0; i < numsurfaces; i++, surf++ )
for( i = 0; i < node->numsurfaces; i++, surf++ )
{
if( !BoundsAndSphereIntersect( surf->info->mins, surf->info->maxs, light->origin, light->radius ))
continue; // no intersection
continue; // no intersection
if( surf->dlightframe != tr.dlightframecount )
if( surf->dlightframe != tr.framecount ) // tr.dlightframecount )
{
surf->dlightbits = 0;
surf->dlightframe = tr.dlightframecount;
surf->dlightframe = tr.framecount; // tr.dlightframecount;
}
surf->dlightbits |= bit;
}
R_MarkLights( light, bit, children[0] );
R_MarkLights( light, bit, children[1] );
R_MarkLights( light, bit, node->children[0] );
R_MarkLights( light, bit, node->children[1] );
}
/*
@@ -211,8 +205,6 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
mtexinfo_t *tex;
matrix3x4 tbn;
vec3_t mid;
mnode_t *children[2];
int firstsurface, numsurfaces;
// didn't hit anything
if( !node || node->contents < 0 )
@@ -221,17 +213,13 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
return false;
}
node_children( children, node, model );
firstsurface = node_firstsurface( node, model );
numsurfaces = node_numsurfaces( node, model );
// calculate mid point
front = PlaneDiff( start, node->plane );
back = PlaneDiff( end, node->plane );
side = front < 0;
if(( back < 0 ) == side )
return R_RecursiveLightPoint( model, children[side], p1f, p2f, cv, start, end );
return R_RecursiveLightPoint( model, node->children[side], p1f, p2f, cv, start, end );
frac = front / ( front - back );
@@ -239,7 +227,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
midf = p1f + ( p2f - p1f ) * frac;
// co down front side
if( R_RecursiveLightPoint( model, children[side], p1f, midf, cv, start, mid ))
if( R_RecursiveLightPoint( model, node->children[side], p1f, midf, cv, start, mid ))
return true; // hit something
if(( back < 0 ) == side )
@@ -249,10 +237,10 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
}
// check for impact on this node
surf = model->surfaces + firstsurface;
surf = model->surfaces + node->firstsurface;
VectorCopy( mid, g_trace_lightspot );
for( i = 0; i < numsurfaces; i++, surf++ )
for( i = 0; i < node->numsurfaces; i++, surf++ )
{
int smax, tmax;
@@ -342,7 +330,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
}
// go down back side
return R_RecursiveLightPoint( model, children[!side], midf, p2f, cv, mid, end );
return R_RecursiveLightPoint( model, node->children[!side], midf, p2f, cv, mid, end );
}
/*

View File

@@ -933,7 +933,7 @@ typedef struct edge_s
unsigned short surfs[2];
struct edge_s *nextremove;
float nearzi;
medge16_t *owner;
medge_t *owner;
} edge_t;

View File

@@ -524,7 +524,6 @@ watertexture to grab fog values from it
static image_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mnode_t *ignore, qboolean down )
{
image_t *tex = NULL;
mnode_t *children[2];
// assure the initial node is not null
// we could check it here, but we would rather check it
@@ -562,18 +561,18 @@ static image_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mnode_t
// this is a regular node
// traverse children
node_children( children, node, WORLDMODEL );
if( children[0] && ( children[0] != ignore ))
if( node->children[0] && ( node->children[0] != ignore ))
{
tex = R_RecursiveFindWaterTexture( children[0], node, true );
if( tex ) return tex;
tex = R_RecursiveFindWaterTexture( node->children[0], node, true );
if( tex )
return tex;
}
if( children[1] && ( children[1] != ignore ))
if( node->children[1] && ( node->children[1] != ignore ))
{
tex = R_RecursiveFindWaterTexture( children[1], node, true );
if( tex ) return tex;
tex = R_RecursiveFindWaterTexture( node->children[1], node, true );
if( tex )
return tex;
}
// for down recursion, return immediately
@@ -797,9 +796,9 @@ static mnode_t *R_FindTopnode( vec3_t mins, vec3_t maxs )
// not split yet; recurse down the contacted side
if( sides & 1 )
node = node_child( node, 0, WORLDMODEL );
node = node->children[0];
else
node = node_child( node, 1, WORLDMODEL );
node = node->children[1];
}
}
@@ -1393,12 +1392,6 @@ void GAME_EXPORT R_NewMap( void )
R_ClearDecals(); // clear all level decals
R_StudioResetPlayerModels();
if( FBitSet( world->flags, MODEL_QBSP2 ))
{
gEngfuncs.Host_Error( "Sorry, ref_soft can't load maps in BSP2 format.\n" );
return;
}
r_cnumsurfs = sw_maxsurfs.value;
if( r_cnumsurfs <= MINSURFACES )

View File

@@ -37,7 +37,7 @@ int c_faceclip; // numbe
clipplane_t *entity_clipplanes;
clipplane_t world_clipplanes[16];
medge16_t *r_pedge;
medge_t *r_pedge;
qboolean r_leftclipped, r_rightclipped;
static qboolean makeleftedge, makerightedge;
@@ -68,7 +68,7 @@ msurface_t *r_skyfaces;
mplane_t r_skyplanes[6];
mtexinfo_t r_skytexinfo[6];
mvertex_t *r_skyverts;
medge16_t *r_skyedges;
medge_t *r_skyedges;
int *r_skysurfedges;
// I just copied this data from a box map...
@@ -438,7 +438,7 @@ void R_RenderFace( msurface_t *fa, int clipflags )
mplane_t *pplane;
float distinv;
vec3_t p_normal;
medge16_t *pedges, tedge;
medge_t *pedges, tedge;
clipplane_t *pclip;
// translucent surfaces are not drawn by the edge renderer
@@ -490,7 +490,7 @@ void R_RenderFace( msurface_t *fa, int clipflags )
r_nearzi = 0;
r_nearzionly = false;
makeleftedge = makerightedge = false;
pedges = RI.currentmodel->edges16;
pedges = RI.currentmodel->edges;
r_lastvertvalid = false;
for( i = 0; i < fa->numedges; i++ )
@@ -560,7 +560,7 @@ void R_RenderFace( msurface_t *fa, int clipflags )
else
{
// it's cached if the cached edge is valid and is owned
// by this medge16_t
// by this medge_t
if((((uintptr_t)edge_p - (uintptr_t)r_edges )
> r_pedge->cachededgeoffset )
&& (((edge_t *)((uintptr_t)r_edges
@@ -651,7 +651,7 @@ void R_RenderBmodelFace( bedge_t *pedges, msurface_t *psurf )
mplane_t *pplane;
float distinv;
vec3_t p_normal;
medge16_t tedge;
medge_t tedge;
clipplane_t *pclip;
/*if (psurf->texinfo->flags & (SURF_TRANS33|SURF_TRANS66))

View File

@@ -11,8 +11,7 @@ fi
# NOTE: to build with other version use --msvc_version during configuration
# NOTE: sometimes you may need to add WinSDK to %PATH%
# NOTE: --enable-msvcdeps only used for CI builds, enabling it non-English versions of MSVC causes useless console spam
./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto --enable-msvcdeps $AMD64 || die_configure
./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto $AMD64 || die_configure
./waf.bat build || die
./waf.bat install --destdir=. || die

View File

@@ -2,7 +2,7 @@
cd $GITHUB_WORKSPACE
wget https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION.dmg -O SDL2.dmg
wget http://libsdl.org/release/SDL2-$SDL_VERSION.dmg -O SDL2.dmg
hdiutil mount SDL2.dmg
sudo cp -vr /Volumes/SDL2/SDL2.framework /Library/Frameworks

View File

@@ -1,5 +1,5 @@
#!/bin/bash
curl -L https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-devel-$SDL_VERSION-VC.zip -o SDL2.zip
curl http://libsdl.org/release/SDL2-devel-$SDL_VERSION-VC.zip -o SDL2.zip
unzip -q SDL2.zip
mv SDL2-$SDL_VERSION SDL2_VC

11
wscript
View File

@@ -91,7 +91,7 @@ SUBDIRS = [
Subproject('3rdparty/gl-wes-v2', lambda x: not x.env.DEDICATED and x.env.GLWES),
Subproject('3rdparty/gl4es', lambda x: not x.env.DEDICATED and x.env.GL4ES),
Subproject('ref/gl', lambda x: not x.env.DEDICATED and (x.env.GL or x.env.NANOGL or x.env.GLWES or x.env.GL4ES)),
Subproject('ref/soft', lambda x: not x.env.DEDICATED and x.env.SOFT),
Subproject('ref/soft', lambda x: not x.env.DEDICATED and not x.env.SUPPORT_BSP2_FORMAT and x.env.SOFT),
Subproject('ref/null', lambda x: not x.env.DEDICATED and x.env.NULL),
Subproject('3rdparty/bzip2', lambda x: not x.env.DEDICATED and not x.env.HAVE_SYSTEM_BZ2),
Subproject('3rdparty/opus', lambda x: not x.env.DEDICATED and not x.env.HAVE_SYSTEM_OPUS),
@@ -148,6 +148,9 @@ def options(opt):
grp.add_option('--enable-bundled-deps', action = 'store_true', dest = 'BUILD_BUNDLED_DEPS', default = False,
help = 'prefer to build bundled dependencies (like opus) instead of relying on system provided')
grp.add_option('--enable-bsp2', action = 'store_true', dest = 'SUPPORT_BSP2_FORMAT', default = False,
help = 'build engine and renderers with BSP2 map support(recommended for Quake, breaks compatibility!) [default: %(default)s]')
grp.add_option('--enable-hl25-extended-structs', action = 'store_true', dest = 'SUPPORT_HL25_EXTENDED_STRUCTS', default = False,
help = 'build engine and renderers with HL25 extended structs compatibility (might be required for some mods) [default: %(default)s]')
@@ -162,7 +165,6 @@ def options(opt):
# a1ba: special option for me
grp.add_option('--debug-all-servers', action='store_true', dest='ALL_SERVERS', default=False, help='')
grp.add_option('--enable-msvcdeps', action='store_true', dest='MSVCDEPS', default=False, help='')
grp = opt.add_option_group('Renderers options')
@@ -201,9 +203,6 @@ def configure(conf):
# Load compilers early
conf.load('xshlib xcompile compiler_c compiler_cxx gccdeps')
if conf.options.MSVCDEPS:
conf.load('msvcdeps')
if conf.options.NSWITCH:
conf.load('nswitch')
@@ -396,7 +395,9 @@ def configure(conf):
conf.env.ENABLE_XAR = conf.options.ENABLE_XAR
conf.env.ENABLE_FUZZER = conf.options.ENABLE_FUZZER
conf.env.DEDICATED = conf.options.DEDICATED
conf.env.SUPPORT_BSP2_FORMAT = conf.options.SUPPORT_BSP2_FORMAT
conf.define_cond('SUPPORT_BSP2_FORMAT', conf.options.SUPPORT_BSP2_FORMAT)
conf.define_cond('SUPPORT_HL25_EXTENDED_STRUCTS', conf.options.SUPPORT_HL25_EXTENDED_STRUCTS)
# disable game_launch compiling on platform where it's not needed