Compare commits
235
Commits
votebgstuff
...
emotes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2800685cfc | ||
|
|
c479d9d706 | ||
|
|
338fbfbeaf | ||
|
|
5ca12bb421 | ||
|
|
6c94e0c9bf | ||
|
|
83d0f6bb50 | ||
|
|
7e06fc986f | ||
|
|
3f5328371a | ||
|
|
148fcc8dab | ||
|
|
72a67d306f | ||
|
|
0dcdcc3da1 | ||
|
|
729c60c9b0 | ||
|
|
1b418caf6b | ||
|
|
d275db9bb4 | ||
|
|
21cfd7c361 | ||
|
|
5a44afcd9f | ||
|
|
3c282b5022 | ||
|
|
f4d40bd55f | ||
|
|
5d8bb3223f | ||
|
|
5e1f943a38 | ||
|
|
612431c1f1 | ||
|
|
fca7b4a837 | ||
|
|
d2bab80b29 | ||
|
|
465fea8bb3 | ||
|
|
78ab90c1a6 | ||
|
|
102e944fd5 | ||
|
|
04385d9700 | ||
|
|
d47e20b54e | ||
|
|
7ef2da5922 | ||
|
|
5638709670 | ||
|
|
9bd4a933cf | ||
|
|
e233635783 | ||
|
|
da24ba20c7 | ||
|
|
74bdabc636 | ||
|
|
4b129314d3 | ||
|
|
3a55972997 | ||
|
|
6e04e4171e | ||
|
|
4e9f9b7e0e | ||
|
|
9650139470 | ||
|
|
054a40a4b2 | ||
|
|
db67176eca | ||
|
|
0b7a4ff4e0 | ||
|
|
972ee5cf76 | ||
|
|
aef02cb347 | ||
|
|
36e485b2a3 | ||
|
|
d23c51e707 | ||
|
|
0db437aadd | ||
|
|
e351c1e62a | ||
|
|
b541de4f8c | ||
|
|
604bc40021 | ||
|
|
be8ddebd80 | ||
|
|
02feb3ad5c | ||
|
|
49f13d2a59 | ||
|
|
b2a36850cb | ||
|
|
8353c1efdd | ||
|
|
d19a2e0912 | ||
|
|
07432c0381 | ||
|
|
4fb3b63152 | ||
|
|
85b736620a | ||
|
|
9f770993d4 | ||
|
|
4bd02ad325 | ||
|
|
6e7b45d15c | ||
|
|
99ebca51d5 | ||
|
|
24eb888af3 | ||
|
|
09ce33abb9 | ||
|
|
044ff158a1 | ||
|
|
36c68d055c | ||
|
|
ddf7d7cdcb | ||
|
|
38950d580f | ||
|
|
707701f317 | ||
|
|
09507d635b | ||
|
|
ab85d6a693 | ||
|
|
5011b17f88 | ||
|
|
7bef45f701 | ||
|
|
40cbce8f9f | ||
|
|
70a70084c9 | ||
|
|
b6da6359d3 | ||
|
|
97075ca5c5 | ||
|
|
e94737945a | ||
|
|
57f15e0213 | ||
|
|
2eae9b197c | ||
|
|
68c7620349 | ||
|
|
7a3faf34e7 | ||
|
|
d401644447 | ||
|
|
dfc349b230 | ||
|
|
be3e5a964d | ||
|
|
687d2bd894 | ||
|
|
78b642cf2d | ||
|
|
cb3b6ca34b | ||
|
|
ad15bf0ea3 | ||
|
|
56021ed999 | ||
|
|
3d22a5906f | ||
|
|
b6d771b48f | ||
|
|
ab30fb2e5e | ||
|
|
618d9e4cdf | ||
|
|
bf78ad9c75 | ||
|
|
918a4e8cd9 | ||
|
|
e90c84c9ac | ||
|
|
a9209a4887 | ||
|
|
0a3e7ba09f | ||
|
|
eb132b08c0 | ||
|
|
82407c3560 | ||
|
|
f1a8210663 | ||
|
|
1d722be4bc | ||
|
|
62a660bfe1 | ||
|
|
2984795175 | ||
|
|
da706d89a5 | ||
|
|
a8005d5cec | ||
|
|
793ccff6e6 | ||
|
|
e7db9bf1fd | ||
|
|
88d62c93a1 | ||
|
|
d73532d019 | ||
|
|
84d3d23936 | ||
|
|
717947843b | ||
|
|
968584a316 | ||
|
|
ccd67f621a | ||
|
|
80b301dbbe | ||
|
|
001e61d39d | ||
|
|
19c98a436a | ||
|
|
8dd6d7cfdd | ||
|
|
7456b6e02c | ||
|
|
5e8096f74c | ||
|
|
6af77afc44 | ||
|
|
42eeb7bdf5 | ||
|
|
6f4b1e5125 | ||
|
|
22e65cdda8 | ||
|
|
9d342d0f3d | ||
|
|
9583bed718 | ||
|
|
b69ce75712 | ||
|
|
a1cd19b023 | ||
|
|
6e50710b25 | ||
|
|
989a971d27 | ||
|
|
24ee56ce7a | ||
|
|
52f99dd9c1 | ||
|
|
6374fda570 | ||
|
|
cdd2d6323e | ||
|
|
c508a7ea78 | ||
|
|
1380a394c7 | ||
|
|
2c937099d4 | ||
|
|
0a936b3bba | ||
|
|
0a31e0a65e | ||
|
|
8627a18452 | ||
|
|
be528adea5 | ||
|
|
5eb4ed8391 | ||
|
|
9a00d30c0c | ||
|
|
71237c5e11 | ||
|
|
9c6e32a1ab | ||
|
|
1bc18801c8 | ||
|
|
221f2a956e | ||
|
|
b450abdf4d | ||
|
|
d36eed3c09 | ||
|
|
43ee791d4a | ||
|
|
c921945922 | ||
|
|
5f8c77e752 | ||
|
|
064db977aa | ||
|
|
5868cd9777 | ||
|
|
b0ddde996a | ||
|
|
e03c3766f0 | ||
|
|
953c0d7451 | ||
|
|
97b303c362 | ||
|
|
2ffe736a20 | ||
|
|
21f2032f34 | ||
|
|
2f66207205 | ||
|
|
5a14b09c1f | ||
|
|
7e9da92dbe | ||
|
|
a27550b95b | ||
|
|
556883487d | ||
|
|
96f8533479 | ||
|
|
f3cca27448 | ||
|
|
252563725d | ||
|
|
9a934a55e2 | ||
|
|
f07d5d381e | ||
|
|
3faab66ef4 | ||
|
|
2a023246be | ||
|
|
006e7fe8f8 | ||
|
|
1a7ff21a04 | ||
|
|
98cb0fdcb2 | ||
|
|
1fd7e9cdac | ||
|
|
0a2eac4d3a | ||
|
|
9ac6fffd4d | ||
|
|
da20f4a087 | ||
|
|
dbf822ced9 | ||
|
|
095842f4aa | ||
|
|
8c290d7597 | ||
|
|
8a6f4db9af | ||
|
|
99186a86db | ||
|
|
c67bf97f7b | ||
|
|
33a1540fcd | ||
|
|
529b0d643a | ||
|
|
4576efbe5c | ||
|
|
185375ece1 | ||
|
|
d11521954e | ||
|
|
41c4300ec2 | ||
|
|
51d5023f29 | ||
|
|
d2878f8834 | ||
|
|
7808159d23 | ||
|
|
e759431948 | ||
|
|
268ccce955 | ||
|
|
f2d3432bf5 | ||
|
|
2da89f1946 | ||
|
|
6153733df4 | ||
|
|
d280b39f9f | ||
|
|
236e7b8d45 | ||
|
|
dcccf672c9 | ||
|
|
03f81bed16 | ||
|
|
fc51c1ba88 | ||
|
|
83d20a72ab | ||
|
|
d50c1ab6d7 | ||
|
|
984c2ff8d6 | ||
|
|
74646acdca | ||
|
|
45ffe87ba6 | ||
|
|
37eb8cfa57 | ||
|
|
a0f903f162 | ||
|
|
8fb1775606 | ||
|
|
fab7635373 | ||
|
|
b29ca13916 | ||
|
|
f1f0782256 | ||
|
|
0e9a825f63 | ||
|
|
68ae880979 | ||
|
|
5c53a90eea | ||
|
|
55c6ba6d12 | ||
|
|
dd499a410f | ||
|
|
c04ba992a7 | ||
|
|
27c053cd48 | ||
|
|
e47e58a982 | ||
|
|
c05068f22f | ||
|
|
f5cb473f3d | ||
|
|
c5b72f24b5 | ||
|
|
7c34733eea | ||
|
|
359befd857 | ||
|
|
279dfcafc4 | ||
|
|
393ade780c | ||
|
|
8b2e6ea17b | ||
|
|
8c31682723 | ||
|
|
7c87b5259a |
No files matched your search
+8
-7
@@ -13,16 +13,17 @@ Win32_LIB_ASM_Release
|
|||||||
*.dgb
|
*.dgb
|
||||||
*.debug
|
*.debug
|
||||||
*.debug.txt
|
*.debug.txt
|
||||||
/bin/VC10/
|
|
||||||
/objs/VC10/
|
|
||||||
*.user
|
*.user
|
||||||
*.db
|
*.db
|
||||||
*.opendb
|
*.opendb
|
||||||
/.vs
|
/.vs
|
||||||
/debian
|
/debian
|
||||||
/assets/debian
|
/assets/debian
|
||||||
compile.sh
|
/make
|
||||||
*.gz
|
/bin
|
||||||
.vscode/
|
/build
|
||||||
out
|
/build/*
|
||||||
build
|
/CMakeUserPresets.json
|
||||||
|
/out
|
||||||
|
/objs/VC10
|
||||||
|
*.kate-swp
|
||||||
+31
@@ -161,6 +161,37 @@ Duration is in milliseconds and is optional to set, default value is 84ms.
|
|||||||
Exactly same as P_CheckSight but uses cheaper algorithm, useful for things like nametags. Doesn't work exactly
|
Exactly same as P_CheckSight but uses cheaper algorithm, useful for things like nametags. Doesn't work exactly
|
||||||
like P_CheckSight so don't use it for anything gameplay-related.
|
like P_CheckSight so don't use it for anything gameplay-related.
|
||||||
|
|
||||||
|
## musicdef_t
|
||||||
|
|
||||||
|
Userdata structure representing a musicdef. Fields:
|
||||||
|
|
||||||
|
`musicdef.name` - song identifier ("kmap01" for example).
|
||||||
|
|
||||||
|
`musicdef.usage`, `musicdef.source` - fields from vanilla MUSICDEFS lump.
|
||||||
|
|
||||||
|
`musicdef.filename` - unused for now.
|
||||||
|
|
||||||
|
`musicdef.title`, `musicdef.alttitle`, `musicdef.authors` - fields from MUSCINFO lump.
|
||||||
|
|
||||||
|
`#musicdef` - returns integer id for musicdef (which can be used as index in `musicdefs`).
|
||||||
|
|
||||||
|
All fields are read-only.
|
||||||
|
|
||||||
|
## S_FindMusicCredit(name)
|
||||||
|
|
||||||
|
Returns musicdef corresponding to music with given identifier. For example, `S_FindMusicCredit("kmap01")` will return
|
||||||
|
musicdef for green hills music.
|
||||||
|
|
||||||
|
## musicdefs
|
||||||
|
|
||||||
|
Global table for all musicdefs, similar to mobjinfo, states, etc. Can take either integer indices,
|
||||||
|
from `0` to `#musicdefs-1`, or string indices (which is equal to calling `S_FindMusicCredit`).
|
||||||
|
|
||||||
|
## addHook("MusicCredit", function(musicdef))
|
||||||
|
|
||||||
|
Hook is called whenever `S_ShowMusicCredit` (either from game or mod) is called. Takes musicdef as only argument, returning true
|
||||||
|
will overwrite vanilla behavior (not show music credit), can be used to implement custom music credit pop-ups.
|
||||||
|
|
||||||
# Other changes
|
# Other changes
|
||||||
|
|
||||||
## P_PlayRinglossSound(source, damager)
|
## P_PlayRinglossSound(source, damager)
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
/lsdlsrb2
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
/lsdlsrb2
|
|
||||||
/pnd
|
|
||||||
/*.mo
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
/lsdlsrb2
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
/lsdl2srb2kart
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
*.exe
|
|
||||||
*.mo
|
|
||||||
r_opengl.dll
|
|
||||||
*.bat
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
*.exe
|
|
||||||
*.mo
|
|
||||||
r_opengl.dll
|
|
||||||
*.bat
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
/srb2sdl.exe
|
|
||||||
/srb2win.exe
|
|
||||||
/r_opengl.dll
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
*.exe
|
|
||||||
*.mo
|
|
||||||
r_opengl.dll
|
|
||||||
*.bat
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#All folders
|
|
||||||
SRB2.res
|
|
||||||
depend.dep
|
|
||||||
depend.ped
|
|
||||||
*.o
|
|
||||||
#VC9 folder only
|
|
||||||
/VC9/Win32
|
|
||||||
/VC9/x64
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
||||||
+13
-1
@@ -228,6 +228,14 @@ set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
|
|||||||
"Use statically linked OpenGL. NOT RECOMMENDED.")
|
"Use statically linked OpenGL. NOT RECOMMENDED.")
|
||||||
set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL
|
set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL
|
||||||
"Enable OpenGL FBO Downsampling support.")
|
"Enable OpenGL FBO Downsampling support.")
|
||||||
|
set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL
|
||||||
|
"Build a dedicated server.")
|
||||||
|
|
||||||
|
if(${SRB2_CONFIG_DEDICATED})
|
||||||
|
set(SRB2_CONFIG_HAVE_GME NO)
|
||||||
|
set(SRB2_CONFIG_HAVE_OPENMPT NO)
|
||||||
|
set(SRB2_CONFIG_HWRENDER NO)
|
||||||
|
endif()
|
||||||
|
|
||||||
### use internal libraries?
|
### use internal libraries?
|
||||||
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
|
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
|
||||||
@@ -554,7 +562,11 @@ add_definitions(-DCMAKECONFIG)
|
|||||||
# ${SRB2_BLUA_HEADERS}
|
# ${SRB2_BLUA_HEADERS}
|
||||||
#)
|
#)
|
||||||
|
|
||||||
add_subdirectory(sdl)
|
if(${SRB2_CONFIG_DEDICATED})
|
||||||
|
add_subdirectory(dedicated)
|
||||||
|
else()
|
||||||
|
add_subdirectory(sdl)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE})
|
if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE})
|
||||||
message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(")
|
message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(")
|
||||||
|
|||||||
+348
-713
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,19 @@
|
|||||||
|
makedir:=$(makedir)/Dedicated
|
||||||
|
|
||||||
|
sources+=$(call List,dedicated/Sourcefile)
|
||||||
|
|
||||||
|
opts+=-DDEDICATED
|
||||||
|
|
||||||
|
ifdef MINGW
|
||||||
|
libs+=-mconsole
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NOTHREADS
|
||||||
|
opts+=-DHAVE_THREADS
|
||||||
|
sources+=dedicated/i_threads.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
NOOPENMPT=1
|
||||||
|
NOGME=1
|
||||||
|
NOHW=1
|
||||||
|
NOUPNP=1
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
#
|
||||||
|
# Detect the host system and compiler version.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Previously featured:\
|
||||||
|
PANDORA\
|
||||||
|
DUMMY\
|
||||||
|
DJGPPDOS\
|
||||||
|
SOLARIS\
|
||||||
|
MACOSX\
|
||||||
|
|
||||||
|
all_systems:=\
|
||||||
|
LINUX64\
|
||||||
|
MINGW64\
|
||||||
|
MINGW\
|
||||||
|
UNIX\
|
||||||
|
LINUX\
|
||||||
|
FREEBSD\
|
||||||
|
HAIKU\
|
||||||
|
|
||||||
|
# check for user specified system
|
||||||
|
ifeq (,$(filter $(all_systems),$(.VARIABLES)))
|
||||||
|
ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
|
||||||
|
|
||||||
|
ifeq ($(shell uname -s | grep -o MINGW64),MINGW64) # 64-bit MinGW
|
||||||
|
_m=Detected a Windows system,\
|
||||||
|
compiling for 64-bit MinGW SDL...)
|
||||||
|
$(call Print,$(_m))
|
||||||
|
MINGW64=1
|
||||||
|
else # 32-bit MinGW
|
||||||
|
_m=Detected a Windows system,\
|
||||||
|
compiling for 32-bit MinGW SDL...)
|
||||||
|
$(call Print,$(_m))
|
||||||
|
MINGW=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
NOOBJDUMP=1
|
||||||
|
else # if you on the *nix
|
||||||
|
|
||||||
|
system:=$(shell uname -s)
|
||||||
|
|
||||||
|
ifeq ($(system),Linux)
|
||||||
|
new_system:=LINUX
|
||||||
|
else ifeq ($(system),Haiku)
|
||||||
|
new_system:=HAIKU
|
||||||
|
else
|
||||||
|
|
||||||
|
$(error \
|
||||||
|
Could not automatically detect your system,\
|
||||||
|
try specifying a system manually)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(shell getconf LONG_BIT),64)
|
||||||
|
system+=64-bit
|
||||||
|
new_system:=$(new_system)64
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(call Print,Detected $(system) ($(new_system))...)
|
||||||
|
$(new_system):=1
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# This must have high to low order.
|
||||||
|
gcc_versions:=\
|
||||||
|
151 150 15\
|
||||||
|
142 141 140 14\
|
||||||
|
132 131 130 13\
|
||||||
|
123 122 121 120 12\
|
||||||
|
114 113 112 111 110 11\
|
||||||
|
105 104 103 102 101 100 10\
|
||||||
|
95 94 93 92 91 90\
|
||||||
|
85 84 83 82 81 80\
|
||||||
|
75 74 73 72 71 70\
|
||||||
|
64 63 62 61 60\
|
||||||
|
55 54 53 52 51 50\
|
||||||
|
49 48 47 46 45 44 43 42 41 40
|
||||||
|
|
||||||
|
latest_gcc_version:=15.1.1
|
||||||
|
|
||||||
|
# Automatically set version flag, but not if one was
|
||||||
|
# manually set. And don't bother if this is a clean only
|
||||||
|
# run.
|
||||||
|
ifeq (,$(call Wildvar,GCC% destructive))
|
||||||
|
|
||||||
|
# can't use $(CC) --version here since that uses argv[0] to display the name
|
||||||
|
# also gcc outputs the information to stderr, so I had to do 2>&1
|
||||||
|
# this program really doesn't like identifying itself
|
||||||
|
shellversion:=$(shell $(CC) -v 2>&1)
|
||||||
|
# Try to remove "-win32"
|
||||||
|
version:=$(subst -win32,.0,$(shellversion))
|
||||||
|
|
||||||
|
# check if this is in fact GCC
|
||||||
|
ifneq (,$(findstring gcc version,$(version)))
|
||||||
|
|
||||||
|
# in stark contrast to the name, gcc will give me a nicely formatted version number for free
|
||||||
|
shellversion:=$(shell $(CC) -dumpfullversion)
|
||||||
|
|
||||||
|
# Try to remove "-win32"
|
||||||
|
version:=$(subst -win32,.0,$(shellversion))
|
||||||
|
|
||||||
|
# Turn version into words of major, minor
|
||||||
|
v:=$(subst ., ,$(version))
|
||||||
|
# concat. major minor
|
||||||
|
v:=$(word 1,$(v))$(word 2,$(v))
|
||||||
|
|
||||||
|
# If this version is not in the list,
|
||||||
|
# default to the latest supported
|
||||||
|
ifeq (,$(filter $(v),$(gcc_versions)))
|
||||||
|
define line =
|
||||||
|
Your compiler version, GCC $(version), \
|
||||||
|
is not supported by the Makefile.
|
||||||
|
The Makefile will assume GCC $(latest_gcc_version).
|
||||||
|
endef
|
||||||
|
$(call Print,$(line))
|
||||||
|
GCC$(subst .,,$(latest_gcc_version)):=1
|
||||||
|
else
|
||||||
|
$(call Print,Detected GCC $(version) (GCC$(v)))
|
||||||
|
GCC$(v):=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
#
|
||||||
|
# Makefile for feature flags.
|
||||||
|
#
|
||||||
|
|
||||||
|
passthru_opts+=\
|
||||||
|
NOHW NOMD5 NOPOSTPROCESSING\
|
||||||
|
MOBJCONSISTANCY PACKETDROP ZDEBUG\
|
||||||
|
HAVE_MINIUPNPC\
|
||||||
|
HAVE_DISCORDRPC DEVELOP\
|
||||||
|
NOBLUAJIT
|
||||||
|
|
||||||
|
# build with debugging information
|
||||||
|
ifdef DEBUGMODE
|
||||||
|
PACKETDROP=1
|
||||||
|
opts+=-DPARANOIA -DRANGECHECK
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NOHW
|
||||||
|
opts+=-DHWRENDER
|
||||||
|
|
||||||
|
ifndef NOSCREENFBO
|
||||||
|
opts+=-DUSE_FBO_OGL
|
||||||
|
endif
|
||||||
|
|
||||||
|
sources+=$(call List,hardware/Sourcefile)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NOMD5
|
||||||
|
sources+=md5.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NONET
|
||||||
|
ifndef NOSATURNJOIN
|
||||||
|
opts+=-DDOSATURNJOIN
|
||||||
|
endif
|
||||||
|
ifndef NOSATURNPAK
|
||||||
|
opts+=-DDOSATURNPAK
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NOZLIB
|
||||||
|
ifndef NOPNG
|
||||||
|
ifdef PNG_PKGCONFIG
|
||||||
|
$(eval $(call Use_pkg_config,PNG_PKGCONFIG))
|
||||||
|
else
|
||||||
|
PNG_CONFIG?=$(call Prefix,libpng-config)
|
||||||
|
$(eval $(call Configure,PNG,$(PNG_CONFIG) \
|
||||||
|
$(if $(PNG_STATIC),--static),,--ldflags))
|
||||||
|
endif
|
||||||
|
ifdef LINUX
|
||||||
|
opts+=-D_LARGEFILE64_SOURCE
|
||||||
|
endif
|
||||||
|
opts+=-DHAVE_PNG
|
||||||
|
sources+=apng.c
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NOCURL
|
||||||
|
CURLCONFIG?=curl-config
|
||||||
|
$(eval $(call Configure,CURL,$(CURLCONFIG)))
|
||||||
|
opts+=-DHAVE_CURL
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef HAVE_MINIUPNPC
|
||||||
|
MINIUPNPC_PKGCONFIG?=miniupnpc
|
||||||
|
$(eval $(call Use_pkg_config,MINIUPNPC))
|
||||||
|
HAVE_MINIUPNPC=1
|
||||||
|
opts+=-DHAVE_MINIUPNPC
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NOLIBBACKTRACE
|
||||||
|
$(eval $(call Propogate_flags,LIBBACKTRACE))
|
||||||
|
libs+=-lbacktrace
|
||||||
|
opts+=-DHAVE_LIBBACKTRACE
|
||||||
|
endif
|
||||||
|
|
||||||
|
#windoze hack
|
||||||
|
ifdef MINGW
|
||||||
|
ifndef NODISCORDRPC
|
||||||
|
HAVE_DISCORDRPC=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef HAVE_DISCORDRPC
|
||||||
|
$(eval $(call Propogate_flags,DISCORDRPC))
|
||||||
|
libs+=-ldiscord-rpc
|
||||||
|
opts+=-DUSE_STUN
|
||||||
|
sources+=discord.c stun.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
# (Valgrind is a memory debugger.)
|
||||||
|
ifdef VALGRIND
|
||||||
|
VALGRIND_PKGCONFIG?=valgrind
|
||||||
|
VALGRIND_LDFLAGS=
|
||||||
|
$(eval $(call Use_pkg_config,VALGRIND))
|
||||||
|
ZDEBUG=1
|
||||||
|
opts+=-DHAVE_VALGRIND
|
||||||
|
endif
|
||||||
|
|
||||||
|
default_packages:=\
|
||||||
|
GME/libgme/LIBGME\
|
||||||
|
OPENMPT/libopenmpt/LIBOPENMPT\
|
||||||
|
ZLIB/zlib\
|
||||||
|
|
||||||
|
$(foreach p,$(default_packages),\
|
||||||
|
$(eval $(call Check_pkg_config,$(p))))
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
#
|
||||||
|
# Makefile options for Haiku
|
||||||
|
#
|
||||||
|
|
||||||
|
opts+=-DUNIXCOMMON -DLUA_USE_POSIX
|
||||||
|
|
||||||
|
ifndef DEDICATED
|
||||||
|
ifndef DUMMY
|
||||||
|
SDL?=1
|
||||||
|
DEDICATED?=0
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
NOEXECINFO=1
|
||||||
|
|
||||||
|
ifeq (${SDL},1)
|
||||||
|
EXENAME?=srb2haiku
|
||||||
|
else ifeq (${DEDICATED},1)
|
||||||
|
EXENAME?=srb2haikud
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NONET
|
||||||
|
libs+=-lnetwork
|
||||||
|
endif
|
||||||
|
|
||||||
|
define _set =
|
||||||
|
$(1)_CFLAGS?=$($(1)_opts)
|
||||||
|
$(1)_LDFLAGS?=$($(1)_libs)
|
||||||
|
endef
|
||||||
|
|
||||||
|
lib:=../libs/gme
|
||||||
|
LIBGME_opts:=-I$(lib)/include
|
||||||
|
LIBGME_libs:=-l:libgme.so.0
|
||||||
|
$(eval $(call _set,LIBGME))
|
||||||
|
|
||||||
|
lib:=../libs/libopenmpt
|
||||||
|
LIBOPENMPT_opts:=-I$(lib)/inc
|
||||||
|
LIBOPENMPT_libs:=-l:libopenmpt.so.0
|
||||||
|
$(eval $(call _set,LIBOPENMPT))
|
||||||
|
|
||||||
|
ifdef SDL
|
||||||
|
lib:=../libs/SDL2_mixer
|
||||||
|
mixer_opts:=-I$(lib)/include
|
||||||
|
mixer_libs:=-l:libSDL2_mixer-2.0.so.0
|
||||||
|
|
||||||
|
lib:=../libs/SDL2
|
||||||
|
SDL_opts:=-I$(lib)/include $(mixer_opts)
|
||||||
|
SDL_libs:=$(mixer_libs) -l:libSDL2-2.0.so.0
|
||||||
|
$(eval $(call _set,SDL))
|
||||||
|
endif
|
||||||
|
|
||||||
|
lib:=../libs/zlib
|
||||||
|
ZLIB_opts:=-I$(lib)
|
||||||
|
ZLIB_libs:=-l:libz.so.1
|
||||||
|
$(eval $(call _set,ZLIB))
|
||||||
|
|
||||||
|
ifndef PNG_CONFIG
|
||||||
|
PNG_opts:=
|
||||||
|
PNG_libs:=-l:libpng16.so.16
|
||||||
|
$(eval $(call _set,PNG))
|
||||||
|
endif
|
||||||
|
|
||||||
|
lib:=../libs/curl
|
||||||
|
CURL_opts:=-I$(lib)/include
|
||||||
|
CURL_libs:=-l:libcurl.so.4
|
||||||
|
$(eval $(call _set,CURL))
|
||||||
|
|
||||||
|
lib:=../libs/miniupnpc
|
||||||
|
MINIUPNPC_opts:=-I$(lib)/include
|
||||||
|
MINIUPNPC_libs:=-l:libminiupnpc.so.17
|
||||||
|
$(eval $(call _set,MINIUPNPC))
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#
|
||||||
|
# Makefile options for unices (linux, bsd...)
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
opts+=-DUNIXCOMMON -DLUA_USE_POSIX
|
||||||
|
# Use -rdynamic so a backtrace log shows function names
|
||||||
|
# instead of addresses
|
||||||
|
libs+=-lm -rdynamic
|
||||||
|
|
||||||
|
ifndef NOHW
|
||||||
|
opts+=-I/usr/X11R6/include
|
||||||
|
libs+=-L/usr/X11R6/lib
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef DEDICATED
|
||||||
|
SDL?=1
|
||||||
|
DEDICATED?=0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq (${SDL},1)
|
||||||
|
EXENAME?=lsdl2srb2kart
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq (${DEDICATED},1)
|
||||||
|
EXENAME?=lsrb2kartd
|
||||||
|
endif
|
||||||
|
|
||||||
|
# In common usage.
|
||||||
|
ifdef LINUX
|
||||||
|
libs+=-lrt
|
||||||
|
passthru_opts+=NOTERMIOS
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Tested by Steel, as of release 2.2.8.
|
||||||
|
ifdef FREEBSD
|
||||||
|
opts+=-I/usr/X11R6/include -DLINUX -DFREEBSD
|
||||||
|
libs+=-L/usr/X11R6/lib -lkvm -lexecinfo
|
||||||
|
endif
|
||||||
|
|
||||||
|
# FIXME: UNTESTED
|
||||||
|
#ifdef SOLARIS
|
||||||
|
#NOIPX=1
|
||||||
|
#opts+=-I/usr/local/include -I/opt/sfw/include \
|
||||||
|
# -DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP
|
||||||
|
#libs+=-L/opt/sfw/lib -lsocket -lnsl
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#
|
||||||
|
# Warn about old build directories and offer to purge.
|
||||||
|
#
|
||||||
|
|
||||||
|
_old:=$(wildcard $(addprefix ../bin/,FreeBSD Linux \
|
||||||
|
Linux64 Mingw Mingw64 SDL dummy) ../objs ../dep)
|
||||||
|
|
||||||
|
ifdef _old
|
||||||
|
$(foreach v,$(_old),$(info $(abspath $(v))))
|
||||||
|
$(info )
|
||||||
|
$(info These directories are no longer\
|
||||||
|
required and should be removed.)
|
||||||
|
$(info You may remove them manually or\
|
||||||
|
by using 'make distclean')
|
||||||
|
$(error )
|
||||||
|
endif
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
#
|
||||||
|
# Platform specific options.
|
||||||
|
#
|
||||||
|
|
||||||
|
PKG_CONFIG?=pkg-config
|
||||||
|
|
||||||
|
ifdef WINDOWSHELL
|
||||||
|
rmrf=-2>NUL DEL /S /Q
|
||||||
|
mkdir=-2>NUL MD
|
||||||
|
cat=TYPE
|
||||||
|
else
|
||||||
|
rmrf=rm -rf
|
||||||
|
mkdir=mkdir -p
|
||||||
|
cat=cat
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef LINUX64
|
||||||
|
LINUX=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef MINGW64
|
||||||
|
MINGW=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef LINUX
|
||||||
|
UNIX=1
|
||||||
|
ifdef LINUX64
|
||||||
|
NONX86=1
|
||||||
|
# LINUX64 does not imply X86_64=1;
|
||||||
|
# could mean ARM64 or Itanium
|
||||||
|
platform=linux/64
|
||||||
|
else
|
||||||
|
platform=linux
|
||||||
|
endif
|
||||||
|
else ifdef FREEBSD
|
||||||
|
UNIX=1
|
||||||
|
platform=freebsd
|
||||||
|
else ifdef HAIKU
|
||||||
|
# Give Haiku its own configuration, since it
|
||||||
|
# isn't actually UNIX.
|
||||||
|
include Makefile.d/haiku.mk
|
||||||
|
else ifdef SOLARIS # FIXME: UNTESTED
|
||||||
|
UNIX=1
|
||||||
|
platform=solaris
|
||||||
|
else ifdef CYGWIN32 # FIXME: UNTESTED
|
||||||
|
platform=cygwin
|
||||||
|
else ifdef MINGW
|
||||||
|
ifdef MINGW64
|
||||||
|
NONX86=1
|
||||||
|
NOASM=1
|
||||||
|
# MINGW64 should not necessarily imply X86_64=1,
|
||||||
|
# but we make that assumption elsewhere
|
||||||
|
# Once that changes, remove this
|
||||||
|
X86_64=1
|
||||||
|
platform=mingw/64
|
||||||
|
else
|
||||||
|
platform=mingw
|
||||||
|
endif
|
||||||
|
include Makefile.d/win32.mk
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef platform
|
||||||
|
makedir:=$(makedir)/$(platform)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef UNIX
|
||||||
|
include Makefile.d/nix.mk
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SDL), 1)
|
||||||
|
include Makefile.d/sdl.mk
|
||||||
|
else ifeq ($(DEDICATED), 1)
|
||||||
|
include Makefile.d/dedicated.mk
|
||||||
|
else
|
||||||
|
include Makefile.d/dummy.mk
|
||||||
|
endif
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
#
|
||||||
|
# Makefile options for SDL2 backend.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# SDL...., *looks at Alam*, THIS IS A MESS!
|
||||||
|
#
|
||||||
|
# ...a little bird flexes its muscles...
|
||||||
|
#
|
||||||
|
|
||||||
|
makedir:=$(makedir)/SDL
|
||||||
|
|
||||||
|
opts+=-DDIRECTFULLSCREEN -DHAVE_SDL
|
||||||
|
sources+=$(call List,sdl/Sourcefile)
|
||||||
|
|
||||||
|
NOUPNP=1
|
||||||
|
|
||||||
|
# FIXME: UNTESTED
|
||||||
|
#ifdef PANDORA
|
||||||
|
#include sdl/SRB2Pandora/Makefile.cfg
|
||||||
|
#endif #ifdef PANDORA
|
||||||
|
|
||||||
|
# FIXME: UNTESTED
|
||||||
|
#ifdef CYGWIN32
|
||||||
|
#include sdl/MakeCYG.cfg
|
||||||
|
#endif #ifdef CYGWIN32
|
||||||
|
|
||||||
|
ifndef NOHW
|
||||||
|
sources+=sdl/ogl_sdl.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef NOMIXER
|
||||||
|
sources+=sdl/sdl_sound.c
|
||||||
|
else
|
||||||
|
opts+=-DHAVE_MIXER
|
||||||
|
sources+=sdl/mixer_sound.c
|
||||||
|
|
||||||
|
ifndef HAIKU # Haiku has a special import path
|
||||||
|
libs+=-lSDL2_mixer
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NOTHREADS
|
||||||
|
opts+=-DHAVE_THREADS
|
||||||
|
sources+=sdl/i_threads.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef SDL_PKGCONFIG
|
||||||
|
$(eval $(call Use_pkg_config,SDL))
|
||||||
|
else
|
||||||
|
SDL_CONFIG?=$(call Prefix,sdl2-config)
|
||||||
|
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
|
||||||
|
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \
|
||||||
|
$(if $(STATIC),--static-libs,--libs))
|
||||||
|
$(eval $(call Propogate_flags,SDL))
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef MINGW
|
||||||
|
ifndef NOSDLMAIN
|
||||||
|
SDLMAIN=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef SDLMAIN
|
||||||
|
opts+=-DSDLMAIN
|
||||||
|
else
|
||||||
|
ifdef MINGW
|
||||||
|
opts+=-Umain
|
||||||
|
libs+=-mconsole
|
||||||
|
endif
|
||||||
|
endif
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
#
|
||||||
|
# Utility macros for the rest of the Makefiles.
|
||||||
|
#
|
||||||
|
|
||||||
|
Ifnot=$(if $(1),$(3),$(2))
|
||||||
|
Ifndef=$(call Ifnot,$($(1)),$(2),$(3))
|
||||||
|
|
||||||
|
# Match and expand a list of variables by pattern.
|
||||||
|
Wildvar=$(foreach v,$(filter $(1),$(.VARIABLES)),$($(v)))
|
||||||
|
|
||||||
|
# Read a list of words from file and prepend each with the
|
||||||
|
# directory of the file.
|
||||||
|
_cat=$(shell $(cat) $(call Windows_path,$(1)))
|
||||||
|
List=$(addprefix $(dir $(1)),$(call _cat,$(1)))
|
||||||
|
|
||||||
|
# Convert path separators to backslash on Windows.
|
||||||
|
Windows_path=$(if $(WINDOWSHELL),$(subst /,\,$(1)),$(1))
|
||||||
|
|
||||||
|
define Propogate_flags =
|
||||||
|
opts+=$$($(1)_CFLAGS)
|
||||||
|
libs+=$$($(1)_LDFLAGS)
|
||||||
|
endef
|
||||||
|
|
||||||
|
# Set library's _CFLAGS and _LDFLAGS from some command.
|
||||||
|
# Automatically propogates the flags too.
|
||||||
|
# 1: variable prefix (e.g. CURL)
|
||||||
|
# 2: start of command (e.g. curl-config)
|
||||||
|
# --- optional ----
|
||||||
|
# 3: CFLAGS command arguments, default '--cflags'
|
||||||
|
# 4: LDFLAGS command arguments, default '--libs'
|
||||||
|
# 5: common command arguments at the end of command
|
||||||
|
define Configure =
|
||||||
|
$(1)_CFLAGS?=$$(shell $(2) $(or $(3),--cflags) $(5))
|
||||||
|
$(1)_LDFLAGS?=$$(shell $(2) $(or $(4),--libs) $(5))
|
||||||
|
$(call Propogate_flags,$(1))
|
||||||
|
endef
|
||||||
|
|
||||||
|
# Configure library with pkg-config. The package name is
|
||||||
|
# taken from a _PKGCONFIG variable.
|
||||||
|
# 1: variable prefix
|
||||||
|
#
|
||||||
|
# LIBGME_PKGCONFIG=libgme
|
||||||
|
# $(eval $(call Use_pkg_config,LIBGME))
|
||||||
|
define Use_pkg_config =
|
||||||
|
$(call Configure,$(1),$(PKG_CONFIG),,,$($(1)_PKGCONFIG))
|
||||||
|
endef
|
||||||
|
|
||||||
|
# Check disabling flag and configure package in one step
|
||||||
|
# according to delimited argument.
|
||||||
|
# (There is only one argument, but it split by slash.)
|
||||||
|
# 1/: short form library name (uppercase). This is
|
||||||
|
# prefixed with 'NO' and 'HAVE_'. E.g. NOGME, HAVE_GME
|
||||||
|
# /2: package name (e.g. libgme)
|
||||||
|
# /3: variable prefix
|
||||||
|
#
|
||||||
|
# The following example would check if NOGME is not
|
||||||
|
# defined before attempting to define LIBGME_CFLAGS and
|
||||||
|
# LIBGME_LDFLAGS as with Use_pkg_config.
|
||||||
|
#
|
||||||
|
# $(eval $(call Check_pkg_config,GME/libgme/LIBGME))
|
||||||
|
define Check_pkg_config =
|
||||||
|
_p:=$(subst /, ,$(1))
|
||||||
|
_v1:=$$(word 1,$$(_p))
|
||||||
|
_v2:=$$(or $$(word 3,$$(_p)),$$(_v1))
|
||||||
|
ifndef NO$$(_v1)
|
||||||
|
$$(_v2)_PKGCONFIG?=$$(word 2,$$(_p))
|
||||||
|
$$(eval $$(call Use_pkg_config,$$(_v2)))
|
||||||
|
opts+=-DHAVE_$$(_v1)
|
||||||
|
endif
|
||||||
|
endef
|
||||||
|
|
||||||
|
# $(call Prefix,gcc)
|
||||||
|
Prefix=$(if $(PREFIX),$(PREFIX)-)$(1)
|
||||||
|
|
||||||
|
Echo=
|
||||||
|
Echo_name=
|
||||||
|
Print=
|
||||||
|
|
||||||
|
ifndef SILENT
|
||||||
|
Echo=@echo $(1)
|
||||||
|
ifndef ECHO
|
||||||
|
ifndef NOECHOFILENAMES
|
||||||
|
Echo_name=$(call Echo,-- $(1) ...)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifndef MAKE_RESTARTS
|
||||||
|
ifndef destructive
|
||||||
|
Print=$(info $(1))
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
.=$(call Ifndef,ECHO,@)
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
#
|
||||||
|
# Flags to put a sock in GCC!
|
||||||
|
#
|
||||||
|
|
||||||
|
# See the versions list in detect.mk
|
||||||
|
# This will define all version flags going backward.
|
||||||
|
# Yes, it's magic.
|
||||||
|
define _predecessor =
|
||||||
|
ifdef GCC$(firstword $(1))
|
||||||
|
GCC$(lastword $(1)):=1
|
||||||
|
endif
|
||||||
|
endef
|
||||||
|
_n:=$(words $(gcc_versions))
|
||||||
|
$(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
|
||||||
|
$(addprefix =,$(wordlist 2,$(_n),$(gcc_versions)))),\
|
||||||
|
$(and $(findstring =,$(v)),\
|
||||||
|
$(eval $(call _predecessor,$(subst =, ,$(v))))))
|
||||||
|
|
||||||
|
# aggregate returns seem to happen alot in c++ so just supress em lel
|
||||||
|
CXXFLAGS+= -Wno-aggregate-return
|
||||||
|
|
||||||
|
# -W -Wno-unused
|
||||||
|
|
||||||
|
ifdef GCC150
|
||||||
|
opts+=-std=gnu17
|
||||||
|
endif
|
||||||
|
WFLAGS:=-Wall -Wno-trigraphs
|
||||||
|
ifndef GCC295
|
||||||
|
#WFLAGS+=-Wno-packed
|
||||||
|
endif
|
||||||
|
ifndef RELAXWARNINGS
|
||||||
|
WFLAGS+=-W
|
||||||
|
#WFLAGS+=-Wno-sign-compare
|
||||||
|
ifndef GCC295
|
||||||
|
WFLAGS+=-Wno-div-by-zero
|
||||||
|
endif
|
||||||
|
#WFLAGS+=-Wsystem-headers
|
||||||
|
WFLAGS+=-Wfloat-equal
|
||||||
|
#WFLAGS+=-Wtraditional
|
||||||
|
WFLAGS+=-Wundef
|
||||||
|
ifndef GCC295
|
||||||
|
WFLAGS+=-Wendif-labels
|
||||||
|
endif
|
||||||
|
ifdef GCC41
|
||||||
|
WFLAGS+=-Wshadow
|
||||||
|
endif
|
||||||
|
#WFLAGS+=-Wlarger-than-%len%
|
||||||
|
WFLAGS+=-Wpointer-arith -Wbad-function-cast
|
||||||
|
ifdef GCC45
|
||||||
|
#WFLAGS+=-Wc++-compat
|
||||||
|
endif
|
||||||
|
WFLAGS+=-Wcast-qual
|
||||||
|
ifndef NOCASTALIGNWARN
|
||||||
|
WFLAGS+=-Wcast-align
|
||||||
|
endif
|
||||||
|
WFLAGS+=-Wwrite-strings
|
||||||
|
ifndef ERRORMODE
|
||||||
|
#WFLAGS+=-Wconversion
|
||||||
|
ifdef GCC43
|
||||||
|
#WFLAGS+=-Wno-sign-conversion
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
WFLAGS+=-Wsign-compare
|
||||||
|
ifdef GCC91
|
||||||
|
WFLAGS+=-Wno-error=address-of-packed-member
|
||||||
|
endif
|
||||||
|
ifdef GCC45
|
||||||
|
WFLAGS+=-Wlogical-op
|
||||||
|
endif
|
||||||
|
WFLAGS+=-Waggregate-return
|
||||||
|
ifdef HAIKU
|
||||||
|
ifdef GCC41
|
||||||
|
#WFLAGS+=-Wno-attributes
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
#WFLAGS+=-Wstrict-prototypes
|
||||||
|
ifdef GCC40
|
||||||
|
WFLAGS+=-Wold-style-definition
|
||||||
|
endif
|
||||||
|
WFLAGS+=-Wmissing-prototypes -Wmissing-declarations
|
||||||
|
ifdef GCC40
|
||||||
|
WFLAGS+=-Wmissing-field-initializers
|
||||||
|
endif
|
||||||
|
WFLAGS+=-Wmissing-noreturn
|
||||||
|
#WFLAGS+=-Wmissing-format-attribute
|
||||||
|
#WFLAGS+=-Wno-multichar
|
||||||
|
#WFLAGS+=-Wno-deprecated-declarations
|
||||||
|
#WFLAGS+=-Wpacked
|
||||||
|
#WFLAGS+=-Wpadded
|
||||||
|
#WFLAGS+=-Wredundant-decls
|
||||||
|
WFLAGS+=-Wnested-externs
|
||||||
|
#WFLAGS+=-Wunreachable-code
|
||||||
|
WFLAGS+=-Winline
|
||||||
|
ifdef DEBUGMODE
|
||||||
|
WFLAGS+=-Wno-error=inline
|
||||||
|
endif
|
||||||
|
ifdef GCC43
|
||||||
|
WFLAGS+=-funit-at-a-time
|
||||||
|
WFLAGS+=-Wlogical-op
|
||||||
|
endif
|
||||||
|
ifndef GCC295
|
||||||
|
WFLAGS+=-Wdisabled-optimization
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
WFLAGS+=-Wformat-y2k
|
||||||
|
ifdef GCC71
|
||||||
|
WFLAGS+=-Wno-error=format-overflow=2
|
||||||
|
endif
|
||||||
|
WFLAGS+=-Wformat-security
|
||||||
|
ifndef GCC29
|
||||||
|
#WFLAGS+=-Winit-self
|
||||||
|
endif
|
||||||
|
ifdef GCC46
|
||||||
|
WFLAGS+=-Wno-suggest-attribute=noreturn
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef NOLDWARNING
|
||||||
|
LDFLAGS+=-Wl,--as-needed
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef ERRORMODE
|
||||||
|
WFLAGS+=-Werror
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef GCC43
|
||||||
|
#WFLAGS+=-Wno-error=clobbered
|
||||||
|
endif
|
||||||
|
ifdef GCC44
|
||||||
|
#WFLAGS+=-Wno-error=array-bounds
|
||||||
|
endif
|
||||||
|
ifdef GCC46
|
||||||
|
WFLAGS+=-Wno-error=suggest-attribute=noreturn
|
||||||
|
endif
|
||||||
|
ifdef GCC54
|
||||||
|
WFLAGS+=-Wno-logical-op -Wno-error=logical-op
|
||||||
|
endif
|
||||||
|
ifdef GCC61
|
||||||
|
WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare
|
||||||
|
endif
|
||||||
|
ifdef GCC71
|
||||||
|
WFLAGS+=-Wimplicit-fallthrough=4
|
||||||
|
endif
|
||||||
|
ifdef GCC81
|
||||||
|
WFLAGS+=-Wno-error=format-overflow
|
||||||
|
WFLAGS+=-Wno-format-overflow
|
||||||
|
WFLAGS+=-Wno-error=multistatement-macros
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef NONX86
|
||||||
|
ifdef X86_64 # yeah that SEEMS contradictory
|
||||||
|
opts+=-march=nocona
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ifndef GCC29
|
||||||
|
opts+=-msse3 -mfpmath=sse
|
||||||
|
else
|
||||||
|
opts+=-mpentium
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef DEBUGMODE
|
||||||
|
ifdef GCC48
|
||||||
|
opts+=-Og
|
||||||
|
else
|
||||||
|
opts+=-O0
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef VALGRIND
|
||||||
|
ifdef GCC46
|
||||||
|
WFLAGS+=-Wno-error=unused-but-set-variable
|
||||||
|
WFLAGS+=-Wno-unused-but-set-variable
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Lua
|
||||||
|
ifdef GCC43
|
||||||
|
ifndef GCC44
|
||||||
|
WFLAGS+=-Wno-logical-op
|
||||||
|
endif
|
||||||
|
endif
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
#
|
||||||
|
# Mingw, if you don't know, that's Win32/Win64
|
||||||
|
#
|
||||||
|
|
||||||
|
ifndef MINGW64
|
||||||
|
EXENAME?=srb2kart-saturn_32bit.exe
|
||||||
|
else
|
||||||
|
EXENAME?=srb2kart-saturn_64bit.exe
|
||||||
|
endif
|
||||||
|
|
||||||
|
# disable dynamicbase if under msys2
|
||||||
|
ifdef MSYSTEM
|
||||||
|
libs+=-Wl,--disable-dynamicbase
|
||||||
|
endif
|
||||||
|
|
||||||
|
sources+=win32/Srb2win.rc
|
||||||
|
opts+=-DSTDC_HEADERS
|
||||||
|
libs+=-ladvapi32 -lkernel32 -lmsvcrt -luser32
|
||||||
|
|
||||||
|
ifndef DEDICATED
|
||||||
|
ifndef DUMMY
|
||||||
|
SDL?=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef NOHW
|
||||||
|
opts+=-DUSE_WGL_SWAP
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef MINGW64
|
||||||
|
libs+=-lws2_32
|
||||||
|
else
|
||||||
|
#ifndef HAVE_IPV6
|
||||||
|
#libs+=-lwsock32
|
||||||
|
#else
|
||||||
|
libs+=-lws2_32
|
||||||
|
#endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef MINGW64
|
||||||
|
libs+=-Wl,--large-address-aware
|
||||||
|
NOLIBBACKTRACE=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef MINGW64
|
||||||
|
32=32
|
||||||
|
x86=x86
|
||||||
|
i686=i686
|
||||||
|
else
|
||||||
|
32=64
|
||||||
|
x86=x86_64
|
||||||
|
i686=x86_64
|
||||||
|
endif
|
||||||
|
|
||||||
|
mingw:=$(i686)-w64-mingw32
|
||||||
|
|
||||||
|
define _set =
|
||||||
|
$(1)_CFLAGS?=$($(1)_opts)
|
||||||
|
$(1)_LDFLAGS?=$($(1)_libs)
|
||||||
|
endef
|
||||||
|
|
||||||
|
lib:=../libs/gme
|
||||||
|
LIBGME_opts:=-I$(lib)/include
|
||||||
|
LIBGME_libs:=-L$(lib)/win$(32) -lgme
|
||||||
|
$(eval $(call _set,LIBGME))
|
||||||
|
|
||||||
|
lib:=../libs/libopenmpt
|
||||||
|
LIBOPENMPT_opts:=-I$(lib)/inc
|
||||||
|
LIBOPENMPT_libs:=-L$(lib)/lib/$(x86)/mingw -lopenmpt
|
||||||
|
$(eval $(call _set,LIBOPENMPT))
|
||||||
|
|
||||||
|
lib:=../libs/SDL2_mixer/$(mingw)
|
||||||
|
|
||||||
|
ifdef SDL
|
||||||
|
mixer_opts:=-I$(lib)/include/SDL2
|
||||||
|
mixer_libs:=-L$(lib)/lib
|
||||||
|
|
||||||
|
lib:=../libs/SDL2/$(mingw)
|
||||||
|
SDL_opts:=-I$(lib)/include/SDL2\
|
||||||
|
$(mixer_opts) -Dmain=SDL_main
|
||||||
|
SDL_libs:=-L$(lib)/lib $(mixer_libs)\
|
||||||
|
-lmingw32 -lSDL2main -lSDL2 -mwindows
|
||||||
|
$(eval $(call _set,SDL))
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef MINGW64
|
||||||
|
lib:=../libs/libbacktrace
|
||||||
|
LIBBACKTRACE_opts:=-I$(lib)/include
|
||||||
|
LIBBACKTRACE_libs:=-L$(lib)/lib/x86_64 -lbacktrace
|
||||||
|
$(eval $(call _set,LIBBACKTRACE))
|
||||||
|
else
|
||||||
|
lib:=../libs/drmingw
|
||||||
|
opts+=-I$(lib)/include
|
||||||
|
libs+=-L$(lib)/lib/win32 -lmgwhelp -lexchndl
|
||||||
|
endif
|
||||||
|
|
||||||
|
lib:=../libs/zlib
|
||||||
|
ZLIB_opts:=-I$(lib)
|
||||||
|
ZLIB_libs:=-L$(lib)/win32 -l:libz$(32).a
|
||||||
|
$(eval $(call _set,ZLIB))
|
||||||
|
|
||||||
|
ifndef PNG_CONFIG
|
||||||
|
lib:=../libs/libpng-src
|
||||||
|
PNG_opts:=-I$(lib)
|
||||||
|
PNG_libs:=-L$(lib)/projects -lpng$(32)
|
||||||
|
$(eval $(call _set,PNG))
|
||||||
|
endif
|
||||||
|
|
||||||
|
lib:=../libs/curl
|
||||||
|
CURL_opts:=-I$(lib)/include
|
||||||
|
CURL_libs:=-L$(lib)/lib$(32) -lcurl
|
||||||
|
$(eval $(call _set,CURL))
|
||||||
|
|
||||||
|
ifndef MINGW64 # miniupnc is broken with MINGW64
|
||||||
|
lib:=../libs/miniupnpc
|
||||||
|
MINIUPNPC_opts:=-I$(lib)/include -DMINIUPNP_STATICLIB
|
||||||
|
MINIUPNPC_libs:=-L$(lib)/mingw$(32) -lminiupnpc -lws2_32 -liphlpapi
|
||||||
|
$(eval $(call _set,MINIUPNPC))
|
||||||
|
endif
|
||||||
|
|
||||||
|
lib:=../libs/discord-rpc/win$(32)-dynamic
|
||||||
|
DISCORDRPC_opts+=-I$(lib)/include
|
||||||
|
DISCORDRPC_libs+=-L$(lib)/lib -ldiscord-rpc
|
||||||
|
$(eval $(call _set,DISCORDRPC))
|
||||||
+100
@@ -0,0 +1,100 @@
|
|||||||
|
am_map.c
|
||||||
|
b_bot.c
|
||||||
|
command.c
|
||||||
|
console.c
|
||||||
|
d_clisrv.c
|
||||||
|
d_main.c
|
||||||
|
d_net.c
|
||||||
|
d_netcmd.c
|
||||||
|
d_netfil.c
|
||||||
|
d_protocol.c
|
||||||
|
dehacked.c
|
||||||
|
f_finale.c
|
||||||
|
f_wipe.c
|
||||||
|
filesrch.c
|
||||||
|
g_game.c
|
||||||
|
g_demo.c
|
||||||
|
g_input.c
|
||||||
|
hu_stuff.c
|
||||||
|
i_tcp.c
|
||||||
|
i_time.c
|
||||||
|
info.c
|
||||||
|
lzf.c
|
||||||
|
m_aatree.c
|
||||||
|
m_anigif.c
|
||||||
|
m_argv.c
|
||||||
|
m_bbox.c
|
||||||
|
m_cheat.c
|
||||||
|
m_cond.c
|
||||||
|
m_fixed.c
|
||||||
|
m_menu.c
|
||||||
|
m_textinput.c
|
||||||
|
m_emotes.cpp
|
||||||
|
m_misc.c
|
||||||
|
m_perfstats.c
|
||||||
|
m_queue.c
|
||||||
|
m_random.c
|
||||||
|
mserv.c
|
||||||
|
http-mserv.c
|
||||||
|
qs22j.c
|
||||||
|
s_sound.c
|
||||||
|
screen.c
|
||||||
|
sounds.c
|
||||||
|
st_stuff.c
|
||||||
|
string.c
|
||||||
|
tables.c
|
||||||
|
v_video.c
|
||||||
|
w_wad.c
|
||||||
|
y_inter.c
|
||||||
|
z_zone.c
|
||||||
|
r_bsp.c
|
||||||
|
r_data.c
|
||||||
|
r_draw.c
|
||||||
|
r_fps.c
|
||||||
|
r_main.cpp
|
||||||
|
r_patch.c
|
||||||
|
r_patchrotation.c
|
||||||
|
r_plane.cpp
|
||||||
|
r_segs.cpp
|
||||||
|
r_skins.c
|
||||||
|
r_sky.c
|
||||||
|
r_splats.c
|
||||||
|
r_things.cpp
|
||||||
|
r_portal.c
|
||||||
|
p_ceilng.c
|
||||||
|
p_enemy.c
|
||||||
|
p_floor.c
|
||||||
|
p_inter.c
|
||||||
|
p_lights.c
|
||||||
|
p_map.c
|
||||||
|
p_maputl.c
|
||||||
|
p_mobj.c
|
||||||
|
p_polyobj.c
|
||||||
|
p_saveg.c
|
||||||
|
p_setup.c
|
||||||
|
p_sight.c
|
||||||
|
p_slopes.c
|
||||||
|
p_spec.c
|
||||||
|
p_telept.c
|
||||||
|
p_tick.c
|
||||||
|
p_user.c
|
||||||
|
k_director.c
|
||||||
|
k_kart.c
|
||||||
|
k_hud.c
|
||||||
|
k_stats.c
|
||||||
|
lua_baselib.c
|
||||||
|
lua_blockmaplib.c
|
||||||
|
lua_consolelib.c
|
||||||
|
lua_hooklib.c
|
||||||
|
lua_hudlib.c
|
||||||
|
lua_hudlib_drawlist.c
|
||||||
|
lua_infolib.c
|
||||||
|
lua_maplib.c
|
||||||
|
lua_mathlib.c
|
||||||
|
lua_mobjlib.c
|
||||||
|
lua_playerlib.c
|
||||||
|
lua_script.c
|
||||||
|
lua_skinlib.c
|
||||||
|
lua_thinkerlib.c
|
||||||
|
lua_udatalib.c
|
||||||
|
lua_glib.c
|
||||||
+1
-1
@@ -341,7 +341,7 @@ static void AM_FrameBufferInit(void)
|
|||||||
f_x = f_y = 0;
|
f_x = f_y = 0;
|
||||||
f_w = vid.width;
|
f_w = vid.width;
|
||||||
f_h = vid.height;
|
f_h = vid.height;
|
||||||
am_buf = screens[0];
|
am_buf = vid.screens[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ INT32 VID_SetMode(INT32 modenum)
|
|||||||
vid.modenum = 0;
|
vid.modenum = 0;
|
||||||
vid.width = 320;
|
vid.width = 320;
|
||||||
vid.height = 240;
|
vid.height = 240;
|
||||||
vid.bpp = 1;
|
|
||||||
vid.buffer = android_surface;
|
vid.buffer = android_surface;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
ifdef UNIXCOMMON
|
|
||||||
LUA_CFLAGS+=-DLUA_USE_POSIX
|
|
||||||
endif
|
|
||||||
ifdef LINUX
|
|
||||||
LUA_CFLAGS+=-DLUA_USE_POSIX
|
|
||||||
endif
|
|
||||||
ifdef GCC43
|
|
||||||
ifndef GCC44
|
|
||||||
WFLAGS+=-Wno-logical-op
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
OBJS:=$(OBJS) \
|
|
||||||
$(OBJDIR)/lapi.o \
|
|
||||||
$(OBJDIR)/lbaselib.o \
|
|
||||||
$(OBJDIR)/ldo.o \
|
|
||||||
$(OBJDIR)/ldblib.o \
|
|
||||||
$(OBJDIR)/lfunc.o \
|
|
||||||
$(OBJDIR)/linit.o \
|
|
||||||
$(OBJDIR)/liolib.o \
|
|
||||||
$(OBJDIR)/llex.o \
|
|
||||||
$(OBJDIR)/lmem.o \
|
|
||||||
$(OBJDIR)/lobject.o \
|
|
||||||
$(OBJDIR)/lstate.o \
|
|
||||||
$(OBJDIR)/lstrlib.o \
|
|
||||||
$(OBJDIR)/ltablib.o \
|
|
||||||
$(OBJDIR)/lundump.o \
|
|
||||||
$(OBJDIR)/lzio.o \
|
|
||||||
$(OBJDIR)/lauxlib.o \
|
|
||||||
$(OBJDIR)/lcode.o \
|
|
||||||
$(OBJDIR)/ldebug.o \
|
|
||||||
$(OBJDIR)/ldump.o \
|
|
||||||
$(OBJDIR)/lgc.o \
|
|
||||||
$(OBJDIR)/lopcodes.o \
|
|
||||||
$(OBJDIR)/lparser.o \
|
|
||||||
$(OBJDIR)/lstring.o \
|
|
||||||
$(OBJDIR)/ltable.o \
|
|
||||||
$(OBJDIR)/ltm.o \
|
|
||||||
$(OBJDIR)/lvm.o \
|
|
||||||
$(OBJDIR)/lua_script.o \
|
|
||||||
$(OBJDIR)/lua_baselib.o \
|
|
||||||
$(OBJDIR)/lua_blockmaplib.o \
|
|
||||||
$(OBJDIR)/lua_mathlib.o \
|
|
||||||
$(OBJDIR)/lua_hooklib.o \
|
|
||||||
$(OBJDIR)/lua_consolelib.o \
|
|
||||||
$(OBJDIR)/lua_infolib.o \
|
|
||||||
$(OBJDIR)/lua_mobjlib.o \
|
|
||||||
$(OBJDIR)/lua_playerlib.o \
|
|
||||||
$(OBJDIR)/lua_skinlib.o \
|
|
||||||
$(OBJDIR)/lua_thinkerlib.o \
|
|
||||||
$(OBJDIR)/lua_maplib.o \
|
|
||||||
$(OBJDIR)/lua_hudlib.o \
|
|
||||||
$(OBJDIR)/lua_hudlib_drawlist.o \
|
|
||||||
$(OBJDIR)/lua_udatalib.o \
|
|
||||||
$(OBJDIR)/lua_glib.o
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
lapi.c
|
||||||
|
lauxlib.c
|
||||||
|
lbaselib.c
|
||||||
|
ldblib.c
|
||||||
|
lcode.c
|
||||||
|
ldebug.c
|
||||||
|
ldo.c
|
||||||
|
ldump.c
|
||||||
|
lfunc.c
|
||||||
|
lgc.c
|
||||||
|
linit.c
|
||||||
|
liolib.c
|
||||||
|
llex.c
|
||||||
|
lmem.c
|
||||||
|
lobject.c
|
||||||
|
lopcodes.c
|
||||||
|
lparser.c
|
||||||
|
lstate.c
|
||||||
|
lstring.c
|
||||||
|
lstrlib.c
|
||||||
|
ltable.c
|
||||||
|
ltablib.c
|
||||||
|
ltm.c
|
||||||
|
lundump.c
|
||||||
|
lvm.c
|
||||||
|
lzio.c
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
#define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
#define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
#define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
|
#define WRITEINT16_2(p,b) do { INT16 *p_tmp = ( INT16 *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) // dumb hack for mumble
|
||||||
#define WRITEUINT16(p,b) do { UINT16 *p_tmp = (void *)p; const UINT16 tv = ( UINT16)(b); memcpy(p, &tv, sizeof( UINT16)); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEUINT16(p,b) do { UINT16 *p_tmp = (void *)p; const UINT16 tv = ( UINT16)(b); memcpy(p, &tv, sizeof( UINT16)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
#define WRITEINT32(p,b) do { INT32 *p_tmp = (void *)p; const INT32 tv = ( INT32)(b); memcpy(p, &tv, sizeof( INT32)); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEINT32(p,b) do { INT32 *p_tmp = (void *)p; const INT32 tv = ( INT32)(b); memcpy(p, &tv, sizeof( INT32)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
#define WRITEUINT32(p,b) do { UINT32 *p_tmp = (void *)p; const UINT32 tv = ( UINT32)(b); memcpy(p, &tv, sizeof( UINT32)); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEUINT32(p,b) do { UINT32 *p_tmp = (void *)p; const UINT32 tv = ( UINT32)(b); memcpy(p, &tv, sizeof( UINT32)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
@@ -38,6 +39,7 @@
|
|||||||
#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
|
#define WRITEINT16_2(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) // dumb hack for mumble
|
||||||
#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
#define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
#define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||||
|
|||||||
+35
-14
@@ -816,12 +816,17 @@ static void COM_Help_f(void)
|
|||||||
cvar = CV_FindVar(help);
|
cvar = CV_FindVar(help);
|
||||||
if (cvar)
|
if (cvar)
|
||||||
{
|
{
|
||||||
|
boolean floatmode = false;
|
||||||
|
const char *cvalue = NULL;
|
||||||
CONS_Printf("\x82""Variable %s:\n", cvar->name);
|
CONS_Printf("\x82""Variable %s:\n", cvar->name);
|
||||||
CONS_Printf(M_GetText(" flags: "));
|
CONS_Printf(M_GetText(" flags: "));
|
||||||
if (cvar->flags & CV_SAVE)
|
if (cvar->flags & CV_SAVE)
|
||||||
CONS_Printf("AUTOSAVE ");
|
CONS_Printf("AUTOSAVE ");
|
||||||
if (cvar->flags & CV_FLOAT)
|
if (cvar->flags & CV_FLOAT)
|
||||||
|
{
|
||||||
CONS_Printf("FLOAT ");
|
CONS_Printf("FLOAT ");
|
||||||
|
floatmode = true;
|
||||||
|
}
|
||||||
if (cvar->flags & CV_NETVAR)
|
if (cvar->flags & CV_NETVAR)
|
||||||
CONS_Printf("NETVAR ");
|
CONS_Printf("NETVAR ");
|
||||||
if (cvar->flags & CV_CALL)
|
if (cvar->flags & CV_CALL)
|
||||||
@@ -831,30 +836,43 @@ static void COM_Help_f(void)
|
|||||||
CONS_Printf("\n");
|
CONS_Printf("\n");
|
||||||
if (cvar->PossibleValue)
|
if (cvar->PossibleValue)
|
||||||
{
|
{
|
||||||
if (!stricmp(cvar->PossibleValue[0].strvalue, "MIN") && !stricmp(cvar->PossibleValue[1].strvalue, "MAX"))
|
|
||||||
{
|
{
|
||||||
CONS_Printf(" range from %d to %d\n", cvar->PossibleValue[0].value,
|
if (!stricmp(cvar->PossibleValue[0].strvalue, "MIN") && !stricmp(cvar->PossibleValue[1].strvalue, "MAX"))
|
||||||
cvar->PossibleValue[1].value);
|
{
|
||||||
i = 2;
|
if (floatmode)
|
||||||
}
|
{
|
||||||
|
float fu = FIXED_TO_FLOAT(cvar->PossibleValue[0].value);
|
||||||
|
float ck = FIXED_TO_FLOAT(cvar->PossibleValue[1].value);
|
||||||
|
CONS_Printf(" range from %ld%s to %ld%s\n",
|
||||||
|
(long)fu, M_Ftrim(fu),
|
||||||
|
(long)ck, M_Ftrim(ck));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CONS_Printf(" range from %d to %d\n", cvar->PossibleValue[0].value,
|
||||||
|
cvar->PossibleValue[1].value);
|
||||||
|
i = 2;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
|
||||||
const char *cvalue = NULL;
|
|
||||||
//CONS_Printf(M_GetText(" possible value : %s\n"), cvar->name);
|
//CONS_Printf(M_GetText(" possible value : %s\n"), cvar->name);
|
||||||
while (cvar->PossibleValue[i].strvalue)
|
while (cvar->PossibleValue[i].strvalue)
|
||||||
{
|
{
|
||||||
CONS_Printf(" %-2d : %s\n", cvar->PossibleValue[i].value,
|
if (floatmode)
|
||||||
cvar->PossibleValue[i].strvalue);
|
CONS_Printf(" %-2f : %s\n", FIXED_TO_FLOAT(cvar->PossibleValue[i].value),
|
||||||
|
cvar->PossibleValue[i].strvalue);
|
||||||
|
else
|
||||||
|
CONS_Printf(" %-2d : %s\n", cvar->PossibleValue[i].value,
|
||||||
|
cvar->PossibleValue[i].strvalue);
|
||||||
if (cvar->PossibleValue[i].value == cvar->value)
|
if (cvar->PossibleValue[i].value == cvar->value)
|
||||||
cvalue = cvar->PossibleValue[i].strvalue;
|
cvalue = cvar->PossibleValue[i].strvalue;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (cvalue)
|
|
||||||
CONS_Printf(" Current value: %s\n", cvalue);
|
|
||||||
else
|
|
||||||
CONS_Printf(" Current value: %d\n", cvar->value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cvalue)
|
||||||
|
CONS_Printf(" Current value: %s\n", cvalue);
|
||||||
|
else if (cvar->string)
|
||||||
|
CONS_Printf(" Current value: %s\n", cvar->string);
|
||||||
else
|
else
|
||||||
CONS_Printf(" Current value: %d\n", cvar->value);
|
CONS_Printf(" Current value: %d\n", cvar->value);
|
||||||
}
|
}
|
||||||
@@ -1025,7 +1043,10 @@ static void COM_Add_f(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (( cvar->flags & CV_FLOAT ))
|
if (( cvar->flags & CV_FLOAT ))
|
||||||
CV_Set(cvar, va("%f", FIXED_TO_FLOAT (cvar->value) + atof(COM_Argv(2))));
|
{
|
||||||
|
float n =FIXED_TO_FLOAT (cvar->value) + atof(COM_Argv(2));
|
||||||
|
CV_Set(cvar, va("%ld%s", (long)n, M_Ftrim(n)));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
CV_AddValue(cvar, atoi(COM_Argv(2)));
|
CV_AddValue(cvar, atoi(COM_Argv(2)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
#ifndef __COMMAND_H__
|
#ifndef __COMMAND_H__
|
||||||
#define __COMMAND_H__
|
#define __COMMAND_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
|
|
||||||
@@ -189,4 +193,8 @@ UINT8 CV_CheatsEnabled(void);
|
|||||||
// Returns cvar by name. Exposed here for Lua.
|
// Returns cvar by name. Exposed here for Lua.
|
||||||
consvar_t *CV_FindVar(const char *name);
|
consvar_t *CV_FindVar(const char *name);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __COMMAND_H__
|
#endif // __COMMAND_H__
|
||||||
@@ -1321,13 +1321,6 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...)
|
|||||||
//
|
//
|
||||||
void CONS_Error(const char *msg)
|
void CONS_Error(const char *msg)
|
||||||
{
|
{
|
||||||
#ifdef RPC_NO_WINDOWS_H
|
|
||||||
if (!graphics_started)
|
|
||||||
{
|
|
||||||
MessageBoxA(vid.WndParent, msg, "SRB2Kart Warning", MB_OK);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
CONS_Printf("\x82%s", msg); // write error msg in different colour
|
CONS_Printf("\x82%s", msg); // write error msg in different colour
|
||||||
CONS_Printf(M_GetText("Press ENTER to continue\n"));
|
CONS_Printf(M_GetText("Press ENTER to continue\n"));
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
target_sourcefile(cpp)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
memory.cpp
|
||||||
|
thread_pool.cpp
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// BLANKART
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2024 by Ronald "Eidolon" Kinard
|
||||||
|
// Copyright (C) 2024 by Kart Krew
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "memory.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#include "../z_zone.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
class LinearMemory
|
||||||
|
{
|
||||||
|
size_t size_;
|
||||||
|
size_t height_;
|
||||||
|
void* memory_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
constexpr explicit LinearMemory(size_t size) noexcept;
|
||||||
|
|
||||||
|
void* allocate(size_t size);
|
||||||
|
void reset() noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr LinearMemory::LinearMemory(size_t size) noexcept : size_(size), height_{0}, memory_{nullptr} {}
|
||||||
|
|
||||||
|
void* LinearMemory::allocate(size_t size)
|
||||||
|
{
|
||||||
|
size_t aligned_size = (size + 15) & ~15;
|
||||||
|
if (height_ + aligned_size > size_)
|
||||||
|
{
|
||||||
|
throw std::bad_alloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memory_ == nullptr)
|
||||||
|
{
|
||||||
|
memory_ = Z_Malloc(size_, PU_STATIC, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* ptr = (void*)((uintptr_t)(memory_) + height_);
|
||||||
|
height_ += aligned_size;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinearMemory::reset() noexcept
|
||||||
|
{
|
||||||
|
height_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
static LinearMemory g_frame_memory {4 * 1024 * 1024};
|
||||||
|
|
||||||
|
void* Z_Frame_Alloc(size_t size)
|
||||||
|
{
|
||||||
|
return g_frame_memory.allocate(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Z_Frame_Reset()
|
||||||
|
{
|
||||||
|
g_frame_memory.reset();
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// BLANKART
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2024 by Ronald "Eidolon" Kinard
|
||||||
|
// Copyright (C) 2024 by Kart Krew
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef __SRB2_CORE_MEMORY_H__
|
||||||
|
#define __SRB2_CORE_MEMORY_H__
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cpluspplus
|
||||||
|
|
||||||
|
/// @brief Allocate a block of memory with a lifespan of the current main-thread frame.
|
||||||
|
/// This function is NOT thread-safe, but the allocated memory may be used across threads.
|
||||||
|
/// @return a pointer to a block of memory aligned with libc malloc alignment, or null if allocation fails
|
||||||
|
void* Z_Frame_Alloc(size_t size);
|
||||||
|
|
||||||
|
/// @brief Resets per-frame memory. Not thread safe.
|
||||||
|
void Z_Frame_Reset(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif // __SRB2_CORE_MEMORY_H__
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This class is derived from Conor Williams' implementation of a concurrent deque
|
||||||
|
// https://github.com/ConorWilliams/ConcurrentDeque
|
||||||
|
// Copyright (C) 2021 Conor Williams
|
||||||
|
|
||||||
|
// The original version was for C++23. This one has been shrunk slightly and adapted to our conventions.
|
||||||
|
|
||||||
|
#ifndef __SRB2_CORE_SPMC_QUEUE_HPP__
|
||||||
|
#define __SRB2_CORE_SPMC_QUEUE_HPP__
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <atomic>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
//#include <tracy/tracy/Tracy.hpp>
|
||||||
|
|
||||||
|
#include "../cxxutil.hpp"
|
||||||
|
|
||||||
|
namespace srb2
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class SpMcQueue
|
||||||
|
{
|
||||||
|
struct RingBuff {
|
||||||
|
public:
|
||||||
|
explicit RingBuff(int64_t cap) : _cap{cap}, _mask{cap - 1}
|
||||||
|
{
|
||||||
|
SRB2_ASSERT(cap && (!(cap & (cap - 1))) && "Capacity must be buf power of 2!");
|
||||||
|
_buff = std::unique_ptr<T[]>(new T[_cap]);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int64_t capacity() const noexcept { return _cap; }
|
||||||
|
|
||||||
|
// Store (copy) at modulo index
|
||||||
|
void store(int64_t i, T&& x) noexcept
|
||||||
|
{
|
||||||
|
_buff[i & _mask] = std::move(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load (copy) at modulo index
|
||||||
|
T load(int64_t i) const noexcept
|
||||||
|
{
|
||||||
|
return _buff[i & _mask];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocates and returns a new ring buffer, copies elements in range [b, t) into the new buffer.
|
||||||
|
RingBuff* resize(std::int64_t b, std::int64_t t) const
|
||||||
|
{
|
||||||
|
//ZoneScoped;
|
||||||
|
RingBuff* ptr = new RingBuff{2 * _cap};
|
||||||
|
for (std::int64_t i = t; i != b; ++i) {
|
||||||
|
ptr->store(i, load(i));
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int64_t _cap; // Capacity of the buffer
|
||||||
|
int64_t _mask; // Bit mask to perform modulo capacity operations
|
||||||
|
|
||||||
|
std::unique_ptr<T[]> _buff;
|
||||||
|
};
|
||||||
|
|
||||||
|
alignas(64) std::atomic<int64_t> bottom_;
|
||||||
|
alignas(64) std::atomic<int64_t> top_;
|
||||||
|
alignas(64) std::atomic<RingBuff*> buffer_;
|
||||||
|
|
||||||
|
std::vector<std::unique_ptr<RingBuff>> garbage_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SpMcQueue(size_t capacity) : bottom_(0), top_(0), buffer_(new RingBuff(capacity))
|
||||||
|
{
|
||||||
|
garbage_.reserve(32);
|
||||||
|
}
|
||||||
|
~SpMcQueue() noexcept
|
||||||
|
{
|
||||||
|
delete buffer_.load(std::memory_order_relaxed);
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t size() const noexcept
|
||||||
|
{
|
||||||
|
int64_t bottom = bottom_.load(std::memory_order_relaxed);
|
||||||
|
int64_t top = top_.load(std::memory_order_relaxed);
|
||||||
|
return static_cast<size_t>(bottom >= top ? bottom - top : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool empty() const noexcept
|
||||||
|
{
|
||||||
|
return size() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void push(T&& v) noexcept
|
||||||
|
{
|
||||||
|
int64_t bottom = bottom_.load(std::memory_order_relaxed);
|
||||||
|
int64_t top = top_.load(std::memory_order_acquire);
|
||||||
|
RingBuff* buf = buffer_.load(std::memory_order_relaxed);
|
||||||
|
|
||||||
|
if (buf->capacity() < (bottom - top) + 1)
|
||||||
|
{
|
||||||
|
// Queue is full, build a new one
|
||||||
|
RingBuff* newbuf = buf->resize(bottom, top);
|
||||||
|
garbage_.emplace_back(buf);
|
||||||
|
buffer_.store(newbuf, std::memory_order_relaxed);
|
||||||
|
buf = newbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct new object, this does not have to be atomic as no one can steal this item until after we
|
||||||
|
// store the new value of bottom, ordering is maintained by surrounding atomics.
|
||||||
|
buf->store(bottom, std::move(v));
|
||||||
|
|
||||||
|
std::atomic_thread_fence(std::memory_order_release);
|
||||||
|
bottom_.store(bottom + 1, std::memory_order_relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<T> pop() noexcept
|
||||||
|
{
|
||||||
|
int64_t bottom = bottom_.load(std::memory_order_relaxed) - 1;
|
||||||
|
RingBuff* buf = buffer_.load(std::memory_order_relaxed);
|
||||||
|
|
||||||
|
bottom_.store(bottom, std::memory_order_relaxed); // Stealers can no longer steal
|
||||||
|
|
||||||
|
std::atomic_thread_fence(std::memory_order_seq_cst);
|
||||||
|
int64_t top = top_.load(std::memory_order_relaxed);
|
||||||
|
|
||||||
|
if (top <= bottom)
|
||||||
|
{
|
||||||
|
// Non-empty deque
|
||||||
|
if (top == bottom)
|
||||||
|
{
|
||||||
|
// The last item could get stolen, by a stealer that loaded bottom before our write above
|
||||||
|
if (!top_.compare_exchange_strong(top, top + 1, std::memory_order_seq_cst, std::memory_order_relaxed))
|
||||||
|
{
|
||||||
|
// Failed race, thief got the last item.
|
||||||
|
bottom_.store(bottom + 1, std::memory_order_relaxed);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
bottom_.store(bottom + 1, std::memory_order_relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can delay load until after acquiring slot as only this thread can push(), this load is not
|
||||||
|
// required to be atomic as we are the exclusive writer.
|
||||||
|
return buf->load(bottom);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bottom_.store(bottom + 1, std::memory_order_relaxed);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<T> steal() noexcept
|
||||||
|
{
|
||||||
|
int64_t top = top_.load(std::memory_order_acquire);
|
||||||
|
std::atomic_thread_fence(std::memory_order_seq_cst);
|
||||||
|
int64_t bottom = bottom_.load(std::memory_order_acquire);
|
||||||
|
|
||||||
|
if (top < bottom)
|
||||||
|
{
|
||||||
|
// Must load *before* acquiring the slot as slot may be overwritten immediately after acquiring.
|
||||||
|
// This load is NOT required to be atomic even-though it may race with an overrite as we only
|
||||||
|
// return the value if we win the race below garanteeing we had no race during our read. If we
|
||||||
|
// loose the race then 'x' could be corrupt due to read-during-write race but as T is trivially
|
||||||
|
// destructible this does not matter.
|
||||||
|
T x = buffer_.load(std::memory_order_consume)->load(top);
|
||||||
|
|
||||||
|
if (!top_.compare_exchange_strong(top, top + 1, std::memory_order_seq_cst, std::memory_order_relaxed))
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace srb2
|
||||||
|
|
||||||
|
#endif // __SRB2_CORE_SPMC_QUEUE_HPP__
|
||||||
@@ -0,0 +1,255 @@
|
|||||||
|
// BLANKART
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2024 by Ronald "Eidolon" Kinard
|
||||||
|
// Copyright (C) 2024 by Kart Krew
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef __SRB2_CORE_STATIC_VEC_HPP__
|
||||||
|
#define __SRB2_CORE_STATIC_VEC_HPP__
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <functional>
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <iterator>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "../cxxutil.hpp"
|
||||||
|
|
||||||
|
namespace srb2
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T, size_t Limit>
|
||||||
|
class StaticVec;
|
||||||
|
|
||||||
|
template <typename T, size_t Limit>
|
||||||
|
class StaticVec
|
||||||
|
{
|
||||||
|
std::array<T, Limit> arr_ {{}};
|
||||||
|
size_t size_ = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using value_type = T;
|
||||||
|
|
||||||
|
constexpr StaticVec() {}
|
||||||
|
|
||||||
|
StaticVec(const StaticVec& rhs)
|
||||||
|
{
|
||||||
|
for (size_t i = size_; i > 0; i--)
|
||||||
|
{
|
||||||
|
arr_[i] = T();
|
||||||
|
}
|
||||||
|
size_ = rhs.size();
|
||||||
|
for (size_t i = 0; i < size_; i++)
|
||||||
|
{
|
||||||
|
arr_[i] = rhs.arr_[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StaticVec(StaticVec&& rhs) noexcept(std::is_nothrow_move_assignable_v<T>)
|
||||||
|
{
|
||||||
|
for (size_t i = size_; i > 0; i--)
|
||||||
|
{
|
||||||
|
arr_[i] = T();
|
||||||
|
}
|
||||||
|
size_ = rhs.size();
|
||||||
|
for (size_t i = 0; i < size_; i++)
|
||||||
|
{
|
||||||
|
arr_[i] = std::move(rhs.arr_[i]);
|
||||||
|
}
|
||||||
|
while (rhs.size() > 0)
|
||||||
|
{
|
||||||
|
rhs.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr StaticVec(std::initializer_list<T> list) noexcept(std::is_nothrow_move_assignable_v<T>)
|
||||||
|
{
|
||||||
|
size_ = list.size();
|
||||||
|
size_t i = 0;
|
||||||
|
for (auto itr = list.begin(); itr != list.end(); itr++)
|
||||||
|
{
|
||||||
|
arr_[i] = *itr;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~StaticVec() = default;
|
||||||
|
|
||||||
|
StaticVec& operator=(const StaticVec& rhs)
|
||||||
|
{
|
||||||
|
for (size_t i = size_; i > 0; i--)
|
||||||
|
{
|
||||||
|
arr_[i] = T();
|
||||||
|
}
|
||||||
|
size_ = rhs.size();
|
||||||
|
for (size_t i = 0; i < size_; i++)
|
||||||
|
{
|
||||||
|
arr_[i] = rhs.arr_[i];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
StaticVec& operator=(StaticVec&& rhs) noexcept(std::is_nothrow_move_constructible_v<T>)
|
||||||
|
{
|
||||||
|
for (size_t i = size_; i > 0; i--)
|
||||||
|
{
|
||||||
|
arr_[i] = T();
|
||||||
|
}
|
||||||
|
size_ = rhs.size();
|
||||||
|
for (size_t i = 0; i < size_; i++)
|
||||||
|
{
|
||||||
|
arr_[i] = std::move(rhs.arr_[i]);
|
||||||
|
}
|
||||||
|
while (rhs.size() > 0)
|
||||||
|
{
|
||||||
|
rhs.pop_back();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void push_back(const T& value) { arr_[size_++] = value; }
|
||||||
|
|
||||||
|
void pop_back() { arr_[--size_] = T(); }
|
||||||
|
|
||||||
|
void resize(size_t size, T value = T())
|
||||||
|
{
|
||||||
|
if (size >= Limit)
|
||||||
|
{
|
||||||
|
throw std::length_error("new size >= Capacity");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size == size_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (size < size_)
|
||||||
|
{
|
||||||
|
while (size_ > size)
|
||||||
|
{
|
||||||
|
pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (size_ < size)
|
||||||
|
{
|
||||||
|
push_back(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
arr_ = {{}};
|
||||||
|
size_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
using iterator = typename std::array<T, Limit>::iterator;
|
||||||
|
using const_iterator = typename std::array<T, Limit>::const_iterator;
|
||||||
|
|
||||||
|
constexpr iterator begin() noexcept { return arr_.begin(); }
|
||||||
|
|
||||||
|
constexpr const_iterator begin() const noexcept { return arr_.cbegin(); }
|
||||||
|
|
||||||
|
constexpr const_iterator cbegin() const noexcept { return arr_.cbegin(); }
|
||||||
|
|
||||||
|
constexpr iterator end() noexcept { return std::next(arr_.begin(), size_); }
|
||||||
|
|
||||||
|
constexpr const_iterator end() const noexcept { return cend(); }
|
||||||
|
|
||||||
|
constexpr const_iterator cend() const noexcept { return std::next(arr_.cbegin(), size_); }
|
||||||
|
|
||||||
|
constexpr std::reverse_iterator<iterator> rbegin() noexcept { return std::reverse_iterator(this->end()); }
|
||||||
|
|
||||||
|
constexpr std::reverse_iterator<const_iterator> crbegin() const noexcept { return std::reverse_iterator(this->cend()); }
|
||||||
|
|
||||||
|
constexpr std::reverse_iterator<iterator> rend() noexcept { return std::reverse_iterator(this->begin()); }
|
||||||
|
|
||||||
|
constexpr std::reverse_iterator<const_iterator> crend() const noexcept { return std::reverse_iterator(this->cbegin()); }
|
||||||
|
|
||||||
|
constexpr bool empty() const noexcept { return size_ == 0; }
|
||||||
|
|
||||||
|
constexpr size_t size() const noexcept { return size_; }
|
||||||
|
|
||||||
|
constexpr size_t capacity() const noexcept { return Limit; }
|
||||||
|
|
||||||
|
constexpr size_t max_size() const noexcept { return Limit; }
|
||||||
|
|
||||||
|
constexpr T& operator[](size_t index) noexcept { return arr_[index]; }
|
||||||
|
|
||||||
|
T& at(size_t index)
|
||||||
|
{
|
||||||
|
if (index >= size_)
|
||||||
|
{
|
||||||
|
throw std::out_of_range("index >= size");
|
||||||
|
}
|
||||||
|
return this[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr const T& operator[](size_t index) const noexcept { return arr_[index]; }
|
||||||
|
|
||||||
|
const T& at(size_t index) const
|
||||||
|
{
|
||||||
|
if (index >= size_)
|
||||||
|
{
|
||||||
|
throw std::out_of_range("index >= size");
|
||||||
|
}
|
||||||
|
return this[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
T& front() { return *arr_[0]; }
|
||||||
|
|
||||||
|
T& back() { return *arr_[size_ - 1]; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace srb2
|
||||||
|
|
||||||
|
template <typename T, size_t L1, size_t L2>
|
||||||
|
bool operator==(const srb2::StaticVec<T, L1>& lhs, const srb2::StaticVec<T, L2>& rhs)
|
||||||
|
{
|
||||||
|
const size_t size = lhs.size();
|
||||||
|
if (size != rhs.size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < lhs; i++)
|
||||||
|
{
|
||||||
|
if (rhs[i] != lhs[i])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t L1, size_t L2>
|
||||||
|
bool operator!=(const srb2::StaticVec<T, L1>& lhs, const srb2::StaticVec<T, L2>& rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t Limit>
|
||||||
|
struct std::hash<srb2::StaticVec<T, Limit>>
|
||||||
|
{
|
||||||
|
size_t operator()(const srb2::StaticVec<T, Limit>& input) const
|
||||||
|
{
|
||||||
|
constexpr size_t prime = sizeof(size_t) == 8 ? 0x00000100000001B3 : 0x01000193;
|
||||||
|
constexpr size_t basis = sizeof(size_t) == 8 ? 0xcbf29ce484222325 : 0x811c9dc5;
|
||||||
|
|
||||||
|
size_t ret = basis;
|
||||||
|
for (auto itr = input.begin(); itr != input.end(); itr++)
|
||||||
|
{
|
||||||
|
ret = (ret * prime) ^ std::hash<T>(*itr);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __SRB2_CORE_STATIC_VEC_HPP__
|
||||||
@@ -0,0 +1,346 @@
|
|||||||
|
// BLANKART
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2024 by Ronald "Eidolon" Kinard
|
||||||
|
// Copyright (C) 2024 by Kart Krew
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "thread_pool.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <exception>
|
||||||
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
|
|
||||||
|
//#include <fmt/format.h>
|
||||||
|
//#include <tracy/tracy/Tracy.hpp>
|
||||||
|
|
||||||
|
#include "../cxxutil.hpp"
|
||||||
|
#include "../m_argv.h"
|
||||||
|
|
||||||
|
using namespace srb2;
|
||||||
|
|
||||||
|
static void do_work(ThreadPool::Task& work)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//ZoneScoped;
|
||||||
|
(work.thunk)(work.raw.data());
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
// can't do anything
|
||||||
|
}
|
||||||
|
|
||||||
|
(work.deleter)(work.raw.data());
|
||||||
|
if (work.pseudosema)
|
||||||
|
{
|
||||||
|
work.pseudosema->fetch_sub(1, std::memory_order_relaxed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pool_executor(
|
||||||
|
//int thread_index,
|
||||||
|
std::shared_ptr<std::atomic<bool>> pool_alive,
|
||||||
|
std::shared_ptr<std::mutex> worker_ready_mutex,
|
||||||
|
std::shared_ptr<std::condition_variable> worker_ready_condvar,
|
||||||
|
std::shared_ptr<ThreadPool::Queue> my_wq,
|
||||||
|
std::vector<std::shared_ptr<ThreadPool::Queue>> other_wqs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
//std::string thread_name = fmt::format("Thread Pool Thread {}", thread_index);
|
||||||
|
//tracy::SetThreadName(thread_name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int spins = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
std::optional<ThreadPool::Task> work = my_wq->steal();
|
||||||
|
bool did_work = false;
|
||||||
|
if (work)
|
||||||
|
{
|
||||||
|
do_work(*work);
|
||||||
|
|
||||||
|
did_work = true;
|
||||||
|
spins = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto& q : other_wqs)
|
||||||
|
{
|
||||||
|
work = q->steal();
|
||||||
|
if (work)
|
||||||
|
{
|
||||||
|
do_work(*work);
|
||||||
|
|
||||||
|
did_work = true;
|
||||||
|
spins = 0;
|
||||||
|
|
||||||
|
// We only want to steal one work item at a time, to prioritize our own queue
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!did_work)
|
||||||
|
{
|
||||||
|
// Spin a few loops to avoid yielding, then wait for the ready lock
|
||||||
|
spins += 1;
|
||||||
|
if (spins > 100)
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> ready_lock {*worker_ready_mutex};
|
||||||
|
while (my_wq->empty() && pool_alive->load())
|
||||||
|
{
|
||||||
|
worker_ready_condvar->wait(ready_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pool_alive->load())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadPool::ThreadPool()
|
||||||
|
{
|
||||||
|
immediate_mode_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadPool::ThreadPool(size_t threads)
|
||||||
|
{
|
||||||
|
next_queue_index_ = 0;
|
||||||
|
pool_alive_ = std::make_shared<std::atomic<bool>>(true);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < threads; i++)
|
||||||
|
{
|
||||||
|
std::shared_ptr<Queue> wsq = std::make_shared<Queue>(2048);
|
||||||
|
work_queues_.push_back(wsq);
|
||||||
|
|
||||||
|
std::shared_ptr<std::mutex> mutex = std::make_shared<std::mutex>();
|
||||||
|
worker_ready_mutexes_.push_back(std::move(mutex));
|
||||||
|
std::shared_ptr<std::condition_variable> condvar = std::make_shared<std::condition_variable>();
|
||||||
|
worker_ready_condvars_.push_back(std::move(condvar));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < threads; i++)
|
||||||
|
{
|
||||||
|
std::shared_ptr<Queue> my_queue = work_queues_[i];
|
||||||
|
std::vector<std::shared_ptr<Queue>> other_queues;
|
||||||
|
for (size_t j = 0; j < threads; j++)
|
||||||
|
{
|
||||||
|
// Order the other queues starting from the next adjacent worker
|
||||||
|
// i.e. if this is worker 2 of 8, then other queues is 3, 4, 5, 6, 7, 0, 1
|
||||||
|
// This tries to balance out work stealing behavior
|
||||||
|
|
||||||
|
size_t other_index = j + i;
|
||||||
|
if (other_index >= threads)
|
||||||
|
{
|
||||||
|
other_index -= threads;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (other_index != i)
|
||||||
|
{
|
||||||
|
other_queues.push_back(work_queues_[other_index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::thread thread;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
thread = std::thread
|
||||||
|
{
|
||||||
|
pool_executor,
|
||||||
|
//i,
|
||||||
|
pool_alive_,
|
||||||
|
worker_ready_mutexes_[i],
|
||||||
|
worker_ready_condvars_[i],
|
||||||
|
my_queue,
|
||||||
|
other_queues
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (const std::system_error& error)
|
||||||
|
{
|
||||||
|
// Safe shutdown and rethrow
|
||||||
|
pool_alive_->store(false);
|
||||||
|
for (auto& t : threads_)
|
||||||
|
{
|
||||||
|
t.join();
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
threads_.push_back(std::move(thread));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadPool::ThreadPool(ThreadPool&&) = default;
|
||||||
|
ThreadPool::~ThreadPool() = default;
|
||||||
|
|
||||||
|
ThreadPool& ThreadPool::operator=(ThreadPool&&) = default;
|
||||||
|
|
||||||
|
void ThreadPool::begin_sema()
|
||||||
|
{
|
||||||
|
sema_begun_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadPool::Sema ThreadPool::end_sema()
|
||||||
|
{
|
||||||
|
Sema ret = Sema(std::move(cur_sema_));
|
||||||
|
cur_sema_ = nullptr;
|
||||||
|
sema_begun_ = false;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadPool::notify()
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < work_queues_.size(); i++)
|
||||||
|
{
|
||||||
|
auto& q = work_queues_[i];
|
||||||
|
size_t count = q->size();
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
worker_ready_condvars_[i]->notify_one();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadPool::notify_sema(const ThreadPool::Sema& sema)
|
||||||
|
{
|
||||||
|
if (!sema.pseudosema_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadPool::wait_idle()
|
||||||
|
{
|
||||||
|
if (immediate_mode_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ZoneScoped;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < work_queues_.size(); i++)
|
||||||
|
{
|
||||||
|
auto& q = work_queues_[i];
|
||||||
|
|
||||||
|
std::optional<Task> work;
|
||||||
|
while ((work = q->pop()).has_value())
|
||||||
|
{
|
||||||
|
do_work(*work);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadPool::wait_sema(const Sema& sema)
|
||||||
|
{
|
||||||
|
if (!sema.pseudosema_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ZoneScoped;
|
||||||
|
|
||||||
|
while (sema.pseudosema_->load(std::memory_order_seq_cst) > 0)
|
||||||
|
{
|
||||||
|
// spin to win
|
||||||
|
for (size_t i = 0; i < work_queues_.size(); i++)
|
||||||
|
{
|
||||||
|
auto& q = work_queues_[i];
|
||||||
|
|
||||||
|
std::optional<Task> work;
|
||||||
|
if ((work = q->pop()).has_value())
|
||||||
|
{
|
||||||
|
do_work(*work);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sema.pseudosema_->load(std::memory_order_seq_cst) != 0)
|
||||||
|
{
|
||||||
|
throw std::exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadPool::shutdown()
|
||||||
|
{
|
||||||
|
if (immediate_mode_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wait_idle();
|
||||||
|
|
||||||
|
pool_alive_->store(false);
|
||||||
|
|
||||||
|
for (auto& condvar : worker_ready_condvars_)
|
||||||
|
{
|
||||||
|
condvar->notify_all();
|
||||||
|
}
|
||||||
|
for (auto& t : threads_)
|
||||||
|
{
|
||||||
|
t.join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<ThreadPool> srb2::g_main_threadpool;
|
||||||
|
|
||||||
|
void I_ThreadPoolInit(void)
|
||||||
|
{
|
||||||
|
SRB2_ASSERT(g_main_threadpool == nullptr);
|
||||||
|
size_t thread_count = std::min(static_cast<unsigned int>(9), std::thread::hardware_concurrency());
|
||||||
|
if (thread_count > 1)
|
||||||
|
{
|
||||||
|
// The main thread will act as a worker when waiting for pool idle
|
||||||
|
// Make one less worker thread to avoid unnecessary context switching
|
||||||
|
thread_count -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (M_CheckParm("-singlethreaded"))
|
||||||
|
{
|
||||||
|
g_main_threadpool = std::make_unique<ThreadPool>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_main_threadpool = std::make_unique<ThreadPool>(thread_count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_ThreadPoolShutdown(void)
|
||||||
|
{
|
||||||
|
if (!g_main_threadpool)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_main_threadpool->shutdown();
|
||||||
|
g_main_threadpool = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_ThreadPoolSubmit(srb2cthunk_t thunk, void* data)
|
||||||
|
{
|
||||||
|
SRB2_ASSERT(g_main_threadpool != nullptr);
|
||||||
|
|
||||||
|
g_main_threadpool->schedule([=]() {
|
||||||
|
(thunk)(data);
|
||||||
|
});
|
||||||
|
g_main_threadpool->notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_ThreadPoolWaitIdle(void)
|
||||||
|
{
|
||||||
|
SRB2_ASSERT(g_main_threadpool != nullptr);
|
||||||
|
|
||||||
|
g_main_threadpool->wait_idle();
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
// BLANKART
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2024 by Ronald "Eidolon" Kinard
|
||||||
|
// Copyright (C) 2024 by Kart Krew
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef __SRB2_CORE_THREAD_POOL_H__
|
||||||
|
#define __SRB2_CORE_THREAD_POOL_H__
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <thread>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "spmc_queue.hpp"
|
||||||
|
|
||||||
|
namespace srb2
|
||||||
|
{
|
||||||
|
|
||||||
|
class ThreadPool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct Task
|
||||||
|
{
|
||||||
|
void (*thunk)(void*);
|
||||||
|
void (*deleter)(void*);
|
||||||
|
std::shared_ptr<std::atomic<uint32_t>> pseudosema;
|
||||||
|
std::array<std::byte, 512 - sizeof(void(*)(void*)) * 2 - sizeof(std::shared_ptr<std::atomic<uint32_t>>)> raw;
|
||||||
|
};
|
||||||
|
|
||||||
|
using Queue = SpMcQueue<Task>;
|
||||||
|
|
||||||
|
class Sema
|
||||||
|
{
|
||||||
|
std::shared_ptr<std::atomic<uint32_t>> pseudosema_;
|
||||||
|
|
||||||
|
explicit Sema(std::shared_ptr<std::atomic<uint32_t>> sema) : pseudosema_(sema) {}
|
||||||
|
|
||||||
|
friend class ThreadPool;
|
||||||
|
public:
|
||||||
|
Sema() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<std::atomic<bool>> pool_alive_;
|
||||||
|
std::vector<std::shared_ptr<std::mutex>> worker_ready_mutexes_;
|
||||||
|
std::vector<std::shared_ptr<std::condition_variable>> worker_ready_condvars_;
|
||||||
|
std::vector<std::shared_ptr<Queue>> work_queues_;
|
||||||
|
std::vector<std::thread> threads_;
|
||||||
|
size_t next_queue_index_ = 0;
|
||||||
|
std::shared_ptr<std::atomic<uint32_t>> cur_sema_;
|
||||||
|
|
||||||
|
bool immediate_mode_ = false;
|
||||||
|
bool sema_begun_ = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ThreadPool();
|
||||||
|
explicit ThreadPool(size_t threads);
|
||||||
|
ThreadPool(const ThreadPool&) = delete;
|
||||||
|
ThreadPool(ThreadPool&&);
|
||||||
|
~ThreadPool();
|
||||||
|
|
||||||
|
ThreadPool& operator=(const ThreadPool&) = delete;
|
||||||
|
ThreadPool& operator=(ThreadPool&&);
|
||||||
|
|
||||||
|
void begin_sema();
|
||||||
|
ThreadPool::Sema end_sema();
|
||||||
|
|
||||||
|
/// Enqueue but don't notify
|
||||||
|
template <typename T> void schedule(T&& thunk);
|
||||||
|
/// Notify threads after several schedules
|
||||||
|
void notify();
|
||||||
|
void notify_sema(const Sema& sema);
|
||||||
|
void wait_idle();
|
||||||
|
void wait_sema(const Sema& sema);
|
||||||
|
void shutdown();
|
||||||
|
};
|
||||||
|
|
||||||
|
extern std::unique_ptr<ThreadPool> g_main_threadpool;
|
||||||
|
|
||||||
|
template <typename F>
|
||||||
|
void callable_caller(F* f)
|
||||||
|
{
|
||||||
|
(*f)();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename F>
|
||||||
|
void callable_destroyer(F* f)
|
||||||
|
{
|
||||||
|
f->~F();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void ThreadPool::schedule(T&& thunk)
|
||||||
|
{
|
||||||
|
static_assert(sizeof(T) <= sizeof(std::declval<Task>().raw));
|
||||||
|
|
||||||
|
if (immediate_mode_)
|
||||||
|
{
|
||||||
|
(thunk)();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sema_begun_)
|
||||||
|
{
|
||||||
|
if (cur_sema_ == nullptr)
|
||||||
|
{
|
||||||
|
cur_sema_ = std::make_shared<std::atomic<uint32_t>>(0);
|
||||||
|
}
|
||||||
|
cur_sema_->fetch_add(1, std::memory_order_relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t qi = next_queue_index_;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::shared_ptr<Queue> q = work_queues_[qi];
|
||||||
|
Task task;
|
||||||
|
task.thunk = reinterpret_cast<void(*)(void*)>(callable_caller<T>);
|
||||||
|
task.deleter = reinterpret_cast<void(*)(void*)>(callable_destroyer<T>);
|
||||||
|
task.pseudosema = cur_sema_;
|
||||||
|
new (reinterpret_cast<T*>(task.raw.data())) T(std::move(thunk));
|
||||||
|
|
||||||
|
q->push(std::move(task));
|
||||||
|
}
|
||||||
|
// worker_ready_condvars_[qi]->notify_one();
|
||||||
|
|
||||||
|
next_queue_index_ += 1;
|
||||||
|
if (next_queue_index_ >= threads_.size())
|
||||||
|
{
|
||||||
|
next_queue_index_ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace srb2
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
typedef void (*srb2cthunk_t)(void*);
|
||||||
|
|
||||||
|
void I_ThreadPoolInit(void);
|
||||||
|
void I_ThreadPoolShutdown(void);
|
||||||
|
void I_ThreadPoolSubmit(srb2cthunk_t thunk, void* data);
|
||||||
|
void I_ThreadPoolWaitIdle(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __SRB2_CORE_THREAD_POOL_H__
|
||||||
+152
@@ -0,0 +1,152 @@
|
|||||||
|
#ifndef __SRB2_CXXUTIL_HPP__
|
||||||
|
#define __SRB2_CXXUTIL_HPP__
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "doomdef.h"
|
||||||
|
|
||||||
|
namespace srb2 {
|
||||||
|
|
||||||
|
template <class F>
|
||||||
|
class Finally {
|
||||||
|
public:
|
||||||
|
explicit Finally(const F& f) noexcept : f_(f) {}
|
||||||
|
explicit Finally(F&& f) noexcept : f_(f) {}
|
||||||
|
|
||||||
|
Finally(Finally&& from) noexcept : f_(std::move(from.f_)), call_(std::exchange(from.call_, false)) {}
|
||||||
|
|
||||||
|
Finally(const Finally& from) = delete;
|
||||||
|
void operator=(const Finally& from) = delete;
|
||||||
|
void operator=(Finally&& from) = delete;
|
||||||
|
|
||||||
|
~Finally() noexcept {
|
||||||
|
if (call_)
|
||||||
|
f_();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
F f_;
|
||||||
|
bool call_ = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class F>
|
||||||
|
Finally<std::decay_t<F>> finally(F&& f) noexcept {
|
||||||
|
return Finally {std::forward<F>(f)};
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SourceLocation {
|
||||||
|
const char* file_name;
|
||||||
|
unsigned int line_number;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SRB2_SOURCE_LOCATION \
|
||||||
|
srb2::SourceLocation { __FILE__, __LINE__ }
|
||||||
|
|
||||||
|
#ifndef SRB2_ASSERT_HANDLER
|
||||||
|
#define SRB2_ASSERT_HANDLER srb2::IErrorAssertHandler
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(NDEBUG) || defined(PARANOIA)
|
||||||
|
// An assertion level of 2 will activate all invocations of the SRB2_ASSERT macro
|
||||||
|
#define SRB2_ASSERTION_LEVEL 2
|
||||||
|
#else
|
||||||
|
// The minimum assertion level is 1
|
||||||
|
#define SRB2_ASSERTION_LEVEL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Assert a precondition expression in debug builds.
|
||||||
|
#define SRB2_ASSERT(expr) srb2::do_assert<2, SRB2_ASSERT_HANDLER>([&] { return (expr); }, SRB2_SOURCE_LOCATION, #expr)
|
||||||
|
|
||||||
|
class IErrorAssertHandler {
|
||||||
|
public:
|
||||||
|
static void handle(const SourceLocation& source_location, const char* expression) {
|
||||||
|
I_Error("Assertion failed at %s:%u: %s != true",
|
||||||
|
source_location.file_name,
|
||||||
|
source_location.line_number,
|
||||||
|
expression);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class NoOpAssertHandler {
|
||||||
|
public:
|
||||||
|
static void handle(const SourceLocation& source_location, const char* expression) {(void)source_location; (void)expression;}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @brief Assert a precondition expression, aborting the application if it fails.
|
||||||
|
/// @tparam Expr
|
||||||
|
/// @tparam Level the level of this assertion; if it is less than or equal to SRB2_ASSERTION_LEVEL, this overload will
|
||||||
|
/// activate.
|
||||||
|
/// @param expr a callable which returns a bool
|
||||||
|
/// @param source_location a struct containing the source location of the assertion, e.g. SRB2_SOURCE_LOCATION
|
||||||
|
/// @param expression the expression evaluated in the expression callable
|
||||||
|
/// @param message an optional message to display for the assertion
|
||||||
|
template <unsigned int Level, class Handler, class Expr>
|
||||||
|
std::enable_if_t<(Level <= SRB2_ASSERTION_LEVEL), void>
|
||||||
|
do_assert(const Expr& expr, const SourceLocation& source_location, const char* expression = "") noexcept {
|
||||||
|
static_assert(Level > 0, "level of an assertion must not be 0");
|
||||||
|
if (!expr()) {
|
||||||
|
Handler::handle(source_location, expression);
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <unsigned int Level, class, class Expr>
|
||||||
|
std::enable_if_t<(Level > SRB2_ASSERTION_LEVEL), void>
|
||||||
|
do_assert(const Expr&, const SourceLocation&, const char* = "") noexcept {
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class NotNull final {
|
||||||
|
T ptr_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static_assert(std::is_convertible_v<decltype(std::declval<T>() != nullptr), bool>,
|
||||||
|
"T is not comparable with nullptr_t");
|
||||||
|
|
||||||
|
/// @brief Move-construct from the pointer value U, asserting that it is not null. Allows construction of a
|
||||||
|
/// NotNull<T> from any compatible pointer U, for example with polymorphic classes.
|
||||||
|
template <typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
|
||||||
|
constexpr NotNull(U&& rhs) : ptr_(std::forward<U>(rhs)) {
|
||||||
|
SRB2_ASSERT(ptr_ != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Wrap the pointer type T, asserting that the pointer is not null.
|
||||||
|
template <typename = std::enable_if_t<!std::is_same_v<std::nullptr_t, T>>>
|
||||||
|
constexpr NotNull(T rhs) : ptr_(std::move(rhs)) {
|
||||||
|
SRB2_ASSERT(ptr_ != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Copy construction from NotNull of convertible type U. Only if the incoming pointer is NotNull already.
|
||||||
|
template <typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
|
||||||
|
constexpr NotNull(const NotNull<U>& rhs) : NotNull(rhs.get()) {
|
||||||
|
// Value is guaranteed to be not null by construction; no assertion necessary
|
||||||
|
}
|
||||||
|
|
||||||
|
NotNull(const NotNull& rhs) = default;
|
||||||
|
NotNull& operator=(const NotNull& rhs) = default;
|
||||||
|
|
||||||
|
/// @brief Get the stored pointer.
|
||||||
|
constexpr T get() const { return ptr_; }
|
||||||
|
|
||||||
|
/// @brief Convert to T (the pointer type).
|
||||||
|
constexpr operator T() const { return get(); }
|
||||||
|
|
||||||
|
/// @brief Arrow-dereference to *T (the actual value pointed to).
|
||||||
|
constexpr decltype(auto) operator->() const { return get(); }
|
||||||
|
|
||||||
|
/// @brief Dereference to *T (the actual value pointed to).
|
||||||
|
constexpr decltype(auto) operator*() const { return *get(); }
|
||||||
|
|
||||||
|
// It is not allowed to construct NotNull<T> with nullptr regardless of T.
|
||||||
|
NotNull(std::nullptr_t) = delete;
|
||||||
|
NotNull& operator=(std::nullptr_t) = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
NotNull(T) -> NotNull<T>;
|
||||||
|
|
||||||
|
} // namespace srb2
|
||||||
|
|
||||||
|
#endif // __SRB2_CXXUTIL_HPP__
|
||||||
+139
-11
@@ -87,6 +87,9 @@ boolean serverrunning = false;
|
|||||||
INT32 serverplayer = 0;
|
INT32 serverplayer = 0;
|
||||||
char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support)
|
char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support)
|
||||||
|
|
||||||
|
plrinfo playerinfo[MAXPLAYERS];
|
||||||
|
SINT8 joinnode = 0; // used for CL_VIEWSERVER
|
||||||
|
|
||||||
// Server specific vars
|
// Server specific vars
|
||||||
UINT8 playernode[MAXPLAYERS];
|
UINT8 playernode[MAXPLAYERS];
|
||||||
|
|
||||||
@@ -95,7 +98,7 @@ UINT8 playernode[MAXPLAYERS];
|
|||||||
tic_t jointimeout = (3*TICRATE);
|
tic_t jointimeout = (3*TICRATE);
|
||||||
static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame?
|
static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame?
|
||||||
#ifdef SATURNPAK
|
#ifdef SATURNPAK
|
||||||
static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame?
|
static tic_t resendingsavegame[MAXNETNODES]; // Are we resending the savegame?
|
||||||
static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again?
|
static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again?
|
||||||
#endif
|
#endif
|
||||||
static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout?
|
static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout?
|
||||||
@@ -1185,6 +1188,7 @@ typedef enum
|
|||||||
#endif
|
#endif
|
||||||
CL_CONNECTED,
|
CL_CONNECTED,
|
||||||
CL_ABORTED,
|
CL_ABORTED,
|
||||||
|
CL_VIEWSERVER,
|
||||||
CL_ASKFULLFILELIST,
|
CL_ASKFULLFILELIST,
|
||||||
CL_CONFIRMCONNECT,
|
CL_CONFIRMCONNECT,
|
||||||
#ifdef HAVE_CURL
|
#ifdef HAVE_CURL
|
||||||
@@ -1248,7 +1252,7 @@ static inline void CL_DrawConnectionStatus(void)
|
|||||||
if (!menuactive) // menu already draws its own fade
|
if (!menuactive) // menu already draws its own fade
|
||||||
V_DrawFadeScreen(0xFF00, 16); // force default
|
V_DrawFadeScreen(0xFF00, 16); // force default
|
||||||
|
|
||||||
if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_LOADFILES && cl_mode != CL_CHECKFILES
|
if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_LOADFILES && cl_mode != CL_CHECKFILES && cl_mode != CL_VIEWSERVER
|
||||||
#ifdef HAVE_CURL
|
#ifdef HAVE_CURL
|
||||||
&& cl_mode != CL_DOWNLOADHTTPFILES
|
&& cl_mode != CL_DOWNLOADHTTPFILES
|
||||||
#endif
|
#endif
|
||||||
@@ -1368,6 +1372,78 @@ static inline void CL_DrawConnectionStatus(void)
|
|||||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
|
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
|
||||||
va(" %2u/%2u Files",loadcompletednum,fileneedednum));
|
va(" %2u/%2u Files",loadcompletednum,fileneedednum));
|
||||||
}
|
}
|
||||||
|
else if (cl_mode == CL_VIEWSERVER)
|
||||||
|
{
|
||||||
|
V_DrawFill(8, 16, BASEVIDWIDTH - 16, 54, 239);
|
||||||
|
|
||||||
|
V_DrawThinString(12 + 80, 18, V_ALLOWLOWERCASE, va("%s", serverlist[joinnode].info.servername));
|
||||||
|
|
||||||
|
const char *map = va("%sP", serverlist[joinnode].info.mapname);
|
||||||
|
patch_t *current_map = W_LumpExists(map) ? W_CachePatchName(map, PU_CACHE) : W_CachePatchName("BLANKLVL", PU_CACHE);
|
||||||
|
V_DrawSmallScaledPatch(10, 18, 0, current_map);
|
||||||
|
|
||||||
|
V_DrawThinString(12 + 80, 38, V_ALLOWLOWERCASE, va("%s", serverlist[joinnode].info.maptitle));
|
||||||
|
V_DrawThinString(12 + 80, 48, V_ALLOWLOWERCASE, va("%s", Gametype_Names[serverlist[joinnode].info.gametype]));
|
||||||
|
|
||||||
|
if (fileneedednum > 0)
|
||||||
|
{
|
||||||
|
V_DrawThinString(12 + 80, 58, V_ALLOWLOWERCASE|V_ORANGEMAP, va("%i Addons", fileneedednum));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
V_DrawThinString(12 + 80, 58, V_ALLOWLOWERCASE|V_YELLOWMAP, "Vanilla");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serverlist[joinnode].info.cheatsenabled)
|
||||||
|
{
|
||||||
|
V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, 58, V_ALLOWLOWERCASE|V_GREENMAP, "Cheats");
|
||||||
|
}
|
||||||
|
|
||||||
|
V_DrawFill(8, 72, BASEVIDWIDTH - 16, 112, 239);
|
||||||
|
|
||||||
|
V_DrawString(12, 74, V_ALLOWLOWERCASE|V_YELLOWMAP, "Players");
|
||||||
|
V_DrawRightAlignedString(BASEVIDWIDTH - 12, 74, V_ALLOWLOWERCASE|V_YELLOWMAP, va("%i / %i", serverlist[joinnode].info.numberofplayer, serverlist[joinnode].info.maxplayer));
|
||||||
|
|
||||||
|
INT32 i;
|
||||||
|
INT32 count = 0;
|
||||||
|
INT32 x = 14;
|
||||||
|
INT32 y = 84;
|
||||||
|
INT32 statuscolor = 1;
|
||||||
|
char player_name[MAXPLAYERNAME+1];
|
||||||
|
if (serverlist[joinnode].info.numberofplayer > 0)
|
||||||
|
{
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
if (playerinfo[i].node < 255)
|
||||||
|
{
|
||||||
|
strncpy(player_name, playerinfo[i].name, MAXPLAYERNAME);
|
||||||
|
V_DrawThinString(x + 10, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, player_name);
|
||||||
|
|
||||||
|
if (playerinfo[i].team == 0) { statuscolor = 184; } // playing
|
||||||
|
if (playerinfo[i].data & 0x20) { statuscolor = 86; } // tag IT
|
||||||
|
if (playerinfo[i].team == 1) { statuscolor = 128; } // ctf red team
|
||||||
|
if (playerinfo[i].team == 2) { statuscolor = 232; } // ctf blue team
|
||||||
|
if (playerinfo[i].team == 255) { statuscolor = 16; } // spectator or non-team
|
||||||
|
|
||||||
|
V_DrawFill(x, y, 7, 7, 31);
|
||||||
|
V_DrawFill(x, y, 6, 6, statuscolor);
|
||||||
|
|
||||||
|
y += 9;
|
||||||
|
count++;
|
||||||
|
if ((count == 11) || (count == 22))
|
||||||
|
{
|
||||||
|
x += 104;
|
||||||
|
y = 84;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
V_DrawFill(8, BASEVIDHEIGHT - 14, BASEVIDWIDTH - 16, 12, 239);
|
||||||
|
V_DrawThinString(16, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sESC%s] = Abort", "\x82", "\x80"));
|
||||||
|
V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sENTER%s] = Join", "\x82", "\x80"));
|
||||||
|
}
|
||||||
else if (filedownload.current != -1)
|
else if (filedownload.current != -1)
|
||||||
{
|
{
|
||||||
INT32 dldlength;
|
INT32 dldlength;
|
||||||
@@ -2469,6 +2545,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
|
|||||||
if (i < 0)
|
if (i < 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
joinnode = i;
|
||||||
|
|
||||||
// Quit here rather than downloading files and being refused later.
|
// Quit here rather than downloading files and being refused later.
|
||||||
if (serverlist[i].info.numberofplayer >= serverlist[i].info.maxplayer)
|
if (serverlist[i].info.numberofplayer >= serverlist[i].info.maxplayer)
|
||||||
@@ -2495,7 +2572,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_mode = CL_CHECKFILES;
|
cl_mode = (cv_serverinfoscreen.value) ? CL_VIEWSERVER : CL_CHECKFILES;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2549,7 +2626,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
|
|||||||
|
|
||||||
case CL_ASKFULLFILELIST:
|
case CL_ASKFULLFILELIST:
|
||||||
if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved
|
if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved
|
||||||
cl_mode = CL_CHECKFILES;
|
cl_mode = (cv_serverinfoscreen.value) ? CL_VIEWSERVER : CL_CHECKFILES;
|
||||||
else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent)
|
else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent)
|
||||||
{
|
{
|
||||||
if (CL_AskFileList(fileneedednum))
|
if (CL_AskFileList(fileneedednum))
|
||||||
@@ -2715,6 +2792,15 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
|
|||||||
D_ProcessEvents(); //needed for menu system to receive inputs
|
D_ProcessEvents(); //needed for menu system to receive inputs
|
||||||
|
|
||||||
key = I_GetKey();
|
key = I_GetKey();
|
||||||
|
|
||||||
|
if (cl_mode == CL_VIEWSERVER)
|
||||||
|
{
|
||||||
|
if (key == KEY_ENTER || key == KEY_JOY1)
|
||||||
|
cl_mode = CL_CHECKFILES;
|
||||||
|
else if (key == KEY_ESCAPE || key == KEY_JOY1+1)
|
||||||
|
cl_mode = CL_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
// Only ESC and non-keyboard keys abort connection
|
// Only ESC and non-keyboard keys abort connection
|
||||||
if (!modeattacking && (key == KEY_ESCAPE || key == KEY_JOY1+1 || cl_mode == CL_ABORTED))
|
if (!modeattacking && (key == KEY_ESCAPE || key == KEY_JOY1+1 || cl_mode == CL_ABORTED))
|
||||||
{
|
{
|
||||||
@@ -4142,6 +4228,8 @@ consvar_t cv_downloadspeed = {"downloadspeed", "300", CV_SAVE, downloadspeed_con
|
|||||||
static CV_PossibleValue_t connectawaittime_cons_t[] = {{1, "MIN"}, {60, "MAX"}, {0, "Inf"}, {0, NULL}};
|
static CV_PossibleValue_t connectawaittime_cons_t[] = {{1, "MIN"}, {60, "MAX"}, {0, "Inf"}, {0, NULL}};
|
||||||
consvar_t cv_connectawaittime = {"connectawaittime", "5", CV_SAVE, connectawaittime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_connectawaittime = {"connectawaittime", "5", CV_SAVE, connectawaittime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
consvar_t cv_serverinfoscreen = {"serverinfoscreen", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
static void Got_AddPlayer(UINT8 **p, INT32 playernum);
|
static void Got_AddPlayer(UINT8 **p, INT32 playernum);
|
||||||
static void Got_RemovePlayer(UINT8 **p, INT32 playernum);
|
static void Got_RemovePlayer(UINT8 **p, INT32 playernum);
|
||||||
|
|
||||||
@@ -4244,7 +4332,7 @@ static void ResetNode(INT32 node)
|
|||||||
// SATURN
|
// SATURN
|
||||||
#ifdef SATURNPAK
|
#ifdef SATURNPAK
|
||||||
is_client_saturn[node] = false;
|
is_client_saturn[node] = false;
|
||||||
resendingsavegame[node] = false;
|
resendingsavegame[node] = 0;
|
||||||
savegameresendcooldown[node] = 0;
|
savegameresendcooldown[node] = 0;
|
||||||
gamestate_resend_counter[node] = 0;
|
gamestate_resend_counter[node] = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -4909,6 +4997,16 @@ static void HandleServerInfo(SINT8 node)
|
|||||||
if (client && cl_mode > CL_SEARCHING && node == servernode)
|
if (client && cl_mode > CL_SEARCHING && node == servernode)
|
||||||
memcpy(connectedservername, netbuffer->u.serverinfo.servername, MAXSERVERNAME);
|
memcpy(connectedservername, netbuffer->u.serverinfo.servername, MAXSERVERNAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void HandlePlayerInfo(SINT8 node)
|
||||||
|
{
|
||||||
|
(void)node;
|
||||||
|
|
||||||
|
INT32 i;
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
playerinfo[i] = netbuffer->u.playerinfo[i];
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SATURNPAK
|
#ifdef SATURNPAK
|
||||||
@@ -4945,7 +5043,7 @@ static void PT_CanReceiveGamestate(SINT8 node)
|
|||||||
CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]);
|
CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]);
|
||||||
|
|
||||||
SV_SendSaveGame(node, true); // Resend a complete game state
|
SV_SendSaveGame(node, true); // Resend a complete game state
|
||||||
resendingsavegame[node] = true;
|
resendingsavegame[node] = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -5198,6 +5296,10 @@ static void HandlePacketFromAwayNode(SINT8 node)
|
|||||||
case PT_CLIENTCMD:
|
case PT_CLIENTCMD:
|
||||||
break; // This is not an "unknown packet"
|
break; // This is not an "unknown packet"
|
||||||
|
|
||||||
|
case PT_PLAYERINFO:
|
||||||
|
HandlePlayerInfo(node);
|
||||||
|
break;
|
||||||
|
|
||||||
case PT_SERVERTICS:
|
case PT_SERVERTICS:
|
||||||
// Do not remove my own server (we have just get a out of order packet)
|
// Do not remove my own server (we have just get a out of order packet)
|
||||||
if (node == servernode)
|
if (node == servernode)
|
||||||
@@ -5392,7 +5494,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||||||
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)
|
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)
|
||||||
&& (!UseSaturnSynch(node) || (!resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() && !SV_ResendingSavegameToAnyone())))
|
&& (!UseSaturnSynch(node) || (!resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() && !SV_ResendingSavegameToAnyone())))
|
||||||
{
|
{
|
||||||
resendingsavegame[node] = false; // reset this before just in case
|
resendingsavegame[node] = 0; // reset this before just in case
|
||||||
|
|
||||||
// Check if a client is saturn before sending ANYTHING!
|
// Check if a client is saturn before sending ANYTHING!
|
||||||
// this way we only send stuff to clients we know can use the gamestate resend
|
// this way we only send stuff to clients we know can use the gamestate resend
|
||||||
@@ -5402,7 +5504,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||||||
// Tell the client we are about to resend them the gamestate
|
// Tell the client we are about to resend them the gamestate
|
||||||
netbuffer->packettype = PT_WILLRESENDGAMESTATE;
|
netbuffer->packettype = PT_WILLRESENDGAMESTATE;
|
||||||
HSendPacket(node, true, 0, 0);
|
HSendPacket(node, true, 0, 0);
|
||||||
resendingsavegame[node] = true;
|
resendingsavegame[node] = 1;
|
||||||
}
|
}
|
||||||
else if (UseVanillaSynch(node))
|
else if (UseVanillaSynch(node))
|
||||||
{
|
{
|
||||||
@@ -5732,7 +5834,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||||||
break;
|
break;
|
||||||
case PT_RECEIVEDGAMESTATE:
|
case PT_RECEIVEDGAMESTATE:
|
||||||
sendingsavegame[node] = false;
|
sendingsavegame[node] = false;
|
||||||
resendingsavegame[node] = false;
|
resendingsavegame[node] = 0;
|
||||||
savegameresendcooldown[node] = I_GetTime() + cv_resynchcooldown.value * TICRATE; // I_GetTime() + 5 * TICRATE;
|
savegameresendcooldown[node] = I_GetTime() + cv_resynchcooldown.value * TICRATE; // I_GetTime() + 5 * TICRATE;
|
||||||
break;
|
break;
|
||||||
case PT_WILLRESENDGAMESTATE:
|
case PT_WILLRESENDGAMESTATE:
|
||||||
@@ -5792,8 +5894,9 @@ static void GetPackets(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (netbuffer->packettype == PT_PLAYERINFO)
|
/*if (netbuffer->packettype == PT_PLAYERINFO)
|
||||||
continue; // We do nothing with PLAYERINFO, that's for the MS browser.
|
continue; // We do nothing with PLAYERINFO, that's for the MS browser. Not quite true anymore :p*/
|
||||||
|
|
||||||
|
|
||||||
// We also count unknown packets, hence "<="
|
// We also count unknown packets, hence "<="
|
||||||
if (netbuffer->packettype <= NUMPACKETTYPE)
|
if (netbuffer->packettype <= NUMPACKETTYPE)
|
||||||
@@ -6362,10 +6465,35 @@ static void SV_Maketic(void)
|
|||||||
maketic++;
|
maketic++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SATURNPAK
|
||||||
|
static void SV_UpdateResendGamestateTimeout(void)
|
||||||
|
{
|
||||||
|
for (INT32 i = 0; i < MAXNETNODES; ++i)
|
||||||
|
{
|
||||||
|
if (!resendingsavegame[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
resendingsavegame[i]++;
|
||||||
|
|
||||||
|
// Resending savegame took too long
|
||||||
|
if (resendingsavegame[i] > (tic_t)TICRATE*cv_pingtimeout.value)
|
||||||
|
{
|
||||||
|
resendingsavegame[i] = 0;
|
||||||
|
SendKick(i, KICK_MSG_CON_FAIL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
boolean TryRunTics(tic_t realtics)
|
boolean TryRunTics(tic_t realtics)
|
||||||
{
|
{
|
||||||
boolean ticking;
|
boolean ticking;
|
||||||
|
|
||||||
|
#ifdef SATURNPAK
|
||||||
|
if (server)
|
||||||
|
SV_UpdateResendGamestateTimeout();
|
||||||
|
#endif
|
||||||
|
|
||||||
// the machine has lagged but it is not so bad
|
// the machine has lagged but it is not so bad
|
||||||
if (realtics > TICRATE/7) // FIXME: consistency failure!!
|
if (realtics > TICRATE/7) // FIXME: consistency failure!!
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
#ifndef __D_CLISRV__
|
#ifndef __D_CLISRV__
|
||||||
#define __D_CLISRV__
|
#define __D_CLISRV__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "d_ticcmd.h"
|
#include "d_ticcmd.h"
|
||||||
#include "d_net.h"
|
#include "d_net.h"
|
||||||
#include "d_netcmd.h"
|
#include "d_netcmd.h"
|
||||||
@@ -577,6 +581,9 @@ extern boolean acceptnewnode;
|
|||||||
extern SINT8 servernode;
|
extern SINT8 servernode;
|
||||||
extern char connectedservername[MAXSERVERNAME+1];
|
extern char connectedservername[MAXSERVERNAME+1];
|
||||||
|
|
||||||
|
extern plrinfo playerinfo[MAXPLAYERS];
|
||||||
|
extern SINT8 joinnode;
|
||||||
|
|
||||||
void Command_Ping_f(void);
|
void Command_Ping_f(void);
|
||||||
extern tic_t connectiontimeout;
|
extern tic_t connectiontimeout;
|
||||||
extern tic_t jointimeout;
|
extern tic_t jointimeout;
|
||||||
@@ -608,6 +615,8 @@ extern consvar_t cv_connectawaittime;
|
|||||||
|
|
||||||
extern consvar_t cv_discordinvites;
|
extern consvar_t cv_discordinvites;
|
||||||
|
|
||||||
|
extern consvar_t cv_serverinfoscreen;
|
||||||
|
|
||||||
// Used in d_net, the only dependence
|
// Used in d_net, the only dependence
|
||||||
//tic_t ExpandTics(INT32 low, tic_t basetic);
|
//tic_t ExpandTics(INT32 low, tic_t basetic);
|
||||||
void D_ClientServerInit(void);
|
void D_ClientServerInit(void);
|
||||||
@@ -689,4 +698,9 @@ typedef struct rewind_s {
|
|||||||
void CL_ClearRewinds(void);
|
void CL_ClearRewinds(void);
|
||||||
rewind_t *CL_SaveRewindPoint(size_t demopos);
|
rewind_t *CL_SaveRewindPoint(size_t demopos);
|
||||||
rewind_t *CL_RewindToTime(tic_t time);
|
rewind_t *CL_RewindToTime(tic_t time);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+67
-35
@@ -40,6 +40,7 @@
|
|||||||
#include "g_game.h"
|
#include "g_game.h"
|
||||||
#include "g_input.h"
|
#include "g_input.h"
|
||||||
#include "hu_stuff.h"
|
#include "hu_stuff.h"
|
||||||
|
#include "m_emotes.h"
|
||||||
#include "i_sound.h"
|
#include "i_sound.h"
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "i_time.h"
|
#include "i_time.h"
|
||||||
@@ -72,6 +73,9 @@
|
|||||||
#include "d_protocol.h"
|
#include "d_protocol.h"
|
||||||
#include "m_perfstats.h"
|
#include "m_perfstats.h"
|
||||||
#include "k_kart.h"
|
#include "k_kart.h"
|
||||||
|
#include "k_hud.h"
|
||||||
|
|
||||||
|
#include "core/memory.h"
|
||||||
|
|
||||||
#include "lua_script.h"
|
#include "lua_script.h"
|
||||||
|
|
||||||
@@ -325,6 +329,39 @@ static void D_Renderview(void)
|
|||||||
|
|
||||||
R_ApplyLevelInterpolators(rendertimefrac);
|
R_ApplyLevelInterpolators(rendertimefrac);
|
||||||
|
|
||||||
|
if (rendermode == render_soft)
|
||||||
|
{
|
||||||
|
// if this is display player 1
|
||||||
|
if (cv_homremoval.value)
|
||||||
|
{
|
||||||
|
if (cv_homremoval.value == 1)
|
||||||
|
{
|
||||||
|
// Clear the software screen buffer to remove HOM
|
||||||
|
memset(vid.screens[0], 31, vid.width * vid.height);
|
||||||
|
}
|
||||||
|
else if (cv_homremoval.value == 2)
|
||||||
|
{
|
||||||
|
//'development' HOM removal -- makes it blindingly obvious if HOM is spotted.
|
||||||
|
memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw over the fourth screen so you don't have to stare at a HOM :V
|
||||||
|
if (splitscreen == 2)
|
||||||
|
{
|
||||||
|
// V_DrawPatchFill, but for the fourth screen only
|
||||||
|
patch_t *pat = W_CachePatchName("SRB2BACK", PU_CACHE);
|
||||||
|
INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy);
|
||||||
|
INT32 x, y, pw = SHORT(pat->width) * dupz, ph = SHORT(pat->height) * dupz;
|
||||||
|
|
||||||
|
for (x = vid.width>>1; x < vid.width; x += pw)
|
||||||
|
{
|
||||||
|
for (y = vid.height>>1; y < vid.height; y += ph)
|
||||||
|
V_DrawScaledPatch(x, y, V_NOSCALESTART, pat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i <= splitscreen; i++)
|
for (i = 0; i <= splitscreen; i++)
|
||||||
{
|
{
|
||||||
const boolean issplitscreen = (i > 0);
|
const boolean issplitscreen = (i > 0);
|
||||||
@@ -336,7 +373,6 @@ static void D_Renderview(void)
|
|||||||
if (!issplitscreen) // Initialize for P1
|
if (!issplitscreen) // Initialize for P1
|
||||||
{
|
{
|
||||||
viewwindowy = viewwindowx = 0;
|
viewwindowy = viewwindowx = 0;
|
||||||
topleft = screens[0];
|
|
||||||
objectsdrawn = 0;
|
objectsdrawn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,13 +381,11 @@ static void D_Renderview(void)
|
|||||||
{
|
{
|
||||||
HWR_RenderPlayerView();
|
HWR_RenderPlayerView();
|
||||||
R_RestoreLevelInterpolators();
|
R_RestoreLevelInterpolators();
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (issplitscreen) // Splitscreen-specific
|
if (issplitscreen) // Splitscreen-specific
|
||||||
{
|
{
|
||||||
const INT32 len = viewheight*sizeof(ylookup[0]);
|
|
||||||
|
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@@ -365,28 +399,20 @@ static void D_Renderview(void)
|
|||||||
viewwindowx = 0;
|
viewwindowx = 0;
|
||||||
viewwindowy = viewheight;
|
viewwindowy = viewheight;
|
||||||
}
|
}
|
||||||
M_Memcpy(ylookup, ylookup2, len);
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
viewwindowx = 0;
|
viewwindowx = 0;
|
||||||
viewwindowy = viewheight;
|
viewwindowy = viewheight;
|
||||||
M_Memcpy(ylookup, ylookup3, len);
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
viewwindowx = viewwidth;
|
viewwindowx = viewwidth;
|
||||||
viewwindowy = viewheight;
|
viewwindowy = viewheight;
|
||||||
M_Memcpy(ylookup, ylookup4, len);
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
R_RenderPlayerView(&players[displayplayers[i]]);
|
R_RenderPlayerView(&players[displayplayers[i]]);
|
||||||
|
|
||||||
if (issplitscreen)
|
|
||||||
M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!issplitscreen)
|
if (!issplitscreen)
|
||||||
@@ -584,7 +610,7 @@ static boolean D_Display(void)
|
|||||||
{
|
{
|
||||||
if (rendermode == render_soft)
|
if (rendermode == render_soft)
|
||||||
{
|
{
|
||||||
VID_BlitLinearScreen(screens[0], screens[1], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes);
|
VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.rowbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastdraw = false;
|
lastdraw = false;
|
||||||
@@ -618,7 +644,7 @@ static boolean D_Display(void)
|
|||||||
V_DrawFadeScreen(TC_RAINBOW, (leveltime & 0x20) ? SKINCOLOR_PASTEL : SKINCOLOR_MOONSLAM);
|
V_DrawFadeScreen(TC_RAINBOW, (leveltime & 0x20) ? SKINCOLOR_PASTEL : SKINCOLOR_MOONSLAM);
|
||||||
|
|
||||||
// vid size change is now finished if it was on...
|
// vid size change is now finished if it was on...
|
||||||
vid.recalc = 0;
|
vid.recalc = false;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
I_lock_mutex(&m_menu_mutex);
|
I_lock_mutex(&m_menu_mutex);
|
||||||
@@ -750,6 +776,8 @@ void D_SRB2Loop(void)
|
|||||||
precise_t enterprecise = I_GetPreciseTime();
|
precise_t enterprecise = I_GetPreciseTime();
|
||||||
precise_t finishprecise = enterprecise;
|
precise_t finishprecise = enterprecise;
|
||||||
|
|
||||||
|
Z_Frame_Reset();
|
||||||
|
|
||||||
// Casting the return value of a function is bad practice (apparently)
|
// Casting the return value of a function is bad practice (apparently)
|
||||||
double budget = ((R_GetFramerateCap() == 0) ? 0.0 : round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision()));
|
double budget = ((R_GetFramerateCap() == 0) ? 0.0 : round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision()));
|
||||||
capbudget = (precise_t)budget;
|
capbudget = (precise_t)budget;
|
||||||
@@ -926,7 +954,7 @@ void D_SRB2Loop(void)
|
|||||||
|
|
||||||
if ((elapsed > 0) && ((INT64)capbudget > elapsed) && !vsync_with_match_refresh)
|
if ((elapsed > 0) && ((INT64)capbudget > elapsed) && !vsync_with_match_refresh)
|
||||||
{
|
{
|
||||||
I_SleepDuration(capbudget - (finishprecise - enterprecise));
|
I_SleepDuration(capbudget - elapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Capture the time once more to get the real delta time.
|
// Capture the time once more to get the real delta time.
|
||||||
@@ -1216,32 +1244,32 @@ static boolean AddIWAD(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// extra graphic patches for saturn specific thingies
|
// extra graphic patches for saturn specific thingies
|
||||||
boolean found_extra_kart = false;
|
boolean found_extra_kart = false;
|
||||||
boolean found_extra2_kart = false;
|
boolean found_extra2_kart = false;
|
||||||
boolean found_extra3_kart = false;
|
boolean found_extra3_kart = false;
|
||||||
|
|
||||||
boolean xtra_speedo = false; // extra speedometer check
|
boolean xtra_speedo = false; // extra speedometer check
|
||||||
boolean xtra_speedo_clr = false; // extra speedometer colour check
|
boolean xtra_speedo_clr = false; // extra speedometer colour check
|
||||||
boolean xtra_speedo3 = false; // 80x 11 extra speedometer check
|
boolean xtra_speedo3 = false; // 80x 11 extra speedometer check
|
||||||
boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check
|
boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check
|
||||||
boolean achi_speedo = false; // achiiro speedometer check
|
boolean achi_speedo = false; // achiiro speedometer check
|
||||||
boolean achi_speedo_clr = false; // extra speedometer colour check
|
boolean achi_speedo_clr = false; // extra speedometer colour check
|
||||||
boolean dial_speedo = false; // dial speedometer check
|
boolean dial_speedo = false; // dial speedometer check
|
||||||
boolean dial_speedo_clr = false; // dial speedometer colour check
|
boolean dial_speedo_clr = false; // dial speedometer colour check
|
||||||
boolean kartz_speedo = false; // kartZ speedo
|
boolean kartz_speedo = false; // kartZ speedo
|
||||||
boolean kartz_speedo_smol = false; // kartZ speedo but smol
|
boolean kartz_speedo_smol = false; // kartZ speedo but smol
|
||||||
|
|
||||||
boolean clr_hud = false; // colour hud check
|
boolean clr_hud = false; // colour hud check
|
||||||
boolean driftgaugegfx_clr = false; // driftgauge colour check
|
boolean driftgaugegfx_clr = false; // driftgauge colour check
|
||||||
boolean big_lap = false; // bigger lap counter
|
boolean big_lap = false; // bigger lap counter
|
||||||
boolean big_lap_color = false; // bigger lap counter but colour
|
boolean big_lap_color = false; // bigger lap counter but colour
|
||||||
boolean statdp = false; // stat display for extended player setup
|
boolean statdp = false; // stat display for extended player setup
|
||||||
boolean nametaggfx = false; // Nametag stuffs
|
boolean nametaggfx = false; // Nametag stuffs
|
||||||
boolean driftgaugegfx = false; // Driftgauge stuffs
|
boolean driftgaugegfx = false; // Driftgauge stuffs
|
||||||
boolean multiitem_icon = false; // Extra icons for Sneakers, Banana and Jawz
|
boolean multiitem_icon = false; // Extra icons for Sneakers, Banana and Jawz
|
||||||
boolean joystickicon = false; // Extra icons for the joystick input display
|
boolean joystickicon = false; // Extra icons for the joystick input display
|
||||||
boolean minidoticon = false; // Dot graphic for minimap player angle display
|
boolean minidoticon = false; // Dot graphic for minimap player angle display
|
||||||
boolean minilighticon = false; // mkwii-style minimap headlight
|
boolean minilighticon = false; // mkwii-style minimap headlight
|
||||||
//
|
//
|
||||||
|
|
||||||
static void IdentifyVersion(void)
|
static void IdentifyVersion(void)
|
||||||
@@ -1610,7 +1638,9 @@ void D_SRB2Main(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// for dedicated server
|
// for dedicated server
|
||||||
|
#if !defined (DEDICATED)
|
||||||
dedicated = M_CheckParm("-dedicated") != 0;
|
dedicated = M_CheckParm("-dedicated") != 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
strcpy(title, "SRB2Kart");
|
strcpy(title, "SRB2Kart");
|
||||||
strcpy(srb2, "SRB2Kart");
|
strcpy(srb2, "SRB2Kart");
|
||||||
@@ -1995,6 +2025,8 @@ void D_SRB2Main(void)
|
|||||||
|
|
||||||
S_InitMusicDefs();
|
S_InitMusicDefs();
|
||||||
|
|
||||||
|
M_InitEmotes();
|
||||||
|
|
||||||
CONS_Printf("ST_Init(): Init status bar.\n");
|
CONS_Printf("ST_Init(): Init status bar.\n");
|
||||||
ST_Init();
|
ST_Init();
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@
|
|||||||
#ifndef __D_MAIN__
|
#ifndef __D_MAIN__
|
||||||
#define __D_MAIN__
|
#define __D_MAIN__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "d_event.h"
|
#include "d_event.h"
|
||||||
#include "w_wad.h" // for MAX_WADFILES
|
#include "w_wad.h" // for MAX_WADFILES
|
||||||
|
|
||||||
@@ -90,4 +94,8 @@ const char *D_Home(void);
|
|||||||
//
|
//
|
||||||
void D_StartTitle(void);
|
void D_StartTitle(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //__D_MAIN__
|
#endif //__D_MAIN__
|
||||||
+8
-2
@@ -18,6 +18,10 @@
|
|||||||
#ifndef __D_NET__
|
#ifndef __D_NET__
|
||||||
#define __D_NET__
|
#define __D_NET__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
// Max computers in a game
|
// Max computers in a game
|
||||||
// 127 is probably as high as this can go, because
|
// 127 is probably as high as this can go, because
|
||||||
// SINT8 is used for nodes sometimes >:(
|
// SINT8 is used for nodes sometimes >:(
|
||||||
@@ -43,8 +47,6 @@ extern SINT8 nodetoplayer4[MAXNETNODES]; // Say the numplayer for this node if a
|
|||||||
extern UINT8 playerpernode[MAXNETNODES]; // Used specially for splitscreen
|
extern UINT8 playerpernode[MAXNETNODES]; // Used specially for splitscreen
|
||||||
extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game
|
extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game
|
||||||
|
|
||||||
extern boolean serverrunning;
|
|
||||||
|
|
||||||
void Net_AckTicker(void);
|
void Net_AckTicker(void);
|
||||||
|
|
||||||
// If reliable return true if packet sent, 0 else
|
// If reliable return true if packet sent, 0 else
|
||||||
@@ -65,4 +67,8 @@ void Net_SendAcks(INT32 node);
|
|||||||
void Net_WaitAllAckReceived(UINT32 timeout);
|
void Net_WaitAllAckReceived(UINT32 timeout);
|
||||||
const char *Net_GetPacketName(UINT8 packettype);
|
const char *Net_GetPacketName(UINT8 packettype);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+8
-7
@@ -21,6 +21,7 @@
|
|||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "g_game.h"
|
#include "g_game.h"
|
||||||
#include "hu_stuff.h"
|
#include "hu_stuff.h"
|
||||||
|
#include "m_emotes.h"
|
||||||
#include "g_input.h"
|
#include "g_input.h"
|
||||||
#include "m_menu.h"
|
#include "m_menu.h"
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
@@ -204,11 +205,6 @@ static void Command_Archivetest_f(void);
|
|||||||
// CLIENT VARIABLES
|
// CLIENT VARIABLES
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
||||||
void SendWeaponPref(void);
|
|
||||||
void SendWeaponPref2(void);
|
|
||||||
void SendWeaponPref3(void);
|
|
||||||
void SendWeaponPref4(void);
|
|
||||||
|
|
||||||
static CV_PossibleValue_t usemouse_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Force"}, {0, NULL}};
|
static CV_PossibleValue_t usemouse_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Force"}, {0, NULL}};
|
||||||
|
|
||||||
static CV_PossibleValue_t autobalance_cons_t[] = {{0, "MIN"}, {4, "MAX"}, {0, NULL}};
|
static CV_PossibleValue_t autobalance_cons_t[] = {{0, "MIN"}, {4, "MAX"}, {0, NULL}};
|
||||||
@@ -302,14 +298,12 @@ consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS] = {
|
|||||||
{"verticallook4", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
|
{"verticallook4", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(HAVE_SDL) || defined(_WINDOWS) //joystick 1 and 2
|
|
||||||
consvar_t cv_usejoystick[MAXSPLITSCREENPLAYERS] = {
|
consvar_t cv_usejoystick[MAXSPLITSCREENPLAYERS] = {
|
||||||
{"use_joystick", "1", CV_SAVE|CV_CALL, NULL, I_InitJoystick1, 0, NULL, NULL, 0, 0, NULL},
|
{"use_joystick", "1", CV_SAVE|CV_CALL, NULL, I_InitJoystick1, 0, NULL, NULL, 0, 0, NULL},
|
||||||
{"use_joystick2", "2", CV_SAVE|CV_CALL, NULL, I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL},
|
{"use_joystick2", "2", CV_SAVE|CV_CALL, NULL, I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL},
|
||||||
{"use_joystick3", "3", CV_SAVE|CV_CALL, NULL, I_InitJoystick3, 0, NULL, NULL, 0, 0, NULL},
|
{"use_joystick3", "3", CV_SAVE|CV_CALL, NULL, I_InitJoystick3, 0, NULL, NULL, 0, 0, NULL},
|
||||||
{"use_joystick4", "4", CV_SAVE|CV_CALL, NULL, I_InitJoystick4, 0, NULL, NULL, 0, 0, NULL}
|
{"use_joystick4", "4", CV_SAVE|CV_CALL, NULL, I_InitJoystick4, 0, NULL, NULL, 0, 0, NULL}
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (HAVE_SDL)
|
#if defined (HAVE_SDL)
|
||||||
consvar_t cv_joyscale[MAXSPLITSCREENPLAYERS] = {
|
consvar_t cv_joyscale[MAXSPLITSCREENPLAYERS] = {
|
||||||
@@ -902,6 +896,7 @@ void D_RegisterClientCommands(void)
|
|||||||
CV_RegisterVar(&cv_netticbuffer);
|
CV_RegisterVar(&cv_netticbuffer);
|
||||||
CV_RegisterVar(&cv_mindelay);
|
CV_RegisterVar(&cv_mindelay);
|
||||||
CV_RegisterVar(&cv_gentlemens);
|
CV_RegisterVar(&cv_gentlemens);
|
||||||
|
CV_RegisterVar(&cv_serverinfoscreen);
|
||||||
|
|
||||||
#ifdef NETGAME_DEVMODE
|
#ifdef NETGAME_DEVMODE
|
||||||
CV_RegisterVar(&cv_fishcake);
|
CV_RegisterVar(&cv_fishcake);
|
||||||
@@ -918,6 +913,8 @@ void D_RegisterClientCommands(void)
|
|||||||
|
|
||||||
CV_RegisterVar(&cv_keyboardlayout);
|
CV_RegisterVar(&cv_keyboardlayout);
|
||||||
|
|
||||||
|
CV_RegisterVar(&cv_emotes);
|
||||||
|
|
||||||
// time attack ghost options are also saved to config
|
// time attack ghost options are also saved to config
|
||||||
CV_RegisterVar(&cv_ghost_besttime);
|
CV_RegisterVar(&cv_ghost_besttime);
|
||||||
CV_RegisterVar(&cv_ghost_bestlap);
|
CV_RegisterVar(&cv_ghost_bestlap);
|
||||||
@@ -1031,6 +1028,8 @@ void D_RegisterClientCommands(void)
|
|||||||
CV_RegisterVar(&cv_scr_width);
|
CV_RegisterVar(&cv_scr_width);
|
||||||
CV_RegisterVar(&cv_scr_height);
|
CV_RegisterVar(&cv_scr_height);
|
||||||
|
|
||||||
|
CV_RegisterVar(&cv_parallelsoftware);
|
||||||
|
|
||||||
CV_RegisterVar(&cv_soundtest);
|
CV_RegisterVar(&cv_soundtest);
|
||||||
|
|
||||||
CV_RegisterVar(&cv_perfstats);
|
CV_RegisterVar(&cv_perfstats);
|
||||||
@@ -1052,7 +1051,9 @@ void D_RegisterClientCommands(void)
|
|||||||
CV_RegisterVar(&cv_verticallook[i]);
|
CV_RegisterVar(&cv_verticallook[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CV_RegisterVar(&cv_resyncdemo);
|
||||||
CV_RegisterVar(&cv_demodateformat);
|
CV_RegisterVar(&cv_demodateformat);
|
||||||
|
|
||||||
CV_RegisterVar(&cv_showspecstuff);
|
CV_RegisterVar(&cv_showspecstuff);
|
||||||
|
|
||||||
// ingame object placing
|
// ingame object placing
|
||||||
|
|||||||
@@ -15,8 +15,17 @@
|
|||||||
#ifndef __D_NETCMD__
|
#ifndef __D_NETCMD__
|
||||||
#define __D_NETCMD__
|
#define __D_NETCMD__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
|
void SendWeaponPref(void);
|
||||||
|
void SendWeaponPref2(void);
|
||||||
|
void SendWeaponPref3(void);
|
||||||
|
void SendWeaponPref4(void);
|
||||||
|
|
||||||
// console vars
|
// console vars
|
||||||
extern consvar_t cv_playername;
|
extern consvar_t cv_playername;
|
||||||
extern consvar_t cv_playercolor;
|
extern consvar_t cv_playercolor;
|
||||||
@@ -318,4 +327,8 @@ void D_SetPassword(const char *pw);
|
|||||||
// used for the player setup menu
|
// used for the player setup menu
|
||||||
UINT8 CanChangeSkin(INT32 playernum);
|
UINT8 CanChangeSkin(INT32 playernum);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -111,7 +111,9 @@ static fileused_t transferFiles[UINT8_MAX + 1];
|
|||||||
// Receiver structure
|
// Receiver structure
|
||||||
INT32 fileneedednum; // Number of files needed to join the server
|
INT32 fileneedednum; // Number of files needed to join the server
|
||||||
fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files
|
fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
static I_mutex downloadmutex;
|
static I_mutex downloadmutex;
|
||||||
|
#endif
|
||||||
char downloaddir[512] = "DOWNLOAD";
|
char downloaddir[512] = "DOWNLOAD";
|
||||||
|
|
||||||
file_download_t filedownload;
|
file_download_t filedownload;
|
||||||
@@ -1351,14 +1353,18 @@ void CURLAbortFile(void)
|
|||||||
{
|
{
|
||||||
filedownload.http_running = false;
|
filedownload.http_running = false;
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
// lock and unlock to wait for the download thread to exit
|
// lock and unlock to wait for the download thread to exit
|
||||||
I_lock_mutex(&downloadmutex);
|
I_lock_mutex(&downloadmutex);
|
||||||
I_unlock_mutex(downloadmutex);
|
I_unlock_mutex(downloadmutex);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CURLGetFile(void)
|
void CURLGetFile(void)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
I_lock_mutex(&downloadmutex);
|
I_lock_mutex(&downloadmutex);
|
||||||
|
#endif
|
||||||
CURLMcode mc; /* return code used by curl_multi_wait() */
|
CURLMcode mc; /* return code used by curl_multi_wait() */
|
||||||
CURLcode easyres; /* Return from easy interface */
|
CURLcode easyres; /* Return from easy interface */
|
||||||
CURLMsg *m; /* for picking up messages with the transfer status */
|
CURLMsg *m; /* for picking up messages with the transfer status */
|
||||||
@@ -1453,7 +1459,9 @@ void CURLGetFile(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
filedownload.http_running = false;
|
filedownload.http_running = false;
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
I_unlock_mutex(downloadmutex);
|
I_unlock_mutex(downloadmutex);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTP_login *
|
HTTP_login *
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
#ifndef __D_NETFIL__
|
#ifndef __D_NETFIL__
|
||||||
#define __D_NETFIL__
|
#define __D_NETFIL__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "d_clisrv.h"
|
#include "d_clisrv.h"
|
||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
|
|
||||||
@@ -125,4 +129,8 @@ HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next);
|
|||||||
size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __D_NETFIL__
|
#endif // __D_NETFIL__
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
# Declare dedicated interface sources
|
||||||
|
|
||||||
|
target_sourcefile(c)
|
||||||
|
|
||||||
|
target_sources(SRB2SDL2 PRIVATE)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||||
|
target_sources(SRB2SDL2 PRIVATE
|
||||||
|
../win32/win_dbg.c
|
||||||
|
../win32/Srb2win.rc)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||||
|
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
|
||||||
|
elseif(${CMAKE_SYSTEM} MATCHES Linux)
|
||||||
|
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy)
|
||||||
|
else()
|
||||||
|
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||||
|
find_library(CORE_LIB CoreFoundation)
|
||||||
|
target_link_libraries(SRB2SDL2 PRIVATE
|
||||||
|
${CORE_LIB}
|
||||||
|
${PNG_LIBRARIES}
|
||||||
|
${ZLIB_LIBRARIES}
|
||||||
|
)
|
||||||
|
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
|
||||||
|
else()
|
||||||
|
target_link_libraries(SRB2SDL2 PRIVATE
|
||||||
|
${PNG_LIBRARIES}
|
||||||
|
${ZLIB_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||||
|
target_link_libraries(SRB2SDL2 PRIVATE
|
||||||
|
m
|
||||||
|
rt
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
|
||||||
|
|
||||||
|
set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION})
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||||
|
target_link_libraries(SRB2SDL2 PRIVATE
|
||||||
|
ws2_32
|
||||||
|
)
|
||||||
|
target_compile_options(SRB2SDL2 PRIVATE
|
||||||
|
-U_WINDOWS
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(SRB2SDL2 PRIVATE
|
||||||
|
${PNG_INCLUDE_DIRS}
|
||||||
|
${ZLIB_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(SRB2SDL2 PRIVATE
|
||||||
|
-DDEDICATED
|
||||||
|
)
|
||||||
|
|
||||||
|
## strip debug symbols into separate file when using gcc
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||||
|
message(STATUS "Will make separate debug symbols in *.debug")
|
||||||
|
add_custom_command(TARGET SRB2SDL2 POST_BUILD
|
||||||
|
COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
|
||||||
|
COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
|
||||||
|
COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#### Installation ####
|
||||||
|
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||||
|
install(TARGETS SRB2SDL2
|
||||||
|
BUNDLE DESTINATION .
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
install(TARGETS SRB2SDL2 SRB2SDL2
|
||||||
|
RUNTIME DESTINATION .
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Mac bundle fixup
|
||||||
|
# HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This
|
||||||
|
# makes it so that var is evaluated LATER during cpack, not right now!
|
||||||
|
# This fixes the quirk where the bundled libraries don't land in the final package
|
||||||
|
# https://cmake.org/pipermail/cmake/2011-March/043532.html
|
||||||
|
#
|
||||||
|
# HOWEVER: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} is NOT escaped, because that var
|
||||||
|
# is only available to us at this step. Read the link: ${CMAKE_INSTALL_PREFIX} at
|
||||||
|
# this current step points to the CMAKE build folder, NOT the folder that CPACK uses.
|
||||||
|
# Therefore, it makes sense to escape that var, but not the other.
|
||||||
|
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||||
|
install(CODE "
|
||||||
|
include(BundleUtilities)
|
||||||
|
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\"
|
||||||
|
\"\"
|
||||||
|
/Library/Frameworks
|
||||||
|
)"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
i_system.c
|
||||||
|
i_main.c
|
||||||
|
i_video.c
|
||||||
|
i_sound.c
|
||||||
|
i_threads.c
|
||||||
|
dosstr.c
|
||||||
|
endtxt.c
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// Emacs style mode select -*- C++ -*-
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file is in the public domain.
|
||||||
|
// (Re)written by Graue in 2006.
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file
|
||||||
|
/// \brief String uppercasing/lowercasing functions for non-DOS non-Win32
|
||||||
|
/// systems
|
||||||
|
|
||||||
|
#include "../doomtype.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_DOSSTR_FUNCS
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
int strupr(char *n)
|
||||||
|
{
|
||||||
|
while (*n != '\0')
|
||||||
|
{
|
||||||
|
*n = toupper(*n);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int strlwr(char *n)
|
||||||
|
{
|
||||||
|
while (*n != '\0')
|
||||||
|
{
|
||||||
|
*n = tolower(*n);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,234 @@
|
|||||||
|
/*
|
||||||
|
* Function to write the SRB2 end message text
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 by Udo Munk <udo@umserver.umnet.de>
|
||||||
|
*
|
||||||
|
* This code is provided AS IS and there are no guarantees, none.
|
||||||
|
* Feel free to share and modify.
|
||||||
|
*/
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file
|
||||||
|
/// \brief Support to show ENDOOM text
|
||||||
|
///
|
||||||
|
/// Loads the lump ENDOOM, set up the console to print
|
||||||
|
/// out the colors and text
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// need this 19990118 by Kin
|
||||||
|
#include "../doomdef.h"
|
||||||
|
#include "../w_wad.h"
|
||||||
|
#include "../z_zone.h"
|
||||||
|
#include "endtxt.h"
|
||||||
|
/** \brief The ShowEndTxt function
|
||||||
|
|
||||||
|
|
||||||
|
Prints out the ENDOOM the way DOOM.EXE/DOOM2.EXE did for Win32 or Linux/GNU
|
||||||
|
|
||||||
|
\return void
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ShowEndTxt(void)
|
||||||
|
{
|
||||||
|
INT32 i;
|
||||||
|
UINT16 j, att = 0;
|
||||||
|
INT32 nlflag = 1;
|
||||||
|
#ifdef _WIN32
|
||||||
|
HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
DWORD mode, bytesWritten;
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO backupcon;
|
||||||
|
COORD resizewin = {80,-1};
|
||||||
|
CHAR let = 0;
|
||||||
|
#endif
|
||||||
|
UINT16 *ptext;
|
||||||
|
void *data;
|
||||||
|
lumpnum_t endoomnum = W_GetNumForName("ENDOOM");
|
||||||
|
//char *col;
|
||||||
|
|
||||||
|
/* if the xterm has more then 80 columns we need to add nl's */
|
||||||
|
/* doesn't work, COLUMNS is not in the environment at this time ???
|
||||||
|
col = I_getenv("COLUMNS");
|
||||||
|
if (col) {
|
||||||
|
if (atoi(col) > 80)
|
||||||
|
nlflag++;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* get the lump with the text */
|
||||||
|
data = ptext = W_CacheLumpNum(endoomnum, PU_CACHE);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (co == INVALID_HANDLE_VALUE || GetFileType(co) != FILE_TYPE_CHAR || !GetConsoleMode(co, &mode)) // test if it a good handle
|
||||||
|
{
|
||||||
|
Z_Free(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
backupcon.wAttributes = FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE; // Just in case
|
||||||
|
GetConsoleScreenBufferInfo(co, &backupcon); //Store old state
|
||||||
|
resizewin.Y = backupcon.dwSize.Y;
|
||||||
|
if (backupcon.dwSize.X < resizewin.X)
|
||||||
|
SetConsoleScreenBufferSize(co, resizewin);
|
||||||
|
|
||||||
|
for (i=1; i<=80*25; i++) // print 80x25 text and deal with the attributes too
|
||||||
|
{
|
||||||
|
j = (UINT16)(*ptext >> 8); // attribute first
|
||||||
|
let = (char)(*ptext & 0xff); // text second
|
||||||
|
if (j != att) // attribute changed?
|
||||||
|
{
|
||||||
|
att = j; // save current attribute
|
||||||
|
SetConsoleTextAttribute(co, j); //set fg and bg color for buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteConsoleA(co, &let, 1, &bytesWritten, NULL); // now the text
|
||||||
|
|
||||||
|
if (nlflag && !(i % 80) && backupcon.dwSize.X > resizewin.X) // do we need a nl?
|
||||||
|
{
|
||||||
|
att = backupcon.wAttributes;
|
||||||
|
SetConsoleTextAttribute(co, att); // all attributes off
|
||||||
|
WriteConsoleA(co, "\n", 1, &bytesWritten, NULL); // newline to console
|
||||||
|
}
|
||||||
|
ptext++;
|
||||||
|
}
|
||||||
|
SetConsoleTextAttribute(co, backupcon.wAttributes); // all attributes off
|
||||||
|
#else
|
||||||
|
/* print 80x25 text and deal with the attributes too */
|
||||||
|
for (i=1; i<=80*25; i++) {
|
||||||
|
/* attribute first */
|
||||||
|
/* attribute changed? */
|
||||||
|
if ((j = *ptext >> 8) != att) {
|
||||||
|
/* save current attribute */
|
||||||
|
att = j;
|
||||||
|
/* set new attribute, forground color first */
|
||||||
|
printf("\033[");
|
||||||
|
switch (j & 0x0f) {
|
||||||
|
case 0: /* black */
|
||||||
|
printf("30");
|
||||||
|
break;
|
||||||
|
case 1: /* blue */
|
||||||
|
printf("34");
|
||||||
|
break;
|
||||||
|
case 2: /* green */
|
||||||
|
printf("32");
|
||||||
|
break;
|
||||||
|
case 3: /* cyan */
|
||||||
|
printf("36");
|
||||||
|
break;
|
||||||
|
case 4: /* red */
|
||||||
|
printf("31");
|
||||||
|
break;
|
||||||
|
case 5: /* magenta */
|
||||||
|
printf("35");
|
||||||
|
break;
|
||||||
|
case 6: /* brown */
|
||||||
|
printf("33");
|
||||||
|
break;
|
||||||
|
case 7: /* bright grey */
|
||||||
|
printf("37");
|
||||||
|
break;
|
||||||
|
case 8: /* dark grey */
|
||||||
|
printf("1;30");
|
||||||
|
break;
|
||||||
|
case 9: /* bright blue */
|
||||||
|
printf("1;34");
|
||||||
|
break;
|
||||||
|
case 10: /* bright green */
|
||||||
|
printf("1;32");
|
||||||
|
break;
|
||||||
|
case 11: /* bright cyan */
|
||||||
|
printf("1;36");
|
||||||
|
break;
|
||||||
|
case 12: /* bright red */
|
||||||
|
printf("1;31");
|
||||||
|
break;
|
||||||
|
case 13: /* bright magenta */
|
||||||
|
printf("1;35");
|
||||||
|
break;
|
||||||
|
case 14: /* yellow */
|
||||||
|
printf("1;33");
|
||||||
|
break;
|
||||||
|
case 15: /* white */
|
||||||
|
printf("1;37");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("m");
|
||||||
|
/* now background color */
|
||||||
|
printf("\033[");
|
||||||
|
switch ((j >> 4) & 0x0f) {
|
||||||
|
case 0: /* black */
|
||||||
|
printf("40");
|
||||||
|
break;
|
||||||
|
case 1: /* blue */
|
||||||
|
printf("44");
|
||||||
|
break;
|
||||||
|
case 2: /* green */
|
||||||
|
printf("42");
|
||||||
|
break;
|
||||||
|
case 3: /* cyan */
|
||||||
|
printf("46");
|
||||||
|
break;
|
||||||
|
case 4: /* red */
|
||||||
|
printf("41");
|
||||||
|
break;
|
||||||
|
case 5: /* magenta */
|
||||||
|
printf("45");
|
||||||
|
break;
|
||||||
|
case 6: /* brown */
|
||||||
|
printf("43");
|
||||||
|
break;
|
||||||
|
case 7: /* bright grey */
|
||||||
|
printf("47");
|
||||||
|
break;
|
||||||
|
case 8: /* dark grey */
|
||||||
|
printf("1;40");
|
||||||
|
break;
|
||||||
|
case 9: /* bright blue */
|
||||||
|
printf("1;44");
|
||||||
|
break;
|
||||||
|
case 10: /* bright green */
|
||||||
|
printf("1;42");
|
||||||
|
break;
|
||||||
|
case 11: /* bright cyan */
|
||||||
|
printf("1;46");
|
||||||
|
break;
|
||||||
|
case 12: /* bright red */
|
||||||
|
printf("1;41");
|
||||||
|
break;
|
||||||
|
case 13: /* bright magenta */
|
||||||
|
printf("1;45");
|
||||||
|
break;
|
||||||
|
case 14: /* yellow */
|
||||||
|
printf("1;43");
|
||||||
|
break;
|
||||||
|
case 15: /* white */
|
||||||
|
printf("1;47");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("m");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now the text */
|
||||||
|
printf("%c",*ptext++ & 0xff);
|
||||||
|
|
||||||
|
/* do we need a nl? */
|
||||||
|
if (nlflag)
|
||||||
|
{
|
||||||
|
if (!(i % 80))
|
||||||
|
{
|
||||||
|
printf("\033[0m");
|
||||||
|
att = 0;
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* all attributes off */
|
||||||
|
printf("\033[0m");
|
||||||
|
#endif
|
||||||
|
if (nlflag)
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
Z_Free(data);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Emacs style mode select -*- C++ -*-
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 2
|
||||||
|
// 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.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file
|
||||||
|
/// \brief Support to show ENDOOM text
|
||||||
|
|
||||||
|
#ifndef __ENDTXT__
|
||||||
|
#define __ENDTXT__
|
||||||
|
|
||||||
|
void ShowEndTxt (void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
// Emacs style mode select -*- C++ -*-
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||||
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 2
|
||||||
|
// 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.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file
|
||||||
|
/// \brief Main program, simply calls D_SRB2Main and D_SRB2Loop, the high level loop.
|
||||||
|
|
||||||
|
#include "../doomdef.h"
|
||||||
|
#include "../m_argv.h"
|
||||||
|
#include "../d_main.h"
|
||||||
|
#include "../m_misc.h" /* path shit */
|
||||||
|
#include "../i_system.h"
|
||||||
|
#include "../d_clisrv.h"
|
||||||
|
|
||||||
|
#if defined (__GNUC__) || defined (__unix__)
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __unix__
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "time.h" // For log timestamps
|
||||||
|
|
||||||
|
#ifdef HAVE_TTF
|
||||||
|
#include "i_ttf.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBBACKTRACE
|
||||||
|
#include <backtrace.h>
|
||||||
|
|
||||||
|
struct backtrace_state *bt_state = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOGMESSAGES
|
||||||
|
FILE *logstream = NULL;
|
||||||
|
char logfilename[1024];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DOXYGEN
|
||||||
|
#ifndef O_TEXT
|
||||||
|
#define O_TEXT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_SEQUENTIAL
|
||||||
|
#define O_SEQUENTIAL 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifndef _AMD64_
|
||||||
|
#include "exchndl.h"
|
||||||
|
#define DRMINGW
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (_WIN32)
|
||||||
|
#include "../win32/win_dbg.h"
|
||||||
|
typedef BOOL (WINAPI *p_IsDebuggerPresent)(VOID);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static void
|
||||||
|
ChDirToExe (void)
|
||||||
|
{
|
||||||
|
CHAR path[MAX_PATH];
|
||||||
|
if (GetModuleFileNameA(NULL, path, MAX_PATH) > 0)
|
||||||
|
{
|
||||||
|
strrchr(path, '\\')[0] = '\0';
|
||||||
|
SetCurrentDirectoryA(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** \brief The main function
|
||||||
|
|
||||||
|
\param argc number of arg
|
||||||
|
\param *argv string table
|
||||||
|
|
||||||
|
\return int
|
||||||
|
*/
|
||||||
|
#if defined (__GNUC__) && (__GNUC__ >= 4)
|
||||||
|
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOGMESSAGES
|
||||||
|
static void InitLogging(void)
|
||||||
|
{
|
||||||
|
const char *logdir = NULL;
|
||||||
|
time_t my_time;
|
||||||
|
struct tm * timeinfo;
|
||||||
|
const char *format;
|
||||||
|
const char *reldir;
|
||||||
|
int left;
|
||||||
|
boolean fileabs;
|
||||||
|
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
|
||||||
|
const char *link;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
logdir = D_Home();
|
||||||
|
|
||||||
|
my_time = time(NULL);
|
||||||
|
timeinfo = localtime(&my_time);
|
||||||
|
|
||||||
|
if (M_CheckParm("-logfile") && M_IsNextParm())
|
||||||
|
{
|
||||||
|
format = M_GetNextParm();
|
||||||
|
fileabs = M_IsPathAbsolute(format);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
format = "log-%Y-%m-%d_%H-%M-%S.txt";
|
||||||
|
fileabs = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileabs)
|
||||||
|
{
|
||||||
|
strftime(logfilename, sizeof logfilename, format, timeinfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (M_CheckParm("-logdir") && M_IsNextParm())
|
||||||
|
reldir = M_GetNextParm();
|
||||||
|
else
|
||||||
|
reldir = "logs";
|
||||||
|
|
||||||
|
if (M_IsPathAbsolute(reldir))
|
||||||
|
{
|
||||||
|
left = snprintf(logfilename, sizeof logfilename,
|
||||||
|
"%s"PATHSEP, reldir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#ifdef DEFAULTDIR
|
||||||
|
if (logdir)
|
||||||
|
{
|
||||||
|
left = snprintf(logfilename, sizeof logfilename,
|
||||||
|
"%s"PATHSEP DEFAULTDIR PATHSEP"%s"PATHSEP, logdir, reldir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif/*DEFAULTDIR*/
|
||||||
|
{
|
||||||
|
left = snprintf(logfilename, sizeof logfilename,
|
||||||
|
"."PATHSEP"%s"PATHSEP, reldir);
|
||||||
|
}
|
||||||
|
|
||||||
|
strftime(&logfilename[left], sizeof logfilename - left,
|
||||||
|
format, timeinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
M_MkdirEachUntil(logfilename,
|
||||||
|
M_PathParts(logdir) - 1,
|
||||||
|
M_PathParts(logfilename) - 1, 0755);
|
||||||
|
|
||||||
|
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
|
||||||
|
logstream = fopen(logfilename, "w");
|
||||||
|
#ifdef DEFAULTDIR
|
||||||
|
if (logdir)
|
||||||
|
link = va("%s/"DEFAULTDIR"/latest-log.txt", logdir);
|
||||||
|
else
|
||||||
|
#endif/*DEFAULTDIR*/
|
||||||
|
link = "latest-log.txt";
|
||||||
|
unlink(link);
|
||||||
|
if (symlink(logfilename, link) == -1)
|
||||||
|
{
|
||||||
|
I_OutputMsg("Error symlinking latest-log.txt: %s\n", strerror(errno));
|
||||||
|
}
|
||||||
|
#else/*defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)*/
|
||||||
|
logstream = fopen("latest-log.txt", "wt+");
|
||||||
|
#endif/*defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)*/
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
myargc = argc;
|
||||||
|
myargv = argv; /// \todo pull out path to exe from this string
|
||||||
|
|
||||||
|
dedicated = true;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBBACKTRACE
|
||||||
|
bt_state = backtrace_create_state(
|
||||||
|
argv[0],
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
1,
|
||||||
|
#else
|
||||||
|
0,
|
||||||
|
#endif
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
ChDirToExe();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOGMESSAGES
|
||||||
|
if (!M_CheckParm("-nolog"))
|
||||||
|
InitLogging();
|
||||||
|
#endif/*LOGMESSAGES*/
|
||||||
|
|
||||||
|
//I_OutputMsg("I_StartupSystem() ...\n");
|
||||||
|
I_StartupSystem();
|
||||||
|
#if defined (_WIN32)
|
||||||
|
{
|
||||||
|
#ifdef DRMINGW
|
||||||
|
ExcHndlInit();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// startup SRB2
|
||||||
|
CONS_Printf("Setting up SRB2Kart...\n");
|
||||||
|
D_SRB2Main();
|
||||||
|
CONS_Printf("Entering main game loop...\n");
|
||||||
|
// never return
|
||||||
|
D_SRB2Loop();
|
||||||
|
|
||||||
|
#ifdef BUGTRAP
|
||||||
|
// This is safe even if BT didn't start.
|
||||||
|
ShutdownBugTrap();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// return to OS
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,339 @@
|
|||||||
|
// Emacs style mode select -*- C++ -*-
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
// The source 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.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file
|
||||||
|
/// \brief SDL interface for sound
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include "../doomdef.h"
|
||||||
|
#include "../i_sound.h"
|
||||||
|
#include "../s_sound.h"
|
||||||
|
|
||||||
|
/** \brief Sound subsystem runing and waiting
|
||||||
|
*/
|
||||||
|
UINT8 sound_started = false;
|
||||||
|
|
||||||
|
/** \brief The I_GetSfx function
|
||||||
|
|
||||||
|
\param sfx sfx to setup
|
||||||
|
|
||||||
|
\return data for sfx
|
||||||
|
*/
|
||||||
|
void *I_GetSfx(sfxinfo_t *sfx)
|
||||||
|
{
|
||||||
|
(void)sfx;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief The I_FreeSfx function
|
||||||
|
|
||||||
|
\param sfx sfx to be freed up
|
||||||
|
|
||||||
|
\return void
|
||||||
|
*/
|
||||||
|
void I_FreeSfx(sfxinfo_t *sfx)
|
||||||
|
{
|
||||||
|
(void)sfx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Init at program start...
|
||||||
|
*/
|
||||||
|
void I_StartupSound(void){}
|
||||||
|
|
||||||
|
/** \brief ... shut down and relase at program termination.
|
||||||
|
*/
|
||||||
|
void I_ShutdownSound(void){}
|
||||||
|
|
||||||
|
/// ------------------------
|
||||||
|
/// SFX I/O
|
||||||
|
/// ------------------------
|
||||||
|
|
||||||
|
/** \brief Starts a sound in a particular sound channel.
|
||||||
|
\param id sfxid
|
||||||
|
\param vol volume for sound
|
||||||
|
\param sep left-right balancle
|
||||||
|
\param pitch not used
|
||||||
|
\param priority not used
|
||||||
|
|
||||||
|
\return sfx handle
|
||||||
|
*/
|
||||||
|
INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel)
|
||||||
|
{
|
||||||
|
(void)id;
|
||||||
|
(void)vol;
|
||||||
|
(void)sep;
|
||||||
|
(void)pitch;
|
||||||
|
(void)priority;
|
||||||
|
(void)channel;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Stops a sound channel.
|
||||||
|
|
||||||
|
\param handle stop sfx handle
|
||||||
|
|
||||||
|
\return void
|
||||||
|
*/
|
||||||
|
void I_StopSound(INT32 handle)
|
||||||
|
{
|
||||||
|
(void)handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Some digital sound drivers need this.
|
||||||
|
*/
|
||||||
|
void I_UpdateSound(void){}
|
||||||
|
|
||||||
|
/** \brief Called by S_*() functions to see if a channel is still playing.
|
||||||
|
|
||||||
|
\param handle sfx handle
|
||||||
|
|
||||||
|
\return 0 if no longer playing, 1 if playing.
|
||||||
|
*/
|
||||||
|
boolean I_SoundIsPlaying(INT32 handle)
|
||||||
|
{
|
||||||
|
(void)handle;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Updates the sfx handle
|
||||||
|
|
||||||
|
\param handle sfx handle
|
||||||
|
\param vol volume
|
||||||
|
\param sep separation
|
||||||
|
\param pitch ptich
|
||||||
|
|
||||||
|
\return void
|
||||||
|
*/
|
||||||
|
void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch)
|
||||||
|
{
|
||||||
|
(void)handle;
|
||||||
|
(void)vol;
|
||||||
|
(void)sep;
|
||||||
|
(void)pitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief The I_SetSfxVolume function
|
||||||
|
|
||||||
|
\param volume volume to set at
|
||||||
|
|
||||||
|
\return void
|
||||||
|
*/
|
||||||
|
void I_SetSfxVolume(UINT8 volume)
|
||||||
|
{
|
||||||
|
(void)volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ------------------------
|
||||||
|
// MUSIC SYSTEM
|
||||||
|
/// ------------------------
|
||||||
|
|
||||||
|
/** \brief Init the music systems
|
||||||
|
*/
|
||||||
|
void I_InitMusic(void){}
|
||||||
|
|
||||||
|
/** \brief Shutdown the music systems
|
||||||
|
*/
|
||||||
|
void I_ShutdownMusic(void){}
|
||||||
|
|
||||||
|
/// ------------------------
|
||||||
|
// MUSIC PROPERTIES
|
||||||
|
/// ------------------------
|
||||||
|
|
||||||
|
musictype_t I_SongType(void)
|
||||||
|
{
|
||||||
|
return MU_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean I_SongPlaying(void)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean I_SongPaused(void)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ------------------------
|
||||||
|
// MUSIC EFFECTS
|
||||||
|
/// ------------------------
|
||||||
|
|
||||||
|
boolean I_SetSongSpeed(float speed)
|
||||||
|
{
|
||||||
|
(void)speed;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ------------------------
|
||||||
|
// MUSIC SEEKING
|
||||||
|
/// ------------------------
|
||||||
|
|
||||||
|
UINT32 I_GetSongLength(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean I_SetSongLoopPoint(UINT32 looppoint)
|
||||||
|
{
|
||||||
|
(void)looppoint;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 I_GetSongLoopPoint(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean I_SetSongPosition(UINT32 position)
|
||||||
|
{
|
||||||
|
(void)position;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 I_GetSongPosition(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ------------------------
|
||||||
|
// MUSIC PLAYBACK
|
||||||
|
/// ------------------------
|
||||||
|
|
||||||
|
/** \brief Registers a song handle to song data.
|
||||||
|
|
||||||
|
\param data pointer to song data
|
||||||
|
\param len len of data
|
||||||
|
|
||||||
|
\return song handle
|
||||||
|
|
||||||
|
\todo Remove this
|
||||||
|
*/
|
||||||
|
boolean I_LoadSong(char *data, size_t len)
|
||||||
|
{
|
||||||
|
(void)data;
|
||||||
|
(void)len;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief See ::I_LoadSong, then think backwards
|
||||||
|
|
||||||
|
\param handle song handle
|
||||||
|
|
||||||
|
\sa I_LoadSong
|
||||||
|
\todo remove midi handle
|
||||||
|
*/
|
||||||
|
void I_UnloadSong(void){}
|
||||||
|
|
||||||
|
/** \brief Called by anything that wishes to start music
|
||||||
|
|
||||||
|
\param handle Song handle
|
||||||
|
\param looping looping it if true
|
||||||
|
|
||||||
|
\return if true, it's playing the song
|
||||||
|
|
||||||
|
\todo pass music name, not handle
|
||||||
|
*/
|
||||||
|
boolean I_PlaySong(boolean looping)
|
||||||
|
{
|
||||||
|
(void)looping;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Stops a song over 3 seconds
|
||||||
|
|
||||||
|
\param handle Song handle
|
||||||
|
\return void
|
||||||
|
|
||||||
|
/todo drop handle
|
||||||
|
*/
|
||||||
|
void I_StopSong(void){}
|
||||||
|
|
||||||
|
/** \brief PAUSE game handling.
|
||||||
|
|
||||||
|
\param handle song handle
|
||||||
|
|
||||||
|
\return void
|
||||||
|
*/
|
||||||
|
void I_PauseSong(void){}
|
||||||
|
|
||||||
|
/** \brief RESUME game handling
|
||||||
|
|
||||||
|
\param handle song handle
|
||||||
|
|
||||||
|
\return void
|
||||||
|
*/
|
||||||
|
void I_ResumeSong(void){}
|
||||||
|
|
||||||
|
/** \brief The I_SetMusicVolume function
|
||||||
|
|
||||||
|
\param volume volume to set at
|
||||||
|
|
||||||
|
\return void
|
||||||
|
*/
|
||||||
|
void I_SetMusicVolume(UINT8 volume)
|
||||||
|
{
|
||||||
|
(void)volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean I_SetSongTrack(INT32 track)
|
||||||
|
{
|
||||||
|
(void)track;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ------------------------
|
||||||
|
/// MUSIC FADING
|
||||||
|
/// ------------------------
|
||||||
|
|
||||||
|
void I_SetInternalMusicVolume(UINT8 volume)
|
||||||
|
{
|
||||||
|
(void)volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_StopFadingSong(void){}
|
||||||
|
|
||||||
|
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void))
|
||||||
|
{
|
||||||
|
(void)target_volume;
|
||||||
|
(void)source_volume;
|
||||||
|
(void)ms;
|
||||||
|
(void)callback;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void))
|
||||||
|
{
|
||||||
|
(void)target_volume;
|
||||||
|
(void)ms;
|
||||||
|
(void)callback;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean I_FadeOutStopSong(UINT32 ms)
|
||||||
|
{
|
||||||
|
(void)ms;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean I_FadeInPlaySong(UINT32 ms, boolean looping)
|
||||||
|
{
|
||||||
|
(void)ms;
|
||||||
|
(void)looping;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_UpdateSongLagThreshold(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,364 @@
|
|||||||
|
// SONIC ROBO BLAST 2
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2020-2023 by James R.
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file i_threads.c
|
||||||
|
/// \brief Multithreading abstraction
|
||||||
|
|
||||||
|
#if defined (__unix__) || (!defined(__APPLE__) && defined (UNIXCOMMON))
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "../i_threads.h"
|
||||||
|
#include "../doomdef.h"
|
||||||
|
|
||||||
|
typedef struct thread_s thread_t;
|
||||||
|
|
||||||
|
struct thread_s
|
||||||
|
{
|
||||||
|
thread_t *next;
|
||||||
|
void *userdata;
|
||||||
|
I_thread_fn func;
|
||||||
|
pthread_t thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
// we use a linked list to avoid moving memory blocks when allocating new threads.
|
||||||
|
static thread_t *thread_list;
|
||||||
|
static pthread_mutex_t thread_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
static void *HandleThread(void *data)
|
||||||
|
{
|
||||||
|
thread_t *thread = data;
|
||||||
|
thread->func(thread->userdata);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&thread_lock);
|
||||||
|
thread->func = NULL;
|
||||||
|
pthread_mutex_unlock(&thread_lock);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
I_spawn_thread (
|
||||||
|
const char * name,
|
||||||
|
I_thread_fn entry,
|
||||||
|
void * userdata
|
||||||
|
)
|
||||||
|
{
|
||||||
|
thread_t *thread;
|
||||||
|
(void)name;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&thread_lock);
|
||||||
|
thread = thread_list;
|
||||||
|
while (thread != NULL)
|
||||||
|
{
|
||||||
|
if (thread->func == NULL)
|
||||||
|
{
|
||||||
|
// join with the exited thread to release it's resources.
|
||||||
|
pthread_join(thread->thread, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
thread = thread->next;
|
||||||
|
}
|
||||||
|
if (thread == NULL)
|
||||||
|
{
|
||||||
|
thread = malloc(sizeof(thread_t));
|
||||||
|
thread->next = thread_list;
|
||||||
|
thread_list = thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
thread->func = entry;
|
||||||
|
thread->userdata = userdata;
|
||||||
|
pthread_create(&thread->thread, NULL, HandleThread, thread);
|
||||||
|
pthread_mutex_unlock(&thread_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
int I_thread_is_stopped(void)
|
||||||
|
{
|
||||||
|
thread_t *thread;
|
||||||
|
pthread_mutex_lock(&thread_lock);
|
||||||
|
thread = thread_list;
|
||||||
|
while (thread != NULL)
|
||||||
|
{
|
||||||
|
if (thread->func != NULL)
|
||||||
|
{
|
||||||
|
pthread_mutex_unlock(&thread_lock);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
thread = thread->next;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&thread_lock);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_start_threads(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_stop_threads(void)
|
||||||
|
{
|
||||||
|
thread_t *thread = thread_list;
|
||||||
|
while (thread != NULL)
|
||||||
|
{
|
||||||
|
// join with all threads here, since finished threads haven't been awaited yet.
|
||||||
|
pthread_join(thread->thread, NULL);
|
||||||
|
thread = thread->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_lock_mutex(I_mutex *anchor)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&thread_lock);
|
||||||
|
if (*anchor == NULL)
|
||||||
|
{
|
||||||
|
pthread_mutexattr_t attr;
|
||||||
|
pthread_mutexattr_init(&attr);
|
||||||
|
|
||||||
|
// SRB2 relies on lock recursion, so we need a mutex configured for that.
|
||||||
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
*anchor = malloc(sizeof(pthread_mutex_t));
|
||||||
|
pthread_mutex_init(*anchor, &attr);
|
||||||
|
pthread_mutexattr_destroy(&attr);
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&thread_lock);
|
||||||
|
pthread_mutex_lock(*anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_unlock_mutex(I_mutex id)
|
||||||
|
{
|
||||||
|
pthread_mutex_unlock(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_hold_cond(I_cond *cond_anchor, I_mutex mutex_id)
|
||||||
|
{
|
||||||
|
I_Assert(mutex_id != NULL);
|
||||||
|
pthread_mutex_lock(&thread_lock);
|
||||||
|
if (*cond_anchor == NULL)
|
||||||
|
{
|
||||||
|
*cond_anchor = malloc(sizeof(pthread_cond_t));
|
||||||
|
pthread_cond_init(*cond_anchor, NULL);
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&thread_lock);
|
||||||
|
pthread_cond_wait(*cond_anchor, mutex_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_wake_one_cond(I_cond *anchor)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&thread_lock);
|
||||||
|
if (*anchor == NULL)
|
||||||
|
{
|
||||||
|
*anchor = malloc(sizeof(pthread_cond_t));
|
||||||
|
pthread_cond_init(*anchor, NULL);
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&thread_lock);
|
||||||
|
pthread_cond_signal(*anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_wake_all_cond(I_cond *anchor)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&thread_lock);
|
||||||
|
if (*anchor == NULL)
|
||||||
|
{
|
||||||
|
*anchor = malloc(sizeof(pthread_cond_t));
|
||||||
|
pthread_cond_init(*anchor, NULL);
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&thread_lock);
|
||||||
|
pthread_cond_broadcast(*anchor);
|
||||||
|
}
|
||||||
|
#elif defined (_WIN32)
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "../i_threads.h"
|
||||||
|
#include "../doomdef.h"
|
||||||
|
#include "../doomtype.h"
|
||||||
|
|
||||||
|
typedef struct thread_s thread_t;
|
||||||
|
|
||||||
|
struct thread_s
|
||||||
|
{
|
||||||
|
thread_t *next;
|
||||||
|
void *userdata;
|
||||||
|
I_thread_fn func;
|
||||||
|
HANDLE thread;
|
||||||
|
DWORD thread_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
// we use a linked list to avoid moving memory blocks when allocating new threads.
|
||||||
|
static thread_t *thread_list;
|
||||||
|
static CRITICAL_SECTION thread_lock;
|
||||||
|
|
||||||
|
static DWORD __stdcall HandleThread(void *data)
|
||||||
|
{
|
||||||
|
thread_t *thread = data;
|
||||||
|
thread->func(thread->userdata);
|
||||||
|
|
||||||
|
EnterCriticalSection(&thread_lock);
|
||||||
|
thread->func = NULL;
|
||||||
|
LeaveCriticalSection(&thread_lock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_spawn_thread(const char *name, I_thread_fn entry, void *userdata)
|
||||||
|
{
|
||||||
|
thread_t *thread;
|
||||||
|
(void)name;
|
||||||
|
EnterCriticalSection(&thread_lock);
|
||||||
|
thread = thread_list;
|
||||||
|
while (thread != NULL)
|
||||||
|
{
|
||||||
|
if (thread->func == NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(thread->thread);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
thread = thread->next;
|
||||||
|
}
|
||||||
|
if (thread == NULL)
|
||||||
|
{
|
||||||
|
thread = malloc(sizeof(thread_t));
|
||||||
|
thread->next = thread_list;
|
||||||
|
thread_list = thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
thread->func = entry;
|
||||||
|
thread->userdata = userdata;
|
||||||
|
thread->thread = CreateThread(NULL, 0, HandleThread, thread, 0, &thread->thread_id);
|
||||||
|
LeaveCriticalSection(&thread_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
int I_thread_is_stopped(void)
|
||||||
|
{
|
||||||
|
thread_t *thread;
|
||||||
|
EnterCriticalSection(&thread_lock);
|
||||||
|
thread = thread_list;
|
||||||
|
while (thread != NULL)
|
||||||
|
{
|
||||||
|
if (thread->func != NULL)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&thread_lock);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
thread = thread->next;
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&thread_lock);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_start_threads(void)
|
||||||
|
{
|
||||||
|
InitializeCriticalSection(&thread_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_stop_threads(void)
|
||||||
|
{
|
||||||
|
thread_t *thread = thread_list;
|
||||||
|
while (thread != NULL)
|
||||||
|
{
|
||||||
|
WaitForSingleObject(thread->thread, INFINITE);
|
||||||
|
CloseHandle(thread->thread);
|
||||||
|
thread = thread->next;
|
||||||
|
}
|
||||||
|
DeleteCriticalSection(&thread_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_lock_mutex(I_mutex *anchor)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&thread_lock);
|
||||||
|
if (*anchor == NULL)
|
||||||
|
{
|
||||||
|
*anchor = malloc(sizeof(CRITICAL_SECTION));
|
||||||
|
InitializeCriticalSection(*anchor);
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&thread_lock);
|
||||||
|
EnterCriticalSection(*anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_unlock_mutex(I_mutex id)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_hold_cond(I_cond *cond_anchor, I_mutex mutex_id)
|
||||||
|
{
|
||||||
|
I_Assert(mutex_id != NULL);
|
||||||
|
EnterCriticalSection(&thread_lock);
|
||||||
|
if (*cond_anchor == NULL)
|
||||||
|
{
|
||||||
|
*cond_anchor = malloc(sizeof(CONDITION_VARIABLE));
|
||||||
|
InitializeConditionVariable(*cond_anchor);
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&thread_lock);
|
||||||
|
SleepConditionVariableCS(*cond_anchor, mutex_id, INFINITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_wake_one_cond(I_cond *anchor)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&thread_lock);
|
||||||
|
if (*anchor == NULL)
|
||||||
|
{
|
||||||
|
*anchor = malloc(sizeof(CONDITION_VARIABLE));
|
||||||
|
InitializeConditionVariable(*anchor);
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&thread_lock);
|
||||||
|
WakeConditionVariable(*anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_wake_all_cond(I_cond *anchor)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&thread_lock);
|
||||||
|
if (*anchor == NULL)
|
||||||
|
{
|
||||||
|
*anchor = malloc(sizeof(CONDITION_VARIABLE));
|
||||||
|
InitializeConditionVariable(*anchor);
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&thread_lock);
|
||||||
|
WakeAllConditionVariable(*anchor);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void I_spawn_thread(const char *name, I_thread_fn entry, void *userdata)
|
||||||
|
{
|
||||||
|
(void)name;
|
||||||
|
entry(userdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
int I_thread_is_stopped(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_start_threads(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_stop_threads(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_lock_mutex(I_mutex *anchor)
|
||||||
|
{
|
||||||
|
(void)anchor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_unlock_mutex(I_mutex id)
|
||||||
|
{
|
||||||
|
(void)id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_hold_cond(I_cond *cond_anchor, I_mutex mutex_id)
|
||||||
|
{
|
||||||
|
(void)cond_anchor;
|
||||||
|
(void)mutex_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_wake_one_cond(I_cond *anchor)
|
||||||
|
{
|
||||||
|
(void)anchor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_wake_all_cond(I_cond *anchor)
|
||||||
|
{
|
||||||
|
(void)anchor;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
// Emacs style mode select -*- C++ -*-
|
||||||
|
// SONIC ROBO BLAST 2
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||||
|
// Portions Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||||
|
// Copyright (C) 2014-2018 by Sonic Team Junior.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file
|
||||||
|
/// \brief SRB2 graphics stuff for dedicated
|
||||||
|
|
||||||
|
#include "../doomdef.h"
|
||||||
|
#include "../i_system.h"
|
||||||
|
#include "../i_video.h"
|
||||||
|
#include "../console.h"
|
||||||
|
#include "../command.h"
|
||||||
|
#include "../i_system.h"
|
||||||
|
#include "../screen.h"
|
||||||
|
|
||||||
|
rendermode_t rendermode = render_none;
|
||||||
|
|
||||||
|
boolean highcolor = false;
|
||||||
|
|
||||||
|
// synchronize page flipping with screen refresh
|
||||||
|
consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
static CV_PossibleValue_t keyboardlayout_cons_t[] = {{1,"Default US"}, {2, "Native"}, {3, "AZERTY"}, {0, NULL}};
|
||||||
|
consvar_t cv_keyboardlayout = {"keyboardlayout", "Default US", CV_SAVE, keyboardlayout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
INT32 numcontrollers = 0;
|
||||||
|
|
||||||
|
UINT8 graphics_started = 0; // Is used in console.c and screen.c
|
||||||
|
|
||||||
|
// To disable fullscreen at startup; is set in VID_PrepareModeList
|
||||||
|
boolean allow_fullscreen = false;
|
||||||
|
UINT16 realwidth = BASEVIDWIDTH;
|
||||||
|
UINT16 realheight = BASEVIDHEIGHT;
|
||||||
|
|
||||||
|
extern boolean consolevent;
|
||||||
|
|
||||||
|
void I_GetConsoleEvents(void);
|
||||||
|
|
||||||
|
void I_GetEvent(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_StartupMouse(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_OsPolling
|
||||||
|
//
|
||||||
|
void I_OsPolling(void)
|
||||||
|
{
|
||||||
|
if (consolevent)
|
||||||
|
I_GetConsoleEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_UpdateNoBlit
|
||||||
|
//
|
||||||
|
void I_UpdateNoBlit(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_FinishUpdate
|
||||||
|
//
|
||||||
|
void I_FinishUpdate(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_UpdateNoVsync
|
||||||
|
//
|
||||||
|
void I_UpdateNoVsync(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_ReadScreen
|
||||||
|
//
|
||||||
|
void I_ReadScreen(UINT8 *scr)
|
||||||
|
{
|
||||||
|
(void)scr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_SetPalette
|
||||||
|
//
|
||||||
|
void I_SetPalette(RGBA_t *palette)
|
||||||
|
{
|
||||||
|
(void)palette;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return number of fullscreen + X11 modes
|
||||||
|
INT32 VID_NumModes(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *VID_GetModeName(INT32 modenum)
|
||||||
|
{
|
||||||
|
(void)modenum;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 VID_GetModeForSize(INT32 w, INT32 h)
|
||||||
|
{
|
||||||
|
(void)w;
|
||||||
|
(void)h;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VID_PrepareModeList(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 VID_SetMode(INT32 modeNum)
|
||||||
|
{
|
||||||
|
(void)modeNum;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_StartupGraphics(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_ShutdownGraphics(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 I_GetRefreshRate(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean I_UseNativeKeyboard(void)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -58,6 +58,9 @@
|
|||||||
// warning C4152: nonstandard extension, function/data pointer conversion in expression
|
// warning C4152: nonstandard extension, function/data pointer conversion in expression
|
||||||
// warning C4213: nonstandard extension used : cast on l-value
|
// warning C4213: nonstandard extension used : cast on l-value
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
|
|
||||||
@@ -524,12 +527,15 @@ UINT32 quickncasehash (const char *p, size_t n)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
#ifndef min // Double-Check with WATTCP-32's cdefs.h
|
#ifndef min // Double-Check with WATTCP-32's cdefs.h
|
||||||
#define min(x, y) (((x) < (y)) ? (x) : (y))
|
#define min(x, y) (((x) < (y)) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
#ifndef max // Double-Check with WATTCP-32's cdefs.h
|
#ifndef max // Double-Check with WATTCP-32's cdefs.h
|
||||||
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CLAMP
|
#ifndef CLAMP
|
||||||
#define CLAMP(x, y, z) ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x)))
|
#define CLAMP(x, y, z) ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x)))
|
||||||
#endif
|
#endif
|
||||||
@@ -560,6 +566,14 @@ UINT32 quickncasehash (const char *p, size_t n)
|
|||||||
#define UNLIKELY(x) (x)
|
#define UNLIKELY(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
|
||||||
|
#define restrict __restrict
|
||||||
|
#else
|
||||||
|
#define restrict
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// An assert-type mechanism.
|
// An assert-type mechanism.
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
#define I_Assert(e) ((e) ? (void)0 : I_Error("assert failed: %s, file %s, line %d", #e, __FILE__, __LINE__))
|
#define I_Assert(e) ((e) ? (void)0 : I_Error("assert failed: %s, file %s, line %d", #e, __FILE__, __LINE__))
|
||||||
@@ -657,4 +671,8 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
|||||||
#undef UPDATE_ALERT
|
#undef UPDATE_ALERT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __DOOMDEF__
|
#endif // __DOOMDEF__
|
||||||
+1
-1
@@ -125,7 +125,7 @@ extern boolean lastdraw;
|
|||||||
extern INT32 postimgparam[MAXSPLITSCREENPLAYERS];
|
extern INT32 postimgparam[MAXSPLITSCREENPLAYERS];
|
||||||
|
|
||||||
extern INT32 viewwindowx, viewwindowy;
|
extern INT32 viewwindowx, viewwindowy;
|
||||||
extern INT32 viewwidth, scaledviewwidth;
|
extern INT32 viewwidth;
|
||||||
|
|
||||||
extern boolean gamedataloaded;
|
extern boolean gamedataloaded;
|
||||||
|
|
||||||
|
|||||||
+23
-16
@@ -17,6 +17,10 @@
|
|||||||
#ifndef __DOOMTYPE__
|
#ifndef __DOOMTYPE__
|
||||||
#define __DOOMTYPE__
|
#define __DOOMTYPE__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined (_WIN32)
|
#if defined (_WIN32)
|
||||||
//#define WIN32_LEAN_AND_MEAN
|
//#define WIN32_LEAN_AND_MEAN
|
||||||
#define RPC_NO_WINDOWS_H
|
#define RPC_NO_WINDOWS_H
|
||||||
@@ -100,8 +104,10 @@ typedef long ssize_t;
|
|||||||
#define strnicmp(x,y,n) strncasecmp(x,y,n)
|
#define strnicmp(x,y,n) strncasecmp(x,y,n)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
char *strcasestr(const char *in, const char *what);
|
char *strcasestr(const char *in, const char *what);
|
||||||
#define stristr strcasestr
|
#define stristr strcasestr
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined (macintosh) //|| defined (__APPLE__) //skip all boolean/Boolean crap
|
#if defined (macintosh) //|| defined (__APPLE__) //skip all boolean/Boolean crap
|
||||||
#define true 1
|
#define true 1
|
||||||
@@ -156,22 +162,19 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
|
|||||||
|
|
||||||
/* Boolean type definition */
|
/* Boolean type definition */
|
||||||
|
|
||||||
// \note __BYTEBOOL__ used to be set above if "macintosh" was defined,
|
#ifndef _WIN32
|
||||||
// if macintosh's version of boolean type isn't needed anymore, then isn't this macro pointless now?
|
#include <stdbool.h>
|
||||||
#ifndef __BYTEBOOL__
|
// dont use stdbools _BOOL type
|
||||||
#define __BYTEBOOL__
|
// its smaller (1 byte) than the old interger bool (4 bytes)
|
||||||
|
// which results in packed struct sizes being mismatched between vanilla and this
|
||||||
//faB: clean that up !!
|
// however we gotta still include stdbool cause since c23 true and false are keywords
|
||||||
#if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward
|
// which we cant use as enumeration constants
|
||||||
#include "stdbool.h"
|
typedef int32_t boolean;
|
||||||
#elif defined (_WIN32)
|
#else
|
||||||
#define false FALSE // use windows types
|
#define false FALSE
|
||||||
#define true TRUE
|
#define true TRUE
|
||||||
#define boolean BOOL
|
#define boolean BOOL
|
||||||
#else
|
#endif
|
||||||
typedef enum {false, true} boolean;
|
|
||||||
#endif
|
|
||||||
#endif // __BYTEBOOL__
|
|
||||||
|
|
||||||
/* 7.18.2.1 Limits of exact-width integer types */
|
/* 7.18.2.1 Limits of exact-width integer types */
|
||||||
#ifndef INT8_MIN
|
#ifndef INT8_MIN
|
||||||
@@ -385,4 +388,8 @@ unset_bit_array (bitarray_t * const array, const int value)
|
|||||||
|
|
||||||
typedef UINT64 precise_t;
|
typedef UINT64 precise_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //__DOOMTYPE__
|
#endif //__DOOMTYPE__
|
||||||
+3
-2
@@ -531,8 +531,8 @@ static const char *credits[] = {
|
|||||||
"\"Xyzzy\"",
|
"\"Xyzzy\"",
|
||||||
"\"Chearii\"",
|
"\"Chearii\"",
|
||||||
" ",
|
" ",
|
||||||
"\"Sunflower\" aka \"AnimeSonic\"",
|
"\"Sunflower\"",
|
||||||
"\"Yuz\" aka \"Yuzler\"",
|
"\"Yuz\"",
|
||||||
"\"Democrab\"",
|
"\"Democrab\"",
|
||||||
"\"EXpand\"",
|
"\"EXpand\"",
|
||||||
"\"Nexit\"",
|
"\"Nexit\"",
|
||||||
@@ -543,6 +543,7 @@ static const char *credits[] = {
|
|||||||
"\"Achii\"",
|
"\"Achii\"",
|
||||||
"\"Anonimus\"",
|
"\"Anonimus\"",
|
||||||
"\"scizor300\"",
|
"\"scizor300\"",
|
||||||
|
"\"Lugent\"",
|
||||||
"",
|
"",
|
||||||
"\1Special Thanks",
|
"\1Special Thanks",
|
||||||
"SEGA",
|
"SEGA",
|
||||||
|
|||||||
+3
-3
@@ -313,7 +313,7 @@ void F_WipeStartScreen(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
wipe_scr_start = screens[3];
|
wipe_scr_start = vid.screens[3];
|
||||||
I_ReadScreen(wipe_scr_start);
|
I_ReadScreen(wipe_scr_start);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -330,7 +330,7 @@ void F_WipeEndScreen(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
wipe_scr_end = screens[4];
|
wipe_scr_end = vid.screens[4];
|
||||||
I_ReadScreen(wipe_scr_end);
|
I_ReadScreen(wipe_scr_end);
|
||||||
V_DrawBlock(0, 0, 0, vid.width, vid.height, wipe_scr_start);
|
V_DrawBlock(0, 0, 0, vid.width, vid.height, wipe_scr_start);
|
||||||
#endif
|
#endif
|
||||||
@@ -353,7 +353,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
|
|||||||
|
|
||||||
// Init the wipe
|
// Init the wipe
|
||||||
WipeInAction = true;
|
WipeInAction = true;
|
||||||
wipe_scr = screens[0];
|
wipe_scr = vid.screens[0];
|
||||||
|
|
||||||
// lastwipetic should either be 0 or the tic we last wiped
|
// lastwipetic should either be 0 or the tic we last wiped
|
||||||
// on for fade-to-black
|
// on for fade-to-black
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
#ifndef __FILESRCH_H__
|
#ifndef __FILESRCH_H__
|
||||||
#define __FILESRCH_H__
|
#define __FILESRCH_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
#include "d_netfil.h"
|
#include "d_netfil.h"
|
||||||
#include "m_menu.h" // MAXSTRINGLENGTH
|
#include "m_menu.h" // MAXSTRINGLENGTH
|
||||||
@@ -96,4 +100,8 @@ void closefilemenu(boolean validsize);
|
|||||||
void searchfilemenu(char *tempname);
|
void searchfilemenu(char *tempname);
|
||||||
boolean preparefilemenu(boolean samedepth, boolean replayhut);
|
boolean preparefilemenu(boolean samedepth, boolean replayhut);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __FILESRCH_H__
|
#endif // __FILESRCH_H__
|
||||||
+4070
File diff suppressed because it is too large.
Load diff
+191
@@ -0,0 +1,191 @@
|
|||||||
|
// SONIC ROBO BLAST 2 KART
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||||
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||||
|
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file g_demo.h
|
||||||
|
/// \brief Demo recording and playback
|
||||||
|
|
||||||
|
#ifndef __G_DEMO__
|
||||||
|
#define __G_DEMO__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "doomdef.h"
|
||||||
|
#include "doomstat.h"
|
||||||
|
#include "d_event.h"
|
||||||
|
#include "p_saveg.h"
|
||||||
|
#include "m_textinput.h"
|
||||||
|
|
||||||
|
extern savebuffer_t demobuf;
|
||||||
|
|
||||||
|
// demoplaying back and demo recording
|
||||||
|
extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demochangemap;
|
||||||
|
extern consvar_t cv_demodateformat;
|
||||||
|
extern consvar_t cv_resyncdemo;
|
||||||
|
|
||||||
|
// Publicly-accessible demo vars
|
||||||
|
struct demovars_s {
|
||||||
|
char titlename[65];
|
||||||
|
textinput_t titlenameinput;
|
||||||
|
boolean recording, playback, timing;
|
||||||
|
UINT16 version; // Current file format of the demo being played
|
||||||
|
boolean title; // Title Screen demo can be cancelled by any key
|
||||||
|
boolean rewinding; // Rewind in progress
|
||||||
|
|
||||||
|
boolean loadfiles, ignorefiles; // Demo file loading options
|
||||||
|
boolean fromtitle; // SRB2Kart: Don't stop the music
|
||||||
|
boolean inreplayhut; // Go back to replayhut after demos
|
||||||
|
boolean quitafterplaying; // quit after playing a demo from cmdline
|
||||||
|
boolean deferstart; // don't start playing demo right away
|
||||||
|
|
||||||
|
tic_t savebutton; // Used to determine when the local player can choose to save the replay while the race is still going
|
||||||
|
enum {
|
||||||
|
DSM_NOTSAVING,
|
||||||
|
DSM_WILLAUTOSAVE,
|
||||||
|
DSM_TITLEENTRY,
|
||||||
|
DSM_WILLSAVE,
|
||||||
|
DSM_SAVED
|
||||||
|
} savemode;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct demovars_s demo;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MD_NOTLOADED,
|
||||||
|
MD_LOADED,
|
||||||
|
MD_SUBDIR,
|
||||||
|
MD_OUTDATED,
|
||||||
|
MD_INVALID
|
||||||
|
} menudemotype_e;
|
||||||
|
|
||||||
|
typedef struct menudemo_s {
|
||||||
|
char filepath[256];
|
||||||
|
menudemotype_e type;
|
||||||
|
|
||||||
|
char title[65]; // Null-terminated for string prints
|
||||||
|
char date[11]; // date when replay was recorded
|
||||||
|
char version[12]; // combined version and subversion
|
||||||
|
UINT16 map;
|
||||||
|
UINT8 addonstatus; // What do we need to do addon-wise to play this demo?
|
||||||
|
UINT8 gametype;
|
||||||
|
UINT8 kartspeed; // Add OR DF_ENCORE for encore mode, idk
|
||||||
|
UINT8 numlaps;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
UINT8 ranking;
|
||||||
|
char name[17];
|
||||||
|
UINT8 skin, color;
|
||||||
|
UINT32 timeorscore;
|
||||||
|
} standings[MAXPLAYERS];
|
||||||
|
} menudemo_t;
|
||||||
|
|
||||||
|
extern mobj_t *metalplayback;
|
||||||
|
|
||||||
|
// Only called by startup code.
|
||||||
|
void G_RecordDemo(const char *name);
|
||||||
|
void G_RecordMetal(void);
|
||||||
|
void G_BeginRecording(void);
|
||||||
|
void G_BeginMetal(void);
|
||||||
|
|
||||||
|
// Only called by shutdown code.
|
||||||
|
void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT32 val);
|
||||||
|
void G_SetDemoTime(UINT32 ptime, UINT32 plap);
|
||||||
|
UINT8 G_CmpDemoTime(char *oldname, char *newname);
|
||||||
|
|
||||||
|
void G_LoadDemoInfo(menudemo_t *pdemo);
|
||||||
|
void G_LoadDemoTitle(menudemo_t *pdemo); // For use in replay search feature
|
||||||
|
void G_DeferedPlayDemo(const char *demo);
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GHC_NORMAL = 0,
|
||||||
|
GHC_SUPER,
|
||||||
|
GHC_FIREFLOWER,
|
||||||
|
GHC_INVINCIBLE
|
||||||
|
} ghostcolor_t;
|
||||||
|
|
||||||
|
extern UINT8 demo_extradata[MAXPLAYERS];
|
||||||
|
extern UINT8 demo_writerng;
|
||||||
|
#define DXD_RESPAWN 0x01 // "respawn" command in console
|
||||||
|
#define DXD_SKIN 0x02 // skin changed
|
||||||
|
#define DXD_NAME 0x04 // name changed
|
||||||
|
#define DXD_COLOR 0x08 // color changed
|
||||||
|
#define DXD_PLAYSTATE 0x10 // state changed between playing, spectating, or not in-game
|
||||||
|
|
||||||
|
#define DXD_PST_PLAYING 0x01
|
||||||
|
#define DXD_PST_SPECTATING 0x02
|
||||||
|
#define DXD_PST_LEFT 0x03
|
||||||
|
|
||||||
|
// Record/playback tics
|
||||||
|
void G_ReadDemoExtraData(void);
|
||||||
|
void G_WriteDemoExtraData(void);
|
||||||
|
void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum);
|
||||||
|
void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum);
|
||||||
|
void G_GhostAddThok(INT32 playernum);
|
||||||
|
void G_GhostAddSpin(INT32 playernum);
|
||||||
|
void G_GhostAddRev(INT32 playernum);
|
||||||
|
void G_GhostAddColor(INT32 playernum, ghostcolor_t color);
|
||||||
|
void G_GhostAddFlip(INT32 playernum);
|
||||||
|
void G_GhostAddScale(INT32 playernum, fixed_t scale);
|
||||||
|
void G_GhostAddHit(INT32 playernum, mobj_t *victim);
|
||||||
|
void G_WriteAllGhostTics(void);
|
||||||
|
void G_WriteGhostTic(mobj_t *ghost, INT32 playernum);
|
||||||
|
void G_ConsAllGhostTics(void);
|
||||||
|
void G_ConsGhostTic(INT32 playernum);
|
||||||
|
void G_GhostTicker(void);
|
||||||
|
|
||||||
|
void G_InitDemoRewind(void);
|
||||||
|
void G_StoreRewindInfo(void);
|
||||||
|
void G_PreviewRewind(tic_t previewtime);
|
||||||
|
void G_ConfirmRewind(tic_t rewindtime);
|
||||||
|
|
||||||
|
void G_ReadMetalTic(mobj_t *metal);
|
||||||
|
void G_WriteMetalTic(mobj_t *metal);
|
||||||
|
void G_SaveMetal(UINT8 **buffer);
|
||||||
|
void G_LoadMetal(UINT8 **buffer);
|
||||||
|
|
||||||
|
// Your naming conventions are stupid and useless.
|
||||||
|
// There is no conflict here.
|
||||||
|
typedef struct demoghost {
|
||||||
|
UINT8 checksum[16];
|
||||||
|
UINT8 *buffer, *p, color;
|
||||||
|
UINT16 version;
|
||||||
|
mobj_t oldmo, *mo;
|
||||||
|
struct demoghost *next;
|
||||||
|
} demoghost;
|
||||||
|
extern demoghost *ghosts;
|
||||||
|
|
||||||
|
// G_CheckDemoExtraFiles: checks if our loaded WAD list matches the demo's.
|
||||||
|
#define DFILE_ERROR_NOTLOADED 0x01 // Files are not loaded, but can be without a restart.
|
||||||
|
#define DFILE_ERROR_OUTOFORDER 0x02 // Files are loaded, but out of order.
|
||||||
|
#define DFILE_ERROR_INCOMPLETEOUTOFORDER 0x03 // Some files are loaded out of order, but others are not.
|
||||||
|
#define DFILE_ERROR_CANNOTLOAD 0x04 // Files are missing and cannot be loaded.
|
||||||
|
#define DFILE_ERROR_EXTRAFILES 0x05 // Extra files outside of the replay's file list are loaded.
|
||||||
|
|
||||||
|
void G_ResetDemoRecording(void);
|
||||||
|
void G_DoPlayDemo(char *defdemoname);
|
||||||
|
void G_TimeDemo(const char *name);
|
||||||
|
void G_AddGhost(char *defdemoname);
|
||||||
|
void G_UpdateStaffGhostName(lumpnum_t l);
|
||||||
|
void G_DoPlayMetal(void);
|
||||||
|
void G_DoneLevelLoad(void);
|
||||||
|
void G_StopMetalDemo(void);
|
||||||
|
ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void);
|
||||||
|
void G_StopDemo(void);
|
||||||
|
boolean G_CheckDemoStatus(void);
|
||||||
|
void G_SaveDemo(void);
|
||||||
|
boolean G_DemoTitleResponder(event_t *ev);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __G_DEMO__
|
||||||
+7
-4009
File diff suppressed because it is too large.
Load diff
+9
-164
@@ -14,9 +14,14 @@
|
|||||||
#ifndef __G_GAME__
|
#ifndef __G_GAME__
|
||||||
#define __G_GAME__
|
#define __G_GAME__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "d_event.h"
|
#include "d_event.h"
|
||||||
|
#include "g_demo.h"
|
||||||
#include "p_saveg.h"
|
#include "p_saveg.h"
|
||||||
#include "m_textinput.h"
|
#include "m_textinput.h"
|
||||||
|
|
||||||
@@ -34,75 +39,6 @@ extern INT32 player_name_changes[MAXPLAYERS];
|
|||||||
extern player_t players[MAXPLAYERS];
|
extern player_t players[MAXPLAYERS];
|
||||||
extern boolean playeringame[MAXPLAYERS];
|
extern boolean playeringame[MAXPLAYERS];
|
||||||
|
|
||||||
extern savebuffer_t demobuf;
|
|
||||||
|
|
||||||
// ======================================
|
|
||||||
// DEMO playback/recording related stuff.
|
|
||||||
// ======================================
|
|
||||||
|
|
||||||
// demoplaying back and demo recording
|
|
||||||
extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demochangemap;
|
|
||||||
extern consvar_t cv_demodateformat;
|
|
||||||
|
|
||||||
// Publicly-accessible demo vars
|
|
||||||
struct demovars_s {
|
|
||||||
char titlename[65];
|
|
||||||
textinput_t titlenameinput;
|
|
||||||
boolean recording, playback, timing;
|
|
||||||
UINT16 version; // Current file format of the demo being played
|
|
||||||
boolean title; // Title Screen demo can be cancelled by any key
|
|
||||||
boolean rewinding; // Rewind in progress
|
|
||||||
|
|
||||||
boolean loadfiles, ignorefiles; // Demo file loading options
|
|
||||||
boolean fromtitle; // SRB2Kart: Don't stop the music
|
|
||||||
boolean inreplayhut; // Go back to replayhut after demos
|
|
||||||
boolean quitafterplaying; // quit after playing a demo from cmdline
|
|
||||||
boolean deferstart; // don't start playing demo right away
|
|
||||||
|
|
||||||
tic_t savebutton; // Used to determine when the local player can choose to save the replay while the race is still going
|
|
||||||
enum {
|
|
||||||
DSM_NOTSAVING,
|
|
||||||
DSM_WILLAUTOSAVE,
|
|
||||||
DSM_TITLEENTRY,
|
|
||||||
DSM_WILLSAVE,
|
|
||||||
DSM_SAVED
|
|
||||||
} savemode;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct demovars_s demo;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
MD_NOTLOADED,
|
|
||||||
MD_LOADED,
|
|
||||||
MD_SUBDIR,
|
|
||||||
MD_OUTDATED,
|
|
||||||
MD_INVALID
|
|
||||||
} menudemotype_e;
|
|
||||||
|
|
||||||
typedef struct menudemo_s {
|
|
||||||
char filepath[256];
|
|
||||||
menudemotype_e type;
|
|
||||||
|
|
||||||
char title[65]; // Null-terminated for string prints
|
|
||||||
char date[11]; // date when replay was recorded
|
|
||||||
char version[12]; // combined version and subversion
|
|
||||||
UINT16 map;
|
|
||||||
UINT8 addonstatus; // What do we need to do addon-wise to play this demo?
|
|
||||||
UINT8 gametype;
|
|
||||||
UINT8 kartspeed; // Add OR DF_ENCORE for encore mode, idk
|
|
||||||
UINT8 numlaps;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
UINT8 ranking;
|
|
||||||
char name[17];
|
|
||||||
UINT8 skin, color;
|
|
||||||
UINT32 timeorscore;
|
|
||||||
} standings[MAXPLAYERS];
|
|
||||||
} menudemo_t;
|
|
||||||
|
|
||||||
|
|
||||||
extern mobj_t *metalplayback;
|
|
||||||
|
|
||||||
// gametic at level start
|
// gametic at level start
|
||||||
extern tic_t levelstarttic;
|
extern tic_t levelstarttic;
|
||||||
|
|
||||||
@@ -286,10 +222,6 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost);
|
|||||||
void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar,
|
void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar,
|
||||||
UINT8 ssplayers, boolean FLS);
|
UINT8 ssplayers, boolean FLS);
|
||||||
|
|
||||||
void G_LoadDemoInfo(menudemo_t *pdemo);
|
|
||||||
void G_LoadDemoTitle(menudemo_t *pdemo); // For use in replay search feature
|
|
||||||
void G_DeferedPlayDemo(const char *demo);
|
|
||||||
|
|
||||||
// Can be called by the startup code or M_Responder, calls P_SetupLevel.
|
// Can be called by the startup code or M_Responder, calls P_SetupLevel.
|
||||||
void G_LoadGame(UINT32 slot, INT16 mapoverride);
|
void G_LoadGame(UINT32 slot, INT16 mapoverride);
|
||||||
|
|
||||||
@@ -297,97 +229,6 @@ void G_SaveGameData(boolean force);
|
|||||||
|
|
||||||
void G_SaveGame(UINT32 slot);
|
void G_SaveGame(UINT32 slot);
|
||||||
|
|
||||||
// Only called by startup code.
|
|
||||||
void G_RecordDemo(const char *name);
|
|
||||||
void G_RecordMetal(void);
|
|
||||||
void G_BeginRecording(void);
|
|
||||||
void G_BeginMetal(void);
|
|
||||||
|
|
||||||
// Only called by shutdown code.
|
|
||||||
void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT32 val);
|
|
||||||
void G_SetDemoTime(UINT32 ptime, UINT32 plap);
|
|
||||||
UINT8 G_CmpDemoTime(char *oldname, char *newname);
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GHC_NORMAL = 0,
|
|
||||||
GHC_SUPER,
|
|
||||||
GHC_FIREFLOWER,
|
|
||||||
GHC_INVINCIBLE
|
|
||||||
} ghostcolor_t;
|
|
||||||
|
|
||||||
extern UINT8 demo_extradata[MAXPLAYERS];
|
|
||||||
extern UINT8 demo_writerng;
|
|
||||||
#define DXD_RESPAWN 0x01 // "respawn" command in console
|
|
||||||
#define DXD_SKIN 0x02 // skin changed
|
|
||||||
#define DXD_NAME 0x04 // name changed
|
|
||||||
#define DXD_COLOR 0x08 // color changed
|
|
||||||
#define DXD_PLAYSTATE 0x10 // state changed between playing, spectating, or not in-game
|
|
||||||
|
|
||||||
#define DXD_PST_PLAYING 0x01
|
|
||||||
#define DXD_PST_SPECTATING 0x02
|
|
||||||
#define DXD_PST_LEFT 0x03
|
|
||||||
|
|
||||||
// Record/playback tics
|
|
||||||
void G_ReadDemoExtraData(void);
|
|
||||||
void G_WriteDemoExtraData(void);
|
|
||||||
void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum);
|
|
||||||
void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum);
|
|
||||||
void G_GhostAddThok(INT32 playernum);
|
|
||||||
void G_GhostAddSpin(INT32 playernum);
|
|
||||||
void G_GhostAddRev(INT32 playernum);
|
|
||||||
void G_GhostAddColor(INT32 playernum, ghostcolor_t color);
|
|
||||||
void G_GhostAddFlip(INT32 playernum);
|
|
||||||
void G_GhostAddScale(INT32 playernum, fixed_t scale);
|
|
||||||
void G_GhostAddHit(INT32 playernum, mobj_t *victim);
|
|
||||||
void G_WriteAllGhostTics(void);
|
|
||||||
void G_WriteGhostTic(mobj_t *ghost, INT32 playernum);
|
|
||||||
void G_ConsAllGhostTics(void);
|
|
||||||
void G_ConsGhostTic(INT32 playernum);
|
|
||||||
void G_GhostTicker(void);
|
|
||||||
|
|
||||||
void G_InitDemoRewind(void);
|
|
||||||
void G_StoreRewindInfo(void);
|
|
||||||
void G_PreviewRewind(tic_t previewtime);
|
|
||||||
void G_ConfirmRewind(tic_t rewindtime);
|
|
||||||
|
|
||||||
void G_ReadMetalTic(mobj_t *metal);
|
|
||||||
void G_WriteMetalTic(mobj_t *metal);
|
|
||||||
void G_SaveMetal(UINT8 **buffer);
|
|
||||||
void G_LoadMetal(UINT8 **buffer);
|
|
||||||
|
|
||||||
// Your naming conventions are stupid and useless.
|
|
||||||
// There is no conflict here.
|
|
||||||
typedef struct demoghost {
|
|
||||||
UINT8 checksum[16];
|
|
||||||
UINT8 *buffer, *p, color;
|
|
||||||
UINT16 version;
|
|
||||||
mobj_t oldmo, *mo;
|
|
||||||
struct demoghost *next;
|
|
||||||
} demoghost;
|
|
||||||
extern demoghost *ghosts;
|
|
||||||
|
|
||||||
// G_CheckDemoExtraFiles: checks if our loaded WAD list matches the demo's.
|
|
||||||
#define DFILE_ERROR_NOTLOADED 0x01 // Files are not loaded, but can be without a restart.
|
|
||||||
#define DFILE_ERROR_OUTOFORDER 0x02 // Files are loaded, but out of order.
|
|
||||||
#define DFILE_ERROR_INCOMPLETEOUTOFORDER 0x03 // Some files are loaded out of order, but others are not.
|
|
||||||
#define DFILE_ERROR_CANNOTLOAD 0x04 // Files are missing and cannot be loaded.
|
|
||||||
#define DFILE_ERROR_EXTRAFILES 0x05 // Extra files outside of the replay's file list are loaded.
|
|
||||||
|
|
||||||
void G_ResetDemoRecording(void);
|
|
||||||
void G_DoPlayDemo(char *defdemoname);
|
|
||||||
void G_TimeDemo(const char *name);
|
|
||||||
void G_AddGhost(char *defdemoname);
|
|
||||||
void G_UpdateStaffGhostName(lumpnum_t l);
|
|
||||||
void G_DoPlayMetal(void);
|
|
||||||
void G_DoneLevelLoad(void);
|
|
||||||
void G_StopMetalDemo(void);
|
|
||||||
ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void);
|
|
||||||
void G_StopDemo(void);
|
|
||||||
boolean G_CheckDemoStatus(void);
|
|
||||||
void G_SaveDemo(void);
|
|
||||||
boolean G_DemoTitleResponder(event_t *ev);
|
|
||||||
|
|
||||||
#define G_GametypeHasTeams() (G_IsGameType(GT_TEAMMATCH) || G_IsGameType(GT_CTF))
|
#define G_GametypeHasTeams() (G_IsGameType(GT_TEAMMATCH) || G_IsGameType(GT_CTF))
|
||||||
#define G_BattleGametype() (G_IsGameType(GT_MATCH))
|
#define G_BattleGametype() (G_IsGameType(GT_MATCH))
|
||||||
#define G_RaceGametype() (G_IsGameType(GT_RACE))
|
#define G_RaceGametype() (G_IsGameType(GT_RACE))
|
||||||
@@ -484,4 +325,8 @@ void G_AddMapToBuffer(INT16 map);
|
|||||||
|
|
||||||
void G_FixCamera(UINT8 view);
|
void G_FixCamera(UINT8 view);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+1
-1
@@ -1030,7 +1030,7 @@ INT32 G_KeyStringtoNum(const char *keystr)
|
|||||||
if (!keystr[0])
|
if (!keystr[0])
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!keystr[0] || (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z'))
|
if (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z')
|
||||||
return keystr[0];
|
return keystr[0];
|
||||||
|
|
||||||
if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9')
|
if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9')
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
hw_bsp.c
|
||||||
|
hw_draw.c
|
||||||
|
hw_main.cpp
|
||||||
|
hw_clip.c
|
||||||
|
hw_md2.c
|
||||||
|
hw_cache.c
|
||||||
|
hw_md2load.c
|
||||||
|
hw_md3load.c
|
||||||
|
hw_model.c
|
||||||
|
hw_portal.c
|
||||||
|
hw_batching.c
|
||||||
|
hw_shaders.c
|
||||||
|
u_list.c
|
||||||
|
r_opengl/r_opengl.c
|
||||||
+62
-80
@@ -25,22 +25,23 @@ GLMipmap_t *current_texture = NULL;
|
|||||||
|
|
||||||
boolean currently_batching = false;
|
boolean currently_batching = false;
|
||||||
|
|
||||||
FOutVector* finalVertexArray = NULL;// contains subset of sorted vertices and texture coordinates to be sent to gpu
|
FOutVector* finalVertexArray = NULL;// contains subset of sorted vertices and texture coordinates to be sent to gpu
|
||||||
UINT32* finalVertexIndexArray = NULL;// contains indexes for glDrawElements, taking into account fan->triangles conversion
|
UINT32* finalVertexIndexArray = NULL;// contains indexes for glDrawElements, taking into account fan->triangles conversion
|
||||||
// NOTE have this alloced as 3x finalVertexArray size
|
// NOTE have this alloced as 3x finalVertexArray size
|
||||||
int finalVertexArrayAllocSize = 65536;
|
int finalVertexArrayAllocSize = 65536;
|
||||||
|
|
||||||
//GLubyte* colorArray = NULL;// contains color data to be sent to gpu, if needed
|
//GLubyte* colorArray = NULL;// contains color data to be sent to gpu, if needed
|
||||||
//int colorArrayAllocSize = 65536;
|
//int colorArrayAllocSize = 65536;
|
||||||
// not gonna use this for now, just sort by color and change state when it changes
|
// not gonna use this for now, just sort by color and change state when it changes
|
||||||
// later maybe when using vertex attributes if it's needed
|
// later maybe when using vertex attributes if it's needed
|
||||||
|
|
||||||
PolygonArrayEntry* polygonArray = NULL;// contains the polygon data from DrawPolygon, waiting to be processed
|
PolygonArrayEntry* polygonArray = NULL ;// contains the polygon data from DrawPolygon, waiting to be processed
|
||||||
int polygonArraySize = 0;
|
PolygonArrayEntry **polygonArraySorted = NULL; // contains sorted pointers to polygonArray
|
||||||
PolygonArrayEntry **polygonArraySorted = NULL;// contains sorted pointers to polygonArray
|
int polygonArraySize = 0;
|
||||||
int polygonArrayAllocSize = 65536;
|
int polygonArrayAllocSize = 65536;
|
||||||
|
|
||||||
FOutVector* unsortedVertexArray = NULL;// contains unsorted vertices and texture coordinates from DrawPolygon
|
FOutVector* unsortedVertexArray = NULL; // contains unsorted vertices and texture coordinates from DrawPolygon
|
||||||
int unsortedVertexArraySize = 0;
|
int unsortedVertexArraySize = 0;
|
||||||
int unsortedVertexArrayAllocSize = 65536;
|
int unsortedVertexArrayAllocSize = 65536;
|
||||||
|
|
||||||
// Enables batching mode. HWR_ProcessPolygon will collect polygons instead of passing them directly to the rendering backend.
|
// Enables batching mode. HWR_ProcessPolygon will collect polygons instead of passing them directly to the rendering backend.
|
||||||
@@ -55,11 +56,11 @@ void HWR_StartBatching(void)
|
|||||||
// init arrays if that has not been done yet
|
// init arrays if that has not been done yet
|
||||||
if (!finalVertexArray)
|
if (!finalVertexArray)
|
||||||
{
|
{
|
||||||
finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
|
finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
|
||||||
finalVertexIndexArray = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32));
|
finalVertexIndexArray = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32));
|
||||||
polygonArray = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry));
|
polygonArray = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry));
|
||||||
polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *));
|
polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *));
|
||||||
unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
|
unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
|
||||||
}
|
}
|
||||||
|
|
||||||
currently_batching = true;
|
currently_batching = true;
|
||||||
@@ -89,32 +90,23 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
|
|||||||
{
|
{
|
||||||
if (!pSurf)
|
if (!pSurf)
|
||||||
{
|
{
|
||||||
I_Error("Got a null FSurfaceInfo in batching");// nulls should not come in the stuff that batching currently applies to
|
I_Error("Got a null FSurfaceInfo in batching"); // nulls should not come in the stuff that batching currently applies to
|
||||||
}
|
}
|
||||||
|
|
||||||
if (polygonArraySize == polygonArrayAllocSize)
|
if (polygonArraySize == polygonArrayAllocSize)
|
||||||
{
|
{
|
||||||
PolygonArrayEntry* new_array;
|
// ran out of space, double the array size
|
||||||
// ran out of space, make new array double the size
|
|
||||||
polygonArrayAllocSize *= 2;
|
polygonArrayAllocSize *= 2;
|
||||||
new_array = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry));
|
polygonArray = realloc(polygonArray, polygonArrayAllocSize * sizeof(PolygonArrayEntry));
|
||||||
memcpy(new_array, polygonArray, polygonArraySize * sizeof(PolygonArrayEntry));
|
|
||||||
free(polygonArray);
|
|
||||||
polygonArray = new_array;
|
|
||||||
// also need to redo the index array, dont need to copy it though
|
// also need to redo the index array, dont need to copy it though
|
||||||
free(polygonArraySorted);
|
polygonArraySorted = realloc(polygonArraySorted, polygonArrayAllocSize * sizeof(PolygonArrayEntry*));
|
||||||
polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize)
|
while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize)
|
||||||
{
|
{
|
||||||
FOutVector* new_array;
|
|
||||||
// need more space for vertices in unsortedVertexArray
|
// need more space for vertices in unsortedVertexArray
|
||||||
unsortedVertexArrayAllocSize *= 2;
|
unsortedVertexArrayAllocSize *= 2;
|
||||||
new_array = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
|
unsortedVertexArray = realloc(unsortedVertexArray, unsortedVertexArrayAllocSize * sizeof(FOutVector));
|
||||||
memcpy(new_array, unsortedVertexArray, unsortedVertexArraySize * sizeof(FOutVector));
|
|
||||||
free(unsortedVertexArray);
|
|
||||||
unsortedVertexArray = new_array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the polygon data to the arrays
|
// add the polygon data to the arrays
|
||||||
@@ -140,13 +132,13 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
|
|||||||
|
|
||||||
static int comparePolygons(const void *p1, const void *p2)
|
static int comparePolygons(const void *p1, const void *p2)
|
||||||
{
|
{
|
||||||
PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1;
|
|
||||||
PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2;
|
|
||||||
int diff;
|
int diff;
|
||||||
INT64 diff64;
|
INT64 diff64;
|
||||||
|
const PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1;
|
||||||
|
const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2;
|
||||||
|
|
||||||
int shader1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? -1 : poly1->shader;
|
const int shader1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? -1 : poly1->shader;
|
||||||
int shader2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? -1 : poly2->shader;
|
const int shader2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? -1 : poly2->shader;
|
||||||
|
|
||||||
// skywalls and horizon lines must retain their order for horizon lines to work
|
// skywalls and horizon lines must retain their order for horizon lines to work
|
||||||
if (shader1 == -1 && shader2 == -1)
|
if (shader1 == -1 && shader2 == -1)
|
||||||
@@ -177,20 +169,18 @@ static int comparePolygons(const void *p1, const void *p2)
|
|||||||
diff = poly1->surf.LightInfo.fade_end - poly2->surf.LightInfo.fade_end;
|
diff = poly1->surf.LightInfo.fade_end - poly2->surf.LightInfo.fade_end;
|
||||||
if (diff != 0) return diff;
|
if (diff != 0) return diff;
|
||||||
|
|
||||||
diff = poly1->surf.LightInfo.directional - poly2->surf.LightInfo.directional;
|
return poly1->surf.LightInfo.directional - poly2->surf.LightInfo.directional;
|
||||||
|
|
||||||
return diff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int comparePolygonsNoShaders(const void *p1, const void *p2)
|
static int comparePolygonsNoShaders(const void *p1, const void *p2)
|
||||||
{
|
{
|
||||||
PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1;
|
|
||||||
PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2;
|
|
||||||
int diff;
|
int diff;
|
||||||
INT64 diff64;
|
INT64 diff64;
|
||||||
|
const PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1;
|
||||||
|
const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2;
|
||||||
|
|
||||||
GLMipmap_t *texture1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? NULL : poly1->texture;
|
const GLMipmap_t *texture1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? NULL : poly1->texture;
|
||||||
GLMipmap_t *texture2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? NULL : poly2->texture;
|
const GLMipmap_t *texture2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? NULL : poly2->texture;
|
||||||
|
|
||||||
// skywalls and horizon lines must retain their order for horizon lines to work
|
// skywalls and horizon lines must retain their order for horizon lines to work
|
||||||
if (!texture1 && !texture2)
|
if (!texture1 && !texture2)
|
||||||
@@ -214,17 +204,16 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2)
|
|||||||
// the rendering backend to draw them.
|
// the rendering backend to draw them.
|
||||||
void HWR_RenderBatches(void)
|
void HWR_RenderBatches(void)
|
||||||
{
|
{
|
||||||
int finalVertexWritePos = 0;// position in finalVertexArray
|
int finalVertexWritePos = 0; // position in finalVertexArray
|
||||||
int finalIndexWritePos = 0;// position in finalVertexIndexArray
|
int finalIndexWritePos = 0; // position in finalVertexIndexArray
|
||||||
|
int polygonReadPos = 0; // position in polygonArraySorted
|
||||||
int polygonReadPos = 0;// position in polygonArraySorted
|
|
||||||
|
|
||||||
int currentShader;
|
int currentShader;
|
||||||
int nextShader = 0;
|
int nextShader = 0;
|
||||||
GLMipmap_t *currentTexture = NULL;
|
GLMipmap_t *currentTexture = NULL;
|
||||||
GLMipmap_t *nextTexture = NULL;
|
GLMipmap_t *nextTexture = NULL;
|
||||||
FBITFIELD currentPolyFlags = 0;
|
FBITFIELD currentPolyFlags = 0;
|
||||||
FBITFIELD nextPolyFlags = 0;
|
FBITFIELD nextPolyFlags = 0;
|
||||||
FSurfaceInfo currentSurfaceInfo;
|
FSurfaceInfo currentSurfaceInfo;
|
||||||
FSurfaceInfo nextSurfaceInfo;
|
FSurfaceInfo nextSurfaceInfo;
|
||||||
|
|
||||||
@@ -235,8 +224,8 @@ void HWR_RenderBatches(void)
|
|||||||
I_Error("HWR_RenderBatches called without starting batching");
|
I_Error("HWR_RenderBatches called without starting batching");
|
||||||
}
|
}
|
||||||
|
|
||||||
nextSurfaceInfo.LightInfo.fade_end = 0;
|
nextSurfaceInfo.LightInfo.fade_end = 0;
|
||||||
nextSurfaceInfo.LightInfo.fade_start = 0;
|
nextSurfaceInfo.LightInfo.fade_start = 0;
|
||||||
nextSurfaceInfo.LightInfo.light_level = 0;
|
nextSurfaceInfo.LightInfo.light_level = 0;
|
||||||
nextSurfaceInfo.LightInfo.directional = false;
|
nextSurfaceInfo.LightInfo.directional = false;
|
||||||
|
|
||||||
@@ -254,7 +243,7 @@ void HWR_RenderBatches(void)
|
|||||||
ps_hw_numpolys.value.i = polygonArraySize;
|
ps_hw_numpolys.value.i = polygonArraySize;
|
||||||
ps_hw_numcalls.value.i = ps_hw_numverts.value.i = 0;
|
ps_hw_numcalls.value.i = ps_hw_numverts.value.i = 0;
|
||||||
ps_hw_numshaders.value.i = ps_hw_numtextures.value.i
|
ps_hw_numshaders.value.i = ps_hw_numtextures.value.i
|
||||||
= ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1;
|
= ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1;
|
||||||
|
|
||||||
// init polygonArraySorted
|
// init polygonArraySorted
|
||||||
for (i = 0; i < polygonArraySize; i++)
|
for (i = 0; i < polygonArraySize; i++)
|
||||||
@@ -264,10 +253,7 @@ void HWR_RenderBatches(void)
|
|||||||
|
|
||||||
// sort polygons
|
// sort polygons
|
||||||
PS_START_TIMING(ps_hw_batchsorttime);
|
PS_START_TIMING(ps_hw_batchsorttime);
|
||||||
if (cv_glshaders.value && gl_shadersavailable)
|
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), (HWR_UseShader() ? comparePolygons : comparePolygonsNoShaders));
|
||||||
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygons);
|
|
||||||
else
|
|
||||||
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygonsNoShaders);
|
|
||||||
PS_STOP_TIMING(ps_hw_batchsorttime);
|
PS_STOP_TIMING(ps_hw_batchsorttime);
|
||||||
|
|
||||||
// sort order
|
// sort order
|
||||||
@@ -279,16 +265,16 @@ void HWR_RenderBatches(void)
|
|||||||
|
|
||||||
PS_START_TIMING(ps_hw_batchdrawtime);
|
PS_START_TIMING(ps_hw_batchdrawtime);
|
||||||
|
|
||||||
currentShader = polygonArraySorted[0]->shader;
|
currentShader = polygonArraySorted[0]->shader;
|
||||||
currentTexture = polygonArraySorted[0]->texture;
|
currentTexture = polygonArraySorted[0]->texture;
|
||||||
currentPolyFlags = polygonArraySorted[0]->polyFlags;
|
currentPolyFlags = polygonArraySorted[0]->polyFlags;
|
||||||
currentSurfaceInfo = polygonArraySorted[0]->surf;
|
currentSurfaceInfo = polygonArraySorted[0]->surf;
|
||||||
// For now, will sort and track the colors. Vertex attributes could be used instead of uniforms
|
// For now, will sort and track the colors. Vertex attributes could be used instead of uniforms
|
||||||
// and a color array could replace the color calls.
|
// and a color array could replace the color calls.
|
||||||
|
|
||||||
// set state for first batch
|
// set state for first batch
|
||||||
|
|
||||||
if (cv_glshaders.value && gl_shadersavailable)
|
if (HWR_UseShader())
|
||||||
{
|
{
|
||||||
GL_SetShader(currentShader);
|
GL_SetShader(currentShader);
|
||||||
}
|
}
|
||||||
@@ -313,42 +299,37 @@ void HWR_RenderBatches(void)
|
|||||||
// steps:
|
// steps:
|
||||||
// write vertices
|
// write vertices
|
||||||
// check for changes or end, otherwise go back to writing
|
// check for changes or end, otherwise go back to writing
|
||||||
// changes will affect the next vars and the change bools
|
// changes will affect the next vars and the change bools
|
||||||
// end could set flag for stopping
|
// end could set flag for stopping
|
||||||
// execute draw call
|
// execute draw call
|
||||||
// could check ending flag here
|
// could check ending flag here
|
||||||
// change states according to next vars and change bools, updating the current vars and reseting the bools
|
// change states according to next vars and change bools, updating the current vars and reseting the bools
|
||||||
// reset write pos
|
// reset write pos
|
||||||
// repeat loop
|
// repeat loop
|
||||||
|
|
||||||
PolygonArrayEntry *entry = polygonArraySorted[polygonReadPos++];
|
const PolygonArrayEntry *entry = polygonArraySorted[polygonReadPos++];
|
||||||
int numVerts = entry->numVerts;
|
const int numVerts = entry->numVerts;
|
||||||
|
|
||||||
// before writing, check if there is enough room
|
// before writing, check if there is enough room
|
||||||
// using 'while' instead of 'if' here makes sure that there will *always* be enough room.
|
// using 'while' instead of 'if' here makes sure that there will *always* be enough room.
|
||||||
// probably never will this loop run more than once though
|
// probably never will this loop run more than once though
|
||||||
while (finalVertexWritePos + numVerts > finalVertexArrayAllocSize)
|
while (finalVertexWritePos + numVerts > finalVertexArrayAllocSize)
|
||||||
{
|
{
|
||||||
FOutVector* new_array;
|
|
||||||
unsigned int* new_index_array;
|
|
||||||
finalVertexArrayAllocSize *= 2;
|
finalVertexArrayAllocSize *= 2;
|
||||||
new_array = malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
|
finalVertexArray = realloc(finalVertexArray, finalVertexArrayAllocSize * sizeof(FOutVector));
|
||||||
memcpy(new_array, finalVertexArray, finalVertexWritePos * sizeof(FOutVector));
|
|
||||||
free(finalVertexArray);
|
|
||||||
finalVertexArray = new_array;
|
|
||||||
// also increase size of index array, 3x of vertex array since
|
// also increase size of index array, 3x of vertex array since
|
||||||
// going from fans to triangles increases vertex count to 3x
|
// going from fans to triangles increases vertex count to 3x
|
||||||
new_index_array = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32));
|
finalVertexIndexArray = realloc(finalVertexIndexArray, finalVertexArrayAllocSize * 3 * sizeof(UINT32));
|
||||||
memcpy(new_index_array, finalVertexIndexArray, finalIndexWritePos * sizeof(UINT32));
|
|
||||||
free(finalVertexIndexArray);
|
|
||||||
finalVertexIndexArray = new_index_array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the vertices of the polygon
|
// write the vertices of the polygon
|
||||||
memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[entry->vertsIndex],
|
memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[entry->vertsIndex], numVerts * sizeof(FOutVector));
|
||||||
numVerts * sizeof(FOutVector));
|
|
||||||
// write the indexes, pointing to the fan vertexes but in triangles format
|
// write the indexes, pointing to the fan vertexes but in triangles format
|
||||||
firstIndex = finalVertexWritePos;
|
firstIndex = finalVertexWritePos;
|
||||||
lastIndex = finalVertexWritePos + numVerts;
|
lastIndex = finalVertexWritePos + numVerts;
|
||||||
finalVertexWritePos += 2;
|
finalVertexWritePos += 2;
|
||||||
|
|
||||||
while (finalVertexWritePos < lastIndex)
|
while (finalVertexWritePos < lastIndex)
|
||||||
{
|
{
|
||||||
finalVertexIndexArray[finalIndexWritePos++] = firstIndex;
|
finalVertexIndexArray[finalIndexWritePos++] = firstIndex;
|
||||||
@@ -363,16 +344,16 @@ void HWR_RenderBatches(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check if a state change is required, set the change bools and next vars
|
// check if a state change is required, set the change bools and next vars
|
||||||
PolygonArrayEntry *nextEntry = polygonArraySorted[polygonReadPos];
|
const PolygonArrayEntry *nextEntry = polygonArraySorted[polygonReadPos];
|
||||||
nextShader = nextEntry->shader;
|
nextShader = nextEntry->shader;
|
||||||
nextTexture = nextEntry->texture;
|
nextTexture = nextEntry->texture;
|
||||||
nextPolyFlags = nextEntry->polyFlags;
|
nextPolyFlags = nextEntry->polyFlags;
|
||||||
nextSurfaceInfo = nextEntry->surf;
|
nextSurfaceInfo = nextEntry->surf;
|
||||||
|
|
||||||
if (nextPolyFlags & PF_NoTexture)
|
if (nextPolyFlags & PF_NoTexture)
|
||||||
nextTexture = 0;
|
nextTexture = 0;
|
||||||
|
|
||||||
if (currentShader != nextShader && cv_glshaders.value && gl_shadersavailable)
|
if (currentShader != nextShader && HWR_UseShader())
|
||||||
{
|
{
|
||||||
changeState = true;
|
changeState = true;
|
||||||
changeShader = true;
|
changeShader = true;
|
||||||
@@ -390,14 +371,14 @@ void HWR_RenderBatches(void)
|
|||||||
changePolyFlags = true;
|
changePolyFlags = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cv_glshaders.value && gl_shadersavailable)
|
if (HWR_UseShader())
|
||||||
{
|
{
|
||||||
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
|
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
|
||||||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
|
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
|
||||||
currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba ||
|
currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba ||
|
||||||
currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level ||
|
currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level ||
|
||||||
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start ||
|
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start ||
|
||||||
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end ||
|
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end ||
|
||||||
currentSurfaceInfo.LightInfo.directional != nextSurfaceInfo.LightInfo.directional)
|
currentSurfaceInfo.LightInfo.directional != nextSurfaceInfo.LightInfo.directional)
|
||||||
{
|
{
|
||||||
changeState = true;
|
changeState = true;
|
||||||
@@ -423,7 +404,7 @@ void HWR_RenderBatches(void)
|
|||||||
ps_hw_numverts.value.i += finalIndexWritePos;
|
ps_hw_numverts.value.i += finalIndexWritePos;
|
||||||
// reset write positions
|
// reset write positions
|
||||||
finalVertexWritePos = 0;
|
finalVertexWritePos = 0;
|
||||||
finalIndexWritePos = 0;
|
finalIndexWritePos = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
@@ -469,9 +450,10 @@ void HWR_RenderBatches(void)
|
|||||||
|
|
||||||
ps_hw_numcolors.value.i++;
|
ps_hw_numcolors.value.i++;
|
||||||
}
|
}
|
||||||
// and that should be it?
|
|
||||||
}
|
}
|
||||||
|
// and that should be it?
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the arrays (set sizes to 0)
|
// reset the arrays (set sizes to 0)
|
||||||
polygonArraySize = 0;
|
polygonArraySize = 0;
|
||||||
unsortedVertexArraySize = 0;
|
unsortedVertexArraySize = 0;
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
#ifndef __HWR_BATCHING_H__
|
#ifndef __HWR_BATCHING_H__
|
||||||
#define __HWR_BATCHING_H__
|
#define __HWR_BATCHING_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "hw_defs.h"
|
#include "hw_defs.h"
|
||||||
#include "hw_data.h"
|
#include "hw_data.h"
|
||||||
#include "hw_gl.h"
|
#include "hw_gl.h"
|
||||||
@@ -36,4 +40,8 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture);
|
|||||||
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial);
|
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial);
|
||||||
void HWR_RenderBatches(void);
|
void HWR_RenderBatches(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loaded 100 of 211 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user