Compare commits

...

324 Commits

Author SHA1 Message Date
James R 17f75903b0 Don't let players change their name more than five times per minute 2020-08-31 20:08:22 -07:00
Sally Coolatta 328d6d9a36 Increase cipher length 2020-08-31 00:25:28 -04:00
Sally Coolatta 1c47841487 Remove default dirs on Windows
Cause more issues than fixes. Still around for Linux.
2020-08-31 00:06:47 -04:00
Sally Coolatta da0d0e41df Expand IP_SIZE 2020-08-30 23:41:27 -04:00
Sally Coolatta 651d25a516 Move to D_RegisterServerCommands 2020-08-30 23:35:41 -04:00
Sally Coolatta 85884ad4e2 Bruh, lowercase 2020-08-30 23:31:54 -04:00
Sally Coolatta 6ca451da45 Wrong file 2020-08-30 23:26:00 -04:00
Sally Coolatta 7dea9d28b9 Dedicated servers can change discordinvites without needing RPC support 2020-08-30 23:20:06 -04:00
James R 6d2c7f4ae7 NO_DISCORDRPC to disable rich presence on Windows 2020-08-30 19:11:30 -07:00
James R 7ab1c4a2df Update versions to 1.3 2020-08-30 19:06:31 -07:00
James R 0371a113ef Update patch.kart asset hash 2020-08-30 19:02:31 -07:00
James R 5e9c197f8a Merge remote-tracking branch 'origin/master' into next 2020-08-30 19:01:04 -07:00
Sal 8acc2b6f3c Merge branch 'world-tour' into 'next'
Flush random map pool after all but 3 are played

See merge request KartKrew/Kart-Public!216
2020-08-30 21:49:20 -04:00
Sal b0f89a5dba Merge branch 'easy-colors' into 'master'
Caret color codes in server name

See merge request KartKrew/Kart-Public!218
2020-08-30 21:49:03 -04:00
Sal 1aca163d12 Merge branch 'discord-rpc-support' into 'next'
Discord Rich Presence

See merge request KartKrew/Kart-Public!207
2020-08-30 21:48:44 -04:00
Sally Coolatta 29f156aac2 Use ENTER and ESC
A and B are v2 terminology
2020-08-30 21:42:04 -04:00
James R bca656e4ac Merge branch 'master' into next 2020-08-29 18:22:19 -07:00
James R daf6e66268 Fix stupid NONET
(cherry picked from commit 679bfa21edec6b652def93082da5586e6c755678)
2020-08-29 18:19:39 -07:00
James R 95a026c98d C90?
(cherry picked from commit 1f38db46298181d117432e12e88b326a92b4b785)
2020-08-29 18:19:15 -07:00
James R 3f842937a8 Merge remote-tracking branch 'origin/master' into next 2020-08-29 11:26:52 -07:00
Sally Coolatta 82bfdf9ccc Add join/leave notification sounds 2020-08-27 20:10:25 -04:00
Sally Coolatta 17318ceec7 This should be set for server too!! 2020-08-27 19:36:37 -04:00
Sally Coolatta 51dce9707f Attach initial join discord info to servercfg, so that we don't have a pause from needing to also send XD_DISCORD
XD_DISCORD is now reserved for when the options are changed mid-game
2020-08-27 19:14:45 -04:00
Sally Coolatta c165b0761c Misc changes to how the program runs
- Call DRPC_Init at the end of D_SRB2Main instead of in the middle
- Call Discord_RunCallbacks in D_SRB2Loop instead of G_Ticker
- Fix errorcount nums in I_Error, an old leftover from when Discord_Shutdown was not handled by I_AddExitFunction
2020-08-27 18:50:36 -04:00
James R 54c3aed86c Convert caret color codes to SRB2 color codes 2020-08-27 15:44:06 -07:00
James R f802e9fbcb Convert from caret colors when sending SERVERINFO 2020-08-27 15:43:20 -07:00
Sal 734ce8dee5 Merge branch 'expose-demoplayback' into 'next'
Expose demo.playback to Lua

See merge request KartKrew/Kart-Public!217
2020-08-27 18:18:39 -04:00
Steel Titanium 35122d3a22 Expose demo.playback to Lua 2020-08-27 14:58:46 -04:00
TehRealSalt 86754cf820 Flush random map pool after all but 3 are played 2020-08-27 14:32:44 -04:00
Sal 5e7926d87f Merge branch 'check-defaultdir' into 'master'
Check ~/.srb2kart for srb2.srb

See merge request KartKrew/Kart-Public!215
2020-08-27 14:08:17 -04:00
James R 4c816f4059 Say DEFAULTDIR not .srb2kart 2020-08-26 23:37:52 -07:00
James R 6e3facf8f4 Check DEFAULTDIR for srb2.srb after cwd 2020-08-26 20:20:40 -07:00
Sally Coolatta cb5ab33a93 Merge branch 'next' into discord-rpc-support 2020-08-26 12:56:58 -04:00
Sally Coolatta ee1ea21336 Merge branch 'master' into next 2020-08-26 12:56:38 -04:00
Sal f87b883ba5 Merge branch 'various-compiling-fixes-2' into 'master'
Fix some compile flags

See merge request KartKrew/Kart-Public!213
2020-08-26 09:58:35 -04:00
Sal 7c69e49a05 Merge branch 'too-many-characters' into 'master'
Warn players when going over the skin limit

See merge request KartKrew/Kart-Public!214
2020-08-26 09:58:22 -04:00
ThatAwesomeGuy173 27b72ccbf5 Replace 'ignoring skin' debug print with a proper console warning 2020-08-25 23:13:58 -06:00
Sal 34b6998b2e Merge branch 'various-compiling-fixes' into 'next'
Various compiling fixes

See merge request KartKrew/Kart-Public!212
2020-08-25 18:36:51 -04:00
James R 04d774c765 Fix NOHW compiling 2020-08-24 18:06:00 -07:00
James R 3437b0690a Kill NOHS 2020-08-24 17:58:39 -07:00
James R 16fc87edcf Fix NOMIXER compiling 2020-08-24 17:55:42 -07:00
James R fbde926497 Fix NOPNG compiling 2020-08-24 17:52:55 -07:00
James R 0d57ba1d02 Fix NOGME compiling 2020-08-24 17:51:01 -07:00
Sal bea6b6a9d2 Merge branch 'fix-asktime-really' into 'next'
Avoid underflows on connection screen timer (fixes hosting servers)

See merge request KartKrew/Kart-Public!211
2020-08-24 16:09:33 -04:00
Steel Titanium c6164a1947 Initialize this variable 2020-08-24 01:25:34 -04:00
Steel Titanium 41c742a699 Hopefully the last time... 2020-08-24 01:18:38 -04:00
Steel Titanium 87d2ad0c23 Remind me why NONET exists? 2020-08-24 01:13:59 -04:00
Steel Titanium 04b7051141 This is just stupid 2020-08-24 01:06:10 -04:00
Steel Titanium 84bab3fc9f Turns out compiling with the internal version of curl was broken on CMake the entire time 🙃 2020-08-24 01:00:28 -04:00
Steel Titanium d4006d00c3 Screw you C90 2020-08-24 00:58:14 -04:00
Steel Titanium 509c57a8d6 Haha NONET... 2020-08-24 00:56:53 -04:00
Steel Titanium e58c9ac410 It's discord-rpc, not libgme 2020-08-23 17:45:31 -04:00
Steel Titanium d9cbb69327 Better CMake support
No idea if it compiles on Mac, it does on Linux though, at least for me.
2020-08-23 16:15:33 -04:00
Sally Coolatta 585cb1cfe3 Finish DEVELOP mode functionality 2020-08-23 07:15:33 -04:00
Sally Coolatta 720eced665 Attempt to improve discord-rpc checking in CMake
Haven't ever gotten CMake to compile SRB2, so I'm unable to really check if this works
2020-08-23 06:45:35 -04:00
Sally Coolatta ed58cb5468 Move the .dll's to libs\dll-binaries 2020-08-23 05:58:09 -04:00
Sally Coolatta 175fa43c90 Update win 32 bit libraries, implement win 64 bit libraries 2020-08-23 05:47:55 -04:00
Sally Coolatta e2f3e76db8 Merge branch 'next' into discord-rpc-support 2020-08-23 05:32:32 -04:00
Sal 88e7b6198d Merge branch 'lineriding-b-gone' into 'next'
Kill offroad line riding

See merge request KartKrew/Kart-Public!199
2020-08-23 05:09:55 -04:00
Sally Coolatta 7d380c326b Merge branch 'master' into next 2020-08-23 04:44:27 -04:00
Sally Coolatta 3ce6b8a54f Fix version string 2020-08-23 04:44:05 -04:00
Sal d0629a9c13 Merge branch 'fix-ogl-timedemo' into 'master'
Fix timedemo in OpenGL mode

See merge request KartKrew/Kart-Public!209
2020-08-23 04:38:57 -04:00
Sal 3f16ef2eaa Merge branch 'misc-optimizations' into 'master'
Remove ESLOPE POLYOBJECTS POLYOBJECTS_PLANES #ifdefs (backport srb2 2.2)

See merge request KartKrew/Kart-Public!204
2020-08-23 04:38:05 -04:00
James R 035fab5f6c Merge branch 'demoleak-fix' into 'master'
Fix replay recording memory leak

See merge request KartKrew/Kart-Public!208
2020-08-22 21:42:34 -04:00
James R 5daaef7e87 Avoid underflow hacks completely with asktime 2020-08-22 18:38:20 -07:00
James R 89ba08a376 Make join requests options on pause menu selectable even if you're already in the menu 2020-08-22 17:16:49 -07:00
James R 805fb01df9 Skip XD_DISCORD payload in non Discord builds 2020-08-22 16:26:15 -07:00
Hannu Hanhi 4210352be9 Fix timedemo in OpenGL mode 2020-08-23 00:10:50 +03:00
Hannu Hanhi 5c13727aac Fix replay recording memory leak 2020-08-22 22:04:45 +03:00
Sally Coolatta 084756ec72 Fix XOR not working 2020-08-22 09:46:25 -04:00
Sal cc3eb94b26 Merge branch 'dehacked-slipup' into 'next'
Correct misplaced MT_ARIDTOAD listing

See merge request KartKrew/Kart-Public!206
2020-08-22 08:16:41 -04:00
Sally Coolatta 5de27be169 Merge remote-tracking branch 'public/next' into discord-rpc-support 2020-08-22 07:28:21 -04:00
Sally Coolatta e5238d095f Remove timer variable
Doesn't feel necessary to me anymore, especially with how the menu works
2020-08-22 07:25:47 -04:00
Sally Coolatta f61e3a77bd Ask to join is a menu option, rather than trying to replace your menu temporarily. 2020-08-22 07:16:52 -04:00
lachwright 32f2ed4a53 Correct misplaced MT_ARIDTOAD listing 2020-08-22 17:35:31 +08:00
Sally Coolatta 6f9025a14d Merge branch 'discord-rpc-support' of https://git.magicalgirl.moe/KartKrew/Kart into discord-rpc-support 2020-08-22 05:03:43 -04:00
Sally Coolatta 3d5d5ad8b5 Always have XD_DISCORD defined, so that people compiling without Discord support can connect to servers that do. 2020-08-22 05:03:08 -04:00
lachwright e01c7aef32 Compile m_menu.c without HAVE_DISCORDRPC 2020-08-22 16:58:59 +08:00
Sally Coolatta 3c128660b4 Add envelope icon, add sounds 2020-08-22 04:54:08 -04:00
Sally Coolatta 98f586a2f9 Menu is pretty now 2020-08-22 03:52:07 -04:00
Sally Coolatta 571c670670 Add some options, maxplayer/allownewplayer dont need to be netvars anymore 2020-08-22 01:53:27 -04:00
Sally Coolatta 8ff62cdc7f Base xor off of inital seed 2020-08-22 00:11:33 -04:00
Sally Coolatta e0d0a3a74e Ignore any duplicate requests
You will still get a message for them, so if they're being annoying you will want to block them anyway, but at least it won't clog up the game.
2020-08-22 00:01:56 -04:00
Sally Coolatta 4d8c65bb73 Don't reset menu in drawing function 2020-08-21 04:17:36 -04:00
Sally Coolatta 983a978c12 Merge branch 'discord-rpc-support' of https://git.magicalgirl.moe/KartKrew/Kart into discord-rpc-support 2020-08-21 04:14:36 -04:00
Sally Coolatta 339be6f90e Invite menu started
Functions! Is not pretty yet!
2020-08-21 04:14:33 -04:00
James R 0b07d0ed6f curl_global_cleanup 2020-08-20 22:36:41 -07:00
Sally Coolatta 7b1e14d017 Don't show map image for title screen demos 2020-08-21 01:18:40 -04:00
Sally Coolatta 6a86d86828 XOR IP addresses before sending them to Discord
Not complex because we aren't sending anything that isn't easily accessible via the Master Server anyway, just means we aren't sending plain-text IPs to Discord. Might be improved by basing the XOR key on other values (base RNG, maybe version) so that it's not like *right* there
2020-08-21 01:16:11 -04:00
Sal 0ca9f8f07d Merge branch 'conenction-screen-improvements' into 'next'
Connection screen improvements

See merge request KartKrew/Kart-Public!187
2020-08-21 00:11:37 -04:00
Ashnal 9e1d7146ad Fixed retry timeout to no ttrigger when starting a local server 2020-08-20 23:38:04 -04:00
Ashnal 247239c2bc Add return false to the connect timeout 2020-08-20 23:09:12 -04:00
James R 5b0cb1afcb Merge remote-tracking branch 'origin/master' into next 2020-08-20 19:55:03 -07:00
FlykeSpice c09cb6d762 Remove POLYOBJECTS POLYOBJECTS_PLANES #ifdefs(backport from srb2 2.2) 2020-08-20 13:02:13 -04:00
FlykeSpice 00137ef4ea Remove ESLOPE #ifdef(backport from srb2 2.2) 2020-08-20 13:02:13 -04:00
Sal 79c299bf31 Merge branch 'port-port-port' into 'master'
2.2's random client port

See merge request KartKrew/Kart-Public!201
2020-08-20 12:19:52 -04:00
Sal 67b37e54b6 Merge branch 'snapback' into 'master'
Instantaneous lookback camera (v2 backport)

See merge request KartKrew/Kart-Public!203
2020-08-20 12:19:41 -04:00
Sal 4c363db516 Merge branch 'gme-fixes-cleanup' into 'master'
GME cleanup and fixes

See merge request KartKrew/Kart-Public!202
2020-08-20 02:07:19 -04:00
lachwright d0d6128053 Instantaneous lookback camera (v2 backport) 2020-08-20 13:41:03 +08:00
Ashnal aa2b25e667 Well actually, lets fix all comparisons of askset to use the same comparison
If we initialize to I_GetTime() - NEWTICRATE*3 it never underflows and everything is good
2020-08-20 00:54:18 -04:00
Steel Titanium e3f07b33bb GME cleanup and fixes
Just some stuff backported from SRB2 2.2, well mostly

get_zlib_error function to reduce code duplication

Return false if it fails to load the VGZ lump

Reduce redundant calls to gme_set_equalizer

Fix sometimes loading a VGZ crashing the game
2020-08-19 22:39:12 -04:00
James R 94512c49e4 -clientport (it's back!) and -serverport, which is an alias to -port
If you ever need to, you can change the client port number.

(cherry picked from commit 843d9b9f0a345330d97c579e94f208eb2b65c156)
2020-08-19 18:16:54 -07:00
James R b77541b51d Use a pointer for port_name
Using strcpy is stupid because we don't know how long the argument would be.
There's no need for a buffer anyway.

(cherry picked from commit 4e321012894b2aa87e312597f19be26b30545a8b)
2020-08-19 18:16:53 -07:00
James R b1f5e66a23 Use a random port when connecting
(cherry picked from commit f584b61c93a97e1a9852f306acba673ced21e03a)
2020-08-19 18:16:53 -07:00
James R 65968f00d3 Fix tiny mistake with the last commit 2020-08-19 17:55:01 -07:00
James R 1cd7c3b747 Rearrange time comparsion on asksent to make it underflow friendly
This fixes '-connect'. NEWTICRATE*5 is subtracted from asksent after
CL_LOADFILES. If this happens too early, an underflow will occur.
2020-08-19 17:49:47 -07:00
Sal a335d6b583 Merge branch 'fix-nocurl' into 'master'
Fix NOCURL compiling

See merge request KartKrew/Kart-Public!197
2020-08-19 20:36:14 -04:00
Sal c6f85cde59 Merge branch 'httpsource-without-curl' into 'master'
Let servers send httpsource without curl

See merge request KartKrew/Kart-Public!196
2020-08-19 20:36:06 -04:00
Sal ed41d5df9e Merge branch 'kart-io' into 'next'
Lua Input/Output library

See merge request KartKrew/Kart-Public!200
2020-08-19 20:35:56 -04:00
Ashnal cadb4719cf Added m_menu_mutex to M_Drawer in connection screen 2020-08-19 19:52:24 -04:00
Ashnal 648a950ac8 Merge remote-tracking branch 'public/next' into conenction-screen-improvements 2020-08-19 19:08:33 -04:00
Ashnal 7c5740d98f COnfirm box now respects rebindable accelerate and brake on keyboards 2020-08-19 18:01:56 -04:00
Sal 8ee7443705 Merge branch 'kimmy-osx-fixes' into 'master'
[OSX] Fix "SIGILL: illegal instruction" on macOS Catalina

See merge request KartKrew/Kart-Public!194
2020-08-18 03:52:47 -04:00
James R 1bf0794d6a Copy the saved wad directory to srb2path 2020-08-17 21:27:59 -07:00
James R c0cac645f8 hate hate hate hate 2020-08-17 21:22:25 -07:00
Sally Coolatta 234983909a Don't show gametype when watching replays 2020-08-17 23:33:55 -04:00
James R 2a2d43a20b Save srb2path to %LOCALAPPDATA%\SRB2Kart\lastwaddir, and chdir here if srb2.srb cannot be found
Windows code goes brrr
2020-08-17 20:11:32 -07:00
Latapostrophe 392b24b769 Merge remote-tracking branch 'stjr/io' into kart-io 2020-08-17 20:22:02 +02:00
Sally Coolatta c76c1b8420 Show game speed and encore 2020-08-17 09:08:05 -04:00
Sally Coolatta 27654ffb6a Don't allow invites if allowjoin is off 2020-08-17 06:55:43 -04:00
Sally Coolatta d163f67700 Update presence when maxplayers is changed 2020-08-17 06:52:46 -04:00
Sally Coolatta 83192827dc Fix ZONE being all caps, standardize the function comments 2020-08-17 06:13:32 -04:00
Latapostrophe d56fdbb933 Kill line riding for offroad 2020-08-17 12:01:16 +02:00
Sally Coolatta da5bda72ee Add distinct images for map hell & normal custom maps 2020-08-17 04:42:22 -04:00
Sally Coolatta a04361a151 Check supported skins by name instead of number, so we can have bonuschars images 2020-08-17 04:42:05 -04:00
Ashnal eb81bea943 Move code down so declarations are above to appease C90 2020-08-17 04:03:02 -04:00
Ashnal 03150e5fe6 Move declaration to appease C90
also remove some extra tab characters
2020-08-17 03:56:13 -04:00
Ashnal afc6bdbc7e Fixes for file accounting
mainwads+1 to not use the first mainwad
2020-08-17 03:51:19 -04:00
Ashnal 9a9d81bbe0 New message boxes for downloads and full server waiting
Downloads must be confirmed before proceeding
Allows downloading mods for full servers
Client will wait for a slot to open on a full server to join
This has a 5 minute timeout
2020-08-17 03:47:23 -04:00
Sally Coolatta 9f4ad1303e Put the cvar in the menu 2020-08-17 02:31:30 -04:00
Sally Coolatta 886db8cde1 Guard discord.h, add cvar to disable rich presence 2020-08-17 02:25:05 -04:00
Sally Coolatta 41a401f703 Merge branch 'master' into next 2020-08-17 02:05:31 -04:00
Sally Coolatta 8d386fba66 Display time elasped/time limit 2020-08-17 02:05:16 -04:00
James R 7a05a8acf7 Do not do master server things when NOCURL 2020-08-16 21:42:58 -07:00
Sally Coolatta d709e9782d Use curl to retrieve your own IP address properly 2020-08-17 00:29:52 -04:00
James R 5dc3ca3934 Remove HAVE_CURL guards on sending httpsource 2020-08-16 20:39:46 -07:00
Sally Coolatta 47f95e22d5 Allow lowercase level name / zone title
Might have some other side-effects, we'll need to see
2020-08-16 22:13:21 -04:00
Sally Coolatta f5bd9d097f Merge remote-tracking branch 'public/master' into discord-rpc-support 2020-08-16 22:12:36 -04:00
Sally Coolatta 07c916f6d2 Little fixes 2020-08-16 21:31:03 -04:00
Sally Coolatta df0cc6a727 No previous prototype for K_DropKitchenSink 2020-08-16 21:18:33 -04:00
Sally Coolatta c8fa1dcfb5 Merge remote-tracking branch 'public/next' into discord-rpc-support 2020-08-16 20:57:31 -04:00
Kimberly Wilber 1bfcec9242 [OSX] Fix "SIGILL: illegal instruction" on macOS Catalina
on OSX, strncpy may copy to overlapping (protected) memory. this
sometimes happens when loading WAD files.

This patch eliminates these problems for me
2020-08-15 12:16:05 -04:00
Ashnal f800159bb8 Improve total downloads bar
Now has total file size AND number of files
2020-08-15 01:03:45 -04:00
James R a772096757 dumbass doesn't test changes before pushing directly to next
(cherry picked from commit be14b8a564a89a5afb84ac19f1586f3db7f68367)
2020-08-14 08:27:25 -07:00
Sal 06f36224ee Merge branch 'http-mserv' into 'master'
Make the HTTP Master Server official

See merge request KartKrew/Kart-Public!193
2020-08-10 16:49:47 -04:00
James R 1a1c215a91 Add http-mserv to fuck 2020-08-09 23:32:43 -07:00
Sal 9590a769ba Merge branch 'maxnetnodes-2-electric-boogaloo' into 'master'
Bump MAXNETNODES to 127

See merge request KartKrew/Kart-Public!192
2020-08-09 22:28:50 -04:00
James R 9d9f8fd8a3 Bump MAXNETNODES to 127 2020-08-09 18:26:34 -07:00
Ashnal cc78ef2c78 Now that the server doesn't erroneously send the last mainwad
As the first part of fileneeded, we must load file 0
2020-08-09 00:48:53 -04:00
Ashnal 4c5eb0d6bc Redo logic for lots of files vs not
Now new CL state for checking files so it can spread over tics
whether we ask for the extended list or not
2020-08-09 00:47:55 -04:00
Sal 97c4e7dfff Merge branch 'indirectitemcooldown' into 'next'
Fix Shrink, SPB and Hyudoro cooldowns never resetting?

See merge request KartKrew/Kart-Public!191
2020-08-06 12:19:27 -04:00
Sally Coolatta c63022350d Merge branch 'master' into next 2020-08-06 12:15:55 -04:00
AJ Martinez 3dada09aa5 Fix Hyudoro cooldown never resetting 2020-08-06 10:51:53 -05:00
AJ Martinez 2add55eb04 Fix indirect item cooldown never resetting 2020-08-06 10:34:16 -05:00
Sal b320256a47 Merge branch 'master' into 'master'
Clarify addon-related messages

See merge request KartKrew/Kart-Public!190
2020-08-05 06:48:44 -04:00
AJ Martinez 8284caf1bc Clarify addon-related messages 2020-08-05 00:40:56 -05:00
Sal 8791fd8835 Merge branch 'mine-punt-sync-fix' into 'next'
Fix desyncs caused by K_PuntMine

See merge request KartKrew/Kart-Public!189
2020-07-25 03:55:28 -04:00
Sal 341ce8f4a3 Merge branch 'rocket-sneaker-hnext-fix' into 'next'
Rocket sneaker and sink hnext fix

See merge request KartKrew/Kart-Public!188
2020-07-25 03:55:22 -04:00
Ashnal 6d0b1e93c6 Appease C91 2020-07-23 21:05:00 -04:00
Ashnal 733aefa64a Also lets do this for kitchen sinks
They also ignored in K_DropHnextList
2020-07-23 20:12:35 -04:00
Ashnal 6562c9b755 Moved K_DropRocketSneaker call into K_StripItems
This should catch when DropHnextList misses it
Should probably fix sinks too ...
2020-07-15 09:17:35 -04:00
Ashnal 3bccf01d4f Properly handle rocket sneakers when shrinking 2020-07-14 19:50:37 -04:00
Ashnal 943a898352 Some safeguards for K_DropRocketSneaker usage 2020-07-14 19:45:15 -04:00
Ashnal 0637ed89aa Fixing RocketSneakers
New function specifically for dropping rocketsneakers K_DropRocketSneaker
Used by Eggbox touchspecial to properly dispose of shoes and clean up hnext
Now also used by the shoe thinker to drop themselves
Fixes angle of spent shoe launch
2020-07-14 18:45:45 -04:00
Ashnal ddc0bc16ab Add clean up to K_PuntMine
This cleans up hnext when a mine shield is P_RemoveMobj'ed while being punted
Otherwise, hnext could point to a removed mobj and cause undefined behavior
This also fixes the bug where if you have multiple mines in your slot, drag one
and have it punted, all your unused mines would disappear.
This should/may fix the crashes/desyncs I've observed in gameplay when a held mine is punted.
2020-07-14 00:21:46 -04:00
Ashnal 159316b155 Remove now unused ret var 2020-07-04 22:25:02 -04:00
Ashnal 2c0671d8fd Let's just ALWAYS go into ask file list mode
Easier to maintain and understand a single code path
Rather than switching behavior based on amount of addons
2020-07-04 01:12:38 -04:00
Ashnal 7da3d70f6c Remove Checking Files spam 2020-07-02 21:48:45 -04:00
Ashnal b8fdd6b89c Fix file number accounting
Should ensure appropriate accounting and prevent loading of
server files if it would put us over MAX_WADFILES
2020-07-02 20:57:33 -04:00
Ashnal 774b917c0e Correct total files to load off by one 2020-07-02 17:47:10 -04:00
Ashnal 6fe8a6c96a Changed "this server has a lot of addons!" to
"Checking server addon list ..." to be more informative
2020-07-01 23:52:43 -04:00
Ashnal 03d479fdb6 Connection screen no longer freezes up while
searching for addons on disk
Game will run one tic after every file status is updated
2020-07-01 23:48:14 -04:00
Ashnal 8eb9a6946f Fix X/0 files display bug for legacy downloader
Also made "Waiting to Download" consistent with other states
2020-07-01 21:40:21 -04:00
Sal c3c466575c Merge branch 'fix-pk3-leak' into 'master'
Fix memory leak in W_ReadLumpHeaderPwad

See merge request KartKrew/Kart-Public!182
2020-07-01 18:36:48 -04:00
Sal 9f4b4d84a6 Merge branch 'http-useragent-fix' into 'master'
Fix user agent for HTTP downloads being set as SRB2Kart/v1.1.2

See merge request KartKrew/Kart-Public!185
2020-07-01 18:36:33 -04:00
Sal d2098c23fc Merge branch 'ogl-color-fix3' into 'master'
Ogl colormap fix third attempt

See merge request KartKrew/Kart-Public!184
2020-07-01 18:36:19 -04:00
Sal b6272fa299 Merge branch 'chatbug-fix' into 'master'
clientside ack fix

See merge request KartKrew/Kart-Public!186
2020-07-01 18:35:57 -04:00
Ashnal ad94b29558 Experiemntal clientside ack fix
Stops the client from using reliable packets before joining a server
Clients can time out during addon loading
sending reliable packets before then can cause out of order acks
This causes joinbug, chatbug, and chatspam, as well as
general server instability due to unnecesary packetspam
2020-06-27 23:43:15 -04:00
Ashnal f2593219a6 Adjust text position 2020-06-27 23:40:13 -04:00
Ashnal d96c938dbf Add progress bar for file loading 2020-06-27 23:26:38 -04:00
Ashnal 9d9105929b Adjustment to new progress text 2020-06-27 21:17:21 -04:00
Ashnal fc9f40a177 New "Overall Download Progress" bar
Shows progress of all file downloads pre-join
2020-06-27 21:17:04 -04:00
Ashnal 12d40a07cc Load one file per tic
Prevents game from locking up when loading large file lists
2020-06-27 20:58:33 -04:00
Steel Titanium 3af4aaff9c Fix user agent for HTTP downloads being set as SRB2Kart/v1.1.2 2020-06-23 18:39:02 -04:00
James R bae37aea2c ADD to the buffer size 2020-06-14 19:13:22 -07:00
Hannu Hanhi 44159de7f3 Colormap alpha handling was still wrong, hopefully it's correct now 2020-06-14 15:03:40 +03:00
Sal eea8c3776c Merge branch 'ogl-color-fix-fix' into 'master'
Fix bug in the OpenGL colormap bugfix

See merge request KartKrew/Kart-Public!183
2020-06-13 22:45:47 -04:00
Hannu Hanhi c382794109 Fix uninitialized alpha when reading colormaps 2020-06-13 23:34:13 +03:00
Hannu Hanhi 38c3d78d8a Cleaner version of the W_ReadLumpHeaderPwad memory leak fix 2020-06-13 21:37:33 +03:00
Hannu Hanhi 2f65955496 Add missing inflateEnd to fix memory leak in W_ReadLumpHeaderPwad 2020-06-13 17:07:05 +03:00
Sryder b96d315f25 Merge branch 'master' of git@git.magicalgirl.moe:KartKrew/Kart-Public.git into next 2020-06-13 14:15:58 +01:00
James R e7d949aeb2 masterserver_token is back 2020-06-12 23:47:08 -07:00
James R 9b3456a860 Merge remote-tracking branch 'origin/master' into http-mserv 2020-06-12 23:36:39 -07:00
Sal f7e74e8884 Merge branch 'ogl-encore-color-fix' into 'master'
Fix bug in OpenGL encore colormaps

See merge request KartKrew/Kart-Public!180
2020-06-12 22:39:18 -04:00
Hannu Hanhi d9e2336277 Guil's encore color bugfix with some additional cleanup 2020-06-01 21:14:17 +03:00
Sal 691a567f5d Merge branch 'fix-ogl-log-crash' into 'master'
Fix opengl crashing on startup due to lack of checks

See merge request KartKrew/Kart-Public!179
2020-05-28 09:47:16 -04:00
Steel Titanium 3f3cb2c976 Fix opengl crashing on startup due to lack of checks
Also fixes the log file not being written to the home directory.
2020-05-23 16:21:26 -04:00
Sryder b03f950c5a Merge branch 'master' into next 2020-05-20 16:50:56 +01:00
Sryder e229aabf22 Merge branch 'fix-clang-compile' into 'master'
Fix clang compiling

See merge request KartKrew/Kart-Public!176
2020-05-20 11:49:47 -04:00
Sryder 6b8ea22bdb Merge branch 'opengl-maybe-uninitialised' into 'master'
Some uninitialised variables that GCC 4.4 complains about

See merge request KartKrew/Kart-Public!177
2020-05-20 11:49:34 -04:00
Sryder 831ed3dedc Merge branch 'itemodds-fallthrough-fix' into 'next'
Mistaken fallthrough in item roulette.

See merge request KartKrew/Kart-Public!178
2020-05-20 11:49:22 -04:00
Sal 73b65b4725 Merge branch 'no-spb-forcing-in-2p' into 'next'
Don't force SPB in 1v1

See merge request KartKrew/Kart-Public!175
2020-05-20 10:11:19 -04:00
Sal 5f70d3e170 Merge branch 'visplane-fix' into 'master'
Fix visplane getting allocated twice

See merge request KartKrew/Kart-Public!172
2020-05-20 10:11:06 -04:00
Sryder 9e6980c8ae Fix a fallthrough issue that could cause thundershield to be rolled less often than intended. 2020-05-20 11:53:14 +01:00
Sryder 66930a0277 Initialise these to 0 just to stop GCC 4.4 from complaining.
This should be okay since 0 generally means "nothing" for these, and they should always be set before being used later on.
2020-05-20 11:47:22 +01:00
Sryder 290abe4fce D_ModifierKeyResponder is unused now so remove it. 2020-05-20 11:37:38 +01:00
Sally Coolatta a7c88d40db Merge branch 'master' into next 2020-05-19 20:40:12 -04:00
TehRealSalt 21e6190932 Don't force SPB in 1v1
(cherry picked from commit 22af2040a021cff243773a0f23371f20e69dfca5)
2020-05-19 20:12:53 -04:00
Sryder c70cf4806b Merge branch 'extra-travis-deploy' into 'master'
Fix Travis Deployment

See merge request KartKrew/Kart-Public!174
2020-05-19 20:10:42 -04:00
Sal e42ae1ed79 Merge branch 'freeplay-be-nice' into 'master'
Also apply HUD translucency to FREE PLAY

See merge request KartKrew/Kart-Public!161
2020-05-19 17:29:05 -04:00
Sal 1d5774fe2f Merge branch 'ghostly-luavars' into 'next'
Fix Luavars being saved into Record Attack ghosts/replays and potentially crashing

See merge request KartKrew/Kart-Public!168
2020-05-19 17:28:48 -04:00
Sal 71d2d357c1 Merge branch 'displayplayer-gonna-getcha' into 'next'
displayplayers.iterate crashes in replays, is that based?

See merge request KartKrew/Kart-Public!171
2020-05-19 17:28:14 -04:00
Sal bb7481a13e Merge branch 'mr-ogl-boostpad-fix' into 'master'
Fix wrong orientation in some boost pads in ogl

See merge request KartKrew/Kart-Public!173
2020-05-19 17:27:24 -04:00
Sryder bca1dd42a3 Use xenial to build all the versions newer than trusty
I'm not 100% sure why we can't use newer series to build the newer installers. But this seems to be what vanilla does
2020-05-19 20:45:49 +01:00
Sal cb9e6473a0 Merge branch 'use-extern-you-idiot' into 'master'
Fix GCC 10 linking errors

See merge request KartKrew/Kart-Public!170
2020-05-16 09:01:46 -04:00
Hannu Hanhi c3e1e1df26 Fix wrong orientation some boost pads in ogl 2020-05-16 13:47:21 +03:00
filpAM 5acafa5a87 Fix visplane getting allocated twice 2020-05-16 00:20:52 +00:00
Sal f60d05764d Merge branch 'clearbans-please' into 'master'
Write empty file on clearbans

See merge request KartKrew/Kart-Public!156
2020-05-15 19:29:11 -04:00
Sal f0f4b7bc1e Merge branch 'nomixer-fix' into 'master'
Fix "NOMIXER" flag compiling

See merge request KartKrew/Kart-Public!159
2020-05-15 19:28:54 -04:00
Sal 43874c3a4d Merge branch 'now-we-spin-in-spinout-only' into 'master'
No more first person hyper spin

See merge request KartKrew/Kart-Public!160
2020-05-15 19:28:38 -04:00
Sal e4766bbaf1 Merge branch 'ferror-errno-yareyare' into 'master'
Fix false file error reporting

See merge request KartKrew/Kart-Public!162
2020-05-15 19:27:08 -04:00
Sal 11331b7bc5 Merge branch 'hud-is-fucked' into 'next'
HUD inconsistency in Record Attack

See merge request KartKrew/Kart-Public!164
2020-05-15 19:26:26 -04:00
Sal ffdb12ccb0 Merge branch 'fastline-identification' into 'next'
Add targets to MT_FASTLINEs that are spawned

See merge request KartKrew/Kart-Public!169
2020-05-15 19:24:35 -04:00
Sal c9c8e5f15f Merge branch 'player-dot-ping' into 'next'
player.ping for the ping in milliseconds of the player

See merge request KartKrew/Kart-Public!167
2020-05-15 19:24:21 -04:00
Sal f2a9981299 Merge branch 'alias-recursion-fix' into 'master'
Fix alias recursion never counting down

See merge request KartKrew/Kart-Public!166
2020-05-15 19:24:02 -04:00
Sryder e0aa6ef252 Use bionic to build focal version because it has GCC 4.8? 2020-05-16 00:02:33 +01:00
James R 7e0b605f34 Properly bound lua displayplayers and displayplayers.iterate to splitscreen
This is fixes crashes in replays because splitscreen displayplayers are
initialized to INT32_MAX there.
2020-05-15 14:21:25 -07:00
James R fcbe4e668f Set timeout on HMS connections 2020-05-15 13:20:40 -07:00
James R bd3ea52cba ok
(cherry picked from commit 0b9c20cc7086000548e02b39c1abf94ffb56feae)
2020-05-15 11:21:40 -07:00
James R 6bd6b3f38e Add missing extern to colortranslations 2020-05-15 10:00:05 -07:00
Monster Iestyn 697c7f859e added missing extern keyword for ms_RoomId in mserv.h (the definition is already in the .c file in this case)
(cherry picked from commit 064f4bcf349e9600552a0b99bd0fbfb3cbcf0958)
2020-05-15 09:58:49 -07:00
Monster Iestyn f89400c728 turn all non-extern variables in s_sound.h into externs (and put their real definitions in the .c file)
(cherry picked from commit dab212dc56936dd92a935d0c81003ff1d35ee2ee)
2020-05-15 09:58:28 -07:00
Monster Iestyn 05c8865528 make savegamename in doomdef.h an extern, put the actual definition in d_main.c
(cherry picked from commit 89cd756cd83e4a03a34d1f16da18142d8167d889)
2020-05-15 09:52:16 -07:00
James R e8a2397dea Rename hms123311.c to http-mserv.c
HMS lives on in our hearts!
2020-05-14 17:26:10 -07:00
James R a6ce21b450 Use Unlock_state here too 2020-05-14 17:23:06 -07:00
James R 85fef2655c Resize response body buffer as needed 2020-05-14 17:19:25 -07:00
Sryder dbcbbf1ae4 Remove now unsupported distros from deployer
Add new supported distros to deployer
2020-05-14 13:16:49 +01:00
Snu 6b5eebe54a Use P_SetTarget instead of fast->target 2020-05-14 04:17:24 +01:00
Snu 3997c05988 god damnit 2020-05-14 03:23:28 +01:00
Snu f24340f46a add targets to MT_FASTLINEs spawned to tell what they're spawned from 2020-05-14 03:13:00 +01:00
Latapostrophe d949a47a70 Don't save Luavars in record attack, especially not for ghosts 2020-05-14 01:41:06 +02:00
James R 615823f024 player.ping for the ping in milliseconds of the player 2020-05-13 16:17:40 -07:00
Latapostrophe d0b4f8765d Merge branch 'master' of git.magicalgirl.moe:KartKrew/Kart-Public 2020-05-14 01:04:30 +02:00
Monster Iestyn db5cb986ee Detect infinite alias self-recursion mixed with other commands, such as in the case of `alias a "echo test; a"; a`.
(Unfortunately, this does not work if "wait" is used instead of "echo", but oh well)

(cherry picked from commit 797ca99f42)
2020-05-13 16:03:26 -07:00
James R 430fb27ec8 Bind HMS connection with -bindaddr 2020-05-13 15:29:17 -07:00
James R 9dc72f46a2 Identify this branch with VERSIONSTRING
This is temporary.
2020-05-12 19:27:54 -07:00
James R 2f63f97692 Reset the masterserver address if the old one was set by the config 2020-05-12 19:22:30 -07:00
James R 72852ab341 Clarify where debug prints go when using masterserver_debug 2020-05-12 19:22:15 -07:00
James R be3da445c3 Use IPv4 for master server connections
Your server's address is gathered from the request, so it needs to be IPv4!
2020-05-12 18:52:55 -07:00
James R bdcae79cd2 Use new two digit version number for HMS 2020-05-12 17:51:27 -07:00
James R 233e6627de Merge remote-tracking branch 'origin/master' into http-mserv 2020-05-12 17:50:32 -07:00
James R e2733600cd Oops a debug condition snuck in there 2020-04-28 14:35:03 -07:00
James R a1aa2a5e12 Fix switching the master server 2020-04-28 14:21:57 -07:00
James R e950efa5fc Put some mutex on CONS_Printf etc. hahaha 2020-04-28 13:08:43 -07:00
James R e20dccafd4 Fucking multithreading in the server registration
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2020-04-28 12:33:50 -07:00
James R 8f3820db66 Wait for threads before SDL_Quit (lol) 2020-04-27 18:03:10 -07:00
James R bdddeb9ecf Create cond if it doesn't exist when signaling 2020-04-27 18:01:27 -07:00
James R 88bcac0168 Use malloc for hms 2020-04-26 21:56:59 -07:00
Steel Titanium ba989dce10 Support for http downloads
(cherry picked from commit 6fcc06bf72)

(cherry picked just the libcurl stuff)
2020-04-26 20:01:15 -07:00
James R c96506dd3b Make mod update, room list and server list multithreaded
This took fucking ages and it still fails sometimes in edge cases, but I
don't give a FUCK right now.
2020-04-26 19:46:35 -07:00
James R c472a9f50d Multithreading in my SRB2??? 2020-04-17 20:05:29 -07:00
James R 7b714a225b WHY THE FUCK DID I DO THIS 2020-04-15 22:04:55 -07:00
James R 60bc61ef70 Oops 2020-04-14 19:41:32 -07:00
James R 30b5ec14fd Handle NULL hms buffer 2020-04-14 16:55:14 -07:00
James R 7488991ecd Compiler errors: won't stop, can't stop 2020-04-13 23:31:26 -07:00
James R a0de059235 masterserver_update_rate cvar determines wait between updates in minutes
The new default is 15 minutes as well. And if you think that's too long, I have
confirmed that the Master Server delists inactive servers after a whopping 40
minutes, at least.
2020-04-13 23:10:06 -07:00
James R ee6de3800e Don't try to update right after registering 2020-04-13 22:54:58 -07:00
James R 2c5566b013 Add a hack so the 'All' room isn't display for hosting 2020-04-13 22:31:11 -07:00
James R 1201e89132 Kill the old mserv, long live HMS! 2020-04-13 22:23:01 -07:00
James R 7255d360e1 Clean up header text 2020-04-13 21:20:29 -07:00
James R 032adadd86 HTTP update alert 2020-04-12 20:37:46 -07:00
James R 48b2112af7 Fix some goofs 2020-04-12 18:33:53 -07:00
James R 03caf27d92 Bruh 2020-04-12 18:27:01 -07:00
James R 269746fe01 Clean up a bunch of stuff and follow the Master Server API more closely 2020-04-12 18:25:59 -07:00
James R 3f4224ed37 Windows certs do work, thanks Steel! 2020-04-12 17:51:30 -07:00
James R 969fe0b28e Handle more errors 2020-04-12 17:51:05 -07:00
James R ef71bef6f3 Kill masterserver_token 2020-04-12 17:15:39 -07:00
James R f0cc851b29 This will be the Master Server in 2020 2020-03-20 20:37:26 -07:00
James R 3f9f07af84 Use https because my web server redirects 2020-03-01 12:31:49 -08:00
James R 56fac10b14 strtok can return NULL 2020-03-01 12:15:48 -08:00
James R 9d42a5ad5e This time I fucked up 2020-03-01 11:59:54 -08:00
James R aca2e97c84 Windows gaysed: the sequel 2020-03-01 11:54:21 -08:00
James R ceb332e580 Windows is weird 2020-03-01 11:46:02 -08:00
James R 32a34cc1b2 masterserver_debug to set CURLOPT_VERBOSE 2020-03-01 11:39:27 -08:00
James R 1959a9b107 Don't show "All" room when hosting 2020-03-01 11:19:59 -08:00
James R 8756ef15a2 I don't even know my own website 2020-03-01 11:17:56 -08:00
James R 47a5f9ef94 lol 2020-03-01 10:59:25 -08:00
James R e2507f390f The big bad HTTP master server
Cvars:

http_masterserver is the url to the master server's API.
masterserver_token may be an authentication token.
2020-03-01 02:36:56 -08:00
Latapostrophe 0c3b5d603b Merge branch 'master' of git.magicalgirl.moe:KartKrew/Kart-Public 2019-11-11 22:15:30 +01:00
James R 44e59e2688 Don't hide HUD with hu_showscores in single player/Record Attack
This also makes Lua game HUD consistent with the Kart HUD.
2019-10-19 14:11:24 -07:00
James R 1d6020883c Forgot includes 2019-10-07 18:10:33 -07:00
James R abaefa05b1 ferror does not return errno, are you stupid?
Use M_FileError to return the proper error description, or "end-of-file".
2019-10-07 17:55:31 -07:00
James R 5e9082fb77 Also apply HUD translucency to FREE PLAY 2019-09-19 20:29:51 -07:00
James R 3801f93181 Let first person camera work in demos 2019-09-15 00:32:01 -07:00
filpAM fe4cbd7ba1 Fix "NOMIXER" flag compiling 2019-09-13 13:20:44 -04:00
James R 3838700f2c Save bans when cleared too
(Why doesn't it work for I_Quit?)
2019-08-22 15:18:14 -07:00
Latapostrophe 496f6bcd79 Merge branch 'master' of git.magicalgirl.moe:KartKrew/Kart-Public 2019-07-02 18:24:14 +02:00
Latapostrophe 3b3a63cd90 Merge branch 'master' of git.magicalgirl.moe:KartKrew/Kart-Public 2019-04-21 15:57:03 +02:00
Latapostrophe c772b05f8c Merge branch 'master' of git.magicalgirl.moe:KartKrew/Kart 2019-04-20 10:44:17 +02:00
TehRealSalt f9c8a1286d House keeping
- Remove the potentially GPL-infringing discord_pass.h file.
- Let DISCORD_APPID be a public #define.
- Use server_context as party ID.
- Add more states ("Watching Demo", "Menu").
- Only show map images on supported maps. Falls back to an image of a dice.
- Displays "???" as the map name for Hell maps.
- Voting displays an image of the BG planet, depending on the gamemode.
- Added a fallback title screen large image.
- Added a fallback character image.
- General code cleanup & safety checks.
- Give CV_NETVAR to cv_maxplayers (I should come up with a better way of sending this information without overwriting user settings, but this'll do for now)
2018-10-30 05:44:29 -04:00
TehRealSalt ff8c70f9fe Missed these from an old experiment 2018-10-22 14:57:02 -04:00
TehRealSalt 4e549532ee Half-done Discord Rich Presence support
It's soooo close to being awesome, but so far away. Making game invitations as the host meant that it would redirect to "connect self" for other people, because we can't get the IP address from the host.

If anyone has a solution, you've got my gratitude; this was going so smoothly until it hit that brick wall.
2018-10-22 00:34:45 -04:00
Alam Ed Arias 3f4e0286eb Merge branch 'master' into io 2016-03-07 16:23:08 -05:00
Alam Ed Arias bdad2ccc12 Merge branch 'next' into io 2016-02-26 01:57:28 -05:00
wolfy852 db7da456d2 Remove block on % in filename strings
According to Alam, supporting this shouldn't cause any issues.
2016-01-29 01:38:41 -06:00
Monster Iestyn 2eedecb93a Get rid of unneeded tab spaces
Least I can do to make up for breaking io.open in the first place :E
2016-01-26 12:07:28 +00:00
Nipples the Enchilada 9c299e5ad4 Fix and clean up io_open after MI broke it horribly
strcpy(NULL, filename); congrats
2016-01-25 22:13:24 -06:00
Monster Iestyn 14dcd2404b Fixed compiler warnings to the best of my ability
Hopefully this all still works properly, try not to kill me if it doesn't =V
2016-01-25 22:12:54 -06:00
Monster Iestyn 63a3e03bb0 Fixed math for calculating current texture in texture animations 2016-01-25 22:12:53 -06:00
Monster Iestyn f65c5c016a Fix shadowing in mapheaderinfo_get 2016-01-25 22:12:52 -06:00
Alam Ed Arias c7e540a870 whitespace cleanup 2016-01-25 22:12:51 -06:00
Inuyasha c30188f9fd interscreen is a lump name and thus needs lstring
... not just lstring though, but the behavior with i that is used elsewhere.
2016-01-25 22:12:50 -06:00
Inuyasha f559b50995 fix bad lstring usage in map header lua
This is not how you use pushlstring! This is actually sending uninitialized memory to Lua, which is making scripts have inconsistent results (duh?)

c/o JTE: "Tell Red they're a doofus."
2016-01-25 22:12:50 -06:00
Monster Iestyn f2f8906a19 Use modulo, not bitwise AND. My fault once again, whoops.
The point here is ColorOpposite(MAXSKINCOLORS) would have given an actual result of its own since MAXSKINCOLORS & MAXSKINCOLORS is still MAXSKINCOLORS. This shouldn't happen though, as both Color_Opposite[MAXSKINCOLORS*2] and Color_Opposite[MAXSKINCOLOR*2+1] aren't defined.
2016-01-25 22:12:49 -06:00
Inuyasha 0f2a092741 objectplace stability fix
Objectplace reallocates the mapthings list to add one more mapthing. By itself there's no problem with this.
But, mobj->spawnpoint is a pointer to the mapthing's location in the mapthings list.
So by reallocating the mapthings list, all references to mobj->spawnpoints point to freed memory.

... Oops.

Now when objectplace reallocates the mapthings list it actually corrects the locations of all mobj's spawnpoints to point to the new list.

Hooray, you can use NiGHTS objectplace again if you really want to.
2016-01-25 22:12:48 -06:00
Nipples the Enchilada 2639bf4c0b Add liolib.c to CMakeLists 2016-01-23 23:29:27 -06:00
wolfy852 591b803566 Limit file write size to 1MB
If the total file size is above 1MB after writing, discard all changes.
2016-01-22 21:45:48 -06:00
wolfy852 e274946528 Call I_mkdir on subdirectories [NEEDS CLEANUP]
I got lazy and used a weird inefficient method, but I don't know how to clean this mess up :c At least it works.
2016-01-22 00:46:32 -06:00
wolfy852 5579fb5240 Limit file creation/manipulation to luafiles subfolder
Also block % in filename strings
2016-01-20 22:35:53 -06:00
wolfy852 de03db99e7 Block possible methods of accessing folders outside of SRB2 2016-01-20 21:31:00 -06:00
wolfy852 569f7d15d1 Efficiency improvement in whitelist check
Thanks Inu!
2016-01-20 16:59:55 -06:00
wolfy852 a68e92690f Implement file type whitelist, completely remove popen and pclose
This is probably super inefficient. Someone please teach me how2C.
2016-01-20 02:26:15 -06:00
wolfy852 c9fe83b95d Block the use of ../ and ..\\
...and remove io.popen(), cause that shit is DANGEROUS.
2016-01-17 01:37:19 -06:00
wolfy852 eb7c36d72c Reimplement I/O library
Note: I/O library is fully functioning in this state, but lacks security restrictions. We'll get to those later ;)
2016-01-16 19:31:36 -06:00
114 changed files with 5368 additions and 2679 deletions

View File

@ -439,6 +439,30 @@ matrix:
# List Ubuntu LTS, newest to oldest
# Then list non-LTS, newest to oldest
################################
- os: linux
addons:
apt:
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
dist: xenial
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
AND env(DPL_TERMINATE_MAIN) != "1"
env:
- _DPL_JOB_ENABLED=1
- _DPL_JOB_NAME=focal
- _DPL_DPUT_TARGET=1
- _DPL_PACKAGE_SOURCE=1
- PACKAGE_DISTRO=focal
- PACKAGE_SUBVERSION=~20.04focal
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
- os: linux
addons:
apt:
@ -463,6 +487,30 @@ matrix:
- PACKAGE_DISTRO=bionic
- PACKAGE_SUBVERSION=~18.04bionic
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
- os: linux
addons:
apt:
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
dist: xenial
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
AND env(DPL_TERMINATE_MAIN) != "1"
env:
- _DPL_JOB_ENABLED=1
- _DPL_JOB_NAME=xenial
- _DPL_DPUT_TARGET=1
- _DPL_PACKAGE_SOURCE=1
- PACKAGE_DISTRO=xenial
- PACKAGE_SUBVERSION=~16.04xenial
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
- os: linux
addons:
apt:
@ -505,59 +553,11 @@ matrix:
AND env(DPL_TERMINATE_MAIN) != "1"
env:
- _DPL_JOB_ENABLED=1
- _DPL_JOB_NAME=disco
- _DPL_JOB_NAME=eoan
- _DPL_DPUT_TARGET=1
- _DPL_PACKAGE_SOURCE=1
- PACKAGE_DISTRO=disco
- PACKAGE_SUBVERSION=~19.04disco
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
- os: linux
addons:
apt:
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
dist: xenial
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
AND env(DPL_TERMINATE_MAIN) != "1"
env:
- _DPL_JOB_ENABLED=1
- _DPL_JOB_NAME=cosmic
- _DPL_DPUT_TARGET=1
- _DPL_PACKAGE_SOURCE=1
- PACKAGE_DISTRO=cosmic
- PACKAGE_SUBVERSION=~18.10cosmic
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
- os: linux
addons:
apt:
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
dist: xenial
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
AND env(DPL_TERMINATE_MAIN) != "1"
env:
- _DPL_JOB_ENABLED=1
- _DPL_JOB_NAME=xenial
- _DPL_DPUT_TARGET=1
- _DPL_PACKAGE_SOURCE=1
- PACKAGE_DISTRO=xenial
- PACKAGE_SUBVERSION=~16.04xenial
- PACKAGE_DISTRO=eoan
- PACKAGE_SUBVERSION=~19.10eoan
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
allow_failures:
- compiler: clang-3.5

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
# Version change is fine.
project(SRB2
VERSION 1.2
VERSION 1.3
LANGUAGES C)
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})

View File

@ -1,4 +1,4 @@
version: 1.2.{branch}-{build}
version: 1.3.{branch}-{build}
os: MinGW
environment:
@ -29,7 +29,7 @@ environment:
##############################
DPL_ENABLED: 0
DPL_TAG_ENABLED: 0
DPL_INSTALLER_NAME: srb2kart-v12
DPL_INSTALLER_NAME: srb2kart-v13
# Asset handling is barebones vs. Travis Deployer. We operate on 7z only.
# Include the README files and the OpenGL batch in the main and patch archives.
# The x86/x64 archives contain the DLL binaries.

View File

@ -0,0 +1,23 @@
include(LibFindMacros)
libfind_pkg_check_modules(DISCORDRPC_PKGCONF DISCORDRPC)
find_path(DISCORDRPC_INCLUDE_DIR
NAMES discord_rpc.h
PATHS
${DISCORDRPC_PKGCONF_INCLUDE_DIRS}
"/usr/include"
"/usr/local/include"
)
find_library(DISCORDRPC_LIBRARY
NAMES discord-rpc
PATHS
${DISCORDRPC_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR)
set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY)
libfind_process(DISCORDRPC)

View File

@ -2,10 +2,7 @@ tar-ignore = "assets/*.srb"
tar-ignore = "assets/*.pk3"
tar-ignore = "assets/*.dta"
tar-ignore = "assets/*.wad"
<<<<<<< HEAD:debian-template/source/options
tar-ignore = "assets/*.kart"
=======
>>>>>>> e251f9c230beda984cdcdea7e903d765f1c68f6f:debian-template/source/options
tar-ignore = "assets/debian/${PACKAGE_NAME}-data/*"
tar-ignore = "assets/debian/tmp/*"
tar-ignore = "*.obj"

View File

@ -1,6 +1,6 @@
# SRB2Kart - Which DLLs do I need to bundle?
Updated 12/4/2018 (v2.1.21)
Updated 8/23/2020 (v1.3)
Here are the required DLLs, per build. For each architecture, copy all the binaries from these folders:
@ -14,6 +14,7 @@ and don't forget to build r_opengl.dll for srb2dd.
* libs\dll-binaries\i686\exchndl.dll
* libs\dll-binaries\i686\libgme.dll
* libs\dll-binaries\i686\discord-rpc.dll
* libs\dll-binaries\i686\mgwhelp.dll (depend for exchndl.dll)
* libs\SDL2\i686-w64-mingw32\bin\SDL2.dll
* libs\SDL2_mixer\i686-w64-mingw32\bin\*.dll (get everything)
@ -22,22 +23,7 @@ and don't forget to build r_opengl.dll for srb2dd.
* libs\dll-binaries\x86_64\exchndl.dll
* libs\dll-binaries\x86_64\libgme.dll
* libs\dll-binaries\x86_64\discord-rpc.dll
* libs\dll-binaries\x86_64\mgwhelp.dll (depend for exchndl.dll)
* libs\SDL2\x86_64-w64-mingw32\bin\SDL2.dll
* libs\SDL2_mixer\x86_64-w64-mingw32\bin\*.dll (get everything)
## srb2kartdd, 32-bit
* libs\dll-binaries\i686\exchndl.dll
* libs\dll-binaries\i686\fmodex.dll
* libs\dll-binaries\i686\libgme.dll
* libs\dll-binaries\i686\mgwhelp.dll (depend for exchndl.dll)
* r_opengl.dll (build this from make)
## srb2kartdd, 64-bit
* libs\dll-binaries\x86_64\exchndl.dll
* libs\dll-binaries\x86_64\fmodex.dll
* libs\dll-binaries\x86_64\libgme.dll
* libs\dll-binaries\x86_64\mgwhelp.dll (depend for exchndl.dll)
* r_opengl.dll (build this from make)

16
libs/discord-rpc.props Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<LibraryPath Condition="'$(Platform)' == 'Win32'">$(SolutionDir)libs\discord-rpc\win32-dynamic\lib;$(LibraryPath)</LibraryPath>
<IncludePath Condition="'$(Platform)' == 'Win32'">$(SolutionDir)libs\discord-rpc\win32-dynamic\lib;$(IncludePath)</IncludePath>
<LibraryPath Condition="'$(Platform)' == 'x64'">$(SolutionDir)libs\discord-rpc\win64-dynamic\lib;$(LibraryPath)</LibraryPath>
<IncludePath Condition="'$(Platform)' == 'x64'">$(SolutionDir)libs\discord-rpc\win64-dynamic\lib;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Platform)' == 'Win32' OR '$(Platform)' == 'x64'">
<Link>
<AdditionalDependencies>discord-rpc.dll.a;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@ -0,0 +1,26 @@
#pragma once
#if defined(DISCORD_DYNAMIC_LIB)
#if defined(_WIN32)
#if defined(DISCORD_BUILDING_SDK)
#define DISCORD_EXPORT __declspec(dllexport)
#else
#define DISCORD_EXPORT __declspec(dllimport)
#endif
#else
#define DISCORD_EXPORT __attribute__((visibility("default")))
#endif
#else
#define DISCORD_EXPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command);
DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,87 @@
#pragma once
#include <stdint.h>
// clang-format off
#if defined(DISCORD_DYNAMIC_LIB)
# if defined(_WIN32)
# if defined(DISCORD_BUILDING_SDK)
# define DISCORD_EXPORT __declspec(dllexport)
# else
# define DISCORD_EXPORT __declspec(dllimport)
# endif
# else
# define DISCORD_EXPORT __attribute__((visibility("default")))
# endif
#else
# define DISCORD_EXPORT
#endif
// clang-format on
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DiscordRichPresence {
const char* state; /* max 128 bytes */
const char* details; /* max 128 bytes */
int64_t startTimestamp;
int64_t endTimestamp;
const char* largeImageKey; /* max 32 bytes */
const char* largeImageText; /* max 128 bytes */
const char* smallImageKey; /* max 32 bytes */
const char* smallImageText; /* max 128 bytes */
const char* partyId; /* max 128 bytes */
int partySize;
int partyMax;
const char* matchSecret; /* max 128 bytes */
const char* joinSecret; /* max 128 bytes */
const char* spectateSecret; /* max 128 bytes */
int8_t instance;
} DiscordRichPresence;
typedef struct DiscordUser {
const char* userId;
const char* username;
const char* discriminator;
const char* avatar;
} DiscordUser;
typedef struct DiscordEventHandlers {
void (*ready)(const DiscordUser* request);
void (*disconnected)(int errorCode, const char* message);
void (*errored)(int errorCode, const char* message);
void (*joinGame)(const char* joinSecret);
void (*spectateGame)(const char* spectateSecret);
void (*joinRequest)(const DiscordUser* request);
} DiscordEventHandlers;
#define DISCORD_REPLY_NO 0
#define DISCORD_REPLY_YES 1
#define DISCORD_REPLY_IGNORE 2
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
DiscordEventHandlers* handlers,
int autoRegister,
const char* optionalSteamId);
DISCORD_EXPORT void Discord_Shutdown(void);
/* checks for incoming messages, dispatches callbacks */
DISCORD_EXPORT void Discord_RunCallbacks(void);
/* If you disable the lib starting its own io thread, you'll need to call this from your own */
#ifdef DISCORD_DISABLE_IO_THREAD
DISCORD_EXPORT void Discord_UpdateConnection(void);
#endif
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
DISCORD_EXPORT void Discord_ClearPresence(void);
DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
#ifdef __cplusplus
} /* extern "C" */
#endif

Binary file not shown.

View File

@ -0,0 +1,26 @@
#pragma once
#if defined(DISCORD_DYNAMIC_LIB)
#if defined(_WIN32)
#if defined(DISCORD_BUILDING_SDK)
#define DISCORD_EXPORT __declspec(dllexport)
#else
#define DISCORD_EXPORT __declspec(dllimport)
#endif
#else
#define DISCORD_EXPORT __attribute__((visibility("default")))
#endif
#else
#define DISCORD_EXPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command);
DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,87 @@
#pragma once
#include <stdint.h>
// clang-format off
#if defined(DISCORD_DYNAMIC_LIB)
# if defined(_WIN32)
# if defined(DISCORD_BUILDING_SDK)
# define DISCORD_EXPORT __declspec(dllexport)
# else
# define DISCORD_EXPORT __declspec(dllimport)
# endif
# else
# define DISCORD_EXPORT __attribute__((visibility("default")))
# endif
#else
# define DISCORD_EXPORT
#endif
// clang-format on
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DiscordRichPresence {
const char* state; /* max 128 bytes */
const char* details; /* max 128 bytes */
int64_t startTimestamp;
int64_t endTimestamp;
const char* largeImageKey; /* max 32 bytes */
const char* largeImageText; /* max 128 bytes */
const char* smallImageKey; /* max 32 bytes */
const char* smallImageText; /* max 128 bytes */
const char* partyId; /* max 128 bytes */
int partySize;
int partyMax;
const char* matchSecret; /* max 128 bytes */
const char* joinSecret; /* max 128 bytes */
const char* spectateSecret; /* max 128 bytes */
int8_t instance;
} DiscordRichPresence;
typedef struct DiscordUser {
const char* userId;
const char* username;
const char* discriminator;
const char* avatar;
} DiscordUser;
typedef struct DiscordEventHandlers {
void (*ready)(const DiscordUser* request);
void (*disconnected)(int errorCode, const char* message);
void (*errored)(int errorCode, const char* message);
void (*joinGame)(const char* joinSecret);
void (*spectateGame)(const char* spectateSecret);
void (*joinRequest)(const DiscordUser* request);
} DiscordEventHandlers;
#define DISCORD_REPLY_NO 0
#define DISCORD_REPLY_YES 1
#define DISCORD_REPLY_IGNORE 2
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
DiscordEventHandlers* handlers,
int autoRegister,
const char* optionalSteamId);
DISCORD_EXPORT void Discord_Shutdown(void);
/* checks for incoming messages, dispatches callbacks */
DISCORD_EXPORT void Discord_RunCallbacks(void);
/* If you disable the lib starting its own io thread, you'll need to call this from your own */
#ifdef DISCORD_DISABLE_IO_THREAD
DISCORD_EXPORT void Discord_UpdateConnection(void);
#endif
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
DISCORD_EXPORT void Discord_ClearPresence(void);
DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
#ifdef __cplusplus
} /* extern "C" */
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -35,6 +35,7 @@ set(SRB2_CORE_SOURCES
m_random.c
md5.c
mserv.c
http-mserv.c
s_sound.c
screen.c
sounds.c
@ -220,6 +221,8 @@ set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
"Enable zlib support.")
set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
"Enable GME support.")
set(SRB2_CONFIG_HAVE_DISCORDRPC OFF CACHE BOOL
"Enable Discord rich presence support.")
set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
"Enable curl support, used for downloading files via HTTP.")
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
@ -234,7 +237,7 @@ set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
### use internal libraries?
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL
"Use SRB2's internal copies of required dependencies (SDL2, PNG, zlib, GME).")
"Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME).")
endif()
if(${SRB2_CONFIG_HAVE_BLUA})
@ -277,6 +280,7 @@ if(${SRB2_CONFIG_HAVE_BLUA})
blua/lfunc.c
blua/lgc.c
blua/linit.c
blua/liolib.c
blua/llex.c
blua/lmem.c
blua/lobject.c
@ -328,7 +332,7 @@ if(${SRB2_CONFIG_HAVE_GME})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(GME_FOUND ON)
set(GME_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/gme/include)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win64 -lgme")
else() # 32-bit
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win32 -lgme")
@ -344,6 +348,32 @@ if(${SRB2_CONFIG_HAVE_GME})
endif()
endif()
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(DISCORDRPC_FOUND ON)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/include)
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/lib -ldiscord-rpc")
else() # 32-bit
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/include)
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/lib -ldiscord-rpc")
endif()
else()
find_package(DiscordRPC)
endif()
if(${DISCORDRPC_FOUND})
set(SRB2_HAVE_DISCORDRPC ON)
add_definitions(-DHAVE_DISCORDRPC)
set(SRB2_DISCORDRPC_SOURCES discord.c)
set(SRB2_DISCORDRPC_HEADERS discord.h)
prepend_sources(SRB2_DISCORDRPC_SOURCES)
prepend_sources(SRB2_DISCORDRPC_HEADERS)
source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS})
else()
message(WARNING "You have specified that Discord Rich Presence is available but it was not found.")
endif()
endif()
if(${SRB2_CONFIG_HAVE_ZLIB})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(ZLIB_FOUND ON)
@ -396,7 +426,7 @@ endif()
if(${SRB2_CONFIG_HAVE_CURL})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(CURL_FOUND ON)
set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl)
set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl/include)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl")
else() # 32-bit

View File

@ -63,7 +63,6 @@
# Compile with extra warnings, add 'WARNINGMODE=1'
# Compile without NASM's tmap.nas, add 'NOASM=1'
# Compile without 3D hardware support, add 'NOHW=1'
# Compile without 3D sound support, add 'NOHS=1'
# Compile with GDBstubs, add 'RDB=1'
# Compile without PNG, add 'NOPNG=1'
# Compile without zlib, add 'NOZLIB=1'
@ -136,7 +135,6 @@ NOPNG=1
NOZLIB=1
NONET=1
NOHW=1
NOHS=1
NOASM=1
NOIPX=1
EXENAME?=srb2dummy
@ -167,7 +165,6 @@ endif
ifdef PANDORA
NONX86=1
NOHW=1
NOHS=1
endif
ifdef WII
@ -217,7 +214,6 @@ NOPNG=1
NOZLIB=1
NONET=1
#NOHW=1
NOHS=1
NOASM=1
NOIPX=1
NONX86=1
@ -287,13 +283,6 @@ endif
$(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o
endif
ifdef NOHS
OPTS+=-DNOHS
else
OPTS+=-DHW3SOUND
OBJS+=$(OBJDIR)/hw3sound.o
endif
OPTS += -DCOMPVERSION
ifndef NONX86
@ -396,6 +385,12 @@ CFLAGS+=-DHAVE_MINIUPNPC
endif
endif
ifdef HAVE_DISCORDRPC
LIBS+=-ldiscord-rpc
CFLAGS+=-DHAVE_DISCORDRPC
OBJS+=$(OBJDIR)/discord.o
endif
ifndef NO_LUA
include blua/Makefile.cfg
endif
@ -548,6 +543,7 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/w_wad.o \
$(OBJDIR)/filesrch.o \
$(OBJDIR)/mserv.o \
$(OBJDIR)/http-mserv.o\
$(OBJDIR)/i_tcp.o \
$(OBJDIR)/lzf.o \
$(OBJDIR)/vid_copy.o \
@ -941,19 +937,6 @@ $(OBJDIR)/r_minigl.o: hardware/r_minigl/r_minigl.c hardware/r_opengl/r_opengl.h
$(CC) $(CFLAGS) $(WFLAGS) -D_WINDOWS -mwindows -c $< -o $@
endif
ifndef NOHS
$(OBJDIR)/s_ds3d.o: hardware/s_ds3d/s_ds3d.c hardware/hw3dsdrv.h \
hardware/hw_dll.h
$(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_ds3d.o $(WFLAGS) -D_WINDOWS -mwindows -c hardware/s_ds3d/s_ds3d.c
$(OBJDIR)/s_fmod.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \
hardware/hw_dll.h
$(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_fmod.o $(WFLAGS) -D_WINDOWS -mwindows -c hardware/s_fmod/s_fmod.c
$(OBJDIR)/s_openal.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \
hardware/hw_dll.h
$(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_openal.o $(WFLAGS) -D_WINDOWS -mwindows -c hardware/s_openal/s_openal.c
endif
endif
endif

View File

@ -862,10 +862,8 @@ static inline void AM_drawWalls(void)
{
size_t i;
static mline_t l;
#ifdef ESLOPE
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
fixed_t backf1 = 0, backf2 = 0, backc1 = 0, backc2 = 0; // back floor ceiling ends
#endif
for (i = 0; i < numlines; i++)
{
@ -873,7 +871,6 @@ static inline void AM_drawWalls(void)
l.a.y = lines[i].v1->y >> FRACTOMAPBITS;
l.b.x = lines[i].v2->x >> FRACTOMAPBITS;
l.b.y = lines[i].v2->y >> FRACTOMAPBITS;
#ifdef ESLOPE
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
if (slope) { \
end1 = P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y); \
@ -888,7 +885,6 @@ static inline void AM_drawWalls(void)
SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight)
}
#undef SLOPEPARAMS
#endif
if (!lines[i].backsector) // 1-sided
{
@ -897,19 +893,11 @@ static inline void AM_drawWalls(void)
else
AM_drawMline(&l, WALLCOLORS);
}
#ifdef ESLOPE
else if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier
|| (frontf1 == frontc1 && frontf2 == frontc2)) // Front is thok barrier
{
if (backf1 == backc1 && backf2 == backc2
&& frontf1 == frontc1 && frontf2 == frontc2) // BOTH are thok barriers
#else
else if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight // Back is thok barrier
|| lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // Front is thok barrier
{
if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight
&& lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // BOTH are thok barriers
#endif
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBTSWALLCOLORS);
@ -927,20 +915,10 @@ static inline void AM_drawWalls(void)
else
{
if (lines[i].flags & ML_NOCLIMB) {
#ifdef ESLOPE
if (backf1 != frontf1 || backf2 != frontf2) {
#else
if (lines[i].backsector->floorheight
!= lines[i].frontsector->floorheight) {
#endif
AM_drawMline(&l, NOCLIMBFDWALLCOLORS); // floor level change
}
#ifdef ESLOPE
else if (backc1 != frontc1 || backc2 != frontc2) {
#else
else if (lines[i].backsector->ceilingheight
!= lines[i].frontsector->ceilingheight) {
#endif
AM_drawMline(&l, NOCLIMBCDWALLCOLORS); // ceiling level change
}
else
@ -948,20 +926,10 @@ static inline void AM_drawWalls(void)
}
else
{
#ifdef ESLOPE
if (backf1 != frontf1 || backf2 != frontf2) {
#else
if (lines[i].backsector->floorheight
!= lines[i].frontsector->floorheight) {
#endif
AM_drawMline(&l, FDWALLCOLORS); // floor level change
}
#ifdef ESLOPE
else if (backc1 != frontc1 || backc2 != frontc2) {
#else
else if (lines[i].backsector->ceilingheight
!= lines[i].frontsector->ceilingheight) {
#endif
AM_drawMline(&l, CDWALLCOLORS); // ceiling level change
}
else

View File

@ -18,6 +18,7 @@ OBJS:=$(OBJS) \
$(OBJDIR)/ldo.o \
$(OBJDIR)/lfunc.o \
$(OBJDIR)/linit.o \
$(OBJDIR)/liolib.o \
$(OBJDIR)/llex.o \
$(OBJDIR)/lmem.o \
$(OBJDIR)/lobject.o \

View File

@ -17,6 +17,7 @@
static const luaL_Reg lualibs[] = {
{"", luaopen_base},
{LUA_TABLIBNAME, luaopen_table},
{LUA_IOLIBNAME, luaopen_io},
{LUA_STRLIBNAME, luaopen_string},
{NULL, NULL}
};

589
src/blua/liolib.c Normal file
View File

@ -0,0 +1,589 @@
/*
** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define liolib_c
#define LUA_LIB
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include "../i_system.h"
#include "../doomdef.h"
#include "../m_misc.h"
#define IO_INPUT 1
#define IO_OUTPUT 2
#define FILELIMIT 1024*1024 // Size limit for reading/writing files
static const char *const fnames[] = {"input", "output"};
static const char *whitelist[] = { // Allow scripters to write files of these types to SRB2's folder
".txt",
".sav2",
".cfg",
".png",
".bmp"
};
static int pushresult (lua_State *L, int i, const char *filename) {
int en = errno; /* calls to Lua API may change this value */
if (i) {
lua_pushboolean(L, 1);
return 1;
}
else {
lua_pushnil(L);
if (filename)
lua_pushfstring(L, "%s: %s", filename, strerror(en));
else
lua_pushfstring(L, "%s", strerror(en));
lua_pushinteger(L, en);
return 3;
}
}
static void fileerror (lua_State *L, int arg, const char *filename) {
lua_pushfstring(L, "%s: %s", filename, strerror(errno));
luaL_argerror(L, arg, lua_tostring(L, -1));
}
#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
static int io_type (lua_State *L) {
void *ud;
luaL_checkany(L, 1);
ud = lua_touserdata(L, 1);
lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE);
if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1))
lua_pushnil(L); /* not a file */
else if (*((FILE **)ud) == NULL)
lua_pushliteral(L, "closed file");
else
lua_pushliteral(L, "file");
return 1;
}
static FILE *tofile (lua_State *L) {
FILE **f = tofilep(L);
if (*f == NULL)
luaL_error(L, "attempt to use a closed file");
return *f;
}
/*
** When creating file handles, always creates a `closed' file handle
** before opening the actual file; so, if there is a memory error, the
** file is not left opened.
*/
static FILE **newfile (lua_State *L) {
FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *));
*pf = NULL; /* file handle is currently `closed' */
luaL_getmetatable(L, LUA_FILEHANDLE);
lua_setmetatable(L, -2);
return pf;
}
/*
** function to (not) close the standard files stdin, stdout, and stderr
*/
static int io_noclose (lua_State *L) {
lua_pushnil(L);
lua_pushliteral(L, "cannot close standard file");
return 2;
}
/*
** function to close regular files
*/
static int io_fclose (lua_State *L) {
FILE **p = tofilep(L);
int ok = (fclose(*p) == 0);
*p = NULL;
return pushresult(L, ok, NULL);
}
static int aux_close (lua_State *L) {
lua_getfenv(L, 1);
lua_getfield(L, -1, "__close");
return (lua_tocfunction(L, -1))(L);
}
static int io_close (lua_State *L) {
if (lua_isnone(L, 1))
lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT);
tofile(L); /* make sure argument is a file */
return aux_close(L);
}
static int io_gc (lua_State *L) {
FILE *f = *tofilep(L);
/* ignore closed files */
if (f != NULL)
aux_close(L);
return 0;
}
static int io_tostring (lua_State *L) {
FILE *f = *tofilep(L);
if (f == NULL)
lua_pushliteral(L, "file (closed)");
else
lua_pushfstring(L, "file (%p)", f);
return 1;
}
static int StartsWith(const char *a, const char *b) // this is wolfs being lazy yet again
{
if(strncmp(a, b, strlen(b)) == 0) return 1;
return 0;
}
static int io_open (lua_State *L) {
FILE **pf;
const char *filename = luaL_checkstring(L, 1);
int pass = 0;
size_t i;
int length = strlen(filename);
char *splitter, *forward, *backward;
char *destFilename;
const char *mode = luaL_optstring(L, 2, "r");
for (i = 0; i < (sizeof (whitelist) / sizeof(const char *)); i++)
{
if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i]))
{
pass = 1;
break;
}
}
if (strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\")
|| StartsWith(filename, "/") || !pass)
{
luaL_error(L,"access denied to %s", filename);
return pushresult(L,0,filename);
}
destFilename = va("luafiles"PATHSEP"%s", filename);
// Make directories as needed
splitter = destFilename;
forward = strchr(splitter, '/');
backward = strchr(splitter, '\\');
while ((splitter = (forward && backward) ? min(forward, backward) : (forward ?: backward)))
{
*splitter = 0;
I_mkdir(destFilename, 0755);
*splitter = '/';
splitter++;
forward = strchr(splitter, '/');
backward = strchr(splitter, '\\');
}
pf = newfile(L);
*pf = fopen(destFilename, mode);
return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
}
static int io_tmpfile (lua_State *L) {
FILE **pf = newfile(L);
*pf = tmpfile();
return (*pf == NULL) ? pushresult(L, 0, NULL) : 1;
}
static FILE *getiofile (lua_State *L, int findex) {
FILE *f;
lua_rawgeti(L, LUA_ENVIRONINDEX, findex);
f = *(FILE **)lua_touserdata(L, -1);
if (f == NULL)
luaL_error(L, "standard %s file is closed", fnames[findex - 1]);
return f;
}
static int g_iofile (lua_State *L, int f, const char *mode) {
if (!lua_isnoneornil(L, 1)) {
const char *filename = lua_tostring(L, 1);
if (filename) {
FILE **pf = newfile(L);
*pf = fopen(filename, mode);
if (*pf == NULL)
fileerror(L, 1, filename);
}
else {
tofile(L); /* check that it's a valid file handle */
lua_pushvalue(L, 1);
}
lua_rawseti(L, LUA_ENVIRONINDEX, f);
}
/* return current value */
lua_rawgeti(L, LUA_ENVIRONINDEX, f);
return 1;
}
static int io_input (lua_State *L) {
return g_iofile(L, IO_INPUT, "r");
}
static int io_output (lua_State *L) {
return g_iofile(L, IO_OUTPUT, "w");
}
static int io_readline (lua_State *L);
static void aux_lines (lua_State *L, int idx, int toclose) {
lua_pushvalue(L, idx);
lua_pushboolean(L, toclose); /* close/not close file when finished */
lua_pushcclosure(L, io_readline, 2);
}
static int f_lines (lua_State *L) {
tofile(L); /* check that it's a valid file handle */
aux_lines(L, 1, 0);
return 1;
}
static int io_lines (lua_State *L) {
if (lua_isnoneornil(L, 1)) { /* no arguments? */
/* will iterate over default input */
lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT);
return f_lines(L);
}
else {
const char *filename = luaL_checkstring(L, 1);
FILE **pf = newfile(L);
*pf = fopen(filename, "r");
if (*pf == NULL)
fileerror(L, 1, filename);
aux_lines(L, lua_gettop(L), 1);
return 1;
}
}
/*
** {======================================================
** READ
** =======================================================
*/
static int read_number (lua_State *L, FILE *f) {
lua_Number d;
if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
lua_pushnumber(L, d);
return 1;
}
else return 0; /* read fails */
}
static int test_eof (lua_State *L, FILE *f) {
int c = getc(f);
ungetc(c, f);
lua_pushlstring(L, NULL, 0);
return (c != EOF);
}
static int read_line (lua_State *L, FILE *f) {
luaL_Buffer b;
luaL_buffinit(L, &b);
for (;;) {
size_t l;
char *p = luaL_prepbuffer(&b);
if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */
luaL_pushresult(&b); /* close buffer */
return (lua_objlen(L, -1) > 0); /* check whether read something */
}
l = strlen(p);
if (l == 0 || p[l-1] != '\n')
luaL_addsize(&b, l);
else {
luaL_addsize(&b, l - 1); /* do not include `eol' */
luaL_pushresult(&b); /* close buffer */
return 1; /* read at least an `eol' */
}
}
}
static int read_chars (lua_State *L, FILE *f, size_t n) {
size_t rlen; /* how much to read */
size_t nr; /* number of chars actually read */
luaL_Buffer b;
luaL_buffinit(L, &b);
rlen = LUAL_BUFFERSIZE; /* try to read that much each time */
do {
char *p = luaL_prepbuffer(&b);
if (rlen > n) rlen = n; /* cannot read more than asked */
nr = fread(p, sizeof(char), rlen, f);
luaL_addsize(&b, nr);
n -= nr; /* still have to read `n' chars */
} while (n > 0 && nr == rlen); /* until end of count or eof */
luaL_pushresult(&b); /* close buffer */
return (n == 0 || lua_objlen(L, -1) > 0);
}
static int g_read (lua_State *L, FILE *f, int first) {
int nargs = lua_gettop(L) - 1;
int success;
int n;
clearerr(f);
if (nargs == 0) { /* no arguments? */
success = read_line(L, f);
n = first+1; /* to return 1 result */
}
else { /* ensure stack space for all results and for auxlib's buffer */
luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
success = 1;
for (n = first; nargs-- && success; n++) {
if (lua_type(L, n) == LUA_TNUMBER) {
size_t l = (size_t)lua_tointeger(L, n);
success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
}
else {
const char *p = lua_tostring(L, n);
luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
switch (p[1]) {
case 'n': /* number */
success = read_number(L, f);
break;
case 'l': /* line */
success = read_line(L, f);
break;
case 'a': /* file */
read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */
success = 1; /* always success */
break;
default:
return luaL_argerror(L, n, "invalid format");
}
}
}
}
if (ferror(f))
return pushresult(L, 0, NULL);
if (!success) {
lua_pop(L, 1); /* remove last result */
lua_pushnil(L); /* push nil instead */
}
return n - first;
}
static int io_read (lua_State *L) {
return g_read(L, getiofile(L, IO_INPUT), 1);
}
static int f_read (lua_State *L) {
return g_read(L, tofile(L), 2);
}
static int io_readline (lua_State *L) {
FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
int sucess;
if (f == NULL) /* file is already closed? */
luaL_error(L, "file is already closed");
sucess = read_line(L, f);
if (ferror(f))
return luaL_error(L, "%s", strerror(errno));
if (sucess) return 1;
else { /* EOF */
if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */
lua_settop(L, 0);
lua_pushvalue(L, lua_upvalueindex(1));
aux_close(L); /* close it */
}
return 0;
}
}
/* }====================================================== */
static int g_write (lua_State *L, FILE *f, int arg) {
int nargs = lua_gettop(L) - 1;
int status = 1;
size_t count;
for (; nargs--; arg++) {
if (lua_type(L, arg) == LUA_TNUMBER) {
/* optimization: could be done exactly as for strings */
status = status &&
fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
}
else {
size_t l;
const char *s = luaL_checklstring(L, arg, &l);
count += l;
if (ftell(f) + l > FILELIMIT)
{
luaL_error(L,"write limit bypassed in file. Changes have been discarded.");
break;
}
status = status && (fwrite(s, sizeof(char), l, f) == l);
}
}
return pushresult(L, status, NULL);
}
static int io_write (lua_State *L) {
return g_write(L, getiofile(L, IO_OUTPUT), 1);
}
static int f_write (lua_State *L) {
return g_write(L, tofile(L), 2);
}
static int f_seek (lua_State *L) {
static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
static const char *const modenames[] = {"set", "cur", "end", NULL};
FILE *f = tofile(L);
int op = luaL_checkoption(L, 2, "cur", modenames);
long offset = luaL_optlong(L, 3, 0);
op = fseek(f, offset, mode[op]);
if (op)
return pushresult(L, 0, NULL); /* error */
else {
lua_pushinteger(L, ftell(f));
return 1;
}
}
static int f_setvbuf (lua_State *L) {
static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
static const char *const modenames[] = {"no", "full", "line", NULL};
FILE *f = tofile(L);
int op = luaL_checkoption(L, 2, NULL, modenames);
lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
int res = setvbuf(f, NULL, mode[op], sz);
return pushresult(L, res == 0, NULL);
}
static int io_flush (lua_State *L) {
return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL);
}
static int f_flush (lua_State *L) {
return pushresult(L, fflush(tofile(L)) == 0, NULL);
}
static const luaL_Reg iolib[] = {
{"close", io_close},
{"flush", io_flush},
{"input", io_input},
{"lines", io_lines},
{"open", io_open},
{"output", io_output},
{"read", io_read},
{"tmpfile", io_tmpfile},
{"type", io_type},
{"write", io_write},
{NULL, NULL}
};
static const luaL_Reg flib[] = {
{"close", io_close},
{"flush", f_flush},
{"lines", f_lines},
{"read", f_read},
{"seek", f_seek},
{"setvbuf", f_setvbuf},
{"write", f_write},
{"__gc", io_gc},
{"__tostring", io_tostring},
{NULL, NULL}
};
static void createmeta (lua_State *L) {
luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */
lua_pushvalue(L, -1); /* push metatable */
lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
luaL_register(L, NULL, flib); /* file methods */
}
static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) {
*newfile(L) = f;
if (k > 0) {
lua_pushvalue(L, -1);
lua_rawseti(L, LUA_ENVIRONINDEX, k);
}
lua_pushvalue(L, -2); /* copy environment */
lua_setfenv(L, -2); /* set it */
lua_setfield(L, -3, fname);
}
static void newfenv (lua_State *L, lua_CFunction cls) {
lua_createtable(L, 0, 1);
lua_pushcfunction(L, cls);
lua_setfield(L, -2, "__close");
}
LUALIB_API int luaopen_io (lua_State *L) {
createmeta(L);
/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
newfenv(L, io_fclose);
lua_replace(L, LUA_ENVIRONINDEX);
/* open library */
luaL_register(L, LUA_IOLIBNAME, iolib);
/* create (and set) default files */
newfenv(L, io_noclose); /* close function for default files */
createstdfile(L, stdin, IO_INPUT, "stdin");
createstdfile(L, stdout, IO_OUTPUT, "stdout");
createstdfile(L, stderr, 0, "stderr");
lua_pop(L, 1); /* pop environment for default files */
return 1;
}

View File

@ -21,6 +21,9 @@ LUALIB_API int (luaopen_base) (lua_State *L);
#define LUA_TABLIBNAME "table"
LUALIB_API int (luaopen_table) (lua_State *L);
#define LUA_IOLIBNAME "io"
LUALIB_API int (luaopen_io) (lua_State *L);
#define LUA_STRLIBNAME "string"
LUALIB_API int (luaopen_string) (lua_State *L);

View File

@ -543,10 +543,7 @@ static void COM_ExecuteString(char *ptext)
if (!stricmp(com_argv[0], a->name))
{
if (recursion > MAX_ALIAS_RECURSION)
{
CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n"));
recursion = 0;
}
else
{
char buf[1024];
@ -578,8 +575,10 @@ static void COM_ExecuteString(char *ptext)
}
WRITESTRING(write, read);
// Monster Iestyn: keep track of how many levels of recursion we're in
recursion++;
COM_BufInsertText(buf);
recursion--;
}
return;
}

View File

@ -37,7 +37,7 @@
* Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb
* Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta
* Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets
* Last updated 2020 / 05 / 09 - Kart v1.2 - patch.kart
* Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart
*/
// Base SRB2 hashes
@ -52,7 +52,7 @@
#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964"
#define ASSET_HASH_MAPS_KART "1335cd064656aedca359cfbb5233ac4a"
#ifdef USE_PATCH_KART
#define ASSET_HASH_PATCH_KART "2a556446ab428492110e7544841e1f42"
#define ASSET_HASH_PATCH_KART "f7b68076f8abc54e1a78963d97f69ab2"
#endif
#endif

View File

@ -31,6 +31,7 @@
#include "i_video.h"
#include "z_zone.h"
#include "i_system.h"
#include "i_threads.h"
#include "d_main.h"
#include "m_menu.h"
#include "filesrch.h"
@ -45,6 +46,16 @@
#define MAXHUDLINES 20
#ifdef HAVE_THREADS
I_mutex con_mutex;
# define Lock_state() I_lock_mutex(&con_mutex)
# define Unlock_state() I_unlock_mutex(con_mutex)
#else/*HAVE_THREADS*/
# define Lock_state()
# define Unlock_state()
#endif/*HAVE_THREADS*/
static boolean con_started = false; // console has been initialised
boolean con_startup = false; // true at game startup, screen need refreshing
static boolean con_forcepic = true; // at startup toggle console translucency when first off
@ -170,6 +181,8 @@ static void CONS_hudlines_Change(void)
{
INT32 i;
Lock_state();
// Clear the currently displayed lines
for (i = 0; i < con_hudlines; i++)
con_hudtime[i] = 0;
@ -181,6 +194,8 @@ static void CONS_hudlines_Change(void)
con_hudlines = cons_hudlines.value;
Unlock_state();
CONS_Printf(M_GetText("Number of console HUD lines is now %d\n"), con_hudlines);
}
@ -188,12 +203,16 @@ static void CONS_hudlines_Change(void)
//
static void CONS_Clear_f(void)
{
Lock_state();
memset(con_buffer, 0, CON_BUFFERSIZE);
con_cx = 0;
con_cy = con_totallines-1;
con_line = &con_buffer[con_cy*con_width];
con_scrollup = 0;
Unlock_state();
}
// Choose english keymap
@ -369,20 +388,29 @@ void CON_Init(void)
for (i = 0; i < NUMINPUTS; i++)
bindtable[i] = NULL;
Lock_state();
// clear all lines
memset(con_buffer, 0, CON_BUFFERSIZE);
// make sure it is ready for the loading screen
con_width = 0;
Unlock_state();
CON_RecalcSize();
CON_SetupColormaps();
Lock_state();
//note: CON_Ticker should always execute at least once before D_Display()
con_clipviewtop = -1; // -1 does not clip
con_hudlines = atoi(cons_hudlines.defaultvalue);
Unlock_state();
// setup console input filtering
CON_InputInit();
@ -391,15 +419,23 @@ void CON_Init(void)
COM_AddCommand("cls", CONS_Clear_f);
//COM_AddCommand("english", CONS_English_f);
// set console full screen for game startup MAKE SURE VID_Init() done !!!
Lock_state();
con_destlines = vid.height;
con_curlines = vid.height;
Unlock_state();
if (!dedicated)
{
Lock_state();
con_started = true;
con_startup = true; // need explicit screen refresh until we are in Doom loop
consoletoggle = false;
Unlock_state();
CV_RegisterVar(&cons_msgtimeout);
CV_RegisterVar(&cons_hudlines);
CV_RegisterVar(&cons_speed);
@ -411,19 +447,27 @@ void CON_Init(void)
}
else
{
Lock_state();
con_started = true;
con_startup = false; // need explicit screen refresh until we are in Doom loop
consoletoggle = true;
Unlock_state();
}
}
// Console input initialization
//
static void CON_InputInit(void)
{
Lock_state();
// prepare the first prompt line
memset(inputlines, 0, sizeof (inputlines));
inputline = 0;
input_cur = input_sel = input_len = 0;
Unlock_state();
}
//======================================================================
@ -439,6 +483,8 @@ static void CON_RecalcSize(void)
char *tmp_buffer;
char *string;
Lock_state();
switch (cv_constextsize.value)
{
case V_NOSCALEPATCH:
@ -476,11 +522,18 @@ static void CON_RecalcSize(void)
// check for change of video width
if (conw == con_width)
{
Unlock_state();
return; // didn't change
}
Unlock_state();
tmp_buffer = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL);
string = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL); // BP: it is a line but who know
Lock_state();
oldcon_width = con_width;
oldnumlines = con_totallines;
oldcon_cy = con_cy;
@ -501,6 +554,8 @@ static void CON_RecalcSize(void)
con_line = &con_buffer[con_cy*con_width];
con_scrollup = 0;
Unlock_state();
// re-arrange console text buffer to keep text
if (oldcon_width) // not the first time
{
@ -525,7 +580,11 @@ static void CON_RecalcSize(void)
static void CON_ChangeHeight(void)
{
INT32 minheight = 20 * con_scalefactor; // 20 = 8+8+4
INT32 minheight;
Lock_state();
minheight = 20 * con_scalefactor; // 20 = 8+8+4
// toggle console in
con_destlines = (cons_height.value*vid.height)/100;
@ -535,13 +594,19 @@ static void CON_ChangeHeight(void)
con_destlines = vid.height;
con_destlines &= ~0x3; // multiple of text row height
Unlock_state();
}
// Handles Console moves in/out of screen (per frame)
//
static void CON_MoveConsole(void)
{
const fixed_t conspeed = FixedDiv(cons_speed.value*vid.fdupy, FRACUNIT);
fixed_t conspeed;
Lock_state();
conspeed = FixedDiv(cons_speed.value*vid.fdupy, FRACUNIT);
// instant
if (!cons_speed.value)
@ -563,6 +628,8 @@ static void CON_MoveConsole(void)
if (con_curlines < con_destlines)
con_curlines = con_destlines;
}
Unlock_state();
}
INT32 CON_ShiftChar(INT32 ch)
@ -587,27 +654,44 @@ void CON_ClearHUD(void)
{
INT32 i;
Lock_state();
for (i = 0; i < con_hudlines; i++)
con_hudtime[i] = 0;
Unlock_state();
}
// Force console to move out immediately
// note: con_ticker will set consoleready false
void CON_ToggleOff(void)
{
Lock_state();
if (!con_destlines)
{
Unlock_state();
return;
}
con_destlines = 0;
con_curlines = 0;
CON_ClearHUD();
con_forcepic = 0;
con_clipviewtop = -1; // remove console clipping of view
Unlock_state();
}
boolean CON_Ready(void)
{
return consoleready;
boolean ready;
Lock_state();
{
ready = consoleready;
}
Unlock_state();
return ready;
}
// Console ticker: handles console move in/out, cursor blinking
@ -615,7 +699,11 @@ boolean CON_Ready(void)
void CON_Ticker(void)
{
INT32 i;
INT32 minheight = 20 * con_scalefactor; // 20 = 8+8+4
INT32 minheight;
Lock_state();
minheight = 20 * con_scalefactor; // 20 = 8+8+4
// cursor blinking
con_tick++;
@ -673,6 +761,8 @@ void CON_Ticker(void)
if (con_hudtime[i] < 0)
con_hudtime[i] = 0;
}
Unlock_state();
}
//
@ -684,32 +774,51 @@ void CON_Ticker(void)
static void CON_InputClear(void)
{
Lock_state();
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
input_cur = input_sel = input_len = 0;
Unlock_state();
}
static void CON_InputSetString(const char *c)
{
Lock_state();
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
strcpy(inputlines[inputline], c);
input_cur = input_sel = input_len = strlen(c);
Unlock_state();
}
static void CON_InputAddString(const char *c)
{
size_t csize = strlen(c);
Lock_state();
if (input_len + csize > CON_MAXPROMPTCHARS-1)
{
Unlock_state();
return;
}
if (input_cur != input_len)
memmove(&inputlines[inputline][input_cur+csize], &inputlines[inputline][input_cur], input_len-input_cur);
memcpy(&inputlines[inputline][input_cur], c, csize);
input_len += csize;
input_sel = (input_cur += csize);
Unlock_state();
}
static void CON_InputDelSelection(void)
{
size_t start, end, len;
Lock_state();
if (input_cur > input_sel)
{
start = input_sel;
@ -728,27 +837,39 @@ static void CON_InputDelSelection(void)
input_len -= len;
input_sel = input_cur = start;
Unlock_state();
}
static void CON_InputAddChar(char c)
{
if (input_len >= CON_MAXPROMPTCHARS-1)
return;
Lock_state();
if (input_cur != input_len)
memmove(&inputlines[inputline][input_cur+1], &inputlines[inputline][input_cur], input_len-input_cur);
inputlines[inputline][input_cur++] = c;
inputlines[inputline][++input_len] = 0;
input_sel = input_cur;
Unlock_state();
}
static void CON_InputDelChar(void)
{
if (!input_cur)
return;
Lock_state();
if (input_cur != input_len)
memmove(&inputlines[inputline][input_cur-1], &inputlines[inputline][input_cur], input_len-input_cur);
inputlines[inputline][--input_len] = 0;
input_sel = --input_cur;
Unlock_state();
}
//
@ -1174,6 +1295,8 @@ static void CON_Print(char *msg)
S_StartSound(NULL, sfx_radio);
}
Lock_state();
if (!(*msg & 0x80))
{
con_line[con_cx++] = '\x80';
@ -1234,7 +1357,10 @@ static void CON_Print(char *msg)
}
if (*msg == '\0')
{
Unlock_state();
return;
}
// printable character
for (l = 0; l < (con_width-11) && msg[l] > ' '; l++)
@ -1252,6 +1378,8 @@ static void CON_Print(char *msg)
for (; l > 0; l--)
con_line[con_cx++] = *(msg++);
}
Unlock_state();
}
void CON_LogMessage(const char *msg)
@ -1283,6 +1411,7 @@ void CONS_Printf(const char *fmt, ...)
{
va_list argptr;
static char *txt = NULL;
boolean startup;
if (txt == NULL)
txt = malloc(8192);
@ -1315,11 +1444,16 @@ void CONS_Printf(const char *fmt, ...)
CON_LogMessage(txt);
#endif
Lock_state();
// make sure new text is visible
con_scrollup = 0;
startup = con_startup;
Unlock_state();
// if not in display loop, force screen update
if (con_startup)
if (startup)
{
#if (defined (_WINDOWS)) || (defined (__OS2__) && !defined (HAVE_SDL))
patch_t *con_backpic = W_CachePatchName("KARTKREW", PU_CACHE);
@ -1633,8 +1767,13 @@ static void CON_DrawConsole(void)
//
void CON_Drawer(void)
{
Lock_state();
if (!con_started || !graphics_started)
{
Unlock_state();
return;
}
if (con_recalc)
CON_RecalcSize();
@ -1644,4 +1783,6 @@ void CON_Drawer(void)
else if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_CUTSCENE || gamestate == GS_CREDITS
|| gamestate == GS_VOTING || gamestate == GS_EVALUATION || gamestate == GS_WAITINGPLAYERS)
CON_DrawHudlines();
Unlock_state();
}

View File

@ -12,6 +12,7 @@
#include "d_event.h"
#include "command.h"
#include "i_threads.h"
#ifdef _WII
void CON_InitWii(void);
@ -21,6 +22,10 @@ void CON_Init(void);
boolean CON_Responder(event_t *ev);
#ifdef HAVE_THREADS
extern I_mutex con_mutex;
#endif
// set true when screen size has changed, to adapt console
extern boolean con_recalc;

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
#include "d_netcmd.h"
#include "tables.h"
#include "d_player.h"
#include "mserv.h"
/*
The 'packet version' is used to distinguish packet formats.
@ -333,6 +334,11 @@ typedef struct
char server_context[8]; // Unique context id, generated at server startup.
// Discord info (always defined for net compatibility)
UINT8 maxplayer;
boolean allownewplayer;
boolean discordinvites;
UINT8 varlengthinputs[0]; // Playernames and netvars
} ATTRPACK serverconfig_pak;
@ -530,7 +536,12 @@ typedef enum
} kickreason_t;
/* the max number of name changes in some time period */
#define MAXNAMECHANGES (5)
#define NAMECHANGERATE (60*TICRATE)
extern boolean server;
extern boolean serverrunning;
#define client (!server)
extern boolean dedicated; // For dedicated server
extern UINT16 software_MAXPACKETLENGTH;
@ -552,6 +563,8 @@ extern consvar_t
#endif
cv_netticbuffer, cv_allownewplayer, cv_maxplayers, cv_resynchattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed;
extern consvar_t cv_discordinvites;
// Used in d_net, the only dependence
tic_t ExpandTics(INT32 low, tic_t basetic);
void D_ClientServerInit(void);
@ -577,6 +590,7 @@ void CL_RemoveSplitscreenPlayer(UINT8 p);
void CL_Reset(void);
void CL_ClearPlayer(INT32 playernum);
void CL_RemovePlayer(INT32 playernum, INT32 reason);
void CL_QueryServerList(msg_server_t *list);
void CL_UpdateServerList(boolean internetsearch, INT32 room);
// Is there a game running
boolean Playing(void);

View File

@ -50,6 +50,7 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "hu_stuff.h"
#include "i_sound.h"
#include "i_system.h"
#include "i_threads.h"
#include "i_video.h"
#include "m_argv.h"
#include "m_menu.h"
@ -102,6 +103,10 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "lua_script.h"
#endif
#ifdef HAVE_DISCORDRPC
#include "discord.h"
#endif
// platform independant focus loss
UINT8 window_notinfocus = false;
@ -143,6 +148,8 @@ boolean advancedemo;
INT32 debugload = 0;
#endif
char savegamename[256];
#ifdef _arch_dreamcast
char srb2home[256] = "/cd";
char srb2path[256] = "/cd";
@ -185,35 +192,6 @@ UINT8 shiftdown = 0; // 0x1 left, 0x2 right
UINT8 ctrldown = 0; // 0x1 left, 0x2 right
UINT8 altdown = 0; // 0x1 left, 0x2 right
boolean capslock = 0; // gee i wonder what this does.
//
// D_ModifierKeyResponder
// Sets global shift/ctrl/alt variables, never actually eats events
//
static inline void D_ModifierKeyResponder(event_t *ev)
{
if (ev->type == ev_keydown || ev->type == ev_console) switch (ev->data1)
{
case KEY_LSHIFT: shiftdown |= 0x1; return;
case KEY_RSHIFT: shiftdown |= 0x2; return;
case KEY_LCTRL: ctrldown |= 0x1; return;
case KEY_RCTRL: ctrldown |= 0x2; return;
case KEY_LALT: altdown |= 0x1; return;
case KEY_RALT: altdown |= 0x2; return;
case KEY_CAPSLOCK: capslock = !capslock; return;
default: return;
}
else if (ev->type == ev_keyup) switch (ev->data1)
{
case KEY_LSHIFT: shiftdown &= ~0x1; return;
case KEY_RSHIFT: shiftdown &= ~0x2; return;
case KEY_LCTRL: ctrldown &= ~0x1; return;
case KEY_RCTRL: ctrldown &= ~0x2; return;
case KEY_LALT: altdown &= ~0x1; return;
case KEY_RALT: altdown &= ~0x2; return;
default: return;
}
}
//
// D_ProcessEvents
@ -223,6 +201,8 @@ void D_ProcessEvents(void)
{
event_t *ev;
boolean eaten;
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
{
ev = &events[eventtail];
@ -244,7 +224,17 @@ void D_ProcessEvents(void)
}
// Menu input
if (M_Responder(ev))
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
{
eaten = M_Responder(ev);
}
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
if (eaten)
continue; // menu ate the event
// Demo input:
@ -253,7 +243,17 @@ void D_ProcessEvents(void)
continue; // demo ate the event
// console input
if (CON_Responder(ev))
#ifdef HAVE_THREADS
I_lock_mutex(&con_mutex);
#endif
{
eaten = CON_Responder(ev);
}
#ifdef HAVE_THREADS
I_unlock_mutex(con_mutex);
#endif
if (eaten)
continue; // ate the event
G_Responder(ev);
@ -280,7 +280,7 @@ static void D_Display(void)
{
if (nodrawers)
return; // for comparative timing/profiling
// check for change of screen size (video mode)
if (setmodeneeded && !wipe)
SCR_SetMode(); // change video mode
@ -549,7 +549,13 @@ static void D_Display(void)
if (gamestate != GS_TIMEATTACK)
CON_Drawer();
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
M_Drawer(); // menu is drawn even on top of everything
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
// focus lost moved to M_Drawer
//
@ -725,6 +731,10 @@ void D_SRB2Loop(void)
#ifdef HAVE_BLUA
LUA_Step();
#endif
#ifdef HAVE_DISCORDRPC
Discord_RunCallbacks();
#endif
}
}
@ -839,9 +849,23 @@ static inline void D_CleanFile(char **filearray)
// Identify the SRB2 version, and IWAD file to use.
// ==========================================================================
static boolean AddIWAD(void)
{
char * path = va(pandf,srb2path,"srb2.srb");
if (FIL_ReadFileOK(path))
{
D_AddFile(path, startupwadfiles);
return true;
}
else
{
return false;
}
}
static void IdentifyVersion(void)
{
char *srb2wad1, *srb2wad2;
const char *srb2waddir = NULL;
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
@ -865,43 +889,28 @@ static void IdentifyVersion(void)
#ifdef _arch_dreamcast
srb2waddir = "/cd";
#else
srb2waddir = ".";
srb2waddir = srb2path;
#endif
}
}
#if defined (macintosh) && !defined (HAVE_SDL)
// cwd is always "/" when app is dbl-clicked
if (!stricmp(srb2waddir, "/"))
srb2waddir = I_GetWadDir();
#endif
// Commercial.
srb2wad1 = malloc(strlen(srb2waddir)+1+8+1);
srb2wad2 = malloc(strlen(srb2waddir)+1+8+1);
if (srb2wad1 == NULL && srb2wad2 == NULL)
I_Error("No more free memory to look in %s", srb2waddir);
if (srb2wad1 != NULL)
sprintf(srb2wad1, pandf, srb2waddir, "srb2.srb");
if (srb2wad2 != NULL)
sprintf(srb2wad2, pandf, srb2waddir, "srb2.wad");
// Load the IWAD
if (AddIWAD())
{
I_SaveCurrentWadDirectory();
}
else
{
if (!( I_UseSavedWadDirectory() && AddIWAD() ))
{
I_Error("SRB2.SRB not found! Expected in %s\n", srb2waddir);
}
}
// will be overwritten in case of -cdrom or unix/win home
snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2waddir);
configfile[sizeof configfile - 1] = '\0';
// Load the IWAD
if (srb2wad2 != NULL && FIL_ReadFileOK(srb2wad2))
D_AddFile(srb2wad2, startupwadfiles);
else if (srb2wad1 != NULL && FIL_ReadFileOK(srb2wad1))
D_AddFile(srb2wad1, startupwadfiles);
else
I_Error("SRB2.SRB/SRB2.WAD not found! Expected in %s, ss files: %s or %s\n", srb2waddir, srb2wad1, srb2wad2);
if (srb2wad1)
free(srb2wad1);
if (srb2wad2)
free(srb2wad2);
// if you change the ordering of this or add/remove a file, be sure to update the md5
// checking in D_SRB2Main
@ -1608,6 +1617,10 @@ void D_SRB2Main(void)
if (!P_SetupLevel(false))
I_Quit(); // fail so reset game stuff
}
#ifdef HAVE_DISCORDRPC
DRPC_Init();
#endif
}
const char *D_Home(void)

View File

@ -19,7 +19,9 @@
#define __D_NET__
// Max computers in a game
#define MAXNETNODES 64
// 127 is probably as high as this can go, because
// SINT8 is used for nodes sometimes >:(
#define MAXNETNODES 127
#define BROADCASTADDR MAXNETNODES
#define NETSPLITSCREEN // Kart's splitscreen netgame feature
@ -41,6 +43,8 @@ extern SINT8 nodetoplayer4[MAXNETNODES]; // Say the numplayer for this node if a
extern UINT8 playerpernode[MAXNETNODES]; // Used specially for splitscreen
extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game
extern boolean serverrunning;
INT32 Net_GetFreeAcks(boolean urgent);
void Net_AckTicker(void);

View File

@ -55,6 +55,10 @@
#define CV_RESTRICT 0
#endif
#ifdef HAVE_DISCORDRPC
#include "discord.h"
#endif
// ------
// protos
// ------
@ -77,6 +81,7 @@ static void Got_RandomSeed(UINT8 **cp, INT32 playernum);
static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum);
static void Got_Teamchange(UINT8 **cp, INT32 playernum);
static void Got_Clearscores(UINT8 **cp, INT32 playernum);
static void Got_DiscordInfo(UINT8 **cp, INT32 playernum);
static void PointLimit_OnChange(void);
static void TimeLimit_OnChange(void);
@ -704,10 +709,13 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_showping);
#ifdef SEENAMES
CV_RegisterVar(&cv_allowseenames);
CV_RegisterVar(&cv_allowseenames);
#endif
CV_RegisterVar(&cv_dummyconsvar);
CV_RegisterVar(&cv_discordinvites);
RegisterNetXCmd(XD_DISCORD, Got_DiscordInfo);
}
// =========================================================================
@ -1000,6 +1008,12 @@ void D_RegisterClientCommands(void)
#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE)
COM_AddCommand("dumplua", Command_Dumplua_f);
#endif
#ifdef HAVE_DISCORDRPC
CV_RegisterVar(&cv_discordrp);
CV_RegisterVar(&cv_discordstreamer);
CV_RegisterVar(&cv_discordasks);
#endif
}
/** Checks if a name (as received from another player) is okay.
@ -1204,6 +1218,8 @@ static void SetPlayerName(INT32 playernum, char *newname)
if (netgame)
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
player_name_changes[playernum]++;
strcpy(player_names[playernum], newname);
demo_extradata[playernum] |= DXD_NAME;
}
@ -1385,7 +1401,12 @@ static void SendNameAndColor(void)
snacpending++;
// Don't change name if muted
if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
if (player_name_changes[consoleplayer] >= MAXNAMECHANGES)
{
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
HU_AddChatText("\x85*You must wait to change your name again", false);
}
else if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
else // Cleanup name if changing it
CleanupPlayerName(consoleplayer, cv_playername.zstring);
@ -1509,7 +1530,12 @@ static void SendNameAndColor2(void)
snac2pending++;
// Don't change name if muted
if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1])))
if (player_name_changes[displayplayers[1]] >= MAXNAMECHANGES)
{
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
HU_AddChatText("\x85*You must wait to change your name again", false);
}
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1])))
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
else // Cleanup name if changing it
CleanupPlayerName(displayplayers[1], cv_playername2.zstring);
@ -1624,7 +1650,12 @@ static void SendNameAndColor3(void)
snac3pending++;
// Don't change name if muted
if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2])))
if (player_name_changes[displayplayers[2]] >= MAXNAMECHANGES)
{
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
HU_AddChatText("\x85*You must wait to change your name again", false);
}
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2])))
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
else // Cleanup name if changing it
CleanupPlayerName(displayplayers[2], cv_playername3.zstring);
@ -1747,7 +1778,12 @@ static void SendNameAndColor4(void)
snac4pending++;
// Don't change name if muted
if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3])))
if (player_name_changes[displayplayers[3]] >= MAXNAMECHANGES)
{
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
HU_AddChatText("\x85*You must wait to change your name again", false);
}
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3])))
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
else // Cleanup name if changing it
CleanupPlayerName(displayplayers[3], cv_playername4.zstring);
@ -1802,8 +1838,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
skin = READUINT8(*cp);
// set name
if (strcasecmp(player_names[playernum], name) != 0)
SetPlayerName(playernum, name);
if (player_name_changes[playernum] < MAXNAMECHANGES)
{
if (strcasecmp(player_names[playernum], name) != 0)
SetPlayerName(playernum, name);
}
// set color
p->skincolor = color % MAXSKINCOLORS;
@ -1859,6 +1898,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
}
else
SetPlayerSkinByNum(playernum, skin);
#ifdef HAVE_DISCORDRPC
if (playernum == consoleplayer)
DRPC_UpdatePresence();
#endif
}
void SendWeaponPref(void)
@ -2670,6 +2714,10 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
if (demo.recording) // Okay, level loaded, character spawned and skinned,
G_BeginRecording(); // I AM NOW READY TO RECORD.
demo.deferstart = true;
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
#endif
}
static void Command_Pause(void)
@ -4088,7 +4136,7 @@ static void Command_RunSOC(void)
static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum)
{
char filename[256];
filestatus_t ncs = FS_NOTFOUND;
filestatus_t ncs = FS_NOTCHECKED;
if (playernum != serverplayer && !IsPlayerAdmin(playernum))
{
@ -4260,7 +4308,7 @@ static void Command_Delfile(void)
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
{
char filename[241];
filestatus_t ncs = FS_NOTFOUND;
filestatus_t ncs = FS_NOTCHECKED;
UINT8 md5sum[16];
boolean kick = false;
boolean toomany = false;
@ -4355,7 +4403,7 @@ static void Got_Delfilecmd(UINT8 **cp, INT32 playernum)
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
{
char filename[241];
filestatus_t ncs = FS_NOTFOUND;
filestatus_t ncs = FS_NOTCHECKED;
UINT8 md5sum[16];
READSTRINGN(*cp, filename, 240);
@ -4643,6 +4691,10 @@ static void TimeLimit_OnChange(void)
}
else if (netgame || multiplayer)
CONS_Printf(M_GetText("Time limit disabled\n"));
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
#endif
}
/** Adjusts certain settings to match a changed gametype.
@ -5668,3 +5720,32 @@ static void KartEliminateLast_OnChange(void)
if (G_RaceGametype() && cv_karteliminatelast.value)
P_CheckRacers();
}
void Got_DiscordInfo(UINT8 **p, INT32 playernum)
{
if (playernum != serverplayer /*&& !IsPlayerAdmin(playernum)*/)
{
// protect against hacked/buggy client
CONS_Alert(CONS_WARNING, M_GetText("Illegal Discord info command received from %s\n"), player_names[playernum]);
if (server)
{
XBOXSTATIC UINT8 buf[2];
buf[0] = (UINT8)playernum;
buf[1] = KICK_MSG_CON_FAIL;
SendNetXCmd(XD_KICK, &buf, 2);
}
return;
}
// Don't do anything with the information if we don't have Discord RP support
#ifdef HAVE_DISCORDRPC
discordInfo.maxPlayers = READUINT8(*p);
discordInfo.joinsAllowed = (boolean)READUINT8(*p);
discordInfo.everyoneCanInvite = (boolean)READUINT8(*p);
DRPC_UpdatePresence();
#else
(*p) += 3;
#endif
}

View File

@ -178,9 +178,10 @@ typedef enum
XD_MODIFYVOTE, // 23
XD_PICKVOTE, // 24
XD_REMOVEPLAYER,// 25
XD_DISCORD, // 26
#ifdef HAVE_BLUA
XD_LUACMD, // 26
XD_LUAVAR, // 27
XD_LUACMD, // 27
XD_LUAVAR, // 28
#endif
MAXNETXCMD
} netxcmd_t;

View File

@ -108,6 +108,10 @@ char downloaddir[512] = "DOWNLOAD";
#ifdef CLIENT_LOADINGSCREEN
// for cl loading screen
INT32 lastfilenum = -1;
INT32 downloadcompletednum = 0;
UINT32 downloadcompletedsize = 0;
INT32 totalfilesrequestednum = 0;
UINT32 totalfilesrequestedsize = 0;
#endif
#ifdef HAVE_CURL
@ -141,7 +145,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile)
char wadfilename[MAX_WADPATH] = "";
UINT8 filestatus;
for (i = mainwads; i < numwadfiles; i++)
for (i = mainwads+1; i < numwadfiles; i++) //mainwads+1, otherwise we start on the first mainwad
{
// If it has only music/sound lumps, don't put it in the list
if (!wadfiles[i]->important)
@ -207,7 +211,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi
p = (UINT8 *)fileneededstr;
for (i = firstfile; i < fileneedednum; i++)
{
fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet
fileneeded[i].status = FS_NOTCHECKED; // We haven't even started looking for the file yet
filestatus = READUINT8(p); // The first byte is the file status
fileneeded[i].willsend = (UINT8)(filestatus >> 4);
fileneeded[i].totalsize = READUINT32(p); // The four next bytes are the file size
@ -370,15 +374,17 @@ boolean Got_RequestFilePak(INT32 node)
* \return 0 if some files are missing
* 1 if all files exist
* 2 if some already loaded files are not requested or are in a different order
* 3 too many files, over WADLIMIT
* 4 still checking, continuing next tic
*
*/
INT32 CL_CheckFiles(void)
{
INT32 i, j;
char wadfilename[MAX_WADPATH];
INT32 ret = 1;
size_t packetsize = 0;
size_t filestoget = 0;
size_t filestoload = 0;
boolean downloadrequired = false;
// if (M_CheckParm("-nofiles"))
// return 1;
@ -395,7 +401,7 @@ INT32 CL_CheckFiles(void)
if (modifiedgame)
{
CONS_Debug(DBG_NETPLAY, "game is modified; only doing basic checks\n");
for (i = 0, j = mainwads; i < fileneedednum || j < numwadfiles;)
for (i = 0, j = mainwads+1; i < fileneedednum || j < numwadfiles;)
{
if (j < numwadfiles && !wadfiles[j]->important)
{
@ -424,10 +430,19 @@ INT32 CL_CheckFiles(void)
for (i = 0; i < fileneedednum; i++)
{
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_FALLBACK)
downloadrequired = true;
if (fileneeded[i].status == FS_FOUND || fileneeded[i].status == FS_NOTFOUND)
filestoload++;
if (fileneeded[i].status != FS_NOTCHECKED) //since we're running this over multiple tics now, its possible for us to come across files checked in previous tics
continue;
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
// Check in already loaded files
for (j = mainwads; wadfiles[j]; j++)
for (j = mainwads+1; wadfiles[j]; j++)
{
nameonly(strcpy(wadfilename, wadfiles[j]->filename));
if (!stricmp(wadfilename, fileneeded[i].filename) &&
@ -435,36 +450,35 @@ INT32 CL_CheckFiles(void)
{
CONS_Debug(DBG_NETPLAY, "already loaded\n");
fileneeded[i].status = FS_OPEN;
break;
return 4;
}
}
if (fileneeded[i].status != FS_NOTFOUND)
continue;
packetsize += nameonlylength(fileneeded[i].filename) + 22;
if (mainwads+filestoget >= MAX_WADFILES)
return 3;
filestoget++;
fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true);
CONS_Debug(DBG_NETPLAY, "found %d\n", fileneeded[i].status);
if (fileneeded[i].status != FS_FOUND)
ret = 0;
return 4;
}
return ret;
//now making it here means we've checked the entire list and no FS_NOTCHECKED files remain
if (numwadfiles+filestoload > MAX_WADFILES)
return 3;
else if (downloadrequired)
return 0; //some stuff is FS_NOTFOUND, needs download
else
return 1; //everything is FS_OPEN or FS_FOUND, proceed to loading
}
// Load it now
void CL_LoadServerFiles(void)
boolean CL_LoadServerFiles(void)
{
INT32 i;
// if (M_CheckParm("-nofiles"))
// return;
for (i = 1; i < fileneedednum; i++)
for (i = 0; i < fileneedednum; i++)
{
if (fileneeded[i].status == FS_OPEN)
continue; // Already loaded
@ -473,6 +487,7 @@ void CL_LoadServerFiles(void)
P_AddWadFile(fileneeded[i].filename);
G_SetGameModified(true, false);
fileneeded[i].status = FS_OPEN;
return false;
}
else if (fileneeded[i].status == FS_MD5SUMBAD)
I_Error("Wrong version of file %s", fileneeded[i].filename);
@ -498,6 +513,7 @@ void CL_LoadServerFiles(void)
fileneeded[i].status, s);
}
}
return true;
}
// Number of files to send
@ -768,7 +784,7 @@ void SV_FileSendTicker(void)
if (ram)
M_Memcpy(p->data, &f->id.ram[transfer[i].position], size);
else if (fread(p->data, 1, size, transfer[i].currentfile) != size)
I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->id.filename, transfer[i].position, strerror(ferror(transfer[i].currentfile)));
I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->id.filename, transfer[i].position, M_FileError(transfer[i].currentfile));
p->position = LONG(transfer[i].position);
// Put flag so receiver knows the total size
if (transfer[i].position + size == f->size)
@ -847,7 +863,7 @@ void Got_Filetxpak(void)
// We can receive packet in the wrong order, anyway all os support gaped file
fseek(file->file, pos, SEEK_SET);
if (fwrite(netbuffer->u.filetxpak.data,size,1,file->file) != 1)
I_Error("Can't write to %s: %s\n",filename, strerror(ferror(file->file)));
I_Error("Can't write to %s: %s\n",filename, M_FileError(file->file));
file->currentsize += size;
// Finished?
@ -858,6 +874,10 @@ void Got_Filetxpak(void)
file->status = FS_FOUND;
CONS_Printf(M_GetText("Downloading %s...(done)\n"),
filename);
#ifndef NONET
downloadcompletednum++;
downloadcompletedsize += file->totalsize;
#endif
}
}
else
@ -1088,7 +1108,7 @@ void CURLPrepareFile(const char* url, int dfilenum)
// Only allow HTTP and HTTPS
curl_easy_setopt(http_handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS);
curl_easy_setopt(http_handle, CURLOPT_USERAGENT, va("SRB2Kart/v%d.%d.%d", VERSION/100, VERSION%100, SUBVERSION)); // Set user agent as some servers won't accept invalid user agents.
curl_easy_setopt(http_handle, CURLOPT_USERAGENT, va("SRB2Kart/v%d.%d", VERSION, SUBVERSION)); // Set user agent as some servers won't accept invalid user agents.
// Follow a redirect request, if sent by the server.
curl_easy_setopt(http_handle, CURLOPT_FOLLOWLOCATION, 1L);
@ -1169,6 +1189,8 @@ void CURLGetFile(void)
{
nameonly(curl_realname);
CONS_Printf(M_GetText("Finished downloading %s\n"), curl_realname);
downloadcompletednum++;
downloadcompletedsize += curl_curfile->totalsize;
curl_curfile->status = FS_FOUND;
fclose(curl_curfile->file);
}

View File

@ -25,6 +25,7 @@ typedef enum
typedef enum
{
FS_NOTCHECKED,
FS_NOTFOUND,
FS_FOUND,
FS_REQUESTED,
@ -52,6 +53,10 @@ extern char downloaddir[512];
#ifdef CLIENT_LOADINGSCREEN
extern INT32 lastfilenum;
extern INT32 downloadcompletednum;
extern UINT32 downloadcompletedsize;
extern INT32 totalfilesrequestednum;
extern UINT32 totalfilesrequestedsize;
#endif
#ifdef HAVE_CURL
@ -65,7 +70,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi
void CL_PrepareDownloadSaveGame(const char *tmpsave);
INT32 CL_CheckFiles(void);
void CL_LoadServerFiles(void);
boolean CL_LoadServerFiles(void);
void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod,
UINT8 fileid);

View File

@ -925,6 +925,18 @@ static void readlevelheader(MYFILE *f, INT32 num)
sizeof(mapheaderinfo[num-1]->subttl), va("Level header %d: subtitle", num));
continue;
}
else if (fastcmp(word, "LEVELNAME"))
{
deh_strlcpy(mapheaderinfo[num-1]->lvlttl, word2,
sizeof(mapheaderinfo[num-1]->lvlttl), va("Level header %d: levelname", num));
continue;
}
else if (fastcmp(word, "ZONETITLE"))
{
deh_strlcpy(mapheaderinfo[num-1]->zonttl, word2,
sizeof(mapheaderinfo[num-1]->zonttl), va("Level header %d: zonetitle", num));
continue;
}
// Lua custom options also go above, contents may be case sensitive.
if (fastncmp(word, "LUA.", 4))
@ -987,16 +999,6 @@ static void readlevelheader(MYFILE *f, INT32 num)
}
// Strings that can be truncated
else if (fastcmp(word, "LEVELNAME"))
{
deh_strlcpy(mapheaderinfo[num-1]->lvlttl, word2,
sizeof(mapheaderinfo[num-1]->lvlttl), va("Level header %d: levelname", num));
}
else if (fastcmp(word, "ZONETITLE"))
{
deh_strlcpy(mapheaderinfo[num-1]->zonttl, word2,
sizeof(mapheaderinfo[num-1]->zonttl), va("Level header %d: zonetitle", num));
}
else if (fastcmp(word, "SCRIPTNAME"))
{
deh_strlcpy(mapheaderinfo[num-1]->scriptname, word2,
@ -7764,7 +7766,6 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s
"MT_TWINKLECARTAMBIENCE",
"MT_EXPLODINGBARREL",
"MT_MERRYHORSE",
"MT_ARIDTOAD",
"MT_BLUEFRUIT",
"MT_ORANGEFRUIT",
"MT_REDFRUIT",
@ -7775,6 +7776,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s
"MT_BOOSTPROMPT",
"MT_BOOSTOFF",
"MT_BOOSTON",
"MT_ARIDTOAD",
"MT_LIZARDMAN",
"MT_LIONMAN",
@ -8622,13 +8624,11 @@ struct {
{"FF_COLORMAPONLY",FF_COLORMAPONLY}, ///< Only copy the colormap, not the lightlevel
{"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop.
#ifdef ESLOPE
// Slope flags
{"SL_NOPHYSICS",SL_NOPHYSICS}, // Don't do momentum adjustment with this slope
{"SL_NODYNAMIC",SL_NODYNAMIC}, // Slope will never need to move during the level, so don't fuss with recalculating it
{"SL_ANCHORVERTEX",SL_ANCHORVERTEX},// Slope is using a Slope Vertex Thing to anchor its position
{"SL_VERTEXSLOPE",SL_VERTEXSLOPE}, // Slope is built from three Slope Vertex Things
#endif
// Angles
{"ANG1",ANG1},
@ -9764,6 +9764,9 @@ static inline int lib_getenum(lua_State *L)
} else if (fastcmp(word,"exitcountdown")) {
lua_pushinteger(L, exitcountdown); // This name is pretty dumb. Hence why we'll prefer more descriptive names at least in Lua...
return 1;
} else if (fastcmp(word,"replayplayback")) {
lua_pushboolean(L, demo.playback);
return 1;
}
return 0;
}

708
src/discord.c Normal file
View File

@ -0,0 +1,708 @@
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2018-2020 by Sally "TehRealSalt" Cochenour.
// Copyright (C) 2018-2020 by Kart Krew.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file discord.h
/// \brief Discord Rich Presence handling
#ifdef HAVE_DISCORDRPC
#ifdef HAVE_CURL
#include <curl/curl.h>
#endif // HAVE_CURL
#include "i_system.h"
#include "d_clisrv.h"
#include "d_netcmd.h"
#include "i_net.h"
#include "g_game.h"
#include "p_tick.h"
#include "m_menu.h" // gametype_cons_t
#include "r_things.h" // skins
#include "mserv.h" // ms_RoomId
#include "z_zone.h"
#include "byteptr.h"
#include "discord.h"
#include "doomdef.h"
// Feel free to provide your own, if you care enough to create another Discord app for this :P
#define DISCORD_APPID "503531144395096085"
// 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};
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};
struct discordInfo_s discordInfo;
discordRequest_t *discordRequestList = NULL;
#ifdef HAVE_CURL
struct SelfIPbuffer
{
CURL *curl;
char *pointer;
size_t length;
};
static char self_ip[IP_SIZE];
#endif // HAVE_CURL
/*--------------------------------------------------
static char *DRPC_XORIPString(const char *input)
Simple XOR encryption/decryption. Not complex or
very secretive because we aren't sending anything
that isn't easily accessible via our Master Server anyway.
--------------------------------------------------*/
static char *DRPC_XORIPString(const char *input)
{
const UINT8 xor[IP_SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21};
char *output = malloc(sizeof(char) * (IP_SIZE+1));
UINT8 i;
for (i = 0; i < IP_SIZE; i++)
{
char xorinput;
if (!input[i])
break;
xorinput = input[i] ^ xor[i];
if (xorinput < 32 || xorinput > 126)
{
xorinput = input[i];
}
output[i] = xorinput;
}
output[i] = '\0';
return output;
}
/*--------------------------------------------------
static void DRPC_HandleReady(const DiscordUser *user)
Callback function, ran when the game connects to Discord.
Input Arguments:-
user - Struct containing Discord user info.
Return:-
None
--------------------------------------------------*/
static void DRPC_HandleReady(const DiscordUser *user)
{
if (cv_discordstreamer.value)
{
CONS_Printf("Discord: connected to %s\n", user->username);
}
else
{
CONS_Printf("Discord: connected to %s#%s (%s)\n", user->username, user->discriminator, user->userId);
}
}
/*--------------------------------------------------
static void DRPC_HandleDisconnect(int err, const char *msg)
Callback function, ran when disconnecting from Discord.
Input Arguments:-
err - Error type
msg - Error message
Return:-
None
--------------------------------------------------*/
static void DRPC_HandleDisconnect(int err, const char *msg)
{
CONS_Printf("Discord: disconnected (%d: %s)\n", err, msg);
}
/*--------------------------------------------------
static void DRPC_HandleError(int err, const char *msg)
Callback function, ran when Discord outputs an error.
Input Arguments:-
err - Error type
msg - Error message
Return:-
None
--------------------------------------------------*/
static void DRPC_HandleError(int err, const char *msg)
{
CONS_Alert(CONS_WARNING, "Discord error (%d: %s)\n", err, msg);
}
/*--------------------------------------------------
static void DRPC_HandleJoin(const char *secret)
Callback function, ran when Discord wants to
connect a player to the game via a channel invite
or a join request.
Input Arguments:-
secret - Value that links you to the server.
Return:-
None
--------------------------------------------------*/
static void DRPC_HandleJoin(const char *secret)
{
char *ip = DRPC_XORIPString(secret);
CONS_Printf("Connecting to %s via Discord\n", ip);
COM_BufAddText(va("connect \"%s\"\n", ip));
free(ip);
}
/*--------------------------------------------------
static boolean DRPC_InvitesAreAllowed(void)
Determines whenever or not invites or
ask to join requests are allowed.
Input Arguments:-
None
Return:-
true if invites are allowed, false otherwise.
--------------------------------------------------*/
static boolean DRPC_InvitesAreAllowed(void)
{
if (!Playing())
{
// We're not playing, so we should not be getting invites.
return false;
}
if (cv_discordasks.value == 0)
{
// Client has the CVar set to off, so never allow invites from this client.
return false;
}
if (discordInfo.joinsAllowed == true)
{
if (discordInfo.everyoneCanInvite == true)
{
// Everyone's allowed!
return true;
}
else if (consoleplayer == serverplayer || IsPlayerAdmin(consoleplayer))
{
// Only admins are allowed!
return true;
}
}
// Did not pass any of the checks
return false;
}
/*--------------------------------------------------
static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
Callback function, ran when Discord wants to
ask the player if another Discord user can join
or not.
Input Arguments:-
requestUser - DiscordUser struct for the user trying to connect.
Return:-
None
--------------------------------------------------*/
static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
{
discordRequest_t *append = discordRequestList;
discordRequest_t *newRequest;
if (DRPC_InvitesAreAllowed() == false)
{
// Something weird happened if this occurred...
Discord_Respond(requestUser->userId, DISCORD_REPLY_IGNORE);
return;
}
newRequest = Z_Calloc(sizeof(discordRequest_t), PU_STATIC, NULL);
newRequest->username = Z_Calloc(344, PU_STATIC, NULL);
snprintf(newRequest->username, 344, "%s", requestUser->username);
newRequest->discriminator = Z_Calloc(8, PU_STATIC, NULL);
snprintf(newRequest->discriminator, 8, "%s", requestUser->discriminator);
newRequest->userID = Z_Calloc(32, PU_STATIC, NULL);
snprintf(newRequest->userID, 32, "%s", requestUser->userId);
if (append != NULL)
{
discordRequest_t *prev = NULL;
while (append != NULL)
{
// CHECK FOR DUPES!! Ignore any that already exist from the same user.
if (!strcmp(newRequest->userID, append->userID))
{
Discord_Respond(newRequest->userID, DISCORD_REPLY_IGNORE);
DRPC_RemoveRequest(newRequest);
return;
}
prev = append;
append = append->next;
}
newRequest->prev = prev;
prev->next = newRequest;
}
else
{
discordRequestList = newRequest;
M_RefreshPauseMenu();
}
// Made it to the end, request was valid, so play the request sound :)
S_StartSound(NULL, sfx_requst);
}
/*--------------------------------------------------
void DRPC_RemoveRequest(discordRequest_t *removeRequest)
See header file for description.
--------------------------------------------------*/
void DRPC_RemoveRequest(discordRequest_t *removeRequest)
{
if (removeRequest->prev != NULL)
{
removeRequest->prev->next = removeRequest->next;
}
if (removeRequest->next != NULL)
{
removeRequest->next->prev = removeRequest->prev;
if (removeRequest == discordRequestList)
{
discordRequestList = removeRequest->next;
}
}
else
{
if (removeRequest == discordRequestList)
{
discordRequestList = NULL;
}
}
Z_Free(removeRequest->username);
Z_Free(removeRequest->userID);
Z_Free(removeRequest);
}
/*--------------------------------------------------
void DRPC_Init(void)
See header file for description.
--------------------------------------------------*/
void DRPC_Init(void)
{
DiscordEventHandlers handlers;
memset(&handlers, 0, sizeof(handlers));
handlers.ready = DRPC_HandleReady;
handlers.disconnected = DRPC_HandleDisconnect;
handlers.errored = DRPC_HandleError;
handlers.joinGame = DRPC_HandleJoin;
handlers.joinRequest = DRPC_HandleJoinRequest;
Discord_Initialize(DISCORD_APPID, &handlers, 1, NULL);
I_AddExitFunc(Discord_Shutdown);
DRPC_UpdatePresence();
}
#ifdef HAVE_CURL
/*--------------------------------------------------
static size_t DRPC_WriteServerIP(char *s, size_t size, size_t n, void *userdata)
Writing function for use with curl. Only intended to be used with simple text.
Input Arguments:-
s - Data to write
size - Always 1.
n - Length of data
userdata - Passed in from CURLOPT_WRITEDATA, intended to be SelfIPbuffer
Return:-
Number of bytes wrote in this pass.
--------------------------------------------------*/
static size_t DRPC_WriteServerIP(char *s, size_t size, size_t n, void *userdata)
{
struct SelfIPbuffer *buffer;
size_t newlength;
buffer = userdata;
newlength = buffer->length + size*n;
buffer->pointer = realloc(buffer->pointer, newlength+1);
memcpy(buffer->pointer + buffer->length, s, size*n);
buffer->pointer[newlength] = '\0';
buffer->length = newlength;
return size*n;
}
#endif // HAVE_CURL
/*--------------------------------------------------
static const char *DRPC_GetServerIP(void)
Retrieves the IP address of the server that you're
connected to. Will attempt to use curl for getting your
own IP address, if it's not yours.
--------------------------------------------------*/
static const char *DRPC_GetServerIP(void)
{
const char *address;
// If you're connected
if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL)
{
if (strcmp(address, "self"))
{
// We're not the server, so we could successfully get the IP!
// No need to do anything else :)
return address;
}
}
#ifdef HAVE_CURL
// This is a little bit goofy, but
// there's practically no good way to get your own public IP address,
// so we've gotta break out curl for this :V
if (!self_ip[0])
{
CURL *curl;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if (curl)
{
// The API to get your public IP address from.
// Picked because it's stupid simple and it's been up for a long time.
const char *api = "http://ip4only.me/api/";
struct SelfIPbuffer buffer;
CURLcode success;
buffer.length = 0;
buffer.pointer = malloc(buffer.length+1);
buffer.pointer[0] = '\0';
curl_easy_setopt(curl, CURLOPT_URL, api);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, DRPC_WriteServerIP);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
success = curl_easy_perform(curl);
if (success == CURLE_OK)
{
char *tmp;
tmp = strtok(buffer.pointer, ",");
if (!strcmp(tmp, "IPv4")) // ensure correct type of IP
{
tmp = strtok(NULL, ",");
strncpy(self_ip, tmp, IP_SIZE); // Yay, we have the IP :)
}
}
free(buffer.pointer);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}
if (self_ip[0])
return self_ip;
else
#endif // HAVE_CURL
return NULL; // Could not get your IP for whatever reason, so we cannot do Discord invites
}
/*--------------------------------------------------
void DRPC_EmptyRequests(void)
Empties the request list. Any existing requests
will get an ignore reply.
--------------------------------------------------*/
static void DRPC_EmptyRequests(void)
{
while (discordRequestList != NULL)
{
Discord_Respond(discordRequestList->userID, DISCORD_REPLY_IGNORE);
DRPC_RemoveRequest(discordRequestList);
}
}
/*--------------------------------------------------
void DRPC_UpdatePresence(void)
See header file for description.
--------------------------------------------------*/
void DRPC_UpdatePresence(void)
{
char detailstr[48+1];
char mapimg[8+1];
char mapname[5+21+21+2+1];
char charimg[4+SKINNAMESIZE+1];
char charname[11+SKINNAMESIZE+1];
boolean joinSecretSet = false;
DiscordRichPresence discordPresence;
memset(&discordPresence, 0, sizeof(discordPresence));
if (!cv_discordrp.value)
{
// User doesn't want to show their game information, so update with empty presence.
// This just shows that they're playing SRB2Kart. (If that's too much, then they should disable game activity :V)
DRPC_EmptyRequests();
Discord_UpdatePresence(&discordPresence);
return;
}
#ifdef DEVELOP
// This way, we can use the invite feature in-dev, but not have snoopers seeing any potential secrets! :P
discordPresence.largeImageKey = "miscdevelop";
discordPresence.largeImageText = "No peeking!";
discordPresence.state = "Testing the game";
DRPC_EmptyRequests();
Discord_UpdatePresence(&discordPresence);
return;
#endif // DEVELOP
// Server info
if (netgame)
{
switch (ms_RoomId)
{
case -1: discordPresence.state = "Private"; break; // Private server
case 33: discordPresence.state = "Standard"; break;
case 28: discordPresence.state = "Casual"; break;
case 38: discordPresence.state = "Custom Gametypes"; break;
case 31: discordPresence.state = "OLDC"; break;
default: discordPresence.state = "Unknown Room"; break; // HOW
}
discordPresence.partyId = server_context; // Thanks, whoever gave us Mumble support, for implementing the EXACT thing Discord wanted for this field!
discordPresence.partySize = D_NumPlayers(); // Players in server
discordPresence.partyMax = discordInfo.maxPlayers; // Max players
if (DRPC_InvitesAreAllowed() == true)
{
const char *join;
// Grab the host's IP for joining.
if ((join = DRPC_GetServerIP()) != NULL)
{
char *xorjoin = DRPC_XORIPString(join);
discordPresence.joinSecret = xorjoin;
free(xorjoin);
joinSecretSet = true;
}
}
}
else
{
// Reset discord info if you're not in a place that uses it!
// Important for if you join a server that compiled without HAVE_DISCORDRPC,
// so that you don't ever end up using bad information from another server.
memset(&discordInfo, 0, sizeof(discordInfo));
// Offline info
if (Playing())
discordPresence.state = "Offline";
else if (demo.playback && !demo.title)
discordPresence.state = "Watching Replay";
else
discordPresence.state = "Menu";
}
// Gametype info
if ((gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING) && Playing())
{
if (modeattacking)
discordPresence.details = "Time Attack";
else
{
snprintf(detailstr, 48, "%s%s%s",
gametype_cons_t[gametype].strvalue,
(gametype == GT_RACE) ? va(" | %s", kartspeed_cons_t[gamespeed].strvalue) : "",
(encoremode == true) ? " | Encore" : ""
);
discordPresence.details = detailstr;
}
}
if ((gamestate == GS_LEVEL || gamestate == GS_INTERMISSION) // Map info
&& !(demo.playback && demo.title))
{
if ((gamemap >= 1 && gamemap <= 60) // supported race maps
|| (gamemap >= 136 && gamemap <= 164)) // supported battle maps
{
snprintf(mapimg, 8, "%s", G_BuildMapName(gamemap));
strlwr(mapimg);
discordPresence.largeImageKey = mapimg; // Map image
}
else if (mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU)
{
// Hell map, use the method that got you here :P
discordPresence.largeImageKey = "miscdice";
}
else
{
// This is probably a custom map!
discordPresence.largeImageKey = "mapcustom";
}
if (mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU)
{
// Hell map, hide the name
discordPresence.largeImageText = "Map: ???";
}
else
{
// Map name on tool tip
snprintf(mapname, 48, "Map: %s", G_BuildMapTitle(gamemap));
discordPresence.largeImageText = mapname;
}
if (gamestate == GS_LEVEL && Playing())
{
const time_t currentTime = time(NULL);
const time_t mapTimeStart = currentTime - ((leveltime + (modeattacking ? starttime : 0)) / TICRATE);
discordPresence.startTimestamp = mapTimeStart;
if (timelimitintics > 0)
{
const time_t mapTimeEnd = mapTimeStart + ((timelimitintics + starttime + 1) / TICRATE);
discordPresence.endTimestamp = mapTimeEnd;
}
}
}
else if (gamestate == GS_VOTING)
{
discordPresence.largeImageKey = (G_BattleGametype() ? "miscredplanet" : "miscblueplanet");
discordPresence.largeImageText = "Voting";
}
else
{
discordPresence.largeImageKey = "misctitle";
discordPresence.largeImageText = "Title Screen";
}
// Character info
if (Playing() && playeringame[consoleplayer] && !players[consoleplayer].spectator)
{
// Supported skin names
static const char *supportedSkins[] = {
// base game
"sonic",
"tails",
"knuckles",
"eggman",
"metalsonic",
// bonus chars
"flicky",
"motobug",
"amy",
"mighty",
"ray",
"espio",
"vector",
"chao",
"gamma",
"chaos",
"shadow",
"rouge",
"herochao",
"darkchao",
"cream",
"omega",
"blaze",
"silver",
"wonderboy",
"arle",
"nights",
"sakura",
"ulala",
"beat",
"vyse",
"aiai",
"kiryu",
"aigis",
"miku",
"doom",
NULL
};
boolean customChar = true;
UINT8 checkSkin = 0;
// Character image
while (supportedSkins[checkSkin] != NULL)
{
if (!strcmp(skins[players[consoleplayer].skin].name, supportedSkins[checkSkin]))
{
snprintf(charimg, 21, "char%s", supportedSkins[checkSkin]);
discordPresence.smallImageKey = charimg;
customChar = false;
break;
}
checkSkin++;
}
if (customChar == true)
{
// Use the custom character icon!
discordPresence.smallImageKey = "charcustom";
}
snprintf(charname, 28, "Character: %s", skins[players[consoleplayer].skin].realname);
discordPresence.smallImageText = charname; // Character name
}
if (joinSecretSet == false)
{
// Not able to join? Flush the request list, if it exists.
DRPC_EmptyRequests();
}
Discord_UpdatePresence(&discordPresence);
}
#endif // HAVE_DISCORDRPC

80
src/discord.h Normal file
View File

@ -0,0 +1,80 @@
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2018-2020 by Sally "TehRealSalt" Cochenour.
// Copyright (C) 2018-2020 by Kart Krew.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file discord.h
/// \brief Discord Rich Presence handling
#ifndef __DISCORD__
#define __DISCORD__
#ifdef HAVE_DISCORDRPC
#include "discord_rpc.h"
extern consvar_t cv_discordrp;
extern consvar_t cv_discordstreamer;
extern consvar_t cv_discordasks;
extern struct discordInfo_s {
UINT8 maxPlayers;
boolean joinsAllowed;
boolean everyoneCanInvite;
} discordInfo;
typedef struct discordRequest_s {
char *username; // Discord user name.
char *discriminator; // Discord discriminator (The little hashtag thing after the username). Separated for a "hide discriminators" cvar.
char *userID; // The ID of the Discord user, gets used with Discord_Respond()
// HAHAHA, no.
// *Maybe* if it was only PNG I would boot up curl just to get AND convert this to Doom GFX,
// but it can *also* be a JEPG, WebP, or GIF :)
// Hey, wanna add ImageMagick as a dependency? :dying:
//patch_t *avatar;
struct discordRequest_s *next; // Next request in the list.
struct discordRequest_s *prev; // Previous request in the list. Not used normally, but just in case something funky happens, this should repair the list.
} discordRequest_t;
extern discordRequest_t *discordRequestList;
/*--------------------------------------------------
void DRPC_RemoveRequest(void);
Removes an invite from the list.
--------------------------------------------------*/
void DRPC_RemoveRequest(discordRequest_t *removeRequest);
/*--------------------------------------------------
void DRPC_Init(void);
Initalizes Discord Rich Presence by linking the Application ID
and setting the callback functions.
--------------------------------------------------*/
void DRPC_Init(void);
/*--------------------------------------------------
void DRPC_UpdatePresence(void);
Updates what is displayed by Rich Presence on the user's profile.
Should be called whenever something that is displayed is
changed in-game.
--------------------------------------------------*/
void DRPC_UpdatePresence(void);
#endif // HAVE_DISCORDRPC
#endif // __DISCORD__

View File

@ -30,7 +30,6 @@
#ifdef HAVE_MIXER
//#if !defined(DC) && !defined(_WIN32_WCE) && !defined(_XBOX) && !defined(GP2X)
#define SOUND SOUND_MIXER
#define NOHS // No HW3SOUND
#ifdef HW3SOUND
#undef HW3SOUND
#endif
@ -47,7 +46,6 @@
// Use FMOD?
#ifdef HAVE_FMOD
#define SOUND SOUND_FMOD
#define NOHS // No HW3SOUND
#ifdef HW3SOUND
#undef HW3SOUND
#endif
@ -64,10 +62,6 @@
#if !defined (HWRENDER) && !defined (NOHW)
#define HWRENDER
#endif
// judgecutor: 3D sound support
#if !defined(HW3SOUND) && !defined (NOHS)
#define HW3SOUND
#endif
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
@ -154,9 +148,9 @@ extern char logfilename[1024];
// we use comprevision and compbranch instead.
#else
#define VERSION 1 // Game version
#define SUBVERSION 2 // more precise version number
#define VERSIONSTRING "v1.2"
#define VERSIONSTRINGW L"v1.2"
#define SUBVERSION 3 // more precise version number
#define VERSIONSTRING "v1.3"
#define VERSIONSTRINGW L"v1.3"
// Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates!
// And change CMakeLists.txt, for CMake users!
// AND appveyor.yml, for the build bots!
@ -229,7 +223,7 @@ extern char logfilename[1024];
// it's only for detection of the version the player is using so the MS can alert them of an update.
// Only set it higher, not lower, obviously.
// Note that we use this to help keep internal testing in check; this is why v2.1.0 is not version "1".
#define MODVERSION 6
#define MODVERSION 7
// Filter consvars by version
// To version config.cfg, MAJOREXECVERSION is set equal to MODVERSION automatically.
@ -506,7 +500,7 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...) FUNCDEBUG;
// Things that used to be in dstrings.h
#define SAVEGAMENAME "srb2sav"
char savegamename[256];
extern char savegamename[256];
// m_misc.h
#ifdef GETTEXT
@ -606,11 +600,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Kalaron/Eternity Engine slope code (SRB2CB ported)
#define ESLOPE
#ifdef ESLOPE
/// Backwards compatibility with SRB2CB's slope linedef types.
/// \note A simple shim that prints a warning.
#define ESLOPE_TYPESHIM
#endif
/// Delete file while the game is running.
/// \note EXTREMELY buggy, tends to crash game.
@ -681,4 +673,10 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Hardware renderer: OpenGL
#define GL_SHADERS
#if defined (HAVE_CURL) && ! defined (NONET)
#define MASTERSERVER
#else
#undef UPDATE_ALERT
#endif
#endif // __DOOMDEF__

View File

@ -24,6 +24,7 @@
#include "w_wad.h"
#include "z_zone.h"
#include "i_system.h"
#include "i_threads.h"
#include "m_menu.h"
#include "dehacked.h"
#include "g_input.h"
@ -317,7 +318,13 @@ void F_IntroDrawer(void)
{
I_OsPolling();
I_UpdateNoBlit();
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
M_Drawer(); // menu is drawn even on top of wipes
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
I_FinishUpdate(); // Update the screen with the image Tails 06-19-2001
}
}

View File

@ -22,6 +22,7 @@
#include "z_zone.h"
#include "i_system.h"
#include "i_threads.h"
#include "m_menu.h"
#include "console.h"
#include "d_main.h"
@ -379,7 +380,15 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
I_UpdateNoBlit();
if (drawMenu)
{
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
M_Drawer(); // menu is drawn even on top of wipes
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
}
I_FinishUpdate(); // page flip or blit buffer

View File

@ -51,6 +51,10 @@
#include "md5.h" // demo checksums
#include "k_kart.h" // SRB2kart
#ifdef HAVE_DISCORDRPC
#include "discord.h"
#endif
gameaction_t gameaction;
gamestate_t gamestate = GS_NULL;
UINT8 ultimatemode = false;
@ -544,6 +548,8 @@ char player_names[MAXPLAYERS][MAXPLAYERNAME+1] =
"Player 16"
}; // SRB2kart - removed Players 17 through 32
int player_name_changes[MAXPLAYERS];
INT16 rw_maximums[NUM_WEAPONS] =
{
800, // MAX_INFINITY
@ -2498,6 +2504,11 @@ void G_Ticker(boolean run)
spectatedelay3--;
if (spectatedelay4)
spectatedelay4--;
if (gametic % NAMECHANGERATE == 0)
{
memset(player_name_changes, 0, sizeof player_name_changes);
}
}
}
@ -3647,7 +3658,7 @@ tryagain:
void G_AddMapToBuffer(INT16 map)
{
INT16 bufx, refreshnum = (TOLMaps(G_TOLFlag(gametype)) / 2) + 1;
INT16 bufx, refreshnum = max(0, TOLMaps(G_TOLFlag(gametype))-3);
// Add the map to the buffer.
for (bufx = NUMMAPS-1; bufx > 0; bufx--)
@ -4717,7 +4728,7 @@ char *G_BuildMapTitle(INT32 mapnum)
}
else if (!(mapheaderinfo[mapnum-1]->levelflags & LF_NOZONE))
{
zonetext = M_GetText("ZONE");
zonetext = M_GetText("Zone");
len += strlen(zonetext) + 1; // ' ' + zonetext
}
if (strlen(mapheaderinfo[mapnum-1]->actnum) > 0)
@ -6326,8 +6337,8 @@ void G_RecordDemo(const char *name)
maxsize = 1024*1024*2;
if (M_CheckParm("-maxdemo") && M_IsNextParm())
maxsize = atoi(M_GetNextParm()) * 1024;
// if (demobuffer)
// free(demobuffer);
if (demobuffer)
free(demobuffer);
demo_p = NULL;
demobuffer = malloc(maxsize);
demoend = demobuffer + maxsize;
@ -6368,7 +6379,9 @@ void G_BeginRecording(void)
demoflags |= DF_ENCORE;
#ifdef HAVE_BLUA
demoflags |= DF_LUAVARS;
if (!modeattacking) // Ghosts don't read luavars, and you shouldn't ever need to save Lua in replays, you doof!
// SERIOUSLY THOUGH WHY WOULD YOU LOAD HOSTMOD AND RECORD A GHOST WITH IT !????
demoflags |= DF_LUAVARS;
#endif
// Setup header.
@ -6379,7 +6392,7 @@ void G_BeginRecording(void)
// Full replay title
demo_p += 64;
snprintf(demo.titlename, 64, "%s - %s", G_BuildMapTitle(gamemap), modeattacking ? "Record Attack" : connectedservername);
snprintf(demo.titlename, 64, "%s - %s", G_BuildMapTitle(gamemap), modeattacking ? "Time Attack" : connectedservername);
// demo checksum
demo_p += 16;
@ -6474,8 +6487,9 @@ void G_BeginRecording(void)
WRITEUINT8(demo_p, 0xFF); // Denote the end of the player listing
#ifdef HAVE_BLUA
// player lua vars, always saved even if empty
LUA_ArchiveDemo();
// player lua vars, always saved even if empty... Unless it's record attack.
if (!modeattacking)
LUA_ArchiveDemo();
#endif
memset(&oldcmd,0,sizeof(oldcmd));
@ -7153,6 +7167,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7181,6 +7196,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7193,6 +7209,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7212,6 +7229,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7272,6 +7290,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7342,6 +7361,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7355,6 +7375,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7379,6 +7400,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7422,6 +7444,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7477,6 +7500,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7491,6 +7515,7 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demobuffer = NULL;
demo.playback = false;
demo.title = false;
return;
@ -7543,6 +7568,7 @@ void G_DoPlayDemo(char *defdemoname)
if (!gL) // No Lua state! ...I guess we'll just start one...
LUA_ClearState();
// No modeattacking check, DF_LUAVARS won't be present here.
LUA_UnArchiveDemo();
}
#endif
@ -8140,6 +8166,7 @@ ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void)
saved = FIL_WriteFile(va("%sMS.LMP", G_BuildMapName(gamemap)), demobuffer, demo_p - demobuffer); // finally output the file.
}
free(demobuffer);
demobuffer = NULL;
metalrecording = false;
if (saved)
I_Error("Saved to %sMS.LMP", G_BuildMapName(gamemap));
@ -8320,6 +8347,7 @@ void G_SaveDemo(void)
if (FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer)) // finally output the file.
demo.savemode = DSM_SAVED;
free(demobuffer);
demobuffer = NULL;
demo.recording = false;
if (modeattacking != ATTACKING_RECORD)
@ -8388,6 +8416,9 @@ boolean G_DemoTitleResponder(event_t *ev)
void G_SetGamestate(gamestate_t newstate)
{
gamestate = newstate;
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
#endif
}
/* These functions handle the exitgame flag. Before, when the user

View File

@ -27,6 +27,7 @@ extern char customversionstring[32];
extern player_t *seenplayer;
#endif
extern char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
extern int player_name_changes[MAXPLAYERS];
extern player_t players[MAXPLAYERS];
extern boolean playeringame[MAXPLAYERS];

View File

@ -407,7 +407,7 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei
if (angle) // Only needs to be done if there's an altered angle
{
angle = (InvAngle(angle)+ANGLE_180)>>ANGLETOFINESHIFT;
angle = InvAngle(angle)>>ANGLETOFINESHIFT;
// This needs to be done so that it scrolls in a different direction after rotation like software
/*tempxsow = FLOAT_TO_FIXED(scrollx);
@ -439,7 +439,7 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei
tempxsow = FLOAT_TO_FIXED(v3d->s);
tempytow = FLOAT_TO_FIXED(v3d->t);
v3d->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));
v3d->t = (FIXED_TO_FLOAT(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle))));
v3d->t = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));
}
//v3d->s = (float)(v3d->s - flatxref + scrollx);
@ -4733,6 +4733,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
}
R_SetupFrame(player, false); // This can stay false because it is only used to set viewsky in r_main.c, which isn't used here
framecount++; // for timedemo
HWR_RenderFrame(viewnumber, player, false);
}

View File

@ -143,7 +143,7 @@ static const GLfloat byte2float[256] = {
// -----------------+
#ifdef DEBUG_TO_FILE
FILE *gllogstream;
FILE *gllogstream = NULL;
#endif
FUNCPRINTF void GL_DBG_Printf(const char *format, ...)
@ -152,14 +152,14 @@ FUNCPRINTF void GL_DBG_Printf(const char *format, ...)
char str[4096] = "";
va_list arglist;
if (!gllogstream)
gllogstream = fopen("ogllog.txt", "w");
if (gllogstream)
{
va_start(arglist, format);
vsnprintf(str, 4096, format, arglist);
va_end(arglist);
va_start(arglist, format);
vsnprintf(str, 4096, format, arglist);
va_end(arglist);
fwrite(str, strlen(str), 1, gllogstream);
fwrite(str, strlen(str), 1, gllogstream);
}
#else
(void)format;
#endif
@ -823,7 +823,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
#ifdef GL_SHADERS
GLuint gl_vertShader, gl_fragShader;
GLint i, result;
if (!pglUseProgram) return false;
gl_customvertexshaders[0] = NULL;
@ -2002,11 +2002,11 @@ EXPORT void HWRAPI(RenderBatches) (int *sNumPolys, int *sNumVerts, int *sNumCall
boolean stopFlag = false;
boolean changeState = false;
boolean changeShader = false;
GLuint nextShader;
GLuint nextShader = 0U;
boolean changeTexture = false;
GLuint nextTexture;
GLuint nextTexture = 0U;
boolean changePolyFlags = false;
FBITFIELD nextPolyFlags;
FBITFIELD nextPolyFlags = 0U;
boolean changeSurfaceInfo = false;
FSurfaceInfo nextSurfaceInfo;
@ -2307,7 +2307,7 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI
pglColor4ubv((GLubyte*)&pSurf->PolyColor.s);
}
// Tint color
tint.red = byte2float[pSurf->TintColor.s.red];
tint.green = byte2float[pSurf->TintColor.s.green];

683
src/http-mserv.c Normal file
View File

@ -0,0 +1,683 @@
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2020 by James R.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
// \brief HTTP based master server
/*
Documentation available here.
<http://mb.srb2.org/MS/tools/api/v1/>
*/
#ifdef HAVE_CURL
#include <curl/curl.h>
#endif
#include "doomdef.h"
#include "d_clisrv.h"
#include "command.h"
#include "m_argv.h"
#include "m_menu.h"
#include "mserv.h"
#include "i_tcp.h"/* for current_port */
#include "i_threads.h"
/* reasonable default I guess?? */
#define DEFAULT_BUFFER_SIZE (4096)
/* I just stop myself from making macros anymore. */
#define Blame( ... ) \
CONS_Printf("\x85" __VA_ARGS__)
static void MasterServer_Debug_OnChange (void);
consvar_t cv_masterserver_timeout = {
"masterserver_timeout", "5", CV_SAVE, CV_Unsigned,
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
};
consvar_t cv_masterserver_debug = {
"masterserver_debug", "Off", CV_SAVE|CV_CALL, CV_OnOff,
MasterServer_Debug_OnChange, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
};
consvar_t cv_masterserver_token = {
"masterserver_token", "", CV_SAVE, NULL,
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
};
#ifdef MASTERSERVER
static int hms_started;
static char *hms_api;
#ifdef HAVE_THREADS
static I_mutex hms_api_mutex;
#endif
static char *hms_server_token;
struct HMS_buffer
{
CURL *curl;
char *buffer;
int needle;
int end;
};
static void
Contact_error (void)
{
CONS_Alert(CONS_ERROR,
"There was a problem contacting the master server...\n"
);
}
static size_t
HMS_on_read (char *s, size_t _1, size_t n, void *userdata)
{
struct HMS_buffer *buffer;
size_t blocks;
(void)_1;
buffer = userdata;
if (n >= (size_t)( buffer->end - buffer->needle ))
{
/* resize to next multiple of buffer size */
blocks = ( n / DEFAULT_BUFFER_SIZE + 1 );
buffer->end += ( blocks * DEFAULT_BUFFER_SIZE );
buffer->buffer = realloc(buffer->buffer, buffer->end);
}
memcpy(&buffer->buffer[buffer->needle], s, n);
buffer->needle += n;
return n;
}
static struct HMS_buffer *
HMS_connect (const char *format, ...)
{
va_list ap;
CURL *curl;
char *url;
char *quack_token;
size_t seek;
size_t token_length;
struct HMS_buffer *buffer;
if (! hms_started)
{
if (curl_global_init(CURL_GLOBAL_ALL) != 0)
{
Contact_error();
Blame("From curl_global_init.\n");
return NULL;
}
else
{
atexit(curl_global_cleanup);
hms_started = 1;
}
}
curl = curl_easy_init();
if (! curl)
{
Contact_error();
Blame("From curl_easy_init.\n");
return NULL;
}
if (cv_masterserver_token.string[0])
{
quack_token = curl_easy_escape(curl, cv_masterserver_token.string, 0);
token_length = ( sizeof "?token="-1 )+ strlen(quack_token);
}
else
{
quack_token = NULL;
token_length = 0;
}
#ifdef HAVE_THREADS
I_lock_mutex(&hms_api_mutex);
#endif
seek = strlen(hms_api) + 1;/* + '/' */
va_start (ap, format);
url = malloc(seek + vsnprintf(0, 0, format, ap) + token_length + 1);
va_end (ap);
sprintf(url, "%s/", hms_api);
#ifdef HAVE_THREADS
I_unlock_mutex(hms_api_mutex);
#endif
va_start (ap, format);
seek += vsprintf(&url[seek], format, ap);
va_end (ap);
if (quack_token)
sprintf(&url[seek], "?token=%s", quack_token);
CONS_Printf("HMS: connecting '%s'...\n", url);
buffer = malloc(sizeof *buffer);
buffer->curl = curl;
buffer->end = DEFAULT_BUFFER_SIZE;
buffer->buffer = malloc(buffer->end);
buffer->needle = 0;
if (cv_masterserver_debug.value)
{
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_STDERR, logstream);
}
if (M_CheckParm("-bindaddr") && M_IsNextParm())
{
curl_easy_setopt(curl, CURLOPT_INTERFACE, M_GetNextParm());
}
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, cv_masterserver_timeout.value);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
curl_free(quack_token);
free(url);
return buffer;
}
static int
HMS_do (struct HMS_buffer *buffer)
{
CURLcode cc;
long status;
char *p;
cc = curl_easy_perform(buffer->curl);
if (cc != CURLE_OK)
{
Contact_error();
Blame(
"From curl_easy_perform: %s\n",
curl_easy_strerror(cc)
);
return 0;
}
buffer->buffer[buffer->needle] = '\0';
curl_easy_getinfo(buffer->curl, CURLINFO_RESPONSE_CODE, &status);
if (status != 200)
{
p = strchr(buffer->buffer, '\n');
if (p)
*p = '\0';
Contact_error();
Blame(
"Master server error %ld: %s%s\n",
status,
buffer->buffer,
( (p) ? "" : " (malformed)" )
);
return 0;
}
else
return 1;
}
static void
HMS_end (struct HMS_buffer *buffer)
{
curl_easy_cleanup(buffer->curl);
free(buffer->buffer);
free(buffer);
}
int
HMS_fetch_rooms (int joining, int query_id)
{
struct HMS_buffer *hms;
int ok;
int doing_shit;
char *id;
char *title;
char *room_motd;
int id_no;
char *p;
char *end;
int i;
(void)query_id;
hms = HMS_connect("rooms");
if (! hms)
return 0;
if (HMS_do(hms))
{
doing_shit = 1;
p = hms->buffer;
for (i = 0; i < NUM_LIST_ROOMS && ( end = strstr(p, "\n\n\n") );)
{
*end = '\0';
id = strtok(p, "\n");
title = strtok(0, "\n");
room_motd = strtok(0, "");
if (id && title && room_motd)
{
id_no = atoi(id);
/*
Don't show the 'All' room if hosting. And it's a hack like this
because I'm way too lazy to add another feature to the MS.
*/
if (joining || id_no != 0)
{
#ifdef HAVE_THREADS
I_lock_mutex(&ms_QueryId_mutex);
{
if (query_id != ms_QueryId)
doing_shit = 0;
}
I_unlock_mutex(ms_QueryId_mutex);
if (! doing_shit)
break;
#endif
room_list[i].header.buffer[0] = 1;
room_list[i].id = id_no;
strlcpy(room_list[i].name, title, sizeof room_list[i].name);
strlcpy(room_list[i].motd, room_motd, sizeof room_list[i].motd);
i++;
}
p = ( end + 3 );/* skip the three linefeeds */
}
else
break;
}
if (doing_shit)
room_list[i].header.buffer[0] = 0;
ok = 1;
if (doing_shit)
{
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
{
for (i = 0; room_list[i].header.buffer[0]; i++)
{
if(*room_list[i].name != '\0')
{
MP_RoomMenu[i+1].text = room_list[i].name;
roomIds[i] = room_list[i].id;
MP_RoomMenu[i+1].status = IT_STRING|IT_CALL;
}
}
}
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
}
}
else
ok = 0;
HMS_end(hms);
return ok;
}
int
HMS_register (void)
{
struct HMS_buffer *hms;
int ok;
char post[256];
char *title;
hms = HMS_connect("rooms/%d/register", ms_RoomId);
if (! hms)
return 0;
title = curl_easy_escape(hms->curl, cv_servername.string, 0);
snprintf(post, sizeof post,
"port=%d&"
"title=%s&"
"version=%d.%d",
current_port,
title,
VERSION,
SUBVERSION
);
curl_free(title);
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
if (ok)
{
hms_server_token = strdup(strtok(hms->buffer, "\n"));
}
HMS_end(hms);
return ok;
}
int
HMS_unlist (void)
{
struct HMS_buffer *hms;
int ok;
hms = HMS_connect("servers/%s/unlist", hms_server_token);
if (! hms)
return 0;
curl_easy_setopt(hms->curl, CURLOPT_CUSTOMREQUEST, "POST");
ok = HMS_do(hms);
HMS_end(hms);
free(hms_server_token);
return ok;
}
int
HMS_update (void)
{
struct HMS_buffer *hms;
int ok;
char post[256];
char *title;
hms = HMS_connect("servers/%s/update", hms_server_token);
if (! hms)
return 0;
title = curl_easy_escape(hms->curl, cv_servername.string, 0);
snprintf(post, sizeof post,
"title=%s",
title
);
curl_free(title);
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
HMS_end(hms);
return ok;
}
void
HMS_list_servers (void)
{
struct HMS_buffer *hms;
char *p;
hms = HMS_connect("servers");
if (! hms)
return;
if (HMS_do(hms))
{
p = &hms->buffer[strlen(hms->buffer)];
while (*--p == '\n')
;
CONS_Printf("%s\n", hms->buffer);
}
HMS_end(hms);
}
msg_server_t *
HMS_fetch_servers (msg_server_t *list, int room_number, int query_id)
{
struct HMS_buffer *hms;
int doing_shit;
char local_version[9];
char *room;
char *address;
char *port;
char *title;
char *version;
char *end;
char *section_end;
char *p;
int i;
(void)query_id;
if (room_number > 0)
{
hms = HMS_connect("rooms/%d/servers", room_number);
}
else
hms = HMS_connect("servers");
if (! hms)
return NULL;
if (HMS_do(hms))
{
doing_shit = 1;
snprintf(local_version, sizeof local_version,
"%d.%d",
VERSION,
SUBVERSION
);
p = hms->buffer;
i = 0;
do
{
section_end = strstr(p, "\n\n");
room = strtok(p, "\n");
p = strtok(0, "");
if (! p)
break;
while (i < MAXSERVERLIST && ( end = strchr(p, '\n') ))
{
*end = '\0';
address = strtok(p, " ");
port = strtok(0, " ");
title = strtok(0, " ");
version = strtok(0, "");
if (address && port && title && version)
{
#ifdef HAVE_THREADS
I_lock_mutex(&ms_QueryId_mutex);
{
if (query_id != ms_QueryId)
doing_shit = 0;
}
I_unlock_mutex(ms_QueryId_mutex);
if (! doing_shit)
break;
#endif
if (strcmp(version, local_version) == 0)
{
strlcpy(list[i].ip, address, sizeof list[i].ip);
strlcpy(list[i].port, port, sizeof list[i].port);
strlcpy(list[i].name, title, sizeof list[i].name);
strlcpy(list[i].version, version, sizeof list[i].version);
list[i].room = atoi(room);
list[i].header.buffer[0] = 1;
i++;
}
if (end == section_end)/* end of list for this room */
break;
else
p = ( end + 1 );/* skip server delimiter */
}
else
{
section_end = 0;/* malformed so quit the parsing */
break;
}
}
if (! doing_shit)
break;
p = ( section_end + 2 );
}
while (section_end) ;
if (doing_shit)
list[i].header.buffer[0] = 0;
}
else
list = NULL;
HMS_end(hms);
return list;
}
int
HMS_compare_mod_version (char *buffer, size_t buffer_size)
{
struct HMS_buffer *hms;
int ok;
char *version;
char *version_name;
hms = HMS_connect("versions/%d", MODID);
if (! hms)
return 0;
ok = 0;
if (HMS_do(hms))
{
version = strtok(hms->buffer, " ");
version_name = strtok(0, "\n");
if (version && version_name)
{
if (atoi(version) != MODVERSION)
{
strlcpy(buffer, version_name, buffer_size);
ok = 1;
}
else
ok = -1;
}
}
HMS_end(hms);
return ok;
}
void
HMS_set_api (char *api)
{
#ifdef HAVE_THREADS
I_lock_mutex(&hms_api_mutex);
#endif
{
free(hms_api);
hms_api = api;
}
#ifdef HAVE_THREADS
I_unlock_mutex(hms_api_mutex);
#endif
}
#endif/*MASTERSERVER*/
static void
MasterServer_Debug_OnChange (void)
{
#ifdef MASTERSERVER
/* TODO: change to 'latest-log.txt' for log files revision. */
if (cv_masterserver_debug.value)
CONS_Printf("Master server debug messages will appear in log.txt\n");
#endif
}

View File

@ -318,6 +318,15 @@ const CPUInfoFlags *I_CPUInfo(void);
*/
const char *I_LocateWad(void);
/** \brief Save current wad directory to appdata
*/
void I_SaveCurrentWadDirectory(void);
/** \brief Change directory to last known directory saved in appdata
\return whether the directory could be saved
*/
boolean I_UseSavedWadDirectory(void);
/** \brief First Joystick's events
*/
void I_GetJoystickEvents(void);

View File

@ -246,7 +246,8 @@ static size_t numbans = 0;
static boolean SOCK_bannednode[MAXNETNODES+1]; /// \note do we really need the +1?
static boolean init_tcp_driver = false;
static char port_name[8] = DEFAULTPORT;
static const char *serverport_name = DEFAULTPORT;
static const char *clientport_name;/* any port */
#ifndef NONET
@ -924,6 +925,7 @@ static boolean UDP_Socket(void)
#ifdef HAVE_IPV6
const INT32 b_ipv6 = M_CheckParm("-ipv6");
#endif
const char *serv;
for (s = 0; s < mysocketses; s++)
@ -939,11 +941,16 @@ static boolean UDP_Socket(void)
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
if (serverrunning)
serv = serverport_name;
else
serv = clientport_name;
if (M_CheckParm("-bindaddr"))
{
while (M_IsNextParm())
{
gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai);
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
if (gaie == 0)
{
runp = ai;
@ -964,7 +971,7 @@ static boolean UDP_Socket(void)
}
else
{
gaie = I_getaddrinfo("0.0.0.0", port_name, &hints, &ai);
gaie = I_getaddrinfo("0.0.0.0", serv, &hints, &ai);
if (gaie == 0)
{
runp = ai;
@ -979,8 +986,8 @@ static boolean UDP_Socket(void)
#ifdef HAVE_MINIUPNPC
if (UPNP_support)
{
I_UPnP_rem(port_name, "UDP");
I_UPnP_add(NULL, port_name, "UDP");
I_UPnP_rem(serverport_name, "UDP");
I_UPnP_add(NULL, serverport_name, "UDP");
}
#endif
}
@ -997,7 +1004,7 @@ static boolean UDP_Socket(void)
{
while (M_IsNextParm())
{
gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai);
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
if (gaie == 0)
{
runp = ai;
@ -1018,7 +1025,7 @@ static boolean UDP_Socket(void)
}
else
{
gaie = I_getaddrinfo("::", port_name, &hints, &ai);
gaie = I_getaddrinfo("::", serv, &hints, &ai);
if (gaie == 0)
{
runp = ai;
@ -1475,15 +1482,19 @@ boolean I_InitTcpNetwork(void)
if (!I_InitTcpDriver())
return false;
if (M_CheckParm("-port"))
if (M_CheckParm("-port") || M_CheckParm("-serverport"))
// Combined -udpport and -clientport into -port
// As it was really redundant having two seperate parms that does the same thing
/* Sorry Steel, I'm adding these back. But -udpport is a stupid name. */
{
if (M_IsNextParm())
strcpy(port_name, M_GetNextParm());
else
strcpy(port_name, "0");
/*
If it's NULL, that's okay! Because then
we'll get a random port from getaddrinfo.
*/
serverport_name = M_GetNextParm();
}
if (M_CheckParm("-clientport"))
clientport_name = M_GetNextParm();
// parse network game options,
if (M_CheckParm("-server") || dedicated)

39
src/i_threads.h Normal file
View File

@ -0,0 +1,39 @@
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2020 by James R.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file i_threads.h
/// \brief Multithreading abstraction
#ifdef HAVE_THREADS
#ifndef I_THREADS_H
#define I_THREADS_H
typedef void (*I_thread_fn)(void *userdata);
typedef void * I_mutex;
typedef void * I_cond;
void I_start_threads (void);
void I_stop_threads (void);
void I_spawn_thread (const char *name, I_thread_fn, void *userdata);
/* check in your thread whether to return early */
int I_thread_is_stopped (void);
void I_lock_mutex (I_mutex *);
void I_unlock_mutex (I_mutex);
void I_hold_cond (I_cond *, I_mutex);
void I_wake_one_cond (I_cond *);
void I_wake_all_cond (I_cond *);
#endif/*I_THREADS_H*/
#endif/*HAVE_THREADS*/

View File

@ -898,6 +898,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp
newodds = 0;
else
POWERITEMODDS(newodds);
break;
case KITEM_HYUDORO:
if ((hyubgone > 0) || COOLDOWNONSTART)
newodds = 0;
@ -1061,6 +1062,10 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
bestbumper = players[i].kartstuff[k_bumper];
}
// No forced SPB in 1v1s, it has to be randomly rolled
if (pingame <= 2)
dontforcespb = true;
// This makes the roulette produce the random noises.
if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player) && !demo.freecam)
{
@ -1372,30 +1377,72 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid)
}
}
/** \brief Checks that the player is on an offroad subsector for realsies
/** \brief Checks that the player is on an offroad subsector for realsies. Also accounts for line riding to prevent cheese.
\param mo player mobj object
\return boolean
*/
static UINT8 K_CheckOffroadCollide(mobj_t *mo, sector_t *sec)
static UINT8 K_CheckOffroadCollide(mobj_t *mo)
{
UINT8 i;
sector_t *sec2;
// Check for sectors in touching_sectorlist
UINT8 i; // special type iter
msecnode_t *node; // touching_sectorlist iter
sector_t *s; // main sector shortcut
sector_t *s2; // FOF sector shortcut
ffloor_t *rover; // FOF
fixed_t flr;
fixed_t cel; // floor & ceiling for height checks to make sure we're touching the offroad sector.
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
sec2 = P_ThingOnSpecial3DFloor(mo);
for (i = 2; i < 5; i++)
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{
if ((sec2 && GETSECSPECIAL(sec2->special, 1) == i)
|| (P_IsObjectOnRealGround(mo, sec) && GETSECSPECIAL(sec->special, 1) == i))
return i-1;
}
if (!node->m_sector)
break; // shouldn't happen.
return 0;
s = node->m_sector;
// 1: Check for the main sector, make sure we're on the floor of that sector and see if we can apply offroad.
// Make arbitrary Z checks because we want to check for 1 sector in particular, we don't want to affect the player if the offroad sector is way below them and they're lineriding a normal sector above.
flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true);
cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); // get Z coords of both floors and ceilings for this sector (this accounts for slopes properly.)
// NOTE: we don't use P_GetZAt with our x/y directly because the mobj won't have the same height because of its hitbox on the slope. Complex garbage but tldr it doesn't work.
if ( ((s->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == flr) // floor check
|| ((mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING) && (mo->z + mo->height) == cel)) ) // ceiling check.
for (i = 2; i < 5; i++) // check for sector special
if (GETSECSPECIAL(s->special, 1) == i)
return i-1; // return offroad type
// 2: If we're here, we haven't found anything. So let's try looking for FOFs in the sectors using the same logic.
for (rover = s->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS)) // This FOF doesn't exist anymore.
continue;
s2 = &sectors[rover->secnum]; // makes things easier for us
flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL);
cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom.
// we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF.
// Reminder that an FOF's floor is its bottom, silly!
if ( ((s2->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == cel) // "floor" check
|| ((s2->flags & SF_FLIPSPECIAL_CEILING) && (mo->z + mo->height) == flr) ) // "ceiling" check.
for (i = 2; i < 5; i++) // check for sector special
if (GETSECSPECIAL(s2->special, 1) == i)
return i-1; // return offroad type
}
}
return 0; // couldn't find any offroad
}
/** \brief Updates the Player's offroad value once per frame
@ -1407,14 +1454,12 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo, sector_t *sec)
static void K_UpdateOffroad(player_t *player)
{
fixed_t offroad;
sector_t *nextsector = R_PointInSubsector(
player->mo->x + player->mo->momx*2, player->mo->y + player->mo->momy*2)->sector;
UINT8 offroadstrength = K_CheckOffroadCollide(player->mo, nextsector);
UINT8 offroadstrength = K_CheckOffroadCollide(player->mo);
// If you are in offroad, a timer starts.
if (offroadstrength)
{
if (K_CheckOffroadCollide(player->mo, player->mo->subsector->sector) && player->kartstuff[k_offroad] == 0)
if (/*K_CheckOffroadCollide(player->mo) &&*/ player->kartstuff[k_offroad] == 0) // With the way offroad is detected now that first check is no longer necessary. -Lat'
player->kartstuff[k_offroad] = (TICRATE/2);
if (player->kartstuff[k_offroad] > 0)
@ -2893,14 +2938,12 @@ void K_SpawnBoostTrail(player_t *player)
{
newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale));
newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale));
#ifdef ESLOPE
if (player->mo->standingslope)
{
ground = P_GetZAt(player->mo->standingslope, newx, newy);
if (player->mo->eflags & MFE_VERTICALFLIP)
ground -= FixedMul(mobjinfo[MT_SNEAKERTRAIL].height, player->mo->scale);
}
#endif
flame = P_SpawnMobj(newx, newy, ground, MT_SNEAKERTRAIL);
P_SetTarget(&flame->target, player->mo);
@ -3312,7 +3355,8 @@ void K_PuntMine(mobj_t *thismine, mobj_t *punter)
if (!thismine || P_MobjWasRemoved(thismine))
return;
if (thismine->type == MT_SSMINE_SHIELD) // Create a new mine
//This guarantees you hit a mine being dragged
if (thismine->type == MT_SSMINE_SHIELD) // Create a new mine, and clean up the old one
{
mine = P_SpawnMobj(thismine->x, thismine->y, thismine->z, MT_SSMINE);
P_SetTarget(&mine->target, thismine->target);
@ -3320,7 +3364,19 @@ void K_PuntMine(mobj_t *thismine, mobj_t *punter)
mine->flags2 = thismine->flags2;
mine->floorz = thismine->floorz;
mine->ceilingz = thismine->ceilingz;
//Since we aren't using P_KillMobj, we need to clean up the hnext reference
{
P_SetTarget(&thismine->target->hnext, NULL); //target is the player who owns the mine
thismine->target->player->kartstuff[k_bananadrag] = 0;
thismine->target->player->kartstuff[k_itemheld] = 0;
if (--thismine->target->player->kartstuff[k_itemamount] <= 0)
thismine->target->player->kartstuff[k_itemtype] = KITEM_NONE;
}
P_RemoveMobj(thismine);
}
else
mine = thismine;
@ -3604,9 +3660,7 @@ void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound)
if (mo->eflags & MFE_SPRUNG)
return;
#ifdef ESLOPE
mo->standingslope = NULL;
#endif
mo->eflags |= MFE_SPRUNG;
@ -3870,6 +3924,62 @@ void K_DropItems(player_t *player)
K_StripItems(player);
}
void K_DropRocketSneaker(player_t *player)
{
mobj_t *shoe = player->mo;
fixed_t flingangle;
boolean leftshoe = true; //left shoe is first
if (!(player->mo && !P_MobjWasRemoved(player->mo) && player->mo->hnext && !P_MobjWasRemoved(player->mo->hnext)))
return;
while ((shoe = shoe->hnext) && !P_MobjWasRemoved(shoe))
{
if (shoe->type != MT_ROCKETSNEAKER)
return; //woah, not a rocketsneaker, bail! safeguard in case this gets used when you're holding non-rocketsneakers
shoe->flags2 &= ~MF2_DONTDRAW;
shoe->flags &= ~MF_NOGRAVITY;
shoe->angle += ANGLE_45;
if (shoe->eflags & MFE_VERTICALFLIP)
shoe->z -= shoe->height;
else
shoe->z += shoe->height;
//left shoe goes off tot eh left, right shoe off to the right
if (leftshoe)
flingangle = -(ANG60);
else
flingangle = ANG60;
S_StartSound(shoe, shoe->info->deathsound);
P_SetObjectMomZ(shoe, 8*FRACUNIT, false);
P_InstaThrust(shoe, R_PointToAngle2(shoe->target->x, shoe->target->y, shoe->x, shoe->y)+flingangle, 16*FRACUNIT);
shoe->momx += shoe->target->momx;
shoe->momy += shoe->target->momy;
shoe->momz += shoe->target->momz;
shoe->extravalue2 = 1;
leftshoe = false;
}
P_SetTarget(&player->mo->hnext, NULL);
player->kartstuff[k_rocketsneakertimer] = 0;
}
void K_DropKitchenSink(player_t *player)
{
if (!(player->mo && !P_MobjWasRemoved(player->mo) && player->mo->hnext && !P_MobjWasRemoved(player->mo->hnext)))
return;
if (player->mo->hnext->type != MT_SINK_SHIELD)
return; //so we can just call this function regardless of what is being held
P_KillMobj(player->mo->hnext, NULL, NULL);
P_SetTarget(&player->mo->hnext, NULL);
}
// When an item in the hnext chain dies.
void K_RepairOrbitChain(mobj_t *orbit)
{
@ -4490,6 +4600,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
fast->momx = 3*player->mo->momx/4;
fast->momy = 3*player->mo->momy/4;
fast->momz = 3*player->mo->momz/4;
P_SetTarget(&fast->target, player->mo); // easier lua access
K_MatchGenericExtraFlags(fast, player->mo);
}
@ -5195,12 +5306,12 @@ void K_KartUpdatePosition(player_t *player)
//
void K_StripItems(player_t *player)
{
K_DropRocketSneaker(player);
K_DropKitchenSink(player);
player->kartstuff[k_itemtype] = KITEM_NONE;
player->kartstuff[k_itemamount] = 0;
player->kartstuff[k_itemheld] = 0;
player->kartstuff[k_rocketsneakertimer] = 0;
if (!player->kartstuff[k_itemroulette] || player->kartstuff[k_roulettetype] != 2)
{
player->kartstuff[k_itemroulette] = 0;
@ -8634,7 +8745,7 @@ void K_drawKartFreePlay(UINT32 flashtime)
return;
V_DrawKartString((BASEVIDWIDTH - (LAPS_X+1)) - (12*9), // mirror the laps thingy
LAPS_Y+3, V_SNAPTOBOTTOM|V_SNAPTORIGHT, "FREE PLAY");
LAPS_Y+3, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, "FREE PLAY");
}
static void K_drawDistributionDebugger(void)

View File

@ -11,7 +11,7 @@
#define KART_FULLTURN 800
UINT8 colortranslations[MAXTRANSLATIONS][16];
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);
@ -55,6 +55,8 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue);
INT32 K_GetKartDriftSparkValue(player_t *player);
void K_KartUpdatePosition(player_t *player);
void K_DropItems(player_t *player);
void K_DropRocketSneaker(player_t *player);
void K_DropKitchenSink(player_t *player);
void K_StripItems(player_t *player);
void K_StripOther(player_t *player);
void K_MomentumToFacing(player_t *player);

View File

@ -14,9 +14,7 @@
#ifdef HAVE_BLUA
#include "p_local.h"
#include "p_setup.h" // So we can have P_SetupLevelSky
#ifdef ESLOPE
#include "p_slopes.h" // P_GetZAt
#endif
#include "z_zone.h"
#include "r_main.h"
#include "r_things.h"
@ -1575,7 +1573,6 @@ static int lib_evCrumbleChain(lua_State *L)
return 0;
}
#ifdef ESLOPE
// P_SLOPES
////////////
@ -1591,7 +1588,6 @@ static int lib_pGetZAt(lua_State *L)
lua_pushfixed(L, P_GetZAt(slope, x, y));
return 1;
}
#endif
// R_DEFS
////////////
@ -3083,10 +3079,8 @@ static luaL_Reg lib[] = {
{"P_StartQuake",lib_pStartQuake},
{"EV_CrumbleChain",lib_evCrumbleChain},
#ifdef ESLOPE
// p_slopes
{"P_GetZAt",lib_pGetZAt},
#endif
// r_defs
{"R_PointToAngle",lib_rPointToAngle},

View File

@ -79,9 +79,7 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
{
INT32 offset;
const INT32 *list; // Big blockmap
#ifdef POLYOBJECTS
polymaplink_t *plink; // haleyjd 02/22/06
#endif
line_t *ld;
if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight)
@ -89,7 +87,6 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
offset = y*bmapwidth + x;
#ifdef POLYOBJECTS
// haleyjd 02/22/06: consider polyobject lines
plink = polyblocklinks[offset];
@ -132,7 +129,6 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
}
plink = (polymaplink_t *)(plink->link.next);
}
#endif
offset = *(blockmap + offset); // offset = blockmap[y*bmapwidth+x];

View File

@ -40,11 +40,9 @@ extern lua_State *gL;
#define META_SUBSECTOR "SUBSECTOR_T*"
#define META_SECTOR "SECTOR_T*"
#define META_FFLOOR "FFLOOR_T*"
#ifdef ESLOPE
#define META_SLOPE "PSLOPE_T*"
#define META_VECTOR2 "VECTOR2_T"
#define META_VECTOR3 "VECTOR3_T"
#endif
#define META_MAPHEADER "MAPHEADER_T*"
#define META_CVAR "CONSVAR_T*"

View File

@ -16,9 +16,7 @@
#include "p_local.h"
#include "p_setup.h"
#include "z_zone.h"
#ifdef ESLOPE
#include "p_slopes.h"
#endif
#include "r_main.h"
#include "lua_script.h"
@ -43,13 +41,9 @@ enum sector_e {
sector_heightsec,
sector_camsec,
sector_lines,
#ifdef ESLOPE
sector_ffloors,
sector_fslope,
sector_cslope
#else
sector_ffloors
#endif
};
static const char *const sector_opt[] = {
@ -66,10 +60,8 @@ static const char *const sector_opt[] = {
"camsec",
"lines",
"ffloors",
#ifdef ESLOPE
"f_slope",
"c_slope",
#endif
NULL};
enum subsector_e {
@ -175,10 +167,8 @@ enum ffloor_e {
ffloor_toplightlevel,
ffloor_bottomheight,
ffloor_bottompic,
#ifdef ESLOPE
ffloor_tslope,
ffloor_bslope,
#endif
ffloor_sector,
ffloor_flags,
ffloor_master,
@ -195,10 +185,8 @@ static const char *const ffloor_opt[] = {
"toplightlevel",
"bottomheight",
"bottompic",
#ifdef ESLOPE
"t_slope",
"b_slope",
#endif
"sector", // secnum pushed as control sector userdata
"flags",
"master", // control linedef
@ -208,7 +196,6 @@ static const char *const ffloor_opt[] = {
"alpha",
NULL};
#ifdef ESLOPE
enum slope_e {
slope_valid = 0,
slope_o,
@ -247,7 +234,6 @@ static const char *const vector_opt[] = {
"y",
"z",
NULL};
#endif
static const char *const array_opt[] ={"iterate",NULL};
static const char *const valid_opt[] ={"valid",NULL};
@ -463,14 +449,12 @@ static int sector_get(lua_State *L)
LUA_PushUserdata(L, sector->ffloors, META_FFLOOR);
lua_pushcclosure(L, sector_iterate, 2); // push lib_iterateFFloors and sector->ffloors as upvalues for the function
return 1;
#ifdef ESLOPE
case sector_fslope: // f_slope
LUA_PushUserdata(L, sector->f_slope, META_SLOPE);
return 1;
case sector_cslope: // c_slope
LUA_PushUserdata(L, sector->c_slope, META_SLOPE);
return 1;
#endif
}
return 0;
}
@ -495,10 +479,8 @@ static int sector_set(lua_State *L)
case sector_heightsec: // heightsec
case sector_camsec: // camsec
case sector_ffloors: // ffloors
#ifdef ESLOPE
case sector_fslope: // f_slope
case sector_cslope: // c_slope
#endif
default:
return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]);
case sector_floorheight: { // floorheight
@ -1134,14 +1116,12 @@ static int ffloor_get(lua_State *L)
lua_pushlstring(L, levelflat->name, i);
return 1;
}
#ifdef ESLOPE
case ffloor_tslope:
LUA_PushUserdata(L, *ffloor->t_slope, META_SLOPE);
return 1;
case ffloor_bslope:
LUA_PushUserdata(L, *ffloor->b_slope, META_SLOPE);
return 1;
#endif
case ffloor_sector:
LUA_PushUserdata(L, &sectors[ffloor->secnum], META_SECTOR);
return 1;
@ -1183,10 +1163,8 @@ static int ffloor_set(lua_State *L)
switch(field)
{
case ffloor_valid: // valid
#ifdef ESLOPE
case ffloor_tslope: // t_slope
case ffloor_bslope: // b_slope
#endif
case ffloor_sector: // sector
case ffloor_master: // master
case ffloor_target: // target
@ -1247,7 +1225,6 @@ static int ffloor_set(lua_State *L)
return 0;
}
#ifdef ESLOPE
static int slope_get(lua_State *L)
{
pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE));
@ -1422,7 +1399,6 @@ static int vector3_get(lua_State *L)
return 0;
}
#endif
static int lib_getMapheaderinfo(lua_State *L)
{
@ -1614,7 +1590,6 @@ int LUA_MapLib(lua_State *L)
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
#ifdef ESLOPE
luaL_newmetatable(L, META_SLOPE);
lua_pushcfunction(L, slope_get);
lua_setfield(L, -2, "__index");
@ -1632,7 +1607,6 @@ int LUA_MapLib(lua_State *L)
lua_pushcfunction(L, vector3_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
#endif
luaL_newmetatable(L, META_MAPHEADER);
lua_pushcfunction(L, mapheaderinfo_get);

View File

@ -82,9 +82,7 @@ enum mobj_e {
mobj_extravalue2,
mobj_cusval,
mobj_cvmem,
#ifdef ESLOPE
mobj_standingslope,
#endif
mobj_colorized
};
@ -145,9 +143,7 @@ static const char *const mobj_opt[] = {
"extravalue2",
"cusval",
"cvmem",
#ifdef ESLOPE
"standingslope",
#endif
"colorized",
NULL};
@ -352,11 +348,9 @@ static int mobj_get(lua_State *L)
case mobj_cvmem:
lua_pushinteger(L, mo->cvmem);
break;
#ifdef ESLOPE
case mobj_standingslope:
LUA_PushUserdata(L, mo->standingslope, META_SLOPE);
break;
#endif
case mobj_colorized:
lua_pushboolean(L, mo->colorized);
break;
@ -670,10 +664,8 @@ static int mobj_set(lua_State *L)
case mobj_cvmem:
mo->cvmem = luaL_checkinteger(L, 3);
break;
#ifdef ESLOPE
case mobj_standingslope:
return NOSET;
#endif
case mobj_colorized:
mo->colorized = luaL_checkboolean(L, 3);
break;

View File

@ -17,6 +17,7 @@
#include "d_player.h"
#include "g_game.h"
#include "p_local.h"
#include "d_clisrv.h"
#include "lua_script.h"
#include "lua_libs.h"
@ -118,7 +119,7 @@ static int lib_iterateDisplayplayers(lua_State *L)
for (i++; i < MAXSPLITSCREENPLAYERS; i++)
{
if (!playeringame[displayplayers[i]] || i > splitscreen)
if (i > splitscreen || !playeringame[displayplayers[i]])
return 0; // Stop! There are no more players for us to go through. There will never be a player gap in displayplayers.
if (!players[displayplayers[i]].mo)
@ -139,6 +140,8 @@ static int lib_getDisplayplayers(lua_State *L)
lua_Integer i = luaL_checkinteger(L, 2);
if (i < 0 || i >= MAXSPLITSCREENPLAYERS)
return luaL_error(L, "displayplayers[] index %d out of range (0 - %d)", i, MAXSPLITSCREENPLAYERS-1);
if (i > splitscreen)
return 0;
if (!playeringame[displayplayers[i]])
return 0;
if (!players[displayplayers[i]].mo)
@ -385,6 +388,8 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"fovadd"))
lua_pushfixed(L, plr->fovadd);
#endif
else if (fastcmp(field,"ping"))
lua_pushinteger(L, playerpingtable[( plr - players )]);
else {
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
I_Assert(lua_istable(L, -1));

View File

@ -22,9 +22,7 @@
#include "byteptr.h"
#include "p_saveg.h"
#include "p_local.h"
#ifdef ESLOPE
#include "p_slopes.h" // for P_SlopeById
#endif
#ifdef LUA_ALLOW_BYTECODE
#include "d_netfil.h" // for LUA_DumpFile
#endif
@ -472,9 +470,7 @@ enum
ARCH_SIDE,
ARCH_SUBSECTOR,
ARCH_SECTOR,
#ifdef ESLOPE
ARCH_SLOPE,
#endif
ARCH_MAPHEADER,
ARCH_TEND=0xFF,
@ -494,9 +490,7 @@ static const struct {
{META_SIDE, ARCH_SIDE},
{META_SUBSECTOR,ARCH_SUBSECTOR},
{META_SECTOR, ARCH_SECTOR},
#ifdef ESLOPE
{META_SLOPE, ARCH_SLOPE},
#endif
{META_MAPHEADER, ARCH_MAPHEADER},
{NULL, ARCH_NULL}
};
@ -701,7 +695,6 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex)
}
break;
}
#ifdef ESLOPE
case ARCH_SLOPE:
{
pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex));
@ -713,7 +706,6 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex)
}
break;
}
#endif
case ARCH_MAPHEADER:
{
mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex));
@ -915,7 +907,6 @@ static UINT8 ArchiveValueDemo(int TABLESINDEX, int myindex)
}
break;
}
#ifdef ESLOPE
case ARCH_SLOPE:
{
pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex));
@ -927,7 +918,6 @@ static UINT8 ArchiveValueDemo(int TABLESINDEX, int myindex)
}
break;
}
#endif
case ARCH_MAPHEADER:
{
mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex));
@ -1233,11 +1223,9 @@ static UINT8 UnArchiveValue(int TABLESINDEX)
case ARCH_SECTOR:
LUA_PushUserdata(gL, &sectors[READUINT16(save_p)], META_SECTOR);
break;
#ifdef ESLOPE
case ARCH_SLOPE:
LUA_PushUserdata(gL, P_SlopeById(READUINT16(save_p)), META_SLOPE);
break;
#endif
case ARCH_MAPHEADER:
LUA_PushUserdata(gL, mapheaderinfo[READUINT16(save_p)], META_MAPHEADER);
break;
@ -1336,11 +1324,9 @@ static UINT8 UnArchiveValueDemo(int TABLESINDEX, char field[1024])
case ARCH_SECTOR:
LUA_PushUserdata(gL, &sectors[READUINT16(demo_p)], META_SECTOR);
break;
#ifdef ESLOPE
case ARCH_SLOPE:
LUA_PushUserdata(gL, P_SlopeById(READUINT16(demo_p)), META_SLOPE);
break;
#endif
case ARCH_MAPHEADER:
LUA_PushUserdata(gL, mapheaderinfo[READUINT16(demo_p)], META_MAPHEADER);
break;

View File

@ -16,6 +16,7 @@
#include "doomdef.h"
#include "command.h"
#include "m_argv.h"
#include "m_misc.h"
/** \brief number of arg
*/
@ -166,7 +167,7 @@ void M_FindResponseFile(void)
if (!file)
I_Error("No more free memory for the response file");
if (fread(file, size, 1, handle) != 1)
I_Error("Couldn't read response file because %s", strerror(ferror(handle)));
I_Error("Couldn't read response file because %s", M_FileError(handle));
fclose(handle);
// keep all the command line arguments following @responsefile

View File

@ -862,13 +862,9 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling)
if (ceiling)
{
#ifdef ESLOPE
// Truncate position to match where mapthing would be when spawned
// (this applies to every further P_GetZAt call as well)
fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight;
#else
fixed_t cheight = sec->ceilingheight;
#endif
if (((cheight - player->mo->z - player->mo->height)>>FRACBITS) >= (1 << (16-ZSHIFT)))
{
@ -879,11 +875,7 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling)
}
else
{
#ifdef ESLOPE
fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight;
#else
fixed_t fheight = sec->floorheight;
#endif
if (((player->mo->z - fheight)>>FRACBITS) >= (1 << (16-ZSHIFT)))
{
CONS_Printf(M_GetText("Sorry, you're too %s to place this object (max: %d %s).\n"), M_GetText("high"),
@ -931,20 +923,12 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c
mt->y = (INT16)(player->mo->y>>FRACBITS);
if (ceiling)
{
#ifdef ESLOPE
fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->ceilingheight;
#else
fixed_t cheight = sec->ceilingheight;
#endif
mt->options = (UINT16)((cheight - player->mo->z - player->mo->height)>>FRACBITS);
}
else
{
#ifdef ESLOPE
fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->floorheight;
#else
fixed_t fheight = sec->floorheight;
#endif
mt->options = (UINT16)((player->mo->z - fheight)>>FRACBITS);
}
mt->options <<= ZSHIFT;
@ -1001,11 +985,7 @@ void OP_NightsObjectplace(player_t *player)
UINT16 angle = (UINT16)(player->anotherflyangle % 360);
INT16 temp = (INT16)FixedInt(AngleFixed(player->mo->angle)); // Traditional 2D Angle
sector_t *sec = player->mo->subsector->sector;
#ifdef ESLOPE
fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight;
#else
fixed_t fheight = sec->floorheight;
#endif
player->pflags |= PF_ATTACKDOWN;
@ -1162,20 +1142,12 @@ void OP_ObjectplaceMovement(player_t *player)
if (!!(mobjinfo[op_currentthing].flags & MF_SPAWNCEILING) ^ !!(cv_opflags.value & MTF_OBJECTFLIP))
{
#ifdef ESLOPE
fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight;
#else
fixed_t cheight = sec->ceilingheight;
#endif
op_displayflags = (UINT16)((cheight - player->mo->z - mobjinfo[op_currentthing].height)>>FRACBITS);
}
else
{
#ifdef ESLOPE
fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight;
#else
fixed_t fheight = sec->floorheight;
#endif
op_displayflags = (UINT16)((player->mo->z - fheight)>>FRACBITS);
}
op_displayflags <<= ZSHIFT;

View File

@ -32,6 +32,7 @@
#include "sounds.h"
#include "s_sound.h"
#include "i_system.h"
#include "i_threads.h"
// Addfile
#include "filesrch.h"
@ -80,6 +81,11 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap);
#endif
#ifdef HAVE_DISCORDRPC
//#include "discord_rpc.h"
#include "discord.h"
#endif
#define SKULLXOFF -32
#define LINEHEIGHT 16
#define STRINGHEIGHT 8
@ -118,6 +124,12 @@ typedef enum
NUM_QUITMESSAGES
} text_enum;
#ifdef HAVE_THREADS
I_mutex m_menu_mutex;
#endif
M_waiting_mode_t m_waiting_mode = M_NOT_WAITING;
const char *quitmsg[NUM_QUITMESSAGES];
// Stuff for customizing the player select screen Tails 09-22-2003
@ -181,6 +193,12 @@ static void M_RoomMenu(INT32 choice);
// the haxor message menu
menu_t MessageDef;
#ifdef HAVE_DISCORDRPC
menu_t MISC_DiscordRequestsDef;
static void M_HandleDiscordRequests(INT32 choice);
static void M_DrawDiscordRequests(void);
#endif
menu_t SPauseDef;
#define lsheadingheight 16
@ -286,6 +304,9 @@ menu_t OP_SoundOptionsDef;
//Misc
menu_t OP_DataOptionsDef, OP_ScreenshotOptionsDef, OP_EraseDataDef;
#ifdef HAVE_DISCORDRPC
menu_t OP_DiscordOptionsDef;
#endif
menu_t OP_HUDOptionsDef, OP_ChatOptionsDef;
menu_t OP_GameOptionsDef, OP_ServerOptionsDef;
#ifndef NONET
@ -578,6 +599,10 @@ static menuitem_t MPauseMenu[] =
{IT_STRING | IT_SUBMENU, NULL, "Scramble Teams...", &MISC_ScrambleTeamDef, 16},
{IT_STRING | IT_CALL, NULL, "Switch Map..." , M_MapChange, 24},
#ifdef HAVE_DISCORDRPC
{IT_STRING | IT_SUBMENU, NULL, "Ask To Join Requests...", &MISC_DiscordRequestsDef, 24},
#endif
{IT_CALL | IT_STRING, NULL, "Continue", M_SelectableClearMenus, 40},
{IT_CALL | IT_STRING, NULL, "P1 Setup...", M_SetupMultiPlayer, 48}, // splitscreen
{IT_CALL | IT_STRING, NULL, "P2 Setup...", M_SetupMultiPlayer2, 56}, // splitscreen
@ -601,6 +626,9 @@ typedef enum
mpause_addons = 0,
mpause_scramble,
mpause_switchmap,
#ifdef HAVE_DISCORDRPC
mpause_discordrequests,
#endif
mpause_continue,
mpause_psetupsplit,
@ -651,6 +679,13 @@ typedef enum
spause_quit
} spause_e;
#ifdef HAVE_DISCORDRPC
static menuitem_t MISC_DiscordRequestsMenu[] =
{
{IT_KEYHANDLER|IT_NOTHING, NULL, "", M_HandleDiscordRequests, 0},
};
#endif
// -----------------
// Misc menu options
// -----------------
@ -1039,7 +1074,7 @@ enum
FIRSTSERVERLINE
};
static menuitem_t MP_RoomMenu[] =
menuitem_t MP_RoomMenu[] =
{
{IT_STRING | IT_CALL, NULL, "<Offline Mode>", M_ChooseRoom, 9},
{IT_DISABLED, NULL, "", M_ChooseRoom, 18},
@ -1336,11 +1371,17 @@ static menuitem_t OP_SoundOptionsMenu[] =
static menuitem_t OP_DataOptionsMenu[] =
{
{IT_STRING | IT_CALL, NULL, "Screenshot Options...", M_ScreenshotOptions, 10},
{IT_STRING | IT_CALL, NULL, "Addon Options...", M_AddonsOptions, 20},
{IT_STRING | IT_SUBMENU, NULL, "Replay Options...", &MISC_ReplayOptionsDef, 30},
#ifdef HAVE_DISCORDRPC
{IT_STRING | IT_SUBMENU, NULL, "Discord Options...", &OP_DiscordOptionsDef, 40},
{IT_STRING | IT_SUBMENU, NULL, "Erase Data...", &OP_EraseDataDef, 60},
#else
{IT_STRING | IT_SUBMENU, NULL, "Erase Data...", &OP_EraseDataDef, 50},
#endif
};
static menuitem_t OP_ScreenshotOptionsMenu[] =
@ -1389,7 +1430,7 @@ static menuitem_t OP_AddonsOptionsMenu[] =
{IT_HEADER, NULL, "Menu", NULL, 0},
{IT_STRING|IT_CVAR, NULL, "Location", &cv_addons_option, 10},
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_addons_folder, 20},
{IT_STRING|IT_CVAR, NULL, "Identify addons via", &cv_addons_md5, 48},
{IT_STRING|IT_CVAR, NULL, "Identify addons via", &cv_addons_md5, 48},
{IT_STRING|IT_CVAR, NULL, "Show unsupported file types", &cv_addons_showall, 58},
{IT_HEADER, NULL, "Search", NULL, 76},
@ -1402,6 +1443,19 @@ enum
op_addons_folder = 2,
};
#ifdef HAVE_DISCORDRPC
static menuitem_t OP_DiscordOptionsMenu[] =
{
{IT_STRING | IT_CVAR, NULL, "Rich Presence", &cv_discordrp, 10},
{IT_HEADER, NULL, "Rich Presence Settings", NULL, 30},
{IT_STRING | IT_CVAR, NULL, "Streamer Mode", &cv_discordstreamer, 40},
{IT_STRING | IT_CVAR, NULL, "Allow Ask To Join", &cv_discordasks, 60},
{IT_STRING | IT_CVAR, NULL, "Allow Invites", &cv_discordinvites, 70},
};
#endif
static menuitem_t OP_HUDOptionsMenu[] =
{
{IT_STRING | IT_CVAR, NULL, "Show HUD (F3)", &cv_showhud, 10},
@ -1642,6 +1696,19 @@ menu_t MAPauseDef = PAUSEMENUSTYLE(MAPauseMenu, 40, 72);
menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72);
menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72);
#ifdef HAVE_DISCORDRPC
menu_t MISC_DiscordRequestsDef = {
NULL,
sizeof (MISC_DiscordRequestsMenu)/sizeof (menuitem_t),
&MPauseDef,
MISC_DiscordRequestsMenu,
M_DrawDiscordRequests,
0, 0,
0,
NULL
};
#endif
// Misc Main Menu
menu_t MISC_ScrambleTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ScrambleTeamMenu, &MPauseDef, 27, 40);
menu_t MISC_ChangeTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeTeamMenu, &MPauseDef, 27, 40);
@ -2068,6 +2135,9 @@ menu_t OP_OpenGLColorDef =
menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30);
menu_t OP_ScreenshotOptionsDef = DEFAULTMENUSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30);
menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30);
#ifdef HAVE_DISCORDRPC
menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_DataOptionsDef, 30, 30);
#endif
menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30);
// ==========================================================================
@ -2896,7 +2966,6 @@ boolean M_Responder(event_t *ev)
//make sure the game doesn't still think we're in a netgame.
if (!Playing() && netgame && multiplayer)
{
MSCloseUDPSocket(); // Clean up so we can re-open the connection later.
netgame = false;
multiplayer = false;
}
@ -3188,12 +3257,18 @@ void M_StartControlPanel(void)
MPauseMenu[mpause_psetup].status = IT_DISABLED;
MISC_ChangeTeamMenu[0].status = IT_DISABLED;
MISC_ChangeSpectateMenu[0].status = IT_DISABLED;
// Reset these in case splitscreen messes things up
MPauseMenu[mpause_addons].alphaKey = 8;
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;
Dummymenuplayer_OnChange();
if ((server || IsPlayerAdmin(consoleplayer)))
@ -3265,6 +3340,19 @@ void M_StartControlPanel(void)
MPauseMenu[mpause_spectate].status = IT_GRAYEDOUT;
}
#ifdef HAVE_DISCORDRPC
{
UINT8 i;
for (i = 0; i < mpause_discordrequests; i++)
MPauseMenu[i].alphaKey -= 8;
MPauseMenu[mpause_discordrequests].alphaKey = MPauseMenu[i].alphaKey;
M_RefreshPauseMenu();
}
#endif
currentMenu = &MPauseDef;
itemOn = mpause_continue;
}
@ -3304,6 +3392,30 @@ void M_SetupNextMenu(menu_t *menudef)
{
INT16 i;
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
if (currentMenu == &MP_RoomDef || currentMenu == &MP_ConnectDef)
{
I_lock_mutex(&ms_QueryId_mutex);
{
ms_QueryId++;
}
I_unlock_mutex(ms_QueryId_mutex);
}
if (currentMenu == &MP_ConnectDef)
{
I_lock_mutex(&ms_ServerList_mutex);
{
if (ms_ServerList)
{
free(ms_ServerList);
ms_ServerList = NULL;
}
}
I_unlock_mutex(ms_ServerList_mutex);
}
#endif/*HAVE_THREADS*/
if (currentMenu->quitroutine)
{
// If you're going from a menu to itself, why are you running the quitroutine? You're not quitting it! -SH
@ -3361,6 +3473,19 @@ void M_Ticker(void)
if (--vidm_testingmode == 0)
setmodeneeded = vidm_previousmode + 1;
}
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
I_lock_mutex(&ms_ServerList_mutex);
{
if (ms_ServerList)
{
CL_QueryServerList(ms_ServerList);
free(ms_ServerList);
ms_ServerList = NULL;
}
}
I_unlock_mutex(ms_ServerList_mutex);
#endif
}
//
@ -4055,6 +4180,25 @@ static void M_DrawPauseMenu(void)
}
#endif
#ifdef HAVE_DISCORDRPC
// kind of hackily baked in here
if (currentMenu == &MPauseDef && discordRequestList != NULL)
{
const tic_t freq = TICRATE/2;
if ((leveltime % freq) >= freq/2)
{
V_DrawFixedPatch(204 * FRACUNIT,
(currentMenu->y + MPauseMenu[mpause_discordrequests].alphaKey - 1) * FRACUNIT,
FRACUNIT,
0,
W_CachePatchName("K_REQUE2", PU_CACHE),
NULL
);
}
}
#endif
M_DrawGenericMenu();
}
@ -4833,7 +4977,7 @@ static boolean M_AddonsRefresh(void)
else if (majormods && !prevmajormods)
{
S_StartSound(NULL, sfx_s221);
message = va("%c%s\x80\nGameplay has now been modified.\nIf you wish to play Record Attack mode, restart the game to clear existing addons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname);
message = va("%c%s\x80\nYou've loaded a gameplay-modifying addon.\n\nRecord Attack has been disabled, but you\ncan still play alone in local Multiplayer.\n\nIf you wish to play Record Attack mode, restart the game to disable loaded addons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname);
prevmajormods = majormods;
}
@ -6178,7 +6322,12 @@ static void M_Options(INT32 choice)
OP_MainMenu[4].status = OP_MainMenu[5].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU);
OP_MainMenu[8].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // Play credits
#ifdef HAVE_DISCORDRPC
OP_DataOptionsMenu[4].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); // Erase data
#else
OP_DataOptionsMenu[3].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); // Erase data
#endif
OP_GameOptionsMenu[3].status =
(M_SecretUnlocked(SECRET_ENCORE)) ? (IT_CVAR|IT_STRING) : IT_SECRET; // cv_kartencore
@ -6219,6 +6368,20 @@ static void M_SelectableClearMenus(INT32 choice)
M_ClearMenus(true);
}
void M_RefreshPauseMenu(void)
{
#ifdef HAVE_DISCORDRPC
if (discordRequestList != NULL)
{
MPauseMenu[mpause_discordrequests].status = IT_STRING | IT_SUBMENU;
}
else
{
MPauseMenu[mpause_discordrequests].status = IT_GRAYEDOUT;
}
#endif
}
// ======
// CHEATS
// ======
@ -7417,7 +7580,7 @@ static void M_DrawStatsMaps(int location)
else
V_DrawString(20, y, 0, va("%s %s %s",
mapheaderinfo[mnum]->lvlttl,
(mapheaderinfo[mnum]->zonttl[0] ? mapheaderinfo[mnum]->zonttl : "ZONE"),
(mapheaderinfo[mnum]->zonttl[0] ? mapheaderinfo[mnum]->zonttl : "Zone"),
mapheaderinfo[mnum]->actnum));
y += 8;
@ -8327,22 +8490,65 @@ static INT32 menuRoomIndex = 0;
static void M_DrawRoomMenu(void)
{
static int frame = -12;
int dot_frame;
char text[4];
const char *rmotd;
const char *waiting_message;
int dots;
if (m_waiting_mode)
{
dot_frame = frame / 4;
dots = dot_frame + 3;
strcpy(text, " ");
if (dots > 0)
{
if (dot_frame < 0)
dot_frame = 0;
strncpy(&text[dot_frame], "...", min(dots, 3 - dot_frame));
}
if (++frame == 12)
frame = -12;
currentMenu->menuitems[0].text = text;
}
// use generic drawer for cursor, items and title
M_DrawGenericMenu();
V_DrawString(currentMenu->x - 16, currentMenu->y, highlightflags, M_GetText("Select a room"));
M_DrawTextBox(144, 24, 20, 20);
if (m_waiting_mode == M_NOT_WAITING)
{
M_DrawTextBox(144, 24, 20, 20);
if (itemOn == 0)
rmotd = M_GetText("Don't connect to the Master Server.");
else
rmotd = room_list[itemOn-1].motd;
if (itemOn == 0)
rmotd = M_GetText("Don't connect to the Master Server.");
else
rmotd = room_list[itemOn-1].motd;
rmotd = V_WordWrap(0, 20*8, 0, rmotd);
V_DrawString(144+8, 32, V_ALLOWLOWERCASE|V_RETURN8, rmotd);
rmotd = V_WordWrap(0, 20*8, 0, rmotd);
V_DrawString(144+8, 32, V_ALLOWLOWERCASE|V_RETURN8, rmotd);
}
if (m_waiting_mode)
{
// Display a little "please wait" message.
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
if (m_waiting_mode == M_WAITING_VERSION)
waiting_message = "Checking for updates...";
else
waiting_message = "Fetching room info...";
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, waiting_message);
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
}
}
static void M_DrawConnectMenu(void)
@ -8416,6 +8622,14 @@ static void M_DrawConnectMenu(void)
localservercount = serverlistcount;
M_DrawGenericMenu();
if (m_waiting_mode)
{
// Display a little "please wait" message.
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Searching for servers...");
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
}
}
static boolean M_CancelConnect(void)
@ -8497,10 +8711,10 @@ void M_SortServerList(void)
#ifndef NONET
#ifdef UPDATE_ALERT
static boolean M_CheckMODVersion(void)
static boolean M_CheckMODVersion(int id)
{
char updatestring[500];
const char *updatecheck = GetMODVersion();
const char *updatecheck = GetMODVersion(id);
if(updatecheck)
{
sprintf(updatestring, UPDATE_ALERT_STRING, VERSIONSTRING, updatecheck);
@ -8509,7 +8723,64 @@ static boolean M_CheckMODVersion(void)
} else
return true;
}
#endif/*UPDATE_ALERT*/
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
static void
Check_new_version_thread (int *id)
{
int hosting;
int okay;
okay = 0;
#ifdef UPDATE_ALERT
if (M_CheckMODVersion(*id))
#endif
{
I_lock_mutex(&ms_QueryId_mutex);
{
okay = ( *id == ms_QueryId );
}
I_unlock_mutex(ms_QueryId_mutex);
if (okay)
{
I_lock_mutex(&m_menu_mutex);
{
m_waiting_mode = M_WAITING_ROOMS;
hosting = ( currentMenu->prevMenu == &MP_ServerDef );
}
I_unlock_mutex(m_menu_mutex);
GetRoomsList(hosting, *id);
}
}
else
{
I_lock_mutex(&ms_QueryId_mutex);
{
okay = ( *id == ms_QueryId );
}
I_unlock_mutex(ms_QueryId_mutex);
}
if (okay)
{
I_lock_mutex(&m_menu_mutex);
{
if (m_waiting_mode)
{
m_waiting_mode = M_NOT_WAITING;
MP_RoomMenu[0].text = "<Offline Mode>";
}
}
I_unlock_mutex(m_menu_mutex);
}
free(id);
}
#endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
static void M_ConnectMenu(INT32 choice)
{
@ -8538,18 +8809,21 @@ static void M_ConnectMenuModChecks(INT32 choice)
if (modifiedgame)
{
M_StartMessage(M_GetText("Addons are currently loaded.\n\nYou will only be able to join a server if\nit has the same ones loaded in the same order, which may be unlikely.\n\nIf you wish to play on other servers,\nrestart the game to clear existing addons.\n\n(Press a key)\n"),M_ConnectMenu,MM_EVENTHANDLER);
M_StartMessage(M_GetText("You have addons loaded.\nYou won't be able to join netgames!\n\nTo play online, restart the game\nand don't load any addons.\nSRB2Kart will automatically add\neverything you need when you join.\n\n(Press a key)\n"),M_ConnectMenu,MM_EVENTHANDLER);
return;
}
M_ConnectMenu(-1);
}
static UINT32 roomIds[NUM_LIST_ROOMS];
UINT32 roomIds[NUM_LIST_ROOMS];
static void M_RoomMenu(INT32 choice)
{
INT32 i;
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
int *id;
#endif
(void)choice;
@ -8562,34 +8836,54 @@ static void M_RoomMenu(INT32 choice)
if (rendermode == render_soft)
I_FinishUpdate(); // page flip or blit buffer
if (GetRoomsList(currentMenu == &MP_ServerDef) < 0)
return;
#ifdef UPDATE_ALERT
if (!M_CheckMODVersion())
return;
#endif
for (i = 1; i < NUM_LIST_ROOMS+1; ++i)
MP_RoomMenu[i].status = IT_DISABLED;
memset(roomIds, 0, sizeof(roomIds));
for (i = 0; room_list[i].header.buffer[0]; i++)
{
if(*room_list[i].name != '\0')
{
MP_RoomMenu[i+1].text = room_list[i].name;
roomIds[i] = room_list[i].id;
MP_RoomMenu[i+1].status = IT_STRING|IT_CALL;
}
}
MP_RoomDef.prevMenu = currentMenu;
M_SetupNextMenu(&MP_RoomDef);
#ifdef MASTERSERVER
#ifdef HAVE_THREADS
#ifdef UPDATE_ALERT
m_waiting_mode = M_WAITING_VERSION;
#else/*UPDATE_ALERT*/
m_waiting_mode = M_WAITING_ROOMS;
#endif/*UPDATE_ALERT*/
MP_RoomMenu[0].text = "";
id = malloc(sizeof *id);
I_lock_mutex(&ms_QueryId_mutex);
{
*id = ms_QueryId;
}
I_unlock_mutex(ms_QueryId_mutex);
I_spawn_thread("check-new-version",
(I_thread_fn)Check_new_version_thread, id);
#else/*HAVE_THREADS*/
#ifdef UPDATE_ALERT
if (M_CheckMODVersion(0))
#endif/*UPDATE_ALERT*/
{
GetRoomsList(currentMenu->prevMenu == &MP_ServerDef, 0);
}
#endif/*HAVE_THREADS*/
#endif/*MASTERSERVER*/
}
static void M_ChooseRoom(INT32 choice)
{
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
I_lock_mutex(&ms_QueryId_mutex);
{
ms_QueryId++;
}
I_unlock_mutex(ms_QueryId_mutex);
#endif
if (choice == 0)
ms_RoomId = -1;
else
@ -11089,3 +11383,161 @@ static void M_OGL_DrawColorMenu(void)
highlightflags, "Gamma correction");
}
#endif
#ifdef HAVE_DISCORDRPC
static const tic_t confirmLength = 3*TICRATE/4;
static tic_t confirmDelay = 0;
static boolean confirmAccept = false;
static void M_HandleDiscordRequests(INT32 choice)
{
if (confirmDelay > 0)
return;
switch (choice)
{
case KEY_ENTER:
Discord_Respond(discordRequestList->userID, DISCORD_REPLY_YES);
confirmAccept = true;
confirmDelay = confirmLength;
S_StartSound(NULL, sfx_s3k63);
break;
case KEY_ESCAPE:
Discord_Respond(discordRequestList->userID, DISCORD_REPLY_NO);
confirmAccept = false;
confirmDelay = confirmLength;
S_StartSound(NULL, sfx_s3kb2);
break;
}
}
static const char *M_GetDiscordName(discordRequest_t *r)
{
if (r == NULL)
return "";
if (cv_discordstreamer.value)
return r->username;
return va("%s#%s", r->username, r->discriminator);
}
// (this goes in k_hud.c when merged into v2)
static void M_DrawSticker(INT32 x, INT32 y, INT32 width, INT32 flags, boolean small)
{
patch_t *stickerEnd;
INT32 height;
if (small == true)
{
stickerEnd = W_CachePatchName("K_STIKE2", PU_CACHE);
height = 6;
}
else
{
stickerEnd = W_CachePatchName("K_STIKEN", PU_CACHE);
height = 11;
}
V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT, flags, stickerEnd, NULL);
V_DrawFill(x, y, width, height, 24|flags);
V_DrawFixedPatch((x + width)*FRACUNIT, y*FRACUNIT, FRACUNIT, flags|V_FLIP, stickerEnd, NULL);
}
static void M_DrawDiscordRequests(void)
{
discordRequest_t *curRequest = discordRequestList;
UINT8 *colormap;
patch_t *hand = NULL;
boolean removeRequest = false;
const char *wantText = "...would like to join!";
const char *controlText = "\x82" "ENTER" "\x80" " - Accept " "\x82" "ESC" "\x80" " - Decline";
INT32 x = 100;
INT32 y = 133;
INT32 slide = 0;
INT32 maxYSlide = 18;
if (confirmDelay > 0)
{
if (confirmAccept == true)
{
colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GREEN, GTC_MENUCACHE);
hand = W_CachePatchName("K_LAPH02", PU_CACHE);
}
else
{
colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_RED, GTC_MENUCACHE);
hand = W_CachePatchName("K_LAPH03", PU_CACHE);
}
slide = confirmLength - confirmDelay;
confirmDelay--;
if (confirmDelay == 0)
removeRequest = true;
}
else
{
colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GREY, GTC_MENUCACHE);
}
V_DrawFixedPatch(56*FRACUNIT, 150*FRACUNIT, FRACUNIT, 0, W_CachePatchName("K_LAPE01", PU_CACHE), colormap);
if (hand != NULL)
{
fixed_t handoffset = (4 - abs((signed)(skullAnimCounter - 4))) * FRACUNIT;
V_DrawFixedPatch(56*FRACUNIT, 150*FRACUNIT + handoffset, FRACUNIT, 0, hand, NULL);
}
M_DrawSticker(x + (slide * 32), y - 1, V_ThinStringWidth(M_GetDiscordName(curRequest), V_ALLOWLOWERCASE|V_6WIDTHSPACE), 0, false);
V_DrawThinString(x + (slide * 32), y, V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_YELLOWMAP, M_GetDiscordName(curRequest));
M_DrawSticker(x, y + 12, V_ThinStringWidth(wantText, V_ALLOWLOWERCASE|V_6WIDTHSPACE), 0, true);
V_DrawThinString(x, y + 10, V_ALLOWLOWERCASE|V_6WIDTHSPACE, wantText);
M_DrawSticker(x, y + 26, V_ThinStringWidth(controlText, V_ALLOWLOWERCASE|V_6WIDTHSPACE), 0, true);
V_DrawThinString(x, y + 24, V_ALLOWLOWERCASE|V_6WIDTHSPACE, controlText);
y -= 18;
while (curRequest->next != NULL)
{
INT32 ySlide = min(slide * 4, maxYSlide);
curRequest = curRequest->next;
M_DrawSticker(x, y - 1 + ySlide, V_ThinStringWidth(M_GetDiscordName(curRequest), V_ALLOWLOWERCASE|V_6WIDTHSPACE), 0, false);
V_DrawThinString(x, y + ySlide, V_ALLOWLOWERCASE|V_6WIDTHSPACE, M_GetDiscordName(curRequest));
y -= 12;
maxYSlide = 12;
}
if (removeRequest == true)
{
DRPC_RemoveRequest(discordRequestList);
if (discordRequestList == NULL)
{
// No other requests
MPauseMenu[mpause_discordrequests].status = IT_GRAYEDOUT;
if (currentMenu->prevMenu)
{
M_SetupNextMenu(currentMenu->prevMenu);
if (currentMenu == &MPauseDef)
itemOn = mpause_continue;
}
else
M_ClearMenus(true);
return;
}
}
}
#endif

View File

@ -17,6 +17,8 @@
#include "d_event.h"
#include "command.h"
#include "i_threads.h"
#include "mserv.h"
#include "r_things.h" // for SKINNAMESIZE
//
@ -72,6 +74,18 @@ typedef enum
} menumessagetype_t;
void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtype);
typedef enum
{
M_NOT_WAITING,
M_WAITING_VERSION,
M_WAITING_ROOMS,
M_WAITING_SERVERS,
}
M_waiting_mode_t;
extern M_waiting_mode_t m_waiting_mode;
// Called by linux_x/i_video_xshm.c
void M_QuitResponse(INT32 ch);
@ -161,6 +175,9 @@ typedef struct menuitem_s
extern menuitem_t PlayerMenu[MAXSKINS];
extern menuitem_t MP_RoomMenu[];
extern UINT32 roomIds[NUM_LIST_ROOMS];
typedef struct menu_s
{
const char *menutitlepic;
@ -176,6 +193,10 @@ typedef struct menu_s
void M_SetupNextMenu(menu_t *menudef);
void M_ClearMenus(boolean callexitmenufunc);
#ifdef HAVE_THREADS
extern I_mutex m_menu_mutex;
#endif
extern menu_t *currentMenu;
extern menu_t MainDef;
@ -246,6 +267,8 @@ void Addons_option_Onchange(void);
void M_ReplayHut(INT32 choice);
void M_SetPlaybackMenuPointer(void);
void M_RefreshPauseMenu(void);
INT32 HU_GetHighlightColor(void);
// These defines make it a little easier to make menus

View File

@ -23,6 +23,8 @@
#include <unistd.h>
#endif
#include <errno.h>
// Extended map support.
#include <ctype.h>
@ -2363,3 +2365,13 @@ void M_SetupMemcpy(void)
M_Memcpy = cpu_cpy;
#endif
}
/** Return the appropriate message for a file error or end of file.
*/
const char *M_FileError(FILE *fp)
{
if (ferror(fp))
return strerror(errno);
else
return "end-of-file";
}

View File

@ -100,6 +100,8 @@ void strcatbf(char *s1, const char *s2, const char *s3);
void M_SetupMemcpy(void);
const char *M_FileError(FILE *handle);
// counting bits, for weapon ammo code, usually
FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size);

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
//-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 2020 by James R.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@ -13,7 +14,7 @@
#ifndef _MSERV_H_
#define _MSERV_H_
#define MASTERSERVERS21 // MasterServer v2.1
#include "i_threads.h"
// lowered from 32 due to menu changes
#define NUM_LIST_ROOMS 16
@ -64,33 +65,47 @@ typedef struct
// ================================ GLOBALS ===============================
extern consvar_t cv_masterserver, cv_servername;
extern consvar_t cv_masterserver_update_rate;
extern consvar_t cv_masterserver_timeout;
extern consvar_t cv_masterserver_debug;
extern consvar_t cv_masterserver_token;
// < 0 to not connect (usually -1) (offline mode)
// == 0 to show all rooms, not a valid hosting room
// anything else is whatever room the MS assigns to that number (online mode)
INT16 ms_RoomId;
extern INT16 ms_RoomId;
const char *GetMasterServerPort(void);
const char *GetMasterServerIP(void);
#ifdef HAVE_THREADS
extern int ms_QueryId;
extern I_mutex ms_QueryId_mutex;
void MSOpenUDPSocket(void);
void MSCloseUDPSocket(void);
void SendAskInfoViaMS(INT32 node, tic_t asktime);
extern msg_server_t *ms_ServerList;
extern I_mutex ms_ServerList_mutex;
#endif
void RegisterServer(void);
void UnregisterServer(void);
void MasterClient_Ticker(void);
const msg_server_t *GetShortServersList(INT32 room);
INT32 GetRoomsList(boolean hosting);
msg_server_t *GetShortServersList(INT32 room, int id);
INT32 GetRoomsList(boolean hosting, int id);
#ifdef UPDATE_ALERT
const char *GetMODVersion(void);
char *GetMODVersion(int id);
void GetMODVersion_Console(void);
#endif
extern msg_rooms_t room_list[NUM_LIST_ROOMS+1];
void AddMServCommands(void);
/* HTTP */
void HMS_set_api (char *api);
int HMS_fetch_rooms (int joining, int id);
int HMS_register (void);
int HMS_unlist (void);
int HMS_update (void);
void HMS_list_servers (void);
msg_server_t * HMS_fetch_servers (msg_server_t *list, int room, int id);
int HMS_compare_mod_version (char *buffer, size_t size_of_buffer);
#endif

View File

@ -5795,13 +5795,8 @@ void A_MixUp(mobj_t *actor)
P_SetThingPosition(players[i].mo);
#ifdef ESLOPE
players[i].mo->floorz = P_GetFloorZ(players[i].mo, players[i].mo->subsector->sector, players[i].mo->x, players[i].mo->y, NULL);
players[i].mo->ceilingz = P_GetCeilingZ(players[i].mo, players[i].mo->subsector->sector, players[i].mo->x, players[i].mo->y, NULL);
#else
players[i].mo->floorz = players[i].mo->subsector->sector->floorheight;
players[i].mo->ceilingz = players[i].mo->subsector->sector->ceilingheight;
#endif
P_CheckPosition(players[i].mo, players[i].mo->x, players[i].mo->y);
}
@ -8517,6 +8512,7 @@ void A_SPBChase(mobj_t *actor)
//fast->momz = (3*actor->momz)/4;
fast->color = SKINCOLOR_RED;
fast->colorized = true;
P_SetTarget(&fast->target, actor); // easier lua access
K_MatchGenericExtraFlags(fast, actor);
}

View File

@ -328,9 +328,7 @@ extern mobj_t *tmfloorthing, *tmhitthing, *tmthing;
extern camera_t *mapcampointer;
extern fixed_t tmx;
extern fixed_t tmy;
#ifdef ESLOPE
extern pslope_t *tmfloorslope, *tmceilingslope;
#endif
/* cphipps 2004/08/30 */
extern void P_MapStart(void);

View File

@ -31,9 +31,7 @@
#include "r_splats.h"
#ifdef ESLOPE
#include "p_slopes.h"
#endif
#include "z_zone.h"
@ -56,9 +54,7 @@ fixed_t tmfloorz, tmceilingz;
static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights
mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector
mobj_t *tmhitthing; // the solid thing you bumped into (for collisions)
#ifdef ESLOPE
pslope_t *tmfloorslope, *tmceilingslope;
#endif
// keep track of the line that lowers the ceiling,
// so missiles don't explode against sky hack walls
@ -135,9 +131,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
return false;
}
#ifdef ESLOPE
object->standingslope = NULL; // Okay, now we can't return - no launching off at silly angles for you.
#endif
object->eflags |= MFE_SPRUNG; // apply this flag asap!
spring->flags &= ~(MF_SOLID|MF_SPECIAL); // De-solidify
@ -275,9 +269,7 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object)
zdist = object->z - spring->z;
}
#ifdef ESLOPE
object->standingslope = NULL; // No launching off at silly angles for you.
#endif
switch (spring->type)
{
@ -1758,9 +1750,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (thing->z + thing->height > tmfloorz)
{
tmfloorz = thing->z + thing->height;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
}
return true;
}
@ -1777,17 +1767,13 @@ static boolean PIT_CheckThing(mobj_t *thing)
&& tmthing->z + tmthing->height < tmthing->ceilingz)
{
tmfloorz = tmceilingz = topz; // block while in air
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
tmfloorthing = thing; // needed for side collision
}
else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height)
{
tmceilingz = topz;
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
tmfloorthing = thing; // thing we may stand on
}
}
@ -1801,9 +1787,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (thing->z < tmceilingz)
{
tmceilingz = thing->z;
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
}
return true;
}
@ -1820,17 +1804,13 @@ static boolean PIT_CheckThing(mobj_t *thing)
&& tmthing->z > tmthing->floorz)
{
tmfloorz = tmceilingz = topz; // block while in air
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
tmfloorthing = thing; // needed for side collision
}
else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z)
{
tmfloorz = topz;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
tmfloorthing = thing; // thing we may stand on
}
}
@ -1964,17 +1944,13 @@ if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a
{
tmceilingz = opentop;
ceilingline = ld;
#ifdef ESLOPE
tmceilingslope = opentopslope;
#endif
}
if (openbottom > tmfloorz)
{
tmfloorz = openbottom;
#ifdef ESLOPE
tmfloorslope = openbottomslope;
#endif
}
if (highceiling > tmdrpoffceilz)
@ -2053,10 +2029,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
// will adjust them.
tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight;
tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight;
#ifdef ESLOPE
tmfloorslope = newsubsec->sector->f_slope;
tmceilingslope = newsubsec->sector->c_slope;
#endif
// Check list of fake floors and see if tmfloorz/tmceilingz need to be altered.
if (newsubsec->sector->ffloors)
@ -2096,18 +2070,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
{
if (tmfloorz < topheight - sinklevel) {
tmfloorz = topheight - sinklevel;
#ifdef ESLOPE
tmfloorslope = *rover->t_slope;
#endif
}
}
else if (thing->eflags & MFE_VERTICALFLIP && thingtop <= bottomheight + sinklevel && thing->momz >= 0)
{
if (tmceilingz > bottomheight + sinklevel) {
tmceilingz = bottomheight + sinklevel;
#ifdef ESLOPE
tmceilingslope = *rover->b_slope;
#endif
}
}
}
@ -2129,9 +2099,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
{
if (tmfloorz < thing->z) {
tmfloorz = thing->z;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
}
}
// Quicksand blocks never change heights otherwise.
@ -2147,18 +2115,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
&& !(rover->flags & FF_REVERSEPLATFORM))
{
tmfloorz = tmdropoffz = topheight;
#ifdef ESLOPE
tmfloorslope = *rover->t_slope;
#endif
}
if (bottomheight < tmceilingz && abs(delta1) >= abs(delta2)
&& !(rover->flags & FF_PLATFORM)
&& !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE)))
{
tmceilingz = tmdrpoffceilz = bottomheight;
#ifdef ESLOPE
tmceilingslope = *rover->b_slope;
#endif
}
}
}
@ -2175,7 +2139,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
BMBOUNDFIX(xl, xh, yl, yh);
#ifdef POLYOBJECTS
// Check polyobjects and see if tmfloorz/tmceilingz need to be altered
{
validcount++;
@ -2233,23 +2196,18 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
if (polytop > tmfloorz && abs(delta1) < abs(delta2)) {
tmfloorz = tmdropoffz = polytop;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
}
if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) {
tmceilingz = tmdrpoffceilz = polybottom;
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
}
}
plink = (polymaplink_t *)(plink->link.next);
}
}
}
#endif
// tmfloorthing is set when tmfloorz comes from a thing's top
tmfloorthing = NULL;
@ -2407,7 +2365,6 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
BMBOUNDFIX(xl, xh, yl, yh);
#ifdef POLYOBJECTS
// Check polyobjects and see if tmfloorz/tmceilingz need to be altered
{
validcount++;
@ -2478,7 +2435,6 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
}
}
}
#endif
// check lines
for (bx = xl; bx <= xh; bx++)
@ -2657,10 +2613,8 @@ boolean PIT_PushableMoved(mobj_t *thing)
mobj_t *oldthing = tmthing;
line_t *oldceilline = ceilingline;
line_t *oldblockline = blockingline;
#ifdef ESLOPE
pslope_t *oldfslope = tmfloorslope;
pslope_t *oldcslope = tmceilingslope;
#endif
// Move the player
P_TryMove(thing, thing->x+stand->momx, thing->y+stand->momy, true);
@ -2673,10 +2627,8 @@ boolean PIT_PushableMoved(mobj_t *thing)
P_SetTarget(&tmthing, oldthing);
ceilingline = oldceilline;
blockingline = oldblockline;
#ifdef ESLOPE
tmfloorslope = oldfslope;
tmceilingslope = oldcslope;
#endif
thing->momz = stand->momz;
}
else
@ -2698,9 +2650,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
fixed_t tryy = thing->y;
fixed_t radius = thing->radius;
fixed_t thingtop = thing->z + thing->height;
#ifdef ESLOPE
fixed_t startingonground = P_IsObjectOnGround(thing);
#endif
floatok = false;
if (radius < MAXRADIUS/2)
@ -2791,26 +2741,22 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
#ifdef ESLOPE
else if (tmceilingz < thingtop && thingtop - tmceilingz <= maxstep)
{
thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
#endif
}
else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep)
{
thing->z = thing->floorz = tmfloorz;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
#ifdef ESLOPE
else if (tmfloorz > thing->z && tmfloorz - thing->z <= maxstep)
{
thing->z = thing->floorz = tmfloorz;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
#endif
}
if (thing->eflags & MFE_VERTICALFLIP)
@ -2872,7 +2818,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
thing->floorz = tmfloorz;
thing->ceilingz = tmceilingz;
#ifdef ESLOPE
if (!(thing->flags & MF_NOCLIPHEIGHT))
{
// Assign thing's standingslope if needed
@ -2893,7 +2838,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
}
else // don't set standingslope if you're not going to clip against it
thing->standingslope = NULL;
#endif
thing->x = x;
thing->y = y;
@ -4674,10 +4618,8 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
sector_t *sec = R_PointInSubsector(x, y)->sector;
fixed_t floorz = sec->floorheight;
#ifdef ESLOPE
if (sec->f_slope)
floorz = P_GetZAt(sec->f_slope, x, y);
#endif
// Intercept the stupid 'fall through 3dfloors' bug Tails 03-17-2002
if (sec->ffloors)
@ -4697,12 +4639,10 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#ifdef ESLOPE
if (*rover->t_slope)
topheight = P_GetZAt(*rover->t_slope, x, y);
if (*rover->b_slope)
bottomheight = P_GetZAt(*rover->b_slope, x, y);
#endif
if (rover->flags & FF_QUICKSAND)
{

View File

@ -308,9 +308,7 @@ fixed_t P_InterceptVector(divline_t *v2, divline_t *v1)
// OPTIMIZE: keep this precalculated
//
fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
#ifdef ESLOPE
pslope_t *opentopslope, *openbottomslope;
#endif
// P_CameraLineOpening
// P_LineOpening, but for camera
@ -337,24 +335,20 @@ void P_CameraLineOpening(line_t *linedef)
{
frontfloor = sectors[front->camsec].floorheight;
frontceiling = sectors[front->camsec].ceilingheight;
#ifdef ESLOPE
if (sectors[front->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[front->camsec].f_slope, camera[0].x, camera[0].y);
if (sectors[front->camsec].c_slope)
frontceiling = P_GetZAt(sectors[front->camsec].c_slope, camera[0].x, camera[0].y);
#endif
}
else if (front->heightsec >= 0)
{
frontfloor = sectors[front->heightsec].floorheight;
frontceiling = sectors[front->heightsec].ceilingheight;
#ifdef ESLOPE
if (sectors[front->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[front->heightsec].f_slope, camera[0].x, camera[0].y);
if (sectors[front->heightsec].c_slope)
frontceiling = P_GetZAt(sectors[front->heightsec].c_slope, camera[0].x, camera[0].y);
#endif
}
else
{
@ -365,23 +359,19 @@ void P_CameraLineOpening(line_t *linedef)
{
backfloor = sectors[back->camsec].floorheight;
backceiling = sectors[back->camsec].ceilingheight;
#ifdef ESLOPE
if (sectors[back->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[back->camsec].f_slope, camera[0].x, camera[0].y);
if (sectors[back->camsec].c_slope)
frontceiling = P_GetZAt(sectors[back->camsec].c_slope, camera[0].x, camera[0].y);
#endif
}
else if (back->heightsec >= 0)
{
backfloor = sectors[back->heightsec].floorheight;
backceiling = sectors[back->heightsec].ceilingheight;
#ifdef ESLOPE
if (sectors[back->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[back->heightsec].f_slope, camera[0].x, camera[0].y);
if (sectors[back->heightsec].c_slope)
frontceiling = P_GetZAt(sectors[back->heightsec].c_slope, camera[0].x, camera[0].y);
#endif
}
else
{
@ -501,14 +491,12 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
}
// Treat polyobjects kind of like 3D Floors
#ifdef POLYOBJECTS
if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT))
{
front = linedef->frontsector;
back = linedef->frontsector;
}
else
#endif
{
front = linedef->frontsector;
back = linedef->backsector;
@ -527,17 +515,13 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{
opentop = frontheight;
highceiling = backheight;
#ifdef ESLOPE
opentopslope = front->c_slope;
#endif
}
else
{
opentop = backheight;
highceiling = frontheight;
#ifdef ESLOPE
opentopslope = back->c_slope;
#endif
}
frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef);
@ -547,17 +531,13 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{
openbottom = frontheight;
lowfloor = backheight;
#ifdef ESLOPE
openbottomslope = front->f_slope;
#endif
}
else
{
openbottom = backheight;
lowfloor = frontheight;
#ifdef ESLOPE
openbottomslope = back->f_slope;
#endif
}
}
@ -625,9 +605,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
// Check for fake floors in the sector.
if (front->ffloors || back->ffloors
#ifdef POLYOBJECTS
|| linedef->polyobj
#endif
)
{
ffloor_t *rover;
@ -637,10 +615,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
fixed_t highestfloor = openbottom;
fixed_t lowestfloor = lowfloor;
fixed_t delta1, delta2;
#ifdef ESLOPE
pslope_t *ceilingslope = opentopslope;
pslope_t *floorslope = openbottomslope;
#endif
// Check for frontsector's fake floors
for (rover = front->ffloors; rover; rover = rover->next)
@ -665,9 +641,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{
if (bottomheight < lowestceiling) {
lowestceiling = bottomheight;
#ifdef ESLOPE
ceilingslope = *rover->b_slope;
#endif
}
else if (bottomheight < highestceiling)
highestceiling = bottomheight;
@ -677,9 +651,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{
if (topheight > highestfloor) {
highestfloor = topheight;
#ifdef ESLOPE
floorslope = *rover->t_slope;
#endif
}
else if (topheight > lowestfloor)
lowestfloor = topheight;
@ -709,9 +681,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{
if (bottomheight < lowestceiling) {
lowestceiling = bottomheight;
#ifdef ESLOPE
ceilingslope = *rover->b_slope;
#endif
}
else if (bottomheight < highestceiling)
highestceiling = bottomheight;
@ -721,16 +691,13 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{
if (topheight > highestfloor) {
highestfloor = topheight;
#ifdef ESLOPE
floorslope = *rover->t_slope;
#endif
}
else if (topheight > lowestfloor)
lowestfloor = topheight;
}
}
#ifdef POLYOBJECTS
// Treat polyobj's backsector like a 3D Floor
if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT))
{
@ -740,38 +707,29 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2)));
if (polysec->floorheight < lowestceiling && delta1 >= delta2) {
lowestceiling = polysec->floorheight;
#ifdef ESLOPE
ceilingslope = NULL;
#endif
}
else if (polysec->floorheight < highestceiling && delta1 >= delta2)
highestceiling = polysec->floorheight;
if (polysec->ceilingheight > highestfloor && delta1 < delta2) {
highestfloor = polysec->ceilingheight;
#ifdef ESLOPE
floorslope = NULL;
#endif
}
else if (polysec->ceilingheight > lowestfloor && delta1 < delta2)
lowestfloor = polysec->ceilingheight;
}
#endif
if (highestceiling < highceiling)
highceiling = highestceiling;
if (highestfloor > openbottom) {
openbottom = highestfloor;
#ifdef ESLOPE
openbottomslope = floorslope;
#endif
}
if (lowestceiling < opentop) {
opentop = lowestceiling;
#ifdef ESLOPE
opentopslope = ceilingslope;
#endif
}
if (lowestfloor > lowfloor)
@ -1023,9 +981,7 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *))
{
INT32 offset;
const INT32 *list; // Big blockmap
#ifdef POLYOBJECTS
polymaplink_t *plink; // haleyjd 02/22/06
#endif
line_t *ld;
if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight)
@ -1033,7 +989,6 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *))
offset = y*bmapwidth + x;
#ifdef POLYOBJECTS
// haleyjd 02/22/06: consider polyobject lines
plink = polyblocklinks[offset];
@ -1057,7 +1012,6 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *))
}
plink = (polymaplink_t *)(plink->link.next);
}
#endif
offset = *(blockmap + offset); // offset = blockmap[y*bmapwidth+x];

View File

@ -55,9 +55,7 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing, fixed_t x,fixed_t y);
boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y);
extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
#ifdef ESLOPE
extern pslope_t *opentopslope, *openbottomslope;
#endif
void P_LineOpening(line_t *plinedef, mobj_t *mobj);

View File

@ -31,9 +31,7 @@
#include "i_video.h"
#include "lua_hook.h"
#include "b_bot.h"
#ifdef ESLOPE
#include "p_slopes.h"
#endif
#include "k_kart.h"
@ -646,12 +644,10 @@ boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover)
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#ifdef ESLOPE
if (*rover->t_slope)
topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y);
if (*rover->b_slope)
bottomheight = P_GetZAt(*rover->b_slope, mobj->x, mobj->y);
#endif
if (mobj->z > topheight)
return false;
@ -662,7 +658,6 @@ boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover)
return true;
}
#ifdef ESLOPE
// P_GetFloorZ (and its ceiling counterpart)
// Gets the floor height (or ceiling height) of the mobj's contact point in sector, assuming object's center if moved to [x, y]
// If line is supplied, it's a divider line on the sector. Set it to NULL if you're not checking for collision with a line
@ -766,15 +761,11 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line,
P_GetZAt(slope, v2.x, v2.y)
);
}
#endif
fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect)
{
#ifdef ESLOPE
I_Assert(mobj != NULL);
#endif
I_Assert(sector != NULL);
#ifdef ESLOPE
if (sector->f_slope) {
fixed_t testx, testy;
pslope_t *slope = sector->f_slope;
@ -844,25 +835,13 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t
return HighestOnLine(mobj->radius, x, y, line, slope, lowest);
} else // Well, that makes it easy. Just get the floor height
#else
(void)mobj;
(void)boundsec;
(void)x;
(void)y;
(void)line;
(void)lowest;
(void)perfect;
#endif
return sector->floorheight;
}
fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect)
{
#ifdef ESLOPE
I_Assert(mobj != NULL);
#endif
I_Assert(sector != NULL);
#ifdef ESLOPE
if (sector->c_slope) {
fixed_t testx, testy;
pslope_t *slope = sector->c_slope;
@ -932,26 +911,14 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
return HighestOnLine(mobj->radius, x, y, line, slope, lowest);
} else // Well, that makes it easy. Just get the ceiling height
#else
(void)mobj;
(void)boundsec;
(void)x;
(void)y;
(void)line;
(void)lowest;
(void)perfect;
#endif
return sector->ceilingheight;
}
// Now do the same as all above, but for cameras because apparently cameras are special?
fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect)
{
#ifdef ESLOPE
I_Assert(mobj != NULL);
#endif
I_Assert(sector != NULL);
#ifdef ESLOPE
if (sector->f_slope) {
fixed_t testx, testy;
pslope_t *slope = sector->f_slope;
@ -1021,25 +988,13 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix
return HighestOnLine(mobj->radius, x, y, line, slope, lowest);
} else // Well, that makes it easy. Just get the floor height
#else
(void)mobj;
(void)boundsec;
(void)x;
(void)y;
(void)line;
(void)lowest;
(void)perfect;
#endif
return sector->floorheight;
}
fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect)
{
#ifdef ESLOPE
I_Assert(mobj != NULL);
#endif
I_Assert(sector != NULL);
#ifdef ESLOPE
if (sector->c_slope) {
fixed_t testx, testy;
pslope_t *slope = sector->c_slope;
@ -1109,15 +1064,6 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f
return HighestOnLine(mobj->radius, x, y, line, slope, lowest);
} else // Well, that makes it easy. Just get the ceiling height
#else
(void)mobj;
(void)boundsec;
(void)x;
(void)y;
(void)line;
(void)lowest;
(void)perfect;
#endif
return sector->ceilingheight;
}
static void P_PlayerFlip(mobj_t *mo)
@ -1406,9 +1352,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy)
else if (abs(player->rmomx) < FixedMul(STOPSPEED, mo->scale)
&& abs(player->rmomy) < FixedMul(STOPSPEED, mo->scale)
&& (!(player->cmd.forwardmove && !(twodlevel || mo->flags2 & MF2_TWOD)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING))
#ifdef ESLOPE
&& !(player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && (abs(player->mo->standingslope->zdelta) >= FRACUNIT/2))
#endif
)
{
// if in a walking frame, stop moving
@ -1556,11 +1500,9 @@ void P_XYMovement(mobj_t *mo)
fixed_t xmove, ymove;
fixed_t oldx, oldy; // reducing bobbing/momentum on ice when up against walls
boolean moved;
#ifdef ESLOPE
pslope_t *oldslope = NULL;
vector3_t slopemom;
fixed_t predictedz = 0;
#endif
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
@ -1590,7 +1532,6 @@ void P_XYMovement(mobj_t *mo)
oldx = mo->x;
oldy = mo->y;
#ifdef ESLOPE
// adjust various things based on slope
if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8) {
if (!P_IsObjectOnGround(mo)) { // We fell off at some point? Do the twisty thing!
@ -1612,7 +1553,6 @@ void P_XYMovement(mobj_t *mo)
}
} else if (P_IsObjectOnGround(mo) && !mo->momz)
predictedz = mo->z;
#endif
// Pushables can break some blocks
if (CheckForBustableBlocks && mo->flags & MF_PUSHABLE)
@ -1799,7 +1739,6 @@ void P_XYMovement(mobj_t *mo)
if (P_MobjWasRemoved(mo)) // MF_SPECIAL touched a player! O_o;;
return;
#ifdef ESLOPE
if (moved && oldslope) { // Check to see if we ran off
if (oldslope != mo->standingslope) { // First, compare different slopes
@ -1847,7 +1786,6 @@ void P_XYMovement(mobj_t *mo)
//CONS_Printf("Launched off of flat surface running into downward slope\n");
}
}
#endif
// Check the gravity status.
P_CheckGravity(mo, false);
@ -1898,11 +1836,9 @@ void P_XYMovement(mobj_t *mo)
if (player && player->pflags & PF_NIGHTSMODE)
return; // no friction for NiGHTS players
#ifdef ESLOPE
if ((mo->type == MT_BIGTUMBLEWEED || mo->type == MT_LITTLETUMBLEWEED)
&& (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8)) // Special exception for tumbleweeds on slopes
return;
#endif
//{ SRB2kart stuff
if (mo->type == MT_ORBINAUT || mo->type == MT_JAWZ_DUD || mo->type == MT_JAWZ || mo->type == MT_BALLHOG) //(mo->type == MT_JAWZ && !mo->tracer))
@ -2140,9 +2076,7 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover)
{
fixed_t topheight =
#ifdef ESLOPE
*rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) :
#endif
*rover->topheight;
if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3
@ -2179,7 +2113,6 @@ static boolean P_ZMovement(mobj_t *mo)
}
mo->z += mo->momz;
#ifdef ESLOPE
if (mo->standingslope)
{
if (mo->flags & MF_NOCLIPHEIGHT)
@ -2187,7 +2120,6 @@ static boolean P_ZMovement(mobj_t *mo)
else if (!P_IsObjectOnGround(mo))
P_SlopeLaunch(mo);
}
#endif
switch (mo->type)
{
@ -2378,7 +2310,6 @@ static boolean P_ZMovement(mobj_t *mo)
else
mo->z = mo->floorz;
#ifdef ESLOPE
if (!(mo->flags & MF_MISSILE) && mo->standingslope) // You're still on the ground; why are we here?
{
mo->momz = 0;
@ -2391,7 +2322,6 @@ static boolean P_ZMovement(mobj_t *mo)
mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope;
P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope);
}
#endif
// hit the floor
if (mo->type == MT_FIREBALL) // special case for the fireball
@ -2491,13 +2421,11 @@ static boolean P_ZMovement(mobj_t *mo)
else
mom.y -= FixedMul(6*FRACUNIT, mo->scale);
}
#ifdef ESLOPE
else if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8)
{
// Pop the object up a bit to encourage bounciness
//mom.z = P_MobjFlip(mo)*mo->scale;
}
#endif
else
{
mom.x = mom.y = mom.z = 0;
@ -2543,11 +2471,9 @@ static boolean P_ZMovement(mobj_t *mo)
|| tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER))
mom.z = tmfloorthing->momz;
#ifdef ESLOPE
if (mo->standingslope) { // MT_STEAM will never have a standingslope, see above.
P_QuantizeMomentumToSlope(&mom, mo->standingslope);
}
#endif
mo->momx = mom.x;
mo->momy = mom.y;
@ -2665,7 +2591,6 @@ static void P_PlayerZMovement(mobj_t *mo)
|| mo->player->playerstate == PST_REBORN)
return;
#ifdef ESLOPE
if (mo->standingslope)
{
if (mo->flags & MF_NOCLIPHEIGHT)
@ -2673,7 +2598,6 @@ static void P_PlayerZMovement(mobj_t *mo)
else if (!P_IsObjectOnGround(mo))
P_SlopeLaunch(mo);
}
#endif
// clip movement
if (P_IsObjectOnGround(mo) && !(mo->flags & MF_NOCLIPHEIGHT))
@ -2702,19 +2626,15 @@ static void P_PlayerZMovement(mobj_t *mo)
&& mo->player->kartstuff[k_spinouttimer] == 0 && mo->player->kartstuff[k_squishedtimer] == 0) // SRB2kart
P_SetPlayerMobjState(mo, S_KART_STND1);
#ifdef ESLOPE
if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) {
// Handle landing on slope during Z movement
P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope));
}
#endif
#ifdef ESLOPE
if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) {
// Handle landing on slope during Z movement
P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope));
}
#endif
if (P_MobjFlip(mo)*mo->momz < 0) // falling
{
@ -2732,7 +2652,6 @@ static void P_PlayerZMovement(mobj_t *mo)
if (mo->eflags & MFE_JUSTHITFLOOR)
{
#ifdef POLYOBJECTS
// Check if we're on a polyobject
// that triggers a linedef executor.
msecnode_t *node;
@ -2792,7 +2711,6 @@ static void P_PlayerZMovement(mobj_t *mo)
}
if (!stopmovecut)
#endif
// Cut momentum in half when you hit the ground and
// aren't pressing any controls.
@ -2961,7 +2879,6 @@ static boolean P_SceneryZMovement(mobj_t *mo)
// set standingslope
P_TryMove(mo, mo->x, mo->y, true);
mo->momz = -mo->momz;
#ifdef ESLOPE
if (mo->standingslope)
{
if (mo->flags & MF_NOCLIPHEIGHT)
@ -2969,7 +2886,6 @@ static boolean P_SceneryZMovement(mobj_t *mo)
else if (!P_IsObjectOnGround(mo))
P_SlopeLaunch(mo);
}
#endif
S_StartSound(mo, mo->info->activesound);
}
break;
@ -3138,13 +3054,11 @@ void P_MobjCheckWater(mobj_t *mobj)
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#ifdef ESLOPE
if (*rover->t_slope)
topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y);
if (*rover->b_slope)
bottomheight = P_GetZAt(*rover->b_slope, mobj->x, mobj->y);
#endif
if (mobj->eflags & MFE_VERTICALFLIP)
{
@ -3387,13 +3301,11 @@ static void P_SceneryCheckWater(mobj_t *mobj)
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#ifdef ESLOPE
if (*rover->t_slope)
topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y);
if (*rover->b_slope)
bottomheight = P_GetZAt(*rover->b_slope, mobj->x, mobj->y);
#endif
if (topheight <= mobj->z
|| bottomheight > (mobj->z + FixedMul(mobj->info->height >> 1, mobj->scale)))
@ -3439,13 +3351,9 @@ static boolean P_CameraCheckHeat(camera_t *thiscam)
continue;
if (halfheight >= (
#ifdef ESLOPE
*rover->t_slope ? P_GetZAt(*rover->t_slope, thiscam->x, thiscam->y) :
#endif
*rover->topheight) || halfheight <= (
#ifdef ESLOPE
*rover->b_slope ? P_GetZAt(*rover->b_slope, thiscam->x, thiscam->y) :
#endif
*rover->bottomheight))
continue;
@ -3475,13 +3383,9 @@ static boolean P_CameraCheckWater(camera_t *thiscam)
continue;
if (halfheight >= (
#ifdef ESLOPE
*rover->t_slope ? P_GetZAt(*rover->t_slope, thiscam->x, thiscam->y) :
#endif
*rover->topheight) || halfheight <= (
#ifdef ESLOPE
*rover->b_slope ? P_GetZAt(*rover->b_slope, thiscam->x, thiscam->y) :
#endif
*rover->bottomheight))
continue;
@ -3681,9 +3585,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
P_MobjCheckWater(mobj);
#ifdef ESLOPE
P_ButteredSlope(mobj);
#endif
// momentum movement
mobj->eflags &= ~MFE_JUSTSTEPPEDDOWN;
@ -3840,9 +3742,7 @@ static void CalculatePrecipFloor(precipmobj_t *mobj)
else
return;
mobj->floorz =
#ifdef ESLOPE
mobjsecsubsec->f_slope ? P_GetZAt(mobjsecsubsec->f_slope, mobj->x, mobj->y) :
#endif
mobjsecsubsec->floorheight;
if (mobjsecsubsec->ffloors)
{
@ -3858,11 +3758,9 @@ static void CalculatePrecipFloor(precipmobj_t *mobj)
if (!(rover->flags & FF_BLOCKOTHERS) && !(rover->flags & FF_SWIMMABLE))
continue;
#ifdef ESLOPE
if (*rover->t_slope)
topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y);
else
#endif
topheight = *rover->topheight;
if (topheight > mobj->floorz)
@ -8312,18 +8210,7 @@ void P_MobjThinker(mobj_t *mobj)
if (!mobj->extravalue2)
{
if (mobj->eflags & MFE_VERTICALFLIP)
mobj->z -= mobj->height;
else
mobj->z += mobj->height;
S_StartSound(mobj, mobj->info->deathsound);
P_SetObjectMomZ(mobj, 8*FRACUNIT, false);
P_InstaThrust(mobj, R_PointToAngle2(mobj->target->x, mobj->target->y, mobj->x, mobj->y)+ANGLE_90, 16*FRACUNIT);
mobj->momx += mobj->target->momx;
mobj->momy += mobj->target->momy;
mobj->momz += mobj->target->momz;
mobj->extravalue2 = 1;
K_DropRocketSneaker(mobj->target->player);
}
else if (P_IsObjectOnGround(mobj))
{
@ -9343,7 +9230,6 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s
mobj->eflags &= ~MFE_JUSTHITFLOOR;
}
#ifdef ESLOPE // Sliding physics for slidey mobjs!
if (mobj->type == MT_FLINGRING
|| mobj->type == MT_FLINGCOIN
|| P_WeaponOrPanel(mobj->type)
@ -9356,7 +9242,6 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s
//if (mobj->standingslope) CONS_Printf("slope physics on mobj\n");
P_ButteredSlope(mobj);
}
#endif
if (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health
&& P_CheckDeathPitCollide(mobj)) // extra pit check in case these didn't have momz
@ -9660,14 +9545,10 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
P_SetScale(mobj, mobj->destscale);
mobj->floorz =
#ifdef ESLOPE
mobj->subsector->sector->f_slope ? P_GetZAt(mobj->subsector->sector->f_slope, x, y) :
#endif
mobj->subsector->sector->floorheight;
mobj->ceilingz =
#ifdef ESLOPE
mobj->subsector->sector->c_slope ? P_GetZAt(mobj->subsector->sector->c_slope, x, y) :
#endif
mobj->subsector->sector->ceilingheight;
// Tells MobjCheckWater that the water height was not set.
@ -10184,14 +10065,10 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
P_SetPrecipitationThingPosition(mobj);
mobj->floorz = starting_floorz =
#ifdef ESLOPE
mobj->subsector->sector->f_slope ? P_GetZAt(mobj->subsector->sector->f_slope, x, y) :
#endif
mobj->subsector->sector->floorheight;
mobj->ceilingz =
#ifdef ESLOPE
mobj->subsector->sector->c_slope ? P_GetZAt(mobj->subsector->sector->c_slope, x, y) :
#endif
mobj->subsector->sector->ceilingheight;
mobj->z = z;
@ -10710,9 +10587,7 @@ void P_RespawnSpecials(void)
if (mthing->options & MTF_OBJECTFLIP)
{
z = (
#ifdef ESLOPE
ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) :
#endif
ss->sector->ceilingheight) - (mthing->options >> ZSHIFT) * FRACUNIT;
if (mthing->options & MTF_AMBUSH
&& (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i)))
@ -10722,9 +10597,7 @@ void P_RespawnSpecials(void)
else
{
z = (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight) + (mthing->options >> ZSHIFT) * FRACUNIT;
if (mthing->options & MTF_AMBUSH
&& (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i)))
@ -10981,14 +10854,10 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing)
sector = R_PointInSubsector(x, y)->sector;
floor =
#ifdef ESLOPE
sector->f_slope ? P_GetZAt(sector->f_slope, x, y) :
#endif
sector->floorheight;
ceiling =
#ifdef ESLOPE
sector->c_slope ? P_GetZAt(sector->c_slope, x, y) :
#endif
sector->ceilingheight;
if (mthing)
@ -11060,14 +10929,10 @@ void P_MovePlayerToStarpost(INT32 playernum)
sector = R_PointInSubsector(mobj->x, mobj->y)->sector;
floor =
#ifdef ESLOPE
sector->f_slope ? P_GetZAt(sector->f_slope, mobj->x, mobj->y) :
#endif
sector->floorheight;
ceiling =
#ifdef ESLOPE
sector->c_slope ? P_GetZAt(sector->c_slope, mobj->x, mobj->y) :
#endif
sector->ceilingheight;
if (mobj->player->kartstuff[k_starpostflip])
@ -11242,9 +11107,7 @@ void P_SpawnMapThing(mapthing_t *mthing)
ss = R_PointInSubsector(mthing->x << FRACBITS, mthing->y << FRACBITS);
mthing->z = (INT16)(((
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, mthing->x << FRACBITS, mthing->y << FRACBITS) :
#endif
ss->sector->floorheight)>>FRACBITS) + (mthing->options >> ZSHIFT));
if (numhuntemeralds < MAXHUNTEMERALDS)
@ -11360,9 +11223,7 @@ void P_SpawnMapThing(mapthing_t *mthing)
if (i == MT_NIGHTSBUMPER)
z = (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight) + ((mthing->options >> ZSHIFT) << FRACBITS);
else if (i == MT_AXIS || i == MT_AXISTRANSFER || i == MT_AXISTRANSFERLINE)
z = ONFLOORZ;
@ -11371,9 +11232,7 @@ void P_SpawnMapThing(mapthing_t *mthing)
if (mthing->options & MTF_OBJECTFLIP)
{
z = (
#ifdef ESLOPE
ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) :
#endif
ss->sector->ceilingheight);
if (mthing->options & MTF_AMBUSH) // Special flag for rings
@ -11386,9 +11245,7 @@ void P_SpawnMapThing(mapthing_t *mthing)
else
{
z = (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight);
if (mthing->options & MTF_AMBUSH) // Special flag for rings
@ -11410,15 +11267,11 @@ void P_SpawnMapThing(mapthing_t *mthing)
// base positions
if (flip)
z = (
#ifdef ESLOPE
ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) :
#endif
ss->sector->ceilingheight) - mobjinfo[i].height;
else
z = (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight);
// offsetting
@ -11985,9 +11838,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
//hoopcenter->flags |= MF_NOTHINK;
z +=
#ifdef ESLOPE
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight;
hoopcenter->z = z - hoopcenter->height/2;
@ -12128,9 +11979,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
hoopcenter->spawnpoint = mthing;
z +=
#ifdef ESLOPE
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight;
hoopcenter->z = z - hoopcenter->height/2;
@ -12250,9 +12099,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
else if (mthing->type == mobjinfo[MT_NIGHTSWING].doomednum)
{
z =
#ifdef ESLOPE
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight;
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
@ -12304,9 +12151,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
if (mthing->options & MTF_OBJECTFLIP)
{
z = (
#ifdef ESLOPE
sec->c_slope ? P_GetZAt(sec->c_slope, x, y) :
#endif
sec->ceilingheight) - mobjinfo[ringthing].height;
if (mthing->options >> ZSHIFT)
z -= ((mthing->options >> ZSHIFT) << FRACBITS);
@ -12314,9 +12159,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
else
{
z =
#ifdef ESLOPE
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight;
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
@ -12370,9 +12213,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
if (mthing->options & MTF_OBJECTFLIP)
{
z = (
#ifdef ESLOPE
sec->c_slope ? P_GetZAt(sec->c_slope, x, y) :
#endif
sec->ceilingheight) - mobjinfo[ringthing].height - dist*r;
if (mthing->options >> ZSHIFT)
z -= ((mthing->options >> ZSHIFT) << FRACBITS);
@ -12380,9 +12221,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
else
{
z = (
#ifdef ESLOPE
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight) + dist*r;
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
@ -12428,9 +12267,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
if (mthing->options & MTF_OBJECTFLIP)
{
z = (
#ifdef ESLOPE
sec->c_slope ? P_GetZAt(sec->c_slope, x, y) :
#endif
sec->ceilingheight) - mobjinfo[ringthing].height - 64*FRACUNIT*r;
if (mthing->options >> ZSHIFT)
z -= ((mthing->options >> ZSHIFT) << FRACBITS);
@ -12438,9 +12275,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
else
{
z = (
#ifdef ESLOPE
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight) + 64*FRACUNIT*r;
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
@ -12473,9 +12308,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
}
z =
#ifdef ESLOPE
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight;
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);

View File

@ -368,9 +368,7 @@ typedef struct mobj_s
INT32 cusval;
INT32 cvmem;
#ifdef ESLOPE
struct pslope_s *standingslope; // The slope that the object is standing on (shouldn't need synced in savegames, right?)
#endif
boolean colorized; // Whether the mobj uses the rainbow colormap

View File

@ -28,7 +28,6 @@
#include "r_state.h"
#include "r_defs.h"
#ifdef POLYOBJECTS
/*
Theory behind Polyobjects:
@ -2864,6 +2863,5 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata)
return 1;
}
#endif // ifdef POLYOBJECTS
// EOF

View File

@ -19,7 +19,6 @@
#include "r_defs.h"
// haleyjd: temporary define
#ifdef POLYOBJECTS
//
// Defines
//
@ -303,7 +302,6 @@ extern polyobj_t *PolyObjects;
extern INT32 numPolyObjects;
extern polymaplink_t **polyblocklinks; // polyobject blockmap
#endif // ifdef POLYOBJECTS
#endif

View File

@ -30,9 +30,7 @@
#include "r_sky.h"
#include "p_polyobj.h"
#include "lua_script.h"
#ifdef ESLOPE
#include "p_slopes.h"
#endif
savedata_t savedata;
UINT8 *save_p;
@ -949,9 +947,7 @@ typedef enum
MD2_HPREV = 1<<8,
MD2_COLORIZED = 1<<9,
MD2_WAYPOINTCAP = 1<<10
#ifdef ESLOPE
, MD2_SLOPE = 1<<11
#endif
} mobj_diff2_t;
typedef enum
@ -985,7 +981,6 @@ typedef enum
tc_noenemies,
tc_eachtime,
tc_disappear,
#ifdef POLYOBJECTS
tc_polyrotate, // haleyjd 03/26/06: polyobjects
tc_polymove,
tc_polywaypoint,
@ -993,7 +988,6 @@ typedef enum
tc_polyswingdoor,
tc_polyflag,
tc_polydisplace,
#endif
tc_end
} specials_e;
@ -1142,10 +1136,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
diff2 |= MD2_HNEXT;
if (mobj->hprev)
diff2 |= MD2_HPREV;
#ifdef ESLOPE
if (mobj->standingslope)
diff2 |= MD2_SLOPE;
#endif
if (mobj->colorized)
diff2 |= MD2_COLORIZED;
if (mobj == waypointcap)
@ -1265,10 +1257,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
WRITEUINT32(save_p, mobj->hnext->mobjnum);
if (diff2 & MD2_HPREV)
WRITEUINT32(save_p, mobj->hprev->mobjnum);
#ifdef ESLOPE
if (diff2 & MD2_SLOPE)
WRITEUINT16(save_p, mobj->standingslope->id);
#endif
if (diff2 & MD2_COLORIZED)
WRITEUINT8(save_p, mobj->colorized);
@ -1552,7 +1542,6 @@ static void SaveDisappearThinker(const thinker_t *th, const UINT8 type)
WRITEINT32(save_p, ht->exists);
}
#ifdef POLYOBJECTS
//
// SavePolyrotateThinker
@ -1662,7 +1651,6 @@ static void SavePolydisplaceThinker(const thinker_t *th, const UINT8 type)
WRITEFIXED(save_p, ht->oldHeights);
}
#endif
/*
//
// SaveWhatThinker
@ -1842,7 +1830,6 @@ static void P_NetArchiveThinkers(void)
SaveDisappearThinker(th, tc_disappear);
continue;
}
#ifdef POLYOBJECTS
else if (th->function.acp1 == (actionf_p1)T_PolyObjRotate)
{
SavePolyrotatetThinker(th, tc_polyrotate);
@ -1878,7 +1865,6 @@ static void P_NetArchiveThinkers(void)
SavePolydisplaceThinker(th, tc_polydisplace);
continue;
}
#endif
#ifdef PARANOIA
else if (th->function.acv != P_RemoveThinkerDelayed) // wait garbage collection
I_Error("unknown thinker type %p", th->function.acp1);
@ -2142,10 +2128,8 @@ static void LoadMobjThinker(actionf_p1 thinker)
mobj->hnext = (mobj_t *)(size_t)READUINT32(save_p);
if (diff2 & MD2_HPREV)
mobj->hprev = (mobj_t *)(size_t)READUINT32(save_p);
#ifdef ESLOPE
if (diff2 & MD2_SLOPE)
mobj->standingslope = P_SlopeById(READUINT16(save_p));
#endif
if (diff2 & MD2_COLORIZED)
mobj->colorized = READUINT8(save_p);
@ -2517,7 +2501,6 @@ static inline void LoadDisappearThinker(actionf_p1 thinker)
P_AddThinker(&ht->thinker);
}
#ifdef POLYOBJECTS
//
// LoadPolyrotateThinker
@ -2637,7 +2620,6 @@ static inline void LoadPolydisplaceThinker(actionf_p1 thinker)
ht->oldHeights = READFIXED(save_p);
P_AddThinker(&ht->thinker);
}
#endif
/*
//
@ -2806,7 +2788,6 @@ static void P_NetUnArchiveThinkers(void)
case tc_disappear:
LoadDisappearThinker((actionf_p1)T_Disappear);
break;
#ifdef POLYOBJECTS
case tc_polyrotate:
LoadPolyrotatetThinker((actionf_p1)T_PolyObjRotate);
break;
@ -2834,7 +2815,6 @@ static void P_NetUnArchiveThinkers(void)
case tc_polydisplace:
LoadPolydisplaceThinker((actionf_p1)T_PolyObjDisplace);
break;
#endif
case tc_scroll:
LoadScrollThinker((actionf_p1)T_Scroll);
break;
@ -2875,7 +2855,6 @@ static void P_NetUnArchiveThinkers(void)
//
// haleyjd 03/26/06: PolyObject saving code
//
#ifdef POLYOBJECTS
#define PD_FLAGS 0x01
#define PD_TRANS 0x02
@ -2964,7 +2943,6 @@ static inline void P_UnArchivePolyObjects(void)
for (i = 0; i < numSavedPolys; ++i)
P_UnArchivePolyObj(&PolyObjects[i]);
}
#endif
//
// P_FinishMobjs
//
@ -3445,9 +3423,7 @@ void P_SaveNetGame(void)
if (gamestate == GS_LEVEL)
{
P_NetArchiveWorld();
#ifdef POLYOBJECTS
P_ArchivePolyObjects();
#endif
P_NetArchiveThinkers();
P_NetArchiveSpecials();
}
@ -3489,9 +3465,7 @@ boolean P_LoadNetGame(void)
if (gamestate == GS_LEVEL)
{
P_NetUnArchiveWorld();
#ifdef POLYOBJECTS
P_UnArchivePolyObjects();
#endif
P_NetUnArchiveThinkers();
P_NetUnArchiveSpecials();
P_RelinkPointers();

View File

@ -78,9 +78,7 @@
#include "hardware/hw_light.h"
#endif
#ifdef ESLOPE
#include "p_slopes.h"
#endif
// SRB2Kart
#include "k_kart.h"
@ -1004,9 +1002,7 @@ static void P_LoadThings(void)
// Z for objects
mt->z = (INT16)(
#ifdef ESLOPE
mtsector->f_slope ? P_GetZAt(mtsector->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) :
#endif
mtsector->floorheight)>>FRACBITS;
if (mt->type == 1700 // MT_AXIS
@ -1277,9 +1273,7 @@ static void P_LoadRawLineDefs(UINT8 *data, size_t i)
if (ld->sidenum[1] != 0xffff && ld->special)
sides[ld->sidenum[1]].special = ld->special;
#ifdef POLYOBJECTS
ld->polyobj = NULL;
#endif
}
}
@ -1407,8 +1401,6 @@ static void P_LoadRawSideDefs2(void *data)
{
UINT16 i;
INT32 num;
size_t j;
UINT32 cr, cg, cb;
for (i = 0; i < numsides; i++)
{
@ -1475,6 +1467,8 @@ static void P_LoadRawSideDefs2(void *data)
|| (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]))
{
char *col;
RGBA_t color;
size_t j;
sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture,
msd->bottomtexture);
@ -1490,23 +1484,21 @@ static void P_LoadRawSideDefs2(void *data)
// encore mode colormaps!
// do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code.
// do this for both the start and fade colormaps.
cr = (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0);
cg = (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8);
cb = (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16);
color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]);
color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]);
color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]);
#ifdef GLENCORE
if (encoremap)
{
j = encoremap[NearestColor((UINT8)cr, (UINT8)cg, (UINT8)cb)];
j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)];
//CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation
cr = pLocalPalette[j].s.red;
cg = pLocalPalette[j].s.green;
cb = pLocalPalette[j].s.blue;
color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below
}
#endif
sec->extra_colormap->rgba = cr + cg + cb;
color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly
sec->extra_colormap->rgba = color.rgba;
// alpha
if (msd->toptexture[7])
@ -1533,23 +1525,21 @@ static void P_LoadRawSideDefs2(void *data)
col = msd->bottomtexture;
// do the exact same thing as above here.
cr = (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0);
cg = (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8);
cb = (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16);
color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]);
color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]);
color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]);
#ifdef GLENCORE
if (encoremap)
{
j = encoremap[NearestColor((UINT8)cr, (UINT8)cg, (UINT8)cb)];
j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)];
//CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation
cr = pLocalPalette[j].s.red;
cg = pLocalPalette[j].s.green;
cb = pLocalPalette[j].s.blue;
color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below
}
#endif
sec->extra_colormap->fadergba = cr + cg + cb;
color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly
sec->extra_colormap->fadergba = color.rgba;
// alpha
if (msd->bottomtexture[7])
@ -1953,11 +1943,9 @@ static void P_CreateBlockMap(void)
blocklinks = Z_Calloc(count, PU_LEVEL, NULL);
blockmap = blockmaplump + 4;
#ifdef POLYOBJECTS
// haleyjd 2/22/06: setup polyobject blockmap
count = sizeof(*polyblocklinks) * bmapwidth * bmapheight;
polyblocklinks = Z_Calloc(count, PU_LEVEL, NULL);
#endif
}
}
@ -2030,11 +2018,9 @@ static boolean P_LoadBlockMap(lumpnum_t lumpnum)
blocklinks = Z_Calloc(count, PU_LEVEL, NULL);
blockmap = blockmaplump+4;
#ifdef POLYOBJECTS
// haleyjd 2/22/06: setup polyobject blockmap
count = sizeof(*polyblocklinks) * bmapwidth * bmapheight;
polyblocklinks = Z_Calloc(count, PU_LEVEL, NULL);
#endif
return true;
/* Original
blockmaplump = W_CacheLumpNum(lump, PU_LEVEL);
@ -2096,11 +2082,9 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count, const char *lumpname
blocklinks = Z_Calloc(count, PU_LEVEL, NULL);
blockmap = blockmaplump+4;
#ifdef POLYOBJECTS
// haleyjd 2/22/06: setup polyobject blockmap
count = sizeof(*polyblocklinks) * bmapwidth * bmapheight;
polyblocklinks = Z_Calloc(count, PU_LEVEL, NULL);
#endif
return true;
#endif
}
@ -2978,7 +2962,7 @@ boolean P_SetupLevel(boolean skipprecip)
snprintf(tx, 63, "%s%s%s",
mapheaderinfo[gamemap-1]->lvlttl,
(strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart
((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE"),
((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone"),
(strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(", Act %s",mapheaderinfo[gamemap-1]->actnum) : "");
V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx);
I_UpdateNoVsync();
@ -3120,9 +3104,7 @@ boolean P_SetupLevel(boolean skipprecip)
P_PrepareThings(lastloadedmaplumpnum + ML_THINGS);
}
#ifdef ESLOPE
P_ResetDynamicSlopes();
#endif
P_LoadThings();

View File

@ -99,7 +99,6 @@ static fixed_t P_InterceptVector2(divline_t *v2, divline_t *v1)
return frac;
}
#ifdef POLYOBJECTS
static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los)
{
size_t i;
@ -145,7 +144,6 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los)
return true;
}
#endif
//
// P_CrossSubsector
@ -156,9 +154,7 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
{
seg_t *seg;
INT32 count;
#ifdef POLYOBJECTS
polyobj_t *po; // haleyjd 02/23/06
#endif
#ifdef RANGECHECK
if (num >= numsubsectors)
@ -168,7 +164,6 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
// haleyjd 02/23/06: this assignment should be after the above check
seg = segs + subsectors[num].firstline;
#ifdef POLYOBJECTS
// haleyjd 02/23/06: check polyobject lines
if ((po = subsectors[num].polyList))
{
@ -183,7 +178,6 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
po = (polyobj_t *)(po->link.next);
}
}
#endif
for (count = subsectors[num].numlines; --count >= 0; seg++) // check lines
{
@ -334,15 +328,10 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
// killough 11/98: shortcut for melee situations
// same subsector? obviously visible
#ifndef POLYOBJECTS
if (t1->subsector == t2->subsector)
return true;
#else
// haleyjd 02/23/06: can't do this if there are polyobjects in the subsec
if (!t1->subsector->polyList &&
t1->subsector == t2->subsector)
return true;
#endif
// An unobstructed LOS is possible.
// Now look from eyes of t1 to any part of t2.

View File

@ -23,7 +23,6 @@
#include "p_maputl.h"
#include "w_wad.h"
#ifdef ESLOPE
static pslope_t *slopelist = NULL;
static UINT16 slopecount = 0;
@ -620,7 +619,6 @@ void P_ResetDynamicSlopes(void) {
size_t i;
#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning
boolean warned = false;
#endif
slopelist = NULL;
slopecount = 0;

View File

@ -13,7 +13,6 @@
#ifndef P_SLOPES_H__
#define P_SLOPES_H__
#ifdef ESLOPE
void P_CalculateSlopeNormal(pslope_t *slope);
void P_ResetDynamicSlopes(void);
void P_RunDynamicSlopes(void);
@ -41,7 +40,6 @@ void P_SlopeLaunch(mobj_t *mo);
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope);
void P_ButteredSlope(mobj_t *mo);
#endif
// EOF
#endif // #ifdef ESLOPE

View File

@ -1242,7 +1242,6 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start)
}
// haleyjd: temporary define
#ifdef POLYOBJECTS
//
// PolyDoor
@ -1451,7 +1450,6 @@ static boolean PolyDisplace(line_t *line)
return EV_DoPolyObjDisplace(&pdd);
}
#endif // ifdef POLYOBJECTS
/** Changes a sector's tag.
* Used by the linedef executor tag changer and by crumblers.
@ -3200,7 +3198,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
break;
}
#ifdef POLYOBJECTS
case 480: // Polyobj_DoorSlide
case 481: // Polyobj_DoorSwing
PolyDoor(line);
@ -3227,7 +3224,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 491:
PolyTranslucency(line);
break;
#endif
default:
break;
@ -4984,10 +4980,8 @@ void P_UpdateSpecials(void)
// POINT LIMIT
P_CheckPointLimit();
#ifdef ESLOPE
// Dynamic slopeness
P_RunDynamicSlopes();
#endif
// ANIMATE TEXTURES
for (anim = anims; anim < lastanim; anim++)
@ -5132,11 +5126,9 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f
ffloor->topyoffs = &sec2->ceiling_yoffs;
ffloor->topangle = &sec2->ceilingpic_angle;
#ifdef ESLOPE
// Add slopes
ffloor->t_slope = &sec2->c_slope;
ffloor->b_slope = &sec2->f_slope;
#endif
if ((flags & FF_SOLID) && (master->flags & ML_EFFECT1)) // Block player only
flags &= ~FF_BLOCKOTHERS;
@ -5583,15 +5575,11 @@ void T_LaserFlash(laserthink_t *flash)
sourcesec = ffloor->master->frontsector; // Less to type!
#ifdef ESLOPE
top = (*ffloor->t_slope) ? P_GetZAt(*ffloor->t_slope, sector->soundorg.x, sector->soundorg.y)
: *ffloor->topheight;
bottom = (*ffloor->b_slope) ? P_GetZAt(*ffloor->b_slope, sector->soundorg.x, sector->soundorg.y)
: *ffloor->bottomheight;
sector->soundorg.z = (top + bottom)/2;
#else
sector->soundorg.z = (*ffloor->topheight + *ffloor->bottomheight)/2;
#endif
S_StartSound(&sector->soundorg, sfx_laser);
// Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough*
@ -6688,13 +6676,11 @@ void P_SpawnSpecials(INT32 fromnetsave)
sectors[s].midmap = lines[i].frontsector->midmap;
break;
#ifdef ESLOPE // Slope copy specials. Handled here for sanity.
case 720:
case 721:
case 722:
P_CopySectorSlope(&lines[i]);
break;
#endif
default:
break;
@ -6708,7 +6694,6 @@ void P_SpawnSpecials(INT32 fromnetsave)
Z_Free(secthinkers);
#ifdef POLYOBJECTS
// haleyjd 02/20/06: spawn polyobjects
Polyobj_InitLevel();
@ -6725,7 +6710,6 @@ void P_SpawnSpecials(INT32 fromnetsave)
break;
}
}
#endif
P_RunLevelLoadExecutors();
}
@ -7246,11 +7230,9 @@ void T_Disappear(disappear_t *d)
if (!(lines[d->sourceline].flags & ML_NOCLIMB))
{
#ifdef ESLOPE
if (*rover->t_slope)
sectors[s].soundorg.z = P_GetZAt(*rover->t_slope, sectors[s].soundorg.x, sectors[s].soundorg.y);
else
#endif
sectors[s].soundorg.z = *rover->topheight;
S_StartSound(&sectors[s].soundorg, sfx_appear);
}

View File

@ -726,9 +726,9 @@ void P_Ticker(boolean run)
if (exitcountdown > 1)
exitcountdown--;
if (indirectitemcooldown > 1)
if (indirectitemcooldown > 0)
indirectitemcooldown--;
if (hyubgone > 1)
if (hyubgone > 0)
hyubgone--;
if (G_BattleGametype())

View File

@ -1781,13 +1781,8 @@ boolean P_InSpaceSector(mobj_t *mo) // Returns true if you are in space
if (GETSECSPECIAL(rover->master->frontsector->special, 1) != SPACESPECIAL)
continue;
#ifdef ESLOPE
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : *rover->topheight;
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, mo->x, mo->y) : *rover->bottomheight;
#else
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#endif
if (mo->z + (mo->height/2) > topheight)
continue;
@ -1821,13 +1816,8 @@ boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand
if (!(rover->flags & FF_QUICKSAND))
continue;
#ifdef ESLOPE
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : *rover->topheight;
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, mo->x, mo->y) : *rover->bottomheight;
#else
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#endif
if (mo->z + flipoffset > topheight)
continue;
@ -1966,9 +1956,7 @@ static void P_CheckBouncySectors(player_t *player)
fixed_t oldx;
fixed_t oldy;
fixed_t oldz;
#ifdef ESLOPE
vector3_t momentum;
#endif
oldx = player->mo->x;
oldy = player->mo->y;
@ -2023,7 +2011,6 @@ static void P_CheckBouncySectors(player_t *player)
{
fixed_t newmom;
#ifdef ESLOPE
pslope_t *slope;
if (abs(oldz - topheight) < abs(oldz + player->mo->height - bottomheight)) { // Hit top
slope = *rover->t_slope;
@ -2039,9 +2026,6 @@ static void P_CheckBouncySectors(player_t *player)
P_ReverseQuantizeMomentumToSlope(&momentum, slope);
newmom = momentum.z = -FixedMul(momentum.z,linedist)/2;
#else
newmom = -FixedMul(player->mo->momz,linedist);
#endif
if (abs(newmom) < (linedist*2))
{
@ -2064,7 +2048,6 @@ static void P_CheckBouncySectors(player_t *player)
else if (newmom < -P_GetPlayerHeight(player)/2)
newmom = -P_GetPlayerHeight(player)/2;
#ifdef ESLOPE
momentum.z = newmom*2;
if (slope)
@ -2073,9 +2056,6 @@ static void P_CheckBouncySectors(player_t *player)
player->mo->momx = momentum.x;
player->mo->momy = momentum.y;
player->mo->momz = momentum.z/2;
#else
player->mo->momz = newmom;
#endif
if (player->pflags & PF_SPINNING)
{
@ -2132,13 +2112,8 @@ static void P_CheckQuicksand(player_t *player)
if (!(rover->flags & FF_QUICKSAND))
continue;
#ifdef ESLOPE
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight;
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
#else
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#endif
if (topheight >= player->mo->z && bottomheight < player->mo->z + player->mo->height)
{
@ -2506,15 +2481,10 @@ static void P_DoClimbing(player_t *player) // SRB2kart - unused
floorclimb = true;
else
{
#ifdef ESLOPE
floorheight = glidesector->sector->f_slope ? P_GetZAt(glidesector->sector->f_slope, player->mo->x, player->mo->y)
: glidesector->sector->floorheight;
ceilingheight = glidesector->sector->c_slope ? P_GetZAt(glidesector->sector->c_slope, player->mo->x, player->mo->y)
: glidesector->sector->ceilingheight;
#else
floorheight = glidesector->sector->floorheight;
ceilingheight = glidesector->sector->ceilingheight;
#endif
if (glidesector->sector->ffloors)
{
@ -2528,13 +2498,8 @@ static void P_DoClimbing(player_t *player) // SRB2kart - unused
floorclimb = true;
#ifdef ESLOPE
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight;
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
#else
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#endif
// Only supports rovers that are moving like an 'elevator', not just the top or bottom.
if (rover->master->frontsector->floorspeed && rover->master->frontsector->ceilspeed == 42)
@ -2575,11 +2540,7 @@ static void P_DoClimbing(player_t *player) // SRB2kart - unused
if (roverbelow == rover)
continue;
#ifdef ESLOPE
bottomheight2 = *roverbelow->b_slope ? P_GetZAt(*roverbelow->b_slope, player->mo->x, player->mo->y) : *roverbelow->bottomheight;
#else
bottomheight2 = *roverbelow->bottomheight;
#endif
if (bottomheight2 < topheight + FixedMul(16*FRACUNIT, player->mo->scale))
foundfof = true;
@ -2625,11 +2586,7 @@ static void P_DoClimbing(player_t *player) // SRB2kart - unused
if (roverbelow == rover)
continue;
#ifdef ESLOPE
topheight2 = *roverbelow->t_slope ? P_GetZAt(*roverbelow->t_slope, player->mo->x, player->mo->y) : *roverbelow->topheight;
#else
topheight2 = *roverbelow->topheight;
#endif
if (topheight2 > bottomheight - FixedMul(16*FRACUNIT, player->mo->scale))
foundfof = true;
@ -2684,11 +2641,7 @@ static void P_DoClimbing(player_t *player) // SRB2kart - unused
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP))
continue;
#ifdef ESLOPE
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
#else
bottomheight = *rover->bottomheight;
#endif
if (bottomheight < floorheight + FixedMul(16*FRACUNIT, player->mo->scale))
{
@ -2729,11 +2682,7 @@ static void P_DoClimbing(player_t *player) // SRB2kart - unused
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP))
continue;
#ifdef ESLOPE
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight;
#else
topheight = *rover->topheight;
#endif
if (topheight > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale))
{
@ -3102,12 +3051,10 @@ static void P_DoTeeter(player_t *player) // SRB2kart - unused.
ceilingheight = sec->ceilingheight;
floorheight = sec->floorheight;
#ifdef ESLOPE
if (sec->c_slope)
ceilingheight = P_GetZAt(sec->c_slope, checkx, checky);
if (sec->f_slope)
floorheight = P_GetZAt(sec->f_slope, checkx, checky);
#endif
highestceilingheight = (ceilingheight > highestceilingheight) ? ceilingheight : highestceilingheight;
lowestfloorheight = (floorheight < lowestfloorheight) ? floorheight : lowestfloorheight;
@ -3118,13 +3065,8 @@ static void P_DoTeeter(player_t *player) // SRB2kart - unused.
{
if (!(rover->flags & FF_EXISTS)) continue;
#ifdef ESLOPE
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight;
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
#else
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#endif
if (P_CheckSolidLava(player->mo, rover))
;
@ -3196,7 +3138,6 @@ static void P_DoTeeter(player_t *player) // SRB2kart - unused.
BMBOUNDFIX(xl, xh, yl, yh);
// Polyobjects
#ifdef POLYOBJECTS
validcount++;
for (by = yl; by <= yh; by++)
@ -3290,7 +3231,6 @@ static void P_DoTeeter(player_t *player) // SRB2kart - unused.
plink = (polymaplink_t *)(plink->link.next);
}
}
#endif
if (teeter) // only bother with objects as a last resort if you were already teetering
{
mobj_t *oldtmthing = tmthing;
@ -3583,9 +3523,7 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) // SRB2kart - unused.
&& !P_PlayerInPain(player)) // subsequent revs
{
if ((cmd->buttons & BT_BRAKE) && player->speed < FixedMul(5<<FRACBITS, player->mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING)
#ifdef ESLOPE
&& (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2)
#endif
)
{
player->mo->momx = player->cmomx;
@ -3616,9 +3554,7 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) // SRB2kart - unused.
// AKA Just go into a spin on the ground, you idiot. ;)
else if ((cmd->buttons & BT_BRAKE || ((twodlevel || (player->mo->flags2 & MF2_TWOD)) && cmd->forwardmove < -20))
&& !player->climbing && !player->mo->momz && onground && (player->speed > FixedMul(5<<FRACBITS, player->mo->scale)
#ifdef ESLOPE
|| (player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)
#endif
) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING))
{
player->pflags |= PF_SPINNING;
@ -3632,9 +3568,7 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) // SRB2kart - unused.
// Rolling normally
if (onground && player->pflags & PF_SPINNING && !(player->pflags & PF_STARTDASH)
&& player->speed < FixedMul(5*FRACUNIT,player->mo->scale)
#ifdef ESLOPE
&& (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2)
#endif
)
{
if (GETSECSPECIAL(player->mo->subsector->sector->special, 4) == 7 || (player->mo->ceilingz - player->mo->floorz < P_GetPlayerHeight(player)))
@ -3873,9 +3807,7 @@ static void P_2dMovement(player_t *player)
else if (player->onconveyor == 4 && !P_IsObjectOnGround(player->mo)) // Actual conveyor belt
player->cmomx = player->cmomy = 0;
else if (player->onconveyor != 2 && player->onconveyor != 4
#ifdef POLYOBJECTS
&& player->onconveyor != 1
#endif
)
player->cmomx = player->cmomy = 0;
@ -4023,12 +3955,10 @@ static void P_3dMovement(player_t *player)
//fixed_t normalspd = FixedMul(player->normalspeed, player->mo->scale);
boolean analogmove = false;
fixed_t oldMagnitude, newMagnitude;
#ifdef ESLOPE
vector3_t totalthrust;
totalthrust.x = totalthrust.y = 0; // I forget if this is needed
totalthrust.z = FRACUNIT*P_MobjFlip(player->mo)/3; // A bit of extra push-back on slopes
#endif // ESLOPE
// Get the old momentum; this will be needed at the end of the function! -SH
oldMagnitude = R_PointToDist2(player->mo->momx - player->cmomx, player->mo->momy - player->cmomy, 0, 0);
@ -4072,9 +4002,7 @@ static void P_3dMovement(player_t *player)
else if (player->onconveyor == 4 && !P_IsObjectOnGround(player->mo)) // Actual conveyor belt
player->cmomx = player->cmomy = 0;
else if (player->onconveyor != 2 && player->onconveyor != 4
#ifdef POLYOBJECTS
&& player->onconveyor != 1
#endif
)
player->cmomx = player->cmomy = 0;
@ -4152,12 +4080,8 @@ static void P_3dMovement(player_t *player)
movepushforward = 0;
}
#ifdef ESLOPE
totalthrust.x += P_ReturnThrustX(player->mo, movepushangle, movepushforward);
totalthrust.y += P_ReturnThrustY(player->mo, movepushangle, movepushforward);
#else
P_Thrust(player->mo, movepushangle, movepushforward);
#endif
}
else if (!(player->kartstuff[k_spinouttimer]))
{
@ -4172,15 +4096,10 @@ static void P_3dMovement(player_t *player)
else
movepushside = (cmd->sidemove * FRACUNIT/128) - FixedDiv(player->speed, K_GetKartSpeed(player, true));
#ifdef ESLOPE
totalthrust.x += P_ReturnThrustX(player->mo, movepushsideangle, movepushside);
totalthrust.y += P_ReturnThrustY(player->mo, movepushsideangle, movepushside);
#else
P_Thrust(player->mo, movepushsideangle, movepushside);
#endif
}
#ifdef ESLOPE
if ((totalthrust.x || totalthrust.y)
&& player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) > FRACUNIT/2) {
// Factor thrust to slope, but only for the part pushing up it!
@ -4200,7 +4119,6 @@ static void P_3dMovement(player_t *player)
player->mo->momx += totalthrust.x;
player->mo->momy += totalthrust.y;
#endif
// Time to ask three questions:
// 1) Are we over topspeed?
@ -5601,14 +5519,12 @@ void P_ElementalFireTrail(player_t *player)
{
newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale));
newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale));
#ifdef ESLOPE
if (player->mo->standingslope)
{
ground = P_GetZAt(player->mo->standingslope, newx, newy);
if (player->mo->eflags & MFE_VERTICALFLIP)
ground -= FixedMul(mobjinfo[MT_SPINFIRE].height, player->mo->scale);
}
#endif
flame = P_SpawnMobj(newx, newy, ground, MT_SPINFIRE);
P_SetTarget(&flame->target, player->mo);
flame->angle = travelangle;
@ -7487,13 +7403,14 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled)
{
static UINT8 lookbackdelay[4] = {0,0,0,0};
static boolean lookbackactive[MAXSPLITSCREENPLAYERS];
static UINT8 lookbackdelay[MAXSPLITSCREENPLAYERS];
UINT8 num;
angle_t angle = 0, focusangle = 0, focusaiming = 0;
fixed_t x, y, z, dist, height, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight;
fixed_t x, y, z, dist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight;
fixed_t pan, xpan, ypan;
INT32 camrotate;
boolean camstill, lookback;
boolean camstill, lookback, lookbackdown;
UINT8 timeover;
mobj_t *mo;
fixed_t f1, f2;
@ -7684,15 +7601,19 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
camstill = true;
else if (lookback || lookbackdelay[num]) // SRB2kart - Camera flipper
{
#define MAXLOOKBACKDELAY 2
camspeed = FRACUNIT;
if (lookback)
{
camrotate += 180;
lookbackdelay[num] = 2;
lookbackdelay[num] = MAXLOOKBACKDELAY;
}
else
lookbackdelay[num]--;
}
lookbackdown = (lookbackdelay[num] == MAXLOOKBACKDELAY) != lookbackactive[num];
lookbackactive[num] = (lookbackdelay[num] == MAXLOOKBACKDELAY);
#undef MAXLOOKBACKDELAY
if (mo->eflags & MFE_VERTICALFLIP)
camheight += thiscam->height;
@ -7735,8 +7656,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
thiscam->angle = angle;
}
height = camheight;
// sets ideal cam pos
dist = camdist;
@ -7745,10 +7664,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
dist += abs(thiscam->momz)/4;
if (player->kartstuff[k_boostcam])
{
dist -= FixedMul(11*dist/16, player->kartstuff[k_boostcam]);
height -= FixedMul(height, player->kartstuff[k_boostcam]);
}
x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
@ -7845,7 +7761,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
}
}
#ifdef POLYOBJECTS
// Check polyobjects and see if floorz/ceilingz need to be altered
{
INT32 xl, xh, yl, yh, bx, by;
@ -7924,7 +7839,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
}
}
}
#endif
// crushed camera
if (myceilingz <= myfloorz + thiscam->height && !resetcalled && !cameranoclip)
@ -8070,6 +7984,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
thiscam->aiming = ANGLE_22h;
}
if (lookbackdown)
P_MoveChaseCamera(player, thiscam, false);
return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming);
}
@ -8201,13 +8118,8 @@ static void P_CalcPostImg(player_t *player)
if (!(rover->flags & FF_EXISTS))
continue;
#ifdef ESLOPE
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight;
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
#else
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#endif
if (pviewheight >= topheight || pviewheight <= bottomheight)
continue;
@ -8229,13 +8141,8 @@ static void P_CalcPostImg(player_t *player)
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER)
continue;
#ifdef ESLOPE
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight;
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
#else
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#endif
if (pviewheight >= topheight || pviewheight <= bottomheight)
continue;
@ -8510,9 +8417,7 @@ void P_PlayerThink(player_t *player)
P_MobjCheckWater(player->mo);
#ifndef SECTORSPECIALSAFTERTHINK
#ifdef POLYOBJECTS
if (player->onconveyor != 1 || !P_IsObjectOnGround(player->mo))
#endif
player->onconveyor = 0;
// check special sectors : damage & secrets
@ -8670,10 +8575,8 @@ void P_PlayerThink(player_t *player)
// it lasts for one tic.
player->pflags &= ~PF_FULLSTASIS;
#ifdef POLYOBJECTS
if (player->onconveyor == 1)
player->cmomy = player->cmomx = 0;
#endif
//P_DoSuperStuff(player);
//P_CheckSneakerAndLivesTimer(player);
@ -8921,9 +8824,7 @@ void P_PlayerAfterThink(player_t *player)
cmd = &player->cmd;
#ifdef SECTORSPECIALSAFTERTHINK
#ifdef POLYOBJECTS
if (player->onconveyor != 1 || !P_IsObjectOnGround(player->mo))
#endif
player->onconveyor = 0;
// check special sectors : damage & secrets

View File

@ -371,15 +371,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back)
{
return (
#ifdef POLYOBJECTS
!line->polyseg &&
#endif
back->ceilingpic == front->ceilingpic
&& back->floorpic == front->floorpic
#ifdef ESLOPE
&& back->f_slope == front->f_slope
&& back->c_slope == front->c_slope
#endif
&& back->lightlevel == front->lightlevel
&& !line->sidedef->midtexture
// Check offsets too!
@ -494,7 +490,6 @@ static void R_AddLine(seg_t *line)
doorclosed = 0;
// Closed door.
#ifdef ESLOPE
if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope)
{
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
@ -537,7 +532,6 @@ static void R_AddLine(seg_t *line)
}
}
else
#endif
{
if (viewsector != backsector && viewsector != frontsector)
{
@ -654,7 +648,6 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
return true;
}
#ifdef POLYOBJECTS
size_t numpolys; // number of polyobjects in current subsector
size_t num_po_ptrs; // number of polyobject pointers allocated
@ -819,7 +812,6 @@ static void R_AddPolyObjects(subsector_t *sub)
R_AddLine(po_ptrs[i]->segs[j]);
}
}
#endif
//
// R_Subsector
@ -860,15 +852,11 @@ static void R_Subsector(size_t num)
floorcolormap = ceilingcolormap = frontsector->extra_colormap;
floorcenterz =
#ifdef ESLOPE
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->floorheight;
ceilingcenterz =
#ifdef ESLOPE
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->ceilingheight;
// Check and prep all 3D floors. Set the sector floor/ceiling light levels and colormaps.
@ -896,29 +884,21 @@ static void R_Subsector(size_t num)
sub->sector->extra_colormap = frontsector->extra_colormap;
if (((
#ifdef ESLOPE
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) :
#endif
frontsector->floorheight) < viewz || (frontsector->heightsec != -1
&& sectors[frontsector->heightsec].ceilingpic == skyflatnum)))
{
floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel,
frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL
#ifdef POLYOBJECTS_PLANES
, NULL
#endif
#ifdef ESLOPE
, frontsector->f_slope
#endif
, R_NoEncore(frontsector, false));
}
else
floorplane = NULL;
if (((
#ifdef ESLOPE
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, viewx, viewy) :
#endif
frontsector->ceilingheight) > viewz || frontsector->ceilingpic == skyflatnum
|| (frontsector->heightsec != -1
&& sectors[frontsector->heightsec].floorpic == skyflatnum)))
@ -926,21 +906,15 @@ static void R_Subsector(size_t num)
ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic,
ceilinglightlevel, frontsector->ceiling_xoffs, frontsector->ceiling_yoffs, frontsector->ceilingpic_angle,
ceilingcolormap, NULL
#ifdef POLYOBJECTS_PLANES
, NULL
#endif
#ifdef ESLOPE
, frontsector->c_slope
#endif
, R_NoEncore(frontsector, true));
}
else
ceilingplane = NULL;
numffloors = 0;
#ifdef ESLOPE
ffloor[numffloors].slope = NULL;
#endif
ffloor[numffloors].plane = NULL;
ffloor[numffloors].polyobj = NULL;
if (frontsector->ffloors)
@ -966,15 +940,11 @@ static void R_Subsector(size_t num)
ffloor[numffloors].polyobj = NULL;
heightcheck =
#ifdef ESLOPE
*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) :
#endif
*rover->bottomheight;
planecenterz =
#ifdef ESLOPE
*rover->b_slope ? P_GetZAt(*rover->b_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
*rover->bottomheight;
if (planecenterz <= ceilingcenterz
&& planecenterz >= floorcenterz
@ -987,21 +957,15 @@ static void R_Subsector(size_t num)
ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic,
*frontsector->lightlist[light].lightlevel, *rover->bottomxoffs,
*rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover
#ifdef POLYOBJECTS_PLANES
, NULL
#endif
#ifdef ESLOPE
, *rover->b_slope
#endif
, R_NoEncore(rover->master->frontsector, true));
#ifdef ESLOPE
ffloor[numffloors].slope = *rover->b_slope;
// Tell the renderer this sector has slopes in it.
if (ffloor[numffloors].slope)
frontsector->hasslope = true;
#endif
ffloor[numffloors].height = heightcheck;
ffloor[numffloors].ffloor = rover;
@ -1013,15 +977,11 @@ static void R_Subsector(size_t num)
ffloor[numffloors].polyobj = NULL;
heightcheck =
#ifdef ESLOPE
*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) :
#endif
*rover->topheight;
planecenterz =
#ifdef ESLOPE
*rover->t_slope ? P_GetZAt(*rover->t_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
*rover->topheight;
if (planecenterz >= floorcenterz
&& planecenterz <= ceilingcenterz
@ -1033,21 +993,15 @@ static void R_Subsector(size_t num)
ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic,
*frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle,
frontsector->lightlist[light].extra_colormap, rover
#ifdef POLYOBJECTS_PLANES
, NULL
#endif
#ifdef ESLOPE
, *rover->t_slope
#endif
, R_NoEncore(rover->master->frontsector, false));
#ifdef ESLOPE
ffloor[numffloors].slope = *rover->t_slope;
// Tell the renderer this sector has slopes in it.
if (ffloor[numffloors].slope)
frontsector->hasslope = true;
#endif
ffloor[numffloors].height = heightcheck;
ffloor[numffloors].ffloor = rover;
@ -1056,7 +1010,6 @@ static void R_Subsector(size_t num)
}
}
#ifdef POLYOBJECTS_PLANES
// Polyobjects have planes, too!
if (sub->polyList)
{
@ -1086,16 +1039,12 @@ static void R_Subsector(size_t num)
polysec->lightlevel, polysec->floor_xoffs, polysec->floor_yoffs,
polysec->floorpic_angle-po->angle,
NULL, NULL, po
#ifdef ESLOPE
, NULL // will ffloors be slopable eventually?
#endif
, R_NoEncore(polysec, false));
ffloor[numffloors].height = polysec->floorheight;
ffloor[numffloors].polyobj = po;
#ifdef ESLOPE
ffloor[numffloors].slope = NULL;
#endif
// ffloor[numffloors].ffloor = rover;
po->visplane = ffloor[numffloors].plane;
numffloors++;
@ -1115,16 +1064,12 @@ static void R_Subsector(size_t num)
polysec->lightlevel, polysec->ceiling_xoffs, polysec->ceiling_yoffs,
polysec->ceilingpic_angle-po->angle,
NULL, NULL, po
#ifdef ESLOPE
, NULL // will ffloors be slopable eventually?
#endif
, R_NoEncore(polysec, true));
ffloor[numffloors].polyobj = po;
ffloor[numffloors].height = polysec->ceilingheight;
#ifdef ESLOPE
ffloor[numffloors].slope = NULL;
#endif
// ffloor[numffloors].ffloor = rover;
po->visplane = ffloor[numffloors].plane;
numffloors++;
@ -1133,7 +1078,6 @@ static void R_Subsector(size_t num)
po = (polyobj_t *)(po->link.next);
}
}
#endif
#ifdef FLOORSPLATS
if (sub->splats)
@ -1156,18 +1100,14 @@ static void R_Subsector(size_t num)
firstseg = NULL;
#ifdef POLYOBJECTS
// haleyjd 02/19/06: draw polyobjects before static lines
if (sub->polyList)
R_AddPolyObjects(sub);
#endif
while (count--)
{
// CONS_Debug(DBG_GAMELOGIC, "Adding normal line %d...(%d)\n", line->linedef-lines, leveltime);
#ifdef POLYOBJECTS
if (!line->polyseg) // ignore segs that belong to polyobjects
#endif
R_AddLine(line);
line++;
curline = NULL; /* cph 2001/11/18 - must clear curline now we're done with it, so stuff doesn't try using it for other things */
@ -1186,11 +1126,9 @@ void R_Prep3DFloors(sector_t *sector)
fixed_t bestheight, maxheight;
INT32 count, i, mapnum;
sector_t *sec;
#ifdef ESLOPE
pslope_t *bestslope = NULL;
fixed_t heighttest; // I think it's better to check the Z height at the sector's center
// than assume unsloped heights are accurate indicators of order in sloped sectors. -Red
#endif
count = 1;
for (rover = sector->ffloors; rover; rover = rover->next)
@ -1213,14 +1151,10 @@ void R_Prep3DFloors(sector_t *sector)
else
memset(sector->lightlist, 0, sizeof (lightlist_t) * count);
#ifdef ESLOPE
heighttest = sector->c_slope ? P_GetZAt(sector->c_slope, sector->soundorg.x, sector->soundorg.y) : sector->ceilingheight;
sector->lightlist[0].height = heighttest + 1;
sector->lightlist[0].slope = sector->c_slope;
#else
sector->lightlist[0].height = sector->ceilingheight + 1;
#endif
sector->lightlist[0].lightlevel = &sector->lightlevel;
sector->lightlist[0].caster = NULL;
sector->lightlist[0].extra_colormap = sector->extra_colormap;
@ -1238,7 +1172,6 @@ void R_Prep3DFloors(sector_t *sector)
&& !(rover->flags & FF_CUTLEVEL) && !(rover->flags & FF_CUTSPRITES)))
continue;
#ifdef ESLOPE
heighttest = *rover->t_slope ? P_GetZAt(*rover->t_slope, sector->soundorg.x, sector->soundorg.y) : *rover->topheight;
if (heighttest > bestheight && heighttest < maxheight)
@ -1260,21 +1193,6 @@ void R_Prep3DFloors(sector_t *sector)
continue;
}
}
#else
if (*rover->topheight > bestheight && *rover->topheight < maxheight)
{
best = rover;
bestheight = *rover->topheight;
continue;
}
if (rover->flags & FF_DOUBLESHADOW && *rover->bottomheight > bestheight
&& *rover->bottomheight < maxheight)
{
best = rover;
bestheight = *rover->bottomheight;
continue;
}
#endif
}
if (!best)
{
@ -1285,9 +1203,7 @@ void R_Prep3DFloors(sector_t *sector)
sector->lightlist[i].height = maxheight = bestheight;
sector->lightlist[i].caster = best;
sector->lightlist[i].flags = best->flags;
#ifdef ESLOPE
sector->lightlist[i].slope = bestslope;
#endif
sec = &sectors[best->secnum];
mapnum = sec->midmap;
if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps)
@ -1313,12 +1229,8 @@ void R_Prep3DFloors(sector_t *sector)
if (best->flags & FF_DOUBLESHADOW)
{
#ifdef ESLOPE
heighttest = *best->b_slope ? P_GetZAt(*best->b_slope, sector->soundorg.x, sector->soundorg.y) : *best->bottomheight;
if (bestheight == heighttest) ///TODO: do this in a more efficient way -Red
#else
if (bestheight == *best->bottomheight)
#endif
{
sector->lightlist[i].lightlevel = sector->lightlist[best->lastlight].lightlevel;
sector->lightlist[i].extra_colormap =

View File

@ -44,13 +44,11 @@ void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2);
// no longer a static since this is used for encore in hw_main.c as well now:
boolean R_NoEncore(sector_t *sector, boolean ceiling);
#ifdef POLYOBJECTS
void R_SortPolyObjects(subsector_t *sub);
extern size_t numpolys; // number of polyobjects in current subsector
extern size_t num_po_ptrs; // number of polyobject pointers allocated
extern polyobj_t **po_ptrs; // temp ptr array to sort polyobject pointers
#endif
sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
INT32 *ceilinglightlevel, boolean back);

View File

@ -91,9 +91,7 @@ typedef struct
fixed_t z; ///< Z coordinate.
} degenmobj_t;
#ifdef POLYOBJECTS
#include "p_polyobj.h"
#endif
// Store fake planes in a resizable array insted of just by
// heightsec. Allows for multiple fake planes.
@ -155,11 +153,9 @@ typedef struct ffloor_s
fixed_t *bottomyoffs;
angle_t *bottomangle;
#ifdef ESLOPE
// Pointers to pointers. Yup.
struct pslope_s **t_slope;
struct pslope_s **b_slope;
#endif
size_t secnum;
ffloortype_e flags;
@ -190,9 +186,7 @@ typedef struct lightlist_s
extracolormap_t *extra_colormap;
INT32 flags;
ffloor_t *caster;
#ifdef ESLOPE
struct pslope_s *slope; // FF_DOUBLESHADOW makes me have to store this pointer here. Bluh bluh.
#endif
} lightlist_t;
@ -226,7 +220,6 @@ typedef struct linechain_s
// Slopes
#ifdef ESLOPE
typedef enum {
SL_NOPHYSICS = 1, // Don't do momentum adjustment with this slope
SL_NODYNAMIC = 1<<1, // Slope will never need to move during the level, so don't fuss with recalculating it
@ -269,7 +262,6 @@ typedef struct pslope_s
struct pslope_s *next; // Make a linked list of dynamic slopes, for easy reference later
} pslope_t;
#endif
typedef enum
{
@ -376,12 +368,10 @@ typedef struct sector_s
precipmobj_t *preciplist;
struct mprecipsecnode_s *touching_preciplist;
#ifdef ESLOPE
// Eternity engine slope
pslope_t *f_slope; // floor slope
pslope_t *c_slope; // ceiling slope
boolean hasslope; // The sector, or one of its visible FOFs, contains a slope
#endif
// these are saved for netgames, so do not let Lua touch these!
INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed
@ -437,9 +427,7 @@ typedef struct line_s
void *splats; // wallsplat_t list
#endif
INT32 firsttag, nexttag; // improves searches for tags.
#ifdef POLYOBJECTS
polyobj_t *polyobj; // Belongs to a polyobject?
#endif
char *text; // a concatination of all front and back texture names, for linedef specials that require a string.
INT16 callcount; // no. of calls left before triggering, for the "X calls" linedef specials, defaults to 0
@ -481,9 +469,7 @@ typedef struct subsector_s
sector_t *sector;
INT16 numlines;
UINT16 firstline;
#ifdef POLYOBJECTS
struct polyobj_s *polyList; // haleyjd 02/19/06: list of polyobjects
#endif
#if 1//#ifdef FLOORSPLATS
void *splats; // floorsplat_t list
#endif
@ -559,10 +545,8 @@ typedef struct seg_s
// Why slow things down by calculating lightlists for every thick side?
size_t numlights;
r_lightlist_t *rlights;
#ifdef POLYOBJECTS
polyobj_t *polyseg;
boolean dontrenderme;
#endif
} seg_t;
//
@ -639,11 +623,9 @@ typedef struct drawseg_s
UINT8 portalpass; // if > 0 and <= portalrender, do not affect sprite clipping
#ifdef ESLOPE
fixed_t maskedtextureheight[MAXVIDWIDTH]; // For handling sloped midtextures
vertex_t leftpos, rightpos; // Used for rendering FOF walls with slopes
#endif
} drawseg_t;
typedef enum

View File

@ -112,11 +112,9 @@ fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
UINT8 *ds_source; // start of a 64*64 tile image
UINT8 *ds_transmap; // one of the translucency tables
#ifdef ESLOPE
pslope_t *ds_slope; // Current slope being used
floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff?
float focallengthf, zeroheight;
#endif
/** \brief Variable flat sizes
*/

View File

@ -62,7 +62,6 @@ extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
extern UINT8 *ds_source; // start of a 64*64 tile image
extern UINT8 *ds_transmap;
#ifdef ESLOPE
typedef struct {
float x, y, z;
} floatv3_t;
@ -70,7 +69,6 @@ typedef struct {
extern pslope_t *ds_slope; // Current slope being used
extern floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff?
extern float focallengthf, zeroheight;
#endif
// Variable flat sizes
extern UINT32 nflatxshift;
@ -157,12 +155,10 @@ void ASMCALL R_DrawSpan_8_MMX(void);
void R_DrawTranslatedColumn_8(void);
void R_DrawTranslatedTranslucentColumn_8(void);
void R_DrawSpan_8(void);
#ifdef ESLOPE
void R_CalcTiltedLighting(fixed_t start, fixed_t end);
void R_DrawTiltedSpan_8(void);
void R_DrawTiltedTranslucentSpan_8(void);
void R_DrawTiltedSplat_8(void);
#endif
void R_DrawSplat_8(void);
void R_DrawTranslucentSplat_8(void);
void R_DrawTranslucentSpan_8(void);

View File

@ -620,7 +620,6 @@ void R_DrawSpan_8 (void)
}
}
#ifdef ESLOPE
// R_CalcTiltedLighting
// Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly.
static INT32 tiltlighting[MAXVIDWIDTH];
@ -1058,7 +1057,6 @@ void R_DrawTiltedSplat_8(void)
}
#endif
}
#endif // ESLOPE
/** \brief The R_DrawSplat_8 function
Just like R_DrawSpan_8, but skips transparent pixels.

View File

@ -536,9 +536,7 @@ static void R_InitTextureMapping(void)
focallength = FixedDiv(projection,
FINETANGENT(FINEANGLES/4+/*cv_fov.value*/ FIELDOFVIEW/2));
#ifdef ESLOPE
focallengthf = FIXED_TO_FLOAT(focallength);
#endif
for (i = 0; i < FINEANGLES/2; i++)
{
@ -1142,7 +1140,7 @@ void R_SetupFrame(player_t *player, boolean skybox)
aimingangle = player->aiming;
viewangle = viewmobj->angle;
if (/*!demo.playback && */player->playerstate != PST_DEAD)
if (!demo.playback && player->playerstate != PST_DEAD)
{
if (player == &players[consoleplayer])
{

View File

@ -322,11 +322,9 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
if (pindex >= MAXLIGHTZ)
pindex = MAXLIGHTZ - 1;
#ifdef ESLOPE
if (currentplane->slope)
ds_colormap = colormaps;
else
#endif
ds_colormap = planezlight[pindex];
if (encoremap && !currentplane->noencore)
ds_colormap += (256*32);
@ -402,7 +400,7 @@ static visplane_t *new_visplane(unsigned hash)
visplane_t *check = freetail;
if (!check)
{
check = calloc(2, sizeof (*check));
check = calloc(1, sizeof (*check));
if (check == NULL) I_Error("%s: Out of memory", "new_visplane"); // FIXME: ugly
}
else
@ -424,20 +422,14 @@ static visplane_t *new_visplane(unsigned hash)
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap,
ffloor_t *pfloor
#ifdef POLYOBJECTS_PLANES
, polyobj_t *polyobj
#endif
#ifdef ESLOPE
, pslope_t *slope
#endif
, boolean noencore)
{
visplane_t *check;
unsigned hash;
#ifdef ESLOPE
if (slope); else // Don't mess with this right now if a slope is involved
#endif
{
xoff += viewx;
yoff -= viewy;
@ -452,7 +444,6 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
}
}
#ifdef POLYOBJECTS_PLANES
if (polyobj)
{
if (polyobj->angle != 0)
@ -467,7 +458,6 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
yoff += polyobj->centerPt.y;
}
}
#endif
// This appears to fix the Nimbus Ruins sky bug.
if (picnum == skyflatnum && pfloor)
@ -481,12 +471,10 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
for (check = visplanes[hash]; check; check = check->next)
{
#ifdef POLYOBJECTS_PLANES
if (check->polyobj && pfloor)
continue;
if (polyobj != check->polyobj)
continue;
#endif
if (height == check->height && picnum == check->picnum
&& lightlevel == check->lightlevel
&& xoff == check->xoffs && yoff == check->yoffs
@ -495,9 +483,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
&& check->viewx == viewx && check->viewy == viewy && check->viewz == viewz
&& check->viewangle == viewangle
&& check->plangle == plangle
#ifdef ESLOPE
&& check->slope == slope
#endif
&& check->noencore == noencore)
{
return check;
@ -520,12 +506,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
check->viewz = viewz;
check->viewangle = viewangle;
check->plangle = plangle;
#ifdef POLYOBJECTS_PLANES
check->polyobj = polyobj;
#endif
#ifdef ESLOPE
check->slope = slope;
#endif
check->noencore = noencore;
memset(check->top, 0xff, sizeof (check->top));
@ -593,12 +575,8 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
new_pl->viewz = pl->viewz;
new_pl->viewangle = pl->viewangle;
new_pl->plangle = pl->plangle;
#ifdef POLYOBJECTS_PLANES
new_pl->polyobj = pl->polyobj;
#endif
#ifdef ESLOPE
new_pl->slope = pl->slope;
#endif
new_pl->noencore = pl->noencore;
pl = new_pl;
pl->minx = start;
@ -623,11 +601,9 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop)
INT32 unionl, unionh;
// INT32 x;
#ifdef POLYOBJECTS_PLANES
// Don't expand polyobject planes here - we do that on our own.
if (pl->polyobj)
return;
#endif
if (start < pl->minx)
{
@ -742,9 +718,7 @@ void R_DrawPlanes(void)
}
if (pl->ffloor != NULL
#ifdef POLYOBJECTS_PLANES
|| pl->polyobj != NULL
#endif
)
continue;
@ -773,7 +747,6 @@ void R_DrawSinglePlane(visplane_t *pl)
#endif
spanfunc = basespanfunc;
#ifdef POLYOBJECTS_PLANES
if (pl->polyobj && pl->polyobj->translucency != 0) {
spanfunc = R_DrawTranslucentSpan_8;
@ -795,7 +768,6 @@ void R_DrawSinglePlane(visplane_t *pl)
light = LIGHTLEVELS-1;
} else
#endif
if (pl->ffloor)
{
// Don't draw planes that shouldn't be drawn.
@ -861,9 +833,7 @@ void R_DrawSinglePlane(visplane_t *pl)
#ifndef NOWATER
if (pl->ffloor->flags & FF_RIPPLE
#ifdef ESLOPE
&& !pl->slope
#endif
)
{
INT32 top, bottom;
@ -902,9 +872,7 @@ void R_DrawSinglePlane(visplane_t *pl)
}
else light = (pl->lightlevel >> LIGHTSEGSHIFT);
#ifdef ESLOPE
if (!pl->slope) // Don't mess with angle on slopes! We'll handle this ourselves later
#endif
if (viewangle != pl->viewangle+pl->plangle)
{
memset(cachedheight, 0, sizeof (cachedheight));
@ -978,7 +946,6 @@ void R_DrawSinglePlane(visplane_t *pl)
if (light < 0)
light = 0;
#ifdef ESLOPE
if (pl->slope) {
// Potentially override other stuff for now cus we're mean. :< But draw a slope plane!
// I copied ZDoom's code and adapted it to SRB2... -fickle
@ -1118,7 +1085,6 @@ void R_DrawSinglePlane(visplane_t *pl)
planezlight = scalelight[light];
} else
#endif // ESLOPE
planezlight = zlight[light];

View File

@ -45,12 +45,8 @@ typedef struct visplane_s
fixed_t xoffs, yoffs; // Scrolling flats.
struct ffloor_s *ffloor;
#ifdef POLYOBJECTS_PLANES
polyobj_t *polyobj;
#endif
#ifdef ESLOPE
pslope_t *slope;
#endif
boolean noencore;
} visplane_t;
@ -83,12 +79,8 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2);
void R_DrawPlanes(void);
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle,
extracolormap_t *planecolormap, ffloor_t *ffloor
#ifdef POLYOBJECTS_PLANES
, polyobj_t *polyobj
#endif
#ifdef ESLOPE
, pslope_t *slope
#endif
, boolean noencore);
visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop);
@ -108,18 +100,14 @@ typedef struct planemgr_s
INT16 f_clip[MAXVIDWIDTH];
INT16 c_clip[MAXVIDWIDTH];
#ifdef ESLOPE
// For slope rendering; the height at the other end
fixed_t f_pos_slope;
fixed_t b_pos_slope;
struct pslope_s *slope;
#endif
struct ffloor_s *ffloor;
#ifdef POLYOBJECTS_PLANES
polyobj_t *polyobj;
#endif
} visffloor_t;
extern visffloor_t ffloor[MAXFFLOORS];

File diff suppressed because it is too large Load Diff

View File

@ -1052,10 +1052,8 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
if (!(sector->lightlist[i].caster->flags & FF_CUTSPRITES))
continue;
#ifdef ESLOPE
if (sector->lightlist[i].slope)
testheight = P_GetZAt(sector->lightlist[i].slope, sprite->gx, sprite->gy);
#endif
if (testheight >= sprite->gzt)
continue;
@ -1373,7 +1371,6 @@ static void R_ProjectSprite(mobj_t *thing)
if (thing->subsector->sector->numlights)
{
INT32 lightnum;
#ifdef ESLOPE // R_GetPlaneLight won't work on sloped lights!
light = thing->subsector->sector->numlights - 1;
for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) {
@ -1384,9 +1381,6 @@ static void R_ProjectSprite(mobj_t *thing)
break;
}
}
#else
light = R_GetPlaneLight(thing->subsector->sector, gzt, false);
#endif
lightnum = (*thing->subsector->sector->lightlist[light].lightlevel >> LIGHTSEGSHIFT);
if (lightnum < 0)
@ -1947,7 +1941,6 @@ static void R_CreateDrawNodes(void)
entry->ffloor = ds->thicksides[i];
}
}
#ifdef POLYOBJECTS_PLANES
// Check for a polyobject plane, but only if this is a front line
if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) {
plane = ds->curline->polyseg->visplane;
@ -1963,7 +1956,6 @@ static void R_CreateDrawNodes(void)
}
ds->curline->polyseg->visplane = NULL;
}
#endif
if (ds->maskedtexturecol)
{
entry = R_CreateDrawNode(&nodehead);
@ -2008,7 +2000,6 @@ static void R_CreateDrawNodes(void)
}
}
#ifdef POLYOBJECTS_PLANES
// find all the remaining polyobject planes and add them on the end of the list
// probably this is a terrible idea if we wanted them to be sorted properly
// but it works getting them in for now
@ -2029,7 +2020,6 @@ static void R_CreateDrawNodes(void)
// note: no seg is set, for what should be obvious reasons
PolyObjects[i].visplane = NULL;
}
#endif
if (visspritecount == 0)
return;
@ -2052,13 +2042,11 @@ static void R_CreateDrawNodes(void)
if (rover->szt > r2->plane->low || rover->sz < r2->plane->high)
continue;
#ifdef ESLOPE
// Effective height may be different for each comparison in the case of slopes
if (r2->plane->slope) {
planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy);
planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy);
} else
#endif
planeobjectz = planecameraz = r2->plane->height;
if (rover->mobjflags & MF_NOCLIPHEIGHT)
@ -2117,20 +2105,16 @@ static void R_CreateDrawNodes(void)
if (scale <= rover->sortscale)
continue;
#ifdef ESLOPE
if (*r2->ffloor->t_slope) {
topplaneobjectz = P_GetZAt(*r2->ffloor->t_slope, rover->gx, rover->gy);
topplanecameraz = P_GetZAt(*r2->ffloor->t_slope, viewx, viewy);
} else
#endif
topplaneobjectz = topplanecameraz = *r2->ffloor->topheight;
#ifdef ESLOPE
if (*r2->ffloor->b_slope) {
botplaneobjectz = P_GetZAt(*r2->ffloor->b_slope, rover->gx, rover->gy);
botplanecameraz = P_GetZAt(*r2->ffloor->b_slope, viewx, viewy);
} else
#endif
botplaneobjectz = botplanecameraz = *r2->ffloor->bottomheight;
if ((topplanecameraz > viewz && botplanecameraz < viewz) ||
@ -2762,7 +2746,7 @@ void R_AddSkins(UINT16 wadnum)
if (numskins >= MAXSKINS)
{
CONS_Debug(DBG_RENDER, "ignored skin (%d skins maximum)\n", 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
}
buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);

View File

@ -236,7 +236,7 @@ void S_StopSoundByNum(sfxenum_t sfxnum);
#ifdef MUSICSLOT_COMPATIBILITY
// For compatibility with code/scripts relying on older versions
// This is a list of all the "special" slot names and their associated numbers
const char *compat_special_music_slots[16];
extern const char *compat_special_music_slots[16];
#endif
#endif

View File

@ -70,6 +70,8 @@ if(${SDL2_FOUND})
set(SRB2_SDL2_TOTAL_SOURCES
${SRB2_CORE_SOURCES}
${SRB2_CORE_HEADERS}
${SRB2_DISCORDRPC_SOURCES}
${SRB2_DISCORDRPC_HEADERS}
${SRB2_PNG_SOURCES}
${SRB2_PNG_HEADERS}
${SRB2_CORE_RENDER_SOURCES}
@ -86,9 +88,11 @@ if(${SDL2_FOUND})
${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS})
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS})
source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES})
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
if(${SRB2_CONFIG_HWRENDER})
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
@ -153,6 +157,7 @@ if(${SDL2_FOUND})
${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES}
${CURL_LIBRARIES}
${DISCORDRPC_LIBRARIES}
)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
else()
@ -164,6 +169,7 @@ if(${SDL2_FOUND})
${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES}
${CURL_LIBRARIES}
${DISCORDRPC_LIBRARIES}
)
if(${CMAKE_SYSTEM} MATCHES Linux)
@ -244,6 +250,7 @@ if(${SDL2_FOUND})
${ZLIB_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${DISCORDRPC_INCLUDE_DIRS}
)
if(${SRB2_HAVE_MIXER})
@ -328,6 +335,10 @@ if(${SDL2_FOUND})
getwinlib(libgme "libgme.dll")
endif()
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
getwinlib(discord-rpc "discord-rpc.dll")
endif()
install(PROGRAMS
${win_extra_dll_list}
DESTINATION .

View File

@ -53,28 +53,6 @@ ifndef NOHW
OBJS+=$(OBJDIR)/r_opengl.o $(OBJDIR)/ogl_sdl.o
endif
ifndef NOHS
ifdef OPENAL
OBJS+=$(OBJDIR)/s_openal.o
OPTS+=-DSTATIC3DS
STATICHS=1
else
ifdef FMOD
OBJS+=$(OBJDIR)/s_fmod.o
OPTS+=-DSTATIC3DS
STATICHS=1
else
ifdef MINGW
ifdef DS3D
OBJS+=$(OBJDIR)/s_ds3d.o
OPTS+=-DSTATIC3DS
STATICHS=1
endif
endif
endif
endif
endif
ifdef NOMIXER
i_sound_o=$(OBJDIR)/sdl_sound.o
else
@ -83,6 +61,11 @@ else
SDL_LDFLAGS+=-lSDL2_mixer
endif
ifndef NOTHREADS
OPTS+=-DHAVE_THREADS
OBJS+=$(OBJDIR)/i_threads.o
endif
ifdef SDL_TTF
OPTS+=-DHAVE_TTF
SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz

View File

@ -249,6 +249,7 @@
<ClInclude Include="..\lzf.h" />
<ClInclude Include="..\md5.h" />
<ClInclude Include="..\mserv.h" />
<ClInclude Include="..\http-mserv.h" />
<ClInclude Include="..\m_aatree.h" />
<ClInclude Include="..\m_anigif.h" />
<ClInclude Include="..\m_argv.h" />
@ -399,6 +400,7 @@
<ClCompile Include="..\lzf.c" />
<ClCompile Include="..\md5.c" />
<ClCompile Include="..\mserv.c" />
<ClCompile Include="..\http-mserv.c" />
<ClCompile Include="..\m_aatree.c" />
<ClCompile Include="..\m_anigif.c" />
<ClCompile Include="..\m_argv.c" />

View File

@ -291,6 +291,9 @@
<ClInclude Include="..\mserv.h">
<Filter>I_Interface</Filter>
</ClInclude>
<ClInclude Include="..\http-mserv.h">
<Filter>I_Interface</Filter>
</ClInclude>
<ClInclude Include="..\lua_hook.h">
<Filter>LUA</Filter>
</ClInclude>
@ -663,6 +666,9 @@
<ClCompile Include="..\mserv.c">
<Filter>I_Interface</Filter>
</ClCompile>
<ClCompile Include="..\http-mserv.c">
<Filter>I_Interface</Filter>
</ClCompile>
<ClCompile Include="..\lua_baselib.c">
<Filter>LUA</Filter>
</ClCompile>

View File

@ -2782,6 +2782,50 @@
RelativePath="..\mserv.h"
>
</File>
<File
RelativePath="..\http-mserv.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\http-mserv.h"
>
</File>
</Filter>
<Filter
Name="M_Misc"

View File

@ -34,6 +34,7 @@
#ifdef _WIN32
#define RPC_NO_WINDOWS_H
#include <windows.h>
#include <shlobj.h>
#include "../doomtype.h"
typedef BOOL (WINAPI *p_GetDiskFreeSpaceExA)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
typedef BOOL (WINAPI *p_IsProcessorFeaturePresent) (DWORD);
@ -146,11 +147,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#define DEFAULTSEARCHPATH1 "/usr/local/games"
#define DEFAULTSEARCHPATH2 "/usr/games"
#define DEFAULTSEARCHPATH3 "/usr/local"
#elif defined (_WIN32)
#define DEFAULTWADLOCATION1 "c:\\games\\srb2kart"
#define DEFAULTWADLOCATION2 "\\games\\srb2kart"
#define DEFAULTSEARCHPATH1 "c:\\games"
#define DEFAULTSEARCHPATH2 "\\games"
#endif
/** \brief WAD file to look for
@ -168,6 +164,7 @@ static char returnWadPath[256];
#include "../i_video.h"
#include "../i_sound.h"
#include "../i_system.h"
#include "../i_threads.h"
#include "../screen.h" //vid.WndParent
#include "../d_net.h"
#include "../g_game.h"
@ -3134,6 +3131,10 @@ INT32 I_StartupSystem(void)
SDL_version SDLlinked;
SDL_VERSION(&SDLcompiled)
SDL_GetVersion(&SDLlinked);
#ifdef HAVE_THREADS
I_start_threads();
I_AddExitFunc(I_stop_threads);
#endif
I_StartupConsole();
#ifdef NEWSIGNALHANDLER
I_Fork();
@ -3655,6 +3656,18 @@ static const char *locateWad(void)
#endif
#ifdef DEFAULTDIR
I_OutputMsg(",HOME/" DEFAULTDIR);
// examine user jart directory
if ((envstr = I_GetEnv("HOME")) != NULL)
{
sprintf(returnWadPath, "%s" PATHSEP DEFAULTDIR, envstr);
if (isWadPathOk(returnWadPath))
return returnWadPath;
}
#endif
#ifdef CMAKECONFIG
#ifndef NDEBUG
I_OutputMsg(","CMAKE_ASSETS_DIR);
@ -3753,6 +3766,65 @@ static const char *locateWad(void)
return NULL;
}
#ifdef _WIN32
static FILE * openAppDataFile(const char *filename, const char *mode)
{
FILE * file = NULL;
char kdir[MAX_PATH];
if (SHGetFolderPathAndSubDirA(NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE,
NULL, 0, "SRB2Kart", kdir) == S_OK)
{
strcat(kdir, "\\");
strcat(kdir, filename);
file = fopen(kdir, mode);
}
return file;
}
#endif
void I_SaveCurrentWadDirectory(void)
{
#ifdef _WIN32
char path[MAX_PATH];
FILE * file = openAppDataFile("lastwaddir", "w");
if (file != NULL)
{
if (strcmp(srb2path, ".") == 0)
{
GetCurrentDirectoryA(sizeof path, path);
fputs(path, file);
}
else
{
fputs(srb2path, file);
}
fclose(file);
}
#endif
}
boolean I_UseSavedWadDirectory(void)
{
boolean ok = false;
#ifdef _WIN32
FILE * file = openAppDataFile("lastwaddir", "r");
if (file != NULL)
{
if (fgets(srb2path, sizeof srb2path, file) != NULL)
{
I_OutputMsg(
"Going to the last known directory with srb2.srb: %s\n",
srb2path);
ok = SetCurrentDirectoryA(srb2path);
}
fclose(file);
}
#endif
return ok;
}
const char *I_LocateWad(void)
{
const char *waddir;

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