Merge significant ray tracer improvements #341 from w23/better-sampling-passes

Initial observation: our vgpr story is abysmal, so need to split the one uber-rt-shader into pieces.

Done here:
- ray tracing pipeline uber shader is split into separate compute phases -> perf x2 (with a possibility of further radical improvements)
- "programmable render": read spirv, extract bindings, auto-create missing resources, etc.
- better light sampling, significant image quality improvements
- better synchronization. cpu can continue preparing the next frame while previous one is still being drawn on GPU
- lots of other small fixes
This commit is contained in:
Ivan Avdeev 2023-02-14 13:00:53 -08:00 committed by GitHub
commit 1f774c6400
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
305 changed files with 20646 additions and 10461 deletions

View File

@ -1,22 +1,10 @@
task:
name: freebsd-11-amd64
freebsd_instance:
image_family: freebsd-11-4
setup_script:
- pkg update
- pkg install -y git sdl2 python
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
- ./scripts/cirrus/build_freebsd.sh full
task:
name: freebsd-12-amd64
freebsd_instance:
image_family: freebsd-12-2
image_family: freebsd-12-3
setup_script:
- pkg update
- pkg install -y git sdl2 python
- pkg install -y git sdl2 python fontconfig
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
@ -25,10 +13,22 @@ task:
task:
name: freebsd-13-amd64
freebsd_instance:
image_family: freebsd-13-0-snap
image_family: freebsd-13-1
setup_script:
- pkg update
- pkg install -y git sdl2 python
- pkg install -y git sdl2 python fontconfig
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
- ./scripts/cirrus/build_freebsd.sh full
task:
name: freebsd-14-amd64
freebsd_instance:
image_family: freebsd-14-0-snap
setup_script:
- pkg update
- pkg install -y git sdl2 python fontconfig
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated

View File

@ -1,6 +1,11 @@
name: Build & Deploy Engine
on: [push, pull_request]
jobs:
# cleanup:
# runs-on: self-hosted
# steps:
# - name: Cleanup
# run: rm -rf .* || true
build:
runs-on: ${{ matrix.os }}
continue-on-error: true
@ -14,6 +19,9 @@ jobs:
- os: ubuntu-18.04
targetos: linux
targetarch: i386
# - os: ubuntu-aarch64-20.04
# targetos: linux
# targetarch: aarch64
# - os: ubuntu-18.04
# targetos: android
@ -38,7 +46,6 @@ jobs:
GH_CPU_ARCH: ${{ matrix.targetarch }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ANDROID_SDK_TOOLS_VER: 4333796
ANDROID_NDK_VER: r10e
UPLOADTOOL_ISPRERELEASE: true
steps:
- name: Checkout
@ -57,15 +64,10 @@ jobs:
- name: Build engine
run: bash scripts/gha/build_${{ matrix.targetos }}.sh
- name: Upload engine (android)
if: matrix.targetos == 'android'
run: bash scripts/continious_upload.sh xashdroid-${{ matrix.targetarch }}.apk
- name: Upload engine (motomagx)
if: matrix.targetos == 'motomagx'
run: bash scripts/continious_upload.sh xash3d-fwgs-magx.7z
- name: Upload engine (linux)
if: matrix.targetos == 'linux'
run: bash scripts/continious_upload.sh xash3d-fwgs-${{ matrix.targetarch }}.AppImage xashds-linux-${{ matrix.targetarch }}
- name: Upload engine (windows)
if: matrix.targetos == 'win32'
run: bash scripts/continious_upload.sh xash3d-fwgs-win32-${{ matrix.targetarch }}.7z
- name: Upload engine (prereleases)
run: bash scripts/continious_upload.sh artifacts/*
- name: Upload engine (artifacts)
uses: actions/upload-artifact@v2
with:
name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }}
path: artifacts/*

6
.gitmodules vendored
View File

@ -8,9 +8,9 @@
[submodule "ref_gl/gl-wes-v2"]
path = ref_gl/gl-wes-v2
url = https://github.com/FWGS/gl-wes-v2
[submodule "vgui-dev"]
path = vgui-dev
url = https://github.com/FWGS/vgui-dev
[submodule "ref_gl/gl4es"]
path = ref_gl/gl4es
url = https://github.com/ptitSeb/gl4es
[submodule "vgui_support"]
path = vgui_support
url = https://github.com/FWGS/vgui_support

View File

@ -7,6 +7,5 @@
|Counter Strike: Condition Zero |The latest steam release |Uses vgui2 library which xash3d does not support |Some work on vgui2 support was made here: https://github.com/FWGS/xash3d/tree/vinterface
|Counter Strike: Condition Zero - Deleted scenes |The latest steam release |Uses vgui2 library which xash3d does not support |Some work on vgui2 support was made here: https://github.com/FWGS/xash3d/tree/vinterface
|Day of Defeat |The latest steam release |Uses vgui2 library which xash3d does not support |Some work on vgui2 support was made here: https://github.com/FWGS/xash3d/tree/vinterface
|Sven-Coop |5.0+ |Uses filesystem_stdio library which xash3d does not support |filesystem_stdio replacement already was made: https://github.com/FWGS/filesystem_stdio_xash
|XDM |3.0.4.0 | |
|Sven-Coop |5.0+ |Uses custom GoldSrc engine |

View File

@ -17,7 +17,9 @@ Mirrored on github - https://github.com/JoelTroch/am_src_rebirth
Mirrored on github - https://github.com/nekonomicon/BattleGrounds
## Bubblemod
Download page on official site - http://www.bubblemod.org/dl_default.php
Download page on official site - http://www.bubblemod.org/dl_default.php (dead link!)
Mirrored on github - https://github.com/HLSources/BubbleMod
## Chicken Fortress
Official github repository - https://github.com/CKFDevPowered/CKF3Alpha
@ -25,6 +27,11 @@ Official github repository - https://github.com/CKFDevPowered/CKF3Alpha
## Cold Ice
Version 1.9 is available on ModDB - https://www.moddb.com/mods/cold-ice/downloads/cold-ice-sdk
Version 1.9 mirrored on github - https://github.com/solidi/hl-mods/tree/master/ci
## Cold Ice Ressurection
Mirrored on github - https://github.com/solidi/hl-mods/tree/master/cir
## Cthulhu
Uploaded to github by Oleg Cherkasky - https://github.com/gunrunners-paradise/Cthulhu-HLmod-SDK
@ -38,25 +45,36 @@ Official github repository - https://github.com/adslbarxatov/xash3d-for-ESHQ
Available on GamerLab - http://gamer-lab.com/eng/code_mods_goldsrc/Half-Life_2D_(Flat-Life)
## Gang Wars
Mirrored on github - https://github.com/hammermaps/gw1.45src
Mirrored on github - https://github.com/nekonomicon/gw1.45src
## Go-mod
Versions 2.0 and 3.0, available in mod archives on ModDB - https://www.moddb.com/mods/go-mod/downloads
Version 3.0, mirrored on github - https://github.com/nekonomicon/Go-mod30
## GT mod
Available on GamerLab - http://gamer-lab.com/eng/code_mods_goldsrc/GT_mod_(Polnie_ishodniki)
## Half-Life: Advanced Deathmatch
Mirrored on github - https://github.com/solidi/hl-mods/tree/master/hla
## Half-Life: Decay
Mirrored on github(PC Port) - https://github.com/hoaxer/Half-Life-Decay
## Half-Life: Echoes
Download link on dropbox - https://www.dropbox.com/s/s6j8gtegn10wgvj/dlls.zip?dl=1
Available on ModDB - https://www.moddb.com/mods/half-life-echoes
## Half-Life: Expanded Arsenal
Available on ModDB - https://www.moddb.com/mods/half-life-expanded-arsenal
## Half-Life: Gravgun mod
Branch **gravgun** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/gravgun
Branch **gravgun** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/gravgun
## Half-Life: Invasion
official github repository - https://github.com/jlecorre/hlinvasion
Official github repository - https://github.com/jlecorre/hlinvasion
## Half-Life: Pong
Mirrored on github - https://github.com/solidi/hl-mods/tree/master/pong
## Half-Life: Quest Mode
Available on cs-mapping.com.ua - https://old.cs-mapping.com.ua/forum/showthread.php?t=38030
@ -92,7 +110,7 @@ Official github repository - https://github.com/desukuran/half-screwed
Version 1.3 on ModDB - https://www.moddb.com/mods/headcrab-frenzy/downloads/headcrab-frenzy-13-beta-source-code
## Heart of Evil
Available on ModDB - https://www.moddb.com/mods/heart-of-evil/downloads/heart-of-evil-dlls-source-code
Mirrored on github - https://github.com/nekonomicon/HeartOfEvil
## Ingram Chillin' Mod
Official SourceForge repository - https://sourceforge.net/projects/icm-hl/
@ -155,7 +173,7 @@ Mirrored on github - https://github.com/ZXCmod/ZXCmod
# Reimplementation
## Absolute Redemption
Branch **redempt** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/redempt
Branch **redempt** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/redempt
## Adrenaline Gamer
OpenAG by YaLTeR - https://github.com/YaLTeR/OpenAG
@ -163,34 +181,34 @@ OpenAG by YaLTeR - https://github.com/YaLTeR/OpenAG
## Afraid of Monsters
malortie's recreation - https://github.com/malortie/hl-aom
Branch **aom** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/aom
Branch **aom** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aom
## Afraid of Monsters: Director's cut
Reverse-engineered code, branch **aomdc** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/aomdc
Reverse-engineered code, branch **aomdc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aomdc
## Azure Sheep
malortie's recreation - https://github.com/malortie/hl-asheep
Reverse-engineered code, branch **asheep** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/asheep
Reverse-engineered code, branch **asheep** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/asheep
## Big Lolly
malortie's recreation - https://github.com/malortie/hl-biglolly
Branch **biglolly** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/biglolly
Branch **biglolly** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/biglolly
## Black Ops
malortie's recreation - https://github.com/malortie/hl-blackops
Branch **blackops** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/blackops
Branch **blackops** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/blackops
## Bloody Pizza: Vendetta
Branch **caseclosed** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/caseclosed
Branch **caseclosed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/caseclosed
## Case Closed
Branch **caseclosed** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/caseclosed
Branch **caseclosed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/caseclosed
## Cleaner's Adventures
Branch **CAd** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/CAd
Branch **CAd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/CAd
## Counter Strike
Reverse-engineered code of client part by a1batross - https://github.com/FWGS/cs16-client/tree/v1.32
@ -208,54 +226,60 @@ Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/crack_lif
## Escape from the Darkness
malortie's recreation - https://github.com/malortie/hl-eftd
Reverse-engineered code, branch **eftd** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/eftd
Reverse-engineered code, branch **eftd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/eftd
## Half-Life: Blue Shift
Unkle Mike's recreation - https://hlfx.ru/forum/showthread.php?s=&threadid=5253
Reverse-engineered code, branch **bshift** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/bshift
Reverse-engineered code, branch **bshift** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/bshift
## Half-Life: Induction
Branch **induction** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/induction
Branch **induction** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/induction
## Half-Life: Opposing Force
Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/hlsdk-xash3d
Reverse-engineered code, clean branch **opfor** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/opfor
Reverse-engineered code, clean branch **opfor** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/opfor
Spirit of Half Life: Opposing-Force Edition - https://github.com/Hammermaps-DEV/SOHL-V1.9-Opposing-Force-Edition
## Half-Life: Rebellion
Reverse-engineered code, branch **rebellion** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/rebellion
Reverse-engineered code, branch **rebellion** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/rebellion
## Half-Life: Urbicide
Branch **hl_urbicide** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/hl_urbicide
## Half-Life: Visitors
malortie's recreation - https://github.com/malortie/hl-visitors
Reverse-engineered code, branch **visitors** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/visitors
Reverse-engineered code, branch **visitors** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/visitors
## Half-Secret
Branch **half-secret** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/half-secret
Branch **half-secret** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/half-secret
## Night at the Office
malortie's recreation - https://github.com/malortie/hl-nato
Branch **noffice** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/noffice
Branch **noffice** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/noffice
## Poke 646
malortie's recreation - https://github.com/malortie/hl-poke646
Reverse-engineered code, branch **poke646** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/poke646
Reverse-engineered code, branch **poke646** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646
## Poke 646: Vendetta
malortie's recreation - https://github.com/malortie/hl-poke646-vendetta
Reverse-engineered code, branch **poke646_vendetta** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/poke646_vendetta
Reverse-engineered code, branch **poke646_vendetta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646_vendetta
## Residual Life
Reverse-engineered code, branch **residual_point** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/residual_point
Reverse-engineered code, branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point
## Residual Point
Reverse-engineered code, branch **residual_point** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/residual_point
Reverse-engineered code, branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point
## Sewer Beta
Branch **sewer_beta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sewer_beta
## Team Fortress Classic
Reverse-engineered code by Velaron - https://github.com/Velaron/tf15-client
@ -263,59 +287,64 @@ Reverse-engineered code by Velaron - https://github.com/Velaron/tf15-client
## The Gate
malortie's recreation - https://github.com/malortie/hl-thegate
Reverse-engineered code, branch **thegate** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/thegate
Reverse-engineered code, branch **thegate** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/thegate
## They Hunger
malortie's recreation - https://github.com/malortie/hl-theyhunger
Reverse-engineered code, branch **theyhunger** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/theyhunger
Reverse-engineered code, branch **theyhunger** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/theyhunger
They Hunger: Tactical - https://www.moddb.com/mods/they-hunger-tactical/downloads/tht-source-code-documentation
## Times of Troubles
malortie's recreation - https://github.com/malortie/hl-tot
Branch **tot** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/tot
Branch **tot** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/tot
# Derived work
## Adrenaline Gamer
Branch **aghl** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/aghl
Branch **aghl** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aghl
## Bubblemod
Branch **bubblemod** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/bubblemod
Branch **bubblemod** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/bubblemod
## Deathmatch Classic
Deathmatch Classic: Adrenaline Gamer Edition - https://github.com/martinwebrant/agmod/tree/master/src/dmc
Deathmatch Quaked - https://www.moddb.com/games/deathmatch-classic/downloads/dmq2
Branch **dmc** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/dmc
Branch **dmc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/dmc
## Half-Life: Echoes
Branch **echoes** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/echoes
Branch **echoes** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/echoes
## Half-Life: Invasion
Port to HLSDK 2.4 by malortie - https://github.com/malortie/hl-invasion
Port to Linux by fmoraw - https://github.com/fmoraw/hlinvasion
Branch **invasion** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/invasion
## Half-Life: Top-Down
Branch **hltopdown** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/hltopdown
Branch **hltopdown** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/hltopdown
## Half-Screwed
Branch **half-screwed** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/half-screwed
Branch **half-screwed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/half-screwed
## Natural Selection
Port to Linux - https://github.com/fmoraw/NS
## Spirit of Half-Life
Version 1.2, branch **sohl1.2** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sohl1.2
## Swiss Cheese Halloween 2002
Just more playable version by malortie - https://github.com/malortie/hl-shall
Branch **halloween** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/halloween
Branch **halloween** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/halloween
## Threewave CTF
Branch **dmc** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/dmc
Branch **dmc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/dmc
## Zombie-X
Branch **zombie-x** in hlsdk-xash3d - https://github.com/FWGS/hlsdk-xash3d/tree/zombie-x
Branch **zombie-x** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/zombie-x

View File

@ -15,24 +15,24 @@ Status:
Table is sorted by status.
| Platform | Status | Maintainer | Note
| -------- | ------ | ---------- | ----
| Windows | Supported | @a1batross |
| *BSD | Supported | @nekonomicon |
| GNU/Linux(x86, amd64, arm) | Supported | @a1batross, @mittorn |
| Android | Supported | @a1batross, @mittorn |
| MotoMAGX | Supported | @a1batross |
| GNU/Linux(elbrus) | Supported | @a1batross, @mittorn | Rare and eventual access to e2k machine
| Haiku | Supported | not maintained | Was added by #478 and #483
| DOS4GW | Supported | @mittorn |
| GNU/Linux(mipsel) | Supported | @mittorn |
| Switch | In progress | @fgsfdsfgs | [Github Repository](https://github.com/fgsfdsfgs/xash3d-fwgs/tree/switch_new)
| Wii | In progress | Collaborative effort | [Github Repository](https://github.com/saucesaft/xash3d-wii)
| PSP | In progress | Collaborative effort | No sources available at this moment
| Emscripten | Old Engine | not maintained |
| Oculus Quest | Old Engine fork | @DrBeef | [GitHub Repository](https://github.com/DrBeef/Lambda1VR)
| PSVita | Old Engine fork | not maintained | [GitHub Repository](https://github.com/fgsfdsfgs/vitaXash3D)
| Switch | Old Engine fork | not maintained | [GitHub Repository](https://github.com/switchports/xash3d-switch)
| 3DS | Old Engine fork | not maintained | [GitHub Repository](https://github.com/masterfeizz/Xash3DS)
| macOS | Deprecated | not maintained | See GitHub issue #61
| iOS | Deprecated | not maintained | See GitHub issue #61
| Platform | Status | Maintainer | Note
| -------- | ------ | ---------- | ----
| Windows | Supported | @a1batross, @SNMetamorph |
| *BSD | Supported | @nekonomicon |
| GNU/Linux(x86, amd64, arm) | Supported | @a1batross, @mittorn |
| Android | Supported | @a1batross, @mittorn |
| MotoMAGX | Supported | @a1batross |
| GNU/Linux(elbrus) | Supported | @a1batross, @mittorn | Rare and eventual access to e2k machine
| Haiku | Supported | not maintained | Was added by #478 and #483
| DOS4GW | Supported | @mittorn |
| GNU/Linux(mipsel) | Supported | @mittorn |
| Switch | In progress | @fgsfdsfgs | [GitHub Repository](https://github.com/fgsfdsfgs/xash3d-fwgs/tree/switch_new)
| Wii | In progress | Collaborative effort | [GitHub Repository](https://github.com/saucesaft/xash3d-wii)
| PSP | In progress | @Crow_bar, @Velaron | [GitHub Repository](https://github.com/Crow-bar/xash3d-fwgs)
| Emscripten | Old Engine | not maintained |
| Oculus Quest | Old Engine fork | @DrBeef | [GitHub Repository](https://github.com/DrBeef/Lambda1VR)
| PSVita | Old Engine fork | not maintained | [GitHub Repository](https://github.com/fgsfdsfgs/vitaXash3D)
| Switch | Old Engine fork | not maintained | [GitHub Repository](https://github.com/switchports/xash3d-switch)
| 3DS | Old Engine fork | not maintained | [GitHub Repository](https://github.com/masterfeizz/Xash3DS)
| macOS | Deprecated | not maintained | See GitHub issue #61
| iOS | Deprecated | not maintained | See GitHub issue #61

View File

@ -46,7 +46,7 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
16. [Betrayal](http://www.moddb.com/mods/betrayal) (this mod has inner bugs; set **gl_allow_mirrors** to **0** to prevent drops of game's perfomance in some areas)
17. [Between Two Worlds](https://www.runthinkshootlive.com/posts/between-two-worlds/)
18. [Black Mesa Energy Testing Chamber](http://twhl.info/competitions.php?results=17)
19. [Black Mesa Sideline](http://www.isolated-design.de/half-life-mods/black-mesa-sideline/) (set **gl_allow_mirrors** to **0** to prevent drops of game's perfomance in some areas)
19. [Black Mesa Sideline](https://www.moddb.com/mods/black-mesa-sideline) (set **gl_allow_mirrors** to **0** to prevent drops of game's perfomance in some areas)
20. [BlackMesa 2007( Black Mesa Missions 2007 )](http://www.moddb.com/addons/blackmesa-2007)
21. [Blood and Bones](https://www.runthinkshootlive.com/posts/blood-and-bones/)
22. Boom (Huknenn) v1.0 & [HL Boom: Gold Edition v1.1](http://www.moddb.com/mods/boom)
@ -103,8 +103,8 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
72. [Freeman](https://www.runthinkshootlive.com/posts/freeman/)
73. [Freeman's Escape](http://www.moddb.com/mods/freeman-escape-french) (2 maps by *JiggZ*)
74. [Freeman's Fight](https://www.runthinkshootlive.com/posts/freemans-fight/)
75. [Freeman's Return](http://jpmaps.wz.cz/epizody.htm)
76. [Freeman's Return 2](http://jpmaps.wz.cz/epizody.htm)
75. [Freeman's Return](https://www.moddb.com/games/half-life/addons/freemans-return-v12)
76. [Freeman's Return 2](https://www.moddb.com/games/half-life/addons/freemans-return-2-v11)
77. [Freeman's Revenge](https://www.runthinkshootlive.com/posts/freemans-revenge/)
78. [Freeman's Tomb( The Crypt )](http://twhl.info/vault.php?map=3787)
79. [G-Invasion v2.5](http://www.moddb.com/mods/g-man-invasion) aka G-Man Invasion (there is an inner crash bug on final titles: some text lines are too long and cannot be properly displayed)
@ -129,7 +129,7 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
96. [Haunted](https://www.runthinkshootlive.com/posts/haunted/) (set **sv_validate_changelevel** to **0** to avoid a problem with level change between maps **pagan7** and **pagan8**)
97. [Hazardous Materials: Episode 1 & 2](http://www.moddb.com/mods/half-life-hazardous-materials)
98. [Hazardous-Course 2](http://www.moddb.com/mods/hazardous-course-2)
99. [Help Wanted](http://maps.mrsucko.org/work/)
99. [Help Wanted](https://www.moddb.com/games/half-life/addons/help-wanted)
100. [Hidden Evil v1.01](https://www.runthinkshootlive.com/posts/hidden-evil/)
101. [High Speed](http://www.moddb.com/games/half-life/addons/high-speed-english-version)
102. [hlife_hotdog_compo26](http://twhl.info/vault.php?map=5181)
@ -155,7 +155,7 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
122. [Mario Keys](http://www.moddb.com/mods/mario-keys)
123. [McBeth](https://www.runthinkshootlive.com/posts/mcbeth/)
124. [Medieval World](http://www.moddb.com/mods/medieval-world)
125. [Mel Soaring 2: Star Rancor](http://www.etherealhell.com/etherealhell/index.php/my-levels/half-life)
125. [Mel Soaring 2: Star Rancor](https://www.moddb.com/addons/mel-soaring-2-star-rancor)
126. [MINIMICUS](http://twhl.info/vault.php?map=163)
127. [Mission Failed](http://www.moddb.com/mods/mission-failed)
128. [Mission MC Poker](http://www.moddb.com/mods/half-life-mission-mc-poker)
@ -176,7 +176,7 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
143. [Operation: Nova](http://www.moddb.com/mods/half-life-operation-nova) (there is an inner bug with an M60 machinegun on a map with Osprey: it can be activated and used if you are staying in front of it, not behind it)
144. [Optimum Fear](https://www.fileplanet.com/7472/0/fileinfo/Optimum-Fear)
145. [Outrun](http://www.moddb.com/mods/outrun)
146. [Outwards (Day One)](http://www.visgi.info/maps/)
146. [Outwards (Day One)](https://drive.google.com/file/d/1mjQ8wUazYbwTq9Ocg0Vs0raq4avbTRne/view?usp=sharing)
147. [Overhaul Pack](http://www.moddb.com/mods/half-life-overhaul-pack) (Just HD pack for Half-Life)
148. [P.I.Z.D.E.C.](https://www.runthinkshootlive.com/posts/pizdec/)
149. [pagoda](http://www.moddb.com/mods/pagoda1)
@ -184,7 +184,7 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
151. [Phobos IV](http://www.moddb.com/mods/phobos-iv)
152. [Pimp My Car](https://www.runthinkshootlive.com/posts/pimp-my-car/) (there is an inner issue with incorrect responses of buttons on combination locks)
153. [Point Blank Stackdeath Complex](https://www.runthinkshootlive.com/posts/half-life-point-blank-stackdeath-complex/)
154. [Prisoner Escaped](http://four0four.org/downloads/maps/)
154. [Prisoner Escaped](https://www.moddb.com/mods/prisoner-escaped-1-2)
155. [Prisoner of Event](http://wp.vondur.net/?page_id=40)
156. [Prisoner of War](https://www.runthinkshootlive.com/posts/prisoner-of-war/)
157. [Project Quantum Leap](http://www.moddb.com/mods/project-quantum-leap)
@ -282,7 +282,7 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
6. [Catacombs: Part 1](https://www.runthinkshootlive.com/posts/catacombs/)
7. [Cro-man's Office Mappack](http://twhl.info/vault.php?map=5547)
8. [Half-Life Episode Two Demo Alpha v1.0](http://hl.loess.ru/?mod=451)
9. [Hazardous-Course (first version of Hazardous-Course 2)](http://www.richmans-maps.ch.vu/) (link dead!)
9. [Hazardous-Course (first version of Hazardous-Course 2)](https://drive.google.com/file/d/16djJZSpNWKyScSxSyMqX-u_S-2i400rl/view?usp=sharing)
10. [High Tech v0.2](http://hl.loess.ru/?mod=499)
11. [HL Shadows, Part 1](https://www.fileplanet.com/7466/0/fileinfo/'HL-Shadows',-Part-1)
12. [HLNewEnd](http://twhl.info/vault.php?map=2275)
@ -305,11 +305,11 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
29. [Shortcut v1.0 Beta](https://www.runthinkshootlive.com/posts/shortcut/)
30. [Stoka](https://www.ceskemody.cz/mapy.php?lng=1&clanek=222&razeni_hra=1&pn=stoka)
31. [Striker's Compo 26](http://twhl.info/vault.php?map=5190) (buggy)
32. [Technology Test 2](http://www.richmans-maps.ch.vu/) (link dead!)
32. [Technology Test 2](https://drive.google.com/file/d/1LfldzsMIN5j07bgtNkfY5v0Xl0S9de_G/view?usp=sharing)
33. [The Gate Playable Demo](https://www.fileplanet.com/116347/110000/fileinfo/The-Gate-Playable-Demo)
34. [They are Back](https://www.runthinkshootlive.com/posts/they-are-back/)
35. [Tiefseelabor( Deep Sea Laboratory )](https://www.runthinkshootlive.com/posts/deep-sea-laboratory/)
36. [Time-Shift](http://www.richmans-maps.ch.vu/) (link dead!)
36. [Time-Shift](https://drive.google.com/file/d/1pK1s-2SIlSMQHVRPMLdC_94wTa__8_DX/view?usp=sharing)
37. [Train Single Beta](https://cs-mapping.com.ua/forum/showthread.php?t=36394) (Remove **gfx.wad** from **TrainSingle** folder)
38. [WAR: The Killer Beta 0.1](http://www.moddb.com/mods/war)
39. [White Force Beta( Residual Point prototype )](http://www.moddb.com/mods/hl-residual-point/downloads/white-force-beta-2002)
@ -379,7 +379,7 @@ Mods:
5. [Half-Life Baby v1.4](http://www.moddb.com/games/half-life/addons/half-life-baby) (it's an unfinished but playable mod; after installing of the mod open **liblist.gam** or **gameinfo.txt** file in the mod's folder and correct the line **gamedll "..\hlbaby\dlls\hl.dll"** for **gamedll "dlls\hl.dll"**, otherwise you'll not be able to start a game)
6. [Half-Secret](http://www.moddb.com/mods/half-secret) (this mod has custom **weapon_snark** code)
7. [Induction](http://www.moddb.com/mods/half-life-induction) (this mod has new item - **item_flashlight**)
8. [Lost in Black Mesa(first version without HLFX)](http://half-life.ru/forum/showthread.php?threadid=13959)
8. [Lost in Black Mesa(first version without HLFX)](https://drive.google.com/file/d/1bEnm_AxJs-ly8hTEZIQBw_v2BsXdSiGa/view?usp=sharing)
9. [Soldier](http://www.moddb.com/mods/half-life-soldier)
10. [Solo Operations](http://www.moddb.com/mods/solo-operations)
11. [The Blood v1.1](http://hl.loess.ru/?mods=&search=The+Blood) (there are some inner bugs in the mod, but they don't interfere with a game progress)
@ -440,7 +440,7 @@ Mods:
51. [Data-base](https://www.runthinkshootlive.com/posts/database/)
52. [de_dust2_azabetfeN](https://cs-mapping.com.ua/forum/showthread.php?t=36394) (remove **cl_dlls** & **dlls** folders from inside of mod's directory before you start the game)
53. [De-railed](http://twhl.info/competitions.php?results=7)
54. [Dead Shift Beta](http://www.moddb.com/mods/dead-shift) - [Demo 1](https://www.gamewatcher.com/mods/half-life-mod/dead-shift-1-0-beta) & [Demo 2](https://www.gamefront.com/files/13532512) (3rd link dead!)
54. [Dead Shift Beta](http://www.moddb.com/mods/dead-shift) - [Demo 1](https://www.gamewatcher.com/mods/half-life-mod/dead-shift-1-0-beta) & [Demo 2](https://drive.google.com/file/d/1uHvr8xONogTTNOy-8X6G4ehFV6Eawvbq/view?usp=sharing)
55. [Deep](http://twhl.info/vault.php?map=1669)
56. [Desert Attack](http://fyzzer.narod.ru/index.html)
57. [Desert Combat Demo](https://www.fileplanet.com/190487/190000/fileinfo/Half-Life---Desert-Combat-Mod) (despite a big file size there's only one small unfinished map)
@ -469,7 +469,7 @@ Mods:
80. [Extinct Lifeform Hunt](https://www.fileplanet.com/13501/10000/fileinfo/Extinct-Lifeform-Hunt)
81. [Facility](http://twhl.info/vault.php?map=5482)
82. [Facility Escape](http://twhl.info/vault.php?map=3673)
83. [Fallout](http://www.thewall.de/forum/thread/hl1-sp-48h-mapping-contest/64975.4.html) (map by *simb*)
83. [Fallout](http://www.thewall.de/forum/thread/hl1-sp-48h-mapping-contest/64975.4.html) (map by *simb*) (link dead!)
84. [Final Assault](http://twhl.info/vault.php?map=4500)
85. [Flat](http://hl.loess.ru/?mods=&search=Flat)
86. [Freeman's Allegiance](https://www.runthinkshootlive.com/posts/freemans-allegiance/)
@ -498,8 +498,8 @@ Mods:
109. [Hospital](https://gamebanana.com/maps/167446) (you need to edit **liblist.gam** file in the mod's folder - delete *gamedll & type* strings from it before you start to play)
110. [Hostage](https://www.runthinkshootlive.com/posts/hostage-2/)
111. [House](http://www.artpeter.net/Data/HalfLife/Hl.php)
112. [Impulse 101 Fun - The Train](http://web.archive.org/web/20070305075816/http://www.twhl.co.za/mapvault/2817.zip) (map from *TWHL* by *Archie* aka *The Hunter*)
113. [In America](http://www.lambda-force.org/load/half_life/karty/half_life_in_america/18-1-0-476)
112. [Impulse 101 Fun - The Train](https://drive.google.com/file/d/1jAuMCCmREH0mfAEAscqaG8FQGa2uNknb/view?usp=sharing) (map from *TWHL* by *Archie* aka *The Hunter*)
113. [In America](https://drive.google.com/file/d/1gOC8zfnUvBxRy8Rr8juNiUNbLYjoZpnn/view?usp=sharing)
114. [In the Kitchen](http://twhl.info/vault.php?map=4314)
115. [Infiltration](https://www.fileplanet.com/7467/0/fileinfo/Infiltration)
116. [Interactivity & Lots of Entities](http://twhl.info/vault.php?map=5744) (link dead!)
@ -668,7 +668,7 @@ Mods:
279. [X-treme Violence](http://www.moddb.com/mods/x-treme-violence)
280. [XargoL's Entry for Vassy's Compo](http://twhl.info/vault.php?map=769)
281. [Xen Again](https://www.fileplanet.com/9132/0/fileinfo/XEN-AGAIN)
282. [Xen World](http://www.lambda-force.org/load/half_life/karty/half_life_xen_world/18-1-0-481)
282. [Xen World](http://www.lambda-force.org/load/half_life/karty/half_life_xen_world/18-1-0-481) (link dead!)
283. [XUnil](https://www.fileplanet.com/7883/0/fileinfo/XUNIL)
284. [Zeeba-G's TWHL Compo 26 Entry](http://twhl.info/competitions.php?results=26)
285. [Zombies!](https://gamebanana.com/maps/160812)
@ -694,7 +694,7 @@ For Linux and OS X you must download crossbuild from [here](http://www.moddb.com
2. [Big Scientists](http://www.moddb.com/mods/big-scientists)
3. [Black Silla Assault DEMO v1.2](http://www.moddb.com/mods/black-silla-assault)
4. [Blbej Den](http://www.moddb.com/mods/blbej-den)
5. [Cold Experiment v1](http://jpmaps.wz.cz/epizody.htm) (you will need some files from SoHL to play it properly; download SoHL 1.2, extract files and copy following folders into **coldexv1** folder: cl_dlls, dlls, models, sprites)
5. [Cold Experiment v1](https://www.moddb.com/games/half-life/addons/cold-experiment) (you will need some files from SoHL to play it properly; download SoHL 1.2, extract files and copy following folders into **coldexv1** folder: cl_dlls, dlls, models, sprites)
6. [Dead Sector v1.0a](http://www.moddb.com/mods/dead-sector)
7. [Death Is Dead](http://www.moddb.com/games/half-life/addons/death-is-dead) (there is a fog-related inner bug at the first map)
8. [Escape from Black Mesa Alpha](http://www.moddb.com/mods/escape-from-black-mesa)
@ -710,9 +710,9 @@ For Linux and OS X you must download crossbuild from [here](http://www.moddb.com
18. [Santa's Revenge](http://twhl.info/vault.php?map=4332) (set **fps_max** to **60** to avoid an inner problem of the last map with final scripted sequence, otherwise the mod can not be finished properly)
19. [Sector 6](https://www.moddb.com/mods/sector-6/)
20. [Space Prisoner v1.1](http://www.moddb.com/games/half-life/addons/space-prisoner-v11) (after installing of the mod open **liblist.gam** or **gameinfo.txt** file in the mod's folder and correct the line **gamedll "..\prison\dlls\spirit.dll"** for **gamedll "dlls\spirit.dll"**, otherwise you'll not be able to start a game; there is also a scripting error on a third map of the mod, so you'll be forced to use **noclip** to pass around bugged place)
21. [Terrorist Attack 2](http://terroristattack.wz.cz/mody.html) (link dead!)
21. [Terrorist Attack 2](https://www.moddb.com/games/half-life/addons/terrorist-attack-2)
22. [Timeline III: The Heart of Darkness](http://www.moddb.com/mods/timeline-series)
23. [Underground 2 Demo](http://www.isolated-design.de/half-life-mods/underground-2/)
23. [Underground 2 Demo](https://www.moddb.com/games/half-life/addons/underground-2-demo)
## Mods which based on modified Spirit of Half-Life 1.2 or older(Partially playable with SoHL 1.2 libraries or not playable at all)
1. [Black Death](http://www.moddb.com/mods/half-life-black-death)
@ -825,10 +825,10 @@ Mods:
3. [Bomb Squad](http://www.snarkpit.net/index.php?s=maps&map=3471)
4. [Corruption](http://www.snarkpit.net/index.php?s=maps&map=3154)
5. [Critical Mass](http://www.moddb.com/mods/half-life-critical-mass) [C3M1 Build 1 Demo](https://www.fileplanet.com/125746/120000/fileinfo/C3M1-Build-1)
6. [EPRST!](http://www.planetphillip.com/posts/ep-rst-opposing-force/) (link dead!)
6. [EPRST!](https://www.runthinkshootlive.com/posts/ep-rst/)
7. [Firing Range](https://www.runthinkshootlive.com/posts/firing-range/)
8. [Friendly Fire](https://www.runthinkshootlive.com/posts/friendly-fire/)
9. [Guitar Star Pre-Alpha](http://hl-lab.ru/eng/mods_goldsrc/Guitar_Star_(Prealpha)) (link dead!)
9. [Guitar Star Pre-Alpha](http://gamer-lab.com/rus/mods_goldsrc/Guitar_Star_(Prealpha))
10. [J2000](https://www.runthinkshootlive.com/posts/j2000/)
11. [Killing House for OF](https://www.runthinkshootlive.com/posts/scientist-rescue-aka-cqb/)
12. [Klabautermann](https://www.runthinkshootlive.com/posts/klabautermann/) (though the map has some inner issues, it can be properly finished, just don't let the welder soldier die and don't press the fifth button until you mount a special gun in its' place)

View File

@ -39,7 +39,7 @@ Regular upstream Xash3D README.md follows.
---
# Xash3D FWGS Engine
[![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://discord.fwgs.ru/) \
[![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 FWGS is a fork of Xash3D Engine by Unkle Mike with extended features and crossplatform.
@ -67,16 +67,13 @@ Read more about Xash3D on ModDB: https://www.moddb.com/engines/xash3d-engine
* Vulkan renderer
## Installation & Running
0) Get Xash3D binaries: you can use [testing](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous) build or you can compile engine from source code.
Choose proper build package depending on which platform you're using.
0) Get Xash3D FWGS binaries: you can use [testing](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous) build or you can compile engine from source code.
1) Copy engine binaries to some directory.
2) Copy `valve` directory from [Half-Life](https://store.steampowered.com/app/70/HalfLife/) to directory with engine binaries.
Also if you're using Windows: you should copy `vgui.dll` library from Half-Life directory to Xash3D directory.
As alternative, you can compile [hlsdk-xash3d](https://github.com/FWGS/hlsdk-xash3d) instead of using official Valve game binaries, but you still needed to copy `valve` directory as all game resources located in there.
3) Download [extras.pak](https://github.com/FWGS/xash-extras/releases/tag/v0.19.2) and place it to `valve` directory.
4) Run `xash3d.exe`/`xash3d.sh`/`xash3d` depending on which platform you're using.
Note: on Linux, you may need to create an sh file with the command `LD_LIBRARY_PATH=. ./xash3d`.
If your CPU is NOT x86 compatible or you're running 64-bit version of the engine, you may want to compile [Half-Life SDK](https://github.com/FWGS/hlsdk-xash3d).
This repository contains our fork of HLSDK and restored source code for some of the mods. Not all of them, of course.
You still needed to copy `valve` directory as all game resources located there.
3) Run the main executable (`xash3d.exe` or AppImage).
For additional info, run Xash3D with `-help` command line key.
@ -91,6 +88,13 @@ We are using Waf build system. If you have some Waf-related questions, I recomme
NOTE: NEVER USE GitHub's ZIP ARCHIVES. GitHub doesn't include external dependencies we're using!
### Prerequisites
If your CPU is x86 compatible, we are building 32-bit code by default. This was dont for keeping compatibility with Steam releases of Half-Life and based on it's engine games.
Even if Xash3D FWGS does support targetting 64-bit, you can't load games without recompiling them from source code!
If your CPU is NOT x86 compatible or you decided build 64-bit version of engine, you may want to compile [Half-Life SDK](https://github.com/FWGS/hlsdk-xash3d).
This repository contains our fork of HLSDK and restored source code for some of the mods. Not all of them, of course.
#### Windows (Visual Studio)
* Install Visual Studio.
* Install latest [Python](https://python.org) **OR** run `cinst python.install` if you have Chocolatey.
@ -100,10 +104,6 @@ NOTE: NEVER USE GitHub's ZIP ARCHIVES. GitHub doesn't include external dependenc
* Make sure you have at least 12GB of free space to store all build-time dependencies: ~10GB for Visual Studio, 300 MB for Git, 100 MB for Python and other.
#### GNU/Linux
NOTE FOR USERS WITH X86 COMPATIBLE CPUs:
We have forced Waf to throw an error, if you're trying to build 64-bit engine. This was done for keeping compatibility with Steam releases of Half-Life and based on it's engine games.
Even if Xash3D FWGS does support targetting 64-bit, you can't load games without recompiling them from source code!
##### Debian/Ubuntu
* Enable i386 on your system, if you're compiling 32-bit engine on amd64. If not, skip this
@ -126,11 +126,10 @@ Even if Xash3D FWGS does support targetting 64-bit, you can't load games without
5) Install: `waf install --destdir=c:/path/to/any/output/directory`
#### Linux
If compiling 32-bit on amd64, you may need to supply `export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig` prior to running configure.
0) Examine which build options are available: `./waf --help`
1) Configure build: `./waf configure -T release`
(You need to pass `-8` to compile 64-bit engine on 64-bit x86 processor)
2) Compile: `./waf build`
3) Install(optional): `./waf install --destdir=/path/to/any/output/directory`
Note: if compiling 32-bit on amd64, you may need to supply `export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig` prior to running configure.

View File

@ -9,7 +9,7 @@ NOTE: number at end of pixelformat name it's a total bitscount e.g. PF_RGB_24 ==
========================================================================
*/
#define ImageRAW( type ) (type == PF_RGBA_32 || type == PF_BGRA_32 || type == PF_RGB_24 || type == PF_BGR_24 || type == PF_LUMINANCE)
#define ImageDXT( type ) (type == PF_DXT1 || type == PF_DXT3 || type == PF_DXT5 || type == PF_ATI2)
#define ImageDXT( type ) (type == PF_DXT1 || type == PF_DXT3 || type == PF_DXT5 || type == PF_ATI2 || type == PF_BC6H_SIGNED || type == PF_BC6H_UNSIGNED || type == PF_BC7)
typedef enum
{
@ -21,10 +21,13 @@ typedef enum
PF_RGB_24, // uncompressed dds or another 24-bit image
PF_BGR_24, // big-endian RGB (MacOS)
PF_LUMINANCE,
PF_DXT1, // s3tc DXT1 format
PF_DXT3, // s3tc DXT3 format
PF_DXT5, // s3tc DXT5 format
PF_ATI2, // latc ATI2N format
PF_DXT1, // s3tc DXT1/BC1 format
PF_DXT3, // s3tc DXT3/BC2 format
PF_DXT5, // s3tc DXT5/BC3 format
PF_ATI2, // latc ATI2N/BC5 format
PF_BC6H_SIGNED, // bptc BC6H signed FP16 format
PF_BC6H_UNSIGNED, // bptc BC6H unsigned FP16 format
PF_BC7, // bptc BC7 format
PF_TOTALCOUNT, // must be last
} pixformat_t;

View File

@ -530,7 +530,7 @@ typedef struct
#define MAX_DEMOS 32
#define MAX_MOVIES 8
#define MAX_CDTRACKS 32
#define MAX_CLIENT_SPRITES 256 // SpriteTextures
#define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client)
#define MAX_EFRAGS 8192 // Arcane Dimensions required
#define MAX_REQUESTS 64

View File

@ -725,7 +725,6 @@ typedef int string_t;
typedef unsigned short word;
#include "xash3d_types.h"
#define Q_isspace( ch ) (ch < 32 || ch > 255)
typedef struct
{

View File

@ -18,6 +18,7 @@ GNU General Public License for more details.
#define GFL_NOMODELS (1<<0)
#define GFL_NOSKILLS (1<<1)
#define GFL_RENDER_PICBUTTON_TEXT (1<<2)
/*
========================================================================

View File

@ -20,8 +20,6 @@ GNU General Public License for more details.
#include "build.h"
#if !XASH_WIN32
#if XASH_APPLE
#include <sys/syslimits.h>
#define OS_LIB_EXT "dylib"
@ -30,67 +28,32 @@ GNU General Public License for more details.
#define OS_LIB_EXT "so"
#define OPEN_COMMAND "xdg-open"
#endif
#define OS_LIB_PREFIX "lib"
#if XASH_ANDROID
//#if defined(LOAD_HARDFP)
// #define POSTFIX "_hardfp"
//#else
#define POSTFIX
//#endif
#else
#endif
#define VGUI_SUPPORT_DLL "libvgui_support." OS_LIB_EXT
// Windows-specific
#define __cdecl
#define __stdcall
#define _inline static inline
#define FORCEINLINE inline __attribute__((always_inline))
#if XASH_POSIX
#define PATH_SPLITTER "/"
#include <unistd.h>
#include <dlfcn.h>
#define O_BINARY 0 // O_BINARY is Windows extension
#define O_TEXT 0 // O_TEXT is Windows extension
// Windows functions to posix equivalent
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
#define LoadLibrary( x ) dlopen( x, RTLD_NOW )
#define GetProcAddress( x, y ) dlsym( x, y )
#define FreeLibrary( x ) dlclose( x )
#define tell( a ) lseek(a, 0, SEEK_CUR)
#define HAVE_DUP
#endif
#if XASH_POSIX
#include <unistd.h>
#include <dlfcn.h>
#if XASH_DOS4GW
#define PATH_SPLITTER "\\"
#define LoadLibrary( x ) (0)
#define GetProcAddress( x, y ) (0)
#define FreeLibrary( x ) (0)
#endif
//#define MAKEWORD( a, b ) ((short int)(((unsigned char)(a))|(((short int)((unsigned char)(b)))<<8)))
#define max( a, b ) (((a) > (b)) ? (a) : (b))
#define min( a, b ) (((a) < (b)) ? (a) : (b))
#define PATH_SPLITTER "/"
#define HAVE_DUP
/// TODO: check if we may clean this defines, it should not appear in non-platform code!
typedef unsigned char BYTE;
typedef short int WORD;
typedef unsigned int DWORD;
typedef int LONG;
typedef unsigned int ULONG;
typedef int WPARAM;
typedef unsigned int LPARAM;
#define O_BINARY 0
#define O_TEXT 0
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
#elif XASH_DOS4GW
#define PATH_SPLITTER "\\"
#endif
typedef void* HANDLE;
typedef void* HMODULE;
typedef void* HINSTANCE;
typedef char* LPSTR;
typedef struct tagPOINT
{
int x, y;
@ -108,19 +71,6 @@ GNU General Public License for more details.
#define read _read
#define alloca _alloca
// shut-up compiler warnings
#pragma warning(disable : 4244) // MIPS
#pragma warning(disable : 4018) // signed/unsigned mismatch
#pragma warning(disable : 4305) // truncation from const double to float
#pragma warning(disable : 4115) // named type definition in parentheses
#pragma warning(disable : 4100) // unreferenced formal parameter
#pragma warning(disable : 4127) // conditional expression is constant
#pragma warning(disable : 4057) // differs in indirection to slightly different base types
#pragma warning(disable : 4201) // nonstandard extension used
#pragma warning(disable : 4706) // assignment within conditional expression
#pragma warning(disable : 4054) // type cast' : from function pointer
#pragma warning(disable : 4310) // cast truncates constant value
#define HSPRITE WINAPI_HSPRITE
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
@ -130,13 +80,9 @@ GNU General Public License for more details.
#define OS_LIB_PREFIX ""
#define OS_LIB_EXT "dll"
#define VGUI_SUPPORT_DLL "../vgui_support." OS_LIB_EXT
#ifdef XASH_64BIT
// windows NameForFunction not implemented yet
#define XASH_ALLOW_SAVERESTORE_OFFSETS
#endif
#define HAVE_DUP
#endif //WIN32
#ifndef XASH_LOW_MEMORY
#define XASH_LOW_MEMORY 0
#endif

View File

@ -2,7 +2,9 @@
#ifndef XASH_TYPES_H
#define XASH_TYPES_H
#ifdef _WIN32
#include "build.h"
#if XASH_WIN32
#include <wchar.h> // off_t
#endif // _WIN32
@ -64,19 +66,41 @@ typedef uint64_t longtime_t;
#define ColorIndex( c ) ((( c ) - '0' ) & 7 )
#if defined(__GNUC__)
#ifdef __i386__
#define EXPORT __attribute__ ((visibility ("default"),force_align_arg_pointer))
#define GAME_EXPORT __attribute((force_align_arg_pointer))
#else
#define EXPORT __attribute__ ((visibility ("default")))
#define GAME_EXPORT
#endif
#ifdef __i386__
#define EXPORT __attribute__ ((visibility ("default"),force_align_arg_pointer))
#define GAME_EXPORT __attribute((force_align_arg_pointer))
#else
#define EXPORT __attribute__ ((visibility ("default")))
#define GAME_EXPORT
#endif
#define _format(x) __attribute__((format(printf, x, x+1)))
#define NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport )
#define GAME_EXPORT
#define EXPORT __declspec( dllexport )
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#else
#define EXPORT
#define GAME_EXPORT
#define EXPORT
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#endif
#if ( __GNUC__ >= 3 )
#define unlikely(x) __builtin_expect(x, 0)
#define likely(x) __builtin_expect(x, 1)
#elif defined( __has_builtin )
#if __has_builtin( __builtin_expect )
#define unlikely(x) __builtin_expect(x, 0)
#define likely(x) __builtin_expect(x, 1)
#else
#define unlikely(x) (x)
#define likely(x) (x)
#endif
#else
#define unlikely(x) (x)
#define likely(x) (x)
#endif
@ -114,9 +138,13 @@ typedef unsigned int dword;
typedef unsigned int uint;
typedef char string[MAX_STRING];
typedef struct file_s file_t; // normal file
typedef struct wfile_s wfile_t; // wad file
typedef struct stream_s stream_t; // sound stream for background music playing
typedef off_t fs_offset_t;
#if XASH_WIN32
typedef int fs_size_t; // return type of _read, _write funcs
#else /* !XASH_WIN32 */
typedef ssize_t fs_size_t;
#endif /* !XASH_WIN32 */
typedef struct dllfunc_s
{
@ -132,7 +160,7 @@ typedef struct dll_info_s
void *link; // hinstance of loading library
} dll_info_t;
typedef void (*setpair_t)( const char *key, const void *value, void *buffer, void *numpairs );
typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs );
// config strings are a general means of communication from
// the server to all connected clients.

View File

@ -106,7 +106,7 @@ void CL_RemoveFromResourceList( resource_t *pResource )
if( pResource->pPrev == NULL || pResource->pNext == NULL )
Host_Error( "mislinked resource in CL_RemoveFromResourceList\n" );
if ( pResource->pNext == pResource || pResource->pPrev == pResource )
if( pResource->pNext == pResource || pResource->pPrev == pResource )
Host_Error( "attempt to free last entry in list.\n" );
pResource->pPrev->pNext = pResource->pNext;

View File

@ -888,7 +888,7 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length )
qboolean swallowmessages = true;
static int tdlastdemoframe = 0;
byte *userbuf = NULL;
size_t size;
size_t size = 0;
byte cmd;
if( !cls.demofile )

View File

@ -188,8 +188,6 @@ void R_StoreEfrags( efrag_t **ppefrag, int framecount )
case mod_brush:
case mod_studio:
case mod_sprite:
pent = pefrag->entity;
if( pent->visframe != framecount )
{
if( CL_AddVisibleEntity( pent, ET_FRAGMENTED ))

View File

@ -46,7 +46,7 @@ short GAME_EXPORT R_LookupColor( byte r, byte g, byte b )
float rf, gf, bf;
bestdiff = 999999;
best = 65535;
best = -1;
for( i = 0; i < 256; i++ )
{
@ -683,42 +683,46 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
switch( beamType )
{
case TE_BEAMPOINTS:
start[0] = MSG_ReadCoord( msg );
start[1] = MSG_ReadCoord( msg );
start[2] = MSG_ReadCoord( msg );
end[0] = MSG_ReadCoord( msg );
end[1] = MSG_ReadCoord( msg );
end[2] = MSG_ReadCoord( msg );
modelIndex = MSG_ReadShort( msg );
startFrame = MSG_ReadByte( msg );
frameRate = (float)MSG_ReadByte( msg );
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.01f);
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
a = (float)MSG_ReadByte( msg ) / 255.0f;
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
R_BeamPoints( start, end, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b );
break;
case TE_BEAMENTPOINT:
startEnt = MSG_ReadShort( msg );
end[0] = MSG_ReadCoord( msg );
end[1] = MSG_ReadCoord( msg );
end[2] = MSG_ReadCoord( msg );
case TE_BEAMENTS:
if( beamType == TE_BEAMENTS )
{
startEnt = MSG_ReadShort( msg );
endEnt = MSG_ReadShort( msg );
}
else
{
if( beamType == TE_BEAMENTPOINT )
{
startEnt = MSG_ReadShort( msg );
}
else
{
start[0] = MSG_ReadCoord( msg );
start[1] = MSG_ReadCoord( msg );
start[2] = MSG_ReadCoord( msg );
}
end[0] = MSG_ReadCoord( msg );
end[1] = MSG_ReadCoord( msg );
end[2] = MSG_ReadCoord( msg );
}
modelIndex = MSG_ReadShort( msg );
startFrame = MSG_ReadByte( msg );
frameRate = (float)MSG_ReadByte( msg );
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.01f);
frameRate = (float)MSG_ReadByte( msg ) * 0.1f;
life = (float)MSG_ReadByte( msg ) * 0.1f;
width = (float)MSG_ReadByte( msg ) * 0.1f;
noise = (float)MSG_ReadByte( msg ) * 0.01f;
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
a = (float)MSG_ReadByte( msg ) / 255.0f;
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
R_BeamEntPoint( startEnt, end, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b );
speed = (float)MSG_ReadByte( msg ) * 0.1f;
if( beamType == TE_BEAMENTS )
R_BeamEnts( startEnt, endEnt, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b );
else if( beamType == TE_BEAMENTPOINT )
R_BeamEntPoint( startEnt, end, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b );
else
R_BeamPoints( start, end, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b );
break;
case TE_LIGHTNING:
start[0] = MSG_ReadCoord( msg );
@ -727,27 +731,11 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
end[0] = MSG_ReadCoord( msg );
end[1] = MSG_ReadCoord( msg );
end[2] = MSG_ReadCoord( msg );
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.01f);
life = (float)MSG_ReadByte( msg ) * 0.1f;
width = (float)MSG_ReadByte( msg ) * 0.1f;
noise = (float)MSG_ReadByte( msg ) * 0.01f;
modelIndex = MSG_ReadShort( msg );
R_BeamLightning( start, end, modelIndex, life, width, noise, 0.6F, 3.5f );
break;
case TE_BEAMENTS:
startEnt = MSG_ReadShort( msg );
endEnt = MSG_ReadShort( msg );
modelIndex = MSG_ReadShort( msg );
startFrame = MSG_ReadByte( msg );
frameRate = (float)(MSG_ReadByte( msg ) * 0.1f);
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.01f);
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
a = (float)MSG_ReadByte( msg ) / 255.0f;
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
R_BeamEnts( startEnt, endEnt, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b );
R_BeamLightning( start, end, modelIndex, life, width, noise, 0.6f, 3.5f );
break;
case TE_BEAM:
break;
@ -773,21 +761,21 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
end[2] = MSG_ReadCoord( msg );
modelIndex = MSG_ReadShort( msg );
startFrame = MSG_ReadByte( msg );
frameRate = (float)(MSG_ReadByte( msg ));
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ));
noise = (float)(MSG_ReadByte( msg ) * 0.1f);
frameRate = (float)MSG_ReadByte( msg ) * 0.1f;
life = (float)MSG_ReadByte( msg ) * 0.1f;
width = (float)MSG_ReadByte( msg );
noise = (float)MSG_ReadByte( msg ) * 0.01f;
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
a = (float)MSG_ReadByte( msg ) / 255.0f;
speed = (float)(MSG_ReadByte( msg ) / 0.1f);
speed = (float)MSG_ReadByte( msg ) * 0.1f;
R_BeamCirclePoints( beamType, start, end, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b );
break;
case TE_BEAMFOLLOW:
startEnt = MSG_ReadShort( msg );
modelIndex = MSG_ReadShort( msg );
life = (float)(MSG_ReadByte( msg ) * 0.1f);
life = (float)MSG_ReadByte( msg ) * 0.1f;
width = (float)MSG_ReadByte( msg );
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
@ -800,15 +788,15 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
endEnt = MSG_ReadShort( msg );
modelIndex = MSG_ReadShort( msg );
startFrame = MSG_ReadByte( msg );
frameRate = (float)MSG_ReadByte( msg );
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.01f);
frameRate = (float)MSG_ReadByte( msg ) * 0.1f;
life = (float)MSG_ReadByte( msg ) * 0.1f;
width = (float)MSG_ReadByte( msg ) * 0.1f;
noise = (float)MSG_ReadByte( msg ) * 0.01f;
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
a = (float)MSG_ReadByte( msg ) / 255.0f;
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
speed = (float)MSG_ReadByte( msg ) * 0.1f;
R_BeamRing( startEnt, endEnt, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b );
break;
case TE_BEAMHOSE:
@ -1265,7 +1253,7 @@ void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t dir, int pcolor,
particle_t *p;
int i, j;
float arc;
float accel = speed;
int accel = speed; // must be integer due to bug in GoldSrc
for( arc = 0.05f, i = 0; i < 100; i++ )
{

View File

@ -158,7 +158,7 @@ CL_EventIndex
*/
word CL_EventIndex( const char *name )
{
int i;
word i;
if( !COM_CheckString( name ))
return 0;
@ -484,7 +484,7 @@ void GAME_EXPORT CL_PlaybackEvent( int flags, const edict_t *pInvoker, word even
return;
// first check event for out of bounds
if( eventindex < 1 || eventindex > MAX_EVENTS )
if( eventindex < 1 || eventindex >= MAX_EVENTS )
{
Con_DPrintf( S_ERROR "CL_PlaybackEvent: invalid eventindex %i\n", eventindex );
return;

View File

@ -58,10 +58,13 @@ void CL_UpdatePositions( cl_entity_t *ent )
ent->current_position = (ent->current_position + 1) & HISTORY_MASK;
ph = &ent->ph[ent->current_position];
VectorCopy( ent->curstate.origin, ph->origin );
VectorCopy( ent->curstate.angles, ph->angles );
ph->animtime = ent->curstate.animtime; // !!!
if( ent->model && ent->model->type == mod_brush )
ph->animtime = ent->curstate.animtime;
else
ph->animtime = cl.time;
}
/*
@ -219,7 +222,7 @@ void CL_UpdateLatchedVars( cl_entity_t *ent )
if( ent->curstate.sequence != ent->prevstate.sequence )
{
memcpy( ent->prevstate.blending, ent->latched.prevseqblending, sizeof( ent->prevstate.blending ));
memcpy( ent->latched.prevseqblending, ent->prevstate.blending, sizeof( ent->latched.prevseqblending ));
ent->latched.prevsequence = ent->prevstate.sequence;
ent->latched.sequencetime = ent->curstate.animtime;
}
@ -310,7 +313,7 @@ void CL_ProcessEntityUpdate( cl_entity_t *ent )
if( FBitSet( ent->curstate.entityType, ENTITY_NORMAL ))
COM_NormalizeAngles( ent->curstate.angles );
parametric = CL_ParametricMove( ent );
parametric = ent->curstate.starttime != 0.0f && ent->curstate.impacttime != 0.0f;
// allow interpolation on bmodels too
if( ent->model && ent->model->type == mod_brush )
@ -349,7 +352,7 @@ find two timestamps
qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, float targettime, position_history_t **ph0, position_history_t **ph1 )
{
qboolean extrapolate = true;
int i, i0, i1, imod;
uint i, i0, i1, imod;
float at;
imod = ent->current_position;
@ -406,7 +409,7 @@ void CL_PureOrigin( cl_entity_t *ent, float t, vec3_t outorigin, vec3_t outangle
VectorSubtract( ph0->origin, ph1->origin, delta );
if( t0 != t1 )
if( !Q_equal( t0, t1 ))
frac = ( t - t1 ) / ( t0 - t1 );
else frac = 1.0f;
@ -486,7 +489,9 @@ int CL_InterpolateModel( cl_entity_t *e )
return 0;
}
if( t2 == t1 )
// HACKHACK: workaround buggy position history animtime
// going backward sometimes
if( Q_equal( t2, t1 ) || t2 < t1 )
{
VectorCopy( ph0->origin, e->origin );
VectorCopy( ph0->angles, e->angles );
@ -978,8 +983,13 @@ qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType )
}
// don't add the player in firstperson mode
if( RP_LOCALCLIENT( ent ) && !CL_IsThirdPerson( ) && ( ent->index == cl.viewentity ))
return false;
if( RP_LOCALCLIENT( ent ))
{
cl.local.apply_effects = true;
if( !CL_IsThirdPerson( ) && ( ent->index == cl.viewentity ))
return false;
}
if( entityType == ET_BEAM )
{
@ -993,12 +1003,8 @@ qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType )
// because pTemp->entity.curstate.effects
// is already occupied by FTENT_FLICKER
if( entityType != ET_TEMPENTITY )
if( entityType != ET_TEMPENTITY && !RP_LOCALCLIENT( ent ) )
{
// no reason to do it twice
if( RP_LOCALCLIENT( ent ))
cl.local.apply_effects = false;
// apply client-side effects
CL_AddEntityEffects( ent );
@ -1050,7 +1056,6 @@ void CL_LinkPlayers( frame_t *frame )
// apply muzzleflash to weaponmodel
if( ent && FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ))
SetBits( clgame.viewent.curstate.effects, EF_MUZZLEFLASH );
cl.local.apply_effects = true;
// check all the clients but add only visible
for( i = 0, state = frame->playerstate; i < MAX_CLIENTS; i++, state++ )

View File

@ -1235,6 +1235,10 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
model_t *mod;
int i;
// use high indices for client sprites
// for GoldSrc bug-compatibility
const int start = type != SPR_HUDSPRITE ? MAX_CLIENT_SPRITES / 2 : 0;
if( !COM_CheckString( filename ))
{
Con_Reportf( S_ERROR "CL_LoadSpriteModel: bad name!\n" );
@ -1244,8 +1248,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
Q_strncpy( name, filename, sizeof( name ));
COM_FixSlashes( name );
// slot 0 isn't used
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
{
if( !Q_stricmp( mod->name, name ))
{
@ -1262,12 +1265,12 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
}
// find a free model slot spot
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
if( !mod->name[0] ) break; // this is a valid spot
if( i == MAX_CLIENT_SPRITES )
if( i == MAX_CLIENT_SPRITES / 2 )
{
Con_Printf( S_ERROR "MAX_CLIENT_SPRITES limit exceeded (%d)\n", MAX_CLIENT_SPRITES );
Con_Printf( S_ERROR "MAX_CLIENT_SPRITES limit exceeded (%d)\n", MAX_CLIENT_SPRITES / 2 );
return NULL;
}
@ -1308,7 +1311,7 @@ HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags )
if(( spr = CL_LoadSpriteModel( szPicName, SPR_CLIENT, texFlags )) == NULL )
return 0;
return (spr - clgame.sprites); // return index
return (spr - clgame.sprites) + 1; // return index
}
/*
@ -1324,7 +1327,7 @@ HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
if(( spr = CL_LoadSpriteModel( szPicName, SPR_HUDSPRITE, 0 )) == NULL )
return 0;
return (spr - clgame.sprites); // return index
return (spr - clgame.sprites) + 1; // return index
}
/*
@ -1336,10 +1339,11 @@ CL_GetSpritePointer
const model_t *CL_GetSpritePointer( HSPRITE hSprite )
{
model_t *mod;
int index = hSprite - 1;
if( hSprite <= 0 || hSprite >= MAX_CLIENT_SPRITES )
if( index < 0 || index >= MAX_CLIENT_SPRITES )
return NULL; // bad image
mod = &clgame.sprites[hSprite];
mod = &clgame.sprites[index];
if( mod->needload == NL_NEEDS_LOADED )
{
@ -2299,9 +2303,9 @@ static void GAME_EXPORT pfnKillEvents( int entnum, const char *eventname )
int i;
event_state_t *es;
event_info_t *ei;
int eventIndex = CL_EventIndex( eventname );
word eventIndex = CL_EventIndex( eventname );
if( eventIndex < 0 || eventIndex >= MAX_EVENTS )
if( eventIndex >= MAX_EVENTS )
return;
if( entnum < 0 || entnum > clgame.maxEntities )
@ -2666,7 +2670,14 @@ pfnLoadMapSprite
*/
model_t *pfnLoadMapSprite( const char *filename )
{
return CL_LoadSpriteModel( filename, SPR_MAPSPRITE, 0 );
model_t *mod;
mod = Mod_FindName( filename, false );
if( CL_LoadHudSprite( filename, mod, SPR_MAPSPRITE, 0 ))
return mod;
return NULL;
}
/*
@ -2929,15 +2940,16 @@ pfnDrawString
*/
static int GAME_EXPORT pfnDrawString( int x, int y, const char *str, int r, int g, int b )
{
int iWidth = 0;
Con_UtfProcessChar(0);
// draw the string until we hit the null character or a newline character
for ( ; *str != 0 && *str != '\n'; str++ )
{
x += pfnVGUI2DrawCharacterAdditive( x, y, (unsigned char)*str, r, g, b, 0 );
iWidth += pfnVGUI2DrawCharacterAdditive( x + iWidth, y, (unsigned char)*str, r, g, b, 0 );
}
return x;
return iWidth;
}
/*
@ -2952,8 +2964,7 @@ static int GAME_EXPORT pfnDrawStringReverse( int x, int y, const char *str, int
char *szIt;
for( szIt = (char*)str; *szIt != 0; szIt++ )
x -= clgame.scrInfo.charWidths[ (unsigned char) *szIt ];
pfnDrawString( x, y, str, r, g, b );
return x;
return pfnDrawString( x, y, str, r, g, b );
}
/*
@ -3087,11 +3098,7 @@ handle colon separately
*/
char *pfnParseFile( char *data, char *token )
{
char *out;
out = _COM_ParseFileSafe( data, token, INT_MAX, PFILE_HANDLECOLON, NULL );
return out;
return COM_ParseFileSafe( data, token, PFILE_TOKEN_MAX_LENGTH, PFILE_HANDLECOLON, NULL, NULL );
}
/*
@ -3178,16 +3185,7 @@ convert world coordinates (x,y,z) into screen (x, y)
*/
int TriWorldToScreen( const float *world, float *screen )
{
int retval;
retval = ref.dllFuncs.WorldToScreen( world, screen );
screen[0] = 0.5f * screen[0] * (float)clgame.viewport[2];
screen[1] = -0.5f * screen[1] * (float)clgame.viewport[3];
screen[0] += 0.5f * (float)clgame.viewport[2];
screen[1] += 0.5f * (float)clgame.viewport[3];
return retval;
return ref.dllFuncs.WorldToScreen( world, screen );
}
/*
@ -3321,7 +3319,7 @@ NetAPI_InitNetworking
*/
void GAME_EXPORT NetAPI_InitNetworking( void )
{
NET_Config( true ); // allow remote
NET_Config( true, false ); // allow remote
}
/*
@ -3874,7 +3872,7 @@ static cl_enginefunc_t gEngfuncs =
(void*)Cmd_GetName,
pfnGetClientOldTime,
pfnGetGravity,
Mod_Handle,
CL_ModelHandle,
pfnEnableTexSort,
pfnSetLightmapColor,
pfnSetLightmapScale,
@ -3923,7 +3921,6 @@ void CL_UnloadProgs( void )
Cvar_FullSet( "host_clientloaded", "0", FCVAR_READ_ONLY );
COM_FreeLibrary( clgame.hInstance );
VGui_Shutdown();
Mem_FreePool( &cls.mempool );
Mem_FreePool( &clgame.mempool );
memset( &clgame, 0, sizeof( clgame ));
@ -3967,7 +3964,7 @@ qboolean CL_LoadProgs( const char *name )
#else
// this doesn't mean other platforms uses SDL2 in any case
// it just helps input code to stay platform-independent
clgame.client_dll_uses_sdl = false;
clgame.client_dll_uses_sdl = true;
#endif
clgame.hInstance = COM_LoadLibrary( name, false, false );
@ -3984,7 +3981,17 @@ qboolean CL_LoadProgs( const char *name )
// trying to fill interface now
GetClientAPI( &clgame.dllFuncs );
}
else if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "F" )) != NULL )
{
Con_Reportf( "CL_LoadProgs: found single callback export (secured client dlls)\n" );
// trying to fill interface now
CL_GetSecuredClientAPI( GetClientAPI );
}
if ( GetClientAPI != NULL )
{
// check critical functions again
for( func = cdll_exports; func && func->name; func++ )
{

View File

@ -418,6 +418,8 @@ static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in )
out->flags |= GFL_NOMODELS;
if( in->noskills )
out->flags |= GFL_NOSKILLS;
if( in->render_picbutton_text )
out->flags |= GFL_RENDER_PICBUTTON_TEXT;
}
static qboolean PIC_Scissor( float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 )
@ -979,7 +981,7 @@ pfnGetGamesList
*/
static GAMEINFO ** GAME_EXPORT pfnGetGamesList( int *numGames )
{
if( numGames ) *numGames = SI.numgames;
if( numGames ) *numGames = FI->numgames;
return gameui.modsInfo;
}
@ -1059,10 +1061,7 @@ pfnChangeInstance
*/
static void GAME_EXPORT pfnChangeInstance( const char *newInstance, const char *szFinalMessage )
{
if( !szFinalMessage ) szFinalMessage = "";
if( !newInstance || !*newInstance ) return;
Host_NewInstance( newInstance, szFinalMessage );
Con_Reportf( S_ERROR "ChangeInstance menu call is deprecated!\n" );
}
/*
@ -1119,6 +1118,29 @@ static char *pfnParseFile( char *buf, char *token )
return COM_ParseFile( buf, token, INT_MAX );
}
/*
=============
pfnFileExists
legacy wrapper
=============
*/
static int pfnFileExists( const char *path, int gamedironly )
{
return FS_FileExists( path, gamedironly );
}
/*
=============
pfnDelete
legacy wrapper
=============
*/
static int pfnDelete( const char *path )
{
return FS_Delete( path );
}
// engine callbacks
static ui_enginefuncs_t gEngfuncs =
@ -1166,7 +1188,7 @@ static ui_enginefuncs_t gEngfuncs =
pfnRenderScene,
pfnAddEntity,
Host_Error,
FS_FileExists,
pfnFileExists,
pfnGetGameDir,
Cmd_CheckMapsList,
CL_Active,
@ -1205,7 +1227,7 @@ static ui_enginefuncs_t gEngfuncs =
COM_CompareFileTime,
VID_GetModeString,
(void*)COM_SaveFile,
(void*)FS_Delete
pfnDelete
};
static void pfnEnableTextInput( int enable )
@ -1227,6 +1249,11 @@ static int pfnGetRenderers( unsigned int num, char *shortName, size_t size1, cha
return 1;
}
static char *pfnParseFileSafe( char *data, char *buf, const int size, unsigned int flags, int *len )
{
return COM_ParseFileSafe( data, buf, size, flags, len, NULL );
}
static ui_extendedfuncs_t gExtendedfuncs =
{
pfnEnableTextInput,
@ -1235,7 +1262,8 @@ static ui_extendedfuncs_t gExtendedfuncs =
Con_UtfMoveRight,
pfnGetRenderers,
Sys_DoubleTime,
_COM_ParseFileSafe,
pfnParseFileSafe,
NET_AdrToString,
R_GetRenderDevice
};
@ -1356,13 +1384,13 @@ qboolean UI_LoadProgs( void )
Cvar_FullSet( "host_gameuiloaded", "1", FCVAR_READ_ONLY );
// setup gameinfo
for( i = 0; i < SI.numgames; i++ )
for( i = 0; i < FI->numgames; i++ )
{
gameui.modsInfo[i] = Mem_Calloc( gameui.mempool, sizeof( GAMEINFO ));
UI_ConvertGameInfo( gameui.modsInfo[i], SI.games[i] );
UI_ConvertGameInfo( gameui.modsInfo[i], FI->games[i] );
}
UI_ConvertGameInfo( &gameui.gameInfo, SI.GameInfo ); // current gameinfo
UI_ConvertGameInfo( &gameui.gameInfo, FI->GameInfo ); // current gameinfo
// setup globals
gameui.globals->developer = host.allow_console;

View File

@ -70,6 +70,7 @@ convar_t *cl_upmax;
convar_t *cl_lw;
convar_t *cl_charset;
convar_t *cl_trace_messages;
convar_t *cl_nat;
convar_t *hud_utf8;
convar_t *ui_renderworld;
@ -195,8 +196,6 @@ void CL_CheckClientState( void )
Netchan_ReportFlow( &cls.netchan );
Con_DPrintf( "client connected at %.2f sec\n", Sys_DoubleTime() - cls.timestart );
if(( cls.demoplayback || cls.disable_servercount != cl.servercount ) && cl.video_prepped )
SCR_EndLoadingPlaque(); // get rid of loading plaque
}
}
@ -234,6 +233,7 @@ void CL_SignonReply( void )
Mem_PrintStats();
break;
case 2:
SCR_EndLoadingPlaque();
if( cl.proxy_redirect && !cls.spectator )
CL_Disconnect();
cl.proxy_redirect = false;
@ -243,7 +243,7 @@ void CL_SignonReply( void )
float CL_LerpInterval( void )
{
return max( cl_interp->value, 1.f / cl_updaterate->value );
return Q_max( cl_interp->value, 1.f / cl_updaterate->value );
}
/*
@ -296,7 +296,7 @@ static float CL_LerpPoint( void )
if( cl_interp->value > 0.001f )
{
// manual lerp value (goldsrc mode)
float td = max( 0.f, cl.time - cl.mtime[0] );
float td = Q_max( 0.f, cl.time - cl.mtime[0] );
frac = td / CL_LerpInterval();
}
else if( server_frametime > 0.001f )
@ -528,7 +528,7 @@ qboolean CL_ProcessShowTexturesCmds( usercmd_t *cmd )
if( released & ( IN_RIGHT|IN_MOVERIGHT ))
Cvar_SetValue( "r_showtextures", gl_showtextures->value + 1 );
if( released & ( IN_LEFT|IN_MOVELEFT ))
Cvar_SetValue( "r_showtextures", max( 1, gl_showtextures->value - 1 ));
Cvar_SetValue( "r_showtextures", Q_max( 1, gl_showtextures->value - 1 ));
oldbuttons = cmd->buttons;
return true;
@ -1253,7 +1253,7 @@ void CL_Connect_f( void )
// if running a local server, kill it and reissue
if( SV_Active( )) Host_ShutdownServer();
NET_Config( true ); // allow remote
NET_Config( true, !CVAR_TO_BOOL( cl_nat )); // allow remote
Con_Printf( "server %s\n", server );
CL_Disconnect();
@ -1299,7 +1299,7 @@ void CL_Rcon_f( void )
message[3] = (char)255;
message[4] = 0;
NET_Config( true ); // allow remote
NET_Config( true, false ); // allow remote
Q_strcat( message, "rcon " );
Q_strcat( message, rcon_client_password->string );
@ -1562,8 +1562,7 @@ void CL_LocalServers_f( void )
netadr_t adr;
Con_Printf( "Scanning for servers on the local network area...\n" );
NET_Config( true ); // allow remote
cls.legacyservercount = 0;
NET_Config( true, true ); // allow remote
// send a broadcast packet
adr.type = NA_BROADCAST;
@ -1585,13 +1584,12 @@ void CL_InternetServers_f( void )
char *info = fullquery + sizeof( MS_SCAN_REQUEST ) - 1;
const size_t remaining = sizeof( fullquery ) - sizeof( MS_SCAN_REQUEST );
NET_Config( true ); // allow remote
NET_Config( true, true ); // allow remote
Con_Printf( "Scanning for servers on the internet area...\n" );
Info_SetValueForKey( info, "gamedir", GI->gamefolder, remaining );
Info_SetValueForKey( info, "clver", XASH_VERSION, remaining ); // let master know about client version
// Info_SetValueForKey( info, "nat", cl_nat->string, remaining );
cls.legacyservercount = 0;
Info_SetValueForKey( info, "nat", cl_nat->string, remaining );
cls.internetservers_wait = NET_SendToMasters( NS_CLIENT, sizeof( MS_SCAN_REQUEST ) + Q_strlen( info ), fullquery );
cls.internetservers_pending = true;
@ -1722,8 +1720,6 @@ void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
{
Netchan_OutOfBandPrint( NS_CLIENT, from, "info %i", PROTOCOL_LEGACY_VERSION );
Con_Printf( "^1Server^7: %s, Info: %s\n", NET_AdrToString( from ), infostring );
if( cls.legacyservercount < MAX_LEGACY_SERVERS )
cls.legacyservers[cls.legacyservercount++] = from;
return;
}
@ -1733,14 +1729,10 @@ void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
return; // unsupported proto
}
for( i = 0; i < cls.legacyservercount; i++ )
if( !COM_CheckString( Info_ValueForKey( infostring, "p" )))
{
if( NET_CompareAdr( cls.legacyservers[i], from ) )
{
Info_SetValueForKey( infostring, "legacy", "1", sizeof( infostring ) );
Con_Print("Legacy: ");
break;
}
Info_SetValueForKey( infostring, "legacy", "1", sizeof( infostring ) );
Con_Print("Legacy: ");
}
// more info about servers
@ -2161,7 +2153,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
}
else if( clgame.request_type == NET_REQUEST_GAMEUI )
{
NET_Config( true ); // allow remote
NET_Config( true, false ); // allow remote
Netchan_OutOfBandPrint( NS_CLIENT, servadr, "info %i", PROTOCOL_VERSION );
}
}
@ -2353,11 +2345,10 @@ Replace the displayed name for some resources
*/
const char *CL_CleanFileName( const char *filename )
{
const char *pfilename = filename;
if( COM_CheckString( filename ) && filename[0] == '!' )
pfilename = "customization";
return pfilename;
return "customization";
return filename;
}
@ -2839,6 +2830,7 @@ void CL_InitLocal( void )
cl_updaterate = Cvar_Get( "cl_updaterate", "20", FCVAR_USERINFO|FCVAR_ARCHIVE, "refresh rate of server messages" );
cl_dlmax = Cvar_Get( "cl_dlmax", "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "max allowed outcoming fragment size" );
cl_upmax = Cvar_Get( "cl_upmax", "1200", FCVAR_ARCHIVE, "max allowed incoming fragment size" );
cl_nat = Cvar_Get( "cl_nat", "0", 0, "show servers running under NAT" );
rate = Cvar_Get( "rate", "3500", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player network rate" );
topcolor = Cvar_Get( "topcolor", "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "player top color" );
bottomcolor = Cvar_Get( "bottomcolor", "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "player bottom color" );
@ -2881,7 +2873,6 @@ void CL_InitLocal( void )
Cmd_AddRestrictedCommand ("kill", NULL, "die instantly" );
Cmd_AddCommand ("god", NULL, "enable godmode" );
Cmd_AddCommand ("fov", NULL, "set client field of view" );
Cmd_AddCommand ("log", NULL, "logging server events" );
// register our commands
Cmd_AddCommand ("pause", NULL, "pause the game (if the server allows pausing)" );
@ -2921,7 +2912,7 @@ void CL_InitLocal( void )
Cmd_AddCommand ("levelshot", CL_LevelShot_f, "same as \"screenshot\", used for create plaque images" );
Cmd_AddCommand ("saveshot", CL_SaveShot_f, "used for create save previews with LoadGame menu" );
Cmd_AddRestrictedCommand ("connect", CL_Connect_f, "connect to a server by hostname" );
Cmd_AddCommand ("connect", CL_Connect_f, "connect to a server by hostname" );
Cmd_AddCommand ("reconnect", CL_Reconnect_f, "reconnect to current level" );
Cmd_AddCommand ("rcon", CL_Rcon_f, "sends a command to the server console (rcon_password and rcon_address required)" );
@ -3078,7 +3069,6 @@ void CL_Init( void )
MSG_Init( &cls.datagram, "cls.datagram", cls.datagram_buf, sizeof( cls.datagram_buf ));
// IN_TouchInit();
Con_LoadHistory();
COM_GetCommonLibraryPath( LIBRARY_CLIENT, libpath, sizeof( libpath ));
@ -3099,13 +3089,9 @@ CL_Shutdown
*/
void CL_Shutdown( void )
{
// already freed
if( !cls.initialized ) return;
cls.initialized = false;
Con_Printf( "CL_Shutdown()\n" );
if( !host.crashed )
if( !host.crashed && cls.initialized )
{
Host_WriteOpenGLConfig ();
Host_WriteVideoConfig ();
@ -3119,6 +3105,9 @@ void CL_Shutdown( void )
Mobile_Shutdown ();
SCR_Shutdown ();
CL_UnloadProgs ();
cls.initialized = false;
VGui_Shutdown();
FS_Delete( "demoheader.tmp" ); // remove tmp file
SCR_FreeCinematic (); // release AVI's *after* client.dll because custom renderer may use them
@ -3126,4 +3115,5 @@ void CL_Shutdown( void )
R_Shutdown ();
Con_Shutdown ();
}

View File

@ -103,6 +103,11 @@ static void pfnTouch_RemoveButton( const char *name )
Touch_RemoveButton( name, true );
}
static char *pfnParseFileSafe( char *data, char *buf, const int size, unsigned int flags, int *len )
{
return COM_ParseFileSafe( data, buf, size, flags, len, NULL );
}
static mobile_engfuncs_t gpMobileEngfuncs =
{
MOBILITY_API_VERSION,
@ -118,7 +123,7 @@ static mobile_engfuncs_t gpMobileEngfuncs =
Sys_Warn,
pfnGetNativeObject,
ID_SetCustomClientID,
_COM_ParseFileSafe
pfnParseFileSafe
};
qboolean Mobile_Init( void )

View File

@ -158,6 +158,7 @@ static void NetGraph_InitColors( void )
f = (float)(i - hfrac) / (float)(NETGRAPH_LERP_HEIGHT - hfrac );
VectorMA( mincolor[1], f, dc[1], netcolors[NETGRAPH_NET_COLORS + i] );
}
netcolors[NETGRAPH_NET_COLORS + i][3] = 255;
}
}
@ -259,7 +260,7 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
for( a = 0; a < w; a++ )
{
i = ( cls.netchan.outgoing_sequence - a ) & NET_TIMINGS_MASK;
h = ( netstat_cmdinfo[i].cmd_lerp / 3.0f ) * NETGRAPH_LERP_HEIGHT;
h = Q_min(( netstat_cmdinfo[i].cmd_lerp / 3.0f ) * NETGRAPH_LERP_HEIGHT, net_graphheight->value * 0.7f);
fill.left = x + w - a - 1;
fill.right = fill.bottom = 1;
@ -395,10 +396,10 @@ static void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int coun
if( !out ) out = lastout;
else lastout = out;
Con_DrawString( x, y, va( "in : %i %.2f k/s", netstat_graph[j].msgbytes, cls.netchan.flow[FLOW_INCOMING].avgkbytespersec ), colors );
Con_DrawString( x, y, va( "in : %i %.2f kb/s", netstat_graph[j].msgbytes, cls.netchan.flow[FLOW_INCOMING].avgkbytespersec ), colors );
y += 15;
Con_DrawString( x, y, va( "out: %i %.2f k/s", out, cls.netchan.flow[FLOW_OUTGOING].avgkbytespersec ), colors );
Con_DrawString( x, y, va( "out: %i %.2f kb/s", out, cls.netchan.flow[FLOW_OUTGOING].avgkbytespersec ), colors );
y += 15;
if( graphtype > 2 )
@ -615,7 +616,7 @@ static void NetGraph_GetScreenPos( wrect_t *rect, int *w, int *x, int *y )
*x = rect->left + rect->right - 5 - *w;
break;
case 2: // center
*x = rect->left + ( rect->right - 10 - *w ) / 2;
*x = ( rect->left + ( rect->right - 10 - *w )) / 2;
break;
default: // left sided
*x = rect->left + 5;
@ -672,7 +673,7 @@ void SCR_DrawNetGraph( void )
if( graphtype < 3 )
{
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
ref.dllFuncs.GL_SetRenderMode( kRenderTransColor );
ref.dllFuncs.GL_Bind( XASH_TEXTURE0, R_GetBuiltinTexture( REF_WHITE_TEXTURE ) );
ref.dllFuncs.Begin( TRI_QUADS ); // draw all the fills as a long solid sequence of quads for speedup reasons

View File

@ -484,6 +484,8 @@ void CL_BatchResourceRequest( qboolean initialize )
switch( p->type )
{
case t_sound:
case t_model:
case t_eventscript:
if( !CL_CheckFile( &msg, p ))
break;
CL_MoveToOnHandList( p );
@ -491,11 +493,6 @@ void CL_BatchResourceRequest( qboolean initialize )
case t_skin:
CL_MoveToOnHandList( p );
break;
case t_model:
if( !CL_CheckFile( &msg, p ))
break;
CL_MoveToOnHandList( p );
break;
case t_decal:
if( !HPAK_GetDataPointer( CUSTOM_RES_PATH, p, NULL, NULL ))
{
@ -520,11 +517,6 @@ void CL_BatchResourceRequest( qboolean initialize )
break;
CL_MoveToOnHandList( p );
break;
case t_eventscript:
if( !CL_CheckFile( &msg, p ))
break;
CL_MoveToOnHandList( p );
break;
case t_world:
ASSERT( 0 );
break;
@ -1322,30 +1314,6 @@ void CL_RegisterUserMessage( sizebuf_t *msg )
CL_LinkUserMessage( pszName, svc_num, size );
}
/*
================
CL_RegisterUserMessage
register new user message or update existing
================
*/
/*
void CL_LegacyRegisterUserMessage( sizebuf_t *msg )
{
char *pszName;
int svc_num, size;
svc_num = MSG_ReadByte( msg );
size = MSG_ReadByte( msg );
pszName = MSG_ReadString( msg );
// important stuff
if( size == 0xFF ) size = -1;
svc_num = bound( 0, svc_num, 255 );
CL_LinkUserMessage( pszName, svc_num, size );
}
*/
/*
================
CL_UpdateUserinfo
@ -1819,7 +1787,7 @@ void CL_ParseScreenShake( sizebuf_t *msg )
clgame.shake.amplitude = (float)(word)MSG_ReadShort( msg ) * (1.0f / (float)(1<<12));
clgame.shake.duration = (float)(word)MSG_ReadShort( msg ) * (1.0f / (float)(1<<12));
clgame.shake.frequency = (float)(word)MSG_ReadShort( msg ) * (1.0f / (float)(1<<8));
clgame.shake.time = cl.time + max( clgame.shake.duration, 0.01f );
clgame.shake.time = cl.time + Q_max( clgame.shake.duration, 0.01f );
clgame.shake.next_shake = 0.0f; // apply immediately
}
@ -2413,14 +2381,11 @@ CL_ParseBaseline
void CL_LegacyParseBaseline( sizebuf_t *msg )
{
int i, newnum;
entity_state_t nullstate;
qboolean player;
cl_entity_t *ent;
Delta_InitClient (); // finalize client delta's
memset( &nullstate, 0, sizeof( nullstate ));
newnum = MSG_ReadWord( msg );
player = CL_IsPlayerIndex( newnum );

View File

@ -794,6 +794,8 @@ static float GAME_EXPORT pfnTraceModel( physent_t *pe, float *start, float *end,
matrix4x4 matrix;
hull_t *hull;
PM_InitTrace( trace, end );
old_usehull = clgame.pmove->usehull;
clgame.pmove->usehull = 2;
@ -992,7 +994,6 @@ void CL_SetupPMove( playermove_t *pmove, local_state_t *from, usercmd_t *ucmd, q
pmove->flFallVelocity = ps->flFallVelocity;
pmove->flSwimTime = cd->flSwimTime;
VectorCopy( cd->punchangle, pmove->punchangle );
pmove->flSwimTime = cd->flSwimTime;
pmove->flNextPrimaryAttack = 0.0f; // not used by PM_ code
pmove->effects = ps->effects;
pmove->flags = cd->flags;

View File

@ -864,7 +864,7 @@ void CL_QuakeExecStuff( void )
if( !*text ) break;
text = _COM_ParseFileSafe( text, token, sizeof( token ), PFILE_IGNOREBRACKET, NULL );
text = COM_ParseFileSafe( text, token, sizeof( token ), PFILE_IGNOREBRACKET, NULL, NULL );
if( !text ) break;

View File

@ -117,7 +117,7 @@ static void R_EnvShot( const float *vieworg, const char *name, qboolean skyshot,
else cls.scrshot_action = scrshot_envshot;
// catch negative values
cls.envshot_viewsize = max( 0, shotsize );
cls.envshot_viewsize = Q_max( 0, shotsize );
}
/*

View File

@ -418,7 +418,6 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
cls.draw_changelevel = !is_background;
SCR_UpdateScreen();
cls.disable_screen = host.realtime;
cls.disable_servercount = cl.servercount;
cl.background = is_background; // set right state before svc_serverdata is came
if( !Host_IsDedicated() )
@ -781,6 +780,7 @@ SCR_VidInit
*/
void SCR_VidInit( void )
{
string libpath;
if( !ref.initialized ) // don't call VidInit too soon
return;
@ -795,7 +795,8 @@ void SCR_VidInit( void )
gameui.globals->scrHeight = refState.height;
}
VGui_Startup( NULL, refState.width, refState.height ); // initialized already, so pass NULL
COM_GetCommonLibraryPath( LIBRARY_CLIENT, libpath, sizeof( libpath ));
VGui_Startup( libpath, refState.width, refState.height );
CL_ClearSpriteTextures(); // now all hud sprites are invalid

View File

@ -0,0 +1,460 @@
/*
cl_securedstub.c - secured client dll stub
Copyright (C) 2022 FWGS
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "client.h"
typedef struct cldll_func_src_s
{
int (*pfnInitialize)( cl_enginefunc_t *pEnginefuncs, int iVersion );
void (*pfnInit)( void );
int (*pfnVidInit)( void );
int (*pfnRedraw)( float flTime, int intermission );
int (*pfnUpdateClientData)( client_data_t *cdata, float flTime );
void (*pfnReset)( void );
void (*pfnPlayerMove)( struct playermove_s *ppmove, int server );
void (*pfnPlayerMoveInit)( struct playermove_s *ppmove );
char (*pfnPlayerMoveTexture)( char *name );
void (*IN_ActivateMouse)( void );
void (*IN_DeactivateMouse)( void );
void (*IN_MouseEvent)( int mstate );
void (*IN_ClearStates)( void );
void (*IN_Accumulate)( void );
void (*CL_CreateMove)( float frametime, struct usercmd_s *cmd, int active );
int (*CL_IsThirdPerson)( void );
void (*CL_CameraOffset)( float *ofs ); // unused
void *(*KB_Find)( const char *name );
void (*CAM_Think)( void ); // camera stuff
void (*pfnCalcRefdef)( ref_params_t *pparams );
int (*pfnAddEntity)( int type, cl_entity_t *ent, const char *modelname );
void (*pfnCreateEntities)( void );
void (*pfnDrawNormalTriangles)( void );
void (*pfnDrawTransparentTriangles)( void );
void (*pfnStudioEvent)( const struct mstudioevent_s *event, const cl_entity_t *entity );
void (*pfnPostRunCmd)( struct local_state_s *from, struct local_state_s *to, usercmd_t *cmd, int runfuncs, double time, unsigned int random_seed );
void (*pfnShutdown)( void );
void (*pfnTxferLocalOverrides)( entity_state_t *state, const clientdata_t *client );
void (*pfnProcessPlayerState)( entity_state_t *dst, const entity_state_t *src );
void (*pfnTxferPredictionData)( entity_state_t *ps, const entity_state_t *pps, clientdata_t *pcd, const clientdata_t *ppcd, weapon_data_t *wd, const weapon_data_t *pwd );
void (*pfnDemo_ReadBuffer)( int size, byte *buffer );
int (*pfnConnectionlessPacket)( const struct netadr_s *net_from, const char *args, char *buffer, int *size );
int (*pfnGetHullBounds)( int hullnumber, float *mins, float *maxs );
void (*pfnFrame)( double time );
int (*pfnKey_Event)( int eventcode, int keynum, const char *pszCurrentBinding );
void (*pfnTempEntUpdate)( double frametime, double client_time, double cl_gravity, struct tempent_s **ppTempEntFree, struct tempent_s **ppTempEntActive, int ( *Callback_AddVisibleEntity )( cl_entity_t *pEntity ), void ( *Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ));
cl_entity_t *(*pfnGetUserEntity)( int index );
void (*pfnVoiceStatus)( int entindex, qboolean bTalking );
void (*pfnDirectorMessage)( int iSize, void *pbuf );
int (*pfnGetStudioModelInterface)( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
void (*pfnChatInputPosition)( int *x, int *y );
int (*pfnGetPlayerTeam)( int iPlayer );
void *(*pfnClientFactory)( void );
} cldll_func_src_t;
typedef struct cldll_func_dst_s
{
void (*pfnInitialize)( cl_enginefunc_t **pEnginefuncs, int *iVersion );
void (*pfnInit)( void );
void (*pfnVidInit)( void );
void (*pfnRedraw)( float *flTime, int *intermission );
void (*pfnUpdateClientData)( client_data_t **cdata, float *flTime );
void (*pfnReset)( void );
void (*pfnPlayerMove)( struct playermove_s **ppmove, int *server );
void (*pfnPlayerMoveInit)( struct playermove_s **ppmove );
void (*pfnPlayerMoveTexture)( char **name );
void (*IN_ActivateMouse)( void );
void (*IN_DeactivateMouse)( void );
void (*IN_MouseEvent)( int *mstate );
void (*IN_ClearStates)( void );
void (*IN_Accumulate)( void );
void (*CL_CreateMove)( float *frametime, struct usercmd_s **cmd, int *active );
void (*CL_IsThirdPerson)( void );
void (*CL_CameraOffset)( float **ofs );
void (*KB_Find)( const char **name );
void (*CAM_Think)( void );
void (*pfnCalcRefdef)( ref_params_t **pparams );
void (*pfnAddEntity)( int *type, cl_entity_t **ent, const char **modelname );
void (*pfnCreateEntities)( void );
void (*pfnDrawNormalTriangles)( void );
void (*pfnDrawTransparentTriangles)( void );
void (*pfnStudioEvent)( const struct mstudioevent_s **event, const cl_entity_t **entity );
void (*pfnPostRunCmd)( struct local_state_s **from, struct local_state_s **to, usercmd_t **cmd, int *runfuncs, double *time, unsigned int *random_seed );
void (*pfnShutdown)( void );
void (*pfnTxferLocalOverrides)( entity_state_t **state, const clientdata_t **client );
void (*pfnProcessPlayerState)( entity_state_t **dst, const entity_state_t **src );
void (*pfnTxferPredictionData)( entity_state_t **ps, const entity_state_t **pps, clientdata_t **pcd, const clientdata_t **ppcd, weapon_data_t **wd, const weapon_data_t **pwd );
void (*pfnDemo_ReadBuffer)( int *size, byte **buffer );
void (*pfnConnectionlessPacket)( const struct netadr_s **net_from, const char **args, char **buffer, int **size );
void (*pfnGetHullBounds)( int *hullnumber, float **mins, float **maxs );
void (*pfnFrame)( double *time );
void (*pfnKey_Event)( int *eventcode, int *keynum, const char **pszCurrentBinding );
void (*pfnTempEntUpdate)( double *frametime, double *client_time, double *cl_gravity, struct tempent_s ***ppTempEntFree, struct tempent_s ***ppTempEntActive, int ( **Callback_AddVisibleEntity )( cl_entity_t *pEntity ), void ( **Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ));
void (*pfnGetUserEntity)( int *index );
void (*pfnVoiceStatus)( int *entindex, qboolean *bTalking );
void (*pfnDirectorMessage)( int *iSize, void **pbuf );
void (*pfnGetStudioModelInterface)( int *version, struct r_studio_interface_s ***ppinterface, struct engine_studio_api_s **pstudio );
void (*pfnChatInputPosition)( int **x, int **y );
void (*pfnGetPlayerTeam)( int *iPlayer );
} cldll_func_dst_t;
struct cl_enginefunc_dst_s;
struct modshelpers_s;
struct modchelpers_s;
struct engdata_s;
typedef struct modfuncs_s
{
void (*m_pfnLoadMod)( char *pchModule );
void (*m_pfnCloseMod)( void );
int (*m_pfnNCall)( int ijump, int cnArg, ... );
void (*m_pfnGetClDstAddrs)( cldll_func_dst_t *pcldstAddrs );
void (*m_pfnGetEngDstAddrs)( struct cl_enginefunc_dst_s *pengdstAddrs );
void (*m_pfnModuleLoaded)( void );
void (*m_pfnProcessOutgoingNet)( struct netchan_s *pchan, struct sizebuf_s *psizebuf );
qboolean (*m_pfnProcessIncomingNet)( struct netchan_s *pchan, struct sizebuf_s *psizebuf );
void (*m_pfnTextureLoad)( char *pszName, int dxWidth, int dyHeight, char *pbData );
void (*m_pfnModelLoad)( struct model_s *pmodel, void *pvBuf );
void (*m_pfnFrameBegin)( void );
void (*m_pfnFrameRender1)( void );
void (*m_pfnFrameRender2)( void );
void (*m_pfnSetModSHelpers)( struct modshelpers_s *pmodshelpers );
void (*m_pfnSetModCHelpers)( struct modchelpers_s *pmodchelpers );
void (*m_pfnSetEngData)( struct engdata_s *pengdata );
int m_nVersion;
void (*m_pfnConnectClient)( int iPlayer );
void (*m_pfnRecordIP)( unsigned int pnIP );
void (*m_pfnPlayerStatus)( unsigned char *pbData, int cbData );
void (*m_pfnSetEngineVersion)( int nVersion );
int m_nVoid2;
int m_nVoid3;
int m_nVoid4;
int m_nVoid5;
int m_nVoid6;
int m_nVoid7;
int m_nVoid8;
int m_nVoid9;
} modfuncs_t;
static void DstInitialize( cl_enginefunc_t **pEnginefuncs, int *iVersion )
{
// stub
}
static void DstInit( void )
{
// stub
}
static void DstVidInit( void )
{
// stub
}
static void DstRedraw( float *flTime, int *intermission )
{
// stub
}
static void DstUpdateClientData( client_data_t **cdata, float *flTime )
{
// stub
}
static void DstReset( void )
{
// stub
}
static void DstPlayerMove( struct playermove_s **ppmove, int *server )
{
// stub
}
static void DstPlayerMoveInit( struct playermove_s **ppmove )
{
// stub
}
static void DstPlayerMoveTexture( char **name )
{
// stub
}
static void DstIN_ActivateMouse( void )
{
// stub
}
static void DstIN_DeactivateMouse( void )
{
// stub
}
static void DstIN_MouseEvent( int *mstate )
{
// stub
}
static void DstIN_ClearStates( void )
{
// stub
}
static void DstIN_Accumulate( void )
{
// stub
}
static void DstCL_CreateMove( float *frametime, struct usercmd_s **cmd, int *active )
{
// stub
}
static void DstCL_IsThirdPerson( void )
{
// stub
}
static void DstCL_CameraOffset( float **ofs )
{
// stub
}
static void DstKB_Find( const char **name )
{
// stub
}
static void DstCAM_Think( void )
{
// stub
}
static void DstCalcRefdef( ref_params_t **pparams )
{
// stub
}
static void DstAddEntity( int *type, cl_entity_t **ent, const char **modelname )
{
// stub
}
static void DstCreateEntities( void )
{
// stub
}
static void DstDrawNormalTriangles( void )
{
// stub
}
static void DstDrawTransparentTriangles( void )
{
// stub
}
static void DstStudioEvent( const struct mstudioevent_s **event, const cl_entity_t **entity )
{
// stub
}
static void DstPostRunCmd( struct local_state_s **from, struct local_state_s **to, usercmd_t **cmd, int *runfuncs, double *time, unsigned int *random_seed )
{
// stub
}
static void DstShutdown( void )
{
// stub
}
static void DstTxferLocalOverrides( entity_state_t **state, const clientdata_t **client )
{
// stub
}
static void DstProcessPlayerState( entity_state_t **dst, const entity_state_t **src )
{
// stub
}
static void DstTxferPredictionData( entity_state_t **ps, const entity_state_t **pps, clientdata_t **pcd, const clientdata_t **ppcd, weapon_data_t **wd, const weapon_data_t **pwd )
{
// stub
}
static void DstDemo_ReadBuffer( int *size, byte **buffer )
{
// stub
}
static void DstConnectionlessPacket( const struct netadr_s **net_from, const char **args, char **buffer, int **size )
{
// stub
}
static void DstGetHullBounds( int *hullnumber, float **mins, float **maxs )
{
// stub
}
static void DstFrame( double *time )
{
// stub
}
static void DstKey_Event( int *eventcode, int *keynum, const char **pszCurrentBinding )
{
// stub
}
static void DstTempEntUpdate( double *frametime, double *client_time, double *cl_gravity, struct tempent_s ***ppTempEntFree, struct tempent_s ***ppTempEntActive, int ( **Callback_AddVisibleEntity )( cl_entity_t *pEntity ), void ( **Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ) )
{
// stub
}
static void DstGetUserEntity( int *index )
{
// stub
}
static void DstVoiceStatus( int *entindex, qboolean *bTalking )
{
// stub
}
static void DstDirectorMessage( int *iSize, void **pbuf )
{
// stub
}
static void DstGetStudioModelInterface( int *version, struct r_studio_interface_s ***ppinterface, struct engine_studio_api_s **pstudio )
{
// stub
}
static void DstChatInputPosition( int **x, int **y )
{
// stub
}
static void DstGetPlayerTeam( int *iPlayer )
{
// stub
}
static cldll_func_dst_t cldllFuncDst =
{
DstInitialize,
DstInit,
DstVidInit,
DstRedraw,
DstUpdateClientData,
DstReset,
DstPlayerMove,
DstPlayerMoveInit,
DstPlayerMoveTexture,
DstIN_ActivateMouse,
DstIN_DeactivateMouse,
DstIN_MouseEvent,
DstIN_ClearStates,
DstIN_Accumulate,
DstCL_CreateMove,
DstCL_IsThirdPerson,
DstCL_CameraOffset,
DstKB_Find,
DstCAM_Think,
DstCalcRefdef,
DstAddEntity,
DstCreateEntities,
DstDrawNormalTriangles,
DstDrawTransparentTriangles,
DstStudioEvent,
DstPostRunCmd,
DstShutdown,
DstTxferLocalOverrides,
DstProcessPlayerState,
DstTxferPredictionData,
DstDemo_ReadBuffer,
DstConnectionlessPacket,
DstGetHullBounds,
DstFrame,
DstKey_Event,
DstTempEntUpdate,
DstGetUserEntity,
DstVoiceStatus,
DstDirectorMessage,
DstGetStudioModelInterface,
DstChatInputPosition,
DstGetPlayerTeam,
};
void CL_GetSecuredClientAPI( CL_EXPORT_FUNCS F )
{
cldll_func_src_t cldllFuncSrc = { 0 };
modfuncs_t modFuncs = { 0 };
// secured client dlls need these
*(cldll_func_dst_t **)&cldllFuncSrc.pfnVidInit = &cldllFuncDst;
*(modfuncs_t **)&cldllFuncSrc.pfnInitialize = &modFuncs;
// trying to fill interface now
F( &cldllFuncSrc );
// map exports to xash's cldll_func_t
clgame.dllFuncs.pfnInitialize = cldllFuncSrc.pfnInitialize;
clgame.dllFuncs.pfnInit = cldllFuncSrc.pfnInit;
clgame.dllFuncs.pfnVidInit = cldllFuncSrc.pfnVidInit;
clgame.dllFuncs.pfnRedraw = cldllFuncSrc.pfnRedraw;
clgame.dllFuncs.pfnUpdateClientData = cldllFuncSrc.pfnUpdateClientData;
clgame.dllFuncs.pfnReset = cldllFuncSrc.pfnReset;
clgame.dllFuncs.pfnPlayerMove = cldllFuncSrc.pfnPlayerMove;
clgame.dllFuncs.pfnPlayerMoveInit = cldllFuncSrc.pfnPlayerMoveInit;
clgame.dllFuncs.pfnPlayerMoveTexture = cldllFuncSrc.pfnPlayerMoveTexture;
clgame.dllFuncs.IN_ActivateMouse = cldllFuncSrc.IN_ActivateMouse;
clgame.dllFuncs.IN_DeactivateMouse = cldllFuncSrc.IN_DeactivateMouse;
clgame.dllFuncs.IN_MouseEvent = cldllFuncSrc.IN_MouseEvent;
clgame.dllFuncs.IN_ClearStates = cldllFuncSrc.IN_ClearStates;
clgame.dllFuncs.IN_Accumulate = cldllFuncSrc.IN_Accumulate;
clgame.dllFuncs.CL_CreateMove = cldllFuncSrc.CL_CreateMove;
clgame.dllFuncs.CL_IsThirdPerson = cldllFuncSrc.CL_IsThirdPerson;
clgame.dllFuncs.CL_CameraOffset = cldllFuncSrc.CL_CameraOffset;
clgame.dllFuncs.KB_Find = cldllFuncSrc.KB_Find;
clgame.dllFuncs.CAM_Think = cldllFuncSrc.CAM_Think;
clgame.dllFuncs.pfnCalcRefdef = cldllFuncSrc.pfnCalcRefdef;
clgame.dllFuncs.pfnAddEntity = cldllFuncSrc.pfnAddEntity;
clgame.dllFuncs.pfnCreateEntities = cldllFuncSrc.pfnCreateEntities;
clgame.dllFuncs.pfnDrawNormalTriangles = cldllFuncSrc.pfnDrawNormalTriangles;
clgame.dllFuncs.pfnDrawTransparentTriangles = cldllFuncSrc.pfnDrawTransparentTriangles;
clgame.dllFuncs.pfnStudioEvent = cldllFuncSrc.pfnStudioEvent;
clgame.dllFuncs.pfnPostRunCmd = cldllFuncSrc.pfnPostRunCmd;
clgame.dllFuncs.pfnShutdown = cldllFuncSrc.pfnShutdown;
clgame.dllFuncs.pfnTxferLocalOverrides = cldllFuncSrc.pfnTxferLocalOverrides;
clgame.dllFuncs.pfnProcessPlayerState = cldllFuncSrc.pfnProcessPlayerState;
clgame.dllFuncs.pfnTxferPredictionData = cldllFuncSrc.pfnTxferPredictionData;
clgame.dllFuncs.pfnDemo_ReadBuffer = cldllFuncSrc.pfnDemo_ReadBuffer;
clgame.dllFuncs.pfnConnectionlessPacket = cldllFuncSrc.pfnConnectionlessPacket;
clgame.dllFuncs.pfnGetHullBounds = cldllFuncSrc.pfnGetHullBounds;
clgame.dllFuncs.pfnFrame = cldllFuncSrc.pfnFrame;
clgame.dllFuncs.pfnKey_Event = cldllFuncSrc.pfnKey_Event;
clgame.dllFuncs.pfnTempEntUpdate = cldllFuncSrc.pfnTempEntUpdate;
clgame.dllFuncs.pfnGetUserEntity = cldllFuncSrc.pfnGetUserEntity;
clgame.dllFuncs.pfnVoiceStatus = cldllFuncSrc.pfnVoiceStatus;
clgame.dllFuncs.pfnDirectorMessage = cldllFuncSrc.pfnDirectorMessage;
clgame.dllFuncs.pfnGetStudioModelInterface = cldllFuncSrc.pfnGetStudioModelInterface;
clgame.dllFuncs.pfnChatInputPosition = cldllFuncSrc.pfnChatInputPosition;
}

View File

@ -361,8 +361,8 @@ void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
sound_t handle;
if( isshellcasing )
fvol *= min ( 1.0f, ((float)zvel) / 350.0f );
else fvol *= min ( 1.0f, ((float)zvel) / 450.0f );
fvol *= Q_min( 1.0f, ((float)zvel) / 350.0f );
else fvol *= Q_min( 1.0f, ((float)zvel) / 450.0f );
if( !COM_RandomLong( 0, 3 ) && !isshellcasing )
pitch = COM_RandomLong( 95, 105 );
@ -1482,7 +1482,6 @@ void GAME_EXPORT R_FunnelSprite( const vec3_t org, int modelIndex, int reverse )
pTemp->entity.baseline.angles[2] = COM_RandomFloat( -100.0f, 100.0f );
pTemp->entity.curstate.framerate = COM_RandomFloat( 0.1f, 0.4f );
pTemp->flags = FTENT_ROTATE|FTENT_FADEOUT;
pTemp->entity.curstate.framerate = 10;
vel = dest[2] / 8.0f;
if( vel < 64.0f ) vel = 64.0f;
@ -1515,17 +1514,18 @@ R_RicochetSound
Make a random ricochet sound
==============
*/
void GAME_EXPORT R_RicochetSound( const vec3_t pos )
static void R_RicochetSound_( const vec3_t pos, int sound )
{
int iPitch = COM_RandomLong( 90, 105 );
float fvol = COM_RandomFloat( 0.7f, 0.9f );
char soundpath[32];
sound_t handle;
Q_strncpy( soundpath, cl_ricochet_sounds[COM_RandomLong( 0, 4 )], sizeof( soundpath ) );
handle = S_RegisterSound( soundpath );
handle = S_RegisterSound( cl_ricochet_sounds[sound] );
S_StartSound( pos, 0, CHAN_AUTO, handle, fvol, ATTN_NORM, iPitch, 0 );
S_StartSound( pos, 0, CHAN_AUTO, handle, VOL_NORM, 1.0, 100, 0 );
}
void GAME_EXPORT R_RicochetSound( const vec3_t pos )
{
R_RicochetSound_( pos, COM_RandomLong( 0, 4 ));
}
/*
@ -1656,7 +1656,7 @@ void GAME_EXPORT R_Explosion( vec3_t pos, int model, float scale, float framerat
dl->color.g = 250;
dl->color.b = 150;
dl->die = cl.time + 0.01f;
dl->decay = 80;
dl->decay = 800;
// red glow
dl = CL_AllocDlight( 0 );
@ -1904,7 +1904,7 @@ handle temp-entity messages
void CL_ParseTempEntity( sizebuf_t *msg )
{
sizebuf_t buf;
byte pbuf[256];
byte pbuf[2048];
int iSize;
int type, color, count, flags;
int decalIndex, modelIndex, entityIndex;
@ -1915,6 +1915,7 @@ void CL_ParseTempEntity( sizebuf_t *msg )
TEMPENTITY *pTemp;
cl_entity_t *pEnt;
dlight_t *dl;
sound_t hSound;
if( cls.legacymode )
iSize = MSG_ReadByte( msg );
@ -1922,6 +1923,10 @@ void CL_ParseTempEntity( sizebuf_t *msg )
decalIndex = modelIndex = entityIndex = 0;
// this will probably be fatal anyway
if( iSize > sizeof( pbuf ))
Con_Printf( S_ERROR "%s: Temp buffer overflow!\n", __FUNCTION__ );
// parse user message into buffer
MSG_ReadBytes( msg, pbuf, iSize );
@ -2014,15 +2019,46 @@ void CL_ParseTempEntity( sizebuf_t *msg )
color = MSG_ReadByte( &buf );
count = MSG_ReadByte( &buf );
R_ParticleExplosion2( pos, color, count );
dl = CL_AllocDlight( 0 );
VectorCopy( pos, dl->origin );
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 300;
hSound = S_RegisterSound( cl_explode_sounds[0] );
S_StartSound( pos, 0, CHAN_STATIC, hSound, VOL_NORM, 0.6f, PITCH_NORM, 0 );
break;
case TE_BSPDECAL:
case TE_DECAL:
case TE_WORLDDECAL:
case TE_WORLDDECALHIGH:
case TE_DECALHIGH:
pos[0] = MSG_ReadCoord( &buf );
pos[1] = MSG_ReadCoord( &buf );
pos[2] = MSG_ReadCoord( &buf );
decalIndex = MSG_ReadShort( &buf );
entityIndex = MSG_ReadShort( &buf );
if( entityIndex ) modelIndex = MSG_ReadShort( &buf );
CL_DecalShoot( CL_DecalIndex( decalIndex ), entityIndex, modelIndex, pos, FDECAL_PERMANENT );
if( type == TE_BSPDECAL )
{
decalIndex = MSG_ReadShort( &buf );
entityIndex = MSG_ReadShort( &buf );
if( entityIndex )
modelIndex = MSG_ReadShort( &buf );
else modelIndex = 0;
}
else
{
decalIndex = MSG_ReadByte( &buf );
if( type == TE_DECALHIGH || type == TE_WORLDDECALHIGH )
decalIndex += 256;
if( type == TE_DECALHIGH || type == TE_DECAL )
entityIndex = MSG_ReadShort( &buf );
else entityIndex = 0;
pEnt = CL_GetEntityByIndex( entityIndex );
modelIndex = pEnt->curstate.modelindex;
}
CL_DecalShoot( CL_DecalIndex( decalIndex ), entityIndex, modelIndex, pos, type == TE_BSPDECAL ? FDECAL_PERMANENT : 0 );
break;
case TE_IMPLOSION:
pos[0] = MSG_ReadCoord( &buf );
@ -2042,10 +2078,12 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos2[2] = MSG_ReadCoord( &buf );
modelIndex = MSG_ReadShort( &buf );
count = MSG_ReadByte( &buf );
life = (float)(MSG_ReadByte( &buf ) * 0.1f);
scale = (float)(MSG_ReadByte( &buf ) * 0.1f);
vel = (float)MSG_ReadByte( &buf );
random = (float)MSG_ReadByte( &buf );
life = (float)MSG_ReadByte( &buf ) * 0.1f;
scale = (float)MSG_ReadByte( &buf );
if( !scale ) scale = 1.0f;
else scale *= 0.1f;
vel = (float)MSG_ReadByte( &buf ) * 10;
random = (float)MSG_ReadByte( &buf ) * 10;
R_Sprite_Trail( type, pos, pos2, modelIndex, count, life, scale, random, 255, vel );
break;
case TE_SPRITE:
@ -2053,36 +2091,23 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos[1] = MSG_ReadCoord( &buf );
pos[2] = MSG_ReadCoord( &buf );
modelIndex = MSG_ReadShort( &buf );
scale = (float)(MSG_ReadByte( &buf ) * 0.1f);
brightness = (float)MSG_ReadByte( &buf );
scale = (float)MSG_ReadByte( &buf ) * 0.1f;
brightness = (float)MSG_ReadByte( &buf ) / 255.0f;
if(( pTemp = R_DefaultSprite( pos, modelIndex, 0 )) != NULL )
{
pTemp->entity.curstate.scale = scale;
pTemp->entity.baseline.renderamt = brightness;
pTemp->entity.curstate.renderamt = brightness;
pTemp->entity.curstate.rendermode = kRenderTransAdd;
}
R_TempSprite( pos, vec3_origin, scale, modelIndex,
kRenderTransAdd, kRenderFxNone, brightness, 0.0, FTENT_SPRANIMATE );
break;
case TE_GLOWSPRITE:
pos[0] = MSG_ReadCoord( &buf );
pos[1] = MSG_ReadCoord( &buf );
pos[2] = MSG_ReadCoord( &buf );
modelIndex = MSG_ReadShort( &buf );
life = (float)(MSG_ReadByte( &buf ) * 0.1f);
scale = (float)(MSG_ReadByte( &buf ) * 0.1f);
brightness = (float)MSG_ReadByte( &buf );
life = (float)MSG_ReadByte( &buf ) * 0.1f;
scale = (float)MSG_ReadByte( &buf ) * 0.1f;
brightness = (float)MSG_ReadByte( &buf ) / 255.0f;
if(( pTemp = R_DefaultSprite( pos, modelIndex, 0 )) != NULL )
{
pTemp->entity.curstate.scale = scale;
pTemp->entity.curstate.rendermode = kRenderGlow;
pTemp->entity.curstate.renderfx = kRenderFxNoDissipation;
pTemp->entity.baseline.renderamt = brightness;
pTemp->entity.curstate.renderamt = brightness;
pTemp->flags = FTENT_FADEOUT;
pTemp->die = cl.time + life;
}
R_TempSprite( pos, vec3_origin, scale, modelIndex,
kRenderGlow, kRenderFxNoDissipation, brightness, life, FTENT_FADEOUT );
break;
case TE_STREAK_SPLASH:
pos[0] = MSG_ReadCoord( &buf );
@ -2172,23 +2197,6 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos2[2] = MSG_ReadCoord( &buf );
R_ShowLine( pos, pos2 );
break;
case TE_DECAL:
case TE_DECALHIGH:
case TE_WORLDDECAL:
case TE_WORLDDECALHIGH:
pos[0] = MSG_ReadCoord( &buf );
pos[1] = MSG_ReadCoord( &buf );
pos[2] = MSG_ReadCoord( &buf );
decalIndex = MSG_ReadByte( &buf );
if( type == TE_DECAL || type == TE_DECALHIGH )
entityIndex = MSG_ReadShort( &buf );
else entityIndex = 0;
if( type == TE_DECALHIGH || type == TE_WORLDDECALHIGH )
decalIndex += 256;
pEnt = CL_GetEntityByIndex( entityIndex );
if( pEnt ) modelIndex = pEnt->curstate.modelindex;
CL_DecalShoot( CL_DecalIndex( decalIndex ), entityIndex, modelIndex, pos, 0 );
break;
case TE_FIZZ:
entityIndex = MSG_ReadShort( &buf );
modelIndex = MSG_ReadShort( &buf );
@ -2244,10 +2252,11 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos[2] = MSG_ReadCoord( &buf );
entityIndex = MSG_ReadShort( &buf );
decalIndex = MSG_ReadByte( &buf );
pEnt = CL_GetEntityByIndex( entityIndex );
CL_DecalShoot( CL_DecalIndex( decalIndex ), entityIndex, 0, pos, 0 );
R_BulletImpactParticles( pos );
R_RicochetSound( pos );
flags = COM_RandomLong( 0, 0x7fff );
if( flags < 0x3fff )
R_RicochetSound_( pos, flags % 5 );
break;
case TE_SPRAY:
case TE_SPRITE_SPRAY:
@ -2393,7 +2402,7 @@ void CL_ParseTempEntity( sizebuf_t *msg )
// throw warning
if( MSG_CheckOverflow( &buf ))
Con_DPrintf( S_WARN "ParseTempEntity: overflow TE message\n" );
Con_DPrintf( S_WARN "ParseTempEntity: overflow TE message %i\n", type );
}
@ -2693,7 +2702,7 @@ apply various effects to entity origin or attachment
void CL_AddEntityEffects( cl_entity_t *ent )
{
// yellow flies effect 'monster stuck in the wall'
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ))
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ) && !RP_LOCALCLIENT( ent ))
R_EntityParticles( ent );
if ( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
@ -2917,7 +2926,7 @@ void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, float *pos
{
if( FBitSet( pCust->resource.ucFlags, RES_CUSTOM ) && pCust->resource.type == t_decal && pCust->bTranslated )
{
if( !pCust->nUserData1 && pCust->pInfo != NULL )
if( !pCust->nUserData1 )
{
const char *decalname = va( "player%dlogo%d", playernum, customIndex );
pCust->nUserData1 = GL_LoadTextureInternal( decalname, pCust->pInfo, TF_DECAL );

View File

@ -35,30 +35,39 @@ void V_CalcViewRect( void )
int sb_lines;
float size;
// intermission is always full screen
if( cl.intermission ) size = 120.0f;
else size = scr_viewsize->value;
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
{
// intermission is always full screen
if( cl.intermission ) size = 120.0f;
else size = scr_viewsize->value;
if( size >= 120.0f )
sb_lines = 0; // no status bar at all
else if( size >= 110.0f )
sb_lines = 24; // no inventory
else sb_lines = 48;
if( size >= 120.0f )
sb_lines = 0; // no status bar at all
else if( size >= 110.0f )
sb_lines = 24; // no inventory
else sb_lines = 48;
if( scr_viewsize->value >= 100.0f )
if( scr_viewsize->value >= 100.0f )
{
full = true;
size = 100.0f;
}
else size = scr_viewsize->value;
if( cl.intermission )
{
size = 100.0f;
sb_lines = 0;
full = true;
}
size /= 100.0f;
}
else
{
full = true;
size = 100.0f;
}
else size = scr_viewsize->value;
if( cl.intermission )
{
size = 100.0f;
sb_lines = 0;
full = true;
size = 1.0f;
}
size /= 100.0f;
clgame.viewport[2] = refState.width * size;
clgame.viewport[3] = refState.height * size;

View File

@ -465,7 +465,7 @@ typedef struct
string cdtracks[MAX_CDTRACKS]; // 32 cd-tracks read from cdaudio.txt
model_t sprites[MAX_CLIENT_SPRITES]; // client spritetextures
model_t sprites[MAX_CLIENT_SPRITES]; // hud&client spritetexturesz
int viewport[4]; // viewport sizes
client_draw_t ds; // draw2d stuff (hud, weaponmenu etc)
@ -527,9 +527,6 @@ typedef struct
float disable_screen; // showing loading plaque between levels
// or changing rendering dlls
// if time gets > 30 seconds ahead, break it
int disable_servercount; // when we receive a frame and cl.servercount
// > cls.disable_servercount, clear disable_screen
qboolean draw_changelevel; // draw changelevel image 'Loading...'
keydest_t key_dest;
@ -625,8 +622,6 @@ typedef struct
// legacy mode support
qboolean legacymode; // one-way 48 protocol compatibility
netadr_t legacyserver;
netadr_t legacyservers[MAX_LEGACY_SERVERS];
int legacyservercount;
int extensions;
netadr_t serveradr;
@ -707,7 +702,7 @@ dlight_t *CL_GetEntityLight( int number );
//
// cl_cmds.c
//
void CL_Quit_f( void ) NORETURN;
void CL_Quit_f( void );
void CL_ScreenShot_f( void );
void CL_SnapShot_f( void );
void CL_PlayCDTrack_f( void );
@ -1048,7 +1043,6 @@ void Con_Bottom( void );
void Con_Top( void );
void Con_PageDown( int lines );
void Con_PageUp( int lines );
void Con_LoadHistory( void );
//
// s_main.c
@ -1112,6 +1106,11 @@ void pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *pr
qboolean Mobile_Init( void );
void Mobile_Shutdown( void );
//
// cl_securedstub.c
//
void CL_GetSecuredClientAPI( CL_EXPORT_FUNCS F );
//
// cl_video.c
//

View File

@ -81,6 +81,14 @@ typedef struct con_lineinfo_s
double addtime; // notify stuff
} con_lineinfo_t;
typedef struct con_history_s
{
field_t lines[CON_HISTORY];
field_t backup;
int line; // the line being displayed from history buffer will be <= nextHistoryLine
int next; // the last line in the history buffer, not masked
} con_history_t;
typedef struct
{
qboolean initialized;
@ -118,10 +126,8 @@ typedef struct
string chat_cmd; // can be overrieded by user
// console history
field_t historyLines[CON_HISTORY];
int historyLine; // the line being displayed from history buffer will be <= nextHistoryLine
int nextHistoryLine; // the last line in the history buffer, not masked
field_t backup;
con_history_t history;
qboolean historyLoaded;
notify_t notify[MAX_DBG_NOTIFY]; // for Con_NXPrintf
qboolean draw_notify; // true if we have NXPrint message
@ -135,6 +141,9 @@ static console_t con;
void Con_ClearField( field_t *edit );
void Field_CharEvent( field_t *edit, int ch );
static void Con_LoadHistory( con_history_t *self );
static void Con_SaveHistory( con_history_t *self );
/*
================
Con_Clear_f
@ -198,8 +207,6 @@ Con_ClearTyping
*/
void Con_ClearTyping( void )
{
int i;
Con_ClearField( &con.input );
con.input.widthInChars = con.linewidth;
@ -276,6 +283,8 @@ void Con_ToggleConsole_f( void )
if( !host.allow_console || UI_CreditsActive( ))
return; // disabled
SCR_EndLoadingPlaque();
// show console only in game or by special call from menu
if( cls.state != ca_active || cls.key_dest == key_menu )
return;
@ -486,7 +495,7 @@ void Con_CheckResize( void )
con.input.widthInChars = con.linewidth;
for( i = 0; i < CON_HISTORY; i++ )
con.historyLines[i].widthInChars = con.linewidth;
con.history.lines[i].widthInChars = con.linewidth;
}
/*
@ -1062,7 +1071,7 @@ int Con_DrawGenericString( int x, int y, const char *string, rgba_t setColor, qb
Con_UtfProcessChar( 0 );
// draw the colored text
*(uint *)color = *(uint *)setColor;
memcpy( color, setColor, sizeof( color ));
s = string;
while( *s )
@ -1113,61 +1122,6 @@ int Con_DrawString( int x, int y, const char *string, rgba_t setColor )
return Con_DrawGenericString( x, y, string, setColor, false, -1 );
}
void Con_LoadHistory( void )
{
const byte *aFile = FS_LoadFile( "console_history.txt", NULL, true );
const char *pLine = (char *)aFile, *pFile = (char *)aFile;
int i;
if( !aFile )
return;
while( true )
{
if( !*pFile )
break;
if( *pFile == '\n')
{
int len = pFile - pLine + 1;
field_t *f;
if( len > 255 ) len = 255;
Con_ClearField( &con.historyLines[con.nextHistoryLine] );
f = &con.historyLines[con.nextHistoryLine % CON_HISTORY];
f->widthInChars = con.linewidth;
f->cursor = len - 1;
Q_strncpy( f->buffer, pLine, len);
con.nextHistoryLine++;
pLine = pFile + 1;
}
pFile++;
}
for( i = con.nextHistoryLine; i < CON_HISTORY; i++ )
{
Con_ClearField( &con.historyLines[i] );
con.historyLines[i].widthInChars = con.linewidth;
}
con.historyLine = con.nextHistoryLine;
}
void Con_SaveHistory( void )
{
int historyStart = con.nextHistoryLine - CON_HISTORY;
int i;
file_t *f;
if( historyStart < 0 )
historyStart = 0;
f = FS_Open("console_history.txt", "w", true );
for( i = historyStart; i < con.nextHistoryLine; i++ )
FS_Printf( f, "%s\n", con.historyLines[i % CON_HISTORY].buffer );
FS_Close(f);
}
/*
================
@ -1207,7 +1161,7 @@ void Con_Init( void )
con.chat.widthInChars = con.linewidth;
Cmd_AddCommand( "toggleconsole", Con_ToggleConsole_f, "opens or closes the console" );
Cmd_AddCommand( "clear", Con_Clear_f, "clear console history" );
Cmd_AddRestrictedCommand( "clear", Con_Clear_f, "clear console history" );
Cmd_AddCommand( "messagemode", Con_MessageMode_f, "enable message mode \"say\"" );
Cmd_AddCommand( "messagemode2", Con_MessageMode2_f, "enable message mode \"say_team\"" );
Cmd_AddCommand( "contimes", Con_SetTimes_f, "change number of console overlay lines (4-64)" );
@ -1233,7 +1187,7 @@ void Con_Shutdown( void )
con.buffer = NULL;
con.lines = NULL;
Con_SaveHistory();
Con_SaveHistory( &con.history );
}
/*
@ -1468,11 +1422,22 @@ Con_ClearField
*/
void Con_ClearField( field_t *edit )
{
memset(edit->buffer, 0, MAX_STRING);
memset( edit->buffer, 0, MAX_STRING );
edit->cursor = 0;
edit->scroll = 0;
}
/*
================
Field_Set
================
*/
static void Field_Set( field_t *f, const char *string )
{
f->scroll = 0;
f->cursor = Q_strncpy( f->buffer, string, MAX_STRING );
}
/*
================
Field_Paste
@ -1492,6 +1457,18 @@ void Field_Paste( field_t *edit )
Field_CharEvent( edit, cbd[i] );
}
/*
=================
Field_GoTo
=================
*/
static void Field_GoTo( field_t *edit, int pos )
{
edit->cursor = pos;
edit->scroll = Q_max( 0, edit->cursor - edit->widthInChars );
}
/*
=================
Field_KeyDownEvent
@ -1544,20 +1521,20 @@ void Field_KeyDownEvent( field_t *edit, int key )
if( key == K_LEFTARROW )
{
if( edit->cursor > 0 ) edit->cursor= Con_UtfMoveLeft( edit->buffer, edit->cursor );
if( edit->cursor > 0 ) edit->cursor = Con_UtfMoveLeft( edit->buffer, edit->cursor );
if( edit->cursor < edit->scroll ) edit->scroll--;
return;
}
if( key == K_HOME || ( Q_tolower(key) == 'a' && Key_IsDown( K_CTRL )))
{
edit->cursor = 0;
Field_GoTo( edit, 0 );
return;
}
if( key == K_END || ( Q_tolower(key) == 'e' && Key_IsDown( K_CTRL )))
{
edit->cursor = len;
Field_GoTo( edit, len );
return;
}
@ -1596,16 +1573,14 @@ void Field_CharEvent( field_t *edit, int ch )
if( ch == 'a' - 'a' + 1 )
{
// ctrl-a is home
edit->cursor = 0;
edit->scroll = 0;
Field_GoTo( edit, 0 );
return;
}
if( ch == 'e' - 'a' + 1 )
{
// ctrl-e is end
edit->cursor = len;
edit->scroll = edit->cursor - edit->widthInChars;
Field_GoTo( edit, len );
return;
}
@ -1708,12 +1683,134 @@ void Field_DrawInputLine( int x, int y, field_t *edit )
}
}
/*
=============================================================================
CONSOLE HISTORY HANDLING
=============================================================================
*/
/*
===================
Con_HistoryUp
===================
*/
static void Con_HistoryUp( con_history_t *self, field_t *in )
{
if( self->line == self->next )
self->backup = *in;
if(( self->next - self->line ) < CON_HISTORY )
self->line = Q_max( 0, self->line - 1 );
*in = self->lines[self->line % CON_HISTORY];
}
/*
===================
Con_HistoryDown
===================
*/
static void Con_HistoryDown( con_history_t *self, field_t *in )
{
self->line = Q_min( self->next, self->line + 1 );
if( self->line == self->next )
*in = self->backup;
else *in = self->lines[self->line % CON_HISTORY];
}
/*
===================
Con_HistoryAppend
===================
*/
static void Con_HistoryAppend( con_history_t *self, field_t *from )
{
int prevLine = Q_max( 0, self->line - 1 );
const char *buf = from->buffer;
// skip backslashes
if( from->buffer[0] == '\\' || from->buffer[1] == '/' )
buf++;
// only if non-empty
if( !from->buffer[0] )
return;
// skip empty commands
if( Q_isspace( buf ))
return;
// if not copy (don't ignore backslashes)
if( !Q_strcmp( from->buffer, self->lines[prevLine % CON_HISTORY].buffer ))
return;
self->lines[self->next % CON_HISTORY] = *from;
self->line = ++self->next;
}
static void Con_LoadHistory( con_history_t *self )
{
const byte *aFile = FS_LoadFile( "console_history.txt", NULL, true );
const char *pLine, *pFile;
int i, len;
field_t *f;
if( !aFile )
return;
for( pFile = pLine = (char *)aFile; *pFile; pFile++ )
{
if( *pFile != '\n' )
continue;
Con_ClearField( &self->lines[self->next] );
len = Q_min( pFile - pLine + 1, sizeof( f->buffer ));
f = &self->lines[self->next % CON_HISTORY];
f->widthInChars = con.linewidth;
f->cursor = len - 1;
Q_strncpy( f->buffer, pLine, len);
self->next++;
pLine = pFile + 1;
}
for( i = self->next; i < CON_HISTORY; i++ )
{
Con_ClearField( &self->lines[i] );
self->lines[i].widthInChars = con.linewidth;
}
self->line = self->next;
}
static void Con_SaveHistory( con_history_t *self )
{
int historyStart = self->next - CON_HISTORY, i;
file_t *f;
if( historyStart < 0 )
historyStart = 0;
f = FS_Open( "console_history.txt", "w", true );
for( i = historyStart; i < self->next; i++ )
FS_Printf( f, "%s\n", self->lines[i % CON_HISTORY].buffer );
FS_Close( f );
}
/*
=============================================================================
CONSOLE LINE EDITING
==============================================================================
=============================================================================
*/
/*
====================
@ -1734,16 +1831,6 @@ void Key_Console( int key )
// enter finishes the line
if( key == K_ENTER || key == K_KP_ENTER )
{
// if not in the game explicitly prepent a slash if needed
if( cls.state != ca_active && con.input.buffer[0] != '\\' && con.input.buffer[0] != '/' )
{
char temp[MAX_SYSPATH];
Q_strncpy( temp, con.input.buffer, sizeof( temp ));
Q_sprintf( con.input.buffer, "\\%s", temp );
con.input.cursor++;
}
// backslash text are commands, else chat
if( con.input.buffer[0] == '\\' || con.input.buffer[0] == '/' )
Cbuf_AddText( con.input.buffer + 1 ); // skip backslash
@ -1754,9 +1841,7 @@ void Key_Console( int key )
Con_Printf( ">%s\n", con.input.buffer );
// copy line to history buffer
con.historyLines[con.nextHistoryLine % CON_HISTORY] = con.input;
con.nextHistoryLine++;
con.historyLine = con.nextHistoryLine;
Con_HistoryAppend( &con.history, &con.input );
Con_ClearField( &con.input );
con.input.widthInChars = con.linewidth;
@ -1781,23 +1866,13 @@ void Key_Console( int key )
// command history (ctrl-p ctrl-n for unix style)
if(( key == K_MWHEELUP && Key_IsDown( K_SHIFT )) || ( key == K_UPARROW ) || (( Q_tolower(key) == 'p' ) && Key_IsDown( K_CTRL )))
{
if( con.historyLine == con.nextHistoryLine )
con.backup = con.input;
if( con.nextHistoryLine - con.historyLine < CON_HISTORY && con.historyLine > 0 )
con.historyLine--;
con.input = con.historyLines[con.historyLine % CON_HISTORY];
Con_HistoryUp( &con.history, &con.input );
return;
}
if(( key == K_MWHEELDOWN && Key_IsDown( K_SHIFT )) || ( key == K_DOWNARROW ) || (( Q_tolower(key) == 'n' ) && Key_IsDown( K_CTRL )))
{
if( con.historyLine >= con.nextHistoryLine - 1 )
con.input = con.backup;
else
{
con.historyLine++;
con.input = con.historyLines[con.historyLine % CON_HISTORY];
}
Con_HistoryDown( &con.history, &con.input );
return;
}
@ -2101,6 +2176,9 @@ void Con_DrawSolidConsole( int lines )
int i, x, y;
float fraction;
int start;
int stringLen, width = 0, charH;
string curbuild;
byte color[4];
if( lines <= 0 ) return;
@ -2114,28 +2192,20 @@ void Con_DrawSolidConsole( int lines )
if( !con.curFont || !host.allow_console )
return; // nothing to draw
if( host.allow_console )
{
// draw current version
int stringLen, width = 0, charH;
string curbuild;
byte color[4];
// draw current version
memcpy( color, g_color_table[7], sizeof( color ));
memcpy( color, g_color_table[7], sizeof( color ));
Q_snprintf( curbuild, MAX_STRING, "%s %i/%s (%s-%s build %i)", XASH_ENGINE_NAME, PROTOCOL_VERSION, XASH_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
Con_DrawStringLen( curbuild, &stringLen, &charH );
start = refState.width - stringLen;
stringLen = Con_StringLength( curbuild );
Q_snprintf( curbuild, MAX_STRING, "%s %i/%s (%s-%s build %i)", XASH_ENGINE_NAME, PROTOCOL_VERSION, XASH_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
fraction = lines / (float)refState.height;
color[3] = Q_min( fraction * 2.0f, 1.0f ) * 255; // fadeout version number
Con_DrawStringLen( curbuild, &stringLen, &charH );
start = refState.width - stringLen;
stringLen = Con_StringLength( curbuild );
fraction = lines / (float)refState.height;
color[3] = Q_min( fraction * 2.0f, 1.0f ) * 255; // fadeout version number
for( i = 0; i < stringLen; i++ )
width += Con_DrawCharacter( start + width, 0, curbuild[i], color );
}
for( i = 0; i < stringLen; i++ )
width += Con_DrawCharacter( start + width, 0, curbuild[i], color );
// draw the text
if( CON_LINES_COUNT > 0 )
@ -2172,7 +2242,7 @@ void Con_DrawSolidConsole( int lines )
Con_DrawInput( lines );
y = lines - ( con.curFont->charHeight * 1.2f );
SCR_DrawFPS( max( y, 4 )); // to avoid to hide fps counter
SCR_DrawFPS( Q_max( y, 4 )); // to avoid to hide fps counter
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}
@ -2388,6 +2458,12 @@ INTERNAL RESOURCE
*/
void Con_VidInit( void )
{
if( !con.historyLoaded )
{
Con_LoadHistory( &con.history );
con.historyLoaded = true;
}
Con_LoadConchars();
Con_CheckResize();
#if XASH_LOW_MEMORY
@ -2423,7 +2499,6 @@ void Con_VidInit( void )
}
}
if( !con.background ) // last chance - quake conback image
{
qboolean draw_to_console = false;
@ -2511,3 +2586,48 @@ void GAME_EXPORT Con_DefaultColor( int r, int g, int b )
b = bound( 0, b, 255 );
MakeRGBA( g_color_table[7], r, g, b, 255 );
}
#if XASH_ENGINE_TESTS
#include "tests.h"
static void Test_RunConHistory( void )
{
con_history_t hist = { 0 };
field_t input = { 0 };
const char *strs1[] = { "map t0a0", "quit", "wtf", "wtf", "", "nyan" };
const char *strs2[] = { "nyan", "wtf", "quit", "map t0a0" };
const char *testbackup = "unfinished_edit";
int i;
for( i = 0; i < ARRAYSIZE( strs1 ); i++ )
{
Field_Set( &input, strs1[i] );
Con_HistoryAppend( &hist, &input );
}
Field_Set( &input, testbackup );
for( i = 0; i < ARRAYSIZE( strs2 ); i++ )
{
Con_HistoryUp( &hist, &input );
TASSERT_STR( input.buffer, strs2[i] );
}
// check for overrun
Con_HistoryUp( &hist, &input );
for( i = ARRAYSIZE( strs2 ) - 1; i >= 0; i-- )
{
TASSERT_STR( input.buffer, strs2[i] );
Con_HistoryDown( &hist, &input );
}
TASSERT_STR( input.buffer, testbackup );
}
void Test_RunCon( void )
{
TRUN( Test_RunConHistory() );
}
#endif /* XASH_ENGINE_TESTS */

View File

@ -503,20 +503,14 @@ void Touch_SetClientOnly( byte state )
touch.move_finger = touch.look_finger = -1;
touch.forward = touch.side = 0;
/// TODO: touch sdl platform
#if 0
if( state )
{
SDL_SetRelativeMouseMode( SDL_FALSE );
SDL_ShowCursor( true );
IN_DeactivateMouse();
}
else
{
SDL_ShowCursor( false );
SDL_GetRelativeMouseState( 0, 0 );
IN_ActivateMouse();
}
#endif
}
static void Touch_SetClientOnly_f( void )
@ -536,7 +530,7 @@ static void Touch_RemoveButtonFromList( touchbuttonlist_t *list, const char *nam
IN_TouchEditClear();
while(( button = Touch_FindFirst( &touch.list_user, name, !privileged )))
while(( button = Touch_FindFirst( &touch.list_user, name, privileged )))
{
if( button->prev )
button->prev->next = button->next;
@ -792,7 +786,6 @@ static touch_button_t *Touch_AddButton( touchbuttonlist_t *list,
button->flags = privileged ? 0 : TOUCH_FL_UNPRIVILEGED | TOUCH_FL_CLIENT;
MakeRGBA( button->color, color[0], color[1], color[2], color[3] );
button->command[0] = 0;
button->flags = 0;
button->fade = 1;
Touch_SetCommand( button, command );

View File

@ -18,7 +18,7 @@ GNU General Public License for more details.
#include "client.h"
#include "vgui_draw.h"
#ifdef XASH_SDL
#if XASH_SDL
#include <SDL.h>
#endif
@ -30,17 +30,16 @@ qboolean in_mouseinitialized;
qboolean in_mouse_suspended;
POINT in_lastvalidpos;
qboolean in_mouse_savedpos;
static int in_mstate = 0;
static struct inputstate_s
{
float lastpitch, lastyaw;
} inputstate;
extern convar_t *vid_fullscreen;
convar_t *m_enginemouse;
convar_t *m_pitch;
convar_t *m_yaw;
convar_t *m_enginesens;
convar_t *m_ignore;
convar_t *cl_forwardspeed;
convar_t *cl_sidespeed;
@ -48,6 +47,8 @@ convar_t *cl_backspeed;
convar_t *look_filter;
convar_t *m_rawinput;
static qboolean s_bRawInput, s_bMouseGrab;
/*
================
IN_CollectInputDevices
@ -113,8 +114,6 @@ void IN_StartupMouse( void )
{
m_ignore = Cvar_Get( "m_ignore", DEFAULT_M_IGNORE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "ignore mouse events" );
m_enginemouse = Cvar_Get( "m_enginemouse", "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "read mouse events in engine instead of client" );
m_enginesens = Cvar_Get( "m_enginesens", "0.3", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse sensitivity, when m_enginemouse enabled" );
m_pitch = Cvar_Get( "m_pitch", "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse pitch value" );
m_yaw = Cvar_Get( "m_yaw", "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse yaw value" );
look_filter = Cvar_Get( "look_filter", "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "filter look events making it smoother" );
@ -127,21 +126,9 @@ void IN_StartupMouse( void )
in_mouseinitialized = true;
}
static void IN_ActivateCursor( void )
{
if( cls.key_dest == key_menu )
{
#ifdef XASH_SDL
SDL_SetCursor( in_mousecursor );
#endif
}
}
void GAME_EXPORT IN_SetCursor( void *hCursor )
{
in_mousecursor = hCursor;
IN_ActivateCursor();
// stub
}
/*
@ -190,47 +177,15 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
if( oldstate == key_game )
{
if( cls.initialized )
clgame.dllFuncs.IN_DeactivateMouse();
IN_DeactivateMouse();
}
else if( newstate == key_game )
{
// reset mouse pos, so cancel effect in game
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( CVAR_TO_BOOL( touch_enable ) )
{
SDL_SetRelativeMouseMode( SDL_FALSE );
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
}
else
#endif
{
Platform_SetMousePos( host.window_center_x, host.window_center_y );
#if XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_TRUE );
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if ( clgame.dllFuncs.pfnLookEvent || ( clgame.client_dll_uses_sdl && CVAR_TO_BOOL( m_rawinput ) ) )
{
SDL_SetRelativeMouseMode( SDL_TRUE );
}
#endif
#endif // XASH_SDL
}
if( cls.initialized )
clgame.dllFuncs.IN_ActivateMouse();
IN_ActivateMouse();
}
if( ( newstate == key_menu || newstate == key_console || newstate == key_message ) && ( !CL_IsBackgroundMap() || CL_IsBackgroundDemo( )))
{
#ifdef XASH_SDL
SDL_SetWindowGrab(host.hWnd, SDL_FALSE);
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if ( clgame.dllFuncs.pfnLookEvent || ( clgame.client_dll_uses_sdl && CVAR_TO_BOOL( m_rawinput ) ) )
{
SDL_SetRelativeMouseMode( SDL_FALSE );
}
#endif
#endif // XASH_SDL
#if XASH_ANDROID
Android_ShowMouse( true );
#endif
@ -249,6 +204,65 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
}
}
void IN_CheckMouseState( qboolean active )
{
#if XASH_WIN32
qboolean useRawInput = CVAR_TO_BOOL( m_rawinput ) && clgame.client_dll_uses_sdl || clgame.dllFuncs.pfnLookEvent;
#else
qboolean useRawInput = true; // always use SDL code
#endif
if( active && useRawInput && !host.mouse_visible && cls.state == ca_active )
{
if( !s_bRawInput )
{
#if XASH_SDL == 2
SDL_GetRelativeMouseState( NULL, NULL );
SDL_SetRelativeMouseMode( SDL_TRUE );
#endif
// Con_Printf( "Enable relative mode\n" );
s_bRawInput = true;
}
}
else
{
if( s_bRawInput )
{
#if XASH_SDL == 2
SDL_GetRelativeMouseState( NULL, NULL );
SDL_SetRelativeMouseMode( SDL_FALSE );
#endif
// Con_Printf( "Disable relative mode\n" );
s_bRawInput = false;
}
}
if( active && !host.mouse_visible && cls.state == ca_active )
{
if( !s_bMouseGrab )
{
#if XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_TRUE );
#endif
// Con_Printf( "Enable grab\n" );
s_bMouseGrab = true;
}
}
else
{
if( s_bMouseGrab )
{
#if XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#endif
// Con_Printf( "Disable grab\n" );
s_bMouseGrab = false;
}
}
}
/*
===========
IN_ActivateMouse
@ -256,58 +270,15 @@ IN_ActivateMouse
Called when the window gains focus or changes in some way
===========
*/
void IN_ActivateMouse( qboolean force )
void IN_ActivateMouse( void )
{
int width, height;
static int oldstate;
if( !in_mouseinitialized )
return;
if( CL_Active() && host.mouse_visible && !force )
return; // VGUI controls
if( cls.key_dest == key_menu && !Cvar_VariableInteger( "fullscreen" ))
{
// check for mouse leave-entering
if( !in_mouse_suspended && !UI_MouseInRect( ))
in_mouse_suspended = true;
if( oldstate != in_mouse_suspended )
{
if( in_mouse_suspended )
{
#ifdef XASH_SDL
/// TODO: Platform_ShowCursor
if( !touch_emulate )
SDL_ShowCursor( SDL_FALSE );
#endif
UI_ShowCursor( false );
}
}
oldstate = in_mouse_suspended;
if( in_mouse_suspended )
{
in_mouse_suspended = false;
in_mouseactive = false; // re-initialize mouse
UI_ShowCursor( true );
}
}
if( in_mouseactive ) return;
in_mouseactive = true;
if( UI_IsVisible( )) return;
if( cls.key_dest == key_game )
{
IN_CheckMouseState( true );
if( clgame.dllFuncs.IN_ActivateMouse )
clgame.dllFuncs.IN_ActivateMouse();
#ifdef XASH_SDL
SDL_GetRelativeMouseState( 0, 0 ); // Reset mouse position
#endif
}
in_mouseactive = true;
}
/*
@ -319,20 +290,17 @@ Called when the window loses focus
*/
void IN_DeactivateMouse( void )
{
if( !in_mouseinitialized || !in_mouseactive )
if( !in_mouseinitialized )
return;
if( cls.key_dest == key_game )
{
IN_CheckMouseState( false );
if( clgame.dllFuncs.IN_DeactivateMouse )
clgame.dllFuncs.IN_DeactivateMouse();
}
in_mouseactive = false;
#ifdef XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#endif // XASH_SDL
}
/*
================
IN_MouseMove
@ -342,7 +310,7 @@ void IN_MouseMove( void )
{
POINT current_pos;
if( !in_mouseinitialized || !in_mouseactive || !UI_IsVisible( ))
if( !in_mouseinitialized )
return;
// find mouse movement
@ -352,15 +320,13 @@ void IN_MouseMove( void )
// HACKHACK: show cursor in UI, as mainui doesn't call
// platform-dependent SetCursor anymore
#ifdef XASH_SDL
#if XASH_SDL
if( UI_IsVisible() )
SDL_ShowCursor( SDL_TRUE );
#endif
// if the menu is visible, move the menu cursor
UI_MouseMove( current_pos.x, current_pos.y );
IN_ActivateCursor();
}
/*
@ -368,73 +334,32 @@ void IN_MouseMove( void )
IN_MouseEvent
===========
*/
void IN_MouseEvent( void )
void IN_MouseEvent( int key, int down )
{
int i;
// touch emu: handle motion
if( CVAR_TO_BOOL( touch_emulate ))
{
if( Key_IsDown( K_SHIFT ) )
Touch_KeyEvent( K_MOUSE2, 2 );
else
Touch_KeyEvent( K_MOUSE1, 2 );
}
if( !in_mouseinitialized || !in_mouseactive )
if( !in_mouseinitialized )
return;
if( m_ignore->value )
return;
if( down )
SetBits( in_mstate, BIT( key ));
else ClearBits( in_mstate, BIT( key ));
if( cls.key_dest == key_game )
{
#if defined( XASH_SDL )
static qboolean ignore; // igonre mouse warp event
int x, y;
Platform_GetMousePos(&x, &y);
if( host.mouse_visible )
SDL_ShowCursor( SDL_TRUE );
else if( !CVAR_TO_BOOL( touch_emulate ) )
SDL_ShowCursor( SDL_FALSE );
// perform button actions
VGui_KeyEvent( K_MOUSE1 + key, down );
if( x < host.window_center_x / 2 ||
y < host.window_center_y / 2 ||
x > host.window_center_x + host.window_center_x / 2 ||
y > host.window_center_y + host.window_center_y / 2 )
{
Platform_SetMousePos( host.window_center_x, host.window_center_y );
ignore = 1; // next mouse event will be mouse warp
return;
}
if ( !ignore )
{
if( !m_enginemouse->value )
{
// a1ba: mouse keys are now separated
// so pass 0 here
clgame.dllFuncs.IN_MouseEvent( 0 );
}
}
else
{
SDL_GetRelativeMouseState( 0, 0 ); // reset relative state
ignore = 0;
}
#endif
return;
// don't do Key_Event here
// client may override IN_MouseEvent
// but by default it calls back to Key_Event anyway
if( in_mouseactive )
clgame.dllFuncs.IN_MouseEvent( in_mstate );
}
else
{
#if XASH_SDL && !XASH_WIN32
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_SetRelativeMouseMode( SDL_FALSE );
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_ShowCursor( SDL_TRUE );
#endif // XASH_SDL && !XASH_WIN32
IN_MouseMove();
// perform button actions
Key_Event( K_MOUSE1 + key, down );
}
}
@ -571,13 +496,9 @@ static void IN_JoyAppendMove( usercmd_t *cmd, float forwardmove, float sidemove
}
}
void IN_CollectInput( float *forward, float *side, float *pitch, float *yaw, qboolean includeMouse, qboolean includeSdlMouse )
static void IN_CollectInput( float *forward, float *side, float *pitch, float *yaw, qboolean includeMouse )
{
if( includeMouse
#if XASH_SDL
&& includeSdlMouse
#endif
)
if( includeMouse )
{
float x, y;
Platform_MouseMove( &x, &y );
@ -626,7 +547,7 @@ void IN_EngineAppendMove( float frametime, void *cmd1, qboolean active )
{
float sensitivity = 1;//( (float)cl.local.scr_fov / (float)90.0f );
IN_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized && !CVAR_TO_BOOL( m_ignore ), m_enginemouse->value );
IN_CollectInput( &forward, &side, &pitch, &yaw, false );
IN_JoyAppendMove( cmd, forward, side );
@ -635,32 +556,22 @@ void IN_EngineAppendMove( float frametime, void *cmd1, qboolean active )
cmd->viewangles[YAW] += yaw * sensitivity;
cmd->viewangles[PITCH] += pitch * sensitivity;
cmd->viewangles[PITCH] = bound( -90, cmd->viewangles[PITCH], 90 );
VectorCopy(cmd->viewangles, cl.viewangles);
VectorCopy( cmd->viewangles, cl.viewangles );
}
}
}
/*
==================
Host_InputFrame
Called every frame, even if not generating commands
==================
*/
void Host_InputFrame( void )
void IN_Commands( void )
{
qboolean shutdownMouse = false;
float forward = 0, side = 0, pitch = 0, yaw = 0;
Sys_SendKeyEvents ();
#ifdef XASH_USE_EVDEV
IN_EvdevFrame();
#endif
if( clgame.dllFuncs.pfnLookEvent )
{
IN_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized && !CVAR_TO_BOOL( m_ignore ), true );
float forward = 0, side = 0, pitch = 0, yaw = 0;
IN_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized && !CVAR_TO_BOOL( m_ignore ) );
if( cls.key_dest == key_game )
{
@ -672,22 +583,21 @@ void Host_InputFrame( void )
if( !in_mouseinitialized )
return;
if( host.status != HOST_FRAME )
{
IN_DeactivateMouse();
return;
}
IN_CheckMouseState( in_mouseactive );
}
// release mouse during pause or console typeing
if( cl.paused && cls.key_dest == key_game )
shutdownMouse = true;
/*
==================
Host_InputFrame
if( shutdownMouse && !Cvar_VariableInteger( "fullscreen" ))
{
IN_DeactivateMouse();
return;
}
Called every frame, even if not generating commands
==================
*/
void Host_InputFrame( void )
{
Sys_SendKeyEvents ();
IN_Commands();
IN_ActivateMouse( false );
IN_MouseMove();
}

View File

@ -33,8 +33,8 @@ extern qboolean in_mouseinitialized;
void IN_Init( void );
void Host_InputFrame( void );
void IN_Shutdown( void );
void IN_MouseEvent( void );
void IN_ActivateMouse( qboolean force );
void IN_MouseEvent( int key, int down );
void IN_ActivateMouse( void );
void IN_DeactivateMouse( void );
void IN_MouseSavePos( void );
void IN_MouseRestorePos( void );

View File

@ -814,9 +814,9 @@ void Key_EnableTextInput( qboolean enable, qboolean force )
OSK_EnableTextInput( enable, force );
return;
}
if( enable && ( !host.textmode || force ) )
if( enable && ( !host.textmode || force ))
Platform_EnableTextInput( true );
else if( !enable )
else if( !enable && ( host.textmode || force ))
Platform_EnableTextInput( false );
host.textmode = enable;
@ -1044,7 +1044,7 @@ static qboolean OSK_KeyEvent( int key, int down )
else
osk.curlayout++;
osk.shift = osk.curbutton.val == OSK_SHIFT;
osk.shift = true;
osk.curbutton.val = osk_keylayout[osk.curlayout][osk.curbutton.y][osk.curbutton.x];
break;
case OSK_BACKSPACE:

View File

@ -335,10 +335,6 @@ static ref_api_t gEngfuncs =
COM_FreeLibrary,
COM_GetProcAddress,
FS_LoadFile,
FS_FileExists,
FS_AllowDirectPaths,
R_Init_Video_,
R_Free_Video,
@ -386,6 +382,8 @@ static ref_api_t gEngfuncs =
pfnDrawTransparentTriangles,
&clgame.drawFuncs,
&g_fsapi,
XVK_GetInstanceExtensions,
XVK_GetVkGetInstanceProcAddr,
XVK_CreateSurface,
@ -691,8 +689,8 @@ static void R_GetRenderDevices_f( void )
if( !device )
break;
Con_Printf( "%-3i %-4x:%-4x %-10s %s\n",
i, device->deviceID, device->vendorID,
Con_Printf( "%-3i %04x:%04x %-10s %s\n",
i, device->vendorID, device->deviceID,
R_DeviceTypeToString( device->deviceType ), device->deviceName );
}

View File

@ -33,7 +33,6 @@ GNU General Public License for more details.
#define MAXDLY (STEREODLY + 1)
#define MAXLP 10
#define MAXPRESETS 29
typedef struct sx_preset_s
{
@ -79,7 +78,7 @@ typedef struct dly_s
int *lpdelayline;
} dly_t;
const sx_preset_t rgsxpre[MAXPRESETS] =
const sx_preset_t rgsxpre[] =
{
// -------reverb-------- -------delay--------
// lp mod size refl rvblp delay feedback dlylp left
@ -116,7 +115,7 @@ const sx_preset_t rgsxpre[MAXPRESETS] =
// 0x0045dca8 enginegl.exe
// SHA256: 42383d32cd712e59ee2c1bd78b7ba48814e680e7026c4223e730111f34a60d66
const sx_preset_t rgsxpre_hlalpha052[MAXPRESETS] =
const sx_preset_t rgsxpre_hlalpha052[] =
{
// -------reverb-------- -------delay--------
// lp mod size refl rvblp delay feedback dlylp left
@ -482,7 +481,7 @@ void DLY_CheckNewDelayVal( void )
}
else
{
delay = min( delay, MAX_MONO_DELAY );
delay = Q_min( delay, MAX_MONO_DELAY );
dly->delaysamples = (int)(delay * idsp_dma_speed) << sxhires;
// init dly
@ -882,7 +881,7 @@ void CheckNewDspPresets( void )
else idsp_room = room_type->value;
// don't pass invalid presets
idsp_room = bound( 0, idsp_room, MAXPRESETS - 1 );
idsp_room = bound( 0, idsp_room, MAX_ROOM_TYPES );
if( FBitSet( hisound->flags, FCVAR_CHANGED ))
{
@ -893,9 +892,6 @@ void CheckNewDspPresets( void )
if( idsp_room == room_typeprev && idsp_room == 0 )
return;
if( idsp_room > MAX_ROOM_TYPES )
return;
if( idsp_room != room_typeprev )
{
const sx_preset_t *cur;

View File

@ -533,6 +533,8 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
// spatialize
memset( target_chan, 0, sizeof( *target_chan ));
pitch *= (sys_timescale.value + 1) / 2;
VectorCopy( pos, target_chan->origin );
target_chan->staticsound = ( ent == 0 ) ? true : false;
target_chan->use_loop = (flags & SND_STOP_LOOPING) ? false : true;
@ -788,6 +790,8 @@ void S_AmbientSound( const vec3_t pos, int ent, sound_t handle, float fvol, floa
return;
}
pitch *= (sys_timescale.value + 1) / 2;
// never update positions if source entity is 0
ch->staticsound = ( ent == 0 ) ? true : false;
ch->use_loop = (flags & SND_STOP_LOOPING) ? false : true;
@ -1151,7 +1155,6 @@ void S_RawSamples( uint samples, uint rate, word width, word channels, const byt
int snd_vol = 128;
if( entnum < 0 ) snd_vol = 256; // bg track or movie track
if( snd_vol < 0 ) snd_vol = 0; // fixup negative values
S_RawEntSamples( entnum, samples, rate, width, channels, data, snd_vol );
}

View File

@ -809,7 +809,7 @@ void S_MixBufferUpsample2x( int count, portable_samplepair_t *pbuffer, portable_
// zero out all paintbuffers
void MIX_ClearAllPaintBuffers( int SampleCount, qboolean clearFilters )
{
int count = min( SampleCount, PAINTBUFFER_SIZE );
int count = Q_min( SampleCount, PAINTBUFFER_SIZE );
int i;
// zero out all paintbuffer data (ignore sampleCount)

File diff suppressed because it is too large Load Diff

View File

@ -21,31 +21,13 @@ GNU General Public License for more details.
#include "keydefs.h"
#include "ref_common.h"
#include "input.h"
#ifdef XASH_SDL
#include <SDL.h>
static SDL_Cursor* s_pDefaultCursor[20];
#endif
#include "platform/platform.h"
static enum VGUI_KeyCode s_pVirtualKeyTrans[256];
static enum VGUI_DefaultCursor s_currentCursor;
static VGUI_DefaultCursor s_currentCursor;
static HINSTANCE s_pVGuiSupport; // vgui_support library
static convar_t *vgui_utf8 = NULL;
// Helper functions for vgui backend
/*void VGUI_HideCursor( void )
{
host.mouse_visible = false;
SDL_HideCursor();
}
void VGUI_ShowCursor( void )
{
host.mouse_visible = true;
SDL_ShowCursor();
}*/
void GAME_EXPORT *VGUI_EngineMalloc(size_t size)
{
return Z_Malloc( size );
@ -66,70 +48,10 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y )
*_x = x / xscale, *_y = y / yscale;
}
void VGUI_InitCursors( void )
void GAME_EXPORT VGUI_CursorSelect( VGUI_DefaultCursor cursor )
{
// load up all default cursors
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
s_pDefaultCursor[dc_none] = NULL;
s_pDefaultCursor[dc_arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
s_pDefaultCursor[dc_ibeam] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
s_pDefaultCursor[dc_hourglass]= SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
s_pDefaultCursor[dc_crosshair]= SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR);
s_pDefaultCursor[dc_up] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
s_pDefaultCursor[dc_sizenwse] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
s_pDefaultCursor[dc_sizenesw] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
s_pDefaultCursor[dc_sizewe] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
s_pDefaultCursor[dc_sizens] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
s_pDefaultCursor[dc_sizeall] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
s_pDefaultCursor[dc_no] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
s_pDefaultCursor[dc_hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
//host.mouse_visible = true;
SDL_SetCursor( s_pDefaultCursor[dc_arrow] );
#endif
}
void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor )
{
qboolean visible;
if( cls.key_dest != key_game || cl.paused )
return;
switch( cursor )
{
case dc_user:
case dc_none:
visible = false;
break;
default:
visible = true;
break;
}
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
/// TODO: platform cursors
if( CVAR_TO_BOOL( touch_emulate ) )
return;
if( host.mouse_visible )
{
SDL_SetRelativeMouseMode( SDL_FALSE );
SDL_SetCursor( s_pDefaultCursor[cursor] );
SDL_ShowCursor( true );
}
else
{
SDL_ShowCursor( false );
if( host.mouse_visible )
SDL_GetRelativeMouseState( NULL, NULL );
Key_EnableTextInput( false, true );
}
//SDL_SetRelativeMouseMode(false);
#endif
if( s_currentCursor == cursor )
return;
Platform_SetCursorType( cursor );
s_currentCursor = cursor;
host.mouse_visible = visible;
}
byte GAME_EXPORT VGUI_GetColor( int i, int j)
@ -138,21 +60,9 @@ byte GAME_EXPORT VGUI_GetColor( int i, int j)
}
// Define and initialize vgui API
void GAME_EXPORT VGUI_SetVisible( qboolean state )
{
host.mouse_visible=state;
#ifdef XASH_SDL
SDL_ShowCursor( state );
if( !state )
SDL_GetRelativeMouseState( NULL, NULL );
#endif
Key_EnableTextInput( false, true );
}
int GAME_EXPORT VGUI_UtfProcessChar( int in )
{
if( CVAR_TO_BOOL( vgui_utf8 ) )
if( CVAR_TO_BOOL( vgui_utf8 ))
return Con_UtfProcessCharForce( in );
else
return in;
@ -175,14 +85,15 @@ vguiapi_t vgui =
NULL, // VGUI_GetTextureSizes,
NULL, // VGUI_GenerateTexture,
VGUI_EngineMalloc,
/* VGUI_ShowCursor,
VGUI_HideCursor,*/
VGUI_CursorSelect,
VGUI_GetColor,
VGUI_IsInGame,
VGUI_SetVisible,
NULL,
VGUI_GetMousePos,
VGUI_UtfProcessChar,
Platform_GetClipboardText,
Platform_SetClipboardText,
Platform_GetKeyModifiers,
NULL,
NULL,
NULL,
@ -190,6 +101,7 @@ vguiapi_t vgui =
NULL,
NULL,
NULL,
NULL
};
qboolean VGui_IsActive( void )
@ -240,7 +152,6 @@ void VGui_Startup( const char *clientlib, int width, int height )
VGui_FillAPIFromRef( &vgui, &ref.dllFuncs );
#ifdef XASH_INTERNAL_GAMELIBS
s_pVGuiSupport = COM_LoadLibrary( clientlib, false, false );
if( s_pVGuiSupport )
@ -250,58 +161,70 @@ void VGui_Startup( const char *clientlib, int width, int height )
{
F( &vgui );
vgui.initialized = true;
VGUI_InitCursors();
Con_Reportf( "vgui_support: found interal client support\n" );
Con_Reportf( "vgui_support: found internal client support\n" );
}
else
{
COM_FreeLibrary( s_pVGuiSupport );
}
}
#endif // XASH_INTERNAL_GAMELIBS
// HACKHACK: load vgui with correct path first if specified.
// it will be reused while resolving vgui support and client deps
if( Sys_GetParmFromCmdLine( "-vguilib", vguilib ) )
if( !vgui.initialized )
{
if( Q_strstr( vguilib, ".dll") )
// HACKHACK: load vgui with correct path first if specified.
// it will be reused while resolving vgui support and client deps
if( Sys_GetParmFromCmdLine( "-vguilib", vguilib ))
{
if( Q_strstr( vguilib, ".dll" ))
Q_strncpy( vguiloader, "vgui_support.dll", 256 );
else
Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 );
if( !COM_LoadLibrary( vguilib, false, false ))
Con_Reportf( S_WARN "VGUI preloading failed. Default library will be used! Reason: %s\n", COM_GetLibraryError() );
}
if( Q_strstr( clientlib, ".dll" ))
Q_strncpy( vguiloader, "vgui_support.dll", 256 );
else
if( !vguiloader[0] && !Sys_GetParmFromCmdLine( "-vguiloader", vguiloader ))
Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 );
if( !COM_LoadLibrary( vguilib, false, false ) )
Con_Reportf( S_WARN "VGUI preloading failed. Default library will be used! Reason: %s\n", COM_GetLibraryError());
}
s_pVGuiSupport = COM_LoadLibrary( vguiloader, false, false );
if( Q_strstr( clientlib, ".dll" ) )
Q_strncpy( vguiloader, "vgui_support.dll", 256 );
if( !vguiloader[0] && !Sys_GetParmFromCmdLine( "-vguiloader", vguiloader ) )
Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 );
s_pVGuiSupport = COM_LoadLibrary( vguiloader, false, false );
if( !s_pVGuiSupport )
{
s_pVGuiSupport = COM_LoadLibrary( va( "../%s", vguiloader ), false, false );
}
if( !s_pVGuiSupport )
{
if( FS_FileExists( vguiloader, false ) )
Con_Reportf( S_ERROR "Failed to load vgui_support library: %s\n", COM_GetLibraryError() );
else
Con_Reportf( "vgui_support: not found\n" );
}
else
{
F = COM_GetProcAddress( s_pVGuiSupport, "InitAPI" );
if( F )
if( !s_pVGuiSupport )
{
F( &vgui );
vgui.initialized = true;
VGUI_InitCursors();
s_pVGuiSupport = COM_LoadLibrary( va( "../%s", vguiloader ), false, false );
}
if( !s_pVGuiSupport )
{
if( FS_FileExists( vguiloader, false ))
{
Con_Reportf( S_ERROR "Failed to load vgui_support library: %s\n", COM_GetLibraryError() );
}
else
{
Con_Reportf( "vgui_support: not found\n" );
}
failed = true;
}
else
Con_Reportf( S_ERROR "Failed to find vgui_support library entry point!\n" );
{
F = COM_GetProcAddress( s_pVGuiSupport, "InitAPI" );
if( F )
{
F( &vgui );
vgui.initialized = true;
}
else
{
Con_Reportf( S_ERROR "Failed to find vgui_support library entry point!\n" );
failed = true;
COM_FreeLibrary( s_pVGuiSupport );
}
}
}
}
if( height < 480 )
@ -498,8 +421,9 @@ void VGui_KeyEvent( int key, int down )
switch( key )
{
case K_MOUSE1:
if( down && host.mouse_visible )
Key_EnableTextInput( true, false );
if( down && host.mouse_visible ) {
Key_EnableTextInput(true, false);
}
vgui.Mouse( down ? MA_PRESSED : MA_RELEASED, MOUSE_LEFT );
return;
case K_MOUSE2:
@ -535,7 +459,7 @@ void VGui_MouseMove( int x, int y )
void VGui_Paint( void )
{
if(vgui.initialized)
if( vgui.initialized )
vgui.Paint();
}
@ -551,3 +475,9 @@ void *GAME_EXPORT VGui_GetPanel( void )
return vgui.GetPanel();
return NULL;
}
void VGui_ReportTextInput( const char *text )
{
if ( vgui.initialized )
vgui.TextInput( text );
}

View File

@ -33,6 +33,7 @@ void VGui_KeyEvent( int key, int down );
void VGui_MouseMove( int x, int y );
qboolean VGui_IsActive( void );
void *VGui_GetPanel( void );
void VGui_ReportTextInput( const char *text );
#ifdef __cplusplus
}
#endif

View File

@ -16,9 +16,9 @@ GNU General Public License for more details.
#ifndef VOX_H
#define VOX_H
#define CVOXWORDMAX 64
#define CVOXZEROSCANMAX 255 // scan up to this many samples for next zero crossing
#define MAX_SENTENCES 4096
#define CVOXWORDMAX 64
#define CVOXFILESENTENCEMAX 4096
#define SENTENCE_INDEX -99999 // unique sentence index
typedef struct voxword_s
@ -34,13 +34,6 @@ typedef struct voxword_s
sfx_t *sfx; // name and cache pointer
} voxword_t;
typedef struct
{
char *pName;
float length;
} sentence_t;
struct channel_s;
void VOX_LoadWord( struct channel_s *pchan );
void VOX_FreeWord( struct channel_s *pchan );

View File

@ -229,7 +229,7 @@ void BaseCmd_Stats_f( void )
Con_Printf( "Empty buckets: %d\n", empty );
}
static void BaseCmd_CheckCvars( const char *key, const char *value, void *buffer, void *ptr )
static void BaseCmd_CheckCvars( const char *key, const char *value, const void *unused, void *ptr )
{
base_command_t *v = BaseCmd_Find( HM_CVAR, key );
qboolean *invalid = ptr;

View File

@ -510,8 +510,8 @@ typedef struct cmd_s
struct cmd_s *next;
char *name;
xcommand_t function;
char *desc;
int flags;
char *desc;
} cmd_t;
static int cmd_argc;
@ -647,7 +647,7 @@ void Cmd_TokenizeString( const char *text )
if( cmd_argc == 1 )
cmd_args = text;
text = _COM_ParseFileSafe( (char*)text, cmd_token, sizeof( cmd_token ), PFILE_IGNOREBRACKET, NULL );
text = COM_ParseFileSafe( (char*)text, cmd_token, sizeof( cmd_token ), PFILE_IGNOREBRACKET, NULL, NULL );
if( !text ) return;
@ -671,21 +671,21 @@ static int Cmd_AddCommandEx( const char *funcname, const char *cmd_name, xcomman
if( !COM_CheckString( cmd_name ))
{
Con_Reportf( S_ERROR "Cmd_AddCommand: NULL name\n" );
Con_Reportf( S_ERROR "%s: NULL name\n", funcname );
return 0;
}
// fail if the command is a variable name
if( Cvar_FindVar( cmd_name ))
{
Con_DPrintf( S_ERROR "Cmd_AddServerCommand: %s already defined as a var\n", cmd_name );
Con_DPrintf( S_ERROR "%s: %s already defined as a var\n", funcname, cmd_name );
return 0;
}
// fail if the command already exists
if( Cmd_Exists( cmd_name ))
{
Con_DPrintf( S_ERROR "Cmd_AddServerCommand: %s already defined\n", cmd_name );
Con_DPrintf( S_ERROR "%s: %s already defined\n", funcname, cmd_name );
return 0;
}
@ -1093,7 +1093,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
if( Cvar_CommandWithPrivilegeCheck( cvar, isPrivileged )) return;
if( host.apply_game_config )
return; // don't send nothing to server: we is a server!
return; // don't send nothing to server: we are a server!
// forward the command line to the server, so the entity DLL can parse it
if( host.type == HOST_NORMAL )
@ -1107,7 +1107,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
#endif // XASH_DEDICATED
if( Cvar_VariableInteger( "host_gameloaded" ))
{
Con_Printf( S_WARN "Unknown command \"%s\"\n", text );
Con_Printf( S_WARN "Unknown command \"%s\"\n", Cmd_Argv( 0 ) );
}
}
}
@ -1384,13 +1384,13 @@ void Cmd_Init( void )
Cmd_AddCommand( "echo", Cmd_Echo_f, "print a message to the console (useful in scripts)" );
Cmd_AddCommand( "wait", Cmd_Wait_f, "make script execution wait for some rendered frames" );
Cmd_AddCommand( "cmdlist", Cmd_List_f, "display all console commands beginning with the specified prefix" );
Cmd_AddCommand( "stuffcmds", Cmd_StuffCmds_f, "execute commandline parameters (must be present in .rc script)" );
Cmd_AddRestrictedCommand( "stuffcmds", Cmd_StuffCmds_f, "execute commandline parameters (must be present in .rc script)" );
Cmd_AddCommand( "apropos", Cmd_Apropos_f, "lists all console variables/commands/aliases containing the specified string in the name or description" );
#if !XASH_DEDICATED
Cmd_AddCommand( "cmd", Cmd_ForwardToServer, "send a console commandline to the server" );
#endif // XASH_DEDICATED
Cmd_AddCommand( "alias", Cmd_Alias_f, "create a script function. Without arguments show the list of all alias" );
Cmd_AddCommand( "unalias", Cmd_UnAlias_f, "remove a script function" );
Cmd_AddRestrictedCommand( "alias", Cmd_Alias_f, "create a script function. Without arguments show the list of all alias" );
Cmd_AddRestrictedCommand( "unalias", Cmd_UnAlias_f, "remove a script function" );
Cmd_AddCommand( "if", Cmd_If_f, "compare and set condition bits" );
Cmd_AddCommand( "else", Cmd_Else_f, "invert condition bit" );

View File

@ -64,6 +64,8 @@ GNU General Public License for more details.
#define DEFAULT_UPDATE_PAGE "https://github.com/FWGS/xash3d-fwgs/releases/latest"
#define XASH_ENGINE_NAME "Xash3D FWGS"
#define XASH_VERSION "0.20" // engine current version
#define XASH_COMPAT_VERSION "0.99" // version we are based on
// renderers order is important, software is always a last chance fallback
#define DEFAULT_RENDERERS { "vk", "gl", "gles1", "gles2", "gl4es", "soft" }

View File

@ -585,23 +585,6 @@ void COM_TrimSpace( const char *source, char *dest )
dest[length] = 0;
}
/*
============
COM_FixSlashes
Changes all '/' characters into '\' characters, in place.
============
*/
void COM_FixSlashes( char *pname )
{
while( *pname )
{
if( *pname == '\\' )
*pname = '/';
pname++;
}
}
/*
==================
COM_Nibble
@ -1182,22 +1165,22 @@ void Test_RunCommon( void )
Msg( "Checking COM_ParseFile...\n" );
file = _COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len );
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "q" ) && len == 1);
file = _COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len );
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "asdf" ) && len == 4);
file = _COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len );
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "qwer" ) && len == -1);
file = _COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len );
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "f \"f" ) && len == 4);
file = _COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len );
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "meow" ) && len == -1);
file = _COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len );
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
TASSERT( !Q_strcmp( buf, "bark" ) && len == 4);
}
#endif

View File

@ -76,13 +76,6 @@ XASH SPECIFIC - sort of hack that works only in Xash3D not in GoldSrc
#define HACKS_RELATED_HLMODS // some HL-mods works differently under Xash and can't be fixed without some hacks at least at current time
typedef struct
{
int numfilenames;
char **filenames;
char *filenamesbuffer;
} search_t;
enum
{
DEV_NONE = 0,
@ -118,9 +111,8 @@ typedef enum
#include "cvar.h"
#include "con_nprint.h"
#include "crclib.h"
#define XASH_VERSION "0.20" // engine current version
#define XASH_COMPAT_VERSION "0.99" // version we are based on
#include "ref_api.h"
#include "fscallback.h"
// PERFORMANCE INFO
#define MIN_FPS 20.0f // host minimum fps value for maxfps.
@ -150,18 +142,6 @@ typedef enum
#define MAX_STATIC_ENTITIES 32 // static entities that moved on the client when level is spawn
#endif
// filesystem flags
#define FS_STATIC_PATH ( 1U << 0 ) // FS_ClearSearchPath will be ignore this path
#define FS_NOWRITE_PATH ( 1U << 1 ) // default behavior - last added gamedir set as writedir. This flag disables it
#define FS_GAMEDIR_PATH ( 1U << 2 ) // just a marker for gamedir path
#define FS_CUSTOM_PATH ( 1U << 3 ) // custom directory
#define FS_GAMERODIR_PATH ( 1U << 4 ) // caseinsensitive
#define FS_GAMEDIRONLY_SEARCH_FLAGS ( FS_GAMEDIR_PATH | FS_CUSTOM_PATH | FS_GAMERODIR_PATH )
#define GI SI.GameInfo
#define FS_Gamedir() SI.GameInfo->gamefolder
#define FS_Title() SI.GameInfo->title
#define GameState (&host.game)
#define FORCE_DRAW_VERSION_TIME 5.0f // draw version for 5 seconds
@ -184,7 +164,8 @@ extern convar_t host_developer;
extern convar_t *host_limitlocal;
extern convar_t *host_framerate;
extern convar_t *host_maxfps;
extern convar_t cl_filterstuffcmd;
extern convar_t sys_timescale;
extern convar_t cl_filterstuffcmd;
/*
==============================================================
@ -201,60 +182,6 @@ GAMEINFO stuff
internal shared gameinfo structure (readonly for engine parts)
========================================================================
*/
typedef struct gameinfo_s
{
// filesystem info
char gamefolder[MAX_QPATH]; // used for change game '-game x'
char basedir[MAX_QPATH]; // base game directory (like 'id1' for Quake or 'valve' for Half-Life)
char falldir[MAX_QPATH]; // used as second basedir
char startmap[MAX_QPATH];// map to start singleplayer game
char trainmap[MAX_QPATH];// map to start hazard course (if specified)
char title[64]; // Game Main Title
float version; // game version (optional)
// .dll pathes
char dll_path[MAX_QPATH]; // e.g. "bin" or "cl_dlls"
char game_dll[MAX_QPATH]; // custom path for game.dll
// .ico path
char iconpath[MAX_QPATH]; // "game.ico" by default
// about mod info
string game_url; // link to a developer's site
string update_url; // link to updates page
char type[MAX_QPATH]; // single, toolkit, multiplayer etc
char date[MAX_QPATH];
size_t size;
int gamemode;
qboolean secure; // prevent to console acess
qboolean nomodels; // don't let player to choose model (use player.mdl always)
qboolean noskills; // disable skill menu selection
char sp_entity[32]; // e.g. info_player_start
char mp_entity[32]; // e.g. info_player_deathmatch
char mp_filter[32]; // filtering multiplayer-maps
char ambientsound[NUM_AMBIENTS][MAX_QPATH]; // quake ambient sounds
int max_edicts; // min edicts is 600, max edicts is 8196
int max_tents; // min temp ents is 300, max is 2048
int max_beams; // min beams is 64, max beams is 512
int max_particles; // min particles is 4096, max particles is 32768
char game_dll_linux[64]; // custom path for game.dll
char game_dll_osx[64]; // custom path for game.dll
qboolean added;
} gameinfo_t;
typedef enum
{
GAME_NORMAL,
GAME_SINGLEPLAYER_ONLY,
GAME_MULTIPLAYER_ONLY
} gametype_t;
typedef struct sysinfo_s
{
string exeName; // exe.filename
@ -262,9 +189,6 @@ typedef struct sysinfo_s
string basedirName; // name of base directory
string gamedll;
string clientlib;
gameinfo_t *GameInfo; // current GameInfo
gameinfo_t *games[MAX_MODS]; // environment games (founded at each engine start)
int numgames;
} sysinfo_t;
typedef enum
@ -471,6 +395,13 @@ extern sysinfo_t SI;
typedef void (*xcommand_t)( void );
//
// filesystem_engine.c
//
qboolean FS_LoadProgs( void );
void FS_Init( void );
void FS_Shutdown( void );
//
// cmd.c
//
@ -530,56 +461,6 @@ void Mem_PrintStats( void );
#define Mem_IsAllocated( mem ) Mem_IsAllocatedExt( NULL, mem )
#define Mem_Check() _Mem_Check( __FILE__, __LINE__ )
//
// filesystem.c
//
void FS_Init( void );
void FS_Path( void );
void FS_Rescan( void );
void FS_Shutdown( void );
void FS_ClearSearchPath( void );
void FS_AllowDirectPaths( qboolean enable );
void FS_AddGameDirectory( const char *dir, uint flags );
void FS_AddGameHierarchy( const char *dir, uint flags );
void FS_LoadGameInfo( const char *rootfolder );
const char *FS_GetDiskPath( const char *name, qboolean gamedironly );
byte *W_LoadLump( wfile_t *wad, const char *lumpname, size_t *lumpsizeptr, const char type );
void W_Close( wfile_t *wad );
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
qboolean CRC32_File( dword *crcvalue, const char *filename );
qboolean MD5_HashFile( byte digest[16], const char *pszFileName, uint seed[4] );
byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr );
qboolean FS_WriteFile( const char *filename, const void *data, fs_offset_t len );
qboolean COM_ParseVector( char **pfile, float *v, size_t size );
void COM_NormalizeAngles( vec3_t angles );
int COM_FileSize( const char *filename );
void COM_FixSlashes( char *pname );
void COM_FreeFile( void *buffer );
int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare );
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly );
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly );
fs_offset_t FS_Write( file_t *file, const void *data, size_t datasize );
fs_offset_t FS_Read( file_t *file, void *buffer, size_t buffersize );
int FS_VPrintf( file_t *file, const char *format, va_list ap );
int FS_Seek( file_t *file, fs_offset_t offset, int whence );
int FS_Gets( file_t *file, byte *string, size_t bufsize );
int FS_Printf( file_t *file, const char *format, ... ) _format( 2 );
fs_offset_t FS_FileSize( const char *filename, qboolean gamedironly );
int FS_FileTime( const char *filename, qboolean gamedironly );
int FS_Print( file_t *file, const char *msg );
qboolean FS_Rename( const char *oldname, const char *newname );
int FS_FileExists( const char *filename, int gamedironly );
int FS_SetCurrentDirectory( const char *path );
qboolean FS_SysFileExists( const char *path, qboolean casesensitive );
qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
qboolean FS_Delete( const char *path );
int FS_UnGetc( file_t *file, byte c );
fs_offset_t FS_Tell( file_t *file );
qboolean FS_Eof( file_t *file );
int FS_Close( file_t *file );
int FS_Getc( file_t *file );
fs_offset_t FS_FileLength( file_t *f );
//
// imagelib
//
@ -668,16 +549,6 @@ void FS_FreeStream( stream_t *stream );
qboolean Sound_Process( wavdata_t **wav, int rate, int width, uint flags );
uint Sound_GetApproxWavePlayLen( const char *filepath );
//
// build.c
//
int Q_buildnum( void );
int Q_buildnum_compat( void );
const char *Q_buildos( void );
const char *Q_buildarch( void );
const char *Q_buildcommit( void );
//
// host.c
//
@ -689,7 +560,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
int Host_CompareFileTime( int ft1, int ft2 );
void Host_NewInstance( const char *name, const char *finalmsg );
void Host_EndGame( qboolean abort, const char *message, ... ) _format( 2 );
void Host_AbortCurrentFrame( void );
void Host_AbortCurrentFrame( void ) NORETURN;
void Host_WriteServerConfig( const char *name );
void Host_WriteOpenGLConfig( void );
void Host_WriteVideoConfig( void );
@ -754,7 +625,6 @@ void pfnDrawSetTextColor( float r, float g, float b );
void pfnDrawConsoleStringLen( const char *pText, int *length, int *height );
void *Cache_Check( poolhandle_t mempool, struct cache_user_s *c );
void COM_TrimSpace( const char *source, char *dest );
edict_t* pfnPEntityOfEntIndex( int iEntIndex );
void pfnGetModelBounds( model_t *mod, float *mins, float *maxs );
void pfnCVarDirectSet( cvar_t *var, const char *szValue );
int COM_CheckParm( char *parm, char **ppnext );
@ -954,6 +824,11 @@ void UI_SetActiveMenu( qboolean fActive );
void UI_ShowConnectionWarning( void );
void Cmd_Null_f( void );
void Rcon_Print( const char *pMsg );
qboolean COM_ParseVector( char **pfile, float *v, size_t size );
void COM_NormalizeAngles( vec3_t angles );
int COM_FileSize( const char *filename );
void COM_FreeFile( void *buffer );
int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare );
// soundlib shared exports
qboolean S_Init( void );

View File

@ -761,10 +761,10 @@ qboolean Cmd_GetGamesList( const char *s, char *completedname, int length )
// compare gamelist with current keyword
len = Q_strlen( s );
for( i = 0, numgamedirs = 0; i < SI.numgames; i++ )
for( i = 0, numgamedirs = 0; i < FI->numgames; i++ )
{
if(( *s == '*' ) || !Q_strnicmp( SI.games[i]->gamefolder, s, len))
Q_strcpy( gamedirs[numgamedirs++], SI.games[i]->gamefolder );
if(( *s == '*' ) || !Q_strnicmp( FI->games[i]->gamefolder, s, len))
Q_strcpy( gamedirs[numgamedirs++], FI->games[i]->gamefolder );
}
if( !numgamedirs ) return false;
@ -1216,7 +1216,7 @@ void Con_CompleteCommand( field_t *field )
if( con.matchCount == 1 )
{
Q_sprintf( con.completionField->buffer, "\\%s", con.cmds[0] );
Q_strncpy( con.completionField->buffer, con.cmds[0], sizeof( con.completionField->buffer ));
if( Cmd_Argc() == 1 ) Q_strncat( con.completionField->buffer, " ", sizeof( con.completionField->buffer ) );
else Con_ConcatRemaining( temp.buffer, con.completionString );
con.completionField->cursor = Q_strlen( con.completionField->buffer );
@ -1244,7 +1244,7 @@ void Con_CompleteCommand( field_t *field )
con.shortestMatch[len] = 0;
// multiple matches, complete to shortest
Q_sprintf( con.completionField->buffer, "\\%s", con.shortestMatch );
Q_strncpy( con.completionField->buffer, con.shortestMatch, sizeof( con.completionField->buffer ));
con.completionField->cursor = Q_strlen( con.completionField->buffer );
Con_ConcatRemaining( temp.buffer, con.completionString );

View File

@ -24,9 +24,11 @@ Crash handler, called from system
================
*/
#if XASH_CRASHHANDLER == CRASHHANDLER_DBGHELP || XASH_CRASHHANDLER == CRASHHANDLER_WIN32
#if XASH_CRASHHANDLER == CRASHHANDLER_DBGHELP
#pragma comment( lib, "dbghelp" )
#pragma comment( lib, "psapi" )
#include <winnt.h>
#include <dbghelp.h>
#include <psapi.h>
@ -35,7 +37,7 @@ Crash handler, called from system
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
#endif
int ModuleName( HANDLE process, char *name, void *address, int len )
static int Sys_ModuleName( HANDLE process, char *name, void *address, int len )
{
DWORD_PTR baseAddress = 0;
static HMODULE *moduleArray;
@ -44,27 +46,24 @@ int ModuleName( HANDLE process, char *name, void *address, int len )
DWORD bytesRequired;
int i;
if(len < 3)
if( len < 3 )
return 0;
if ( !moduleArray && EnumProcessModules( process, NULL, 0, &bytesRequired ) )
if( !moduleArray && EnumProcessModules( process, NULL, 0, &bytesRequired ) )
{
if ( bytesRequired )
{
moduleArrayBytes = (LPBYTE)LocalAlloc( LPTR, bytesRequired );
if ( moduleArrayBytes )
if( moduleArrayBytes && EnumProcessModules( process, (HMODULE *)moduleArrayBytes, bytesRequired, &bytesRequired ) )
{
if( EnumProcessModules( process, (HMODULE *)moduleArrayBytes, bytesRequired, &bytesRequired ) )
{
moduleCount = bytesRequired / sizeof( HMODULE );
moduleArray = (HMODULE *)moduleArrayBytes;
}
moduleCount = bytesRequired / sizeof( HMODULE );
moduleArray = (HMODULE *)moduleArrayBytes;
}
}
}
for( i = 0; i<moduleCount; i++ )
for( i = 0; i < moduleCount; i++ )
{
MODULEINFO info;
GetModuleInformation( process, moduleArray[i], &info, sizeof(MODULEINFO) );
@ -73,9 +72,10 @@ int ModuleName( HANDLE process, char *name, void *address, int len )
( (DWORD64)address < (DWORD64)info.lpBaseOfDll + (DWORD64)info.SizeOfImage ) )
return GetModuleBaseName( process, moduleArray[i], name, len );
}
return Q_snprintf(name, len, "???");
return Q_snprintf( name, len, "???" );
}
static void stack_trace( PEXCEPTION_POINTERS pInfo )
static void Sys_StackTrace( PEXCEPTION_POINTERS pInfo )
{
char message[1024];
int len = 0;
@ -89,7 +89,8 @@ static void stack_trace( PEXCEPTION_POINTERS pInfo )
STACKFRAME64 stackframe;
DWORD image;
memcpy( &context, pInfo->ContextRecord, sizeof(CONTEXT) );
memcpy( &context, pInfo->ContextRecord, sizeof( CONTEXT ));
options = SymGetOptions();
options |= SYMOPT_DEBUG;
options |= SYMOPT_LOAD_LINES;
@ -97,9 +98,7 @@ static void stack_trace( PEXCEPTION_POINTERS pInfo )
SymInitialize( process, NULL, TRUE );
ZeroMemory( &stackframe, sizeof(STACKFRAME64) );
ZeroMemory( &stackframe, sizeof( STACKFRAME64 ));
#ifdef _M_IX86
image = IMAGE_FILE_MACHINE_I386;
@ -127,19 +126,25 @@ static void stack_trace( PEXCEPTION_POINTERS pInfo )
stackframe.AddrBStore.Mode = AddrModeFlat;
stackframe.AddrStack.Offset = context.IntSp;
stackframe.AddrStack.Mode = AddrModeFlat;
#elif
#error
#endif
len += Q_snprintf( message + len, 1024 - len, "Sys_Crash: address %p, code %p\n", pInfo->ExceptionRecord->ExceptionAddress, (void*)pInfo->ExceptionRecord->ExceptionCode );
len += Q_snprintf( message + len, 1024 - len, "Sys_Crash: address %p, code %p\n",
pInfo->ExceptionRecord->ExceptionAddress, (void*)pInfo->ExceptionRecord->ExceptionCode );
if( SymGetLineFromAddr64( process, (DWORD64)pInfo->ExceptionRecord->ExceptionAddress, &dline, &line ) )
{
len += Q_snprintf(message + len, 1024 - len,"Exception: %s:%d:%d\n", (char*)line.FileName, (int)line.LineNumber, (int)dline);
len += Q_snprintf(message + len, 1024 - len, "Exception: %s:%d:%d\n",
(char*)line.FileName, (int)line.LineNumber, (int)dline);
}
if( SymGetLineFromAddr64( process, stackframe.AddrPC.Offset, &dline, &line ) )
{
len += Q_snprintf(message + len, 1024 - len,"PC: %s:%d:%d\n", (char*)line.FileName, (int)line.LineNumber, (int)dline);
len += Q_snprintf(message + len, 1024 - len,"PC: %s:%d:%d\n",
(char*)line.FileName, (int)line.LineNumber, (int)dline);
}
if( SymGetLineFromAddr64( process, stackframe.AddrFrame.Offset, &dline, &line ) )
{
len += Q_snprintf(message + len, 1024 - len,"Frame: %s:%d:%d\n", (char*)line.FileName, (int)line.LineNumber, (int)dline);
len += Q_snprintf(message + len, 1024 - len,"Frame: %s:%d:%d\n",
(char*)line.FileName, (int)line.LineNumber, (int)dline);
}
for( i = 0; i < 25; i++ )
{
@ -149,39 +154,43 @@ static void stack_trace( PEXCEPTION_POINTERS pInfo )
image, process, thread,
&stackframe, &context, NULL,
SymFunctionTableAccess64, SymGetModuleBase64, NULL);
DWORD64 displacement = 0;
if( !result )
break;
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
symbol->MaxNameLen = MAX_SYM_NAME;
len += Q_snprintf( message + len, 1024 - len, "% 2d %p", i, (void*)stackframe.AddrPC.Offset );
len += Q_snprintf( message + len, 1024 - len, "% 2d %p",
i, (void*)stackframe.AddrPC.Offset );
if( SymFromAddr( process, stackframe.AddrPC.Offset, &displacement, symbol ) )
{
len += Q_snprintf( message + len, 1024 - len, " %s ", symbol->Name );
}
if( SymGetLineFromAddr64( process, stackframe.AddrPC.Offset, &dline, &line ) )
{
len += Q_snprintf(message + len, 1024 - len,"(%s:%d:%d) ", (char*)line.FileName, (int)line.LineNumber, (int)dline);
len += Q_snprintf(message + len, 1024 - len,"(%s:%d:%d) ",
(char*)line.FileName, (int)line.LineNumber, (int)dline);
}
len += Q_snprintf( message + len, 1024 - len, "(");
len += ModuleName( process, message + len, (void*)stackframe.AddrPC.Offset, 1024 - len );
len += Sys_ModuleName( process, message + len, (void*)stackframe.AddrPC.Offset, 1024 - len );
len += Q_snprintf( message + len, 1024 - len, ")\n");
}
#ifdef XASH_SDL
if( host.type != HOST_DEDICATED ) // let system to restart server automaticly
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR,"Sys_Crash", message, host.hWnd );
#endif
Sys_PrintLog(message);
SymCleanup(process);
#if XASH_SDL == 2
if( host.type != HOST_DEDICATED ) // let system to restart server automaticly
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Sys_Crash", message, host.hWnd );
#endif
Sys_PrintLog( message );
SymCleanup( process );
}
#endif //DBGHELP
#endif /* XASH_CRASHHANDLER == CRASHHANDLER_DBGHELP */
LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
long _stdcall Sys_Crash( PEXCEPTION_POINTERS pInfo )
static long _stdcall Sys_Crash( PEXCEPTION_POINTERS pInfo )
{
// save config
if( host.status != HOST_CRASHED )
@ -190,7 +199,7 @@ long _stdcall Sys_Crash( PEXCEPTION_POINTERS pInfo )
host.crashed = true;
#if XASH_CRASHHANDLER == CRASHHANDLER_DBGHELP
stack_trace( pInfo );
Sys_StackTrace( pInfo );
#else
Sys_Warn( "Sys_Crash: call %p at address %p", pInfo->ExceptionRecord->ExceptionAddress, pInfo->ExceptionRecord->ExceptionCode );
#endif
@ -233,13 +242,14 @@ void Sys_RestoreCrashHandler( void )
#include "library.h"
#if XASH_FREEBSD || XASH_NETBSD || XASH_ANDROID || XASH_LINUX
#if XASH_FREEBSD || XASH_NETBSD || XASH_OPENBSD || XASH_ANDROID || XASH_LINUX
#define HAVE_UCONTEXT_H 1
#endif
#ifdef HAVE_UCONTEXT_H
#include <ucontext.h>
#endif
#include <signal.h>
#include <sys/mman.h>
@ -261,7 +271,7 @@ static int d_dladdr( void *sym, Dl_info *info )
#define dladdr d_dladdr
#endif
int printframe( char *buf, int len, int i, void *addr )
static int Sys_PrintFrame( char *buf, int len, int i, void *addr )
{
Dl_info dlinfo;
if( len <= 0 )
@ -271,7 +281,7 @@ int printframe( char *buf, int len, int i, void *addr )
{
if( dlinfo.dli_sname )
return Q_snprintf( buf, len, "%2d: %p <%s+%lu> (%s)\n", i, addr, dlinfo.dli_sname,
(unsigned long)addr - (unsigned long)dlinfo.dli_saddr, dlinfo.dli_fname ); // print symbol, module and address
(unsigned long)addr - (unsigned long)dlinfo.dli_saddr, dlinfo.dli_fname ); // print symbol, module and address
else
return Q_snprintf( buf, len, "%2d: %p (%s)\n", i, addr, dlinfo.dli_fname ); // print module and address
}
@ -281,10 +291,11 @@ int printframe( char *buf, int len, int i, void *addr )
struct sigaction oldFilter;
#define STACK_BACKTRACE_STR_LEN 17
#define STACK_BACKTRACE_STR "Stack backtrace:\n"
#define STACK_DUMP_STR_LEN 12
#define STACK_DUMP_STR "Stack dump:\n"
#define STACK_BACKTRACE_STR "Stack backtrace:\n"
#define STACK_DUMP_STR "Stack dump:\n"
#define STACK_BACKTRACE_STR_LEN (sizeof( STACK_BACKTRACE_STR ) - 1)
#define STACK_DUMP_STR_LEN (sizeof( STACK_DUMP_STR ) - 1)
#define ALIGN( x, y ) (((uintptr_t) (x) + ((y)-1)) & ~((y)-1))
static void Sys_Crash( int signal, siginfo_t *si, void *context)
@ -356,7 +367,7 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
len += Q_snprintf( message + len, sizeof( message ) - len, "Crash: signal %d errno %d with code %d at %p\n", signal, si->si_errno, si->si_code, si->si_addr );
#endif
write( 2, message, len );
write( STDERR_FILENO, message, len );
// flush buffers before writing directly to descriptors
fflush( stdout );
@ -370,9 +381,9 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
{
size_t pagesize = sysconf( _SC_PAGESIZE );
// try to print backtrace
write( 2, STACK_BACKTRACE_STR, STACK_BACKTRACE_STR_LEN );
write( STDERR_FILENO, STACK_BACKTRACE_STR, STACK_BACKTRACE_STR_LEN );
write( logfd, STACK_BACKTRACE_STR, STACK_BACKTRACE_STR_LEN );
strncpy( message + len, STACK_BACKTRACE_STR, sizeof( message ) - len );
Q_strncpy( message + len, STACK_BACKTRACE_STR, sizeof( message ) - len );
len += STACK_BACKTRACE_STR_LEN;
// false on success, true on failure
@ -384,8 +395,8 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
do
{
int line = printframe( message + len, sizeof( message ) - len, ++i, pc);
write( 2, message + len, line );
int line = Sys_PrintFrame( message + len, sizeof( message ) - len, ++i, pc);
write( STDERR_FILENO, message + len, line );
write( logfd, message + len, line );
len += line;
//if( !dladdr(bp,0) ) break; // only when bp is in module
@ -399,17 +410,17 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
while( bp && i < 128 );
// try to print stack
write( 2, STACK_DUMP_STR, STACK_DUMP_STR_LEN );
write( STDERR_FILENO, STACK_DUMP_STR, STACK_DUMP_STR_LEN );
write( logfd, STACK_DUMP_STR, STACK_DUMP_STR_LEN );
strncpy( message + len, STACK_DUMP_STR, sizeof( message ) - len );
Q_strncpy( message + len, STACK_DUMP_STR, sizeof( message ) - len );
len += STACK_DUMP_STR_LEN;
if( !try_allow_read( sp, pagesize ) )
{
for( i = 0; i < 32; i++ )
{
int line = printframe( message + len, sizeof( message ) - len, i, sp[i] );
write( 2, message + len, line );
int line = Sys_PrintFrame( message + len, sizeof( message ) - len, i, sp[i] );
write( STDERR_FILENO, message + len, line );
write( logfd, message + len, line );
len += line;
}

View File

@ -21,7 +21,7 @@ GNU General Public License for more details.
convar_t *cvar_vars = NULL; // head of list
convar_t *cmd_scripting;
CVAR_DEFINE_AUTO( cl_filterstuffcmd, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "filter commands coming from server" );
CVAR_DEFINE_AUTO( cl_filterstuffcmd, "0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "filter commands coming from server" );
/*
============

View File

@ -306,11 +306,6 @@ void SCR_CheckStartupVids( void )
}
void Sys_SetClipboardData( const char *text, size_t size )
{
}
void CL_StopPlayback( void )
{

View File

@ -1,200 +0,0 @@
/*
filesystem.h - engine FS
Copyright (C) 2007 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
/*
========================================================================
PAK FILES
The .pak files are just a linear collapse of a directory tree
========================================================================
*/
// header
#define IDPACKV1HEADER (('K'<<24)+('C'<<16)+('A'<<8)+'P') // little-endian "PACK"
#define MAX_FILES_IN_PACK 65536 // pak
typedef struct
{
int ident;
int dirofs;
int dirlen;
} dpackheader_t;
typedef struct
{
char name[56]; // total 64 bytes
int filepos;
int filelen;
} dpackfile_t;
/*
========================================================================
.WAD archive format (WhereAllData - WAD)
List of compressed files, that can be identify only by TYPE_*
<format>
header: dwadinfo_t[dwadinfo_t]
file_1: byte[dwadinfo_t[num]->disksize]
file_2: byte[dwadinfo_t[num]->disksize]
file_3: byte[dwadinfo_t[num]->disksize]
...
file_n: byte[dwadinfo_t[num]->disksize]
infotable dlumpinfo_t[dwadinfo_t->numlumps]
========================================================================
*/
#define WAD3_NAMELEN 16
#define HINT_NAMELEN 5 // e.g. _mask, _norm
#define MAX_FILES_IN_WAD 65535 // real limit as above <2Gb size not a lumpcount
#include "const.h"
typedef struct
{
int ident; // should be WAD3
int numlumps; // num files
int infotableofs; // LUT offset
} dwadinfo_t;
typedef struct
{
int filepos; // file offset in WAD
int disksize; // compressed or uncompressed
int size; // uncompressed
signed char type; // TYP_*
signed char attribs; // file attribs
signed char pad0;
signed char pad1;
char name[WAD3_NAMELEN]; // must be null terminated
} dlumpinfo_t;
#include "custom.h"
/*
========================================================================
.HPK archive format (Hash PAK - HPK)
List of compressed files, that can be identify only by TYPE_*
<format>
header: dwadinfo_t[dwadinfo_t]
file_1: byte[dwadinfo_t[num]->disksize]
file_2: byte[dwadinfo_t[num]->disksize]
file_3: byte[dwadinfo_t[num]->disksize]
...
file_n: byte[dwadinfo_t[num]->disksize]
infotable dlumpinfo_t[dwadinfo_t->numlumps]
========================================================================
*/
#define IDHPAKHEADER (('K'<<24)+('A'<<16)+('P'<<8)+'H') // little-endian "HPAK"
#define IDHPAK_VERSION 1
typedef struct
{
int ident; // should be equal HPAK
int version;
int infotableofs;
} hpak_header_t;
typedef struct
{
resource_t resource;
int filepos;
int disksize;
} hpak_lump_t;
typedef struct
{
int count;
hpak_lump_t *entries; // variable sized.
} hpak_info_t;
#define ZIP_HEADER_LF (('K'<<8)+('P')+(0x03<<16)+(0x04<<24))
#define ZIP_HEADER_SPANNED ((0x08<<24)+(0x07<<16)+('K'<<8)+'P')
#define ZIP_HEADER_CDF ((0x02<<24)+(0x01<<16)+('K'<<8)+'P')
#define ZIP_HEADER_EOCD ((0x06<<24)+(0x05<<16)+('K'<<8)+'P')
#define ZIP_COMPRESSION_NO_COMPRESSION 0
#define ZIP_COMPRESSION_DEFLATED 8
#define ZIP_ZIP64 0xffffffff
#pragma pack( push, 1 )
typedef struct zip_header_s
{
unsigned int signature; // little endian ZIP_HEADER
unsigned short version; // version of pkzip need to unpack
unsigned short flags; // flags (16 bits == 16 flags)
unsigned short compression_flags; // compression flags (bits)
unsigned int dos_date; // file modification time and file modification date
unsigned int crc32; //crc32
unsigned int compressed_size;
unsigned int uncompressed_size;
unsigned short filename_len;
unsigned short extrafield_len;
} zip_header_t;
/*
in zip64 comp and uncompr size == 0xffffffff remeber this
compressed and uncompress filesize stored in extra field
*/
typedef struct zip_header_extra_s
{
unsigned int signature; // ZIP_HEADER_SPANNED
unsigned int crc32;
unsigned int compressed_size;
unsigned int uncompressed_size;
} zip_header_extra_t;
typedef struct zip_cdf_header_s
{
unsigned int signature;
unsigned short version;
unsigned short version_need;
unsigned short generalPurposeBitFlag;
unsigned short flags;
unsigned short modification_time;
unsigned short modification_date;
unsigned int crc32;
unsigned int compressed_size;
unsigned int uncompressed_size;
unsigned short filename_len;
unsigned short extrafield_len;
unsigned short file_commentary_len;
unsigned short disk_start;
unsigned short internal_attr;
unsigned int external_attr;
unsigned int local_header_offset;
} zip_cdf_header_t;
typedef struct zip_header_eocd_s
{
unsigned short disk_number;
unsigned short start_disk_number;
unsigned short number_central_directory_record;
unsigned short total_central_directory_record;
unsigned int size_of_central_directory;
unsigned int central_directory_offset;
unsigned short commentary_len;
} zip_header_eocd_t;
#pragma pack( pop )
#endif//FILESYSTEM_H

View File

@ -0,0 +1,153 @@
/*
filesystem.c - game filesystem based on DP fs
Copyright (C) 2007 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "library.h"
fs_api_t g_fsapi;
fs_globals_t *FI;
static HINSTANCE fs_hInstance;
static void FS_Rescan_f( void )
{
FS_Rescan();
}
static void FS_ClearPaths_f( void )
{
FS_ClearSearchPath();
}
static void FS_Path_f_( void )
{
FS_Path_f();
}
static fs_interface_t fs_memfuncs =
{
Con_Printf,
Con_DPrintf,
Con_Reportf,
Sys_Error,
_Mem_AllocPool,
_Mem_FreePool,
_Mem_Alloc,
_Mem_Realloc,
_Mem_Free,
};
static void FS_UnloadProgs( void )
{
COM_FreeLibrary( fs_hInstance );
fs_hInstance = 0;
}
#ifdef XASH_INTERNAL_GAMELIBS
#define FILESYSTEM_STDIO_DLL "filesystem_stdio"
#else
#define FILESYSTEM_STDIO_DLL "filesystem_stdio." OS_LIB_EXT
#endif
qboolean FS_LoadProgs( void )
{
const char *name = FILESYSTEM_STDIO_DLL;
FSAPI GetFSAPI;
fs_hInstance = COM_LoadLibrary( name, false, true );
if( !fs_hInstance )
{
Host_Error( "FS_LoadProgs: can't load filesystem library %s: %s\n", name, COM_GetLibraryError() );
return false;
}
if( !( GetFSAPI = (FSAPI)COM_GetProcAddress( fs_hInstance, GET_FS_API )))
{
FS_UnloadProgs();
Host_Error( "FS_LoadProgs: can't find GetFSAPI entry point in %s\n", name );
return false;
}
if( !GetFSAPI( FS_API_VERSION, &g_fsapi, &FI, &fs_memfuncs ))
{
FS_UnloadProgs();
Host_Error( "FS_LoadProgs: can't initialize filesystem API: wrong version\n" );
return false;
}
Con_DPrintf( "FS_LoadProgs: filesystem_stdio successfully loaded\n" );
return true;
}
/*
================
FS_Init
================
*/
void FS_Init( void )
{
qboolean hasBaseDir = false;
qboolean hasGameDir = false;
qboolean caseinsensitive = true;
int i;
string gamedir;
Cmd_AddRestrictedCommand( "fs_rescan", FS_Rescan_f, "rescan filesystem search pathes" );
Cmd_AddRestrictedCommand( "fs_path", FS_Path_f_, "show filesystem search pathes" );
Cmd_AddRestrictedCommand( "fs_clearpaths", FS_ClearPaths_f, "clear filesystem search pathes" );
#if !XASH_WIN32
if( Sys_CheckParm( "-casesensitive" ) )
caseinsensitive = false;
#endif
if( !Sys_GetParmFromCmdLine( "-game", gamedir ))
Q_strncpy( gamedir, SI.basedirName, sizeof( gamedir )); // gamedir == basedir
if( !FS_InitStdio( caseinsensitive, host.rootdir, SI.basedirName, gamedir, host.rodir ))
{
Host_Error( "Can't init filesystem_stdio!\n" );
return;
}
if( !Sys_GetParmFromCmdLine( "-dll", SI.gamedll ))
SI.gamedll[0] = 0;
if( !Sys_GetParmFromCmdLine( "-clientlib", SI.clientlib ))
SI.clientlib[0] = 0;
}
/*
================
FS_Shutdown
================
*/
void FS_Shutdown( void )
{
int i;
FS_ShutdownStdio();
memset( &SI, 0, sizeof( sysinfo_t ));
FS_UnloadProgs();
}

View File

@ -51,6 +51,7 @@ struct tests_stats_s tests_stats;
#endif
CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" );
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_CHEAT|FCVAR_FILTERABLE, "scale frame time" );
CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" );
convar_t *host_serverstate;
@ -85,9 +86,11 @@ void Sys_PrintUsage( void )
O("-dev [level] ","set log verbosity 0-2")
O("-log ","write log to \"engine.log\"")
O("-nowriteconfig ","disable config save")
#if !XASH_WIN32
O("-casesensitive ","disable case-insensitive FS emulation")
#endif // !XASH_WIN32
#if !XASH_MOBILE_PLATFORM
O("-daemonize ","run engine in background, dedicated only")
#endif // !XASH_MOBILE_PLATFORM
@ -98,53 +101,53 @@ void Sys_PrintUsage( void )
O("-height <n> ","set window height")
O("-oldfont ","enable unused Quake font in Half-Life")
#if !XASH_MOBILE_PLATFORM
#if !XASH_MOBILE_PLATFORM
O("-fullscreen ","run engine in fullscreen mode")
O("-windowed ","run engine in windowed mode")
O("-dedicated ","run engine in dedicated server mode")
#endif // XASH_MOBILE_PLATFORM
#endif // XASH_MOBILE_PLATFORM
#if XASH_ANDROID
O("-nativeegl ","use native egl implementation. Use if screen does not update or black")
#endif // XASH_ANDROID
#if XASH_ANDROID
O("-nativeegl ","use native egl implementation. Use if screen does not update or black")
#endif // XASH_ANDROID
#if XASH_WIN32
O("-noavi ","disable AVI support")
O("-nointro ","disable intro video")
#endif // XASH_WIN32
#if XASH_WIN32
O("-noavi ","disable AVI support")
O("-nointro ","disable intro video")
#endif // XASH_WIN32
#if XASH_DOS
#if XASH_DOS
O("-novesa ","disable vesa")
#endif // XASH_DOS
#endif // XASH_DOS
#if XASH_VIDEO == VIDEO_FBDEV
#if XASH_VIDEO == VIDEO_FBDEV
O("-fbdev <path> ","open selected framebuffer")
O("-ttygfx ","set graphics mode in tty")
O("-doublebuffer ","enable doublebuffering")
#endif // XASH_VIDEO == VIDEO_FBDEV
#endif // XASH_VIDEO == VIDEO_FBDEV
#if XASH_SOUND == SOUND_ALSA
#if XASH_SOUND == SOUND_ALSA
O("-alsadev <dev> ","open selected ALSA device")
#endif // XASH_SOUND == SOUND_ALSA
#endif // XASH_SOUND == SOUND_ALSA
O("-nojoy ","disable joystick support")
#ifdef XASH_SDL
#ifdef XASH_SDL
O("-sdl_joy_old_api ","use SDL legacy joystick API")
O("-sdl_renderer <n>","use alternative SDL_Renderer for software")
#endif // XASH_SDL
#endif // XASH_SDL
O("-nosound ","disable sound")
O("-noenginemouse ","disable mouse completely")
O("-ref <name> ","use selected renderer dll")
O("-gldebug ","enable OpenGL debug log")
O("-gldebug ","enable OpenGL debug log")
#endif // XASH_DEDICATED
O("-noip ","disable TCP/IP")
O("-noch ","disable crashhandler")
O("-disablehelp ","disable this message")
O("-dll <path> ","override server DLL path")
#ifndef XASH_DEDICATED
#if !XASH_DEDICATED
O("-clientlib <path>","override client DLL path")
#endif
O("-rodir <path> ","set read-only base directory, experimental")
@ -302,7 +305,9 @@ void Host_NewInstance( const char *name, const char *finalmsg )
host.change_game = true;
Q_strncpy( host.finalmsg, finalmsg, sizeof( host.finalmsg ));
pChangeGame( name ); // call from hl.exe
if( !Sys_NewInstance( name ))
pChangeGame( name ); // call from hl.exe
}
/*
@ -323,13 +328,13 @@ void Host_ChangeGame_f( void )
}
// validate gamedir
for( i = 0; i < SI.numgames; i++ )
for( i = 0; i < FI->numgames; i++ )
{
if( !Q_stricmp( SI.games[i]->gamefolder, Cmd_Argv( 1 )))
if( !Q_stricmp( FI->games[i]->gamefolder, Cmd_Argv( 1 )))
break;
}
if( i == SI.numgames )
if( i == FI->numgames )
{
Con_Printf( "%s not exist\n", Cmd_Argv( 1 ));
}
@ -340,7 +345,7 @@ void Host_ChangeGame_f( void )
else
{
const char *arg1 = va( "%s%s", (host.type == HOST_NORMAL) ? "" : "#", Cmd_Argv( 1 ));
const char *arg2 = va( "change game to '%s'", SI.games[i]->title );
const char *arg2 = va( "change game to '%s'", FI->games[i]->title );
Host_NewInstance( arg1, arg2 );
}
@ -626,8 +631,9 @@ qboolean Host_FilterTime( float time )
{
static double oldtime;
double fps;
double scale = sys_timescale.value;
host.realtime += time;
host.realtime += time * scale;
fps = Host_CalcFPS( );
// clamp the fps in multiplayer games
@ -638,12 +644,12 @@ qboolean Host_FilterTime( float time )
if( Host_IsDedicated() )
{
if(( host.realtime - oldtime ) < ( 1.0 / ( fps + 1.0 )))
if(( host.realtime - oldtime ) < ( 1.0 / ( fps + 1.0 )) * scale)
return false;
}
else
{
if(( host.realtime - oldtime ) < ( 1.0 / fps ))
if(( host.realtime - oldtime ) < ( 1.0 / fps ) * scale )
return false;
}
}
@ -654,7 +660,7 @@ qboolean Host_FilterTime( float time )
// NOTE: allow only in singleplayer while demos are not active
if( host_framerate->value > 0.0f && Host_IsLocalGame() && !CL_IsPlaybackDemo() && !CL_IsRecordDemo( ))
host.frametime = bound( MIN_FRAMETIME, host_framerate->value, MAX_FRAMETIME );
host.frametime = bound( MIN_FRAMETIME, host_framerate->value * scale, MAX_FRAMETIME );
else host.frametime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
return true;
@ -717,7 +723,6 @@ void GAME_EXPORT Host_Error( const char *error, ... )
else if( host.framecount == host.errorframe )
{
Sys_Error( "Host_MultiError: %s", hosterror2 );
return;
}
else
{
@ -737,7 +742,6 @@ void GAME_EXPORT Host_Error( const char *error, ... )
{
Con_Printf( "Host_RecursiveError: %s", hosterror2 );
Sys_Error( "%s", hosterror1 );
return; // don't multiple executes
}
recursive = true;
@ -820,9 +824,15 @@ static void Host_RunTests( int stage )
Test_RunCommon();
Test_RunCmd();
Test_RunCvar();
#if !XASH_DEDICATED
Test_RunCon();
#endif /* XASH_DEDICATED */
break;
case 1: // after FS load
Test_RunImagelib();
#if !XASH_DEDICATED
Test_RunVOX();
#endif
Msg( "Done! %d passed, %d failed\n", tests_stats.passed, tests_stats.failed );
Sys_Quit();
}
@ -860,7 +870,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
host.enabledll = !Sys_CheckParm( "-nodll" );
host.change_game = bChangeGame;
host.change_game = bChangeGame || Sys_CheckParm( "-changegame" );
host.config_executed = false;
host.status = HOST_INIT; // initialzation started
@ -998,7 +1008,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
len = Q_strlen( host.rootdir );
if( host.rootdir[len - 1] == '/' )
if( len && host.rootdir[len - 1] == '/' )
host.rootdir[len - 1] = 0;
// get readonly root. The order is: check for arg, then env.
@ -1017,18 +1027,27 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
if( len && host.rodir[len - 1] == '/' )
host.rodir[len - 1] = 0;
if( !COM_CheckStringEmpty( host.rootdir ) || FS_SetCurrentDirectory( host.rootdir ) != 0 )
if( !COM_CheckStringEmpty( host.rootdir ))
{
Sys_Error( "Changing working directory failed (empty working directory)\n" );
return;
}
FS_LoadProgs();
if( FS_SetCurrentDirectory( host.rootdir ) != 0 )
Con_Reportf( "%s is working directory now\n", host.rootdir );
else
Sys_Error( "Changing working directory to %s failed.\n", host.rootdir );
FS_Init();
Sys_InitLog();
Cmd_AddCommand( "exec", Host_Exec_f, "execute a script file" );
Cmd_AddCommand( "memlist", Host_MemStats_f, "prints memory pool information" );
Cmd_AddRestrictedCommand( "userconfigd", Host_Userconfigd_f, "execute all scripts from userconfig.d" );
FS_Init();
Image_Init();
Sound_Init();
@ -1038,8 +1057,16 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
#endif
FS_LoadGameInfo( NULL );
if( FS_FileExists( va( "%s.rc", SI.basedirName ), false ))
Q_strncpy( SI.rcName, SI.basedirName, sizeof( SI.rcName )); // e.g. valve.rc
else Q_strncpy( SI.rcName, SI.exeName, sizeof( SI.rcName )); // e.g. quake.rc
Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder ));
Image_CheckPaletteQ1 ();
Host_InitDecals (); // reload decals
// DEPRECATED: by FWGS fork
#if 0
if( GI->secure )
@ -1095,10 +1122,12 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
host_clientloaded = Cvar_Get( "host_clientloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" );
host_limitlocal = Cvar_Get( "host_limitlocal", "0", 0, "apply cl_cmdrate and rate to loopback connection" );
con_gamemaps = Cvar_Get( "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" );
Cvar_RegisterVariable( &sys_timescale );
build = Cvar_Get( "buildnum", va( "%i", Q_buildnum_compat()), FCVAR_READ_ONLY, "returns a current build number" );
ver = Cvar_Get( "ver", va( "%i/%s (hw build %i)", PROTOCOL_VERSION, XASH_COMPAT_VERSION, Q_buildnum_compat()), FCVAR_READ_ONLY, "shows an engine version" );
Cvar_Get( "host_ver", va( "%i %s %s %s %s", Q_buildnum(), XASH_VERSION, Q_buildos(), Q_buildarch(), Q_buildcommit() ), FCVAR_READ_ONLY, "detailed info about this build" );
Cvar_Get( "host_lowmemorymode", va( "%i", XASH_LOW_MEMORY ), FCVAR_READ_ONLY, "indicates if engine compiled for low RAM consumption (0 - normal, 1 - low engine limits, 2 - low protocol limits)" );
Mod_Init();
NET_Init();

View File

@ -14,7 +14,7 @@ GNU General Public License for more details.
*/
#include "common.h"
#include "filesystem.h"
#include "hpak.h"
#define HPAK_MAX_ENTRIES 0x8000
#define HPAK_MIN_SIZE (1 * 1024)
@ -402,7 +402,7 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet )
FS_Seek( f, hdr.infotableofs, SEEK_SET );
FS_Read( f, &num_lumps, sizeof( num_lumps ));
if( num_lumps < 1 || num_lumps > MAX_FILES_IN_WAD )
if( num_lumps < 1 || num_lumps > HPAK_MAX_ENTRIES )
{
Con_DPrintf( S_ERROR "HPAK_ValidatePak: %s has too many lumps %u.\n", pakname, num_lumps );
FS_Close( f );

60
engine/common/hpak.h Normal file
View File

@ -0,0 +1,60 @@
/*
hpak.c - custom user package to send other clients
Copyright (C) 2010 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef HPAK_H
#define HPAK_H
#include "custom.h"
/*
========================================================================
.HPK archive format (Hash PAK - HPK)
List of compressed files, that can be identify only by TYPE_*
<format>
header: dwadinfo_t[dwadinfo_t]
file_1: byte[dwadinfo_t[num]->disksize]
file_2: byte[dwadinfo_t[num]->disksize]
file_3: byte[dwadinfo_t[num]->disksize]
...
file_n: byte[dwadinfo_t[num]->disksize]
infotable dlumpinfo_t[dwadinfo_t->numlumps]
========================================================================
*/
#define IDHPAKHEADER (('K'<<24)+('A'<<16)+('P'<<8)+'H') // little-endian "HPAK"
#define IDHPAK_VERSION 1
typedef struct
{
int ident; // should be equal HPAK
int version;
int infotableofs;
} hpak_header_t;
typedef struct
{
resource_t resource;
int filepos;
int disksize;
} hpak_lump_t;
typedef struct
{
int count;
hpak_lump_t *entries; // variable sized.
} hpak_info_t;
#endif // HPAK_H

View File

@ -41,7 +41,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
buf_p = (byte *)buffer;
memcpy( &bhdr, buf_p, sizeof( bmp_t ));
buf_p += sizeof( bmp_t );
buf_p += BI_FILE_HEADER_SIZE + bhdr.bitmapHeaderSize;
// bogus file header check
if( bhdr.reserved0 != 0 ) return false;
@ -53,9 +53,9 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
return false;
}
if( bhdr.bitmapHeaderSize != 0x28 )
if(!( bhdr.bitmapHeaderSize == 40 || bhdr.bitmapHeaderSize == 108 || bhdr.bitmapHeaderSize == 124 ))
{
Con_DPrintf( S_ERROR "Image_LoadBMP: invalid header size %i\n", bhdr.bitmapHeaderSize );
Con_DPrintf( S_ERROR "Image_LoadBMP: %s have non-standard header size %i\n", name, bhdr.bitmapHeaderSize );
return false;
}
@ -187,6 +187,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
return false;
}
image.depth = 1;
image.size = image.width * image.height * bpp;
image.rgba = Mem_Malloc( host.imagepool, image.size );
@ -313,8 +314,8 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
}
VectorDivide( reflectivity, ( image.width * image.height ), image.fogParams );
if( image.palette ) Image_GetPaletteBMP( image.palette );
image.depth = 1;
if( image.palette )
Image_GetPaletteBMP( image.palette );
return true;
}

View File

@ -22,6 +22,7 @@ GNU General Public License for more details.
========================================================================
*/
#define BI_FILE_HEADER_SIZE 14
#define BI_SIZE 40 // size of bitmap info header.
#if !defined(BI_RGB)
#define BI_RGB 0 // uncompressed RGB bitmap(defined in wingdi.h)

View File

@ -91,7 +91,7 @@ qboolean Image_CheckDXT5Alpha( dds_t *hdr, byte *fin )
return false;
}
void Image_DXTGetPixelFormat( dds_t *hdr )
void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
{
uint bits = hdr->dsPixelFormat.dwRGBBitCount;
@ -100,29 +100,53 @@ void Image_DXTGetPixelFormat( dds_t *hdr )
if( FBitSet( hdr->dsPixelFormat.dwFlags, DDS_FOURCC ))
{
switch( hdr->dsPixelFormat.dwFourCC )
if( hdr->dsPixelFormat.dwFourCC == TYPE_DX10 )
{
case TYPE_DXT1:
image.type = PF_DXT1;
break;
case TYPE_DXT2:
image.flags &= ~IMAGE_HAS_ALPHA; // alpha is already premultiplied by color
// intentionally fallthrough
case TYPE_DXT3:
image.type = PF_DXT3;
break;
case TYPE_DXT4:
image.flags &= ~IMAGE_HAS_ALPHA; // alpha is already premultiplied by color
// intentionally fallthrough
case TYPE_DXT5:
image.type = PF_DXT5;
break;
case TYPE_ATI2:
image.type = PF_ATI2;
break;
default:
image.type = PF_UNKNOWN; // assume error
break;
switch( headerExt->dxgiFormat )
{
case DXGI_FORMAT_BC6H_SF16:
image.type = PF_BC6H_SIGNED;
break;
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_TYPELESS:
image.type = PF_BC6H_UNSIGNED;
break;
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
case DXGI_FORMAT_BC7_TYPELESS:
image.type = PF_BC7;
break;
default:
image.type = PF_UNKNOWN;
break;
}
}
else
{
switch( hdr->dsPixelFormat.dwFourCC )
{
case TYPE_DXT1:
image.type = PF_DXT1;
break;
case TYPE_DXT2:
image.flags &= ~IMAGE_HAS_ALPHA; // alpha is already premultiplied by color
// intentionally fallthrough
case TYPE_DXT3:
image.type = PF_DXT3;
break;
case TYPE_DXT4:
image.flags &= ~IMAGE_HAS_ALPHA; // alpha is already premultiplied by color
// intentionally fallthrough
case TYPE_DXT5:
image.type = PF_DXT5;
break;
case TYPE_ATI2:
image.type = PF_ATI2;
break;
default:
image.type = PF_UNKNOWN; // assume error
break;
}
}
}
else
@ -171,6 +195,9 @@ size_t Image_DXTGetLinearSize( int type, int width, int height, int depth )
case PF_DXT1: return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 8 );
case PF_DXT3:
case PF_DXT5:
case PF_BC6H_SIGNED:
case PF_BC6H_UNSIGNED:
case PF_BC7:
case PF_ATI2: return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 16 );
case PF_LUMINANCE: return (width * height * depth);
case PF_BGR_24:
@ -254,16 +281,18 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
{
dds_t header;
byte *fin;
int headersOffset;
dds_header_dxt10_t header2;
if( filesize < sizeof( dds_t ))
if( filesize < sizeof( header ))
return false;
memcpy( &header, buffer, sizeof( dds_t ));
memcpy( &header, buffer, sizeof( header ));
if( header.dwIdent != DDSHEADER )
return false; // it's not a dds file, just skip it
if( header.dwSize != sizeof( dds_t ) - sizeof( uint )) // size of the structure (minus MagicNum)
if( header.dwSize != sizeof( header ) - sizeof( uint )) // size of the structure (minus MagicNum)
{
Con_DPrintf( S_ERROR "Image_LoadDDS: (%s) have corrupted header\n", name );
return false;
@ -275,6 +304,13 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
return false;
}
headersOffset = sizeof( header );
if( header.dsPixelFormat.dwFourCC == TYPE_DX10 )
{
memcpy( &header2, buffer + sizeof( header ), sizeof( header2 ));
headersOffset += sizeof( header2 );
}
image.width = header.dwWidth;
image.height = header.dwHeight;
@ -284,7 +320,7 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
if( !Image_ValidSize( name )) return false;
Image_DXTGetPixelFormat( &header ); // and image type too :)
Image_DXTGetPixelFormat( &header, &header2 ); // and image type too :)
Image_DXTAdjustVolume( &header );
if( !Image_CheckFlag( IL_DDS_HARDWARE ) && ImageDXT( image.type ))
@ -296,9 +332,9 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
return false;
}
image.size = Image_DXTCalcSize( name, &header, filesize - 128 );
image.size = Image_DXTCalcSize( name, &header, filesize - headersOffset );
if( image.size == 0 ) return false; // just in case
fin = (byte *)(buffer + sizeof( dds_t ));
fin = (byte *)( buffer + headersOffset );
// copy an encode method
image.encode = (word)header.dwReserved1[0];
@ -320,6 +356,8 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
SetBits( image.flags, IMAGE_HAS_ALPHA );
else if( image.type == PF_DXT5 && Image_CheckDXT5Alpha( &header, fin ))
SetBits( image.flags, IMAGE_HAS_ALPHA );
else if ( image.type == PF_BC7 )
SetBits(image.flags, IMAGE_HAS_ALPHA);
if( !FBitSet( header.dsPixelFormat.dwFlags, DDS_LUMINANCE ))
SetBits( image.flags, IMAGE_HAS_COLOR );
break;

View File

@ -29,6 +29,7 @@ GNU General Public License for more details.
#define TYPE_DXT3 (('3'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT3"
#define TYPE_DXT4 (('4'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT4"
#define TYPE_DXT5 (('5'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT5"
#define TYPE_DX10 (('0'<<24)+('1'<<16)+('X'<<8)+'D') // little-endian "DX10"
#define TYPE_ATI1 (('1'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI1"
#define TYPE_ATI2 (('2'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI2"
#define TYPE_RXGB (('B'<<24)+('G'<<16)+('X'<<8)+'R') // little-endian "RXGB" doom3 normalmaps
@ -75,6 +76,141 @@ GNU General Public License for more details.
#define DDS_CUBEMAP_ALL_SIDES 0x0000FC00L
#define DDS_VOLUME 0x00200000L
typedef enum
{
DXGI_FORMAT_UNKNOWN = 0,
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
DXGI_FORMAT_R32G32B32A32_UINT = 3,
DXGI_FORMAT_R32G32B32A32_SINT = 4,
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
DXGI_FORMAT_R32G32B32_FLOAT = 6,
DXGI_FORMAT_R32G32B32_UINT = 7,
DXGI_FORMAT_R32G32B32_SINT = 8,
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
DXGI_FORMAT_R16G16B16A16_UINT = 12,
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
DXGI_FORMAT_R16G16B16A16_SINT = 14,
DXGI_FORMAT_R32G32_TYPELESS = 15,
DXGI_FORMAT_R32G32_FLOAT = 16,
DXGI_FORMAT_R32G32_UINT = 17,
DXGI_FORMAT_R32G32_SINT = 18,
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
DXGI_FORMAT_R10G10B10A2_UINT = 25,
DXGI_FORMAT_R11G11B10_FLOAT = 26,
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
DXGI_FORMAT_R8G8B8A8_UINT = 30,
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
DXGI_FORMAT_R8G8B8A8_SINT = 32,
DXGI_FORMAT_R16G16_TYPELESS = 33,
DXGI_FORMAT_R16G16_FLOAT = 34,
DXGI_FORMAT_R16G16_UNORM = 35,
DXGI_FORMAT_R16G16_UINT = 36,
DXGI_FORMAT_R16G16_SNORM = 37,
DXGI_FORMAT_R16G16_SINT = 38,
DXGI_FORMAT_R32_TYPELESS = 39,
DXGI_FORMAT_D32_FLOAT = 40,
DXGI_FORMAT_R32_FLOAT = 41,
DXGI_FORMAT_R32_UINT = 42,
DXGI_FORMAT_R32_SINT = 43,
DXGI_FORMAT_R24G8_TYPELESS = 44,
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
DXGI_FORMAT_R8G8_TYPELESS = 48,
DXGI_FORMAT_R8G8_UNORM = 49,
DXGI_FORMAT_R8G8_UINT = 50,
DXGI_FORMAT_R8G8_SNORM = 51,
DXGI_FORMAT_R8G8_SINT = 52,
DXGI_FORMAT_R16_TYPELESS = 53,
DXGI_FORMAT_R16_FLOAT = 54,
DXGI_FORMAT_D16_UNORM = 55,
DXGI_FORMAT_R16_UNORM = 56,
DXGI_FORMAT_R16_UINT = 57,
DXGI_FORMAT_R16_SNORM = 58,
DXGI_FORMAT_R16_SINT = 59,
DXGI_FORMAT_R8_TYPELESS = 60,
DXGI_FORMAT_R8_UNORM = 61,
DXGI_FORMAT_R8_UINT = 62,
DXGI_FORMAT_R8_SNORM = 63,
DXGI_FORMAT_R8_SINT = 64,
DXGI_FORMAT_A8_UNORM = 65,
DXGI_FORMAT_R1_UNORM = 66,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
DXGI_FORMAT_BC1_TYPELESS = 70,
DXGI_FORMAT_BC1_UNORM = 71,
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
DXGI_FORMAT_BC2_TYPELESS = 73,
DXGI_FORMAT_BC2_UNORM = 74,
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
DXGI_FORMAT_BC3_TYPELESS = 76,
DXGI_FORMAT_BC3_UNORM = 77,
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
DXGI_FORMAT_BC4_TYPELESS = 79,
DXGI_FORMAT_BC4_UNORM = 80,
DXGI_FORMAT_BC4_SNORM = 81,
DXGI_FORMAT_BC5_TYPELESS = 82,
DXGI_FORMAT_BC5_UNORM = 83,
DXGI_FORMAT_BC5_SNORM = 84,
DXGI_FORMAT_B5G6R5_UNORM = 85,
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
DXGI_FORMAT_BC6H_TYPELESS = 94,
DXGI_FORMAT_BC6H_UF16 = 95,
DXGI_FORMAT_BC6H_SF16 = 96,
DXGI_FORMAT_BC7_TYPELESS = 97,
DXGI_FORMAT_BC7_UNORM = 98,
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
DXGI_FORMAT_AYUV = 100,
DXGI_FORMAT_Y410 = 101,
DXGI_FORMAT_Y416 = 102,
DXGI_FORMAT_NV12 = 103,
DXGI_FORMAT_P010 = 104,
DXGI_FORMAT_P016 = 105,
DXGI_FORMAT_420_OPAQUE = 106,
DXGI_FORMAT_YUY2 = 107,
DXGI_FORMAT_Y210 = 108,
DXGI_FORMAT_Y216 = 109,
DXGI_FORMAT_NV11 = 110,
DXGI_FORMAT_AI44 = 111,
DXGI_FORMAT_IA44 = 112,
DXGI_FORMAT_P8 = 113,
DXGI_FORMAT_A8P8 = 114,
DXGI_FORMAT_B4G4R4A4_UNORM = 115,
DXGI_FORMAT_P208 = 130,
DXGI_FORMAT_V208 = 131,
DXGI_FORMAT_V408 = 132,
DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE,
DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE,
DXGI_FORMAT_FORCE_UINT = 0xffffffff
} dxgi_format_t;
typedef enum
{
D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
D3D10_RESOURCE_DIMENSION_BUFFER = 1,
D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2,
D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3,
D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4
} dds_resource_dimension_t;
typedef struct dds_pf_s
{
uint32_t dwSize;
@ -96,6 +232,15 @@ typedef struct dds_caps_s
uint32_t dwCaps4; // currently unused
} dds_caps_t;
typedef struct dds_header_dxt10_s
{
dxgi_format_t dxgiFormat;
dds_resource_dimension_t resourceDimension;
uint32_t miscFlag;
uint32_t arraySize;
uint32_t miscFlags2;
} dds_header_dxt10_t;
typedef struct dds_s
{
uint32_t dwIdent; // must matched with DDSHEADER

View File

@ -566,4 +566,25 @@ void Test_RunImagelib( void )
Z_Free( rgb.buffer );
}
#define IMPLEMENT_IMAGELIB_FUZZ_TARGET( export, target ) \
int EXPORT export( const uint8_t *Data, size_t Size ) \
{ \
rgbdata_t *rgb; \
host.type = HOST_NORMAL; \
Memory_Init(); \
Image_Init(); \
if( target( "#internal", Data, Size )) \
{ \
rgb = ImagePack(); \
FS_FreeImage( rgb ); \
} \
Image_Shutdown(); \
return 0; \
} \
IMPLEMENT_IMAGELIB_FUZZ_TARGET( Fuzz_Image_LoadBMP, Image_LoadBMP )
IMPLEMENT_IMAGELIB_FUZZ_TARGET( Fuzz_Image_LoadPNG, Image_LoadPNG )
IMPLEMENT_IMAGELIB_FUZZ_TARGET( Fuzz_Image_LoadDDS, Image_LoadDDS )
IMPLEMENT_IMAGELIB_FUZZ_TARGET( Fuzz_Image_LoadTGA, Image_LoadTGA )
#endif /* XASH_ENGINE_TESTS */

View File

@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#define MINIZ_HEADER_FILE_ONLY
#include "miniz.h"
#include "imagelib.h"
#include "xash3d_mathlib.h"

View File

@ -96,8 +96,8 @@ static const loadpixformat_t load_null[] =
static const loadpixformat_t load_game[] =
{
{ "%s%s.%s", "dds", Image_LoadDDS, IL_HINT_NO }, // dds for world and studio models
{ "%s%s.%s", "tga", Image_LoadTGA, IL_HINT_NO }, // hl vgui menus
{ "%s%s.%s", "bmp", Image_LoadBMP, IL_HINT_NO }, // WON menu images
{ "%s%s.%s", "tga", Image_LoadTGA, IL_HINT_NO }, // hl vgui menus
{ "%s%s.%s", "png", Image_LoadPNG, IL_HINT_NO }, // NightFire 007 menus
{ "%s%s.%s", "mip", Image_LoadMIP, IL_HINT_NO }, // hl textures from wad or buffer
{ "%s%s.%s", "mdl", Image_LoadMDL, IL_HINT_HL }, // hl studio model skins
@ -456,8 +456,8 @@ void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int
g = palSrc[i*pal_size+1];
b = palSrc[i*pal_size+2];
maxcol = max( max( r, g ), b ) / 255.0f;
mincol = min( min( r, g ), b ) / 255.0f;
maxcol = Q_max( Q_max( r, g ), b ) / 255.0f;
mincol = Q_min( Q_min( r, g ), b ) / 255.0f;
if( maxcol == 0 ) continue;

View File

@ -23,66 +23,42 @@ GNU General Public License for more details.
#if XASH_EMSCRIPTEN
#include <emscripten.h>
#endif
#if XASH_WIN32
#define XASH_NOCONHOST 1
#endif
static char szGameDir[128]; // safe place to keep gamedir
static int g_iArgc;
static char **g_pszArgv;
void Launcher_ChangeGame( const char *progname )
#elif XASH_WIN32
extern "C"
{
// Enable NVIDIA High Performance Graphics while using Integrated Graphics.
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
// Enable AMD High Performance Graphics while using Integrated Graphics.
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
#define E_GAME "XASH3D_GAME" // default env dir to start from
#define GAME_PATH "valve" // default dir to start from
static char szGameDir[128]; // safe place to keep gamedir
static int szArgc;
static char **szArgv;
static void Sys_ChangeGame( const char *progname )
{
// a1ba: may never be called within engine
// if platform supports execv() function
Q_strncpy( szGameDir, progname, sizeof( szGameDir ) - 1 );
Host_Shutdown( );
exit( Host_Main( g_iArgc, g_pszArgv, szGameDir, 1, &Launcher_ChangeGame ) );
exit( Host_Main( szArgc, szArgv, szGameDir, 1, &Sys_ChangeGame ) );
}
#if XASH_NOCONHOST
#include <windows.h>
#include <shellapi.h> // CommandLineToArgvW
int __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdLine, int nShow)
_inline int Sys_Start( void )
{
int szArgc;
char **szArgv;
LPWSTR* lpArgv = CommandLineToArgvW(GetCommandLineW(), &szArgc);
int i = 0;
int ret;
const char *game = getenv( E_GAME );
szArgv = (char**)malloc(szArgc*sizeof(char*));
for (; i < szArgc; ++i)
{
size_t size = wcslen(lpArgv[i]) + 1;
szArgv[i] = (char*)malloc(size);
wcstombs(szArgv[i], lpArgv[i], size);
}
szArgv[i] = NULL;
LocalFree(lpArgv);
main( szArgc, szArgv );
for( i = 0; i < szArgc; ++i )
free( szArgv[i] );
free( szArgv );
}
#endif
int main( int argc, char** argv )
{
char gamedir_buf[32] = "";
const char *gamedir = getenv( "XASH3D_GAMEDIR" );
if( !COM_CheckString( gamedir ) )
{
gamedir = "valve";
}
else
{
Q_strncpy( gamedir_buf, gamedir, 32 );
gamedir = gamedir_buf;
}
if( !game )
game = GAME_PATH;
Q_strncpy( szGameDir, game, sizeof( szGameDir ));
#if XASH_EMSCRIPTEN
#ifdef EMSCRIPTEN_LIB_FS
// For some unknown reason emscripten refusing to load libraries later
@ -98,17 +74,56 @@ int main( int argc, char** argv )
FS.chdir('/xash');
}catch(e){};);
#endif
#endif
g_iArgc = argc;
g_pszArgv = argv;
#if XASH_IOS
#elif XASH_IOS
{
void IOS_LaunchDialog( void );
IOS_LaunchDialog();
}
#endif
return Host_Main( g_iArgc, g_pszArgv, gamedir, 0, &Launcher_ChangeGame );
ret = Host_Main( szArgc, szArgv, game, 0, Sys_ChangeGame );
return ret;
}
#if !XASH_WIN32
int main( int argc, char **argv )
{
szArgc = argc;
szArgv = argv;
return Sys_Start();
}
#else
int __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdLine, int nShow)
{
LPWSTR* lpArgv;
int ret, i;
lpArgv = CommandLineToArgvW( GetCommandLineW(), &szArgc );
szArgv = ( char** )malloc( (szArgc + 1) * sizeof( char* ));
for( i = 0; i < szArgc; ++i )
{
size_t size = wcslen(lpArgv[i]) + 1;
// just in case, allocate some more memory
szArgv[i] = ( char * )malloc( size * sizeof( wchar_t ));
wcstombs( szArgv[i], lpArgv[i], size );
}
szArgv[szArgc] = 0;
LocalFree( lpArgv );
ret = Sys_Start();
for( ; i < szArgc; ++i )
free( szArgv[i] );
free( szArgv );
return ret;
}
#endif // XASH_WIN32
#endif

View File

@ -86,6 +86,38 @@ const char *COM_OffsetNameForFunction( void *function )
return sname;
}
dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath )
{
dll_user_t *p;
fs_dllinfo_t dllInfo;
// no fs loaded yet, but let engine find fs
if( !g_fsapi.FindLibrary )
{
p = Mem_Calloc( host.mempool, sizeof( dll_user_t ));
Q_strncpy( p->shortPath, dllname, sizeof( p->shortPath ));
Q_strncpy( p->fullPath, dllname, sizeof( p->fullPath ));
Q_strncpy( p->dllName, dllname, sizeof( p->dllName ));
return p;
}
// fs can't find library
if( !g_fsapi.FindLibrary( dllname, directpath, &dllInfo ))
return NULL;
// NOTE: for libraries we not fail even if search is NULL
// let the OS find library himself
p = Mem_Calloc( host.mempool, sizeof( dll_user_t ));
Q_strncpy( p->shortPath, dllInfo.shortPath, sizeof( p->shortPath ));
Q_strncpy( p->fullPath, dllInfo.fullPath, sizeof( p->fullPath ));
Q_strncpy( p->dllName, dllname, sizeof( p->dllName ));
p->custom_loader = dllInfo.custom_loader;
p->encrypted = dllInfo.encrypted;
return p;
}
/*
=============================================================================
@ -291,12 +323,12 @@ static char *COM_GetItaniumName( const char * const in_name )
len = len * 10 + ( *f - '0' );
// sane value
len = min( remaining, len );
len = Q_min( remaining, len );
if( len == 0 )
goto invalid_format;
Q_strncpy( symbols[i], f, min( len + 1, sizeof( out_name )));
Q_strncpy( symbols[i], f, Q_min( len + 1, sizeof( out_name )));
f += len;
remaining -= len;
@ -361,7 +393,7 @@ char **COM_ConvertToLocalPlatform( EFunctionMangleType to, const char *from, siz
if( at ) len = (uint)( at - prev );
else len = (uint)Q_strlen( prev );
Q_strncpy( symbols[i], prev, min( len + 1, sizeof( symbols[i] )));
Q_strncpy( symbols[i], prev, Q_min( len + 1, sizeof( symbols[i] )));
prev = at + 1;
if( !at )

View File

@ -254,6 +254,5 @@ void NET_InitMasters( void )
// keep main master always there
NET_AddMaster( MASTERSERVER_ADR, false );
NET_AddMaster( MASTERSERVER_ADR2, false );
NET_LoadMasters( );
}

View File

@ -1020,6 +1020,8 @@ Fills in surf->texturemins[] and surf->extents[]
*/
static void Mod_CalcSurfaceExtents( msurface_t *surf )
{
// this place is VERY critical to precision
// keep it as float, don't use double, because it causes issues with lightmap
float mins[2], maxs[2], val;
float lmmins[2], lmmaxs[2];
int bmins[2], bmaxs[2];
@ -1049,14 +1051,14 @@ static void Mod_CalcSurfaceExtents( msurface_t *surf )
for( j = 0; j < 2; j++ )
{
val = DotProduct( v->position, surf->texinfo->vecs[j] ) + surf->texinfo->vecs[j][3];
val = DotProductPrecise( v->position, surf->texinfo->vecs[j] ) + surf->texinfo->vecs[j][3];
mins[j] = Q_min( val, mins[j] );
maxs[j] = Q_max( val, maxs[j] );
}
for( j = 0; j < 2; j++ )
{
val = DotProduct( v->position, info->lmvecs[j] ) + info->lmvecs[j][3];
val = DotProductPrecise( v->position, info->lmvecs[j] ) + info->lmvecs[j][3];
lmmins[j] = Q_min( val, lmmins[j] );
lmmaxs[j] = Q_max( val, lmmaxs[j] );
}
@ -2734,6 +2736,37 @@ static void Mod_LoadLighting( dbspmodel_t *bmod )
}
}
/*
=================
Mod_LumpLooksLikePlanes
=================
*/
static qboolean Mod_LumpLooksLikePlanes( const byte *in, dlump_t *lump, qboolean fast )
{
int numplanes, i;
const dplane_t *planes;
if( lump->filelen < sizeof( dplane_t ) &&
lump->filelen % sizeof( dplane_t ) != 0 )
return false;
if( fast )
return true;
numplanes = lump->filelen / sizeof( dplane_t );
planes = (const dplane_t*)(in + lump->fileofs);
for( i = 0; i < numplanes; i++ )
{
// planes can only be from 0 to 5: PLANE_X, Y, Z and PLANE_ANYX, Y and Z
if( planes[i].type < 0 || planes[i].type > 5 )
return false;
}
return true;
}
/*
=================
Mod_LoadBmodelLumps
@ -2783,8 +2816,8 @@ qboolean Mod_LoadBmodelLumps( const byte *mod_base, qboolean isworld )
if( header->version == HLBSP_VERSION )
{
// only relevant for half-life maps
if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 &&
(header->lumps[LUMP_ENTITIES].filelen % sizeof( dplane_t )) == 0 )
if( !Mod_LumpLooksLikePlanes( mod_base, &header->lumps[LUMP_PLANES], false ) &&
Mod_LumpLooksLikePlanes( mod_base, &header->lumps[LUMP_ENTITIES], false ))
{
// blue-shift swapped lumps
srclumps[0].lumpnumber = LUMP_PLANES;
@ -2908,13 +2941,28 @@ qboolean Mod_TestBmodelLumps( const char *name, const byte *mod_base, qboolean s
break;
}
if( header->version == HLBSP_VERSION &&
header->lumps[LUMP_ENTITIES].fileofs <= 1024 &&
(header->lumps[LUMP_ENTITIES].filelen % sizeof( dplane_t )) == 0 )
if( header->version == HLBSP_VERSION )
{
// blue-shift swapped lumps
srclumps[0].lumpnumber = LUMP_PLANES;
srclumps[1].lumpnumber = LUMP_ENTITIES;
// only relevant for half-life maps
if( Mod_LumpLooksLikePlanes( mod_base, &header->lumps[LUMP_ENTITIES], true ) &&
!Mod_LumpLooksLikePlanes( mod_base, &header->lumps[LUMP_PLANES], true ))
{
// blue-shift swapped lumps
srclumps[0].lumpnumber = LUMP_PLANES;
srclumps[1].lumpnumber = LUMP_ENTITIES;
}
else
{
// everything else
srclumps[0].lumpnumber = LUMP_ENTITIES;
srclumps[1].lumpnumber = LUMP_PLANES;
}
}
else
{
// everything else
srclumps[0].lumpnumber = LUMP_ENTITIES;
srclumps[1].lumpnumber = LUMP_PLANES;
}
// loading base lumps

View File

@ -143,7 +143,6 @@ model_t *Mod_ForName( const char *name, qboolean crash, qboolean trackCRC );
qboolean Mod_ValidateCRC( const char *name, CRC32_t crc );
void Mod_NeedCRC( const char *name, qboolean needCRC );
void Mod_FreeUnused( void );
model_t *Mod_Handle( int handle );
//
// mod_bmodel.c

View File

@ -600,20 +600,3 @@ void Mod_NeedCRC( const char *name, qboolean needCRC )
if( needCRC ) SetBits( p->flags, FCRC_SHOULD_CHECKSUM );
else ClearBits( p->flags, FCRC_SHOULD_CHECKSUM );
}
/*
==================
Mod_Handle
==================
*/
model_t *GAME_EXPORT Mod_Handle( int handle )
{
if( handle < 0 || handle >= MAX_MODELS )
{
Con_Reportf( "Mod_Handle: bad handle #%i\n", handle );
return NULL;
}
return &mod_known[handle];
}

View File

@ -980,10 +980,6 @@ qboolean Delta_CompareField( delta_t *pField, void *from, void *to, double timeb
}
else if( pField->flags & DT_INTEGER )
{
#if defined __GNUC__ && __GNUC_MAJOR < 9 && !defined __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wduplicated-branches"
#endif
if( pField->flags & DT_SIGNED )
{
fromF = *(int *)((byte *)from + pField->offset );
@ -994,9 +990,6 @@ qboolean Delta_CompareField( delta_t *pField, void *from, void *to, double timeb
fromF = *(uint *)((byte *)from + pField->offset );
toF = *(uint *)((byte *)to + pField->offset );
}
#if defined __GNUC__ && __GNUC_MAJOR < 9 && !defined __clang__
#pragma GCC diagnostic pop
#endif
fromF = Delta_ClampIntegerField( pField, fromF, bSigned, pField->bits );
toF = Delta_ClampIntegerField( pField, toF, bSigned, pField->bits );
if( !Q_equal( pField->multiplier, 1.0 ) )
@ -1121,7 +1114,7 @@ assume from and to is valid
qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to, double timebase )
{
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false;
float flValue, flAngle, flTime;
float flValue, flAngle;
uint iValue;
const char *pStr;
@ -1161,17 +1154,10 @@ qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to
}
else if( pField->flags & DT_INTEGER )
{
#if defined __GNUC__ && __GNUC_MAJOR < 9 && !defined __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wduplicated-branches"
#endif
if( bSigned )
iValue = *(int32_t *)((int8_t *)to + pField->offset );
else
iValue = *(uint32_t *)((int8_t *)to + pField->offset );
#if defined __GNUC__ && __GNUC_MAJOR < 9 && !defined __clang__
#pragma GCC diagnostic pop
#endif
iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits );
if( !Q_equal( pField->multiplier, 1.0 ) )
@ -1218,6 +1204,53 @@ qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to
return true;
}
/*
====================
Delta_CopyField
====================
*/
static void Delta_CopyField( delta_t *pField, void *from, void *to, double timebase )
{
qboolean bSigned = FBitSet( pField->flags, DT_SIGNED );
uint8_t *to_field = (uint8_t *)to + pField->offset;
uint8_t *from_field = (uint8_t *)from + pField->offset;
if( FBitSet( pField->flags, DT_BYTE ))
{
if( bSigned )
*(int8_t *)( to_field ) = *(int8_t *)( from_field );
else
*(uint8_t *)( to_field ) = *(uint8_t *)( from_field );
}
else if( FBitSet( pField->flags, DT_SHORT ))
{
if( bSigned )
*(int16_t *)( to_field ) = *(int16_t *)( from_field );
else
*(uint16_t *)( to_field ) = *(uint16_t *)( from_field );
}
else if( FBitSet( pField->flags, DT_INTEGER ))
{
if( bSigned )
*(int32_t *)( to_field ) = *(int32_t *)( from_field );
else
*(uint32_t *)( to_field ) = *(uint32_t *)( from_field );
}
else if( FBitSet( pField->flags, DT_FLOAT|DT_ANGLE|DT_TIMEWINDOW_8|DT_TIMEWINDOW_BIG ))
{
*(float *)( to_field ) = *(float *)( from_field );
}
else if( FBitSet( pField->flags, DT_STRING ))
{
Q_strncpy( to_field, from_field, pField->size );
}
else
{
Assert( 0 );
}
}
/*
=====================
Delta_ReadField
@ -1230,30 +1263,24 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to,
{
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false;
float flValue, flAngle, flTime;
qboolean bChanged;
uint iValue;
const char *pStr;
char *pOut;
bChanged = MSG_ReadOneBit( msg );
if( !MSG_ReadOneBit( msg ) )
{
Delta_CopyField( pField, from, to, timebase );
return false;
}
Assert( pField->multiplier != 0.0f );
if( pField->flags & DT_BYTE )
{
if( bChanged )
{
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
if( !Q_equal( pField->multiplier, 1.0 ) )
iValue /= pField->multiplier;
}
else
{
if( bSigned )
iValue = *(int8_t *)((uint8_t *)from + pField->offset );
else
iValue = *(uint8_t *)((uint8_t *)from + pField->offset );
}
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
if( !Q_equal( pField->multiplier, 1.0 ) )
iValue /= pField->multiplier;
if( bSigned )
*(int8_t *)((uint8_t *)to + pField->offset ) = iValue;
else
@ -1261,19 +1288,10 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to,
}
else if( pField->flags & DT_SHORT )
{
if( bChanged )
{
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
if( !Q_equal( pField->multiplier, 1.0 ) )
iValue /= pField->multiplier;
}
else
{
if( bSigned )
iValue = *(int16_t *)((uint8_t *)from + pField->offset );
else
iValue = *(uint16_t *)((uint8_t *)from + pField->offset );
}
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
if( !Q_equal( pField->multiplier, 1.0 ) )
iValue /= pField->multiplier;
if( bSigned )
*(int16_t *)((uint8_t *)to + pField->offset ) = iValue;
else
@ -1281,112 +1299,63 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to,
}
else if( pField->flags & DT_INTEGER )
{
#if defined __GNUC__ && __GNUC_MAJOR < 9 && !defined __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wduplicated-branches"
#endif
if( bChanged )
{
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
if( !Q_equal( pField->multiplier, 1.0 ) )
iValue /= pField->multiplier;
}
else
{
if( bSigned )
iValue = *(int32_t *)((uint8_t *)from + pField->offset );
else
iValue = *(uint32_t *)((uint8_t *)from + pField->offset );
}
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
if( !Q_equal( pField->multiplier, 1.0 ) )
iValue /= pField->multiplier;
if( bSigned )
*(int32_t *)((uint8_t *)to + pField->offset ) = iValue;
else
*(uint32_t *)((uint8_t *)to + pField->offset ) = iValue;
#if defined __GNUC__ && __GNUC_MAJOR < 9 && !defined __clang__
#pragma GCC diagnostic pop
#endif
}
else if( pField->flags & DT_FLOAT )
{
if( bChanged )
{
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
if( bSigned )
flValue = (int)iValue;
else
flValue = iValue;
if( !Q_equal( pField->multiplier, 1.0 ) )
flValue = flValue / pField->multiplier;
if( !Q_equal( pField->post_multiplier, 1.0 ) )
flValue = flValue * pField->post_multiplier;
}
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
if( bSigned )
flValue = (int)iValue;
else
{
flValue = *(float *)((byte *)from + pField->offset );
}
flValue = iValue;
if( !Q_equal( pField->multiplier, 1.0 ) )
flValue = flValue / pField->multiplier;
if( !Q_equal( pField->post_multiplier, 1.0 ) )
flValue = flValue * pField->post_multiplier;
*(float *)((byte *)to + pField->offset ) = flValue;
}
else if( pField->flags & DT_ANGLE )
{
if( bChanged )
{
flAngle = MSG_ReadBitAngle( msg, pField->bits );
}
else
{
flAngle = *(float *)((byte *)from + pField->offset );
}
flAngle = MSG_ReadBitAngle( msg, pField->bits );
*(float *)((byte *)to + pField->offset ) = flAngle;
}
else if( pField->flags & DT_TIMEWINDOW_8 )
{
if( bChanged )
{
bSigned = true; // timewindow is always signed
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
flTime = (timebase * 100.0 - iValue) / 100.0;
}
else
{
flTime = *(float *)((byte *)from + pField->offset );
}
bSigned = true; // timewindow is always signed
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
flTime = (timebase * 100.0 - (int)iValue) / 100.0;
*(float *)((byte *)to + pField->offset ) = flTime;
}
else if( pField->flags & DT_TIMEWINDOW_BIG )
{
if( bChanged )
{
bSigned = true; // timewindow is always signed
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
bSigned = true; // timewindow is always signed
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
if( !Q_equal( pField->multiplier, 1.0 ) )
flTime = ( timebase * pField->multiplier - iValue ) / pField->multiplier;
else
flTime = timebase - iValue;
}
if( !Q_equal( pField->multiplier, 1.0 ) )
flTime = ( timebase * pField->multiplier - (int)iValue ) / pField->multiplier;
else
{
flTime = *(float *)((byte *)from + pField->offset );
}
flTime = timebase - (int)iValue;
*(float *)((byte *)to + pField->offset ) = flTime;
}
else if( pField->flags & DT_STRING )
{
if( bChanged )
{
pStr = MSG_ReadString( msg );
}
else
{
pStr = (char *)((byte *)from + pField->offset );
}
pStr = MSG_ReadString( msg );
pOut = (char *)((byte *)to + pField->offset );
Q_strncpy( pOut, pStr, pField->size );
}
return bChanged;
return true;
}
/*
@ -1636,6 +1605,7 @@ void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, d
delta_t *pField;
delta_info_t *dt;
int i;
qboolean noChanges;
dt = Delta_FindStruct( "clientdata_t" );
Assert( dt && dt->bInitialized );
@ -1643,15 +1613,14 @@ void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, d
pField = dt->pFields;
Assert( pField != NULL );
*to = *from;
if( !cls.legacymode && !MSG_ReadOneBit( msg ))
return; // we have no changes
noChanges = !cls.legacymode && !MSG_ReadOneBit( msg );
// process fields
for( i = 0; i < dt->numFields; i++, pField++ )
{
Delta_ReadField( msg, pField, from, to, timebase );
if( noChanges )
Delta_CopyField( pField, from, to, timebase );
else Delta_ReadField( msg, pField, from, to, timebase );
}
#endif
}
@ -1722,8 +1691,6 @@ void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to,
pField = dt->pFields;
Assert( pField != NULL );
*to = *from;
// process fields
for( i = 0; i < dt->numFields; i++, pField++ )
{
@ -1909,7 +1876,7 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
from = &cl.instanced_baseline[baseline_offset];
}
}
}
}
// g-cont. probably is redundant
*to = *from;

View File

@ -1382,10 +1382,10 @@ qboolean NET_BufferToBufferDecompress( byte *dest, uint *destLen, byte *source,
/*
====================
NET_Isocket
NET_IPSocket
====================
*/
static int NET_Isocket( const char *net_interface, int port, qboolean multicast )
static int NET_IPSocket( const char *net_interface, int port, qboolean multicast )
{
struct sockaddr_in addr;
int err, net_socket;
@ -1396,7 +1396,7 @@ static int NET_Isocket( const char *net_interface, int port, qboolean multicast
{
err = WSAGetLastError();
if( err != WSAEAFNOSUPPORT )
Con_DPrintf( S_WARN "NET_UDsocket: port: %d socket: %s\n", port, NET_ErrorString( ));
Con_DPrintf( S_WARN "NET_UDPSocket: port: %d socket: %s\n", port, NET_ErrorString( ));
return INVALID_SOCKET;
}
@ -1404,7 +1404,7 @@ static int NET_Isocket( const char *net_interface, int port, qboolean multicast
{
struct timeval timeout;
Con_DPrintf( S_WARN "NET_UDsocket: port: %d ioctl FIONBIO: %s\n", port, NET_ErrorString( ));
Con_DPrintf( S_WARN "NET_UDPSocket: port: %d ioctl FIONBIO: %s\n", port, NET_ErrorString( ));
// try timeout instead of NBIO
timeout.tv_sec = timeout.tv_usec = 0;
setsockopt( net_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
@ -1413,14 +1413,14 @@ static int NET_Isocket( const char *net_interface, int port, qboolean multicast
// make it broadcast capable
if( NET_IsSocketError( setsockopt( net_socket, SOL_SOCKET, SO_BROADCAST, (char *)&_true, sizeof( _true ) ) ) )
{
Con_DPrintf( S_WARN "NET_UDsocket: port: %d setsockopt SO_BROADCAST: %s\n", port, NET_ErrorString( ));
Con_DPrintf( S_WARN "NET_UDPSocket: port: %d setsockopt SO_BROADCAST: %s\n", port, NET_ErrorString( ));
}
if( Sys_CheckParm( "-reuse" ) || multicast )
{
if( NET_IsSocketError( setsockopt( net_socket, SOL_SOCKET, SO_REUSEADDR, (const char *)&optval, sizeof( optval )) ) )
{
Con_DPrintf( S_WARN "NET_UDsocket: port: %d setsockopt SO_REUSEADDR: %s\n", port, NET_ErrorString( ));
Con_DPrintf( S_WARN "NET_UDPSocket: port: %d setsockopt SO_REUSEADDR: %s\n", port, NET_ErrorString( ));
closesocket( net_socket );
return INVALID_SOCKET;
}
@ -1435,7 +1435,7 @@ static int NET_Isocket( const char *net_interface, int port, qboolean multicast
{
err = WSAGetLastError();
if( err != WSAENOPROTOOPT )
Con_Printf( S_WARN "NET_UDsocket: port: %d setsockopt IP_TOS: %s\n", port, NET_ErrorString( ));
Con_Printf( S_WARN "NET_UDPSocket: port: %d setsockopt IP_TOS: %s\n", port, NET_ErrorString( ));
closesocket( net_socket );
return INVALID_SOCKET;
}
@ -1452,7 +1452,7 @@ static int NET_Isocket( const char *net_interface, int port, qboolean multicast
if( NET_IsSocketError( bind( net_socket, (void *)&addr, sizeof( addr )) ) )
{
Con_DPrintf( S_WARN "NET_UDsocket: port: %d bind: %s\n", port, NET_ErrorString( ));
Con_DPrintf( S_WARN "NET_UDPSocket: port: %d bind: %s\n", port, NET_ErrorString( ));
closesocket( net_socket );
return INVALID_SOCKET;
}
@ -1461,7 +1461,7 @@ static int NET_Isocket( const char *net_interface, int port, qboolean multicast
{
optval = 1;
if( NET_IsSocketError( setsockopt( net_socket, IPPROTO_IP, IP_MULTICAST_LOOP, (const char *)&optval, sizeof( optval )) ) )
Con_DPrintf( S_WARN "NET_UDsocket: port %d setsockopt IP_MULTICAST_LOOP: %s\n", port, NET_ErrorString( ));
Con_DPrintf( S_WARN "NET_UDPSocket: port %d setsockopt IP_MULTICAST_LOOP: %s\n", port, NET_ErrorString( ));
}
return net_socket;
@ -1472,35 +1472,71 @@ static int NET_Isocket( const char *net_interface, int port, qboolean multicast
NET_OpenIP
====================
*/
static void NET_OpenIP( void )
static void NET_OpenIP( qboolean change_port )
{
int port, sv_port = 0, cl_port = 0;
int port;
qboolean sv_nat = Cvar_VariableInteger("sv_nat");
qboolean cl_nat = Cvar_VariableInteger("cl_nat");
if( change_port && ( FBitSet( net_hostport->flags, FCVAR_CHANGED ) || sv_nat ))
{
// reopen socket to set random port
if( NET_IsSocketValid( net.ip_sockets[NS_SERVER] ))
closesocket( net.ip_sockets[NS_SERVER] );
net.ip_sockets[NS_SERVER] = INVALID_SOCKET;
ClearBits( net_hostport->flags, FCVAR_CHANGED );
}
if( !NET_IsSocketValid( net.ip_sockets[NS_SERVER] ) )
{
port = net_iphostport->value;
if( !port ) port = net_hostport->value;
if( !port ) port = PORT_SERVER; // forcing to default
net.ip_sockets[NS_SERVER] = NET_Isocket( net_ipname->string, port, false );
if( !port )
{
if( sv_nat )
port = PORT_ANY;
else
port = net_hostport->value;
if( !port )
port = PORT_SERVER; // forcing to default
}
net.ip_sockets[NS_SERVER] = NET_IPSocket( net_ipname->string, port, false );
if( !NET_IsSocketValid( net.ip_sockets[NS_SERVER] ) && Host_IsDedicated() )
Host_Error( "Couldn't allocate dedicated server IP port %d.\n", port );
sv_port = port;
}
// dedicated servers don't need client ports
if( Host_IsDedicated() ) return;
if (change_port && ( FBitSet( net_clientport->flags, FCVAR_CHANGED ) || cl_nat ))
{
// reopen socket to set random port
if( NET_IsSocketValid(net.ip_sockets[NS_CLIENT] ))
closesocket( net.ip_sockets[NS_CLIENT] );
net.ip_sockets[NS_CLIENT] = INVALID_SOCKET;
ClearBits( net_clientport->flags, FCVAR_CHANGED );
}
if( !NET_IsSocketValid( net.ip_sockets[NS_CLIENT] ) )
{
port = net_ipclientport->value;
if( !port ) port = net_clientport->value;
if( !port ) port = PORT_ANY; // forcing to default
net.ip_sockets[NS_CLIENT] = NET_Isocket( net_ipname->string, port, false );
if( !port )
{
if( cl_nat )
port = PORT_ANY;
else
port = net_clientport->value;
if( !port )
port = PORT_ANY; // forcing to default
}
net.ip_sockets[NS_CLIENT] = NET_IPSocket( net_ipname->string, port, false );
if( !NET_IsSocketValid( net.ip_sockets[NS_CLIENT] ) )
net.ip_sockets[NS_CLIENT] = NET_Isocket( net_ipname->string, PORT_ANY, false );
cl_port = port;
net.ip_sockets[NS_CLIENT] = NET_IPSocket( net_ipname->string, PORT_ANY, false );
}
}
@ -1570,7 +1606,7 @@ NET_Config
A single player game will only use the loopback code
====================
*/
void NET_Config( qboolean multiplayer )
void NET_Config( qboolean multiplayer, qboolean changeport )
{
static qboolean bFirst = true;
static qboolean old_config;
@ -1586,7 +1622,7 @@ void NET_Config( qboolean multiplayer )
if( multiplayer )
{
// open sockets
if( net.allow_ip ) NET_OpenIP();
if( net.allow_ip ) NET_OpenIP( changeport );
// get our local address, if possible
if( bFirst )
@ -1695,7 +1731,7 @@ void NET_Init( void )
net_clockwindow = Cvar_Get( "clockwindow", "0.5", FCVAR_PRIVILEGED, "timewindow to execute client moves" );
net_address = Cvar_Get( "net_address", "0", FCVAR_READ_ONLY, "contain local address of current client" );
net_ipname = Cvar_Get( "ip", "localhost", FCVAR_READ_ONLY, "network ip address" );
net_ipname = Cvar_Get( "ip", "localhost", 0, "network ip address" );
net_iphostport = Cvar_Get( "ip_hostport", "0", FCVAR_READ_ONLY, "network ip host port" );
net_hostport = Cvar_Get( "hostport", va( "%i", PORT_SERVER ), FCVAR_READ_ONLY, "network default host port" );
net_ipclientport = Cvar_Get( "ip_clientport", "0", FCVAR_READ_ONLY, "network ip client port" );
@ -1756,7 +1792,7 @@ void NET_Shutdown( void )
NET_ClearLagData( true, true );
NET_Config( false );
NET_Config( false, false );
#if XASH_WIN32
WSACleanup();
#endif
@ -2280,7 +2316,7 @@ void HTTP_Run( void )
}
// update progress
if( !Host_IsDedicated() )
if( !Host_IsDedicated() && iProgressCount != 0 )
Cvar_SetValue( "scr_download", flProgress/iProgressCount * 100 );
HTTP_AutoClean();

View File

@ -51,7 +51,7 @@ void NET_Shutdown( void );
void NET_Sleep( int msec );
qboolean NET_IsActive( void );
qboolean NET_IsConfigured( void );
void NET_Config( qboolean net_enable );
void NET_Config( qboolean net_enable, qboolean changeport );
qboolean NET_IsLocalAddress( netadr_t adr );
const char *NET_AdrToString( const netadr_t a );
const char *NET_BaseAdrToString( const netadr_t a );

View File

@ -69,8 +69,7 @@ GNU General Public License for more details.
// bytes will be stripped by the networking channel layer
#define NET_MAX_MESSAGE PAD_NUMBER(( NET_MAX_PAYLOAD + HEADER_BYTES ), 16 )
#define MASTERSERVER_ADR "ms.xash.su:27010"
#define MASTERSERVER_ADR2 "ms2.xash.su:27010"
#define MASTERSERVER_ADR "mentality.rip:27010"
#define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0"
#define PORT_MASTER 27010

View File

@ -17,6 +17,9 @@ GNU General Public License for more details.
#define PM_LOCAL_H
#include "pm_defs.h"
#include "xash3d_mathlib.h"
#include <string.h> // memset
typedef int (*pfnIgnore)( physent_t *pe ); // custom trace filter
@ -40,6 +43,22 @@ int PM_TruePointContents( playermove_t *pmove, const vec3_t p );
int PM_PointContents( playermove_t *pmove, const vec3_t p );
void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent );
static inline void PM_InitTrace( trace_t *trace, const vec3_t end )
{
memset( trace, 0, sizeof( *trace ));
VectorCopy( end, trace->endpos );
trace->allsolid = true;
trace->fraction = 1.0f;
}
static inline void PM_InitPMTrace( pmtrace_t *trace, const vec3_t end )
{
memset( trace, 0, sizeof( *trace ));
VectorCopy( end, trace->endpos );
trace->allsolid = true;
trace->fraction = 1.0f;
}
//
// pm_surface.c
//

View File

@ -446,10 +446,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
VectorSubtract( end, offset, end_l );
}
memset( &trace_bbox, 0, sizeof( trace_bbox ));
VectorCopy( end, trace_bbox.endpos );
trace_bbox.allsolid = true;
trace_bbox.fraction = 1.0f;
PM_InitPMTrace( &trace_bbox, end );
if( hullcount < 1 )
{
@ -475,10 +472,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
for( last_hitgroup = 0, j = 0; j < hullcount; j++ )
{
memset( &trace_hitbox, 0, sizeof( trace_hitbox ));
VectorCopy( end, trace_hitbox.endpos );
trace_hitbox.allsolid = true;
trace_hitbox.fraction = 1.0f;
PM_InitPMTrace( &trace_hitbox, end );
PM_RecursiveHullCheck( &hull[j], hull[j].firstclipnode, 0, 1, start_l, end_l, &trace_hitbox );
@ -622,10 +616,7 @@ int PM_TestPlayerPosition( playermove_t *pmove, vec3_t pos, pmtrace_t *ptrace, p
{
pmtrace_t trace;
memset( &trace, 0, sizeof( trace ));
VectorCopy( pos, trace.endpos );
trace.allsolid = true;
trace.fraction = 1.0f;
PM_InitPMTrace( &trace, pos );
// run custom sweep callback
if( pmove->server || Host_IsLocalClient( ))

View File

@ -110,13 +110,7 @@ GNU General Public License for more details.
#define MAX_EVENTS (1<<MAX_EVENT_BITS) // 10 bits == 1024 events (the original Half-Life limit)
#define MAX_MODEL_BITS 12 // 12 bits == 4096 models
#define MAX_SUPPORTED_MODELS (1<<MAX_MODEL_BITS)
#ifdef SUPPORT_BSP2_FORMAT
#define MAX_MODELS MAX_SUPPORTED_MODELS // because BSP2 contain too much embedded bsp-models
#else
#define MAX_MODELS 1024 // g-cont. reduce the memory without breaking proto
#endif
#define MAX_MODELS (1<<MAX_MODEL_BITS)
#define MAX_SOUND_BITS 11
#define MAX_SOUNDS (1<<MAX_SOUND_BITS) // 11 bits == 2048 sounds
@ -187,7 +181,6 @@ GNU General Public License for more details.
#undef MAX_VISIBLE_PACKET
#undef MAX_VISIBLE_PACKET_VIS_BYTES
#undef MAX_EVENTS
#undef MAX_SUPPORTED_MODELS
#undef MAX_MODELS
#undef MAX_SOUNDS
#undef MAX_CUSTOM
@ -198,17 +191,10 @@ GNU General Public License for more details.
// memory reduced protocol, not for use in multiplayer (but still compatible)
#define MAX_VISIBLE_PACKET 128
#define MAX_VISIBLE_PACKET_VIS_BYTES ((MAX_VISIBLE_PACKET + 7) / 8)
#define MAX_EVENTS 128
#define MAX_SUPPORTED_MODELS 512
#define MAX_MODELS 512
#define MAX_SOUNDS 512
#define MAX_CUSTOM 32
#define MAX_DLIGHTS 16 // dynamic lights (rendered per one frame)
#define MAX_ELIGHTS 32 // entity only point lights
#define MAX_RENDER_DECALS 64 // max rendering decals per a level
@ -217,20 +203,14 @@ GNU General Public License for more details.
#undef MAX_VISIBLE_PACKET
#undef MAX_VISIBLE_PACKET_VIS_BYTES
#undef MAX_EVENTS
#undef MAX_SUPPORTED_MODELS
#undef MAX_MODELS
#undef MAX_CUSTOM
#undef MAX_RENDER_DECALS
#undef MAX_RESOURCES
#define MAX_VISIBLE_PACKET 256
#define MAX_VISIBLE_PACKET_VIS_BYTES ((MAX_VISIBLE_PACKET + 7) / 8)
#define MAX_EVENTS 128
#define MAX_SUPPORTED_MODELS 1024
#define MAX_MODELS 1024
#define MAX_CUSTOM 512
#define MAX_RENDER_DECALS 128
#define MAX_RESOURCES 1024
@ -319,11 +299,6 @@ extern const char *clc_strings[clc_lastmsg+1];
#define MAX_LEGACY_ENTITY_BITS 12
#define MAX_LEGACY_WEAPON_BITS 5
#define MAX_LEGACY_MODEL_BITS 11
#if XASH_LOW_MEMORY >= 1
#define MAX_LEGACY_SERVERS 32
#else
#define MAX_LEGACY_SERVERS 256
#endif
#define MAX_LEGACY_TOTAL_CMDS 28 // magic number from old engine's sv_client.c
#endif//NET_PROTOCOL_H

View File

@ -278,3 +278,25 @@ void FS_FreeStream( stream_t *stream )
stream->format->freefunc( stream );
}
#if XASH_ENGINE_TESTS
#define IMPLEMENT_SOUNDLIB_FUZZ_TARGET( export, target ) \
int EXPORT export( const uint8_t *Data, size_t Size ) \
{ \
wavdata_t *wav; \
host.type = HOST_NORMAL; \
Memory_Init(); \
Sound_Init(); \
if( target( "#internal", Data, Size )) \
{ \
wav = SoundPack(); \
FS_FreeSound( wav ); \
} \
Sound_Shutdown(); \
return 0; \
} \
IMPLEMENT_SOUNDLIB_FUZZ_TARGET( Fuzz_Sound_LoadMPG, Sound_LoadMPG )
IMPLEMENT_SOUNDLIB_FUZZ_TARGET( Fuzz_Sound_LoadWAV, Sound_LoadWAV )
#endif

View File

@ -14,15 +14,23 @@ GNU General Public License for more details.
*/
#include "common.h"
#if XASH_ANDROID
#if XASH_WIN32
#define STDOUT_FILENO 1
#include <io.h>
#elif XASH_ANDROID
#include <android/log.h>
#endif
#include <string.h>
#include <errno.h>
#if !XASH_WIN32 && !XASH_MOBILE_PLATFORM
#define XASH_COLORIZE_CONSOLE
// do not waste precious CPU cycles on mobiles or low memory devices
#if !XASH_WIN32 && !XASH_MOBILE_PLATFORM && !XASH_LOW_MEMORY
#define XASH_COLORIZE_CONSOLE true
// use with caution, running engine in Qt Creator may cause a freeze in read() call
// I was never encountered this bug anywhere else, so still enable by default
// #define XASH_USE_SELECT 1
#else
#define XASH_COLORIZE_CONSOLE false
#endif
#if XASH_USE_SELECT
@ -95,6 +103,20 @@ int Sys_LogFileNo( void )
return s_ld.logfileno;
}
static void Sys_FlushStdout( void )
{
// never printing anything to stdout on mobiles
#if !XASH_MOBILE_PLATFORM
fflush( stdout );
#endif
}
static void Sys_FlushLogfile( void )
{
if( s_ld.logfile )
fflush( s_ld.logfile );
}
void Sys_InitLog( void )
{
const char *mode;
@ -113,10 +135,17 @@ void Sys_InitLog( void )
if( s_ld.log_active )
{
s_ld.logfile = fopen( s_ld.log_path, mode );
if( !s_ld.logfile ) Con_Reportf( S_ERROR "Sys_InitLog: can't create log file %s\n", s_ld.log_path );
if ( !s_ld.logfile )
{
Con_Reportf( S_ERROR "Sys_InitLog: can't create log file %s: %s\n", s_ld.log_path, strerror( errno ) );
return;
}
s_ld.logfileno = fileno( s_ld.logfile );
fprintf( s_ld.logfile, "=================================================================================\n" );
fprintf( s_ld.logfile, "\t%s (build %i) started at %s\n", s_ld.title, Q_buildnum(), Q_timestamp( TIME_FULL ));
fprintf( s_ld.logfile, "\t%s (build %i) started at %s\n", s_ld.title, Q_buildnum(), Q_timestamp( TIME_FULL ) );
fprintf( s_ld.logfile, "=================================================================================\n" );
}
}
@ -140,6 +169,8 @@ void Sys_CloseLog( void )
break;
}
Sys_FlushStdout(); // flush to stdout to ensure all data was written
if( s_ld.logfile )
{
fprintf( s_ld.logfile, "\n");
@ -153,89 +184,120 @@ void Sys_CloseLog( void )
}
}
#if XASH_COLORIZE_CONSOLE == true
static void Sys_WriteEscapeSequenceForColorcode( int fd, int c )
{
static const char *q3ToAnsi[ 8 ] =
{
"\033[30m", // COLOR_BLACK
"\033[31m", // COLOR_RED
"\033[32m", // COLOR_GREEN
"\033[33m", // COLOR_YELLOW
"\033[34m", // COLOR_BLUE
"\033[36m", // COLOR_CYAN
"\033[35m", // COLOR_MAGENTA
"\033[0m", // COLOR_WHITE
};
const char *esc = q3ToAnsi[c];
if( c == 7 )
write( fd, esc, 4 );
else write( fd, esc, 5 );
}
#else
static void Sys_WriteEscapeSequenceForColorcode( int fd, int c ) {}
#endif
static void Sys_PrintLogfile( const int fd, const char *logtime, const char *msg, const qboolean colorize )
{
const char *p = msg;
write( fd, logtime, Q_strlen( logtime ) );
while( p && *p )
{
p = Q_strchr( msg, '^' );
if( p == NULL )
{
write( fd, msg, Q_strlen( msg ));
break;
}
else if( IsColorString( p ))
{
if( p != msg )
write( fd, msg, p - msg );
msg = p + 2;
if( colorize )
Sys_WriteEscapeSequenceForColorcode( fd, ColorIndex( p[1] ));
}
else
{
write( fd, msg, p - msg + 1 );
msg = p + 1;
}
}
// flush the color
if( colorize )
Sys_WriteEscapeSequenceForColorcode( fd, 7 );
}
static void Sys_PrintStdout( const char *logtime, const char *msg )
{
#if XASH_MOBILE_PLATFORM
static char buf[MAX_PRINT_MSG];
// strip color codes
COM_StripColors( msg, buf );
// platform-specific output
#if XASH_ANDROID && !XASH_DEDICATED
__android_log_write( ANDROID_LOG_DEBUG, "Xash", buf );
#endif // XASH_ANDROID && !XASH_DEDICATED
#if TARGET_OS_IOS
void IOS_Log( const char * );
IOS_Log( buf );
#endif // TARGET_OS_IOS
#elif !XASH_WIN32 // Wcon does the job
Sys_PrintLogfile( STDOUT_FILENO, logtime, msg, XASH_COLORIZE_CONSOLE );
Sys_FlushStdout();
#endif
}
void Sys_PrintLog( const char *pMsg )
{
time_t crt_time;
time_t crt_time;
const struct tm *crt_tm;
char logtime[32] = "";
static char lastchar;
time( &crt_time );
crt_tm = localtime( &crt_time );
#if XASH_ANDROID && !XASH_DEDICATED
__android_log_print( ANDROID_LOG_DEBUG, "Xash", "%s", pMsg );
#endif
#if TARGET_OS_IOS
void IOS_Log(const char*);
IOS_Log(pMsg);
#endif
if( !lastchar || lastchar == '\n')
strftime( logtime, sizeof( logtime ), "[%H:%M:%S] ", crt_tm ); //short time
#ifdef XASH_COLORIZE_CONSOLE
{
char colored[4096];
const char *msg = pMsg;
int len = 0;
while( *msg && ( len < 4090 ) )
{
static char q3ToAnsi[ 8 ] =
{
'0', // COLOR_BLACK
'1', // COLOR_RED
'2', // COLOR_GREEN
'3', // COLOR_YELLOW
'4', // COLOR_BLUE
'6', // COLOR_CYAN
'5', // COLOR_MAGENTA
0 // COLOR_WHITE
};
if( IsColorString( msg ) )
{
int color;
msg++;
color = q3ToAnsi[ *msg++ % 8 ];
colored[len++] = '\033';
colored[len++] = '[';
if( color )
{
colored[len++] = '3';
colored[len++] = color;
}
else
colored[len++] = '0';
colored[len++] = 'm';
}
else
colored[len++] = *msg++;
}
colored[len] = 0;
printf( "\033[34m%s\033[0m%s\033[0m", logtime, colored );
}
#else
#if !XASH_ANDROID || XASH_DEDICATED
printf( "%s %s", logtime, pMsg );
fflush( stdout );
#endif
#endif
// save last char to detect when line was not ended
lastchar = pMsg[strlen(pMsg)-1];
// spew to stdout
Sys_PrintStdout( logtime, pMsg );
if( !s_ld.logfile )
{
// save last char to detect when line was not ended
lastchar = pMsg[Q_strlen( pMsg ) - 1];
return;
}
if( !lastchar || lastchar == '\n')
strftime( logtime, sizeof( logtime ), "[%Y:%m:%d|%H:%M:%S]", crt_tm ); //full time
strftime( logtime, sizeof( logtime ), "[%Y:%m:%d|%H:%M:%S] ", crt_tm ); //full time
// save last char to detect when line was not ended
lastchar = pMsg[Q_strlen( pMsg ) - 1];
fprintf( s_ld.logfile, "%s %s", logtime, pMsg );
fflush( s_ld.logfile );
Sys_PrintLogfile( s_ld.logfileno, logtime, pMsg, false );
Sys_FlushLogfile();
}
/*

View File

@ -17,6 +17,7 @@ GNU General Public License for more details.
#include "xash3d_mathlib.h"
#include "platform/platform.h"
#include <stdlib.h>
#include <errno.h>
#ifdef XASH_SDL
#include <SDL.h>
@ -32,8 +33,15 @@ GNU General Public License for more details.
#endif
#endif
#if XASH_WIN32
#include <process.h>
#endif
#include "menu_int.h" // _UPDATE_PAGE macro
#include "library.h"
#include "whereami.h"
qboolean error_on_exit = false; // arg for exit();
#define DEBUG_BREAK
@ -81,18 +89,6 @@ char *Sys_GetClipboardData( void )
return data;
}
/*
================
Sys_SetClipboardData
write screenshot into clipboard
================
*/
void Sys_SetClipboardData( const char *buffer, size_t size )
{
Platform_SetClipboardText( buffer, size );
}
#endif // XASH_DEDICATED
/*
@ -107,7 +103,7 @@ void Sys_Sleep( int msec )
if( !msec )
return;
msec = min( msec, 1000 );
msec = Q_min( msec, 1000 );
Platform_Sleep( msec );
}
@ -284,7 +280,8 @@ qboolean Sys_LoadLibrary( dll_info_t *dll )
*func->func = NULL;
}
if( !dll->link ) dll->link = LoadLibrary ( dll->name ); // environment pathes
if( !dll->link )
dll->link = COM_LoadLibrary( dll->name, false, true ); // environment pathes
// no DLL found
if( !dll->link )
@ -319,7 +316,7 @@ void* Sys_GetProcAddress( dll_info_t *dll, const char* name )
if( !dll || !dll->link ) // invalid desc
return NULL;
return (void *)GetProcAddress( dll->link, name );
return (void *)COM_GetProcAddress( dll->link, name );
}
qboolean Sys_FreeLibrary( dll_info_t *dll )
@ -336,7 +333,7 @@ qboolean Sys_FreeLibrary( dll_info_t *dll )
}
else Con_Reportf( "Sys_FreeLibrary: Unloading %s\n", dll->name );
FreeLibrary( dll->link );
COM_FreeLibrary( dll->link );
dll->link = NULL;
return true;
@ -353,9 +350,6 @@ void Sys_WaitForQuit( void )
{
#if XASH_WIN32
MSG msg;
Wcon_RegisterHotkeys();
msg.message = 0;
// wait for the user to quit
@ -427,9 +421,12 @@ void Sys_Error( const char *error, ... )
#if XASH_SDL == 2
if( host.hWnd ) SDL_HideWindow( host.hWnd );
#endif
#if XASH_WIN32
Wcon_ShowConsole( false );
#endif
MSGBOX( text );
}
if( host_developer.value )
else
{
#if XASH_WIN32
Wcon_ShowConsole( true );
@ -438,14 +435,7 @@ void Sys_Error( const char *error, ... )
Sys_Print( text ); // print error message
Sys_WaitForQuit();
}
else
{
#if XASH_WIN32
Wcon_ShowConsole( false );
#endif
MSGBOX( text );
}
Sys_Quit();
}
@ -531,10 +521,6 @@ void Sys_Print( const char *pMsg )
{
i++; // skip console pseudo graph
}
else if( IsColorString( &msg[i] ))
{
i++; // skip color prefix
}
else
{
if( msg[i] == '\1' || msg[i] == '\2' || msg[i] == '\3' )
@ -555,3 +541,67 @@ void Sys_Print( const char *pMsg )
Rcon_Print( pMsg );
}
/*
==================
Sys_ChangeGame
This is a special function
Here we restart engine with new -game parameter
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 )
{
int i = 0;
qboolean replacedArg = false;
size_t exelen;
char *exe, **newargs;
// don't use engine allocation utils here
// they will be freed after Host_Shutdown
newargs = calloc( host.argc + 4, sizeof( *newargs ));
while( i < host.argc )
{
newargs[i] = strdup( host.argv[i] );
// replace existing -game argument
if( !Q_stricmp( newargs[i], "-game" ))
{
newargs[i + 1] = strdup( gamedir );
replacedArg = true;
i += 2;
}
else i++;
}
if( !replacedArg )
{
newargs[i++] = strdup( "-game" );
newargs[i++] = strdup( gamedir );
}
newargs[i++] = strdup( "-changegame" );
newargs[i] = NULL;
exelen = wai_getExecutablePath( NULL, 0, NULL );
exe = malloc( exelen + 1 );
wai_getExecutablePath( exe, exelen, NULL );
exe[exelen] = 0;
Host_Shutdown();
execv( exe, newargs );
// if execv returned, it's probably an error
printf( "execv failed: %s", strerror( errno ));
for( ; i >= 0; i-- )
free( newargs[i] );
free( newargs );
free( exe );
return false;
}

View File

@ -59,7 +59,6 @@ void Sys_ParseCommandLine( int argc, char **argv );
void Sys_MergeCommandLine( void );
void Sys_SetupCrashHandler( void );
void Sys_RestoreCrashHandler( void );
void Sys_SetClipboardData( const char *buffer, size_t size );
#define Sys_GetParmFromCmdLine( parm, out ) _Sys_GetParmFromCmdLine( parm, out, sizeof( out ))
qboolean _Sys_GetParmFromCmdLine( const char *parm, char *out, size_t size );
qboolean Sys_GetIntFromCmdLine( const char *parm, int *out );
@ -69,6 +68,7 @@ void Sys_PrintLog( const char *pMsg );
void Sys_InitLog( void );
void Sys_CloseLog( void );
void Sys_Quit( void ) NORETURN;
qboolean Sys_NewInstance( const char *gamedir );
//
// sys_con.c
@ -89,10 +89,9 @@ void Wcon_ShowConsole( qboolean show );
void Wcon_CreateConsole( void );
void Wcon_DestroyConsole( void );
void Wcon_DisableInput( void );
void Wcon_Clear( void );
char *Wcon_Input( void );
void Wcon_WinPrint( const char *pMsg );
void Wcon_RegisterHotkeys( void );
void Wcon_SetStatus( const char *pStatus );
#endif
// text messages

View File

@ -11,21 +11,32 @@ struct tests_stats_s
extern struct tests_stats_s tests_stats;
#define TRUN( x ) Msg( "Running " #x "\n" ); x
#define TRUN( x ) Msg( "Starting " #x "\n" ); \
x; \
Msg( "Finished " #x "\n" )
#define TASSERT( exp ) \
if(!( exp )) \
#define _TASSERT( exp, msg ) \
if( exp ) \
{ \
tests_stats.failed++; \
Msg( S_ERROR "assert failed at %s:%i\n", __FILE__, __LINE__ ); \
msg; \
} \
else tests_stats.passed++;
#define TASSERT( exp ) \
_TASSERT( !(exp), Msg( S_ERROR "assert failed at %s:%i\n", __FILE__, __LINE__ ) )
#define TASSERT_EQi( val1, val2 ) \
_TASSERT( ( val1 ) != ( val2 ), Msg( S_ERROR "assert failed at %s:%i, \"%d\" != \"%d\"\n", __FILE__, __LINE__, #val1, #val2 ))
#define TASSERT_STR( str1, str2 ) \
_TASSERT( Q_strcmp(( str1 ), ( str2 )), Msg( S_ERROR "assert failed at %s:%i, \"%s\" != \"%s\"\n", __FILE__, __LINE__, ( str1 ), ( str2 )))
void Test_RunImagelib( void );
void Test_RunLibCommon( void );
void Test_RunCommon( void );
void Test_RunCmd( void );
void Test_RunCvar( void );
void Test_RunCon( void );
void Test_RunVOX( void );
#endif

806
engine/common/whereami.c Normal file
View File

@ -0,0 +1,806 @@
// (‑●‑●)> dual licensed under the WTFPL v2 and MIT licenses
// without any warranty.
// by Gregory Pakosz (@gpakosz)
// https://github.com/gpakosz/whereami
// in case you want to #include "whereami.c" in a larger compilation unit
#if !defined(WHEREAMI_H)
#include <whereami.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__linux__) || defined(__CYGWIN__)
#undef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#elif defined(__APPLE__)
#undef _DARWIN_C_SOURCE
#define _DARWIN_C_SOURCE
#define _DARWIN_BETTER_REALPATH
#endif
#if !defined(WAI_MALLOC) || !defined(WAI_FREE) || !defined(WAI_REALLOC)
#include <stdlib.h>
#endif
#if !defined(WAI_MALLOC)
#define WAI_MALLOC(size) malloc(size)
#endif
#if !defined(WAI_FREE)
#define WAI_FREE(p) free(p)
#endif
#if !defined(WAI_REALLOC)
#define WAI_REALLOC(p, size) realloc(p, size)
#endif
#ifndef WAI_NOINLINE
#if defined(_MSC_VER)
#define WAI_NOINLINE __declspec(noinline)
#elif defined(__GNUC__)
#define WAI_NOINLINE __attribute__((noinline))
#else
#error unsupported compiler
#endif
#endif
#if defined(_MSC_VER)
#define WAI_RETURN_ADDRESS() _ReturnAddress()
#elif defined(__GNUC__)
#define WAI_RETURN_ADDRESS() __builtin_extract_return_addr(__builtin_return_address(0))
#else
#error unsupported compiler
#endif
#if defined(_WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#if defined(_MSC_VER)
#pragma warning(push, 3)
#endif
#include <windows.h>
#include <intrin.h>
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#include <stdbool.h>
static int WAI_PREFIX(getModulePath_)(HMODULE module, char* out, int capacity, int* dirname_length)
{
wchar_t buffer1[MAX_PATH];
wchar_t buffer2[MAX_PATH];
wchar_t* path = NULL;
int length = -1;
bool ok;
for (ok = false; !ok; ok = true)
{
DWORD size;
int length_, length__;
size = GetModuleFileNameW(module, buffer1, sizeof(buffer1) / sizeof(buffer1[0]));
if (size == 0)
break;
else if (size == (DWORD)(sizeof(buffer1) / sizeof(buffer1[0])))
{
DWORD size_ = size;
do
{
wchar_t* path_;
path_ = (wchar_t*)WAI_REALLOC(path, sizeof(wchar_t) * size_ * 2);
if (!path_)
break;
size_ *= 2;
path = path_;
size = GetModuleFileNameW(module, path, size_);
}
while (size == size_);
if (size == size_)
break;
}
else
path = buffer1;
if (!_wfullpath(buffer2, path, MAX_PATH))
break;
length_ = (int)wcslen(buffer2);
length__ = WideCharToMultiByte(CP_UTF8, 0, buffer2, length_ , out, capacity, NULL, NULL);
if (length__ == 0)
length__ = WideCharToMultiByte(CP_UTF8, 0, buffer2, length_, NULL, 0, NULL, NULL);
if (length__ == 0)
break;
if (length__ <= capacity && dirname_length)
{
int i;
for (i = length__ - 1; i >= 0; --i)
{
if (out[i] == '\\')
{
*dirname_length = i;
break;
}
}
}
length = length__;
}
if (path != buffer1)
WAI_FREE(path);
return ok ? length : -1;
}
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
return WAI_PREFIX(getModulePath_)(NULL, out, capacity, dirname_length);
}
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
HMODULE module;
int length = -1;
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4054)
#endif
if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)WAI_RETURN_ADDRESS(), &module))
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
{
length = WAI_PREFIX(getModulePath_)(module, out, capacity, dirname_length);
}
return length;
}
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun) || defined(WAI_USE_PROC_SELF_EXE)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(__linux__)
#include <linux/limits.h>
#else
#include <limits.h>
#endif
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#include <stdbool.h>
#if !defined(WAI_PROC_SELF_EXE)
#if defined(__sun)
#define WAI_PROC_SELF_EXE "/proc/self/path/a.out"
#else
#define WAI_PROC_SELF_EXE "/proc/self/exe"
#endif
#endif
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
char buffer[PATH_MAX];
char* resolved = NULL;
int length = -1;
bool ok;
for (ok = false; !ok; ok = true)
{
resolved = realpath(WAI_PROC_SELF_EXE, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
return ok ? length : -1;
}
#if !defined(WAI_PROC_SELF_MAPS_RETRY)
#define WAI_PROC_SELF_MAPS_RETRY 5
#endif
#if !defined(WAI_PROC_SELF_MAPS)
#if defined(__sun)
#define WAI_PROC_SELF_MAPS "/proc/self/map"
#else
#define WAI_PROC_SELF_MAPS "/proc/self/maps"
#endif
#endif
#if defined(__ANDROID__) || defined(ANDROID)
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#endif
#include <stdbool.h>
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
int length = -1;
FILE* maps = NULL;
int r;
for (r = 0; r < WAI_PROC_SELF_MAPS_RETRY; ++r)
{
maps = fopen(WAI_PROC_SELF_MAPS, "r");
if (!maps)
break;
for (;;)
{
char buffer[PATH_MAX < 1024 ? 1024 : PATH_MAX];
uint64_t low, high;
char perms[5];
uint64_t offset;
uint32_t major, minor;
char path[PATH_MAX];
uint32_t inode;
if (!fgets(buffer, sizeof(buffer), maps))
break;
if (sscanf(buffer, "%" PRIx64 "-%" PRIx64 " %s %" PRIx64 " %x:%x %u %s\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8)
{
uint64_t addr = (uintptr_t)WAI_RETURN_ADDRESS();
if (low <= addr && addr <= high)
{
char* resolved;
resolved = realpath(path, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
#if defined(__ANDROID__) || defined(ANDROID)
if (length > 4
&&buffer[length - 1] == 'k'
&&buffer[length - 2] == 'p'
&&buffer[length - 3] == 'a'
&&buffer[length - 4] == '.')
{
char *begin, *p;
int fd = open(path, O_RDONLY);
if (fd == -1)
{
length = -1; // retry
break;
}
begin = (char*)mmap(0, offset, PROT_READ, MAP_SHARED, fd, 0);
if (begin == MAP_FAILED)
{
close(fd);
length = -1; // retry
break;
}
p = begin + offset - 30; // minimum size of local file header
while (p >= begin) // scan backwards
{
if (*((uint32_t*)p) == 0x04034b50UL) // local file header signature found
{
uint16_t length_ = *((uint16_t*)(p + 26));
if (length + 2 + length_ < (int)sizeof(buffer))
{
memcpy(&buffer[length], "!/", 2);
memcpy(&buffer[length + 2], p + 30, length_);
length += 2 + length_;
}
break;
}
--p;
}
munmap(begin, offset);
close(fd);
}
#endif
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
break;
}
}
}
fclose(maps);
maps = NULL;
if (length != -1)
break;
}
return length;
}
#elif defined(__APPLE__)
#include <mach-o/dyld.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <stdbool.h>
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
char buffer1[PATH_MAX];
char buffer2[PATH_MAX];
char* path = buffer1;
char* resolved = NULL;
int length = -1;
bool ok;
for (ok = false; !ok; ok = true)
{
uint32_t size = (uint32_t)sizeof(buffer1);
if (_NSGetExecutablePath(path, &size) == -1)
{
path = (char*)WAI_MALLOC(size);
if (!_NSGetExecutablePath(path, &size))
break;
}
resolved = realpath(path, buffer2);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
if (path != buffer1)
WAI_FREE(path);
return ok ? length : -1;
}
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
char buffer[PATH_MAX];
char* resolved = NULL;
int length = -1;
for(;;)
{
Dl_info info;
if (dladdr(WAI_RETURN_ADDRESS(), &info))
{
resolved = realpath(info.dli_fname, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
break;
}
return length;
}
#elif defined(__QNXNTO__)
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <stdbool.h>
#if !defined(WAI_PROC_SELF_EXE)
#define WAI_PROC_SELF_EXE "/proc/self/exefile"
#endif
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
char buffer1[PATH_MAX];
char buffer2[PATH_MAX];
char* resolved = NULL;
FILE* self_exe = NULL;
int length = -1;
bool ok;
for (ok = false; !ok; ok = true)
{
self_exe = fopen(WAI_PROC_SELF_EXE, "r");
if (!self_exe)
break;
if (!fgets(buffer1, sizeof(buffer1), self_exe))
break;
resolved = realpath(buffer1, buffer2);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
fclose(self_exe);
return ok ? length : -1;
}
WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
char buffer[PATH_MAX];
char* resolved = NULL;
int length = -1;
for(;;)
{
Dl_info info;
if (dladdr(WAI_RETURN_ADDRESS(), &info))
{
resolved = realpath(info.dli_fname, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
break;
}
return length;
}
#elif defined(__DragonFly__) || defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <dlfcn.h>
#include <stdbool.h>
#if defined(__OpenBSD__)
#include <unistd.h>
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
char buffer1[4096];
char buffer2[PATH_MAX];
char buffer3[PATH_MAX];
char** argv = (char**)buffer1;
char* resolved = NULL;
int length = -1;
bool ok;
for (ok = false; !ok; ok = true)
{
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
size_t size;
if (sysctl(mib, 4, NULL, &size, NULL, 0) != 0)
break;
if (size > sizeof(buffer1))
{
argv = (char**)WAI_MALLOC(size);
if (!argv)
break;
}
if (sysctl(mib, 4, argv, &size, NULL, 0) != 0)
break;
if (strchr(argv[0], '/'))
{
resolved = realpath(argv[0], buffer2);
if (!resolved)
break;
}
else
{
const char* PATH = getenv("PATH");
if (!PATH)
break;
size_t argv0_length = strlen(argv[0]);
const char* begin = PATH;
while (1)
{
const char* separator = strchr(begin, ':');
const char* end = separator ? separator : begin + strlen(begin);
if (end - begin > 0)
{
if (*(end -1) == '/')
--end;
if (((end - begin) + 1 + argv0_length + 1) <= sizeof(buffer2))
{
memcpy(buffer2, begin, end - begin);
buffer2[end - begin] = '/';
memcpy(buffer2 + (end - begin) + 1, argv[0], argv0_length + 1);
resolved = realpath(buffer2, buffer3);
if (resolved)
break;
}
}
if (!separator)
break;
begin = ++separator;
}
if (!resolved)
break;
}
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
if (argv != (char**)buffer1)
WAI_FREE(argv);
return ok ? length : -1;
}
#else
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
char buffer1[PATH_MAX];
char buffer2[PATH_MAX];
char* path = buffer1;
char* resolved = NULL;
int length = -1;
bool ok;
for (ok = false; !ok; ok = true)
{
#if defined(__NetBSD__)
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME };
#else
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
#endif
size_t size = sizeof(buffer1);
if (sysctl(mib, 4, path, &size, NULL, 0) != 0)
break;
resolved = realpath(path, buffer2);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
return ok ? length : -1;
}
#endif
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
char buffer[PATH_MAX];
char* resolved = NULL;
int length = -1;
for(;;)
{
Dl_info info;
if (dladdr(WAI_RETURN_ADDRESS(), &info))
{
resolved = realpath(info.dli_fname, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
break;
}
return length;
}
#else
#error unsupported platform
#endif
#ifdef __cplusplus
}
#endif

67
engine/common/whereami.h Normal file
View File

@ -0,0 +1,67 @@
// (‑●‑●)> dual licensed under the WTFPL v2 and MIT licenses
// without any warranty.
// by Gregory Pakosz (@gpakosz)
// https://github.com/gpakosz/whereami
#ifndef WHEREAMI_H
#define WHEREAMI_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WAI_FUNCSPEC
#define WAI_FUNCSPEC
#endif
#ifndef WAI_PREFIX
#define WAI_PREFIX(function) wai_##function
#endif
/**
* Returns the path to the current executable.
*
* Usage:
* - first call `int length = wai_getExecutablePath(NULL, 0, NULL);` to
* retrieve the length of the path
* - allocate the destination buffer with `path = (char*)malloc(length + 1);`
* - call `wai_getExecutablePath(path, length, NULL)` again to retrieve the
* path
* - add a terminal NUL character with `path[length] = '\0';`
*
* @param out destination buffer, optional
* @param capacity destination buffer capacity
* @param dirname_length optional recipient for the length of the dirname part
* of the path.
*
* @return the length of the executable path on success (without a terminal NUL
* character), otherwise `-1`
*/
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length);
/**
* Returns the path to the current module
*
* Usage:
* - first call `int length = wai_getModulePath(NULL, 0, NULL);` to retrieve
* the length of the path
* - allocate the destination buffer with `path = (char*)malloc(length + 1);`
* - call `wai_getModulePath(path, length, NULL)` again to retrieve the path
* - add a terminal NUL character with `path[length] = '\0';`
*
* @param out destination buffer, optional
* @param capacity destination buffer capacity
* @param dirname_length optional recipient for the length of the dirname part
* of the path.
*
* @return the length of the module path on success (without a terminal NUL
* character), otherwise `-1`
*/
WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length);
#ifdef __cplusplus
}
#endif
#endif // #ifndef WHEREAMI_H

View File

@ -91,8 +91,8 @@ void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char
pool->totalsize += size;
// big allocations are not clumped
pool->realsize += sizeof( memheader_t ) + size + sizeof( int );
mem = (memheader_t *)Q_malloc( sizeof( memheader_t ) + size + sizeof( int ));
pool->realsize += sizeof( memheader_t ) + size + sizeof( size_t );
mem = (memheader_t *)Q_malloc( sizeof( memheader_t ) + size + sizeof( size_t ));
if( mem == NULL ) Sys_Error( "Mem_Alloc: out of memory (alloc at %s:%i)\n", filename, fileline );
mem->filename = filename;
@ -162,7 +162,7 @@ static void Mem_FreeBlock( memheader_t *mem, const char *filename, int fileline
// memheader has been unlinked, do the actual free now
pool->totalsize -= mem->size;
pool->realsize -= sizeof( memheader_t ) + mem->size + sizeof( int );
pool->realsize -= sizeof( memheader_t ) + mem->size + sizeof( size_t );
Q_free( mem );
}

39
engine/cursor_type.h Normal file
View File

@ -0,0 +1,39 @@
/*
cursor_type.h - enumeration of possible mouse cursor types
Copyright (C) 2022 FWGS Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#pragma once
#ifndef CURSOR_TYPE_H
#define CURSOR_TYPE_H
typedef enum
{
dc_user,
dc_none,
dc_arrow,
dc_ibeam,
dc_hourglass,
dc_crosshair,
dc_up,
dc_sizenwse,
dc_sizenesw,
dc_sizewe,
dc_sizens,
dc_sizeall,
dc_no,
dc_hand,
dc_last
} VGUI_DefaultCursor;
#endif

View File

@ -278,6 +278,9 @@ typedef struct enginefuncs_s
void (*pfnQueryClientCvarValue)( const edict_t *player, const char *cvarName );
void (*pfnQueryClientCvarValue2)( const edict_t *player, const char *cvarName, int requestID );
int (*pfnCheckParm)( char *parm, char **ppnext );
// added in 8279
edict_t* (*pfnPEntityOfEntIndexAllEntities)( int iEntIndex );
} enginefuncs_t;
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138

35
engine/key_modifiers.h Normal file
View File

@ -0,0 +1,35 @@
/*
key_modifiers.h - enumeration of possible key modifiers
Copyright (C) 2022 FWGS Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#pragma once
#ifndef KEY_MODIFIERS_H
#define KEY_MODIFIERS_H
typedef enum
{
KeyModifier_None = 0,
KeyModifier_LeftShift = (1 << 0),
KeyModifier_RightShift = (1 << 1),
KeyModifier_LeftCtrl = (1 << 2),
KeyModifier_RightCtrl = (1 << 3),
KeyModifier_LeftAlt = (1 << 4),
KeyModifier_RightAlt = (1 << 5),
KeyModifier_LeftSuper = (1 << 6),
KeyModifier_RightSuper = (1 << 7),
KeyModifier_NumLock = (1 << 8),
KeyModifier_CapsLock = (1 << 9)
} key_modifier_t;
#endif

View File

@ -21,9 +21,9 @@
//
#define K_TAB 9
#define K_ENTER 13
#define K_ESCAPE 27
#define K_ESCAPE 27
#define K_SPACE 32
#define K_SCROLLOCK 70
#define K_SCROLLOCK 70
// normal keys should be passed as lowercased ascii
@ -59,7 +59,7 @@
#define K_KP_UPARROW 161
#define K_KP_PGUP 162
#define K_KP_LEFTARROW 163
#define K_KP_5 164
#define K_KP_5 164
#define K_KP_RIGHTARROW 165
#define K_KP_END 166
#define K_KP_DOWNARROW 167
@ -71,8 +71,9 @@
#define K_KP_MINUS 173
#define K_KP_PLUS 174
#define K_CAPSLOCK 175
#define K_KP_NUMLOCK 176
#define K_KP_MUL 176
#define K_WIN 177
#define K_KP_NUMLOCK 178
//
// joystick buttons
@ -143,30 +144,30 @@
#define K_AUX19 225
#define K_DPAD_RIGHT K_AUX19
#define K_AUX20 226
#define K_AUX21 227
#define K_AUX22 228
#define K_AUX23 229
#define K_AUX24 230
#define K_AUX25 231
#define K_AUX26 232
#define K_AUX27 233
#define K_AUX28 234
#define K_AUX29 235
#define K_AUX30 236
#define K_AUX31 237
#define K_AUX32 238
#define K_AUX20 226
#define K_AUX21 227
#define K_AUX22 228
#define K_AUX23 229
#define K_AUX24 230
#define K_AUX25 231
#define K_AUX26 232
#define K_AUX27 233
#define K_AUX28 234
#define K_AUX29 235
#define K_AUX30 236
#define K_AUX31 237
#define K_AUX32 238
#define K_MWHEELDOWN 239
#define K_MWHEELUP 240
#define K_PAUSE 255
#define K_PAUSE 255
//
// mouse buttons generate virtual keys
//
#define K_MOUSE1 241
#define K_MOUSE2 243
#define K_MOUSE3 242
#define K_MOUSE2 242
#define K_MOUSE3 243
#define K_MOUSE4 244
#define K_MOUSE5 245

View File

@ -31,6 +31,7 @@ typedef int HIMAGE; // handle to a graphic
#define PIC_NEAREST (1<<0) // disable texfilter
#define PIC_KEEP_SOURCE (1<<1) // some images keep source
#define PIC_NOFLIP_TGA (1<<2) // Steam background completely ignore tga attribute 0x20
#define PIC_EXPAND_SOURCE (1<<3) // don't keep as 8-bit source, expand to RGBA
// flags for COM_ParseFileSafe
#define PFILE_IGNOREBRACKET (1<<0)
@ -88,10 +89,10 @@ typedef struct ui_enginefuncs_s
const char* (*pfnCmd_Args)( void );
// debug messages (in-menu shows only notify)
void (*Con_Printf)( const char *fmt, ... );
void (*Con_DPrintf)( const char *fmt, ... );
void (*Con_NPrintf)( int pos, const char *fmt, ... );
void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... );
void (*Con_Printf)( const char *fmt, ... ) _format( 1 );
void (*Con_DPrintf)( const char *fmt, ... ) _format( 1 );
void (*Con_NPrintf)( int pos, const char *fmt, ... ) _format( 2 );
void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... ) _format( 2 );
// sound handlers
void (*pfnPlayLocalSound)( const char *szSound );
@ -117,7 +118,7 @@ typedef struct ui_enginefuncs_s
int (*CL_CreateVisibleEntity)( int type, struct cl_entity_s *ent );
// misc handlers
void (*pfnHostError)( const char *szFmt, ... );
void (*pfnHostError)( const char *szFmt, ... ) _format( 1 );
int (*pfnFileExists)( const char *filename, int gamedironly );
void (*pfnGetGameDir)( char *szGetGameDir );
@ -214,6 +215,8 @@ typedef struct ui_extendedfuncs_s {
char *(*pfnParseFile)( char *data, char *buf, const int size, unsigned int flags, int *len );
const char *(*pfnAdrToString)( const struct netadr_s a );
const ref_device_t *(*pfnGetRenderDevice)( unsigned int idx );
} ui_extendedfuncs_t;

View File

@ -776,17 +776,29 @@ void Platform_ShellExecute( const char *path, const char *parms )
// no need to free jstr
}
void Platform_GetClipboardText( char *buffer, size_t size )
int Platform_GetClipboardText( char *buffer, size_t size )
{
// stub
if( size ) buffer[0] = 0;
return 0;
}
void Platform_SetClipboardText( const char *buffer, size_t size )
void Platform_SetClipboardText( const char *buffer )
{
// stub
}
void Platform_SetCursorType( VGUI_DefaultCursor cursor )
{
// stub
}
key_modifier_t Platform_GetKeyModifiers( void )
{
// stub
return KeyModifier_None;
}
void Platform_PreCreateMove( void )
{
// stub

View File

@ -34,7 +34,7 @@ void *ANDROID_LoadLibrary( const char *dllname )
if( !libdir[i] )
continue;
Q_snprintf( path, MAX_SYSPATH, "%s/lib%s"POSTFIX"."OS_LIB_EXT, libdir[i], dllname );
Q_snprintf( path, MAX_SYSPATH, "%s/lib%s."OS_LIB_EXT, libdir[i], dllname );
pHandle = dlopen( path, RTLD_LAZY );
if( pHandle )
return pHandle;
@ -51,7 +51,7 @@ void *ANDROID_LoadLibrary( const char *dllname )
}
else
{
Q_snprintf( path, MAX_SYSPATH, "lib%s"POSTFIX"."OS_LIB_EXT, dllname );
Q_snprintf( path, MAX_SYSPATH, "lib%s."OS_LIB_EXT, dllname );
pHandle = dlopen( path, RTLD_LAZY );
if( pHandle )
return pHandle;

View File

@ -20,6 +20,8 @@ GNU General Public License for more details.
#include "common.h"
#include "system.h"
#include "defaults.h"
#include "cursor_type.h"
#include "key_modifiers.h"
#include "ref_vulkan.h"
/*
@ -46,6 +48,12 @@ const char *Android_LoadID( void );
void Android_SaveID( const char *id );
#endif
#if XASH_WIN32
void Platform_UpdateStatusLine( void );
#else
static inline void Platform_UpdateStatusLine( void ) { }
#endif
/*
==============================================================================
@ -67,6 +75,7 @@ void*Platform_GetNativeObject( const char *name );
int Platform_JoyInit( int numjoy ); // returns number of connected gamepads, negative if error
// Text input
void Platform_EnableTextInput( qboolean enable );
key_modifier_t Platform_GetKeyModifiers( void );
// System events
void Platform_RunEvents( void );
// Mouse
@ -74,9 +83,10 @@ void Platform_GetMousePos( int *x, int *y );
void Platform_SetMousePos( int x, int y );
void Platform_PreCreateMove( void );
void Platform_MouseMove( float *x, float *y );
void Platform_SetCursorType( VGUI_DefaultCursor type );
// Clipboard
void Platform_GetClipboardText( char *buffer, size_t size );
void Platform_SetClipboardText( const char *buffer, size_t size );
int Platform_GetClipboardText( char *buffer, size_t size );
void Platform_SetClipboardText( const char *buffer );
#if XASH_SDL == 12
#define SDL_SetWindowGrab( wnd, state ) SDL_WM_GrabInput( (state) )

View File

@ -15,8 +15,7 @@ GNU General Public License for more details.
#define _GNU_SOURCE
#include "platform/platform.h"
#if XASH_LIB == LIB_POSIX
#include <dlfcn.h>
#include "common.h"
#include "library.h"
#include "filesystem.h"
@ -103,7 +102,7 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d
// try to find by linker(LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, LD_32_LIBRARY_PATH and so on...)
if( !pHandle )
{
pHandle = dlopen( dllname, RTLD_LAZY );
pHandle = dlopen( dllname, RTLD_NOW );
if( pHandle )
return pHandle;
@ -140,7 +139,7 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d
else
#endif
{
if( !( hInst->hInstance = dlopen( hInst->fullPath, RTLD_LAZY ) ) )
if( !( hInst->hInstance = dlopen( hInst->fullPath, RTLD_NOW ) ) )
{
COM_PushLibraryError( dlerror() );
Mem_Free( hInst );
@ -189,12 +188,7 @@ void *COM_GetProcAddress( void *hInstance, const char *name )
void *COM_FunctionFromName( void *hInstance, const char *pName )
{
void *function;
if( !( function = COM_GetProcAddress( hInstance, pName ) ) )
{
Con_Reportf( S_ERROR "FunctionFromName: Can't get symbol %s: %s\n", pName, dlerror());
}
return function;
return COM_GetProcAddress( hInstance, pName );
}
#ifdef XASH_DYNAMIC_DLADDR

View File

@ -122,7 +122,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
#endif
qboolean numLock = SDL_GetModState() & KMOD_NUM;
if( SDL_IsTextInputActive() && down )
if( SDL_IsTextInputActive() && down && cls.key_dest != key_game )
{
if( SDL_GetModState() & KMOD_CTRL )
{
@ -271,30 +271,29 @@ SDLash_MouseEvent
static void SDLash_MouseEvent( SDL_MouseButtonEvent button )
{
int down = button.state != SDL_RELEASED;
qboolean istouch;
uint mstate = 0;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
istouch = button.which == SDL_TOUCH_MOUSEID;
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
istouch = false;
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
if( button.which == SDL_TOUCH_MOUSEID )
return;
#endif
switch( button.button )
{
case SDL_BUTTON_LEFT:
SDLash_MouseKey( K_MOUSE1, down, istouch );
IN_MouseEvent( 0, down );
break;
case SDL_BUTTON_RIGHT:
SDLash_MouseKey( K_MOUSE2, down, istouch );
IN_MouseEvent( 1, down );
break;
case SDL_BUTTON_MIDDLE:
SDLash_MouseKey( K_MOUSE3, down, istouch );
IN_MouseEvent( 2, down );
break;
case SDL_BUTTON_X1:
SDLash_MouseKey( K_MOUSE4, down, istouch );
IN_MouseEvent( 3, down );
break;
case SDL_BUTTON_X2:
SDLash_MouseKey( K_MOUSE5, down, istouch );
IN_MouseEvent( 4, down );
break;
#if ! SDL_VERSION_ATLEAST( 2, 0, 0 )
case SDL_BUTTON_WHEELUP:
@ -319,6 +318,7 @@ SDLash_InputEvent
static void SDLash_InputEvent( SDL_TextInputEvent input )
{
char *text;
VGui_ReportTextInput( input.text );
for( text = input.text; *text; text++ )
{
int ch;
@ -341,7 +341,11 @@ static void SDLash_ActiveEvent( int gain )
if( gain )
{
host.status = HOST_FRAME;
IN_ActivateMouse( true );
if( cls.key_dest == key_game )
{
IN_ActivateMouse( );
}
if( dma.initialized && snd_mute_losefocus.value )
{
SNDDMA_Activate( true );
@ -361,7 +365,11 @@ static void SDLash_ActiveEvent( int gain )
}
#endif
host.status = HOST_NOFOCUS;
IN_DeactivateMouse();
if( cls.key_dest == key_game )
{
IN_DeactivateMouse();
}
if( dma.initialized && snd_mute_losefocus.value )
{
SNDDMA_Activate( false );
@ -426,13 +434,10 @@ static void SDLash_EventFilter( SDL_Event *event )
{
/* Mouse events */
case SDL_MOUSEMOTION:
if( !host.mouse_visible
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
&& event->motion.which != SDL_TOUCH_MOUSEID )
#else
)
#endif
IN_MouseEvent();
if( host.mouse_visible )
{
SDL_GetRelativeMouseState( NULL, NULL );
}
break;
case SDL_MOUSEBUTTONUP:

View File

@ -33,5 +33,11 @@ void VID_SaveWindowSize( int width, int height );
// joystick events
extern SDL_Joystick *g_joy;
//
// in_sdl.c
//
void SDLash_InitCursors( void );
void SDLash_FreeCursors( void );
#endif // XASH_SDL
#endif // KEYWRAPPER_H

Some files were not shown because too many files have changed in this diff Show More