Compare commits

..
217 Commits
Author SHA1 Message Date
indev 5a44afcd9f Disable multithreading in R_DrawMaskedList 2025-07-01 16:09:18 +03:00
Alug 3c282b5022 this can use min/max 2025-07-01 14:42:28 +02:00
Alug f4d40bd55f "-Wno-aggregate-return" for c++ 2025-07-01 14:38:42 +02:00
Alug 465fea8bb3 "restrict" macro for c++
since it does not have it, use __restrict instead
2025-06-30 12:18:21 +02:00
Alug d47e20b54e those can be const 2025-06-29 11:44:29 +02:00
Alug 4e9f9b7e0e Revert "add "for_each" to srb2 threadpool"
This reverts commit 604bc40021.
2025-06-27 16:38:19 +02:00
Alug 9650139470 Revert "allocate tiltlighting buffer in R_AllocViewMemory again"
This reverts commit b541de4f8c.
2025-06-27 16:38:16 +02:00
Alug 054a40a4b2 Revert "omit realloc and use unique_ptr for our tiltlighting buffer"
This reverts commit e351c1e62a.
2025-06-27 16:38:13 +02:00
Alug 972ee5cf76 remove erronous BACKSLASH
was from when this was a macro lel
edit: screw you comptime
2025-06-26 20:17:33 +02:00
Gustaf Alhäll aef02cb347 Fix one-pixel wide gaps in tall sprites 2025-06-26 20:09:16 +02:00
Alug 36e485b2a3 move gl portalcullsector check back to the right place lel
oopsie
2025-06-26 15:13:54 +02:00
Alug d23c51e707 mark node as restrict again pointonside 2025-06-26 13:22:17 +02:00
Alug 0db437aadd do some more tiny optimizations
-those can all be declared with restrict
-our ternary clamp macro is slightly faster than std::clamp
2025-06-26 13:22:15 +02:00
Alug e351c1e62a omit realloc and use unique_ptr for our tiltlighting buffer
this makes asan shut up, since those effectively clean up after themselves
2025-06-26 13:22:11 +02:00
Alug b541de4f8c allocate tiltlighting buffer in R_AllocViewMemory again
just removes the ugly stuff in the span drawers
needs to be tested a little, but should be fine
2025-06-26 13:21:56 +02:00
Alug 604bc40021 add "for_each" to srb2 threadpool
this exectures something for EACH thread not some abritatrily choosen ones
2025-06-26 13:21:52 +02:00
Alug be8ddebd80 forgor about the new signal handler oop 2025-06-26 00:39:01 +02:00
Alug b2a36850cb Merge branch 'Saturn-Next' into softwarecrap 2025-06-25 12:47:43 +02:00
Alug 8353c1efdd add toggle for software cyan cut stuff
"softwarecyancut"
this is disabled by default, since some vanilla maps were designed around this
also costs a bit of performance (splat span drawers are slooooow)
2025-06-25 12:47:25 +02:00
Alug d19a2e0912 attempt to make fofs in software always cut cyan pixels
if they do contain cyan pixels lel
kinda meh, and needs a toggle
2025-06-25 12:45:14 +02:00
Alug 07432c0381 turn angle stuff into a switch in R_SetupSkyScale 2025-06-25 12:29:58 +02:00
Alug 4fb3b63152 optimize R_StoreWallRange with cut down version of rendersegloop when a seg is untextured
from srb2, its just a cut down rendersegloop with alot less things to check and such
2025-06-23 19:38:57 +02:00
Alug 85b736620a Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Next 2025-06-23 19:26:07 +02:00
Alug 9f770993d4 proper init enterprecise 2025-06-23 19:25:50 +02:00
Alug 4bd02ad325 check if player is local here 2025-06-23 19:25:46 +02:00
Alug 6e7b45d15c simplify R_SetupAimingFrame 2025-06-23 19:25:34 +02:00
Alug 99ebca51d5 use const_cast for colfunccopy
idk its from rr idk why it was like this
2025-06-23 19:23:56 +02:00
Alug 24eb888af3 make skytextures support texture offsets in software 2025-06-23 19:20:20 +02:00
Alug 09ce33abb9 just always clamp the non psprite texture column
this may underflow, which the check in the lööp body does not account for
2025-06-23 19:18:11 +02:00
indev 044ff158a1 SF_HIRES is already handled via spritexscale and spriteyscale 2025-06-23 18:37:57 +03:00
Alug 36c68d055c minor optimizations r_things 2025-06-21 18:07:44 +02:00
Alug ddf7d7cdcb use templates for R_ClipWallSegment
actual slight speedup
2025-06-21 18:07:41 +02:00
Alug 38950d580f fix a clang warning 2025-06-20 09:54:20 +02:00
Alug 707701f317 do palette stuff in st_ticker
cleanup and dont call it in normal ogl at all unless palette render with flashpals is enabled
inspired by Nyan-Doom/Woof
2025-06-20 09:54:17 +02:00
Alug 09507d635b remove now unecessary type cast 2025-06-19 17:41:26 +02:00
Alug ab85d6a693 shut the up -Waggregate-return 2025-06-19 17:41:23 +02:00
Alug 5011b17f88 attempt at optimizing drawcolumn drawers a bit more
inspired by dsda/prboom
seems to be super slighty faster
2025-06-19 15:57:21 +02:00
Alug 7bef45f701 Merge remote-tracking branch 'origin/Saturn-Next' into softwarecrap 2025-06-19 15:50:55 +02:00
indev 40cbce8f9f Merge pull request #178 from Indev450/newmakefiles
Port over SRB2´s makefile rewrites + Port Dedicated server build
2025-06-19 16:47:34 +03:00
Alug 70a70084c9 macrofy ogl function pointer setup
should make it a little less annoying to add new functions
2025-06-17 19:21:09 +02:00
indev b6da6359d3 If gamestate resend took too long, abort resynching 2025-06-16 21:43:54 +03:00
Alug 97075ca5c5 remove some code dupe
starting to like those lambda things
2025-06-13 16:08:06 +02:00
Alug e94737945a fix double sided skies per addline clipping code
fixes greencave skybox
hopefully this is it and doesent break anything else sigh
2025-06-13 08:11:45 +02:00
Alug 57f15e0213 R_GenerateBlendTables can be static 2025-06-13 03:23:31 +02:00
Alug 2eae9b197c port the span and column drawer templates + tilted translucent splat drawer
took the liberty to also carry over our optimizations, this is actually slightly faster than what we had before
2025-06-13 03:23:25 +02:00
Alug 68c7620349 Merge branch 'Saturn-Next' into softwarecrap 2025-06-13 00:53:30 +02:00
Alug 7a3faf34e7 move this into an if else
saves us a little work
2025-06-13 00:20:59 +02:00
Alug d401644447 tweak the sky checks even more
apparently koda has a skybox, and checking like this makes it not trigger, lets hope this has no bad side effects Zzz...
2025-06-13 00:20:48 +02:00
Alug dfc349b230 Merge branch 'newmakefiles' into softwarecrap 2025-06-12 23:33:49 +02:00
Alug be3e5a964d pass -flto to linkerflags too
lel forgor
somehow this still worked anyways
2025-06-12 23:33:41 +02:00
Alug 687d2bd894 Merge remote-tracking branch 'origin/Saturn' into Saturn-Next 2025-06-12 23:18:45 +02:00
Alug 78b642cf2d Merge pull request #183 from P-AS/mac-fixes
Fix build on macOS
2025-06-12 21:46:39 +01:00
Alug cb3b6ca34b Merge pull request #184 from chromaticpipe/levelinterpolatorjitter
Fix level interpolators jittering during objectplace
2025-06-12 20:46:31 +01:00
Alug ad15bf0ea3 readd some lost comments in r_bsp 2025-06-12 19:48:58 +02:00
Alug 56021ed999 dont compile with software multithread if NOTHREADS/HAVE_THREADS=0
might be useful for smth ig
2025-06-12 19:48:55 +02:00
chromaticpipe 3d22a5906f Fix level interpolators jittering during objectplac 2025-06-12 11:37:25 -05:00
Alug b6d771b48f unnest the skybox scale setup stuff 2025-06-12 17:10:26 +02:00
Alug ab30fb2e5e check if seg has any texture at all
seems to work even better and less "false positives"
also removing some redundant conditons
2025-06-12 17:10:22 +02:00
Alug 618d9e4cdf add lugent to credits 2025-06-11 20:55:26 +02:00
Alug bf78ad9c75 absolute insanity to hopefully fix all sky issues while keeping skyvisible 2025-06-11 20:28:16 +02:00
Alug 918a4e8cd9 add tilted fog span drawer
fixes the red fog blocks on mkrevamp
2025-06-11 17:10:47 +02:00
Alug e90c84c9ac we have a var for that lul 2025-06-11 16:32:36 +02:00
PAS a9209a4887 Include errno.h on macOS 2025-06-10 21:53:43 -04:00
Eidolon 0a3e7ba09f Include poll.h on UNIXCOMMON
Apple was not including poll.h despite needing it.
2025-06-10 21:49:00 -04:00
Alug eb132b08c0 make the check a little more robust + account for slopes a little 2025-06-11 00:31:01 +02:00
Alug 82407c3560 add missing plane bounds check to R_DrawSkyPlane 2025-06-11 00:30:59 +02:00
Alug f1a8210663 another attempt at actually fixing sky issues
absolutely fucking horrible
but this also does account for single sided lines aswell and gets rid of artifacts and perf
2025-06-10 18:33:20 +02:00
Alug 1d722be4bc few smoler optimizations r_segs 2025-06-10 01:21:36 +02:00
Alug 62a660bfe1 maybe this makes perf better somehow 2025-06-10 01:21:34 +02:00
Alug 2984795175 kill the splitscreen lööps from R_RenderPlayerView
this already gets called from within the one that assigns viewssnum which we can just use here
2025-06-09 23:45:02 +02:00
Alug da706d89a5 absolutely disgusting hack for sky issues
instead of homremoval, we draw the fucking skyplane before everything lmao
there probably is a right way to fix this, but im too dumb for that
needs some performance testing, but since i could move the semaphores back, its even better in some instances
2025-06-09 22:59:52 +02:00
Alug a8005d5cec fix portals dying
due to nummasks being too small and causing an overflow
ty hannu!
2025-06-09 20:57:19 +02:00
Alug 793ccff6e6 fix the goddamn portal use after free
https://git.do.srb2.org/STJr/SRB2/-/commit/f536ab34674fb8d3ee262a0009753f552074305c
2025-06-09 19:02:58 +02:00
Alug e7db9bf1fd fix bad copy paste lul 2025-06-09 17:09:57 +02:00
Alug 88d62c93a1 fix SHITPLANESPARENCY and QUINCUNX
maybe
2025-06-09 17:06:31 +02:00
Alug d73532d019 fix some fofs not rendering in software
i did an oopsie in 7.2 X)
2025-06-09 17:06:23 +02:00
Alug 84d3d23936 declare fracstep as const 2025-06-09 17:06:20 +02:00
Alug 717947843b memset those 2025-06-09 17:06:16 +02:00
Alug 968584a316 make skyportals account for how kart sets the viewheight
no we still dont use it
2025-06-09 17:06:14 +02:00
Alug ccd67f621a dont set any texture mapped drawer when fog 2025-06-09 17:06:10 +02:00
Alug 80b301dbbe unnest the overflow_test stuff
its also a ternary now lul
2025-06-09 17:06:07 +02:00
Alug 001e61d39d Merge branch 'Saturn-Next' into softwarecrap 2025-06-09 17:06:02 +02:00
Alug 19c98a436a fix some fofs not rendering in software
i did an oopsie in 7.2 X)
2025-06-09 17:05:42 +02:00
Alug 8dd6d7cfdd fix the fov adjust check
lmao oops
2025-06-09 16:59:00 +02:00
Alug 7456b6e02c Revert "bring back old clipwallsegment stuff"
This reverts commit 6af77afc44.
2025-06-09 04:27:58 +02:00
Alug 5e8096f74c move hom removal to D_Renderview
removes the hwr code dupe and moves this out of the splitscreen loop
2025-06-09 00:21:41 +02:00
Alug 6af77afc44 bring back old clipwallsegment stuff
i just didnt like the flow of the new ones
2025-06-08 21:38:57 +02:00
Alug 42eeb7bdf5 fix the massive slowdown on ante
due to really bad loop layout
std::fill is only cause it looks fancy :3
2025-06-08 21:38:54 +02:00
Alug 6f4b1e5125 fix portals on slopes
idk this is quite the hack, but it works
this adjustment somehow got omitted from srb2 during the portal refactor
2025-06-08 20:03:09 +02:00
Alug 22e65cdda8 readd portalcullsector
+ sprite clipping improvements with portals
2025-06-08 20:03:06 +02:00
Alug 9d342d0f3d fix lightlist memory leak
not sure if we need to copy over the old shit, but this seems to work aswell
2025-06-08 17:24:18 +02:00
Alug 9583bed718 fix da rippled wöter
i hate fixed point maths lmao
2025-06-08 00:43:15 +02:00
Alug b69ce75712 do NOT use Z_ functions in threaded stuff
shit dies
2025-06-08 00:25:03 +02:00
Alug a1cd19b023 make the fov dependant init stuff bit more safe and stuff 2025-06-07 23:54:12 +02:00
Alug 6e50710b25 fix column data colormap shit in R_RenderThickSideRange
too lazy to explain so https://git.do.srb2.org/KartKrew/RingRacers/-/commit/1ccd41c3dbb3132ce7467edf0c12c9d420b189f9
2025-06-07 23:31:51 +02:00
indev 989a971d27 Fix 'C++11 requires a space between literal and string macro' warning 2025-06-07 23:18:55 +03:00
indev 24ee56ce7a ceepeepee 17 :3 2025-06-07 23:15:55 +03:00
Alug 52f99dd9c1 fix span corruption due to wrong types being used
i did not realise srb2 changed this at some point to use fixed_t
2025-06-07 20:05:51 +02:00
Alug 6374fda570 convert i_system to cpp add missing exit for threading errors 2025-06-07 20:05:48 +02:00
Alug cdd2d6323e dont think we need this twice lel 2025-06-07 20:05:03 +02:00
Alug c508a7ea78 smol makefile stuff 2025-06-07 20:05:01 +02:00
Alug 1380a394c7 remove duped declaration 2025-06-07 20:04:58 +02:00
Alug 2c937099d4 this does nothing lel 2025-06-07 20:04:55 +02:00
Alug 0a936b3bba fix le sourcefile 2025-06-07 20:04:52 +02:00
Alug 0a31e0a65e use realloc for batching stuff
seems to strangely speed things up even
didnt think those happen often?
2025-06-07 11:55:52 +02:00
Alug 8627a18452 Merge pull request #182 from chromaticpipe/fixedhelp
Fixed help command
2025-06-07 10:54:36 +01:00
Alug be528adea5 thanks michaelsoft! 2025-06-07 10:21:25 +01:00
James R. 5eb4ed8391 R_FindPlane: fix offsets rotation overflow for non-sloped planes 2025-06-07 11:43:13 +02:00
James R 9a00d30c0c Do not factor height into sprite thickseg sorting 2025-06-07 11:43:10 +02:00
James R 71237c5e11 Check that top of sprite is above plane or bottom is below
This fixes slightly raised fofs drawing on top of sprites that should be in
front of them. Previously would check that the bottom of the object was above
the plane. Now also uses sprite offsets like the fof seg sorting does.
2025-06-07 11:43:07 +02:00
Alug 9c6e32a1ab HACK: dont pass wflags to c++
silences some annoying compiler complaints lel
2025-06-07 11:43:04 +02:00
Alug 1bc18801c8 cleanup the software drawers even more + unroll them
looks pretty clean now, not sure if i want to port the templates, this is good enough for now
2025-06-07 11:43:01 +02:00
Alug 221f2a956e tiny optimizations 2025-06-07 11:42:58 +02:00
Alug b450abdf4d simplify R_ExpandPlane 2025-06-07 11:42:55 +02:00
Alug d36eed3c09 convert r_segs to ceepeepee + overflow fix from RR R_DrawRepeatMaskedColumn
+ alot of cleanup
should more or less function the same, just alot less messy
2025-06-07 11:42:52 +02:00
Alug 43ee791d4a fix slopes and slope flat alignment
software slopes finally are sane........
fixes certain maps like stardust speedway looking like complete butt
need to test ogl, not sure if theres any real change there
2025-06-07 11:42:48 +02:00
Alug c921945922 cleanup software drawer handling stuff
mostly ported from rr
is alot more readable and less confusing
2025-06-07 11:42:45 +02:00
Alug 5f8c77e752 test: allow multithreading for masked planes
quite a neat speedup on some maps
needs testing
2025-06-07 01:20:52 +02:00
Alug 064db977aa HACK: move semaphores into the drawplane loop, to fix a few visual glitches
a bit of slowdown, but i have no clue what exactly causes shit, so this is the best solution for now i guess
2025-06-07 01:20:48 +02:00
Alug 5868cd9777 make drawcolum lightlists use realloc again lel
otherwise theres a crapton of overlapping memory lel
2025-06-07 01:20:44 +02:00
Alug b0ddde996a forgor this from removing screen size static array stuff lel 2025-06-07 01:20:41 +02:00
Alug e03c3766f0 forgor to free the mask heads lel 2025-06-07 01:20:37 +02:00
Alug 953c0d7451 convert r_things to ceepeepee 2025-06-07 01:20:34 +02:00
Alug 97b303c362 split skin stuff from r_things into r_skins
what a mess
2025-06-07 01:20:31 +02:00
Alug 2ffe736a20 smol cleanup 2025-06-07 01:20:28 +02:00
Alug 21f2032f34 save smol amount of fixed to double conversions in R_StoreWallRange
also adds those as actual functions in case we wanna use it for smth else
2025-06-06 17:37:55 +02:00
Alug 2f66207205 make this less ugly 2025-06-06 16:55:38 +02:00
Alug 5a14b09c1f cache ds->transmap for translucent span drawers
super slight speedup
2025-06-06 16:35:26 +02:00
Alug 7e9da92dbe dont redundantly clamp the sprites texturecolumn
we already take care of this in the lööp header
2025-06-06 16:35:23 +02:00
Alug a27550b95b fix R_ProjectSprite clipping checks overflowing
was causing sprites to disappear in some angles
2025-06-06 14:43:03 +02:00
Alug 556883487d optimize software hud drawing
from srb2classic adjusted to our drawers
2025-06-06 01:17:36 +02:00
Alug 96f8533479 dont check for wraps on 0 height textures in column drawers
slight speedup thx srb2classic!
2025-06-06 01:04:20 +02:00
Alug f3cca27448 cache vid.width in the column drawers
shit was really slow lel
2025-06-06 00:55:23 +02:00
indev 252563725d Make tiltlighting buffer thread_local 2025-06-06 01:42:15 +03:00
indev 9a934a55e2 Revert "ok fuck you tiltlighting static buffer it is"
This reverts commit 2a023246be.
2025-06-06 01:39:51 +03:00
Alug f07d5d381e fix the goddamn boolean 2025-06-06 00:19:23 +02:00
Alug 3faab66ef4 add toggle for software multithread 2025-06-06 00:04:42 +02:00
Alug 2a023246be ok fuck you tiltlighting static buffer it is 2025-06-06 00:04:39 +02:00
Alug 006e7fe8f8 move this 2025-06-06 00:04:36 +02:00
Alug 1a7ff21a04 fix some warnings and plane ripple 2025-06-06 00:04:33 +02:00
Alug 98cb0fdcb2 fix slopes and other shit 2025-06-06 00:04:30 +02:00
indev 1fd7e9cdac Add -lpthread into libs and cxxopts into c++ compilation flags 2025-06-06 00:04:27 +02:00
indev 0a2eac4d3a Add ifdef __cplusplus into hardware/hw_main.h 2025-06-06 00:04:24 +02:00
Alug 9ac6fffd4d busted ass multithreading for le soft 2025-06-06 00:04:19 +02:00
Alug da20f4a087 Merge branch 'newmakefiles' into softwarecrap 2025-06-06 00:04:14 +02:00
Alug dbf822ced9 dont draw precip in the skybox lel 2025-06-05 15:05:29 +02:00
Alug 095842f4aa smol cleanup the splat drawers
didnt knew we actually use em so kinda didnt care lel
2025-06-05 15:00:35 +02:00
Alug 8c290d7597 kill static buffer for tiltlighting, again
kinda ugly but gets the job done lel
2025-06-05 14:48:50 +02:00
Alug 8a6f4db9af fix precip not drawing 2025-06-05 14:48:47 +02:00
Alug 99186a86db port masked drawlists for software + portal visplanes
Note: need to check if we gotta readd portalcullsector for ogl portals, technically this is alot faster and fixes the occasional portal disappearing, but may introduce occasional visual bugs
2025-06-05 14:48:44 +02:00
Alug c67bf97f7b unglobalize drawspandata 2025-06-05 14:48:41 +02:00
Alug 33a1540fcd unglobalise drawcolumndata
from RRs multithread
will follow up with spandata
2025-06-05 14:48:38 +02:00
Alug 529b0d643a delet dc_hires 2025-06-05 01:41:55 +02:00
Alug 4576efbe5c remove FIXMEs from draw column stuff 2025-06-05 01:27:34 +02:00
Alug 185375ece1 use ternaries for column clamp
it is slightly faster for me lel
also lets us get rid of an extra variable
npow2min is also declared static as its always -1
2025-06-05 01:25:33 +02:00
Alug d11521954e move those around + remove NOWATER ifdef 2025-06-05 01:01:31 +02:00
Alug 41c4300ec2 split r_draw8 into r_drawcolumn and r_drawspan
+ remove the _8 from the "namespace" since we dont have highcolor stuff
2025-06-05 00:52:53 +02:00
Alug 51d5023f29 those can be just "while" lööps 2025-06-05 00:44:59 +02:00
Alug d2878f8834 set MAXVIDWIDTH and MAXVIDHEIGHT to 8192
should accomidate absolutely everything
2025-06-04 23:03:17 +02:00
Alug 7808159d23 get rid of static screen size buffers, alloc em to current screen size instead
mostly taken from srb2s any-resolution branch
2025-06-04 23:03:14 +02:00
Alug e759431948 clamp shit so vhs effect doesent do oob writes on some resolutions
shoddy way but fuckit
2025-06-04 20:46:12 +02:00
Alug 268ccce955 move ripple blit stuff into own function 2025-06-04 20:00:06 +02:00
Alug f2d3432bf5 make software ripple splitscreen checks less awful to look at 2025-06-04 18:48:33 +02:00
Alug 2da89f1946 remove ylookup, columnofs and topleft lookups
move screens array to "vid" struct
remove a bunch of unused stuff

