Compare commits

...
128 Commits
Author SHA1 Message Date
lug420 e6a1e58405 uaaagheue 2023-09-18 17:14:59 +02:00
lug420 ea10c9ac13 v3 2023-09-18 16:00:19 +02:00
indev e6d3f3f27c Merge pull request #72 from Indev450/localskins
Localskins
2023-09-18 16:52:11 +03:00
indev f713b7fb60 Merge pull request #71 from Indev450/paletteshader
Paletteshader
2023-09-18 16:51:58 +03:00
indev c35a542d60 Merge pull request #70 from Indev450/slopetexture
Slopetexture
2023-09-18 16:51:45 +03:00
indev e6c699faf4 Merge pull request #69 from Indev450/lua-more-rotation-fields
Add mo.rollsum and player.sliproll fields. Rendering and frame interp…
2023-09-18 16:51:34 +03:00
indev f626b4b031 Merge pull request #61 from Indev450/animatedvotescreens
Animatedvotescreens
2023-09-18 16:51:23 +03:00
indev aed81c0ff5 Merge pull request #60 from Indev450/sdldraganddrop-utf8-on-windows
Sdldraganddrop utf8 on windows
2023-09-18 16:51:07 +03:00
indev 1354f2f302 Merge pull request #59 from Indev450/softwarestuff
Softwarestuff
2023-09-18 16:50:49 +03:00
indev 8ea5d0f729 Merge pull request #58 from Indev450/no-discordrpc-when-cvar-is-off
No discordrpc when cvar is off
2023-09-18 16:50:29 +03:00
lug420 ab93865255 make flashpals toggable
could be a bit distracting for some
2023-09-18 15:39:13 +02:00
hayaunderscore 1ecdd3dae6 fix compilation error 2023-09-18 14:49:56 +02:00
hayaunderscore ddcd6b0d31 Redo localskin command 2023-09-18 14:49:19 +02:00
alufolie91 5196f1c5b9 Merge remote-tracking branch 'origin/Saturn' into localskins 2023-09-18 14:47:56 +02:00
Alug 9dd6ec718f Merge pull request #68 from hayaunderscore/paletteshader
`P_FlashPal` support in palette renderering
2023-09-17 01:52:12 +02:00
hayaunderscore 69237d6a3a Fix stuttering and gamma 2023-09-17 07:28:47 +08:00
hayaunderscore 426cbee752 Make flashpals work
I hate this
2023-09-17 07:28:34 +08:00
lug420 c2f3486e6d Revert "(hopefully) make flashpals work with palette rendering"
This reverts commit e4a575cc5e.
2023-09-15 21:36:05 +02:00
lug420 e4a575cc5e (hopefully) make flashpals work with palette rendering 2023-09-15 20:54:57 +02:00
lug420 f00c9d8c23 dont do this in dedi
unecessary if someone runs this thing in dedi mode
2023-09-15 20:54:25 +02:00
lug420 f70f7152ab let the thing do its thing
fixes switching of paletterenderer thing
2023-09-14 20:24:36 +02:00
lug420 8c7f35fa29 absolute hell
lighttable sorting was on even with the palette shader disabled, but, we dont need that shit for non palette renderer mode

hope this shit doesent break anything ever pls
2023-09-14 19:17:46 +02:00
lug420 fe74e69da6 dont need this 2023-09-14 18:42:35 +02:00
alufolie91 c170f53948 Merge remote-tracking branch 'origin/slopetexture' into paletteshader 2023-09-14 18:32:10 +02:00
alufolie91 13fd825bcf hackiest shit to make custom shaders not kill palette shader
this is so super dumb its unreal
but it works
2023-09-14 03:43:11 +02:00
indev 8ee4fc2fa1 Oops used upscaled image >< 2023-09-14 00:18:22 +03:00
indev 679a8387c9 Add logo (WIP) 2023-09-14 00:09:33 +03:00
lug420 9044a46b31 fix fullscreen toggle and resolution changes 2023-09-13 21:32:35 +02:00
indev e1b41d2c58 Merge pull request #62 from Indev450/fix-lua-onchange-error-in-error-handling
Fix 'error in error handling' for cases when error happens in cvar.fu…
2023-09-13 21:16:54 +03:00
lug420 3204095afb revert "redo parts of the lighttable shader"
die
2023-09-13 16:09:58 +02:00
lug420 538de7d2d2 fix memfree command on 64bit 2023-09-13 04:42:35 +02:00
alufolie91 2cba586d9c im good at coding
absolute bruh thing, but it somehow works, fixes the midtextures, and doesent kill performance lmao
2023-09-13 03:54:12 +02:00
alufolie91 ad4d587a52 screw you
bleh, pegging midtextures to slopes now works correctly, but cutting them is broken again
atleast this fixes the performance issues
no idea tho why it screws up things so much
2023-09-13 02:58:20 +02:00
alufolie91 a929636a28 Revert "cleanup HWR_SplitWall"
This reverts commit 06a2508a9c.
2023-09-13 02:56:11 +02:00
alufolie91 06a2508a9c cleanup HWR_SplitWall
e
2023-09-13 01:52:25 +02:00
alufolie91 64b2e2ee37 Fix bugs with HWR_SplitWall and sloped midtextures but cleaner
performance still pretty bad, atleast this is cleaner than last time
2023-09-13 01:40:52 +02:00
alufolie91 b6ef6eb801 revert sloped midtexture fix for now
huge performance regression on some maps
ill look into it in the future again maybe
2023-09-12 21:03:58 +02:00
indev b4d48cc9ec Set palette uniform in InitPalette instead of DrawScreenFinalTexture 2023-09-12 21:55:35 +03:00
alufolie91 f83a937dc5 redo parts of the lighttable shader
this caused performance drops before even with the whole thing disabled
2023-09-12 18:56:51 +02:00
alufolie91 e2acb4c3fc only do this when were running the palette shader 2023-09-12 17:07:19 +02:00
alufolie91 5bf722a1fb only allow this thing when shaders are enabled aswell
yes i will do it like that
no i wont use gl_allowshaders
i want this thing to be able to affect the menus and hud, just like software :p
2023-09-12 01:50:46 +02:00
alufolie91 0751484439 fix some effects
idk lmao but this fixes a few effects to be "on par" with software renderer
aswell as menus and hud stuff
2023-09-12 00:38:50 +02:00
alufolie91 e5b16c7aa0 Merge remote-tracking branch 'origin/Saturn' into paletteshader 2023-09-11 20:45:20 +02:00
lug420 bac058d128 forgor some things 2023-09-11 20:07:03 +02:00
haya dd4a9ae890 i may be stupid 2023-09-11 20:01:27 +02:00
hayaunderscore f91687209b fix horizon lines on batching somewhat 2023-09-11 20:01:22 +02:00
lug420 ec4140a9d2 remove custom shader toggle + clear colormaps when toggle palette shader
the custom shader toggle often broke stuff when toggled while palette shader was active

also clearing colormaps when toggling palette shader is ugly midlevel but atleast it doesent visually break completely

def need to somehow reinitialze colormaps instead or smth
2023-09-11 20:00:09 +02:00
lug420 2553c9e878 cleanup a bit
remove debug prints and vars
clean stuff up a bit
2023-09-11 18:30:35 +02:00
lug420 f9f33aa53a add lighttabble shader
this was way too much headache
set up a basic condition atm, so lighttable generation turns off if the paletteshader is turned off
this will break visually if the shader is turned on midrace atm
will implement smth better
2023-09-11 18:13:59 +02:00
hayaunderscore 4455ebe58f Fix issue with upside-down salty hop 2023-09-11 16:03:18 +02:00
alufolie91 35cfdea9e7 allow opengl to also use widescreen backgrounds for votes
thanks kk for locking this to software mode only despite this working without issues in opengl aswell
2023-09-11 15:55:59 +02:00
indev 346433d248 Shutdown DiscordRPC when discordrp cvar is set to Off 2023-09-11 13:17:12 +03:00
indev 16a7e69292 Don't init discord rich presence untill discordrp is set to On
Haven't tested this since i'm on linux and the feature looks like it is windows only
2023-09-11 13:01:29 +03:00
Alug 441824fc70 Merge pull request #57 from hayaunderscore/paletteshader
Fix shader compile error and level palettes
2023-09-11 10:40:01 +02:00
hayaunderscore f46b77ab7b fix shader compile error, fix custom level palettes 2023-09-11 14:00:36 +08:00
alufolie91 561af0e601 smol adjustment 2023-09-11 02:14:22 +02:00
alufolie91 362c21505d smol fixup
fixes the weird black/white screen on game start
2023-09-11 01:04:43 +02:00
alufolie91 d3d40de996 unfuck this thing change lut size to full 64
holy fuck, goddamit, im so mad at this
2023-09-10 18:59:31 +02:00
alufolie91 3ce4653bb5 smol adjustment 2023-09-10 16:57:38 +02:00
alufolie91 a639c87a90 rework this thing, use parts of the new palette renderer
this atleast completely fixed the stutters and prob the memory leaks the thing had before

its still super messy and idk
2023-09-10 16:43:42 +02:00
alufolie91 3aac16432a adjust things more
try to mitigate performance loss and stutters
readjust the look a bit
cleanup stuff a bit
this thing still pretty much runs badly
2023-09-09 16:18:46 +02:00
lug420 1c9ea1eb2e fix a crash with rotsprites
+ clean up this absolute mess
2023-09-09 01:38:23 +02:00
indev a47aea4c9f Fix 'error in error handling' for cases when error happens in cvar.func right when cvar is registered 2023-09-08 18:29:05 +03:00
indev 9cd0e6c385 Why is this 'variable-sized' and can't be initialized like that??? 2023-09-08 12:00:10 +03:00
indev c23a0f08c4 Merge pull request #55 from Indev450/rotsnap
smoother slope rotation for players
2023-09-08 11:51:55 +03:00
indev 3ff865b1b6 Merge pull request #56 from Indev450/sdldraganddrop
Addfile per drag and drop
2023-09-08 11:51:31 +03:00
indev cdedf1349c Attempt to fix non-ansii filenames on windows 2023-09-08 11:47:19 +03:00
alufolie91 7beab3b582 fix the sprite renderstats again
aAAaaa
2023-09-08 10:42:31 +02:00
alufolie91 b1b592f88d readd the stuff blubuabb 2023-09-08 10:38:48 +02:00
lug420 8737a40a4d bleh 2023-09-07 23:55:26 +02:00
lug420 71ce5be570 me wondering why the hw sprite perfstats were broken
+ removing some stuff we dont need
2023-09-07 23:54:22 +02:00
indev b883d02abb Use P_AddWadFile directly instead of command so non-ansii file names also supported 2023-09-07 19:28:53 +03:00
alufolie91 09f79a6934 Addfile per drag and drop
https://git.do.srb2.org/SteelT/SRB2/-/commit/01cc2b91e189e4d268eddd38f3ba917133a07adc
2023-09-07 17:24:06 +02:00
lug420 9bdcfe9750 adjust some stuff
bleh looks alr, but def loose some color depth with it
2023-09-07 15:59:10 +02:00
lug420 b767180473 readd the lookup texture, adjust its size
it runs a bit better like this, but also is a bit darker
def needs adjustments
2023-09-07 14:38:10 +02:00
indev acb5d96788 Merge pull request #54 from Indev450/misc-fixes
Fix few typos
2023-09-06 19:58:45 +03:00
indev 228a932598 Fix few typos 2023-09-06 19:54:14 +03:00
lug420 b53cc6fd2b fuck it palette renderer "lite"
remove the goddamn lookup textures, this atleast runs okish and looks not that bad
2023-09-06 18:29:26 +02:00
lug420 01cd8f5a0f 4fps
this thing runs like crap 4fps
2023-09-06 18:02:04 +02:00
alufolie91 9732e74bf3 more work
https://git.do.srb2.org/Hannu_Hanhi/SRB2/-/commit/140dba15b86ad7e206c50c8336103bee89e6b032
2023-09-06 15:24:31 +02:00
alufolie91 2ed4a7b548 Palette Lookup Texture
https://git.do.srb2.org/Hannu_Hanhi/SRB2/-/commit/9562a95d0adb9384b5db26145ed03cb5d3e5a893
https://git.do.srb2.org/Hannu_Hanhi/SRB2/-/commit/d8a329b89dad75a57e076d88b8d5d1fdb5f959bc
2023-09-06 15:19:39 +02:00
alufolie91 52c11d1444 paletteshader
stuff from hannu
https://git.do.srb2.org/Hannu_Hanhi/SRB2/-/commit/2530e8b2938eb3ecb6f56b6cdc9916f387a72c6a

this thing tanks my framerate to hell
2023-09-06 15:12:18 +02:00
alufolie91 78d50e4c43 just a bit more
looks even better like this imo
2023-09-05 23:01:03 +02:00
indev 7f05d27f42 Allow lua to change vote background via hud.setVoteBackground 2023-09-05 12:47:49 +03:00
alufolie91 3675fdd361 smoother slope rotation for players
dont snap player directly to whatever theyre standing on
instead make the sprite rotate a bit smoother
see: https://git.do.srb2.org/haya_/Kart-Public/-/commit/8448d75b031fa86cdb854d13eda4712352d35a89
2023-09-05 09:13:12 +02:00
alufolie91 98dfe528d8 remove this 2023-09-04 16:37:11 +02:00
alufolie91 7da590df94 Fix sprite scale column iteration crash
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2130
2023-09-04 15:30:42 +02:00
alufolie91 90cc5a6cb0 Fix a possible crash in R_RenderMaskedSegRange
https://git.do.srb2.org/STJr/SRB2/-/commit/55b4458001b2ffe76774ff07a11b56ebf1f70de9
2023-09-04 15:30:21 +02:00
alufolie91 ca9277366c anim screen stuff 2023-09-01 19:43:24 +02:00
indev e79bf24bcd Add lua memory usage in memfree command output 2023-09-01 18:34:06 +03:00
indev 2c1201ff34 Add mo.rollsum and player.sliproll fields. Rendering and frame interpolation code was used, so they are NOT synch safe! 2023-09-01 12:45:23 +03:00
alufolie91 c4ff1a3aca forgor to readd those 2023-09-01 10:12:06 +02:00
alufolie91 5760f25c74 readd the namecheck to addlocalskin menu
until we find a better way to check for skins c:
2023-08-31 13:41:25 +02:00
indev 0a6f700c6f Addon browser can now be in 2 states - loading addons and loading localskins, which fixes its behavior when trying to load character addon as server admin 2023-08-31 13:59:30 +03:00
alufolie91 3147dfb012 2.1 2023-08-31 11:18:38 +02:00
Alug 5007a33bbf Merge pull request #49 from Indev450/fixspeedometer
fix the speedometer
2023-08-31 10:57:03 +02:00
Alug c65acfa90e Merge pull request #50 from Indev450/nospecialmusic
Nospecialmusic
2023-08-31 10:56:50 +02:00
Alug b167c19137 Merge pull request #51 from hayaunderscore/readme-refactor
make the readme look more consistent
2023-08-31 10:56:15 +02:00
alufolie91 d48b08856e Support for Animated Votingscreens
i hate the interpolation i hate it
no idea honestly if those play correctly atm but atleast they dont freak out with uncapped
https://gitlab.com/blondedradio/srb-2-k-cep/-/commit/776a547087cdef46b2bdbfc3ddc9d4d963bbea4b
2023-08-31 10:42:43 +02:00
alufolie91 9ba5c9a38b bruuuuuh 2023-08-31 03:35:42 +02:00
haya 1a9f30a328 ok github markdown 2023-08-31 07:06:17 +08:00
haya 97058bfcf6 try being consistent 2023-08-31 07:05:06 +08:00
alufolie91 bd41bbb304 fix the speedometer
things got swapped X)
also removed the extra number, kart adds a 3rd one if needed
2023-08-31 00:24:16 +02:00
alufolie91 f47cb885cc eeeeheheheeheheh ifdefs 2023-08-30 22:27:52 +02:00
alufolie91 1ab243d93a add shit to menu 2023-08-30 22:26:38 +02:00
alufolie91 15d59cbbd8 i dont want any special music
no to grow and star music!
2023-08-30 22:20:07 +02:00
Alug c88d2dadb0 Update README.md again 2023-08-30 21:15:07 +02:00
alufolie91 a4e96d2380 bruh 2023-08-30 19:20:35 +02:00
alufolie91 002c550263 more fixes
ugh
2023-08-30 19:17:51 +02:00
alufolie91 25b9bc4100 smol fix 2023-08-30 19:15:22 +02:00
alufolie91 7105606475 more menu shit
- Youll now get a preview of what skin is going to be used.
- Removed redundant code
https://git.do.srb2.org/haya_/Kart-Public/-/commit/a6728c26f76bfc94f7bc07aa076c8979c9bef5c9
2023-08-30 19:14:41 +02:00
alufolie91 71e4005226 add menu n shit
https://git.do.srb2.org/haya_/Kart-Public/-/commit/b85a55137cfef0a18b297c59e62018586323a2e9
2023-08-30 19:12:56 +02:00
alufolie91 76b66b41b6 Argh!
https://git.do.srb2.org/haya_/Kart-Public/-/commit/217f15452c1fda9ea3c0d00650d470e13e14e0f5
2023-08-30 18:58:26 +02:00
alufolie91 43e1331594 another localfile thingie
https://git.do.srb2.org/haya_/Kart-Public/-/commit/4a60babf75ce6362d32a1633b12a718d65bcd18c
2023-08-30 18:51:10 +02:00
alufolie91 23ba3d493b issues fixing 2023-08-30 18:50:00 +02:00
alufolie91 487cbc495a more changes
https://git.do.srb2.org/haya_/Kart-Public/-/commit/9e3919195d143956e31bf092f6822cab61d1ee81
2023-08-30 18:47:57 +02:00
alufolie91 faeb4d22ed Add a -force parameter to addskins, fix localskin not playing the right sounds
https://git.do.srb2.org/haya_/Kart-Public/-/commit/932e9b92c3551dc4910157ea8d3eea1145ccfc40
2023-08-30 18:43:55 +02:00
alufolie91 9dc2ad4f32 add localskinall command
https://git.do.srb2.org/haya_/Kart-Public/-/commit/958fe796eb070b6678cd45ea835a998d8dc6d2c9
2023-08-30 17:39:41 +02:00
alufolie91 ceae12baba fix an issue with desynchs
https://git.do.srb2.org/haya_/Kart-Public/-/commit/a47d965b82e45bcf600217899a2cd6951024093b
2023-08-30 17:34:28 +02:00
alufolie91 58c58e9542 fix shit even more
https://git.do.srb2.org/haya_/Kart-Public/-/commit/37d72b4680bbb1ecb68aaa817f2afc8b34deab96
2023-08-30 17:31:57 +02:00
alufolie91 46c7bf8b03 fix shit
https://git.do.srb2.org/haya_/Kart-Public/-/commit/e4ba8b9a753fe741f1e5a65490ae0d2d645baa97
2023-08-30 17:24:50 +02:00
alufolie91 c011d09e33 fix for localskins not properly saving when returning back into the titlescreen
https://git.do.srb2.org/haya_/Kart-Public/-/commit/e679dfe0aa059cca68bc67da5a45c12c26dfd9ac
2023-08-30 17:11:38 +02:00
alufolie91 65fadcf709 fix
https://git.do.srb2.org/haya_/Kart-Public/-/commit/b6b3dcb3f08b470d6075c2949b2dee364afb5c99
2023-08-30 17:09:40 +02:00
alufolie91 e2b06aa600 Ghost and signpost support
https://git.do.srb2.org/haya_/Kart-Public/-/commit/f07179589414b15605da14901f742342ab53de66
2023-08-30 17:08:50 +02:00
alufolie91 7ab0a808a9 Show which skin is the real one 2023-08-30 17:05:21 +02:00
alufolie91 bc7ce5c983 "immersion"
https://git.do.srb2.org/haya_/Kart-Public/-/commit/4547347e219158c1d11a6f373c9c94a7bd2ee789
2023-08-30 17:04:40 +02:00
alufolie91 6e55d88816 more shit
https://git.do.srb2.org/haya_/Kart-Public/-/commit/28fa3039c147d7b479b8d4ddfca50918c620aa2f
2023-08-30 17:02:05 +02:00
alufolie91 97f0ea1b0f initial support
https://git.do.srb2.org/haya_/Kart-Public/-/commit/a464df2165d62528af46d7ef0a6cbdbf29c3d07c
2023-08-30 16:59:23 +02:00
67 changed files with 3140 additions and 1504 deletions

No files matched your search

+22 -16
View File
@@ -6,29 +6,34 @@
- Sprites player rotation on slopes; going on hills, levitate, going down, and so on alters your sprites (configurable)
- You can alter all the base kart HUD element offsets on the fly in the Saturn Options settings menu
- "addfilelocal" Command, for those who want to use things like their custom hud in netgames (Same as addfile but completely client sided)
- OpenMPT for Tracker module playback (Complete with filters) fixed looping issues while even sounding better than the old GME playback
- `addfilelocal` Command, for those who want to use things like their custom hud in netgames (Same as addfile but completely client sided)
- OpenMPT for Tracker module playback instead of GME
- Fixes looping and sounds better
- Allows filter configuration
- The minimal brightness with Shaders can be configured, now you can seeeee in dark areas (0-255 , uses Sector brightness values)
- Lua hooks for Intermission (ex: You can make hostmod votes still visible during intermission!)
- Lua hooks for Vote Screen (ex: You can make hostmod votes still visible during map vote screen!)
- Lua HUD hooks for Intermission (ex: You can make hostmod votes still visible during intermission!)
- Lua HUD hooks for Vote Screen (ex: You can make hostmod votes still visible during map vote screen!)
- Saltyhop! do a funny hop
- Smaller Speedometer (optional / requieres extra.kart file)
- Record Attack input display can now be used everywhere
- Smaller minimap icons and also show player names on the minimap (toggable)
- "showmusiccredits" command, shows you the current music track again
- "listskins" show a list of all skins currently loaded
- Visual Portals from Haya´s HEP Client
- Toggable lowercase menu´s also from Haya´s HEP client
- `showmusiccredit` command, shows you the current music track again
- `listskins` show a list of all skins currently loaded
- Visual Portals from Haya's HEP Client
- Toggable lowercase menu's also from Haya's HEP client
- Everything that Galaxy has
## Improvements / Bug fixes
- Replay size has been increased to 10MiB minimum, to make replay overflows very unlikely to happen (can be set to 100MiB max with "maxdemosize" command in console)
- Music changes now properly show the music credits (ex: Kart maps with easter eggs that alter the music) *The mapper still has to provide a MusicDEF for this to work.
- Replay size has been increased to 10MiB minimum, to make replay overflows very unlikely to happen
- can be set to 100MiB max with `maxdemosize` command in console
- Music changes now properly show the music credits (ex: Kart maps with easter eggs that alter the music)
- The mapper still has to provide a MusicDEF for this to work.
- Configurable chatlog length (yay can read those messages from 30 mins ago without opening log.txt)
- Configurable timeout for waiting to join a full server (in vanilla this is capped to 5 minutes before it boots you out)
- Characters now spin in skin selection menu (configurable)
- HTTP Addon download speed has been raised dramatically (configurable with "downloadspeed" command)
- HTTP Addon download speed has been raised dramatically
- configurable with `downloadspeed` command
- HWR Drawnodes have been refactored, this should fix a few rare crashes esp in regards to OpenGL Visportals
- The Position Number in the corner is alot smaller now (half the size!)
- Toggable Lap animation
@@ -40,17 +45,18 @@
- Access for `mobj_t` and `player_t` fields from Lua has been completely rewritten, for much better performance with many Lua scripts
- Lua shows Tracebacks whenever an error occurs
- The Lua Perfstats page now has multiple pages and is more organized (ps_thinkframe_page X in console)
- People with lower end hardware can disable "screen textures" with "gr_screentextures" command, huge performance gain with minimal visual loss (Note intermission screen background is broken with this)
- Software mode has gotten "ffloorclip", which boosts performance on maps with many Floor over Floor roads
- People with lower end hardware can disable "screen textures" with "gr_screentextures" command, huge performance gain with minimal visual loss
- Intermission backgrounds, heat wave effects and etc are broken with this
- `ffloorclip`, exclusive to Software, which boosts performance on maps with many Floor over Floor sectors
## Technical fixes
- ZFigthing Textures in Opengl mode have been fixed in engine (well almost all of it)
- Fof's intersecting with slopes have less issues and now render correctly in Opengl
- FOFs intersecting with slopes have less issues and now render correctly in Opengl
- Midtextures on slopes in Opengl are fixed, many weird guardrails and fences, aswell as some of those sticking out textures from the ground on some maps should be gone
- The annoying depraction messages for "P_TeleportMove" and "P_AproxDistance" have been silenced
- The annoying depraction messages for `P_TeleportMove` and `P_AproxDistance` have been silenced
- Silenced the annoying "cant find next map..." messages as theyre super useless and annoying anyways
- Added a small cooldown on "map" command due to spamming causing a SIGSEGV
- Added a small cooldown on `map` command due to spamming causing a SIGSEGV
## MISC
- Bird's Camara Tilting feature is no longer turned on by default
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

