Compare commits

..

88 Commits

Author SHA1 Message Date
Alibek Omarov
8044646a2b First merge attempt (many PSP tunings are missing, as they are outdated now) 2024-01-18 06:51:13 +03:00
Crow-bar
cae351f7b1 engine: psp math optimization, QuaternionSlerp, BoundsIntersect, Mod_SetStudioHullPlane 2022-12-20 11:10:04 +03:00
Crow-bar
9812a9104b ref_gu: clipping code update 2022-12-07 17:03:11 +03:00
Crow-bar
d419921ca3 engine: psp filesystem fix 2022-12-06 11:46:31 +03:00
Crow-bar
3ccb156554 platform: using hw psp mp3 decoder for streams 2022-11-21 11:14:22 +03:00
Crow-bar
15ea61ea34 psp: mainui update 2022-11-11 10:10:47 +03:00
Crow-bar
e6a9724d7c platform: psp joystick curve support 2022-11-02 16:40:39 +03:00
Crow-bar
28723b01a9 platform: psp PATH_MAX fix 2022-11-02 16:38:33 +03:00
Crow-bar
0dc1c13b83 engine: psp Adrenaline bug 2022-11-02 16:36:23 +03:00
Crow-bar
1704712650 platform: psp fixed issues with libc 2022-11-02 09:52:42 +03:00
Crow-bar
066d87f546 ref_gu: depth mask returned 2022-10-31 09:34:16 +03:00
Crow-bar
0b500168a7 ref_gu: gl_nosort cvar removed 2022-10-31 09:32:22 +03:00
Crow-bar
e3e5fe8e18 platform: psp filesystem helper strip_path 2022-10-31 09:21:37 +03:00
Crow-bar
da161103b1 ref_gu: correct ONE/ZERO modifier for sceGuBlendFunc 2022-10-20 16:57:48 +03:00
Crow-bar
d6d8ee3e57 ref_gu: updated initial GU settings 2022-10-20 16:54:06 +03:00
Crow-bar
89ee68d5d0 ref_gu: depth bug fixed, sort code removed 2022-10-20 16:50:48 +03:00
Crow-bar
f5ca0175a5 engine: DSP optimization 2022-10-20 16:45:05 +03:00
Crow-bar
5559f728b7 waf: psp profiling flags for c++ 2022-10-19 10:57:21 +03:00
Crow-bar
238687affa Merge branch 'psp-tgapal' into psp 2022-10-18 09:51:35 +03:00
Crow-bar
5832d017c7 Merge branch 'psp-triapi' into psp 2022-10-18 09:51:22 +03:00
Crow-bar
4e78898c6f Merge branch 'psp-cachedfs' into psp 2022-10-18 09:51:06 +03:00
Crow-bar
c6520b83b2 server: sv_save.c: checking P5Ram_Alloc results; memory leak fix 2022-10-18 09:31:03 +03:00
Crow-bar
a440d1ff7a paltform: psp filesystem helper update 2022-10-18 09:19:57 +03:00
Crow-bar
3889ed8c52 engine: using sceIoRemove() instead of remove() for psp 2022-10-14 15:37:24 +03:00
Crow-bar
53d44f4c0e paltform: psp filesystem helper 2022-10-13 14:40:02 +03:00
Crow-bar
bdc2009683 server: minor fix for inline functions 2022-10-12 11:04:35 +03:00
Crow-bar
a375adb9ea ref_gu: skybox_ext reordering 2022-10-10 16:54:11 +03:00
Crow-bar
122a11005b imagelib: hardware palette support for tga 2022-10-10 16:49:01 +03:00
Crow-bar
f70938d2b0 ref_gl: ref_soft: ref_gu: engine: TriAPI update 2022-10-10 16:44:48 +03:00
Crow-bar
40dca1ea1f ref_gu: vsync fix 2022-10-06 16:58:33 +03:00
Crow-bar
f8452b8490 ref_gu: R_TextureList_f total size fix 2022-10-06 16:45:15 +03:00
Crow-bar
3b50fded8b ref_gu: menu freeze fix 2022-10-06 15:25:07 +03:00
Crow-bar
5ad4f43a7e waf: self.onlypsp fixed 2022-10-05 10:42:11 +03:00
Crow-bar
ef117ffbb3 readme: psp profiling 2022-10-05 10:36:39 +03:00
Crow-bar
8850d2ae52 waf: updated build rules for psp 2022-10-05 10:26:13 +03:00
Crow-bar
e66400ca39 engine: net_encode.c, net_buffer.c inline functions optimization 2022-10-04 10:31:33 +03:00
Crow-bar
01affdcbbd psp: lower sound thread priority 2022-10-04 10:27:31 +03:00
Crow-bar
ed2ba1f226 psp: additional buttons, when pressed HOME 2022-10-04 10:27:01 +03:00
Crow-bar
1abec2620a psp: fixed bug in asm code, returned vsqrt+vrcp in TransformPositivePlane and TransformStandartPlane 2022-10-04 09:00:49 +03:00
Crow-bar
f4ae5cf8e0 platform: using sceKernelGetSystemTimeWide instead of sceRtcGetCurrentTick 2022-10-03 08:19:49 +03:00
Crow-bar
57ddff5457 engine: R_BreakModel limit reduction for psp 2022-10-02 21:36:41 +03:00
Crow-bar
d98330adca psp: asm code optimization 2022-10-02 12:38:12 +03:00
Crow-bar
21ed285da7 engine: psp filetime fix 2022-09-21 17:01:14 +03:00
Crow-bar
b517019750 platform: p5 allocator fix; ref_gu: using vram for palettes 2022-09-21 15:31:26 +03:00
Crow-bar
b567531cdb platform: PSP volatile(P5) memory allocator 2022-09-21 08:58:02 +03:00
Crow-bar
9c61941e52 ref_gu: code cleanup, fix spaces and tabs, asm Matrix_FromOriginQuat 2022-09-09 10:18:29 +03:00
Crow-bar
3afc7134ab ref_gu: efx optimization 2022-09-05 11:58:33 +03:00
Crow-bar
bcf838c42f engine: .bss size reduction for PSP 2022-08-30 16:47:03 +03:00
Crow-bar
91d6fdd190 psp: using the maximum amount of VRAM 2022-08-10 16:58:20 +03:00
Crow-bar
b8ff41eac9 psp: removed dll_psp.h 2022-08-10 16:49:49 +03:00
Alibek Omarov
0277700977 gitignore: fix waf ignores 2022-08-10 16:44:09 +03:00
Crow-bar
da68591f03 ref_gu: .bss size reduction 2022-06-16 14:14:55 +03:00
Crow-bar
da695b75c4 engine: using MSGBOX in developer mode (Sys_Error) 2022-06-16 14:08:01 +03:00
Crow-bar
1b4bc7f5ec platform: module loader refactoring 2022-06-16 09:59:01 +03:00
Crow-bar
cbfb43f05b engine: NORETURN macro disabled for PSP 2022-06-10 13:32:03 +03:00
Crow-bar
db9e82cdec engine: CL_IsPlayerIndex macro 2022-06-10 11:19:16 +03:00
Crow-bar
12889494e0 ref_gu: reducing the number of calls to CL_GetEntityLight and CL_GetDynamicLight 2022-06-10 10:49:07 +03:00
Crow-bar
f2d59eb7f8 ref_gu: studio model optimization 2022-06-09 11:13:29 +03:00
Crow-bar
3a3b8e2c4a ref_gu: triapi update 2022-06-08 16:15:38 +03:00
Crow-bar
1e132bf29e ref_gu: added rgb 332 format; changeable output format in R_BuildLightMap 2022-06-01 16:16:51 +03:00
Crow-bar
d35330cd55 psp: enabled console background image 2022-06-01 14:55:43 +03:00
Crow-bar
c07c1357e5 platform: buttons layout update 2022-05-27 15:11:38 +03:00
Crow-bar
8071355d68 ref_soft: framebuffer width fix 2022-05-27 15:00:30 +03:00
Crow-bar
6073e35bfc vid_psp.c: CRLF -> LF 2022-05-27 14:58:47 +03:00
Crow-bar
8e8a0e4908 ref_gu: optimized sprites and particles 2022-05-26 15:53:31 +03:00
Crow-bar
1d7176751c ref_gu: pixel converter update 2022-05-25 16:56:53 +03:00
Crow-bar
07e29771a1 ref_gu: refactoring 2022-05-24 08:35:13 +03:00
Crow-bar
89ec7122fe ref_gu: cleanup, added texture wrap mode in GL_Bind 2022-05-17 11:50:04 +03:00
Crow-bar
fe8fea742d filesystem: added XASH_NO_ZIP define, 64 byte alignment for file buffer 2022-05-13 09:59:00 +03:00
Crow-bar
2ab8bce924 ref_gu: texture min size fixed 2022-05-05 21:54:18 +03:00
Crow-bar
90faeb231f optimization: aligned memory access, vfpu math 2022-05-05 21:50:14 +03:00
Crow-bar
2885d44593 platform: 60 fps cap fix 2022-05-04 10:49:07 +03:00
Crow-bar
4dfdbdd6aa ref_gu: unnecessary operations 2022-04-25 16:44:01 +03:00
Crow-bar
5eb19c1478 ref_gu: viewport bug fixed 2022-04-24 23:34:39 +03:00
Crow-bar
13a9c41b0c added .vscode/ to .gitignore 2022-04-16 18:38:11 +03:00
Crow-bar
2eef2cec49 sound: psp sound output rewritten 2022-04-16 12:39:02 +03:00
Crow-bar
7be87a913d filesystem: small changes 2022-04-14 14:54:52 +03:00
Crow-bar
dc22f5cbaf vox: MAX_SENTENCES changed to 2048 2022-04-14 10:17:28 +03:00
Crow-bar
5c244b4140 filesystem: Stream_OpenWAV hold mode fix 2022-04-11 14:53:01 +03:00
Crow-bar
e7e10ac8b9 filesystem: hold mode fix 2022-04-10 21:34:43 +03:00
Crow-bar
a308ce2f48 ref_gu: texture loader update 2022-04-09 17:34:42 +03:00
Crow-bar
eea17a4e32 Matrix_CreateFromEntity ASM BUG 2022-04-09 17:28:09 +03:00
Crow-bar
cab187618d FCVAR_GLCONFIG permission update 2022-04-09 17:26:42 +03:00
Crow-bar
32e175311b mainui update 2022-04-07 11:24:55 +03:00
Crow-bar
190279c117 system user name 2022-04-05 22:35:13 +03:00
Crow-bar
f5aaa58ff9 readme: update 2022-04-03 18:10:58 +03:00
Crow-bar
cd37d866c2 code cleanup 2022-04-03 18:00:12 +03:00
Sergey Galushko
64020b2902 PSP Port initial 2022-03-30 21:36:08 +03:00
366 changed files with 41053 additions and 13351 deletions

View File

@@ -1,27 +0,0 @@
image: alpine/latest
packages:
- build-base
- sdl2-dev
- freetype-dev
- fontconfig-dev
- opus-dev
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
./waf configure -8 --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
./waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-alpine-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-alpine-amd64.tar.bz2

View File

@@ -1,30 +0,0 @@
image: debian/sid
arch: amd64
packages:
- build-essential
- python-is-python3
- libsdl2-dev
- libfreetype-dev
- libfontconfig-dev
- libopus-dev
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
./waf configure -8 --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
./waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-debian-arm64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-debian-arm64.tar.bz2

View File

@@ -1,29 +0,0 @@
image: debian/sid
packages:
- build-essential
- python-is-python3
- libsdl2-dev
- libfreetype-dev
- libfontconfig-dev
- libopus-dev
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
./waf configure -8 --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
./waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-debian-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-debian-amd64.tar.bz2

View File

@@ -1,29 +0,0 @@
image: freebsd/latest
packages:
- lang/python
- devel/pkgconf
- devel/sdl20
- print/freetype2
- x11-fonts/fontconfig
- audio/opus
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
./waf configure --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
./waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-freebsd-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-freebsd-amd64.tar.bz2

View File

@@ -1,29 +0,0 @@
image: netbsd/latest
packages:
- python311
- SDL2
- freetype2
- fontconfig
- libopus
- pkgconf
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
python3.11 waf configure --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
python3.11 waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-netbsd-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-netbsd-amd64.tar.bz2

View File

@@ -1,26 +0,0 @@
image: openbsd/latest
packages:
- python3
- sdl2
- opus
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
python3 waf configure --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
python3 waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-openbsd-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-openbsd-amd64.tar.bz2

View File

@@ -1,7 +1,32 @@
task:
# Seems packages for it were removed from the mirrors
# name: freebsd-12-amd64
# freebsd_instance:
# image_family: freebsd-12-4
# setup_script:
# - pkg update
# - pkg install -y pkgconf git sdl2 python fontconfig opus
# - git submodule update --init --recursive
# test_script:
# - ./scripts/cirrus/build_freebsd.sh dedicated
# - ./scripts/cirrus/build_freebsd.sh full
task:
name: freebsd-13-amd64
freebsd_instance:
image_family: freebsd-13-2
setup_script:
- pkg update
- pkg install -y pkgconf git sdl2 python fontconfig opus
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
- ./scripts/cirrus/build_freebsd.sh full
task:
name: freebsd-14-amd64
freebsd_instance:
image_family: freebsd-14-0
image_family: freebsd-14-0-snap
setup_script:
- pkg update
- pkg install -y pkgconf git sdl2 python fontconfig opus

View File

@@ -1,365 +1,9 @@
# this file is just a suggestion, you might follow it, you might not
# EditorConfig is awesome: https://EditorConfig.org
root = true
[*]
charset = utf-8
charset = latin1
end_of_line = lf
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]
# Visual C++ Formatting settings
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = true
cpp_indent_case_contents = true
cpp_indent_case_labels = false
cpp_indent_case_contents_when_block = false
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_goto_labels = one_left
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = false
cpp_new_line_before_open_brace_namespace = new_line
cpp_new_line_before_open_brace_type = new_line
cpp_new_line_before_open_brace_function = new_line
cpp_new_line_before_open_brace_block = new_line
cpp_new_line_before_open_brace_lambda = new_line
cpp_new_line_scope_braces_on_separate_lines = true
cpp_new_line_close_brace_same_line_empty_type = false
cpp_new_line_close_brace_same_line_empty_function = false
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = false
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = true
cpp_space_between_empty_parameter_list_parentheses = true
cpp_space_after_keywords_in_control_flow_statements = false
cpp_space_within_control_flow_statement_parentheses = true
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = true
cpp_space_before_block_open_brace = true
cpp_space_between_empty_braces = true
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = true
cpp_space_preserve_in_initializer_list = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = true
cpp_space_before_constructor_colon = true
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = true
cpp_space_remove_around_unary_operator = true
cpp_space_around_binary_operator = insert
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = right
cpp_space_around_ternary_operator = insert
cpp_use_unreal_engine_macro_formatting = true
cpp_wrap_preserve_blocks = one_liners
# IDEA settings
ij_c_add_brief_tag = false
ij_c_add_getter_prefix = true
ij_c_add_setter_prefix = true
ij_c_align_dictionary_pair_values = false
ij_c_align_group_field_declarations = false
ij_c_align_init_list_in_columns = true
ij_c_align_multiline_array_initializer_expression = false
ij_c_align_multiline_assignment = false
ij_c_align_multiline_binary_operation = false
ij_c_align_multiline_chained_methods = false
ij_c_align_multiline_for = true
ij_c_align_multiline_ternary_operation = false
ij_c_array_initializer_comma_on_next_line = false
ij_c_array_initializer_new_line_after_left_brace = false
ij_c_array_initializer_right_brace_on_new_line = false
ij_c_array_initializer_wrap = off
ij_c_assignment_wrap = off
ij_c_binary_operation_sign_on_next_line = false
ij_c_binary_operation_wrap = off
ij_c_blank_lines_after_class_header = 0
ij_c_blank_lines_after_imports = 1
ij_c_blank_lines_around_class = 1
ij_c_blank_lines_around_field = 0
ij_c_blank_lines_around_field_in_interface = 0
ij_c_blank_lines_around_method = 1
ij_c_blank_lines_around_method_in_interface = 1
ij_c_blank_lines_around_namespace = 0
ij_c_blank_lines_around_properties_in_declaration = 0
ij_c_blank_lines_around_properties_in_interface = 0
ij_c_blank_lines_before_imports = 1
ij_c_blank_lines_before_method_body = 0
ij_c_block_brace_placement = next_line
ij_c_block_brace_style = next_line
ij_c_block_comment_at_first_column = true
ij_c_catch_on_new_line = false
ij_c_class_brace_style = next_line
ij_c_class_constructor_init_list_align_multiline = true
ij_c_class_constructor_init_list_comma_on_next_line = false
ij_c_class_constructor_init_list_new_line_after_colon = never
ij_c_class_constructor_init_list_new_line_before_colon = if_long
ij_c_class_constructor_init_list_wrap = normal
ij_c_copy_is_deep = false
ij_c_create_interface_for_categories = true
ij_c_declare_generated_methods = true
ij_c_description_include_member_names = true
ij_c_discharged_short_ternary_operator = false
ij_c_do_not_add_breaks = false
ij_c_do_while_brace_force = never
ij_c_else_on_new_line = false
ij_c_enum_constants_comma_on_next_line = false
ij_c_enum_constants_wrap = off
ij_c_for_brace_force = never
ij_c_for_statement_new_line_after_left_paren = false
ij_c_for_statement_right_paren_on_new_line = false
ij_c_for_statement_wrap = off
ij_c_function_brace_placement = next_line
ij_c_function_call_arguments_align_multiline = true
ij_c_function_call_arguments_align_multiline_pars = false
ij_c_function_call_arguments_comma_on_next_line = false
ij_c_function_call_arguments_new_line_after_lpar = false
ij_c_function_call_arguments_new_line_before_rpar = false
ij_c_function_call_arguments_wrap = normal
ij_c_function_non_top_after_return_type_wrap = normal
ij_c_function_parameters_align_multiline = true
ij_c_function_parameters_align_multiline_pars = false
ij_c_function_parameters_comma_on_next_line = false
ij_c_function_parameters_new_line_after_lpar = false
ij_c_function_parameters_new_line_before_rpar = false
ij_c_function_parameters_wrap = normal
ij_c_function_top_after_return_type_wrap = normal
ij_c_generate_additional_eq_operators = true
ij_c_generate_additional_rel_operators = true
ij_c_generate_class_constructor = true
ij_c_generate_comparison_operators_use_std_tie = false
ij_c_generate_instance_variables_for_properties = ask
ij_c_generate_operators_as_members = true
ij_c_header_guard_style_pattern = ${PROJECT_NAME}_${FILE_NAME}_${EXT}
ij_c_if_brace_force = never
ij_c_in_line_short_ternary_operator = true
ij_c_indent_block_comment = true
ij_c_indent_c_struct_members = 4
ij_c_indent_case_from_switch = true
ij_c_indent_class_members = 4
ij_c_indent_directive_as_code = false
ij_c_indent_implementation_members = 0
ij_c_indent_inside_code_block = 4
ij_c_indent_interface_members = 0
ij_c_indent_interface_members_except_ivars_block = false
ij_c_indent_namespace_members = 4
ij_c_indent_preprocessor_directive = 0
ij_c_indent_visibility_keywords = 0
ij_c_insert_override = true
ij_c_insert_virtual_with_override = false
ij_c_introduce_auto_consts = false
ij_c_introduce_auto_vars = false
ij_c_introduce_const_params = false
ij_c_introduce_const_vars = false
ij_c_introduce_constexpr_consts = false
ij_c_introduce_generate_property = false
ij_c_introduce_generate_synthesize = true
ij_c_introduce_globals_to_header = true
ij_c_introduce_prop_to_private_category = false
ij_c_introduce_static_consts = true
ij_c_introduce_use_ns_types = false
ij_c_ivars_prefix = _
ij_c_ivars_suffix =
ij_c_keep_blank_lines_before_end = 2
ij_c_keep_blank_lines_before_right_brace = 2
ij_c_keep_blank_lines_in_code = 2
ij_c_keep_blank_lines_in_declarations = 2
ij_c_keep_case_expressions_in_one_line = false
ij_c_keep_control_statement_in_one_line = false
ij_c_keep_directive_at_first_column = true
ij_c_keep_first_column_comment = false
ij_c_keep_line_breaks = true
ij_c_keep_nested_namespaces_in_one_line = false
ij_c_keep_simple_blocks_in_one_line = false
ij_c_keep_simple_methods_in_one_line = false
ij_c_keep_structures_in_one_line = false
ij_c_lambda_capture_list_align_multiline = false
ij_c_lambda_capture_list_align_multiline_bracket = false
ij_c_lambda_capture_list_comma_on_next_line = false
ij_c_lambda_capture_list_new_line_after_lbracket = false
ij_c_lambda_capture_list_new_line_before_rbracket = false
ij_c_lambda_capture_list_wrap = off
ij_c_line_comment_add_space = false
ij_c_line_comment_at_first_column = true
ij_c_method_brace_placement = end_of_line
ij_c_method_call_arguments_align_by_colons = true
ij_c_method_call_arguments_align_multiline = false
ij_c_method_call_arguments_special_dictionary_pairs_treatment = true
ij_c_method_call_arguments_wrap = off
ij_c_method_call_chain_wrap = off
ij_c_method_parameters_align_by_colons = true
ij_c_method_parameters_align_multiline = false
ij_c_method_parameters_wrap = off
ij_c_namespace_brace_placement = next_line
ij_c_parentheses_expression_new_line_after_left_paren = false
ij_c_parentheses_expression_right_paren_on_new_line = false
ij_c_place_assignment_sign_on_next_line = false
ij_c_property_nonatomic = true
ij_c_put_ivars_to_implementation = true
ij_c_refactor_compatibility_aliases_and_classes = true
ij_c_refactor_properties_and_ivars = true
ij_c_release_style = ivar
ij_c_retain_object_parameters_in_constructor = true
ij_c_semicolon_after_method_signature = false
ij_c_shift_operation_align_multiline = true
ij_c_shift_operation_wrap = normal
ij_c_show_non_virtual_functions = false
ij_c_space_after_colon = true
ij_c_space_after_colon_in_foreach = true
ij_c_space_after_colon_in_selector = false
ij_c_space_after_comma = true
ij_c_space_after_cup_in_blocks = false
ij_c_space_after_dictionary_literal_colon = true
ij_c_space_after_for_semicolon = true
ij_c_space_after_init_list_colon = true
ij_c_space_after_method_parameter_type_parentheses = false
ij_c_space_after_method_return_type_parentheses = false
ij_c_space_after_pointer_in_declaration = false
ij_c_space_after_quest = true
ij_c_space_after_reference_in_declaration = false
ij_c_space_after_reference_in_rvalue = false
ij_c_space_after_structures_rbrace = true
ij_c_space_after_superclass_colon = true
ij_c_space_after_type_cast = false
ij_c_space_after_visibility_sign_in_method_declaration = true
ij_c_space_before_autorelease_pool_lbrace = true
ij_c_space_before_catch_keyword = true
ij_c_space_before_catch_left_brace = true
ij_c_space_before_catch_parentheses = false
ij_c_space_before_category_parentheses = true
ij_c_space_before_chained_send_message = true
ij_c_space_before_class_left_brace = true
ij_c_space_before_colon = true
ij_c_space_before_colon_in_foreach = true
ij_c_space_before_comma = false
ij_c_space_before_dictionary_literal_colon = true
ij_c_space_before_do_left_brace = true
ij_c_space_before_else_keyword = true
ij_c_space_before_else_left_brace = true
ij_c_space_before_export_lbrace = true
ij_c_space_before_for_left_brace = true
ij_c_space_before_for_parentheses = false
ij_c_space_before_for_semicolon = false
ij_c_space_before_if_left_brace = true
ij_c_space_before_if_parentheses = false
ij_c_space_before_init_list = false
ij_c_space_before_init_list_colon = true
ij_c_space_before_method_call_parentheses = false
ij_c_space_before_method_left_brace = true
ij_c_space_before_method_parentheses = false
ij_c_space_before_namespace_lbrace = true
ij_c_space_before_pointer_in_declaration = true
ij_c_space_before_property_attributes_parentheses = false
ij_c_space_before_protocols_brackets = true
ij_c_space_before_quest = true
ij_c_space_before_reference_in_declaration = true
ij_c_space_before_superclass_colon = true
ij_c_space_before_switch_left_brace = true
ij_c_space_before_switch_parentheses = false
ij_c_space_before_template_call_lt = false
ij_c_space_before_template_declaration_lt = true
ij_c_space_before_try_left_brace = true
ij_c_space_before_while_keyword = true
ij_c_space_before_while_left_brace = true
ij_c_space_before_while_parentheses = false
ij_c_space_between_adjacent_brackets = false
ij_c_space_between_operator_and_punctuator = false
ij_c_space_within_empty_array_initializer_braces = true
ij_c_spaces_around_additive_operators = true
ij_c_spaces_around_assignment_operators = true
ij_c_spaces_around_bitwise_operators = true
ij_c_spaces_around_equality_operators = true
ij_c_spaces_around_lambda_arrow = true
ij_c_spaces_around_logical_operators = true
ij_c_spaces_around_multiplicative_operators = true
ij_c_spaces_around_pm_operators = false
ij_c_spaces_around_relational_operators = true
ij_c_spaces_around_shift_operators = true
ij_c_spaces_around_unary_operator = false
ij_c_spaces_within_array_initializer_braces = true
ij_c_spaces_within_braces = false
ij_c_spaces_within_brackets = false
ij_c_spaces_within_cast_parentheses = false
ij_c_spaces_within_catch_parentheses = true
ij_c_spaces_within_category_parentheses = false
ij_c_spaces_within_empty_braces = false
ij_c_spaces_within_empty_function_call_parentheses = true
ij_c_spaces_within_empty_function_declaration_parentheses = true
ij_c_spaces_within_empty_lambda_capture_list_bracket = false
ij_c_spaces_within_empty_template_call_ltgt = false
ij_c_spaces_within_empty_template_declaration_ltgt = false
ij_c_spaces_within_for_parentheses = true
ij_c_spaces_within_function_call_parentheses = true
ij_c_spaces_within_function_declaration_parentheses = true
ij_c_spaces_within_if_parentheses = true
ij_c_spaces_within_lambda_capture_list_bracket = false
ij_c_spaces_within_method_parameter_type_parentheses = false
ij_c_spaces_within_method_return_type_parentheses = false
ij_c_spaces_within_parentheses = true
ij_c_spaces_within_property_attributes_parentheses = false
ij_c_spaces_within_protocols_brackets = false
ij_c_spaces_within_send_message_brackets = false
ij_c_spaces_within_structured_binding_list_bracket = false
ij_c_spaces_within_switch_parentheses = true
ij_c_spaces_within_template_call_ltgt = false
ij_c_spaces_within_template_declaration_ltgt = false
ij_c_spaces_within_template_double_gt = false
ij_c_spaces_within_while_parentheses = true
ij_c_special_else_if_treatment = true
ij_c_structured_binding_list_align_multiline = false
ij_c_structured_binding_list_align_multiline_bracket = false
ij_c_structured_binding_list_comma_on_next_line = false
ij_c_structured_binding_list_new_line_after_lbracket = false
ij_c_structured_binding_list_new_line_before_rbracket = false
ij_c_structured_binding_list_wrap = off
ij_c_superclass_list_after_colon = never
ij_c_superclass_list_align_multiline = true
ij_c_superclass_list_before_colon = if_long
ij_c_superclass_list_comma_on_next_line = false
ij_c_superclass_list_wrap = on_every_item
ij_c_tag_prefix_of_block_comment = at
ij_c_tag_prefix_of_line_comment = back_slash
ij_c_template_call_arguments_align_multiline = false
ij_c_template_call_arguments_align_multiline_pars = false
ij_c_template_call_arguments_comma_on_next_line = false
ij_c_template_call_arguments_new_line_after_lt = false
ij_c_template_call_arguments_new_line_before_gt = false
ij_c_template_call_arguments_wrap = off
ij_c_template_declaration_function_body_indent = false
ij_c_template_declaration_function_wrap = split_into_lines
ij_c_template_declaration_struct_body_indent = false
ij_c_template_declaration_struct_wrap = split_into_lines
ij_c_template_parameters_align_multiline = false
ij_c_template_parameters_align_multiline_pars = false
ij_c_template_parameters_comma_on_next_line = false
ij_c_template_parameters_new_line_after_lt = false
ij_c_template_parameters_new_line_before_gt = false
ij_c_template_parameters_wrap = off
ij_c_ternary_operation_signs_on_next_line = false
ij_c_ternary_operation_wrap = off
ij_c_type_qualifiers_placement = before
ij_c_use_modern_casts = true
ij_c_use_setters_in_constructor = true
ij_c_while_brace_force = never
ij_c_while_on_new_line = false
ij_c_wrap_property_declaration = off

1
.github/FUNDING.yml vendored
View File

@@ -1 +0,0 @@
custom: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/donate.md

View File

@@ -24,9 +24,14 @@ jobs:
# - os: ubuntu-aarch64-20.04
# targetos: linux
# targetarch: aarch64
- os: ubuntu-20.04
targetos: android
targetarch: multiarch
# - os: ubuntu-20.04
# targetos: android
# targetarch: 32
# - os: ubuntu-20.04
# targetos: android
# targetarch: 64
# - os: ubuntu-20.04
# targetos: motomagx
# targetarch: armv6
@@ -43,82 +48,81 @@ jobs:
- os: windows-2019 # always use the oldest possible for 32-bit because of older compilers, and better support of certain legacy OSes
targetos: win32
targetarch: i386
- os: macos-14 # in GitHub documentation, it's an ARM64 machine
targetos: apple
targetarch: arm64
- os: macos-12 # in GitHub documentation, it's an x86 machine
targetos: apple
targetarch: amd64
env:
SDL_VERSION: 2.30.3
SDL_VERSION: 2.28.5
GH_CPU_ARCH: ${{ matrix.targetarch }}
ANDROID_SDK_TOOLS_VER: 4333796
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install dependencies
run: bash scripts/gha/deps_${{ matrix.targetos }}.sh
- name: Build engine
env:
FWGS_PFX_PASSWORD: ${{ secrets.FWGS_PFX_PASSWORD }}
run: bash scripts/gha/build_${{ matrix.targetos }}.sh
- name: Upload engine (artifacts)
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }}
path: artifacts/*
flatpak:
name: "Flatpak"
runs-on: ubuntu-latest
strategy:
matrix:
include:
- app: su.xash.Engine.Compat.i386
container:
image: bilelmoussaoui/flatpak-github-actions:freedesktop-23.08
image: bilelmoussaoui/flatpak-github-actions:freedesktop-22.08
options: --privileged
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build flatpak (Compat.i386)
uses: FWGS/flatpak-github-actions/flatpak-builder@v6.3
uses: FWGS/flatpak-github-actions/flatpak-builder@v6.1
with:
bundle: ${{ matrix.app }}.flatpak
manifest-path: scripts/flatpak/${{ matrix.app }}.yml
- name: Upload engine (artifacts)
uses: actions/upload-artifact@v3
with:
name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }}
path: artifacts/*
release:
name: "Upload releases"
runs-on: ubuntu-latest
needs: [build, flatpak]
if: ${{ github.event_name == 'push' }}
steps:
- name: Remove old release, fetch artifacts, repackage binaries and upload new release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }}
- name: Remove old release
uses: FWGS/delete-tag-and-release@v0.2.1-dev
with:
tag_name: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }}
delete_release: true
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch artifacts
uses: actions/download-artifact@v3.0.1
with:
path: artifacts/
- name: Repackage binaries and allow GitHub to process removed release for few seconds
run: |
gh release delete "$RELEASE_TAG" \
--yes \
--cleanup-tag \
--repo "$GITHUB_REPOSITORY" || true
sleep 20s
gh run download "$GITHUB_RUN_ID" \
--dir artifacts/ \
--repo "$GITHUB_REPOSITORY"
pushd artifacts/
echo "Found artifacts:"
ls
for i in $(find -mindepth 1 -maxdepth 1 -type d); do
cd artifacts/
for i in artifact-* su.xash.Engine.*; do
mv "$i"/* .
rm -rf "$i"
done
echo "Repackaged artifacts:"
ls -R
popd
ls -R .
cd ../
sleep 20s
gh release create "$RELEASE_TAG" artifacts/* \
--title "Xash3D FWGS Continuous ${{ github.ref_name }} Build" \
--target $GITHUB_SHA \
--repo "$GITHUB_REPOSITORY" \
--prerelease
- name: Upload new release
uses: FWGS/action-gh-release@v0.1.15
with:
name: Xash3D FWGS Continuous ${{ github.ref_name }} Build
tag_name: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }}
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
files: artifacts/*
draft: false

5
.gitignore vendored
View File

@@ -54,11 +54,6 @@ CMakeFiles
Makefile
cmake_install.cmake
install_manifest.txt
CMakeLists.txt*
CMakeScripts
Testing
compile_commands.json
_deps
# makedepend
Makefile.dep
*.bak

View File

@@ -18,7 +18,7 @@ def build(bld):
target = 'gl4es',
features = 'c',
includes = ['gl4es/src', 'gl4es/src/gl', 'gl4es/src/glx', 'gl4es/include'],
defines = ['NOX11', 'NO_GBM', 'NO_INIT_CONSTRUCTOR', 'DEFAULT_ES=2', 'NOEGL', 'NO_LOADER', 'STATICLIB'],
defines = ['NOX11', 'NO_GBM', 'NO_INIT_CONSTRUCTOR', 'DEFAULT_ES=2', 'NOEGL', 'EXTERNAL_GETPROCADDRESS=GL4ES_GetProcAddress', 'NO_LOADER', 'STATICLIB'],
cflags = ['-w', '-fvisibility=hidden', '-std=gnu99'],
subsystem = bld.env.MSVC_SUBSYSTEM,
export_includes = '.')

View File

@@ -1,17 +1,17 @@
# Bug-compatibility in Xash3D FWGS
Xash3D FWGS has special mode for games that rely on original engine bugs. In this mode, we emulate the behaviour of selected functions that may help running mods relying on engine bugs, but enabling them by default may break majority of other games.
Xash3D FWGS has special mode for games that rely on original engine bugs.
In this mode, we emulate the behaviour of selected functions that may help running mods relying on engine bugs, but enabling them by default may break majority of other games.
At this time, we only have implemented GoldSrc bug-compatibility. It can be enabled with `-bugcomp` command line switch.
When `-bugcomp` is specified without argument, it enables everything. This behavior might be changed or removed in future versions.
When `-bugcomp` is specified with argument, it interpreted as flags separated with `+`. This way it's possible to combine multiple levels of bug-compatibility.
## GoldSrc bug-compatibility
| Flag | Description | Games that require this flag |
| ------- | ----------- | ---------------------------- |
| `peoei` | Reverts `pfnPEntityOfEntIndex` behavior to GoldSrc, where it returns NULL for last player due to incorrect player index comparison | * Counter-Strike: Condition Zero - Deleted Scenes |
| `gsmrf` | Rewrites message at the moment when Game DLL attempts to write an internal engine message, usually specific to GoldSrc protocol. Right now only supports `svc_spawnstaticsound`, more messages added by request. | * MetaMod/AMXModX based mods |
| `sp_attn_none` | Makes sounds with attenuation zero spatialized, i.e. have a stereo effect. | Possibly, every game that was made for GoldSrc. |
### Emulated bugs
* `pfnPEntityOfEntIndex` in GoldSrc returns NULL for last player due to incorrect player index comparison
### Games and mods that require this
* Counter-Strike: Condition Zero - Deleted Scenes

View File

@@ -1,21 +0,0 @@
## Environment variables
#### Xash3D FWGS
The engine respects these environment variables:
| Variable | Type | Description |
| --------------------- | ---------- | ----------- |
| `XASH3D_GAME` | _string_ | Overrides default game directory. Ignored if `-game` command line argument is set |
| `XASH3D_BASEDIR` | _string_ | Sets path to base (root) directory, instead of current working directory |
| `XASH3D_RODIR` | _string_ | Sets path to read-only base (root) directory. Ignored if `-rodir` command line argument is set |
| `XASH3D_EXTRAS_PAK1` | _string_ | Archive file from specified path will be added to virtual filesystem search path in the lowest possible priority |
| `XASH3D_EXTRAS_PAK2` | _string_ | Similar to `XASH3D_EXTRAS_PAK1` but next to it in priority list |
Environment variables NOT listed in the table above are used internally, and aren't considered as stable interface.
#### mdldec
| Variable | Type | Description |
| --------------------- | ---------- | ----------- |
| `MDLDEC_ACT_PATH` | _string_ | If set, will read activities list from this path |

View File

@@ -1,25 +0,0 @@
# GetNativeObject API
To be able to use platform-specific features or get optional engine interfaces, we've added a simple call to MobilityAPI on client DLL and PhysicsAPI for server DLL and extended MenuAPI for menu DLL.
It's defined like this:
```
void *pfnGetNativeObject( const char *name );
```
#### Cross-platform objects
Only these objects are guaranteed to be available on all targets.
| Object name | Interface |
|-------------|-----------|
| `VFileSystem009` | Provides C++ interface to filesystem, binary-compatible with Valve's VFileSystem009. |
| `XashFileSystemXXX` | Provides C interface to filesystem. This interface is unstable and not recommended for generic use, outside of engine internals. For more info about current version look into `filesystem.h`. |
#### Android-specific objects
| Object name | Interface |
|-------------|-----------|
| `JNIEnv` | Allows interfacing with Java Native Interface. |
| `ActivityClass` | Returns JNI object for engine Android activity class. |

View File

@@ -1,65 +0,0 @@
# sounds.lst.md
Using sounds.lst located in scripts folder, modder can override some of the hardcoded sounds in temp entities and server physics.
File format:
```
<group name>
{
<path1>
<path2>
<path3>
}
<group2 name> <path with %d> <min number> <max number>
```
* Sounds can use any supported sound format (WAV or MP3).
* The path must be relative to the sounds/ folder in the game or base directory root, addon folder, or archive root.
* Groups can be empty or omitted from the file to load no sound.
* Groups can either list a set of files or specify a format string and a range.
* Anything after // will be considered a comment and ignored.
* Behavior is undefined if the group was listed multiple times.
Currently supported groups are:
|Group name|Usage|
|----------|-----|
|`BouncePlayerShell`|Used for BOUNCE_SHELL tempentity hitsound|
|`BounceWeaponShell`|Used for BOUCNE_SHOTSHELL tempentity hitsound|
|`BounceConcrete`|Used for BOUNCE_CONCRETE tempentity hitsound|
|`BounceGlass`|Used for BOUCNE_GLASS|
|`BounceMetal`|Used for BOUNCE_METAL|
|`BounceFlesh`|Used for BOUNCE_FLESH|
|`BounceWood`|Used for BOUNCE_WOOD|
|`Ricochet`|Used for BOUNCE_SHRAP and ricochet tempentities|
|`Explode`|Used for tempentity explosions|
|`EntityWaterEnter`|Used for entity entering water|
|`EntityWaterExit`|Used for entity exiting water|
|`PlayerWaterEnter`|Used for player entering water|
|`PlayerWaterExit`|Used for player exiting water|
## Example
This example is based on defaults sounds used in Half-Life:
```
BouncePlayerShell "player/pl_shell%d.wav" 1 3
BounceWeaponShell "weapons/sshell%d.wav" 1 3
BounceConcrete "debris/concrete%d.wav" 1 3
BounceGlass "debris/glass%d.wav" 1 4
BounceMetal "debris/metal%d.wav" 1 6
BounceFlesh "debris/flesh%d.wav" 1 7
BounceWood "debris/wood%d.wav" 1 4
Ricochet "weapons/ric%d.wav" 1 5
Explode "weapons/explode%d.wav" 3 5
EntityWaterEnter "player/pl_wade%d.wav" 1 4
EntityWaterExit "player/pl_wade%d.wav" 1 4
PlayerWaterEnter
{
"player/pl_wade1.wav"
}
PlayerWaterExit
{
"player/pl_wade2.wav"
}
```

View File

@@ -78,7 +78,6 @@ These strings are specific to Xash3D FWGS.
| `internal_vgui_support` | boolean | 0 | Only for programmers! Required to be set as 1 for PrimeXT!<br>When set to 1, the engine will not load vgui_support DLL, as VGUI support is done (or intentionally ignored) on the game side. |
| `render_picbutton_text` | boolean | 0 | When set to 1, the UI will not use prerendered `btns_main.bmp` and dynamically render them instead |
| `quicksave_aged_count` | integer | 2 | Quick saves limit used in saves rotation |
| `demomap` | string | Empty string | The name of the demo chapter map (Half-Life Uplink) |
## Note on GoldSrc liblist.gam support

View File

@@ -1,40 +0,0 @@
### HD (external) textures support
Xash3D supports loading texture replacements in TGA format for almost all types of models in the game, except alias models at this time.
Textures are expected to be located at:
* `modfolder/materials/<mapname>` - for a specific map
* `modfolder/materials/common` - common for all maps
* `modfolder/materials/decals` - for decals
* `modfolder/materials/models/<model>` - for models (texture name must match the internal texture name in the model)
Support for high-resolution textures is enabled setting `host_allow_materials` cvar to `1` or in the menu, in "Video options" section.
#### Xash3D FWGS additions
In addition to paths above, Xash3D FWGS checks following paths:
* `modfolder/materials/sprites/<sprite>` - for sprites, except HUD sprites
Also, to check which texture replacements are loaded successfully, failed or weren't found, a mod developer can set `host_allow_materials` cvar value to `2`. The engine will spew log at any developer level in the following format:
```
Looking for <replacement> replacement... <status code> (<path relative to mod directory>)
```
Status codes:
* `OK` - texture replacement file was found and loaded into GPU memory successfully
* `FAIL` - texture file was found but hasn't been parsed or loaded successfully. Refer to engine log for more details.
* `MISS` - texture file wasn't found
Example:
```
Looking for maps/bounce.bsp:!waterblue tex replacement...OK (materials/common/!waterblue.tga)
Looking for maps/bounce.bsp:!waterblue_luma tex replacement...MISS (not found)
Looking for {shot2 decal replacement...MISS (materials/decals/{shot2.tga)
Looking for {shot4 decal replacement...MISS (materials/decals/{shot4.tga)
Looking for {shot3 decal replacement...MISS (materials/decals/{shot3.tga)
Looking for models/gman tex replacement...FAIL (materials/models/gman/GMan_Case1.tga)
Looking for models/gman tex replacement...FAIL (materials/models/gman/inside_1.tga)
```

View File

@@ -1,15 +0,0 @@
# Xash3D FWGS on `musl`
Xash3D FWGS works on `musl` out of the box. However, the engine doesn't try to differentiate glibc and musl anymore. If you see error similar to:
```
Host_InitError: can't initialize cl_dlls/client.so: Error relocating valve/cl_dlls/client.so: __sprintf_chk: symbol not found
```
... or you know that the game you're running is linked against glibc, you can try using `libgcompat`, like this:
```
$ LD_PRELOAD=/lib/libgcompat.so.0 ./xash3d ...
```
It will automatically add the missing symbols that glibc binaries usually need. In the future we might automatically link engine against `libgcompat` for better compatibility with prebuilt or closed-source games, if there will be any use for this.

View File

@@ -19,22 +19,7 @@
- [List of XashXT-based mods](#list-of-xashxt-based-mods)
- [List of maps for They Hunger](#list-of-maps-for-they-hunger)
- [List of games and mods with custom gamedll](#list-of-games-and-mods-with-custom-gamedll)
- [List of mods for Counter Strike](#list-of-mods-for-counter-strike)
- [List of supported mods from mobile_hacks branch of HLSDK Portable by FWGS](#list-of-supported-mods-from-mobile_hacks-branch-of-hlsdk-portable-by-fwgs)
# List of supported mods from mobile_hacks branch of HLSDK Portable by FWGS
1. [Afraid of Monsters](https://www.moddb.com/mods/afraid-of-monsters/downloads/afraid-of-monsters-v1)
2. [Big Lolly](https://www.moddb.com/mods/big-lolly)
3. [Half-Life: Blue Shift](https://store.steampowered.com/app/130/HalfLife_Blue_Shift/)
4. [Half-Secret](https://www.moddb.com/mods/half-secret)
5. [Case Closed](https://www.moddb.com/mods/caseclosed)
6. [Bloody Pizza - Vendetta](https://www.moddb.com/games/half-life/addons/bloody-pizza-vendetta)
7. [Borderlands](https://www.moddb.com/games/half-life/addons/borderlands-v04)
8. [Half-Life: Induction](https://www.moddb.com/mods/half-life-induction/downloads/half-life-induction-12)
9. [Redemption/Absolute Redemption](https://www.moddb.com/mods/absolute-redemption)
10. [Sewer beta](https://www.moddb.com/games/half-life/addons/sewer-beta)
11. [Times of Troubles](https://www.moddb.com/mods/times-of-troubles)
12. [Half-Life: Urbicide](https://www.moddb.com/mods/half-life-urbicide)
- [List of mods for Counter Strike(Android only)](#list-of-mods-for-counter-strike)
# List of Half-Life-based mods
Originally this list was written by *Qwertyus*(*Qortez*)
@@ -191,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)](https://web.archive.org/web/20161026104825/http://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)
@@ -297,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)](https://web.archive.org/web/20110512012317/http://www.richmans-maps.ch.vu/)
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)
@@ -320,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](https://web.archive.org/web/20110512012317/http://www.richmans-maps.ch.vu/)
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](https://web.archive.org/web/20110512012317/http://www.richmans-maps.ch.vu/)
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)
@@ -394,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)](https://web.archive.org/web/20160407041812/http://half-life.ru/forum/showthread.php?threadid=13959) (download links dead!)
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)
@@ -455,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://web.archive.org/web/20151030005310/http://www.gamefront.com/files/13532512)
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)
@@ -513,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](https://web.archive.org/web/20170221213409/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!)

View File

@@ -1,8 +1,8 @@
# Xash3D FWGS Engine <img align="right" width="128" height="128" src="https://github.com/FWGS/xash3d-fwgs/raw/master/game_launch/icon-xash-material.png" alt="Xash3D FWGS icon" />
[![builds.sr.ht status](https://builds.sr.ht/~a1batross/xash3d-fwgs.svg)](https://builds.sr.ht/~a1batross/xash3d-fwgs?) [![GitHub Actions Status](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [![FreeBSD Build Status](https://img.shields.io/cirrus/github/FWGS/xash3d-fwgs?label=freebsd%20build)](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](http://fwgsdiscord.mentality.rip/) \
[![GitHub Actions Status](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [![FreeBSD Build Status](https://img.shields.io/cirrus/github/FWGS/xash3d-fwgs?label=freebsd%20build)](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](http://fwgsdiscord.mentality.rip/) \
[![Download Stable](https://img.shields.io/badge/download-stable-yellow)](https://github.com/FWGS/xash3d-fwgs/releases/latest) [![Download Testing](https://img.shields.io/badge/downloads-testing-orange)](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous)
Xash3D (pronounced `[ksɑʂ]`) FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
Xash3D FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://www.moddb.com/engines/xash3d-engine) by Unkle Mike.
@@ -28,7 +28,7 @@ If you like Xash3D FWGS, consider supporting individual engine maintainers. By s
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.
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-portable).
This repository contains our fork of HLSDK and restored source code for Half-Life expansions and some mods.
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).
@@ -46,11 +46,11 @@ NOTE: NEVER USE GitHub's ZIP ARCHIVES. GitHub doesn't include external dependenc
### Prerequisites
If your CPU is x86 compatible and you're on Windows or Linux, we are building 32-bit code by default. This was done to maintain compatibility with Steam releases of Half-Life and based on it's engine games.
If your CPU is x86 compatible, we are building 32-bit code by default. This was done to maintain 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-portable).
This repository contains our fork of HLSDK and restored source code for Half-Life expansions and some mods.
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.
@@ -73,6 +73,10 @@ This repository contains our fork of HLSDK and restored source code for Half-Lif
* Clone this repostory:
`$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`
#### PSP
* Build pspsdk(GCC 9.3) from https://github.com/pspdev
* Clone this repository: `git clone --recursive https://github.com/Crow-bar/xash3d-fwgs`.
### Building
#### Windows (Visual Studio)
0) Open command line
@@ -90,3 +94,20 @@ If compiling 32-bit on amd64, you may need to supply `export PKG_CONFIG_PATH=/us
(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`
#### PSP
0) Navigate to `xash3d-fwgs` directory.
1) Examine which build options are available: `./waf --help`
2) Configure build:
Normal: `./waf configure -T fast --psp=prx,660,HW --prefix=/path/to/any/output/directory`
Profiling: `./waf configure -T debug --psp=elf,660,HW --enable-profiling --prefix=/path/to/any/output/directory`
3) Compile: `./waf build`
4) Install(optional): `./waf install`
## Running
0) Copy libraries and main executable somewhere, if you're skipped installation stage.
1) Copy game files to same directory
2) Run `xash3d.exe`/`xash3d.sh`/`xash3d` depending on which platform you're using.
For additional info, run Xash3D with `-help` command line key.

View File

@@ -20,16 +20,19 @@ GNU General Public License for more details.
#define VIDEO_SDL 1
#define VIDEO_FBDEV 3
#define VIDEO_DOS 4
#define VIDEO_PSP 5
// audio backends (XASH_SOUND)
#define SOUND_NULL 0
#define SOUND_SDL 1
#define SOUND_ALSA 3
#define SOUND_PSP 4
// input (XASH_INPUT)
#define INPUT_NULL 0
#define INPUT_SDL 1
#define INPUT_EVDEV 3
#define INPUT_PSP 4
// timer (XASH_TIMER)
#define TIMER_NULL 0 // not used
@@ -37,17 +40,20 @@ GNU General Public License for more details.
#define TIMER_POSIX 2
#define TIMER_WIN32 3
#define TIMER_DOS 4
#define TIMER_PSP 5
// messageboxes (XASH_MESSAGEBOX)
#define MSGBOX_STDERR 0
#define MSGBOX_SDL 1
#define MSGBOX_WIN32 3
#define MSGBOX_NSWITCH 4
#define MSGBOX_PSP 5
// library loading (XASH_LIB)
#define LIB_NULL 0
#define LIB_POSIX 1
#define LIB_WIN32 2
#define LIB_NULL 0
#define LIB_POSIX 1
#define LIB_WIN32 2
#define LIB_STATIC 3
#define LIB_PSP 4
#endif /* BACKENDS_H */

25
common/boneinfo.h Normal file
View File

@@ -0,0 +1,25 @@
/*
boneinfo.h - structure that send delta-compressed bones across network
Copyright (C) 2018 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 BONEINFO_H
#define BONEINFO_H
typedef struct
{
vec3_t angles;
vec3_t origin;
} boneinfo_t;
#endif//BONEINFO_H

View File

@@ -23,6 +23,7 @@ NOTE: number at end of pixelformat name it's a total bitscount e.g. PF_RGB_24 ==
|| type == PF_BC7_UNORM \
|| type == PF_BC7_SRGB \
|| type == PF_KTX2_RAW )
#define ImageIND( type ) (type == PF_INDEXED_32 || type == PF_INDEXED_24)
typedef enum
{
@@ -33,6 +34,10 @@ typedef enum
PF_BGRA_32, // big endian RGBA (MacOS)
PF_RGB_24, // uncompressed dds or another 24-bit image
PF_BGR_24, // big-endian RGB (MacOS)
PF_RGB_332, // 8-bit R3 G3 B2
PF_RGB_5650, // 16-bit R5 G6 B5
PF_RGBA_5551, // 16-bit R5 G5 B5 A1
PF_RGBA_4444, // 16-bit R4 G4 B4 A4
PF_LUMINANCE,
PF_DXT1, // s3tc DXT1/BC1 format
PF_DXT3, // s3tc DXT3/BC2 format

View File

@@ -127,24 +127,30 @@ typedef struct
int flags; // sky or slime, no lightmap or 256 subdivision
} mtexinfo_t;
// a1ba: changed size to avoid undefined behavior. Check your allocations if you take this header!
// For example:
// before: malloc( sizeof( glpoly_t ) + ( numverts - 4 ) * VERTEXSIZE * sizeof( float ))
// after (C): malloc( sizeof( glpoly_t ) + numverts * VERTEXSIZE * sizeof( float ))
// after (C++): malloc( sizeof( glpoly_t ) + ( numverts - 1 ) * VERTEXSIZE * sizeof( float ))
typedef struct glpoly2_s
#if XASH_PSP
typedef struct
{
struct glpoly2_s *next;
struct glpoly2_s *chain;
float uv[2];
float xyz[3];
}gu_vert_t;
typedef struct glpoly_s
{
struct glpoly_s *next;
struct glpoly_s *chain;
int numverts;
int flags; // for SURF_UNDERWATER
gu_vert_t verts[1]; // variable sized (xyz s1t1 + lm(xyz s2t2))
} glpoly_t;
#else
typedef struct glpoly_s
{
struct glpoly_s *next;
struct glpoly_s *chain;
int numverts;
int flags; // for SURF_UNDERWATER
#ifdef __cplusplus
float verts[1][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
#else
float verts[][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
} glpoly_t;
#endif
} glpoly2_t;
typedef struct mnode_s
{
// common with leaf
@@ -182,7 +188,7 @@ struct decal_s
short entityIndex; // Entity this is attached to
// Xash3D specific
vec3_t position; // location of the decal center in world space.
glpoly2_t *polys; // precomputed decal vertices
glpoly_t *polys; // precomputed decal vertices
intptr_t reserved[4]; // just for future expansions or mod-makers
};
@@ -255,7 +261,7 @@ struct msurface_s
int light_s, light_t; // gl lightmap coordinates
glpoly2_t *polys; // multiple if warped
glpoly_t *polys; // multiple if warped
struct msurface_s *texturechain;
mtexinfo_t *texinfo;
@@ -497,8 +503,7 @@ typedef struct
int flags;
float size;
const trivertex_t **pposeverts; // only valid during loading, used to build GL mesh
intptr_t reserved[7]; // VBO offsets
int reserved[8]; // VBO offsets
int numposes;
int poseverts;
@@ -541,10 +546,8 @@ typedef struct
#define MAX_MOVIES 8
#define MAX_CDTRACKS 32
#define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client)
#define MAX_EFRAGS 8192 // Arcane Dimensions required
#define MAX_REQUESTS 64
STATIC_CHECK_SIZEOF( mextrasurf_t, 324, 496 );
STATIC_CHECK_SIZEOF( decal_t, 60, 88 );
STATIC_CHECK_SIZEOF( mfaceinfo_t, 176, 304 );
#endif//COM_MODEL_H

View File

@@ -1,122 +1,49 @@
/*
cvardef.h - quake cvar definition
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2024 Alibek Omarov
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#ifndef CVARDEF_H
#define CVARDEF_H
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 2
of the License, or (at your option) any later version.
#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc
#define FCVAR_USERINFO (1<<1) // changes the client's info string
#define FCVAR_SERVER (1<<2) // notifies players when changed
#define FCVAR_EXTDLL (1<<3) // defined by external DLL
#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar
#define FCVAR_PRIVILEGED (1<<10) // only available in privileged mode
#define FCVAR_FILTERABLE (1<<11) // filtered in unprivileged mode if cl_filterstuffcmd is 1
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.
// Xash3D extensions
#define FCVAR_GLCONFIG (1<<12) // write it into <renderer>.cfg(see RefAPI)
#define FCVAR_CHANGED (1<<13) // set each time the cvar is changed
#define FCVAR_GAMEUIDLL (1<<14) // defined by the menu DLL
#define FCVAR_CHEAT (1<<15) // can not be changed if cheats are disabled
See the GNU General Public License for more details.
// a1ba: let's reuse higher bits for flags extensions from now on
#define FCVAR_LATCH (1<<30) // notify client what this cvar will be applied only after server restart (but don't does more nothing)
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef CVAR
#define CVAR
#include STDINT_H
#include "xash3d_types.h"
/*
cvar_t variables are used to hold scalar or string variables that can be changed
or displayed at the console or prog code as well as accessed directly
in C code.
The user can access cvars from the console in three ways:
r_draworder prints the current value
r_draworder 0 sets the current value to 0
set r_draworder 0 as above, but creates the cvar if not present
Cvars are restricted from having the same names as commands to keep this
interface from being ambiguous.
The are also occasionally used to communicated information between different
modules of the program.
*/
enum
typedef struct cvar_s
{
// GoldSrc compatibility flags
FCVAR_ARCHIVE = 1 << 0, // set to cause it to be saved to vars.rc
FCVAR_USERINFO = 1 << 1, // added to userinfo when changed
FCVAR_SERVER = 1 << 2, // added to serverinfo when changed, will notify clients by default
FCVAR_EXTDLL = 1 << 3, // defined by server.dll
FCVAR_CLIENTDLL = 1 << 4, // defined by client.dll
FCVAR_PROTECTED = 1 << 5, // private server cvar
FCVAR_SPONLY = 1 << 6, // can be set only in singleplayer
FCVAR_PRINTABLEONLY = 1 << 7, // only allows printable characters
FCVAR_UNLOGGED = 1 << 8, // disables notifying client about server cvar change
FCVAR_NOEXTRAWHITESPACE = 1 << 9, // removes space characters from the beginning and the end of the string
FCVAR_PRIVILEGED = 1 << 10, // only available in privileged mode
FCVAR_FILTERABLE = 1 << 11, // treated as privileged if cl_filterstuffcmd is 1, otherwise ignored
char *name;
char *string;
int flags;
float value;
struct cvar_s *next;
} cvar_t;
// Xash3D public flags
// FCVAR_LATCH = 1 << 11, // deprecated Xash3D flag, conflicts with FCVAR_FILTERABLE. Use another FCVAR_LATCH!
FCVAR_GLCONFIG = 1 << 12, // set to cause it to be saved to <renderer>.cfg (see RefAPI)
FCVAR_CHANGED = 1 << 13, // set each time the cvar changed
FCVAR_GAMEUIDLL = 1 << 14, // defined by menu.dll
FCVAR_CHEAT = 1 << 15, // cannot be changed if sv_cheats is 0
#if REF_DLL || ENGINE_DLL // Xash3D internal flags, MUST NOT be used outside of engine
FCVAR_RENDERINFO = 1 << 16, // set to cause it to be saved to video.cfg
FCVAR_READ_ONLY = 1 << 17, // display only, cannot be set by user at all
FCVAR_EXTENDED = 1 << 18, // extended cvar structure
FCVAR_ALLOCATED = 1 << 19, // allocated by the engine, must be freed with Mem_Free
FCVAR_VIDRESTART = 1 << 20, // triggers video subsystem to recreate/modify window parameters
FCVAR_TEMPORARY = 1 << 21, // only used to temporarly hold some value, can be unlinked
FCVAR_MOVEVARS = 1 << 22, // access to movevars_t structure, synchornized between client and server
FCVAR_USER_CREATED = 1 << 23, // created by a set command
FCVAR_REFDLL = 1 << 29, // (Xash3D FWGS internal flag) defined by the renderer DLL
#endif // REF_DLL || ENGINE_DLL
FCVAR_LATCH = 1 << 30, // (Xash3D FWGS public flag, was FCVAR_FILTERABLE in Xash3D) save changes until server restart
};
struct cvar_s {
char *name;
char *string;
uint32_t flags;
float value;
struct cvar_s *next;
};
typedef struct cvar_s cvar_t;
STATIC_CHECK_SIZEOF( struct cvar_s, 20, 32 );
#if REF_DLL || ENGINE_DLL // Xash3D internal cvar format, MUST NOT be used outside of engine
struct convar_s {
char *name;
char *string;
uint32_t flags;
float value;
struct convar_s *next;
char *desc;
char *def_string;
};
typedef struct convar_s convar_t;
#if XASH_64BIT
#define CVAR_SENTINEL (uintptr_t)0xDEADBEEFDEADBEEF
#else
#define CVAR_SENTINEL (uintptr_t)0xDEADBEEF
#endif
#define CVAR_CHECK_SENTINEL( cv ) ((uintptr_t)(cv)->next == CVAR_SENTINEL)
#define CVAR_DEFINE( cv, cvname, cvstr, cvflags, cvdesc ) \
convar_t cv = { (char*)cvname, (char*)cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, (char*)cvdesc, NULL }
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) CVAR_DEFINE( cv, #cv, cvstr, cvflags, cvdesc )
#endif // REF_DLL || ENGINE_DLL
#endif // CVAR
#endif//CVARDEF_H

View File

@@ -77,6 +77,30 @@ SETUP BACKENDS DEFINITIONS
// usually only 10-20 fds availiable
#define XASH_REDUCE_FD
#elif XASH_PSP
#ifndef XASH_VIDEO
#define XASH_VIDEO VIDEO_PSP
#endif
#ifndef XASH_TIMER
#define XASH_TIMER TIMER_PSP
#endif
#ifndef XASH_INPUT
#define XASH_INPUT INPUT_PSP
#endif
#ifndef XASH_SOUND
#define XASH_SOUND SOUND_PSP
#endif // XASH_SOUND
#ifndef XASH_MESSAGEBOX
#define XASH_MESSAGEBOX MSGBOX_PSP
#endif // XASH_MESSAGEBOX
#define XASH_REDUCE_FD
#define XASH_NO_TOUCH
#define XASH_NO_ZIP
#endif
#endif // XASH_DEDICATED
@@ -105,7 +129,7 @@ SETUP BACKENDS DEFINITIONS
#endif // !XASH_WIN32
#endif
#ifdef XASH_STATIC_LIBS
#if defined(XASH_STATIC_LIBS) && !XASH_PSP
#define XASH_LIB LIB_STATIC
#define XASH_INTERNAL_GAMELIBS
#define XASH_ALLOW_SAVERESTORE_OFFSETS
@@ -113,6 +137,8 @@ SETUP BACKENDS DEFINITIONS
#define XASH_LIB LIB_WIN32
#elif XASH_POSIX
#define XASH_LIB LIB_POSIX
#elif XASH_PSP
#define XASH_LIB LIB_PSP
#endif
//
@@ -193,4 +219,20 @@ Default build-depended cvar and constant values
#define DEFAULT_MAX_EDICTS 1200 // was 900 before HL25
#endif // DEFAULT_MAX_EDICTS
#ifndef DEFAULT_ACCELERATED_RENDERER
#ifdef XASH_PSP
#define DEFAULT_ACCELERATED_RENDERER "gu"
#else
#if XASH_MOBILE_PLATFORM
#define DEFAULT_ACCELERATED_RENDERER "gles1"
#else // !XASH_MOBILE_PLATFORM
#define DEFAULT_ACCELERATED_RENDERER "gl"
#endif // !XASH_MOBILE_PLATFORM
#endif
#endif // DEFAULT_ACCELERATED_RENDERER
#ifndef DEFAULT_SOFTWARE_RENDERER
#define DEFAULT_SOFTWARE_RENDERER "soft" // mittorn's ref_soft
#endif // DEFAULT_SOFTWARE_RENDERER
#endif // DEFAULTS_H

View File

@@ -1,5 +1,5 @@
/*
enginefeatures.h - engine features that can be enabled by mod-maker request
features.h - engine features that can be enabled by mod-maker request
Copyright (C) 2012 Uncle Mike
This program is free software: you can redistribute it and/or modify
@@ -27,7 +27,6 @@ GNU General Public License for more details.
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine
#define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer
#define ENGINE_DISABLE_HDTEXTURES (1U<<30) // disable support of HD-textures in case custom renderer have separate way to load them
#define ENGINE_STEP_POSHISTORY_LERP (1U<<31) // enable MOVETYPE_STEP interpolation based on position history. Incompatible with ENGINE_COMPUTE_STUDIO_LERP!
// adjust the mask when features will be added or removed

View File

@@ -30,7 +30,7 @@ GAMEINFO stuff
internal shared gameinfo structure (readonly for engine parts)
========================================================================
*/
typedef struct GAMEINFO_s
typedef struct
{
// filesystem info
char gamefolder[64]; // used for change game '-game x'
@@ -50,48 +50,4 @@ typedef struct GAMEINFO_s
int gamemode;
} GAMEINFO;
/*
========================================================================
Extended GameInfo struct introduced in Xash3D FWGS
GAMEINFO can't be reliably extended, as nor engine, nor menu can't be
sure about struct size. By adding struct versioning, we can check the
presense for extra fields.
========================================================================
*/
#define GAMEINFO_VERSION 2
typedef enum gametype_e
{
GAME_NORMAL,
GAME_SINGLEPLAYER_ONLY,
GAME_MULTIPLAYER_ONLY,
} gametype_t;
typedef struct gameinfo2_s
{
int gi_version; // should be set to desired struct version, e.g. GAMEINFO_VERSION
// filesystem info
char gamefolder[64]; // used for change game
char startmap[64]; // map to start singleplayer game from
char trainmap[64]; // map to start hazardous course from (if specified)
char demomap[64]; // map to start demo chapter from (if specified)
char title[64]; // game title
char iconpath[64]; // path to game icon
char version[16]; // game version (optional)
uint32_t flags; // gameinfo flags, extended to fit more flags
// mod info
char game_url[256]; // link to a developer's site
char update_url[256]; // link to updates page
char type[64]; // single, toolkit, multiplayer, etc
char date[64]; // release date
uint64_t size; // size in bytes
gametype_t gamemode;
} gameinfo2_t;
#endif//GAMEINFO_H

View File

@@ -30,6 +30,6 @@ typedef struct
int state; // low bit is down state
} kbutton_t;
STATIC_CHECK_SIZEOF( kbutton_t, 12, 12 );
STATIC_ASSERT( sizeof( kbutton_t ) == 12, "kbutton_t isn't 12 bytes!" );
#endif // KBUTTON_H

View File

@@ -27,7 +27,6 @@
// Set this flag for things like broadcast requests, etc. where the engine should not
// kill the request hook after receiving the first response
#define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 )
#define FNETAPI_LEGACY_PROTOCOL ( 1<<1 ) // xash3d-fwgs extension
struct net_response_s;
typedef void (*net_api_response_func_t) ( struct net_response_s *response );
@@ -36,7 +35,6 @@ typedef void (*net_api_response_func_t) ( struct net_response_s *response );
#define NET_ERROR_TIMEOUT ( 1<<0 )
#define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 )
#define NET_ERROR_UNDEFINED ( 1<<2 )
#define NET_ERROR_FORBIDDEN ( 1<<3 ) // xash3d-fwgs extension
typedef struct net_adrlist_s
{

View File

@@ -69,6 +69,6 @@ typedef struct netadr_s
} netadr_t;
#pragma pack( pop )
STATIC_CHECK_SIZEOF( netadr_t, 20, 20 );
STATIC_ASSERT( sizeof( netadr_t ) == 20, "netadr_t isn't 20 bytes!" );
#endif // NET_ADR_H

View File

@@ -24,7 +24,9 @@ GNU General Public License for more details.
#include <sys/syslimits.h>
#define OS_LIB_EXT "dylib"
#define OPEN_COMMAND "open"
#else
#elif XASH_PSP
#define OS_LIB_EXT "prx"
#else
#define OS_LIB_EXT "so"
#define OPEN_COMMAND "xdg-open"
#endif
@@ -35,6 +37,7 @@ GNU General Public License for more details.
#define __cdecl
#define __stdcall
#define _inline static inline
#define FORCEINLINE inline __attribute__((always_inline))
#if XASH_POSIX
#include <unistd.h>
@@ -54,6 +57,16 @@ GNU General Public License for more details.
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
#endif
#if XASH_PSP
#include <unistd.h>
#include <pspiofilemgr.h>
#define O_BINARY 0
#define O_TEXT 0
#define _mkdir( x ) sceIoMkdir( x, FIO_S_IRWXU | FIO_S_IRWXG | FIO_S_IROTH | FIO_S_IXOTH )
#endif
typedef void* HANDLE;
typedef void* HINSTANCE;
@@ -62,6 +75,13 @@ GNU General Public License for more details.
int x, y;
} POINT;
#else // WIN32
#ifdef __MINGW32__
#define _inline static inline
#define FORCEINLINE inline __attribute__((always_inline))
#else
#define FORCEINLINE __forceinline
#endif
#define open _open
#define read _read
#define alloca _alloca

View File

@@ -56,8 +56,6 @@ color24 gTracerColors[] =
};
*/
#define TRACER_COLORINDEX_DEFAULT 4
// Temporary entity array
#define TENTPRIORITY_LOW 0
#define TENTPRIORITY_HIGH 1

View File

@@ -101,14 +101,18 @@ typedef enum
TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D
TF_ATLAS_PAGE = (1<<21), // bit who indicate lightmap page or deluxemap page
TF_ALPHACONTRAST = (1<<22), // special texture mode for A2C
#if XASH_PSP
TF_IMG_SWIZZLED = (1<<23),
TF_IMG_INVRAM = (1<<24),
#else
// reserved
// reserved
#endif
TF_IMG_UPLOADED = (1<<25), // this is set for first time when called glTexImage, otherwise it will be call glTexSubImage
TF_ARB_FLOAT = (1<<26), // float textures
TF_NOCOMPARE = (1<<27), // disable comparing for depth textures
TF_ARB_16BIT = (1<<28), // keep image as 16-bit (not 24)
TF_MULTISAMPLE = (1<<29), // multisampling texture
TF_ALLOW_NEAREST = (1<<30), // allows toggling nearest filtering for TF_NOMIPMAP textures
TF_MULTISAMPLE = (1<<29) // multisampling texture
} texFlags_t;
typedef enum

View File

@@ -21,14 +21,28 @@ typedef int sound_t;
typedef float vec_t;
typedef vec_t vec2_t[2];
typedef vec_t vec3_t[3];
#if XASH_PSP
typedef vec_t vec4_t[4] __attribute__( ( aligned( 16 ) ) );
typedef vec_t quat_t[4] __attribute__( ( aligned( 16 ) ) );
#else
typedef vec_t vec4_t[4];
typedef vec_t quat_t[4];
#endif
typedef byte rgba_t[4]; // unsigned byte colorpack
typedef byte rgb_t[3]; // unsigned byte colorpack
#if XASH_PSP
typedef vec_t matrix3x4[3][4] __attribute__( ( aligned( 16 ) ) );
typedef vec_t matrix4x4[4][4] __attribute__( ( aligned( 16 ) ) );
#else
typedef vec_t matrix3x4[3][4];
typedef vec_t matrix4x4[4][4];
#endif
#if XASH_64BIT
typedef uint32_t poolhandle_t;
#else
typedef void* poolhandle_t;
#endif
#undef true
#undef false
@@ -70,64 +84,48 @@ typedef uint64_t longtime_t;
#define IsColorString( p ) ( p && *( p ) == '^' && *(( p ) + 1) && *(( p ) + 1) >= '0' && *(( p ) + 1 ) <= '9' )
#define ColorIndex( c ) ((( c ) - '0' ) & 7 )
#if defined( __GNUC__ )
#if defined( __i386__ )
#define EXPORT __attribute__(( visibility( "default" ), force_align_arg_pointer ))
#define GAME_EXPORT __attribute(( force_align_arg_pointer ))
#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 EXPORT __attribute__ ((visibility ("default")))
#define GAME_EXPORT
#endif
#define MALLOC __attribute__(( malloc ))
// added in GCC 11
#if __GNUC__ >= 11
// might want to set noclone due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116893
// but it's easier to not force mismatched-dealloc to error yet
#define MALLOC_LIKE( x, y ) __attribute__(( malloc( x, y )))
#else
#define MALLOC_LIKE( x, y ) MALLOC
#endif
#define NORETURN __attribute__(( noreturn ))
#define NONNULL __attribute__(( nonnull ))
#define _format( x ) __attribute__(( format( printf, x, x + 1 )))
#define ALLOC_CHECK( x ) __attribute__(( alloc_size( x )))
#define NO_ASAN __attribute__(( no_sanitize( "address" )))
#define WARN_UNUSED_RESULT __attribute__(( warn_unused_result ))
#define RENAME_SYMBOL( x ) asm( x )
#else
#if defined( _MSC_VER )
#define EXPORT __declspec( dllexport )
#define NO_ASAN __declspec( no_sanitize_address )
#else
#define EXPORT
#define NO_ASAN
#endif
#define _format(x) __attribute__((format(printf, x, x+1)))
#define NORETURN __attribute__((noreturn))
#define NONNULL __attribute__((nonnull))
#define ALLOC_CHECK(x) __attribute__((alloc_size(x)))
#elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport )
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#define NONNULL
#define _format( x )
#define ALLOC_CHECK( x )
#define RENAME_SYMBOL( x )
#define MALLOC
#define MALLOC_LIKE( x, y )
#define WARN_UNUSED_RESULT
#define ALLOC_CHECK(x)
#else
#define EXPORT
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#define NONNULL
#define ALLOC_CHECK(x)
#endif
#if __GNUC__ >= 3
#define unlikely( x ) __builtin_expect( x, 0 )
#define likely( x ) __builtin_expect( x, 1 )
#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 ) // this must be after defined() check
#define unlikely( x ) __builtin_expect( x, 0 )
#define likely( x ) __builtin_expect( x, 1 )
#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
#endif
#if !defined( unlikely ) || !defined( likely )
#define unlikely( x ) ( x )
#define likely( x ) ( x )
#else
#define unlikely(x) (x)
#define likely(x) (x)
#endif
#if __STDC_VERSION__ >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword
@@ -144,23 +142,6 @@ typedef uint64_t longtime_t;
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_2( __LINE__, x, y )
#endif
// at least, statically check size of some public structures
#if XASH_64BIT
#define STATIC_CHECK_SIZEOF( type, size32, size64 ) \
STATIC_ASSERT( sizeof( type ) == size64, #type " unexpected size" )
#else
#define STATIC_CHECK_SIZEOF( type, size32, size64 ) \
STATIC_ASSERT( sizeof( type ) == size32, #type " unexpected size" )
#endif
#if !defined( __cplusplus ) && __STDC_VERSION__ >= 199101L // not C++ and C99 or newer
#define XASH_RESTRICT restrict
#elif _MSC_VER || __GNUC__ || __clang__ // compiler-specific extensions
#define XASH_RESTRICT __restrict
#else
#define XASH_RESTRICT // nothing
#endif
#ifdef XASH_BIG_ENDIAN
#define LittleLong(x) (((int)(((x)&255)<<24)) + ((int)((((x)>>8)&255)<<16)) + ((int)(((x)>>16)&255)<<8) + (((x) >> 24)&255))
#define LittleLongSW(x) (x = LittleLong(x) )
@@ -191,9 +172,8 @@ _inline float LittleFloat( float f )
#endif
typedef unsigned int dword;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned int dword;
typedef unsigned int uint;
typedef char string[MAX_STRING];
typedef struct file_s file_t; // normal file
typedef struct stream_s stream_t; // sound stream for background music playing
@@ -224,6 +204,9 @@ typedef void *(*pfnCreateInterface_t)( const char *, int * );
// config strings are a general means of communication from
// the server to all connected clients.
// each config string can be at most CS_SIZE characters.
#if XASH_PSP
#define MAX_QPATH 48
#else
#if XASH_LOW_MEMORY == 0
#define MAX_QPATH 64 // max length of a game pathname
#elif XASH_LOW_MEMORY == 2
@@ -231,6 +214,7 @@ typedef void *(*pfnCreateInterface_t)( const char *, int * );
#elif XASH_LOW_MEMORY == 1
#define MAX_QPATH 48
#endif
#endif
#define MAX_OSPATH 260 // max length of a filesystem pathname
#define CS_SIZE 64 // size of one config string
#define CS_TIME 16 // size of time string

View File

@@ -74,7 +74,7 @@ typedef struct
float size;
} daliashdr_t;
STATIC_CHECK_SIZEOF( daliashdr_t, 84, 84 );
STATIC_ASSERT( sizeof( daliashdr_t ) == 84, "invalid daliashdr_t size" );
typedef struct
{
@@ -83,7 +83,7 @@ typedef struct
int32_t t;
} stvert_t;
STATIC_CHECK_SIZEOF( stvert_t, 12, 12 );
STATIC_ASSERT( sizeof( stvert_t ) == 12, "invalid stvert_t size" );
typedef struct dtriangle_s
{
@@ -91,7 +91,7 @@ typedef struct dtriangle_s
int32_t vertindex[3];
} dtriangle_t;
STATIC_CHECK_SIZEOF( dtriangle_t, 16, 16 );
STATIC_ASSERT( sizeof( dtriangle_t ) == 16, "invalid dtriangle_t size" );
#define DT_FACES_FRONT 0x0010
#define ALIAS_ONSEAM 0x0020
@@ -103,7 +103,7 @@ typedef struct
char name[16]; // frame name from grabbing
} daliasframe_t;
STATIC_CHECK_SIZEOF( daliasframe_t, 24, 24 );
STATIC_ASSERT( sizeof( daliasframe_t ) == 24, "invalid daliasframe_t size" );
typedef struct
{
@@ -112,41 +112,41 @@ typedef struct
trivertex_t bboxmax; // lightnormal isn't used
} daliasgroup_t;
STATIC_CHECK_SIZEOF( daliasgroup_t, 12, 12 );
STATIC_ASSERT( sizeof( daliasgroup_t ) == 12, "invalid daliasgrou_t size" );
typedef struct
{
int32_t numskins;
} daliasskingroup_t;
STATIC_CHECK_SIZEOF( daliasskingroup_t, 4, 4 );
STATIC_ASSERT( sizeof( daliasskingroup_t ) == 4, "invalid daliasskingroup_t size" );
typedef struct
{
float interval;
} daliasinterval_t;
STATIC_CHECK_SIZEOF( daliasinterval_t, 4, 4 );
STATIC_ASSERT( sizeof( daliasinterval_t ) == 4, "invalid daliasinterval_t size" );
typedef struct
{
float interval;
} daliasskininterval_t;
STATIC_CHECK_SIZEOF( daliasskininterval_t, 4, 4 );
STATIC_ASSERT( sizeof( daliasskininterval_t ) == 4, "invalid daliasskininterval_t size" );
typedef struct
{
uint32_t type; // was aliasframetype_t
} daliasframetype_t;
STATIC_CHECK_SIZEOF( daliasframetype_t, 4, 4 );
STATIC_ASSERT( sizeof( daliasframetype_t ) == 4, "invalid daliasframetype_t size" );
typedef struct
{
uint32_t type; // was aliasskintype_t
} daliasskintype_t;
STATIC_CHECK_SIZEOF( daliasskintype_t, 4, 4 );
STATIC_ASSERT( sizeof( daliasskintype_t ) == 4, "invalid daliasskintype_t size" );
#endif//ALIAS_H

View File

@@ -157,12 +157,32 @@ void CL_PlayCDTrack_f( void )
CL_ScreenshotGetName
==================
*/
static qboolean CL_ScreenshotGetName( const char *fmt, int lastnum, char *filename, size_t size )
static qboolean CL_ScreenshotGetName( int lastnum, char *filename, size_t size )
{
if( lastnum < 0 || lastnum > 9999 )
{
Con_Printf( S_ERROR "unable to write screenshot\n" );
return false;
}
return Q_snprintf( filename, size, fmt, clgame.mapname, lastnum ) > 0;
return Q_snprintf( filename, size, "scrshots/%s_shot%04d.png", clgame.mapname, lastnum ) > 0;
}
/*
==================
CL_SnapshotGetName
==================
*/
static qboolean CL_SnapshotGetName( int lastnum, char *filename, size_t size )
{
if( lastnum < 0 || lastnum > 9999 )
{
Con_Printf( S_ERROR "unable to write snapshot\n" );
FS_AllowDirectPaths( false );
return false;
}
return Q_snprintf( filename, size, "../%s_%04d.png", clgame.mapname, lastnum ) > 0;
}
/*
@@ -172,6 +192,127 @@ static qboolean CL_ScreenshotGetName( const char *fmt, int lastnum, char *filena
==============================================================================
*/
/*
==================
CL_ScreenShot_f
normal screenshot
==================
*/
void CL_ScreenShot_f( void )
{
int i;
string checkname;
if( CL_IsDevOverviewMode() == 1 )
{
// special case for write overview image and script file
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
cls.scrshot_action = scrshot_mapshot; // build new frame for mapshot
}
else
{
// scan for a free filename
for( i = 0; i < 9999; i++ )
{
if( !CL_ScreenshotGetName( i, checkname, sizeof( checkname )))
return; // no namespace
if( !FS_FileExists( checkname, true ))
break;
}
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
cls.scrshot_action = scrshot_normal; // build new frame for screenshot
}
cls.envshot_vieworg = NULL; // no custom view
cls.envshot_viewsize = 0;
}
/*
==================
CL_SnapShot_f
save screenshots into root dir
==================
*/
void CL_SnapShot_f( void )
{
int i;
string checkname;
if( CL_IsDevOverviewMode() == 1 )
{
// special case for write overview image and script file
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
cls.scrshot_action = scrshot_mapshot; // build new frame for mapshot
}
else
{
FS_AllowDirectPaths( true );
// scan for a free filename
for( i = 0; i < 9999; i++ )
{
if( !CL_SnapshotGetName( i, checkname, sizeof( checkname )))
return; // no namespace
if( !FS_FileExists( checkname, true ))
break;
}
FS_AllowDirectPaths( false );
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
cls.scrshot_action = scrshot_snapshot; // build new frame for screenshot
}
cls.envshot_vieworg = NULL; // no custom view
cls.envshot_viewsize = 0;
}
/*
==================
CL_EnvShot_f
cubemap view
==================
*/
void CL_EnvShot_f( void )
{
if( Cmd_Argc() < 2 )
{
Con_Printf( S_USAGE "envshot <shotname>\n" );
return;
}
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "gfx/env/%s", Cmd_Argv( 1 ));
cls.scrshot_action = scrshot_envshot; // build new frame for envshot
cls.envshot_vieworg = NULL; // no custom view
cls.envshot_viewsize = 0;
}
/*
==================
CL_SkyShot_f
skybox view
==================
*/
void CL_SkyShot_f( void )
{
if( Cmd_Argc() < 2 )
{
Con_Printf( S_USAGE "skyshot <shotname>\n" );
return;
}
Q_snprintf( cls.shotname, sizeof( cls.shotname ),"gfx/env/%s", Cmd_Argv( 1 ));
cls.scrshot_action = scrshot_skyshot; // build new frame for skyshot
cls.envshot_vieworg = NULL; // no custom view
cls.envshot_viewsize = 0;
}
/*
==================
CL_LevelShot_f
@@ -214,107 +355,23 @@ void CL_LevelShot_f( void )
else cls.scrshot_action = scrshot_inactive; // disable - not needs
}
static scrshot_t CL_GetScreenshotTypeFromString( const char *string )
/*
==================
CL_SaveShot_f
mini-pic in loadgame menu
==================
*/
void CL_SaveShot_f( void )
{
if( !Q_stricmp( string, "snapshot" ))
return scrshot_snapshot;
if( !Q_stricmp( string, "screenshot" ))
return scrshot_normal;
if( !Q_stricmp( string, "saveshot" ))
return scrshot_savegame;
if( !Q_stricmp( string, "envshot" ))
return scrshot_envshot;
if( !Q_stricmp( string, "skyshot" ))
return scrshot_skyshot;
return scrshot_inactive;
}
void CL_GenericShot_f( void )
{
const char *argv0 = Cmd_Argv( 0 );
scrshot_t type;
type = CL_GetScreenshotTypeFromString( argv0 );
if( type == scrshot_normal || type == scrshot_snapshot )
if( Cmd_Argc() < 2 )
{
if( CL_IsDevOverviewMode() == 1 )
type = scrshot_mapshot;
}
else
{
if( Cmd_Argc() < 2 )
{
Con_Printf( S_USAGE "%s <shotname>\n", argv0 );
return;
}
Con_Printf( S_USAGE "saveshot <savename>\n" );
return;
}
switch( type )
{
case scrshot_envshot:
case scrshot_skyshot:
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "gfx/env/%s", Cmd_Argv( 1 ));
break;
case scrshot_savegame:
Q_snprintf( cls.shotname, sizeof( cls.shotname ), DEFAULT_SAVE_DIRECTORY "%s.bmp", Cmd_Argv( 1 ));
break;
case scrshot_mapshot:
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
break;
case scrshot_normal:
case scrshot_snapshot:
{
const char *fmt;
string checkname;
int i;
// allow overriding screenshot by users request
if( Cmd_Argc() > 1 )
{
Q_strncpy( cls.shotname, Cmd_Argv( 1 ), sizeof( cls.shotname ));
break;
}
if( type == scrshot_snapshot )
{
fmt = "../%s_%04d.png";
FS_AllowDirectPaths( true );
}
else fmt = "scrshots/%s_shot%04d.png";
for( i = 0; i < 9999; i++ )
{
if( !CL_ScreenshotGetName( fmt, i, checkname, sizeof( checkname )))
{
Con_Printf( S_ERROR "unable to write %s\n", argv0 );
FS_AllowDirectPaths( false );
return;
}
if( !FS_FileExists( checkname, true ))
break;
}
FS_AllowDirectPaths( false );
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
break;
}
case scrshot_inactive:
case scrshot_plaque:
default:
return; // shouldn't happen
}
cls.scrshot_action = type; // build new frame for saveshot
cls.envshot_vieworg = NULL;
cls.envshot_viewsize = 0;
Q_snprintf( cls.shotname, sizeof( cls.shotname ), DEFAULT_SAVE_DIRECTORY "%s.bmp", Cmd_Argv( 1 ));
cls.scrshot_action = scrshot_savegame; // build new frame for saveshot
}
/*
@@ -356,7 +413,7 @@ void CL_SetSky_f( void )
return;
}
R_SetupSky( Cmd_Argv( 1 ));
ref.dllFuncs.R_SetupSky( Cmd_Argv( 1 ));
}
/*

View File

@@ -70,17 +70,16 @@ qboolean CL_CheckFile( sizebuf_t *msg, resource_t *pResource )
return true;
}
host.downloadcount++;
if( cl.http_download )
if( cl.downloadUrl[0] )
{
HTTP_AddDownload( filepath, pResource->nDownloadSize, true );
host.downloadcount++;
return false;
}
else
{
MSG_BeginClientCmd( msg, clc_stringcmd );
MSG_WriteStringf( msg, "dlfile %s", filepath );
}
MSG_BeginClientCmd( msg, clc_stringcmd );
MSG_WriteStringf( msg, "dlfile %s", filepath );
host.downloadcount++;
return false;
}
@@ -105,7 +104,7 @@ void CL_AddToResourceList( resource_t *pResource, resource_t *pList )
void CL_RemoveFromResourceList( resource_t *pResource )
{
if( pResource->pPrev == NULL || pResource->pNext == NULL )
Host_Error( "mislinked resource in %s\n", __func__ );
Host_Error( "mislinked resource in CL_RemoveFromResourceList\n" );
if( pResource->pNext == pResource || pResource->pPrev == pResource )
Host_Error( "attempt to free last entry in list.\n" );
@@ -120,7 +119,7 @@ void CL_MoveToOnHandList( resource_t *pResource )
{
if( !pResource )
{
Con_Reportf( "Null resource passed to %s\n", __func__ );
Con_Reportf( "Null resource passed to CL_MoveToOnHandList\n" );
return;
}
@@ -128,7 +127,7 @@ void CL_MoveToOnHandList( resource_t *pResource )
CL_AddToResourceList( pResource, &cl.resourcesonhand );
}
static void CL_ClearResourceList( resource_t *pList )
void CL_ClearResourceList( resource_t *pList )
{
resource_t *p, *n;

View File

@@ -50,29 +50,7 @@ const char *CL_MsgInfo( int cmd )
if( cmd >= 0 && cmd <= svc_lastmsg )
{
// get engine message name
const char *svc_string = NULL;
switch( cls.legacymode )
{
case PROTO_CURRENT:
svc_string = svc_strings[cmd];
break;
case PROTO_LEGACY:
svc_string = svc_legacy_strings[cmd];
break;
case PROTO_QUAKE:
svc_string = svc_quake_strings[cmd];
break;
case PROTO_GOLDSRC:
svc_string = svc_goldsrc_strings[cmd];
break;
}
// fall back to current protocol strings
if( !svc_string )
svc_string = svc_strings[cmd];
Q_strncpy( sz, svc_string, sizeof( sz ));
Q_strncpy( sz, svc_strings[cmd], sizeof( sz ));
}
else if( cmd > svc_lastmsg && cmd <= ( svc_lastmsg + MAX_USER_MESSAGES ))
{

View File

@@ -79,7 +79,7 @@ typedef struct
typedef struct
{
demoentry_t *entries; // track entry info
int32_t numentries; // number of tracks
int numentries; // number of tracks
} demodirectory_t;
// add angles
@@ -107,42 +107,6 @@ struct
int angle_position;
} demo;
static qboolean CL_NextDemo( void );
static int CL_GetDemoNetProtocol( connprotocol_t proto )
{
switch( proto )
{
case PROTO_CURRENT:
return PROTOCOL_VERSION;
case PROTO_LEGACY:
return PROTOCOL_LEGACY_VERSION;
case PROTO_QUAKE:
return PROTOCOL_VERSION_QUAKE;
case PROTO_GOLDSRC:
return PROTOCOL_GOLDSRC_VERSION;
}
return PROTOCOL_VERSION;
}
static connprotocol_t CL_GetProtocolFromDemo( int net_protocol )
{
switch( net_protocol )
{
case PROTOCOL_VERSION:
return PROTO_CURRENT;
case PROTOCOL_LEGACY_VERSION:
return PROTO_LEGACY;
case PROTOCOL_VERSION_QUAKE:
return PROTO_QUAKE;
case PROTOCOL_GOLDSRC_VERSION:
return PROTO_GOLDSRC;
}
return PROTO_CURRENT;
}
/*
====================
CL_StartupDemoHeader
@@ -153,8 +117,12 @@ we record a demo on this level
*/
void CL_StartupDemoHeader( void )
{
CL_CloseDemoHeader();
if( cls.demoheader )
{
FS_Close( cls.demoheader );
}
// Note: this is replacing tmpfile()
cls.demoheader = FS_Open( "demoheader.tmp", "w+b", true );
if( !cls.demoheader )
@@ -188,7 +156,7 @@ CL_GetDemoRecordClock
write time while demo is recording
====================
*/
static float CL_GetDemoRecordClock( void )
float CL_GetDemoRecordClock( void )
{
return cl.mtime[0];
}
@@ -200,7 +168,7 @@ CL_GetDemoPlaybackClock
overwrite host.realtime
====================
*/
static float CL_GetDemoPlaybackClock( void )
float CL_GetDemoPlaybackClock( void )
{
return host.realtime + host.frametime;
}
@@ -226,7 +194,7 @@ CL_WriteDemoCmdHeader
Writes the demo command header and time-delta
====================
*/
static void CL_WriteDemoCmdHeader( byte cmd, file_t *file )
void CL_WriteDemoCmdHeader( byte cmd, file_t *file )
{
float dt;
@@ -299,7 +267,7 @@ Save state of cls.netchan sequences
so that we can play the demo correctly.
====================
*/
static void CL_WriteDemoSequence( file_t *file )
void CL_WriteDemoSequence( file_t *file )
{
Assert( file != NULL );
@@ -327,6 +295,10 @@ void CL_WriteDemoMessage( qboolean startup, int start, sizebuf_t *msg )
if( !file ) return;
// past the start but not recording a demo.
if( !startup && !cls.demorecording )
return;
swlen = MSG_GetNumBytesWritten( msg ) - start;
if( swlen <= 0 ) return;
@@ -376,7 +348,7 @@ CL_WriteDemoHeader
Write demo header
====================
*/
static void CL_WriteDemoHeader( const char *name )
void CL_WriteDemoHeader( const char *name )
{
int copysize;
int savepos;
@@ -399,7 +371,7 @@ static void CL_WriteDemoHeader( const char *name )
demo.header.id = IDEMOHEADER;
demo.header.dem_protocol = DEMO_PROTOCOL;
demo.header.net_protocol = CL_GetDemoNetProtocol( cls.legacymode );
demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION;
demo.header.host_fps = host_maxfps.value ? bound( MIN_FPS, host_maxfps.value, MAX_FPS ) : MAX_FPS;
Q_strncpy( demo.header.mapname, clgame.mapname, sizeof( demo.header.mapname ));
Q_strncpy( demo.header.comment, clgame.maptitle, sizeof( demo.header.comment ));
@@ -419,7 +391,6 @@ static void CL_WriteDemoHeader( const char *name )
// finish off the startup info.
CL_WriteDemoCmdHeader( dem_stop, cls.demoheader );
FS_Flush( cls.demoheader );
// now copy the stuff we cached from the server.
copysize = savepos = FS_Tell( cls.demoheader );
@@ -465,7 +436,7 @@ CL_StopRecord
finish recording demo
=================
*/
static void CL_StopRecord( void )
void CL_StopRecord( void )
{
int i, curpos;
float stoptime;
@@ -547,7 +518,7 @@ CL_ReadDemoCmdHeader
read the demo command
=================
*/
static qboolean CL_ReadDemoCmdHeader( byte *cmd, float *dt )
qboolean CL_ReadDemoCmdHeader( byte *cmd, float *dt )
{
// read the command
// HACKHACK: skip NOPs
@@ -577,7 +548,7 @@ read the demo usercmd for predicting
and smooth movement during playback the demo
=================
*/
static void CL_ReadDemoUserCmd( qboolean discard )
void CL_ReadDemoUserCmd( qboolean discard )
{
byte data[1024];
int cmdnumber;
@@ -642,7 +613,7 @@ CL_ReadDemoSequence
read netchan sequences
=================
*/
static void CL_ReadDemoSequence( qboolean discard )
void CL_ReadDemoSequence( qboolean discard )
{
int incoming_sequence;
int incoming_acknowledged;
@@ -676,7 +647,7 @@ static void CL_ReadDemoSequence( qboolean discard )
CL_DemoStartPlayback
=================
*/
static void CL_DemoStartPlayback( int mode )
void CL_DemoStartPlayback( int mode )
{
if( cls.changedemo )
{
@@ -721,7 +692,7 @@ static void CL_DemoStartPlayback( int mode )
CL_DemoAborted
=================
*/
static void CL_DemoAborted( void )
void CL_DemoAborted( void )
{
if( cls.demofile )
FS_Close( cls.demofile );
@@ -761,7 +732,7 @@ returns true on success, false on failure
g-cont. probably captain obvious mode is ON
=================
*/
static qboolean CL_DemoMoveToNextSection( void )
qboolean CL_DemoMoveToNextSection( void )
{
if( ++demo.entryIndex >= demo.directory.numentries )
{
@@ -783,7 +754,7 @@ static qboolean CL_DemoMoveToNextSection( void )
return true;
}
static qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length )
qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length )
{
int msglen = 0;
@@ -834,7 +805,7 @@ CL_DemoReadMessageQuake
reads demo data and write it to client
=================
*/
static qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length )
qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length )
{
vec3_t viewangles;
int msglen = 0;
@@ -1049,7 +1020,7 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length )
return CL_ReadRawNetworkData( buffer, length );
}
static void CL_DemoFindInterpolatedViewAngles( float t, float *frac, demoangle_t **prev, demoangle_t **next )
void CL_DemoFindInterpolatedViewAngles( float t, float *frac, demoangle_t **prev, demoangle_t **next )
{
int i, i0, i1, imod;
float at;
@@ -1144,9 +1115,8 @@ CL_FinishTimeDemo
show stats
==============
*/
static void CL_FinishTimeDemo( void )
void CL_FinishTimeDemo( void )
{
qboolean temp = host.allow_console;
int frames;
double time;
@@ -1157,9 +1127,7 @@ static void CL_FinishTimeDemo( void )
time = host.realtime - cls.td_starttime;
if( !time ) time = 1.0;
host.allow_console = true;
Con_Printf( "timedemo result: %i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time );
host.allow_console = temp;
if( Sys_CheckParm( "-timedemo" ))
CL_Quit_f();
@@ -1296,7 +1264,7 @@ CL_NextDemo
Called when a demo finishes
==================
*/
static qboolean CL_NextDemo( void )
qboolean CL_NextDemo( void )
{
char str[MAX_QPATH];
@@ -1448,51 +1416,6 @@ void CL_Record_f( void )
CL_WriteDemoHeader( demopath );
}
static qboolean CL_ParseDemoHeader( const char *callee, const char *filename, file_t *f, demoheader_t *hdr, int32_t *numentries )
{
if( FS_Read( f, hdr, sizeof( *hdr )) != sizeof( *hdr ) || hdr->id != IDEMOHEADER )
{
Con_Printf( S_ERROR "%s: %s is not in supported format or not a demo file\n", callee, filename );
return false;
}
// force null terminate strings
hdr->mapname[sizeof( hdr->mapname ) - 1] = 0;
hdr->comment[sizeof( hdr->comment ) - 1] = 0;
hdr->gamedir[sizeof( hdr->gamedir ) - 1] = 0;
if( hdr->dem_protocol != DEMO_PROTOCOL )
{
Con_Printf( S_ERROR "%s: demo protocol outdated (%i should be %i)\n",
callee, hdr->net_protocol, DEMO_PROTOCOL );
return false;
}
if( hdr->net_protocol != PROTOCOL_VERSION && hdr->net_protocol != PROTOCOL_LEGACY_VERSION )
{
Con_Printf( S_ERROR "%s: net protocol outdated (%i should be %i or %i)\n",
callee, hdr->net_protocol, PROTOCOL_VERSION, PROTOCOL_LEGACY_VERSION );
return false;
}
if( FS_Seek( f, hdr->directory_offset, SEEK_SET ) < 0
|| FS_Read( f, numentries, sizeof( *numentries )) != sizeof( *numentries ))
{
Con_Printf( S_ERROR "%s: can't find directory offset in %s, demo file corrupted\n",
callee, filename );
return false;
}
if(( *numentries < 1 ) || ( *numentries > 1024 ))
{
Con_Printf( S_ERROR "%s: demo have bogus # of directory entries: %i\n",
callee, *numentries );
return false;
}
return true;
}
/*
====================
CL_PlayDemo_f
@@ -1513,7 +1436,9 @@ void CL_PlayDemo_f( void )
}
if( cls.demoplayback )
{
CL_StopPlayback();
}
if( cls.demorecording )
{
@@ -1563,32 +1488,51 @@ void CL_PlayDemo_f( void )
if( neg ) cls.forcetrack = -cls.forcetrack;
CL_DemoStartPlayback( DEMO_QUAKE1 );
cls.legacymode = PROTO_QUAKE;
return; // quake demo is started
}
// read in the demo header
if( !CL_ParseDemoHeader( Cmd_Argv( 0 ), filename, cls.demofile, &demo.header, &demo.directory.numentries ))
FS_Read( cls.demofile, &demo.header, sizeof( demoheader_t ));
if( demo.header.id != IDEMOHEADER )
{
Con_Printf( S_ERROR "%s is not a demo file\n", demoname );
CL_DemoAborted();
return;
}
if( demo.header.dem_protocol != DEMO_PROTOCOL )
{
Con_Printf( S_ERROR "playdemo: demo protocol outdated (%i should be %i)\n", demo.header.dem_protocol, DEMO_PROTOCOL );
CL_DemoAborted();
return;
}
if( demo.header.net_protocol != PROTOCOL_VERSION &&
demo.header.net_protocol != PROTOCOL_LEGACY_VERSION )
{
Con_Printf( S_ERROR "playdemo: net protocol outdated (%i should be %i)\n", demo.header.net_protocol, PROTOCOL_VERSION );
CL_DemoAborted();
return;
}
// now read in the directory structure.
FS_Seek( cls.demofile, demo.header.directory_offset, SEEK_SET );
FS_Read( cls.demofile, &demo.directory.numentries, sizeof( int ));
if( demo.directory.numentries < 1 || demo.directory.numentries > 1024 )
{
Con_Printf( S_ERROR "demo had bogus # of directory entries: %i\n", demo.directory.numentries );
CL_DemoAborted();
return;
}
// allocate demo entries
demo.directory.entries = Mem_Malloc( cls.mempool, sizeof( *demo.directory.entries ) * demo.directory.numentries );
demo.directory.entries = Mem_Malloc( cls.mempool, sizeof( demoentry_t ) * demo.directory.numentries );
for( i = 0; i < demo.directory.numentries; i++ )
{
demoentry_t *entry = &demo.directory.entries[i];
if( FS_Read( cls.demofile, entry, sizeof( *entry )) != sizeof( *entry ))
{
Con_Printf( S_ERROR "%s: demo entry %i of %s corrupted", Cmd_Argv( 0 ), i, filename );
CL_DemoAborted();
return;
}
entry->description[sizeof( entry->description ) - 1] = 0;
FS_Read( cls.demofile, &demo.directory.entries[i], sizeof( demoentry_t ));
}
demo.entryIndex = 0;
@@ -1598,11 +1542,9 @@ void CL_PlayDemo_f( void )
CL_DemoStartPlayback( DEMO_XASH3D );
// must be after DemoStartPlayback, as CL_Disconnect_f resets the protocol
cls.legacymode = CL_GetProtocolFromDemo( demo.header.net_protocol );
// g-cont. is this need?
Q_strncpy( cls.servername, demoname, sizeof( cls.servername ));
cls.legacymode = demo.header.net_protocol == PROTOCOL_LEGACY_VERSION;
// begin a playback demo
}
@@ -1644,7 +1586,7 @@ void CL_StartDemos_f( void )
c = Cmd_Argc() - 1;
if( c > MAX_DEMOS )
{
Con_DPrintf( S_WARN "%s: max %i demos in demoloop\n", __func__, MAX_DEMOS );
Con_DPrintf( S_WARN "Host_StartDemos: max %i demos in demoloop\n", MAX_DEMOS );
c = MAX_DEMOS;
}
@@ -1702,78 +1644,3 @@ void CL_Stop_f( void )
S_StopBackgroundTrack();
}
}
void CL_ListDemo_f( void )
{
demoheader_t hdr;
int32_t num_entries;
file_t *f;
char filename[MAX_QPATH];
char demoname[MAX_QPATH];
int i;
if( Cmd_Argc() < 2 )
{
Con_Printf( S_USAGE "%s <demoname>\n", Cmd_Argv( 0 ));
return;
}
Q_strncpy( demoname, Cmd_Argv( 1 ), sizeof( demoname ));
COM_StripExtension( demoname );
Q_snprintf( filename, sizeof( filename ), "%s.dem", demoname );
f = FS_Open( filename, "rb", true );
if( !f )
{
Con_Printf( S_ERROR "couldn't open %s\n", filename );
return;
}
if( !CL_ParseDemoHeader( Cmd_Argv( 0 ), filename, f, &hdr, &num_entries ))
{
FS_Close( f );
return;
}
Con_Printf( "Demo contents for %s:\n"
"\tProtocol: %i net/%i demo\n"
"\tFPS: %g\n"
"\tMap: %s\n"
"\tComment: %s\n"
"\tGame: %s\n",
filename, hdr.net_protocol, hdr.dem_protocol, hdr.host_fps, hdr.mapname,
hdr.comment, hdr.gamedir );
for( i = 0; i < num_entries; i++ )
{
demoentry_t entry;
Con_Printf( "Demo entry #%i:\n", i );
if( FS_Read( f, &entry, sizeof( entry )) != sizeof( entry ))
{
Con_Printf( S_ERROR "can't read demo entry\n" );
FS_Close( f );
return;
}
entry.description[sizeof( entry.description ) - 1] = 0;
if( entry.entrytype == DEMO_STARTUP )
{
// startup entries don't have anything useful
Con_Printf( "\tEntry type: " S_YELLOW "startup" S_DEFAULT "\n" );
}
else
{
Con_Printf( "\tEntry type: " S_GREEN "normal" S_DEFAULT " (%i)\n"
"\tEntry playback time/frames: %.2f seconds/%i frames\n"
"\tEntry flags: 0x%x\n"
"\tEntry description: %s\n",
entry.entrytype, entry.playback_time, entry.playback_frames,
entry.flags, entry.description );
}
}
FS_Close( f );
}

View File

@@ -28,51 +28,10 @@ GNU General Public License for more details.
===============================================================================
*/
#define NUM_EFRAGS_ALLOC 64 // alloc 64 efrags (1-2kb each alloc)
static efrag_t **lastlink;
static mnode_t *r_pefragtopnode;
static vec3_t r_emins, r_emaxs;
static cl_entity_t *r_addent;
static int cl_efrags_num;
static efrag_t *cl_efrags;
static efrag_t *CL_AllocEfrags( int num )
{
int i;
efrag_t *efrags;
if( !cl.worldmodel )
{
Host_Error( "%s: called with NULL world\n", __func__ );
return NULL;
}
if( num == 0 )
return NULL;
// set world to be the owner, so it will get automatically cleaned up
efrags = Mem_Calloc( cl.worldmodel->mempool, sizeof( *efrags ) * num );
// initialize linked list
for( i = 0; i < num - 1; i++ )
efrags[i].entnext = &efrags[i + 1];
cl_efrags_num += num;
return efrags;
}
/*
==============
CL_ClearEfrags
==============
*/
void CL_ClearEfrags( void )
{
cl_efrags_num = 0;
cl_efrags = NULL;
}
/*
===================
@@ -97,11 +56,14 @@ static void R_SplitEntityOnNode( mnode_t *node )
leaf = (mleaf_t *)node;
// grab an efrag off the free list
ef = cl_efrags;
ef = clgame.free_efrags;
if( !ef )
ef = CL_AllocEfrags( NUM_EFRAGS_ALLOC );
{
Con_Printf( S_ERROR "too many efrags!\n" );
return; // no free fragments...
}
cl_efrags = ef->entnext;
clgame.free_efrags = ef->entnext;
ef->entity = r_addent;
// add the entity link
@@ -171,29 +133,35 @@ R_StoreEfrags
*/
void R_StoreEfrags( efrag_t **ppefrag, int framecount )
{
efrag_t *pefrag;
cl_entity_t *pent;
model_t *clmodel;
cl_entity_t *pent;
model_t *clmodel;
efrag_t *pefrag;
while(( pefrag = *ppefrag ) != NULL )
{
pent = pefrag->entity;
clmodel = pent->model;
// how this could happen?
if( unlikely( clmodel->type < mod_brush || clmodel->type > mod_studio ))
continue;
if( pent->visframe != framecount )
switch( clmodel->type )
{
if( CL_AddVisibleEntity( pent, ET_FRAGMENTED ))
case mod_alias:
case mod_brush:
case mod_studio:
case mod_sprite:
if( pent->visframe != framecount )
{
// mark that we've recorded this entity for this frame
pent->curstate.messagenum = cl.parsecount;
pent->visframe = framecount;
if( CL_AddVisibleEntity( pent, ET_FRAGMENTED ))
{
// mark that we've recorded this entity for this frame
pent->curstate.messagenum = cl.parsecount;
pent->visframe = framecount;
}
}
}
ppefrag = &pefrag->leafnext;
ppefrag = &pefrag->leafnext;
break;
default:
break;
}
}
}

View File

@@ -218,7 +218,7 @@ R_AllocTracer
can return NULL if particles is out
================
*/
static particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
{
particle_t *p;
@@ -250,7 +250,7 @@ static particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life
VectorCopy( vel, p->vel );
p->die = cl.time + life;
p->ramp = tracerlength.value;
p->color = TRACER_COLORINDEX_DEFAULT; // select custom color
p->color = 4; // select custom color
p->packedColor = 255; // alpha
return p;
@@ -300,7 +300,7 @@ R_BeamAlloc
==============
*/
static BEAM *R_BeamAlloc( void )
BEAM *R_BeamAlloc( void )
{
BEAM *pBeam;
@@ -323,7 +323,7 @@ R_BeamFree
==============
*/
static void R_BeamFree( BEAM *pBeam )
void R_BeamFree( BEAM *pBeam )
{
// free particles that have died off.
R_FreeDeadParticles( &pBeam->particles );
@@ -605,7 +605,7 @@ CL_BeamAttemptToDie
Check for expired beams
==============
*/
static qboolean CL_BeamAttemptToDie( BEAM *pBeam )
qboolean CL_BeamAttemptToDie( BEAM *pBeam )
{
Assert( pBeam != NULL );
@@ -636,24 +636,12 @@ and all particle trails (if this is a beamfollow)
*/
void GAME_EXPORT R_BeamKill( int deadEntity )
{
BEAM *beam;
cl_entity_t *pDeadEntity;
for( beam = cl_active_beams; beam; beam = beam->next )
{
if( FBitSet( beam->flags, FBEAM_STARTENTITY ) && beam->startEntity == deadEntity )
{
if( beam->type != TE_BEAMFOLLOW )
beam->die = cl.time;
pDeadEntity = R_BeamGetEntity( deadEntity );
if( !pDeadEntity ) return;
ClearBits( beam->flags, FBEAM_STARTENTITY );
}
if( FBitSet( beam->flags, FBEAM_ENDENTITY ) && beam->endEntity == deadEntity )
{
beam->die = cl.time;
ClearBits( beam->flags, FBEAM_ENDENTITY );
}
}
CL_KillDeadBeams( pDeadEntity );
}
/*
@@ -1106,7 +1094,9 @@ void GAME_EXPORT R_ParticleExplosion2( const vec3_t org, int colorStart, int col
int colorMod = 0, packedColor;
particle_t *p;
packedColor = Host_IsQuakeCompatible( ) ? 255 : 0; // use old code for blob particles
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
packedColor = 255; // use old code for blob particles
else packedColor = 0;
for( i = 0; i < 512; i++ )
{
@@ -1139,7 +1129,9 @@ void GAME_EXPORT R_BlobExplosion( const vec3_t org )
particle_t *p;
int i, j, packedColor;
packedColor = Host_IsQuakeCompatible( ) ? 255 : 0; // use old code for blob particles
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
packedColor = 255; // use old code for blob particles
else packedColor = 0;
for( i = 0; i < 1024; i++ )
{
@@ -2048,7 +2040,7 @@ void CL_ReadPointFile_f( void )
else Con_Printf( "map %s has no leaks!\n", clgame.mapname );
}
static void CL_FreeDeadBeams( void )
void CL_FreeDeadBeams( void )
{
BEAM *pBeam, *pNext, *pPrev = NULL;
// draw temporary entity beams

View File

@@ -40,7 +40,7 @@ CL_CalcPlayerVelocity
compute velocity for a given client
=============
*/
static void CL_CalcPlayerVelocity( int idx, vec3_t velocity )
void CL_CalcPlayerVelocity( int idx, vec3_t velocity )
{
clientdata_t *pcd;
vec3_t delta;
@@ -78,7 +78,7 @@ CL_DescribeEvent
=============
*/
static void CL_DescribeEvent( event_info_t *ei, int slot )
void CL_DescribeEvent( event_info_t *ei, int slot )
{
int idx = (slot & 63) * 2;
con_nprint_t info;
@@ -192,7 +192,7 @@ void CL_RegisterEvent( int lastnum, const char *szEvName, pfnEventHook func )
ev = clgame.events[lastnum];
// NOTE: ev->index will be set later
Q_strncpy( ev->name, szEvName, sizeof( ev->name ));
Q_strncpy( ev->name, szEvName, MAX_QPATH );
ev->func = func;
}
@@ -202,7 +202,7 @@ CL_FireEvent
=============
*/
static qboolean CL_FireEvent( event_info_t *ei, int slot )
qboolean CL_FireEvent( event_info_t *ei, int slot )
{
cl_user_event_t *ev;
const char *name;
@@ -219,7 +219,7 @@ static qboolean CL_FireEvent( event_info_t *ei, int slot )
if( !ev )
{
idx = bound( 1, ei->index, ( MAX_EVENTS - 1 ));
Con_Reportf( S_ERROR "%s: %s not precached\n", __func__, cl.event_precache[idx] );
Con_Reportf( S_ERROR "CL_FireEvent: %s not precached\n", cl.event_precache[idx] );
break;
}
@@ -244,7 +244,7 @@ static qboolean CL_FireEvent( event_info_t *ei, int slot )
return true;
}
Con_Reportf( S_ERROR "%s: %s not hooked\n", __func__, name );
Con_Reportf( S_ERROR "CL_FireEvent: %s not hooked\n", name );
break;
}
}
@@ -292,7 +292,7 @@ CL_FindEvent
find first empty event
=============
*/
static event_info_t *CL_FindEmptyEvent( void )
event_info_t *CL_FindEmptyEvent( void )
{
int i;
event_state_t *es;
@@ -320,7 +320,7 @@ CL_FindEvent
replace only unreliable events
=============
*/
static event_info_t *CL_FindUnreliableEvent( void )
event_info_t *CL_FindUnreliableEvent( void )
{
event_state_t *es;
event_info_t *ei;
@@ -350,7 +350,7 @@ CL_QueueEvent
=============
*/
static void CL_QueueEvent( int flags, int index, float delay, event_args_t *args )
void CL_QueueEvent( int flags, int index, float delay, event_args_t *args )
{
event_info_t *ei;
@@ -497,14 +497,14 @@ void GAME_EXPORT CL_PlaybackEvent( int flags, const edict_t *pInvoker, word even
// first check event for out of bounds
if( eventindex < 1 || eventindex >= MAX_EVENTS )
{
Con_DPrintf( S_ERROR "%s: invalid eventindex %i\n", __func__, eventindex );
Con_DPrintf( S_ERROR "CL_PlaybackEvent: invalid eventindex %i\n", eventindex );
return;
}
// check event for precached
if( !CL_EventIndex( cl.event_precache[eventindex] ))
{
Con_DPrintf( S_ERROR "%s: event %i was not precached\n", __func__, eventindex );
Con_DPrintf( S_ERROR "CL_PlaybackEvent: event %i was not precached\n", eventindex );
return;
}

View File

@@ -46,35 +46,10 @@ static int CL_LoadFontTexture( const char *fontname, uint texFlags, int *width )
return tex;
}
static int CL_FontRenderMode( convar_t *fontrender )
{
switch((int)fontrender->value )
{
case 0:
return kRenderTransAdd;
case 1:
return kRenderTransAlpha;
case 2:
return kRenderTransTexture;
default:
Cvar_DirectSet( fontrender, fontrender->def_string );
}
return kRenderTransTexture;
}
void CL_SetFontRendermode( cl_font_t *font )
{
ref.dllFuncs.GL_SetRenderMode( CL_FontRenderMode( font->rendermode ));
}
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags )
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags )
{
int font_width, i;
if( !rendermode )
return false;
if( font->valid )
return true; // already loaded
@@ -85,6 +60,7 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc
font->type = FONT_FIXED;
font->valid = true;
font->scale = scale;
font->nearest = FBitSet( texFlags, TF_NEAREST );
font->rendermode = rendermode;
font->charHeight = Q_rint( font_width / 16 * scale );
@@ -101,16 +77,13 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc
return true;
}
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags )
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags )
{
fs_offset_t length;
qfont_t src;
byte *pfile;
int font_width, i;
if( !rendermode )
return false;
if( font->valid )
return true;
@@ -133,7 +106,8 @@ qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float
font->type = FONT_VARIABLE;
font->valid = true;
font->scale = scale ? scale : 1.0f;
font->scale = scale;
font->nearest = FBitSet( texFlags, TF_NEAREST );
font->rendermode = rendermode;
font->charHeight = Q_rint( src.rowheight * scale );
@@ -205,8 +179,7 @@ int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *fon
return font->charWidths[number];
rc = &font->fontRc[number];
if( font->scale <= 1.f || !REF_GET_PARM( PARM_TEX_FILTERING, font->hFontTexture ))
if( font->nearest || font->scale <= 1.0f )
half = 0;
s1 = ((float)rc->left + half ) / texw;
@@ -220,7 +193,7 @@ int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *fon
SPR_AdjustSize( &x, &y, &w, &h );
if( !FBitSet( flags, FONT_DRAW_NORENDERMODE ))
CL_SetFontRendermode( font );
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
// don't apply color to fixed fonts it's already colored
if( font->type != FONT_FIXED || REF_GET_PARM( PARM_TEX_GLFORMAT, font->hFontTexture ) == 0x8045 ) // GL_LUMINANCE8_ALPHA8
@@ -243,7 +216,7 @@ int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *fon
Con_UtfProcessChar( 0 ); // clear utf state
if( !FBitSet( flags, FONT_DRAW_NORENDERMODE ))
CL_SetFontRendermode( font );
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
Vector4Copy( color, current_color );

View File

@@ -26,18 +26,6 @@ GNU General Public License for more details.
// #define STUDIO_INTERPOLATION_FIX
/*
==================
CL_IsPlayerIndex
detect player entity
==================
*/
qboolean CL_IsPlayerIndex( int idx )
{
return ( idx >= 1 && idx <= cl.maxclients );
}
/*
=========================================================================
@@ -52,7 +40,7 @@ CL_UpdatePositions
Store another position into interpolation circular buffer
==================
*/
static void CL_UpdatePositions( cl_entity_t *ent )
void CL_UpdatePositions( cl_entity_t *ent )
{
position_history_t *ph, *prev;
@@ -85,7 +73,7 @@ CL_ResetPositions
Interpolation init or reset after teleporting
==================
*/
static void CL_ResetPositions( cl_entity_t *ent )
void CL_ResetPositions( cl_entity_t *ent )
{
position_history_t store;
@@ -95,7 +83,8 @@ static void CL_ResetPositions( cl_entity_t *ent )
ent->current_position = 1;
memset( ent->ph, 0, sizeof( position_history_t ) * HISTORY_MAX );
ent->ph[1] = ent->ph[0] = store;
memcpy( &ent->ph[1], &store, sizeof( position_history_t ));
memcpy( &ent->ph[0], &store, sizeof( position_history_t ));
}
/*
@@ -106,7 +95,7 @@ check for instant movement in case
we don't want interpolate this
==================
*/
static qboolean CL_EntityTeleported( cl_entity_t *ent )
qboolean CL_EntityTeleported( cl_entity_t *ent )
{
float len, maxlen;
vec3_t delta;
@@ -127,7 +116,7 @@ CL_CompareTimestamps
round-off floating errors
==================
*/
static qboolean CL_CompareTimestamps( float t1, float t2 )
qboolean CL_CompareTimestamps( float t1, float t2 )
{
int iTime1 = t1 * 1000;
int iTime2 = t2 * 1000;
@@ -142,7 +131,7 @@ CL_EntityIgnoreLerp
some ents will be ignore lerping
==================
*/
static qboolean CL_EntityIgnoreLerp( cl_entity_t *e )
qboolean CL_EntityIgnoreLerp( cl_entity_t *e )
{
if( cl_nointerp.value > 0.f )
return true;
@@ -159,7 +148,7 @@ CL_EntityCustomLerp
==================
*/
static qboolean CL_EntityCustomLerp( cl_entity_t *e )
qboolean CL_EntityCustomLerp( cl_entity_t *e )
{
switch( e->curstate.movetype )
{
@@ -225,7 +214,7 @@ CL_UpdateLatchedVars
====================
*/
static void CL_UpdateLatchedVars( cl_entity_t *ent )
void CL_UpdateLatchedVars( cl_entity_t *ent )
{
if( !ent->model || ( ent->model->type != mod_alias && ent->model->type != mod_studio ))
return; // below fields used only for alias and studio interpolation
@@ -320,7 +309,7 @@ CL_ProcessEntityUpdate
apply changes since new frame received
==================
*/
static void CL_ProcessEntityUpdate( cl_entity_t *ent )
void CL_ProcessEntityUpdate( cl_entity_t *ent )
{
qboolean parametric;
@@ -584,7 +573,7 @@ CL_ProcessPlayerState
process player states after the new packet has received
=================
*/
static void CL_ProcessPlayerState( int playerindex, entity_state_t *state )
void CL_ProcessPlayerState( int playerindex, entity_state_t *state )
{
entity_state_t *ps;
@@ -604,7 +593,7 @@ reset latched state if this frame entity was teleported
or just EF_NOINTERP was set
=================
*/
static void CL_ResetLatchedState( int pnum, frame_t *frame, cl_entity_t *ent )
void CL_ResetLatchedState( int pnum, frame_t *frame, cl_entity_t *ent )
{
if( CHECKVISBIT( frame->flags, pnum ))
{
@@ -694,7 +683,7 @@ CL_FlushEntityPacket
Read and ignore whole entity packet.
=================
*/
static void CL_FlushEntityPacket( sizebuf_t *msg )
void CL_FlushEntityPacket( sizebuf_t *msg )
{
int newnum;
entity_state_t from, to;
@@ -711,7 +700,7 @@ static void CL_FlushEntityPacket( sizebuf_t *msg )
break; // done
if( MSG_CheckOverflow( msg ))
Host_Error( "%s: overflow\n", __func__ );
Host_Error( "CL_FlushEntityPacket: overflow\n" );
MSG_ReadDeltaEntity( msg, &from, &to, newnum, CL_IsPlayerIndex( newnum ) ? DELTA_PLAYER : DELTA_ENTITY, cl.mtime[0] );
}
@@ -724,7 +713,7 @@ CL_DeltaEntity
processing delta update
=================
*/
static void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t *old, qboolean has_update )
void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t *old, qboolean has_update )
{
cl_entity_t *ent;
entity_state_t *state;
@@ -739,7 +728,7 @@ static void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_s
if(( newnum < 0 ) || ( newnum >= clgame.maxEntities ))
{
Con_DPrintf( S_ERROR "%s: invalid newnum: %d\n", __func__, newnum );
Con_DPrintf( S_ERROR "CL_DeltaEntity: invalid newnum: %d\n", newnum );
if( has_update )
MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] );
return;
@@ -751,7 +740,7 @@ static void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_s
if( has_update )
alive = MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] );
else *state = *old;
else memcpy( state, old, sizeof( entity_state_t ));
if( !alive )
{
@@ -884,7 +873,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
break; // done
if( MSG_CheckOverflow( msg ))
Host_Error( "%s: overflow\n", __func__ );
Host_Error( "CL_ParsePacketEntities: overflow\n" );
player = CL_IsPlayerIndex( newnum );
@@ -954,7 +943,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
}
if( newframe->num_entities != count && newframe->num_entities != 0 )
Con_Reportf( S_WARN "%s%s: (%i should be %i)\n", __func__, delta ? "Delta" : "", newframe->num_entities, count );
Con_Reportf( S_WARN "CL_Parse%sPacketEntities: (%i should be %i)\n", delta ? "Delta" : "", newframe->num_entities, count );
if( !newframe->valid )
return playerbytes; // frame is not valid but message was parsed
@@ -1056,7 +1045,7 @@ CL_LinkCustomEntity
Add server beam to draw list
=============
*/
static void CL_LinkCustomEntity( cl_entity_t *ent, entity_state_t *state )
void CL_LinkCustomEntity( cl_entity_t *ent, entity_state_t *state )
{
ent->curstate.movetype = state->modelindex; // !!!
@@ -1079,7 +1068,7 @@ Create visible entities in the correct position
for all current players
=============
*/
static void CL_LinkPlayers( frame_t *frame )
void CL_LinkPlayers( frame_t *frame )
{
entity_state_t *state;
cl_entity_t *ent;
@@ -1162,7 +1151,7 @@ CL_LinkPacketEntities
===============
*/
static void CL_LinkPacketEntities( frame_t *frame )
void CL_LinkPacketEntities( frame_t *frame )
{
cl_entity_t *ent;
entity_state_t *state;
@@ -1186,7 +1175,7 @@ static void CL_LinkPacketEntities( frame_t *frame )
if( !ent )
{
Con_Reportf( S_ERROR "%s: bad entity %i\n", __func__, state->number );
Con_Reportf( S_ERROR "CL_LinkPacketEntity: bad entity %i\n", state->number );
continue;
}
@@ -1491,3 +1480,9 @@ qboolean CL_GetMovieSpatialization( rawchan_t *ch )
return true;
}
void CL_ExtraUpdate( void )
{
clgame.dllFuncs.IN_Accumulate();
S_ExtraUpdate();
}

View File

@@ -96,41 +96,6 @@ static dllfunc_t cdll_new_exports[] = // allowed only in SDK 2.3 and higher
static void pfnSPR_DrawHoles( int frame, int x, int y, const wrect_t *prc );
/*
====================
CL_GetEntityByIndex
Render callback for studio models
====================
*/
cl_entity_t *CL_GetEntityByIndex( int index )
{
if( !clgame.entities ) // not in game yet
return NULL;
if( index < 0 || index >= clgame.maxEntities )
return NULL;
if( index == 0 )
return clgame.entities;
return CL_EDICT_NUM( index );
}
/*
================
CL_ModelHandle
get model handle by index
================
*/
model_t *CL_ModelHandle( int modelindex )
{
if( modelindex < 0 || modelindex >= MAX_MODELS )
return NULL;
return cl.models[modelindex];
}
/*
====================
CL_IsThirdPerson
@@ -231,7 +196,7 @@ static void CL_InitCDAudio( const char *filename )
if( ++c > MAX_CDTRACKS - 1 )
{
Con_Reportf( S_WARN "%s: too many tracks %i in %s\n", __func__, MAX_CDTRACKS, filename );
Con_Reportf( S_WARN "CD_Init: too many tracks %i in %s\n", MAX_CDTRACKS, filename );
break;
}
}
@@ -357,23 +322,20 @@ void SPR_AdjustSize( float *x, float *y, float *w, float *h )
*h *= yscale;
}
static void SPR_AdjustTexCoords( int texnum, float width, float height, float *s1, float *t1, float *s2, float *t2 )
void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float *s2, float *t2 )
{
if( REF_GET_PARM( PARM_TEX_FILTERING, texnum ))
if( refState.width != clgame.scrInfo.iWidth )
{
if( refState.width != clgame.scrInfo.iWidth )
{
// align to texel if scaling
*s1 += 0.5f;
*s2 -= 0.5f;
}
// align to texel if scaling
*s1 += 0.5f;
*s2 -= 0.5f;
}
if( refState.height != clgame.scrInfo.iHeight )
{
// align to texel if scaling
*t1 += 0.5f;
*t2 -= 0.5f;
}
if( refState.height != clgame.scrInfo.iHeight )
{
// align to texel if scaling
*t1 += 0.5f;
*t2 -= 0.5f;
}
*s1 /= width;
@@ -405,8 +367,6 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
height = h;
}
texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame );
if( prc )
{
wrect_t rc = *prc;
@@ -423,7 +383,7 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
t2 = rc.bottom;
// calc user-defined rectangle
SPR_AdjustTexCoords( texnum, width, height, &s1, &t1, &s2, &t2 );
SPR_AdjustTexCoords( width, height, &s1, &t1, &s2, &t2 );
width = rc.right - rc.left;
height = rc.bottom - rc.top;
}
@@ -439,6 +399,7 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
// scale for screen sizes
SPR_AdjustSize( &x, &y, &width, &height );
texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame );
ref.dllFuncs.Color4ub( clgame.ds.spriteColor[0], clgame.ds.spriteColor[1], clgame.ds.spriteColor[2], clgame.ds.spriteColor[3] );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, texnum );
}
@@ -474,7 +435,8 @@ void CL_DrawCenterPrint( void )
pText = clgame.centerPrint.message;
CL_DrawCharacterLen( font, 0, NULL, &charHeight );
CL_SetFontRendermode( font );
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
for( i = 0; i < clgame.centerPrint.lines; i++ )
{
lineLength = 0;
@@ -550,7 +512,7 @@ fill screen with specfied color
can be modulated
=============
*/
static void CL_DrawScreenFade( void )
void CL_DrawScreenFade( void )
{
screenfade_t *sf = &clgame.fade;
int alpha;
@@ -560,19 +522,7 @@ static void CL_DrawScreenFade( void )
if( !alpha )
return;
if( !FBitSet( sf->fadeFlags, FFADE_MODULATE ))
{
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.Color4ub( sf->fader, sf->fadeg, sf->fadeb, alpha );
}
else if( Host_IsQuakeCompatible( ))
{
// Quake Wrapper and Quake Remake use FFADE_MODULATE for item pickups
// so hack the check here
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
ref.dllFuncs.Color4ub( sf->fader, sf->fadeg, sf->fadeb, alpha );
}
else
if( FBitSet( sf->fadeFlags, FFADE_MODULATE ))
{
ref.dllFuncs.GL_SetRenderMode( kRenderScreenFadeModulate );
@@ -582,6 +532,11 @@ static void CL_DrawScreenFade( void )
(uint16_t)( sf->fadeb * alpha + ( 255 - alpha ) * 255 ) >> 8,
255 );
}
else
{
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.Color4ub( sf->fader, sf->fadeg, sf->fadeb, alpha );
}
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1,
R_GetBuiltinTexture( REF_WHITE_TEXTURE ));
@@ -773,7 +728,7 @@ CL_SoundFromIndex
return soundname from index
====================
*/
static const char *CL_SoundFromIndex( int index )
const char *CL_SoundFromIndex( int index )
{
sfx_t *sfx = NULL;
int hSound;
@@ -784,14 +739,14 @@ static const char *CL_SoundFromIndex( int index )
if( !hSound )
{
Con_DPrintf( S_ERROR "%s: invalid sound index %i\n", __func__, index );
Con_DPrintf( S_ERROR "CL_SoundFromIndex: invalid sound index %i\n", index );
return NULL;
}
sfx = S_GetSfxByHandle( hSound );
if( !sfx )
{
Con_DPrintf( S_ERROR "%s: bad sfx for index %i\n", __func__, index );
Con_DPrintf( S_ERROR "CL_SoundFromIndex: bad sfx for index %i\n", index );
return NULL;
}
@@ -919,7 +874,7 @@ CL_DrawCrosshair
Render crosshair
====================
*/
static void CL_DrawCrosshair( void )
void CL_DrawCrosshair( void )
{
int x, y, width, height;
float xscale, yscale;
@@ -949,7 +904,7 @@ static void CL_DrawCrosshair( void )
VectorAdd( refState.viewangles, cl.crosshairangle, angles );
AngleVectors( angles, forward, NULL, NULL );
VectorAdd( refState.vieworg, forward, point );
ref.dllFuncs.WorldToScreen( point, screen );
gTriApi.WorldToScreen( point, screen );
x += ( clgame.viewport[2] >> 1 ) * screen[0] + 0.5f;
y += ( clgame.viewport[3] >> 1 ) * screen[1] + 0.5f;
@@ -1048,10 +1003,10 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
int i;
if( !pszName || !*pszName )
Host_Error( "%s: bad message name\n", __func__ );
Host_Error( "CL_LinkUserMessage: bad message name\n" );
if( svc_num <= svc_lastmsg )
Host_Error( "%s: tried to hook a system message \"%s\"\n", __func__, svc_strings[svc_num] );
Host_Error( "CL_LinkUserMessage: tried to hook a system message \"%s\"\n", svc_strings[svc_num] );
// see if already hooked
for( i = 0; i < MAX_USER_MESSAGES && clgame.msg[i].name[0]; i++ )
@@ -1068,7 +1023,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
if( i == MAX_USER_MESSAGES )
{
Host_Error( "%s: MAX_USER_MESSAGES hit!\n", __func__ );
Host_Error( "CL_LinkUserMessage: MAX_USER_MESSAGES hit!\n" );
return;
}
@@ -1094,7 +1049,6 @@ void CL_ClearWorld( void )
world.max_recursion = 0;
clgame.ds.cullMode = TRI_FRONT;
clgame.numStatics = 0;
}
@@ -1189,7 +1143,7 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite,
if( type == SPR_CLIENT || type == SPR_HUDSPRITE )
SetBits( m_pSprite->flags, MODEL_CLIENT );
m_pSprite->numtexinfo = texFlags; // store texFlags for renderer into numtexinfo
m_pSprite->numtexinfo = texFlags; // store texFlags into numtexinfo
if( !FS_FileExists( szSpriteName, false ) )
{
@@ -1216,7 +1170,7 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite,
ref.dllFuncs.Mod_LoadMapSprite( m_pSprite, buf, size, &loaded );
else
{
Mod_LoadSpriteModel( m_pSprite, buf, &loaded );
Mod_LoadSpriteModel( m_pSprite, buf, &loaded, texFlags );
ref.dllFuncs.Mod_ProcessRenderData( m_pSprite, true, buf );
}
@@ -1249,7 +1203,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
if( !COM_CheckString( filename ))
{
Con_Reportf( S_ERROR "%s: bad name!\n", __func__ );
Con_Reportf( S_ERROR "CL_LoadSpriteModel: bad name!\n" );
return NULL;
}
@@ -1336,7 +1290,6 @@ pfnSPR_Load
function exported for support GoldSrc Monitor utility
=========
*/
HSPRITE EXPORT pfnSPR_Load( const char *szPicName );
HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
{
model_t *spr;
@@ -1386,7 +1339,6 @@ pfnSPR_Frames
function exported for support GoldSrc Monitor utility
=========
*/
int EXPORT pfnSPR_Frames( HSPRITE hPic );
int EXPORT pfnSPR_Frames( HSPRITE hPic )
{
int numFrames = 0;
@@ -1455,7 +1407,7 @@ pfnSPR_Draw
*/
static void GAME_EXPORT pfnSPR_Draw( int frame, int x, int y, const wrect_t *prc )
{
ref.dllFuncs.GL_SetRenderMode( kRenderTransAlpha );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
}
@@ -1510,12 +1462,12 @@ static void GAME_EXPORT pfnSPR_DrawAdditive( int frame, int x, int y, const wrec
/*
=========
SPR_GetList
pfnSPR_GetList
for parsing half-life scripts - hud.txt etc
=========
*/
static client_sprite_t *SPR_GetList( char *psz, int *piCount )
static client_sprite_t *pfnSPR_GetList( char *psz, int *piCount )
{
cached_spritelist_t *pEntry = &clgame.sprlist[0];
int slot, index, numSprites = 0;
@@ -1541,7 +1493,7 @@ static client_sprite_t *SPR_GetList( char *psz, int *piCount )
if( slot == MAX_CLIENT_SPRITES )
{
Con_Printf( S_ERROR "%s: overflow cache!\n", __func__ );
Con_Printf( S_ERROR "SPR_GetList: overflow cache!\n" );
return NULL;
}
@@ -1605,7 +1557,7 @@ CL_FillRGBA
=============
*/
static void GAME_EXPORT CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a )
void GAME_EXPORT CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a )
{
float _x = x, _y = y, _w = w, _h = h;
@@ -1647,7 +1599,6 @@ get actual screen info
*/
int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
{
qboolean apply_scale_factor = false;
float scale_factor = hud_scale.value;
if( FBitSet( hud_fontscale.flags, FCVAR_CHANGED ))
@@ -1662,24 +1613,17 @@ int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
clgame.scrInfo.iSize = sizeof( clgame.scrInfo );
clgame.scrInfo.iFlags = SCRINFO_SCREENFLASH;
if( scale_factor && scale_factor != 1.0f )
{
float scaled_width = (float)refState.width / scale_factor;
if( scaled_width >= hud_scale_minimal_width.value )
apply_scale_factor = true;
}
if( apply_scale_factor )
if( scale_factor && scale_factor != 1.0f)
{
clgame.scrInfo.iWidth = (float)refState.width / scale_factor;
clgame.scrInfo.iHeight = (float)refState.height / scale_factor;
SetBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED );
clgame.scrInfo.iFlags |= SCRINFO_STRETCHED;
}
else
{
clgame.scrInfo.iWidth = refState.width;
clgame.scrInfo.iHeight = refState.height;
ClearBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED );
clgame.scrInfo.iFlags &= ~SCRINFO_STRETCHED;
}
if( !pscrinfo ) return 0;
@@ -1720,8 +1664,7 @@ pfnCvar_RegisterVariable
static cvar_t *GAME_EXPORT pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags )
{
// a1ba: try to mitigate outdated client.dll vulnerabilities
if( !Q_stricmp( szName, "motdfile" )
|| !Q_stricmp( szName, "sensitivity" ))
if( !Q_stricmp( szName, "motdfile" ))
flags |= FCVAR_PRIVILEGED;
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_CLIENTDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_CLIENTDLL ));
@@ -1750,7 +1693,7 @@ static int GAME_EXPORT pfnHookUserMsg( const char *pszName, pfnUserMsgHook pfn )
if( i == MAX_USER_MESSAGES )
{
Host_Error( "%s: MAX_USER_MESSAGES hit!\n", __func__ );
Host_Error( "HookUserMsg: MAX_USER_MESSAGES hit!\n" );
return 0;
}
@@ -2142,7 +2085,7 @@ pfnGetViewModel
=============
*/
static cl_entity_t* GAME_EXPORT CL_GetViewModel( void )
cl_entity_t* GAME_EXPORT CL_GetViewModel( void )
{
return &clgame.viewent;
}
@@ -2300,7 +2243,7 @@ static void GAME_EXPORT pfnHookEvent( const char *filename, pfnEventHook pfn )
if( !Q_stricmp( name, ev->name ) && ev->func != NULL )
{
Con_Reportf( S_WARN "%s: %s already hooked!\n", __func__, name );
Con_Reportf( S_WARN "CL_HookEvent: %s already hooked!\n", name );
return;
}
}
@@ -2383,7 +2326,7 @@ static int GAME_EXPORT CL_FindModelIndex( const char *m )
if( lasttimewarn < host.realtime )
{
// tell user about problem (but don't spam console)
Con_DPrintf( S_ERROR "Could not find index for model %s: not precached\n", filepath );
Con_Printf( S_ERROR "Could not find index for model %s: not precached\n", filepath );
lasttimewarn = host.realtime + 1.0f;
}
@@ -2435,8 +2378,8 @@ static void GAME_EXPORT pfnLocalPlayerBounds( int hull, float *mins, float *maxs
{
if( hull >= 0 && hull < 4 )
{
if( mins ) VectorCopy( host.player_mins[hull], mins );
if( maxs ) VectorCopy( host.player_maxs[hull], maxs );
if( mins ) VectorCopy( clgame.pmove->player_mins[hull], mins );
if( maxs ) VectorCopy( clgame.pmove->player_maxs[hull], maxs );
}
}
@@ -2491,51 +2434,6 @@ static physent_t *pfnGetVisent( int idx )
return NULL;
}
static int GAME_EXPORT CL_TestLine( const vec3_t start, const vec3_t end, int flags )
{
return PM_TestLineExt( clgame.pmove, clgame.pmove->physents, clgame.pmove->numphysent, start, end, flags );
}
/*
=============
CL_PushTraceBounds
=============
*/
static void GAME_EXPORT CL_PushTraceBounds( int hullnum, const float *mins, const float *maxs )
{
if( !host.trace_bounds_pushed )
{
memcpy( host.player_mins_backup, host.player_mins, sizeof( host.player_mins_backup ));
memcpy( host.player_maxs_backup, host.player_maxs, sizeof( host.player_maxs_backup ));
host.trace_bounds_pushed = true;
}
hullnum = bound( 0, hullnum, 3 );
VectorCopy( mins, host.player_mins[hullnum] );
VectorCopy( maxs, host.player_maxs[hullnum] );
}
/*
=============
CL_PopTraceBounds
=============
*/
static void GAME_EXPORT CL_PopTraceBounds( void )
{
if( !host.trace_bounds_pushed )
{
Con_Reportf( S_ERROR "%s called without push!\n", __func__ );
return;
}
host.trace_bounds_pushed = false;
memcpy( host.player_mins, host.player_mins_backup, sizeof( host.player_mins ));
memcpy( host.player_maxs, host.player_maxs_backup, sizeof( host.player_maxs ));
}
/*
=============
pfnSetTraceHull
@@ -2731,48 +2629,6 @@ static model_t *pfnLoadMapSprite( const char *filename )
return NULL;
}
/*
=============
COM_AddAppDirectoryToSearchPath
=============
*/
static void GAME_EXPORT COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName )
{
FS_AddGameHierarchy( pszBaseDir, FS_NOWRITE_PATH );
}
/*
===========
COM_ExpandFilename
Finds the file in the search path, copies over the name with the full path name.
This doesn't search in the pak file.
===========
*/
static int GAME_EXPORT COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize )
{
char result[MAX_SYSPATH];
if( !COM_CheckString( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
return 0;
// filename examples:
// media\sierra.avi - D:\Xash3D\valve\media\sierra.avi
// models\barney.mdl - D:\Xash3D\bshift\models\barney.mdl
if( g_fsapi.GetFullDiskPath( result, sizeof( result ), fileName, false ))
{
// check for enough room
if( Q_strlen( result ) > nameOutBufferSize )
return 0;
Q_strncpy( nameOutBuffer, result, nameOutBufferSize );
return 1;
}
return 0;
}
/*
=============
PlayerInfo_ValueForKey
@@ -2810,10 +2666,10 @@ static void GAME_EXPORT PlayerInfo_SetValueForKey( const char *key, const char *
{
Cvar_DirectSet( var, value );
}
else if( Info_SetValueForStarKey( cls.userinfo, key, value, sizeof( cls.userinfo )))
else if( Info_SetValueForStarKey( cls.userinfo, key, value, MAX_INFO_STRING ))
{
// time to update server copy of userinfo
CL_UpdateInfo( key, value );
CL_ServerCommand( true, "setinfo \"%s\" \"%s\"\n", key, value );
}
}
@@ -3305,7 +3161,7 @@ Heavy legacy of Quake...
*/
void TriColor4fRendermode( float r, float g, float b, float a, int rendermode )
{
if( rendermode == kRenderTransAlpha )
if( clgame.ds.renderMode == kRenderTransAlpha )
{
clgame.ds.triRGBA[3] = a / 255.0f;
ref.dllFuncs.Color4f( r, g, b, a );
@@ -3437,15 +3293,16 @@ NetAPI_SendRequest
static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags, double timeout, netadr_t *remote_address, net_api_response_func_t response )
{
net_request_t *nr = NULL;
string req;
int i;
if( !response )
{
Con_DPrintf( S_ERROR "%s: no callbcak specified for request with context %i!\n", __func__, context );
Con_DPrintf( S_ERROR "Net_SendRequest: no callbcak specified for request with context %i!\n", context );
return;
}
if( remote_address->type == NA_IPX || remote_address->type == NA_BROADCAST_IPX )
if( remote_address->type != NA_IPX && remote_address->type != NA_BROADCAST_IPX )
return; // IPX no longer support
if( request == NETAPI_REQUEST_SERVERLIST )
@@ -3488,7 +3345,8 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,
nr->flags = flags;
// local servers request
Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "netinfo %i %i %i", FBitSet( flags, FNETAPI_LEGACY_PROTOCOL ) ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION, context, request );
Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request );
Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req );
}
/*
@@ -3792,7 +3650,7 @@ static demo_api_t gDemoApi =
Demo_WriteBuffer,
};
net_api_t gNetApi =
static net_api_t gNetApi =
{
NetAPI_InitNetworking,
NetAPI_Status,
@@ -3828,7 +3686,7 @@ static cl_enginefunc_t gEngfuncs =
pfnSPR_DrawAdditive,
SPR_EnableScissor,
SPR_DisableScissor,
SPR_GetList,
pfnSPR_GetList,
CL_FillRGBA,
CL_GetScreenInfo,
pfnSetCrosshair,
@@ -4050,14 +3908,14 @@ qboolean CL_LoadProgs( const char *name )
// trying to get single export
if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "GetClientAPI" )) != NULL )
{
Con_Reportf( "%s: found single callback export\n", __func__ );
Con_Reportf( "CL_LoadProgs: found single callback export\n" );
// trying to fill interface now
GetClientAPI( &clgame.dllFuncs );
}
else if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "F" )) != NULL )
{
Con_Reportf( "%s: found single callback export (secured client dlls)\n", __func__ );
Con_Reportf( "CL_LoadProgs: found single callback export (secured client dlls)\n" );
// trying to fill interface now
CL_GetSecuredClientAPI( GetClientAPI );
@@ -4085,7 +3943,7 @@ qboolean CL_LoadProgs( const char *name )
// functions are cleared before all the extensions are evaluated
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
{
Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );
Con_Reportf( "CL_LoadProgs: failed to get address of %s proc\n", func->name );
if( critical_exports )
{
@@ -4112,13 +3970,13 @@ qboolean CL_LoadProgs( const char *name )
// functions are cleared before all the extensions are evaluated
// NOTE: new exports can be missed without stop the engine
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );
Con_Reportf( "CL_LoadProgs: failed to get address of %s proc\n", func->name );
}
if( !clgame.dllFuncs.pfnInitialize( &gEngfuncs, CLDLL_INTERFACE_VERSION ))
{
COM_FreeLibrary( clgame.hInstance );
Con_Reportf( "%s: can't init client API\n", __func__ );
Con_Reportf( "CL_LoadProgs: can't init client API\n" );
clgame.hInstance = NULL;
return false;
}
@@ -4135,10 +3993,10 @@ qboolean CL_LoadProgs( const char *name )
CL_InitTempEnts ();
if( !R_InitRenderAPI()) // Xash3D extension
Con_Reportf( S_WARN "%s: couldn't get render API\n", __func__ );
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get render API\n" );
if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface
Con_Reportf( S_WARN "%s: couldn't get mobility API\n", __func__ );
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" );
CL_InitEdicts( cl.maxclients ); // initailize local player and world
CL_InitClientMove(); // initialize pm_shared

View File

@@ -25,14 +25,6 @@ static void UI_UpdateUserinfo( void );
gameui_static_t gameui;
static void UI_ToggleAllowConsole_f( void )
{
host.allow_console = host.allow_console_init = true;
if( gameui.globals )
gameui.globals->developer = true;
}
void UI_UpdateMenu( float realtime )
{
if( !gameui.hInstance ) return;
@@ -224,14 +216,12 @@ UI_ShowConnectionWarning
show message box
=================
*/
qboolean UI_ShowMessageBox( const char *text )
void UI_ShowMessageBox( const char *text )
{
if( gameui.dllFuncs2.pfnShowMessageBox )
{
gameui.dllFuncs2.pfnShowMessageBox( text );
return true;
}
return false;
}
void UI_ConnectionProgress_Disconnect( void )
@@ -407,21 +397,17 @@ void Host_Credits( void )
gameui.dllFuncs.pfnFinalCredits();
}
static void UI_ConvertGameInfo( gameinfo2_t *out, const gameinfo_t *in )
static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in )
{
out->gi_version = GAMEINFO_VERSION;
Q_strncpy( out->gamefolder, in->gamefolder, sizeof( out->gamefolder ));
Q_strncpy( out->startmap, in->startmap, sizeof( out->startmap ));
Q_strncpy( out->trainmap, in->trainmap, sizeof( out->trainmap ));
Q_strncpy( out->demomap, in->demomap, sizeof( out->demomap ));
Q_strncpy( out->title, in->title, sizeof( out->title ));
Q_snprintf( out->version, sizeof( out->version ), "%g", in->version );
Q_strncpy( out->iconpath, in->iconpath, sizeof( out->iconpath ));
Q_strncpy( out->game_url, in->game_url, sizeof( out->game_url ));
Q_strncpy( out->update_url, in->update_url, sizeof( out->update_url ));
out->size = in->size;
Q_strncpy( out->size, Q_pretifymem( in->size, 0 ), sizeof( out->size ));
Q_strncpy( out->type, in->type, sizeof( out->type ));
Q_strncpy( out->date, in->date, sizeof( out->date ));
@@ -439,31 +425,6 @@ static void UI_ConvertGameInfo( gameinfo2_t *out, const gameinfo_t *in )
SetBits( out->flags, GFL_ANIMATED_TITLE );
}
static void UI_ToOldGameInfo( GAMEINFO *out, const gameinfo2_t *in )
{
Q_strncpy( out->gamefolder, in->gamefolder, sizeof( out->gamefolder ));
Q_strncpy( out->startmap, in->startmap, sizeof( out->startmap ));
Q_strncpy( out->trainmap, in->trainmap, sizeof( out->trainmap ));
Q_strncpy( out->title, in->title, sizeof( out->title ));
Q_strncpy( out->version, in->version, sizeof( out->version ));
out->flags = in->flags & 0xFFFF;
Q_strncpy( out->game_url, in->game_url, sizeof( out->game_url ));
Q_strncpy( out->update_url, in->update_url, sizeof( out->update_url ));
Q_strncpy( out->size, Q_memprint( in->size ), sizeof( out->size ));
Q_strncpy( out->type, in->type, sizeof( out->type ));
Q_strncpy( out->date, in->date, sizeof( out->date ));
out->gamemode = in->gamemode;
}
static void UI_GetModsInfo( void )
{
int i;
gameui.modsInfo = Mem_Calloc( gameui.mempool, sizeof( *gameui.modsInfo ) * FI->numgames );
for( i = 0; i < FI->numgames; i++ )
UI_ConvertGameInfo( &gameui.modsInfo[i], FI->games[i] );
}
/*
====================
PIC_DrawGeneric
@@ -531,7 +492,7 @@ static HIMAGE GAME_EXPORT pfnPIC_Load( const char *szPicName, const byte *image_
if( !COM_CheckString( szPicName ))
{
Con_Reportf( S_ERROR "%s: refusing to load image with empty name\n", __func__ );
Con_Reportf( S_ERROR "CL_LoadImage: refusing to load image with empty name\n" );
return 0;
}
@@ -581,7 +542,7 @@ pfnPIC_Set
=========
*/
static void GAME_EXPORT pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a )
void GAME_EXPORT pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a )
{
gameui.ds.gl_texturenum = hPic;
r = bound( 0, r, 255 );
@@ -597,7 +558,7 @@ pfnPIC_Draw
=========
*/
static void GAME_EXPORT pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc )
void GAME_EXPORT pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc )
{
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
PIC_DrawGeneric( x, y, width, height, prc );
@@ -609,7 +570,7 @@ pfnPIC_DrawTrans
=========
*/
static void GAME_EXPORT pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc )
void GAME_EXPORT pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc )
{
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
PIC_DrawGeneric( x, y, width, height, prc );
@@ -621,7 +582,7 @@ pfnPIC_DrawHoles
=========
*/
static void GAME_EXPORT pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc )
void GAME_EXPORT pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc )
{
ref.dllFuncs.GL_SetRenderMode( kRenderTransAlpha );
PIC_DrawGeneric( x, y, width, height, prc );
@@ -633,7 +594,7 @@ pfnPIC_DrawAdditive
=========
*/
static void GAME_EXPORT pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc )
void GAME_EXPORT pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc )
{
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
PIC_DrawGeneric( x, y, width, height, prc );
@@ -961,12 +922,11 @@ pfnGetGameInfo
=========
*/
static int GAME_EXPORT pfnGetOldGameInfo( GAMEINFO *pgameinfo )
static int GAME_EXPORT pfnGetGameInfo( GAMEINFO *pgameinfo )
{
if( !pgameinfo )
return 0;
if( !pgameinfo ) return 0;
UI_ToOldGameInfo( pgameinfo, &gameui.gameInfo );
*pgameinfo = gameui.gameInfo;
return 1;
}
@@ -978,26 +938,8 @@ pfnGetGamesList
*/
static GAMEINFO ** GAME_EXPORT pfnGetGamesList( int *numGames )
{
if( numGames )
*numGames = FI->numgames;
if( !gameui.oldModsInfo )
{
int i;
if( !gameui.modsInfo )
UI_GetModsInfo();
// first allocate array of pointers
gameui.oldModsInfo = Mem_Calloc( gameui.mempool, sizeof( *gameui.oldModsInfo ) * FI->numgames );
for( i = 0; i < FI->numgames; i++ )
{
gameui.oldModsInfo[i] = Mem_Calloc( gameui.mempool, sizeof( *gameui.oldModsInfo[i] ));
UI_ToOldGameInfo( gameui.oldModsInfo[i], &gameui.modsInfo[i] );
}
}
return gameui.oldModsInfo;
if( numGames ) *numGames = FI->numgames;
return gameui.modsInfo;
}
/*
@@ -1042,7 +984,7 @@ pfnCheckGameDll
=========
*/
static int GAME_EXPORT pfnCheckGameDll( void )
int GAME_EXPORT pfnCheckGameDll( void )
{
#ifdef XASH_INTERNAL_GAMELIBS
return true;
@@ -1069,7 +1011,7 @@ pfnChangeInstance
*/
static void GAME_EXPORT pfnChangeInstance( const char *newInstance, const char *szFinalMessage )
{
Con_Reportf( S_ERROR "%s menu call is deprecated!\n", __func__ );
Con_Reportf( S_ERROR "ChangeInstance menu call is deprecated!\n" );
}
/*
@@ -1150,27 +1092,8 @@ static int pfnDelete( const char *path )
return FS_Delete( path );
}
static void GAME_EXPORT pfnCon_DefaultColor( int r, int g, int b )
{
Con_DefaultColor( r, g, b, true );
}
static void GAME_EXPORT pfnSetCursor( void *hCursor )
{
uintptr_t cursor;
if( !gameui.use_extended_api )
return; // ignore original Xash menus
cursor = (uintptr_t)hCursor;
if( cursor < dc_user || cursor > dc_last )
return;
Platform_SetCursorType( cursor );
}
// engine callbacks
static const ui_enginefuncs_t gEngfuncs =
static ui_enginefuncs_t gEngfuncs =
{
pfnPIC_Load,
GL_FreeImage,
@@ -1208,7 +1131,7 @@ static const ui_enginefuncs_t gEngfuncs =
UI_DrawConsoleString,
UI_DrawSetTextColor,
Con_DrawStringLen,
pfnCon_DefaultColor,
Con_DefaultColor,
pfnGetPlayerModel,
pfnSetPlayerModel,
pfnClearScene,
@@ -1234,7 +1157,7 @@ static const ui_enginefuncs_t gEngfuncs =
pfnKeyGetState,
pfnMemAlloc,
pfnMemFree,
pfnGetOldGameInfo,
pfnGetGameInfo,
pfnGetGamesList,
pfnGetFilesList,
SV_GetSaveComment,
@@ -1248,7 +1171,7 @@ static const ui_enginefuncs_t gEngfuncs =
pfnHostEndGame,
COM_RandomFloat,
COM_RandomLong,
pfnSetCursor,
IN_SetCursor,
pfnIsMapValid,
GL_ProcessTexture,
COM_CompareFileTime,
@@ -1281,28 +1204,6 @@ static char *pfnParseFileSafe( char *data, char *buf, const int size, unsigned i
return COM_ParseFileSafe( data, buf, size, flags, len, NULL );
}
static gameinfo2_t *pfnGetGameInfo( int gi_version )
{
if( gi_version != gameui.gameInfo.gi_version )
return NULL;
return &gameui.gameInfo;
}
static gameinfo2_t *pfnGetModInfo( int gi_version, int i )
{
if( i < 0 || i >= FI->numgames )
return NULL;
if( !gameui.modsInfo )
UI_GetModsInfo();
if( gi_version != gameui.modsInfo[i].gi_version )
return NULL;
return &gameui.modsInfo[i];
}
static ui_extendedfuncs_t gExtendedfuncs =
{
pfnEnableTextInput,
@@ -1314,10 +1215,6 @@ static ui_extendedfuncs_t gExtendedfuncs =
pfnParseFileSafe,
NET_AdrToString,
NET_CompareAdrSort,
Sys_GetNativeObject,
&gNetApi,
pfnGetGameInfo,
pfnGetModInfo,
};
void UI_UnloadProgs( void )
@@ -1327,7 +1224,6 @@ void UI_UnloadProgs( void )
// deinitialize game
gameui.dllFuncs.pfnShutdown();
Cmd_RemoveCommand( "ui_allowconsole" );
Cvar_FullSet( "host_gameuiloaded", "0", FCVAR_READ_ONLY );
Cvar_Unlink( FCVAR_GAMEUIDLL );
@@ -1378,65 +1274,71 @@ qboolean UI_LoadProgs( void )
if(( GetMenuAPI = (MENUAPI)COM_GetProcAddress( gameui.hInstance, "GetMenuAPI" )) == NULL )
{
COM_FreeLibrary( gameui.hInstance );
Con_Reportf( "%s: can't init menu API\n", __func__ );
Con_Reportf( "UI_LoadProgs: can't init menu API\n" );
gameui.hInstance = NULL;
return false;
}
gameui.use_extended_api = false;
gameui.use_text_api = false;
// make local copy of engfuncs to prevent overwrite it with user dll
gpEngfuncs = gEngfuncs;
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
gameui.mempool = Mem_AllocPool( "Menu Pool" );
if( !GetMenuAPI( &gameui.dllFuncs, &gpEngfuncs, gameui.globals ))
{
COM_FreeLibrary( gameui.hInstance );
Con_Reportf( "%s: can't init menu API\n", __func__ );
Con_Reportf( "UI_LoadProgs: can't init menu API\n" );
Mem_FreePool( &gameui.mempool );
gameui.hInstance = NULL;
return false;
}
// make local copy of engfuncs to prevent overwrite it with user dll
gpExtendedfuncs = gExtendedfuncs;
memcpy( &gpExtendedfuncs, &gExtendedfuncs, sizeof( gExtendedfuncs ));
memset( &gameui.dllFuncs2, 0, sizeof( gameui.dllFuncs2 ));
// try to initialize new extended API
if( ( GetExtAPI = (UIEXTENEDEDAPI)COM_GetProcAddress( gameui.hInstance, "GetExtAPI" ) ) )
{
Con_Reportf( "%s: extended Menu API found\n", __func__ );
Con_Reportf( "UI_LoadProgs: extended Menu API found\n" );
if( GetExtAPI( MENU_EXTENDED_API_VERSION, &gameui.dllFuncs2, &gpExtendedfuncs ) )
{
Con_Reportf( "%s: extended Menu API initialized\n", __func__ );
gameui.use_extended_api = true;
Con_Reportf( "UI_LoadProgs: extended Menu API initialized\n" );
gameui.use_text_api = true;
}
}
else // otherwise, fallback to old and deprecated extensions
{
if( ( GiveTextApi = (UITEXTAPI)COM_GetProcAddress( gameui.hInstance, "GiveTextAPI" ) ) )
{
Con_Reportf( "%s: extended text API found\n", __func__ );
Con_Reportf( "UI_LoadProgs: extended text API found\n" );
Con_Reportf( S_WARN "Text API is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" );
if( GiveTextApi( &gpExtendedfuncs ) ) // they are binary compatible, so we can just pass extended funcs API to menu
{
Con_Reportf( "%s: extended text API initialized\n", __func__ );
gameui.use_extended_api = true;
Con_Reportf( "UI_LoadProgs: extended text API initialized\n" );
gameui.use_text_api = true;
}
}
gameui.dllFuncs2.pfnAddTouchButtonToList = (ADDTOUCHBUTTONTOLIST)COM_GetProcAddress( gameui.hInstance, "AddTouchButtonToList" );
if( gameui.dllFuncs2.pfnAddTouchButtonToList )
{
Con_Reportf( "%s: AddTouchButtonToList call found\n", __func__ );
Con_Reportf( "UI_LoadProgs: AddTouchButtonToList call found\n" );
Con_Reportf( S_WARN "AddTouchButtonToList is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" );
}
}
Cvar_FullSet( "host_gameuiloaded", "1", FCVAR_READ_ONLY );
Cmd_AddRestrictedCommand( "ui_allowconsole", UI_ToggleAllowConsole_f, "unlocks developer console" );
// setup gameinfo
for( i = 0; i < FI->numgames; i++ )
{
gameui.modsInfo[i] = Mem_Calloc( gameui.mempool, sizeof( GAMEINFO ));
UI_ConvertGameInfo( gameui.modsInfo[i], FI->games[i] );
}
UI_ConvertGameInfo( &gameui.gameInfo, FI->GameInfo ); // current gameinfo

File diff suppressed because it is too large Load Diff

View File

@@ -20,6 +20,8 @@ GNU General Public License for more details.
#include "input.h"
#include "platform/platform.h"
static mobile_engfuncs_t *gMobileEngfuncs;
static CVAR_DEFINE_AUTO( vibration_length, "1.0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "vibration length" );
static CVAR_DEFINE_AUTO( vibration_enable, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "enable vibration" );
@@ -28,9 +30,17 @@ static float g_font_scale;
static void pfnVibrate( float life, char flags )
{
if( !vibration_enable.value || life < 0.0f )
if( !vibration_enable.value )
return;
if( life < 0.0f )
{
Con_Reportf( S_WARN "Negative vibrate time: %f\n", life );
return;
}
//Con_Reportf( "Vibrate: %f %d\n", life, flags );
// here goes platform-specific backends
Platform_Vibrate( life * vibration_length.value, flags );
}
@@ -43,7 +53,7 @@ static void Vibrate_f( void )
return;
}
pfnVibrate( Q_atof( Cmd_Argv( 1 )), VIBRATE_NORMAL );
pfnVibrate( Q_atof( Cmd_Argv(1) ), VIBRATE_NORMAL );
}
static void pfnEnableTextInput( int enable )
@@ -92,7 +102,7 @@ static char *pfnParseFileSafe( char *data, char *buf, const int size, unsigned i
return COM_ParseFileSafe( data, buf, size, flags, len, NULL );
}
static const mobile_engfuncs_t gMobileEngfuncs =
static mobile_engfuncs_t gpMobileEngfuncs =
{
MOBILITY_API_VERSION,
pfnVibrate,
@@ -112,38 +122,21 @@ static const mobile_engfuncs_t gMobileEngfuncs =
qboolean Mobile_Init( void )
{
qboolean success = false;
pfnMobilityInterface ExportToClient;
Cmd_AddCommand( "vibrate", Vibrate_f, "Vibrate for specified time");
// find a mobility interface
ExportToClient = COM_GetProcAddress( clgame.hInstance, MOBILITY_CLIENT_EXPORT );
gMobileEngfuncs = &gpMobileEngfuncs;
if( ExportToClient && !ExportToClient( gMobileEngfuncs ) )
success = true;
Cmd_AddCommand( "vibrate", (xcommand_t)Vibrate_f, "Vibrate for specified time");
Cvar_RegisterVariable( &vibration_length );
Cvar_RegisterVariable( &vibration_enable );
// find mobility interface
if(( ExportToClient = COM_GetProcAddress( clgame.hInstance, MOBILITY_CLIENT_EXPORT )))
{
static mobile_engfuncs_t mobile_engfuncs; // keep a copy, don't let user change engine pointers
mobile_engfuncs = gMobileEngfuncs;
if( !ExportToClient( &mobile_engfuncs ))
{
Con_Reportf( "%s: ^2initailized extended MobilityAPI ^7ver. %i\n", __func__, MOBILITY_API_VERSION );
return true;
}
// make sure that mobile functions are cleared
#if 1
// some SDKs define export as returning void, breaking the contract
// ignore result for now...
return true;
#else
memset( &mobile_engfuncs, 0, sizeof( mobile_engfuncs ));
return false; // just tell user about problems
#endif
}
return true; // mobile interface is missed
return success;
}
void Mobile_Shutdown( void )

View File

@@ -81,12 +81,12 @@ NetGraph_FillRGBA shortcut
*/
static void NetGraph_DrawRect( wrect_t *rect, byte colors[4] )
{
ref.dllFuncs.Color4ub( colors[0], colors[1], colors[2], colors[3] ); // color for this quad
gTriApi.Color4ub( colors[0], colors[1], colors[2], colors[3] ); // color for this quad
ref.dllFuncs.Vertex3f( rect->left, rect->top, 0 );
ref.dllFuncs.Vertex3f( rect->left + rect->right, rect->top, 0 );
ref.dllFuncs.Vertex3f( rect->left + rect->right, rect->top + rect->bottom, 0 );
ref.dllFuncs.Vertex3f( rect->left, rect->top + rect->bottom, 0 );
gTriApi.Vertex3f( rect->left, rect->top, 0 );
gTriApi.Vertex3f( rect->left + rect->right, rect->top, 0 );
gTriApi.Vertex3f( rect->left + rect->right, rect->top + rect->bottom, 0 );
gTriApi.Vertex3f( rect->left, rect->top + rect->bottom, 0 );
}
/*
@@ -387,7 +387,7 @@ static void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int coun
// move rolling average
framerate = FRAMERATE_AVG_FRAC * host.frametime + ( 1.0f - FRAMERATE_AVG_FRAC ) * framerate;
CL_SetFontRendermode( font );
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
if( framerate > 0.0f )
{
@@ -691,7 +691,7 @@ void SCR_DrawNetGraph( void )
ref.dllFuncs.End();
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.RenderMode( kRenderNormal );
}
}

View File

@@ -21,6 +21,7 @@ GNU General Public License for more details.
#include "shake.h"
#include "hltv.h"
#include "input.h"
#include "server.h"
#if XASH_LOW_MEMORY != 2
int CL_UPDATE_BACKUP = SINGLEPLAYER_BACKUP;
#endif
@@ -31,7 +32,7 @@ CL_UserMsgStub
Default stub for missed callbacks
===============
*/
static int CL_UserMsgStub( const char *pszName, int iSize, void *pbuf )
int CL_UserMsgStub( const char *pszName, int iSize, void *pbuf )
{
return 1;
}
@@ -57,7 +58,7 @@ CL_ParseSoundPacket
==================
*/
static void CL_ParseSoundPacket( sizebuf_t *msg )
void CL_ParseSoundPacket( sizebuf_t *msg )
{
vec3_t pos;
int chan, sound;
@@ -188,7 +189,7 @@ void CL_ParseServerTime( sizebuf_t *msg )
cl.mtime[1] = cl.mtime[0];
cl.mtime[0] = MSG_ReadFloat( msg );
if( cls.legacymode == PROTO_QUAKE )
if( cls.demoplayback == DEMO_QUAKE1 )
return; // don't mess the time
if( cl.maxclients == 1 )
@@ -249,9 +250,9 @@ void CL_ParseMovevars( sizebuf_t *msg )
// update sky if changed
if( Q_strcmp( clgame.oldmovevars.skyName, clgame.movevars.skyName ) && cl.video_prepped )
R_SetupSky( clgame.movevars.skyName );
ref.dllFuncs.R_SetupSky( clgame.movevars.skyName );
clgame.oldmovevars = clgame.movevars;
memcpy( &clgame.oldmovevars, &clgame.movevars, sizeof( movevars_t ));
clgame.entities->curstate.scale = clgame.movevars.waveHeight;
// keep features an actual!
@@ -304,7 +305,7 @@ CL_ParseStaticEntity
static client entity
==================
*/
static void CL_ParseStaticEntity( sizebuf_t *msg )
void CL_ParseStaticEntity( sizebuf_t *msg )
{
int i, newnum;
entity_state_t from, to;
@@ -388,6 +389,7 @@ void CL_ParseStaticDecal( sizebuf_t *msg )
{
vec3_t origin;
int decalIndex, entityIndex, modelIndex;
cl_entity_t *ent = NULL;
float scale;
int flags;
@@ -457,7 +459,6 @@ void CL_BatchResourceRequest( qboolean initialize )
byte data[MAX_INIT_MSG];
resource_t *p, *n;
sizebuf_t msg;
qboolean done_downloading = true;
MSG_Init( &msg, "Resource Batch", data, sizeof( data ));
@@ -487,24 +488,20 @@ void CL_BatchResourceRequest( qboolean initialize )
case t_model:
case t_eventscript:
if( !CL_CheckFile( &msg, p ))
{
done_downloading = false;
break;
}
CL_MoveToOnHandList( p );
break;
case t_skin:
CL_MoveToOnHandList( p );
break;
case t_decal:
if( !HPAK_GetDataPointer( hpk_custom_file.string, p, NULL, NULL ))
if( !HPAK_GetDataPointer( CUSTOM_RES_PATH, p, NULL, NULL ))
{
if( !FBitSet( p->ucFlags, RES_REQUESTED ))
{
MSG_BeginClientCmd( &msg, clc_stringcmd );
MSG_WriteStringf( &msg, "dlfile !MD5%s", MD5_Print( p->rgucMD5_hash ));;
SetBits( p->ucFlags, RES_REQUESTED );
done_downloading = false;
}
break;
}
@@ -529,7 +526,11 @@ void CL_BatchResourceRequest( qboolean initialize )
if( cls.state != ca_disconnected )
{
if( done_downloading && CL_PrecacheResources( ))
if( !cl.downloadUrl[0] && !MSG_GetNumBytesWritten( &msg ) && CL_PrecacheResources( ))
{
CL_RegisterResources( &msg );
}
if( cl.downloadUrl[0] && host.downloadcount == 0 && CL_PrecacheResources( ) )
{
CL_RegisterResources( &msg );
}
@@ -618,7 +619,7 @@ static void CL_StartResourceDownloading( const char *pszMessage, qboolean bCusto
CL_BatchResourceRequest( !bCustom );
}
static customization_t *CL_PlayerHasCustomization( int nPlayerNum, resourcetype_t type )
customization_t *CL_PlayerHasCustomization( int nPlayerNum, resourcetype_t type )
{
customization_t *pList;
@@ -630,7 +631,7 @@ static customization_t *CL_PlayerHasCustomization( int nPlayerNum, resourcetype_
return NULL;
}
static void CL_RemoveCustomization( int nPlayerNum, customization_t *pRemove )
void CL_RemoveCustomization( int nPlayerNum, customization_t *pRemove )
{
customization_t *pList;
customization_t *pNext;
@@ -721,7 +722,7 @@ void CL_ParseCustomization( sizebuf_t *msg )
}
}
if( HPAK_GetDataPointer( hpk_custom_file.string, pRes, NULL, NULL ))
if( HPAK_GetDataPointer( CUSTOM_RES_PATH, pRes, NULL, NULL ))
{
qboolean bError = false;
@@ -801,7 +802,7 @@ CL_CreateCustomizationList
loading custom decal for self
==================
*/
static void CL_CreateCustomizationList( void )
void CL_CreateCustomizationList( void )
{
resource_t *pResource;
player_info_t *pPlayer;
@@ -853,7 +854,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
int i;
uint32_t mapCRC;
HPAK_CheckSize( hpk_custom_file.string );
HPAK_CheckSize( CUSTOM_RES_PATH );
Con_Reportf( "%s packet received.\n", legacy ? "Legacy serverdata" : "Serverdata" );
@@ -1180,16 +1181,17 @@ CL_ParseBaseline
*/
void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
{
const entity_state_t nullstate = { 0 };
int i, newnum;
entity_state_t nullstate;
qboolean player;
cl_entity_t *ent;
Delta_InitClient (); // finalize client delta's
memset( &nullstate, 0, sizeof( nullstate ));
while( 1 )
{
cl_entity_t *ent;
qboolean player;
int newnum;
if( legacy )
{
newnum = MSG_ReadWord( msg );
@@ -1202,13 +1204,13 @@ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
player = CL_IsPlayerIndex( newnum );
if( newnum >= clgame.maxEntities )
Host_Error( "%s: no free edicts\n", __func__ );
Host_Error( "CL_AllocEdict: no free edicts\n" );
ent = CL_EDICT_NUM( newnum );
ent->prevstate = nullstate;
memset( &ent->prevstate, 0, sizeof( ent->prevstate ));
ent->index = newnum;
MSG_ReadDeltaEntity( msg, &nullstate, &ent->baseline, newnum, player, 1.0f );
MSG_ReadDeltaEntity( msg, &ent->prevstate, &ent->baseline, newnum, player, 1.0f );
if( legacy )
{
@@ -1218,13 +1220,11 @@ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
if( !legacy )
{
int i;
cl.instanced_baseline_count = MSG_ReadUBitLong( msg, 6 );
for( i = 0; i < cl.instanced_baseline_count; i++ )
{
int newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
MSG_ReadDeltaEntity( msg, &nullstate, &cl.instanced_baseline[i], newnum, false, 1.0f );
}
}
@@ -1381,15 +1381,11 @@ void CL_UpdateUserinfo( sizebuf_t *msg, qboolean legacy )
slot = MSG_ReadUBitLong( msg, MAX_CLIENT_BITS );
if( slot >= MAX_CLIENTS )
Host_Error( "%s: svc_updateuserinfo >= MAX_CLIENTS\n", __func__ );
player = &cl.players[slot];
Host_Error( "CL_ParseServerMessage: svc_updateuserinfo >= MAX_CLIENTS\n" );
if( !legacy )
id = MSG_ReadLong( msg ); // unique user ID
else
id = 0; // bogus
player = &cl.players[slot];
active = MSG_ReadOneBit( msg ) ? true : false;
if( active )
@@ -1403,7 +1399,7 @@ void CL_UpdateUserinfo( sizebuf_t *msg, qboolean legacy )
if( !legacy )
MSG_ReadBytes( msg, player->hashedcdkey, sizeof( player->hashedcdkey ));
if( slot == cl.playernum ) gameui.playerinfo = *player;
if( slot == cl.playernum ) memcpy( &gameui.playerinfo, player, sizeof( player_info_t ));
}
else
{
@@ -1411,10 +1407,6 @@ void CL_UpdateUserinfo( sizebuf_t *msg, qboolean legacy )
memset( player, 0, sizeof( *player ));
}
// in GoldSrc userinfo might be empty but userid is always sent as separate value
// thus avoids clean up even after client disconnect
player->userid = id;
}
/*
@@ -1494,7 +1486,7 @@ void CL_UpdateUserPings( sizebuf_t *msg )
slot = MSG_ReadUBitLong( msg, MAX_CLIENT_BITS );
if( slot >= MAX_CLIENTS )
Host_Error( "%s: svc_pings > MAX_CLIENTS\n", __func__ );
Host_Error( "CL_ParseServerMessage: svc_pings > MAX_CLIENTS\n" );
player = &cl.players[slot];
player->ping = MSG_ReadUBitLong( msg, 12 );
@@ -1502,7 +1494,7 @@ void CL_UpdateUserPings( sizebuf_t *msg )
}
}
static void CL_SendConsistencyInfo( sizebuf_t *msg )
void CL_SendConsistencyInfo( sizebuf_t *msg )
{
qboolean user_changed_diskfile;
vec3_t mins, maxs;
@@ -1646,9 +1638,6 @@ void CL_RegisterResources( sizebuf_t *msg )
CL_ClearWorld ();
// load skybox
R_SetupSky( clgame.movevars.skyName );
// tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap ();
@@ -1682,7 +1671,7 @@ void CL_RegisterResources( sizebuf_t *msg )
}
}
static void CL_ParseConsistencyInfo( sizebuf_t *msg )
void CL_ParseConsistencyInfo( sizebuf_t *msg )
{
int lastcheck;
int delta;
@@ -1722,7 +1711,7 @@ static void CL_ParseConsistencyInfo( sizebuf_t *msg )
}
if( cl.num_consistency >= MAX_MODELS )
Host_Error( "%s: MAX_MODELS limit exceeded (%d)\n", __func__, MAX_MODELS );
Host_Error( "CL_CheckConsistency: MAX_MODELS limit exceeded (%d)\n", MAX_MODELS );
pc = &cl.consistency_list[cl.num_consistency];
cl.num_consistency++;
@@ -1747,7 +1736,7 @@ CL_ParseResourceList
==============
*/
static void CL_ParseResourceList( sizebuf_t *msg )
void CL_ParseResourceList( sizebuf_t *msg )
{
resource_t *pResource;
int i, total;
@@ -1784,12 +1773,12 @@ CL_ParseVoiceInit
==================
*/
static void CL_ParseVoiceInit( sizebuf_t *msg )
void CL_ParseVoiceInit( sizebuf_t *msg )
{
char *pszCodec = MSG_ReadString( msg );
int quality = MSG_ReadByte( msg );
Voice_Init( pszCodec, quality, false ); // init requested codec and the device
Voice_Init( pszCodec, quality );
}
/*
@@ -1798,7 +1787,7 @@ CL_ParseVoiceData
==================
*/
static void CL_ParseVoiceData( sizebuf_t *msg )
void CL_ParseVoiceData( sizebuf_t *msg )
{
int size, idx, frames;
byte received[8192];
@@ -1844,10 +1833,13 @@ void CL_ParseResLocation( sizebuf_t *msg )
return;
}
while(( data = COM_ParseFile( data, token, sizeof( token ))))
while( ( data = COM_ParseFile( data, token, sizeof( token ) ) ) )
{
Con_Reportf( "Adding %s as download location\n", token );
cl.http_download = true;
if( !cl.downloadUrl[0] )
Q_strncpy( cl.downloadUrl, token, sizeof( token ) );
HTTP_AddCustomServer( token );
}
}
@@ -1878,12 +1870,8 @@ void CL_ParseHLTV( sizebuf_t *msg )
break;
case HLTV_LISTEN:
cls.signon = SIGNONS;
#if 1
MSG_ReadString( msg );
#else
NET_StringToAdr( MSG_ReadString( msg ), &cls.hltv_listen_address );
NET_JoinGroup( cls.netchan.sock, cls.hltv_listen_address );
#endif
// NET_JoinGroup( cls.netchan.sock, cls.hltv_listen_address );
SCR_EndLoadingPlaque();
break;
default:
@@ -1916,7 +1904,7 @@ CL_ParseScreenShake
Set screen shake
==============
*/
static void CL_ParseScreenShake( sizebuf_t *msg )
void CL_ParseScreenShake( sizebuf_t *msg )
{
float amplitude = (float)(word)MSG_ReadShort( msg ) * ( 1.0f / (float)( 1 << 12 ));
float duration = (float)(word)MSG_ReadShort( msg ) * ( 1.0f / (float)( 1 << 12 ));
@@ -1939,7 +1927,7 @@ CL_ParseScreenFade
Set screen fade
==============
*/
static void CL_ParseScreenFade( sizebuf_t *msg )
void CL_ParseScreenFade( sizebuf_t *msg )
{
float duration, holdTime;
screenfade_t *sf = &clgame.fade;
@@ -1993,7 +1981,7 @@ Find the client cvar value
and sent it back to the server
==============
*/
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t proto )
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext )
{
const char *cvarName, *response;
convar_t *cvar;
@@ -2016,14 +2004,7 @@ void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t
else
response = cvar->string;
}
else if( proto == PROTO_LEGACY )
{
response = "Not Found";
}
else
{
response = "Bad CVAR request";
}
else response = "Bad CVAR request";
if( ext )
{
@@ -2045,7 +2026,7 @@ CL_ParseExec
Exec map/class specific configs
==============
*/
static void CL_ParseExec( sizebuf_t *msg )
void CL_ParseExec( sizebuf_t *msg )
{
qboolean is_class;
int class_idx;
@@ -2140,7 +2121,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
if( svc_num <= svc_lastmsg || svc_num > ( MAX_USER_MESSAGES + svc_lastmsg ))
{
// out or range
Host_Error( "%s: illegible server message %d\n", __func__, svc_num );
Host_Error( "CL_ParseUserMessage: illegible server message %d\n", svc_num );
return;
}
@@ -2152,7 +2133,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
}
if( i == MAX_USER_MESSAGES ) // probably unregistered
Host_Error( "%s: illegible server message %d\n", __func__, svc_num );
Host_Error( "CL_ParseUserMessage: illegible server message %d\n", svc_num );
// NOTE: some user messages handled into engine
if( !Q_strcmp( clgame.msg[i].name, "ScreenShake" ))
@@ -2178,7 +2159,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
if( iSize >= MAX_USERMSG_LENGTH )
{
Con_Reportf( "%s: user message %s size limit hit (%d > %d)!\n", __func__, clgame.msg[i].name, iSize, MAX_USERMSG_LENGTH );
Msg("WTF??? %d %d\n", i, svc_num );
return;
}
@@ -2207,7 +2188,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
}
else
{
Con_DPrintf( S_ERROR "%s: No pfn %s %d\n", __func__, clgame.msg[i].name, clgame.msg[i].number );
Con_DPrintf( S_ERROR "UserMsg: No pfn %s %d\n", clgame.msg[i].name, clgame.msg[i].number );
clgame.msg[i].func = CL_UserMsgStub; // throw warning only once
}
}
@@ -2226,19 +2207,36 @@ CL_ParseServerMessage
dispatch messages
=====================
*/
void CL_ParseServerMessage( sizebuf_t *msg )
void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
{
size_t bufStart, playerbytes;
int cmd, param1, param2;
int old_background;
const char *s;
cls.starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
CL_Parse_Debug( true ); // begin parsing
if( normal_message )
{
// assume no entity/player update this packet
if( cls.state == ca_active )
{
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].valid = false;
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = false;
}
else
{
CL_ResetFrame( &cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK] );
}
}
// parse the message
while( 1 )
{
if( MSG_CheckOverflow( msg ))
{
Host_Error( "%s: overflow!\n", __func__ );
Host_Error( "CL_ParseServerMessage: overflow!\n" );
return;
}
@@ -2324,18 +2322,11 @@ void CL_ParseServerMessage( sizebuf_t *msg )
break;
case svc_stufftext:
s = MSG_ReadString( msg );
if( cl_trace_stufftext.value )
{
size_t len = Q_strlen( s );
Con_Printf( "Stufftext: %s%c", s, len && s[len-1] == '\n' ? '\0' : '\n' );
}
#ifdef HACKS_RELATED_HLMODS
// disable Cry Of Fear antisave protection
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
break; // too early
#endif
Cbuf_AddFilteredText( s );
break;
case svc_setangle:
@@ -2483,10 +2474,10 @@ void CL_ParseServerMessage( sizebuf_t *msg )
CL_ParseResLocation( msg );
break;
case svc_querycvarvalue:
CL_ParseCvarValue( msg, false, PROTO_CURRENT );
CL_ParseCvarValue( msg, false );
break;
case svc_querycvarvalue2:
CL_ParseCvarValue( msg, true, PROTO_CURRENT );
CL_ParseCvarValue( msg, true );
break;
case svc_exec:
CL_ParseExec( msg );
@@ -2497,4 +2488,21 @@ void CL_ParseServerMessage( sizebuf_t *msg )
break;
}
}
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - cls.starting_count;
CL_Parse_Debug( false ); // done
// we don't know if it is ok to save a demo message until
// after we have parsed the frame
if( !cls.demoplayback )
{
if( cls.demorecording && !cls.demowaiting )
{
CL_WriteDemoMessage( false, cls.starting_count, msg );
}
else if( cls.state != ca_active )
{
CL_WriteDemoMessage( true, cls.starting_count, msg );
}
}
}

View File

@@ -30,7 +30,7 @@ CL_ParseStaticEntity
static client entity
==================
*/
static void CL_LegacyParseStaticEntity( sizebuf_t *msg )
void CL_LegacyParseStaticEntity( sizebuf_t *msg )
{
int i;
entity_state_t state;
@@ -98,7 +98,7 @@ static void CL_LegacyParseStaticEntity( sizebuf_t *msg )
R_AddEfrags( ent ); // add link
}
static void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
{
vec3_t pos;
int chan, sound;
@@ -167,14 +167,14 @@ CL_PrecacheSound
prceache sound from server
================
*/
static void CL_LegacyPrecacheSound( sizebuf_t *msg )
void CL_LegacyPrecacheSound( sizebuf_t *msg )
{
int soundIndex;
soundIndex = MSG_ReadUBitLong( msg, MAX_SOUND_BITS );
if( soundIndex < 0 || soundIndex >= MAX_SOUNDS )
Host_Error( "%s: bad soundindex %i\n", __func__, soundIndex );
Host_Error( "CL_PrecacheSound: bad soundindex %i\n", soundIndex );
Q_strncpy( cl.sound_precache[soundIndex], MSG_ReadString( msg ), sizeof( cl.sound_precache[0] ));
@@ -184,7 +184,7 @@ static void CL_LegacyPrecacheSound( sizebuf_t *msg )
cl.sound_index[soundIndex] = S_RegisterSound( cl.sound_precache[soundIndex] );
}
static void CL_LegacyPrecacheModel( sizebuf_t *msg )
void CL_LegacyPrecacheModel( sizebuf_t *msg )
{
int modelIndex;
string model;
@@ -192,9 +192,9 @@ static void CL_LegacyPrecacheModel( sizebuf_t *msg )
modelIndex = MSG_ReadUBitLong( msg, MAX_LEGACY_MODEL_BITS );
if( modelIndex < 0 || modelIndex >= MAX_MODELS )
Host_Error( "%s: bad modelindex %i\n", __func__, modelIndex );
Host_Error( "CL_PrecacheModel: bad modelindex %i\n", modelIndex );
Q_strncpy( model, MSG_ReadString( msg ), sizeof( model ));
Q_strncpy( model, MSG_ReadString( msg ), MAX_STRING );
//Q_strncpy( cl.model_precache[modelIndex], BF_ReadString( msg ), sizeof( cl.model_precache[0] ));
// when we loading map all resources is precached sequentially
@@ -214,14 +214,14 @@ static void CL_LegacyPrecacheModel( sizebuf_t *msg )
cl.nummodels = Q_max( cl.nummodels, modelIndex );
}
static void CL_LegacyPrecacheEvent( sizebuf_t *msg )
void CL_LegacyPrecacheEvent( sizebuf_t *msg )
{
int eventIndex;
eventIndex = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
if( eventIndex < 0 || eventIndex >= MAX_EVENTS )
Host_Error( "%s: bad eventindex %i\n", __func__, eventIndex );
Host_Error( "CL_PrecacheEvent: bad eventindex %i\n", eventIndex );
Q_strncpy( cl.event_precache[eventIndex], MSG_ReadString( msg ), sizeof( cl.event_precache[0] ));
@@ -242,7 +242,7 @@ CL_ParseResourceList
==============
*/
static void CL_LegacyParseResourceList( sizebuf_t *msg )
void CL_LegacyParseResourceList( sizebuf_t *msg )
{
int i = 0;
static struct
@@ -256,15 +256,15 @@ static void CL_LegacyParseResourceList( sizebuf_t *msg )
reslist.rescount = MSG_ReadWord( msg ) - 1;
if( reslist.rescount > MAX_LEGACY_RESOURCES )
Host_Error( "MAX_RESOURCES reached\n" );
Host_Error("MAX_RESOURCES reached\n");
for( i = 0; i < reslist.rescount; i++ )
{
reslist.restype[i] = MSG_ReadWord( msg );
Q_strncpy( reslist.resnames[i], MSG_ReadString( msg ), sizeof( reslist.resnames[i] ));
Q_strncpy( reslist.resnames[i], MSG_ReadString( msg ), MAX_QPATH );
}
if( cls.demoplayback )
if( CL_IsPlaybackDemo() )
return;
if( !cl_allow_download.value )
@@ -317,19 +317,36 @@ CL_ParseLegacyServerMessage
dispatch messages
=====================
*/
void CL_ParseLegacyServerMessage( sizebuf_t *msg )
void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
{
size_t bufStart, playerbytes;
int cmd, param1, param2;
int old_background;
const char *s;
cls.starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
CL_Parse_Debug( true ); // begin parsing
if( normal_message )
{
// assume no entity/player update this packet
if( cls.state == ca_active )
{
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].valid = false;
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = false;
}
else
{
CL_ResetFrame( &cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK] );
}
}
// parse the message
while( 1 )
{
if( MSG_CheckOverflow( msg ))
{
Host_Error( "%s: overflow!\n", __func__ );
Host_Error( "CL_ParseServerMessage: overflow!\n" );
return;
}
@@ -368,9 +385,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
{
int maxclients = cl.maxclients;
// we can only changelevel in singleplayer
// and singleplayer always runs in current protocol
// cls.changelevel = true;
cls.changelevel = true;
S_StopAllSounds( true );
Con_Printf( "Server changing, reconnecting\n" );
@@ -428,17 +443,13 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
break;
case svc_stufftext:
s = MSG_ReadString( msg );
if( cl_trace_stufftext.value )
{
size_t len = Q_strlen( s );
Con_Printf( "Stufftext: %s%c", s, len && s[len-1] == '\n' ? '\0' : '\n' );
}
#ifdef HACKS_RELATED_HLMODS
// disable Cry Of Fear antisave protection
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
break; // too early
#endif
Con_Reportf( "Stufftext: %s", s );
Cbuf_AddFilteredText( s );
break;
case svc_setangle:
@@ -597,10 +608,10 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
CL_ParseResLocation( msg );
break;
case svc_querycvarvalue:
CL_ParseCvarValue( msg, false, PROTO_LEGACY );
CL_ParseCvarValue( msg, false );
break;
case svc_querycvarvalue2:
CL_ParseCvarValue( msg, true, PROTO_LEGACY );
CL_ParseCvarValue( msg, true );
break;
default:
CL_ParseUserMessage( msg, cmd );
@@ -608,6 +619,23 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
break;
}
}
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - cls.starting_count;
CL_Parse_Debug( false ); // done
// we don't know if it is ok to save a demo message until
// after we have parsed the frame
if( !cls.demoplayback )
{
if( cls.demorecording && !cls.demowaiting )
{
CL_WriteDemoMessage( false, cls.starting_count, msg );
}
else if( cls.state != ca_active )
{
CL_WriteDemoMessage( true, cls.starting_count, msg );
}
}
}
void CL_LegacyPrecache_f( void )
@@ -632,9 +660,6 @@ void CL_LegacyPrecache_f( void )
if( clgame.entities )
clgame.entities->model = cl.worldmodel;
// load skybox
R_SetupSky( clgame.movevars.skyName );
// tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap ();
@@ -656,10 +681,22 @@ void CL_LegacyPrecache_f( void )
// Include server count in case server disconnects and changes level during d/l
MSG_BeginClientCmd( &cls.netchan.message, clc_stringcmd );
MSG_WriteStringf( &cls.netchan.message, "begin %i", spawncount );
cls.signon = SIGNONS - 1;
cls.signon = SIGNONS;
}
void CL_LegacyUpdateInfo( void )
{
if( !cls.legacymode )
return;
if( cls.state != ca_active )
return;
MSG_BeginClientCmd( &cls.netchan.message, clc_legacy_userinfo );
MSG_WriteString( &cls.netchan.message, cls.userinfo );
}
qboolean CL_LegacyMode( void )
{
return cls.legacymode == PROTO_LEGACY;
return cls.legacymode;
}

View File

@@ -54,6 +54,31 @@ void GAME_EXPORT CL_PopPMStates( void )
clgame.pushed = false;
}
/*
=============
CL_PushTraceBounds
=============
*/
void GAME_EXPORT CL_PushTraceBounds( int hullnum, const float *mins, const float *maxs )
{
hullnum = bound( 0, hullnum, 3 );
VectorCopy( mins, clgame.pmove->player_mins[hullnum] );
VectorCopy( maxs, clgame.pmove->player_maxs[hullnum] );
}
/*
=============
CL_PopTraceBounds
=============
*/
void GAME_EXPORT CL_PopTraceBounds( void )
{
memcpy( clgame.pmove->player_mins, host.player_mins, sizeof( host.player_mins ));
memcpy( clgame.pmove->player_maxs, host.player_maxs, sizeof( host.player_maxs ));
}
/*
===============
CL_IsPredicted
@@ -392,7 +417,7 @@ CL_AddLinksToPmove
collect solid entities
====================
*/
static void CL_AddLinksToPmove( frame_t *frame )
void CL_AddLinksToPmove( frame_t *frame )
{
entity_state_t *state;
model_t *model;
@@ -544,8 +569,8 @@ void GAME_EXPORT CL_SetSolidPlayers( int playernum )
// some fields needs to be override from cls.predicted_players
VectorCopy( player->origin, pe->origin );
VectorCopy( player->angles, pe->angles );
VectorCopy( host.player_mins[player->usehull], pe->mins );
VectorCopy( host.player_maxs[player->usehull], pe->maxs );
VectorCopy( clgame.pmove->player_mins[player->usehull], pe->mins );
VectorCopy( clgame.pmove->player_maxs[player->usehull], pe->maxs );
pe->movetype = player->movetype;
pe->solid = player->solid;
}
@@ -662,6 +687,11 @@ cl_entity_t *CL_GetWaterEntity( const float *rgflPos )
return CL_GetEntityByIndex( entnum );
}
int GAME_EXPORT CL_TestLine( const vec3_t start, const vec3_t end, int flags )
{
return PM_TestLineExt( clgame.pmove, clgame.pmove->physents, clgame.pmove->numphysent, start, end, flags );
}
static int GAME_EXPORT pfnTestPlayerPosition( float *pos, pmtrace_t *ptrace )
{
return PM_TestPlayerPosition( clgame.pmove, pos, ptrace, NULL );
@@ -795,14 +825,25 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
pmove->player_index = ps->number - 1;
// a1ba: workaround bug where the server refuse to send our local player in delta
// cl.playernum, in theory, must be equal to our local player index anyway
//
// a1ba: workaround bug on old protocol where the server refuse to send
// our local player in delta. cl.playernum, in theory, must be equal
// to our local player index anyway
// this might not be a real solution, since everything else will be bogus
// but we need to properly run prediction and avoid potential memory
// corruption
// either debug this, or remove when old protocol will be dropped!!!
if( pmove->player_index < 0 )
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );
{
if( cls.legacymode )
{
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );
}
else
{
// if this happens, record a demo and send it to a1ba
Host_Error( "%s: ps->number == %d\n", __func__, ps->number );
}
}
pmove->multiplayer = (cl.maxclients > 1);
pmove->runfuncs = runfuncs;
@@ -853,10 +894,10 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
VectorCopy( cd->vuser4, pmove->vuser4 );
pmove->cmd = *ucmd; // copy current cmds
Q_strncpy( pmove->physinfo, cls.physinfo, sizeof( pmove->physinfo ));
Q_strncpy( pmove->physinfo, cls.physinfo, MAX_INFO_STRING );
}
static const void CL_FinishPMove( const playermove_t *pmove, local_state_t *to )
const void CL_FinishPMove( const playermove_t *pmove, local_state_t *to )
{
entity_state_t *ps;
clientdata_t *cd;
@@ -909,7 +950,7 @@ CL_RunUsercmd
Runs prediction code for user cmd
=================
*/
static void CL_RunUsercmd( local_state_t *from, local_state_t *to, usercmd_t *u, qboolean runfuncs, double *time, unsigned int random_seed )
void CL_RunUsercmd( local_state_t *from, local_state_t *to, usercmd_t *u, qboolean runfuncs, double *time, unsigned int random_seed )
{
usercmd_t cmd;

View File

@@ -22,24 +22,22 @@ GNU General Public License for more details.
#include "hltv.h"
#include "input.h"
enum {
STAT_HEALTH = 0,
STAT_FRAGS,
STAT_WEAPON,
STAT_AMMO,
STAT_ARMOR,
STAT_WEAPONFRAME,
STAT_SHELLS,
STAT_NAILS,
STAT_ROCKETS,
STAT_CELLS,
STAT_ACTIVEWEAPON,
STAT_TOTALSECRETS,
STAT_TOTALMONSTERS,
STAT_SECRETS, // bumped on client side by svc_foundsecret
STAT_MONSTERS, // bumped by svc_killedmonster
MAX_STATS = 32,
};
#define STAT_HEALTH 0
#define STAT_FRAGS 1
#define STAT_WEAPON 2
#define STAT_AMMO 3
#define STAT_ARMOR 4
#define STAT_WEAPONFRAME 5
#define STAT_SHELLS 6
#define STAT_NAILS 7
#define STAT_ROCKETS 8
#define STAT_CELLS 9
#define STAT_ACTIVEWEAPON 10
#define STAT_TOTALSECRETS 11
#define STAT_TOTALMONSTERS 12
#define STAT_SECRETS 13 // bumped on client side by svc_foundsecret
#define STAT_MONSTERS 14 // bumped by svc_killedmonster
#define MAX_STATS 32
static char cmd_buf[8192];
static char msg_buf[8192];
@@ -213,7 +211,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
clgame.maxEntities = GI->max_edicts;
clgame.maxEntities = bound( 600, clgame.maxEntities, MAX_EDICTS );
clgame.maxModels = MAX_MODELS;
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle ));
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), MAX_STRING );
// Re-init hud video, especially if we changed game directories
clgame.dllFuncs.pfnVidInit();
@@ -330,7 +328,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
clgame.movevars.gravity = 800.0f; // quake doesn't write gravity in demos
clgame.movevars.maxvelocity = 2000.0f;
clgame.oldmovevars = clgame.movevars;
memcpy( &clgame.oldmovevars, &clgame.movevars, sizeof( movevars_t ));
}
/*
@@ -416,7 +414,7 @@ If an entities model or origin changes from frame to frame, it must be
relinked. Other attributes can change without relinking.
==================
*/
static void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits )
void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits )
{
int i, newnum, pack;
qboolean forcelink;
@@ -567,7 +565,7 @@ CL_ParseQuakeParticles
==================
*/
static void CL_ParseQuakeParticle( sizebuf_t *msg )
void CL_ParseQuakeParticle( sizebuf_t *msg )
{
int count, color;
vec3_t org, dir;
@@ -589,7 +587,7 @@ CL_ParseQuakeStaticSound
===================
*/
static void CL_ParseQuakeStaticSound( sizebuf_t *msg )
void CL_ParseQuakeStaticSound( sizebuf_t *msg )
{
int sound_num;
float vol, attn;
@@ -622,11 +620,11 @@ static void CL_ParseQuakeDamage( sizebuf_t *msg )
/*
===================
CL_ParseStaticEntity
CL_ParseQuakeStaticEntity
===================
*/
static void CL_ParseStaticEntity( sizebuf_t *msg )
static void CL_ParseQuakeStaticEntity( sizebuf_t *msg )
{
entity_state_t state;
cl_entity_t *ent;
@@ -648,7 +646,7 @@ static void CL_ParseStaticEntity( sizebuf_t *msg )
i = clgame.numStatics;
if( i >= MAX_STATIC_ENTITIES )
{
Con_Printf( S_ERROR "%s: static entities limit exceeded!\n", __func__ );
Con_Printf( S_ERROR "CL_ParseStaticEntity: static entities limit exceeded!\n" );
return;
}
@@ -699,7 +697,7 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
newnum = MSG_ReadWord( msg ); // entnum
if( newnum >= clgame.maxEntities )
Host_Error( "%s: no free edicts\n", __func__ );
Host_Error( "CL_AllocEdict: no free edicts\n" );
// parse baseline
memset( &state, 0, sizeof( state ));
@@ -717,7 +715,8 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
ent = CL_EDICT_NUM( newnum );
ent->index = newnum;
ent->player = CL_IsPlayerIndex( newnum );
ent->prevstate = ent->baseline = state;
memcpy( &ent->baseline, &state, sizeof( entity_state_t ));
memcpy( &ent->prevstate, &state, sizeof( entity_state_t ));
}
/*
@@ -779,7 +778,7 @@ static void CL_ParseQuakeSignon( sizebuf_t *msg )
int i = MSG_ReadByte( msg );
if( i == 3 ) cls.signon = SIGNONS - 1;
Con_Reportf( "%s: %d\n", __func__, i );
Con_Reportf( "CL_Signon: %d\n", i );
}
/*
@@ -817,7 +816,7 @@ CL_QuakeStuffText
==================
*/
static void CL_QuakeStuffText( const char *text )
void CL_QuakeStuffText( const char *text )
{
Q_strncat( cmd_buf, text, sizeof( cmd_buf ));
@@ -832,7 +831,7 @@ CL_QuakeExecStuff
==================
*/
static void CL_QuakeExecStuff( void )
void CL_QuakeExecStuff( void )
{
char *text = cmd_buf;
char token[256];
@@ -845,7 +844,7 @@ static void CL_QuakeExecStuff( void )
while( 1 )
{
// skip whitespace up to a /n
while( *text && ((byte)*text ) <= ' ' && *text != '\r' && *text != '\n' )
while( *text && ((byte)*text) <= ' ' && *text != '\r' && *text != '\n' )
text++;
if( *text == '\n' || *text == '\r' )
@@ -887,21 +886,38 @@ CL_ParseQuakeMessage
==================
*/
void CL_ParseQuakeMessage( sizebuf_t *msg )
void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message )
{
int cmd, param1, param2;
size_t bufStart;
const char *str;
cls.starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
CL_Parse_Debug( true ); // begin parsing
// init excise buffer
MSG_Init( &msg_demo, "UserMsg", msg_buf, sizeof( msg_buf ));
if( normal_message )
{
// assume no entity/player update this packet
if( cls.state == ca_active )
{
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].valid = false;
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = false;
}
else
{
CL_ResetFrame( &cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK] );
}
}
// parse the message
while( 1 )
{
if( MSG_CheckOverflow( msg ))
{
Host_Error( "%s: overflow!\n", __func__ );
Host_Error( "CL_ParseServerMessage: overflow!\n" );
return;
}
@@ -1006,7 +1022,7 @@ void CL_ParseQuakeMessage( sizebuf_t *msg )
CL_ParseQuakeDamage( msg );
break;
case svc_spawnstatic:
CL_ParseStaticEntity( msg );
CL_ParseQuakeStaticEntity( msg );
break;
case svc_spawnbinary:
// never used in Quake
@@ -1092,11 +1108,14 @@ void CL_ParseQuakeMessage( sizebuf_t *msg )
}
break;
default:
Host_Error( "%s: Illegible server message\n", __func__ );
Host_Error( "CL_ParseServerMessage: Illegible server message\n" );
break;
}
}
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - cls.starting_count;
CL_Parse_Debug( false ); // done
// now process packet.
CL_ProcessPacket( &cl.frames[cl.parsecountmod] );

View File

@@ -20,7 +20,7 @@ GNU General Public License for more details.
int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis )
{
return Mod_FatPVS( org, radius, visbuffer, world.visbytes, merge, fullvis, false );
return Mod_FatPVS( org, radius, visbuffer, world.visbytes, merge, fullvis );
}
lightstyle_t *CL_GetLightStyle( int number )
@@ -126,7 +126,7 @@ CL_GenericHandle
=============
*/
static const char *CL_GenericHandle( int fileindex )
const char *CL_GenericHandle( int fileindex )
{
if( fileindex < 0 || fileindex >= MAX_CUSTOM )
return 0;
@@ -170,12 +170,6 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return refState.width;
case PARM_SCREEN_HEIGHT:
return refState.height;
case PARM_SKY_SPHERE:
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
case PARM_SURF_SAMPLESIZE:
if( arg >= 0 && arg < cl.worldmodel->numsurfaces )
return Mod_SampleSizeForFace( &cl.worldmodel->surfaces[arg] );
return LM_SAMPLE_SIZE;
default:
// indicates call from client.dll
if( checkRef )
@@ -347,7 +341,7 @@ qboolean R_InitRenderAPI( void )
{
if( clgame.dllFuncs.pfnGetRenderInterface( CL_RENDER_INTERFACE_VERSION, &gRenderAPI, &clgame.drawFuncs ))
{
Con_Reportf( "%s: ^2initailized extended RenderAPI ^7ver. %i\n", __func__, CL_RENDER_INTERFACE_VERSION );
Con_Reportf( "CL_LoadProgs: ^2initailized extended RenderAPI ^7ver. %i\n", CL_RENDER_INTERFACE_VERSION );
return true;
}

View File

@@ -24,7 +24,7 @@ CVAR_DEFINE_AUTO( scr_centertime, "2.5", 0, "centerprint hold time" );
CVAR_DEFINE_AUTO( scr_loading, "0", 0, "loading bar progress" );
CVAR_DEFINE_AUTO( scr_download, "-1", 0, "downloading bar progress" );
CVAR_DEFINE( scr_viewsize, "viewsize", "120", FCVAR_ARCHIVE, "screen size (quake only)" );
CVAR_DEFINE_AUTO( cl_testlights, "0", FCVAR_CHEAT, "test dynamic lights" );
CVAR_DEFINE_AUTO( cl_testlights, "0", 0, "test dynamic lights" );
CVAR_DEFINE( cl_allow_levelshots, "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
CVAR_DEFINE_AUTO( cl_levelshot_name, "*black", 0, "contains path to current levelshot" );
static CVAR_DEFINE_AUTO( cl_envshot_size, "256", FCVAR_ARCHIVE, "envshot size of cube side" );
@@ -32,7 +32,6 @@ CVAR_DEFINE_AUTO( v_dark, "0", 0, "starts level from dark screen" );
static CVAR_DEFINE_AUTO( net_speeds, "0", FCVAR_ARCHIVE, "show network packets" );
static CVAR_DEFINE_AUTO( cl_showfps, "0", FCVAR_ARCHIVE, "show client fps" );
static CVAR_DEFINE_AUTO( cl_showpos, "0", FCVAR_ARCHIVE, "show local player position and velocity" );
static CVAR_DEFINE_AUTO( cl_showents, "0", FCVAR_ARCHIVE | FCVAR_CHEAT, "show entities information (largely undone)" );
typedef struct
{
@@ -123,7 +122,7 @@ void SCR_DrawPos( void )
if( cls.state != ca_active || !cl_showpos.value || cl.background )
return;
ent = CL_EDICT_NUM( cl.playernum + 1 );
ent = CL_GetLocalPlayer();
speed = VectorLength( cl.simvel );
Q_snprintf( msg, MAX_SYSPATH,
@@ -141,68 +140,6 @@ void SCR_DrawPos( void )
Con_DrawString( refState.width / 2, 4, msg, color );
}
/*
==============
SCR_DrawEnts
==============
*/
void SCR_DrawEnts( void )
{
rgba_t color = { 255, 255, 255, 255 };
int i;
if( cls.state != ca_active || !cl_showents.value || ( cl.maxclients > 1 && !cls.demoplayback ))
return;
// this probably better hook CL_AddVisibleEntities
// as entities might get added by client.dll
for( i = 0; i < clgame.maxEntities; i++ )
{
const cl_entity_t *ent = &clgame.entities[i];
string msg;
vec3_t screen, pos;
if( ent->curstate.messagenum != cl.parsecount )
continue;
VectorCopy( ent->origin, pos );
if( ent->model != NULL )
{
vec3_t v;
// simple model type filter
if( cl_showents.value > 1 )
{
if( ent->model->type != (modtype_t)( cl_showents.value - 2 ))
continue;
}
VectorAverage( ent->model->mins, ent->model->maxs, v );
VectorAdd( pos, v, pos );
}
if( !ref.dllFuncs.WorldToScreen( pos, screen ))
{
Q_snprintf( msg, sizeof( msg ),
"entity %d\n"
"model %s\n"
"movetype %d\n",
ent->index,
ent->model ? ent->model->name : "(null)",
ent->curstate.movetype );
screen[0] = 0.5f * screen[0] * refState.width;
screen[1] = -0.5f * screen[1] * refState.height;
screen[0] += 0.5f * refState.width;
screen[1] += 0.5f * refState.height;
Con_DrawString( screen[0], screen[1], msg, color );
}
}
}
/*
==============
SCR_NetSpeeds
@@ -315,7 +252,7 @@ VID_WriteOverviewScript
Create overview script file
===============
*/
static void VID_WriteOverviewScript( void )
void VID_WriteOverviewScript( void )
{
ref_overview_t *ov = &clgame.overView;
string filename;
@@ -351,9 +288,6 @@ void SCR_MakeScreenShot( void )
qboolean iRet = false;
int viewsize;
if( cls.scrshot_action == scrshot_inactive )
return;
if( cls.envshot_viewsize > 0 )
viewsize = cls.envshot_viewsize;
else viewsize = cl_envshot_size.value;
@@ -385,6 +319,8 @@ void SCR_MakeScreenShot( void )
if( iRet )
VID_WriteOverviewScript(); // store overview script too
break;
case scrshot_inactive:
return;
}
// report
@@ -408,7 +344,7 @@ void SCR_MakeScreenShot( void )
SCR_DrawPlaque
================
*/
static qboolean SCR_DrawPlaque( void )
void SCR_DrawPlaque( void )
{
if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background )
{
@@ -416,11 +352,7 @@ static qboolean SCR_DrawPlaque( void )
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
if( !cl.background ) CL_DrawHUD( CL_LOADING );
return true;
}
return false;
}
/*
@@ -430,10 +362,15 @@ SCR_BeginLoadingPlaque
*/
void SCR_BeginLoadingPlaque( qboolean is_background )
{
float oldclear = 0;;
S_StopAllSounds( true );
cl.audio_prepped = false; // don't play ambients
cl.video_prepped = false;
if( cls.key_dest == key_menu && !cls.changedemo && !is_background )
if( !Host_IsDedicated() )
oldclear = gl_clear.value;
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
{
UI_SetActiveMenu( false );
if( cls.state == ca_disconnected && !(GameState->curstate == STATE_RUNFRAME && GameState->nextstate != STATE_RUNFRAME) )
@@ -446,15 +383,18 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
if( cls.key_dest == key_console )
return;
if( !Host_IsDedicated() )
gl_clear.value = 0.0f;
if( is_background ) IN_MouseSavePos( );
cls.draw_changelevel = !is_background;
SCR_UpdateScreen();
// set video_prepped after update screen, so engine can draw last remaining frame
cl.video_prepped = false;
cls.disable_screen = host.realtime;
cl.background = is_background; // set right state before svc_serverdata is came
if( !Host_IsDedicated() )
gl_clear.value = oldclear;
// SNDDMA_LockSound();
}
@@ -475,7 +415,7 @@ void SCR_EndLoadingPlaque( void )
SCR_AddDirtyPoint
=================
*/
static void SCR_AddDirtyPoint( int x, int y )
void SCR_AddDirtyPoint( int x, int y )
{
if( x < scr_dirty.x1 ) scr_dirty.x1 = x;
if( x > scr_dirty.x2 ) scr_dirty.x2 = x;
@@ -504,7 +444,7 @@ void SCR_TileClear( void )
int i, top, bottom, left, right;
dirty_t clear;
if( likely( scr_viewsize.value >= 120 ))
if( scr_viewsize.value >= 120 )
return; // full screen rendering
// erase rect will be the union of the past three frames
@@ -582,8 +522,6 @@ text to the screen.
*/
void SCR_UpdateScreen( void )
{
qboolean screen_redraw = true; // assume screen has been redrawn
if( !V_PreRender( )) return;
switch( cls.state )
@@ -594,7 +532,7 @@ void SCR_UpdateScreen( void )
case ca_connecting:
case ca_connected:
case ca_validate:
screen_redraw = SCR_DrawPlaque();
SCR_DrawPlaque();
break;
case ca_active:
Con_RunConsole ();
@@ -604,15 +542,11 @@ void SCR_UpdateScreen( void )
SCR_DrawCinematic();
break;
default:
Host_Error( "%s: bad cls.state\n", __func__ );
Host_Error( "SCR_UpdateScreen: bad cls.state\n" );
break;
}
// during changelevel we might have a few frames when we have nothing to draw
// (assuming levelshots are off) and drawing 2d on top of nothing or cleared screen
// is ugly, specifically with Adreno and ImgTec GPUs
if( screen_redraw || !cls.changelevel || !cls.changedemo )
V_PostRender();
V_PostRender();
}
/*
@@ -638,15 +572,15 @@ void SCR_LoadCreditsFont( void )
"creditsfont_%s.fnt", Cvar_VariableString( "con_charset" )) > 0 )
{
if( FS_FileExists( charsetFnt, false ))
success = Con_LoadVariableWidthFont( charsetFnt, font, scale, &hud_fontrender, TF_FONT );
success = Con_LoadVariableWidthFont( charsetFnt, font, scale, kRenderTransAdd, TF_FONT );
}
}
if( !success )
success = Con_LoadVariableWidthFont( "gfx/creditsfont.fnt", font, scale, &hud_fontrender, TF_FONT );
success = Con_LoadVariableWidthFont( "gfx/creditsfont.fnt", font, scale, kRenderTransAdd, TF_FONT );
if( !success )
success = Con_LoadFixedWidthFont( "gfx/conchars", font, scale, &hud_fontrender, TF_FONT );
success = Con_LoadFixedWidthFont( "gfx/conchars", font, scale, kRenderTransAdd, TF_FONT );
// copy font size for client.dll
if( success )
@@ -668,7 +602,7 @@ SCR_InstallParticlePalette
INTERNAL RESOURCE
================
*/
static void SCR_InstallParticlePalette( void )
void SCR_InstallParticlePalette( void )
{
rgbdata_t *pic;
int i;
@@ -714,21 +648,21 @@ void SCR_RegisterTextures( void )
// register gfx.wad images
if( FS_FileExists( "gfx/paused.lmp", false ))
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "gfx/pause.lmp", false ))
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );
if( FS_FileExists( "gfx/lambda.lmp", false ))
{
if( cl_allow_levelshots.value )
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE|TF_ALLOW_NEAREST );
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
}
else if( FS_FileExists( "gfx/loading.lmp", false ))
{
if( cl_allow_levelshots.value )
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE|TF_ALLOW_NEAREST );
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
}
cls.tileImage = ref.dllFuncs.GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
@@ -741,7 +675,7 @@ SCR_SizeUp_f
Keybinding command
=================
*/
static void SCR_SizeUp_f( void )
void SCR_SizeUp_f( void )
{
Cvar_SetValue( "viewsize", Q_min( scr_viewsize.value + 10, 120 ));
}
@@ -754,7 +688,7 @@ SCR_SizeDown_f
Keybinding command
=================
*/
static void SCR_SizeDown_f( void )
void SCR_SizeDown_f( void )
{
Cvar_SetValue( "viewsize", Q_max( scr_viewsize.value - 10, 30 ));
}
@@ -818,9 +752,6 @@ void SCR_Init( void )
Cvar_RegisterVariable( &net_speeds );
Cvar_RegisterVariable( &cl_showfps );
Cvar_RegisterVariable( &cl_showpos );
#ifdef _DEBUG
Cvar_RegisterVariable( &cl_showents );
#endif // NDEBUG
// register our commands
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );

View File

@@ -57,7 +57,35 @@ const char *cl_default_sprites[] =
"sprites/shellchrome.spr",
};
static void CL_PlayerDecal( int playerIndex, int textureIndex, int entityIndex, float *pos );
const char *cl_player_shell_sounds[] =
{
"player/pl_shell1.wav",
"player/pl_shell2.wav",
"player/pl_shell3.wav",
};
const char *cl_weapon_shell_sounds[] =
{
"weapons/sshell1.wav",
"weapons/sshell2.wav",
"weapons/sshell3.wav",
};
const char *cl_ricochet_sounds[] =
{
"weapons/ric1.wav",
"weapons/ric2.wav",
"weapons/ric3.wav",
"weapons/ric4.wav",
"weapons/ric5.wav",
};
const char *cl_explode_sounds[] =
{
"weapons/explode3.wav",
"weapons/explode4.wav",
"weapons/explode5.wav",
};
/*
================
@@ -118,7 +146,6 @@ client resources not precached by server
*/
void CL_AddClientResources( void )
{
const char *snd;
char filepath[MAX_QPATH];
int i;
@@ -134,37 +161,37 @@ void CL_AddClientResources( void )
}
// then check sounds
for( i = 0; ( snd = SoundList_Get( BouncePlayerShell, i )); i++ )
for( i = 0; i < ARRAYSIZE( cl_player_shell_sounds ); i++ )
{
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", cl_player_shell_sounds[i] );
if( !FS_FileExists( filepath, false ))
CL_AddClientResource( snd, t_sound );
CL_AddClientResource( cl_player_shell_sounds[i], t_sound );
}
for( i = 0; ( snd = SoundList_Get( BounceWeaponShell, i )); i++ )
for( i = 0; i < ARRAYSIZE( cl_weapon_shell_sounds ); i++ )
{
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", cl_weapon_shell_sounds[i] );
if( !FS_FileExists( filepath, false ))
CL_AddClientResource( snd, t_sound );
CL_AddClientResource( cl_weapon_shell_sounds[i], t_sound );
}
for( i = 0; ( snd = SoundList_Get( Explode, i )); i++ )
for( i = 0; i < ARRAYSIZE( cl_explode_sounds ); i++ )
{
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", cl_explode_sounds[i] );
if( !FS_FileExists( filepath, false ))
CL_AddClientResource( snd, t_sound );
CL_AddClientResource( cl_explode_sounds[i], t_sound );
}
#if 0 // ric sounds was precached by server-side
for( i = 0; ( snd = SoundList_Get( Ricochet, i )); i++ )
for( i = 0; i < ARRAYSIZE( cl_ricochet_sounds ); i++ )
{
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", cl_ricochet_sounds[i] );
if( !FS_FileExists( filepath, false ))
CL_AddClientResource( snd, t_sound );
CL_AddClientResource( cl_ricochet_sounds[i], t_sound );
}
#endif
}
@@ -228,7 +255,7 @@ CL_PrepareTEnt
set default values
==============
*/
static void CL_PrepareTEnt( TEMPENTITY *pTemp, model_t *pmodel )
void CL_PrepareTEnt( TEMPENTITY *pTemp, model_t *pmodel )
{
int frameCount = 0;
int modelIndex = 0;
@@ -269,10 +296,10 @@ CL_TempEntPlaySound
play collide sound
==============
*/
static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
{
float fvol;
const char *soundname = NULL;
char soundname[32];
qboolean isshellcasing = false;
int zvel;
@@ -283,39 +310,36 @@ static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
switch( pTemp->hitSound )
{
case BOUNCE_GLASS:
soundname = SoundList_GetRandom( BounceGlass );
Q_snprintf( soundname, sizeof( soundname ), "debris/glass%i.wav", COM_RandomLong( 1, 4 ));
break;
case BOUNCE_METAL:
soundname = SoundList_GetRandom( BounceMetal );
Q_snprintf( soundname, sizeof( soundname ), "debris/metal%i.wav", COM_RandomLong( 1, 6 ));
break;
case BOUNCE_FLESH:
soundname = SoundList_GetRandom( BounceFlesh );
Q_snprintf( soundname, sizeof( soundname ), "debris/flesh%i.wav", COM_RandomLong( 1, 7 ));
break;
case BOUNCE_WOOD:
soundname = SoundList_GetRandom( BounceWood );
Q_snprintf( soundname, sizeof( soundname ), "debris/wood%i.wav", COM_RandomLong( 1, 4 ));
break;
case BOUNCE_SHRAP:
soundname = SoundList_GetRandom( Ricochet );
Q_strncpy( soundname, cl_ricochet_sounds[COM_RandomLong( 0, 4 )], sizeof( soundname ) );
break;
case BOUNCE_SHOTSHELL:
soundname = SoundList_GetRandom( BounceWeaponShell );
Q_strncpy( soundname, cl_weapon_shell_sounds[COM_RandomLong( 0, 2 )], sizeof( soundname ) );
isshellcasing = true; // shell casings have different playback parameters
fvol = 0.5f;
break;
case BOUNCE_SHELL:
soundname = SoundList_GetRandom( BouncePlayerShell );
Q_strncpy( soundname, cl_player_shell_sounds[COM_RandomLong( 0, 2 )], sizeof( soundname ) );
isshellcasing = true; // shell casings have different playback parameters
break;
case BOUNCE_CONCRETE:
soundname = SoundList_GetRandom( BounceConcrete );
Q_snprintf( soundname, sizeof( soundname ), "debris/concrete%i.wav", COM_RandomLong( 1, 3 ));
break;
default: // null sound
return;
}
if( !soundname )
return;
zvel = abs( pTemp->entity.baseline.origin[2] );
// only play one out of every n
@@ -356,7 +380,7 @@ CL_TEntAddEntity
add entity to renderlist
==============
*/
static int CL_TempEntAddEntity( cl_entity_t *pEntity )
int CL_TempEntAddEntity( cl_entity_t *pEntity )
{
vec3_t mins, maxs;
@@ -369,7 +393,7 @@ static int CL_TempEntAddEntity( cl_entity_t *pEntity )
VectorAdd( pEntity->origin, pEntity->model->maxs, maxs );
// g-cont. just use PVS from previous frame
if( TriBoxInPVS( mins, maxs ))
if( Mod_BoxVisible( mins, maxs, ref.dllFuncs.Mod_GetCurrentVis( )))
{
VectorCopy( pEntity->angles, pEntity->curstate.angles );
VectorCopy( pEntity->origin, pEntity->curstate.origin );
@@ -408,7 +432,7 @@ CL_TEntAddEntity
free the first low priority tempent it finds.
==============
*/
static qboolean CL_FreeLowPriorityTempEnt( void )
qboolean CL_FreeLowPriorityTempEnt( void )
{
TEMPENTITY *pActive = cl_active_tents;
TEMPENTITY *pPrev = NULL;
@@ -999,8 +1023,12 @@ void GAME_EXPORT R_BreakModel( const vec3_t pos, const vec3_t size, const vec3_t
count = (size[0] * size[1] + size[1] * size[2] + size[2] * size[0]) / (3 * SHARD_VOLUME * SHARD_VOLUME);
}
#if XASH_PSP
if( count > 15 ) count = 15;
#else
// limit to 100 pieces
if( count > 100 ) count = 100;
#endif
for( i = 0; i < count; i++ )
{
@@ -1269,73 +1297,6 @@ void GAME_EXPORT R_Sprite_Smoke( TEMPENTITY *pTemp, float scale )
pTemp->entity.curstate.scale = scale;
}
static void R_Spray_Generic( const char *func, const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int spread, int rendermode, qboolean sprite_spray )
{
model_t *mod = CL_ModelHandle( modelIndex );
float noise = spread / 100.0f;
float znoise = noise * 1.5f;
int i;
znoise = Q_min( 1.0f, znoise );
if( !mod )
{
Con_Reportf( "%s: No model %d!\n", func, modelIndex );
return;
}
for( i = 0; i < count; i++ )
{
TEMPENTITY *tent = CL_TempEntAlloc( pos, mod );
float rand_speed;
vec3_t noise_vec, vout;
if( !tent )
break;
tent->flags |= FTENT_SLOWGRAVITY;
tent->entity.curstate.rendermode = rendermode;
tent->entity.curstate.renderamt = 255;
tent->entity.baseline.renderamt = 255;
tent->entity.curstate.renderfx = kRenderFxNoDissipation;
noise_vec[0] = COM_RandomFloat( -noise, noise );
noise_vec[1] = COM_RandomFloat( -noise, noise );
noise_vec[2] = COM_RandomFloat( 0.0f, znoise );
rand_speed = COM_RandomFloat( speed * 0.8f, speed * 1.2f );
VectorAdd( dir, noise_vec, vout );
VectorScale( vout, rand_speed, tent->entity.baseline.origin );
if( sprite_spray ) // if TE_SPRITE_SPRAY
{
tent->flags |= FTENT_FADEOUT;
tent->fadeSpeed = 2.0f;
tent->entity.curstate.framerate = 0.5f;
tent->die = cl.time + 0.35;
tent->entity.curstate.frame = COM_RandomLong( 0, tent->frameMax ); // frameMax inclusive
}
else
{
tent->flags |= FTENT_COLLIDEWORLD;
if( tent->frameMax > 1 )
{
tent->flags |= FTENT_SPRANIMATE;
tent->entity.curstate.framerate = 10.0f;
tent->die = cl.time + tent->frameMax * 0.1;
}
else
{
tent->entity.curstate.framerate = 1.0f;
tent->die = cl.time + 0.35;
}
tent->entity.curstate.frame = 0.0f;
}
}
}
/*
===============
R_Spray
@@ -1345,7 +1306,61 @@ Throws a shower of sprites or models
*/
void GAME_EXPORT R_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int spread, int rendermode )
{
R_Spray_Generic( __func__, pos, dir, modelIndex, count, speed, spread, rendermode, false );
TEMPENTITY *pTemp;
float noise;
float znoise;
model_t *pmodel;
int i;
if(( pmodel = CL_ModelHandle( modelIndex )) == NULL )
{
Con_Reportf( "No model %d!\n", modelIndex );
return;
}
noise = (float)spread / 100.0f;
// more vertical displacement
znoise = Q_min( 1.0f, noise * 1.5f );
for( i = 0; i < count; i++ )
{
pTemp = CL_TempEntAlloc( pos, pmodel );
if( !pTemp ) return;
pTemp->entity.curstate.rendermode = rendermode;
pTemp->entity.baseline.renderamt = pTemp->entity.curstate.renderamt = 255;
pTemp->entity.curstate.renderfx = kRenderFxNoDissipation;
if( rendermode != kRenderGlow )
{
// spray
pTemp->flags |= FTENT_COLLIDEWORLD | FTENT_SLOWGRAVITY;
if( pTemp->frameMax > 1 )
{
pTemp->flags |= FTENT_COLLIDEWORLD | FTENT_SLOWGRAVITY | FTENT_SPRANIMATE;
pTemp->die = cl.time + (pTemp->frameMax * 0.1f);
pTemp->entity.curstate.framerate = 10;
}
else pTemp->die = cl.time + 0.35f;
}
else
{
// sprite spray
pTemp->entity.curstate.frame = COM_RandomLong( 0, pTemp->frameMax );
pTemp->flags |= FTENT_FADEOUT | FTENT_SLOWGRAVITY;
pTemp->entity.curstate.framerate = 0.5;
pTemp->die = cl.time + 0.35f;
pTemp->fadeSpeed = 2.0;
}
// make the spittle fly the direction indicated, but mix in some noise.
pTemp->entity.baseline.origin[0] = dir[0] + COM_RandomFloat( -noise, noise );
pTemp->entity.baseline.origin[1] = dir[1] + COM_RandomFloat( -noise, noise );
pTemp->entity.baseline.origin[2] = dir[2] + COM_RandomFloat( 0, znoise );
VectorScale( pTemp->entity.baseline.origin, COM_RandomFloat(( speed * 0.8f ), ( speed * 1.2f )), pTemp->entity.baseline.origin );
}
}
/*
@@ -1357,7 +1372,7 @@ Spray of alpha sprites
*/
void GAME_EXPORT R_Sprite_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int spread )
{
R_Spray_Generic( __func__, pos, dir, modelIndex, count, speed, spread, kRenderTransAlpha, true );
R_Spray( pos, dir, modelIndex, count, speed, spread, kRenderGlow );
}
/*
@@ -1478,7 +1493,7 @@ void GAME_EXPORT R_FunnelSprite( const vec3_t org, int modelIndex, int reverse )
===============
R_SparkEffect
Create a streaks + ricochet sprite
Create a streaks + richochet sprite
===============
*/
void GAME_EXPORT R_SparkEffect( const vec3_t pos, int count, int velocityMin, int velocityMax )
@@ -1494,25 +1509,18 @@ R_RicochetSound
Make a random ricochet sound
==============
*/
static void R_RicochetSoundByName( const vec3_t pos, const char *name )
static void R_RicochetSound_( const vec3_t pos, int sound )
{
sound_t handle;
handle = S_RegisterSound( name );
S_StartSound( pos, 0, CHAN_AUTO, handle, VOL_NORM, 1.0, 100, 0 );
}
sound_t handle;
static void R_RicochetSoundByIndex( const vec3_t pos, int idx )
{
const char *name = SoundList_Get( Ricochet, idx );
if( name )
R_RicochetSoundByName( pos, name );
handle = S_RegisterSound( cl_ricochet_sounds[sound] );
S_StartSound( pos, 0, CHAN_AUTO, handle, VOL_NORM, 1.0, 100, 0 );
}
void GAME_EXPORT R_RicochetSound( const vec3_t pos )
{
const char *name = SoundList_GetRandom( Ricochet );
if( name )
R_RicochetSoundByName( pos, name );
R_RicochetSound_( pos, COM_RandomLong( 0, 4 ));
}
/*
@@ -1659,12 +1667,8 @@ void GAME_EXPORT R_Explosion( vec3_t pos, int model, float scale, float framerat
if( !FBitSet( flags, TE_EXPLFLAG_NOSOUND ))
{
const char *name = SoundList_GetRandom( Explode );
if( name )
{
hSound = S_RegisterSound( name );
S_StartSound( pos, 0, CHAN_STATIC, hSound, VOL_NORM, 0.3f, PITCH_NORM, 0 );
}
hSound = S_RegisterSound( cl_explode_sounds[COM_RandomLong( 0, 2 )] );
S_StartSound( pos, 0, CHAN_STATIC, hSound, VOL_NORM, 0.3f, PITCH_NORM, 0 );
}
}
@@ -1907,7 +1911,6 @@ void CL_ParseTempEntity( sizebuf_t *msg )
cl_entity_t *pEnt;
dlight_t *dl;
sound_t hSound;
const char *name;
if( cls.legacymode )
iSize = MSG_ReadByte( msg );
@@ -1917,7 +1920,7 @@ void CL_ParseTempEntity( sizebuf_t *msg )
// this will probably be fatal anyway
if( iSize > sizeof( pbuf ))
Con_Printf( S_ERROR "%s: Temp buffer overflow!\n", __func__ );
Con_Printf( S_ERROR "%s: Temp buffer overflow!\n", __FUNCTION__ );
// parse user message into buffer
MSG_ReadBytes( msg, pbuf, iSize );
@@ -1967,11 +1970,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos[2] = MSG_ReadCoord( &buf );
R_BlobExplosion( pos );
if(( name = SoundList_Get( Explode, 0 )))
{
hSound = S_RegisterSound( name );
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 1.0f, PITCH_NORM, 0 );
}
hSound = S_RegisterSound( cl_explode_sounds[0] );
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 1.0f, PITCH_NORM, 0 );
break;
case TE_SMOKE:
pos[0] = MSG_ReadCoord( &buf );
@@ -2024,11 +2024,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
dl->die = cl.time + 0.5;
dl->decay = 300;
if(( name = SoundList_Get( Explode, 0 )))
{
hSound = S_RegisterSound( name );
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 1.0f, PITCH_NORM, 0 );
}
hSound = S_RegisterSound( cl_explode_sounds[0] );
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 0.6f, PITCH_NORM, 0 );
break;
case TE_BSPDECAL:
case TE_DECAL:
@@ -2256,8 +2253,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
CL_DecalShoot( CL_DecalIndex( decalIndex ), entityIndex, 0, pos, 0 );
R_BulletImpactParticles( pos );
flags = COM_RandomLong( 0, 0x7fff );
if( flags < 0x3fff && ( count = SoundList_Count( Ricochet )))
R_RicochetSoundByIndex( pos, flags % count );
if( flags < 0x3fff )
R_RicochetSound_( pos, flags % 5 );
break;
case TE_SPRAY:
case TE_SPRITE_SPRAY:
@@ -2397,13 +2394,13 @@ void CL_ParseTempEntity( sizebuf_t *msg )
R_UserTracerParticle( pos, pos2, life, color, scale, 0, NULL );
break;
default:
Con_DPrintf( S_ERROR "%s: illegible TE message %i\n", __func__, type );
Con_DPrintf( S_ERROR "ParseTempEntity: illegible TE message %i\n", type );
break;
}
// throw warning
if( MSG_CheckOverflow( &buf ))
Con_DPrintf( S_WARN "%s: overflow TE message %i\n", __func__, type );
Con_DPrintf( S_WARN "ParseTempEntity: overflow TE message %i\n", type );
}
@@ -2421,7 +2418,7 @@ LIGHT STYLE MANAGEMENT
CL_ClearLightStyles
================
*/
static void CL_ClearLightStyles( void )
void CL_ClearLightStyles( void )
{
memset( cl.lightstyles, 0, sizeof( cl.lightstyles ));
}
@@ -2461,8 +2458,7 @@ void CL_SetLightstyle( int style, const char *s, float f )
}
}
if( ls->length >= 1 )
Con_Reportf( "Lightstyle %i (%s), interp %s\n", style, ls->pattern, ls->interp ? "Yes" : "No" );
Con_Reportf( "Lightstyle %i (%s), interp %s\n", style, ls->pattern, ls->interp ? "Yes" : "No" );
}
/*
@@ -2480,7 +2476,7 @@ dlight_t cl_elights[MAX_ELIGHTS];
CL_ClearDlights
================
*/
static void CL_ClearDlights( void )
void CL_ClearDlights( void )
{
memset( cl_dlights, 0, sizeof( cl_dlights ));
memset( cl_elights, 0, sizeof( cl_elights ));
@@ -2584,43 +2580,31 @@ CL_DecayLights
*/
void CL_DecayLights( void )
{
const float time = cl.time;
const float dt = cl.time - cl.oldtime;
dlight_t *dl;
float time;
int i;
for( i = 0; i < MAX_DLIGHTS; i++ )
time = cl.time - cl.oldtime;
for( i = 0, dl = cl_dlights; i < MAX_DLIGHTS; i++, dl++ )
{
dlight_t *dl = &cl_dlights[i];
if( !dl->radius ) continue;
if( !dl->radius )
continue;
dl->radius -= time * dl->decay;
if( dl->radius < 0 ) dl->radius = 0;
if( dl->die < time )
{
memset( dl, 0, sizeof( *dl ));
continue;
}
dl->radius -= dt * dl->decay;
if( dl->radius <= 0 )
if( dl->die < cl.time || !dl->radius )
memset( dl, 0, sizeof( *dl ));
}
for( i = 0; i < MAX_ELIGHTS; i++ )
for( i = 0, dl = cl_elights; i < MAX_ELIGHTS; i++, dl++ )
{
dlight_t *dl = &cl_elights[i];
if( !dl->radius ) continue;
if( !dl->radius )
continue;
dl->radius -= time * dl->decay;
if( dl->radius < 0 ) dl->radius = 0;
if( dl->die < time )
{
memset( dl, 0, sizeof( *dl ));
continue;
}
dl->radius -= dt * dl->decay;
if( dl->radius <= 0 )
if( dl->die < cl.time || !dl->radius )
memset( dl, 0, sizeof( *dl ));
}
}
@@ -2763,12 +2747,7 @@ void CL_AddEntityEffects( cl_entity_t *ent )
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
R_EntityBrightlight( ent, ent->index /* 1 in GoldSrc */, 400 );
else if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
{
if( Host_IsQuakeCompatible( ))
R_EntityDimlight( ent, ent->index );
else
CL_UpdateFlashlight( ent );
}
CL_UpdateFlashlight( ent );
}
else
{
@@ -2944,7 +2923,7 @@ CL_PlayerDecal
spray custom colored decal (clan logo etc)
===============
*/
static void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, float *pos )
void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, float *pos )
{
int textureIndex = 0;
customization_t *pCust = NULL;
@@ -2958,26 +2937,16 @@ static void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, flo
{
if( !pCust->nUserData1 )
{
int sprayTextureIndex;
char decalname[MAX_VA_STRING];
int width, height;
Q_snprintf( decalname, sizeof( decalname ), "player%dlogo%d", playernum, customIndex );
textureIndex = ref.dllFuncs.GL_FindTexture( decalname );
if( textureIndex != 0 )
ref.dllFuncs.GL_FreeTexture( textureIndex );
pCust->nUserData1 = GL_LoadTextureInternal( decalname, pCust->pInfo, TF_DECAL );
width = REF_GET_PARM( PARM_TEX_WIDTH, pCust->nUserData1 );
height = REF_GET_PARM( PARM_TEX_HEIGHT, pCust->nUserData1 );
if( width > cl_logomaxdim.value || height > cl_logomaxdim.value )
sprayTextureIndex = ref.dllFuncs.GL_FindTexture( decalname );
if( sprayTextureIndex != 0 )
{
double scale = cl_logomaxdim.value / Q_max( width, height );
width = round( width * scale );
height = round( height * scale );
ref.dllFuncs.R_OverrideTextureSourceSize( pCust->nUserData1, width, height ); // default custom decal from HL1
ref.dllFuncs.GL_FreeTexture( sprayTextureIndex );
}
pCust->nUserData1 = GL_LoadTextureInternal( decalname, pCust->pInfo, TF_DECAL );
}
textureIndex = pCust->nUserData1;
}
@@ -3022,47 +2991,8 @@ int GAME_EXPORT CL_DecalIndex( int id )
if( cl.decal_index[id] == 0 )
{
int gl_texturenum = 0;
Image_SetForceFlags( IL_LOAD_DECAL );
if( Mod_AllowMaterials( ))
{
string decalname;
if( Q_snprintf( decalname, sizeof( decalname ), "materials/decals/%s.tga", host.draw_decals[id] ) > 0 )
{
if( g_fsapi.FileExists( decalname, false ))
{
gl_texturenum = ref.dllFuncs.GL_LoadTexture( decalname, NULL, 0, TF_DECAL );
if( host_allow_materials.value == 2.0f )
Con_Printf( "Looking for %s decal replacement...%s (%s)\n", host.draw_decals[id], gl_texturenum != 0 ? S_GREEN "OK" : S_RED "FAIL", decalname );
}
else if( host_allow_materials.value == 2.0f )
Con_Printf( "Looking for %s decal replacement..." S_YELLOW "MISS (%s)\n", host.draw_decals[id], decalname );
}
else if( host_allow_materials.value == 2.0f )
Con_Printf( "Looking for %s decal replacement..." S_YELLOW "MISS (overflow)\n", host.draw_decals[id] );
if( gl_texturenum )
{
byte *fin;
Q_snprintf( decalname, sizeof( decalname ), "decals.wad/%s", host.draw_decals[id] );
if(( fin = g_fsapi.LoadFile( decalname, NULL, false )) != NULL )
{
mip_t *mip = (mip_t *)fin;
ref.dllFuncs.R_OverrideTextureSourceSize( gl_texturenum, mip->width, mip->height );
Mem_Free( fin );
}
}
}
if( !gl_texturenum )
gl_texturenum = ref.dllFuncs.GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
cl.decal_index[id] = gl_texturenum;
cl.decal_index[id] = ref.dllFuncs.GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
Image_ClearForceFlags();
}
@@ -3089,6 +3019,26 @@ EFRAGS MANAGEMENT
==============================================================
*/
efrag_t cl_efrags[MAX_EFRAGS];
/*
==============
CL_ClearEfrags
==============
*/
void CL_ClearEfrags( void )
{
int i;
memset( cl_efrags, 0, sizeof( cl_efrags ));
// allocate the efrags and chain together into a free list
clgame.free_efrags = cl_efrags;
for( i = 0; i < MAX_EFRAGS - 1; i++ )
clgame.free_efrags[i].entnext = &clgame.free_efrags[i+1];
clgame.free_efrags[i].entnext = NULL;
}
/*
=======================
R_ClearStaticEntities
@@ -3126,3 +3076,4 @@ void CL_ClearEffects( void )
CL_ClearParticles ();
CL_ClearLightStyles ();
}

View File

@@ -101,19 +101,6 @@ struct beam_s *R_BeamRing( int startEnt, int endEnt, int modelIndex, float life,
struct beam_s *R_BeamFollow( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness );
void R_BeamKill( int deadEntity );
// TriAPI
void TriRenderMode( int mode );
void TriColor4f( float r, float g, float b, float a );
void TriColor4ub( byte r, byte g, byte b, byte a );
void TriBrightness( float brightness );
void TriCullFace( TRICULLSTYLE mode );
int TriWorldToScreen( const float *world, float *screen );
int TriBoxInPVS( float *mins, float *maxs );
void TriLightAtPoint( float *pos, float *value );
void TriColor4fRendermode( float r, float g, float b, float a, int rendermode );
int TriSpriteTexture( model_t *pSpriteModel, int frame );
extern model_t *cl_sprite_dot;
extern model_t *cl_sprite_shell;

View File

@@ -68,7 +68,7 @@ qboolean SCR_NextMovie( void )
return true;
}
static void SCR_CreateStartupVids( void )
void SCR_CreateStartupVids( void )
{
file_t *f;

View File

@@ -29,13 +29,13 @@ V_CalcViewRect
calc frame rectangle (Quake1 style)
===============
*/
static void V_CalcViewRect( void )
void V_CalcViewRect( void )
{
qboolean full = false;
int sb_lines;
float size;
if( Host_IsQuakeCompatible( ))
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
{
// intermission is always full screen
if( cl.intermission ) size = 120.0f;
@@ -88,7 +88,7 @@ static void V_CalcViewRect( void )
V_SetupViewModel
===============
*/
static void V_SetupViewModel( void )
void V_SetupViewModel( void )
{
cl_entity_t *view = &clgame.viewent;
player_info_t *info = &cl.players[cl.playernum];
@@ -118,7 +118,7 @@ static void V_SetupViewModel( void )
V_SetRefParams
===============
*/
static void V_SetRefParams( ref_params_t *fd )
void V_SetRefParams( ref_params_t *fd )
{
memset( fd, 0, sizeof( ref_params_t ));
@@ -144,9 +144,7 @@ static void V_SetRefParams( ref_params_t *fd )
VectorCopy( cl.viewangles, fd->cl_viewangles );
fd->health = cl.local.health;
VectorCopy( cl.crosshairangle, fd->crosshairangle );
if( Host_IsQuakeCompatible( ))
fd->viewsize = scr_viewsize.value;
else fd->viewsize = 120.0f;
fd->viewsize = scr_viewsize.value;
VectorCopy( cl.punchangle, fd->punchangle );
fd->maxclients = cl.maxclients;
@@ -184,7 +182,7 @@ V_MergeOverviewRefdef
merge refdef with overview settings
===============
*/
static void V_RefApplyOverview( ref_viewpass_t *rvp )
void V_RefApplyOverview( ref_viewpass_t *rvp )
{
ref_overview_t *ov = &clgame.overView;
float aspect;
@@ -283,7 +281,7 @@ static void V_AdjustFov( float *fov_x, float *fov_y, float width, float height,
V_GetRefParams
=============
*/
static void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp )
void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp )
{
// part1: deniable updates
VectorCopy( fd->simvel, cl.simvel );
@@ -343,7 +341,7 @@ qboolean V_PreRender( void )
{
if(( host.realtime - cls.disable_screen ) > cl_timeout.value )
{
Con_Reportf( "%s: loading plaque timed out\n", __func__ );
Con_Reportf( "V_PreRender: loading plaque timed out\n" );
cls.disable_screen = 0.0f;
}
return false;
@@ -410,22 +408,22 @@ void V_RenderView( void )
#define NODE_INTERVAL_X(x) (x * 16.0f)
#define NODE_INTERVAL_Y(x) (x * 16.0f)
static void R_DrawLeafNode( float x, float y, float scale )
void R_DrawLeafNode( float x, float y, float scale )
{
float downScale = scale * 0.25f;// * POINT_SIZE;
ref.dllFuncs.R_DrawStretchPic( x - downScale * 0.5f, y - downScale * 0.5f, downScale, downScale, 0, 0, 1, 1, R_GetBuiltinTexture( REF_PARTICLE_TEXTURE ) );
}
static void R_DrawNodeConnection( float x, float y, float x2, float y2 )
void R_DrawNodeConnection( float x, float y, float x2, float y2 )
{
ref.dllFuncs.Begin( TRI_LINES );
ref.dllFuncs.Vertex3f( x, y, 0 );
ref.dllFuncs.Vertex3f( x2, y2, 0 );
ref.dllFuncs.End( );
gTriApi.Begin( TRI_LINES );
gTriApi.Vertex3f( x, y, 0 );
gTriApi.Vertex3f( x2, y2, 0 );
gTriApi.End( );
}
static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes, mleaf_t *viewleaf )
void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes, mleaf_t *viewleaf )
{
float downScale = scale * 0.8f;
@@ -445,10 +443,10 @@ static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int show
if( shownodes == 1 )
{
if( cl.worldmodel->leafs == leaf )
ref.dllFuncs.Color4f( 1.0f, 1.0f, 1.0f, 1.0f );
gTriApi.Color4f( 1.0f, 1.0f, 1.0f, 1.0f );
else if( viewleaf && viewleaf == leaf )
ref.dllFuncs.Color4f( 1.0f, 0.0f, 0.0f, 1.0f );
else ref.dllFuncs.Color4f( 0.0f, 1.0f, 0.0f, 1.0f );
gTriApi.Color4f( 1.0f, 0.0f, 0.0f, 1.0f );
else gTriApi.Color4f( 0.0f, 1.0f, 0.0f, 1.0f );
R_DrawLeafNode( x, y, scale );
}
world.recursion_level--;
@@ -457,7 +455,7 @@ static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int show
if( shownodes == 1 )
{
ref.dllFuncs.Color4f( 0.0f, 0.0f, 1.0f, 1.0f );
gTriApi.Color4f( 0.0f, 0.0f, 1.0f, 1.0f );
R_DrawLeafNode( x, y, scale );
}
else if( shownodes == 2 )
@@ -472,7 +470,7 @@ static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int show
world.recursion_level--;
}
static void R_ShowTree( void )
void R_ShowTree( void )
{
float x = (float)((refState.width - (int)POINT_SIZE) >> 1);
float y = NODE_INTERVAL_Y(1.0f);
@@ -489,7 +487,7 @@ static void R_ShowTree( void )
//pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
//pglLineWidth( 2.0f );
ref.dllFuncs.Color4f( 1, 0.7f, 0, 1.0f );
gTriApi.Color4f( 1, 0.7f, 0, 1.0f );
//pglDisable( GL_TEXTURE_2D );
R_ShowTree_r( cl.worldmodel->nodes, x, y, world.max_recursion * 3.5f, 2, viewleaf );
//pglEnable( GL_TEXTURE_2D );
@@ -508,6 +506,7 @@ V_PostRender
*/
void V_PostRender( void )
{
static double oldtime;
qboolean draw_2d = false;
ref.dllFuncs.R_AllowFog( false );
@@ -534,7 +533,6 @@ void V_PostRender( void )
SCR_RSpeeds();
SCR_NetSpeeds();
SCR_DrawPos();
SCR_DrawEnts();
SCR_DrawNetGraph();
SV_DrawOrthoTriangles();
CL_DrawDemoRecording();
@@ -555,6 +553,4 @@ void V_PostRender( void )
ref.dllFuncs.R_AllowFog( true );
Platform_SetTimer( 0.0f );
ref.dllFuncs.R_EndFrame();
V_CheckGammaEnd();
}

View File

@@ -229,7 +229,7 @@ typedef struct
char serverinfo[MAX_SERVERINFO_STRING];
player_info_t players[MAX_CLIENTS]; // collected info about all other players include himself
double lastresourcecheck;
qboolean http_download;
string downloadUrl;
event_state_t events;
// predicting stuff but not only...
@@ -276,8 +276,6 @@ typedef struct
model_t *worldmodel; // pointer to world
int lostpackets; // count lost packets and show dialog in menu
double frametime_remainder;
} client_t;
/*
@@ -309,14 +307,6 @@ typedef enum
CL_CHANGELEVEL, // draw 'loading' during changelevel
} scrstate_t;
typedef enum
{
PROTO_CURRENT = 0, // Xash3D 49
PROTO_LEGACY = 1, // Xash3D 48
PROTO_QUAKE = 2, // Quake 15
PROTO_GOLDSRC = 3, // GoldSrc 48
} connprotocol_t;
typedef struct
{
char name[32];
@@ -352,7 +342,8 @@ typedef struct
byte charWidths[256]; // scaled widths
int charHeight; // scaled height
int type; // fixed width font or variable
convar_t *rendermode; // user-defined default rendermode
int rendermode; // default rendermode
qboolean nearest; // nearest filtering enabled
qboolean valid; // all rectangles are valid
} cl_font_t;
@@ -379,7 +370,6 @@ typedef struct
// holds text color
rgba_t textColor;
rgba_t spriteColor;
vec4_t triRGBA;
// crosshair members
const model_t *pCrosshair;
@@ -501,6 +491,7 @@ typedef struct
net_request_t net_requests[MAX_REQUESTS]; // no reason to keep more
efrag_t *free_efrags; // linked efrags
cl_entity_t viewent; // viewmodel
qboolean client_dll_uses_sdl;
@@ -517,9 +508,8 @@ typedef struct
player_info_t playerinfo; // local playerinfo
gameui_draw_t ds; // draw2d stuff (menu images)
gameinfo2_t gameInfo; // current gameInfo
gameinfo2_t *modsInfo; // simplified gameInfo for MainUI, allocated by demand
GAMEINFO **oldModsInfo; // simplified gameInfo for older MainUI, allocated by demand
GAMEINFO gameInfo; // current gameInfo
GAMEINFO *modsInfo[MAX_MODS]; // simplified gameInfo for MainUI
ui_globalvars_t *globals;
@@ -528,7 +518,7 @@ typedef struct
int logo_yres;
float logo_length;
qboolean use_extended_api;
qboolean use_text_api;
} gameui_static_t;
typedef struct
@@ -549,8 +539,12 @@ typedef struct
poolhandle_t mempool; // client premamnent pool: edicts etc
int signon; // 0 to SIGNONS, for the signon sequence.
netadr_t hltv_listen_address;
int signon; // 0 to SIGNONS, for the signon sequence.
int quakePort; // a 16 bit value that allows quake servers
// to work around address translating routers
// g-cont. this port allow many copies of engine in multiplayer game
// connection information
char servername[MAX_QPATH]; // name of server from original connect
double connect_time; // for connection retransmits
@@ -634,14 +628,12 @@ typedef struct
char internetservers_query[512]; // cached query
uint32_t internetservers_query_len;
// multiprotocol support
connprotocol_t legacymode;
// legacy mode support
qboolean legacymode; // one-way 48 protocol compatibility
netadr_t legacyserver;
int extensions;
netadr_t serveradr;
// do we accept utf8 as input
qboolean accept_utf8;
} client_static_t;
#ifdef __cplusplus
@@ -661,11 +653,14 @@ extern gameui_static_t gameui;
// cvars
//
extern convar_t mp_decals;
extern convar_t cl_logomaxdim;
extern convar_t cl_logofile;
extern convar_t cl_logocolor;
extern convar_t cl_allow_download;
extern convar_t cl_allow_upload;
extern convar_t cl_download_ingame;
extern convar_t cl_nopred;
extern convar_t cl_timeout;
extern convar_t cl_nodelta;
extern convar_t cl_interp;
extern convar_t cl_nointerp;
extern convar_t cl_showerror;
@@ -678,20 +673,19 @@ extern convar_t cl_updaterate;
extern convar_t cl_solid_players;
extern convar_t cl_idealpitchscale;
extern convar_t cl_allow_levelshots;
extern convar_t cl_lightstyle_lerping;
extern convar_t cl_draw_particles;
extern convar_t cl_draw_tracers;
extern convar_t cl_levelshot_name;
extern convar_t cl_draw_beams;
extern convar_t cl_clockreset;
extern convar_t cl_fixtimerate;
extern convar_t hud_fontscale;
extern convar_t hud_fontrender;
extern convar_t hud_scale;
extern convar_t hud_scale_minimal_width;
extern convar_t r_showtextures;
extern convar_t cl_bmodelinterp;
extern convar_t cl_lw; // local weapons
extern convar_t cl_charset;
extern convar_t cl_trace_stufftext;
extern convar_t cl_trace_messages;
extern convar_t cl_trace_events;
extern convar_t hud_utf8;
@@ -710,6 +704,7 @@ extern convar_t cl_fixmodelinterpolationartifacts;
//=============================================================================
void CL_SetLightstyle( int style, const char* s, float f );
void CL_RunLightStyles( void );
void CL_DecayLights( void );
dlight_t *CL_GetDynamicLight( int number );
dlight_t *CL_GetEntityLight( int number );
@@ -720,8 +715,12 @@ dlight_t *CL_GetEntityLight( int number );
// cl_cmds.c
//
void CL_Quit_f( void );
void CL_GenericShot_f( void );
void CL_ScreenShot_f( void );
void CL_SnapShot_f( void );
void CL_PlayCDTrack_f( void );
void CL_EnvShot_f( void );
void CL_SkyShot_f( void );
void CL_SaveShot_f( void );
void CL_LevelShot_f( void );
void CL_SetSky_f( void );
void SCR_Viewpos_f( void );
@@ -742,6 +741,8 @@ void CL_ClearResourceLists( void );
void CL_Parse_Debug( qboolean enable );
void CL_Parse_RecordCommand( int cmd, int startoffset );
void CL_ResetFrame( frame_t *frame );
void CL_WriteMessageHistory( void );
const char *CL_MsgInfo( int cmd );
//
// cl_efx.c
@@ -752,6 +753,7 @@ void CL_Particle( const vec3_t org, int color, float life, int zpos, int zvel );
// cl_main.c
//
void CL_Init( void );
void CL_SendCommand( void );
void CL_Disconnect_f( void );
void CL_ProcessFile( qboolean successfully_received, const char *filename );
void CL_WriteUsercmd( sizebuf_t *msg, int from, int to );
@@ -760,6 +762,7 @@ qboolean CL_PrecacheResources( void );
void CL_SetupOverviewParams( void );
void CL_UpdateFrameLerp( void );
int CL_IsDevOverviewMode( void );
void CL_PingServers_f( void );
void CL_SignonReply( void );
void CL_ClearState( void );
@@ -777,6 +780,8 @@ void CL_CheckStartupDemos( void );
void CL_WriteDemoJumpTime( void );
void CL_CloseDemoHeader( void );
void CL_DemoCompleted( void );
void CL_StopPlayback( void );
void CL_StopRecord( void );
void CL_PlayDemo_f( void );
void CL_TimeDemo_f( void );
void CL_StartDemos_f( void );
@@ -784,8 +789,6 @@ void CL_Demos_f( void );
void CL_DeleteDemo_f( void );
void CL_Record_f( void );
void CL_Stop_f( void );
void CL_ListDemo_f( void );
int CL_GetDemoComment( const char *demoname, char *comment );
//
// cl_events.c
@@ -793,9 +796,12 @@ int CL_GetDemoComment( const char *demoname, char *comment );
void CL_ParseEvent( sizebuf_t *msg );
void CL_ParseReliableEvent( sizebuf_t *msg );
void CL_SetEventIndex( const char *szEvName, int ev_index );
void CL_QueueEvent( int flags, int index, float delay, event_args_t *args );
void CL_PlaybackEvent( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin,
float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
void CL_RegisterEvent( int lastnum, const char *szEvName, pfnEventHook func );
void CL_BatchResourceRequest( qboolean initialize );
int CL_EstimateNeededResources( void );
void CL_ResetEvent( event_info_t *ei );
word CL_EventIndex( const char *name );
void CL_FireEvents( void );
@@ -804,10 +810,9 @@ void CL_FireEvents( void );
// cl_font.c
//
qboolean CL_FixedFont( cl_font_t *font );
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags );
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags );
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags );
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags );
void CL_FreeFont( cl_font_t *font );
void CL_SetFontRendermode( cl_font_t *font );
int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *font, int flags );
int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *font, int flags );
void CL_DrawCharacterLen( cl_font_t *font, int number, int *width, int *height );
@@ -820,7 +825,10 @@ int CL_DrawStringf( cl_font_t *font, float x, float y, rgba_t color, int flags,
//
void CL_UnloadProgs( void );
qboolean CL_LoadProgs( const char *name );
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num );
void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize );
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
void CL_ParseTextMessage( sizebuf_t *msg );
void CL_DrawHUD( int state );
void CL_InitEdicts( int maxclients );
void CL_FreeEdicts( void );
@@ -830,38 +838,66 @@ void CL_ClearSpriteTextures( void );
void CL_CenterPrint( const char *text, float y );
void CL_TextMessageParse( byte *pMemFile, int fileSize );
client_textmessage_t *CL_TextMessageGet( const char *pName );
model_t *CL_ModelHandle( int modelindex );
void NetAPI_CancelAllRequests( void );
cl_entity_t *CL_GetLocalPlayer( void );
model_t *CL_LoadClientSprite( const char *filename );
model_t *CL_LoadModel( const char *modelname, int *index );
HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags );
void SPR_AdjustSize( float *x, float *y, float *w, float *h );
void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float *s2, float *t2 );
int CL_GetScreenInfo( SCREENINFO *pscrinfo );
void CL_FillRGBA( int x, int y, int width, int height, int r, int g, int b, int a );
pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe );
const char *PM_CL_TraceTexture( int ground, float *vstart, float *vend );
int PM_CL_PointContents( const float *p, int *truecontents );
void CL_GetMousePosition( int *mx, int *my ); // TODO: move to input
cl_entity_t* CL_GetViewModel( void );
physent_t *pfnGetPhysent( int idx );
struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend );
movevars_t *pfnGetMoveVars( void );
void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int height );
void CL_DisableScissor( scissor_state_t *scissor );
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 );
struct cl_entity_s *CL_GetEntityByIndex( int index );
_inline cl_entity_t *CL_EDICT_NUM( int n )
static inline cl_entity_t *CL_EDICT_NUM( int n )
{
if( !clgame.entities )
if( unlikely( !clgame.entities )) // not in game yet
{
Host_Error( "%s: clgame.entities is NULL\n", __func__ );
Host_Error( "CL_EDICT_NUM: clgame.entities is NULL\n");
return NULL;
}
if(( n >= 0 ) && ( n < clgame.maxEntities ))
return clgame.entities + n;
if( unlikely( n < 0 || n >= clgame.maxEntities ))
{
Host_Error( "CL_EDICT_NUM: bad number %i\n", n );
return NULL;
}
Host_Error( "%s: bad number %i\n", __func__, n );
return NULL;
return &clgame.entities[n];
}
static inline cl_entity_t *CL_GetEntityByIndex( int n )
{
if( unlikely( !clgame.entities )) // not in game yet
return NULL;
if( unlikely( n < 0 || n >= clgame.maxEntities ))
return NULL;
return &clgame.entities[n];
}
static inline model_t *CL_ModelHandle( int modelindex )
{
if( unlikely( modelindex < 0 || modelindex >= MAX_MODELS ))
return NULL;
return cl.models[modelindex];
}
static inline qboolean CL_IsPlayerIndex( int idx )
{
return ( idx >= 1 && idx <= cl.maxclients );
}
//
@@ -891,24 +927,19 @@ void CL_ParseFileTransferFailed( sizebuf_t *msg );
void CL_ParseHLTV( sizebuf_t *msg );
void CL_ParseDirector( sizebuf_t *msg );
void CL_ParseResLocation( sizebuf_t *msg );
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t proto );
void CL_ParseServerMessage( sizebuf_t *msg );
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext );
void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message );
void CL_ParseTempEntity( sizebuf_t *msg );
qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf );
qboolean CL_RequestMissingResources( void );
void CL_RegisterResources ( sizebuf_t *msg );
void CL_ParseViewEntity( sizebuf_t *msg );
void CL_ParseServerTime( sizebuf_t *msg );
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num );
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
void CL_ParseTextMessage( sizebuf_t *msg );
void CL_BatchResourceRequest( qboolean initialize );
int CL_EstimateNeededResources( void );
//
// cl_parse_48.c
//
void CL_ParseLegacyServerMessage( sizebuf_t *msg );
void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message );
void CL_LegacyPrecache_f( void );
//
@@ -917,6 +948,8 @@ void CL_LegacyPrecache_f( void );
void SCR_VidInit( void );
void SCR_TileClear( void );
void SCR_DirtyScreen( void );
void SCR_AddDirtyPoint( int x, int y );
void SCR_InstallParticlePalette( void );
void SCR_EndLoadingPlaque( void );
void SCR_RegisterTextures( void );
void SCR_LoadCreditsFont( void );
@@ -926,7 +959,6 @@ void SCR_NetSpeeds( void );
void SCR_RSpeeds( void );
void SCR_DrawFPS( int height );
void SCR_DrawPos( void );
void SCR_DrawEnts( void );
//
// cl_netgraph.c
@@ -953,22 +985,25 @@ void CL_InitClientMove( void );
void CL_PredictMovement( qboolean repredicting );
void CL_CheckPredictionError( void );
qboolean CL_IsPredicted( void );
int CL_TruePointContents( const vec3_t p );
int CL_WaterEntity( const float *rgflPos );
cl_entity_t *CL_GetWaterEntity( const float *rgflPos );
int CL_TestLine( const vec3_t start, const vec3_t end, int flags );
pmtrace_t *CL_VisTraceLine( vec3_t start, vec3_t end, int flags );
pmtrace_t CL_TraceLine( vec3_t start, vec3_t end, int flags );
void CL_PushTraceBounds( int hullnum, const float *mins, const float *maxs );
void CL_PopTraceBounds( void );
void CL_MoveSpectatorCamera( void );
void CL_SetLastUpdate( void );
void CL_RedoPrediction( void );
void CL_PushPMStates( void );
void CL_PopPMStates( void );
void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient );
void CL_SetIdealPitch( void );
//
// cl_qparse.c
//
void CL_ParseQuakeMessage( sizebuf_t *msg );
void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message );
//
// cl_frame.c
@@ -980,10 +1015,11 @@ qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType );
void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset );
qboolean CL_GetEntitySpatialization( struct channel_s *ch );
qboolean CL_GetMovieSpatialization( struct rawchan_s *ch );
void CL_ProcessPlayerState( int playerindex, entity_state_t *state );
void CL_ComputePlayerOrigin( cl_entity_t *clent );
void CL_ProcessPacket( frame_t *frame );
void CL_MoveThirdpersonCamera( void );
qboolean CL_IsPlayerIndex( int idx );
void CL_SetIdealPitch( void );
void CL_EmitEntities( void );
//
@@ -1007,7 +1043,6 @@ const ref_overview_t *GL_GetOverviewParms( void );
//
void R_StoreEfrags( efrag_t **ppefrag, int framecount );
void R_AddEfrags( cl_entity_t *ent );
//
// cl_tent.c
//
@@ -1018,6 +1053,7 @@ void CL_ClearEfrags( void );
void CL_TestLights( void );
void CL_FireCustomDecal( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags, float scale );
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );
void CL_PlayerDecal( int playerIndex, int textureIndex, int entityIndex, float *pos );
void R_FreeDeadParticles( struct particle_s **ppparticles );
void CL_AddClientResource( const char *filename, int type );
void CL_AddClientResources( void );
@@ -1039,6 +1075,7 @@ void CL_ReadPointFile_f( void );
void CL_DrawEFX( float time, qboolean fTrans );
void CL_ThinkParticle( double frametime, particle_t *p );
void CL_ReadLineFile_f( void );
void CL_RunLightStyles( void );
//
// console.c
@@ -1058,22 +1095,27 @@ int Con_UtfProcessChar( int in );
int Con_UtfProcessCharForce( int in );
int Con_UtfMoveLeft( char *str, int pos );
int Con_UtfMoveRight( char *str, int pos, int length );
void Con_DefaultColor( int r, int g, int b, qboolean gameui );
void Con_DefaultColor( int r, int g, int b );
void Con_InvalidateFonts( void );
cl_font_t *Con_GetCurFont( void );
cl_font_t *Con_GetFont( int num );
void Con_DrawCharacterLen( int number, int *width, int *height );
int Con_DrawString( int x, int y, const char *string, rgba_t setColor ); // legacy, use cl_font.c
void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height ); // legacy, use cl_font.c
void Con_CharEvent( int key );
void Con_RestoreFont( void );
void Key_Console( int key );
void Key_Message( int key );
void Con_FastClose( void );
void Con_Bottom( void );
void Con_Top( void );
void Con_PageDown( int lines );
void Con_PageUp( int lines );
//
// s_main.c
//
void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data );
void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float synctime );
void S_StartBackgroundTrack( const char *intro, const char *loop, int position, qboolean fullpath );
void S_StopBackgroundTrack( void );
@@ -1111,7 +1153,7 @@ qboolean UI_MouseInRect( void );
qboolean UI_IsVisible( void );
void UI_ResetPing( void );
void UI_ShowUpdateDialog( qboolean preferStore );
qboolean UI_ShowMessageBox( const char *text );
void UI_ShowMessageBox( const char *text );
void UI_AddTouchButtonToList( const char *name, const char *texture, const char *command, unsigned char *color, int flags );
void UI_ConnectionProgress_Disconnect( void );
void UI_ConnectionProgress_Download( const char *pszFileName, const char *pszServerName, const char *pszServerPath, int iCurrent, int iTotal, const char *comment );
@@ -1120,6 +1162,11 @@ void UI_ConnectionProgress_Precache( void );
void UI_ConnectionProgress_Connect( const char *server );
void UI_ConnectionProgress_ChangeLevel( void );
void UI_ConnectionProgress_ParseServerInfo( const char *server );
void pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a );
void pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc );
void pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc );
void pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc );
void pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc );
//
// cl_mobile.c
@@ -1166,6 +1213,5 @@ void OSK_Draw( void );
extern rgba_t g_color_table[8];
extern triangleapi_t gTriApi;
extern net_api_t gNetApi;
#endif//CLIENT_H

View File

@@ -21,12 +21,10 @@ GNU General Public License for more details.
#include "qfont.h"
#include "wadfile.h"
#include "input.h"
#include "utflib.h"
static CVAR_DEFINE_AUTO( scr_conspeed, "600", FCVAR_ARCHIVE, "console moving speed" );
static CVAR_DEFINE_AUTO( con_notifytime, "3", FCVAR_ARCHIVE, "notify time to live" );
CVAR_DEFINE_AUTO( con_fontsize, "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" );
static CVAR_DEFINE_AUTO( con_fontrender, "2", FCVAR_ARCHIVE, "console font render mode (0: additive, 1: holes, 2: trans)" );
static CVAR_DEFINE_AUTO( con_charset, "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" );
static CVAR_DEFINE_AUTO( con_fontscale, "1.0", FCVAR_ARCHIVE, "scale font texture" );
static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
@@ -35,6 +33,7 @@ static CVAR_DEFINE_AUTO( scr_drawversion, "1", FCVAR_ARCHIVE, "draw version in m
static CVAR_DEFINE_AUTO( con_oldfont, "0", 0, "use legacy font from gfx.wad, might be missing or broken" );
static int g_codepage = 0;
static qboolean g_utf8 = false;
static qboolean g_messagemode_privileged = true;
@@ -141,9 +140,8 @@ typedef struct
static console_t con;
static void Con_ClearField( field_t *edit );
static void Field_CharEvent( field_t *edit, int ch );
static void Con_InvalidateFonts( void );
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 );
@@ -153,7 +151,7 @@ static void Con_SaveHistory( con_history_t *self );
Con_Clear_f
================
*/
static void Con_Clear_f( void )
void Con_Clear_f( void )
{
con.lines_count = 0;
con.backscroll = 0; // go to end
@@ -177,10 +175,10 @@ static void Con_SetColor( void )
switch( num )
{
case 1:
Con_DefaultColor( r, r, r, false );
Con_DefaultColor( r, r, r );
break;
case 3:
Con_DefaultColor( r, g, b, false );
Con_DefaultColor( r, g, b );
break;
default:
Cvar_DirectSet( &con_color, con_color.def_string );
@@ -208,7 +206,7 @@ void Con_ClearNotify( void )
Con_ClearTyping
================
*/
static void Con_ClearTyping( void )
void Con_ClearTyping( void )
{
Con_ClearField( &con.input );
con.input.widthInChars = con.linewidth;
@@ -221,7 +219,7 @@ static void Con_ClearTyping( void )
Con_MessageMode_f
================
*/
static void Con_MessageMode_f( void )
void Con_MessageMode_f( void )
{
g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged();
@@ -237,7 +235,7 @@ static void Con_MessageMode_f( void )
Con_MessageMode2_f
================
*/
static void Con_MessageMode2_f( void )
void Con_MessageMode2_f( void )
{
g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged();
@@ -282,7 +280,7 @@ void Con_ToggleConsole_f( void )
Con_SetTimes_f
================
*/
static void Con_SetTimes_f( void )
void Con_SetTimes_f( void )
{
int newtimes;
@@ -305,7 +303,7 @@ Notifies the console code about the current time
went backwards)
================
*/
static void Con_FixTimes( void )
void Con_FixTimes( void )
{
double diff;
int i;
@@ -326,7 +324,7 @@ Con_DeleteLine
Deletes the first line from the console history.
================
*/
static void Con_DeleteLine( void )
void Con_DeleteLine( void )
{
if( con.lines_count == 0 )
return;
@@ -341,7 +339,7 @@ Con_DeleteLastLine
Deletes the last line from the console history.
================
*/
static void Con_DeleteLastLine( void )
void Con_DeleteLastLine( void )
{
if( con.lines_count == 0 )
return;
@@ -400,7 +398,7 @@ Con_AddLine
Appends a given string as a new line to the console.
================
*/
static void Con_AddLine( const char *line, int length, qboolean newline )
void Con_AddLine( const char *line, int length, qboolean newline )
{
char *putpos;
con_lineinfo_t *p;
@@ -446,7 +444,7 @@ Con_CheckResize
If the line width has changed, reformat the buffer.
================
*/
static void Con_CheckResize( void )
void Con_CheckResize( void )
{
int charWidth = 8;
int i, width;
@@ -495,7 +493,7 @@ void Con_PageDown( int lines )
Con_Top
================
*/
static void Con_Top( void )
void Con_Top( void )
{
con.backscroll = CON_MAXLINES;
}
@@ -548,7 +546,7 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
if( con_oldfont.value )
{
success = Con_LoadVariableWidthFont( "gfx/conchars.fnt", font, scale, &con_fontrender, TF_FONT|TF_NEAREST );
success = Con_LoadVariableWidthFont( "gfx/conchars.fnt", font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST );
}
else
{
@@ -561,14 +559,14 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
if( Q_snprintf( path, sizeof( path ),
"font%i_%s.fnt", fontNumber, Cvar_VariableString( "con_charset" )) > 0 )
{
success = Con_LoadVariableWidthFont( path, font, scale, &con_fontrender, TF_FONT|TF_NEAREST );
success = Con_LoadVariableWidthFont( path, font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST );
}
}
if( !success )
{
Q_snprintf( path, sizeof( path ), "fonts/font%i", fontNumber );
success = Con_LoadVariableWidthFont( path, font, scale, &con_fontrender, TF_FONT|TF_NEAREST );
success = Con_LoadVariableWidthFont( path, font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST );
}
}
@@ -576,7 +574,7 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
{
// quake fixed font as fallback
// keep source to print directly into conback image
if( !Con_LoadFixedWidthFont( "gfx/conchars", font, scale, &con_fontrender, TF_FONT|TF_NEAREST|TF_KEEP_SOURCE ))
if( !Con_LoadFixedWidthFont( "gfx/conchars", font, scale, kRenderTransTexture, TF_FONT|TF_KEEP_SOURCE ))
Con_DPrintf( S_ERROR "failed to load console font\n" );
}
}
@@ -610,6 +608,19 @@ static void Con_LoadConchars( void )
con.curFont = &con.chars[fontSize];
}
// CP1251 table
int table_cp1251[64] = {
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x007F, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457
};
/*
============================
Con_UtfProcessChar
@@ -619,28 +630,84 @@ Convert utf char to current font's single-byte encoding
*/
int Con_UtfProcessCharForce( int in )
{
// TODO: get rid of global state where possible
static utfstate_t state = { 0 };
static int m = -1, k = 0; //multibyte state
static int uc = 0; //unicode char
int ch = Q_DecodeUTF8( &state, in );
if( !in )
{
m = -1;
k = 0;
uc = 0;
return 0;
}
if( g_codepage == 1251 )
return Q_UnicodeToCP1251( ch );
if( g_codepage == 1252 )
return Q_UnicodeToCP1252( ch );
// Get character length
if(m == -1)
{
uc = 0;
if( in >= 0xF8 )
return 0;
else if( in >= 0xF0 )
uc = in & 0x07, m = 3;
else if( in >= 0xE0 )
uc = in & 0x0F, m = 2;
else if( in >= 0xC0 )
uc = in & 0x1F, m = 1;
else if( in <= 0x7F)
return in; //ascii
// return 0 if we need more chars to decode one
k=0;
return 0;
}
// get more chars
else if( k <= m )
{
uc <<= 6;
uc += in & 0x3F;
k++;
}
if( in > 0xBF || m < 0 )
{
m = -1;
return 0;
}
if( k == m )
{
k = m = -1;
if( g_codepage == 1251 )
{
// cp1251 now
if( uc >= 0x0410 && uc <= 0x042F )
return uc - 0x410 + 0xC0;
if( uc >= 0x0430 && uc <= 0x044F )
return uc - 0x430 + 0xE0;
else
{
int i;
for( i = 0; i < 64; i++ )
if( table_cp1251[i] == uc )
return i + 0x80;
}
}
else if( g_codepage == 1252 )
{
if( uc < 255 )
return uc;
}
return '?'; // not implemented yet
// not implemented yet
return '?';
}
return 0;
}
int GAME_EXPORT Con_UtfProcessChar( int in )
{
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
if( !g_utf8 )
return in;
// otherwise, decode it and convert to selected codepage
return Con_UtfProcessCharForce( in );
else
return Con_UtfProcessCharForce( in );
}
/*
=================
Con_UtfMoveLeft
@@ -650,22 +717,16 @@ get position of previous printful char
*/
int Con_UtfMoveLeft( char *str, int pos )
{
utfstate_t state = { 0 };
int k = 0;
int i;
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
int i, k = 0;
// int j;
if( !g_utf8 )
return pos - 1;
if( pos == 1 )
return 0;
for( i = 0; i < pos - 1; i++ )
{
if( Q_DecodeUTF8( &state, (byte)str[i] ))
k = i + 1;
}
Con_UtfProcessChar( 0 );
if(pos == 1) return 0;
for( i = 0; i < pos-1; i++ )
if( Con_UtfProcessChar( (unsigned char)str[i] ) )
k = i+1;
Con_UtfProcessChar( 0 );
return k;
}
@@ -678,19 +739,17 @@ get next of previous printful char
*/
int Con_UtfMoveRight( char *str, int pos, int length )
{
utfstate_t state = { 0 };
int i;
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
if( !g_utf8 )
return pos + 1;
Con_UtfProcessChar( 0 );
for( i = pos; i <= length; i++ )
{
if( Q_DecodeUTF8( &state, (byte)str[i] ))
return i + 1;
if( Con_UtfProcessChar( (unsigned char)str[i] ) )
return i+1;
}
return pos + 1;
Con_UtfProcessChar( 0 );
return pos+1;
}
static void Con_DrawCharToConback( int num, const byte *conchars, byte *dest )
@@ -780,7 +839,6 @@ void Con_Init( void )
Cvar_RegisterVariable( &con_fontsize );
Cvar_RegisterVariable( &con_charset );
Cvar_RegisterVariable( &con_fontscale );
Cvar_RegisterVariable( &con_fontrender );
Cvar_RegisterVariable( &con_fontnum );
Cvar_RegisterVariable( &con_color );
Cvar_RegisterVariable( &scr_drawversion );
@@ -847,6 +905,7 @@ void Con_Print( const char *txt )
static char buf[MAX_PRINT_MSG];
qboolean norefresh = false;
static int lastlength = 0;
static qboolean inupdate;
static int bufpos = 0;
int c, mask = 0;
@@ -937,27 +996,6 @@ void Con_Print( const char *txt )
}
}
/*
================
Con_NXPrintfv
Draw a single debug line with specified height, color and time to live
================
*/
static void Con_NXPrintfv( keydest_t key_dest, const con_nprint_t *info, const char *fmt, va_list va )
{
if( info->index < 0 || info->index >= ARRAYSIZE( con.notify ))
return;
Q_vsnprintf( con.notify[info->index].szNotify, sizeof( con.notify[info->index].szNotify ), fmt, va );
// setup values
con.notify[info->index].key_dest = key_dest;
con.notify[info->index].expire = host.realtime + info->time_to_live;
MakeRGBA( con.notify[info->index].color, (byte)(info->color[0] * 255), (byte)(info->color[1] * 255), (byte)(info->color[2] * 255), 255 );
con.draw_notify = true;
}
/*
================
Con_NPrint
@@ -968,16 +1006,21 @@ Draw a single debug line with specified height
void GAME_EXPORT Con_NPrintf( int idx, const char *fmt, ... )
{
va_list args;
con_nprint_t info =
{
.index = idx,
.time_to_live = 4.0f,
.color = { 1.0f, 1.0f, 1.0f },
};
if( idx < 0 || idx >= MAX_DBG_NOTIFY )
return;
memset( con.notify[idx].szNotify, 0, MAX_STRING );
va_start( args, fmt );
Con_NXPrintfv( key_game, &info, fmt, args );
Q_vsnprintf( con.notify[idx].szNotify, MAX_STRING, fmt, args );
va_end( args );
// reset values
con.notify[idx].key_dest = key_game;
con.notify[idx].expire = host.realtime + 4.0f;
MakeRGBA( con.notify[idx].color, 255, 255, 255, 255 );
con.draw_notify = true;
}
/*
@@ -993,9 +1036,20 @@ void GAME_EXPORT Con_NXPrintf( con_nprint_t *info, const char *fmt, ... )
if( !info ) return;
if( info->index < 0 || info->index >= MAX_DBG_NOTIFY )
return;
memset( con.notify[info->index].szNotify, 0, MAX_STRING );
va_start( args, fmt );
Con_NXPrintfv( key_game, info, fmt, args );
Q_vsnprintf( con.notify[info->index].szNotify, MAX_STRING, fmt, args );
va_end( args );
// setup values
con.notify[info->index].key_dest = key_game;
con.notify[info->index].expire = host.realtime + info->time_to_live;
MakeRGBA( con.notify[info->index].color, (byte)(info->color[0] * 255), (byte)(info->color[1] * 255), (byte)(info->color[2] * 255), 255 );
con.draw_notify = true;
}
/*
@@ -1008,16 +1062,21 @@ Draw a single debug line with specified height (menu version)
void GAME_EXPORT UI_NPrintf( int idx, const char *fmt, ... )
{
va_list args;
con_nprint_t info =
{
.index = idx,
.time_to_live = 4.0f,
.color = { 1.0f, 1.0f, 1.0f },
};
if( idx < 0 || idx >= MAX_DBG_NOTIFY )
return;
memset( con.notify[idx].szNotify, 0, MAX_STRING );
va_start( args, fmt );
Con_NXPrintfv( key_menu, &info, fmt, args );
Q_vsnprintf( con.notify[idx].szNotify, MAX_STRING, fmt, args );
va_end( args );
// reset values
con.notify[idx].key_dest = key_menu;
con.notify[idx].expire = host.realtime + 4.0f;
MakeRGBA( con.notify[idx].color, 255, 255, 255, 255 );
con.draw_notify = true;
}
/*
@@ -1033,9 +1092,20 @@ void GAME_EXPORT UI_NXPrintf( con_nprint_t *info, const char *fmt, ... )
if( !info ) return;
if( info->index < 0 || info->index >= MAX_DBG_NOTIFY )
return;
memset( con.notify[info->index].szNotify, 0, MAX_STRING );
va_start( args, fmt );
Con_NXPrintfv( key_menu, info, fmt, args );
Q_vsnprintf( con.notify[info->index].szNotify, MAX_STRING, fmt, args );
va_end( args );
// setup values
con.notify[info->index].key_dest = key_menu;
con.notify[info->index].expire = host.realtime + info->time_to_live;
MakeRGBA( con.notify[info->index].color, (byte)(info->color[0] * 255), (byte)(info->color[1] * 255), (byte)(info->color[2] * 255), 255 );
con.draw_notify = true;
}
/*
@@ -1050,9 +1120,9 @@ EDIT FIELDS
Con_ClearField
================
*/
static void Con_ClearField( field_t *edit )
void Con_ClearField( field_t *edit )
{
memset( edit->buffer, 0, sizeof( edit->buffer ));
memset( edit->buffer, 0, MAX_STRING );
edit->cursor = 0;
edit->scroll = 0;
}
@@ -1065,7 +1135,7 @@ Field_Set
static void Field_Set( field_t *f, const char *string )
{
f->scroll = 0;
f->cursor = Q_strncpy( f->buffer, string, sizeof( f->buffer ));
f->cursor = Q_strncpy( f->buffer, string, MAX_STRING );
}
/*
@@ -1073,7 +1143,7 @@ static void Field_Set( field_t *f, const char *string )
Field_Paste
================
*/
static void Field_Paste( field_t *edit )
void Field_Paste( field_t *edit )
{
char *cbd;
int i, pasteLen;
@@ -1109,7 +1179,7 @@ in-game talk, and menu fields
Key events are used for non-printable characters, others are gotten from char events.
=================
*/
static void Field_KeyDownEvent( field_t *edit, int key )
void Field_KeyDownEvent( field_t *edit, int key )
{
int len;
@@ -1180,7 +1250,7 @@ static void Field_KeyDownEvent( field_t *edit, int key )
Field_CharEvent
==================
*/
static void Field_CharEvent( field_t *edit, int ch )
void Field_CharEvent( field_t *edit, int ch )
{
int len;
@@ -1241,7 +1311,7 @@ static void Field_CharEvent( field_t *edit, int ch )
Field_DrawInputLine
==================
*/
static void Field_DrawInputLine( int x, int y, field_t *edit )
void Field_DrawInputLine( int x, int y, field_t *edit )
{
int len, cursorChar;
int drawLen;
@@ -1371,49 +1441,36 @@ static void Con_HistoryAppend( con_history_t *self, field_t *from )
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;
file_t *fd;
int i;
fd = FS_Open( "console_history.txt", "rb", true );
if( !fd )
if( !aFile )
return;
while( !FS_Eof( fd ))
for( pFile = pLine = (char *)aFile; *pFile; pFile++ )
{
f = &self->lines[self->next % CON_HISTORY];
Con_ClearField( f );
f->widthInChars = con.linewidth;
FS_Gets( fd, f->buffer, sizeof( f->buffer ));
f->cursor = Q_strlen( f->buffer );
// skip empty lines
if( f->cursor == 0 )
if( *pFile != '\n' )
continue;
// skip repeating lines
if( self->next > 0 )
{
field_t *prev;
prev = &self->lines[(self->next - 1) % CON_HISTORY];
if( !Q_stricmp( prev->buffer, f->buffer ))
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++;
}
FS_Close( fd );
pLine = pFile + 1;
}
for( i = self->next; i < CON_HISTORY; i++ )
{
f = &self->lines[i];
Con_ClearField( f );
f->widthInChars = con.linewidth;
Con_ClearField( &self->lines[i] );
self->lines[i].widthInChars = con.linewidth;
}
self->line = self->next;
@@ -1431,18 +1488,10 @@ static void Con_SaveHistory( con_history_t *self )
if( historyStart < 0 )
historyStart = 0;
f = FS_Open( "console_history.txt", "wb", true );
f = FS_Open( "console_history.txt", "w", true );
for( i = historyStart; i < self->next; i++ )
{
const char *s = self->lines[i % CON_HISTORY].buffer;
// HACKHACK: don't save lines that have something that looks like a password
if( Q_stristr( s, "password" ) || Q_stristr( s, "_pw" ))
continue;
FS_Printf( f, "%s\n", s );
}
FS_Printf( f, "%s\n", self->lines[i % CON_HISTORY].buffer );
FS_Close( f );
}
@@ -1484,9 +1533,6 @@ void Key_Console( int key )
Con_Printf( ">%s\n", con.input.buffer );
// copy line to history buffer
// just in case, remove all CR and LF characters pushing it to the history
// not sure how they get even added in the first place
COM_RemoveLineFeed( con.input.buffer, sizeof( con.input.buffer ));
Con_HistoryAppend( &con.history, &con.input );
Con_ClearField( &con.input );
@@ -1637,7 +1683,7 @@ Con_DrawInput
The input line scrolls horizontally if typing goes beyond the right edge
================
*/
static void Con_DrawInput( int lines )
void Con_DrawInput( int lines )
{
int y;
@@ -1657,7 +1703,7 @@ Con_DrawDebugLines
Custom debug messages
================
*/
static int Con_DrawDebugLines( void )
int Con_DrawDebugLines( void )
{
notify_t *notify = con.notify;
int i, count = 0;
@@ -1742,7 +1788,7 @@ Con_DrawNotify
Draws the last few lines of output transparently over the game top
================
*/
static void Con_DrawNotify( void )
void Con_DrawNotify( void )
{
double time = cl.time;
int i, x, y = 0;
@@ -1753,7 +1799,7 @@ static void Con_DrawNotify( void )
if( host.allow_console && ( !Cvar_VariableInteger( "cl_background" ) && !Cvar_VariableInteger( "sv_background" )))
{
for( i = Q_max( 0, CON_LINES_COUNT - con.num_times ); i < CON_LINES_COUNT; i++ )
for( i = CON_LINES_COUNT - con.num_times; i < CON_LINES_COUNT; i++ )
{
con_lineinfo_t *l = &CON_LINES( i );
@@ -1794,7 +1840,7 @@ If alpha is 0, the line is not drawn, but still wrapped and its height
returned.
================
*/
static int Con_DrawConsoleLine( int y, int lineno )
int Con_DrawConsoleLine( int y, int lineno )
{
con_lineinfo_t *li = &CON_LINES( lineno );
@@ -1849,7 +1895,7 @@ Con_DrawConsole
Draws the console with the solid background
================
*/
static void Con_DrawSolidConsole( int lines )
void Con_DrawSolidConsole( int lines )
{
int i, x, y;
float fraction;
@@ -2051,13 +2097,9 @@ void Con_RunConsole( void )
// decide on the destination height of the console
if( host.allow_console && cls.key_dest == key_console )
{
#if XASH_MOBILE_PLATFORM
con.showlines = refState.height; // always full screen on mobile devices
#else
if( cls.state < ca_active || cl.first_frame )
con.showlines = refState.height; // full screen
else con.showlines = (refState.height >> 1); // half screen
#endif
}
else con.showlines = 0; // none visible
@@ -2095,7 +2137,7 @@ void Con_RunConsole( void )
g_codepage = 1252;
}
cls.accept_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
g_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
Con_InvalidateFonts();
Con_LoadConchars();
ClearBits( con_charset.flags, FCVAR_CHANGED );
@@ -2133,34 +2175,6 @@ void Con_CharEvent( int key )
}
}
static int Con_LoadSimpleConback( const char *name, int flags )
{
const char *paths[] = {
"gfx/shell/%s.dds",
"gfx/shell/%s.bmp",
"gfx/shell/%s.tga",
"cached/%s640",
"cached/%s",
};
size_t i;
for( i = 0; i < ARRAYSIZE( paths ); i++ )
{
string path;
Q_snprintf( path, sizeof( path ), paths[i], name );
if( g_fsapi.FileExists( path, false ))
{
int gl_texturenum = ref.dllFuncs.GL_LoadTexture( path, NULL, 0, flags );
if( gl_texturenum )
return gl_texturenum;
}
}
return 0;
}
/*
=========
Con_VidInit
@@ -2170,8 +2184,6 @@ INTERNAL RESOURCE
*/
void Con_VidInit( void )
{
const uint flags = TF_IMAGE|TF_ALLOW_NEAREST;
if( !con.historyLoaded )
{
Con_LoadHistory( &con.history );
@@ -2183,12 +2195,38 @@ void Con_VidInit( void )
Con_LoadConchars();
Con_CheckResize();
#if XASH_LOW_MEMORY
con.background = R_GetBuiltinTexture( REF_GRAY_TEXTURE );
#if XASH_LOW_MEMORY && !XASH_PSP
con.background = R_GetBuiltinTexture( REF_BLACK_TEXTURE );
#else
// loading console image
con.background = Con_LoadSimpleConback( host.allow_console ? "conback" : "loading", flags );
if( host.allow_console )
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/conback.bmp", false ) || FS_FileExists( "gfx/shell/conback.tga", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
if( !con.background )
{
if( FS_FileExists( "cached/conback640", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/conback", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
}
}
else
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/loading.bmp", false ) || FS_FileExists( "gfx/shell/loading.tga", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
if( !con.background )
{
if( FS_FileExists( "cached/loading640", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/loading", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
}
}
if( !con.background ) // last chance - quake conback image
{
@@ -2272,20 +2310,11 @@ Con_DefaultColor
called from MainUI
=========
*/
void Con_DefaultColor( int r, int g, int b, qboolean gameui )
void GAME_EXPORT Con_DefaultColor( int r, int g, int b )
{
r = bound( 0, r, 255 );
g = bound( 0, g, 255 );
b = bound( 0, b, 255 );
// gameui wants to override console color... check if it's not default
if( gameui && ( g_color_table[7][0] != r || g_color_table[7][1] != g || g_color_table[7][2] != b ))
{
// yes, different from default orange, disable con_color
SetBits( con_color.flags, FCVAR_READ_ONLY );
ClearBits( con_color.flags, FCVAR_CHANGED );
}
MakeRGBA( g_color_table[7], r, g, b, 255 );
}

View File

@@ -21,7 +21,6 @@ GNU General Public License for more details.
//-----------------------------------------------------------------------------
// Gamma conversion support
//-----------------------------------------------------------------------------
static qboolean gamma_rebuilt;
static byte texgammatable[256];
static uint lightgammatable[1024];
static uint lineargammatable[1024];
@@ -83,6 +82,9 @@ static void BuildGammaTable( const float gamma, const float brightness, const fl
static void V_ValidateGammaCvars( void )
{
if( Host_IsLocalGame( ))
return;
if( v_gamma.value < 1.8f )
Cvar_DirectSet( &v_gamma, "1.8" );
else if( v_gamma.value > 3.0f )
@@ -100,13 +102,14 @@ static void V_ValidateGammaCvars( void )
if( v_brightness.value < 0.0f )
Cvar_DirectSet( &v_brightness, "0" );
else if( v_brightness.value > 3.0f )
Cvar_DirectSet( &v_brightness, "3" );
else if( v_brightness.value > 2.0f )
Cvar_DirectSet( &v_brightness, "2" );
}
void V_CheckGamma( void )
{
static qboolean dirty = false;
qboolean notify_refdll = false;
// because these cvars were defined as archive
// but wasn't doing anything useful
@@ -132,33 +135,20 @@ void V_CheckGamma( void )
V_ValidateGammaCvars();
dirty = false;
gamma_rebuilt = true;
BuildGammaTable( v_gamma.value, v_brightness.value, v_texgamma.value, v_lightgamma.value );
// force refdll to recalculate lightmaps
if( ref.initialized )
ref.dllFuncs.R_GammaChanged( false );
}
}
notify_refdll = true;
void V_CheckGammaEnd( void )
{
// don't reset changed flag if it was set during frame
// keep it for next frame
if( !gamma_rebuilt )
return;
gamma_rebuilt = false;
// keep the flags until the end of frame so client.dll will catch these changes
if( FBitSet( v_texgamma.flags|v_lightgamma.flags|v_brightness.flags|v_gamma.flags, FCVAR_CHANGED ))
{
// unfortunately, recalculating textures isn't possible yet
ClearBits( v_texgamma.flags, FCVAR_CHANGED );
ClearBits( v_lightgamma.flags, FCVAR_CHANGED );
ClearBits( v_brightness.flags, FCVAR_CHANGED );
ClearBits( v_gamma.flags, FCVAR_CHANGED );
}
if( notify_refdll && ref.initialized )
ref.dllFuncs.R_GammaChanged( false );
}
void V_Init( void )

View File

@@ -134,7 +134,7 @@ static void Joy_ProcessTrigger( const engineAxis_t engineAxis, short value )
trigThreshold = joy_lt_threshold.value;
break;
default:
Con_Reportf( S_ERROR "%s: invalid axis = %i\n", __func__, engineAxis );
Con_Reportf( S_ERROR "Joy_ProcessTrigger: invalid axis = %i", engineAxis );
break;
}
@@ -205,7 +205,7 @@ static void Joy_ProcessStick( const engineAxis_t engineAxis, short value )
case JOY_AXIS_PITCH: deadzone = joy_pitch_deadzone.value; break;
case JOY_AXIS_YAW: deadzone = joy_yaw_deadzone.value; break;
default:
Con_Reportf( S_ERROR "%s: invalid axis = %i\n", __func__, engineAxis );
Con_Reportf( S_ERROR "Joy_ProcessStick: invalid axis = %i", engineAxis );
break;
}
@@ -218,7 +218,7 @@ static void Joy_ProcessStick( const engineAxis_t engineAxis, short value )
// fwd/side axis simulate hat movement
if( ( engineAxis == JOY_AXIS_SIDE || engineAxis == JOY_AXIS_FWD ) &&
( cls.key_dest == key_menu || cls.key_dest == key_console ))
( CL_IsInMenu() || CL_IsInConsole() ) )
{
int val = 0;

View File

@@ -19,6 +19,24 @@ GNU General Public License for more details.
#include "vgui_draw.h"
#include "mobility_int.h"
#ifdef XASH_NO_TOUCH
void Touch_WriteConfig( void ) {}
void Touch_SetClientOnly( qboolean state ) {}
void Touch_RemoveButton( const char *name ) {}
void Touch_HideButtons( const char *name, byte hide ) {}
void Touch_AddClientButton( const char *name, const char *texture, const char *command, float x1, float y1, float x2, float y2, byte *color, int round, float aspect, int flags ) {}
void Touch_AddDefaultButton( const char *name, const char *texturefile, const char *command, float x1, float y1, float x2, float y2, byte *color, int round, float aspect, int flags ) {}
void Touch_ResetDefaultButtons( void ){}
void Touch_Init( void ) {}
void Touch_Draw( void ) {}
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy ) { return 0; }
void Touch_GetMove( float *forward, float *side, float *yaw, float *pitch ) {}
void Touch_KeyEvent( int key, int down ) {}
void Touch_Shutdown( void ) {}
#else /* XASH_NO_TOUCH */
typedef enum
{
touch_command, // just tap a button
@@ -142,7 +160,7 @@ static struct touch_s
touchdefaultbutton_t g_DefaultButtons[256];
int g_LastDefaultButton;
static CVAR_DEFINE_AUTO( touch_in_menu, "0", FCVAR_PRIVILEGED, "draw touch in menu (for internal use only)" );
static CVAR_DEFINE_AUTO( touch_in_menu, "0", FCVAR_FILTERABLE, "draw touch in menu (for internal use only)" );
static CVAR_DEFINE_AUTO( touch_forwardzone, "0.06", FCVAR_FILTERABLE, "forward touch zone" );
static CVAR_DEFINE_AUTO( touch_sidezone, "0.06", FCVAR_FILTERABLE, "side touch zone" );
static CVAR_DEFINE_AUTO( touch_pitch, "90", FCVAR_FILTERABLE, "touch pitch sensitivity" );
@@ -163,8 +181,8 @@ static CVAR_DEFINE_AUTO( touch_dpad_radius, "1.0", FCVAR_FILTERABLE, "dpad radiu
static CVAR_DEFINE_AUTO( touch_joy_radius, "1.0", FCVAR_FILTERABLE, "joy radius multiplier" );
static CVAR_DEFINE_AUTO( touch_move_indicator, "0.0", FCVAR_FILTERABLE, "indicate move events (0 to disable)" );
static CVAR_DEFINE_AUTO( touch_joy_texture, "touch_default/joy", FCVAR_FILTERABLE, "texture for move indicator");
static CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "emulate touch with mouse" );
CVAR_DEFINE_AUTO( touch_enable, DEFAULT_TOUCH_ENABLE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable touch controls" );
CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "emulate touch with mouse" );
// code looks smaller with it
#define B(x) (button->x)
@@ -252,7 +270,7 @@ Touch_DumpConfig
Dump config to file
=================
*/
static qboolean Touch_DumpConfig( const char *name, const char *profilename )
qboolean Touch_DumpConfig( const char *name, const char *profilename )
{
file_t *f;
touch_button_t *button;
@@ -333,7 +351,7 @@ void Touch_WriteConfig( void )
if( Sys_CheckParm( "-nowriteconfig" ) || !touch.configchanged || !touch.config_loaded )
return;
Con_DPrintf( "%s: %s\n", __func__, touch_config_file.string );
Con_DPrintf( "Touch_WriteConfig(): %s\n", touch_config_file.string );
Q_snprintf( newconfigfile, sizeof( newconfigfile ), "%s.new", touch_config_file.string );
Q_snprintf( oldconfigfile, sizeof( oldconfigfile ), "%s.bak", touch_config_file.string );
@@ -767,18 +785,14 @@ static void Touch_ReloadConfig_f( void )
touch.state = state_none;
if( touch.edit )
touch.edit->finger = -1;
if( touch.selection )
touch.selection->finger = -1;
touch.edit = touch.selection = NULL;
touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1;
if( touch_in_menu.value )
Cvar_DirectSet( &touch_in_menu, "0" );
if( FS_FileExists( touch_config_file.string, true ))
if( FS_FileExists( touch_config_file.string, true ) )
{
Cbuf_AddTextf( "exec \"%s\"\n", touch_config_file.string );
}
else
{
Touch_LoadDefaults_f();
@@ -1014,7 +1028,7 @@ static void Touch_DisableEdit_f( void )
{
Cvar_Set( "touch_in_menu", "0" );
}
else if( cls.key_dest == key_game )
else if( cls.key_dest == key_game )
Touch_WriteConfig();
}
@@ -1068,7 +1082,7 @@ void Touch_Init( void )
return;
touch.mempool = Mem_AllocPool( "Touch" );
//touch.first = touch.last = NULL;
Con_Printf( "%s()\n", __func__ );
Con_Printf( "IN_TouchInit()\n");
touch.move_finger = touch.resize_finger = touch.look_finger = touch.wheel_finger = -1;
touch.state = state_none;
touch.showeditbuttons = true;
@@ -1091,19 +1105,18 @@ void Touch_Init( void )
Touch_AddDefaultButton( "jump", "touch_default/jump", "+jump", 0.880000, 0.227228, 1.000000, 0.454457, color, 2, 1, 0 );
Touch_AddDefaultButton( "attack", "touch_default/shoot", "+attack", 0.760000, 0.530200, 0.880000, 0.757428, color, 2, 1, 0 );
Touch_AddDefaultButton( "attack2", "touch_default/shoot_alt", "+attack2", 0.760000, 0.302971, 0.880000, 0.530200, color, 2, 1, 0 );
Touch_AddDefaultButton( "loadquick", "touch_default/load", "loadquick", 0.760000, 0.000000, 0.840000, 0.142222, color, 2, 1, 16 );
Touch_AddDefaultButton( "savequick", "touch_default/save", "savequick", 0.840000, 0.000000, 0.920000, 0.142222, color, 2, 1, 16 );
Touch_AddDefaultButton( "messagemode", "touch_default/keyboard", "messagemode", 0.840000, 0.000000, 0.920000, 0.142222, color, 2, 1, 8 );
Touch_AddDefaultButton( "loadquick", "touch_default/load", "loadquick", 0.680000, 0.000000, 0.760000, 0.151486, color, 2, 1, 16 );
Touch_AddDefaultButton( "savequick", "touch_default/save", "savequick", 0.760000, 0.000000, 0.840000, 0.151486, color, 2, 1, 16 );
Touch_AddDefaultButton( "messagemode", "touch_default/keyboard", "messagemode", 0.760000, 0.000000, 0.840000, 0.151486, color, 2, 1, 8 );
Touch_AddDefaultButton( "reload", "touch_default/reload", "+reload", 0.000000, 0.302971, 0.120000, 0.530200, color, 2, 1, 0 );
Touch_AddDefaultButton( "flashlight", "touch_default/flash_light_filled", "impulse 100", 0.920000, 0.000000, 1.000000, 0.151486, color, 2, 1, 0 );
Touch_AddDefaultButton( "scores", "touch_default/map", "+showscores", 0.760000, 0.000000, 0.840000, 0.142222, color, 2, 1, 8 );
Touch_AddDefaultButton( "scores", "touch_default/map", "+showscores", 0.680000, 0.000000, 0.760000, 0.151486, color, 2, 1, 8 );
Touch_AddDefaultButton( "show_numbers", "touch_default/show_weapons", "exec touch_default/numbers.cfg", 0.440000, 0.833171, 0.520000, 0.984656, color, 2, 1, 0 );
Touch_AddDefaultButton( "duck", "touch_default/crouch", "+duck", 0.880000, 0.757428, 1.000000, 0.984656, color, 2, 1, 0 );
Touch_AddDefaultButton( "tduck", "touch_default/tduck", ";+duck", 0.560000, 0.833171, 0.620000, 0.946785, color, 2, 1, 0 );
Touch_AddDefaultButton( "edit", "touch_default/settings", "touch_enableedit", 0.420000, 0.000000, 0.500000, 0.151486, color, 2, 1, 32 );
Touch_AddDefaultButton( "menu", "touch_default/menu", "escape", 0.000000, 0.833171, 0.080000, 0.984656, color, 2, 1, 0 );
Touch_AddDefaultButton( "spray", "touch_default/spray", "impulse 201", 0.680000, 0.000000, 0.760000, 0.142222, color, 2, 1, 8 );
Touch_AddDefaultButton( "voicechat", "touch_default/microphone", "+voicerecord", 0.780000, 0.817778, 0.860000, 0.960000, color, 2, 1, 8 );
Touch_AddDefaultButton( "spray", "touch_default/spray", "impulse 201", 0.840000, 0.000000, 0.920000, 0.151486, color, 2, 1, 0 );
Cmd_AddCommand( "touch_addbutton", Touch_AddButton_f, "add native touch button" );
Cmd_AddCommand( "touch_removebutton", IN_TouchRemoveButton_f, "remove native touch button" );
@@ -1222,10 +1235,10 @@ static qboolean Touch_IsVisible( touch_button_t *button )
if( FBitSet( button->flags, TOUCH_FL_HIDE ))
return false; // skip hidden
if( FBitSet( button->flags, TOUCH_FL_SP ) && cl.maxclients != 1 )
if( FBitSet( button->flags, TOUCH_FL_SP ) && CL_GetMaxClients() != 1 )
return false; // skip singleplayer(load, save) buttons in multiplayer
if( FBitSet( button->flags, TOUCH_FL_MP ) && cl.maxclients == 1 )
if( FBitSet( button->flags, TOUCH_FL_MP ) && CL_GetMaxClients() == 1 )
return false; // skip multiplayer buttons in singleplayer
return true;
@@ -1534,7 +1547,6 @@ void Touch_Draw( void )
ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( touch.move_start_x + touch.side * width - GRID_X * touch_move_indicator.value ),
TO_SCRN_Y( touch.move_start_y - touch.forward * height - GRID_Y * touch_move_indicator.value ),
TO_SCRN_X( GRID_X * 2 * touch_move_indicator.value ), TO_SCRN_Y( GRID_Y * 2 * touch_move_indicator.value ), 0, 0, 1, 1, touch.joytexture );
}
}
@@ -2034,18 +2046,10 @@ int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx
{
touch.move_finger = touch.resize_finger = touch.look_finger = -1;
// Hack for keyboard, hope it help
// a1ba: this is absolutely horrible
if( cls.key_dest == key_console || cls.key_dest == key_message )
{
static float x1 = 0.0f;
x1 += dx;
if( type == event_up ) // don't show keyboard on every tap
{
if ( type == event_down ) // don't pop it again on event_up
Key_EnableTextInput( true, true );
x1 = 0.0f;
}
if( cls.key_dest == key_console )
{
static float y1 = 0;
@@ -2067,13 +2071,6 @@ int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx
// exit of console area
if( type == event_down && x < 0.1f && y > 0.9f )
Cbuf_AddText( "escape\n" );
// swipe from edge to exit console/chat
if(( x > 0.8f && x1 < -0.1f ) || ( x < 0.2f && x1 > 0.1f ))
{
Cbuf_AddText( "escape\n" );
x1 = 0.0f;
}
}
UI_MouseMove( TO_SCRN_X(x), TO_SCRN_Y(y) );
//MsgDev( D_NOTE, "touch %d %d\n", TO_SCRN_X(x), TO_SCRN_Y(y) );
@@ -2127,7 +2124,7 @@ void Touch_KeyEvent( int key, int down )
float x, y;
int finger, xi, yi;
if( !Touch_Emulated( ))
if( !touch_emulate.value )
{
if( touch_enable.value )
return;
@@ -2168,7 +2165,8 @@ void Touch_KeyEvent( int key, int down )
x = xi / SCR_W;
y = yi / SCR_H;
// Con_DPrintf( "event %d %.2f %.2f %.2f %.2f\n", event, x, y, x - lx, y - ly );
Con_DPrintf( "event %d %.2f %.2f %.2f %.2f\n",
event, x, y, x - lx, y - ly );
IN_TouchEvent( event, finger, x, y, x - lx, y - ly );
@@ -2181,11 +2179,6 @@ qboolean Touch_WantVisibleCursor( void )
return ( touch_enable.value && touch_emulate.value ) || touch.clientonly;
}
qboolean Touch_Emulated( void )
{
return touch_emulate.value || touch_in_menu.value;
}
void Touch_Shutdown( void )
{
if( !touch.initialized )
@@ -2215,3 +2208,5 @@ void Touch_Shutdown( void )
touch.initialized = false;
Mem_FreePool( &touch.mempool );
}
#endif /* XASH_NO_TOUCH */

View File

@@ -17,7 +17,6 @@ GNU General Public License for more details.
#include "input.h"
#include "client.h"
#include "vgui_draw.h"
#include "cursor_type.h"
#if XASH_SDL
#include <SDL.h>
@@ -47,8 +46,6 @@ static CVAR_DEFINE_AUTO( cl_forwardspeed, "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL
static CVAR_DEFINE_AUTO( cl_backspeed, "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default back move speed" );
static CVAR_DEFINE_AUTO( cl_sidespeed, "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default side move speed" );
static CVAR_DEFINE_AUTO( m_grab_debug, "0", FCVAR_PRIVILEGED, "show debug messages on mouse state change" );
/*
================
IN_CollectInputDevices
@@ -63,8 +60,10 @@ uint IN_CollectInputDevices( void )
if( !m_ignore.value ) // no way to check is mouse connected, so use cvar only
ret |= INPUT_DEVICE_MOUSE;
#ifndef XASH_NO_TOUCH
if( touch_enable.value )
ret |= INPUT_DEVICE_TOUCH;
#endif
if( Joy_IsActive() ) // connected or enabled
ret |= INPUT_DEVICE_JOYSTICK;
@@ -94,13 +93,17 @@ void IN_LockInputDevices( qboolean lock )
{
SetBits( m_ignore.flags, FCVAR_READ_ONLY );
SetBits( joy_enable.flags, FCVAR_READ_ONLY );
#ifndef XASH_NO_TOUCH
SetBits( touch_enable.flags, FCVAR_READ_ONLY );
#endif
}
else
{
ClearBits( m_ignore.flags, FCVAR_READ_ONLY );
ClearBits( joy_enable.flags, FCVAR_READ_ONLY );
#ifndef XASH_NO_TOUCH
ClearBits( touch_enable.flags, FCVAR_READ_ONLY );
#endif
}
}
@@ -110,7 +113,7 @@ void IN_LockInputDevices( qboolean lock )
IN_StartupMouse
===========
*/
static void IN_StartupMouse( void )
void IN_StartupMouse( void )
{
Cvar_RegisterVariable( &m_ignore );
@@ -118,7 +121,6 @@ static void IN_StartupMouse( void )
Cvar_RegisterVariable( &m_yaw );
Cvar_RegisterVariable( &look_filter );
Cvar_RegisterVariable( &m_rawinput );
Cvar_RegisterVariable( &m_grab_debug );
// You can use -nomouse argument to prevent using mouse from client
// -noenginemouse will disable all mouse input
@@ -127,6 +129,11 @@ static void IN_StartupMouse( void )
in_mouseinitialized = true;
}
void GAME_EXPORT IN_SetCursor( void *hCursor )
{
// stub
}
/*
===========
IN_MouseSavePos
@@ -205,81 +212,68 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
}
}
static void IN_SetRelativeMouseMode( qboolean set, qboolean verbose )
void IN_CheckMouseState( qboolean active )
{
static qboolean s_bRawInput;
if( set && !s_bRawInput )
{
#if XASH_SDL == 2
SDL_GetRelativeMouseState( NULL, NULL );
SDL_SetRelativeMouseMode( SDL_TRUE );
#endif
s_bRawInput = true;
if( verbose )
Con_Printf( "%s: true\n", __func__ );
}
else if( !set && s_bRawInput )
{
#if XASH_SDL == 2
SDL_GetRelativeMouseState( NULL, NULL );
SDL_SetRelativeMouseMode( SDL_FALSE );
#endif
s_bRawInput = false;
if( verbose )
Con_Printf( "%s: false\n", __func__ );
}
}
static void IN_SetMouseGrab( qboolean set, qboolean verbose )
{
static qboolean s_bMouseGrab;
if( set && !s_bMouseGrab )
{
#if XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_TRUE );
#endif
s_bMouseGrab = true;
if( verbose )
Con_Printf( "%s: true\n", __func__ );
}
else if( !set && s_bMouseGrab )
{
#if XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#endif
s_bMouseGrab = false;
if( verbose )
Con_Printf( "%s: false\n", __func__ );
}
}
static void IN_CheckMouseState( qboolean active )
{
qboolean use_raw_input, verbose;
static qboolean s_bRawInput, s_bMouseGrab;
#if XASH_WIN32
use_raw_input = ( m_rawinput.value && clgame.client_dll_uses_sdl ) || clgame.dllFuncs.pfnLookEvent != NULL;
qboolean useRawInput = ( m_rawinput.value && clgame.client_dll_uses_sdl ) || clgame.dllFuncs.pfnLookEvent != NULL;
#else
use_raw_input = true; // always use SDL code
qboolean useRawInput = true; // always use SDL code
#endif
verbose = m_grab_debug.value ? true : false;
if( m_ignore.value )
active = false;
return;
if( active && use_raw_input && !host.mouse_visible && cls.state == ca_active )
IN_SetRelativeMouseMode( true, verbose );
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
IN_SetRelativeMouseMode( false, verbose );
{
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 )
IN_SetMouseGrab( true, verbose );
{
if( !s_bMouseGrab )
{
#if XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_TRUE );
#endif
// Con_Printf( "Enable grab\n" );
s_bMouseGrab = true;
}
}
else
IN_SetMouseGrab( false, verbose );
{
if( s_bMouseGrab )
{
#if XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#endif
// Con_Printf( "Disable grab\n" );
s_bMouseGrab = false;
}
}
}
/*
@@ -325,14 +319,14 @@ void IN_DeactivateMouse( void )
IN_MouseMove
================
*/
static void IN_MouseMove( void )
void IN_MouseMove( void )
{
int x, y;
if( !in_mouseinitialized )
return;
if( Touch_Emulated( ))
if( touch_emulate.value )
{
// touch emulation overrides all input
Touch_KeyEvent( 0, 0 );
@@ -363,11 +357,14 @@ void IN_MouseEvent( int key, int down )
else ClearBits( in_mstate, BIT( key ));
// touch emulation overrides all input
if( Touch_Emulated( ))
#if XASH_NO_TOUCH
if( touch_emulate.value )
{
Touch_KeyEvent( K_MOUSE1 + key, down );
}
else if( cls.key_dest == key_game )
else
#endif
if( cls.key_dest == key_game )
{
// perform button actions
VGui_MouseEvent( K_MOUSE1 + key, down );
@@ -376,8 +373,7 @@ void IN_MouseEvent( int key, int down )
// client may override IN_MouseEvent
// but by default it calls back to Key_Event anyway
if( in_mouseactive )
clgame.dllFuncs.IN_MouseEvent( in_mstate );
}
clgame.dllFuncs.IN_MouseEvent( in_mstate ); }
else
{
// perform button actions
@@ -600,7 +596,7 @@ void IN_EngineAppendMove( float frametime, void *cmd1, qboolean active )
}
}
static void IN_Commands( void )
void IN_Commands( void )
{
#if XASH_USE_EVDEV
IN_EvdevFrame();

View File

@@ -40,6 +40,7 @@ void IN_DeactivateMouse( void );
void IN_MouseSavePos( void );
void IN_MouseRestorePos( void );
void IN_ToggleClientMouse( int newstate, int oldstate );
void IN_SetCursor( void *hCursor );
uint IN_CollectInputDevices( void );
void IN_LockInputDevices( qboolean lock );
@@ -58,6 +59,7 @@ typedef enum
} touchEventType;
extern convar_t touch_enable;
extern convar_t touch_emulate;
void Touch_Draw( void );
void Touch_SetClientOnly( byte state );
@@ -73,7 +75,6 @@ void Touch_ResetDefaultButtons( void );
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy );
void Touch_KeyEvent( int key, int down );
qboolean Touch_WantVisibleCursor( void );
qboolean Touch_Emulated( void );
void Touch_NotifyResize( void );
//

View File

@@ -332,7 +332,7 @@ int Key_GetKey( const char *pBinding )
Key_Unbind_f
===================
*/
static void Key_Unbind_f( void )
void Key_Unbind_f( void )
{
int b;
@@ -358,7 +358,7 @@ static void Key_Unbind_f( void )
Key_Unbindall_f
===================
*/
static void Key_Unbindall_f( void )
void Key_Unbindall_f( void )
{
int i;
@@ -378,7 +378,7 @@ static void Key_Unbindall_f( void )
Key_Reset_f
===================
*/
static void Key_Reset_f( void )
void Key_Reset_f( void )
{
keyname_t *kn;
int i;
@@ -400,7 +400,7 @@ static void Key_Reset_f( void )
Key_Bind_f
===================
*/
static void Key_Bind_f( void )
void Key_Bind_f( void )
{
char cmd[1024];
int i, c, b;
@@ -473,7 +473,7 @@ Key_Bindlist_f
============
*/
static void Key_Bindlist_f( void )
void Key_Bindlist_f( void )
{
int i;
@@ -515,7 +515,6 @@ void Key_Init( void )
Cvar_RegisterVariable( &osk_enable );
Cvar_RegisterVariable( &key_rotate );
}
/*
@@ -523,7 +522,7 @@ void Key_Init( void )
Key_AddKeyCommands
===================
*/
static void Key_AddKeyCommands( int key, const char *kb, qboolean down )
void Key_AddKeyCommands( int key, const char *kb, qboolean down )
{
char button[1024];
char *buttonPtr;
@@ -553,7 +552,7 @@ static void Key_AddKeyCommands( int key, const char *kb, qboolean down )
}
buttonPtr = button;
while((((byte)kb[i]) <= ' ' || kb[i] == ';' ) && kb[i] != 0 )
while(( kb[i] <= ' ' || kb[i] == ';' ) && kb[i] != 0 )
i++;
}
@@ -703,7 +702,11 @@ void GAME_EXPORT Key_Event( int key, int down )
VGui_KeyEvent( key, down );
// console key is hardcoded, so the user can never unbind it
#if XASH_PSP
if( key == '`' || key == '~' || key == K_MODE_BUTTON )
#else
if( key == '`' || key == '~' )
#endif
{
// we are in typing mode, so don't switch to console
if( cls.key_dest == key_message || !down )
@@ -714,7 +717,11 @@ void GAME_EXPORT Key_Event( int key, int down )
}
// escape is always handled special
#if XASH_PSP
if( ( key == K_ESCAPE || key == K_START_BUTTON ) && down )
#else
if( key == K_ESCAPE && down )
#endif
{
switch( cls.key_dest )
{
@@ -749,10 +756,10 @@ void GAME_EXPORT Key_Event( int key, int down )
if( cls.key_dest == key_menu )
{
// only non printable keys passed
if( !gameui.use_extended_api )
if( !gameui.use_text_api )
Key_EnableTextInput( true, false );
//pass printable chars for old menus
if( !gameui.use_extended_api && !host.textmode && down && ( key >= 32 ) && ( key <= 'z' ) )
if( !gameui.use_text_api && !host.textmode && down && ( key >= 32 ) && ( key <= 'z' ) )
{
if( Key_IsDown( K_SHIFT ) )
{
@@ -840,7 +847,7 @@ void GAME_EXPORT Key_SetKeyDest( int key_dest )
cls.key_dest = key_message;
break;
default:
Host_Error( "%s: wrong destination (%i)\n", __func__, key_dest );
Host_Error( "Key_SetKeyDest: wrong destination (%i)\n", key_dest );
break;
}
}
@@ -881,7 +888,11 @@ Normal keyboard characters, already shifted / capslocked / etc
void CL_CharEvent( int key )
{
// the console key should never be used as a char
#if XASH_PSP
if( key == '`' || key == '~' || key == K_MODE_BUTTON ) return;
#else
if( key == '`' || key == '~' ) return;
#endif
if( cls.key_dest == key_console && !Con_Visible( ))
{
@@ -1006,7 +1017,11 @@ static qboolean OSK_KeyEvent( int key, int down )
if( osk.curbutton.val == 0 )
{
#if XASH_PSP
if( key == K_ENTER || key == K_A_BUTTON )
#else
if( key == K_ENTER )
#endif
{
osk.curbutton.val = osk_keylayout[osk.curlayout][osk.curbutton.y][osk.curbutton.x];
return true;
@@ -1017,6 +1032,9 @@ static qboolean OSK_KeyEvent( int key, int down )
switch ( key )
{
#if XASH_PSP
case K_A_BUTTON:
#endif
case K_ENTER:
switch( osk.curbutton.val )
{
@@ -1055,16 +1073,18 @@ static qboolean OSK_KeyEvent( int key, int down )
break;
}
ch = (byte)osk.curbutton.val;
// do not pass UTF-8 sequence into the engine, convert it here
if( !cls.accept_utf8 )
ch = Con_UtfProcessCharForce( ch );
if( !Q_stricmp( cl_charset.string, "utf-8" ) )
ch = (unsigned char)osk.curbutton.val;
else
ch = Con_UtfProcessCharForce( (unsigned char)osk.curbutton.val );
if( !ch )
break;
CL_CharEvent( ch );
Con_CharEvent( ch );
if( cls.key_dest == key_menu )
UI_CharEvent ( ch );
break;
}
}
@@ -1119,6 +1139,7 @@ static void OSK_EnableTextInput( qboolean enable, qboolean force )
{
osk.curlayout = 0;
osk.curbutton.val = osk_keylayout[osk.curlayout][osk.curbutton.y][osk.curbutton.x];
}
}

View File

@@ -74,7 +74,7 @@ static void free_winding( winding_t *w )
{
// simple sentinel by Carmack
if( *(unsigned *)w == 0xDEADC0DE )
Host_Error( "%s: freed a freed winding\n", __func__ );
Host_Error( "free_winding: freed a freed winding\n" );
*(unsigned *)w = 0xDEADC0DE;
free( w );
}
@@ -154,7 +154,7 @@ static winding_t *winding_for_plane( const mplane_t *p )
vup[0] = 1;
break;
default:
Host_Error( "%s: no axis found\n", __func__ );
Host_Error( "BaseWindingForPlane: no axis found\n" );
return NULL;
}
@@ -685,9 +685,6 @@ void Mod_CreatePolygonsForHull( int hullnum )
if( hullnum < 1 || hullnum > 3 )
return;
if( !world.num_hull_models )
Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc)
Con_Printf( "generating polygons for hull %u...\n", hullnum );
start = Sys_DoubleTime();

View File

@@ -8,9 +8,7 @@
struct ref_state_s ref;
ref_globals_t refState;
static const char* r_skyBoxSuffix[SKYBOX_MAX_SIDES] = { "rt", "bk", "lf", "ft", "up", "dn" };
CVAR_DEFINE_AUTO( gl_vsync, "1", FCVAR_ARCHIVE, "enable vertical syncronization" );
CVAR_DEFINE_AUTO( gl_vsync, "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
CVAR_DEFINE_AUTO( r_showtextures, "0", FCVAR_CHEAT, "show all uploaded textures" );
CVAR_DEFINE_AUTO( r_adjust_fov, "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" );
CVAR_DEFINE_AUTO( r_decals, "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" );
@@ -51,102 +49,13 @@ void R_GetTextureParms( int *w, int *h, int texnum )
if( h ) *h = REF_GET_PARM( PARM_TEX_HEIGHT, texnum );
}
static qboolean CheckSkybox( const char *name, char out[SKYBOX_MAX_SIDES][MAX_STRING] )
{
static const char *skybox_ext[3] = { "dds", "tga", "bmp" };
static const char *skybox_delim[2] = { "", "_" }; // no space for HL style, underscore for Q1 style
int i;
// search for skybox images
for( i = 0; i < ARRAYSIZE( skybox_ext ); i++ )
{
int j;
for( j = 0; j < ARRAYSIZE( skybox_delim ); j++ )
{
int k, num_checked_sides = 0;
for( k = 0; k < SKYBOX_MAX_SIDES; k++ )
{
char sidename[MAX_VA_STRING];
Q_snprintf( sidename, sizeof( sidename ), "%s%s%s.%s", name, skybox_delim[j], r_skyBoxSuffix[k], skybox_ext[i] );
if( g_fsapi.FileExists( sidename, false ))
{
Q_strncpy( out[k], sidename, sizeof( out[k] ));
num_checked_sides++;
}
}
if( num_checked_sides == SKYBOX_MAX_SIDES )
return true; // image exists
}
}
return false;
}
void R_SetupSky( const char *name )
{
string loadname;
char sidenames[SKYBOX_MAX_SIDES][MAX_STRING];
int skyboxTextures[SKYBOX_MAX_SIDES] = { 0 };
int i, len;
qboolean result;
if( !COM_CheckString( name ))
{
ref.dllFuncs.R_SetupSky( NULL ); // unload skybox
return;
}
Q_snprintf( loadname, sizeof( loadname ), "gfx/env/%s", name );
COM_StripExtension( loadname );
// kill the underline suffix to find them manually later
len = Q_strlen( loadname );
if( loadname[len - 1] == '_' )
loadname[len - 1] = '\0';
result = CheckSkybox( loadname, sidenames );
// to prevent infinite recursion if default skybox was missed
if( !result && Q_stricmp( name, DEFAULT_SKYBOX_NAME ))
{
Con_Reportf( S_WARN "missed or incomplete skybox '%s'\n", name );
R_SetupSky( DEFAULT_SKYBOX_NAME ); // force to default
return;
}
ref.dllFuncs.R_SetupSky( NULL ); // unload skybox
Con_DPrintf( "SKY: " );
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
{
skyboxTextures[i] = ref.dllFuncs.GL_LoadTexture( sidenames[i], NULL, 0, TF_CLAMP|TF_SKY );
if( !skyboxTextures[i] )
break;
Con_DPrintf( "%s%s%s", name, r_skyBoxSuffix[i], i != 5 ? ", " : ". " );
}
if( i == SKYBOX_MAX_SIDES )
{
SetBits( world.flags, FWORLD_CUSTOM_SKYBOX );
Con_DPrintf( "done\n" );
ref.dllFuncs.R_SetupSky( skyboxTextures );
return; // loaded
}
Con_DPrintf( "^2failed\n" );
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
{
if( skyboxTextures[i] )
ref.dllFuncs.GL_FreeTexture( skyboxTextures[i] );
}
}
/*
================
GL_FreeImage
Frees image by name
================
*/
void GAME_EXPORT GL_FreeImage( const char *name )
{
int texnum;
@@ -171,22 +80,6 @@ static intptr_t pfnEngineGetParm( int parm, int arg )
return CL_RenderGetParm( parm, arg, false ); // prevent recursion
}
static cvar_t *pfnCvar_Get( const char *szName, const char *szValue, int flags, const char *description )
{
return (cvar_t *)Cvar_Get( szName, szValue, flags | FCVAR_REFDLL, description );
}
static void pfnCvar_RegisterVariable( convar_t *var )
{
SetBits( var->flags, FCVAR_REFDLL );
Cvar_RegisterVariable( var );
}
static void pfnCvar_FullSet( const char *var_name, const char *value, int flags )
{
Cvar_FullSet( var_name, value, flags | FCVAR_REFDLL );
}
static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
{
clgame.dllFuncs.pfnStudioEvent( event, e );
@@ -198,7 +91,7 @@ static model_t *pfnGetDefaultSprite( enum ref_defaultsprite_e spr )
{
case REF_DOT_SPRITE: return cl_sprite_dot;
case REF_CHROME_SPRITE: return cl_sprite_shell;
default: Host_Error( "%s: unknown sprite %d\n", __func__, spr );
default: Host_Error( "GetDefaultSprite: unknown sprite %d\n", spr );
}
return NULL;
}
@@ -211,17 +104,11 @@ static void *pfnMod_Extradata( int type, model_t *m )
case mod_studio: return Mod_StudioExtradata( m );
case mod_sprite: // fallthrough
case mod_brush: return NULL;
default: Host_Error( "%s: unknown type %d\n", __func__, type );
default: Host_Error( "Mod_Extradata: unknown type %d\n", type );
}
return NULL;
}
static void CL_ExtraUpdate( void )
{
clgame.dllFuncs.IN_Accumulate();
S_ExtraUpdate();
}
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
{
if( width ) *width = clgame.scrInfo.iWidth;
@@ -301,18 +188,18 @@ static qboolean R_Init_Video_( const int type )
return R_Init_Video( type );
}
static const ref_api_t gEngfuncs =
static ref_api_t gEngfuncs =
{
pfnEngineGetParm,
pfnCvar_Get,
(void*)Cvar_Get,
(void*)Cvar_FindVarExt,
Cvar_VariableValue,
Cvar_VariableString,
Cvar_SetValue,
Cvar_Set,
pfnCvar_RegisterVariable,
pfnCvar_FullSet,
Cvar_RegisterVariable,
Cvar_FullSet,
Cmd_AddRefCommand,
Cmd_RemoveCommand,
@@ -436,6 +323,10 @@ static const ref_api_t gEngfuncs =
&clgame.drawFuncs,
&g_fsapi,
#if XASH_PSP
P5Ram_Alloc,
P5Ram_Free,
#endif
};
static void R_UnloadProgs( void )
@@ -447,7 +338,7 @@ static void R_UnloadProgs( void )
Cvar_FullSet( "host_refloaded", "0", FCVAR_READ_ONLY );
Cvar_Unlink( FCVAR_RENDERINFO | FCVAR_GLCONFIG | FCVAR_REFDLL );
Cvar_Unlink( FCVAR_RENDERINFO | FCVAR_GLCONFIG );
Cmd_Unlink( CMD_REFDLL );
COM_FreeLibrary( ref.hInstance );
@@ -457,30 +348,6 @@ static void R_UnloadProgs( void )
memset( &ref.dllFuncs, 0, sizeof( ref.dllFuncs ));
}
static void CL_FillTriAPIFromRef( triangleapi_t *dst, const ref_interface_t *src )
{
dst->version = TRI_API_VERSION;
dst->Begin = src->Begin;
dst->RenderMode = TriRenderMode;
dst->End = src->End;
dst->Color4f = TriColor4f;
dst->Color4ub = TriColor4ub;
dst->TexCoord2f = src->TexCoord2f;
dst->Vertex3f = src->Vertex3f;
dst->Vertex3fv = src->Vertex3fv;
dst->Brightness = TriBrightness;
dst->CullFace = TriCullFace;
dst->SpriteTexture = TriSpriteTexture;
dst->WorldToScreen = TriWorldToScreen;
dst->Fog = src->Fog;
dst->ScreenToWorld = src->ScreenToWorld;
dst->GetMatrix = src->GetMatrix;
dst->BoxInPVS = TriBoxInPVS;
dst->LightAtPoint = TriLightAtPoint;
dst->Color4fRendermode = TriColor4fRendermode;
dst->FogParams = src->FogParams;
}
static qboolean R_LoadProgs( const char *name )
{
static ref_api_t gpEngfuncs;
@@ -489,44 +356,56 @@ static qboolean R_LoadProgs( const char *name )
if( ref.hInstance ) R_UnloadProgs();
FS_AllowDirectPaths( true );
if( !( ref.hInstance = COM_LoadLibrary( name, false, true )))
if( !(ref.hInstance = COM_LoadLibrary( name, false, true ) ))
{
FS_AllowDirectPaths( false );
Con_Reportf( "%s: can't load renderer library %s: %s\n", __func__, name, COM_GetLibraryError() );
Con_Reportf( "R_LoadProgs: can't load renderer library %s: %s\n", name, COM_GetLibraryError() );
return false;
}
FS_AllowDirectPaths( false );
if( !( GetRefAPI = (REFAPI)COM_GetProcAddress( ref.hInstance, GET_REF_API )))
if( !( GetRefAPI = (REFAPI)COM_GetProcAddress( ref.hInstance, GET_REF_API )) )
{
Con_Reportf( "%s: can't find GetRefAPI entry point in %s\n", __func__, name );
COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't find GetRefAPI entry point in %s\n", name );
ref.hInstance = NULL;
return false;
}
// make local copy of engfuncs to prevent overwrite it with user dll
gpEngfuncs = gEngfuncs;
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
if( GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ) != REF_API_VERSION )
{
Con_Reportf( "%s: can't init renderer API: wrong version\n", __func__ );
COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" );
ref.hInstance = NULL;
return false;
}
refState.developer = host_developer.value;
if( !ref.dllFuncs.R_Init( ))
if( !ref.dllFuncs.R_Init( ) )
{
Con_Reportf( "%s: can't init renderer!\n", __func__ ); //, ref.dllFuncs.R_GetInitError() );
COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't init renderer!\n" ); //, ref.dllFuncs.R_GetInitError() );
ref.hInstance = NULL;
return false;
}
// initialize TriAPI callbacks
if( !ref.dllFuncs.getTriAPI( TRI_API_VERSION, &gTriApi ))
{
COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't init TriAPI Interface: wrong version, %i must be %i\n", gTriApi.version, TRI_API_VERSION );
ref.hInstance = NULL;
return false;
}
Cvar_FullSet( "host_refloaded", "1", FCVAR_READ_ONLY );
ref.initialized = true;
// initialize TriAPI callbacks
CL_FillTriAPIFromRef( &gTriApi, &ref.dllFuncs );
return true;
}
@@ -554,19 +433,21 @@ static void R_GetRendererName( char *dest, size_t size, const char *opt )
{
if( !Q_strstr( opt, "." OS_LIB_EXT ))
{
const char *format;
#ifdef XASH_INTERNAL_GAMELIBS
#define FMT1 "%s"
#define FMT2 "ref_%s"
#else
#define FMT1 OS_LIB_PREFIX "%s." OS_LIB_EXT
#define FMT2 OS_LIB_PREFIX "ref_%s." OS_LIB_EXT
#endif
if( !Q_strncmp( opt, "ref_", 4 ))
Q_snprintf( dest, size, FMT1, opt );
if( !Q_strcmp( opt, "ref_" ))
format = "%s";
else
Q_snprintf( dest, size, FMT2, opt );
#undef FMT1
#undef FMT2
format = "ref_%s";
#else
if( !Q_strcmp( opt, "ref_" ))
format = OS_LIB_PREFIX "%s." OS_LIB_EXT;
else
format = OS_LIB_PREFIX "ref_%s." OS_LIB_EXT;
#endif
Q_snprintf( dest, size, format, opt );
}
else
{
@@ -663,7 +544,7 @@ static void R_CollectRendererNames( void )
"GL4ES",
#endif
#if XASH_REF_GLES3COMPAT_ENABLED
"GLES3 (gl2_shim)",
"GLES3 (gl2_shim)"
#endif
#if XASH_REF_SOFT_ENABLED
"Software",
@@ -678,8 +559,7 @@ static void R_CollectRendererNames( void )
qboolean R_Init( void )
{
qboolean success = false;
string requested_cmdline;
string requested_cvar;
string requested;
Cvar_RegisterVariable( &gl_vsync );
Cvar_RegisterVariable( &r_showtextures );
@@ -710,7 +590,6 @@ qboolean R_Init( void )
// cvars that are expected to exist by client.dll
// refdll should just get pointer to them
Cvar_Get( "r_lighting_modulate", "0.6", FCVAR_ARCHIVE, "compatibility cvar, does nothing" );
Cvar_Get( "r_drawentities", "1", FCVAR_CHEAT, "render entities" );
Cvar_Get( "cl_himodels", "1", FCVAR_ARCHIVE, "draw high-resolution player models in multiplayer" );
@@ -729,16 +608,15 @@ qboolean R_Init( void )
// 1. Command line `-ref` argument.
// 2. `ref_dll` cvar.
// 3. Detected renderers in `DEFAULT_RENDERERS` order.
requested_cmdline[0] = 0;
requested_cvar[0] = 0;
requested[0] = 0;
if( Sys_GetParmFromCmdLine( "-ref", requested_cmdline ))
success = R_LoadRenderer( requested_cmdline );
if( !success && Sys_GetParmFromCmdLine( "-ref", requested ))
success = R_LoadRenderer( requested );
if( !success && COM_CheckString( r_refdll.string ) && Q_stricmp( requested_cmdline, r_refdll.string ))
if( !success && COM_CheckString( r_refdll.string ))
{
Q_strncpy( requested_cvar, r_refdll.string, sizeof( requested_cvar ));
success = R_LoadRenderer( requested_cvar );
Q_strncpy( requested, r_refdll.string, sizeof( requested ));
success = R_LoadRenderer( requested );
}
if( !success )
@@ -748,10 +626,7 @@ qboolean R_Init( void )
for( i = 0; i < ref.numRenderers && !success; i++ )
{
// skip renderer that was requested but failed to load
if( !Q_strcmp( requested_cmdline, ref.shortNames[i] ))
continue;
if( !Q_strcmp( requested_cvar, ref.shortNames[i] ))
if( !Q_strcmp( requested, ref.shortNames[i] ))
continue;
success = R_LoadRenderer( ref.shortNames[i] );
@@ -760,7 +635,7 @@ qboolean R_Init( void )
if( !success )
{
Sys_Error( "Can't initialize any renderer. Check your video drivers!\n" );
Host_Error( "Can't initialize any renderer. Check your video drivers!\n" );
return false;
}

View File

@@ -18,18 +18,19 @@ GNU General Public License for more details.
#include "ref_api.h"
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
struct ref_state_s
{
HINSTANCE hInstance;
qboolean initialized;
int numRenderers;
qboolean initialized;
HINSTANCE hInstance;
ref_interface_t dllFuncs;
// depends on build configuration
const char **shortNames;
const char **readableNames;
int numRenderers;
const char **shortNames;
const char **readableNames;
};
extern struct ref_state_s ref;
@@ -44,14 +45,14 @@ void R_GetTextureParms( int *w, int *h, int texnum );
void GL_RenderFrame( const struct ref_viewpass_s *rvp );
void R_SetupSky( const char *name );
// common engine and renderer cvars
extern convar_t r_decals;
extern convar_t r_adjust_fov;
extern convar_t r_decals;
extern convar_t r_adjust_fov;
extern convar_t gl_clear;
qboolean R_Init( void );
void R_Shutdown( void );
extern triangleapi_t gTriApi;
#endif // REF_COMMON_H

View File

@@ -154,8 +154,7 @@ static const sx_preset_t rgsxpre_hlalpha052[] =
static const sx_preset_t *ptable = rgsxpre;
// cvars
static CVAR_DEFINE_AUTO( dsp_off, "0", FCVAR_ARCHIVE, "disable DSP processing (deprecated)" );
static CVAR_DEFINE_AUTO( room_off, "0", FCVAR_ARCHIVE, "disable DSP processing (GoldSrc compatible cvar)" );
static CVAR_DEFINE_AUTO( dsp_off, "0", FCVAR_ARCHIVE, "disable DSP processing" );
static CVAR_DEFINE_AUTO( dsp_coeff_table, "0", FCVAR_ARCHIVE, "select DSP coefficient table: 0 for release or 1 for alpha 0.52" );
static CVAR_DEFINE_AUTO( room_type, "0", 0, "current room type preset" );
@@ -233,7 +232,6 @@ void SX_Init( void )
sxmod2cur = sxmod2 = 450 * ( idsp_dma_speed / SOUND_11k );
Cvar_RegisterVariable( &dsp_off );
Cvar_RegisterVariable( &room_off );
Cvar_RegisterVariable( &dsp_coeff_table );
Cvar_RegisterVariable( &roomwater_type );
@@ -811,7 +809,7 @@ DSP_Process
*/
void DSP_Process( portable_samplepair_t *pbfront, int sampleCount )
{
if( dsp_off.value || room_off.value || !sampleCount )
if( dsp_off.value || !sampleCount )
return;
// preset is already installed by CheckNewDspPresets
@@ -845,7 +843,7 @@ CheckNewDspPresets
*/
void CheckNewDspPresets( void )
{
if( dsp_off.value || room_off.value )
if( dsp_off.value != 0.0f )
return;
if( FBitSet( dsp_coeff_table.flags, FCVAR_CHANGED ))

View File

@@ -21,7 +21,11 @@ GNU General Public License for more details.
// than could actually be referenced during gameplay,
// because we don't want to free anything until we are
// sure we won't need it.
#if XASH_PSP
#define MAX_SFX 2048
#else
#define MAX_SFX 8192
#endif
#define MAX_SFX_HASH (MAX_SFX/4)
static int s_numSfx = 0;
@@ -52,11 +56,8 @@ void S_SoundList_f( void )
{
totalSize += sc->size;
if( FBitSet( sc->flags, SOUND_LOOPED ))
Con_Printf( "L" );
else
Con_Printf( " " );
if( sc->loopStart >= 0 ) Con_Printf( "L" );
else Con_Printf( " " );
if( sfx->name[0] == '*' || !Q_strncmp( sfx->name, DEFAULT_SOUNDPATH, sizeof( DEFAULT_SOUNDPATH ) - 1 ))
Con_Printf( " (%2db) %s : %s\n", sc->width * 8, Q_memprint( sc->size ), sfx->name );
else Con_Printf( " (%2db) %s : " DEFAULT_SOUNDPATH "%s\n", sc->width * 8, Q_memprint( sc->size ), sfx->name );
@@ -113,7 +114,7 @@ static wavdata_t *S_CreateDefaultSound( void )
sc->width = 2;
sc->channels = 1;
sc->loopStart = 0;
sc->loopStart = -1;
sc->rate = SOUND_DMA_SPEED;
sc->samples = SOUND_DMA_SPEED;
sc->size = sc->samples * sc->width * sc->channels;
@@ -144,8 +145,8 @@ wavdata_t *S_LoadSound( sfx_t *sfx )
if( Q_stricmp( sfx->name, "*default" ))
{
// load it from disk
if( s_warn_late_precache.value > 0 && cls.state == ca_active )
Con_Printf( S_WARN "%s: late precache of %s\n", __func__, sfx->name );
if( s_warn_late_precache.value > 0 && CL_Active() )
Con_Printf( S_WARN "S_LoadSound: late precache of %s\n", sfx->name );
if( sfx->name[0] == '*' )
sc = FS_LoadSound( sfx->name + 1, NULL, 0 );
@@ -155,11 +156,11 @@ wavdata_t *S_LoadSound( sfx_t *sfx )
if( !sc ) sc = S_CreateDefaultSound();
if( sc->rate < SOUND_11k ) // some bad sounds
Sound_Process( &sc, SOUND_11k, sc->width, sc->channels, SOUND_RESAMPLE );
Sound_Process( &sc, SOUND_11k, sc->width, SOUND_RESAMPLE );
else if( sc->rate > SOUND_11k && sc->rate < SOUND_22k ) // some bad sounds
Sound_Process( &sc, SOUND_22k, sc->width, sc->channels, SOUND_RESAMPLE );
else if( sc->rate > SOUND_22k && sc->rate < SOUND_44k ) // some bad sounds
Sound_Process( &sc, SOUND_44k, sc->width, sc->channels, SOUND_RESAMPLE );
Sound_Process( &sc, SOUND_22k, sc->width, SOUND_RESAMPLE );
else if( sc->rate > SOUND_22k && sc->rate <= SOUND_32k ) // some bad sounds
Sound_Process( &sc, SOUND_44k, sc->width, SOUND_RESAMPLE );
sfx->cache = sc;
@@ -221,7 +222,7 @@ sfx_t *S_FindName( const char *pname, int *pfInCache )
sfx = &s_knownSfx[i];
memset( sfx, 0, sizeof( *sfx ));
if( pfInCache ) *pfInCache = false;
Q_strncpy( sfx->name, name, sizeof( sfx->name ));
Q_strncpy( sfx->name, name, MAX_STRING );
sfx->servercount = cl.servercount;
sfx->hashValue = COM_HashKey( sfx->name, MAX_SFX_HASH );
@@ -380,7 +381,7 @@ S_InitSounds
void S_InitSounds( void )
{
// create unused 0-entry
Q_strncpy( s_knownSfx->name, "*default", sizeof( s_knownSfx->name ));
Q_strncpy( s_knownSfx->name, "*default", MAX_QPATH );
s_knownSfx->hashValue = COM_HashKey( s_knownSfx->name, MAX_SFX_HASH );
s_knownSfx->hashNext = s_sfxHashList[s_knownSfx->hashValue];
s_sfxHashList[s_knownSfx->hashValue] = s_knownSfx;

View File

@@ -64,12 +64,6 @@ float S_GetMasterVolume( void )
{
float scale = 1.0f;
if( host.status == HOST_NOFOCUS && snd_mute_losefocus.value != 0.0f )
{
// we return zero volume to keep sounds running
return 0.0f;
}
if( !s_listener.inmenu && soundfade.percent != 0 )
{
scale = bound( 0.0f, soundfade.percent / 100.0f, 1.0f );
@@ -97,7 +91,7 @@ void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime
S_IsClient
=================
*/
static qboolean S_IsClient( int entnum )
qboolean S_IsClient( int entnum )
{
return ( entnum == s_listener.entnum );
}
@@ -130,7 +124,7 @@ void S_FreeChannel( channel_t *ch )
S_UpdateSoundFade
=================
*/
static void S_UpdateSoundFade( void )
void S_UpdateSoundFade( void )
{
float f, totaltime, elapsed;
@@ -190,7 +184,7 @@ override any other sound playing on the same channel (see code comments below fo
exceptions).
=================
*/
static qboolean SND_FStreamIsPlaying( sfx_t *sfx )
qboolean SND_FStreamIsPlaying( sfx_t *sfx )
{
int ch_idx;
@@ -328,7 +322,7 @@ channel_t *SND_PickDynamicChannel( int entnum, int channel, sfx_t *sfx, qboolean
// don't restart looping sounds for the same entity
wavdata_t *sc = channels[first_to_die].sfx->cache;
if( sc && FBitSet( sc->flags, SOUND_LOOPED ))
if( sc && sc->loopStart != -1 )
{
channel_t *ch = &channels[first_to_die];
@@ -382,7 +376,7 @@ channel_t *SND_PickStaticChannel( const vec3_t pos, sfx_t *sfx )
// no empty slots, alloc a new static sound channel
if( total_channels == MAX_CHANNELS )
{
Con_DPrintf( S_ERROR "%s: no free channels\n", __func__ );
Con_DPrintf( S_ERROR "S_PickStaticChannel: no free channels\n" );
return NULL;
}
@@ -405,7 +399,7 @@ returns TRUE if sound was altered,
returns FALSE if sound was not found (sound is not playing)
=================
*/
static int S_AlterChannel( int entnum, int channel, sfx_t *sfx, int vol, int pitch, int flags )
int S_AlterChannel( int entnum, int channel, sfx_t *sfx, int vol, int pitch, int flags )
{
channel_t *ch;
int i;
@@ -463,7 +457,7 @@ static int S_AlterChannel( int entnum, int channel, sfx_t *sfx, int vol, int pit
S_SpatializeChannel
=================
*/
static void S_SpatializeChannel( int *left_vol, int *right_vol, int master_vol, float gain, float dot, float dist )
void S_SpatializeChannel( int *left_vol, int *right_vol, int master_vol, float gain, float dot, float dist )
{
float lscale, rscale, scale;
@@ -486,7 +480,7 @@ static void S_SpatializeChannel( int *left_vol, int *right_vol, int master_vol,
SND_Spatialize
=================
*/
static void SND_Spatialize( channel_t *ch )
void SND_Spatialize( channel_t *ch )
{
vec3_t source_vec;
float dist, dot, gain = 1.0f;
@@ -503,7 +497,7 @@ static void SND_Spatialize( channel_t *ch )
pSource = ch->sfx->cache;
if( ch->use_loop && pSource && FBitSet( pSource->flags, SOUND_LOOPED ))
if( ch->use_loop && pSource && pSource->loopStart != -1 )
looping = true;
if( !ch->staticsound )
@@ -524,11 +518,8 @@ static void SND_Spatialize( channel_t *ch )
dist = VectorNormalizeLength( source_vec );
dot = DotProduct( s_listener.right, source_vec );
if( !FBitSet( host.bugcomp, BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE ))
{
// don't pan sounds with no attenuation
if( ch->dist_mult <= 0.0f ) dot = 0.0f;
}
// don't pan sounds with no attenuation
if( ch->dist_mult <= 0.0f ) dot = 0.0f;
// fill out channel volumes for single location
S_SpatializeChannel( &ch->leftvol, &ch->rightvol, ch->master_vol, gain, dot, dist * ch->dist_mult );
@@ -644,7 +635,7 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
if( !target_chan->leftvol && !target_chan->rightvol )
{
// looping sounds don't use this optimization because they should stick around until they're killed.
if( !sfx->cache || !FBitSet( sfx->cache->flags, SOUND_LOOPED ))
if( !sfx->cache || sfx->cache->loopStart == -1 )
{
// if this is a streaming sound, play the whole thing.
if( chan != CHAN_STREAM )
@@ -896,7 +887,7 @@ int S_GetCurrentStaticSounds( soundlist_t *pout, int size )
VectorCopy( channels[i].origin, pout->origin );
pout->volume = (float)channels[i].master_vol / 255.0f;
pout->attenuation = channels[i].dist_mult * SND_CLIP_DISTANCE;
pout->looping = ( channels[i].use_loop && FBitSet( channels[i].sfx->cache->flags, SOUND_LOOPED ));
pout->looping = ( channels[i].use_loop && channels[i].sfx->cache->loopStart != -1 );
pout->pitch = channels[i].basePitch;
pout->channel = channels[i].entchannel;
pout->wordIndex = channels[i].wordIndex;
@@ -931,7 +922,7 @@ int S_GetCurrentDynamicSounds( soundlist_t *pout, int size )
if( !channels[i].sfx || !channels[i].sfx->name[0] || !Q_stricmp( channels[i].sfx->name, "*default" ))
continue; // don't serialize default sounds
looped = ( channels[i].use_loop && FBitSet( channels[i].sfx->cache->flags, SOUND_LOOPED ));
looped = ( channels[i].use_loop && channels[i].sfx->cache->loopStart != -1 );
if( channels[i].entchannel == CHAN_STATIC && looped && !Host_IsQuakeCompatible())
continue; // never serialize static looped sounds. It will be restoring in game code
@@ -962,7 +953,7 @@ int S_GetCurrentDynamicSounds( soundlist_t *pout, int size )
S_InitAmbientChannels
===================
*/
static void S_InitAmbientChannels( void )
void S_InitAmbientChannels( void )
{
int ambient_channel;
channel_t *chan;
@@ -984,7 +975,7 @@ static void S_InitAmbientChannels( void )
S_UpdateAmbientSounds
===================
*/
static void S_UpdateAmbientSounds( void )
void S_UpdateAmbientSounds( void )
{
mleaf_t *leaf;
float vol;
@@ -1095,7 +1086,7 @@ rawchan_t *S_FindRawChannel( int entnum, qboolean create )
if( !raw_channels[best] )
{
raw_samples = MAX_RAW_SAMPLES;
raw_channels[best] = Mem_Calloc( sndpool, sizeof( *ch ) + sizeof( portable_samplepair_t ) * raw_samples );
raw_channels[best] = Mem_Calloc( sndpool, sizeof( *ch ) + sizeof( portable_samplepair_t ) * ( raw_samples - 1 ));
}
ch = raw_channels[best];
@@ -1416,7 +1407,7 @@ static void S_FreeRawChannels( void )
S_ClearBuffer
==================
*/
static void S_ClearBuffer( void )
void S_ClearBuffer( void )
{
S_ClearRawChannels();
@@ -1515,7 +1506,7 @@ static int S_GetSoundtime( void )
}
//=============================================================================
static void S_UpdateChannels( void )
void S_UpdateChannels( void )
{
uint endtime;
int samps;
@@ -1602,10 +1593,11 @@ void SND_UpdateSound( void )
// release raw-channels that no longer used more than 10 secs
S_FreeIdleRawChannels();
VectorCopy( cl.simvel, s_listener.velocity );
s_listener.frametime = (cl.time - cl.oldtime);
s_listener.waterlevel = cl.local.waterlevel;
s_listener.active = CL_IsInGame();
s_listener.inmenu = cls.key_dest == key_menu;
s_listener.inmenu = CL_IsInMenu();
s_listener.paused = cl.paused;
// update general area ambient sound sources
@@ -1703,7 +1695,7 @@ console functions
===============================================================================
*/
static void S_Play_f( void )
void S_Play_f( void )
{
if( Cmd_Argc() == 1 )
{
@@ -1714,7 +1706,7 @@ static void S_Play_f( void )
S_StartLocalSound( Cmd_Argv( 1 ), VOL_NORM, false );
}
static void S_Play2_f( void )
void S_Play2_f( void )
{
int i = 1;
@@ -1731,7 +1723,7 @@ static void S_Play2_f( void )
}
}
static void S_PlayVol_f( void )
void S_PlayVol_f( void )
{
if( Cmd_Argc() == 1 )
{
@@ -1757,7 +1749,7 @@ static void S_Say( const char *name, qboolean reliable )
S_StartLocalSound( sentence, 1.0f, reliable );
}
static void S_Say_f( void )
void S_Say_f( void )
{
if( Cmd_Argc() == 1 )
{
@@ -1768,7 +1760,7 @@ static void S_Say_f( void )
S_Say( Cmd_Argv( 1 ), false );
}
static void S_SayReliable_f( void )
void S_SayReliable_f( void )
{
if( Cmd_Argc() == 1 )
{
@@ -1784,7 +1776,7 @@ static void S_SayReliable_f( void )
S_Music_f
=================
*/
static void S_Music_f( void )
void S_Music_f( void )
{
int c = Cmd_Argc();
@@ -1848,7 +1840,7 @@ static void S_Music_f( void )
S_StopSound_f
=================
*/
static void S_StopSound_f( void )
void S_StopSound_f( void )
{
S_StopAllSounds( true );
}
@@ -1858,7 +1850,7 @@ static void S_StopSound_f( void )
S_SoundFade_f
=================
*/
static void S_SoundFade_f( void )
void S_SoundFade_f( void )
{
int c = Cmd_Argc();
float fadeTime = 5.0f;
@@ -1892,7 +1884,7 @@ void S_SoundInfo_f( void )
S_VoiceRecordStart_f
=================
*/
static void S_VoiceRecordStart_f( void )
void S_VoiceRecordStart_f( void )
{
if( cls.state != ca_active || cls.legacymode )
return;
@@ -1905,7 +1897,7 @@ static void S_VoiceRecordStart_f( void )
S_VoiceRecordStop_f
=================
*/
static void S_VoiceRecordStop_f( void )
void S_VoiceRecordStop_f( void )
{
if( cls.state != ca_active || !Voice_IsRecording() )
return;

View File

@@ -17,56 +17,30 @@ GNU General Public License for more details.
#include "sound.h"
#include "client.h"
enum
{
IPAINTBUFFER = 0,
IROOMBUFFER,
ISTREAMBUFFER,
CPAINTBUFFERS,
};
#define IPAINTBUFFER 0
#define IROOMBUFFER 1
#define ISTREAMBUFFER 2
enum
{
FILTERTYPE_NONE = 0,
FILTERTYPE_LINEAR,
FILTERTYPE_CUBIC,
};
#define FILTERTYPE_NONE 0
#define FILTERTYPE_LINEAR 1
#define FILTERTYPE_CUBIC 2
#define CCHANVOLUMES 2
#define SND_SCALE_BITS 7
#define SND_SCALE_SHIFT ( 8 - SND_SCALE_BITS )
#define SND_SCALE_LEVELS ( 1 << SND_SCALE_BITS )
#define SND_SCALE_BITS 7
#define SND_SCALE_SHIFT (8 - SND_SCALE_BITS)
#define SND_SCALE_LEVELS (1 << SND_SCALE_BITS)
// sound mixing buffer
#define CPAINTFILTERMEM 3
#define CPAINTFILTERS 4 // maximum number of consecutive upsample passes per paintbuffer
portable_samplepair_t *g_curpaintbuffer;
portable_samplepair_t streambuffer[(PAINTBUFFER_SIZE+1)];
portable_samplepair_t paintbuffer[(PAINTBUFFER_SIZE+1)];
portable_samplepair_t roombuffer[(PAINTBUFFER_SIZE+1)];
portable_samplepair_t facingbuffer[(PAINTBUFFER_SIZE+1)];
portable_samplepair_t temppaintbuffer[(PAINTBUFFER_SIZE+1)];
paintbuffer_t paintbuffers[CPAINTBUFFERS];
// fixed point stuff for real-time resampling
#define FIX_BITS 28
#define FIX_SCALE ( 1 << FIX_BITS )
#define FIX_MASK (( 1 << FIX_BITS ) - 1 )
#define FIX_FLOAT( a ) ((int)(( a ) * FIX_SCALE ))
#define FIX( a ) (((int)( a )) << FIX_BITS )
#define FIX_INTPART( a ) (((int)( a )) >> FIX_BITS )
#define FIX_FRACPART( a ) (( a ) & FIX_MASK )
int snd_scaletable[SND_SCALE_LEVELS][256];
typedef struct
{
qboolean factive; // if true, mix to this paintbuffer using flags
portable_samplepair_t *pbuf; // front stereo mix buffer, for 2 or 4 channel mixing
int ifilter; // current filter memory buffer to use for upsampling pass
portable_samplepair_t fltmem[CPAINTFILTERS][CPAINTFILTERMEM];
} paintbuffer_t;
static portable_samplepair_t *g_curpaintbuffer;
static portable_samplepair_t streambuffer[(PAINTBUFFER_SIZE+1)];
static portable_samplepair_t paintbuffer[(PAINTBUFFER_SIZE+1)];
static portable_samplepair_t roombuffer[(PAINTBUFFER_SIZE+1)];
static portable_samplepair_t temppaintbuffer[(PAINTBUFFER_SIZE+1)];
static paintbuffer_t paintbuffers[CPAINTBUFFERS];
static int snd_scaletable[SND_SCALE_LEVELS][256];
void S_InitScaletable( void )
{
int i, j;
@@ -84,7 +58,7 @@ S_TransferPaintBuffer
===================
*/
static void S_TransferPaintBuffer( int endtime )
void S_TransferPaintBuffer( int endtime )
{
int *snd_p, snd_linear_count;
int lpos, lpaintedtime;
@@ -93,7 +67,7 @@ static void S_TransferPaintBuffer( int endtime )
dword *pbuf;
pbuf = (dword *)dma.buffer;
snd_p = (int *)g_curpaintbuffer;
snd_p = (int *)PAINTBUFFER;
lpaintedtime = paintedtime;
sampleMask = ((dma.samples >> 1) - 1);
@@ -137,20 +111,20 @@ static void S_TransferPaintBuffer( int endtime )
//===============================================================================
// Activate a paintbuffer. All active paintbuffers are mixed in parallel within
// MIX_MixChannelsToPaintbuffer, according to flags
static void MIX_ActivatePaintbuffer( int ipaintbuffer )
_inline void MIX_ActivatePaintbuffer( int ipaintbuffer )
{
Assert( ipaintbuffer < CPAINTBUFFERS );
paintbuffers[ipaintbuffer].factive = true;
}
static void MIX_SetCurrentPaintbuffer( int ipaintbuffer )
_inline void MIX_SetCurrentPaintbuffer( int ipaintbuffer )
{
Assert( ipaintbuffer < CPAINTBUFFERS );
g_curpaintbuffer = paintbuffers[ipaintbuffer].pbuf;
Assert( g_curpaintbuffer != NULL );
}
static int MIX_GetCurrentPaintbufferIndex( void )
_inline int MIX_GetCurrentPaintbufferIndex( void )
{
int i;
@@ -162,7 +136,7 @@ static int MIX_GetCurrentPaintbufferIndex( void )
return 0;
}
static paintbuffer_t *MIX_GetCurrentPaintbufferPtr( void )
_inline paintbuffer_t *MIX_GetCurrentPaintbufferPtr( void )
{
int ipaint = MIX_GetCurrentPaintbufferIndex();
@@ -171,7 +145,7 @@ static paintbuffer_t *MIX_GetCurrentPaintbufferPtr( void )
}
// Don't mix into any paintbuffers
static void MIX_DeactivateAllPaintbuffers( void )
_inline void MIX_DeactivateAllPaintbuffers( void )
{
int i;
@@ -180,7 +154,7 @@ static void MIX_DeactivateAllPaintbuffers( void )
}
// set upsampling filter indexes back to 0
static void MIX_ResetPaintbufferFilterCounters( void )
_inline void MIX_ResetPaintbufferFilterCounters( void )
{
int i;
@@ -189,13 +163,13 @@ static void MIX_ResetPaintbufferFilterCounters( void )
}
// return pointer to front paintbuffer pbuf, given index
static portable_samplepair_t *MIX_GetPFrontFromIPaint( int ipaintbuffer )
_inline portable_samplepair_t *MIX_GetPFrontFromIPaint( int ipaintbuffer )
{
Assert( ipaintbuffer < CPAINTBUFFERS );
return paintbuffers[ipaintbuffer].pbuf;
}
static paintbuffer_t *MIX_GetPPaintFromIPaint( int ipaint )
_inline paintbuffer_t *MIX_GetPPaintFromIPaint( int ipaint )
{
Assert( ipaint < CPAINTBUFFERS );
return &paintbuffers[ipaint];
@@ -227,7 +201,7 @@ CHANNEL MIXING
===============================================================================
*/
static void S_PaintMonoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pData, int outCount )
void S_PaintMonoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pData, int outCount )
{
int *lscale, *rscale;
int i, data;
@@ -243,7 +217,7 @@ static void S_PaintMonoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pD
}
}
static void S_PaintStereoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pData, int outCount )
void S_PaintStereoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pData, int outCount )
{
int *lscale, *rscale;
uint left, right;
@@ -263,7 +237,7 @@ static void S_PaintStereoFrom8( portable_samplepair_t *pbuf, int *volume, byte *
}
}
static void S_PaintMonoFrom16( portable_samplepair_t *pbuf, int *volume, short *pData, int outCount )
void S_PaintMonoFrom16( portable_samplepair_t *pbuf, int *volume, short *pData, int outCount )
{
int left, right;
int i, data;
@@ -278,7 +252,7 @@ static void S_PaintMonoFrom16( portable_samplepair_t *pbuf, int *volume, short *
}
}
static void S_PaintStereoFrom16( portable_samplepair_t *pbuf, int *volume, short *pData, int outCount )
void S_PaintStereoFrom16( portable_samplepair_t *pbuf, int *volume, short *pData, int outCount )
{
uint *data;
int left, right;
@@ -299,11 +273,11 @@ static void S_PaintStereoFrom16( portable_samplepair_t *pbuf, int *volume, short
}
}
static void S_Mix8MonoTimeCompress( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount, int timecompress )
void S_Mix8MonoTimeCompress( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount, int timecompress )
{
}
static void S_Mix8Mono( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount, int timecompress )
void S_Mix8Mono( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount, int timecompress )
{
int i, sampleIndex = 0;
uint sampleFrac = inputOffset;
@@ -335,7 +309,7 @@ static void S_Mix8Mono( portable_samplepair_t *pbuf, int *volume, byte *pData, i
}
}
static void S_Mix8Stereo( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount )
void S_Mix8Stereo( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount )
{
int i, sampleIndex = 0;
uint sampleFrac = inputOffset;
@@ -361,7 +335,7 @@ static void S_Mix8Stereo( portable_samplepair_t *pbuf, int *volume, byte *pData,
}
}
static void S_Mix16Mono( portable_samplepair_t *pbuf, int *volume, short *pData, int inputOffset, uint rateScale, int outCount )
void S_Mix16Mono( portable_samplepair_t *pbuf, int *volume, short *pData, int inputOffset, uint rateScale, int outCount )
{
int i, sampleIndex = 0;
uint sampleFrac = inputOffset;
@@ -383,7 +357,7 @@ static void S_Mix16Mono( portable_samplepair_t *pbuf, int *volume, short *pData,
}
}
static void S_Mix16Stereo( portable_samplepair_t *pbuf, int *volume, short *pData, int inputOffset, uint rateScale, int outCount )
void S_Mix16Stereo( portable_samplepair_t *pbuf, int *volume, short *pData, int inputOffset, uint rateScale, int outCount )
{
int i, sampleIndex = 0;
uint sampleFrac = inputOffset;
@@ -405,7 +379,7 @@ static void S_Mix16Stereo( portable_samplepair_t *pbuf, int *volume, short *pDat
}
}
static void S_MixChannel( channel_t *pChannel, void *pData, int outputOffset, int inputOffset, uint fracRate, int outCount, int timecompress )
void S_MixChannel( channel_t *pChannel, void *pData, int outputOffset, int inputOffset, uint fracRate, int outCount, int timecompress )
{
int pvol[CCHANVOLUMES];
paintbuffer_t *ppaint = MIX_GetCurrentPaintbufferPtr();
@@ -522,7 +496,7 @@ int S_MixDataToDevice( channel_t *pChannel, int sampleCount, int outRate, int ou
return outOffset - startingOffset;
}
static qboolean S_ShouldContinueMixing( channel_t *ch )
qboolean S_ShouldContinueMixing( channel_t *ch )
{
if( ch->isSentence )
{
@@ -543,13 +517,12 @@ static qboolean S_ShouldContinueMixing( channel_t *ch )
// this routine will fill the paintbuffer to endtime. Otherwise, fewer samples are mixed.
// if( endtime - paintedtime ) is not aligned on boundaries of 4,
// we'll miss data if outputRate < SOUND_DMA_SPEED!
static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate )
void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate )
{
channel_t *ch;
wavdata_t *pSource;
int i, sampleCount;
qboolean bZeroVolume;
qboolean local = Host_IsLocalGame();
// mix each channel into paintbuffer
ch = channels;
@@ -576,7 +549,7 @@ static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate
{
// play, playvol
}
else if(( s_listener.inmenu || s_listener.paused ) && !ch->localsound && local )
else if(( s_listener.inmenu || s_listener.paused ) && !ch->localsound )
{
// play only local sounds, keep pause for other
continue;
@@ -594,7 +567,6 @@ static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate
// Don't mix sound data for sounds with zero volume. If it's a non-looping sound,
// just remove the sound when its volume goes to zero.
bZeroVolume = !ch->leftvol && !ch->rightvol;
if( !bZeroVolume )
@@ -604,7 +576,7 @@ static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate
bZeroVolume = true;
}
if( !pSource || ( bZeroVolume && !FBitSet( pSource->flags, SOUND_LOOPED )))
if( !pSource || ( bZeroVolume && pSource->loopStart == -1 ))
{
if( !pSource )
{
@@ -657,7 +629,7 @@ static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate
}
// pass in index -1...count+2, return pointer to source sample in either paintbuffer or delay buffer
static portable_samplepair_t *S_GetNextpFilter( int i, portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem )
_inline portable_samplepair_t *S_GetNextpFilter( int i, portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem )
{
// The delay buffer is assumed to precede the paintbuffer by 6 duplicated samples
if( i == -1 ) return (&(pfiltermem[0]));
@@ -675,7 +647,7 @@ static portable_samplepair_t *S_GetNextpFilter( int i, portable_samplepair_t *pb
// if NULL then perform no filtering.
// count: how many samples to upsample. will become count*2 samples in buffer, in place.
static void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int count )
void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int count )
{
// implement cubic interpolation on 2x upsampled buffer. Effectively delays buffer contents by 2 samples.
@@ -768,7 +740,7 @@ static void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_sampl
// prevfilter: filter memory. NOTE: this must match the filtertype ie: filterlinear[] for FILTERTYPE_LINEAR
// if NULL then perform no filtering.
// count: how many samples to upsample. will become count*2 samples in buffer, in place.
static void S_Interpolate2xLinear( portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int count )
void S_Interpolate2xLinear( portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int count )
{
int i, upCount = count<<1;
@@ -797,7 +769,7 @@ static void S_Interpolate2xLinear( portable_samplepair_t *pbuffer, portable_samp
// if NULL then perform no filtering.
// cfltmem: max number of sample pairs filter can use
// filtertype: FILTERTYPE_NONE, _LINEAR, _CUBIC etc. Must match prevfilter.
static void S_MixBufferUpsample2x( int count, portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int filtertype )
void S_MixBufferUpsample2x( int count, portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int filtertype )
{
int upCount = count<<1;
int i, j;
@@ -850,7 +822,7 @@ void MIX_ClearAllPaintBuffers( int SampleCount, qboolean clearFilters )
// mixes pbuf1 + pbuf2 into pbuf3, count samples
// fgain is output gain 0-1.0
// NOTE: pbuf3 may equal pbuf1 or pbuf2!
static void MIX_MixPaintbuffers( int ibuf1, int ibuf2, int ibuf3, int count, float fgain )
void MIX_MixPaintbuffers( int ibuf1, int ibuf2, int ibuf3, int count, float fgain )
{
portable_samplepair_t *pbuf1, *pbuf2, *pbuf3;
int i, gain;
@@ -866,14 +838,6 @@ static void MIX_MixPaintbuffers( int ibuf1, int ibuf2, int ibuf3, int count, flo
pbuf2 = paintbuffers[ibuf2].pbuf;
pbuf3 = paintbuffers[ibuf3].pbuf;
if( !gain )
{
// do not mix buf2 into buf3, just copy
if( pbuf1 != pbuf3 )
memcpy( pbuf3, pbuf1, sizeof( *pbuf1 ) * count );
return;
}
// destination buffer stereo - average n chans down to stereo
// destination 2ch:
@@ -891,7 +855,7 @@ static void MIX_MixPaintbuffers( int ibuf1, int ibuf2, int ibuf3, int count, flo
}
}
static void MIX_CompressPaintbuffer( int ipaint, int count )
void MIX_CompressPaintbuffer( int ipaint, int count )
{
portable_samplepair_t *pbuf;
paintbuffer_t *ppaint;
@@ -907,7 +871,7 @@ static void MIX_CompressPaintbuffer( int ipaint, int count )
}
}
static void S_MixUpsample( int sampleCount, int filtertype )
void S_MixUpsample( int sampleCount, int filtertype )
{
paintbuffer_t *ppaint = MIX_GetCurrentPaintbufferPtr();
int ifilter = ppaint->ifilter;
@@ -920,10 +884,10 @@ static void S_MixUpsample( int sampleCount, int filtertype )
ppaint->ifilter++;
}
static void MIX_MixRawSamplesBuffer( int end )
void MIX_MixRawSamplesBuffer( int end )
{
portable_samplepair_t *pbuf, *roombuf, *streambuf;
uint i, j, stop;
uint i, j, stop;
roombuf = MIX_GetPFrontFromIPaint( IROOMBUFFER );
streambuf = MIX_GetPFrontFromIPaint( ISTREAMBUFFER );
@@ -956,11 +920,7 @@ static void MIX_MixRawSamplesBuffer( int end )
}
if( ch->entnum > 0 )
{
int pos = paintedtime & ( ch->max_samples - 1 );
SND_MoveMouthRaw( ch, &ch->rawsamples[pos], bound( 0, ch->max_samples - pos, stop - paintedtime ));
}
SND_MoveMouthRaw( ch, &ch->rawsamples[paintedtime & ( ch->max_samples - 1 )], stop - paintedtime );
}
}
@@ -968,7 +928,7 @@ static void MIX_MixRawSamplesBuffer( int end )
// IROOMBUFFER, IFACINGBUFFER, IFACINGAWAY
// dsp fx are then applied to these buffers by the caller.
// caller also remixes all into final IPAINTBUFFER output.
static void MIX_UpsampleAllPaintbuffers( int end, int count )
void MIX_UpsampleAllPaintbuffers( int end, int count )
{
// 11khz sounds are mixed into 3 buffers based on distance from listener, and facing direction
// These buffers are facing, facingaway, room

View File

@@ -57,12 +57,6 @@ float S_GetMusicVolume( void )
{
float scale = 1.0f;
if( host.status == HOST_NOFOCUS && snd_mute_losefocus.value != 0.0f )
{
// we return zero volume to keep sounds running
return 0.0f;
}
if( !s_listener.inmenu && musicfade.percent != 0 )
{
scale = bound( 0.0f, musicfade.percent / 100.0f, 1.0f );
@@ -148,7 +142,7 @@ S_StreamGetCurrentState
save\restore code
=================
*/
qboolean S_StreamGetCurrentState( char *currentTrack, size_t currentTrackSize, char *loopTrack, size_t loopTrackSize, int *position )
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position )
{
if( !s_bgTrack.stream )
return false; // not active
@@ -156,15 +150,15 @@ qboolean S_StreamGetCurrentState( char *currentTrack, size_t currentTrackSize, c
if( currentTrack )
{
if( s_bgTrack.current[0] )
Q_strncpy( currentTrack, s_bgTrack.current, currentTrackSize );
else Q_strncpy( currentTrack, "*", currentTrackSize ); // no track
Q_strncpy( currentTrack, s_bgTrack.current, MAX_STRING );
else Q_strncpy( currentTrack, "*", MAX_STRING ); // no track
}
if( loopTrack )
{
if( s_bgTrack.loopName[0] )
Q_strncpy( loopTrack, s_bgTrack.loopName, loopTrackSize );
else Q_strncpy( loopTrack, "*", loopTrackSize ); // no track
Q_strncpy( loopTrack, s_bgTrack.loopName, MAX_STRING );
else Q_strncpy( loopTrack, "*", MAX_STRING ); // no track
}
if( position )

View File

@@ -27,7 +27,7 @@ int S_ConvertLoopedPosition( wavdata_t *pSource, int samplePosition, qboolean us
// convert to a position within the loop
// At the end of the loop, we return a short buffer, and subsequent call
// will loop back and get the rest of the buffer
if( FBitSet( pSource->flags, SOUND_LOOPED ) && samplePosition >= pSource->samples && use_loop )
if( pSource->loopStart >= 0 && samplePosition >= pSource->samples && use_loop )
{
// size of loop
int loopSize = pSource->samples - pSource->loopStart;

View File

@@ -96,7 +96,7 @@ static int S_TrimEnd( const wavdata_t *wav, int end )
if( width == 1 )
{
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * ( end - 1 )];
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * end];
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
{
@@ -109,7 +109,7 @@ static int S_TrimEnd( const wavdata_t *wav, int end )
}
else if( width == 2 )
{
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * ( end - 1 )];
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * end];
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
{
@@ -261,7 +261,7 @@ static const char *VOX_GetDirectory( char *szpath, const char *psz, int nsize )
if( len > nsize )
{
Con_Printf( "%s: invalid directory in: %s\n", __func__, psz );
Con_Printf( "VOX_GetDirectory: invalid directory in: %s\n", psz );
return NULL;
}
@@ -467,7 +467,7 @@ void VOX_LoadSound( channel_t *ch, const char *pszin )
if( !psz )
{
Con_Printf( "%s: no sentence named %s\n", __func__, pszin );
Con_Printf( "VOX_LoadSound: no sentence named %s\n", pszin );
return;
}
@@ -475,13 +475,13 @@ void VOX_LoadSound( channel_t *ch, const char *pszin )
if( !psz )
{
Con_Printf( "%s: failed getting directory for %s\n", __func__, pszin );
Con_Printf( "VOX_LoadSound: failed getting directory for %s\n", pszin );
return;
}
if( Q_strlen( psz ) >= sizeof( buffer ) )
{
Con_Printf( "%s: sentence is too long %s", __func__, psz );
Con_Printf( "VOX_LoadSound: sentence is too long %s", psz );
return;
}

View File

@@ -20,181 +20,215 @@ extern poolhandle_t sndpool;
#include "xash3d_mathlib.h"
#define XASH_AUDIO_CD_QUALITY 1 // some platforms might need this
// sound engine rate defines
#if XASH_AUDIO_CD_QUALITY
#define SOUND_11k 11025 // 11khz sample rate
#define SOUND_22k 22050 // 22khz sample rate
#define SOUND_44k 44100 // 44khz sample rate
#else // XASH_AUDIO_CD_QUALITY
#define SOUND_11k 12000 // 11khz sample rate
#define SOUND_22k 24000 // 22khz sample rate
#define SOUND_44k 48000 // 44khz sample rate
#endif // XASH_AUDIO_CD_QUALITY
#define SOUND_DMA_SPEED 44100 // hardware playback rate
#define SOUND_11k 11025 // 11khz sample rate
#define SOUND_16k 16000 // 16khz sample rate
#define SOUND_22k 22050 // 22khz sample rate
#define SOUND_32k 32000 // 32khz sample rate
#define SOUND_44k 44100 // 44khz sample rate
#define DMA_MSEC_PER_SAMPLE ((float)(1000.0 / SOUND_DMA_SPEED))
#define SOUND_DMA_SPEED SOUND_44k // hardware playback rate
// fixed point stuff for real-time resampling
#define FIX_BITS 28
#define FIX_SCALE (1 << FIX_BITS)
#define FIX_MASK ((1 << FIX_BITS)-1)
#define FIX_FLOAT(a) ((int)((a) * FIX_SCALE))
#define FIX(a) (((int)(a)) << FIX_BITS)
#define FIX_INTPART(a) (((int)(a)) >> FIX_BITS)
#define FIX_FRACTION(a,b) (FIX(a)/(b))
#define FIX_FRACPART(a) ((a) & FIX_MASK)
// NOTE: clipped sound at 32760 to avoid overload
#define CLIP( x ) (( x ) > 32760 ? 32760 : (( x ) < -32760 ? -32760 : ( x )))
#define CLIP( x ) (( x ) > 32760 ? 32760 : (( x ) < -32760 ? -32760 : ( x )))
#define PAINTBUFFER_SIZE 1024 // 44k: was 512
#define PAINTBUFFER_SIZE 1024 // 44k: was 512
#define PAINTBUFFER (g_curpaintbuffer)
#define CPAINTBUFFERS 3
#define S_RAW_SOUND_IDLE_SEC 10 // time interval for idling raw sound before it's freed
#define S_RAW_SOUND_BACKGROUNDTRACK -2
#define S_RAW_SOUND_SOUNDTRACK -1
#define S_RAW_SAMPLES_PRECISION_BITS 14
// sound mixing buffer
#define CPAINTFILTERMEM 3
#define CPAINTFILTERS 4 // maximum number of consecutive upsample passes per paintbuffer
#define S_RAW_SOUND_IDLE_SEC 10 // time interval for idling raw sound before it's freed
#define S_RAW_SOUND_BACKGROUNDTRACK -2
#define S_RAW_SOUND_SOUNDTRACK -1
#define S_RAW_SAMPLES_PRECISION_BITS 14
#define CIN_FRAMETIME (1.0f / 30.0f)
typedef struct
{
int left;
int right;
int left;
int right;
} portable_samplepair_t;
typedef struct
{
qboolean factive; // if true, mix to this paintbuffer using flags
portable_samplepair_t *pbuf; // front stereo mix buffer, for 2 or 4 channel mixing
int ifilter; // current filter memory buffer to use for upsampling pass
portable_samplepair_t fltmem[CPAINTFILTERS][CPAINTFILTERMEM];
} paintbuffer_t;
typedef struct sfx_s
{
char name[MAX_QPATH];
wavdata_t *cache;
char name[MAX_QPATH];
wavdata_t *cache;
int servercount;
uint hashValue;
struct sfx_s *hashNext;
int servercount;
uint hashValue;
struct sfx_s *hashNext;
} sfx_t;
extern portable_samplepair_t paintbuffer[];
extern portable_samplepair_t roombuffer[];
extern portable_samplepair_t temppaintbuffer[];
extern portable_samplepair_t *g_curpaintbuffer;
extern paintbuffer_t paintbuffers[];
// structure used for fading in and out client sound volume.
typedef struct
{
float initial_percent;
float percent; // how far to adjust client's volume down by.
float starttime; // GetHostTime() when we started adjusting volume
float fadeouttime; // # of seconds to get to faded out state
float holdtime; // # of seconds to hold
float fadeintime; // # of seconds to restore
float initial_percent;
float percent; // how far to adjust client's volume down by.
float starttime; // GetHostTime() when we started adjusting volume
float fadeouttime; // # of seconds to get to faded out state
float holdtime; // # of seconds to hold
float fadeintime; // # of seconds to restore
} soundfade_t;
typedef struct
{
float percent;
float percent;
} musicfade_t;
typedef struct snd_format_s
{
uint speed;
byte width;
byte channels;
unsigned int speed;
unsigned int width;
unsigned int channels;
} snd_format_t;
typedef struct
{
snd_format_t format;
int samples; // mono samples in buffer
int samplepos; // in mono samples
qboolean initialized; // sound engine is active
byte *buffer;
const char *backendName;
snd_format_t format;
int samples; // mono samples in buffer
int samplepos; // in mono samples
byte *buffer;
qboolean initialized; // sound engine is active
const char *backendName;
} dma_t;
#include "vox.h"
typedef struct
{
double sample;
wavdata_t *pData;
double forcedEndSample;
qboolean finished;
double sample;
wavdata_t *pData;
double forcedEndSample;
qboolean finished;
} mixer_t;
typedef struct rawchan_s
{
int entnum;
int master_vol;
int leftvol; // 0-255 left volume
int rightvol; // 0-255 right volume
float dist_mult; // distance multiplier (attenuation/clipK)
vec3_t origin; // only use if fixed_origin is set
volatile uint s_rawend;
float oldtime; // catch time jumps
wavdata_t sound_info; // advance play position
size_t max_samples; // buffer length
portable_samplepair_t rawsamples[]; // variable sized
int entnum;
int master_vol;
int leftvol; // 0-255 left volume
int rightvol; // 0-255 right volume
float dist_mult; // distance multiplier (attenuation/clipK)
vec3_t origin; // only use if fixed_origin is set
volatile uint s_rawend;
wavdata_t sound_info; // advance play position
float oldtime; // catch time jumps
size_t max_samples; // buffer length
portable_samplepair_t rawsamples[1]; // variable sized
} rawchan_t;
typedef struct channel_s
{
char name[16]; // keep sentence name
sfx_t *sfx; // sfx number
char name[16]; // keept sentence name
sfx_t *sfx; // sfx number
int leftvol; // 0-255 left volume
int rightvol; // 0-255 right volume
int leftvol; // 0-255 left volume
int rightvol; // 0-255 right volume
int entnum; // entity soundsource
int entchannel; // sound channel (CHAN_STREAM, CHAN_VOICE, etc.)
vec3_t origin; // only use if fixed_origin is set
float dist_mult; // distance multiplier (attenuation/clipK)
int master_vol; // 0-255 master volume
int basePitch; // base pitch percent (100% is normal pitch playback)
float pitch; // real-time pitch after any modulation or shift by dynamic data
qboolean use_loop; // don't loop default and local sounds
qboolean staticsound; // use origin instead of fetching entnum's origin
qboolean localsound; // it's a local menu sound (not looped, not paused)
mixer_t pMixer;
int entnum; // entity soundsource
int entchannel; // sound channel (CHAN_STREAM, CHAN_VOICE, etc.)
vec3_t origin; // only use if fixed_origin is set
float dist_mult; // distance multiplier (attenuation/clipK)
int master_vol; // 0-255 master volume
qboolean isSentence; // bit who indicated sentence
int basePitch; // base pitch percent (100% is normal pitch playback)
float pitch; // real-time pitch after any modulation or shift by dynamic data
qboolean use_loop; // don't loop default and local sounds
qboolean staticsound; // use origin instead of fetching entnum's origin
qboolean localsound; // it's a local menu sound (not looped, not paused)
mixer_t pMixer;
// sentence mixer
qboolean isSentence; // bit indicating sentence
int wordIndex;
mixer_t *currentWord; // NULL if sentence is finished
voxword_t words[CVOXWORDMAX];
int wordIndex;
mixer_t *currentWord; // NULL if sentence is finished
voxword_t words[CVOXWORDMAX];
} channel_t;
typedef struct
{
vec3_t origin; // simorg + view_ofs
vec3_t forward;
vec3_t right;
vec3_t up;
vec3_t origin; // simorg + view_ofs
vec3_t velocity;
vec3_t forward;
vec3_t right;
vec3_t up;
int entnum;
int waterlevel;
float frametime; // used for sound fade
qboolean active;
qboolean inmenu; // listener in-menu ?
qboolean paused;
qboolean streaming; // playing AVI-file
qboolean stream_paused; // pause only background track
int entnum;
int waterlevel;
float frametime; // used for sound fade
qboolean active;
qboolean inmenu; // listener in-menu ?
qboolean paused;
qboolean streaming; // playing AVI-file
qboolean stream_paused; // pause only background track
} listener_t;
typedef struct
{
string current; // a currently playing track
string loopName; // may be empty
stream_t *stream;
int source; // may be game, menu, etc
string current; // a currently playing track
string loopName; // may be empty
stream_t *stream;
int source; // may be game, menu, etc
} bg_track_t;
//====================================================================
#define MAX_DYNAMIC_CHANNELS (60 + NUM_AMBIENTS)
#define MAX_CHANNELS (256 + MAX_DYNAMIC_CHANNELS) // Scourge Of Armagon has too many static sounds on hip2m4.bsp
#define MAX_RAW_CHANNELS 48
#define MAX_RAW_SAMPLES 8192
#if XASH_PSP
#define MAX_DYNAMIC_CHANNELS (20 + NUM_AMBIENTS)
#define MAX_CHANNELS (128 + MAX_DYNAMIC_CHANNELS)
#define MAX_RAW_CHANNELS 16
#else
#define MAX_DYNAMIC_CHANNELS (60 + NUM_AMBIENTS)
#define MAX_CHANNELS (256 + MAX_DYNAMIC_CHANNELS) // Scourge Of Armagon has too many static sounds on hip2m4.bsp
#define MAX_RAW_CHANNELS 48
#endif
#define MAX_RAW_SAMPLES 8192
extern sound_t ambient_sfx[NUM_AMBIENTS];
extern qboolean snd_ambient;
extern channel_t channels[MAX_CHANNELS];
extern rawchan_t *raw_channels[MAX_RAW_CHANNELS];
extern int total_channels;
extern int paintedtime;
extern int soundtime;
extern listener_t s_listener;
extern int idsp_room;
extern dma_t dma;
extern sound_t ambient_sfx[NUM_AMBIENTS];
extern qboolean snd_ambient;
extern channel_t channels[MAX_CHANNELS];
extern rawchan_t *raw_channels[MAX_RAW_CHANNELS];
extern int total_channels;
extern int paintedtime;
extern int soundtime;
extern listener_t s_listener;
extern int idsp_room;
extern dma_t dma;
extern convar_t s_musicvolume;
extern convar_t s_lerping;
extern convar_t s_test; // cvar to test new effects
extern convar_t s_musicvolume;
extern convar_t s_lerping;
extern convar_t s_test; // cvar to testify new effects
extern convar_t s_samplecount;
extern convar_t s_warn_late_precache;
extern convar_t snd_mute_losefocus;
extern convar_t s_warn_late_precache;
void S_InitScaletable( void );
wavdata_t *S_LoadSound( sfx_t *sfx );
@@ -265,6 +299,7 @@ void SND_ForceCloseMouth( int entnum );
//
void S_StreamSoundTrack( void );
void S_StreamBackgroundTrack( void );
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position );
void S_PrintBackgroundTrackState( void );
void S_FadeMusicVolume( float fadePercent );

View File

@@ -250,7 +250,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
if( IsEndOfText( trim ))
{
Con_Reportf( "%s: unexpected '}' found, line %d\n", __func__, lineNumber );
Con_Reportf( "TextMessage: unexpected '}' found, line %d\n", lineNumber );
return;
}
Q_strncpy( currentName, trim, sizeof( currentName ));
@@ -263,7 +263,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
// save name on name heap
if( lastNamePos + length > 32768 )
{
Con_Reportf( "%s: error while parsing!\n", __func__ );
Con_Reportf( "TextMessage: error while parsing!\n" );
return;
}
@@ -286,7 +286,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
}
if( IsStartOfText( trim ))
{
Con_Reportf( "%s: unexpected '{' found, line %d\n", __func__, lineNumber );
Con_Reportf( "TextMessage: unexpected '{' found, line %d\n", lineNumber );
return;
}
break;
@@ -302,7 +302,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
}
}
Con_Reportf( "%s: parsed %d text messages\n", __func__, messageCount );
Con_Reportf( "TextMessage: parsed %d text messages\n", messageCount );
nameHeapSize = lastNamePos;
textHeapSize = 0;
@@ -347,7 +347,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
}
if(( pCurrentText - (char *)clgame.titles ) != ( textHeapSize + nameHeapSize + messageSize ))
Con_DPrintf( S_ERROR "%s: overflow text message buffer!\n", __func__ );
Con_DPrintf( S_ERROR "TextMessage: overflow text message buffer!\n" );
clgame.numTitles = messageCount;
}

View File

@@ -23,182 +23,55 @@ GNU General Public License for more details.
#include "input.h"
#include "platform/platform.h"
#define VGUI_MAX_TEXTURES 1024
CVAR_DEFINE_AUTO( vgui_utf8, "0", FCVAR_ARCHIVE, "enable utf-8 support for vgui text" );
typedef struct vgui_static_s
static void GAME_EXPORT *VGUI_EngineMalloc( size_t size );
static void GAME_EXPORT VGUI_GetMousePos( int *, int * );
static void GAME_EXPORT VGUI_CursorSelect( VGUI_DefaultCursor );
static byte GAME_EXPORT VGUI_GetColor( int, int );
static int GAME_EXPORT VGUI_UtfProcessChar( int in );
static qboolean GAME_EXPORT VGUI_IsInGame( void );
static struct
{
qboolean initialized;
VGUI_DefaultCursor cursor;
vguiapi_t dllFuncs;
int textures[VGUI_MAX_TEXTURES];
int texture_id;
int bound_texture;
byte color[4];
qboolean enable_texture;
VGUI_DefaultCursor cursor;
HINSTANCE hInstance;
enum VGUI_KeyCode virtualKeyTrans[256];
} vgui_static_t;
static vgui_static_t vgui = {
false, -1
} vgui =
{
false,
{
false, // Not initialized yet
NULL, // VGUI_DrawInit,
NULL, // VGUI_DrawShutdown,
NULL, // VGUI_SetupDrawingText,
NULL, // VGUI_SetupDrawingRect,
NULL, // VGUI_SetupDrawingImage,
NULL, // VGUI_BindTexture,
NULL, // VGUI_EnableTexture,
NULL, // VGUI_CreateTexture,
NULL, // VGUI_UploadTexture,
NULL, // VGUI_UploadTextureBlock,
NULL, // VGUI_DrawQuad,
NULL, // VGUI_GetTextureSizes,
NULL, // VGUI_GenerateTexture,
VGUI_EngineMalloc,
VGUI_CursorSelect,
VGUI_GetColor,
VGUI_IsInGame,
Key_EnableTextInput,
VGUI_GetMousePos,
VGUI_UtfProcessChar,
Platform_GetClipboardText,
Platform_SetClipboardText,
Platform_GetKeyModifiers,
},
-1
};
static CVAR_DEFINE_AUTO( vgui_utf8, "0", FCVAR_ARCHIVE, "enable utf-8 support for vgui text" );
static void GAME_EXPORT VGUI_DrawInit( void )
{
memset( vgui.textures, 0, sizeof( vgui.textures ));
memset( vgui.color, 0, sizeof( vgui.color ));
vgui.texture_id = vgui.bound_texture = 0;
vgui.enable_texture = true;
}
static void GAME_EXPORT VGUI_DrawShutdown( void )
{
int i;
for( i = 1; i < vgui.texture_id; i++ )
ref.dllFuncs.GL_FreeTexture( vgui.textures[i] );
}
static int GAME_EXPORT VGUI_GenerateTexture( void )
{
if( ++vgui.texture_id >= VGUI_MAX_TEXTURES )
Host_Error( "%s: VGUI_MAX_TEXTURES limit exceeded\n", __func__ );
return vgui.texture_id;
}
static void GAME_EXPORT VGUI_UploadTexture( int id, const char *buffer, int width, int height )
{
rgbdata_t r_image = { 0 };
char texName[32];
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
{
Con_DPrintf( S_ERROR "%s: bad texture %i. Ignored\n", __func__, id );
return;
}
Q_snprintf( texName, sizeof( texName ), "*vgui%i", id );
r_image.width = width;
r_image.height = height;
r_image.type = PF_RGBA_32;
r_image.size = width * height * 4;
r_image.flags = IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA;
r_image.buffer = (byte*)buffer;
vgui.textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE );
}
static void GAME_EXPORT VGUI_CreateTexture( int id, int width, int height )
{
rgbdata_t r_image = { 0 };
char texName[32];
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
{
Con_DPrintf( S_ERROR "%s: bad texture %i. Ignored\n", __func__, id );
return;
}
Q_snprintf( texName, sizeof( texName ), "*vgui%i", id );
r_image.width = width;
r_image.height = height;
r_image.type = PF_RGBA_32;
r_image.size = width * height * 4;
r_image.flags = IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA;
r_image.buffer = NULL;
vgui.textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE );
vgui.bound_texture = id;
}
static void GAME_EXPORT VGUI_UploadTextureBlock( int id, int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight )
{
if( id <= 0 || id >= VGUI_MAX_TEXTURES || vgui.textures[id] == 0 )
{
Con_DPrintf( S_ERROR "%s: bad texture %i. Ignored\n", __func__, id );
return;
}
ref.dllFuncs.VGUI_UploadTextureBlock( drawX, drawY, rgba, blockWidth, blockHeight );
vgui.bound_texture = id;
}
static void GAME_EXPORT VGUI_BindTexture( int id )
{
if( id <= 0 || id >= VGUI_MAX_TEXTURES || !vgui.textures[id] )
id = 1; // NOTE: same as bogus index 2700 in GoldSrc
ref.dllFuncs.GL_Bind( XASH_TEXTURE0, vgui.textures[id] );
vgui.bound_texture = id;
}
static void GAME_EXPORT VGUI_GetTextureSizes( int *w, int *h )
{
int texnum;
if( vgui.bound_texture )
texnum = vgui.textures[vgui.bound_texture];
else
texnum = R_GetBuiltinTexture( REF_DEFAULT_TEXTURE );
R_GetTextureParms( w, h, texnum );
}
static void GAME_EXPORT VGUI_SetupDrawingRect( int *pColor )
{
ref.dllFuncs.VGUI_SetupDrawing( true );
Vector4Set( vgui.color, pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
}
static void GAME_EXPORT VGUI_SetupDrawingText( int *pColor )
{
ref.dllFuncs.VGUI_SetupDrawing( false );
Vector4Set( vgui.color, pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
}
static void GAME_EXPORT VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr )
{
float x, y, w, h;
if( !ul || !lr )
return;
x = ul->point[0];
y = ul->point[1];
w = lr->point[0] - x;
h = lr->point[1] - y;
SPR_AdjustSize( &x, &y, &w, &h );
if( vgui.enable_texture )
{
float s1, s2, t1, t2;
s1 = ul->coord[0];
t1 = ul->coord[1];
s2 = lr->coord[0];
t2 = lr->coord[1];
ref.dllFuncs.Color4ub( vgui.color[0], vgui.color[1], vgui.color[2], vgui.color[3] );
ref.dllFuncs.R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, vgui.textures[vgui.bound_texture] );
}
else
{
ref.dllFuncs.FillRGBABlend( x, y, w, h, vgui.color[0], vgui.color[1], vgui.color[2], vgui.color[3] );
}
}
static void GAME_EXPORT VGUI_EnableTexture( qboolean enable )
{
vgui.enable_texture = enable;
}
static void GAME_EXPORT *VGUI_EngineMalloc( size_t size )
{
@@ -244,46 +117,33 @@ qboolean VGui_IsActive( void )
return vgui.initialized;
}
static void VGui_FillAPIFromRef( vguiapi_t *to, const ref_interface_t *from )
{
to->DrawInit = from->VGUI_DrawInit;
to->DrawShutdown = from->VGUI_DrawShutdown;
to->SetupDrawingText = from->VGUI_SetupDrawingText;
to->SetupDrawingRect = from->VGUI_SetupDrawingRect;
to->SetupDrawingImage = from->VGUI_SetupDrawingImage;
to->BindTexture = from->VGUI_BindTexture;
to->EnableTexture = from->VGUI_EnableTexture;
to->CreateTexture = from->VGUI_CreateTexture;
to->UploadTexture = from->VGUI_UploadTexture;
to->UploadTextureBlock = from->VGUI_UploadTextureBlock;
to->DrawQuad = from->VGUI_DrawQuad;
to->GetTextureSizes = from->VGUI_GetTextureSizes;
to->GenerateTexture = from->VGUI_GenerateTexture;
}
void VGui_RegisterCvars( void )
{
Cvar_RegisterVariable( &vgui_utf8 );
}
static const vguiapi_t gEngfuncs =
{
false, // Not initialized yet
VGUI_DrawInit, // VGUI_DrawInit,
VGUI_DrawShutdown, // VGUI_DrawShutdown,
VGUI_SetupDrawingText, // VGUI_SetupDrawingText,
VGUI_SetupDrawingRect, // VGUI_SetupDrawingRect,
VGUI_SetupDrawingText, // VGUI_SetupDrawingImage, (same as text)
VGUI_BindTexture, // VGUI_BindTexture,
VGUI_EnableTexture, // VGUI_EnableTexture,
VGUI_CreateTexture, // VGUI_CreateTexture,
VGUI_UploadTexture, // VGUI_UploadTexture,
VGUI_UploadTextureBlock, // VGUI_UploadTextureBlock,
VGUI_DrawQuad, // VGUI_DrawQuad,
VGUI_GetTextureSizes, // VGUI_GetTextureSizes,
VGUI_GenerateTexture, // VGUI_GenerateTexture,
VGUI_EngineMalloc,
VGUI_CursorSelect,
VGUI_GetColor,
VGUI_IsInGame,
Key_EnableTextInput,
VGUI_GetMousePos,
VGUI_UtfProcessChar,
Platform_GetClipboardText,
Platform_SetClipboardText,
Platform_GetKeyModifiers,
};
qboolean VGui_LoadProgs( HINSTANCE hInstance )
{
void (*F)( vguiapi_t* );
qboolean client = hInstance != NULL;
vgui.dllFuncs = gEngfuncs;
// not loading interface from client.dll, load vgui_support.dll instead
if( !client )
{
@@ -307,7 +167,7 @@ qboolean VGui_LoadProgs( HINSTANCE hInstance )
{
if( FS_FileExists( vguiloader, false ))
Con_Reportf( S_ERROR "Failed to load vgui_support library: %s\n", COM_GetLibraryError() );
else Con_Reportf( "%s: not found\n", __func__ );
else Con_Reportf( "vgui_support: not found\n" );
return false;
}
@@ -318,15 +178,16 @@ qboolean VGui_LoadProgs( HINSTANCE hInstance )
if( F )
{
VGui_FillAPIFromRef( &vgui.dllFuncs, &ref.dllFuncs );
F( &vgui.dllFuncs );
vgui.initialized = vgui.dllFuncs.initialized = true;
Con_Reportf( "%s: initialized legacy API in %s module\n", __func__, client ? "client" : "support" );
Con_Reportf( "vgui_support: initialized legacy API in %s module\n", client ? "client" : "support" );
return true;
}
Con_Reportf( S_ERROR "%s: Failed to find VGUI support API entry point in %s module\n", __func__, client ? "client" : "support" );
Con_Reportf( S_ERROR "Failed to find VGUI support API entry point in %s module\n", client ? "client" : "support" );
return false;
}
@@ -372,9 +233,8 @@ void VGui_Shutdown( void )
if( vgui.hInstance )
COM_FreeLibrary( vgui.hInstance );
// drop pointers to now unloaded vgui_support
vgui.dllFuncs = gEngfuncs;
vgui.hInstance = NULL;
vgui.initialized = false;
}

View File

@@ -20,15 +20,15 @@ GNU General Public License for more details.
#include "vid_common.h"
#include "platform/platform.h"
static CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
static CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
static CVAR_DEFINE_AUTO( vid_mode, "0", FCVAR_RENDERINFO, "current video mode index (used only for storage)" );
static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen rotation (0-3)" );
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );
CVAR_DEFINE_AUTO( vid_highdpi, "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );
CVAR_DEFINE_AUTO( vid_maximized, "0", FCVAR_RENDERINFO, "window maximized state, read-only" );
CVAR_DEFINE( vid_fullscreen, "fullscreen", DEFAULT_FULLSCREEN, FCVAR_RENDERINFO|FCVAR_VIDRESTART, "fullscreen state (0 windowed, 1 fullscreen, 2 borderless)" );
CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
CVAR_DEFINE( vid_fullscreen, "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "fullscreen state (0 windowed, 1 fullscreen, 2 borderless)" );
CVAR_DEFINE( window_xpos, "_window_xpos", "-1", FCVAR_RENDERINFO, "window position by horizontal" );
CVAR_DEFINE( window_ypos, "_window_ypos", "-1", FCVAR_RENDERINFO, "window position by vertical" );
@@ -175,7 +175,7 @@ static void VID_Mode_f( void )
vidmode = R_GetVideoMode( Q_atoi( Cmd_Argv( 1 )) );
if( !vidmode )
{
Con_Printf( S_ERROR "unable to set mode, backend returned null" );
Con_Print( S_ERROR "unable to set mode, backend returned null" );
return;
}

View File

@@ -38,8 +38,6 @@ extern glwstate_t glw_state;
extern convar_t vid_fullscreen;
extern convar_t vid_maximized;
extern convar_t vid_highdpi;
extern convar_t window_width;
extern convar_t window_height;
extern convar_t window_xpos;
extern convar_t window_ypos;
extern convar_t gl_msaa_samples;

View File

@@ -25,17 +25,11 @@ voice_state_t voice = { 0 };
CVAR_DEFINE_AUTO( voice_enable, "1", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "enable voice chat" );
CVAR_DEFINE_AUTO( voice_loopback, "0", FCVAR_PRIVILEGED, "loopback voice back to the speaker" );
CVAR_DEFINE_AUTO( voice_scale, "1.0", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "incoming voice volume scale" );
CVAR_DEFINE_AUTO( voice_transmit_scale, "1.0", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "outcoming voice volume scale" );
CVAR_DEFINE_AUTO( voice_avggain, "0.5", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "automatic voice gain control (average)" );
CVAR_DEFINE_AUTO( voice_maxgain, "5.0", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "automatic voice gain control (maximum)" );
CVAR_DEFINE_AUTO( voice_inputfromfile, "0", FCVAR_PRIVILEGED, "input voice from voice_input.wav" );
static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale );
// in case user enabled voice after connection
// can't keep in `voice` struct because it gets zeroed on shutdown
static string voice_codec_init;
static int voice_quality_init;
static void Voice_ApplyGainAdjust( int16_t *samples, int count );
/*
===============================================================================
@@ -45,25 +39,6 @@ static int voice_quality_init;
===============================================================================
*/
static qboolean Voice_InitCustomMode( void )
{
int err = 0;
voice.width = sizeof( opus_int16 );
voice.samplerate = VOICE_OPUS_CUSTOM_SAMPLERATE;
voice.frame_size = VOICE_OPUS_CUSTOM_FRAME_SIZE;
voice.custom_mode = opus_custom_mode_create( SOUND_44k, voice.frame_size, &err );
if( !voice.custom_mode )
{
Con_Printf( S_ERROR "Can't create Opus Custom mode: %s\n", opus_strerror( err ));
return false;
}
return true;
}
/*
=========================
Voice_InitOpusDecoder
@@ -72,17 +47,24 @@ Voice_InitOpusDecoder
*/
static qboolean Voice_InitOpusDecoder( void )
{
int err = 0;
int err;
for( int i = 0; i < cl.maxclients; i++ )
voice.width = sizeof( opus_int16 );
voice.samplerate = VOICE_OPUS_CUSTOM_SAMPLERATE;
voice.frame_size = VOICE_OPUS_CUSTOM_FRAME_SIZE;
voice.custom_mode = opus_custom_mode_create( SOUND_44k, voice.frame_size, &err );
if( !voice.custom_mode )
{
voice.decoders[i] = opus_custom_decoder_create( voice.custom_mode, VOICE_PCM_CHANNELS, &err );
Con_Printf( S_ERROR "Can't create Opus Custom mode: %s\n", opus_strerror( err ));
return false;
}
if( !voice.decoders[i] )
{
Con_Printf( S_ERROR "Can't create Opus decoder for %i: %s\n", i, opus_strerror( err ));
return false;
}
voice.decoder = opus_custom_decoder_create( voice.custom_mode, VOICE_PCM_CHANNELS, &err );
if( !voice.decoder )
{
Con_Printf( S_ERROR "Can't create Opus encoder: %s\n", opus_strerror( err ));
return false;
}
return true;
@@ -96,7 +78,7 @@ Voice_InitOpusEncoder
*/
static qboolean Voice_InitOpusEncoder( int quality )
{
int err = 0;
int err;
voice.encoder = opus_custom_encoder_create( voice.custom_mode, VOICE_PCM_CHANNELS, &err );
if( !voice.encoder )
@@ -135,13 +117,10 @@ Voice_ShutdownOpusDecoder
*/
static void Voice_ShutdownOpusDecoder( void )
{
for( int i = 0; i < MAX_CLIENTS; i++ )
if( voice.decoder )
{
if( !voice.decoders[i] )
continue;
opus_custom_decoder_destroy( voice.decoders[i] );
voice.decoders[i] = NULL;
opus_custom_decoder_destroy( voice.decoder );
voice.decoder = NULL;
}
}
@@ -158,10 +137,7 @@ static void Voice_ShutdownOpusEncoder( void )
opus_custom_encoder_destroy( voice.encoder );
voice.encoder = NULL;
}
}
static void Voice_ShutdownCustomMode( void )
{
if( voice.custom_mode )
{
opus_custom_mode_destroy( voice.custom_mode );
@@ -208,7 +184,7 @@ static uint Voice_GetOpusCompressedData( byte *out, uint maxsize, uint *frames )
if( !voice.input_file )
{
// adjust gain before encoding, but only for input from voice
Voice_ApplyGainAdjust((opus_int16*)(voice.input_buffer + ofs), voice.frame_size, voice_transmit_scale.value);
Voice_ApplyGainAdjust((opus_int16*)(voice.input_buffer + ofs), voice.frame_size);
}
#endif
@@ -262,10 +238,10 @@ Voice_ApplyGainAdjust
=========================
*/
static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale )
static void Voice_ApplyGainAdjust( int16_t *samples, int count )
{
float gain, modifiedMax;
int average, blockOffset = 0;
int average, adjustedSample, blockOffset = 0;
for( ;; )
{
@@ -284,8 +260,10 @@ static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale )
localMax = absSample;
localSum += absSample;
gain = voice.autogain.current_gain + i * voice.autogain.gain_multiplier;
samples[blockOffset + i] = bound( SHRT_MIN, (int)( sample * gain ), SHRT_MAX );
adjustedSample = Q_min( SHRT_MAX, Q_max(( int )( sample * gain ), SHRT_MIN ));
samples[blockOffset + i] = adjustedSample;
}
if( blockOffset % voice.autogain.block_size == 0 )
@@ -293,9 +271,9 @@ static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale )
average = localSum / blockSize;
modifiedMax = average + ( localMax - average ) * voice_avggain.value;
voice.autogain.current_gain = voice.autogain.next_gain * scale;
voice.autogain.next_gain = Q_min( (float)SHRT_MAX / modifiedMax, voice_maxgain.value ) * scale;
voice.autogain.gain_multiplier = ( voice.autogain.next_gain - voice.autogain.current_gain ) / ( blockSize - 1 );
voice.autogain.current_gain = voice.autogain.next_gain * voice_scale.value;
voice.autogain.next_gain = Q_min( (float)SHRT_MAX / modifiedMax, voice_maxgain.value ) * voice_scale.value;
voice.autogain.gain_multiplier = ( voice.autogain.next_gain - voice.autogain.current_gain ) / ( voice.autogain.block_size - 1 );
}
blockOffset += blockSize;
}
@@ -402,7 +380,7 @@ void Voice_RecordStart( void )
if( voice.input_file )
{
Sound_Process( &voice.input_file, voice.samplerate, voice.width, VOICE_PCM_CHANNELS, SOUND_RESAMPLE );
Sound_Process( &voice.input_file, voice.samplerate, voice.width, SOUND_RESAMPLE );
voice.input_file_pos = 0;
voice.start_time = Sys_DoubleTime();
@@ -450,9 +428,6 @@ void Voice_Disconnect( void )
voice.players_status[i].talking_ack = false;
}
}
VoiceCapture_Shutdown();
voice.device_opened = false;
}
/*
@@ -465,7 +440,7 @@ Feed the decoded data to engine sound subsystem
static void Voice_StartChannel( uint samples, byte *data, int entnum )
{
SND_ForceInitMouth( entnum );
S_RawEntSamples( entnum, samples, voice.samplerate, voice.width, VOICE_PCM_CHANNELS, data, bound( 0, 255 * voice_scale.value, 255 ));
S_RawEntSamples( entnum, samples, voice.samplerate, voice.width, VOICE_PCM_CHANNELS, data, 255 );
}
/*
@@ -477,11 +452,10 @@ Received encoded voice data, decode it
*/
void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames )
{
const int playernum = ent - 1;
int samples = 0;
int ofs = 0;
if( playernum < 0 || playernum >= cl.maxclients || !voice.decoders[playernum] )
if( !voice.decoder )
return;
// decode frame by frame
@@ -501,7 +475,7 @@ void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames )
if( ofs + compressed_size > size )
break;
frame_samples = opus_custom_decode( voice.decoders[playernum], data + ofs, compressed_size,
frame_samples = opus_custom_decode( voice.decoder, data + ofs, compressed_size,
(opus_int16*)voice.decompress_buffer + samples, voice.frame_size );
ofs += compressed_size;
@@ -525,8 +499,8 @@ void CL_AddVoiceToDatagram( void )
if( cls.state != ca_active || !Voice_IsRecording() || !voice.encoder )
return;
size = Voice_GetOpusCompressedData( voice.compress_buffer, sizeof( voice.compress_buffer ), &frames );
size = Voice_GetOpusCompressedData( voice.output_buffer, sizeof( voice.output_buffer ), &frames );
if( size > 0 && MSG_GetNumBytesLeft( &cls.datagram ) >= size + 32 )
{
@@ -534,7 +508,7 @@ void CL_AddVoiceToDatagram( void )
MSG_WriteByte( &cls.datagram, voice_loopback.value != 0 );
MSG_WriteByte( &cls.datagram, frames );
MSG_WriteShort( &cls.datagram, size );
MSG_WriteBytes( &cls.datagram, voice.compress_buffer, size );
MSG_WriteBytes( &cls.datagram, voice.output_buffer, size );
}
}
@@ -550,7 +524,6 @@ void Voice_RegisterCvars( void )
Cvar_RegisterVariable( &voice_enable );
Cvar_RegisterVariable( &voice_loopback );
Cvar_RegisterVariable( &voice_scale );
Cvar_RegisterVariable( &voice_transmit_scale );
Cvar_RegisterVariable( &voice_avggain );
Cvar_RegisterVariable( &voice_maxgain );
Cvar_RegisterVariable( &voice_inputfromfile );
@@ -568,9 +541,8 @@ static void Voice_Shutdown( void )
int i;
Voice_RecordStop();
Voice_ShutdownOpusDecoder();
Voice_ShutdownOpusEncoder();
Voice_ShutdownCustomMode();
Voice_ShutdownOpusDecoder();
VoiceCapture_Shutdown();
if( voice.local.talking_ack )
@@ -596,17 +568,10 @@ void Voice_Idle( double frametime )
{
int i;
if( FBitSet( voice_enable.flags, FCVAR_CHANGED ))
if( FBitSet( voice_enable.flags, FCVAR_CHANGED ) && !voice_enable.value )
{
ClearBits( voice_enable.flags, FCVAR_CHANGED );
if( voice_enable.value )
{
if( cls.state == ca_active && COM_CheckString( voice_codec_init ) && voice_quality_init != 0 )
Voice_Init( voice_codec_init, voice_quality_init, false );
}
else
Voice_Shutdown();
Voice_Shutdown();
return;
}
// update local player status first
@@ -623,68 +588,48 @@ Voice_Init
Initialize the voice subsystem
=========================
*/
qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit )
qboolean Voice_Init( const char *pszCodecName, int quality )
{
if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC ))
{
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
// reset saved codec name, we won't enable voice for this connection
voice_codec_init[0] = 0;
voice_quality_init = 0;
return false;
}
Q_strncpy( voice_codec_init, pszCodecName, sizeof( voice_codec_init ));
voice_quality_init = quality;
if( !voice_enable.value )
return false;
if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC ))
{
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
return false;
}
// reinitialize only if codec parameters are different
if( Q_strcmp( pszCodecName, voice.codec ) || voice.quality != quality )
if( !Q_strcmp( voice.codec, pszCodecName ) && voice.quality == quality )
return true;
Voice_Shutdown();
voice.autogain.block_size = 128;
if( !Voice_InitOpusDecoder( ))
{
// no reason to init encoder and open audio device
// if we can't hear other players
Con_Printf( S_ERROR "Voice chat disabled.\n" );
Voice_Shutdown();
voice.autogain.block_size = 128;
if( !Voice_InitCustomMode( ))
{
// no reason to init encoder and open audio device
// if we can't hear other players
Voice_Shutdown();
return false;
}
// we can hear others players, so it's fine to fail now
voice.initialized = true;
Q_strncpy( voice.codec, pszCodecName, sizeof( voice.codec ));
if( !Voice_InitOpusEncoder( quality ))
{
Con_Printf( S_WARN "Other players will not be able to hear you.\n" );
return false;
}
voice.quality = quality;
return false;
}
if( !preinit )
// we can hear others players, so it's fine to fail now
voice.initialized = true;
Q_strncpy( voice.codec, pszCodecName, sizeof( voice.codec ));
if( !Voice_InitOpusEncoder( quality ))
{
Voice_ShutdownOpusDecoder();
if( !Voice_InitOpusDecoder())
{
// no reason to init encoder and open audio device
// if we can't hear other players
Con_Printf( S_ERROR "Can't create decoders, voice chat is disabled.\n" );
Voice_Shutdown();
return false;
}
voice.device_opened = VoiceCapture_Init();
if( !voice.device_opened )
Con_Printf( S_WARN "No microphone is available.\n" );
Con_Printf( S_WARN "Other players will not be able to hear you.\n" );
return false;
}
voice.quality = quality;
if( !VoiceCapture_Init( ))
Con_Printf( S_WARN "No microphone is available.\n" );
return true;
}

View File

@@ -31,7 +31,7 @@ typedef struct OpusCustomMode OpusCustomMode;
#define VOICE_PCM_CHANNELS 1 // always mono
// never change these parameters when using opuscustom
#define VOICE_OPUS_CUSTOM_SAMPLERATE 44100
#define VOICE_OPUS_CUSTOM_SAMPLERATE SOUND_44k
// must follow opus custom requirements
// also be divisible with MAX_RAW_SAMPLES
#define VOICE_OPUS_CUSTOM_FRAME_SIZE 1024
@@ -53,7 +53,6 @@ typedef struct voice_state_s
qboolean initialized;
qboolean is_recording;
qboolean device_opened;
double start_time;
voice_status_t local;
@@ -62,7 +61,7 @@ typedef struct voice_state_s
// opus stuff
OpusCustomMode *custom_mode;
OpusCustomEncoder *encoder;
OpusCustomDecoder *decoders[MAX_CLIENTS];
OpusCustomDecoder *decoder;
// audio info
uint width;
@@ -71,7 +70,7 @@ typedef struct voice_state_s
// buffers
byte input_buffer[MAX_RAW_SAMPLES];
byte compress_buffer[MAX_RAW_SAMPLES];
byte output_buffer[MAX_RAW_SAMPLES];
byte decompress_buffer[MAX_RAW_SAMPLES];
fs_offset_t input_buffer_pos; // in bytes
@@ -93,7 +92,7 @@ extern voice_state_t voice;
void CL_AddVoiceToDatagram( void );
void Voice_RegisterCvars( void );
qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit );
qboolean Voice_Init( const char *pszCodecName, int quality );
void Voice_Idle( double frametime );
qboolean Voice_IsRecording( void );
void Voice_RecordStop( void );

View File

@@ -16,20 +16,21 @@ GNU General Public License for more details.
#ifndef VOX_H
#define VOX_H
#define CVOXWORDMAX 64
#define SENTENCE_INDEX -99999 // unique sentence index
#define CVOXWORDMAX 64
#define SENTENCE_INDEX -99999 // unique sentence index
typedef struct voxword_s
{
int volume; // increase percent, ie: 125 = 125% increase
int pitch; // pitch shift up percent
int start; // offset start of wave percent
int end; // offset end of wave percent
int cbtrim; // end of wave after being trimmed to 'end'
int fKeepCached; // 1 if this word was already in cache before sentence referenced it
int samplefrac; // if pitch shifting, this is position into wav * 256
int timecompress; // % of wave to skip during playback (causes no pitch shift)
sfx_t *sfx; // name and cache pointer
int volume; // increase percent, ie: 125 = 125% increase
int pitch; // pitch shift up percent
int start; // offset start of wave percent
int end; // offset end of wave percent
int cbtrim; // end of wave after being trimmed to 'end'
int fKeepCached; // 1 if this word was already in cache before sentence referenced it
int samplefrac; // if pitch shifting, this is position into wav * 256
int timecompress; // % of wave to skip during playback (causes no pitch shift)
sfx_t *sfx; // name and cache pointer
} voxword_t;
struct channel_s;

View File

@@ -19,15 +19,13 @@ GNU General Public License for more details.
#define HASH_SIZE 128 // 128 * 4 * 4 == 2048 bytes
typedef struct base_command_hashmap_s base_command_hashmap_t;
struct base_command_hashmap_s
typedef struct base_command_hashmap_s
{
base_command_t *basecmd; // base command: cvar, alias or command
base_command_hashmap_t *next;
base_command_type_e type; // type for faster searching
char name[1]; // key for searching
};
base_command_t *basecmd; // base command: cvar, alias or command
const char *name; // key for searching
base_command_type_e type; // type for faster searching
struct base_command_hashmap_s *next;
} base_command_hashmap_t;
static base_command_hashmap_t *hashed_cmds[HASH_SIZE];
@@ -126,12 +124,11 @@ void BaseCmd_Insert( base_command_type_e type, base_command_t *basecmd, const ch
{
base_command_hashmap_t *elem, *cur, *find;
uint hash = BaseCmd_HashKey( name );
size_t len = Q_strlen( name );
elem = Z_Malloc( sizeof( base_command_hashmap_t ) + len );
elem = Z_Malloc( sizeof( base_command_hashmap_t ) );
elem->basecmd = basecmd;
elem->type = type;
Q_strncpy( elem->name, name, len + 1 );
elem->name = name;
// link the variable in alphanumerical order
for( cur = NULL, find = hashed_cmds[hash];
@@ -162,7 +159,7 @@ void BaseCmd_Remove( base_command_type_e type, const char *name )
if( !i )
{
Con_Reportf( S_ERROR "%s: Couldn't find %s in buckets\n", __func__, name );
Con_Reportf( S_ERROR "Couldn't find %s in buckets\n", name );
return;
}

View File

@@ -31,6 +31,8 @@ typedef enum base_command_type
typedef void base_command_t;
void BaseCmd_Init( void );
base_command_t *BaseCmd_Find( base_command_type_e type, const char *name );
void BaseCmd_FindAll( const char *name,

175
engine/common/build.c Normal file
View File

@@ -0,0 +1,175 @@
/*
build.c - returns a engine build number
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.
*/
#include "common.h"
static char *date = __DATE__ ;
static char *mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
// returns days since Apr 1 2015
int Q_buildnum( void )
{
int m = 0, d = 0, y = 0;
static int b = 0;
if( b != 0 ) return b;
for( m = 0; m < 11; m++ )
{
if( !Q_strnicmp( &date[0], mon[m], 3 ))
break;
d += mond[m];
}
d += Q_atoi( &date[4] ) - 1;
y = Q_atoi( &date[7] ) - 1900;
b = d + (int)((y - 1) * 365.25f );
if((( y % 4 ) == 0 ) && m > 1 )
{
b += 1;
}
b -= 41728; // Apr 1 2015
return b;
}
/*
=============
Q_buildnum_compat
Returns a Xash3D build number. This is left for compability with original Xash3D.
IMPORTANT: this value must be changed ONLY after updating to newer Xash3D
IMPORTANT: this value must be acquired through "build" cvar.
=============
*/
int Q_buildnum_compat( void )
{
// do not touch this! Only author of Xash3D can increase buildnumbers!
return 4529;
}
/*
============
Q_buildos
Returns current name of operating system. Without any spaces.
============
*/
const char *Q_buildos( void )
{
const char *osname;
#if XASH_MINGW
osname = "win32-mingw";
#elif XASH_WIN32
osname = "win32";
#elif XASH_ANDROID
osname = "android";
#elif XASH_LINUX
osname = "linux";
#elif XASH_APPLE
osname = "apple";
#elif XASH_FREEBSD
osname = "freebsd";
#elif XASH_NETBSD
osname = "netbsd";
#elif XASH_OPENBSD
osname = "openbsd";
#elif XASH_EMSCRIPTEN
osname = "emscripten";
#elif XASH_DOS4GW
osname = "DOS4GW";
#elif XASH_PSP
osname = "psp";
#else
#error "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug"
#endif
return osname;
}
/*
============
Q_buildos
Returns current name of operating system. Without any spaces.
============
*/
const char *Q_buildarch( void )
{
const char *archname;
#if XASH_AMD64
archname = "amd64";
#elif XASH_X86
archname = "i386";
#elif XASH_ARM && XASH_64BIT
archname = "arm64";
#elif XASH_ARM
archname = "armv"
#if XASH_ARM == 8
"8_32" // for those who (mis)using 32-bit OS on 64-bit CPU
#elif XASH_ARM == 7
"7"
#elif XASH_ARM == 6
"6"
#elif XASH_ARM == 5
"5"
#elif XASH_ARM == 4
"4"
#endif
#if XASH_ARM_HARDFP
"hf";
#else
"l";
#endif
#elif XASH_MIPS && defined XASH_BIG_ENDIAN
archname = "mips";
#elif XASH_MIPS && defined XASH_LITTLE_ENDIAN
archname = "mipsel";
#elif XASH_JS
archname = "javascript";
#elif XASH_E2K
archname = "e2k";
#else
#error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug"
#endif
return archname;
}
/*
=============
Q_buildcommit
Returns a short hash of current commit in VCS as string.
XASH_BUILD_COMMIT must be passed in quotes
if XASH_BUILD_COMMIT is not defined,
Q_buildcommit will identify this build as "notset"
=============
*/
const char *Q_buildcommit( void )
{
#ifdef XASH_BUILD_COMMIT
return XASH_BUILD_COMMIT;
#else
return "notset";
#endif
}

View File

@@ -52,7 +52,7 @@ CSCR_ExpectString
Return true if next token is pExpext and skip it
===================
*/
static qboolean CSCR_ExpectString( parserstate_t *ps, const char *pExpect, qboolean skip, qboolean error )
qboolean CSCR_ExpectString( parserstate_t *ps, const char *pExpect, qboolean skip, qboolean error )
{
char *tmp = COM_ParseFile( ps->buf, ps->token, sizeof( ps->token ));
@@ -75,7 +75,7 @@ CSCR_ParseType
Determine script variable type
===================
*/
static cvartype_t CSCR_ParseType( parserstate_t *ps )
cvartype_t CSCR_ParseType( parserstate_t *ps )
{
int i;
@@ -96,7 +96,7 @@ static cvartype_t CSCR_ParseType( parserstate_t *ps )
CSCR_ParseSingleCvar
=========================
*/
static qboolean CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result )
qboolean CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result )
{
// read the name
ps->buf = COM_ParseFile( ps->buf, result->name, sizeof( result->name ));
@@ -170,7 +170,7 @@ CSCR_ParseHeader
Check version and seek to first cvar name
======================
*/
static qboolean CSCR_ParseHeader( parserstate_t *ps )
qboolean CSCR_ParseHeader( parserstate_t *ps )
{
if( !CSCR_ExpectString( ps, "VERSION", false, true ))
return false;

View File

@@ -53,7 +53,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
Cbuf_Init
============
*/
static void Cbuf_Init( void )
void Cbuf_Init( void )
{
cmd_text.data = cmd_text_buf;
filteredcmd_text.data = filteredcmd_text_buf;
@@ -79,14 +79,14 @@ void Cbuf_Clear( void )
Cbuf_GetSpace
============
*/
static void *Cbuf_GetSpace( cmdbuf_t *buf, int length )
void *Cbuf_GetSpace( cmdbuf_t *buf, int length )
{
void *data;
if(( buf->cursize + length ) > buf->maxsize )
{
buf->cursize = 0;
Host_Error( "%s: overflow\n", __func__ );
Host_Error( "Cbuf_GetSpace: overflow\n" );
}
data = buf->data + buf->cursize;
@@ -156,7 +156,7 @@ static void Cbuf_InsertTextToBuffer( cmdbuf_t *buf, const char *text )
if(( buf->cursize + l ) >= buf->maxsize )
{
Con_Reportf( S_WARN "%s: overflow\n", __func__ );
Con_Reportf( S_WARN "Cbuf_InsertText: overflow\n" );
}
else
{
@@ -176,7 +176,7 @@ void Cbuf_InsertText( const char *text )
Cbuf_Execute
============
*/
static void Cbuf_ExecuteCommandsFromBuffer( cmdbuf_t *buf, qboolean isPrivileged, int cmdsToExecute )
void Cbuf_ExecuteCommandsFromBuffer( cmdbuf_t *buf, qboolean isPrivileged, int cmdsToExecute )
{
char *text;
char line[MAX_CMD_LINE];
@@ -224,7 +224,7 @@ static void Cbuf_ExecuteCommandsFromBuffer( cmdbuf_t *buf, qboolean isPrivileged
if( i >= ( MAX_CMD_LINE - 1 ))
{
Con_DPrintf( S_ERROR "%s: command string owerflow\n", __func__ );
Con_DPrintf( S_ERROR "Cbuf_Execute: command string owerflow\n" );
line[0] = 0;
}
else
@@ -356,7 +356,7 @@ hl.exe -dev 3 +map c1a0d
hl.exe -nosound -game bshift
===============
*/
static void Cmd_StuffCmds_f( void )
void Cmd_StuffCmds_f( void )
{
host.stuffcmds_pending = true;
}
@@ -370,7 +370,7 @@ next frame. This allows commands like:
bind g "cmd use rocket ; +attack ; wait ; -attack ; cmd use blaster"
============
*/
static void Cmd_Wait_f( void )
void Cmd_Wait_f( void )
{
cmd_wait = true;
}
@@ -382,12 +382,12 @@ Cmd_Echo_f
Just prints the rest of the line to the console
===============
*/
static void Cmd_Echo_f( void )
void Cmd_Echo_f( void )
{
int i;
for( i = 1; i < Cmd_Argc(); i++ )
Con_Printf( "%s ", Cmd_Argv( i ));
Con_Printf( "%s", Cmd_Argv( i ));
Con_Printf( "\n" );
}
@@ -398,7 +398,7 @@ Cmd_Alias_f
Creates a new command that executes a command string (possibly ; seperated)
===============
*/
static void Cmd_Alias_f( void )
void Cmd_Alias_f( void )
{
cmdalias_t *a;
char cmd[MAX_CMD_LINE];
@@ -529,6 +529,7 @@ typedef struct cmd_s
static int cmd_argc;
static const char *cmd_args = NULL;
static char *cmd_argv[MAX_CMD_TOKENS];
static char cmd_tokenized[MAX_CMD_BUFFER]; // will have 0 bytes inserted
static cmd_t *cmd_functions; // possible commands to execute
/*
@@ -640,7 +641,7 @@ void Cmd_TokenizeString( const char *text )
while( 1 )
{
// skip whitespace up to a /n
while( *text && ((byte)*text ) <= ' ' && *text != '\r' && *text != '\n' )
while( *text && *text <= ' ' && *text != '\r' && *text != '\n' )
text++;
if( *text == '\n' || *text == '\r' )
@@ -682,7 +683,7 @@ static int Cmd_AddCommandEx( const char *funcname, const char *cmd_name, xcomman
if( !COM_CheckString( cmd_name ))
{
Con_Reportf( S_ERROR "%s: NULL name\n", funcname );
Con_Reportf( S_ERROR "%s: NULL name\n", funcname );
return 0;
}
@@ -728,7 +729,7 @@ Cmd_AddCommand
*/
void Cmd_AddCommand( const char *cmd_name, xcommand_t function, const char *cmd_desc )
{
Cmd_AddCommandEx( __func__, cmd_name, function, cmd_desc, 0 );
Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, cmd_desc, 0 );
}
@@ -739,7 +740,7 @@ Cmd_AddRestrictedCommand
*/
void Cmd_AddRestrictedCommand( const char *cmd_name, xcommand_t function, const char *cmd_desc )
{
Cmd_AddCommandEx( __func__, cmd_name, function, cmd_desc, CMD_PRIVILEGED );
Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, cmd_desc, CMD_PRIVILEGED );
}
/*
@@ -749,7 +750,7 @@ Cmd_AddServerCommand
*/
void GAME_EXPORT Cmd_AddServerCommand( const char *cmd_name, xcommand_t function )
{
Cmd_AddCommandEx( __func__, cmd_name, function, "server command", CMD_SERVERDLL );
Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, "server command", CMD_SERVERDLL );
}
/*
@@ -767,7 +768,7 @@ int GAME_EXPORT Cmd_AddClientCommand( const char *cmd_name, xcommand_t function
flags |= CMD_PRIVILEGED;
}
return Cmd_AddCommandEx( __func__, cmd_name, function, "client command", flags );
return Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, "client command", flags );
}
/*
@@ -777,7 +778,7 @@ Cmd_AddGameUICommand
*/
int GAME_EXPORT Cmd_AddGameUICommand( const char *cmd_name, xcommand_t function )
{
return Cmd_AddCommandEx( __func__, cmd_name, function, "gameui command", CMD_GAMEUIDLL );
return Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, "gameui command", CMD_GAMEUIDLL );
}
/*
@@ -787,7 +788,7 @@ Cmd_AddRefCommand
*/
int Cmd_AddRefCommand( const char *cmd_name, xcommand_t function, const char *description )
{
return Cmd_AddCommandEx( __func__, cmd_name, function, description, CMD_REFDLL );
return Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, description, CMD_REFDLL );
}
/*
@@ -881,7 +882,7 @@ Cmd_If_f
Compare and et condition bit if true
============
*/
static void Cmd_If_f( void )
void Cmd_If_f( void )
{
// reset bit first
cmd_condition &= ~BIT( cmd_condlevel );
@@ -942,14 +943,14 @@ Cmd_Else_f
Invert condition bit
============
*/
static void Cmd_Else_f( void )
void Cmd_Else_f( void )
{
cmd_condition ^= BIT( cmd_condlevel );
}
static qboolean Cmd_ShouldAllowCommand( cmd_t *cmd, qboolean isPrivileged )
{
const char *prefixes[] = { "cl_", "gl_", "r_", "m_", "hud_", "joy_", "con_", "scr_" };
const char *prefixes[] = { "cl_", "gl_", "r_", "m_", "hud_" };
int i;
// always allow local commands
@@ -1015,7 +1016,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
*ptoken++ = *text++;
*ptoken = 0;
len += Q_strncpy( pcmd, Cvar_VariableString( token ), sizeof( token ) - len );
len += Q_strncpy( pcmd, Cvar_VariableString( token ), MAX_CMD_LINE - len );
pcmd = command + len;
if( !*text ) break;
@@ -1178,7 +1179,7 @@ void Cmd_ForwardToServer( void )
Cmd_List_f
============
*/
static void Cmd_List_f( void )
void Cmd_List_f( void )
{
cmd_t *cmd;
int i = 0;

View File

@@ -17,28 +17,22 @@ GNU General Public License for more details.
#define COM_STRINGS_H
// default colored message headers
#define S_BLACK "^0"
#define S_RED "^1"
#define S_GREEN "^2"
#define S_YELLOW "^3"
#define S_BLUE "^4"
#define S_CYAN "^5"
#define S_MAGENTA "^6"
#define S_DEFAULT "^7"
#define S_NOTE "^2Note:^7 "
#define S_WARN "^3Warning:^7 "
#define S_ERROR "^1Error:^7 "
#define S_USAGE "Usage: "
#define S_USAGE_INDENT " "
#define S_NOTE S_GREEN "Note: " S_DEFAULT
#define S_WARN S_YELLOW "Warning: " S_DEFAULT
#define S_ERROR S_RED "Error: " S_DEFAULT
#define S_USAGE "Usage: "
#define S_USAGE_INDENT "\t"
#define S_OPENGL_NOTE S_GREEN "OpenGL Note: " S_DEFAULT
#define S_OPENGL_WARN S_YELLOW "OpenGL Warning: " S_DEFAULT
#define S_OPENGL_ERROR S_RED "OpenGL Error: " S_DEFAULT
#define S_OPENGL_NOTE "^2OpenGL Note:^7 "
#define S_OPENGL_WARN "^3OpenGL Warning:^7 "
#define S_OPENGL_ERROR "^3OpenGL Error:^7 "
// end game final default message
#define DEFAULT_ENDGAME_MESSAGE "The End"
// path to the hash-pak that contain custom player decals
#define CUSTOM_RES_PATH "custom.hpk"
// path to default playermodel in GoldSrc
#define DEFAULT_PLAYER_PATH_HALFLIFE "models/player.mdl"
@@ -52,20 +46,14 @@ GNU General Public License for more details.
#define DEFAULT_EXTERNAL_PALETTE "gfx/palette.pal"
// path to sound files
// path to folders where placed all sounds
#define DEFAULT_SOUNDPATH "sound/"
// path to saved games
// path store saved games
#define DEFAULT_SAVE_DIRECTORY "save/"
// path to download games
#define DEFAULT_DOWNLOADED_DIRECTORY "downloaded/"
// path to user mod directory
#define DEFAULT_CUSTOM_DIRECTORY "custom/"
// fallback to this skybox
#define DEFAULT_SKYBOX_NAME "desert"
#define DEFAULT_SKYBOX_PATH "gfx/env/desert"
// playlist for startup videos
#define DEFAULT_VIDEOLIST_PATH "media/StartupVids.txt"
@@ -77,8 +65,7 @@ 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_DEDICATED_SERVER_NAME "XashDS"
#define XASH_VERSION "0.21" // engine current version
#define XASH_VERSION "0.20" // engine current version
#define XASH_COMPAT_VERSION "0.99" // version we are based on
#endif//COM_STRINGS_H

View File

@@ -25,19 +25,16 @@ GNU General Public License for more details.
static const char *file_exts[] =
{
// ban text files that don't make sense as resource
"cfg", "lst", "ini", "log",
// ban Windows code
"exe", "vbs", "com", "bat",
"dll", "sys", "ps1",
// ban common unix code
// NOTE: in unix anything can be executed as long it has access flag
"so", "sh", "dylib",
// ban mobile archives
"apk", "ipa",
"cfg",
"lst",
"exe",
"vbs",
"com",
"bat",
"dll",
"ini",
"log",
"sys",
};
#ifdef _DEBUG
@@ -393,9 +390,6 @@ byte *LZSS_Compress( byte *pInput, int inputLength, uint *pOutputSize )
byte *pFinal = NULL;
lzss_state_t state;
if( !pStart )
return NULL;
memset( &state, 0, sizeof( state ));
state.window_size = LZSS_WINDOW_SIZE;
@@ -537,6 +531,47 @@ int GAME_EXPORT COM_FileSize( const char *filename )
return FS_FileSize( filename, false );
}
/*
=============
COM_AddAppDirectoryToSearchPath
=============
*/
void GAME_EXPORT COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName )
{
FS_AddGameHierarchy( pszBaseDir, FS_NOWRITE_PATH );
}
/*
===========
COM_ExpandFilename
Finds the file in the search path, copies over the name with the full path name.
This doesn't search in the pak file.
===========
*/
int GAME_EXPORT COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize )
{
char result[MAX_SYSPATH];
if( !COM_CheckString( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
return 0;
// filename examples:
// media\sierra.avi - D:\Xash3D\valve\media\sierra.avi
// models\barney.mdl - D:\Xash3D\bshift\models\barney.mdl
if( g_fsapi.GetFullDiskPath( result, sizeof( result ), fileName, false ))
{
// check for enough room
if( Q_strlen( result ) > nameOutBufferSize )
return 0;
Q_strncpy( nameOutBuffer, result, nameOutBufferSize );
return 1;
}
return 0;
}
/*
=============
COM_TrimSpace
@@ -699,7 +734,7 @@ COM_LoadFileForMe
byte *GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
{
string name;
byte *pfile;
byte *file, *pfile;
fs_offset_t iLength;
if( !COM_CheckString( filename ))
@@ -712,9 +747,21 @@ byte *GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
Q_strncpy( name, filename, sizeof( name ));
COM_FixSlashes( name );
pfile = g_fsapi.LoadFileMalloc( name, &iLength, false );
pfile = FS_LoadFile( name, &iLength, false );
if( pLength ) *pLength = (int)iLength;
if( pfile )
{
file = malloc( iLength + 1 );
if( file != NULL )
{
memcpy( file, pfile, iLength );
file[iLength] = '\0';
}
Mem_Free( pfile );
pfile = file;
}
return pfile;
}
@@ -822,6 +869,18 @@ cvar_t *GAME_EXPORT pfnCVarGetPointer( const char *szVarName )
return (cvar_t *)Cvar_FindVar( szVarName );
}
/*
=============
pfnCVarDirectSet
allow to set cvar directly
=============
*/
void GAME_EXPORT pfnCVarDirectSet( cvar_t *var, const char *szValue )
{
Cvar_DirectSet( (convar_t *)var, szValue );
}
/*
=============
COM_CompareFileTime
@@ -903,10 +962,7 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
if( !COM_CheckString( filename ))
return false;
ext = COM_FileExtension( lwrfilename );
// only allow extensionless files that start with !MD5
if( !Q_strncmp( filename, "!MD5", 4 ) && ext[0] == 0 )
if( !Q_strncmp( filename, "!MD5", 4 ))
return true;
Q_strnlwr( filename, lwrfilename, sizeof( lwrfilename ));
@@ -929,6 +985,8 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
if( Q_strlen( first ) != 4 )
return false;
ext = COM_FileExtension( lwrfilename );
for( i = 0; i < ARRAYSIZE( file_exts ); i++ )
{
if( !Q_stricmp( ext, file_exts[i] ))
@@ -938,6 +996,21 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
return true;
}
const char *COM_GetResourceTypeName( resourcetype_t restype )
{
switch( restype )
{
case t_decal: return "decal";
case t_eventscript: return "eventscript";
case t_generic: return "generic";
case t_model: return "model";
case t_skin: return "skin";
case t_sound: return "sound";
case t_world: return "world";
default: return "unknown";
}
}
char *_copystring( poolhandle_t mempool, const char *s, const char *filename, int fileline )
{
size_t size;
@@ -971,7 +1044,7 @@ used by CS:CZ
*/
void *GAME_EXPORT pfnSequenceGet( const char *fileName, const char *entryName )
{
Msg( "%s: file %s, entry %s\n", __func__, fileName, entryName );
Msg( "Sequence_Get: file %s, entry %s\n", fileName, entryName );
return NULL;
}
@@ -985,7 +1058,7 @@ used by CS:CZ
*/
void *GAME_EXPORT pfnSequencePickSentence( const char *groupName, int pickMethod, int *picked )
{
Msg( "%s: group %s, pickMethod %i\n", __func__, groupName, pickMethod );
Msg( "Sequence_PickSentence: group %s, pickMethod %i\n", groupName, pickMethod );
return NULL;

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