this speeds up 4 player splitscreen ever so slighty
mostly just alot cleaner than the mess it was before
2025-06-04 15:55:46 +02:00
Alug 6153733df4 unroll span drawer loops 2025-06-04 15:55:43 +02:00
Alug d280b39f9f use floats flor slope drawing
idea from srb2classic
2025-06-04 15:55:40 +02:00
indev 236e7b8d45 Fix game rendering only first splitscreen player in opengl 2025-06-04 03:57:54 +03:00
chromaticpipe dcccf672c9 Truncate trailing zeroes in float CVars 2025-06-03 13:18:02 -05:00
Alug 03f81bed16 dont initialise those twice lol 2025-06-03 20:00:52 +02:00
chromaticpipe fc51c1ba88 Fix help command for CV_FLOAT CVars 2025-06-03 11:38:46 -05:00
Alug 83d20a72ab delet this since its mostly wrong anyways 2025-06-02 20:05:09 +02:00
indev d50c1ab6d7 dedi's do run got_mapcmd :p 2025-06-02 14:21:34 +03:00
Alug 984c2ff8d6 Merge pull request #175 from chromaticpipe/serverinfo
Display server information before connecting to it
2025-06-01 21:03:19 +01:00
chromaticpipe 74646acdca Options. 2025-05-31 16:27:34 -05:00
indev 45ffe87ba6 Add new music credit draw style, 'songcredits Box' 2025-05-31 22:27:17 +03:00
Alug 37eb8cfa57 shut up curl im already long 2025-05-31 21:01:57 +02:00
Alug a0f903f162 i like switches mhhhm 2025-05-31 21:01:53 +02:00
Alug f1f0782256 fix memoryleak in pk3 verify functions 2025-05-31 17:30:19 +02:00
Alug 0e9a825f63 some crap from ceepeepeecheck 2025-05-31 17:27:07 +02:00
Alug 5c53a90eea hack: reset musiccredits when changing gamestate
otherwise they may persist if theyve been currently displayed
2025-05-31 16:20:58 +02:00
Alug 55c6ba6d12 fix awayview join crash
player->awayviewmobj may not exist yet in some cases
2025-05-31 15:57:20 +02:00
Alug 6617382f54 Revert "reset the palette earlier during levelload"
This reverts commit 5e532a76cf.
2025-05-30 23:59:08 +02:00
chromaticpipe dd499a410f Very bad gamepad support 2025-05-30 13:30:47 -05:00
chromaticpipe c04ba992a7 Forgort something 2025-05-30 13:26:27 -05:00
chromaticpipe 27c053cd48 Add Server info screen, ported from SRB2Classic 2025-05-30 13:23:36 -05:00
Alug 7d68c0598c Fix underflow in consistancy checking code
https://git.srb2.org/Hanicef/SRB2Classic/-/commit/9f5686ef48956cd64ef92f737e59cbbaa27d8cf9
2025-05-30 02:54:48 +02:00
Alug 201c725dc7 cleanup d_main a little 2025-05-30 02:54:45 +02:00
Alug e47e58a982 fixup ceepeepee support 2025-05-29 21:40:15 +02:00
Alug c05068f22f why are those still here lel 2025-05-29 19:35:15 +02:00
Alug f5cb473f3d thanks windoze very cool part 2 2025-05-29 19:33:46 +02:00
Alug c5b72f24b5 thanks windoze very cool 2025-05-29 19:33:37 +02:00
Alug 57b2316c42 didnt mean to change this lel 2025-05-29 19:01:19 +02:00
Alug fe682a8071 only make screentexture for postprocess if we need to
gives quite a neat perfboost on the gpu side
2025-05-29 19:01:16 +02:00
Alug bf44a054a1 move HWR_GetTexturePalette calls
to after early returns/where they are used
2025-05-29 18:17:26 +02:00
Alug eca9c60d9b call HWR_LoadMapTextures in paletterender toggle callback
from srb2 pr
2025-05-29 18:17:23 +02:00
Alug cf42c35b9f add mo checks to automap stuff 2025-05-29 13:40:57 +02:00
Alug a364068abb add a bunch of checks for if G_BuildMapTitle returns NULL 2025-05-29 13:40:53 +02:00
Alug e88093d9cf no need for an else here 2025-05-29 12:30:07 +02:00
Alug 5e532a76cf reset the palette earlier during levelload
generally make this behave like srb2/rr again
2025-05-29 12:30:05 +02:00
Alug fb9c459269 readd cubeapply check here 2025-05-29 12:30:00 +02:00
Alug 7c34733eea add nofork parameter to dedibuild 2025-05-28 23:58:10 +02:00
Alug a6898bd1cd this memset is incorrect and does nothing 2025-05-28 22:12:00 +02:00
Alug ff474d18ee remove this
prob wrong assumption, our netcode sucks massive ass
2025-05-28 21:44:38 +02:00
Alug f15d3be263 forgor the hw state lel 2025-05-28 18:39:20 +02:00
Alug 19e5366c5b add wireframe mode for ogl 2025-05-28 18:31:55 +02:00
Alug 346dee019c fix compiler warning bout playeringame 2025-05-28 18:31:37 +02:00
Alug 18914f22f2 remove crappy memcpy redifine from md5 2025-05-28 18:31:33 +02:00
Alug 1219ecf818 check for 32bit with __SIZEOF_POINTER__ for precip drawdistance
thx @chromaticpipe for the tip!
2025-05-28 16:27:40 +02:00
Alug b6923d0d0d readd flexible array for softwarepatch columnofs
how did this ever work lel
2025-05-28 16:21:57 +02:00
Alug 393ade780c add missing "time" include from dedi i_system 2025-05-28 14:43:27 +01:00
indev 8b2e6ea17b libpeethread 2025-05-28 16:54:37 +03:00
Alug 8c31682723 smol adjustments for main 2025-05-28 15:43:21 +02:00
Alug 7c87b5259a port SRB2s new makefiles + add dedicated build (squashed)
also fix some of the new warnings
to make a dedicated build just pass DEDICATED=1 to the compiler
TODO:make this compatible with bluajit
2025-05-28 15:38:25 +02:00
Alug e8969b0645 dont always print openmpt version to console
just use I_OutputMsg instead
2025-05-27 18:31:20 +02:00
Alug 7932c1af6f Print the current SDL_mixer version
when initializing the sound system
2025-05-27 18:30:55 +02:00
Alug 95b4228d3c update windoze libbacktrace
never was updated since we added this 2 years ago lel
2025-05-26 11:03:56 +01:00
Alug a0ff44043f Merge branch 'Saturn' into Saturn-Next 2025-05-25 17:37:40 +02:00
196 changed files with 13816 additions and 8074 deletions