+2
View File
@@ -3,6 +3,7 @@
# Core sources
set(SRB2_CORE_SOURCES
am_map.c
args.c
b_bot.c
command.c
comptime.c
@@ -52,6 +53,7 @@ set(SRB2_CORE_SOURCES
set(SRB2_CORE_HEADERS
am_map.h
args.h
b_bot.h
byteptr.h
command.h
+1
View File
@@ -626,6 +626,7 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/lzf.o \
$(OBJDIR)/vid_copy.o \
$(OBJDIR)/b_bot.o \
$(OBJDIR)/args.o \
$(i_cdmus_o) \
$(i_net_o) \
$(i_system_o) \
+1 -1
View File
@@ -24,7 +24,7 @@ static INT64 start_time; // as microseconds since the epoch
// I should probably return how much memory is remaining
// for this process, considering Android's process memory limit.
UINT32 I_GetFreeMem(UINT32 *total)
size_t I_GetFreeMem(size_t *total)
{
// what the heck? sysinfo() is partially missing in bionic?
/* struct sysinfo si; */
+11 -1
View File
@@ -277,7 +277,7 @@ static xcommand_t *com_commands = NULL; // current commands
#define MAX_ARGS 80
static size_t com_argc;
static char *com_argv[MAX_ARGS];
char *com_argv[MAX_ARGS];
static const char *com_null_string = "";
static char *com_args = NULL; // current command args or NULL
@@ -327,6 +327,16 @@ const char *COM_Argv(size_t arg)
return com_argv[arg];
}
/** Returns all of the console command arguments
*
* \return String pointer to the argv table.
* \sa COM_ArgvList
*/
char **COM_ArgvList(void)
{
return com_argv;
}
/** Gets all console command arguments.
*
* \return String pointer to all arguments for the last command.
+4
View File
@@ -33,8 +33,12 @@ typedef void (*com_func_t)(void);
void COM_AddCommand(const char *name, com_func_t func);
int COM_AddLuaCommand(const char *name);
#define MAX_ARGS 80
extern char *com_argv[MAX_ARGS];
size_t COM_Argc(void);
const char *COM_Argv(size_t arg); // if argv > argc, returns empty string
char **COM_ArgvList(void);
char *COM_Args(void);
size_t COM_CheckParm(const char *check); // like M_CheckParm :)
size_t COM_CheckPartialParm(const char *check);
+169 -4
View File
@@ -49,6 +49,7 @@
#include "m_anigif.h"
#include "k_kart.h" // SRB2kart
#include "y_inter.h"
#include "fastcmp.h"
#include "m_perfstats.h"
#ifdef NETGAME_DEVMODE
@@ -141,6 +142,8 @@ static void Command_SetViews_f(void);
static void Command_Addfilelocal(void);
static void Command_Addfile(void);
static void Command_Addskins(void);
static void Command_GLocalSkin(void);
static void Command_ListWADS_f(void);
#ifdef DELFILE
static void Command_Delfile(void);
@@ -289,6 +292,8 @@ consvar_t cv_skin = {"skin", DEFAULTSKIN, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin_
consvar_t cv_skin2 = {"skin2", DEFAULTSKIN2, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_skin3 = {"skin3", DEFAULTSKIN3, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin3_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_skin4 = {"skin4", DEFAULTSKIN4, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin4_OnChange, 0, NULL, NULL, 0, 0, NULL};
// haha I've beaten you now, ONLINE
consvar_t cv_localskin = {"internal___localskin", "none", CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -447,6 +452,7 @@ static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, "
consvar_t cv_basenumlaps = {"basenumlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_forceskin = {"forceskin", "Off", CV_NETVAR|CV_CALL|CV_CHEAT, Forceskin_cons_t, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fakelocalskin = {"fakelocalskin", "None", CV_SAVE, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_downloading = {"downloading", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_allowexitlevel = {"allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -468,6 +474,7 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0
static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}};
consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -512,7 +519,7 @@ consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_
consvar_t cv_showtrackaddon = {"showtrackaddon", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t skinselectmenu_t[] = {{SKINMENUTYPE_SCROLL, "Scoll"}, {SKINMENUTYPE_2D, "2d"}, {SKINMENUTYPE_GRID, "Grid"}, {0, NULL}};
static CV_PossibleValue_t skinselectmenu_t[] = {{SKINMENUTYPE_SCROLL, "Scroll"}, {SKINMENUTYPE_2D, "2d"}, {SKINMENUTYPE_GRID, "Grid"}, {0, NULL}};
consvar_t cv_skinselectmenu = {"skinselectmenu", "Grid", CV_SAVE, skinselectmenu_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t skinselectgridsort_t[] ={
@@ -643,6 +650,8 @@ void D_RegisterServerCommands(void)
COM_AddCommand("addfilelocal", Command_Addfilelocal);
COM_AddCommand("addfile", Command_Addfile);
COM_AddCommand("addskins", Command_Addskins);
COM_AddCommand("localskin", Command_GLocalSkin);
COM_AddCommand("listwad", Command_ListWADS_f);
#ifdef DELFILE
@@ -777,6 +786,9 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_showping);
CV_RegisterVar(&cv_pingmeasurement);
CV_RegisterVar(&cv_luaimmersion);
CV_RegisterVar(&cv_fakelocalskin);
CV_RegisterVar(&cv_minihead);
CV_RegisterVar(&cv_showminimapnames);
@@ -885,6 +897,7 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_playername);
CV_RegisterVar(&cv_playercolor);
CV_RegisterVar(&cv_skin); // r_things.c (skin NAME)
CV_RegisterVar(&cv_localskin);
// secondary player (splitscreen)
CV_RegisterVar(&cv_playername2);
CV_RegisterVar(&cv_playercolor2);
@@ -976,6 +989,9 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_saltyhop);
CV_RegisterVar(&cv_saltyhopsfx);
CV_RegisterVar(&cv_saltysquish);
CV_RegisterVar(&cv_growmusic);
CV_RegisterVar(&cv_supermusic);
//CV_RegisterVar(&cv_crosshair);
//CV_RegisterVar(&cv_crosshair2);
@@ -4564,7 +4580,7 @@ static void Command_Addfile(void)
// Add file on your client directly if it is trivial, or you aren't in a netgame.
if (!(netgame || multiplayer) || musiconly)
{
P_AddWadFile(fn);
P_AddWadFile(fn, false);
return;
}
@@ -4613,6 +4629,156 @@ static void Command_Addfile(void)
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
}
// i hate myself
static boolean DumbStartsWith(const char *pre, const char *str)
{
size_t lenpre = strlen(pre),
lenstr = strlen(str);
return lenstr < lenpre ? false : memcmp(pre, str, lenpre) == 0;
}
/** Adds something at runtime.
*/
static void
Command_Addskins (void)
{
if (COM_Argc() > 3)
{
CONS_Printf(
"addskins <file>: Load a skin file.\n");
return;
}
// no forcing?
/*
if (fasticmp(COM_Argv(2), "-force") || fasticmp(COM_Argv(2), "-f")) {
CONS_Alert(CONS_NOTICE, M_GetText("Adding file %s. May or may not be a skin.\n"), COM_Argv(1));
P_AddWadFile(COM_Argv(1), 0, true);
} else {
if (DumbStartsWith("KC_", COM_Argv(1))) {
P_AddWadFile(COM_Argv(1), 0, true);
} else if (DumbStartsWith("KCL_", COM_Argv(1))) {
if (!demo.playback) {
CONS_Alert(CONS_ERROR, M_GetText("Cannot add file %s as it is a skin with lua. Include -force or -f to force it to load.\n"), COM_Argv(1));
return;
} else {
*/
P_AddWadFile(COM_Argv(1), true);
/*
}
} else {
CONS_Alert(CONS_ERROR, M_GetText("Cannot add file %s as it is not a skin.\n"), COM_Argv(1));
return;
}
}
*/
}
// args n stuff
#include "args.h"
static void Command_GLocalSkin (void)
{
size_t first_option;
size_t option_display;
size_t option_all;
size_t option_player;
option_player = COM_CheckPartialParm("-p");
option_display = COM_CheckPartialParm("-d");
option_all = COM_CheckPartialParm("-a");
char* fuck; // local skin name
if (!( first_option = COM_FirstOption() ))
first_option = COM_Argc();
if (first_option < 2)
{
/* holy fucking shit */
CONS_Printf("localskin <name> [-player <name>] [-display <number>] [-all]:\n");
CONS_Printf(M_GetText("Set a localskin via its internal name (usually printed on the console).\n\n\
* Using \"-player\" will set a localskin to a specified player.\n\
Defaults to yourself.\n\
* Using \"-display\" will set a localskin to the displayed player.\n\
Defaults to 0, which is the first player displayed.\n\
Can go up to 3 for splitscreen.\n\
* Using \"-all\" will set a localskin to ALL players.\n\
* \"localskin none\" removes the localskin, just like how\n\
\"forceskin none\" does.\n"));
return;
}
fuck = ConcatCommandArgv(1, first_option);
char* player_name = player_names[consoleplayer];
char* display_num = "0";
size_t dnum = 0;
if (option_display) // -display
{
// handle default: 0
if (COM_Argv(option_display + 1)[0] == "" || COM_Argv(option_display + 1)[0] != "-")
display_num = COM_Argv(option_display + 1);
if (isdigit(display_num[0]) || display_num == "0")
{
dnum = atoi(display_num);
if (dnum > 3 || dnum < 0) // nuh uh
dnum = 0;
SetLocalPlayerSkin(displayplayers[dnum], fuck, NULL);
CONS_Printf("Successfully applied localskin to displayed player.\n");
return;
}
CONS_Printf("Could not apply localskin.\n");
return;
}
else if (option_all) // -all
{
int i;
for (i = 0; i < MAXPLAYERS; ++i)
{
if (!playeringame[i])
continue;
SetLocalPlayerSkin(i, fuck, NULL);
}
CONS_Printf("Successfully applied localskin to all players.\n");
return;
}
else // -player or no other arguments
{
if (option_player)
{
int i;
player_name = COM_Argv(option_player + 1);
for (i = 0; i < MAXPLAYERS; ++i)
{
if (fasticmp(player_names[i], player_name))
SetLocalPlayerSkin(i, fuck, NULL);
}
CONS_Printf("Successfully applied localskin to specified player.\n");
return;
}
else
{
SetLocalPlayerSkin(consoleplayer, fuck, &cv_localskin);
CONS_Printf("Successfully applied localskin.\n");
return;
}
CONS_Printf("Could not apply localskin.\n");
return;
}
}
#ifdef DELFILE
/** removes the last added pwad at runtime.
* Searches for sounds, maps, music and images to remove
@@ -4769,7 +4935,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
ncs = findfile(filename,md5sum,true);
if (ncs != FS_FOUND || !P_AddWadFile(filename))
if (ncs != FS_FOUND || !P_AddWadFile(filename, false))
{
Command_ExitGame_f();
if (ncs == FS_FOUND)
@@ -5925,7 +6091,6 @@ static void Command_ListSkins(void)
}
}
/** Sends a color change for the console player, unless that player is moving.
* \sa cv_playercolor, Color2_OnChange, Skin_OnChange
* \author Graue <graue@oceanbase.org>
+3
View File
@@ -21,6 +21,7 @@
extern consvar_t cv_playername;
extern consvar_t cv_playercolor;
extern consvar_t cv_skin;
extern consvar_t cv_localskin;
// secondary splitscreen player
extern consvar_t cv_playername2;
extern consvar_t cv_playercolor2;
@@ -157,6 +158,8 @@ extern consvar_t cv_minihead;
extern consvar_t cv_showlapemblem;
extern consvar_t cv_showviewpointtext;
extern consvar_t cv_luaimmersion;
extern consvar_t cv_fakelocalskin;
extern consvar_t cv_skipmapcheck;
+1 -1
View File
@@ -513,7 +513,7 @@ INT32 CL_CheckFiles(void)
for (i = 0, j = mainwads+1; i < fileneedednum || j < numwadfiles;)
{
if (j < numwadfiles && !wadfiles[j]->important)
if (j < numwadfiles && (!wadfiles[j]->important || wadfiles[j]->localfile))
{
// Unimportant on our side. still don't care.
++j;
+3
View File
@@ -371,6 +371,7 @@ typedef struct player_s
angle_t viewrollangle;
angle_t tilt;
angle_t tilt_sprite;
// Mouse aiming, where the guy is looking at!
// It is updated with cmd->aiming.
@@ -415,6 +416,8 @@ typedef struct player_s
UINT8 skincolor;
INT32 skin;
INT32 localskin;
boolean skinlocal;
UINT32 score; // player score
fixed_t dashspeed; // dashing speed
+39 -2
View File
@@ -37,7 +37,9 @@
// length of IP strings
#define IP_SIZE 21
consvar_t cv_discordrp = {"discordrp", "On", CV_SAVE|CV_CALL, CV_OnOff, DRPC_UpdatePresence, 0, NULL, NULL, 0, 0, NULL};
static void Discordrp_OnChange(void);
consvar_t cv_discordrp = {"discordrp", "On", CV_SAVE|CV_CALL, CV_OnOff, Discordrp_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_discordstreamer = {"discordstreamer", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_discordasks = {"discordasks", "Yes", CV_SAVE|CV_CALL, CV_YesNo, DRPC_UpdatePresence, 0, NULL, NULL, 0, 0, NULL};
@@ -47,6 +49,8 @@ discordRequest_t *discordRequestList = NULL;
static char self_ip[IP_SIZE];
boolean drpc_init = false;
/*--------------------------------------------------
static char *DRPC_XORIPString(const char *input)
@@ -315,6 +319,9 @@ void DRPC_RemoveRequest(discordRequest_t *removeRequest)
--------------------------------------------------*/
void DRPC_Init(void)
{
if (drpc_init || !cv_discordrp.value) return;
drpc_init = true;
DiscordEventHandlers handlers;
memset(&handlers, 0, sizeof(handlers));
@@ -325,10 +332,36 @@ void DRPC_Init(void)
handlers.joinRequest = DRPC_HandleJoinRequest;
Discord_Initialize(DISCORD_APPID, &handlers, 1, NULL);
I_AddExitFunc(Discord_Shutdown);
I_AddExitFunc(DRPC_Shutdown);
DRPC_UpdatePresence();
}
void DRPC_Shutdown(void)
{
if (!drpc_init)
{
CONS_Printf("DiscordRPC never started\n");
return;
}
CONS_Printf("Shutting down DiscordRPC\n");
Discord_Shutdown();
drpc_init = false;
}
static void Discordrp_OnChange(void)
{
if (cv_discordrp.value)
{
DRPC_UpdatePresence();
}
else
{
DRPC_Shutdown();
}
}
/*--------------------------------------------------
static void DRPC_GotServerIP(UINT32 address)
@@ -402,6 +435,10 @@ static void DRPC_EmptyRequests(void)
--------------------------------------------------*/
void DRPC_UpdatePresence(void)
{
if (!cv_discordrp.value) return;
if (!drpc_init) DRPC_Init();
char detailstr[48+1];
char mapimg[8+1];
+7
View File
@@ -64,6 +64,13 @@ void DRPC_RemoveRequest(discordRequest_t *removeRequest);
void DRPC_Init(void);
/*--------------------------------------------------
void DRPC_Shutdown(void);
Shutdown Discord Rich Presence if it was started at all.
--------------------------------------------------*/
void DRPC_Shutdown(void);
/*--------------------------------------------------
void DRPC_UpdatePresence(void);
+2 -2
View File
@@ -149,8 +149,8 @@ extern char logfilename[1024];
#else
#define VERSION 1 // Game version
#define SUBVERSION 6 // more precise version number
#define VERSIONSTRING "Saturn v2 "
#define VERSIONSTRINGW L"Saturn v2"
#define VERSIONSTRING "Saturn v3 "
#define VERSIONSTRINGW L"Saturn v3"
// Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates!
// And change CMakeLists.txt (not src/, but in root), for CMake users!
// AND appveyor.yml, for the build bots!
+1 -1
View File
@@ -5,7 +5,7 @@ UINT8 graphics_started = 0;
UINT8 keyboard_started = 0;
UINT32 I_GetFreeMem(UINT32 *total)
size_t I_GetFreeMem(size_t *total)
{
*total = 0;
return 0;
+20
View File
@@ -468,6 +468,10 @@ consvar_t cv_songcredits = {"songcredits", "On", CV_SAVE, CV_OnOff, NULL, 0, NUL
// Show "FREE PLAY" when you're alone. :(
consvar_t cv_showfreeplay = { "showfreeplay", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
// We can disable special tunes!
consvar_t cv_growmusic = {"growmusic", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_supermusic = {"supermusic", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
/*consvar_t cv_crosshair = {"crosshair", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_crosshair2 = {"crosshair2", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_crosshair3 = {"crosshair3", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -846,6 +850,16 @@ void G_SetGameModified(boolean silent, boolean major)
M_EndModeAttackRun();
}
void G_SetWadModified(boolean silent, boolean major, UINT16 wadnum)
{
// now that we have a wad that is actually well, a gameplay changing mod
// (for later)
wadfiles[wadnum]->majormod = true;
// set our game to be marked as modified.
G_SetGameModified(silent, major);
}
/** Builds an original game map name from a map number.
* The complexity is due to MAPA0-MAPZZ.
*
@@ -2702,6 +2716,8 @@ void G_PlayerReborn(INT32 player)
UINT8 mare;
UINT8 skincolor;
INT32 skin;
int localskin;
boolean skinlocal;
tic_t jointime;
UINT8 splitscreenindex;
boolean spectator;
@@ -2748,6 +2764,8 @@ void G_PlayerReborn(INT32 player)
skincolor = players[player].skincolor;
skin = players[player].skin;
localskin = players[player].localskin;
skinlocal = players[player].skinlocal;
// SRB2kart
kartspeed = players[player].kartspeed;
kartweight = players[player].kartweight;
@@ -2837,6 +2855,8 @@ void G_PlayerReborn(INT32 player)
// save player config truth reborn
p->skincolor = skincolor;
p->skin = skin;
p->localskin = localskin;
p->skinlocal = skinlocal;
// SRB2kart
p->kartspeed = kartspeed;
p->kartweight = kartweight;
+2
View File
@@ -113,6 +113,7 @@ extern INT16 rw_maximums[NUM_WEAPONS];
extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection/*, cv_compactscoreboard*/;
extern consvar_t cv_songcredits;
extern consvar_t cv_showfreeplay;
extern consvar_t cv_growmusic, cv_supermusic;
extern consvar_t cv_pauseifunfocused;
//extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4;
extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove*/;
@@ -402,6 +403,7 @@ boolean G_GetRetryFlag(void);
void G_LoadGameData(void);
void G_LoadGameSettings(void);
void G_SetWadModified(boolean silent, boolean major, UINT16 wadnum);
void G_SetGameModified(boolean silent, boolean major);
void G_SetGamestate(gamestate_t newstate);
-1
View File
@@ -576,7 +576,6 @@ void HWR_SetPalette(RGBA_t *palette)
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED);
}
}
// --------------------------------------------------------------------------
// Make sure texture is downloaded and set it as the source
// --------------------------------------------------------------------------
+2
View File
@@ -224,6 +224,7 @@ struct FSurfaceInfo
RGBA_t PolyColor;
RGBA_t TintColor;
RGBA_t FadeColor;
UINT32 LightTableId;
FLightInfo LightInfo; // jimita 14032019
};
typedef struct FSurfaceInfo FSurfaceInfo;
@@ -231,6 +232,7 @@ typedef struct FSurfaceInfo FSurfaceInfo;
enum hwdsetspecialstate
{
HWD_SET_SHADERS,
HWD_SET_PALETTE_SHADER_ENABLED,
HWD_SET_TEXTUREFILTERMODE,
HWD_SET_TEXTUREANISOTROPICMODE,
+11 -11
View File
@@ -122,7 +122,7 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option)
flags |= PF_ForceWrapY;
// clip it since it is used for bunny scroll in doom I
HWD.pfnDrawPolygon(NULL, v, 4, flags);
HWD.pfnDrawPolygon(NULL, v, 4, flags, false);
}
void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap)
@@ -300,10 +300,10 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans];
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
HWD.pfnDrawPolygon(&Surf, v, 4, flags, false);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags);
HWD.pfnDrawPolygon(NULL, v, 4, flags, false);
}
void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h)
@@ -454,10 +454,10 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value];
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
HWD.pfnDrawPolygon(&Surf, v, 4, flags, false);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags);
HWD.pfnDrawPolygon(NULL, v, 4, flags, false);
}
// ==========================================================================
@@ -533,7 +533,7 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
// BTW, I see we put 0 for PFs, and If I'm right, that
// means we take the previous PFs as default
// how can we be sure they are ok?
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest, false); //PF_Translucent);
}
@@ -570,7 +570,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
Surf.PolyColor.rgba = pLocalPalette[color].rgba;
Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f);
}
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest, false);
}
// Draw the console background with translucency support
@@ -597,7 +597,7 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height)
Surf.PolyColor.rgba = UINT2RGBA(color);
Surf.PolyColor.s.alpha = 0x80;
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest, false);
}
@@ -846,7 +846,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
Surf.PolyColor = V_GetColor(color);
HWD.pfnDrawPolygon(&Surf, v, 4,
PF_Modulated|PF_NoTexture|PF_NoDepthTest);
PF_Modulated|PF_NoTexture|PF_NoDepthTest, false);
}
// -------------------+
@@ -954,7 +954,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
Surf.PolyColor.rgba = UINT2RGBA(color);
Surf.PolyColor.s.alpha = 0x80;
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest, false);
}
// -----------------+
@@ -1062,7 +1062,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
Surf.PolyColor = V_GetColor(color);
HWD.pfnDrawPolygon(&Surf, v, 4,
PF_Modulated|PF_NoTexture|PF_NoDepthTest);
PF_Modulated|PF_NoTexture|PF_NoDepthTest, false);
}
#ifdef HAVE_PNG
+8 -1
View File
@@ -21,6 +21,7 @@
#include "hw_md2.h"
#include "hw_dll.h"
#include "../doomdef.h"
// ==========================================================================
// STANDARD DLL EXPORTS
@@ -34,7 +35,7 @@ EXPORT void HWRAPI(SetPalette) (RGBA_t *ppal, RGBA_t *pgamma);
#endif
EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl);
EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, boolean horizonSpecial);
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
@@ -79,6 +80,9 @@ EXPORT void HWRAPI(InitCustomShaders) (void);
EXPORT void HWRAPI(StartBatching) (void);
EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, int *sNumPolys, int *sNumVerts, int *sNumCalls, int *sNumShaders, int *sNumTextures, int *sNumPolyFlags, int *sNumColors);
EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable);
EXPORT void HWRAPI(ClearLightTableCache) (void);
// ==========================================================================
// HWR DRIVER OBJECT, FOR CLIENT PROGRAM
// ==========================================================================
@@ -125,6 +129,9 @@ struct hwdriver_s
StartBatching pfnStartBatching;
RenderBatches pfnRenderBatches;
AddLightTable pfnAddLightTable;
ClearLightTableCache pfnClearLightTableCache;
};
extern struct hwdriver_s hwdriver;
+212 -58
View File
@@ -30,6 +30,7 @@
#include "../r_fps.h"
#include "../r_state.h"
#include "../r_local.h"
#include "../r_data.h"
#include "../r_patch.h" // a mystery as to what this is for
#include "../r_bsp.h" // R_NoEncore
#include "../r_main.h" // cv_fov
@@ -60,10 +61,14 @@ struct hwdriver_s hwdriver;
// Commands and console variables
// ==========================================================================
// keep the state here instead of in the cv var, so it always matches the state in r_opengl.c
int gr_use_palette_shader = 0;
static void CV_filtermode_ONChange(void);
static void CV_anisotropic_ONChange(void);
static void CV_screentextures_ONChange(void);
static void CV_useCustomShaders_ONChange(void);
static void CV_useCustomShaders_ONChange(void);
static void CV_grpaletteshader_OnChange(void);
static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"},
{HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"},
@@ -115,7 +120,11 @@ static INT32 current_bsp_culling_distance = 0;
consvar_t cv_grscreentextures = {"gr_screentextures", "On", CV_CALL, CV_OnOff,
CV_screentextures_ONChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grusecustomshaders = {"gr_usecustomshaders", "Yes", CV_CALL|CV_SAVE, CV_OnOff, CV_useCustomShaders_ONChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grusecustomshaders = {"gr_usecustomshaders", "Yes", CV_CALL|CV_SAVE, CV_OnOff, CV_useCustomShaders_ONChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grpaletteshader = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_grpaletteshader_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grflashpal = {"gr_flashpal", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static void CV_filtermode_ONChange(void)
{
@@ -138,6 +147,16 @@ static void CV_useCustomShaders_ONChange(void)
HWD.pfnInitCustomShaders();
}
static void CV_grpaletteshader_OnChange(void)
{
if (rendermode == render_opengl)
{
HWD.pfnSetSpecialState(HWD_SET_PALETTE_SHADER_ENABLED, cv_grpaletteshader.value);
gr_use_palette_shader = cv_grpaletteshader.value;
V_SetPalette(0);
}
}
// ==========================================================================
// Globals
// ==========================================================================
@@ -400,6 +419,7 @@ static size_t gr_numportalcullsectors = 0;
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap)
{
RGBA_t poly_color, tint_color, fade_color;
boolean default_colormap = false;
poly_color.rgba = 0xFFFFFFFF;
tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GL_DEFAULTMIX;
@@ -451,6 +471,37 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
Surface->LightInfo.light_level = light_level;
Surface->LightInfo.fade_start = (colormap != NULL) ? colormap->fadestart : 0;
Surface->LightInfo.fade_end = (colormap != NULL) ? colormap->fadeend : 31;
if (gr_use_palette_shader)
{
if (!colormap)
{
colormap = &extra_colormaps[num_extra_colormaps];
default_colormap = true;
}
if (!colormap->gl_lighttable_id)
{
UINT8 *colormap_pointer;
if (default_colormap)
{
colormap_pointer = colormaps;
}
else
{
colormap_pointer = colormap->colormap;
}
colormap->gl_lighttable_id = HWD.pfnAddLightTable(colormap_pointer);
}
Surface->LightTableId = colormap->gl_lighttable_id;
}
}
void HWR_ClearLightTableCache()
{
if (rendermode == render_opengl)
HWD.pfnClearLightTableCache();
}
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if this can work
@@ -723,9 +774,82 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei
else if (PolyFlags & PF_Ripple)
HWD.pfnSetShader(5); // water shader
else
HWD.pfnSetShader(1); // floor shader
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags);
HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, false);
if (subsector)
{
// Horizon lines
FOutVector horizonpts[6];
float dist, vx, vy;
float x1, y1, xd, yd;
UINT8 numplanes, j;
vertex_t v; // For determining the closest distance from the line to the camera, to split render planes for minimum distortion;
const float renderdist = 27000.0f; // How far out to properly render the plane
const float farrenderdist = 32768.0f; // From here, raise plane to horizon level to fill in the line with some texture distortion
seg_t *line = &segs[subsector->firstline];
for (i = 0; i < subsector->numlines; i++, line++)
{
if (line->linedef->special == 41 && R_PointOnSegSide(dup_viewx, dup_viewy, line) == 0)
{
P_ClosestPointOnLine(viewx, viewy, line->linedef, &v);
dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y));
x1 = ((polyvertex_t *)line->pv1)->x;
y1 = ((polyvertex_t *)line->pv1)->y;
xd = ((polyvertex_t *)line->pv2)->x - x1;
yd = ((polyvertex_t *)line->pv2)->y - y1;
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
if (dist > 100.0f)
numplanes = 100;
else
numplanes = (UINT8)dist + 1;
for (j = 0; j < numplanes; j++)
{
// Left side
vx = x1 + xd * j / numplanes;
vy = y1 + yd * j / numplanes;
SETUP3DVERT((&horizonpts[1]), vx, vy);
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
vx = (vx - gr_viewx) * renderdist / dist + gr_viewx;
vy = (vy - gr_viewy) * renderdist / dist + gr_viewy;
SETUP3DVERT((&horizonpts[0]), vx, vy);
// Right side
vx = x1 + xd * (j+1) / numplanes;
vy = y1 + yd * (j+1) / numplanes;
SETUP3DVERT((&horizonpts[2]), vx, vy);
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
vx = (vx - gr_viewx) * renderdist / dist + gr_viewx;
vy = (vy - gr_viewy) * renderdist / dist + gr_viewy;
SETUP3DVERT((&horizonpts[3]), vx, vy);
// Horizon fills
vx = (horizonpts[0].x - gr_viewx) * farrenderdist / renderdist + gr_viewx;
vy = (horizonpts[0].z - gr_viewy) * farrenderdist / renderdist + gr_viewy;
SETUP3DVERT((&horizonpts[5]), vx, vy);
horizonpts[5].y = gr_viewz;
vx = (horizonpts[3].x - gr_viewx) * farrenderdist / renderdist + gr_viewx;
vy = (horizonpts[3].z - gr_viewy) * farrenderdist / renderdist + gr_viewy;
SETUP3DVERT((&horizonpts[4]), vx, vy);
horizonpts[4].y = gr_viewz;
// Draw
HWD.pfnDrawPolygon(&Surf, horizonpts, 6, PolyFlags, true);
}
}
}
}
}
#ifdef WALLSPLATS
@@ -788,8 +912,8 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
break;
}
HWD.pfnSetShader(2); // wall shader
HWD.pfnDrawPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal);
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
HWD.pfnDrawPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal, false);
}
}
#endif
@@ -822,7 +946,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend
{
HWR_Lighting(pSurf, lightlevel, wallcolormap);
HWD.pfnSetShader(2); // wall shader
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
// don't draw to color buffer when drawing to stencil
if (gl_drawing_stencil)
@@ -831,7 +955,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend
blendmode &= ~PF_Masked;
}
HWD.pfnDrawPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude);
HWD.pfnDrawPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, false);
#ifdef WALLSPLATS
if (gr_curline->linedef->splats && cv_splats.value)
@@ -904,13 +1028,15 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa
{
if (pfloor && (pfloor->flags & FF_FOG))
{
lightnum = HWR_CalcWallLight(pfloor->master->frontsector->lightlevel, v1x, v1y, v2x, v2y);
colormap = pfloor->master->frontsector->extra_colormap;
lightnum = pfloor->master->frontsector->lightlevel;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
}
else
{
lightnum = HWR_CalcWallLight(*list[i].lightlevel, v1x, v1y, v2x, v2y);
colormap = list[i].extra_colormap;
lightnum = *list[i].lightlevel;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
}
}
@@ -1001,9 +1127,22 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa
}
#endif
// Found a break
bot = min(max(bheight, realbot), top);
#ifdef ESLOPE
if (endbheight > endtop)
endbot = endtop;
#endif
if (bheight >= top)
continue;
//Found a break;
bot = bheight;
if (bot < realbot)
bot = realbot;
#ifdef ESLOPE
endbot = min(max(endbheight, endrealbot), endtop);
#endif
Surf->PolyColor.s.alpha = alpha;
@@ -1125,7 +1264,7 @@ void HWR_DrawSkyWallList()
HWD.pfnUnSetShader();
for (i = 0; i < skyWallVertexArraySize; i++)
{
HWD.pfnDrawPolygon(&surf, skyWallVertexArray + i * 4, 4, PF_Occlude|PF_Invisible|PF_NoTexture);
HWD.pfnDrawPolygon(&surf, skyWallVertexArray + i * 4, 4, PF_Occlude|PF_Invisible|PF_NoTexture, false);
}
}
@@ -1297,8 +1436,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT));
}
lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
colormap = gr_frontsector->extra_colormap;
lightnum = gr_frontsector->lightlevel;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
if (gr_frontsector)
Surf.PolyColor.s.alpha = 255;
@@ -2119,8 +2259,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
blendmode = PF_Fog|PF_NoTexture;
lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
colormap = rover->master->frontsector->extra_colormap;
lightnum = rover->master->frontsector->lightlevel;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
@@ -2242,8 +2384,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
blendmode = PF_Fog|PF_NoTexture;
lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
colormap = rover->master->frontsector->extra_colormap;
lightnum = rover->master->frontsector->lightlevel;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
@@ -2950,8 +3093,8 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t
else
blendmode |= PF_Masked|PF_Modulated;
HWD.pfnSetShader(1); // floor shader
HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode);
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, false);
}
void HWR_AddPolyObjectPlanes(void)
@@ -3749,8 +3892,8 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
if (sSurf.PolyColor.s.alpha > floorheight/4)
{
sSurf.PolyColor.s.alpha = (UINT8)(sSurf.PolyColor.s.alpha - floorheight/4);
HWD.pfnSetShader(1); // floor shader
HWD.pfnDrawPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated);
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
HWD.pfnDrawPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated, false);
}
}
@@ -3825,7 +3968,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
FOutVector baseWallVerts[4]; // This is what the verts should end up as
GLPatch_t *gpatch;
FSurfaceInfo Surf;
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES);
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES);
extracolormap_t *colormap;
FUINT lightlevel;
FBITFIELD blend = 0;
@@ -3849,7 +3992,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
this_scale = FIXED_TO_FLOAT(spr->mobj->scale);
if (hires)
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)spr->mobj->skin)->highresscale);
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale);
gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE);
@@ -4116,8 +4259,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
Surf.PolyColor.s.alpha = alpha;
HWD.pfnSetShader(3); // sprite shader
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated);
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, false);
top = bot;
#ifdef ESLOPE
@@ -4156,8 +4299,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
Surf.PolyColor.s.alpha = alpha;
HWD.pfnSetShader(3); // sprite shader
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated);
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, false);
}
// -----------------+
@@ -4171,11 +4314,11 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
FOutVector wallVerts[4];
GLPatch_t *gpatch; // sprite patch converted to hardware
FSurfaceInfo Surf;
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES);
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES);
if (spr->mobj)
this_scale = FIXED_TO_FLOAT(spr->mobj->scale);
if (hires)
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)spr->mobj->skin)->highresscale);
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale);
if (!spr->mobj)
return;
@@ -4309,8 +4452,8 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
blend = PF_Translucent|PF_Occlude;
}
HWD.pfnSetShader(3); // sprite shader
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated);
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, false);
}
}
@@ -4403,8 +4546,8 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
blend = PF_Translucent|PF_Occlude;
}
HWD.pfnSetShader(3); // sprite shader
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated);
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, false);
}
// --------------------------------------------------------------------------
@@ -4722,8 +4865,19 @@ void HWR_DrawSprites(void)
else
if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
{
md2_t *md2;
if (spr->mobj->localskin)
{
if (spr->mobj->skinlocal)
md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins];
else
md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins];
}
else
md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins];
// 8/1/19: Only don't display player models if no default SPR_PLAY is found.
if (!cv_grmdls.value || ((md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound || md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale < 0.0f) && ((!cv_grfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN])
if (!cv_grmdls.value || ((md2->notfound || md2->scale < 0.0f) && ((!cv_grfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN])
HWR_DrawSprite(spr);
else
HWR_DrawMD2(spr);
@@ -4970,7 +5124,7 @@ void HWR_ProjectSprite(mobj_t *thing)
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
if (thing->skin && thing->sprite == SPR_PLAY)
{
sprdef = &((skin_t *)thing->skin)->spritedef;
sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef;
#ifdef ROTSPRITE
sprinfo = &spriteinfo[thing->sprite];
#endif
@@ -5045,8 +5199,8 @@ void HWR_ProjectSprite(mobj_t *thing)
}
}
if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES)
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)thing->skin)->highresscale);
if (thing->skin && ((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->flags & SF_HIRES)
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->highresscale);
spr_width = spritecachedinfo[lumpoff].width;
spr_height = spritecachedinfo[lumpoff].height;
@@ -5065,7 +5219,7 @@ void HWR_ProjectSprite(mobj_t *thing)
rollsum = (thing->rollangle)+(thing->sloperoll);
rollangle = R_GetRollAngle(rollsum);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
if (rotsprite != NULL)
{
@@ -5205,10 +5359,7 @@ void HWR_ProjectSprite(mobj_t *thing)
if (thing->colorized)
vis->colormap = R_GetTranslationColormap(TC_RAINBOW, thing->color, GTC_CACHE);
else if (thing->skin && thing->sprite == SPR_PLAY) // This thing is a player!
{
size_t skinnum = (skin_t*)thing->skin-skins;
vis->colormap = R_GetTranslationColormap((INT32)skinnum, thing->color, GTC_CACHE);
}
vis->colormap = R_GetLocalTranslationColormap(thing->skin, thing->localskin, thing->color, GTC_CACHE, thing->skinlocal);
else
vis->colormap = R_GetTranslationColormap(TC_DEFAULT, thing->color, GTC_CACHE);
}
@@ -5696,8 +5847,18 @@ void RecursivePortalRendering(portal_t *rootportal, const float fpov, player_t *
HWR_SetTransform(fpov, player);// restore transform
}
gr_collect_skywalls = false;
ps_numsprites.value.i = gr_visspritecount;
PS_START_TIMING(ps_hw_spritesorttime);
HWR_SortVisSprites();
PS_STOP_TIMING(ps_hw_spritesorttime);
PS_START_TIMING(ps_hw_spritedrawtime);
HWR_DrawSprites();
PS_STOP_TIMING(ps_hw_spritedrawtime);
ps_numdrawnodes.value.i = 0;
ps_hw_nodesorttime.value.p = 0;
ps_hw_nodedrawtime.value.p = 0;
HWR_RenderDrawNodes();
}
// free memory from portal list allocated by calls to Add2Lines
@@ -5713,6 +5874,7 @@ void RecursivePortalRendering(portal_t *rootportal, const float fpov, player_t *
// TODO: is it okay if stencil test is on all the time even when its not needed?
}
// ==========================================================================
// Render the current frame.
// ==========================================================================
@@ -5833,7 +5995,6 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_grshaders.value);
HWD.pfnSetShader(0);
//drawcount = 0;
validcount++;
portalclipline = NULL;
@@ -5871,18 +6032,8 @@ void HWR_RenderSinglePortal(portal_t *portal, size_t portalnum, float fpov, play
portalcullsector = gr_portalcullsectors[portalnum];
HWR_RenderBSPNode((INT32)numnodes - 1);
// Draw MD2 and sprites
ps_numsprites.value.i = gr_visspritecount;
PS_START_TIMING(ps_hw_spritesorttime);
HWR_SortVisSprites();
PS_STOP_TIMING(ps_hw_spritesorttime);
PS_START_TIMING(ps_hw_spritedrawtime);
HWR_DrawSprites();
PS_STOP_TIMING(ps_hw_spritedrawtime);
ps_numdrawnodes.value.i = 0;
ps_hw_nodesorttime.value.p = 0;
ps_hw_nodedrawtime.value.p = 0;
HWR_RenderDrawNodes();
}
@@ -5951,6 +6102,8 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_portalline);
CV_RegisterVar(&cv_portalonly);
CV_RegisterVar(&cv_secbright);
CV_RegisterVar(&cv_grpaletteshader);
CV_RegisterVar(&cv_grflashpal);
}
// --------------------------------------------------------------------------
@@ -5992,7 +6145,6 @@ void HWR_Startup(void)
}
}
// --------------------------------------------------------------------------
// Free resources allocated by the hardware renderer
// --------------------------------------------------------------------------
@@ -6014,8 +6166,6 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend,
pSurf->PolyColor.s.alpha = alpha; // put the alpha back after lighting
HWD.pfnSetShader(2); // wall shader
if (blend & PF_Environment)
blendmode |= PF_Occlude; // PF_Occlude must be used for solid objects
@@ -6027,7 +6177,9 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend,
blendmode |= PF_Modulated; // No PF_Occlude means overlapping (incorrect) transparency
HWD.pfnDrawPolygon(pSurf, wallVerts, 4, blendmode);
if (!fogwall)
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
HWD.pfnDrawPolygon(pSurf, wallVerts, 4, blendmode, false);
#ifdef WALLSPLATS
if (gr_curline->linedef->splats && cv_splats.value)
@@ -6058,7 +6210,7 @@ void HWR_DoPostProcessor(player_t *player)
// Armageddon Blast Flash!
// Could this even be considered postprocessor?
if (player->flashcount)
if (player->flashcount && !cv_grpaletteshader.value || player->flashcount && cv_grpaletteshader.value && !cv_grflashpal.value)
{
FOutVector v[4];
FSurfaceInfo Surf;
@@ -6078,7 +6230,7 @@ void HWR_DoPostProcessor(player_t *player)
Surf.PolyColor.s.alpha = 0xc0; // match software mode
HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Translucent|PF_NoTexture|PF_NoDepthTest);
HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Translucent|PF_NoTexture|PF_NoDepthTest, false);
}
if (!cv_grscreentextures.value) // screen textures are needed for the rest of the effects
@@ -6187,6 +6339,8 @@ void HWR_MakeScreenFinalTexture(void)
void HWR_DrawScreenFinalTexture(int width, int height)
{
if (gr_use_palette_shader)
HWD.pfnSetShader(11); //post processing
HWD.pfnDrawScreenFinalTexture(width, height);
}
+4
View File
@@ -142,6 +142,8 @@ void HWR_AddLine(seg_t *line);
boolean HWR_CheckBBox(fixed_t *bspcoord);
void HWR_RenderDrawNodes(void);
void HWR_ClearLightTableCache(void);
// hw_main.c: Sprites
void HWR_AddSprites(sector_t *sec);
void HWR_ProjectSprite(mobj_t *thing);
@@ -179,6 +181,8 @@ extern consvar_t cv_grfallbackplayermodel;
extern consvar_t cv_grbatching;
extern consvar_t cv_grrenderdistance;
extern consvar_t cv_grusecustomshaders;
extern consvar_t cv_grpaletteshader;
extern consvar_t cv_grflashpal;
extern consvar_t cv_grportals;
extern consvar_t cv_nostencil;
extern consvar_t cv_secbright;
+46 -14
View File
@@ -75,6 +75,7 @@
md2_t md2_models[NUMSPRITES];
md2_t md2_playermodels[MAXSKINS];
md2_t md2_localplayermodels[MAXSKINS];
/*
@@ -487,6 +488,13 @@ void HWR_InitMD2(void)
md2_playermodels[s].skin = -1;
md2_playermodels[s].notfound = true;
md2_playermodels[s].error = false;
md2_localplayermodels[s].scale = -1.0f;
md2_localplayermodels[s].model = NULL;
md2_localplayermodels[s].grpatch = NULL;
md2_localplayermodels[s].skin = -1;
md2_localplayermodels[s].notfound = true;
md2_localplayermodels[s].error = false;
}
for (i = 0; i < NUMSPRITES; i++)
{
@@ -559,11 +567,12 @@ md2found:
fclose(f);
}
void HWR_AddPlayerMD2(int skin) // For MD2's that were added after startup
void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added after startup
{
FILE *f;
char name[20], filename[32];
float scale, offset;
md2_t *md2s;
if (nomd2s)
return;
@@ -585,22 +594,23 @@ void HWR_AddPlayerMD2(int skin) // For MD2's that were added after startup
}
}
// Check for any MD2s that match the names of sprite names!
md2s = ( (local) ? md2_localplayermodels : md2_playermodels );
// Check for any MD2s that match the names of player skins!
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
{
if (stricmp(name, skins[skin].name) == 0)
if (stricmp(name, ( (local) ? localskins : skins )[skin].name) == 0)
{
md2_playermodels[skin].skin = skin;
md2_playermodels[skin].scale = scale;
md2_playermodels[skin].offset = offset;
md2_playermodels[skin].notfound = false;
strcpy(md2_playermodels[skin].filename, filename);
md2s[skin].skin = skin;
md2s[skin].scale = scale;
md2s[skin].offset = offset;
md2s[skin].notfound = false;
strcpy(md2s[skin].filename, filename);
goto playermd2found;
}
}
//CONS_Printf("MD2 for player skin %s not found\n", skins[skin].name);
md2_playermodels[skin].notfound = true;
md2s[skin].notfound = true;
playermd2found:
fclose(f);
}
@@ -1154,6 +1164,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
{
R_InterpolateMobjState(spr->mobj, FRACUNIT, &interp);
}
md2_t *md2s;
int skinnum;
// Apparently people don't like jump frames like that, so back it goes
//if (tics > durs)
@@ -1168,13 +1180,33 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
// dont forget to enabled the depth test because we can't do this like
// before: polygons models are not sorted
/* fuck you */
if (spr->mobj->localskin)
{
if (spr->mobj->skinlocal)
{
md2s = md2_localplayermodels;
skinnum = (skin_t *)spr->mobj->localskin - localskins;
}
else
{
md2s = md2_playermodels;
skinnum = (skin_t *)spr->mobj->localskin - skins;
}
}
else
{
md2s = md2_playermodels;
skinnum = (skin_t *)spr->mobj->skin - skins;
}
// 1. load model+texture if not already loaded
// 2. draw model with correct position, rotation,...
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && !md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound) // Use the player MD2 list if the mobj has a skin and is using the player sprites
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && !md2s[skinnum].notfound) // Use the player MD2 list if the mobj has a skin and is using the player sprites
{
md2 = &md2_playermodels[(skin_t*)spr->mobj->skin-skins];
md2->skin = (skin_t*)spr->mobj->skin-skins;
md2 = &md2s[skinnum];
md2->skin = skinnum;
sprinfo = &spriteinfo[spr->mobj->sprite];
}
else
@@ -1239,7 +1271,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
skinnum = TC_RAINBOW;
else
{
skinnum = (INT32)((skin_t*)spr->mobj->skin-skins);
skinnum = (INT32)((skin_t*)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ) - ( (spr->mobj->skinlocal) ? localskins : skins ));
}
}
else skinnum = TC_DEFAULT;
@@ -1306,7 +1338,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
p.z = FIXED_TO_FLOAT(interp.z);
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
sprdef = &((skin_t *)spr->mobj->skin)->spritedef;
sprdef = &((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->spritedef;
else
sprdef = &sprites[spr->mobj->sprite];
+2 -1
View File
@@ -37,10 +37,11 @@ typedef struct
extern md2_t md2_models[NUMSPRITES];
extern md2_t md2_playermodels[MAXSKINS];
extern md2_t md2_localplayermodels[MAXSKINS];
void HWR_InitMD2(void);
void HWR_DrawMD2(gr_vissprite_t *spr);
void HWR_AddPlayerMD2(INT32 skin);
void HWR_AddPlayerMD2(INT32 skin, boolean local);
void HWR_AddSpriteMD2(size_t spritenum);
#endif // _HW_MD2_H_
+419 -30
View File
@@ -26,10 +26,15 @@
#include "r_opengl.h"
#include "r_vbo.h"
#include "../../v_video.h" // pLocalPalette
#include "../../r_data.h" // NearestColor
#include "../../p_tick.h" // for leveltime (NOTE: THIS IS BAD, FIGURE OUT HOW TO PROPERLY IMPLEMENT gl_leveltime)
#include "../../i_system.h" // for I_GetPreciseTime (batching time measurements)
// Eeeeh not sure is this right way, but it works
#include "../hw_main.h"
// Eeeeh not sure is this right way, but it works < sry :c
extern consvar_t cv_grusecustomshaders;
extern fixed_t fovtan; // also extremely bad, I'm just too lazy!!!
@@ -44,12 +49,15 @@ struct GLRGBAFloat
GLfloat alpha;
};
typedef struct GLRGBAFloat GLRGBAFloat;
static const GLubyte white[4] = { 255, 255, 255, 255 };
// ==========================================================================
// CONSTANTS
// ==========================================================================
// With OpenGL 1.1+, the first texture should be 1
#define NOTEXTURE_NUM 0
@@ -70,8 +78,17 @@ static GLuint tex_downloaded = 0;
static GLfloat fov = 90.0f;
static FBITFIELD CurrentPolyFlags;
static FTextureInfo* gr_cachetail = NULL;
static FTextureInfo* gr_cachehead = NULL;
static FTextureInfo *gr_cachetail = NULL;
static FTextureInfo *gr_cachehead = NULL;
typedef struct LightTableCacheEntry_s
{
GLuint id;
struct LightTableCacheEntry_s *next;
} LightTableCacheEntry_t;
LightTableCacheEntry_t *ltcachehead = NULL;
LightTableCacheEntry_t *ltcachetail = NULL;
RGBA_t myPaletteData[256];
GLint screen_width = 0; // used by Draw2DLine()
@@ -235,6 +252,7 @@ FUNCPRINTF void GL_DBG_Printf(const char *format, ...)
#define pglTexEnvi glTexEnvi
#define pglTexParameteri glTexParameteri
#define pglTexImage2D glTexImage2D
#define pglTexImage3D glTexImage3D
/* Fog */
#define pglFogf glFogf
@@ -355,6 +373,8 @@ typedef void (APIENTRY * PFNglTexParameteri) (GLenum target, GLenum pname, GLint
static PFNglTexParameteri pglTexParameteri;
typedef void (APIENTRY * PFNglTexImage2D) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
static PFNglTexImage2D pglTexImage2D;
typedef void (APIENTRY * PFNglTexImage3D) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
static PFNglTexImage3D pglTexImage3D;
/* Fog */
typedef void (APIENTRY * PFNglFogf) (GLenum pname, GLfloat param);
@@ -511,6 +531,7 @@ typedef void (APIENTRY *PFNglLinkProgram) (GLuint);
typedef void (APIENTRY *PFNglGetProgramiv) (GLuint, GLenum, GLint*);
typedef void (APIENTRY *PFNglUseProgram) (GLuint);
typedef void (APIENTRY *PFNglUniform1i) (GLint, GLint);
typedef void (APIENTRY *PFNglUniform1iv) (GLint, GLsizei, const GLint*);
typedef void (APIENTRY *PFNglUniform1f) (GLint, GLfloat);
typedef void (APIENTRY *PFNglUniform2f) (GLint, GLfloat, GLfloat);
typedef void (APIENTRY *PFNglUniform3f) (GLint, GLfloat, GLfloat, GLfloat);
@@ -532,6 +553,7 @@ static PFNglLinkProgram pglLinkProgram;
static PFNglGetProgramiv pglGetProgramiv;
static PFNglUseProgram pglUseProgram;
static PFNglUniform1i pglUniform1i;
static PFNglUniform1iv pglUniform1iv;
static PFNglUniform1f pglUniform1f;
static PFNglUniform2f pglUniform2f;
static PFNglUniform3f pglUniform3f;
@@ -555,6 +577,10 @@ static boolean gl_shaderprogramchanged = true;
static boolean gl_batching = false;// are we currently collecting batches?
static GLint gl_palette[768];
static INT32 gl_use_palette_shader = 0;
boolean gl_palette_initialized = false;
static INT32 gl_enable_screen_textures = 1;
static GLint gl_portal_stencil_level = 0;
@@ -571,10 +597,15 @@ typedef enum
gluniform_lighting,
gluniform_fade_start,
gluniform_fade_end,
// misc. (custom shaders)
// palette rendering
gluniform_palette,
gluniform_color_lookup,
gluniform_lighttable_tex,
// misc.
gluniform_leveltime,
gluniform_max,
} gluniform_t;
@@ -594,6 +625,18 @@ static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS];
// GLSL Software fragment shader
//
#define GLSL_DOOM_COLORMAP_floors \
"float R_DoomColormap(float light, float z)\n" \
"{\n" \
"float lightnum = clamp(light / 17.0, 0.0, 15.0);\n" \
"float lightz = clamp(z / 16.0, 0.0, 127.0);\n" \
"float startmap = (15.0 - lightnum) * 4.0;\n" \
"float scale = 160.0 / (lightz + 1.0);\n" \
"return startmap * 1.06 - scale * 0.5 * 1.15;\n" \
"}\n"
// 1.06 and 1.15 were chosen when trying to match software lighting in a test map
#define GLSL_DOOM_COLORMAP \
"float R_DoomColormap(float light, float z)\n" \
"{\n" \
@@ -604,6 +647,16 @@ static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS];
"return startmap - scale * 0.5;\n" \
"}\n"
#define GLSL_DOOM_COLORMAP_walls \
"float R_DoomColormap(float light, float z)\n" \
"{\n" \
"float lightnum = clamp(light / 17.0, 0.0, 15.0);\n" \
"float lightz = clamp(z / 16.0, 0.0, 127.0);\n" \
"float startmap = (15.0 - lightnum) * 4.0;\n" \
"float scale = 160.0 / (lightz + 1.0);\n" \
"return startmap * 1.05 - scale * 1.0 * 1.1;\n" \
"}\n"
#define GLSL_DOOM_LIGHT_EQUATION \
"float R_DoomLightingEquation(float light)\n" \
"{\n" \
@@ -631,16 +684,16 @@ static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS];
"}\n" \
"final_color = mix(final_color, fade_color, darkness);\n"
#define GLSL_SOFTWARE_FRAGMENT_SHADER \
#define GLSL_SOFTWARE_UNIFORMS \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"uniform vec4 tint_color;\n" \
"uniform vec4 fade_color;\n" \
"uniform float lighting;\n" \
"uniform float fade_start;\n" \
"uniform float fade_end;\n" \
GLSL_DOOM_COLORMAP \
GLSL_DOOM_LIGHT_EQUATION \
"uniform float fade_end;\n"
#define GLSL_SOFTWARE_MAIN \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
"vec4 base_color = texel * poly_color;\n" \
@@ -649,7 +702,59 @@ static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS];
GLSL_SOFTWARE_FADE_EQUATION \
"final_color.a = texel.a * poly_color.a;\n" \
"gl_FragColor = final_color;\n" \
"}\0"
"}\n"
#define GLSL_SOFTWARE_FRAGMENT_SHADER_FLOORS \
GLSL_SOFTWARE_UNIFORMS \
GLSL_DOOM_COLORMAP_floors \
GLSL_DOOM_LIGHT_EQUATION \
GLSL_SOFTWARE_MAIN \
"\0"
#define GLSL_SOFTWARE_FRAGMENT_SHADER_WALLS \
GLSL_SOFTWARE_UNIFORMS \
GLSL_DOOM_COLORMAP_walls \
GLSL_DOOM_LIGHT_EQUATION \
GLSL_SOFTWARE_MAIN \
"\0"
#define GLSL_SOFTWARE_PAL_UNIFORMS \
"uniform sampler2D tex;\n" \
"uniform sampler2D lighttable_tex;\n" \
"uniform sampler3D lookup_tex;\n" \
"uniform int palette[768];\n" \
"uniform vec4 poly_color;\n" \
"uniform float lighting;\n" \
#define GLSL_SOFTWARE_PAL_MAIN \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
"int tex_pal_idx = int(texture3D(lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0);\n" \
"float z = gl_FragCoord.z / gl_FragCoord.w;\n" \
"int light_y = int(clamp(floor(R_DoomColormap(lighting, z)), 0.0, 31.0));\n" \
"vec2 lighttable_coord = vec2((float(tex_pal_idx) + 0.5) / 256.0, (float(light_y) + 0.5) / 32.0);\n" \
"int final_idx = int(texture2D(lighttable_tex, lighttable_coord)[0] * 255.0);\n" \
"vec4 final_color = vec4(float(palette[final_idx*3])/255.0, float(palette[final_idx*3+1])/255.0, float(palette[final_idx*3+2])/255.0, 1.0);\n" \
"final_color.a = texel.a * poly_color.a;\n" \
"gl_FragColor = final_color;\n" \
"}\n"
#define GLSL_SOFTWARE_PAL_FRAGMENT_SHADER_FLOORS \
GLSL_SOFTWARE_PAL_UNIFORMS \
GLSL_DOOM_COLORMAP_floors \
GLSL_SOFTWARE_PAL_MAIN \
"\0"
#define GLSL_SOFTWARE_PAL_FRAGMENT_SHADER_WALLS \
GLSL_SOFTWARE_PAL_UNIFORMS \
GLSL_DOOM_COLORMAP_walls \
GLSL_SOFTWARE_PAL_MAIN \
"\0"
#define GLSL_SOFTWARE_PAL_FRAGMENT_SHADER_POSTPROCESS \
GLSL_SOFTWARE_PAL_UNIFORMS \
GLSL_SOFTWARE_PAL_MAIN \
"\0"
//
// Water surface shader
@@ -708,6 +813,20 @@ static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS];
GLSL_SOFTWARE_FADE_EQUATION \
"gl_FragColor = final_color;\n" \
"}\0"
//
// Palette color quantization shader
//
#define GLSL_PALETTE_FRAGMENT_SHADER \
"uniform sampler2D tex;\n" \
"uniform sampler3D lookup_tex;\n" \
"uniform int palette[768];\n" \
"void main(void) {\n" \
"vec3 texel = vec3(texture2D(tex, gl_TexCoord[0].st));\n" \
"int pal_idx = int(texture3D(lookup_tex, vec3((63.0/64.0) * texel + 1.0 / 128.0))[0] * 255.0);\n" \
"gl_FragColor = vec4(float(palette[pal_idx*3])/255.0, float(palette[pal_idx*3+1])/255.0, float(palette[pal_idx*3+2])/255.0, 1.0);\n" \
"}\0"
//
// GLSL generic fragment shader
@@ -725,16 +844,16 @@ static const char *fragment_shaders[] = {
GLSL_DEFAULT_FRAGMENT_SHADER,
// Floor fragment shader
GLSL_SOFTWARE_FRAGMENT_SHADER,
GLSL_SOFTWARE_FRAGMENT_SHADER_FLOORS,
// Wall fragment shader
GLSL_SOFTWARE_FRAGMENT_SHADER,
GLSL_SOFTWARE_FRAGMENT_SHADER_WALLS,
// Sprite fragment shader
GLSL_SOFTWARE_FRAGMENT_SHADER,
GLSL_SOFTWARE_FRAGMENT_SHADER_WALLS,
// Model fragment shader
GLSL_SOFTWARE_FRAGMENT_SHADER,
GLSL_SOFTWARE_FRAGMENT_SHADER_WALLS,
// Water fragment shader
GLSL_WATER_FRAGMENT_SHADER,
@@ -747,6 +866,15 @@ static const char *fragment_shaders[] = {
"void main(void) {\n"
"gl_FragColor = texture2D(tex, gl_TexCoord[0].st);\n"
"}\0",
// Palette fragment shader
GLSL_PALETTE_FRAGMENT_SHADER,
GLSL_SOFTWARE_PAL_FRAGMENT_SHADER_FLOORS,
GLSL_SOFTWARE_PAL_FRAGMENT_SHADER_WALLS,
GLSL_SOFTWARE_PAL_FRAGMENT_SHADER_POSTPROCESS,
NULL,
};
@@ -792,6 +920,13 @@ static const char *vertex_shaders[] = {
// Sky vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
// Palette vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
GLSL_DEFAULT_VERTEX_SHADER,
GLSL_DEFAULT_VERTEX_SHADER,
NULL,
};
@@ -800,6 +935,7 @@ static const char *vertex_shaders[] = {
void SetupGLFunc4(void)
{
pglTexImage3D = GetGLFunc("glTexImage3D");
pglActiveTexture = GetGLFunc("glActiveTexture");
pglMultiTexCoord2f = GetGLFunc("glMultiTexCoord2f");
pglClientActiveTexture = GetGLFunc("glClientActiveTexture");
@@ -826,6 +962,7 @@ void SetupGLFunc4(void)
pglGetProgramiv = GetGLFunc("glGetProgramiv");
pglUseProgram = GetGLFunc("glUseProgram");
pglUniform1i = GetGLFunc("glUniform1i");
pglUniform1iv = GetGLFunc("glUniform1iv");
pglUniform1f = GetGLFunc("glUniform1f");
pglUniform2f = GetGLFunc("glUniform2f");
pglUniform3f = GetGLFunc("glUniform3f");
@@ -858,12 +995,13 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
const GLchar* vert_shader = vertex_shaders[i];
const GLchar* frag_shader = fragment_shaders[i];
boolean custom = cv_grusecustomshaders.value && ((gl_customvertexshaders[i] || gl_customfragmentshaders[i]) && (i > 0));
// 18032019
if (cv_grusecustomshaders.value && gl_customvertexshaders[i])
vert_shader = gl_customvertexshaders[i];
if (cv_grusecustomshaders.value && gl_customfragmentshaders[i])
frag_shader = gl_customfragmentshaders[i];
if (i >= MAXSHADERS)
break;
@@ -946,11 +1084,38 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
shader->uniforms[gluniform_lighting] = GETUNI("lighting");
shader->uniforms[gluniform_fade_start] = GETUNI("fade_start");
shader->uniforms[gluniform_fade_end] = GETUNI("fade_end");
// palette rendering
shader->uniforms[gluniform_palette] = GETUNI("palette");
shader->uniforms[gluniform_color_lookup] = GETUNI("lookup_tex");
shader->uniforms[gluniform_lighttable_tex] = GETUNI("lighttable_tex");
// misc. (custom shaders)
shader->uniforms[gluniform_leveltime] = GETUNI("leveltime");
#undef GETUNI
// set permanent uniform values
#define UNIFORM_1(uniform, a, function) \
if (uniform != -1) \
function (uniform, a);
#define UNIFORM_2(uniform, a, b, function) \
if (uniform != -1) \
function (uniform, a, b);
pglUseProgram(shader->program);
// texture unit numbers for the samplers used for palette rendering
UNIFORM_2(shader->uniforms[gluniform_palette], 768, gl_palette, pglUniform1iv);
UNIFORM_1(shader->uniforms[gluniform_color_lookup], 1, pglUniform1i);
UNIFORM_1(shader->uniforms[gluniform_lighttable_tex], 2, pglUniform1i);
pglUseProgram(0);
#undef UNIFORM_1
#undef UNIFORM_2
}
#endif
return true;
@@ -962,7 +1127,9 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boolean fragment)
{
#ifdef GL_SHADERS
if (!pglUseProgram) return;
if (!pglUseProgram)
return;
if (number < 1 || number > MAXSHADERS)
I_Error("LoadCustomShader(): cannot load shader %d (max %d)", number, MAXSHADERS);
@@ -984,8 +1151,14 @@ EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boo
EXPORT void HWRAPI(InitCustomShaders) (void)
{
#ifdef GL_SHADERS
KillShaders();
LoadShaders();
if (gl_use_palette_shader)
{
InitPalette(0, false);
}
#endif
}
@@ -1022,6 +1195,105 @@ EXPORT void HWRAPI(KillShaders) (void)
// unused.........................
}
GLuint palette_tex_num;
// length of one side of lookup texture
// smallest separation between all the colors in the srb2 palette is 6, so
// possibly a 64x64x64 lookup texture might be enough for 100% correct colors
// (min separation for 64^3 size is 4)
#define LUT_SIZE 64
#define STEP_SIZE (256/LUT_SIZE)
// the +2 in the NearestColor call also needs to be adjusted if LUT_SIZE is changed!
// the hardcoded values in the shader also need to be adjusted if LUT_SIZE is changed!
void InitPalette(int flashnum, boolean skiplut)
{
int i, r, g, b;
//Hudler: 16/10/99: added for OpenGL gamma correction
RGBA_t gamma_correction = {0x7F7F7F7F};
//Hurdler 16/10/99: added for OpenGL gamma correction
gamma_correction.s.red = (UINT8)cv_grgammared.value;
gamma_correction.s.green = (UINT8)cv_grgammagreen.value;
gamma_correction.s.blue = (UINT8)cv_grgammablue.value;
// init the palette
int flashoffset = flashnum*256;
for (i = 0+flashoffset; i < 256+flashoffset; i++)
{
int fi = i-flashoffset;
// gamma correction
int pr, pg, pb;
pr = (UINT8)MIN((pLocalPalette[i].s.red*gamma_correction.s.red)/127, 255);
pg = (UINT8)MIN((pLocalPalette[i].s.green*gamma_correction.s.green)/127, 255);
pb = (UINT8)MIN((pLocalPalette[i].s.blue*gamma_correction.s.blue)/127, 255);
// crush to 16-bit rgb565, like software currently does
float fred = (float)(pr >> 3);
float fgreen = (float)(pg >> 2);
float fblue = (float)(pb >> 3);
// restore to rgb888
gl_palette[fi*3] = (GLint)(fred / 31.0f * 255.0f);
gl_palette[fi*3+1] = (GLint)(fgreen / 63.0f * 255.0f);
gl_palette[fi*3+2] = (GLint)(fblue / 31.0f * 255.0f);
}
if (!skiplut)
{
// init the palette conversion lookup texture
GLubyte *pal_lookup_tex = malloc(LUT_SIZE*LUT_SIZE*LUT_SIZE*sizeof(GLubyte));
if (!pal_lookup_tex)
I_Error("Failed to allocate memory for generating palette lookup texture.");
for (b = 0; b < LUT_SIZE; b++)
{
for (g = 0; g < LUT_SIZE; g++)
{
for (r = 0; r < LUT_SIZE; r++)
{
pal_lookup_tex[b*LUT_SIZE*LUT_SIZE+g*LUT_SIZE+r] = NearestColor(r*STEP_SIZE+0, g*STEP_SIZE+0, b*STEP_SIZE+0);
}
}
}
pglGenTextures(1, &palette_tex_num);
pglBindTexture(GL_TEXTURE_3D, palette_tex_num);
pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if (!pglTexImage3D)
I_Error("pglTexImage3D is NULL!");
pglTexImage3D(GL_TEXTURE_3D, 0, GL_R8, LUT_SIZE, LUT_SIZE, LUT_SIZE, 0, GL_RED, GL_UNSIGNED_BYTE, pal_lookup_tex);
free(pal_lookup_tex);
}
#undef STEP_SIZE
pglUseProgram(gl_shaderprograms[8].program);
pglUniform1i(gl_shaderprograms[8].uniforms[gluniform_color_lookup], 1); // bind sampler to second texture unit
pglUniform1iv(gl_shaderprograms[8].uniforms[gluniform_palette], 768, gl_palette);
// bind the palette to the fancy shader here
pglUseProgram(gl_shaderprograms[9].program);
pglUniform1iv(gl_shaderprograms[9].uniforms[gluniform_palette], 768, gl_palette);
// bind tex unit 2 to lighttable tex
pglUniform1i(gl_shaderprograms[9].uniforms[gluniform_lighttable_tex], 2);
pglUniform1i(gl_shaderprograms[9].uniforms[gluniform_color_lookup], 1);
// bind the palette to the fancy shader here
pglUseProgram(gl_shaderprograms[10].program);
pglUniform1iv(gl_shaderprograms[10].uniforms[gluniform_palette], 768, gl_palette);
// bind tex unit 2 to lighttable tex
pglUniform1i(gl_shaderprograms[10].uniforms[gluniform_lighttable_tex], 2);
pglUniform1i(gl_shaderprograms[10].uniforms[gluniform_color_lookup], 1);
pglUseProgram(0);
pglBindTexture(GL_TEXTURE_3D, 0);
// bind 3d lookup to unit 1, maybe it can stay there
pglActiveTexture(GL_TEXTURE1);
pglBindTexture(GL_TEXTURE_3D, palette_tex_num);
pglActiveTexture(GL_TEXTURE0);
gl_palette_initialized = true;
}
// -----------------+
// SetNoTexture : Disable texture
// -----------------+
@@ -1201,6 +1473,46 @@ EXPORT void HWRAPI(ClearMipMapCache) (void)
Flush();
}
EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable)
{
LightTableCacheEntry_t *cache_entry = malloc(sizeof(LightTableCacheEntry_t));
if (!ltcachetail)
{
ltcachehead = ltcachetail = cache_entry;
}
else
{
ltcachetail->next = cache_entry;
ltcachetail = cache_entry;
}
ltcachetail->next = NULL;
pglGenTextures(1, &ltcachetail->id);
if (!ltcachetail->id)
I_Error("hwr lighttable cache entry id is zero");
pglBindTexture(GL_TEXTURE_2D, ltcachetail->id);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexImage2D(GL_TEXTURE_2D, 0, GL_R8, 256, 32, 0, GL_RED, GL_UNSIGNED_BYTE, lighttable);
// restore previously bound texture
if (!gl_batching)
pglBindTexture(GL_TEXTURE_2D, tex_downloaded);
return ltcachetail->id;
}
// Delete light table textures, ids given before become invalid and must not be used.
EXPORT void HWRAPI(ClearLightTableCache) (void)
{
while (ltcachehead)
{
pglDeleteTextures(1, &ltcachehead->id);
LightTableCacheEntry_t *next = ltcachehead->next;
free(ltcachehead);
ltcachehead = next;
}
ltcachetail = NULL;
}
// -----------------+
// ReadRect : Read a rectangle region of the truecolor framebuffer
@@ -1312,6 +1624,9 @@ EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask,
pglClear(ClearMask);
pglEnableClientState(GL_VERTEX_ARRAY); // We always use this one
pglEnableClientState(GL_TEXTURE_COORD_ARRAY); // And mostly this one, too
if (!gl_palette_initialized)
InitPalette(0, false); // just gonna put this here for now
}
@@ -1822,6 +2137,8 @@ typedef struct
FBITFIELD polyFlags;
GLuint texNum;
GLuint shader;
// this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls
boolean horizonSpecial;
} PolygonArrayEntry;
FOutVector* finalVertexArray = NULL;// contains subset of sorted vertices and texture coordinates to be sent to gpu
@@ -1861,23 +2178,35 @@ EXPORT void HWRAPI(StartBatching) (void)
static int comparePolygons(const void *p1, const void *p2)
{
PolygonArrayEntry* poly1 = &polygonArray[*(const unsigned int*)p1];
PolygonArrayEntry* poly2 = &polygonArray[*(const unsigned int*)p2];
unsigned int index1 = *(const unsigned int*)p1;
unsigned int index2 = *(const unsigned int*)p2;
PolygonArrayEntry* poly1 = &polygonArray[index1];
PolygonArrayEntry* poly2 = &polygonArray[index2];
int diff;
INT64 diff64;
int shader1 = poly1->shader;
int shader2 = poly2->shader;
// make skywalls first in order
if (poly1->polyFlags & PF_NoTexture)
// make skywalls and horizon lines first in order
if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial)
shader1 = -1;
if (poly2->polyFlags & PF_NoTexture)
if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial)
shader2 = -1;
diff = shader1 - shader2;
if (diff != 0) return diff;
// skywalls and horizon lines must retain their order for horizon lines to work
if (shader1 == -1 && shader2 == -1)
return index1 - index2;
diff = poly1->texNum - poly2->texNum;
if (diff != 0) return diff;
if (gl_use_palette_shader)
{
diff = poly1->surf.LightTableId - poly2->surf.LightTableId;
if (diff != 0) return diff;
}
diff = poly1->polyFlags - poly2->polyFlags;
if (diff != 0) return diff;
@@ -1899,20 +2228,26 @@ static int comparePolygons(const void *p1, const void *p2)
static int comparePolygonsNoShaders(const void *p1, const void *p2)
{
PolygonArrayEntry* poly1 = &polygonArray[*(const unsigned int*)p1];
PolygonArrayEntry* poly2 = &polygonArray[*(const unsigned int*)p2];
unsigned int index1 = *(const unsigned int*)p1;
unsigned int index2 = *(const unsigned int*)p2;
PolygonArrayEntry* poly1 = &polygonArray[index1];
PolygonArrayEntry* poly2 = &polygonArray[index2];
int diff;
INT64 diff64;
GLuint texNum1 = poly1->texNum;
GLuint texNum2 = poly2->texNum;
if (poly1->polyFlags & PF_NoTexture)
if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial)
texNum1 = 0;
if (poly2->polyFlags & PF_NoTexture)
if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial)
texNum2 = 0;
diff = texNum1 - texNum2;
if (diff != 0) return diff;
// skywalls and horizon lines must retain their order for horizon lines to work
if (texNum1 == 0 && texNum2 == 0)
return index1 - index2;
diff = poly1->polyFlags - poly2->polyFlags;
if (diff != 0) return diff;
@@ -2010,7 +2345,15 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i
firstFade.alpha = byte2float[currentSurfaceInfo.FadeColor.s.alpha];
if (gl_allowshaders)
{
load_shaders(&currentSurfaceInfo, &firstPoly, &firstTint, &firstFade);
if (gl_use_palette_shader)
{
pglActiveTexture(GL_TEXTURE2);// this stuff could be done better but gonna do it quick like this for now
pglBindTexture(GL_TEXTURE_2D, currentSurfaceInfo.LightTableId);
pglActiveTexture(GL_TEXTURE0);
}
}
if (currentPolyFlags & PF_NoTexture)
currentTexture = 0;
@@ -2121,7 +2464,21 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i
changeState = true;
changePolyFlags = true;
}
if (gl_allowshaders)
if ((gl_allowshaders) && (gl_use_palette_shader))
{
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
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.LightTableId != nextSurfaceInfo.LightTableId)
{
changeState = true;
changeSurfaceInfo = true;
}
}
else if ((gl_allowshaders) && (!gl_use_palette_shader))
{
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
@@ -2251,7 +2608,15 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i
fade.alpha = byte2float[nextSurfaceInfo.FadeColor.s.alpha];
load_shaders(&nextSurfaceInfo, &poly, &tint, &fade);
if (gl_use_palette_shader)
{
pglActiveTexture(GL_TEXTURE2);// this stuff could be done better but gonna do it quick like this for now
pglBindTexture(GL_TEXTURE_2D, nextSurfaceInfo.LightTableId);
pglActiveTexture(GL_TEXTURE0);
}
}
currentSurfaceInfo = nextSurfaceInfo;
changeSurfaceInfo = false;
@@ -2269,7 +2634,7 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i
// -----------------+
// DrawPolygon : Render a polygon, set the texture, set render mode
// -----------------+
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags)
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, boolean horizonSpecial)
{
if (gl_batching)
{
@@ -2309,6 +2674,7 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI
polygonArray[polygonArraySize].polyFlags = PolyFlags;
polygonArray[polygonArraySize].texNum = tex_downloaded;
polygonArray[polygonArraySize].shader = gl_currentshaderprogram;
polygonArray[polygonArraySize].horizonSpecial = horizonSpecial;
polygonArraySize++;
memcpy(&unsortedVertexArray[unsortedVertexArraySize], pOutVerts, iNumPts * sizeof(FOutVector));
@@ -2350,6 +2716,13 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI
fade.green = byte2float[pSurf->FadeColor.s.green];
fade.blue = byte2float[pSurf->FadeColor.s.blue];
fade.alpha = byte2float[pSurf->FadeColor.s.alpha];
if (gl_use_palette_shader && gl_allowshaders)
{
pglActiveTexture(GL_TEXTURE2);
pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId);
pglActiveTexture(GL_TEXTURE0);
}
}
load_shaders(pSurf, &poly, &tint, &fade);
@@ -2692,6 +3065,10 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
break;
}
break;
case HWD_SET_PALETTE_SHADER_ENABLED:
gl_use_palette_shader = Value;
break;
case HWD_SET_TEXTUREFILTERMODE:
switch (Value)
@@ -3760,6 +4137,12 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
clearColour.alpha = 1;
ClearBuffer(true, false, false, &clearColour);
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
if (gl_use_palette_shader && cv_grshaders.value)
{
pglUseProgram(gl_shaderprograms[8].program); // palette shader
pglActiveTexture(GL_TEXTURE1);
}
pglColor4ubv(white);
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
@@ -3768,6 +4151,12 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
tex_downloaded = finalScreenTexture;
if (gl_use_palette_shader && cv_grshaders.value)
{
pglUseProgram(0);
pglActiveTexture(GL_TEXTURE0);
}
}
#endif //HWRENDER
+4
View File
@@ -133,4 +133,8 @@ typedef enum
GLF_NOTEXENV = 0x02,
} oglflags_t;
// in order for custom playpals n shit to work properly
extern boolean gl_palette_initialized;
void InitPalette(int flashnum, boolean skiplut);
#endif
+1 -1
View File
@@ -40,7 +40,7 @@ extern UINT8 keyboard_started;
\return free memory in the system
*/
UINT32 I_GetFreeMem(UINT32 *total);
size_t I_GetFreeMem(size_t *total);
/** \brief Returns precise time value for performance measurement. The precise
time should be a monotonically increasing counter, and will wrap.
+45 -22
View File
@@ -504,7 +504,7 @@ void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor)
\return void
*/
void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color)
void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, boolean local)
{
INT32 i;
INT32 starttranscolor;
@@ -540,7 +540,7 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color)
return;
}
starttranscolor = (skinnum != TC_DEFAULT) ? skins[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR;
starttranscolor = (skinnum != TC_DEFAULT) ? ( (local) ? localskins : skins )[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR;
// Fill in the entries of the palette that are fixed
for (i = 0; i < starttranscolor; i++)
@@ -3100,7 +3100,7 @@ static void K_QuiteSaltyHop(player_t *p)
p->mo->spriteyscale += (mos/8);
p->mo->spritexscale -= (mos/8);
}
p->mo->spriteyoffset = p->mo->salty_zoffset*P_MobjFlip(p->mo);
p->mo->spriteyoffset = p->mo->salty_zoffset;
if (S_SoundPlaying(p->mo, sfx_screec))
S_StopSoundByID(p->mo, sfx_screec);
if (S_SoundPlaying(p->mo, sfx_drift))
@@ -3132,6 +3132,7 @@ static angle_t K_GetSlopeRollAngle(player_t *p, boolean dontflip, boolean useRes
angle_t zangle = 0;
angle_t xydirection = 0;
angle_t an;
angle_t final_slope;
INT32 pNum = K_FindPlayerNum(p);
I_Assert(p != NULL);
@@ -3171,7 +3172,14 @@ static angle_t K_GetSlopeRollAngle(player_t *p, boolean dontflip, boolean useRes
zangle = InvAngle(zangle);
an = (lookAngle - xydirection);
return FixedMul(zangle, FINESINE(an>>ANGLETOFINESHIFT));
final_slope = -(FixedMul(FINESINE(an>>ANGLETOFINESHIFT), zangle));
an = (INT32)(final_slope - p->tilt_sprite) / 3; // instead of just a direct snap
if (an)
p->tilt_sprite += an;
else
p->tilt_sprite = final_slope;
return -p->tilt_sprite;
}
static void K_RollPlayerBySlopes(player_t *p, boolean usedistance)
@@ -6647,7 +6655,7 @@ void K_CheckBumpers(void)
if (winnernum > -1 && playeringame[winnernum])
{
players[winnernum].marescore += winnerscoreadd;
CONS_Printf(M_GetText("%s recieved %d point%s for winning!\n"), player_names[winnernum], winnerscoreadd, (winnerscoreadd == 1 ? "" : "s"));
CONS_Printf(M_GetText("%s received %d point%s for winning!\n"), player_names[winnernum], winnerscoreadd, (winnerscoreadd == 1 ? "" : "s"));
}
for (i = 0; i < MAXPLAYERS; i++) // This can't go in the earlier loop because winning adds points
@@ -8090,7 +8098,11 @@ static boolean K_drawKartPositionFaces(void)
else
colormap = R_GetTranslationColormap(players[rankplayer[i]].skin, players[rankplayer[i]].mo->color, GTC_CACHE);
V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, facerankprefix[players[rankplayer[i]].skin], colormap);
{
player_t *p;
p = &players[rankplayer[i]];
V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, ( (p->skinlocal) ? localfacerankprefix : facerankprefix )[( (p->localskin) ? p->localskin-1 : p->skin )], colormap);
}
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_battlebumpers))
@@ -8176,7 +8188,11 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I
else
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE);
V_DrawMappedPatch(x, y-4, 0, facerankprefix[players[tab[i].num].skin], colormap);
{
player_t *p;
p = &players[tab[i].num];
V_DrawMappedPatch(x, y-4, 0, ( (p->skinlocal) ? localfacerankprefix : facerankprefix )[( (p->localskin) ? p->localskin-1 : p->skin )], colormap);
}
/*if (G_BattleGametype() && players[tab[i].num].kartstuff[k_bumper] > 0) -- not enough space for this
{
INT32 bumperx = x+19;
@@ -8321,11 +8337,11 @@ static void K_drawKartSpeedometer(void)
speedtype = 1;
break;
case 2:
convSpeed = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale)/FRACUNIT; // 2.172409058
convSpeed = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale)/FRACUNIT; // 1.349868774
speedtype = 2;
break;
case 3:
convSpeed = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale)/FRACUNIT; // 1.349868774
convSpeed = FixedDiv(stplyr->speed, mapobjectscale)/FRACUNIT;
speedtype = 3;
break;
case 4:
@@ -8342,19 +8358,19 @@ static void K_drawKartSpeedometer(void)
{
switch (speedtype) {
case 1:
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d km/h", convSpeed));
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d km/h", convSpeed));
break;
case 2:
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d mph", convSpeed));
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d mph", convSpeed));
break;
case 3:
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d fu/t", convSpeed));
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d fu/t", convSpeed));
break;
case 4: // if extra.kart is found, use its included % symbol
if (!found_extra_kart)
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d P", convSpeed));
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%4d P", convSpeed));
else
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d %%", convSpeed));
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%4d %%", convSpeed));
}
}
else if (cv_newspeedometer.value && found_extra_kart) { // why bother if we dont?
@@ -8523,7 +8539,7 @@ static void K_drawKartWanted(void)
if (players[battlewanted[i]].skincolor)
{
colormap = R_GetTranslationColormap(TC_RAINBOW, p->skincolor, GTC_CACHE);
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, V_HUDTRANS|(splitscreen < 3 ? V_SNAPTORIGHT : 0)|V_SNAPTOBOTTOM, (scale == FRACUNIT ? facewantprefix[p->skin] : facerankprefix[p->skin]), colormap);
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, V_HUDTRANS|(splitscreen < 3 ? V_SNAPTORIGHT : 0)|V_SNAPTOBOTTOM, (scale == FRACUNIT ? ( (p->skinlocal) ? localfacewantprefix : facewantprefix )[( (p->localskin) ? p->localskin-1 : p->skin )] : ( (p->skinlocal) ? localfacerankprefix : facerankprefix )[( (p->localskin) ? p->localskin-1 : p->skin )]), colormap);
/*if (basey2) // again with 4p stuff
V_DrawFixedPatch(x<<FRACBITS, (y - (basey-basey2))<<FRACBITS, FRACUNIT, V_HUDTRANS|V_SNAPTOTOP, (scale == FRACUNIT ? facewantprefix[p->skin] : facerankprefix[p->skin]), colormap);*/
}
@@ -8590,6 +8606,7 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags, pat
// it, they wouldn't 'spawn' on the top-right side of the HUD.
UINT8 skin = 0;
boolean skinlocal = mo->skinlocal;
fixed_t amnumxpos, amnumypos;
INT32 amxpos, amypos;
@@ -8602,7 +8619,7 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags, pat
fixed_t xscale, yscale, zoom;
if (mo->skin)
skin = ((skin_t*)mo->skin)-skins;
skin = ((skin_t*)( (mo->localskin) ? mo->localskin : mo->skin ))-( (skinlocal) ? localskins : skins );
maxx = maxy = INT32_MAX;
minx = miny = INT32_MIN;
@@ -8646,20 +8663,26 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags, pat
if (encoremode)
amnumxpos = -amnumxpos;
amxpos = amnumxpos + ((x + AutomapPic->width/2 - (facemmapprefix[skin]->width/2))<<FRACBITS);
amypos = amnumypos + ((y + AutomapPic->height/2 - (facemmapprefix[skin]->height/2))<<FRACBITS);
amxpos = amnumxpos + ((x + AutomapPic->width/2 - (( (skinlocal) ? localfacemmapprefix : facemmapprefix )[skin]->width/2))<<FRACBITS);
amypos = amnumypos + ((y + AutomapPic->height/2 - (( (skinlocal) ? localfacemmapprefix : facemmapprefix )[skin]->height/2))<<FRACBITS);
if (!mo->color) // 'default' color
V_DrawSciencePatch(amxpos, amypos, flags, facemmapprefix[skin], FRACUNIT);
V_DrawSciencePatch(amxpos, amypos, flags, ( (skinlocal) ? localfacemmapprefix : facemmapprefix )[skin], FRACUNIT);
else
{
UINT8 *colormap = R_GetTranslationColormap((mo->colorized) ? TC_RAINBOW : skin, mo->color, GTC_CACHE);
if (cv_minihead.value == 1)
V_DrawFixedPatch(amxpos + (2 * FRACUNIT), amypos + (2 * FRACUNIT), FRACUNIT/2, flags, facemmapprefix[skin], colormap);
{
colormap = R_GetLocalTranslationColormap(mo->skin, mo->localskin, mo->color, GTC_CACHE, skinlocal);
V_DrawFixedPatch(amxpos + (2 * FRACUNIT), amypos + (2 * FRACUNIT), FRACUNIT/2, flags, ( (skinlocal) ? localfacemmapprefix : facemmapprefix )[skin], colormap);
}
else if (cv_minihead.value == 0)
V_DrawFixedPatch(amxpos, amypos, FRACUNIT, flags, facemmapprefix[skin], colormap);
{
colormap = R_GetLocalTranslationColormap(mo->skin, mo->localskin, mo->color, GTC_CACHE, skinlocal);
V_DrawFixedPatch(amxpos, amypos, FRACUNIT, flags, ( (skinlocal) ? localfacemmapprefix : facemmapprefix )[skin], colormap);
}
if (cv_showminimapnames.value && !(modeattacking || gamestate == GS_TIMEATTACK))
{
const char *player_name = va("%c%s", V_GetSkincolorChar(mo->color), player_names[mo->player - players]);
+1 -1
View File
@@ -15,7 +15,7 @@ extern UINT8 colortranslations[MAXTRANSLATIONS][16];
extern const char *KartColor_Names[MAXSKINCOLORS];
extern const UINT8 KartColor_Opposite[MAXSKINCOLORS*2];
void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor);
void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color);
void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, boolean local);
UINT8 K_GetKartColorByName(const char *name);
void K_RegisterKartStuff(void);
+3 -1
View File
@@ -293,6 +293,8 @@ static void Lua_OnChange(void)
//lua_settop(gL, 0); // Just in case...
lua_pushcfunction(gL, LUA_GetErrorMessage);
int error_handler_i = abs_index(gL, -1);
// From CV_OnChange registry field, get the function for this cvar by name.
lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange");
I_Assert(lua_istable(gL, -1));
@@ -304,7 +306,7 @@ static void Lua_OnChange(void)
lua_getfield(gL, -1, cvname); // get consvar_t* userdata.
lua_remove(gL, -2); // pop the CV_Vars table.
LUA_Call(gL, 1, 0, 1); // call function(cvar)
LUA_Call(gL, 1, 0, error_handler_i); // call function(cvar)
lua_pop(gL, 2); // pop CV_OnChange table and error handler
}
+36
View File
@@ -15,6 +15,7 @@
#include "r_defs.h"
#include "r_local.h"
#include "st_stuff.h" // hudinfo[]
#include "y_inter.h"
#include "g_game.h"
#include "i_video.h" // rendermode
#include "p_local.h" // camera_t
@@ -966,11 +967,46 @@ static int lib_hudadd(lua_State *L)
return 0;
}
static int lib_hudsetvotebackground(lua_State *L)
{
if (lua_isnoneornil(L, 1))
{
if (luaVoteScreen)
{
free(luaVoteScreen);
}
luaVoteScreen = NULL;
return 0;
}
const char *prefix = luaL_checkstring(L, 1);
if (strlen(prefix) != 4)
{
return luaL_argerror(L, 1, "prefix should 4 characters wide");
}
if (!luaVoteScreen)
{
luaVoteScreen = (char*)malloc(5);
luaVoteScreen[4] = 0;
}
strncpy(luaVoteScreen, prefix, 4);
strupr(luaVoteScreen);
return 0;
}
static luaL_Reg lib_hud[] = {
{"enable", lib_hudenable},
{"disable", lib_huddisable},
{"enabled", lib_hudenabled},
{"add", lib_hudadd},
{"setVoteBackground", lib_hudsetvotebackground},
{NULL, NULL}
};
+45 -4
View File
@@ -16,9 +16,12 @@
#ifdef HAVE_BLUA
#include "fastcmp.h"
#include "r_things.h"
#include "r_main.h"
#include "p_local.h"
#include "g_game.h"
#include "p_setup.h"
#include "doomdef.h"
#include "d_netcmd.h"
#include "lua_script.h"
#include "lua_libs.h"
@@ -65,6 +68,8 @@ int mobj_mobjnum_unimplemented(lua_State *L);
int mobj_scale_setter(lua_State *L);
int mobj_destscale_setter(lua_State *L);
int mobj_standingslope_noset(lua_State *L);
int mobj_rollsum_getter(lua_State *L);
int mobj_rollsum_noset(lua_State *L);
static const char *const array_opt[] ={"iterate",NULL};
@@ -78,6 +83,8 @@ static const udata_field_t mobj_fields[] = {
FIELD(mobj_t, angle, udatalib_getter_angle, mobj_angle_setter),
FIELD(mobj_t, rollangle, udatalib_getter_angle, udatalib_setter_angle),
FIELD(mobj_t, sloperoll, udatalib_getter_angle, mobj_sloperoll_noop),
// Macro fails here
{ "rollsum", 0, mobj_rollsum_getter, mobj_rollsum_noset },
FIELD(mobj_t, sprite, udatalib_getter_spritenum, udatalib_setter_spritenum),
FIELD(mobj_t, frame, udatalib_getter_uint32, udatalib_setter_uint32),
FIELD(mobj_t, anim_duration, udatalib_getter_uint16, udatalib_setter_uint16),
@@ -174,13 +181,21 @@ int mobj_ ## field ## _noset(lua_State *L) \
return luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly.", #field); \
}
#define NOSET_USE(field, use) \
int mobj_ ## field ## _noset(lua_State *L) \
{ \
return luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly. Use " LUA_QL(use) " instead.", #field); \
}
NOSET(snext)
NOSET(bnext)
NOSET(info)
NOSET(player)
NOSET(standingslope)
NOSET_USE(rollsum, "rollangle")
#undef NOSET
#undef NOSET_USE
// Unimplemented fields (why would you need to set them like that explicitly?
// No idea, i'm keeping it for synch reasons)
@@ -350,8 +365,14 @@ int mobj_skin_getter(lua_State *L)
if (!mo->skin)
return 0;
lua_pushstring(L, ((skin_t *)mo->skin)->name);
if (hud_running && cv_luaimmersion.value) {
if (mo->localskin) // HUD ONLY!!!!!!!!!!
lua_pushstring(L, ((skin_t *)mo->localskin)->name);
else
lua_pushstring(L, ((skin_t *)mo->skin)->name);
} else {
lua_pushstring(L, ((skin_t *)mo->skin)->name);
}
return 1;
}
@@ -363,7 +384,7 @@ int mobj_skin_setter(lua_State *L)
char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
strlcpy(skin, luaL_checkstring(L, 2), sizeof skin);
strlwr(skin); // all skin names are lowercase
for (i = 0; i < numskins; i++)
for (i = 0; i < numskins; i++) {
{
if (fastcmp(skins[i].name, skin))
{
@@ -372,7 +393,9 @@ int mobj_skin_setter(lua_State *L)
}
}
return luaL_error(L, "mobj.skin '%s' not found!", skin);
}
return luaL_error(L, "mobj.skin '%s' not found!", skin);
}
int mobj_color_setter(lua_State *L)
@@ -539,6 +562,24 @@ int mobj_destscale_setter(lua_State *L)
return 0;
}
// WARNING: Not synch safe!
// Don't use this field in game logic code!
int mobj_rollsum_getter(lua_State *L)
{
mobj_t *mo = GETMO();
angle_t rollsum = mo->rollangle + cv_sloperoll.value ? mo->sloperoll : 0;
if (mo->player)
{
rollsum += R_PlayerSliptideAngle(mo->player);
}
lua_pushangle(L, rollsum);
return 1;
}
static int mobj_get(lua_State *L)
{
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
+16
View File
@@ -13,6 +13,7 @@
#include "doomdef.h"
#ifdef HAVE_BLUA
#include "fastcmp.h"
#include "r_main.h"
#include "p_mobj.h"
#include "d_player.h"
#include "g_game.h"
@@ -44,6 +45,10 @@ int player_splitscreenindex_noset(lua_State *L);
int player_ping_getter(lua_State *L);
int player_ping_noset(lua_State *L);
// Non synch safe!
int player_sliproll_getter(lua_State *L);
int player_sliproll_noset(lua_State *L);
#define FIELD(type, field_name, getter, setter) { #field_name, offsetof(type, field_name), getter, setter }
static const udata_field_t player_fields[] = {
// Player doesn't actually have field "name" so macro fails. Need to declare field manually.
@@ -150,6 +155,7 @@ static const udata_field_t player_fields[] = {
FIELD(player_t, fovadd, udatalib_getter_fixed, udatalib_setter_fixed), // Mmm yeah thats definitely synch safe
#endif
// Same as player.name
{ "sliproll", 0, player_sliproll_getter, player_sliproll_noset },
{ "ping", 0, player_ping_getter, player_ping_noset }, // Hmm originally setter doesn't exist so data is written as unreachable custom field...
{ NULL },
};
@@ -207,6 +213,7 @@ NOSET(kartstuff)
NOSET(bot)
NOSET(splitscreenindex)
NOSET(ping)
NOSET(sliproll)
#undef NOSET
@@ -331,6 +338,15 @@ int player_ping_getter(lua_State *L)
return 1;
}
int player_sliproll_getter(lua_State *L)
{
player_t *plr = GETPLAYER();
lua_pushangle(L, R_PlayerSliptideAngle(plr));
return 1;
}
static int lib_iteratePlayers(lua_State *L)
{
INT32 i = -1;
+1 -1
View File
@@ -280,7 +280,7 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump)
LUA_LoadFile(&f, name); // actually load file!
// Okay, we've modified the game beyond the point of no return.
G_SetGameModified(multiplayer, true);
G_SetWadModified(multiplayer, true, wad);
free(name);
Z_Free(f.data);
+9 -9
View File
@@ -166,14 +166,14 @@ static int lib_iterateSkins(lua_State *L)
lua_remove(L, 1); // state is unused.
if (!lua_isnil(L, 1))
i = (INT32)(*((skin_t **)luaL_checkudata(L, 1, META_SKIN)) - skins) + 1;
i = (INT32)(*((skin_t **)luaL_checkudata(L, 1, META_SKIN)) - allskins) + 1;
else
i = 0;
// skins are always valid, only added, never removed
if (i < numskins)
if (i < numallskins)
{
LUA_PushUserdata(L, &skins[i], META_SKIN);
LUA_PushUserdata(L, &allskins[i], META_SKIN);
return 1;
}
@@ -191,9 +191,9 @@ static int lib_getSkin(lua_State *L)
i = luaL_checkinteger(L, 2);
if (i < 0 || i >= MAXSKINS)
return luaL_error(L, "skins[] index %d out of range (0 - %d)", i, MAXSKINS-1);
if (i >= numskins)
if (i >= numallskins)
return 0;
LUA_PushUserdata(L, &skins[i], META_SKIN);
LUA_PushUserdata(L, &allskins[i], META_SKIN);
return 1;
}
@@ -207,10 +207,10 @@ static int lib_getSkin(lua_State *L)
}
// find skin by name
for (i = 0; i < numskins; i++)
if (fastcmp(skins[i].name, field))
for (i = 0; i < numallskins; i++)
if (fastcmp(allskins[i].name, field))
{
LUA_PushUserdata(L, &skins[i], META_SKIN);
LUA_PushUserdata(L, &allskins[i], META_SKIN);
return 1;
}
@@ -219,7 +219,7 @@ static int lib_getSkin(lua_State *L)
static int lib_numSkins(lua_State *L)
{
lua_pushinteger(L, numskins);
lua_pushinteger(L, numallskins);
return 1;
}
+239 -27
View File
@@ -145,6 +145,8 @@ INT32 mapwads[NUMMAPS];
//static char *char_notes = NULL;
//static fixed_t char_scroll = 0;
boolean browselocalskins = false;
boolean menuactive = false;
boolean fromlevelselect = false;
@@ -234,6 +236,8 @@ menu_t SR_MainDef, SR_UnlockChecklistDef;
static void M_SinglePlayerMenu(INT32 choice);
#endif
static void M_Options(INT32 choice);
static void M_LocalSkinMenu(INT32 choice);
static void M_LocalSkinChange(INT32 choice);
static void M_Manual(INT32 choice);
static void M_SelectableClearMenus(INT32 choice);
static void M_Retry(INT32 choice);
@@ -336,7 +340,9 @@ menu_t OP_MonitorToggleDef;
static void M_ScreenshotOptions(INT32 choice);
static void M_EraseData(INT32 choice);
static void M_AddonsInternal();
static void M_Addons(INT32 choice);
static void M_LocalSkins(INT32 choice);
static void M_AddonsOptions(INT32 choice);
static patch_t *addonsp[NUM_EXT+5];
@@ -350,6 +356,9 @@ menu_t OP_SaturnCreditsDef;
// Bird
menu_t OP_BirdDef;
// Stuff, yknow.
menu_t OP_ForkedBirdDef;
menu_t OP_LocalSkinDef;
menu_t OP_TiltDef;
menu_t OP_AdvancedBirdDef;
@@ -407,6 +416,7 @@ static void M_DrawConnectMenu(void);
#endif
static void M_DrawJoystick(void);
static void M_DrawSetupMultiPlayerMenu(void);
static void M_DrawLocalSkinMenu(void);
// Handling functions
#ifndef NONET
@@ -627,12 +637,13 @@ typedef enum
// ---------------------
static menuitem_t MPauseMenu[] =
{
{IT_STRING | IT_CALL, NULL, "Addons...", M_Addons, 8},
{IT_STRING | IT_SUBMENU, NULL, "Scramble Teams...", &MISC_ScrambleTeamDef, 16},
{IT_STRING | IT_CALL, NULL, "Switch Map..." , M_MapChange, 24},
{IT_STRING | IT_CALL, NULL, "Addons...", M_Addons, 8},
{IT_STRING | IT_CALL, NULL, "Add local skins...", M_LocalSkins, 16},
{IT_STRING | IT_SUBMENU, NULL, "Scramble Teams...", &MISC_ScrambleTeamDef, 24},
{IT_STRING | IT_CALL, NULL, "Switch Map..." , M_MapChange, 32},
#ifdef HAVE_DISCORDRPC
{IT_STRING | IT_SUBMENU, NULL, "Ask To Join Requests...", &MISC_DiscordRequestsDef, 24},
{IT_STRING | IT_SUBMENU, NULL, "Ask To Join Requests...", &MISC_DiscordRequestsDef, 32},
#endif
{IT_CALL | IT_STRING, NULL, "Continue", M_SelectableClearMenus, 40},
@@ -647,15 +658,17 @@ static menuitem_t MPauseMenu[] =
{IT_STRING | IT_SUBMENU, NULL, "Switch Team...", &MISC_ChangeTeamDef, 48},
{IT_STRING | IT_SUBMENU, NULL, "Enter/Spectate...", &MISC_ChangeSpectateDef,48},
{IT_CALL | IT_STRING, NULL, "Player Setup...", M_SetupMultiPlayer, 56}, // alone
{IT_CALL | IT_STRING, NULL, "Options", M_Options, 64},
{IT_CALL | IT_STRING, NULL, "Local Skin...", M_LocalSkinMenu, 64}, // alone
{IT_CALL | IT_STRING, NULL, "Options", M_Options, 72},
{IT_CALL | IT_STRING, NULL, "Return to Title", M_EndGame, 80},
{IT_CALL | IT_STRING, NULL, "Quit Game", M_QuitSRB2, 88},
{IT_CALL | IT_STRING, NULL, "Return to Title", M_EndGame, 88},
{IT_CALL | IT_STRING, NULL, "Quit Game", M_QuitSRB2, 96},
};
typedef enum
{
mpause_addons = 0,
mpause_addlocalskins,
mpause_scramble,
mpause_switchmap,
#ifdef HAVE_DISCORDRPC
@@ -674,6 +687,7 @@ typedef enum
mpause_switchteam,
mpause_switchspectate,
mpause_psetup,
mpause_localskin,
mpause_options,
mpause_title,
@@ -1128,6 +1142,7 @@ static menuitem_t OP_MainMenu[] =
{IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 140},
{IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 150},
{IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 160},
};
static menuitem_t OP_ControlsMenu[] =
@@ -1347,7 +1362,8 @@ static menuitem_t OP_OpenGLOptionsMenu[] =
{IT_STRING | IT_CVAR, NULL, "3D Models", &cv_grmdls, 5},
{IT_STRING | IT_CVAR, NULL, "Fallback Player 3D Model", &cv_grfallbackplayermodel, 15},
{IT_STRING|IT_CVAR, NULL, "Shaders", &cv_grshaders, 25},
{IT_STRING|IT_CVAR, NULL, "Use custom Shaders", &cv_grusecustomshaders, 35},
//{IT_STRING|IT_CVAR, NULL, "Use custom Shaders", &cv_grusecustomshaders, 35},
{IT_STRING|IT_CVAR, NULL, "Palette Rendering", &cv_grpaletteshader, 35},
{IT_STRING | IT_CVAR, NULL, "Min Shader Brightness", &cv_secbright, 45},
{IT_STRING|IT_CVAR, NULL, "Texture Quality", &cv_scr_depth, 65},
@@ -1404,24 +1420,27 @@ static menuitem_t OP_SoundOptionsMenu[] =
{IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125},
{IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135},
#ifdef HAVE_OPENMPT
{IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155}
#endif
};
#ifdef HAVE_OPENMPT
static menuitem_t OP_SoundAdvancedMenu[] =
{
#ifdef HAVE_OPENMPT
{IT_HEADER, NULL, "Tracker Module Options", NULL, 10},
{IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 42},
{IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 62},
{IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 22},
{IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42},
#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4
{IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 82},
{IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 62},
#endif
{IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 102},
{IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 82},
#endif
{IT_HEADER, NULL, "Misc", NULL, 105},
{IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 117},
{IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 137},
};
#endif
static menuitem_t OP_DataOptionsMenu[] =
{
@@ -1702,8 +1721,9 @@ static menuitem_t OP_SaturnMenu[] =
{IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 80},
{IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 90},
{IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 110},
{IT_SUBMENU|IT_STRING, NULL, "Player distortion...", &OP_PlayerDistortDef, 130},
{IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 145},
{IT_STRING | IT_CVAR, NULL, "Flashpals in Palette Renderer", &cv_grflashpal, 120},
{IT_SUBMENU|IT_STRING, NULL, "Player distortion...", &OP_PlayerDistortDef, 140},
{IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 155},
{IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 170}, // uwu
};
@@ -1812,6 +1832,17 @@ static menuitem_t OP_BirdMenu[] =
{IT_STRING | IT_SUBMENU, NULL, "Advanced Music Options...", &OP_AdvancedBirdDef, 120},
};
static menuitem_t OP_ForkedBirdMenu[] =
{
{IT_HEADER, NULL, "Local Skins", NULL, 0},
{IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Local Skin Name", &cv_fakelocalskin, 10},
{IT_STRING2 | IT_SPACE, NULL, "Set to None for no Local Skin", NULL, 20},
{IT_STRING | IT_CALL, NULL, "Apply to All Players", M_LocalSkinChange, 140},
{IT_STRING | IT_CALL, NULL, "Apply to Displaying Player", M_LocalSkinChange, 150},
{IT_STRING | IT_CALL, NULL, "Apply to Yourself", M_LocalSkinChange, 160},
{IT_STRING | IT_CVAR, NULL, "Lua Immersion", &cv_luaimmersion, 170},
};
static menuitem_t OP_TiltMenu[] =
{
{IT_STRING | IT_CVAR, NULL, "Camera Tilting", &cv_tilting, 0},
@@ -2375,6 +2406,20 @@ menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30);
menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60);
menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60);
menu_t OP_ForkedBirdDef = {
NULL,
sizeof(OP_ForkedBirdMenu)/sizeof(menuitem_t),
&OP_MainDef,
OP_ForkedBirdMenu,
M_DrawLocalSkinMenu,
30, 6,
0,
NULL
};
menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60);
// ==========================================================================
// CVAR ONCHANGE EVENTS GO HERE
// ==========================================================================
@@ -3588,14 +3633,16 @@ void M_StartControlPanel(void)
// Reset these in case splitscreen messes things up
MPauseMenu[mpause_addons].alphaKey = 8;
MPauseMenu[mpause_addlocalskins].alphaKey = 16;
MPauseMenu[mpause_scramble].alphaKey = 8;
MPauseMenu[mpause_switchmap].alphaKey = 24;
MPauseMenu[mpause_switchteam].alphaKey = 48;
MPauseMenu[mpause_switchspectate].alphaKey = 48;
MPauseMenu[mpause_options].alphaKey = 64;
MPauseMenu[mpause_title].alphaKey = 80;
MPauseMenu[mpause_quit].alphaKey = 88;
MPauseMenu[mpause_localskin].alphaKey = 64;
MPauseMenu[mpause_options].alphaKey = 72;
MPauseMenu[mpause_title].alphaKey = 88;
MPauseMenu[mpause_quit].alphaKey = 96;
Dummymenuplayer_OnChange();
@@ -3618,6 +3665,7 @@ void M_StartControlPanel(void)
{
MPauseMenu[mpause_switchteam].status = IT_STRING | IT_SUBMENU;
MPauseMenu[mpause_switchteam].alphaKey += ((splitscreen+1) * 8);
MPauseMenu[mpause_localskin].alphaKey += 8;
MPauseMenu[mpause_options].alphaKey += 8;
MPauseMenu[mpause_title].alphaKey += 8;
MPauseMenu[mpause_quit].alphaKey += 8;
@@ -3626,6 +3674,7 @@ void M_StartControlPanel(void)
{
MPauseMenu[mpause_switchspectate].status = IT_STRING | IT_SUBMENU;
MPauseMenu[mpause_switchspectate].alphaKey += ((splitscreen+1) * 8);
MPauseMenu[mpause_localskin].alphaKey += 8;
MPauseMenu[mpause_options].alphaKey += 8;
MPauseMenu[mpause_title].alphaKey += 8;
MPauseMenu[mpause_quit].alphaKey += 8;
@@ -3636,6 +3685,7 @@ void M_StartControlPanel(void)
{
MPauseMenu[mpause_psetupsplit3].status = IT_STRING | IT_CALL;
MPauseMenu[mpause_localskin].alphaKey += 8;
MPauseMenu[mpause_options].alphaKey += 8;
MPauseMenu[mpause_title].alphaKey += 8;
MPauseMenu[mpause_quit].alphaKey += 8;
@@ -3643,6 +3693,7 @@ void M_StartControlPanel(void)
if (splitscreen > 2)
{
MPauseMenu[mpause_psetupsplit4].status = IT_STRING | IT_CALL;
MPauseMenu[mpause_localskin].alphaKey += 8;
MPauseMenu[mpause_options].alphaKey += 8;
MPauseMenu[mpause_title].alphaKey += 8;
MPauseMenu[mpause_quit].alphaKey += 8;
@@ -4283,7 +4334,7 @@ static void M_DrawGenericMenu(void)
y += STRINGHEIGHT;
break;
case IT_STRING2:
V_DrawString(x, y, lowercase, currentMenu->menuitems[i].text);
V_DrawString(((BASEVIDWIDTH - V_StringWidth(currentMenu->menuitems[i].text, 0))>>1), y, 0, currentMenu->menuitems[i].text);
/* FALLTHRU */
case IT_DYLITLSPACE:
y += SMALLLINEHEIGHT;
@@ -5110,12 +5161,10 @@ static void M_AddonsOptions(INT32 choice)
#define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make addons!"
#define LOCATIONSTRING2 "Visit \x88SRB2.ORG/MODS\x80 to get & make addons!"
static void M_Addons(INT32 choice)
static void M_AddonsInternal()
{
const char *pathname = ".";
(void)choice;
#if 1
if (cv_addons_option.value == 0)
pathname = usehome ? srb2home : srb2path;
@@ -5176,6 +5225,20 @@ static void M_Addons(INT32 choice)
M_SetupNextMenu(&MISC_AddonsDef);
}
static void M_Addons(INT32 choice)
{
(void)choice;
browselocalskins = false;
M_AddonsInternal();
}
static void M_LocalSkins(INT32 choice)
{
(void)choice;
browselocalskins = true;
M_AddonsInternal();
}
#define width 4
#define vpadding 27
#define h (BASEVIDHEIGHT-(2*vpadding))
@@ -5328,7 +5391,12 @@ static void M_DrawAddons(void)
}
if (Playing())
V_DrawCenteredString(BASEVIDWIDTH/2, 5, warningflags, "Adding files mid-game may cause problems.");
{
if (browselocalskins)
V_DrawCenteredString(BASEVIDWIDTH/2, 5, V_ALLOWLOWERCASE, "Load \x83local skins\x80 from addons!");
else
V_DrawCenteredString(BASEVIDWIDTH/2, 5, warningflags, "Adding files mid-game may cause problems.");
}
else
V_DrawCenteredString(BASEVIDWIDTH/2, 5, 0, (recommendedflags == V_SKYMAP ? LOCATIONSTRING2 : LOCATIONSTRING1));
@@ -5499,6 +5567,14 @@ static boolean M_ChangeStringAddons(INT32 choice)
}
#undef len
// i hate myself
static boolean DumbStartsWith(const char *pre, const char *str)
{
size_t lenpre = strlen(pre),
lenstr = strlen(str);
return lenstr < lenpre ? false : memcmp(pre, str, lenpre) == 0;
}
static void M_HandleAddons(INT32 choice)
{
boolean exitmenu = false; // exit to previous menu
@@ -5617,7 +5693,16 @@ static void M_HandleAddons(INT32 choice)
case EXT_KART:
#endif
case EXT_PK3:
COM_BufAddText(va("addfile \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING));
if (browselocalskins) {
if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) {
M_StartMessage(va("%c%s\x80\nYou are loading a local skin.\nLocal skins will not be usable\nafter going back from\nthe title screen.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING);
COM_BufAddText(va("addskins \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING));
}
else
S_StartSound(NULL, sfx_s26d);
}
else
COM_BufAddText(va("addfile \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING));
break;
default:
S_StartSound(NULL, sfx_s26d);
@@ -11895,6 +11980,133 @@ static void M_DrawHUDOptions(void)
V_DrawRightAlignedString(x, y, highlightflags, "(");
}
static void M_LocalSkinMenu(INT32 choice)
{
(void)choice;
multi_state = &states[mobjinfo[MT_PLAYER].seestate];
multi_tics = multi_state->tics;
OP_ForkedBirdDef.prevMenu = currentMenu;
M_SetupNextMenu(&OP_ForkedBirdDef);
}
static void M_LocalSkinChange(INT32 choice)
{
(void)choice;
switch (itemOn) {
case 3:
COM_BufAddText(va("localskin -a %s", cv_fakelocalskin.string));
break;
case 4:
COM_BufAddText(va("localskin -d 0 %s", cv_fakelocalskin.string));
break;
case 5:
COM_BufAddText(va("localskin %s", cv_fakelocalskin.string));
break;
default:
break;
}
S_StartSound(NULL, sfx_s221);
}
// Display our localskin in our goofy ahhhh local skin menu
static void M_DrawLocalSkinMenu(void)
{
INT32 mx, my, st, flags = 0;
spritedef_t *sprdef;
spriteframe_t *sprframe;
patch_t *patch;
UINT8 frame;
UINT8 skintodisplay;
UINT32 speenframe;
mx = OP_ForkedBirdDef.x;
my = OP_ForkedBirdDef.y;
// use generic drawer for cursor, items and title
M_DrawGenericMenu();
#define charw 72
// anim the player in the box
if (--multi_tics <= 0)
{
st = multi_state->nextstate;
if (st != S_NULL)
multi_state = &states[st];
multi_tics = multi_state->tics;
if (multi_tics == -1)
multi_tics = 15;
}
// skin 0 is default player sprite
if (R_AnySkinAvailable(cv_fakelocalskin.string) != -1)
{
sprdef = &allskins[R_AnySkinAvailable(cv_fakelocalskin.string)].spritedef;
skintodisplay = R_AnySkinAvailable(cv_fakelocalskin.string);
}
else
{
// ATTEMPT TO FIND REAL SKIN
if (R_AnySkinAvailable(cv_skin.string) != -1)
{
sprdef = &allskins[R_AnySkinAvailable(cv_skin.string)].spritedef;
skintodisplay = R_AnySkinAvailable(cv_skin.string);
} else { // STILL NOTHIN? use sonic instead
sprdef = &allskins[0].spritedef;
skintodisplay = 0;
}
}
if (!sprdef->numframes) // No frames ??
return; // Can't render!
frame = multi_state->frame & FF_FRAMEMASK;
if (frame >= sprdef->numframes) // Walking animation missing
frame = 0; // Try to use standing frame
sprframe = &sprdef->spriteframes[frame];
//minenice's speen css, it's a piece of shit but hey
//patch = W_CachePatchNum(sprframe->lumppat[1], PU_CACHE);
speenframe = (I_GetTime()*4/TICRATE + 1)%8;
//this is a very shitty solution for checking if a sprite needs flipping
//but it works
if ((sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]) && (speenframe > 4)) {
flags = V_FLIP; // This sprite is left/right flipped!
}
patch = W_CachePatchNum(sprframe->lumppat[speenframe], PU_CACHE);
// draw box around guy
V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239);
// draw player sprite
UINT8 *colormap = R_GetTranslationColormap(skintodisplay, cv_playercolor.value, GTC_MENUCACHE);
colormap = R_GetLocalTranslationColormap(&skins[allskins[skintodisplay].localnum], (allskins[skintodisplay].localskin ? &localskins[allskins[skintodisplay].localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, allskins[skintodisplay].localskin);
V_DrawMappedPatch(mx, my+50, 0, W_CachePatchName(allskins[skintodisplay].facewant, PU_CACHE), colormap);
V_DrawMappedPatch(mx+8, my+85, 0, W_CachePatchName(allskins[skintodisplay].facerank, PU_CACHE), colormap);
V_DrawString(mx, my+108, V_ALLOWLOWERCASE, "Character");
if (strlen(allskins[skintodisplay].realname) > 10)
V_DrawThinString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, allskins[skintodisplay].realname);
else
V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, allskins[skintodisplay].realname);
if (allskins[skintodisplay].flags & SF_HIRES)
{
V_DrawFixedPatch((mx+220)<<FRACBITS,
(my+120)<<FRACBITS,
allskins[skintodisplay].highresscale,
flags, patch, colormap);
}
else
V_DrawMappedPatch(mx+220, my+120, flags, patch, colormap);
#undef charw
}
// Draw the video modes list, a-la-Quake
static void M_DrawVideoMode(void)
{
+19 -6
View File
@@ -2608,6 +2608,7 @@ void A_MonitorPop(mobj_t *actor)
remains->fuse = actor->fuse; // Transfer respawn timer
remains->threshold = 68;
remains->skin = NULL;
remains->localskin = NULL;
P_SetTarget(&tmthing, remains);
@@ -4167,6 +4168,18 @@ void A_SignPlayer(mobj_t *actor)
P_SetTarget(&ov->target, actor);
ov->color = actor->target->player->skincolor;
ov->skin = &skins[actor->target->player->skin];
if (actor->target->skinlocal) {
// needs - 1 or else it pukes an error out
// same thing happens on p_mobj.c
ov->localskin = &localskins[actor->target->player->localskin - 1];
ov->skinlocal = actor->target->skinlocal;
} else {
// needs - 1 or else it pukes an error out
// same thing happens on p_mobj.c
if (actor->target->player->localskin)
ov->localskin = &skins[actor->target->player->localskin - 1];
ov->skinlocal = actor->target->skinlocal;
}
P_SetMobjState(ov, actor->info->seestate); // S_PLAY_SIGN
}
@@ -7444,10 +7457,10 @@ void A_RollAngle(mobj_t *actor)
INT32 locvar2 = var2;
const angle_t angle = FixedAngle(locvar1*FRACUNIT);
/*#ifdef HAVE_BLUA
#ifdef HAVE_BLUA
if (LUA_CallAction("A_RollAngle", actor))
return;
#endif*/
#endif
// relative (default)
if (!locvar2)
@@ -7470,10 +7483,10 @@ void A_ChangeRollAngleRelative(mobj_t *actor)
INT32 locvar2 = var2;
const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT;
/*#ifdef HAVE_BLUA
#ifdef HAVE_BLUA
if (LUA_CallAction("A_ChangeRollAngleRelative", actor))
return;
#endif*/
#endif
#ifdef PARANOIA
if (amin > amax)
@@ -7496,10 +7509,10 @@ void A_ChangeRollAngleAbsolute(mobj_t *actor)
INT32 locvar2 = var2;
const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT;
/*#ifdef HAVE_BLUA
#ifdef HAVE_BLUA
if (LUA_CallAction("A_ChangeRollAngleAbsolute", actor))
return;
#endif*/
#endif
#ifdef PARANOIA
if (amin > amax)
+10
View File
@@ -10772,6 +10772,16 @@ void P_SpawnPlayer(INT32 playernum)
// (usefulness: when body mobj is detached from player (who respawns),
// the dead body mobj retains the skin through the 'spritedef' override).
mobj->skin = &skins[p->skin];
if (p->localskin > 0)
{
if (p->skinlocal)
mobj->localskin = &localskins[p->localskin - 1];
else
mobj->localskin = & skins[p->localskin - 1];
}
else
mobj->localskin = 0;
mobj->skinlocal = p->skinlocal;
mobj->health = p->health;
p->playerstate = PST_LIVE;
+2
View File
@@ -327,6 +327,8 @@ typedef struct mobj_s
UINT16 eflags; // extra flags
void *skin; // overrides 'sprite' when non-NULL (for player bodies to 'remember' the skin)
void *localskin;
boolean skinlocal;
// Player and mobj sprites in multiplayer modes are modified
// using an internal color lookup table for re-indexing.
UINT8 color; // This replaces MF_TRANSLATION. Use 0 for default (no translation).
+10 -5
View File
@@ -3433,7 +3433,7 @@ boolean P_RunSOC(const char *socfilename)
lumpnum_t lump;
if (strstr(socfilename, ".soc") != NULL)
return P_AddWadFile(socfilename);
return P_AddWadFile(socfilename, false);
lump = W_CheckNumForName(socfilename);
if (lump == LUMPERROR)
@@ -3449,11 +3449,11 @@ boolean P_RunSOC(const char *socfilename)
// Add a wadfile to the active wad files,
// replace sounds, musics, patches, textures, sprites and maps
//
boolean P_AddWadFile(const char *wadfilename)
boolean P_AddWadFile(const char *wadfilename, boolean local)
{
UINT16 wadnum;
if ((wadnum = P_PartialAddWadFile(wadfilename, false)) == UINT16_MAX)
if ((wadnum = P_PartialAddWadFile(wadfilename, local)) == UINT16_MAX)
return false;
P_MultiSetupWadFiles(true);
@@ -3483,7 +3483,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
boolean mapsadded = false;
lumpinfo_t *lumpinfo;
if ((numlumps = W_InitFile(wadfilename, local)) == INT16_MAX)
if ((numlumps = W_InitFile(wadfilename, 0, &wadnum, local)) == INT16_MAX)
{
refreshdirmenu |= REFRESHDIR_NOTLOADED;
CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename);
@@ -3493,6 +3493,11 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
if (wadfiles[wadnum]->important)
partadd_important = true;
if (local)
wadfiles[wadnum]->localfile = true;
else
wadfiles[wadnum]->localfile = false;
//
// search for sound replacements
@@ -3545,7 +3550,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
//
// look for skins
//
R_AddSkins(wadnum); // faB: wadfile index in wadfiles[]
R_AddSkins(wadnum, local); // faB: wadfile index in wadfiles[]
//
// edit music defs
+1 -1
View File
@@ -60,7 +60,7 @@ void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum);
#endif
void P_LoadThingsOnly(void);
boolean P_SetupLevel(boolean skipprecip);
boolean P_AddWadFile(const char *wadfilename);
boolean P_AddWadFile(const char *wadfilename, boolean local);
boolean P_AddWadFileLocal(const char *wadfilename);
#ifdef DELFILE
boolean P_DelWadFile(void);
+17 -6
View File
@@ -1278,13 +1278,13 @@ void P_RestoreMusic(player_t *player)
}
// Item - Grow
if (wantedmus == 2)
if (wantedmus == 2 && cv_growmusic.value)
{
S_ChangeMusicInternal("kgrow", true);
S_SetRestoreMusicFadeInCvar(&cv_growmusicfade);
}
// Item - Invincibility
else if (wantedmus == 1)
else if (wantedmus == 1 && cv_supermusic.value)
{
S_ChangeMusicInternal("kinvnc", true);
S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade);
@@ -1696,6 +1696,8 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
ghost->fuse = ghost->info->damage;
ghost->skin = mobj->skin;
ghost->localskin = mobj->localskin;
ghost->skinlocal = mobj->skinlocal;
if (mobj->flags2 & MF2_OBJECTFLIP)
ghost->flags |= MF2_OBJECTFLIP;
@@ -1737,10 +1739,19 @@ void P_DoPlayerExit(player_t *player)
if (P_IsLocalPlayer(player))
{
sfxenum_t sfx_id;
if (K_IsPlayerLosing(player))
sfx_id = ((skin_t *)player->mo->skin)->soundsid[S_sfx[sfx_klose].skinsound];
else
sfx_id = ((skin_t *)player->mo->skin)->soundsid[S_sfx[sfx_kwin].skinsound];
// fix godjjsa win sounds
if (K_IsPlayerLosing(player)) {
if (player->mo->localskin)
sfx_id = ((skin_t *)player->mo->localskin)->soundsid[S_sfx[sfx_klose].skinsound];
else
sfx_id = ((skin_t *)player->mo->skin)->soundsid[S_sfx[sfx_klose].skinsound];
}
else {
if (player->mo->localskin)
sfx_id = ((skin_t *)player->mo->localskin)->soundsid[S_sfx[sfx_kwin].skinsound];
else
sfx_id = ((skin_t *)player->mo->skin)->soundsid[S_sfx[sfx_kwin].skinsound];
}
S_StartSound(NULL, sfx_id);
}
else
+13 -5
View File
@@ -26,6 +26,10 @@
#include "v_video.h" // pLocalPalette
#include "dehacked.h"
#ifdef HWRENDER
#include "hardware/hw_main.h"
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
#include <malloc.h> // alloca(sizeof)
#endif
@@ -1137,6 +1141,10 @@ void R_ClearColormaps(void)
foundcolormaps[i] = LUMPERROR;
memset(extra_colormaps, 0, sizeof (extra_colormaps));
#ifdef HWRENDER
HWR_ClearLightTableCache();
#endif
}
/*INT32 R_ColormapNumForName(char *name)
@@ -1316,13 +1324,13 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
extra_colormaps[mapnum].fadestart = (UINT16)fadestart;
extra_colormaps[mapnum].fadeend = (UINT16)fadeend;
extra_colormaps[mapnum].fog = fog;
if (rendermode == render_soft)
{
if (rendermode == render_soft || rendermode == render_opengl)
{
double r, g, b, cbrightness;
int p;
lighttable_t *colormap_p;
// Initialise the map and delta arrays
// map[i] stores an RGB color (as double) for index i,
// which is then converted to SRB2's palette later
@@ -1402,7 +1410,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
}
}
}
return (INT32)mapnum;
}
-2
View File
@@ -104,6 +104,4 @@ UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
extern INT32 numtextures;
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
#endif
+7
View File
@@ -19,6 +19,7 @@
// We rely on the thinker data struct to handle sound origins in sectors.
#include "d_think.h"
// SECTORS do store MObjs anyway.
#include "p_mobj.h"
@@ -62,6 +63,12 @@ typedef struct
INT32 fadergba; // The colour the colourmaps fade to
lighttable_t *colormap;
#ifdef HWRENDER
// The id of the hardware lighttable. Zero means it does not exist yet.
UINT32 gl_lighttable_id;
#endif
} extracolormap_t;
//
+43 -14
View File
@@ -18,6 +18,7 @@
#include "doomdef.h"
#include "doomstat.h"
#include "r_local.h"
#include "r_things.h"
#include "st_stuff.h" // need ST_HEIGHT
#include "i_video.h"
#include "v_video.h"
@@ -141,6 +142,7 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask;
#define NUM_PALETTE_ENTRIES 256
static UINT8** translationtablecache[TT_CACHE_SIZE] = {NULL};
static UINT8** localtranslationtablecache[MAXSKINS] = {NULL};
// See also the enum skincolors_t
@@ -519,29 +521,39 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U
\return Colormap. If not cached, caller should Z_Free.
*/
UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags)
static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags, boolean local)
{
UINT8 ***tt;
UINT8* ret;
INT32 skintableindex;
// Adjust if we want the default colormap
if (skinnum == TC_DEFAULT) skintableindex = DEFAULT_TT_CACHE_INDEX;
else if (skinnum == TC_BOSS) skintableindex = BOSS_TT_CACHE_INDEX;
else if (skinnum == TC_METALSONIC) skintableindex = METALSONIC_TT_CACHE_INDEX;
else if (skinnum == TC_ALLWHITE) skintableindex = ALLWHITE_TT_CACHE_INDEX;
else if (skinnum == TC_RAINBOW) skintableindex = RAINBOW_TT_CACHE_INDEX;
else if (skinnum == TC_BLINK) skintableindex = BLINK_TT_CACHE_INDEX;
else skintableindex = skinnum;
if (local)
{
tt = localtranslationtablecache;
skintableindex = skinnum;
}
else
{
tt = translationtablecache;
// Adjust if we want the default colormap
if (skinnum == TC_DEFAULT) skintableindex = DEFAULT_TT_CACHE_INDEX;
else if (skinnum == TC_BOSS) skintableindex = BOSS_TT_CACHE_INDEX;
else if (skinnum == TC_METALSONIC) skintableindex = METALSONIC_TT_CACHE_INDEX;
else if (skinnum == TC_ALLWHITE) skintableindex = ALLWHITE_TT_CACHE_INDEX;
else if (skinnum == TC_RAINBOW) skintableindex = RAINBOW_TT_CACHE_INDEX;
else if (skinnum == TC_BLINK) skintableindex = BLINK_TT_CACHE_INDEX;
else skintableindex = skinnum;
}
if (flags & GTC_CACHE)
{
// Allocate table for skin if necessary
if (!translationtablecache[skintableindex])
translationtablecache[skintableindex] = Z_Calloc(MAXTRANSLATIONS * sizeof(UINT8**), PU_STATIC, NULL);
if (!tt[skintableindex])
tt[skintableindex] = Z_Calloc(MAXTRANSLATIONS * sizeof(UINT8**), PU_STATIC, NULL);
// Get colormap
ret = translationtablecache[skintableindex][color];
ret = tt[skintableindex][color];
}
else ret = NULL;
@@ -549,16 +561,29 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags)
if (!ret)
{
ret = Z_MallocAlign(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL, 8);
K_GenerateKartColormap(ret, skinnum, color); //R_GenerateTranslationColormap(ret, skinnum, color); // SRB2kart
K_GenerateKartColormap(ret, skinnum, color, local); //R_GenerateTranslationColormap(ret, skinnum, color); // SRB2kart
// Cache the colormap if desired
if (flags & GTC_CACHE)
translationtablecache[skintableindex][color] = ret;
tt[skintableindex][color] = ret;
}
return ret;
}
UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags)
{
return RGetTranslationColormap(skinnum, color, flags, false);
}
UINT8* R_GetLocalTranslationColormap(skin_t *skin, skin_t *localskin, skincolors_t color, UINT8 flags, boolean local)
{
if (localskin)
return RGetTranslationColormap(( localskin - ( (local) ? localskins : skins ) ), color, flags, local);
else
return RGetTranslationColormap(( skin - skins ), color, flags, false);
}
/** \brief Flushes cache of translation colormaps.
Flushes cache of translation colormaps, but doesn't actually free the
@@ -574,6 +599,10 @@ void R_FlushTranslationColormapCache(void)
for (i = 0; i < (INT32)(sizeof(translationtablecache) / sizeof(translationtablecache[0])); i++)
if (translationtablecache[i])
memset(translationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**));
for (i = 0; i < (INT32)(sizeof(localtranslationtablecache) / sizeof(localtranslationtablecache[0])); i++)
if (localtranslationtablecache[i])
memset(localtranslationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**));
}
/*
+2
View File
@@ -15,6 +15,7 @@
#define __R_DRAW__
#include "r_defs.h"
#include "r_things.h"
// -------------------------------
// COMMON STUFF FOR 8bpp AND 16bpp
@@ -115,6 +116,7 @@ extern lumpnum_t viewborderlump[8];
// Initialize color translation tables, for player rendering etc.
void R_InitTranslationTables(void);
UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags);
UINT8* R_GetLocalTranslationColormap(skin_t *skin, skin_t *localskin, skincolors_t color, UINT8 flags, boolean local);
void R_FlushTranslationColormapCache(void);
UINT8 R_GetColorByName(const char *name);
+56
View File
@@ -439,6 +439,60 @@ fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1)
return FixedHypot(px1 - px2, py1 - py2);
}
angle_t R_PlayerSliptideAngle(player_t *player)
{
mobj_t *mo = player->mo;
if (!cv_sliptideroll.value || !mo || P_MobjWasRemoved(mo)) return 0;
size_t rot = mo->frame&FF_FRAMEMASK;
boolean papersprite = (mo->frame & FF_PAPERSPRITE);
spritedef_t *sprdef;
spriteframe_t *sprframe;
angle_t ang = 0;
interpmobjstate_t interp = {0};
// Yes.
if (R_UsingFrameInterpolation() && !paused)
{
R_InterpolateMobjState(mo, rendertimefrac, &interp);
}
else
{
R_InterpolateMobjState(mo, FRACUNIT, &interp);
}
if (mo->skin && mo->sprite == SPR_PLAY)
{
sprdef = &((skin_t *)mo->skin)->spritedef;
if (rot >= sprdef->numframes)
sprdef = &sprites[mo->sprite];
}
else
{
sprdef = &sprites[mo->sprite];
}
if (rot >= sprdef->numframes)
{
sprdef = &sprites[states[S_UNKNOWN].sprite];
rot = states[S_UNKNOWN].frame&FF_FRAMEMASK;
}
sprframe = &sprdef->spriteframes[rot];
// No sprite frame? I guess it is possible
if (!sprframe) return 0;
if (sprframe->rotate != SRF_SINGLE || papersprite)
ang = R_PointToAngle(interp.x, interp.y) - interp.angle;
return FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mo->player->sliproll*(mo->player->sliptidemem));
}
// Little extra utility. Works in the same way as R_PointToAngle2
fixed_t R_PointToDist(fixed_t x, fixed_t y)
{
@@ -1955,6 +2009,8 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_grshearing);
CV_RegisterVar(&cv_grshaders);
CV_RegisterVar(&cv_grusecustomshaders);
CV_RegisterVar(&cv_grpaletteshader);
CV_RegisterVar(&cv_grflashpal);
#endif
#ifdef HWRENDER
+1
View File
@@ -73,6 +73,7 @@ angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1);
fixed_t R_PointToDist(fixed_t x, fixed_t y);
fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
angle_t R_PlayerSliptideAngle(player_t *player);
fixed_t R_ScaleFromGlobalAngle(angle_t visangle);
subsector_t *R_PointInSubsector(fixed_t x, fixed_t y);
+1018 -1102
View File
File diff suppressed because it is too large. Load diff
+68 -69
View File
@@ -1,69 +1,68 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 2018-2019 by Jaime "Lactozilla" Passos.
// Copyright (C) 2019 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file r_patch.h
/// \brief Patch generation.
#ifndef __R_PATCH__
#define __R_PATCH__
#include "r_defs.h"
#include "doomdef.h"
// Structs
typedef enum
{
ROTAXIS_X, // Roll (the default)
ROTAXIS_Y, // Pitch
ROTAXIS_Z // Yaw
} rotaxis_t;
typedef struct
{
INT32 x, y;
rotaxis_t rotaxis;
} spriteframepivot_t;
typedef struct
{
spriteframepivot_t pivot[64];
boolean available;
} spriteinfo_t;
// Conversions between patches / flats / textures...
boolean R_CheckIfPatch(lumpnum_t lump);
void R_TextureToFlat(size_t tex, UINT8 *flat);
void R_PatchToFlat(patch_t *patch, UINT8 *flat);
void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip);
patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency);
patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize);
// SpriteInfo
extern spriteinfo_t spriteinfo[NUMSPRITES];
void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps);
void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum);
// Sprite rotation
#ifdef ROTSPRITE
INT32 R_GetRollAngle(angle_t rollangle);
patch_t *Patch_GetRotatedSprite(
spriteframe_t *sprite,
size_t frame, size_t spriteangle,
boolean flip, void *info,
INT32 rotationangle);
rotsprite_t *RotatedPatch_Create(INT32 numangles);
void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, UINT8 flip);
//void R_FreeSkinRotSprite(size_t skinnum);
extern fixed_t rollcosang[ROTANGLES];
extern fixed_t rollsinang[ROTANGLES];
void R_FreeAllRotSprite(void);
#endif
#endif // __R_PATCH__
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 2018-2019 by Jaime "Lactozilla" Passos.
// Copyright (C) 2019 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file r_patch.h
/// \brief Patch generation.
#ifndef __R_PATCH__
#define __R_PATCH__
#include "r_defs.h"
#include "doomdef.h"
// Structs
typedef enum
{
ROTAXIS_X, // Roll (the default)
ROTAXIS_Y, // Pitch
ROTAXIS_Z // Yaw
} rotaxis_t;
typedef struct
{
INT32 x, y;
rotaxis_t rotaxis;
} spriteframepivot_t;
typedef struct
{
spriteframepivot_t pivot[64];
boolean available;
} spriteinfo_t;
// Conversions between patches / flats / textures...
boolean R_CheckIfPatch(lumpnum_t lump);
void R_TextureToFlat(size_t tex, UINT8 *flat);
void R_PatchToFlat(patch_t *patch, UINT8 *flat);
void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip);
patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency);
patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize);
// SpriteInfo
extern spriteinfo_t spriteinfo[NUMSPRITES];
void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps);
void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum);
// Sprite rotation
#ifdef ROTSPRITE
INT32 R_GetRollAngle(angle_t rollangle);
patch_t *Patch_GetRotatedSprite(
spriteframe_t *sprite,
size_t frame, size_t spriteangle,
boolean flip, boolean adjustfeet,
void *info, INT32 rotationangle);
rotsprite_t *RotatedPatch_Create(INT32 numangles);
void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip);
extern fixed_t rollcosang[ROTANGLES];
extern fixed_t rollsinang[ROTANGLES];
#endif
#endif // __R_PATCH__
+3
View File
@@ -1769,6 +1769,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
while (need > maxopenings);
openings = Z_Realloc(openings, maxopenings * sizeof (*openings), PU_STATIC, NULL);
lastopening = openings + pos;
if (oldopenings == NULL)
return;
// borrowed fix from *cough* zdoom *cough*
// [RH] We also need to adjust the openings pointers that
+170 -38
View File
@@ -643,7 +643,7 @@ void R_InitSprites(void)
// it can be is do before loading config for skin cvar possible value
R_InitSkins();
for (i = 0; i < numwadfiles; i++)
R_AddSkins((UINT16)i);
R_AddSkins((UINT16)i, false);
//
// check if all sprites have frames
@@ -851,6 +851,15 @@ static void R_DrawVisSprite(vissprite_t *vis)
if (overflow_test < 0) overflow_test = -overflow_test;
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) return; // ditto
}
// TODO This check should not be necessary. But Papersprites near to the camera will sometimes create invalid values
// for the vissprite's startfrac. This happens because they are not depth culled like other sprites.
// Someone who is more familiar with papersprites pls check and try to fix <3
if (vis->startfrac < 0 || vis->startfrac > (patch->width << FRACBITS))
{
// never draw vissprites with startfrac out of patch range
return;
}
colfunc = basecolfunc; // hack: this isn't resetting properly somewhere.
dc_colormap = vis->colormap;
@@ -872,10 +881,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
if (vis->mobj->colorized)
dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE);
else if (vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // MT_GHOST LOOKS LIKE A PLAYER SO USE THE PLAYER TRANSLATION TABLES. >_>
{
size_t skinnum = (skin_t*)vis->mobj->skin-skins;
dc_translation = R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE);
}
dc_translation = R_GetLocalTranslationColormap(vis->mobj->skin, vis->mobj->localskin, vis->mobj->color, GTC_CACHE, vis->mobj->skinlocal);
else // Use the defaults
dc_translation = R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color, GTC_CACHE);
}
@@ -893,10 +899,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
if (vis->mobj->colorized)
dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE);
else if (vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // This thing is a player!
{
size_t skinnum = (skin_t*)vis->mobj->skin-skins;
dc_translation = R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE);
}
dc_translation = R_GetLocalTranslationColormap(vis->mobj->skin, vis->mobj->localskin, vis->mobj->color, GTC_CACHE, vis->mobj->skinlocal);
else // Use the defaults
dc_translation = R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color, GTC_CACHE);
}
@@ -925,7 +928,9 @@ static void R_DrawVisSprite(vissprite_t *vis)
frac = vis->startfrac;
windowtop = windowbottom = sprbotscreen = INT32_MAX;
if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES)
if (vis->mobj->localskin && ((skin_t *)vis->mobj->localskin)->flags & SF_HIRES)
this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->localskin)->highresscale);
else if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES)
this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale);
if (this_scale <= 0)
this_scale = 1;
@@ -1274,7 +1279,7 @@ static void R_ProjectSprite(mobj_t *thing)
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
if (thing->skin && thing->sprite == SPR_PLAY)
{
sprdef = &((skin_t *)thing->skin)->spritedef;
sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef;
#ifdef ROTSPRITE
sprinfo = &spriteinfo[thing->sprite];
#endif
@@ -1348,7 +1353,9 @@ static void R_ProjectSprite(mobj_t *thing)
I_Assert(lump < max_spritelumps);
if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES)
if (thing->localskin && ((skin_t *)thing->localskin)->flags & SF_HIRES)
this_scale = FixedMul(this_scale, ((skin_t *)thing->localskin)->highresscale);
else if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES)
this_scale = FixedMul(this_scale, ((skin_t *)thing->skin)->highresscale);
spr_width = spritecachedinfo[lump].width;
@@ -1373,7 +1380,7 @@ static void R_ProjectSprite(mobj_t *thing)
rollsum = (thing->rollangle) + (thing->sloperoll);
rollangle = R_GetRollAngle(rollsum);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
if (rotsprite != NULL)
{
@@ -2784,6 +2791,8 @@ void R_DrawMasked(void)
// ==========================================================================
INT32 numskins = 0;
INT32 numallskins = 0;
INT32 numlocalskins = 0;
skin_t skins[MAXSKINS];
UINT8 skinstats[9][9][MAXSKINS];
UINT8 skinstatscount[9][9] = {
@@ -2798,13 +2807,16 @@ UINT8 skinstatscount[9][9] = {
{0, 0, 0, 0, 0, 0, 0, 0, 0}
};
UINT8 skinsorted[MAXSKINS];
skin_t localskins[MAXSKINS];
skin_t allskins[MAXSKINS*2];
// FIXTHIS: don't work because it must be inistilised before the config load
//#define SKINVALUES
#ifdef SKINVALUES
CV_PossibleValue_t skin_cons_t[MAXSKINS+1];
CV_PossibleValue_t localskin_cons_t[MAXSKINS+1];
#endif
static void Sk_SetDefaultValue(skin_t *skin)
static void Sk_SetDefaultValue(skin_t *skin, boolean local)
{
INT32 i;
//
@@ -2812,7 +2824,7 @@ static void Sk_SetDefaultValue(skin_t *skin)
//
memset(skin, 0, sizeof (skin_t));
snprintf(skin->name,
sizeof skin->name, "skin %u", (UINT32)(skin-skins));
sizeof skin->name, "skin %u", (UINT32)(skin-( (local) ? localskins : skins )));
skin->name[sizeof skin->name - 1] = '\0';
skin->wadnum = INT16_MAX;
strcpy(skin->sprite, "");
@@ -2853,13 +2865,15 @@ void R_InitSkins(void)
{
skin_cons_t[i].value = 0;
skin_cons_t[i].strvalue = NULL;
localskin_cons_t[i].value = 0;
localskin_cons_t[i].strvalue = NULL;
}
#endif
// skin[0] = Sonic skin
skin = &skins[0];
numskins = 1;
Sk_SetDefaultValue(skin);
Sk_SetDefaultValue(skin, false);
memset(skinstats, 0, sizeof(skinstats));
memset(skinsorted, 0, sizeof(skinsorted));
@@ -2875,7 +2889,10 @@ void R_InitSkins(void)
strncpy(skin->facerank, "PLAYRANK", 9);
strncpy(skin->facewant, "PLAYWANT", 9);
strncpy(skin->facemmap, "PLAYMMAP", 9);
skin->wadnum = 0; // god what have you brought to this world
skin->prefcolor = SKINCOLOR_BLUE;
skin->localskin = false;
skin->localnum = 0;
// SRB2kart
skin->kartspeed = 8;
@@ -2893,8 +2910,12 @@ void R_InitSkins(void)
//MD2 for sonic doesn't want to load in Linux.
#ifdef HWRENDER
if (rendermode == render_opengl)
HWR_AddPlayerMD2(0);
HWR_AddPlayerMD2(0, false);
#endif
// lets set it
allskins[0] = skins[0];
numallskins = 1;
}
// returns true if the skin name is found (loaded from pwad)
@@ -2911,6 +2932,37 @@ INT32 R_SkinAvailable(const char *name)
return -1;
}
// returns true if the skin name is found (loaded from pwad)
// warning return -1 if not found
INT32 R_AnySkinAvailable(const char *name)
{
INT32 i;
for (i = 0; i < numallskins; i++)
{
if (stricmp(allskins[i].name,name)==0)
return i;
}
return -1;
}
INT32 R_LocalSkinAvailable(const char *name, boolean local)
{
INT32 i;
if (local)
{
for (i = 0; i < numlocalskins; i++)
{
if (stricmp(localskins[i].name,name)==0)
return i;
}
return -1;
}
else
return R_SkinAvailable(name);
}
// network code calls this when a 'skin change' is received
boolean SetPlayerSkin(INT32 playernum, const char *skinname)
{
@@ -2936,6 +2988,67 @@ boolean SetPlayerSkin(INT32 playernum, const char *skinname)
return false;
}
void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
{
player_t *player = &players[playernum];
INT32 i;
if (strcasecmp(skinname, "none"))
{
for (i = 0; i < numlocalskins; i++)
{
// search in the skin list
if (stricmp(localskins[i].name, skinname) == 0)
{
player->localskin = 1 + i;
player->skinlocal = true;
if (player->mo)
{
player->mo->localskin = &localskins[i];
player->mo->skinlocal = true;
}
break;
}
}
for (i = 0; i < numskins; i++)
{
// search in the skin list
if (stricmp(skins[i].name, skinname) == 0)
{
player->localskin = 1 + i;
player->skinlocal = false;
if (player->mo)
{
player->mo->localskin = &skins[i];
player->mo->skinlocal = false;
}
break;
}
}
}
else
{
player->localskin = 0;
player->skinlocal = false;
if (player->mo)
{
player->mo->localskin = 0;
player->mo->skinlocal = false;
}
}
if (cvar != NULL) {
if (player->localskin > 0) {
CV_StealthSet(&cv_fakelocalskin, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name);
CV_StealthSet(cvar, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name);
}
else {
CV_StealthSet(&cv_fakelocalskin, "none");
CV_StealthSet(cvar, "none");
}
}
}
// Same as SetPlayerSkin, but uses the skin #.
// network code calls this when a 'skin change' is received
void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
@@ -3120,7 +3233,7 @@ void sortSkinGrid(void)
//
// Find skin sprites, sounds & optional status bar face, & add them
//
void R_AddSkins(UINT16 wadnum)
void R_AddSkins(UINT16 wadnum, boolean local)
{
UINT16 lump, lastlump = 0;
char *buf;
@@ -3140,7 +3253,7 @@ void R_AddSkins(UINT16 wadnum)
// advance by default
lastlump = lump + 1;
if (numskins >= MAXSKINS)
if (( (local) ? numlocalskins : numskins ) >= MAXSKINS)
{
CONS_Alert(CONS_WARNING, M_GetText("Unable to add skin, too many characters are loaded (%d maximum)\n"), MAXSKINS);
continue; // so we know how many skins couldn't be added
@@ -3156,8 +3269,8 @@ void R_AddSkins(UINT16 wadnum)
buf2[size] = '\0';
// set defaults
skin = &skins[numskins];
Sk_SetDefaultValue(skin);
skin = &( (local) ? localskins : skins )[( (local) ? numlocalskins : numskins )];
Sk_SetDefaultValue(skin, local);
skin->wadnum = wadnum;
hudname = realname = false;
// parse
@@ -3181,7 +3294,7 @@ void R_AddSkins(UINT16 wadnum)
// the skin name must uniquely identify a single skin
// I'm lazy so if name is already used I leave the 'skin x'
// default skin name set in Sk_SetDefaultValue
if (R_SkinAvailable(value) == -1)
if (R_LocalSkinAvailable(value, local) == -1)
{
STRBUFCPY(skin->name, value);
strlwr(skin->name);
@@ -3191,12 +3304,12 @@ void R_AddSkins(UINT16 wadnum)
else
{
const size_t stringspace =
strlen(value) + sizeof (numskins) + 1;
strlen(value) + sizeof (( (local) ? numlocalskins : numskins )) + 1;
char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL);
snprintf(value2, stringspace,
"%s%d", value, numskins);
"%s%d", value, ( (local) ? numlocalskins : numskins ));
value2[stringspace - 1] = '\0';
if (R_SkinAvailable(value2) == -1)
if (R_LocalSkinAvailable(value2, local) == -1)
{
STRBUFCPY(skin->name,
value2);
@@ -3379,29 +3492,48 @@ next_token:
CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name);
#ifdef SKINVALUES
skin_cons_t[numskins].value = numskins;
skin_cons_t[numskins].strvalue = skin->name;
( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].value = ( (local) ? numlocalskins : numskins );
( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].strvalue = skin->name;
#endif
// Update the forceskin possiblevalues
Forceskin_cons_t[numskins+1].value = numskins;
Forceskin_cons_t[numskins+1].strvalue = skins[numskins].name;
if (!local)
{
Forceskin_cons_t[numskins+1].value = numskins;
Forceskin_cons_t[numskins+1].strvalue = skins[numskins].name;
}
skin->localskin = local;
// so we dont have to guess
if (local)
skin->localnum = numlocalskins;
else
skin->localnum = numskins;
// add face graphics
ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins);
if (local) {
ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins);
} else {
ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins);
}
#ifdef HWRENDER
if (rendermode == render_opengl)
HWR_AddPlayerMD2(numskins);
HWR_AddPlayerMD2(( (local) ? numlocalskins : numskins ), local);
#endif
skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins;
CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight);
skinstatscount[skin->kartspeed-1][skin->kartweight-1]++;
CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]);
if (!local) {
skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins;
CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight);
skinstatscount[skin->kartspeed-1][skin->kartweight-1]++;
CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]);
skinsorted[numskins] = numskins;
}
allskins[numallskins] = ( (local) ? localskins : skins )[( (local) ? numlocalskins : numskins )];
skinsorted[numskins] = numskins;
numskins++;
( (local) ? numlocalskins++ : numskins++ );
numallskins++;
}
sortSkinGrid();
+11 -3
View File
@@ -97,6 +97,9 @@ typedef struct
// specific sounds per skin
sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table
boolean localskin;
INT32 localnum;
} skin_t;
extern CV_PossibleValue_t Forceskin_cons_t[];
@@ -152,8 +155,6 @@ typedef struct vissprite_s
extracolormap_t *extra_colormap; // global colormaps
//fixed_t xscale;
// Precalculated top and bottom screen coords for the sprite.
fixed_t thingheight; // The actual height of the thing (for 3D floors)
sector_t *sector; // The sector containing the thing.
@@ -201,17 +202,24 @@ typedef struct drawnode_s
} drawnode_t;
extern INT32 numskins;
extern INT32 numlocalskins;
extern INT32 numallskins;
extern skin_t skins[MAXSKINS];
extern UINT8 skinstats[9][9][MAXSKINS];
extern UINT8 skinstatscount[9][9];
extern UINT8 skinsorted[MAXSKINS];
void sortSkinGrid(void);
extern skin_t localskins[MAXSKINS];
extern skin_t allskins[MAXSKINS*2];
boolean SetPlayerSkin(INT32 playernum,const char *skinname);
void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002
void SetLocalPlayerSkin(INT32 playernum,const char *skinname, consvar_t *cvar);
INT32 R_SkinAvailable(const char *name);
void R_AddSkins(UINT16 wadnum);
INT32 R_AnySkinAvailable(const char *name);
INT32 R_LocalSkinAvailable(const char *name, boolean local);
void R_AddSkins(UINT16 wadnum, boolean local);
#ifdef DELFILE
void R_DelSkins(UINT16 wadnum);
+1 -1
View File
@@ -578,7 +578,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
if (sfx->skinsound != -1 && origin && origin->skin)
{
// redirect player sound to the sound in the skin table
sfx_id = ((skin_t *)origin->skin)->soundsid[sfx->skinsound];
sfx_id = ((skin_t *)( (origin->localskin) ? origin->localskin : origin->skin ))->soundsid[sfx->skinsound];
sfx = &S_sfx[sfx_id];
}
+3
View File
@@ -113,6 +113,9 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(StartBatching);
GETFUNC(RenderBatches);
GETFUNC(AddLightTable);
GETFUNC(ClearLightTableCache);
#else //HWRENDER
if (0 == strcmp("FinishUpdate", funcName))
+6 -7
View File
@@ -3806,8 +3806,7 @@ static long get_entry(const char* name, const char* buf)
}
#endif
// quick fix for compil
UINT32 I_GetFreeMem(UINT32 *total)
size_t I_GetFreeMem(size_t *total)
{
#ifdef FREEBSD
struct vmmeter sum;
@@ -3855,8 +3854,8 @@ UINT32 I_GetFreeMem(UINT32 *total)
info.dwLength = sizeof (MEMORYSTATUS);
GlobalMemoryStatus( &info );
if (total)
*total = (UINT32)info.dwTotalPhys;
return (UINT32)info.dwAvailPhys;
*total = (size_t)info.dwTotalPhys;
return (size_t)info.dwAvailPhys;
#elif defined (__OS2__)
UINT32 pr_arena;
@@ -3871,8 +3870,8 @@ UINT32 I_GetFreeMem(UINT32 *total)
/* Linux */
char buf[1024];
char *memTag;
UINT32 freeKBytes;
UINT32 totalKBytes;
size_t freeKBytes;
size_t totalKBytes;
INT32 n;
INT32 meminfo_fd = -1;
long Cached;
@@ -3903,7 +3902,7 @@ UINT32 I_GetFreeMem(UINT32 *total)
}
memTag += sizeof (MEMTOTAL);
totalKBytes = atoi(memTag);
totalKBytes = (size_t)atoi(memTag);
if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL)
{
+10
View File
@@ -59,6 +59,7 @@
#endif
#include "../doomstat.h"
#include "../p_setup.h"
#include "../i_system.h"
#include "../v_video.h"
#include "../m_argv.h"
@@ -969,6 +970,7 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
void I_GetEvent(void)
{
SDL_Event evt;
char* dropped_filedir;
// We only want the first motion event,
// otherwise we'll end up catching the warp back to center.
//int mouseMotionOnce = 0;
@@ -1293,6 +1295,11 @@ void I_GetEvent(void)
if (currentMenu == &OP_JoystickSetDef)
M_SetupJoystickMenu(0);
break;
case SDL_DROPFILE:
dropped_filedir = evt.drop.file;
P_AddWadFile(dropped_filedir, false);
SDL_free(dropped_filedir); // Free dropped_filedir memory
break;
case SDL_QUIT:
I_Quit();
M_QuitResponse('y');
@@ -2141,6 +2148,9 @@ void I_StartupGraphics(void)
HWD.pfnStartBatching = hwSym("StartBatching",NULL);
HWD.pfnRenderBatches = hwSym("RenderBatches",NULL);
HWD.pfnAddLightTable = hwSym("AddLightTable",NULL);
HWD.pfnClearLightTableCache = hwSym("ClearLightTableCache",NULL);
if (!HWD.pfnInit()) // load the OpenGL library
rendermode = render_soft;
+45 -6
View File
@@ -58,6 +58,18 @@ patch_t *facerankprefix[MAXSKINS]; // ranking
patch_t *facewantprefix[MAXSKINS]; // wanted
patch_t *facemmapprefix[MAXSKINS]; // minimap
patch_t *localfacerankprefix[MAXSKINS]; // ranking
patch_t *localfacewantprefix[MAXSKINS]; // wanted
patch_t *localfacemmapprefix[MAXSKINS]; // minimap
char *facerankprefix_name[MAXSKINS]; // ranking
char *facewantprefix_name[MAXSKINS]; // wanted
char *facemmapprefix_name[MAXSKINS]; // minimap
char *localfacerankprefix_name[MAXSKINS]; // ranking
char *localfacewantprefix_name[MAXSKINS]; // wanted
char *localfacemmapprefix_name[MAXSKINS]; // minimap
// ------------------------------------------
// status bar overlay
// ------------------------------------------
@@ -232,18 +244,22 @@ void ST_doPaletteStuff(void)
else
palette = 0;
palette = min(max(palette, 0), 13);
#ifdef HWRENDER
if (rendermode == render_opengl)
if (rendermode == render_opengl && !cv_grpaletteshader.value || rendermode == render_opengl && cv_grpaletteshader.value && !cv_grflashpal.value)
palette = 0; // No flashpals here in OpenGL
#endif
palette = min(max(palette, 0), 13);
if (palette != st_palette)
{
st_palette = palette;
if (rendermode == render_soft)
#ifdef HWRENDER
if (rendermode != render_none && cv_grpaletteshader.value && cv_grflashpal.value)
#else
if (rendermode != render_none)
#endif
{
//V_SetPaletteLump(GetPalette()); // Reset the palette -- is this needed?
if (!splitscreen)
@@ -378,6 +394,25 @@ void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skin
facerankprefix[skinnum] = W_CachePatchName(rankstr, PU_HUDGFX);
facewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX);
facemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX);
facerankprefix_name[skinnum] = rankstr;
facewantprefix_name[skinnum] = wantstr;
facemmapprefix_name[skinnum] = mmapstr;
}
void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skinnum)
{
localfacerankprefix[skinnum] = W_CachePatchName(rankstr, PU_HUDGFX);
localfacewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX);
localfacemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX);
localfacerankprefix_name[skinnum] = rankstr;
localfacewantprefix_name[skinnum] = wantstr;
localfacemmapprefix_name[skinnum] = mmapstr;
//CONS_Printf("Added rank prefix %s\n", rankstr);
//CONS_Printf("Added want prefix %s\n", wantstr);
//CONS_Printf("Added mmap prefix %s\n", mmapstr);
}
void ST_ReloadSkinFaceGraphics(void)
@@ -386,6 +421,10 @@ void ST_ReloadSkinFaceGraphics(void)
for (i = 0; i < numskins; i++)
ST_LoadFaceGraphics(skins[i].facerank, skins[i].facewant, skins[i].facemmap, i);
for (i = 0; i < numlocalskins; i++) {
ST_LoadLocalFaceGraphics(localskins[i].facerank, localskins[i].facewant, localskins[i].facemmap, i);
}
}
static inline void ST_InitData(void)
@@ -2167,9 +2206,9 @@ void ST_Drawer(void)
//25/08/99: Hurdler: palette changes is done for all players,
// not only player1! That's why this part
// of code is moved somewhere else.
if (rendermode == render_soft)
if (rendermode == render_soft || rendermode == render_opengl && cv_grpaletteshader.value && cv_grflashpal.value)
#endif
if (rendermode != render_none) ST_doPaletteStuff();
if (rendermode != render_none) ST_doPaletteStuff();
if (st_overlay)
{
+10
View File
@@ -51,6 +51,7 @@ void ST_LoadGraphics(void);
// face load graphics, called when skin changes
void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum);
void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum);
void ST_ReloadSkinFaceGraphics(void);
#ifdef DELFILE
void ST_UnLoadFaceGraphics(INT32 skinnum);
@@ -78,6 +79,15 @@ extern patch_t *sboperiod;
extern patch_t *facerankprefix[MAXSKINS]; // ranking
extern patch_t *facewantprefix[MAXSKINS]; // wanted
extern patch_t *facemmapprefix[MAXSKINS]; // minimap
extern patch_t *localfacerankprefix[MAXSKINS]; // ranking
extern patch_t *localfacewantprefix[MAXSKINS]; // wanted
extern patch_t *localfacemmapprefix[MAXSKINS]; // minimap
extern char *facerankprefix_name[MAXSKINS]; // ranking
extern char *facewantprefix_name[MAXSKINS]; // wanted
extern char *facemmapprefix_name[MAXSKINS]; // minimap
extern char *localfacerankprefix_name[MAXSKINS]; // ranking
extern char *localfacewantprefix_name[MAXSKINS]; // wanted
extern char *localfacemmapprefix_name[MAXSKINS]; // minimap
extern patch_t *livesback;
extern patch_t *ngradeletters[7];
+22 -4
View File
@@ -28,6 +28,7 @@
#ifdef HWRENDER
#include "hardware/hw_main.h"
#include "hardware/r_opengl/r_opengl.h"
#endif
// Each screen is [vid.width*vid.height];
@@ -224,8 +225,17 @@ void V_SetPalette(INT32 palettenum)
LoadMapPalette();
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none)
HWR_SetPalette(&pLocalPalette[palettenum*256]);
if (rendermode != render_soft && rendermode != render_none) {
// in palette rendering mode, we already manage our palette ourselves
if (cv_grpaletteshader.value == 1)
{
// reset our palette lookups n shit
gl_palette_initialized = false;
InitPalette(palettenum, true);
}
else
HWR_SetPalette(pLocalPalette);
}
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
else
#endif
@@ -238,8 +248,16 @@ void V_SetPaletteLump(const char *pal)
{
LoadPalette(pal);
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none)
HWR_SetPalette(pLocalPalette);
if (rendermode != render_soft && rendermode != render_none) {
if (cv_grpaletteshader.value == 1)
{
// reset our palette lookups n shit
gl_palette_initialized = false;
InitPalette(0, false);
}
else
HWR_SetPalette(pLocalPalette);
}
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
else
#endif
+50 -9
View File
@@ -65,6 +65,7 @@
#include "i_system.h"
#include "md5.h"
#include "lua_script.h"
#include "st_stuff.h"
#ifdef SCANTHINGS
#include "p_setup.h" // P_ScanThings
#endif
@@ -148,6 +149,40 @@ void W_Shutdown(void)
static char filenamebuf[MAX_WADPATH];
// This #if is copied from filesrch.c, so not sure if it is 100% suitable for
// this
#if defined (_WIN32) && !defined (_XBOX)
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h>
// Windows can't open utf-8 path so it must be converted to utf-16
FILE* fopen_utf8(const char* filename, const char* mode)
{
static const int MY_PATH_MAX = 2048;
WCHAR nameW[MY_PATH_MAX];
memset(nameW, 0, sizeof(WCHAR)*MY_PATH_MAX);
WCHAR modeW[16];
memset(modeW, 0, sizeof(WCHAR)*16);
// the following function converts the UTF-8 filename to UTF-16 (WCHAR) nameW
int len = MultiByteToWideChar(CP_UTF8, 0, filename, -1, nameW, MY_PATH_MAX);
if(len > 0 && MultiByteToWideChar(CP_UTF8, 0, mode, -1, modeW, 16) > 0)
{
// using _wfopen_s() shuts up MSVC's complaints
// about _wfopen() being unsafe..
FILE* ret = NULL;
if(_wfopen_s(&ret, nameW, modeW) == 0)
return ret;
}
return NULL;
}
#else
#define fopen_utf8 fopen
#endif
// W_OpenWadFile
// Helper function for opening the WAD file.
// Returns the FILE * handle for the file, or NULL if not found or could not be opened
@@ -165,7 +200,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
*filename = filenamebuf;
// open wad file
if ((handle = fopen(*filename, "rb")) == NULL)
if ((handle = fopen_utf8(*filename, "rb")) == NULL)
{
// If we failed to load the file with the path as specified by
// the user, strip the directories and search for the file.
@@ -175,7 +210,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
// in filenamebuf == *filename.
if (findfile(filenamebuf, NULL, true))
{
if ((handle = fopen(*filename, "rb")) == NULL)
if ((handle = fopen_utf8(*filename, "rb")) == NULL)
{
if (useerrors)
CONS_Alert(CONS_ERROR, M_GetText("Can't open %s\n"), *filename);
@@ -690,7 +725,7 @@ static void W_ReadFileShaders(wadfile_t *wadfile)
//
// Can now load dehacked files (.soc)
//
UINT16 W_InitFile(const char *filename, boolean local)
UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, boolean local)
{
FILE *handle;
lumpinfo_t *lumpinfo = NULL;
@@ -743,10 +778,13 @@ UINT16 W_InitFile(const char *filename, boolean local)
{
if (!memcmp(wadfiles[i]->md5sum, md5sum, 16))
{
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename);
if (handle)
fclose(handle);
return INT16_MAX;
if (!local) {
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename);
if (handle)
fclose(handle);
return INT16_MAX;
}
CONS_Alert(CONS_WARNING, M_GetText("%s is a local skin that is already loaded\n"), filename);
}
}
#endif
@@ -789,6 +827,7 @@ UINT16 W_InitFile(const char *filename, boolean local)
fseek(handle, 0, SEEK_END);
wadfile->filesize = (unsigned)ftell(handle);
wadfile->type = type;
wadfile->majormod = false;
// already generated, just copy it over
M_Memcpy(&wadfile->md5sum, &md5sum, 16);
@@ -898,7 +937,7 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons)
G_SetGameModified(true, false);
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
rc = W_InitFile(*filenames, false);
rc = W_InitFile(*filenames, 0, 0, false);
if (rc == INT16_MAX)
CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames);
overallrc &= (rc != INT16_MAX) ? 1 : 0;
@@ -1727,7 +1766,9 @@ void *W_CachePatchName(const char *name, INT32 tag)
{
lumpnum_t num;
num = W_CheckNumForName(name);
const char *finalname = name;
num = W_CheckNumForName(finalname);
if (num == LUMPERROR)
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
+3 -1
View File
@@ -114,6 +114,8 @@ typedef struct wadfile_s
UINT32 filesize; // for network
UINT8 md5sum[16];
boolean important;
boolean majormod;
boolean localfile; // only for skins
} wadfile_t;
#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word
@@ -132,7 +134,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors);
//
// if local is true, it wouldn't check if file adds complex things, therefore
// allowing to still join server without the "you have wrong addons loaded" error
UINT16 W_InitFile(const char *filename, boolean local);
UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, boolean local);
#ifdef DELFILE
void W_UnloadWadFile(UINT16 num);
#endif
+140 -10
View File
@@ -116,6 +116,19 @@ static INT32 intertic;
static INT32 endtic = -1;
static INT32 sorttic = -1;
patch_t *animVoteFramesPatches = NULL;
// VEXTRN - Vote (V) Extra (EXT) Race (R) Normal (N - Normal sized patch)
// VEXTBN - Vote (V) Extra (EXT) Battle (B) Normal (N - Normal sized patch)
// VEXTBW - Vote (V) Extra (EXT) Battle (B) Normal (W - Wide patch used in software)
// VEXTRW - Vote (V) Extra (EXT) Race (R) Normal (W - Wide patch used in software)
char animPrefix[] = "INTSC";
char animWidePrefix[] = "INTSW";
char *luaVoteScreen = NULL;
INT32 currentAnimFrame = 0;
static INT32 foundAnimVoteFrames = 0;
static INT32 foundAnimVoteWideFrames = 0;
intertype_t intertype = int_none;
@@ -159,6 +172,7 @@ typedef struct
static y_votelvlinfo levelinfo[5];
static y_voteclient voteclient;
static INT32 votetic;
static INT32 lastvotetic;
static INT32 voteendtic = -1;
static patch_t *cursor = NULL;
static patch_t *cursor1 = NULL;
@@ -325,6 +339,54 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
}
}
//
// Y_AnimatedVoteScreenCheck
//
// Check if the lumps exist (checking for VEXTR(N|W)xx for race and VEXTRB(N|W)xx for battle)
void Y_AnimatedVoteScreenCheck(void)
{
char tmpPrefix[] = "INTS";
boolean stopSearching = false;
if (luaVoteScreen)
{
strncpy(tmpPrefix, luaVoteScreen, 4);
}
else
{
if(G_BattleGametype()) {
strcpy(tmpPrefix, "BTLS");
}
}
strncpy(animPrefix, tmpPrefix, 4);
animPrefix[4] = 'C';
strncpy(animWidePrefix, tmpPrefix, 4);
animWidePrefix[4] = 'W';
foundAnimVoteFrames = 0;
foundAnimVoteWideFrames = 0;
currentAnimFrame = 0;
INT32 i = 1;
while(!stopSearching){
boolean normalLumpExists = W_LumpExists(va("%sC%d", tmpPrefix, i));
boolean wideLumpExists = W_LumpExists(va("%sW%d", tmpPrefix, i));
if(normalLumpExists || wideLumpExists){
if(normalLumpExists){
foundAnimVoteFrames++;
}
if(wideLumpExists){
foundAnimVoteWideFrames++;
}
} else { // If we don't find at least frame 1 (e.g VEXTRN1), let's just stop looking
stopSearching = true;
}
i++;
}
}
//
// Y_IntermissionDrawer
//
@@ -482,7 +544,15 @@ void Y_IntermissionDrawer(void)
if (data.match.color[i])
{
UINT8 *colormap = R_GetTranslationColormap(*data.match.character[i], *data.match.color[i], GTC_CACHE);
V_DrawMappedPatch(x+16, y-4, 0, facerankprefix[*data.match.character[i]], colormap);
// i fucking hate this i fucking hate this i hate this so much
if (!players[data.match.num[i]].skinlocal) {
if (!players[data.match.num[i]].localskin)
V_DrawMappedPatch(x+16, y-4, 0, facerankprefix[*data.match.character[i]], colormap);
else
V_DrawMappedPatch(x+16, y-4, 0, facerankprefix[players[data.match.num[i]].localskin - 1], colormap);
} else {
V_DrawMappedPatch(x+16, y-4, 0, localfacerankprefix[players[data.match.num[i]].localskin - 1], colormap);
}
}
if (data.match.num[i] == whiteplayer)
@@ -978,6 +1048,42 @@ static void Y_UnloadData(void)
// SRB2Kart: Voting!
// Y_DrawAnimatedVoteScreenPatch
//
// Draw animated patch based on frame counter on vote screen
//
void Y_DrawAnimatedVoteScreenPatch(boolean widePatch){
char tempAnimPrefix[7];
(widePatch) ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix);
INT32 tempFoundAnimVoteFrames = (widePatch) ? foundAnimVoteWideFrames : foundAnimVoteFrames;
INT32 flags = V_SNAPTOBOTTOM | V_SNAPTOTOP;
// Just in case someone provides LESS widescreen frames than normal frames or vice versa, reset the frame counter to 0
if(widePatch) {
if(currentAnimFrame > foundAnimVoteWideFrames-1){
currentAnimFrame = 0;
}
} else {
if(currentAnimFrame > foundAnimVoteFrames-1){
currentAnimFrame = 0;
}
}
/*patch_t *currPatch = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame+1), PU_CACHE);
V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(currPatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?)
(vid.height / vid.dupy) - SHORT(currPatch->height),
V_SNAPTOTOP|V_SNAPTOLEFT, currPatch);
if(votetic % 3 == 0 && !paused){*/
{
patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE);
V_DrawScaledPatch(160 - (background->width / 2), (200 - (background->height)), flags, background);
}
if (lastvotetic != votetic && lastvotetic % 2 == 0) {
currentAnimFrame = (currentAnimFrame+1 > tempFoundAnimVoteFrames-1) ? 0 : currentAnimFrame + 1; // jeez no fucking idea how to make this shit not go nuts with interpolation
}
}
//
// Y_VoteDrawer
//
@@ -1006,14 +1112,34 @@ void Y_VoteDrawer(void)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
if (widebgpatch && rendermode == render_soft && vid.width / vid.dupx > 320)
V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2),
(vid.height / vid.dupy) - SHORT(widebgpatch->height),
V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch);
else
V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?)
(vid.height / vid.dupy) - SHORT(bgpatch->height),
V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch);
if (widebgpatch && vid.width / vid.dupx > 320) {
if(foundAnimVoteWideFrames == 0){
V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2),
(vid.height / vid.dupy) - SHORT(widebgpatch->height),
V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch);
} else {
// patch_t *currPatch = W_CachePatchName(va("%s%d", animPrefix, currentAnimFrame+1), PU_CACHE);
// V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(currPatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?)
// (vid.height / vid.dupy) - SHORT(currPatch->height),
// V_SNAPTOTOP|V_SNAPTOLEFT, currPatch);
// if(votetic % 4 == 0 && !paused){
// currentAnimFrame = (currentAnimFrame+1 > foundAnimVoteFrames-1) ? 0 : currentAnimFrame + 1;
// }
Y_DrawAnimatedVoteScreenPatch(true);
}
} else {
if(foundAnimVoteFrames == 0) {
V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?)
(vid.height / vid.dupy) - SHORT(bgpatch->height),
V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch);
} else {
Y_DrawAnimatedVoteScreenPatch(false);
}
}
for (i = 0; i < 4; i++) // First, we need to figure out the height of this thing...
{
@@ -1200,7 +1326,7 @@ void Y_VoteDrawer(void)
if (players[i].skincolor)
{
UINT8 *colormap = R_GetTranslationColormap(players[i].skin, players[i].skincolor, GTC_CACHE);
V_DrawMappedPatch(x+24, y+9, V_SNAPTOLEFT, facerankprefix[players[i].skin], colormap);
V_DrawMappedPatch(x+24, y+9, V_SNAPTOLEFT, (players[i].skinlocal ? localfacerankprefix : facerankprefix)[((players[i].localskin) ? players[i].localskin-1 : players[i].skin)], colormap);
}
if (!splitscreen && i == consoleplayer)
@@ -1231,6 +1357,8 @@ void Y_VoteDrawer(void)
V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol,
va("Vote ends in %d", tickdown));
}
lastvotetic = votetic;
#ifdef HAVE_BLUA
if (renderisnewtic)
@@ -1487,6 +1615,8 @@ void Y_StartVote(void)
I_Error("voteendtic is dirty");
#endif
Y_AnimatedVoteScreenCheck();
widebgpatch = W_CachePatchName(((prefgametype == GT_MATCH) ? "BATTLSCW" : "INTERSCW"), PU_STATIC);
bgpatch = W_CachePatchName(((prefgametype == GT_MATCH) ? "BATTLSCR" : "INTERSCR"), PU_STATIC);
cursor = W_CachePatchName("M_CURSOR", PU_STATIC);
+1
View File
@@ -10,6 +10,7 @@
/// \brief Tally screens, or "Intermissions" as they were formally called in Doom
extern boolean usebuffer;
extern char *luaVoteScreen;
void Y_IntermissionDrawer(void);
void Y_Ticker(void);
+6 -5
View File
@@ -140,14 +140,14 @@ static void Command_Memdump_f(void);
void Z_Init(void)
{
UINT32 total, memfree;
size_t total, memfree;
memset(&head, 0x00, sizeof(head));
head.next = head.prev = &head;
memfree = I_GetFreeMem(&total)>>20;
CONS_Printf("System memory: %uMB - Free: %uMB\n", total>>20, memfree);
CONS_Printf("System memory: %sMB - Free: %sMB\n", sizeu1(total>>20), sizeu2(memfree));
// Note: This allocates memory. Watch out.
COM_AddCommand("memfree", Command_Memfree_f);
@@ -616,12 +616,13 @@ size_t Z_TagUsage(INT32 tagnum)
void Command_Memfree_f(void)
{
UINT32 freebytes, totalbytes;
size_t freebytes, totalbytes;
Z_CheckHeap(-1);
CONS_Printf("\x82%s", M_GetText("Memory Info\n"));
CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TagsUsage(0, INT32_MAX)>>10));
CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10));
CONS_Printf(M_GetText("Lua : %7s KB\n"), sizeu1(Z_TagUsage(PU_LUA)>>10));
CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10));
CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10));
CONS_Printf(M_GetText("Locked cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_CACHE)>>10));
@@ -643,8 +644,8 @@ void Command_Memfree_f(void)
CONS_Printf("\x82%s", M_GetText("System Memory Info\n"));
freebytes = I_GetFreeMem(&totalbytes);
CONS_Printf(M_GetText(" Total physical memory: %7u KB\n"), totalbytes>>10);
CONS_Printf(M_GetText("Available physical memory: %7u KB\n"), freebytes>>10);
CONS_Printf(M_GetText(" Total physical memory: %s KB\n"), sizeu1(totalbytes>>10));
CONS_Printf(M_GetText("Available physical memory: %s KB\n"), sizeu1(freebytes>>10));
}
#ifdef ZDEBUG