No files matched your search

+8 -7
View File
@@ -13,16 +13,17 @@ Win32_LIB_ASM_Release
*.dgb
*.debug
*.debug.txt
/bin/VC10/
/objs/VC10/
*.user
*.db
*.opendb
/.vs
/debian
/assets/debian
compile.sh
*.gz
.vscode/
out
build
/make
/bin
/build
/build/*
/CMakeUserPresets.json
/out
/objs/VC10
*.kate-swp
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-1
View File
@@ -1 +0,0 @@
/lsdlsrb2
-3
View File
@@ -1,3 +0,0 @@
/lsdlsrb2
/pnd
/*.mo
-1
View File
@@ -1 +0,0 @@
/lsdlsrb2
-1
View File
@@ -1 +0,0 @@
/lsdl2srb2kart
-4
View File
@@ -1,4 +0,0 @@
*.exe
*.mo
r_opengl.dll
*.bat
-4
View File
@@ -1,4 +0,0 @@
*.exe
*.mo
r_opengl.dll
*.bat
-3
View File
@@ -1,3 +0,0 @@
/srb2sdl.exe
/srb2win.exe
/r_opengl.dll
-4
View File
@@ -1,4 +0,0 @@
*.exe
*.mo
r_opengl.dll
*.bat
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
+9 -8
View File
@@ -1,5 +1,5 @@
/* backtrace.h -- Public header file for stack backtrace library.
Copyright (C) 2012-2020 Free Software Foundation, Inc.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without
@@ -54,13 +54,14 @@ struct backtrace_state;
invalid after this function returns.
As a special case, the ERRNUM argument will be passed as -1 if no
debug info can be found for the executable, but the function
requires debug info (e.g., backtrace_full, backtrace_pcinfo). The
MSG in this case will be something along the lines of "no debug
info". Similarly, ERRNUM will be passed as -1 if there is no
symbol table, but the function requires a symbol table (e.g.,
backtrace_syminfo). This may be used as a signal that some other
approach should be tried. */
debug info can be found for the executable, or if the debug info
exists but has an unsupported version, but the function requires
debug info (e.g., backtrace_full, backtrace_pcinfo). The MSG in
this case will be something along the lines of "no debug info".
Similarly, ERRNUM will be passed as -1 if there is no symbol table,
but the function requires a symbol table (e.g., backtrace_syminfo).
This may be used as a signal that some other approach should be
tried. */
typedef void (*backtrace_error_callback) (void *data, const char *msg,
int errnum);
Binary file not shown.
-8
View File
@@ -1,8 +0,0 @@
#All folders
SRB2.res
depend.dep
depend.ped
*.o
#VC9 folder only
/VC9/Win32
/VC9/x64
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
+13 -1
View File
@@ -228,6 +228,14 @@ set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.")
set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL
"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?
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
@@ -554,7 +562,11 @@ add_definitions(-DCMAKECONFIG)
# ${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})
message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(")
+348 -713
View File
File diff suppressed because it is too large. Load diff
+19
View File
@@ -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
+124
View File
@@ -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
+106
View File
@@ -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))))
+71
View File
@@ -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))
+47
View File
@@ -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
+16
View File
@@ -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
+76
View File
@@ -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
+71
View File
@@ -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
+93
View File
@@ -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,@)
+181
View File
@@ -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
+124
View File
@@ -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))
+97
View File
@@ -0,0 +1,97 @@
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_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_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_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
+8 -4
View File
@@ -197,7 +197,7 @@ static fixed_t scale_mtof = (fixed_t)INITSCALEMTOF;
// used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof)
static fixed_t scale_ftom;
static player_t *plr; // the player represented by an arrow
static player_t *plr = NULL; // the player represented by an arrow
static boolean followplayer = true; // specifies whether to follow the player around
@@ -237,7 +237,7 @@ static inline void AM_restoreScaleAndLoc(void)
m_x = old_m_x;
m_y = old_m_y;
}
else
else if (plr && plr->mo)
{
m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2;
m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2;
@@ -318,7 +318,8 @@ static void AM_initVariables(void)
break;
plr = &players[pnum];
if (plr != NULL && plr->mo != NULL)
if (plr && plr->mo)
{
m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2;
m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2;
@@ -340,7 +341,7 @@ static void AM_FrameBufferInit(void)
f_x = f_y = 0;
f_w = vid.width;
f_h = vid.height;
am_buf = screens[0];
am_buf = vid.screens[0];
}
//
@@ -597,6 +598,9 @@ static inline void AM_changeWindowScale(void)
static inline void AM_doFollowPlayer(void)
{
if (!plr || !plr->mo)
return;
if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y)
{
m_x = FTOM(MTOF(plr->mo->x >> FRACTOMAPBITS)) - m_w/2;
-1
View File
@@ -46,7 +46,6 @@ INT32 VID_SetMode(INT32 modenum)
vid.modenum = 0;
vid.width = 320;
vid.height = 240;
vid.bpp = 1;
vid.buffer = android_surface;
return 0;
}
-55
View File
@@ -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
+26
View File
@@ -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
+2
View File
@@ -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 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_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 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)
@@ -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 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_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 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)
+35 -15
View File
@@ -240,7 +240,6 @@ void COM_ImmedExecute(const char *ptext)
while (i < strlen(ptext))
{
quotes = 0;
for (j = 0; i < strlen(ptext); i++,j++)
{
@@ -817,12 +816,17 @@ static void COM_Help_f(void)
cvar = CV_FindVar(help);
if (cvar)
{
boolean floatmode = false;
const char *cvalue = NULL;
CONS_Printf("\x82""Variable %s:\n", cvar->name);
CONS_Printf(M_GetText(" flags: "));
if (cvar->flags & CV_SAVE)
CONS_Printf("AUTOSAVE ");
if (cvar->flags & CV_FLOAT)
{
CONS_Printf("FLOAT ");
floatmode = true;
}
if (cvar->flags & CV_NETVAR)
CONS_Printf("NETVAR ");
if (cvar->flags & CV_CALL)
@@ -832,30 +836,43 @@ static void COM_Help_f(void)
CONS_Printf("\n");
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,
cvar->PossibleValue[1].value);
i = 2;
}
if (!stricmp(cvar->PossibleValue[0].strvalue, "MIN") && !stricmp(cvar->PossibleValue[1].strvalue, "MAX"))
{
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);
while (cvar->PossibleValue[i].strvalue)
{
CONS_Printf(" %-2d : %s\n", cvar->PossibleValue[i].value,
cvar->PossibleValue[i].strvalue);
if (floatmode)
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)
cvalue = cvar->PossibleValue[i].strvalue;
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
CONS_Printf(" Current value: %d\n", cvar->value);
}
@@ -1026,7 +1043,10 @@ static void COM_Add_f(void)
}
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
CV_AddValue(cvar, atoi(COM_Argv(2)));
}
+8
View File
@@ -13,6 +13,10 @@
#ifndef __COMMAND_H__
#define __COMMAND_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "doomdef.h"
@@ -189,4 +193,8 @@ UINT8 CV_CheatsEnabled(void);
// Returns cvar by name. Exposed here for Lua.
consvar_t *CV_FindVar(const char *name);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __COMMAND_H__
-7
View File
@@ -1321,13 +1321,6 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...)
//
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(M_GetText("Press ENTER to continue\n"));
+1
View File
@@ -0,0 +1 @@
target_sourcefile(cpp)
+2
View File
@@ -0,0 +1,2 @@
memory.cpp
thread_pool.cpp
+71
View File
@@ -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();
}
+32
View File
@@ -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__
+192
View File
@@ -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__
+255
View File
@@ -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__
+346
View File
@@ -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();
}
+163
View File
@@ -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
View File
@@ -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__
+158 -35
View File
@@ -87,6 +87,9 @@ boolean serverrunning = false;
INT32 serverplayer = 0;
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
UINT8 playernode[MAXPLAYERS];
@@ -95,7 +98,7 @@ UINT8 playernode[MAXPLAYERS];
tic_t jointimeout = (3*TICRATE);
static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame?
#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?
#endif
static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout?
@@ -1068,6 +1071,7 @@ static void SV_RequireResynch(INT32 node)
// Initial setup
memset(resynch_sent[node], 0, MAXPLAYERS);
for (i = 0; i < MAXPLAYERS; ++i)
{
if (!playeringame[i]) // Player not in game so just drop it from required synch
@@ -1184,6 +1188,7 @@ typedef enum
#endif
CL_CONNECTED,
CL_ABORTED,
CL_VIEWSERVER,
CL_ASKFULLFILELIST,
CL_CONFIRMCONNECT,
#ifdef HAVE_CURL
@@ -1247,7 +1252,7 @@ static inline void CL_DrawConnectionStatus(void)
if (!menuactive) // menu already draws its own fade
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
&& cl_mode != CL_DOWNLOADHTTPFILES
#endif
@@ -1367,6 +1372,78 @@ static inline void CL_DrawConnectionStatus(void)
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
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)
{
INT32 dldlength;
@@ -1687,13 +1764,7 @@ static void SV_SendPlayerInfo(INT32 node)
for (i = 0; i < MSCOMPAT_MAXPLAYERS; i++)
{
if (i >= MAXPLAYERS)
{
netbuffer->u.playerinfo[i].node = 255;
continue;
}
if (playeringame[i] == UINT8_MAX || !playeringame[i])
if ((i >= MAXPLAYERS) || !playeringame[i])
{
netbuffer->u.playerinfo[i].node = 255; // This slot is empty.
continue;
@@ -1778,8 +1849,6 @@ static boolean SV_SendServerConfig(INT32 node)
memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins));
memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor));
memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers));
for (i = 0; i < MAXPLAYERS; i++)
{
netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i];
@@ -2476,6 +2545,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
if (i < 0)
return true;
}
joinnode = i;
// Quit here rather than downloading files and being refused later.
if (serverlist[i].info.numberofplayer >= serverlist[i].info.maxplayer)
@@ -2502,7 +2572,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
return true;
}
cl_mode = CL_CHECKFILES;
cl_mode = (cv_serverinfoscreen.value) ? CL_VIEWSERVER : CL_CHECKFILES;
}
else
{
@@ -2556,7 +2626,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
case CL_ASKFULLFILELIST:
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)
{
if (CL_AskFileList(fileneedednum))
@@ -2722,6 +2792,15 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
D_ProcessEvents(); //needed for menu system to receive inputs
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
if (!modeattacking && (key == KEY_ESCAPE || key == KEY_JOY1+1 || cl_mode == CL_ABORTED))
{
@@ -3275,7 +3354,7 @@ void CL_ClearPlayer(INT32 playernum)
P_RemoveMobj(players[playernum].mo);
}
memset(&players[playernum], 0, sizeof (player_t));
memset(&players[playernum], 0, sizeof(player_t));
}
//
@@ -4149,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}};
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_RemovePlayer(UINT8 **p, INT32 playernum);
@@ -4251,7 +4332,7 @@ static void ResetNode(INT32 node)
// SATURN
#ifdef SATURNPAK
is_client_saturn[node] = false;
resendingsavegame[node] = false;
resendingsavegame[node] = 0;
savegameresendcooldown[node] = 0;
gamestate_resend_counter[node] = 0;
#endif
@@ -4284,14 +4365,14 @@ void SV_ResetServer(void)
sprintf(player_names[i], "Player %d", i + 1);
}
memset(player_name_changes, 0, sizeof player_name_changes);
memset(player_name_changes, 0, sizeof(player_name_changes));
memset(playeringame, false, sizeof playeringame);
memset(playernode, UINT8_MAX, sizeof playernode);
memset(playeringame, false, sizeof(playeringame));
memset(playernode, UINT8_MAX, sizeof(playernode));
pingmeasurecount = 1;
memset(realpingtable, 0, sizeof realpingtable);
memset(playerpingtable, 0, sizeof playerpingtable);
memset(realpingtable, 0, sizeof(realpingtable));
memset(playerpingtable, 0, sizeof(playerpingtable));
ClearAdminPlayers();
@@ -4916,6 +4997,16 @@ static void HandleServerInfo(SINT8 node)
if (client && cl_mode > CL_SEARCHING && node == servernode)
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
#ifdef SATURNPAK
@@ -4952,7 +5043,7 @@ static void PT_CanReceiveGamestate(SINT8 node)
CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]);
SV_SendSaveGame(node, true); // Resend a complete game state
resendingsavegame[node] = true;
resendingsavegame[node] = 1;
}
#endif
@@ -5204,6 +5295,10 @@ static void HandlePacketFromAwayNode(SINT8 node)
case PT_CLIENTCMD:
break; // This is not an "unknown packet"
case PT_PLAYERINFO:
HandlePlayerInfo(node);
break;
case PT_SERVERTICS:
// Do not remove my own server (we have just get a out of order packet)
@@ -5324,18 +5419,18 @@ static void HandlePacketFromPlayer(SINT8 node)
/// \todo Use a separate cvar for that kind of timeout?
freezetimeout[node] = I_GetTime() + connectiontimeout;
// If we've alredy received a ticcmd for this tic, just submit it for the next one.
tic_t faketic = maketic;
if ((!!(netcmds[maketic % TICQUEUE][netconsole].angleturn & TICCMD_RECEIVED))
&& (maketic - firstticstosend < TICQUEUE - 1))
faketic++;
// Don't do anything for packets of type NODEKEEPALIVE?
// Sryder 2018/07/01: Update the freezetimeout still!
if (netbuffer->packettype == PT_NODEKEEPALIVE
|| netbuffer->packettype == PT_NODEKEEPALIVEMIS)
break;
// If we've alredy received a ticcmd for this tic, just submit it for the next one.
tic_t faketic = maketic;
if ((!!(netcmds[maketic % TICQUEUE][netconsole].angleturn & TICCMD_RECEIVED))
&& (maketic - firstticstosend < TICQUEUE - 1))
faketic++;
// Copy ticcmd
G_MoveTiccmd(&netcmds[faketic%TICQUEUE][netconsole], &netbuffer->u.clientpak.cmd, 1);
@@ -5395,11 +5490,11 @@ static void HandlePacketFromPlayer(SINT8 node)
// Check player consistancy during the level
if (gamestate == GS_LEVEL
&& (realstart > gametic - TICQUEUE+1 && realstart <= gametic)
&& (realstart <= gametic && realstart + TICQUEUE - 1 > gametic)
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)
&& (!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!
// this way we only send stuff to clients we know can use the gamestate resend
@@ -5409,7 +5504,7 @@ static void HandlePacketFromPlayer(SINT8 node)
// Tell the client we are about to resend them the gamestate
netbuffer->packettype = PT_WILLRESENDGAMESTATE;
HSendPacket(node, true, 0, 0);
resendingsavegame[node] = true;
resendingsavegame[node] = 1;
}
else if (UseVanillaSynch(node))
{
@@ -5425,10 +5520,13 @@ static void HandlePacketFromPlayer(SINT8 node)
}
if (cv_blamecfail.value)
{
CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"),
netconsole+1, player_names[netconsole],
consistancy[realstart%TICQUEUE],
SHORT(netbuffer->u.clientpak.consistancy));
}
DEBFILE(va("Restoring player %d (synch failure) [%update] %d!=%d\n",
netconsole, realstart, consistancy[realstart%TICQUEUE],
SHORT(netbuffer->u.clientpak.consistancy)));
@@ -5700,7 +5798,7 @@ static void HandlePacketFromPlayer(SINT8 node)
break;
}
//Update client ping table from the server.
// Update client ping table from the server.
if (client)
{
UINT8 i;
@@ -5736,7 +5834,7 @@ static void HandlePacketFromPlayer(SINT8 node)
break;
case PT_RECEIVEDGAMESTATE:
sendingsavegame[node] = false;
resendingsavegame[node] = false;
resendingsavegame[node] = 0;
savegameresendcooldown[node] = I_GetTime() + cv_resynchcooldown.value * TICRATE; // I_GetTime() + 5 * TICRATE;
break;
case PT_WILLRESENDGAMESTATE:
@@ -5796,8 +5894,9 @@ static void GetPackets(void)
}
#endif
if (netbuffer->packettype == PT_PLAYERINFO)
continue; // We do nothing with PLAYERINFO, that's for the MS browser.
/*if (netbuffer->packettype == PT_PLAYERINFO)
continue; // We do nothing with PLAYERINFO, that's for the MS browser. Not quite true anymore :p*/
// We also count unknown packets, hence "<="
if (netbuffer->packettype <= NUMPACKETTYPE)
@@ -6366,10 +6465,35 @@ static void SV_Maketic(void)
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 ticking;
#ifdef SATURNPAK
if (server)
SV_UpdateResendGamestateTimeout();
#endif
// the machine has lagged but it is not so bad
if (realtics > TICRATE/7) // FIXME: consistency failure!!
{
@@ -6510,7 +6634,6 @@ static inline void PingUpdate(void)
if (pingtimeout[i] > 0)
pingtimeout[i]--;
}
}
//kick lagging players... unless everyone but the server's ping sucks.
+14
View File
@@ -13,6 +13,10 @@
#ifndef __D_CLISRV__
#define __D_CLISRV__
#ifdef __cplusplus
extern "C" {
#endif
#include "d_ticcmd.h"
#include "d_net.h"
#include "d_netcmd.h"
@@ -577,6 +581,9 @@ extern boolean acceptnewnode;
extern SINT8 servernode;
extern char connectedservername[MAXSERVERNAME+1];
extern plrinfo playerinfo[MAXPLAYERS];
extern SINT8 joinnode;
void Command_Ping_f(void);
extern tic_t connectiontimeout;
extern tic_t jointimeout;
@@ -608,6 +615,8 @@ extern consvar_t cv_connectawaittime;
extern consvar_t cv_discordinvites;
extern consvar_t cv_serverinfoscreen;
// Used in d_net, the only dependence
//tic_t ExpandTics(INT32 low, tic_t basetic);
void D_ClientServerInit(void);
@@ -689,4 +698,9 @@ typedef struct rewind_s {
void CL_ClearRewinds(void);
rewind_t *CL_SaveRewindPoint(size_t demopos);
rewind_t *CL_RewindToTime(tic_t time);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
+156 -125
View File
@@ -73,6 +73,8 @@
#include "m_perfstats.h"
#include "k_kart.h"
#include "core/memory.h"
#include "lua_script.h"
#ifdef CMAKECONFIG
@@ -197,12 +199,10 @@ static void D_PadMenuScrollInput(UINT8 input)
// and pass it to the eventlist
static void D_GamePadMenuScrollTicker(void)
{
UINT8 i;
static UINT8 menuInputDelayTimer = 0;
if (dedicated)
return;
for (UINT8 i = 0; i < 4; i++)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (dpadscrollstate[i])
{
@@ -222,10 +222,10 @@ static void D_GamePadMenuScrollTicker(void)
static void D_DeviceLEDTick(void)
{
UINT8 i;
static UINT16 color[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
static UINT16 color[MAXSPLITSCREENPLAYERS] = {0};
static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {0};
if (dedicated || numcontrollers == 0)
if (numcontrollers == 0)
{
return;
}
@@ -252,7 +252,6 @@ static void D_DeviceLEDTick(void)
void D_ProcessEvents(void)
{
event_t *ev;
boolean eaten;
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
@@ -291,8 +290,10 @@ void D_ProcessEvents(void)
// Demo input:
if (demo.playback)
{
if (M_DemoResponder(ev))
continue; // demo ate the event
}
// console input
#ifdef HAVE_THREADS
@@ -317,6 +318,110 @@ void D_ProcessEvents(void)
// draw current display, possibly wiping it from the previous
//
static void D_Renderview(void)
{
UINT8 i;
if (automapactive)
return;
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++)
{
const boolean issplitscreen = (i > 0);
if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD)
{
viewssnum = i;
if (!issplitscreen) // Initialize for P1
{
viewwindowy = viewwindowx = 0;
objectsdrawn = 0;
}
#ifdef HWRENDER
if (rendermode == render_opengl)
{
HWR_RenderPlayerView();
R_RestoreLevelInterpolators();
continue;
}
#endif
if (issplitscreen) // Splitscreen-specific
{
switch (i)
{
case 1:
if (splitscreen > 1)
{
viewwindowx = viewwidth;
viewwindowy = 0;
}
else
{
viewwindowx = 0;
viewwindowy = viewheight;
}
break;
case 2:
viewwindowx = 0;
viewwindowy = viewheight;
break;
case 3:
viewwindowx = viewwidth;
viewwindowy = viewheight;
default:
break;
}
}
R_RenderPlayerView(&players[displayplayers[i]]);
}
if (!issplitscreen)
R_ApplyViewMorph();
V_DoPostProcessor(i, postimgparam[i]);
}
R_RestoreLevelInterpolators();
}
// wipegamestate can be set to -1 to force a wipe on the next draw
// added comment : there is a wipe eatch change of the gamestate
gamestate_t wipegamestate = GS_LEVEL;
@@ -327,7 +432,6 @@ static boolean D_Display(void)
boolean forcerefresh = false;
static boolean wipe = false;
INT32 wipedefindex = 0;
UINT8 i;
if (!dedicated)
{
@@ -366,6 +470,7 @@ static boolean D_Display(void)
{
// set for all later
wipedefindex = gamestate; // wipe_xxx_toblack
if (gamestate == GS_TITLESCREEN && wipegamestate != GS_INTRO)
wipedefindex = wipe_timeattack_toblack;
else if (gamestate == GS_INTERMISSION)
@@ -378,26 +483,28 @@ static boolean D_Display(void)
if (!dedicated)
{
// Fade to black first
if (gamestate != GS_LEVEL // fades to black on its own timing, always
&& wipedefs[wipedefindex] != UINT8_MAX)
if (gamestate != GS_LEVEL)
{
F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
F_WipeEndScreen();
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK);
ranwipe = true;
}
// Fade to black first
if (wipedefs[wipedefindex] != UINT8_MAX) // fades to black on its own timing, always
{
F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
F_WipeEndScreen();
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK);
ranwipe = true;
}
if (gamestate != GS_LEVEL && rendermode != render_none)
{
V_SetPaletteLump("PLAYPAL"); // Reset the palette
R_ReInitColormaps(0, LUMPERROR);
if (rendermode != render_none)
{
V_SetPaletteLump("PLAYPAL"); // Reset the palette
R_ReInitColormaps(0, LUMPERROR);
}
}
F_WipeStartScreen();
}
else //dedicated servers
else // dedicated servers
{
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK);
ranwipe = true;
@@ -405,7 +512,7 @@ static boolean D_Display(void)
}
}
if (dedicated) //bail out after wipe logic
if (dedicated) // bail out after wipe logic
return false;
// do buffered drawing
@@ -430,9 +537,6 @@ static boolean D_Display(void)
HU_Drawer();
break;
case GS_TIMEATTACK:
break;
case GS_INTRO:
F_IntroDrawer();
if (wipegamestate == (gamestate_t)-1)
@@ -484,6 +588,7 @@ static boolean D_Display(void)
HU_Erase();
HU_Drawer();
}
case GS_TIMEATTACK:
case GS_DEDICATEDSERVER:
case GS_NULL:
break;
@@ -492,89 +597,10 @@ static boolean D_Display(void)
if (gamestate == GS_LEVEL)
{
// draw the view directly
if (cv_renderview.value && !automapactive)
if (cv_renderview.value)
{
PS_START_TIMING(ps_rendercalltime);
R_ApplyLevelInterpolators(rendertimefrac);
for (i = 0; i <= splitscreen; i++)
{
if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD)
{
viewssnum = i;
if (i == 0) // Initialize for P1
{
viewwindowy = 0;
viewwindowx = 0;
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
objectsdrawn = 0;
}
#ifdef HWRENDER
if (rendermode == render_opengl)
HWR_RenderPlayerView();
else
#endif
if (rendermode != render_none)
{
if (i > 0) // Splitscreen-specific
{
switch (i)
{
case 1:
if (splitscreen > 1)
{
viewwindowx = viewwidth;
viewwindowy = 0;
}
else
{
viewwindowx = 0;
viewwindowy = viewheight;
}
M_Memcpy(ylookup, ylookup2, viewheight*sizeof (ylookup[0]));
break;
case 2:
viewwindowx = 0;
viewwindowy = viewheight;
M_Memcpy(ylookup, ylookup3, viewheight*sizeof (ylookup[0]));
break;
case 3:
viewwindowx = viewwidth;
viewwindowy = viewheight;
M_Memcpy(ylookup, ylookup4, viewheight*sizeof (ylookup[0]));
default:
break;
}
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
}
R_RenderPlayerView(&players[displayplayers[i]]);
if (i > 0)
M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0]));
}
}
}
if (rendermode == render_soft)
{
if (!splitscreen)
R_ApplyViewMorph();
for (i = 0; i <= splitscreen; i++)
{
V_DoPostProcessor(i, postimgparam[i]);
}
}
R_RestoreLevelInterpolators();
D_Renderview();
PS_STOP_TIMING(ps_rendercalltime);
}
@@ -582,8 +608,9 @@ static boolean D_Display(void)
{
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;
}
@@ -606,13 +633,8 @@ static boolean D_Display(void)
// draw pause pic
if (paused && cv_showhud.value && !demo.playback)
{
INT32 py;
patch_t *patch;
if (automapactive)
py = 4;
else
py = viewwindowy + 4;
patch = W_CachePatchName("M_PAUSE", PU_PATCH);
INT32 py = (automapactive) ? 4 : (viewwindowy + 4);
patch_t *patch = W_CachePatchName("M_PAUSE", PU_PATCH);
V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - patch->width)/2, py, V_SNAPTOTOP, patch);
}
@@ -620,7 +642,7 @@ static boolean D_Display(void)
V_DrawFadeScreen(TC_RAINBOW, (leveltime & 0x20) ? SKINCOLOR_PASTEL : SKINCOLOR_MOONSLAM);
// vid size change is now finished if it was on...
vid.recalc = 0;
vid.recalc = false;
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
@@ -752,9 +774,11 @@ void D_SRB2Loop(void)
precise_t enterprecise = I_GetPreciseTime();
precise_t finishprecise = enterprecise;
Z_Frame_Reset();
// 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()));
capbudget = (precise_t) budget;
capbudget = (precise_t)budget;
boolean ranwipe = false;
@@ -824,12 +848,15 @@ void D_SRB2Loop(void)
doDisplay = true;
}
if (menuactive)
if (!dedicated)
{
D_GamePadMenuScrollTicker();
}
if (menuactive)
{
D_GamePadMenuScrollTicker();
}
D_DeviceLEDTick();
D_DeviceLEDTick();
}
}
if (interp)
@@ -841,7 +868,9 @@ void D_SRB2Loop(void)
ps_interp_frac.value.p = (precise_t)((FIXED_TO_FLOAT(g_time.timefrac)) * 1000.0f);
ps_interp_lag.value.p = (precise_t)((deltasecs) * 1000.0f);
if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped)
const boolean lagging = ((deltatics >= 1.0) || hu_stopped);
if (!(paused || P_AutoPause()) && !lagging)
{
rendertimefrac = g_time.timefrac;
}
@@ -850,7 +879,7 @@ void D_SRB2Loop(void)
rendertimefrac = FRACUNIT;
}
if ((deltatics < 1.0) && !hu_stopped)
if (!lagging)
{
rendertimefrac_unpaused = g_time.timefrac;
}
@@ -923,7 +952,7 @@ void D_SRB2Loop(void)
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.
@@ -1607,7 +1636,9 @@ void D_SRB2Main(void)
#endif
// for dedicated server
#if !defined (DEDICATED)
dedicated = M_CheckParm("-dedicated") != 0;
#endif
strcpy(title, "SRB2Kart");
strcpy(srb2, "SRB2Kart");
+8
View File
@@ -14,6 +14,10 @@
#ifndef __D_MAIN__
#define __D_MAIN__
#ifdef __cplusplus
extern "C" {
#endif
#include "d_event.h"
#include "w_wad.h" // for MAX_WADFILES
@@ -90,4 +94,8 @@ const char *D_Home(void);
//
void D_StartTitle(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif //__D_MAIN__
+8 -2
View File
@@ -18,6 +18,10 @@
#ifndef __D_NET__
#define __D_NET__
#ifdef __cplusplus
extern "C" {
#endif
// Max computers in a game
// 127 is probably as high as this can go, because
// 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 boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game
extern boolean serverrunning;
void Net_AckTicker(void);
// If reliable return true if packet sent, 0 else
@@ -65,4 +67,8 @@ void Net_SendAcks(INT32 node);
void Net_WaitAllAckReceived(UINT32 timeout);
const char *Net_GetPacketName(UINT8 packettype);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
+12 -14
View File
@@ -204,11 +204,6 @@ static void Command_Archivetest_f(void);
// 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 autobalance_cons_t[] = {{0, "MIN"}, {4, "MAX"}, {0, NULL}};
@@ -216,11 +211,8 @@ static CV_PossibleValue_t teamscramble_cons_t[] = {{0, "Off"}, {1, "Random"}, {2
static CV_PossibleValue_t startingliveslimit_cons_t[] = {{1, "MIN"}, {99, "MAX"}, {0, NULL}};
static CV_PossibleValue_t sleeping_cons_t[] = {{0, "MIN"}, {1000/TICRATE, "MAX"}, {0, NULL}};
static CV_PossibleValue_t competitionboxes_cons_t[] = {{0, "Normal"}, {1, "Random"}, {2, "Teleports"},
{3, "None"}, {0, NULL}};
static CV_PossibleValue_t matchboxes_cons_t[] = {{0, "Normal"}, {1, "Random"}, {2, "Non-Random"},
{3, "None"}, {0, NULL}};
static CV_PossibleValue_t competitionboxes_cons_t[] = {{0, "Normal"}, {1, "Random"}, {2, "Teleports"}, {3, "None"}, {0, NULL}};
static CV_PossibleValue_t matchboxes_cons_t[] = {{0, "Normal"}, {1, "Random"}, {2, "Non-Random"}, {3, "None"}, {0, NULL}};
//static CV_PossibleValue_t chances_cons_t[] = {{0, "MIN"}, {9, "MAX"}, {0, NULL}};
static CV_PossibleValue_t match_scoring_cons_t[] = {{0, "Normal"}, {1, "Classic"}, {0, NULL}};
@@ -305,14 +297,12 @@ consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS] = {
{"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] = {
{"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_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}
};
#endif
#if defined (HAVE_SDL)
consvar_t cv_joyscale[MAXSPLITSCREENPLAYERS] = {
@@ -905,6 +895,7 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_netticbuffer);
CV_RegisterVar(&cv_mindelay);
CV_RegisterVar(&cv_gentlemens);
CV_RegisterVar(&cv_serverinfoscreen);
#ifdef NETGAME_DEVMODE
CV_RegisterVar(&cv_fishcake);
@@ -1034,6 +1025,8 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_scr_width);
CV_RegisterVar(&cv_scr_height);
CV_RegisterVar(&cv_parallelsoftware);
CV_RegisterVar(&cv_soundtest);
CV_RegisterVar(&cv_perfstats);
@@ -2777,7 +2770,7 @@ static void Command_Map_f(void)
// G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer
else
{
if (!mapheaderinfo[newmapnum-1] || mapheaderinfo[newmapnum-1] == NULL)
if (!mapheaderinfo[newmapnum-1])
{
CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum));
Z_Free(realmapname);
@@ -3031,9 +3024,14 @@ static void Command_ReplayMarker(void)
adjustedleveltime = 0;
char *title = G_BuildMapTitle(gamemap);
snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername);
if (title)
{
snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername);
Z_Free(title);
}
else
snprintf(demo.titlename, 64, "[%i:%02d/%.5s]", G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername);
CONS_Printf("Replay will be saved!\n");
}
+13
View File
@@ -15,8 +15,17 @@
#ifndef __D_NETCMD__
#define __D_NETCMD__
#ifdef __cplusplus
extern "C" {
#endif
#include "command.h"
void SendWeaponPref(void);
void SendWeaponPref2(void);
void SendWeaponPref3(void);
void SendWeaponPref4(void);
// console vars
extern consvar_t cv_playername;
extern consvar_t cv_playercolor;
@@ -318,4 +327,8 @@ void D_SetPassword(const char *pw);
// used for the player setup menu
UINT8 CanChangeSkin(INT32 playernum);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
+8
View File
@@ -111,7 +111,9 @@ static fileused_t transferFiles[UINT8_MAX + 1];
// Receiver structure
INT32 fileneedednum; // Number of files needed to join the server
fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files
#ifdef HAVE_THREADS
static I_mutex downloadmutex;
#endif
char downloaddir[512] = "DOWNLOAD";
file_download_t filedownload;
@@ -1351,14 +1353,18 @@ void CURLAbortFile(void)
{
filedownload.http_running = false;
#ifdef HAVE_THREADS
// lock and unlock to wait for the download thread to exit
I_lock_mutex(&downloadmutex);
I_unlock_mutex(downloadmutex);
#endif
}
void CURLGetFile(void)
{
#ifdef HAVE_THREADS
I_lock_mutex(&downloadmutex);
#endif
CURLMcode mc; /* return code used by curl_multi_wait() */
CURLcode easyres; /* Return from easy interface */
CURLMsg *m; /* for picking up messages with the transfer status */
@@ -1453,7 +1459,9 @@ void CURLGetFile(void)
}
filedownload.http_running = false;
#ifdef HAVE_THREADS
I_unlock_mutex(downloadmutex);
#endif
}
HTTP_login *
+8
View File
@@ -13,6 +13,10 @@
#ifndef __D_NETFIL__
#define __D_NETFIL__
#ifdef __cplusplus
extern "C" {
#endif
#include "d_clisrv.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);
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __D_NETFIL__
+108
View File
@@ -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)
+7
View File
@@ -0,0 +1,7 @@
i_system.c
i_main.c
i_video.c
i_sound.c
i_threads.c
dosstr.c
endtxt.c
+38
View File
@@ -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
+234
View File
@@ -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);
}
+24
View File
@@ -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
+238
View File
@@ -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;
}
+339
View File
@@ -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
+364
View File
@@ -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
+154
View File
@@ -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;
}
+10 -4
View File
@@ -388,7 +388,7 @@ static void DRPC_GotServerIP(UINT32 address)
--------------------------------------------------*/
static const char *DRPC_GetServerIP(void)
{
const char *address;
const char *address;
// If you're connected
if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL)
@@ -489,7 +489,7 @@ void DRPC_UpdatePresence(void)
{
#endif
discordPresence.state = "Private";
#ifdef MASTERSERVER
#ifdef MASTERSERVER
}
#endif
@@ -571,9 +571,15 @@ void DRPC_UpdatePresence(void)
{
// Map name on tool tip
char *title = G_BuildMapTitle(gamemap);
snprintf(mapname, 48, "Map: %s", title);
if (title)
{
snprintf(mapname, 48, "Map: %s", title);
Z_Free(title);
}
else
snprintf(mapname, 48, "Map: UNKNOWN");
discordPresence.largeImageText = mapname;
Z_Free(title);
}
if (gamestate == GS_LEVEL && Playing())
+18
View File
@@ -58,6 +58,9 @@
// warning C4152: nonstandard extension, function/data pointer conversion in expression
// warning C4213: nonstandard extension used : cast on l-value
#ifdef __cplusplus
extern "C" {
#endif
#include "doomtype.h"
@@ -524,12 +527,15 @@ UINT32 quickncasehash (const char *p, size_t n)
return x;
}
#ifndef __cplusplus
#ifndef min // Double-Check with WATTCP-32's cdefs.h
#define min(x, y) (((x) < (y)) ? (x) : (y))
#endif
#ifndef max // Double-Check with WATTCP-32's cdefs.h
#define max(x, y) (((x) > (y)) ? (x) : (y))
#endif
#endif
#ifndef CLAMP
#define CLAMP(x, y, z) ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x)))
#endif
@@ -560,6 +566,14 @@ UINT32 quickncasehash (const char *p, size_t n)
#define UNLIKELY(x) (x)
#endif
#ifdef __cplusplus
#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
#define restrict __restrict
#else
#define restrict
#endif
#endif
// An assert-type mechanism.
#ifdef PARANOIA
#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
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __DOOMDEF__
+1 -1
View File
@@ -125,7 +125,7 @@ extern boolean lastdraw;
extern INT32 postimgparam[MAXSPLITSCREENPLAYERS];
extern INT32 viewwindowx, viewwindowy;
extern INT32 viewwidth, scaledviewwidth;
extern INT32 viewwidth;
extern boolean gamedataloaded;
+23 -16
View File
@@ -17,6 +17,10 @@
#ifndef __DOOMTYPE__
#define __DOOMTYPE__
#ifdef __cplusplus
extern "C" {
#endif
#if defined (_WIN32)
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
@@ -100,8 +104,10 @@ typedef long ssize_t;
#define strnicmp(x,y,n) strncasecmp(x,y,n)
#endif
#ifndef __cplusplus
char *strcasestr(const char *in, const char *what);
#define stristr strcasestr
#endif
#if defined (macintosh) //|| defined (__APPLE__) //skip all boolean/Boolean crap
#define true 1
@@ -156,22 +162,19 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
/* Boolean type definition */
// \note __BYTEBOOL__ used to be set above if "macintosh" was defined,
// if macintosh's version of boolean type isn't needed anymore, then isn't this macro pointless now?
#ifndef __BYTEBOOL__
#define __BYTEBOOL__
//faB: clean that up !!
#if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward
#include "stdbool.h"
#elif defined (_WIN32)
#define false FALSE // use windows types
#define true TRUE
#define boolean BOOL
#else
typedef enum {false, true} boolean;
#endif
#endif // __BYTEBOOL__
#ifndef _WIN32
#include <stdbool.h>
// dont use stdbools _BOOL type
// its smaller (1 byte) than the old interger bool (4 bytes)
// which results in packed struct sizes being mismatched between vanilla and this
// however we gotta still include stdbool cause since c23 true and false are keywords
// which we cant use as enumeration constants
typedef int32_t boolean;
#else
#define false FALSE
#define true TRUE
#define boolean BOOL
#endif
/* 7.18.2.1 Limits of exact-width integer types */
#ifndef INT8_MIN
@@ -385,4 +388,8 @@ unset_bit_array (bitarray_t * const array, const int value)
typedef UINT64 precise_t;
#ifdef __cplusplus
} // extern "C"
#endif
#endif //__DOOMTYPE__
+3 -2
View File
@@ -531,8 +531,8 @@ static const char *credits[] = {
"\"Xyzzy\"",
"\"Chearii\"",
" ",
"\"Sunflower\" aka \"AnimeSonic\"",
"\"Yuz\" aka \"Yuzler\"",
"\"Sunflower\"",
"\"Yuz\"",
"\"Democrab\"",
"\"EXpand\"",
"\"Nexit\"",
@@ -543,6 +543,7 @@ static const char *credits[] = {
"\"Achii\"",
"\"Anonimus\"",
"\"scizor300\"",
"\"Lugent\"",
"",
"\1Special Thanks",
"SEGA",
+3 -3
View File
@@ -313,7 +313,7 @@ void F_WipeStartScreen(void)
return;
}
#endif
wipe_scr_start = screens[3];
wipe_scr_start = vid.screens[3];
I_ReadScreen(wipe_scr_start);
#endif
}
@@ -330,7 +330,7 @@ void F_WipeEndScreen(void)
return;
}
#endif
wipe_scr_end = screens[4];
wipe_scr_end = vid.screens[4];
I_ReadScreen(wipe_scr_end);
V_DrawBlock(0, 0, 0, vid.width, vid.height, wipe_scr_start);
#endif
@@ -353,7 +353,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
// Init the wipe
WipeInAction = true;
wipe_scr = screens[0];
wipe_scr = vid.screens[0];
// lastwipetic should either be 0 or the tic we last wiped
// on for fade-to-black
+8
View File
@@ -4,6 +4,10 @@
#ifndef __FILESRCH_H__
#define __FILESRCH_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "doomdef.h"
#include "d_netfil.h"
#include "m_menu.h" // MAXSTRINGLENGTH
@@ -96,4 +100,8 @@ void closefilemenu(boolean validsize);
void searchfilemenu(char *tempname);
boolean preparefilemenu(boolean samedepth, boolean replayhut);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __FILESRCH_H__
+42 -33
View File
@@ -385,7 +385,8 @@ consvar_t cv_consolechat = {"chatmode", "Window", CV_SAVE, consolechat_cons_t, N
consvar_t cv_pauseifunfocused = {"pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
// Display song credits
consvar_t cv_songcredits = {"songcredits", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t songcredits_cons_t[] = {{0, "Off"}, {1, "Default"}, {2, "Box"}, {0, NULL}};
consvar_t cv_songcredits = {"songcredits", "Default", CV_SAVE, songcredits_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
// Show "FREE PLAY" when you're alone. :(
consvar_t cv_showfreeplay = { "showfreeplay", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -3998,7 +3999,6 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
}
}
char *G_BuildMapTitle(INT32 mapnum)
{
char *title = NULL;
@@ -5465,33 +5465,36 @@ void G_GhostTicker(void)
break;
}
}
if (type == MT_GHOST)
if (type != -1)
{
mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us
mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<<FF_TRANSSHIFT; // P_SpawnGhostMobj sets trans50, we want trans60
}
else
{
mobj = P_SpawnMobj(g->mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK);
mobj->sprite = states[mobjinfo[type].spawnstate].sprite;
mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<<FF_TRANSSHIFT;
mobj->tics = -1; // nope.
mobj->color = g->mo->color;
if (g->mo->eflags & MFE_VERTICALFLIP)
if (type == MT_GHOST)
{
mobj->flags2 |= MF2_OBJECTFLIP;
mobj->eflags |= MFE_VERTICALFLIP;
mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us
mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<<FF_TRANSSHIFT; // P_SpawnGhostMobj sets trans50, we want trans60
}
P_SetScale(mobj, g->mo->scale);
mobj->destscale = g->mo->scale;
else
{
mobj = P_SpawnMobj(g->mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK);
mobj->sprite = states[mobjinfo[type].spawnstate].sprite;
mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<<FF_TRANSSHIFT;
mobj->tics = -1; // nope.
mobj->color = g->mo->color;
if (g->mo->eflags & MFE_VERTICALFLIP)
{
mobj->flags2 |= MF2_OBJECTFLIP;
mobj->eflags |= MFE_VERTICALFLIP;
}
P_SetScale(mobj, g->mo->scale);
mobj->destscale = g->mo->scale;
}
mobj->floorz = mobj->z;
mobj->ceilingz = mobj->z+mobj->height;
P_UnsetThingPosition(mobj);
mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up...
P_SetThingPosition(mobj);
mobj->fuse = 8;
P_SetTarget(&mobj->target, g->mo);
}
mobj->floorz = mobj->z;
mobj->ceilingz = mobj->z+mobj->height;
P_UnsetThingPosition(mobj);
mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up...
P_SetThingPosition(mobj);
mobj->fuse = 8;
P_SetTarget(&mobj->target, g->mo);
}
if (ziptic & EZT_HIT)
{ // Spawn hit poofs for killing things!
@@ -6068,15 +6071,19 @@ void G_BeginRecording(void)
char *title = G_BuildMapTitle(gamemap);
// Print to a separate temp buffer instead of demo.titlename, so we can use it in M_TextInputSetString
snprintf(demotitlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername);
if (title)
{
snprintf(demotitlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername);
Z_Free(title);
}
else
snprintf(demotitlename, 64, "%s", modeattacking ? "Time Attack" : connectedservername);
// Init just in case it isn't initialized already
M_TextInputInit(&demo.titlenameinput, demo.titlename, sizeof(demo.titlename));
// This will indirectly assign to demo.titlename too
M_TextInputSetString(&demo.titlenameinput, demotitlename);
Z_Free(title);
}
// demo checksum
@@ -8117,9 +8124,6 @@ void G_SaveDemo(void)
UINT8 *p = demobuf.buffer+16; // after version
UINT32 length;
#ifdef NOMD5
UINT8 i;
#endif
// Ensure extrainfo pointer is always available, even if no info is present.
if (demoinfo_p && *(UINT32 *)demoinfo_p == 0)
@@ -8140,7 +8144,7 @@ void G_SaveDemo(void)
size_t i, strindex = 0;
boolean dash = true;
for (i = 0; i < 127 && demo.titlename[i]; i++)
for (i = 0; demo.titlename[i] && i < 127; i++)
{
if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') ||
(demo.titlename[i] >= '0' && demo.titlename[i] <= '9'))
@@ -8174,7 +8178,7 @@ void G_SaveDemo(void)
length = *(UINT32 *)demoinfo_p;
WRITEUINT32(demoinfo_p, length);
#ifdef NOMD5
for (i = 0; i < 16; i++, p++)
for (UINT8 k = 0; k < 16; k++, p++)
*p = M_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct.
#else
// Make a checksum of everything after the checksum in the file up to the end of the standard data. Extrainfo is freely modifiable.
@@ -8231,6 +8235,11 @@ boolean G_DemoTitleResponder(event_t *ev)
void G_SetGamestate(gamestate_t newstate)
{
gamestate = newstate;
//HACK: reset musiccredits whenever we change gamestate
// since we allow them to run everywhere now
S_ResetMusicCredit();
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
#endif
+8
View File
@@ -14,6 +14,10 @@
#ifndef __G_GAME__
#define __G_GAME__
#ifdef __cplusplus
extern "C" {
#endif
#include "doomdef.h"
#include "doomstat.h"
#include "d_event.h"
@@ -484,4 +488,8 @@ void G_AddMapToBuffer(INT16 map);
void G_FixCamera(UINT8 view);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
+1 -1
View File
@@ -1030,7 +1030,7 @@ INT32 G_KeyStringtoNum(const char *keystr)
if (!keystr[0])
return 0;
if (!keystr[0] || (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z'))
if (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z')
return keystr[0];
if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9')
+14
View File
@@ -0,0 +1,14 @@
hw_bsp.c
hw_draw.c
hw_main.c
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
+13 -32
View File
@@ -89,32 +89,23 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
{
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)
{
PolygonArrayEntry* new_array;
// ran out of space, make new array double the size
// ran out of space, double the array size
polygonArrayAllocSize *= 2;
new_array = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry));
memcpy(new_array, polygonArray, polygonArraySize * sizeof(PolygonArrayEntry));
free(polygonArray);
polygonArray = new_array;
polygonArray = realloc(polygonArray, polygonArrayAllocSize * sizeof(PolygonArrayEntry));
// also need to redo the index array, dont need to copy it though
free(polygonArraySorted);
polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *));
polygonArraySorted = realloc(polygonArraySorted, polygonArrayAllocSize * sizeof(PolygonArrayEntry*));
}
while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize)
{
FOutVector* new_array;
// need more space for vertices in unsortedVertexArray
unsortedVertexArrayAllocSize *= 2;
new_array = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
memcpy(new_array, unsortedVertexArray, unsortedVertexArraySize * sizeof(FOutVector));
free(unsortedVertexArray);
unsortedVertexArray = new_array;
unsortedVertexArray = realloc(unsortedVertexArray, unsortedVertexArrayAllocSize * sizeof(FOutVector));
}
// add the polygon data to the arrays
@@ -124,7 +115,7 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
polygonArray[polygonArraySize].numVerts = iNumPts;
polygonArray[polygonArraySize].polyFlags = PolyFlags;
polygonArray[polygonArraySize].texture = current_texture;
polygonArray[polygonArraySize].shader = (shader_target != -1) ? HWR_GetShaderFromTarget(shader_target) : shader_target;
polygonArray[polygonArraySize].shader = (shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target;
polygonArray[polygonArraySize].horizonSpecial = horizonSpecial;
polygonArraySize++;
@@ -140,8 +131,8 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
static int comparePolygons(const void *p1, const void *p2)
{
PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1;
PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2;
const PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1;
const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2;
int diff;
INT64 diff64;
@@ -177,9 +168,7 @@ static int comparePolygons(const void *p1, const void *p2)
diff = poly1->surf.LightInfo.fade_end - poly2->surf.LightInfo.fade_end;
if (diff != 0) return diff;
diff = poly1->surf.LightInfo.directional - poly2->surf.LightInfo.directional;
return diff;
return poly1->surf.LightInfo.directional - poly2->surf.LightInfo.directional;
}
static int comparePolygonsNoShaders(const void *p1, const void *p2)
@@ -328,19 +317,11 @@ void HWR_RenderBatches(void)
// probably never will this loop run more than once though
while (finalVertexWritePos + numVerts > finalVertexArrayAllocSize)
{
FOutVector* new_array;
unsigned int* new_index_array;
finalVertexArrayAllocSize *= 2;
new_array = malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
memcpy(new_array, finalVertexArray, finalVertexWritePos * sizeof(FOutVector));
free(finalVertexArray);
finalVertexArray = new_array;
finalVertexArray = realloc(finalVertexArray, finalVertexArrayAllocSize * sizeof(FOutVector));
// also increase size of index array, 3x of vertex array since
// going from fans to triangles increases vertex count to 3x
new_index_array = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32));
memcpy(new_index_array, finalVertexIndexArray, finalIndexWritePos * sizeof(UINT32));
free(finalVertexIndexArray);
finalVertexIndexArray = new_index_array;
finalVertexIndexArray = realloc(finalVertexIndexArray, finalVertexArrayAllocSize * 3 * sizeof(UINT32));
}
// write the vertices of the polygon
memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[entry->vertsIndex],
@@ -396,8 +377,8 @@ void HWR_RenderBatches(void)
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba ||
currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level ||
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start ||
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end ||
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start ||
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end ||
currentSurfaceInfo.LightInfo.directional != nextSurfaceInfo.LightInfo.directional)
{
changeState = true;
+14 -9
View File
@@ -46,12 +46,16 @@ RGBA_t *HWR_GetTexturePalette(void)
static INT32 format2bpp(GLTextureFormat_t format)
{
if (format == GL_TEXFMT_RGBA)
return 4;
else if (format == GL_TEXFMT_ALPHA_INTENSITY_88 || format == GL_TEXFMT_AP_88)
return 2;
else
return 1;
switch (format)
{
case GL_TEXFMT_RGBA:
return 4;
case GL_TEXFMT_ALPHA_INTENSITY_88:
case GL_TEXFMT_AP_88:
return 2;
default:
return 1;
}
}
// This code was originally placed directly in HWR_DrawPatchInCache.
@@ -221,8 +225,6 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
if (texture->width <= 0 || texture->height <= 0)
return;
palette = HWR_GetTexturePalette();
x1 = patch->originx;
width = SHORT(realpatch->width);
height = SHORT(realpatch->height);
@@ -234,6 +236,8 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
if (patch->originy > texture->height || (patch->originy + height) < 0)
return; // patch not located within texture's y bounds, ignore
palette = HWR_GetTexturePalette();
// patch is actually inside the texture!
// now check if texture is partly off-screen and adjust accordingly
@@ -323,7 +327,6 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
boolean skyspecial = false; // poor hack for Legacy large skies..
RGBA_t *palette;
palette = HWR_GetTexturePalette();
texture = textures[texnum];
@@ -361,6 +364,8 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
INT32 j;
RGBA_t col;
palette = HWR_GetTexturePalette();
col = palette[HWR_CHROMAKEY_EQUIVALENTCOLORINDEX];
for (idx = 0, j = 0; j < blockheight; j++)
Loaded 100 of 196 files, more files were not shown because too many files have changed in this diff. Show more