Compare commits

..
Author SHA1 Message Date
Alug 3fdc829686 add g_localplayers similar to displayplayers
but this keeps track of actual local players and will never change during runtime
2024-12-30 17:27:04 +01:00
Alug f2b9077f5a no need to check for all this crap 2024-12-29 20:00:42 +01:00
Alug cd4bdde67c remove this turning off director
director will only work when in spec anyways
2024-12-29 19:46:54 +01:00
Alug de94ad24a5 Merge branch 'freecamstuffs' into splitscreendirector 2024-12-29 19:46:49 +01:00
Alug 6d01ec4c55 dont need this anymore 2024-12-29 19:46:44 +01:00
Alug f72c64d7d1 fix some potential issues with viewinterp
now unpaused disabled interp on netlag
also fixes screencoord stuff not being interpolated during pause
2024-12-29 19:46:41 +01:00
Alug 92a3e974b0 fix driftgauge showing with freecam while ingame 2024-12-29 19:46:35 +01:00
Alug 7d6cce5881 readd cam cmd stuff
cause it may break the cam in replays or smth a
2024-12-29 19:46:33 +01:00
Alug bb3f9b5882 fix wrong cam default controls 2024-12-29 16:51:24 +01:00
Alug 27d6447a83 fix wrong cam default controls 2024-12-29 16:51:18 +01:00
Alug 20044fa6a7 Merge branch 'freecamstuffs' into splitscreendirector 2024-12-29 16:47:25 +01:00
Alug 26480882c8 remove the remainder or demo.freecam 2024-12-29 16:43:34 +01:00
Alug b23020435f replace all this crap with either stplyrnum or R_GetViewNumber 2024-12-29 16:43:09 +01:00
Alug 267e2be69b fix offbyone issue 2024-12-29 16:42:33 +01:00
Alug b9428360c0 Merge branch 'Saturn-Next' into splitscreendirector 2024-12-29 16:16:59 +01:00
Alug 2112be8ef7 Merge branch 'Saturn-Next' into freecamstuffs 2024-12-29 16:16:49 +01:00
Alug 44288a5865 Merge branch 'unglobsavep' into Saturn-Next 2024-12-29 16:04:21 +01:00
Alug 66f89fb4ad oops 2024-12-29 16:03:56 +01:00
Alug eceb671ea8 add missing include 2024-12-29 16:02:05 +01:00
Alug a15615a229 add missing include 2024-12-29 16:01:35 +01:00
Alug 8e10bcc739 add a bunch of extra checks into demo stuff
buffer may be NULL in some cases
should fix dedis crashing when replay recording is disabled
2024-12-29 15:59:10 +01:00
Alug 22e65cd5e7 fixup conflicts 2024-12-29 15:58:43 +01:00
Alug 72383520cb Merge branch 'Saturn-Next' into unglobsavep 2024-12-29 15:51:25 +01:00
Alug 38ef55b869 add a mipmap check here ig 2024-12-29 15:41:28 +01:00
Alug 649373ff51 Merge branch 'freecamstuffs' into splitscreendirector 2024-12-29 06:41:40 +01:00
Alug ca09a5dd46 dont need to do this twice 2024-12-29 06:41:11 +01:00
Alug 11546cd906 fix centerview 2024-12-29 06:41:07 +01:00
Alug 4110130ca7 block freecam toggling when player is in spec 2024-12-29 06:41:04 +01:00
Alug 6b9900ad4e clean up cam stuff for good 2024-12-29 06:41:00 +01:00
Alug 97e6222176 make function to return button names
to use with new rebindable cam controls
2024-12-29 06:03:20 +01:00
Alug 3d39f50388 make function to return button names
to use with new rebindable cam controls
2024-12-29 06:03:10 +01:00
Alug eef56a7c82 make debugdirector show stuff for p1 atleast 2024-12-29 05:51:13 +01:00
Alug 8853666645 track views in directorinfo structs
should hopefully fix any potential remaining issues
2024-12-29 05:45:04 +01:00
Alug a379764076 fix director toggling + smol cleanup 2024-12-29 05:45:01 +01:00
Alug edd1cc6059 Merge branch 'freecamstuffs' into splitscreendirector 2024-12-29 05:44:53 +01:00
Alug f355b2269c toggle off freecam when f12ing 2024-12-29 05:42:31 +01:00
Alug 03280db377 missing inlucde 2024-12-28 18:52:57 +01:00
Alug 86aeff5547 cleanup K_DirectorIsAvailable 2024-12-28 18:25:23 +01:00
Alug b5b2062efa add K_DirectorIsAvailable 2024-12-28 18:25:05 +01:00
Alug b51731d675 cleanup director splitscreen stuff 2024-12-28 17:48:02 +01:00
Alug 229e8d9592 WIP splitscreen director lel 2024-12-28 17:47:58 +01:00
indev da9c19bba4 Update replayfreecam lua global to use camera.freecam for currently viewed player 2024-12-28 18:48:58 +03:00
Alug 3156851554 fix cam interp during pause again 2024-12-28 04:01:21 +01:00
Alug a19cb5f2bc fix speccam again 2024-12-28 04:01:18 +01:00
Alug 2639f94dff fix freecam not being steerable when not in spec
ugh this is godawful
its literally almost a complete copy of
2024-12-28 03:44:32 +01:00
Alug 2c769f8043 changable freecam speed 2024-12-28 01:46:20 +01:00
Alug 332f7db32f make freecam work in splitscreen
banish cameracmd shit
2024-12-28 01:46:17 +01:00
Alug 3381f6af3a set default controls for float and sink ig 2024-12-28 01:46:12 +01:00
Alug 45d33b951c add alternative cam float and sink buttons 2024-12-28 01:46:09 +01:00
Alug 1922b32799 add bindable freecam toggle 2024-12-28 01:46:06 +01:00
Alug 6bb72c363f fix freecam not being interpolated when ingame 2024-12-28 01:46:03 +01:00
Alug 378382f3ad use demo freecam for spec
its more versataile and lets you pass through walls and floors just like in replays
2024-12-28 01:45:59 +01:00
Alug 7e09493cf2 whoops this never did anything lol 2024-12-26 16:01:49 +01:00
Alug 126fce9119 1px 2024-12-26 01:08:12 +01:00
Alug 0b5879ffb3 fix compile 2024-12-26 01:00:52 +01:00
Alug 0bd2c6220d drifgauge gfx using the extra 3 speedometer sticker
arsepain
+ smol cleanup colorhud
2024-12-26 01:00:27 +01:00
Alug a434ce2080 super smol optimizations 2024-12-26 00:57:19 +01:00
Alug c8193380e7 make some cam stuff behave exactly like vanilla again
no clue if this changes anything at all, but cam stuff be causing so many issues id rather just have it behave like it used to
2024-12-23 17:45:59 +01:00
Alug e38580c9c2 dont remember removing this in s_sound 2024-12-23 17:45:54 +01:00
Alug c46ff7daff use P_MobjWasRemoved for HWR_DrawSprite 2024-12-22 21:19:08 +01:00
Alug 4418653edb Merge pull request #147 from Indev450/refactorogl
Refactor OpenGL library handling
2024-12-22 19:22:12 +01:00
Alug 1d9bcaa786 Merge branch 'Saturn-Next' into refactorogl 2024-12-22 19:21:27 +01:00
Alug 27bfd0078c fix compile 2024-12-22 18:38:17 +01:00
Alug 67a75730d0 Revert "massive cleanup unused code"
This reverts commit e35612a6f6.
2024-12-22 18:23:38 +01:00
Alug d12369f6f4 add some () 2024-12-22 01:47:14 +01:00
Alug 4a7ce87ac2 do the same for R_ProjectPrecipitationSprite 2024-12-22 01:44:33 +01:00
Alug d8b36ef0da dont put potential null mobj into interpolation stuff 2024-12-22 01:42:51 +01:00
Alug 1341ec80bf dont dereference potential null mobjs in software projectsprite 2024-12-22 01:40:52 +01:00
Alug 9882291828 compiler pls shut up 2024-12-22 01:32:05 +01:00
Alug aa4fa1e42e use P_MobjWasRemoved and null check for thing subsector in projectsprite 2024-12-22 01:32:01 +01:00
Alug 8a641d3e37 fix fade to menu again oops 2024-12-20 18:23:27 +01:00
Alug 317f5f8d48 fix no fbo compile 2024-12-20 18:23:25 +01:00
Alug 92c0ddd068 always reset those just in case 2024-12-20 11:35:30 +01:00
Alug 4f037896db oops this is lugstuff only lel 2024-12-20 11:27:49 +01:00
Alug 494a87feea idk just set to false here too 2024-12-20 11:19:18 +01:00
Alug 4a3af6bc8a whoops 2024-12-20 03:17:20 +01:00
Alug 0c7851bd26 try to clean up downsampling and resolution checking stuff
- global function that updates variables with current display resolution
-smol boolean function that quickly checks if the game res matches the desktop res
- i_downsample has been simplyfied a bit
2024-12-20 03:13:17 +01:00
Alug 5b46ae2eb9 better nvidia xwayland workaround handling
what in the world was i thinking????
2024-12-20 03:12:57 +01:00
Alug 2034eedbe4 add another early return 2024-12-20 01:21:09 +01:00
Alug fde4f64b83 simplify this crap and make compiler happy 2024-12-20 00:59:46 +01:00
Alug 404927c53c no 2024-12-20 00:59:22 +01:00
Alug e0796b0cf1 just query this once 2024-12-20 00:59:18 +01:00
Alug 8df8749a9c return false here 2024-12-20 00:58:41 +01:00
Alug 1c2fb14f45 makes no sense without screen tex 2024-12-20 00:58:35 +01:00
Alug 82f70ff75e fix compile due to missing am_map.h include 2024-12-19 22:42:22 +01:00
Alug 46b2d5fbcd fix compile without USE_FBO_OGL 2024-12-19 22:40:28 +01:00
Alug 23b2e35dbd use slightly diff maths for skydomevertex calc
from DSDA-Doom
maybe fixes some issues with certain skydomes?
2024-12-19 20:56:25 +01:00
Alug a576ddf0e4 oops 2024-12-19 20:43:05 +01:00
Alug df63b3ece0 add "listmapthings" and "listunusedsprites" commands
the former also shows duplicated mapthings
2024-12-19 20:34:10 +01:00
Alug 52cd614613 prevent potential crash if viewmobj was removed 2024-12-16 16:38:03 +01:00
Alug db04046cb3 smol fix for gamma stuff
-dont apply gamma adjust when gamma is on default value
-fix saturation not being applied on console on OpenGL without paletterendering
2024-12-16 15:48:33 +01:00
Alug 5ec48f72e0 fix changing gamma absolutely trashing performance
not quite sure why it made stuff die so much but uhhh
instead i just check in the cube initialistion function instead and only let it build when needed to not change how the game looks with raised gamma values
2024-12-15 22:14:57 +01:00
Alug 7a1c6bd9e4 slight cleanup K_GetScreenCoords and related functions
mostly just reducing scope and adding const clarifyier
also use mobjwasremoved checks everywhere instead of just simple null checks for some safety
2024-12-14 21:20:03 +01:00
Alug 75af036fcf seems like you CANNOT apply dispoffset to papersprites
well then
2024-12-14 16:53:34 +01:00
Alug accc9890df fix inverted papersprite roll
oopsie
2024-12-14 16:53:31 +01:00
indev cb97973b1c Merge pull request #150 from utkumaden/Saturn
Fixed gr_glinfo crash when there are way too many extensions present.
2024-12-12 19:21:15 +03:00
themixedupstuff 331f09cdd9 Fixed gr_glinfo crash when there are way too many extensions present. 2024-12-12 19:17:04 +03:00
indev 939084d57b Avoid overflowing CONS_Printf's buffer by using vsnprintf 2024-12-12 18:47:35 +03:00
indev 1cbfc71fc6 Revert "Change gl_extension to use glGetStringi instead of glGetString"
This reverts commit 7b550200f0.

Not supported on opengl version before 3.0 unfortunately
2024-12-12 18:03:16 +03:00
indev 7b550200f0 Change gl_extension to use glGetStringi instead of glGetString 2024-12-12 17:52:36 +03:00
indev 665a11fa2b Merge branch 'Saturn-Next' into refactorogl 2024-12-12 14:38:59 +03:00
indev 1a49b161cc Merge pull request #146 from utkumaden/Saturn
Add gr_glinfo.
2024-12-12 14:34:32 +03:00
Alug 99e4870a52 check for the flag first 2024-12-12 02:31:44 +01:00
Alug 13ad27bc90 remove some precip code dupe 2024-12-12 00:30:54 +01:00
Alug 7ae361cb7c better cv_lessprecip handling
idk what i was thinking lmao
2024-12-12 00:11:50 +01:00
Alug 0e1bfbb0b5 clean up hw_cache stuff + fix accidental wrong cast 2024-12-11 23:24:00 +01:00
Alug 3dec352245 smol cleanup GL_SetBlend
use early return since i likeit more
2024-12-11 22:14:20 +01:00
Alug 8e273a1f19 GL_UpdateTexture can be static 2024-12-11 22:14:17 +01:00
Alug 1ab20814e9 simplify GL_SetPalette
can just copy the whole struct
2024-12-11 14:39:38 +01:00
Alug 37649a0d3c more cleanup GL_UpdateTexture
also some optimizations
2024-12-11 14:23:51 +01:00
Alug f3d1bf1106 clean up GL_UpdateTexture
use switches and reduce code dupe
2024-12-11 14:23:48 +01:00
Alug 93311c628e Merge branch 'Saturn-Next' into refactorogl 2024-12-11 14:23:42 +01:00
Alug f8dfc954a0 test "or" 2024-12-11 03:11:33 +01:00
Alug dbe5f8a4ba clamp splitsprite heights aswell 2024-12-11 01:26:04 +01:00
Alug a05c38b1fe those should better be clamped oops 2024-12-11 01:25:55 +01:00
Alug 91b6143f15 clean up this stuff; make splitwall behave more like vanilla
changes some splitwall issues slightly but gives bit better performance in some cases
2024-12-11 01:25:52 +01:00
Alug 0eaedd4b5e "extra safety" 2024-12-11 01:25:42 +01:00
Alug 727a31fdb5 one line those 2024-12-10 21:18:20 +01:00
Alug 3b64263dc6 Unconditionally interpolate view
even if it may NOT change
but i get the feeling it may cause some issues
2024-12-10 21:18:17 +01:00
Alug 83b6a63f13 dont pass fwrapv to compiler flags
this technically changes behavior of some things, even if it MAY fix some undefined behaviour
2024-12-10 21:18:14 +01:00
Alug f6f6600118 interp.subsector is unused
so dont need to assign it nor call pointinsubsector for nothing
2024-12-09 23:20:07 +01:00
themixedupstuff 04c0bf2f17 Fix compiler warning on implicit GLuint* to GLint* conversion. 2024-12-09 17:30:04 +03:00
Alug 4da9c5ac07 "P_CheckSightFast" for lua
should be faster than normal P_CheckSight
only to be used for things like nametags etc so nothing gameplaywise as it will desynch
2024-12-09 10:53:11 +01:00
Alug 97cae4de59 smol things 2024-12-09 10:53:08 +01:00
Alug 74088c1d26 use loop instead of memcpy for setpalette
idk last time this died with models for some reason kek
2024-12-08 15:43:46 +01:00
Alug b03e74c366 rename to "hw_gl" 2024-12-08 15:39:52 +01:00
Alug cd9ee7d139 smol cleanup 2024-12-08 15:31:41 +01:00
Alug 3080f2953d optimized checksight for nametags and camera
idk should this be exposed to lua too?
2024-12-08 15:26:40 +01:00
Alug f7c7dae3a5 smol cleanup p_sight 2024-12-08 15:14:04 +01:00
Alug 3f16f42adf forgor 2024-12-08 05:03:36 +01:00
Alug 7b2e763d07 inline those two
smol speedup
2024-12-08 03:34:19 +01:00
Alug c1b771fdc8 fix make files 2024-12-08 03:16:13 +01:00
Alug e5b12ece35 change this 2024-12-08 03:15:14 +01:00
Alug 43c99f8851 delet this 2024-12-08 03:13:50 +01:00
Alug 7304988071 fix conflitc 2024-12-08 03:12:48 +01:00
Alug d0b0a7490a Merge branch 'Saturn-Next' into refactorogl 2024-12-08 03:06:26 +01:00
Alug de4bcec782 make those less chaotic 2024-12-08 01:34:16 +01:00
Alug 0e843c2a96 stuff 2024-12-08 01:33:53 +01:00
Alug 9abd34baa3 proper macros 2024-12-08 01:33:44 +01:00
Alug 4fca31049f no need to set all that stuff manually 2024-12-07 12:52:09 +01:00
Alug 13f6b62dc0 port updated skydome code from srb2
seems to actually fix some visual issues on certain maps with it
2024-12-07 12:38:53 +01:00
Alug 3a5b282b9b try less maths for projectionmatrix
from dsdadoom again lul
2024-12-07 12:33:13 +01:00
themixedupstuff d763456655 Add gr_glinfo. 2024-12-05 22:38:47 +03:00
themixedupstuff b23fa084f1 Add GL_VENDOR string to the list of global GL variables. 2024-12-05 21:54:31 +03:00
Alug 216acf083a bruh 2024-12-05 14:30:19 +01:00
Alug 686a9f7237 use long M_PI to fix some render issues 2024-12-05 14:30:16 +01:00
Alug 5a206822c5 little extra safety 2024-12-05 08:10:13 +01:00
Alug 9805b03533 reduce the scope of those
only this function needs those
2024-12-05 08:08:00 +01:00
Alug d519f9cf06 try fix keepmusic occasionally not working
idk but sometimes DoReborn broke it?
also this ensures keepmusic and skipintromus flags always get reset
2024-12-05 07:58:20 +01:00
Alug 6265d0e38e why does this need a variable?
it just gets assigned kartstuff[k_aizdriftstrat] anyways?
2024-12-04 14:23:06 +01:00
Alug 55d9d64910 clean up this mess 2024-12-04 14:23:03 +01:00
Alug e2a651e553 make those const 2024-12-04 14:23:00 +01:00
Alug e4343f0935 only ever call pointtoangle for sprites that really need it 2024-12-04 01:39:17 +01:00
Alug 68090a55e1 change this a little 2024-12-03 21:50:45 +01:00
Alug 00bdd684ed 1463 lmao change this to be readable
also raise to 40 secs
2024-12-03 20:52:02 +01:00
Alug f4e498e559 this may be used unitialised lul 2024-12-03 20:40:05 +01:00
Alug 39c33b1f59 Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Next 2024-12-03 20:39:54 +01:00
Alug 55acbb208e try to make demo data handling a bit safer
- Use Z_Malloc to allocate demobuffer
- Use Z_Free to free demobuffer
- Make functions for freeing and resseting demobuffer
- Always reset demobuffer when not saving
2024-12-03 20:39:46 +01:00
indev 208f96535e Add MENUCAPS to some menu options 2024-12-03 22:06:35 +03:00
Alug 64bda53a78 Merge pull request #144 from Indev450/mobjcache2
Cache and reuse removed mobjs when spawning mobjs - Take 2
2024-12-02 21:31:25 +01:00
Alug e016777331 Merge pull request #145 from Indev450/hooklibrefactor
Lua Hooklib refactor
2024-12-02 21:31:16 +01:00
Alug 508cab4a0d Merge pull request #142 from Indev450/fastpoinonside
Add R_PointOnSideFast and R_PointInSubsectorFast and use it to optimize some non synch critical things
2024-12-02 21:13:07 +01:00
Alug b779be3574 Merge branch 'Saturn-Next' into hooklibrefactor 2024-12-02 21:12:16 +01:00
Alug fddcebc2d2 Merge branch 'fastpoinonside' into mobjcache2 2024-12-02 21:11:18 +01:00
Alug 91c5dc3c19 Merge branch 'Saturn-Next' into fastpoinonside 2024-12-02 21:11:10 +01:00
Alug 9401eb1591 oops revert this just in case 2024-12-02 21:09:58 +01:00
Alug 521bb88cda gah 2024-12-02 20:58:01 +01:00
Alug c1765258b2 quickncasehash 2024-12-02 20:57:08 +01:00
Alug 6afcb06e08 forgor
- refactored musicdef handling
- other things
2024-12-02 20:56:21 +01:00
Alug 1ae5bb9d27 lugstuff merge
- Completely refactor player camera handling
- Refactor ALOT of gamepad code
- Refactor local cmds
- Refactor automap and add minimap generator ("minigen" command)
- Remove a bunch of unused netcode
- Remove ALOT of unused gametype code
- Remove alot of unused bot code
- Optimize some sectorspecial code slightly
- Remove a bunch of nights mode related stuff that was unused
- Bunch of smaller optimizations and code improvements
2024-12-02 20:49:53 +01:00
Alug 252cd5cde5 better fix for netgame join hoop crash
this actually works and makes em animate
apparently somehow on netjoin some hprev entries get mangled but are not null?
no clue why that happens since hoops arent even netsynched only their "spawnpoint" is
2024-12-01 22:14:24 +01:00
Alug 12558740a4 better fix for G_FixCamera
completely forgor in kart and srb2.1 cmd.angleturn needs to be bitshifted to accomidate localangle
using it again is better, since player mobj angle is not always suitable for localangle and may slightly mismatch where a player is steering
2024-12-01 10:29:06 +01:00
Alug e1fbe8d657 seems like player not always have mobjs
titledemo moment
2024-12-01 10:18:18 +01:00
Alug b29a3ecfba this only ever applies to ogl
no need in software lol
2024-11-30 23:39:18 +01:00
Alug bd3a5ac284 give those better names 2024-11-30 23:23:05 +01:00
Alug 7de8b2d881 save one R_PointToAngle call
very smol optimisation lul
2024-11-30 22:31:45 +01:00
Alug 3139dff6ba missed this 2024-11-30 22:04:56 +01:00
Alug c4211045f2 oops this gets directly called in one instance
also why do we keep checking for null mobj when P_MobjWasRemoved checks that anyways?
2024-11-30 21:59:56 +01:00
Alug 6633dfe1e2 smol cleanup 2024-11-30 21:54:55 +01:00
Alug 9e2a48cae1 whoops 2024-11-30 21:54:52 +01:00
Alug 43f8a0213a sloperoll already has "off" setting, delet spriteroll cvar since redundant 2024-11-30 21:54:48 +01:00
Alug 975978ca9c this is null anyways if disabled 2024-11-30 21:54:45 +01:00
Alug dad630f3eb delet this 2024-11-30 20:29:08 +01:00
Alug 11f8b974df forgor sliptide roll 2024-11-30 20:28:26 +01:00
Alug 00773a0c10 okay? shut up compiler 2024-11-30 20:09:12 +01:00
Alug 6f6066906e optimize sprite rotation / sprite drawing a bit
- make software and ogl use same variable names
- let papersprites also roll in ogl not just software
- throw pitchnroll calc into a function to reduce code dupe
- save some calcs when having sliptide roll disabled
- fix software not calculating camang when just player roll is enabled (did that ever work right before? oops)
- determine early if the sprite is supposed to rotate, and only if it really does, run the rotation stuff
2024-11-30 20:05:15 +01:00
Alug 7730b69ef4 delete A_RollAngle things
they cant be used, since theyre not synchsafe
and nothing uses those anyways
2024-11-30 20:05:13 +01:00
Alug e3084cc28e allow demo play commands while watching a demo again 2024-11-29 23:25:58 +01:00
Alug b784fc58d0 loading not sending
just to clarify
2024-11-29 22:25:13 +01:00
Alug 8baa972bb2 this is also redundant 2024-11-29 13:15:59 +01:00
Alug 3b2251017c use continue instead of huge if block 2024-11-29 12:14:28 +01:00
Alug f0e7dace72 Merge branch 'Saturn-Next' into mobjcache2 2024-11-29 11:34:03 +01:00
Alug 4a837d3339 Fix buffer overrun with players with no associated node
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/810/diffs?commit_id=af9164f336a65634f6908e677b47773d88f583af
2024-11-29 10:41:00 +01:00
Alug a2aa43e7fc dont think we need to reset anything here
kick cmd gets send out which should clear stuff in theory
2024-11-29 10:40:09 +01:00
Alug 3c0899263f those are redundant 2024-11-29 10:14:47 +01:00
Alug 91bb601ecb why? 2024-11-29 10:14:43 +01:00
Alug 1bd0c5d9bf those dont need to be inlined tbh 2024-11-29 09:37:13 +01:00
Alug 8b76426825 remove dupes 2024-11-29 09:37:10 +01:00
Alug 85464921ba eh this looks better 2024-11-29 09:37:07 +01:00
indev 9b6034853f Simplify consistency check a bit 2024-11-28 22:24:51 +03:00
indev 0ab732c9b2 Only check nodes that are in game in SV_ResendingSavegameToAnyone 2024-11-28 22:03:29 +03:00
Alug 8662648ef5 init polyobject thinker->references to 0
otherwise they wont get removed alot of the time
2024-11-27 23:00:32 +01:00
Alug 51808b8ced init polyobject thinker->references to 0
otherwise they wont get removed alot of the time
2024-11-27 23:00:16 +01:00
indev 2a7e442544 Use textinput_t for addon search 2024-11-28 00:54:26 +03:00
Alug dbdd5b8b6e only apply palrender postprocess shader once 2024-11-27 22:34:48 +01:00
Alug b8483376c4 dont draw final screen texture twice if you use native res
no need to
saves some performance
2024-11-27 22:29:49 +01:00
Alug 70105ccefc make own screentex for vhs effect
idk if its really needed tbh, but also doesent hurt
2024-11-27 17:12:25 +01:00
Alug 3a9082a694 memset screentex to 0 in FlushScreenTextures 2024-11-27 17:10:56 +01:00
Alug 82c18be717 why do replay play commands only have netgame check???????
bad things will happen if theyre played ingame regardless of netgame or not
2024-11-27 00:36:29 +01:00
Alug 0d39c2a0f6 we dont even need to check this
this doesent do anything with papersprites so dont even call it kek
2024-11-26 22:30:38 +01:00
Alug 4240af23cf Merge remote-tracking branch 'origin/cleanspriteclip' into Saturn-Next 2024-11-26 22:25:00 +01:00
Alug 80697046d5 clean up spriteclip fix + fix papersprites being affected by it
its now its own function HWR_ApplyDispoffset
papersprites are now also unaffected by it, which caused some minor visual issues before (ex zfighting signposts)
also just check for papersprite once and put it into a bool so we dont have to recheck sprite frames and flags 10 times
2024-11-26 20:31:20 +01:00
Alug 765dd72b38 Merge branch 'Saturn-Next' into fastpoinonside 2024-11-26 19:31:59 +01:00
Alug 403b60240f check for titlescreen music 2024-11-26 19:25:59 +01:00
Alug f973e6cd72 init polyobj thinker cachable bool
otherwise shit will die lol
2024-11-26 19:18:38 +01:00
Alug 5aff1acea8 mobjcache with explicit "true" check
just in case smth throws a garbo value and is not actually a mobj thinker
2024-11-26 19:18:34 +01:00
Alug 9e07ca0007 make hud hooks clean up after themselves 2024-11-22 16:04:16 +01:00
Alug df97bef4b5 Refactor HUD hooks too 2024-11-22 00:40:05 +01:00
indev b402738428 Fix mobj hooks called for mobj type 0 being interpreted as regular hooks 2024-11-22 01:31:02 +03:00
Alug 2de9a6bb94 forgor to remove those 2024-11-21 22:08:50 +01:00
Alug fb0c88cf55 Fix -Warray-bounds warning in lua_hooklib.c 2024-11-21 20:34:09 +01:00
Alug 1f6096e3ff fix pre and post thinkframe perfstats pages 2024-11-21 20:34:06 +01:00
Alug a4e6b5d177 Fix HurtMsg inflictor mobj type discriminator
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1903
2024-11-21 20:34:03 +01:00
Alug 4477f5ab93 Fix MusicChange hook crashing when called 2024-11-21 20:34:01 +01:00
Alug 11992d2e08 MORE MACROS 2024-11-21 20:33:58 +01:00
Alug 802979b81d Refactor hook ref allocation 2024-11-21 20:33:55 +01:00
Alug 06d0f5b95b Automatically count hook values 2024-11-21 20:33:52 +01:00
Alug da06c84aa4 we dont have key event hooks 2024-11-21 20:33:49 +01:00
Alug ecae607b59 this is unused for now 2024-11-21 20:33:46 +01:00
Alug f26717954e change those to fit rest of style 2024-11-21 20:33:44 +01:00
Alug a4080980ec make intermissionthinker use LUA_HookVoid
comment out hookbool since unused
2024-11-21 20:33:41 +01:00
indev 3db21bf778 Fix warning regarding MusicChange hook 2024-11-21 20:33:38 +01:00
indev 66518ced75 Add Should- and Player- Spin/Explode/Squish, and ServerJoin hooks into new hook system 2024-11-21 20:33:36 +01:00
Alug 5598526f52 delet serverjoin stuff i forgor and add old should spin stuff 2024-11-21 20:33:32 +01:00
Alug 14ec6e0674 serverjoin hook 2024-11-21 20:33:29 +01:00
Alug 549112822a port srb2 hooklib refactor (WIP)
lol lmao
2024-11-21 20:33:06 +01:00
indev e1cb858d9a Players that get 'NO CONTEST' can save replays too now 2024-11-21 22:02:25 +03:00
Alug 1659c2e753 try to make shadows not so offset on slopes with rotation enabled
lmaos
2024-11-21 02:11:51 +01:00
Alug e2222f66a9 those should be SHORT i think? 2024-11-21 02:11:48 +01:00
Alug 8a15b5e640 last attempt at fixing those things 2024-11-20 23:44:35 +01:00
Alug f499b11113 add R_PointInSubsectorFast for non critical gameplay stuff like sounds and camera
and some parts of rendering
2024-11-20 21:27:29 +01:00
Alug bec632800d use it for R_IsPointInSubsector
this is fine since R_IsPointInSubsector is only used for precip spawn unless you disable noclipcam lol
2024-11-20 21:26:18 +01:00
Alug a14c2f59b8 rename to R_PointOnSideFast 2024-11-20 21:25:18 +01:00
Alug e66d215dd3 Fix integer overflows on very large numbers 2024-11-20 21:24:16 +01:00
Alug 809ae20558 use highly optmized (but slightly inaccurate) version of R_PointOnSide for rendering 2024-11-20 21:24:04 +01:00
Alug 7b26ecb5f5 fixed float to integer conversion problems
from dsda doom
should hopefully make this behave the same everywhere
2024-11-19 22:10:08 +01:00
Alug 0c2ccc56cd inline _GetZAt stuff
those are very small but frequently used, so cant hurt
2024-11-17 21:42:20 +01:00
Alug 525681b5a5 Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Next 2024-11-17 21:41:33 +01:00
Alug c9a3dfcac9 reset pingtable in SV_ResetServer
and use some memsets cause they look cooler
also use ClearAdminPlayers simply to make this consistent with the other stuff that resets adminplayers
2024-11-17 21:41:25 +01:00
Alug a05aab1c7b Merge pull request #141 from Indev450/interpfixes
Some interpolation related fixes
2024-11-17 21:25:42 +01:00
Alug 7dfc638305 make replay/time attack menu support lowercase if toggled, also levelselect addon names too 2024-11-17 14:41:49 +01:00
Alug 3585969285 why is that declared here?? 2024-11-17 13:30:37 +01:00
Alug 3361ebe3c5 make menucaps stuff global macro and also apply to downloader text 2024-11-17 13:03:32 +01:00
Alug ebfd7f3e4e try make this look less like crap lol 2024-11-17 13:03:18 +01:00
Alug e2c8a773be prevent some palrender startup crashes
thx srb2 apparently this can be null during init so add some extra safety
2024-11-12 16:23:08 +01:00
Alug 6816c6dd19 add some paranthesis here 2024-11-12 15:44:29 +01:00
Alug b9e26a7e2f Merge branch 'Saturn-Next' into interpfixes 2024-11-12 15:44:16 +01:00
indev 38abb4c9e4 That didn't work in spectator camera, oops 2024-11-10 03:26:15 +03:00
indev fc469d6433 Fix spectating other players setting wrong angle when returning back to local player 2024-11-10 03:18:01 +03:00
Alug 52f1d727c0 Merge branch 'Saturn-Next' into interpfixes 2024-11-09 16:11:08 +01:00
indev 80a29dc5a1 Fix r_portal.c and r_portal.h missing from src/CMakeLists.txt 2024-11-08 11:52:03 +03:00
indev f4703be2ca Fix r_portal.c and r_portal.h missing from src/CMakeLists.txt 2024-11-08 11:47:58 +03:00
Alug 7c78cf067c forgor ifdef here 2024-11-03 15:35:03 +01:00
Alug 86ea7dde40 Merge branch 'Saturn-Next' into unglobsavep 2024-10-20 16:27:26 +02:00
indev cb94235ac1 If corrupted save received, leave netgame 2024-10-12 22:09:20 +02:00
Alug d0c50c49a7 Add few checks to prevent game crashing if netgame archive becomes corrupted
https://github.com/alufolie91/saturn-32p/commit/1e47728ea8c60a1f04130170ddfab9b02e1a7e4c#diff-0c6396d5a9ad45f461741cd44ffb2c0d3cf0eb2ec7b0500053005196fe53f1a6R1517
2024-10-12 22:09:18 +02:00
Alug 7f1217b2ab Attempt to fix a lua panic when unarchiveing extvars (print error to console instead. Not sure if it would be safe for game to read from save afterwards though)
https://github.com/alufolie91/saturn-32p/commit/a770ecdbd4afd56a9d8325eae47f0c69f71661ee#diff-0c6396d5a9ad45f461741cd44ffb2c0d3cf0eb2ec7b0500053005196fe53f1a6R1462
2024-10-12 22:09:15 +02:00
Alug 3b01393a71 Merge branch 'Saturn-Next' into unglobsavep 2024-10-12 22:08:49 +02:00
Alug ef763487a5 this doesent make much sense tbh 2024-10-06 18:51:43 +02:00
Alug 03f5ac87fa Merge branch 'Saturn-Next' into interpfixes 2024-10-06 18:51:20 +02:00
Alug b2cac97106 fix this 2024-10-06 14:53:25 +02:00
Alug c3ce75055a only do this in replays
otherwise shit will jitter during netlag
2024-10-06 14:30:28 +02:00
Alug 90d64c4e15 fix main menu interpolation
apparently in main menu, opening the menu pauses the game so rendertimefrac was FRACUNIT and didnt interpolate
2024-10-06 13:47:20 +02:00
Alug 595648a2b3 Interpolate view, even when paused
https://github.com/KartKrewDev/RingRacers/commit/3320faec8cebecb124882d38c7ec0ad37b79340a#diff-607b68058edc6124b3061267d902aabeddb6ba338c6483df0af8b1a7cf796a01R43
2024-10-06 13:47:17 +02:00
Alug 8e799ddd74 fix a interp bug where the jitter on tally increase would be for only one rendered frame, not one full tic. 2024-10-06 13:47:14 +02:00
Alug a754e9c08a HACK: reset interp values in case 412 teleporter without using P_Setorigin
since that function does some wonky stuff and idk if that would be synch safe
2024-10-06 13:47:11 +02:00
Alug 112c9398e7 add missing break 2024-10-06 13:47:08 +02:00
Alug ccd691548e more R_ResetViewInterpolation stuff 2024-10-06 13:47:05 +02:00
Alug afd7b85005 R_ResetViewInterpolation: wait an extra tic if R_UpdateViewInterpolation has not run yet, do not add extra time for subsequent calls 2024-10-06 13:47:02 +02:00
Alug f9e1cdb940 P_Ticker: update view interpolation at the start of a tic 2024-10-06 13:46:43 +02:00
Alug 63fe657c7d Do not set hu_stopped on interpolated frame 2024-10-06 13:46:31 +02:00
Alug 63f649724e Merge branch 'Saturn-Next' into unglobsavep 2024-09-24 17:05:42 +02:00
Alug df10262ebb Revert "beta hud driftgauge"
This reverts commit 26e8c2ca2b.
2024-09-23 01:34:47 +02:00
Alug a87ac3e35e Revert "extra check"
This reverts commit 0bb1efcd50.
2024-09-23 01:34:41 +02:00
Alug b71d9d2e68 Merge branch 'Saturn-Next' into unglobsavep 2024-09-23 01:04:04 +02:00
Alug cc44a5785d lets not archive players as mobjs 2024-09-22 23:08:33 +02:00
Alug 172d2bf545 Merge branch 'Saturn-Next' into unglobsavep 2024-09-22 22:20:19 +02:00
Alug 7493b3d2ab Revert "clean up leveload a bit"
This reverts commit c14af4a136.
2024-09-22 22:10:57 +02:00
Alug 31370741f2 Merge branch 'Saturn-Next' into unglobsavep 2024-09-22 17:01:27 +02:00
Alug e187f73044 Merge branch 'Saturn-Next' into unglobsavep 2024-09-21 17:41:58 +02:00
Alug 3aa55ee9c3 dont need this 2024-09-16 18:12:52 +02:00
Alug 8cfc8a5492 "player" 2024-09-16 17:52:58 +02:00
Alug 3f1c8db362 some stuff i forgor 2024-09-16 17:33:31 +02:00
Alug 0d999d7a70 Revert "Contain end & size into savebuffer_t"
This reverts commit 1a810bc923.
2024-09-16 17:17:19 +02:00
Alug 8bc081d937 Use Zone memory functions for sending compressed saves 2024-09-16 13:47:46 +02:00
Alug 42eb8d1af5 Only save demo if demobuf.p is ready 2024-09-16 13:47:43 +02:00
Alug 1a810bc923 Contain end & size into savebuffer_t 2024-09-16 13:47:40 +02:00
Alug 065572ef64 more fixup 2024-09-16 12:56:19 +02:00
Alug e88702e10c fix demo checkspace 2024-09-16 12:56:16 +02:00
Alug ee2d934525 rest smol fixes 2024-09-16 12:42:39 +02:00
Alug 2a3a33226e fixup demo savebuf 2024-09-16 12:42:36 +02:00
Alug 539315710c clean up 2024-09-16 12:42:33 +02:00
Alug 191a6ca76f unglobalize savebuffer
needs some cleanup
2024-09-16 12:42:29 +02:00
116 changed files with 8171 additions and 11405 deletions

No files matched your search

+4 -2
View File
@@ -134,6 +134,7 @@ set(SRB2_CORE_RENDER_SOURCES
r_sky.c
r_splats.c
r_things.c
r_portal.c
r_bsp.h
r_data.h
@@ -149,6 +150,7 @@ set(SRB2_CORE_RENDER_SOURCES
r_splats.h
r_state.h
r_things.h
r_portal.h
)
set(SRB2_CORE_GAME_SOURCES
@@ -485,10 +487,10 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_gl.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.h
+4 -3
View File
@@ -229,6 +229,7 @@ endif
ifdef LINUX
UNIXCOMMON=1
NOOBJDUMP=1
ifndef NOGME
HAVE_LIBGME=1
endif
@@ -297,7 +298,7 @@ else
$(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o $(OBJDIR)/hw_shaders.o
endif
OPTS += -DCOMPVERSION -fwrapv
OPTS += -DCOMPVERSION
ifndef NONX86
ifndef GCC29
@@ -737,7 +738,7 @@ else
ifdef SDL
ifdef MINGW
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_gl.h screen.h \
command.h hardware/hw_data.h hardware/hw_defs.h hardware/hw_md2.h \
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h hardware/hw_portal.h\
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
@@ -746,7 +747,7 @@ $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
else
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_gl.h screen.h \
command.h hardware/hw_data.h hardware/hw_defs.h hardware/hw_md2.h \
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h hardware/hw_portal.h \
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
+372 -111
View File
@@ -1,8 +1,10 @@
// SONIC ROBO BLAST 2
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 2024 by Vivian "toastergrl" Grannell.
// Copyright (C) 2024 by Kart Krew.
// Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -26,43 +28,37 @@
#endif
// For use if I do walls with outsides/insides
static const UINT8 REDS = (8*16);
static const UINT8 REDS = (2*16);
static const UINT8 REDRANGE = 16;
static const UINT8 GRAYS = (1*16);
static const UINT8 GRAYSRANGE = 16;
static const UINT8 BROWNS = (3*16);
static const UINT8 YELLOWS = (7*16);
static const UINT8 GREENS = (10*16);
static const UINT8 BROWNS = (15*16);
static const UINT8 YELLOWS = (5*16)+8;
static const UINT8 GREENS = (6*16);
static const UINT8 BLUES = (9*16);
static const UINT8 DBLACK = 31;
static const UINT8 DWHITE = 0;
static const UINT8 NOCLIMBREDS = 248;
static const UINT8 NOCLIMBREDRANGE = 8;
static const UINT8 NOCLIMBGRAYS = 204;
static const UINT8 NOCLIMBBROWNS = (2*16);
static const UINT8 NOCLIMBYELLOWS = (11*16);
// Automap colors
#define BACKGROUND DBLACK
#define WALLCOLORS (REDS + REDRANGE/2)
#define WALLRANGE (REDRANGE/2)
#define NOCLIMBWALLCOLORS (NOCLIMBREDS + NOCLIMBREDRANGE/2)
#define NOCLIMBWALLRANGE (NOCLIMBREDRANGE/2)
#define THOKWALLCOLORS REDS
#define THOKWALLRANGE REDRANGE
#define NOCLIMBTHOKWALLCOLORS NOCLIMBREDS
#define NOCLIMBTHOKWALLRANGE NOCLIMBREDRANGE
#define TSWALLCOLORS GRAYS
#define TSWALLRANGE GRAYSRANGE
#define NOCLIMBTSWALLCOLORS NOCLIMBGRAYS
#define TSWALLCOLORS DWHITE
#define TSFINISHLINE GRAYS
#define TSFOFINFO (BLUES + 4)
#define FDWALLCOLORS BROWNS
#define NOCLIMBFDWALLCOLORS NOCLIMBBROWNS
#define CDWALLCOLORS YELLOWS
#define NOCLIMBCDWALLCOLORS NOCLIMBYELLOWS
#define THINGCOLORS GREENS
#define GRIDCOLORS (GRAYS + GRAYSRANGE/2)
#define XHAIRCOLORS GRAYS
// Automap passes
#define PASS_SOLID 1
#define PASS_INTANGIBLE 2
#define PASS_FOF 4
// controls
#define AM_PANUPKEY KEY_UPARROW
#define AM_PANDOWNKEY KEY_DOWNARROW
@@ -110,11 +106,6 @@ typedef struct
mpoint_t a, b;
} mline_t;
typedef struct
{
fixed_t slp, islp;
} islope_t;
//
// The vector graphics for the automap.
// A line drawing of the player pointing right,
@@ -136,16 +127,14 @@ static const mline_t player_arrow[] = {
#undef R
#define NUMPLYRLINES (sizeof (player_arrow)/sizeof (mline_t))
#if 0
#define R (FRACUNIT)
static mline_t triangle_guy[] = {
{ { (fixed_t)-.867f*R, (fixed_t)-.5f*R }, { (fixed_t) .867f*R, (fixed_t)-.5f*R } },
{ { (fixed_t) .867f*R, (fixed_t)-.5f*R }, { (fixed_t) 0, (fixed_t) R } },
{ { (fixed_t) 0, (fixed_t) R }, { (fixed_t)-.867f*R, (fixed_t)-.5f*R } }
static const mline_t cross_mark[] =
{
{ { -R, 0 }, { R, 0} },
{ { 0, -R }, { 0, R } },
};
#undef R
#define NUMTRIANGLEGUYLINES (sizeof (triangle_guy)/sizeof (mline_t))
#endif
#define NUMCROSSMARKLINES (sizeof(cross_mark)/sizeof(mline_t))
#define R (FRACUNIT)
static const mline_t thintriangle_guy[] = {
@@ -162,10 +151,14 @@ static boolean draw_grid = false;
boolean automapactive = false;
boolean am_recalc = false; //added : 05-02-98 : true when screen size changes
static boolean am_stopped = true;
static boolean am_minigen = false;
static UINT8 *am_buf = NULL;
static INT32 f_x, f_y; // location of window on screen (always zero for both)
static INT32 f_w, f_h; // size of window on screen (always the screen width and height respectively)
static boolean m_keydown[4]; // which window panning keys are being pressed down?
static mpoint_t m_paninc; // how far the window pans each tic (map coords)
static fixed_t mtof_zoommul; // how far the window zooms in each tic (map coords)
static fixed_t ftom_zoommul; // how far the window zooms in each tic (fb coords)
@@ -205,12 +198,13 @@ static fixed_t scale_ftom;
static player_t *plr; // the player represented by an arrow
static INT32 followplayer = true; // specifies whether to follow the player around
static boolean followplayer = true; // specifies whether to follow the player around
// function for drawing lines, depends on rendermode
typedef void (*AMDRAWFLINEFUNC) (const fline_t *fl, INT32 color);
static AMDRAWFLINEFUNC AM_drawFline;
static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc);
static void AM_drawFline_soft(const fline_t *fl, INT32 color);
static void AM_activateNewScale(void)
@@ -340,22 +334,23 @@ static void AM_initVariables(void)
old_m_h = m_h;
}
//
// Called when the screen size changes.
//
static void AM_FrameBufferInit(void)
{
f_x = f_y = 0;
f_w = vid.width;
f_h = vid.height;
am_buf = screens[0];
}
//
// should be called at the start of every level
// right now, i figure it out myself
//
static void AM_LevelInit(void)
{
f_x = f_y = 0;
f_w = vid.width;
f_h = vid.height;
AM_drawFline = AM_drawFline_soft;
#ifdef HWRENDER
if (rendermode == render_opengl)
AM_drawFline = HWR_drawAMline;
#endif
AM_findMinMaxBoundaries();
scale_mtof = FixedDiv(min_scale_mtof*10, 7*FRACUNIT);
if (scale_mtof > max_scale_mtof)
@@ -377,7 +372,7 @@ void AM_Stop(void)
*
* \sa AM_Stop
*/
static inline void AM_Start(void)
void AM_Start(void)
{
static INT32 lastlevel = -1;
@@ -386,8 +381,12 @@ static inline void AM_Start(void)
am_stopped = false;
if (lastlevel != gamemap || am_recalc) // screen size changed
{
AM_LevelInit();
lastlevel = gamemap;
AM_FrameBufferInit();
if (lastlevel != gamemap)
{
AM_LevelInit();
lastlevel = gamemap;
}
am_recalc = false;
}
AM_initVariables();
@@ -413,6 +412,27 @@ static void AM_maxOutWindowScale(void)
AM_activateNewScale();
}
//
// set window panning
//
static void AM_setWindowPanning(void)
{
// up and down
if (m_keydown[2]) // pan up
m_paninc.y = FTOM(F_PANINC);
else if (m_keydown[3]) // pan down
m_paninc.y = -FTOM(F_PANINC);
else
m_paninc.y = 0;
// left and right
if (m_keydown[0]) // pan right
m_paninc.x = FTOM(F_PANINC);
else if (m_keydown[1]) // pan left
m_paninc.x = -FTOM(F_PANINC);
else
m_paninc.x = 0;
}
/** Responds to user inputs in automap mode.
*
* \param ev Event to possibly respond to.
@@ -445,35 +465,49 @@ boolean AM_Responder(event_t *ev)
{
case AM_PANRIGHTKEY: // pan right
if (!followplayer)
m_paninc.x = FTOM(F_PANINC);
{
m_keydown[0] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_PANLEFTKEY: // pan left
if (!followplayer)
m_paninc.x = -FTOM(F_PANINC);
{
m_keydown[1] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_PANUPKEY: // pan up
if (!followplayer)
m_paninc.y = FTOM(F_PANINC);
{
m_keydown[2] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_PANDOWNKEY: // pan down
if (!followplayer)
m_paninc.y = -FTOM(F_PANINC);
{
m_keydown[3] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_ZOOMOUTKEY: // zoom out
mtof_zoommul = M_ZOOMOUT;
ftom_zoommul = M_ZOOMIN;
AM_setWindowPanning();
break;
case AM_ZOOMINKEY: // zoom in
mtof_zoommul = M_ZOOMIN;
ftom_zoommul = M_ZOOMOUT;
AM_setWindowPanning();
break;
case AM_TOGGLEKEY:
AM_Stop();
@@ -487,6 +521,7 @@ boolean AM_Responder(event_t *ev)
}
else
AM_restoreScaleAndLoc();
AM_setWindowPanning();
break;
case AM_FOLLOWKEY:
followplayer = !followplayer;
@@ -506,14 +541,32 @@ boolean AM_Responder(event_t *ev)
switch (ev->data1)
{
case AM_PANRIGHTKEY:
if (!followplayer)
{
m_keydown[0] = false;
AM_setWindowPanning();
}
break;
case AM_PANLEFTKEY:
if (!followplayer)
m_paninc.x = 0;
{
m_keydown[1] = false;
AM_setWindowPanning();
}
break;
case AM_PANUPKEY:
if (!followplayer)
{
m_keydown[2] = false;
AM_setWindowPanning();
}
break;
case AM_PANDOWNKEY:
if (!followplayer)
m_paninc.y = 0;
{
m_keydown[3] = false;
AM_setWindowPanning();
}
break;
case AM_ZOOMOUTKEY:
case AM_ZOOMINKEY:
@@ -714,6 +767,16 @@ static boolean AM_clipMline(const mline_t *ml, fline_t *fl)
}
#undef DOOUTCODE
//
// Draws a pixel.
//
static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc)
{
if (xx < 0 || yy < 0 || xx >= f_w || yy >= f_h)
return; // off the screen
am_buf[(yy*f_w) + xx] = cc;
}
//
// Classic Bresenham w/ whatever optimizations needed for speed
//
@@ -735,8 +798,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
}
#endif
#define PUTDOT(xx,yy,cc) V_DrawFill(xx,yy,1,1,cc|V_NOSCALESTART);
dx = fl->b.x - fl->a.x;
ax = 2 * (dx < 0 ? -dx : dx);
sx = dx < 0 ? -1 : 1;
@@ -753,7 +814,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
d = ay - ax/2;
for (;;)
{
PUTDOT(x, y, color)
AM_drawPixel(x, y, color);
if (x == fl->b.x)
return;
if (d >= 0)
@@ -770,7 +831,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
d = ax - ay/2;
for (;;)
{
PUTDOT(x, y, color)
AM_drawPixel(x, y, color);
if (y == fl->b.y)
return;
if (d >= 0)
@@ -782,8 +843,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
d += ax;
}
}
#undef PUTDOT
}
//
@@ -805,17 +864,18 @@ static void AM_drawGrid(INT32 color)
fixed_t x, y;
fixed_t start, end;
mline_t ml;
fixed_t gridsize = (MAPBLOCKUNITS<<MAPBITS);
// Figure out start of vertical gridlines
start = m_x;
if ((start - bmaporgx) % (MAPBLOCKUNITS<<FRACBITS))
start += (MAPBLOCKUNITS<<FRACBITS) - ((start - bmaporgx) % (MAPBLOCKUNITS<<FRACBITS));
if ((start - (bmaporgx>>FRACTOMAPBITS)) % gridsize)
start += gridsize - ((start - (bmaporgx>>FRACTOMAPBITS)) % gridsize);
end = m_x + m_w;
// draw vertical gridlines
ml.a.y = m_y;
ml.b.y = m_y + m_h;
for (x = start; x < end; x += (MAPBLOCKUNITS<<FRACBITS))
for (x = start; x < end; x += gridsize)
{
ml.a.x = x;
ml.b.x = x;
@@ -824,14 +884,14 @@ static void AM_drawGrid(INT32 color)
// Figure out start of horizontal gridlines
start = m_y;
if ((start - bmaporgy) % (MAPBLOCKUNITS<<FRACBITS))
start += (MAPBLOCKUNITS<<FRACBITS) - ((start - bmaporgy) % (MAPBLOCKUNITS<<FRACBITS));
if ((start - (bmaporgy>>FRACTOMAPBITS)) % gridsize)
start += gridsize - ((start - (bmaporgy>>FRACTOMAPBITS)) % gridsize);
end = m_y + m_h;
// draw horizontal gridlines
ml.a.x = m_x;
ml.b.x = m_x + m_w;
for (y = start; y < end; y += (MAPBLOCKUNITS<<FRACBITS))
for (y = start; y < end; y += gridsize)
{
ml.a.y = y;
ml.b.y = y;
@@ -839,14 +899,63 @@ static void AM_drawGrid(INT32 color)
}
}
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
if (slope) { \
end1 = (P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y) + FRACUNIT/2) >> FRACBITS; \
end2 = (P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y) + FRACUNIT/2) >> FRACBITS; \
} else \
end1 = end2 = (normalheight + FRACUNIT/2) >> FRACBITS;
static ffloor_t *AM_CompareFOFs(size_t i, ffloor_t *rover, ffloor_t *secondarystore)
{
ffloor_t *secondaryrover = NULL;
for (; rover; rover = rover->next)
{
fixed_t rovt1, rovt2;
fixed_t rovb1, rovb2;
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->flags & FF_BLOCKPLAYER))
continue;
SLOPEPARAMS(*rover->t_slope, rovt1, rovt2, *rover->topheight)
SLOPEPARAMS(*rover->b_slope, rovb1, rovb2, *rover->bottomheight)
for (secondaryrover = secondarystore; secondaryrover; secondaryrover = secondaryrover->next)
{
fixed_t sect1, sect2;
fixed_t secb1, secb2;
if (!(secondaryrover->flags & FF_EXISTS))
continue;
if (!(secondaryrover->flags & FF_BLOCKPLAYER))
continue;
if (secondaryrover->secnum == rover->secnum)
break;
SLOPEPARAMS(*secondaryrover->t_slope, sect1, sect2, *secondaryrover->topheight)
SLOPEPARAMS(*secondaryrover->b_slope, secb1, secb2, *secondaryrover->bottomheight)
if (rovt1 != sect1)
continue;
if (rovt2 != sect2)
continue;
if (rovb1 != secb1)
continue;
if (rovb2 != secb2)
continue;
break;
}
if (secondaryrover == NULL)
break;
}
return rover;
}
//
// Determines visible lines, draws them.
// This is LineDef based, not LineSeg based.
//
static inline void AM_drawWalls(void)
static void AM_drawWalls(UINT8 pass)
{
size_t i;
static mline_t l;
const fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale)>>FRACBITS;
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
fixed_t backf1 = 0, backf2 = 0, backc1 = 0, backc2 = 0; // back floor ceiling ends
@@ -856,74 +965,143 @@ 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;
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
if (slope) { \
end1 = P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y); \
end2 = P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y); \
} else \
end1 = end2 = normalheight;
SLOPEPARAMS(lines[i].frontsector->f_slope, frontf1, frontf2, lines[i].frontsector->floorheight)
SLOPEPARAMS(lines[i].frontsector->c_slope, frontc1, frontc2, lines[i].frontsector->ceilingheight)
if (lines[i].backsector) {
SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight)
SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight)
}
#undef SLOPEPARAMS
if (!lines[i].backsector) // 1-sided
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBWALLCOLORS);
else
if (!(pass & PASS_SOLID))
;
else if (frontf1 != frontc1 || frontf2 != frontc2 || lines[i].frontsector->f_slope)
{
AM_drawMline(&l, TSWALLCOLORS);
}
else if (!am_minigen)
{
AM_drawMline(&l, WALLCOLORS);
}
continue;
}
else if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier
SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight)
SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight)
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
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBTSWALLCOLORS);
else
AM_drawMline(&l, TSWALLCOLORS);
if (!am_minigen && (pass & PASS_INTANGIBLE))
{
AM_drawMline(&l, GRIDCOLORS);
}
}
else
else if (pass & PASS_SOLID)
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBTHOKWALLCOLORS);
else
AM_drawMline(&l, THOKWALLCOLORS);
AM_drawMline(&l, TSWALLCOLORS);
}
}
else
{
if (lines[i].flags & ML_NOCLIMB) {
if (backf1 != frontf1 || backf2 != frontf2) {
AM_drawMline(&l, NOCLIMBFDWALLCOLORS); // floor level change
}
else if (backc1 != frontc1 || backc2 != frontc2) {
AM_drawMline(&l, NOCLIMBCDWALLCOLORS); // ceiling level change
//dont think kart even supports those idk?
/*if (lines[i].flags & (ML_IMPASSABLE|ML_BLOCKPLAYERS))
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSWALLCOLORS); // Completely solid course boundary
}
else if ((lines[i].flags & ML_MIDSOLID)
&& sides[lines->sidenum[0]].midtexture)
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSWALLCOLORS); // solid midtexture, likely a course boundary
}*/
if ((backf1 != frontf1 && abs(backf1 - frontf1) > maxstep)
|| (backf2 != frontf2 && abs(backf2 - frontf2) > maxstep))
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSWALLCOLORS); // floor-wall, likely a course boundary
}
/*else if (lines[i].special == 2001) // guh its a sector effect in kart idk how to make it work tbh lol
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSFINISHLINE); // finish line
}*/
else if (backf1 != frontf1 || backf2 != frontf2)
{
if (pass & PASS_INTANGIBLE)
AM_drawMline(&l, FDWALLCOLORS); // floorlevel change
}
else if (backc1 != frontc1 || backc2 != frontc2)
{
if (!(pass & PASS_INTANGIBLE))
;
else if (abs(backc1 - frontc1) < maxstep
|| abs(backc2 - frontc2) < maxstep)
{
AM_drawMline(&l, CDWALLCOLORS); // ceilinglevel change
}
else
AM_drawMline(&l, NOCLIMBTSWALLCOLORS);
{
AM_drawMline(&l, GRIDCOLORS); // ceiling-wall, not likely to be a course boundary but flagged up just in case
}
}
else
{
if (backf1 != frontf1 || backf2 != frontf2) {
AM_drawMline(&l, FDWALLCOLORS); // floor level change
{
ffloor_t *rover = NULL;
if (lines[i].frontsector->ffloors || lines[i].backsector->ffloors)
{
if (lines[i].backsector->ffloors == NULL)
{
// Check frontside for one solid
for (rover = lines[i].frontsector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->flags & FF_BLOCKPLAYER))
continue;
break;
}
}
else if (lines[i].frontsector->ffloors == NULL)
{
// Check backside for one solid
for (rover = lines[i].backsector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->flags & FF_BLOCKPLAYER))
continue;
break;
}
}
else
{
// Check to see if any secnums exist in one but not the other.
rover = AM_CompareFOFs(i, lines[i].frontsector->ffloors, lines[i].backsector->ffloors);
if (rover == NULL)
rover = AM_CompareFOFs(i, lines[i].backsector->ffloors, lines[i].frontsector->ffloors);
}
}
if (rover != NULL)
{
if (pass & PASS_FOF)
AM_drawMline(&l, TSFOFINFO); // a FOF is here but we don't know how to distinguish them yet
}
else if (!am_minigen)
{
if (pass & PASS_INTANGIBLE)
AM_drawMline(&l, GRIDCOLORS); // likely low-relevance line
}
}
else if (backc1 != frontc1 || backc2 != frontc2) {
AM_drawMline(&l, CDWALLCOLORS); // ceiling level change
}
else
AM_drawMline(&l, TSWALLCOLORS);
}
}
}
}
#undef SLOPEPARAMS
//
// Rotation in 2D.
// Used to rotate player arrow line character.
@@ -996,7 +1174,7 @@ static inline void AM_drawPlayers(void)
if (!multiplayer)
{
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, plr->mo->angle, DWHITE, plr->mo->x, plr->mo->y);
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 16<<FRACBITS, plr->mo->angle, DWHITE, plr->mo->x, plr->mo->y);
return;
}
@@ -1013,7 +1191,7 @@ static inline void AM_drawPlayers(void)
if (p->skincolor > 0)
color = R_GetTranslationColormap(TC_DEFAULT, p->skincolor, GTC_CACHE)[GREENS + 8];
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, p->mo->angle, color, p->mo->x, p->mo->y);
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 16<<FRACBITS, p->mo->angle, color, p->mo->x, p->mo->y);
}
}
@@ -1033,13 +1211,27 @@ static inline void AM_drawThings(UINT8 colors)
}
}
/** Draws the crosshair, actually just a dot in software mode.
/** Draws the crosshair.
*
* \param color Color for the crosshair.
*/
static inline void AM_drawCrosshair(UINT8 color)
{
V_DrawFill(f_w/2 + f_x, f_h/2 + f_y, 1, 1, color|V_NOSCALESTART);
const fixed_t scale = 4<<FRACBITS;
size_t i;
fline_t fl;
for (i = 0; i < NUMCROSSMARKLINES; i++)
{
fl.a.x = FixedMul(cross_mark[i].a.x, scale) >> FRACBITS;
fl.a.y = FixedMul(cross_mark[i].a.y, scale) >> FRACBITS;
fl.b.x = FixedMul(cross_mark[i].b.x, scale) >> FRACBITS;
fl.b.y = FixedMul(cross_mark[i].b.y, scale) >> FRACBITS;
fl.a.x += f_x + (f_w / 2);
fl.a.y += f_y + (f_h / 2);
fl.b.x += f_x + (f_w / 2);
fl.b.y += f_y + (f_h / 2);
AM_drawFline(&fl, color);
}
}
/** Draws the automap.
@@ -1049,11 +1241,80 @@ void AM_Drawer(void)
if (!automapactive)
return;
AM_drawFline = AM_drawFline_soft;
#ifdef HWRENDER
if (rendermode == render_opengl)
AM_drawFline = HWR_drawAMline;
#endif
AM_clearFB(BACKGROUND);
if (draw_grid) AM_drawGrid(GRIDCOLORS);
AM_drawWalls();
AM_drawWalls(PASS_FOF|PASS_INTANGIBLE|PASS_SOLID);
AM_drawPlayers();
AM_drawThings(THINGCOLORS);
AM_drawCrosshair(XHAIRCOLORS);
if (!followplayer) AM_drawCrosshair(XHAIRCOLORS);
}
minigen_t *AM_MinimapGenerate(INT32 mul)
{
static minigen_t ret = {0};
if (automapactive)
return NULL;
am_minigen = true;
AM_drawFline = AM_drawFline_soft; // yes, even in GL
//AM_FrameBufferInit();
f_x = f_y = 0;
ret.w = f_w = minimapinfo.minimap_w * mul;
ret.h = f_h = minimapinfo.minimap_h * mul;
am_buf = ret.buf = NULL;
//AM_LevelInit();
AM_findMinMaxBoundaries();
scale_mtof = min_scale_mtof - (min_scale_mtof/20);
scale_ftom = FixedDiv(FRACUNIT, scale_mtof);
//AM_initVariables();
f_oldloc.x = INT32_MAX;
m_paninc.x = m_paninc.y = 0;
ftom_zoommul = FRACUNIT;
mtof_zoommul = FRACUNIT;
m_w = FTOM(f_w);
m_h = FTOM(f_h);
//AM_changeWindowLoc();
m_x = min_x - FixedMul(m_w, FRACUNIT/40);
m_y = min_y - FixedMul(m_h, FRACUNIT/40);
m_x2 = m_x + m_w;
m_y2 = m_y + m_h;
// for saving & restoring
old_m_x = m_x;
old_m_y = m_y;
old_m_w = m_w;
old_m_h = m_h;
am_buf = ret.buf = malloc((f_w*f_h));
if (ret.buf == NULL)
return NULL;
//AM_clearFB(BACKGROUND);
memset(am_buf, 0xff, (f_w*f_h));
AM_drawWalls(PASS_FOF);
AM_drawWalls(PASS_INTANGIBLE);
AM_drawWalls(PASS_SOLID);
am_buf = NULL;
am_recalc = true;
am_minigen = false;
return &ret;
}
+17 -8
View File
@@ -1,8 +1,10 @@
// SONIC ROBO BLAST 2
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 2024 by Vivian "toastergrl" Grannell.
// Copyright (C) 2024 by Kart Krew.
// Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -26,11 +28,6 @@ typedef struct
fpoint_t a, b;
} fline_t;
// Used by ST StatusBar stuff.
#define AM_MSGHEADER (('a'<<24)+('m'<<16))
#define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8))
#define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8))
extern boolean am_recalc; // true if screen size changes
extern boolean automapactive; // In AutoMap mode?
@@ -43,7 +40,19 @@ void AM_Ticker(void);
// Called by main loop, instead of view drawer if automap is active.
void AM_Drawer(void);
// Enables the automap.
void AM_Start(void);
// Called to force the automap to quit if the level is completed while it is up.
void AM_Stop(void);
typedef struct
{
INT32 w, h;
UINT8 *buf;
} minigen_t;
// Minimap generation
minigen_t *AM_MinimapGenerate(INT32 mul);
#endif
+2 -5
View File
@@ -36,7 +36,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm
return;
// Lua can handle it!
if (LUAh_BotAI(sonic, tails, cmd))
if (LUA_HookBotAI(sonic, tails, cmd))
return;
if (tails->player->pflags & (PF_MACESPIN|PF_ITEMHANG))
@@ -118,11 +118,8 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd)
return;
}
// Bot AI isn't programmed in analog.
//CV_SetValue(&cv_analog2, false);
// Let Lua scripts build ticcmds
if (LUAh_BotTiccmd(player, cmd))
if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd)))
return;
// We don't have any main character AI, sorry. D:
+28 -23
View File
@@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 1999-2024 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -11,6 +11,9 @@
/// \brief Macros to read/write from/to a UINT8 *,
/// used for packet creation and such
#ifndef __BYTEPTR_H__
#define __BYTEPTR_H__
#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__)
#define DEALIGNED
#endif
@@ -150,7 +153,7 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
#undef DEALIGNED
#define WRITESTRINGN(p, s, n) ({ \
#define WRITESTRINGN(p, s, n) do { \
size_t tmp_i; \
\
for (tmp_i = 0; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) \
@@ -158,70 +161,72 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
\
if (tmp_i < n) \
WRITECHAR(p, '\0'); \
})
} while (0)
#define WRITESTRINGL(p, s, n) ({ \
#define WRITESTRINGL(p, s, n) do { \
size_t tmp_i; \
\
for (tmp_i = 0; tmp_i < n - 1 && s[tmp_i] != '\0'; tmp_i++) \
WRITECHAR(p, s[tmp_i]); \
\
WRITECHAR(p, '\0'); \
})
} while (0)
#define WRITESTRING(p, s) ({ \
#define WRITESTRING(p, s) do { \
size_t tmp_i; \
\
for (tmp_i = 0; s[tmp_i] != '\0'; tmp_i++) \
WRITECHAR(p, s[tmp_i]); \
\
WRITECHAR(p, '\0'); \
})
} while (0)
#define WRITEMEM(p, s, n) ({ \
memcpy(p, s, n); \
p += n; \
})
#define WRITEMEM(p, s, n) do { \
memcpy(p, s, n); \
p += n; \
} while (0)
#define SKIPSTRING(p) while (READCHAR(p) != '\0')
#define SKIPSTRINGN(p, n) ({ \
#define SKIPSTRINGN(p, n) do { \
size_t tmp_i = 0; \
\
while (tmp_i < n && READCHAR(p) != '\0') \
tmp_i++; \
})
} while (0)
#define SKIPSTRINGL(p, n) SKIPSTRINGN(p, n)
#define READSTRINGN(p, s, n) ({ \
#define READSTRINGN(p, s, n) do { \
size_t tmp_i = 0; \
\
while (tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0') \
tmp_i++; \
\
s[tmp_i] = '\0'; \
})
} while (0)
#define READSTRINGL(p, s, n) ({ \
#define READSTRINGL(p, s, n) do { \
size_t tmp_i = 0; \
\
while (tmp_i < n - 1 && (s[tmp_i] = READCHAR(p)) != '\0') \
tmp_i++; \
\
s[tmp_i] = '\0'; \
})
} while (0)
#define READSTRING(p, s) ({ \
#define READSTRING(p, s) do { \
size_t tmp_i = 0; \
\
while ((s[tmp_i] = READCHAR(p)) != '\0') \
tmp_i++; \
\
s[tmp_i] = '\0'; \
})
} while (0)
#define READMEM(p, s, n) ({ \
memcpy(s, p, n); \
p += n; \
})
#define READMEM(p, s, n) do { \
memcpy(s, p, n); \
p += n; \
} while (0)
#endif // __BYTEPTR_H__
+1 -1
View File
@@ -1236,7 +1236,7 @@ void CONS_Printf(const char *fmt, ...)
txt = malloc(8192);
va_start(argptr, fmt);
vsprintf(txt, fmt, argptr);
vsnprintf(txt, 8192, fmt, argptr);
va_end(argptr);
// echo console prints to log file
+308 -365
View File
File diff suppressed because it is too large. Load diff
+5 -5
View File
@@ -600,10 +600,8 @@ void D_ClientServerInit(void);
// Initialise the other field
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum));
void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam);
void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam); // splitsreen player
void SendNetXCmd3(netxcmd_t id, const void *param, size_t nparam); // splitsreen3 player
void SendNetXCmd4(netxcmd_t id, const void *param, size_t nparam); // splitsreen4 player
void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam);
#define SendNetXCmd(id, param, nparam) SendNetXCmdForPlayer(0, id, param, nparam) // Shortcut for P1
// Create any new ticcmds and broadcast to other players.
void NetKeepAlive(void);
@@ -647,10 +645,12 @@ extern char motd[254], server_context[8];
extern UINT8 playernode[MAXPLAYERS];
INT32 D_NumPlayers(void);
void D_ResetTiccmds(void);
ticcmd_t *D_LocalTiccmd(UINT8 ss);
tic_t GetLag(INT32 node);
UINT8 GetFreeXCmdSize(void);
//UINT8 GetFreeXCmdSize(UINT8 playerid);
extern UINT8 hu_resynching;
#ifdef SATURNSYNCH
+22 -9
View File
@@ -15,6 +15,7 @@
/// plus functions to parse command line parameters, configure game
/// parameters, and call the startup functions.
#include "d_netcmd.h"
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
#include <sys/stat.h>
#include <sys/types.h>
@@ -181,7 +182,7 @@ static inline void D_DeviceLEDTick(void)
for (i = 0; i <= splitscreen; i++)
{
if (G_GetDeviceForPlayer(i) == 0)
if (cv_usejoystick[i].value == 0)
continue;
color[i] = G_GetSkinColor(i);
@@ -449,6 +450,8 @@ static boolean D_Display(void)
{
if (players[displayplayers[i]].mo || players[displayplayers[i]].playerstate == PST_DEAD)
{
viewssnum = i;
if (i == 0) // Initialize for P1
{
viewwindowy = 0;
@@ -458,8 +461,6 @@ static boolean D_Display(void)
objectsdrawn = 0;
}
viewssnum = i;
#ifdef HWRENDER
if (rendermode == render_opengl)
HWR_RenderPlayerView(i, &players[displayplayers[i]]);
@@ -537,6 +538,8 @@ static boolean D_Display(void)
PS_START_TIMING(ps_uitime);
ST_Drawer();
HU_Drawer();
NetUpdate(); // TEST: run this EVERY frame
}
else
{
@@ -740,10 +743,10 @@ void D_SRB2Loop(void)
renderisnewtic = (realtics > 0 || singletics);
refreshdirmenu = 0; // not sure where to put this, here as good as any?
if (renderisnewtic)
{
refreshdirmenu = 0; // not sure where to put this, here as good as any?
// don't skip more than 10 frames at a time
// (fadein / fadeout cause massive frame skip!)
if (realtics > 8)
@@ -813,7 +816,7 @@ void D_SRB2Loop(void)
{
renderdeltatics = FLOAT_TO_FIXED(deltatics);
if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped)
if (!(paused || P_AutoPause()) && !hu_stopped)
{
rendertimefrac = g_time.timefrac;
}
@@ -822,7 +825,14 @@ void D_SRB2Loop(void)
rendertimefrac = FRACUNIT;
}
rendertimefrac_unpaused = g_time.timefrac;
if (!hu_stopped)
{
rendertimefrac_unpaused = g_time.timefrac;
}
else
{
rendertimefrac_unpaused = FRACUNIT;
}
}
else
{
@@ -852,7 +862,7 @@ void D_SRB2Loop(void)
LUA_Step();
#ifdef HAVE_DISCORDRPC
if (! dedicated)
if (!dedicated)
{
Discord_RunCallbacks();
}
@@ -957,10 +967,14 @@ void D_StartTitle(void)
gameaction = ga_nothing;
memset(displayplayers, 0, sizeof(displayplayers));
memset(g_localplayers, 0, sizeof g_localplayers);
consoleplayer = 0;
//demosequence = -1;
gametype = GT_RACE; // SRB2kart
paused = false;
S_ResetKeepAndSpecialMus(); // just in case
F_StartTitleScreen();
// Reset the palette -- SRB2Kart: actually never mind let's do this in the middle of every fade
@@ -1836,7 +1850,6 @@ void D_SRB2Main(void)
}
S_InitMusicDefs();
S_InitMTDefs();
CONS_Printf("ST_Init(): Init status bar.\n");
ST_Init();
+1 -13
View File
@@ -69,8 +69,6 @@ INT16 hardware_MAXPACKETLENGTH;
boolean (*I_NetGet)(void) = NULL;
void (*I_NetSend)(void) = NULL;
boolean (*I_NetCanSend)(void) = NULL;
boolean (*I_NetCanGet)(void) = NULL;
void (*I_NetCloseSocket)(void) = NULL;
void (*I_NetFreeNodenum)(INT32 nodenum) = NULL;
SINT8 (*I_NetMakeNodewPort)(const char *address, const char* port) = NULL;
@@ -1087,15 +1085,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
netbuffer->ackreturn = 0;
if (reliable)
{
if (I_NetCanSend && !I_NetCanSend())
{
if (netbuffer->packettype < PT_CANFAIL)
GetFreeAcknum(&netbuffer->ack, true);
DEBFILE("HSendPacket: Out of bandwidth\n");
return false;
}
else if (!GetFreeAcknum(&netbuffer->ack, false))
if (!GetFreeAcknum(&netbuffer->ack, false))
return false;
}
else
@@ -1292,7 +1282,6 @@ boolean D_CheckNetGame(void)
I_NetGet = Internal_Get;
I_NetSend = Internal_Send;
I_NetCanSend = NULL;
I_NetCloseSocket = NULL;
I_NetFreeNodenum = Internal_FreeNodenum;
I_NetMakeNodewPort = NULL;
@@ -1491,7 +1480,6 @@ void D_CloseConnection(void)
I_NetGet = Internal_Get;
I_NetSend = Internal_Send;
I_NetCanSend = NULL;
I_NetCloseSocket = NULL;
I_NetFreeNodenum = Internal_FreeNodenum;
I_NetMakeNodewPort = NULL;
+259 -218
View File
@@ -16,6 +16,7 @@
#include "console.h"
#include "command.h"
#include "dehacked.h"
#include "i_time.h"
#include "i_system.h"
#include "g_game.h"
@@ -141,6 +142,8 @@ static void Command_Addfile(void);
static void Command_Addskins(void);
static void Command_GLocalSkin(void);
static void Command_ListWADS_f(void);
static void Command_ListDoomednums_f(void);
static void Command_ListUnusedSprites_f(void);
static void Command_RunSOC(void);
static void Command_Pause(void);
static void Command_Respawn(void);
@@ -303,14 +306,12 @@ consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL,
consvar_t cv_laglesscam = {"laglesscamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#if defined(HAVE_SDL) || defined(_WINDOWS) //joystick 1 and 2
consvar_t cv_usejoystick = {"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick2 = {"use_joystick2", "2", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick3 = {"use_joystick3", "3", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick3, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick4 = {"use_joystick4", "4", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick4, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick[MAXSPLITSCREENPLAYERS] = {
{"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick1, 0, NULL, NULL, 0, 0, NULL},
{"use_joystick2", "2", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL},
{"use_joystick3", "3", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick3, 0, NULL, NULL, 0, 0, NULL},
{"use_joystick4", "4", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick4, 0, NULL, NULL, 0, 0, NULL}
};
#endif
#if (defined (LJOYSTICK) || defined (HAVE_SDL))
@@ -318,13 +319,17 @@ consvar_t cv_usejoystick4 = {"use_joystick4", "4", CV_SAVE|CV_CALL, usejoystick_
consvar_t cv_joyport = {"joyport", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyport2 = {"joyport2", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: for later
#endif
consvar_t cv_joyscale = {"joyscale", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale2 = {"joyscale2", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale2, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale3 = {"joyscale3", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale3, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale4 = {"joyscale4", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale4, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale[MAXSPLITSCREENPLAYERS] = {
{"joyscale", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale, 0, NULL, NULL, 0, 0, NULL},
{"joyscale2", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale2, 0, NULL, NULL, 0, 0, NULL},
{"joyscale3", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale3, 0, NULL, NULL, 0, 0, NULL},
{"joyscale4", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale4, 0, NULL, NULL, 0, 0, NULL}
};
#else
consvar_t cv_joyscale = {"joyscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save
consvar_t cv_joyscale2 = {"joyscale2", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save
consvar_t cv_joyscale[2] = { //Alam: Dummy for save
{"joyscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL},
{"joyscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}
};
#endif
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
consvar_t cv_mouse2port = {"mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -539,9 +544,9 @@ consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL,
consvar_t cv_shownametagfinish = {"kartshownametagfinished", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t driftgaugeoffset_cons_t[] = {
{-FRACUNIT*128, "MIN"}, {FRACUNIT*128, "MAX"}, {0, NULL}};
static CV_PossibleValue_t driftgaugestyle_cons_t[] = {
{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}};
@@ -567,7 +572,15 @@ static CV_PossibleValue_t ps_descriptor_cons_t[] = {
{1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}};
consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
//consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_director[MAXSPLITSCREENPLAYERS] = {
{"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"director2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"director3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"director4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_kartdebugdirector = {"debugdirector", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showdirectorhud = {"showdirectorhud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -703,6 +716,8 @@ void D_RegisterServerCommands(void)
COM_AddCommand("addskins", Command_Addskins);
COM_AddCommand("localskin", Command_GLocalSkin);
COM_AddCommand("listwad", Command_ListWADS_f);
COM_AddCommand("listmapthings", Command_ListDoomednums_f);
COM_AddCommand("listunusedsprites", Command_ListUnusedSprites_f);
COM_AddCommand("runsoc", Command_RunSOC);
COM_AddCommand("pause", Command_Pause);
@@ -900,6 +915,7 @@ void D_RegisterClientCommands(void)
COM_AddCommand("screenshot", M_ScreenShot);
COM_AddCommand("startmovie", Command_StartMovie_f);
COM_AddCommand("stopmovie", Command_StopMovie_f);
COM_AddCommand("minigen", M_MinimapGenerate);
CV_RegisterVar(&cv_screenshot_option);
CV_RegisterVar(&cv_screenshot_folder);
@@ -997,7 +1013,11 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_showviewpointtext);
CV_RegisterVar(&cv_showdownloadprompt);
CV_RegisterVar(&cv_director);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_director[i]);
}
CV_RegisterVar(&cv_kartdebugdirector);
CV_RegisterVar(&cv_showdirectorhud);
@@ -1019,58 +1039,22 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_pauseifunfocused);
// g_input.c
CV_RegisterVar(&cv_turnaxis);
CV_RegisterVar(&cv_turnaxis2);
CV_RegisterVar(&cv_turnaxis3);
CV_RegisterVar(&cv_turnaxis4);
CV_RegisterVar(&cv_moveaxis);
CV_RegisterVar(&cv_moveaxis2);
CV_RegisterVar(&cv_moveaxis3);
CV_RegisterVar(&cv_moveaxis4);
CV_RegisterVar(&cv_brakeaxis);
CV_RegisterVar(&cv_brakeaxis2);
CV_RegisterVar(&cv_brakeaxis3);
CV_RegisterVar(&cv_brakeaxis4);
CV_RegisterVar(&cv_aimaxis);
CV_RegisterVar(&cv_aimaxis2);
CV_RegisterVar(&cv_aimaxis3);
CV_RegisterVar(&cv_aimaxis4);
CV_RegisterVar(&cv_lookaxis);
CV_RegisterVar(&cv_lookaxis2);
CV_RegisterVar(&cv_lookaxis3);
CV_RegisterVar(&cv_lookaxis4);
CV_RegisterVar(&cv_fireaxis);
CV_RegisterVar(&cv_fireaxis2);
CV_RegisterVar(&cv_fireaxis3);
CV_RegisterVar(&cv_fireaxis4);
CV_RegisterVar(&cv_driftaxis);
CV_RegisterVar(&cv_driftaxis2);
CV_RegisterVar(&cv_driftaxis3);
CV_RegisterVar(&cv_driftaxis4);
CV_RegisterVar(&cv_lookbackaxis);
CV_RegisterVar(&cv_lookbackaxis2);
CV_RegisterVar(&cv_lookbackaxis3);
CV_RegisterVar(&cv_lookbackaxis4);
CV_RegisterVar(&cv_custom1axis);
CV_RegisterVar(&cv_custom1axis2);
CV_RegisterVar(&cv_custom1axis3);
CV_RegisterVar(&cv_custom1axis4);
CV_RegisterVar(&cv_custom2axis);
CV_RegisterVar(&cv_custom2axis2);
CV_RegisterVar(&cv_custom2axis3);
CV_RegisterVar(&cv_custom2axis4);
CV_RegisterVar(&cv_custom3axis);
CV_RegisterVar(&cv_custom3axis2);
CV_RegisterVar(&cv_custom3axis3);
CV_RegisterVar(&cv_custom3axis4);
CV_RegisterVar(&cv_xdeadzone);
CV_RegisterVar(&cv_ydeadzone);
CV_RegisterVar(&cv_xdeadzone2);
CV_RegisterVar(&cv_ydeadzone2);
CV_RegisterVar(&cv_xdeadzone3);
CV_RegisterVar(&cv_ydeadzone3);
CV_RegisterVar(&cv_xdeadzone4);
CV_RegisterVar(&cv_ydeadzone4);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_turnaxis[i]);
CV_RegisterVar(&cv_moveaxis[i]);
CV_RegisterVar(&cv_brakeaxis[i]);
CV_RegisterVar(&cv_aimaxis[i]);
CV_RegisterVar(&cv_lookaxis[i]);
CV_RegisterVar(&cv_fireaxis[i]);
CV_RegisterVar(&cv_driftaxis[i]);
CV_RegisterVar(&cv_lookbackaxis[i]);
CV_RegisterVar(&cv_custom1axis[i]);
CV_RegisterVar(&cv_custom2axis[i]);
CV_RegisterVar(&cv_custom3axis[i]);
CV_RegisterVar(&cv_xdeadzone[i]);
CV_RegisterVar(&cv_ydeadzone[i]);
}
// filesrch.c
CV_RegisterVar(&cv_addons_option);
@@ -1107,28 +1091,19 @@ void D_RegisterClientCommands(void)
//CV_RegisterVar(&cv_mousemove);
//CV_RegisterVar(&cv_mousemove2);
CV_RegisterVar(&cv_usejoystick);
CV_RegisterVar(&cv_usejoystick2);
CV_RegisterVar(&cv_usejoystick3);
CV_RegisterVar(&cv_usejoystick4);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_usejoystick[i]);
}
#ifdef LJOYSTICK
CV_RegisterVar(&cv_joyport);
CV_RegisterVar(&cv_joyport2);
#endif
CV_RegisterVar(&cv_joyscale);
CV_RegisterVar(&cv_joyscale2);
CV_RegisterVar(&cv_joyscale3);
CV_RegisterVar(&cv_joyscale4);
// Analog Control
/*CV_RegisterVar(&cv_analog);
CV_RegisterVar(&cv_analog2);
CV_RegisterVar(&cv_analog3);
CV_RegisterVar(&cv_analog4);
CV_RegisterVar(&cv_useranalog);
CV_RegisterVar(&cv_useranalog2);
CV_RegisterVar(&cv_useranalog3);
CV_RegisterVar(&cv_useranalog4);*/
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_joyscale[i]);
}
// s_sound.c
CV_RegisterVar(&cv_soundvolume);
@@ -1157,7 +1132,7 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_scr_height);
CV_RegisterVar(&cv_soundtest);
CV_RegisterVar(&cv_nametag);
CV_RegisterVar(&cv_nametagtrans);
CV_RegisterVar(&cv_nametagfacerank);
@@ -1172,7 +1147,7 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_nametagscore);
CV_RegisterVar(&cv_shownametagfinish);
CV_RegisterVar(&cv_shownametagspectator);
CV_RegisterVar(&cv_driftgauge);
CV_RegisterVar(&cv_driftgaugeofs);
CV_RegisterVar(&cv_driftgaugetrans);
@@ -1675,25 +1650,9 @@ static void SendNameAndColor(void)
}
else if ((foundskin = R_SkinAvailable(cv_skin.string)) != -1)
{
//boolean notsame;
cv_skin.value = foundskin;
//notsame = (cv_skin.value != players[consoleplayer].skin);
SetPlayerSkin(consoleplayer, cv_skin.string);
CV_StealthSet(&cv_skin, skins[cv_skin.value].name);
// SRB2Kart
/*if (notsame)
{
CV_StealthSetValue(&cv_playercolor, skins[cv_skin.value].prefcolor);
players[consoleplayer].skincolor = (cv_playercolor.value&0x3F) % MAXSKINCOLORS;
if (players[consoleplayer].mo)
players[consoleplayer].mo->color = (UINT8)players[consoleplayer].skincolor;
}*/
}
else
{
@@ -1737,7 +1696,7 @@ static void SendNameAndColor(void)
WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME);
WRITEUINT8(p, (UINT8)cv_playercolor.value);
WRITEUINT8(p, (UINT8)cv_skin.value);
SendNetXCmd(XD_NAMEANDCOLOR, buf, p - buf);
SendNetXCmdForPlayer(0, XD_NAMEANDCOLOR, buf, p - buf);
}
// splitscreen
@@ -1807,24 +1766,8 @@ static void SendNameAndColor2(void)
if ((foundskin = R_SkinAvailable(cv_skin2.string)) != -1)
{
//boolean notsame;
cv_skin2.value = foundskin;
//notsame = (cv_skin2.value != players[secondplaya].skin);
SetPlayerSkin(secondplaya, cv_skin2.string);
// SRB2Kart
/*if (notsame)
{
CV_StealthSetValue(&cv_playercolor2, skins[players[secondplaya].skin].prefcolor);
players[secondplaya].skincolor = (cv_playercolor2.value&0x3F) % MAXSKINCOLORS;
if (players[secondplaya].mo)
players[secondplaya].mo->color = players[secondplaya].skincolor;
}*/
}
else
{
@@ -1867,7 +1810,7 @@ static void SendNameAndColor2(void)
WRITESTRINGN(p, cv_playername2.zstring, MAXPLAYERNAME);
WRITEUINT8(p, (UINT8)cv_playercolor2.value);
WRITEUINT8(p, (UINT8)cv_skin2.value);
SendNetXCmd2(XD_NAMEANDCOLOR, buf, p - buf);
SendNetXCmdForPlayer(1, XD_NAMEANDCOLOR, buf, p - buf);
}
static void SendNameAndColor3(void)
@@ -1988,7 +1931,7 @@ static void SendNameAndColor3(void)
WRITESTRINGN(p, cv_playername3.zstring, MAXPLAYERNAME);
WRITEUINT8(p, (UINT8)cv_playercolor3.value);
WRITEUINT8(p, (UINT8)cv_skin3.value);
SendNetXCmd3(XD_NAMEANDCOLOR, buf, p - buf);
SendNetXCmdForPlayer(2, XD_NAMEANDCOLOR, buf, p - buf);
}
static void SendNameAndColor4(void)
@@ -2057,24 +2000,8 @@ static void SendNameAndColor4(void)
if ((foundskin = R_SkinAvailable(cv_skin4.string)) != -1)
{
//boolean notsame;
cv_skin4.value = foundskin;
//notsame = (cv_skin4.value != players[fourthplaya].skin);
SetPlayerSkin(fourthplaya, cv_skin4.string);
// SRB2Kart
/*if (notsame)
{
CV_StealthSetValue(&cv_playercolor4, skins[players[fourthplaya].skin].prefcolor);
players[fourthplaya].skincolor = (cv_playercolor4.value&0x3F) % MAXSKINCOLORS;
if (players[fourthplaya].mo)
players[fourthplaya].mo->color = players[fourthplaya].skincolor;
}*/
}
else
{
@@ -2117,7 +2044,7 @@ static void SendNameAndColor4(void)
WRITESTRINGN(p, cv_playername4.zstring, MAXPLAYERNAME);
WRITEUINT8(p, (UINT8)cv_playercolor4.value);
WRITEUINT8(p, (UINT8)cv_skin4.value);
SendNetXCmd4(XD_NAMEANDCOLOR, buf, p - buf);
SendNetXCmdForPlayer(3, XD_NAMEANDCOLOR, buf, p - buf);
}
static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
@@ -2222,11 +2149,9 @@ void SendWeaponPref(void)
UINT8 buf[1];
buf[0] = 0;
if (cv_flipcam.value)
if (cv_flipcam[0].value)
buf[0] |= 1;
if (cv_analog.value)
buf[0] |= 2;
SendNetXCmd(XD_WEAPONPREF, buf, 1);
SendNetXCmdForPlayer(0, XD_WEAPONPREF, buf, 1);
}
void SendWeaponPref2(void)
@@ -2234,11 +2159,9 @@ void SendWeaponPref2(void)
UINT8 buf[1];
buf[0] = 0;
if (cv_flipcam2.value)
if (cv_flipcam[1].value)
buf[0] |= 1;
if (cv_analog2.value)
buf[0] |= 2;
SendNetXCmd2(XD_WEAPONPREF, buf, 1);
SendNetXCmdForPlayer(1, XD_WEAPONPREF, buf, 1);
}
void SendWeaponPref3(void)
@@ -2246,11 +2169,9 @@ void SendWeaponPref3(void)
UINT8 buf[1];
buf[0] = 0;
if (cv_flipcam3.value)
if (cv_flipcam[2].value)
buf[0] |= 1;
if (cv_analog3.value)
buf[0] |= 2;
SendNetXCmd3(XD_WEAPONPREF, buf, 1);
SendNetXCmdForPlayer(2, XD_WEAPONPREF, buf, 1);
}
void SendWeaponPref4(void)
@@ -2258,11 +2179,9 @@ void SendWeaponPref4(void)
UINT8 buf[1];
buf[0] = 0;
if (cv_flipcam4.value)
if (cv_flipcam[3].value)
buf[0] |= 1;
if (cv_analog4.value)
buf[0] |= 2;
SendNetXCmd4(XD_WEAPONPREF, buf, 1);
SendNetXCmdForPlayer(3, XD_WEAPONPREF, buf, 1);
}
static void Got_WeaponPref(UINT8 **cp,INT32 playernum)
@@ -2394,7 +2313,7 @@ static void Command_View_f(void)
return;
}
if (demo.freecam)
if (camera[viewnum-1].freecam)
return;
displayplayerp = &displayplayers[viewnum-1];
@@ -2521,6 +2440,12 @@ static void Command_Playdemo_f(void)
return;
}
if (!demo.playback && gamestate == GS_LEVEL) // special case: allow starting another demo while watching a demo
{
CONS_Printf(M_GetText("You can't time a demo while in a game.\n"));
return;
}
// disconnect from server here?
if (demo.playback)
G_StopDemo();
@@ -2560,6 +2485,12 @@ static void Command_Timedemo_f(void)
return;
}
if (!demo.playback && gamestate == GS_LEVEL) // special case: allow starting another demo while watching a demo
{
CONS_Printf(M_GetText("You can't time a demo while in a game.\n"));
return;
}
// disconnect from server here?
if (demo.playback)
G_StopDemo();
@@ -3023,9 +2954,14 @@ static void Command_Map_f(void)
}
}
// spend atleast 35 seconds in one map
if (cv_demochangemap.value && demo.recording && demo.savemode != DSM_NOTSAVING && (timeinmap > 1463) && ((cv_demochangemap.value == 2 && newmapnum == gamemap) || newmapnum != gamemap))
G_SaveDemo();
if (cv_demochangemap.value && demo.recording)
{
// spend atleast 40 seconds in one map
if (demo.savemode != DSM_NOTSAVING && (timeinmap > (TICRATE * 40)) && ((cv_demochangemap.value == 2 && newmapnum == gamemap) || newmapnum != gamemap))
G_SaveDemo();
else
G_ResetDemoRecording();
}
fromlevelselect = false;
D_MapChange(newmapnum, newgametype, newencoremode, newresetplayers, 0, false, false);
@@ -3114,7 +3050,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
SetPlayerSkinByNum(0, cv_chooseskin.value-1);
//mapnumber = M_MapNumber(mapname[3], mapname[4]);
//LUAh_MapChange(mapnumber);
//LUA_HookInt(mapnumber, HOOK(MapChange));
demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING;
demo.savebutton = 0;
@@ -3474,7 +3410,7 @@ static void Command_Teamchange_f(void)
}
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
SendNetXCmdForPlayer(0, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
}
static void Command_Teamchange2_f(void)
@@ -3565,7 +3501,7 @@ static void Command_Teamchange2_f(void)
}
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
SendNetXCmd2(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
SendNetXCmdForPlayer(1, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
}
static void Command_Teamchange3_f(void)
@@ -3656,7 +3592,7 @@ static void Command_Teamchange3_f(void)
}
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
SendNetXCmd3(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
SendNetXCmdForPlayer(2, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
}
static void Command_Teamchange4_f(void)
@@ -3747,7 +3683,7 @@ static void Command_Teamchange4_f(void)
}
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
SendNetXCmd4(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
SendNetXCmdForPlayer(3, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
}
static void Command_ServerTeamChange_f(void)
@@ -4013,19 +3949,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
if (!players[playernum].spectator)
{
if (players[playernum].mo)
{
//if (!players[playernum].spectator)
P_DamageMobj(players[playernum].mo, NULL, NULL, 10000);
/*else
{
if (players[playernum].mo)
{
P_RemoveMobj(players[playernum].mo);
players[playernum].mo = NULL;
}
players[playernum].playerstate = PST_REBORN;
}*/
}
P_DamageMobj(players[playernum].mo, NULL, NULL, 10000);
else
players[playernum].playerstate = PST_REBORN;
}
@@ -4159,10 +4083,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
players[playernum].mo->health = 1;
}
// In tag, check to see if you still have a game.
/*if (G_TagGametype())
P_CheckSurvivors();
else*/ if (G_BattleGametype())
if (G_BattleGametype())
K_CheckBumpers(); // SRB2Kart
else if (G_RaceGametype())
P_CheckRacers(); // also SRB2Kart
@@ -4886,10 +4807,6 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
boolean kick = false;
boolean toomany = false;
INT32 i,j;
serverinfo_pak *dummycheck = NULL;
// Shut the compiler up.
(void)dummycheck;
READSTRINGN(*cp, filename, 240);
READMEM(*cp, md5sum, 16);
@@ -5017,6 +4934,151 @@ static void Command_ListWADS_f(void)
}
}
#define MAXDOOMEDNUM 4095
static void Command_ListDoomednums_f(void)
{
INT16 i, j, k = 0, l = 0;
INT32 argc = COM_Argc();
INT16 table[MAXDOOMEDNUM];
switch (argc)
{
case 1:
l = MAXDOOMEDNUM;
break;
case 3:
l = atoi(COM_Argv(2));
if (l < 1 || l > MAXDOOMEDNUM)
{
CONS_Printf("arg 2: doomednum \x82""%d \x85out of range (1-4095)\n", k);
return;
}
//FALLTHRU
case 2:
k = atoi(COM_Argv(1));
if (k < 1 || k > MAXDOOMEDNUM)
{
CONS_Printf("arg 1: doomednum \x82""%d \x85out of range (1-4095)\n", k);
return;
}
if (!l)
l = k;
else if (l < k) // silently and helpfully swap.
{
j = k;
k = l;
l = j;
}
break;
default:
CONS_Printf("listmapthings: \x86too many arguments!\n");
return;
}
// see P_SpawnNonMobjMapThing
memset(table, 0, sizeof(table));
for (i = 1; i <= MAXPLAYERS; i++)
table[i-1] = MT_PLAYER; // playerstarts
table[33-1] = table[34-1] = table[35-1] = MT_PLAYER; // battle/team starts
table[750-1] = table[777-1] = table[778-1] = MT_UNKNOWN; // slopes
for (i = 600; i <= 609; i++)
table[i-1] = MT_RING; // placement patterns
table[1705-1] = table[1713-1] = MT_HOOP; // types of hoop
CONS_Printf("\x82""Checking for double defines...\n");
for (i = 1; i < MT_FIRSTFREESLOT+NUMMOBJFREESLOTS; i++)
{
j = mobjinfo[i].doomednum;
if (j < (k ? k : 1) || j > (l ? l : MAXDOOMEDNUM))
continue;
if (table[j-1])
{
CONS_Printf(" doomednum \x82""%d""\x80 is \x85""double-defined\x80 by ", j);
if (i < MT_FIRSTFREESLOT)
{
CONS_Printf("\x87""hardcode %s <-- MAJOR ERROR\n", MOBJTYPE_LIST[i]);
continue;
}
CONS_Printf("\x81""freeslot MT_""%s\n", FREE_MOBJS[i-MT_FIRSTFREESLOT]);
continue;
}
table[j-1] = i;
}
CONS_Printf("\x82Printing doomednum usage...\n");
if (!k)
{
i = 35; // skip MT_PLAYER spam
CONS_Printf(" doomednums \x82""1-35""\x80 are used by ""\x87""hardcode MT_PLAYER\n");
}
else
i = k-1;
for (; i < l; i++)
{
if (!table[i])
{
if (k)
{
CONS_Printf(" doomednum \x82""%d""\x80 is \x83""free!", i+1);
if (i < 99) // above the humble crawla? how dare you
CONS_Printf(" (Don't freeslot this low...)");
CONS_Printf("\n");
}
continue;
}
CONS_Printf(" doomednum \x82""%d""\x80 is used by ", i+1);
if (table[i] < MT_FIRSTFREESLOT)
{
CONS_Printf("\x87""hardcode %s\n", MOBJTYPE_LIST[table[i]]);
continue;
}
CONS_Printf("\x81""freeslot MT_""%s\n", FREE_MOBJS[table[i]-MT_FIRSTFREESLOT]);
}
}
#undef MAXDOOMEDNUM
void Command_ListUnusedSprites_f(void)
{
size_t i, j;
CONS_Printf("\x82Printing sprite non-usage...\n");
for (i = 0; i < NUMSPRITES; i++)
{
if (sprites[i].numframes)
{
// We're only showing unused sprites...
continue;
}
if (i < SPR_FIRSTFREESLOT)
{
CONS_Printf(" \x87""hardcode SPR_""%.4s\n", sprnames[i]);
continue;
}
if (used_spr[(i-SPR_FIRSTFREESLOT)/8] == 0xFF)
{
for (j = 0; j < 8; j++)
{
CONS_Printf(" \x81""freeslot SPR_""%.4s\n", sprnames[i+j]);
}
i += j;
}
if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8)))
{
CONS_Printf(" \x81""freeslot SPR_""%.4s\n", sprnames[i]);
continue;
}
break;
}
}
// =========================================================================
// MISC. COMMANDS
// =========================================================================
@@ -5306,9 +5368,6 @@ void D_GameTypeChanged(INT32 lastgametype)
else if (!multiplayer && !netgame)
{
gametype = GT_RACE; // SRB2kart
// These shouldn't matter anymore
//CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue);
//CV_SetValue(&cv_itemrespawn, 0);
}
// reset timelimit and pointlimit in race/coop, prevent stupid cheats
@@ -5330,19 +5389,6 @@ void D_GameTypeChanged(INT32 lastgametype)
}
}
// When swapping to a gametype that supports spectators,
// make everyone a spectator initially.
/*if (G_GametypeHasSpectators())
{
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i])
{
players[i].ctfteam = 0;
players[i].spectator = true;
}
}*/
// don't retain teams in other modes or between changes from ctf to team match.
// also, stop any and all forms of team scrambling that might otherwise take place.
if (G_GametypeHasTeams())
@@ -5793,10 +5839,6 @@ void Command_Retry_f(void)
CONS_Printf(M_GetText("You must be in a level to use this.\n"));
else if (netgame || multiplayer)
CONS_Printf(M_GetText("This only works in single player.\n"));
/*else if (!&players[consoleplayer] || players[consoleplayer].lives <= 1)
CONS_Printf(M_GetText("You can't retry without any lives remaining!\n"));
else if (G_IsSpecialStage(gamemap))
CONS_Printf(M_GetText("You can't retry special stages!\n"));*/
else
{
M_ClearMenus(true);
@@ -5866,10 +5908,9 @@ static void Command_Togglemodified_f(void)
modifiedgame = !modifiedgame;
}
extern UINT8 *save_p;
static void Command_Archivetest_f(void)
{
UINT8 *buf;
savebuffer_t save;
UINT32 i, wrote;
thinker_t *th;
if (gamestate != GS_LEVEL)
@@ -5885,28 +5926,28 @@ static void Command_Archivetest_f(void)
((mobj_t *)th)->mobjnum = i++;
// allocate buffer
buf = save_p = ZZ_Alloc(1024);
save.buffer = save.p = ZZ_Alloc(1024);
// test archive
CONS_Printf("LUA_Archive...\n");
LUA_Archive();
WRITEUINT8(save_p, 0x7F);
wrote = (UINT32)(save_p-buf);
LUA_Archive(&save, true);
WRITEUINT8(save.p, 0x7F);
wrote = (UINT32)(save.p - save.buffer);
// clear Lua state, so we can really see what happens!
CONS_Printf("Clearing state!\n");
LUA_ClearExtVars();
// test unarchive
save_p = buf;
save.p = save.buffer;
CONS_Printf("LUA_UnArchive...\n");
LUA_UnArchive();
i = READUINT8(save_p);
if (i != 0x7F || wrote != (UINT32)(save_p-buf))
CONS_Printf("Savegame corrupted. (write %u, read %u)\n", wrote, (UINT32)(save_p-buf));
LUA_UnArchive(&save, true);
i = READUINT8(save.p);
if (i != 0x7F || wrote != (UINT32)(save.p - save.buffer))
CONS_Printf("Savegame corrupted. (write %u, read %u)\n", wrote, (UINT32)(save.p - save.buffer));
// free buffer
Z_Free(buf);
Z_Free(save.buffer);
CONS_Printf("Done. No crash.\n");
}
#endif
+4 -9
View File
@@ -43,18 +43,12 @@ extern consvar_t cv_seenames, cv_allowseenames;
extern consvar_t cv_usemouse;
//WTF
extern consvar_t cv_mouseturn;
extern consvar_t cv_usejoystick;
extern consvar_t cv_usejoystick2;
extern consvar_t cv_usejoystick3;
extern consvar_t cv_usejoystick4;
extern consvar_t cv_usejoystick[4]; //MAXSPLITSCREENPLAYERS
#ifdef LJOYSTICK
extern consvar_t cv_joyport;
extern consvar_t cv_joyport2;
#endif
extern consvar_t cv_joyscale;
extern consvar_t cv_joyscale2;
extern consvar_t cv_joyscale3;
extern consvar_t cv_joyscale4;
extern consvar_t cv_joyscale[4]; //MAXSPLITSCREENPLAYERS
// splitscreen with second mouse
extern consvar_t cv_mouse2port;
@@ -203,7 +197,8 @@ extern consvar_t cv_ps_thinkframe_page;
extern consvar_t cv_ps_samplesize;
extern consvar_t cv_ps_descriptor;
extern consvar_t cv_director, cv_kartdebugdirector, cv_showdirectorhud;
extern consvar_t cv_director[4]; // screw you includes
extern consvar_t cv_kartdebugdirector, cv_showdirectorhud;
extern consvar_t cv_showtrackaddon;
-1
View File
@@ -403,7 +403,6 @@ typedef struct player_s
angle_t old_frameangle, old_frameangle2;
// SRB2Kart CEP: Sliptide rolling
INT32 sliptidemem;
angle_t sliproll;
INT16 lturn_max[MAXPREDICTTICS]; // What's the expected turn value for full-left for a number of frames back (to account for netgame latency)?
+1
View File
@@ -49,6 +49,7 @@ typedef struct thinker_s
// killough 11/98: count of how many other objects reference
// this one using pointers. Used for garbage collection.
INT32 references;
boolean cachable;
} thinker_t;
#endif
+33 -26
View File
@@ -14,7 +14,6 @@
#include "d_main.h" // for srb2home
#include "g_game.h"
#include "sounds.h"
#include "info.h"
#include "d_think.h"
#include "m_argv.h"
#include "z_zone.h"
@@ -33,12 +32,12 @@
#include "r_sky.h"
#include "r_draw.h" // translation colormap consts (for lua)
#include "fastcmp.h"
#include "lua_script.h"
#include "lua_glib.h"
#include "lua_hook.h"
#include "d_clisrv.h"
#include "v_video.h" // video flags (for lua)
#include "lua_glib.h"
#include "lua_hook.h"
#include "lua_script.h"
#include "lua_libs.h"
@@ -48,13 +47,14 @@
// Free slot names
// The crazy word-reading stuff uses these.
static char *FREE_STATES[NUMSTATEFREESLOTS];
static char *FREE_MOBJS[NUMMOBJFREESLOTS];
static UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
char *FREE_STATES[NUMSTATEFREESLOTS];
char *FREE_MOBJS[NUMMOBJFREESLOTS];
UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
#define initfreeslots() {\
memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\
memset(FREE_MOBJS,0,sizeof(char *) * NUMMOBJFREESLOTS);\
memset(used_spr,0,sizeof(UINT8) * ((NUMSPRITEFREESLOTS / 8) + 1));\
memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\
memset(FREE_MOBJS,0,sizeof(char *) * NUMMOBJFREESLOTS);\
memset(used_spr,0,sizeof(UINT8) * ((NUMSPRITEFREESLOTS / 8) + 1));\
}
// Crazy word-reading stuff
@@ -1493,9 +1493,6 @@ actionpointer_t actionpointers[] =
{{A_SpawnObjectRelative}, "A_SPAWNOBJECTRELATIVE"},
{{A_ChangeAngleRelative}, "A_CHANGEANGLERELATIVE"},
{{A_ChangeAngleAbsolute}, "A_CHANGEANGLEABSOLUTE"},
{{A_RollAngle}, "A_ROLLANGLE"},
{{A_ChangeRollAngleRelative},"A_CHANGEROLLANGLERELATIVE"},
{{A_ChangeRollAngleAbsolute},"A_CHANGEROLLANGLEABSOLUTE"},
{{A_PlaySound}, "A_PLAYSOUND"},
{{A_FindTarget}, "A_FINDTARGET"},
{{A_FindTracer}, "A_FINDTRACER"},
@@ -3150,7 +3147,7 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum)
// RegEx to generate this from info.h: ^\tS_([^,]+), --> \t"S_\1",
// I am leaving the prefixes solely for clarity to programmers,
// because sadly no one remembers this place while searching for full state names.
static const char *const STATE_LIST[] = { // array length left dynamic for sanity testing later.
const char *const STATE_LIST[] = { // array length left dynamic for sanity testing later.
"S_NULL",
"S_UNKNOWN",
"S_INVISIBLE", // state for invisible sprite
@@ -6364,7 +6361,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit
// RegEx to generate this from info.h: ^\tMT_([^,]+), --> \t"MT_\1",
// I am leaving the prefixes solely for clarity to programmers,
// because sadly no one remembers this place while searching for full state names.
static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later.
const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later.
"MT_NULL",
"MT_UNKNOWN",
@@ -7155,7 +7152,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s
#endif
};
static const char *const MOBJFLAG_LIST[] = {
const char *const MOBJFLAG_LIST[] = {
"SPECIAL",
"SOLID",
"SHOOTABLE",
@@ -7191,7 +7188,7 @@ static const char *const MOBJFLAG_LIST[] = {
};
// \tMF2_(\S+).*// (.+) --> \t"\1", // \2
static const char *const MOBJFLAG2_LIST[] = {
const char *const MOBJFLAG2_LIST[] = {
"AXIS", // It's a NiGHTS axis! (For faster checking)
"TWOD", // Moves like it's in a 2D level
"DONTRESPAWN", // Don't respawn this object!
@@ -7224,7 +7221,7 @@ static const char *const MOBJFLAG2_LIST[] = {
NULL
};
static const char *const MOBJEFLAG_LIST[] = {
const char *const MOBJEFLAG_LIST[] = {
"ONGROUND", // The mobj stands on solid floor (not on another mobj or in air)
"JUSTHITFLOOR", // The mobj just hit the floor while falling, this is cleared on next frame
"TOUCHWATER", // The mobj stands in a sector with water, and touches the surface
@@ -7242,14 +7239,14 @@ static const char *const MOBJEFLAG_LIST[] = {
NULL
};
static const char *const MAPTHINGFLAG_LIST[4] = {
const char *const MAPTHINGFLAG_LIST[4] = {
NULL,
"OBJECTFLIP", // Reverse gravity flag for objects.
"OBJECTSPECIAL", // Special flag used with certain objects.
"AMBUSH" // Deaf monsters/do not react to sound.
};
static const char *const PLAYERFLAG_LIST[] = {
const char *const PLAYERFLAG_LIST[] = {
// Flip camera angle with gravity flip prefrence.
"FLIPCAM",
@@ -7321,7 +7318,7 @@ static const char *const PLAYERFLAG_LIST[] = {
};
// Linedef flags
static const char *const ML_LIST[16] = {
const char *const ML_LIST[16] = {
"IMPASSIBLE",
"BLOCKMONSTERS",
"TWOSIDED",
@@ -7342,7 +7339,7 @@ static const char *const ML_LIST[16] = {
// This DOES differ from r_draw's Color_Names, unfortunately.
// Also includes Super colors
static const char *COLOR_ENUMS[] = { // Rejigged for Kart.
const char *COLOR_ENUMS[] = { // Rejigged for Kart.
"NONE", // SKINCOLOR_NONE
"WHITE", // SKINCOLOR_WHITE
"SILVER", // SKINCOLOR_SILVER
@@ -7510,7 +7507,7 @@ static const char *COLOR_ENUMS[] = { // Rejigged for Kart.
"CSUPER5" // SKINCOLOR_CSUPER5,
};
static const char *const POWERS_LIST[] = {
const char *const POWERS_LIST[] = {
"INVULNERABILITY",
"SNEAKERS",
"FLASHING",
@@ -7545,7 +7542,7 @@ static const char *const POWERS_LIST[] = {
"INGOOP" // In goop
};
static const char *const KARTSTUFF_LIST[] = {
const char *const KARTSTUFF_LIST[] = {
"POSITION",
"OLDPOSITION",
"POSITIONDELAY",
@@ -7632,7 +7629,7 @@ static const char *const KARTSTUFF_LIST[] = {
"GROWCANCEL"
};
static const char *const HUDITEMS_LIST[] = {
const char *const HUDITEMS_LIST[] = {
"LIVESNAME",
"LIVESPIC",
"LIVESNUM",
@@ -8545,6 +8542,16 @@ static int lua_enumlib_mariomode_get(lua_State *L)
return 1;
}
static int lua_enumlib_replayfreecam_get(lua_State *L)
{
if (dedicated) // huh?
lua_pushboolean(L, false);
else
lua_pushboolean(L, camera[R_GetViewNumber()].freecam);
return 1;
}
static int lua_enumlib_twodlevel_get(lua_State *L)
{
lua_pushboolean(L, twodlevel);
@@ -9222,7 +9229,7 @@ int LUA_EnumLib(lua_State *L)
lua_pushcfunction(L, lua_glib_new_getter);
lua_pushliteral(L, "replayfreecam");
lua_glib_push_bool_getter(L, &demo.freecam);
lua_pushcfunction(L, lua_enumlib_replayfreecam_get);
lua_call(L, 2, 0);
if (!mathlib)
+20
View File
@@ -14,6 +14,26 @@
#define __DEHACKED_H__
#include "m_fixed.h" // for get_number
#include "info.h"
// Free slot names
// The crazy word-reading stuff uses these.
extern char *FREE_STATES[NUMSTATEFREESLOTS];
extern char *FREE_MOBJS[NUMMOBJFREESLOTS];
extern UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
extern const char *const STATE_LIST[];
extern const char *const MOBJTYPE_LIST[];
extern const char *const MOBJFLAG_LIST[];
extern const char *const MOBJFLAG2_LIST[]; // \tMF2_(\S+).*// (.+) --> \t"\1", // \2
extern const char *const MOBJEFLAG_LIST[];
extern const char *const MAPTHINGFLAG_LIST[4];
extern const char *const PLAYERFLAG_LIST[];
extern const char *const ML_LIST[]; // Linedef flags
extern const char *COLOR_ENUMS[];
extern const char *const POWERS_LIST[];
extern const char *const KARTSTUFF_LIST[];
extern const char *const HUDITEMS_LIST[];
void DEH_LoadDehackedLump(lumpnum_t lumpnum);
void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump);
+16
View File
@@ -522,6 +522,22 @@ extern boolean capslock;
// i_system.c, replace getchar() once the keyboard has been appropriated
INT32 I_GetKey(void);
/* http://www.cse.yorku.ca/~oz/hash.html */
static inline
UINT32 quickncasehash (const char *p, size_t n)
{
size_t i = 0;
UINT32 x = 5381;
while (i < n && p[i])
{
x = (x * 33) ^ tolower(p[i]);
i++;
}
return x;
}
#ifndef min // Double-Check with WATTCP-32's cdefs.h
#define min(x, y) (((x) < (y)) ? (x) : (y))
#endif
+1
View File
@@ -122,6 +122,7 @@ extern boolean gamedataloaded;
// Player taking events, and displaying.
extern INT32 consoleplayer;
extern INT32 displayplayers[MAXSPLITSCREENPLAYERS];
extern INT32 g_localplayers[MAXSPLITSCREENPLAYERS];
// Maps of special importance
extern INT16 spstage_start;
+24
View File
@@ -365,6 +365,30 @@ typedef UINT32 tic_t;
#define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24)
#endif
#define TOSTR(x) #x
typedef UINT8 bitarray_t;
#define BIT_ARRAY_SIZE(n) (((n) + 7) >> 3)
static inline int
in_bit_array (const bitarray_t * const array, const int value)
{
return (array[value >> 3] & (1<<(value & 7)));
}
static inline void
set_bit_array (bitarray_t * const array, const int value)
{
array[value >> 3] |= (1<<(value & 7));
}
static inline void
unset_bit_array (bitarray_t * const array, const int value)
{
array[value >> 3] &= ~(1<<(value & 7));
}
typedef UINT64 precise_t;
#endif //__DOOMTYPE__
+6 -5
View File
@@ -327,7 +327,8 @@ char menupath[1024];
size_t menupathindex[menudepth];
size_t menudepthleft = menudepth;
char menusearch[MAXSTRINGLENGTH+1];
char menusearchbuf[MAXSTRINGLENGTH+1];
textinput_t menusearch;
char **dirmenu, **coredirmenu; // core only local for this file
size_t sizedirmenu, sizecoredirmenu; // ditto
@@ -497,7 +498,7 @@ static boolean filemenucmp(char *haystack, char *needle)
strupr(localhaystack);
if (cv_addons_search_type.value)
return (strstr(localhaystack, needle) != 0);
return (!strncmp(localhaystack, needle, menusearch[0]));
return (!strncmp(localhaystack, needle, menusearch.length));
}
void closefilemenu(boolean validsize)
@@ -563,7 +564,7 @@ void searchfilemenu(char *tempname)
first = (((UINT8)(coredirmenu[0][DIR_TYPE]) == EXT_UP) ? 1 : 0); // skip UP...
if (!menusearch[0])
if (!menusearch.length)
{
if (dirmenu)
Z_Free(dirmenu);
@@ -590,7 +591,7 @@ void searchfilemenu(char *tempname)
return;
}
strcpy(localmenusearch, menusearch+1);
strcpy(localmenusearch, menusearch.buffer);
if (!cv_addons_search_case.value)
strupr(localmenusearch);
@@ -652,7 +653,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
tempname = Z_StrDup(dirmenu[dir_on[menudepthleft]]+DIR_STRING); // don't need to I_Error if can't make - not important, just QoL
}
else
menusearch[0] = menusearch[1] = 0; // clear search
M_TextInputInit(&menusearch, menusearchbuf, MAXSTRINGLENGTH+1);
if (!(dirhandle = opendir(menupath))) // get directory
{
+3 -1
View File
@@ -7,6 +7,7 @@
#include "doomdef.h"
#include "d_netfil.h"
#include "m_menu.h" // MAXSTRINGLENGTH
#include "m_textinput.h"
extern consvar_t cv_addons_option, cv_addons_folder, cv_addons_md5, cv_addons_showall, cv_addons_search_case, cv_addons_search_type;
@@ -34,7 +35,8 @@ extern char menupath[1024];
extern size_t menupathindex[menudepth];
extern size_t menudepthleft;
extern char menusearch[MAXSTRINGLENGTH+1];
extern char menusearchbuf[MAXSTRINGLENGTH+1];
extern textinput_t menusearch;
extern char **dirmenu;
extern size_t sizedirmenu;
+663 -946
View File
File diff suppressed because it is too large. Load diff
+18 -9
View File
@@ -17,6 +17,7 @@
#include "doomdef.h"
#include "doomstat.h"
#include "d_event.h"
#include "p_saveg.h"
#include "m_textinput.h"
extern char gamedatafilename[64];
@@ -33,7 +34,7 @@ extern INT32 player_name_changes[MAXPLAYERS];
extern player_t players[MAXPLAYERS];
extern boolean playeringame[MAXPLAYERS];
extern UINT8 *demo_p;
extern savebuffer_t demobuf;
// ======================================
// DEMO playback/recording related stuff.
@@ -120,12 +121,21 @@ extern consvar_t cv_pauseifunfocused;
//extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4;
extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove*/;
extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/;
extern consvar_t cv_useranalog, cv_useranalog2, cv_useranalog3, cv_useranalog4;
extern consvar_t cv_analog, cv_analog2, cv_analog3, cv_analog4;
extern consvar_t cv_turnaxis,cv_moveaxis,cv_brakeaxis,cv_aimaxis,cv_lookaxis,cv_fireaxis,cv_driftaxis,cv_lookbackaxis,cv_custom1axis,cv_custom2axis,cv_custom3axis,cv_xdeadzone,cv_ydeadzone;
extern consvar_t cv_turnaxis2,cv_moveaxis2,cv_brakeaxis2,cv_aimaxis2,cv_lookaxis2,cv_fireaxis2,cv_driftaxis2,cv_lookbackaxis2,cv_custom1axis2,cv_custom2axis2,cv_custom3axis2,cv_xdeadzone2,cv_ydeadzone2;
extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis3,cv_fireaxis3,cv_driftaxis3,cv_lookbackaxis3,cv_custom1axis3,cv_custom2axis3,cv_custom3axis3,cv_xdeadzone3,cv_ydeadzone3;
extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_lookbackaxis4,cv_custom1axis4,cv_custom2axis4,cv_custom3axis4,cv_xdeadzone4,cv_ydeadzone4;
extern consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_aimaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_lookaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_lookbackaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_fireaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_driftaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_custom1axis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_custom2axis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_custom3axis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_xdeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff;
// Hud offsets
@@ -166,7 +176,6 @@ extern consvar_t cv_saltysquish;
extern consvar_t cv_driftsparkpulse;
extern consvar_t cv_gravstretch;
extern consvar_t cv_sloperoll;
extern consvar_t cv_spriteroll;
extern consvar_t cv_sliptideroll;
extern consvar_t cv_slamsound;
extern consvar_t cv_sloperolldist;
@@ -266,7 +275,6 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost);
// A normal game starts at map 1, but a warp test can start elsewhere
void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar,
UINT8 ssplayers, boolean FLS);
void G_DoLoadLevel(boolean resetplayer);
void G_LoadDemoInfo(menudemo_t *pdemo);
void G_LoadDemoTitle(menudemo_t *pdemo); // For use in replay search feature
@@ -356,6 +364,7 @@ extern demoghost *ghosts;
#define DFILE_ERROR_CANNOTLOAD 0x04 // Files are missing and cannot be loaded.
#define DFILE_ERROR_EXTRAFILES 0x05 // Extra files outside of the replay's file list are loaded.
void G_ResetDemoRecording(void);
void G_DoPlayDemo(char *defdemoname);
void G_TimeDemo(const char *name);
void G_AddGhost(char *defdemoname);
+14 -27
View File
@@ -902,34 +902,15 @@ static const char *gamecontrolname[num_gamecontrols] =
"custom2",
"custom3",
"director",
"freecam",
"camfloat",
"camsink",
};
#define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t))
#include "k_kart.h"
INT32 G_GetDeviceForPlayer(INT32 player)
{
switch (player)
{
case 0:
return cv_usejoystick.value;
break;
case 1:
return cv_usejoystick2.value;
break;
case 2:
return cv_usejoystick3.value;
break;
case 3:
return cv_usejoystick4.value;
break;
default:
return 0;
break;
}
}
inline UINT16 G_GetSkinColor(INT32 player)
{
// make rgb rainbow vomit when invul or flash blue when grow
@@ -972,7 +953,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color)
if (cv_gamepadled[player].value == 0)
return;
device = G_GetDeviceForPlayer(player);
device = cv_usejoystick[player].value;
if (device <= 0)
{
@@ -989,7 +970,7 @@ static void G_ResetPlayerGamepadIndicatorColor(INT32 player)
{
if (cv_gamepadled[player].value == 0)
{
INT32 device = G_GetDeviceForPlayer(player);
INT32 device = cv_usejoystick[player].value;
if (device <= 0)
return;
@@ -1003,7 +984,7 @@ static void G_ResetPlayerDeviceRumble(INT32 player)
{
INT32 device_id;
device_id = G_GetDeviceForPlayer(player);
device_id = cv_usejoystick[player].value;
if (device_id < 1)
{
@@ -1022,7 +1003,7 @@ void G_ResetAllDeviceRumbles(void)
for (i = 0; i < devices; i++)
{
INT32 device_id = G_GetDeviceForPlayer(i);
INT32 device_id = cv_usejoystick[i].value;
I_GamepadRumble(device_id, 0, 0, 0);
}
@@ -1037,7 +1018,7 @@ void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strengt
return;
}
device_id = G_GetDeviceForPlayer(player);
device_id = cv_usejoystick[player].value;
if (device_id < 1)
{
@@ -1161,6 +1142,12 @@ void G_Controldefault(UINT8 player)
//gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT
gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down
gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up
gamecontrol[gc_camfloat ][0] = 'a';
gamecontrol[gc_camsink ][0] = 'd';
gamecontrol[gc_camfloat ][1] = KEY_JOY1+0; // A
gamecontrol[gc_camsink ][1] = KEY_JOY1+1; // B
}
if (player == 0 || player == 2)
+3
View File
@@ -100,6 +100,9 @@ typedef enum
gc_custom2, // Lua scriptable
gc_custom3, // Lua scriptable
gc_director,
gc_freecam, // Toggle for freecam while ingame
gc_camfloat, // alternative button for raising cam
gc_camsink, // alternative button for sinking
num_gamecontrols
} gamecontrols_e;
+13 -12
View File
@@ -15,8 +15,9 @@
#include "hw_main.h"
#include "../i_system.h"
#include "../qs22j.h"
#include "../doomdef.h"
#include "../qs22j.h"
// The texture for the next polygon given to HWR_ProcessPolygon.
// Set with HWR_SetCurrentTexture.
@@ -64,7 +65,7 @@ void HWR_StartBatching(void)
currently_batching = true;
}
// This replaces the direct calls to pfnSetTexture in cases where batching is available.
// This replaces the direct calls to GL_SetTexture in cases where batching is available.
// The texture selection is saved for the next HWR_ProcessPolygon call.
// Doing this was easier than getting a texture pointer to HWR_ProcessPolygon.
void HWR_SetCurrentTexture(GLMipmap_t *texture)
@@ -75,7 +76,7 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture)
}
else
{
HWD.pfnSetTexture(texture);
GL_SetTexture(texture);
}
}
@@ -129,8 +130,8 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
}
else
{
HWD.pfnSetShader((shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target);
HWD.pfnDrawPolygon(pSurf, pOutVerts, iNumPts, PolyFlags);
GL_SetShader((shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target);
GL_DrawPolygon(pSurf, pOutVerts, iNumPts, PolyFlags);
}
}
@@ -227,7 +228,7 @@ void HWR_RenderBatches(void)
int currentShader;
int nextShader = 0;
GLMipmap_t *currentTexture;
GLMipmap_t *currentTexture = NULL;
GLMipmap_t *nextTexture = NULL;
FBITFIELD currentPolyFlags = 0;
FBITFIELD nextPolyFlags = 0;
@@ -291,13 +292,13 @@ void HWR_RenderBatches(void)
if (cv_glshaders.value && gl_shadersavailable)
{
HWD.pfnSetShader(currentShader);
GL_SetShader(currentShader);
}
if (currentPolyFlags & PF_NoTexture)
currentTexture = NULL;
else
HWD.pfnSetTexture(currentTexture);
GL_SetTexture(currentTexture);
while (1)// note: remember handling notexture polyflag as having texture number 0 (also in comparePolygons)
{
@@ -412,7 +413,7 @@ void HWR_RenderBatches(void)
if (changeState || stopFlag)
{
// execute draw call
HWD.pfnDrawIndexedTriangles(&currentSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray);
GL_DrawIndexedTriangles(&currentSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray);
// update stats
ps_hw_numcalls.value.i++;
ps_hw_numverts.value.i += finalIndexWritePos;
@@ -430,7 +431,7 @@ void HWR_RenderBatches(void)
{
if (changeShader)
{
HWD.pfnSetShader(nextShader);
GL_SetShader(nextShader);
currentShader = nextShader;
changeShader = false;
@@ -438,8 +439,8 @@ void HWR_RenderBatches(void)
}
if (changeTexture)
{
// texture should be already ready for use from calls to SetTexture during batch collection
HWD.pfnSetTexture(nextTexture);
// texture should be already ready for use from calls to GL_SetTexture during batch collection
GL_SetTexture(nextTexture);
currentTexture = nextTexture;
changeTexture = false;
+3 -1
View File
@@ -15,7 +15,9 @@
#include "hw_defs.h"
#include "hw_data.h"
#include "hw_drv.h"
#include "hw_gl.h"
extern boolean currently_batching;
typedef struct
{
+102 -96
View File
@@ -14,9 +14,10 @@
#include "../doomdef.h"
#ifdef HWRENDER
#include "hw_main.h"
#include "hw_glob.h"
#include "hw_drv.h"
#include "hw_gl.h"
#include "hw_batching.h"
#include "../doomstat.h" //gamemode
@@ -54,10 +55,10 @@ static INT32 format2bpp(GLTextureFormat_t format)
// It is now split from it for my sanity! (and the sanity of others)
// -- Monster Iestyn (13/02/19)
static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap,
INT32 pblockheight, INT32 blockmodulo,
fixed_t yfracstep, fixed_t scale_y,
texpatch_t *originPatch, INT32 patchheight,
INT32 bpp, RGBA_t *palette)
INT32 pblockheight, INT32 blockmodulo,
fixed_t yfracstep, fixed_t scale_y,
texpatch_t *originPatch, INT32 patchheight,
INT32 bpp, RGBA_t *palette)
{
fixed_t yfrac, position, count;
UINT8 *dest;
@@ -73,6 +74,9 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
(void)patchheight; // This parameter is unused
if (!mipmap)
return;
if (originPatch) // originPatch can be NULL here, unlike in the software version
originy = originPatch->originy;
@@ -108,14 +112,14 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
count--;
texel = source[yfrac>>FRACBITS];
alpha = 0xff;
alpha = 0xFF;
//Hurdler: not perfect, but better than holes
if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX && (mipmap->flags & TF_CHROMAKEYED))
// Make pixel transparent if chroma keyed
if ((mipmap && mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
alpha = 0x00;
//Hurdler: 25/04/2000: now support colormap in hardware mode
if (mipmap->colormap)
if (mipmap && mipmap->colormap)
texel = mipmap->colormap[texel];
// hope compiler will get this switch out of the loops (dreams...)
@@ -123,7 +127,8 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
// Alam: SRB2 uses Mingw, HUGS
switch (bpp)
{
case 2 : texelu16 = (UINT16)((alpha<<8) | texel);
case 2 : // uhhhhhhhh..........
texelu16 = (UINT16)((alpha<<8) | texel);
memcpy(dest, &texelu16, sizeof(UINT16));
break;
case 3 : colortemp = palette[texel];
@@ -141,6 +146,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
dest += blockmodulo;
yfrac += yfracstep;
}
patchcol = (const column_t *)((const UINT8 *)patchcol + patchcol->length + 4);
}
}
@@ -182,6 +188,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp);
// NOTE: should this actually be pblockwidth*bpp?
blockmodulo = pblockwidth*bpp;
// Draw each column to the block cache
@@ -260,6 +267,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawTexturePatchInCache: no drawer defined for this bpp (%d)\n",bpp);
// NOTE: should this actually be pblockwidth*bpp?
blockmodulo = pblockwidth*bpp;
// Draw each column to the block cache
@@ -333,8 +341,8 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
else
gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY;
gltex->mipmap.width = (UINT16)texture->width;
gltex->mipmap.height = (UINT16)texture->height;
gltex->mipmap.width = (UINT16)(texture->width);
gltex->mipmap.height = (UINT16)(texture->height);
if (skyspecial)
gltex->mipmap.format = GL_TEXFMT_RGBA; // that skyspecial code below assumes this format ...
@@ -359,14 +367,17 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
RGBA_t col;
col = palette[HWR_CHROMAKEY_EQUIVALENTCOLORINDEX];
for (j = 0; j < blockheight; j++)
{
for (i = 0; i < blockwidth; i++)
{
block[4*(j*blockwidth+i)+0] = col.s.red;
block[4*(j*blockwidth+i)+1] = col.s.green;
block[4*(j*blockwidth+i)+2] = col.s.blue;
block[4*(j*blockwidth+i)+3] = 0xff;
int idx = (j*blockwidth+i);
block[4*idx+0] = col.s.red;
block[4*idx+1] = col.s.green;
block[4*idx+2] = col.s.blue;
block[4*idx+3] = 0xff;
}
}
}
@@ -375,15 +386,12 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++)
{
realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE);
HWR_DrawTexturePatchInCache(&gltex->mipmap,
blockwidth, blockheight,
texture, patch,
realpatch);
HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch);
Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED);
}
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
if (format2bpp(gltex->mipmap.format)==4)
if (format2bpp(gltex->mipmap.format) == 4)
{
for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp
{
@@ -413,14 +421,13 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, bo
glPatch->leftoffset = SHORT(patch->leftoffset);
glPatch->topoffset = SHORT(patch->topoffset);
//glMipmap->width = (UINT16)SHORT(patch->width);
//glMipmap->height = (UINT16)SHORT(patch->height);
glMipmap->width = glMipmap->height = 1;
while (glMipmap->width < glPatch->width) glMipmap->width <<= 1;
while (glMipmap->height < glPatch->height) glMipmap->height <<= 1;
// no wrap around, no chroma key
glMipmap->flags = 0;
// setup the texture info
glMipmap->format = patchformat;
@@ -435,13 +442,12 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, bo
if (makebitmap)
{
MakeBlock(glMipmap);
HWR_DrawPatchInCache(glMipmap,
glMipmap->width, glMipmap->height,
glPatch->width, glPatch->height,
patch);
}
//glPatch->max_s = glPatch->max_t = 1.0f;
}
// =================================================
@@ -494,7 +500,7 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
if (next->data)
Z_Free(next->data);
next->data = NULL;
HWD.pfnDeleteTexture(next);
GL_DeleteTexture(next);
// Free the old colormap mipmap from memory.
free(next);
@@ -505,7 +511,7 @@ void HWR_FreeMipmapCache(void)
{
INT32 i;
// free references to the textures
HWD.pfnClearMipMapCache();
GL_ClearMipMapCache();
// free all hardware-converted graphics cached in the heap
// our gool is only the textures since user of the texture is the texture cache
@@ -572,7 +578,7 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore)
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!gltex->mipmap.downloaded)
HWD.pfnSetTexture(&gltex->mipmap);
GL_SetTexture(&gltex->mipmap);
HWR_SetCurrentTexture(&gltex->mipmap);
// The system-memory data can be purged now.
@@ -641,117 +647,117 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum)
// Download a Doom 'flat' to the hardware cache and make it ready for use
void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
{
GLMipmap_t *glmip;
GLMipmap_t *glMipmap;
if (flatlumpnum == LUMPERROR)
return;
glmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
glMipmap = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
glmip->colormap = colormaps;
glMipmap->colormap = colormaps;
#ifdef GLENCORE
if (!noencoremap && encoremap)
glmip->colormap += COLORMAP_REMAPOFFSET;
glMipmap->colormap += COLORMAP_REMAPOFFSET;
#endif
if (!glmip->downloaded && !glmip->data)
HWR_CacheFlat(glmip, flatlumpnum);
if (!glMipmap->downloaded && !glMipmap->data)
HWR_CacheFlat(glMipmap, flatlumpnum);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!glmip->downloaded)
HWD.pfnSetTexture(glmip);
HWR_SetCurrentTexture(glmip);
if (!glMipmap->downloaded)
GL_SetTexture(glMipmap);
HWR_SetCurrentTexture(glMipmap);
// The system-memory data can be purged now.
Z_ChangeTag(glmip->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
}
//
// HWR_LoadMappedPatch(): replace the skin color of the sprite in cache
// : load it first in doom cache if not already
//
static void HWR_LoadMappedPatch(GLMipmap_t *glmip, GLPatch_t *gpatch)
static void HWR_LoadMappedPatch(GLMipmap_t *glMipmap, GLPatch_t *glPatch)
{
if (!glmip->downloaded && !glmip->data)
if (!glMipmap->downloaded && !glMipmap->data)
{
patch_t *patch = gpatch->rawpatch;
patch_t *patch = glPatch->rawpatch;
if (!patch)
patch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
HWR_MakePatch(patch, gpatch, glmip, true);
patch = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC);
HWR_MakePatch(patch, glPatch, glMipmap, true);
// You can't free rawpatch for some reason?
// (Obviously I can't, sprite rotation needs that...)
if (!gpatch->rawpatch)
if (!glPatch->rawpatch)
Z_Free(patch);
}
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!glmip->downloaded)
HWD.pfnSetTexture(glmip);
HWR_SetCurrentTexture(glmip);
if (!glMipmap->downloaded)
GL_SetTexture(glMipmap);
HWR_SetCurrentTexture(glMipmap);
// The system-memory data can be purged now.
Z_ChangeTag(glmip->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
}
// -----------------+
// HWR_GetPatch : Download a patch to the hardware cache and make it ready for use
// HWR_GetPatch : Downloads a patch to the hardware cache and make it ready for use
// -----------------+
void HWR_GetPatch(GLPatch_t *gpatch)
void HWR_GetPatch(GLPatch_t *glPatch)
{
// is it in hardware cache
if (!gpatch->mipmap->downloaded && !gpatch->mipmap->data)
if (!glPatch->mipmap->downloaded && !glPatch->mipmap->data)
{
// load the software patch, PU_STATIC or the Z_Malloc for hardware patch will
// flush the software patch before the conversion! oh yeah I suffered
patch_t *ptr = gpatch->rawpatch;
patch_t *ptr = glPatch->rawpatch;
if (!ptr)
ptr = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
HWR_MakePatch(ptr, gpatch, gpatch->mipmap, true);
ptr = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC);
HWR_MakePatch(ptr, glPatch, glPatch->mipmap, true);
// this is inefficient.. but the hardware patch in heap is purgeable so it should
// not fragment memory, and besides the REAL cache here is the hardware memory
if (!gpatch->rawpatch)
if (!glPatch->rawpatch)
Z_Free(ptr);
}
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!gpatch->mipmap->downloaded)
HWD.pfnSetTexture(gpatch->mipmap);
HWR_SetCurrentTexture(gpatch->mipmap);
if (!glPatch->mipmap->downloaded)
GL_SetTexture(glPatch->mipmap);
HWR_SetCurrentTexture(glPatch->mipmap);
// The system-memory patch data can be purged now.
Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glPatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
}
// -------------------+
// HWR_GetMappedPatch : Same as HWR_GetPatch for sprite color
// -------------------+
void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap)
{
GLMipmap_t *glmip, *newmip;
GLMipmap_t *glMipmap, *newMipmap;
// Blatant hack for encore colormapping aside...
if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET))
{
// Load the default (green) color in doom cache (temporary?) AND hardware cache
HWR_GetPatch(gpatch);
HWR_GetPatch(glPatch);
return;
}
// search for the mimmap
// search for the mipmap
// skip the first (no colormap translated)
for (glmip = gpatch->mipmap; glmip->nextcolormap; )
for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap; )
{
glmip = glmip->nextcolormap;
glMipmap = glMipmap->nextcolormap;
if (glmip->colormap != colormap)
if (glMipmap->colormap != colormap)
continue;
HWR_LoadMappedPatch(glmip, gpatch);
HWR_LoadMappedPatch(glMipmap, glPatch);
return;
}
// not found, create it!
@@ -761,38 +767,38 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
// (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeTextureCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
newmip = calloc(1, sizeof (*newmip));
if (newmip == NULL)
newMipmap = calloc(1, sizeof (*newMipmap));
if (newMipmap == NULL)
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
glmip->nextcolormap = newmip;
glMipmap->nextcolormap = newMipmap;
newmip->colormap = colormap;
HWR_LoadMappedPatch(newmip, gpatch);
newMipmap->colormap = colormap;
HWR_LoadMappedPatch(newMipmap, glPatch);
}
void HWR_UnlockCachedPatch(GLPatch_t *gpatch)
void HWR_UnlockCachedPatch(GLPatch_t *glPatch)
{
if (!gpatch)
if (!glPatch)
return;
Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glPatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
}
GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum)
{
aatree_t *hwrcache = wadfiles[wadnum]->hwrcache;
GLPatch_t *glpatch;
GLPatch_t *glPatch;
if (!(glpatch = M_AATreeGet(hwrcache, lumpnum)))
if (!(glPatch = M_AATreeGet(hwrcache, lumpnum)))
{
glpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
glpatch->wadnum = wadnum;
glpatch->lumpnum = lumpnum;
glpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
M_AATreeSet(hwrcache, lumpnum, glpatch);
glPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
glPatch->wadnum = wadnum;
glPatch->lumpnum = lumpnum;
glPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
M_AATreeSet(hwrcache, lumpnum, glPatch);
}
return glpatch;
return glPatch;
}
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum)
@@ -887,17 +893,17 @@ static void HWR_CacheFadeMask(GLMipmap_t *glMipmap, lumpnum_t fademasklumpnum)
void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
{
GLMipmap_t *glmip;
GLMipmap_t *glMipmap;
glmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
glMipmap = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
if (!glmip->downloaded && !glmip->data)
HWR_CacheFadeMask(glmip, fademasklumpnum);
if (!glMipmap->downloaded && !glMipmap->data)
HWR_CacheFadeMask(glMipmap, fademasklumpnum);
HWD.pfnSetTexture(glmip);
GL_SetTexture(glMipmap);
// The system-memory data can be purged now.
Z_ChangeTag(glmip->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
}
// =================================================
@@ -927,11 +933,11 @@ void HWR_SetPalette(RGBA_t *palette)
crushed_palette[i].s.blue = (UINT8)(fblue / 31.0f * 255.0f);
crushed_palette[i].s.alpha = 255;
}
HWD.pfnSetScreenPalette(crushed_palette);
GL_SetScreenPalette(crushed_palette);
}
else
{
HWD.pfnSetScreenPalette(palette);
GL_SetScreenPalette(palette);
}
// this part is responsible for keeping track of the palette OUTSIDE of a level.
@@ -941,7 +947,7 @@ void HWR_SetPalette(RGBA_t *palette)
else
{
// set the palette for the textures
HWD.pfnSetTexturePalette(palette);
GL_SetPalette(palette);
// reset mapPalette so next call to HWR_SetMapPalette will update everything correctly
memset(mapPalette, 0, sizeof(mapPalette));
// hardware driver will flush there own cache if cache is non paletized
@@ -974,7 +980,7 @@ static void HWR_SetPaletteLookup(RGBA_t *palette)
}
}
#undef STEP_SIZE
HWD.pfnSetPaletteLookup(lut);
GL_SetPaletteLookup(lut);
Z_Free(lut);
}
@@ -1022,7 +1028,7 @@ void HWR_SetMapPalette(void)
// in palette rendering mode, this means that all rgba textures now have wrong colors
// and the lookup table is outdated
HWR_SetPaletteLookup(mapPalette);
HWD.pfnSetTexturePalette(mapPalette);
GL_SetPalette(mapPalette);
if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA)
{
@@ -1045,7 +1051,7 @@ UINT32 HWR_CreateLightTable(UINT8 *lighttable)
for (i = 0; i < 256 * 32; i++)
hw_lighttable[i] = palette[lighttable[i]];
id = HWD.pfnCreateLightTable(hw_lighttable);
id = GL_CreateLightTable(hw_lighttable);
Z_Free(hw_lighttable);
return id;
}
@@ -1081,7 +1087,7 @@ UINT32 HWR_GetLightTableID(extracolormap_t *colormap)
void HWR_ClearLightTables(void)
{
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWD.pfnClearLightTables();
GL_ClearLightTables();
}
#endif //HWRENDER
+3 -3
View File
@@ -333,11 +333,11 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
// ok, this is a gross hack that barely works...
// but at least it doesn't overestimate too much...
clipfov = atan(1 / projMatrix[0]) * 360 / M_PI;
clipfov = atan(1 / projMatrix[0]) * 360 / M_PIl;
floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * clipfov / 90.0f;
if (floatangle >= 180.0)
return 0xffffffff;
a1 = (angle_t)(ANG1 * (int)floatangle);
a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle);
return a1;
}
@@ -458,4 +458,4 @@ boolean gld_SphereInFrustum(float x, float y, float z, float radius)
}
return true;
}
#endif
#endif
+7 -5
View File
@@ -33,16 +33,18 @@ typedef enum GLTextureFormat_e
GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22,
} GLTextureFormat_t;
// data holds the address of the graphics data cached in heap memory
// NULL if the texture is not in Doom heap cache.
// Texture information (misleadingly named "mipmap" all over the code.)
// The *data pointer holds the address of the graphics data cached in heap memory.
// NULL if the texture is not in SRB2's heap cache.
struct GLMipmap_s
{
// for UpdateTexture
GLTextureFormat_t format;
void *data;
UINT32 flags;
UINT16 width, height;
UINT32 downloaded; // tex_downloaded
UINT32 downloaded; // The GPU has this texture.
struct GLMipmap_s *nextcolormap;
const UINT8 *colormap;
@@ -50,12 +52,12 @@ struct GLMipmap_s
typedef struct GLMipmap_s GLMipmap_t;
//
// Doom texture info, as cached for hardware rendering
// Level textures, as cached for hardware rendering.
//
struct GLMapTexture_s
{
GLMipmap_t mipmap;
float scaleX; //used for scaling textures on walls
float scaleX; //used for scaling textures on walls
float scaleY;
};
typedef struct GLMapTexture_s GLMapTexture_t;
+41 -7
View File
@@ -132,14 +132,14 @@ typedef struct
{
FLOAT x,y,z; // position
#ifdef USE_FTRANSFORM_ANGLEZ
FLOAT anglex,angley,anglez; // aimingangle / viewangle
FLOAT anglex2,anglez2; // secondaries
FLOAT anglex, angley, anglez; // aimingangle / viewangle
FLOAT anglex2, anglez2; // secondaries
#else
FLOAT anglex,angley; // aimingangle / viewangle
FLOAT anglex, angley; // aimingangle / viewangle
FLOAT anglex2; // secondaries
#endif
FLOAT scalex,scaley,scalez;
FLOAT spritexscale,spriteyscale;
FLOAT scalex, scaley, scalez;
FLOAT spritexscale, spriteyscale;
FLOAT fovxangle, fovyangle;
UINT8 splitscreen;
boolean flip; // screenflip
@@ -164,6 +164,41 @@ typedef struct
FLOAT s,t;
} FOutVector;
typedef struct vbo_vertex_s
{
float x, y, z;
float u, v;
unsigned char r, g, b, a;
} gl_skyvertex_t;
typedef enum gl_skyloopmode_e
{
HWD_SKYLOOP_FAN,
HWD_SKYLOOP_STRIP
} gl_skyloopmode_t;
typedef struct
{
gl_skyloopmode_t mode;
int vertexcount;
int vertexindex;
boolean use_texture;
} gl_skyloopdef_t;
typedef struct
{
unsigned int vbo;
int rows, columns;
int loopcount;
int detail, vertex_count;
int texture, width, height;
boolean rebuild; // VBO needs to be rebuilt
gl_skyloopdef_t *loops;
gl_skyvertex_t *data;
} gl_sky_t;
// Shader targets used to render specific types of geometry.
// A shader target is resolved to an actual shader with HWR_GetShaderFromTarget.
// The shader returned may be a base shader or a custom shader.
@@ -171,7 +206,6 @@ enum
{
SHADER_NONE = -1,
SHADER_FLOOR = 0,
SHADER_SHADOW,
SHADER_WALL,
SHADER_SPRITE,
SHADER_MODEL,
@@ -202,7 +236,6 @@ enum hwdshaderstage
typedef enum hwdshaderstage hwdshaderstage_t;
// ==========================================================================
// RENDER MODES
// ==========================================================================
@@ -341,6 +374,7 @@ enum hwdscreentexture
HWD_SCREENTEXTURE_WIPE_END, // destination image for the wipe/fade effect
HWD_SCREENTEXTURE_GENERIC1, // underwater/heat effect, intermission background
HWD_SCREENTEXTURE_GENERIC2, // palette-based colormap fade, final screen texture
HWD_SCREENTEXTURE_VHS,
NUMSCREENTEXTURES, // (generic3 is unused if palette rendering is disabled)
};
typedef enum hwdscreentexture hwdscreentexture_t;
+39 -38
View File
@@ -18,9 +18,10 @@
#include "../doomdef.h"
#ifdef HWRENDER
#include "hw_main.h"
#include "hw_glob.h"
#include "hw_drv.h"
#include "hw_gl.h"
#include "../m_misc.h" //FIL_WriteFile()
#include "../r_draw.h" //viewborderlump
@@ -122,7 +123,7 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option)
flags |= PF_ForceWrapY;
// clip it since it is used for bunny scroll in doom I
HWD.pfnDrawPolygon(NULL, v, 4, flags);
GL_DrawPolygon(NULL, v, 4, flags);
}
void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap)
@@ -303,10 +304,10 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans];
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
GL_DrawPolygon(&Surf, v, 4, flags);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags);
GL_DrawPolygon(NULL, v, 4, flags);
}
void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h)
@@ -460,10 +461,10 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value];
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
GL_DrawPolygon(&Surf, v, 4, flags);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags);
GL_DrawPolygon(NULL, v, 4, flags);
}
// ==========================================================================
@@ -539,7 +540,7 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
// BTW, I see we put 0 for PFs, and If I'm right, that
// means we take the previous PFs as default
// how can we be sure they are ok?
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
GL_DrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
}
@@ -552,33 +553,33 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
// 0--1
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
{
FOutVector v[4];
FSurfaceInfo Surf;
FOutVector v[4];
FSurfaceInfo Surf;
FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest;
v[0].x = v[3].x = -1.0f;
v[2].x = v[1].x = 1.0f;
v[0].y = v[1].y = -1.0f;
v[2].y = v[3].y = 1.0f;
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
v[0].x = v[3].x = -1.0f;
v[2].x = v[1].x = 1.0f;
v[0].y = v[1].y = -1.0f;
v[2].y = v[3].y = 1.0f;
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
v[0].s = v[3].s = 0.0f;
v[2].s = v[1].s = 1.0f;
v[0].t = v[1].t = 1.0f;
v[2].t = v[3].t = 0.0f;
v[0].s = v[3].s = 0.0f;
v[2].s = v[1].s = 1.0f;
v[0].t = v[1].t = 1.0f;
v[2].t = v[3].t = 0.0f;
if (color & 0xFF00) // Do COLORMAP fade.
{
if (color & 0xFF00) // Do COLORMAP fade.
{
if (HWR_ShouldUsePaletteRendering() && cv_glscreentextures.value)
{
const hwdscreentexture_t scr_tex = HWD_SCREENTEXTURE_GENERIC2;
Surf.LightTableId = HWR_GetLightTableID(NULL);
Surf.LightInfo.light_level = strength;
HWD.pfnMakeScreenTexture(scr_tex);
HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_UI_COLORMAP_FADE));
HWD.pfnDrawScreenTexture(scr_tex, &Surf, PF_ColorMapped|PF_NoDepthTest);
HWD.pfnUnSetShader();
GL_MakeScreenTexture(scr_tex);
GL_SetShader(HWR_GetShaderFromTarget(SHADER_UI_COLORMAP_FADE));
GL_DrawScreenTexture(scr_tex, &Surf, PF_ColorMapped|PF_NoDepthTest);
GL_UnSetShader();
return;
}
@@ -588,9 +589,9 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
Surf.PolyColor.s.alpha = (strength*8);
poly_flags |= PF_Translucent;
}
}
else // Do TRANSMAP** fade.
{
}
else // Do TRANSMAP** fade.
{
RGBA_t *palette = HWR_GetTexturePalette();
Surf.PolyColor.rgba = palette[color&0xFF].rgba;
@@ -600,9 +601,9 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f);
poly_flags |= PF_Translucent;
}
}
HWD.pfnDrawPolygon(&Surf, v, 4, poly_flags);
GL_DrawPolygon(&Surf, v, 4, poly_flags);
}
// Draw the console background with translucency support
@@ -629,7 +630,7 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height)
Surf.PolyColor.rgba = UINT2RGBA(color);
Surf.PolyColor.s.alpha = 0x80;
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
}
@@ -785,7 +786,7 @@ void HWR_drawAMline(const fline_t *fl, INT32 color)
v2.x = ((float)fl->b.x-(vid.width/2.0f))*(2.0f/vid.width);
v2.y = ((float)fl->b.y-(vid.height/2.0f))*(2.0f/vid.height);
HWD.pfnDraw2DLine(&v1, &v2, color_rgba);
GL_Draw2DLine(&v1, &v2, color_rgba);
}
// -----------------+
@@ -879,7 +880,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
Surf.PolyColor = palette[color&0xFF];
HWD.pfnDrawPolygon(&Surf, v, 4,
GL_DrawPolygon(&Surf, v, 4,
PF_Modulated|PF_NoTexture|PF_NoDepthTest);
}
@@ -918,7 +919,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
clearColour.green = (float)rgbaColour.s.green / 255;
clearColour.blue = (float)rgbaColour.s.blue / 255;
clearColour.alpha = 1;
HWD.pfnClearBuffer(true, false, false, &clearColour);
GL_ClearBuffer(true, false, false, &clearColour);
return;
}
@@ -989,7 +990,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
Surf.PolyColor.rgba = UINT2RGBA(color);
Surf.PolyColor.s.alpha = 0x80;
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
}
// -----------------+
@@ -1029,7 +1030,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
clearColour.green = (float)rgbaColour.s.green / 255;
clearColour.blue = (float)rgbaColour.s.blue / 255;
clearColour.alpha = 1;
HWD.pfnClearBuffer(true, false, false, &clearColour);
GL_ClearBuffer(true, false, false, &clearColour);
return;
}
@@ -1107,7 +1108,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
}
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
}
#ifdef HAVE_PNG
@@ -1191,7 +1192,7 @@ UINT8 *HWR_GetScreenshot(void)
return NULL;
// returns 24bit 888 RGB
HWD.pfnReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
GL_ReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
return buf;
}
@@ -1207,7 +1208,7 @@ boolean HWR_Screenshot(const char *pathname)
}
// returns 24bit 888 RGB
HWD.pfnReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
GL_ReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
#ifdef USE_PNG
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
-142
View File
@@ -1,142 +0,0 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2019 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief imports/exports for the GPU hardware low-level interface API
#ifndef __HWR_DRV_H__
#define __HWR_DRV_H__
// this must be here 19991024 by Kin
#include "../screen.h"
#include "hw_data.h"
#include "hw_defs.h"
#include "hw_md2.h"
#include "hw_dll.h"
#include "../doomdef.h"
// ==========================================================================
// STANDARD DLL EXPORTS
// ==========================================================================
EXPORT boolean HWRAPI(Init) (void);
EXPORT void HWRAPI(SetupGLInfo) (void);
EXPORT void HWRAPI(SetTexturePalette) (RGBA_t *ppal);
EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl);
EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray);
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT16 *dst_data);
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
EXPORT void HWRAPI(ClearMipMapCache) (void);
//Hurdler: added for backward compatibility
EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
//Hurdler: added for new development
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface);
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model);
EXPORT void HWRAPI(SetTransform) (FTransform *stransform);
EXPORT INT32 HWRAPI(GetTextureUsed) (void);
EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture_height, FTransform transform);
EXPORT void HWRAPI(FlushScreenTextures) (void);
EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd);
EXPORT void HWRAPI(DrawScreenTexture) (int tex, FSurfaceInfo *surf, FBITFIELD polyflags);
EXPORT void HWRAPI(MakeScreenTexture) (int tex);
EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, INT32 width, INT32 height);
EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize);
#define SCREENVERTS 10
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
// jimita
EXPORT boolean HWRAPI(InitShaders) (void);
EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage);
EXPORT boolean HWRAPI(CompileShader) (int slot);
EXPORT void HWRAPI(SetShader) (int slot);
EXPORT void HWRAPI(UnSetShader) (void);
EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value);
EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut);
EXPORT UINT32 HWRAPI(CreateLightTable)(RGBA_t *hw_lighttable);
EXPORT void HWRAPI(ClearLightTables)(void);
EXPORT void HWRAPI(SetScreenPalette)(RGBA_t *palette);
// ==========================================================================
// HWR DRIVER OBJECT, FOR CLIENT PROGRAM
// ==========================================================================
#if !defined (_CREATE_DLL_)
struct hwdriver_s
{
Init pfnInit;
SetupGLInfo pfnSetupGLInfo;
SetTexturePalette pfnSetTexturePalette;
FinishUpdate pfnFinishUpdate;
Draw2DLine pfnDraw2DLine;
DrawPolygon pfnDrawPolygon;
DrawIndexedTriangles pfnDrawIndexedTriangles;
SetBlend pfnSetBlend;
ClearBuffer pfnClearBuffer;
SetTexture pfnSetTexture;
UpdateTexture pfnUpdateTexture;
DeleteTexture pfnDeleteTexture;
ReadScreenTexture pfnReadScreenTexture;
GClipRect pfnGClipRect;
ClearMipMapCache pfnClearMipMapCache;
SetSpecialState pfnSetSpecialState;
DrawModel pfnDrawModel;
CreateModelVBOs pfnCreateModelVBOs;
SetTransform pfnSetTransform;
GetTextureUsed pfnGetTextureUsed;
PostImgRedraw pfnPostImgRedraw;
FlushScreenTextures pfnFlushScreenTextures;
DoScreenWipe pfnDoScreenWipe;
DrawScreenTexture pfnDrawScreenTexture;
MakeScreenTexture pfnMakeScreenTexture;
RenderVhsEffect pfnRenderVhsEffect;
DrawScreenFinalTexture pfnDrawScreenFinalTexture;
RenderSkyDome pfnRenderSkyDome;
InitShaders pfnInitShaders;
LoadShader pfnLoadShader;
CompileShader pfnCompileShader;
SetShader pfnSetShader;
UnSetShader pfnUnSetShader;
SetShaderInfo pfnSetShaderInfo;
SetPaletteLookup pfnSetPaletteLookup;
CreateLightTable pfnCreateLightTable;
ClearLightTables pfnClearLightTables;
SetScreenPalette pfnSetScreenPalette;
};
extern struct hwdriver_s hwdriver;
#define HWD hwdriver
#endif //not defined _CREATE_DLL_
#endif //__HWR_DRV_H__
+79
View File
@@ -0,0 +1,79 @@
// SONIC ROBO BLAST 2 Kart
//-----------------------------------------------------------------------------
// Copyright (C) 2020 by Jaime "Lactozilla" Passos.
// Copyright (C) 2020 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file hw_gl.h
/// \brief OpenGL low-level interface API
#ifndef __HWR_GL_H__
#define __HWR_GL_H__
#include "../screen.h"
#include "hw_data.h"
#include "hw_defs.h"
#include "hw_md2.h"
#define SCREENVERTS 10
boolean GL_Init(void);
void GL_FinishUpdate(INT32 waitvbl);
void SetupGLInfo(void);
void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value);
void GL_SetTransform(FTransform *stransform);
void GL_SetBlend(FBITFIELD PolyFlags);
void GL_SetPalette(RGBA_t *palette);
void GL_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat * ClearColor);
void GL_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
void GL_DrawIndexedTriangles(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray);
void GL_Draw2DLine(F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface);
#define GL_DrawModel(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface) GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface)
void GL_RenderSkyDome(gl_sky_t *sky);
void GL_SetTexture(GLMipmap_t *pTexInfo);
void GL_DeleteTexture(GLMipmap_t *pTexInfo);
void GL_Flush(void);
#define GL_ClearMipMapCache GL_Flush
INT32 GL_GetTextureUsed(void);
void GL_CreateModelVBOs(model_t *model);
void GL_ReadScreenTexture(int tex, UINT16 *dst_data);
void GL_GClipRect(INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
void GL_MakeScreenTexture(int tex);
void GL_FlushScreenTextures(void);
void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags);
void GL_DoScreenWipe(int wipeStart, int wipeEnd);
void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize);
void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean useshader);
void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]);
boolean GL_InitShaders(void);
void GL_LoadShader(int slot, char *code, hwdshaderstage_t stage);
boolean GL_CompileShader(int slot);
void GL_SetShader(int slot);
void GL_UnSetShader(void);
void GL_SetShaderInfo(hwdshaderinfo_t info, INT32 value);
void GL_SetPaletteLookup(UINT8 *lut);
UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable);
void GL_ClearLightTables(void);
void GL_SetScreenPalette(RGBA_t *palette);
#endif // __HWR_GL_H__
+496 -262
View File
File diff suppressed because it is too large. Load diff
+4 -1
View File
@@ -105,6 +105,9 @@ void HWR_AddCommands(void);
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *player, int stencil_level, boolean allow_portals);
void HWR_ClearSkyDome(void);
void HWR_BuildSkyDome(void);
void HWR_SetTransform(float fpov, player_t *player);
void HWR_ClearClipper(void);
void HWR_SetStencilState(int state, int level);
@@ -131,7 +134,7 @@ void HWR_DrawIntermissionBG(void);
void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum);
void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize);
void HWR_MakeScreenFinalTexture(void);
void HWR_DrawScreenFinalTexture(INT32 width, INT32 height);
void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader);
// hw_main.c: Segs
void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom
+45 -47
View File
@@ -25,12 +25,14 @@
#include "../doomstat.h"
#ifdef HWRENDER
#include "hw_drv.h"
#include "hw_gl.h"
#include "hw_md2.h"
#include "../d_main.h"
#include "../r_bsp.h"
#include "../r_fps.h"
#include "../r_main.h"
#include "../p_setup.h"
#include "../m_misc.h"
#include "../w_wad.h"
#include "../z_zone.h"
@@ -43,8 +45,8 @@
#include "hw_main.h"
#include "../v_video.h"
#ifdef HAVE_PNG
#ifdef HAVE_PNG
#ifndef _MSC_VER
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
@@ -417,7 +419,7 @@ static void md2_loadTexture(md2_t *model)
}
}
}
HWD.pfnSetTexture(glpatch->mipmap);
GL_SetTexture(glpatch->mipmap);
HWR_UnlockCachedPatch(glpatch);
}
@@ -467,7 +469,7 @@ static void md2_loadBlendTexture(md2_t *model)
glpatch->mipmap->width = (UINT16)w;
glpatch->mipmap->height = (UINT16)h;
}
HWD.pfnSetTexture(glpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary
GL_SetTexture(glpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary
HWR_UnlockCachedPatch(glpatch);
Z_Free(filename);
@@ -680,7 +682,7 @@ spritemd2found:
#define SETBRIGHTNESS(brightness,r,g,b) \
brightness = (UINT8)(((1063*(UINT32)(r))/5000) + ((3576*(UINT32)(g))/5000) + ((361*(UINT32)(b))/5000))
static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *glmip, INT32 skinnum, skincolors_t color)
static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *glMipmap, INT32 skinnum, skincolors_t color)
{
UINT16 w = gpatch->width, h = gpatch->height;
UINT32 size = w*h;
@@ -696,24 +698,24 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
memset(translation, 0, sizeof(translation));
memset(cutoff, 0, sizeof(cutoff));
if (glmip->width == 0)
if (glMipmap->width == 0)
{
glmip->width = gpatch->width;
glmip->height = gpatch->height;
glMipmap->width = gpatch->width;
glMipmap->height = gpatch->height;
// no wrap around, no chroma key
glmip->flags = 0;
glMipmap->flags = 0;
// setup the texture info
glmip->format = GL_TEXFMT_RGBA;
glMipmap->format = GL_TEXFMT_RGBA;
}
if (glmip->data)
if (glMipmap->data)
{
Z_Free(glmip->data);
glmip->data = NULL;
Z_Free(glMipmap->data);
glMipmap->data = NULL;
}
cur = Z_Malloc(size*4, PU_HWRCACHE, &glmip->data);
cur = Z_Malloc(size*4, PU_HWRCACHE, &glMipmap->data);
memset(cur, 0x00, size*4);
image = gpatch->mipmap->data;
@@ -794,10 +796,9 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
}
}
}
}
if (translen > 0)
colorbrightnesses[translen] = colorbrightnesses[translen-1];
}
while (size--)
{
@@ -1044,28 +1045,29 @@ skippixel:
static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolors_t color)
{
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment
GLMipmap_t *glmip, *newmip;
GLMipmap_t *glMipmap, *newMipmap;
if (colormap == colormaps || colormap == NULL)
{
// Don't do any blending
HWD.pfnSetTexture(gpatch->mipmap);
GL_SetTexture(gpatch->mipmap);
return;
}
// search for the mimmap
// search for the Mipmap
// skip the first (no colormap translated)
for (glmip = gpatch->mipmap; glmip->nextcolormap; )
for (glMipmap = gpatch->mipmap; glMipmap->nextcolormap; )
{
glmip = glmip->nextcolormap;
if (glmip->colormap == colormap)
glMipmap = glMipmap->nextcolormap;
if (glMipmap->colormap != colormap)
continue;
if (glMipmap->downloaded && glMipmap->data)
{
if (glmip->downloaded && glmip->data)
{
HWD.pfnSetTexture(glmip); // found the colormap, set it to the correct texture
Z_ChangeTag(glmip->data, PU_HWRCACHE_UNLOCKED);
return;
}
GL_SetTexture(glMipmap); // found the colormap, set it to the correct texture
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
return;
}
}
@@ -1076,19 +1078,18 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
// (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeTextureCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
newmip = calloc(1, sizeof (*newmip));
if (newmip == NULL)
newMipmap = calloc(1, sizeof (*newMipmap));
if (newMipmap == NULL)
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
glmip->nextcolormap = newmip;
newmip->colormap = colormap;
glMipmap->nextcolormap = newMipmap;
newMipmap->colormap = colormap;
HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color);
HWR_CreateBlendedTexture(gpatch, blendgpatch, newMipmap, skinnum, color);
HWD.pfnSetTexture(newmip);
Z_ChangeTag(newmip->data, PU_HWRCACHE_UNLOCKED);
GL_SetTexture(newMipmap);
Z_ChangeTag(newMipmap->data, PU_HWRCACHE_UNLOCKED);
}
// -----------------+
// HWR_DrawMD2 : Draw MD2
// :
@@ -1234,7 +1235,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
if (md2->model)
{
md2_printModelInfo(md2->model);
HWD.pfnCreateModelVBOs(md2->model);
GL_CreateModelVBOs(md2->model);
}
else
{
@@ -1289,7 +1290,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
else
{
// This is safe, since we know the texture has been downloaded
HWD.pfnSetTexture(gpatch->mipmap);
GL_SetTexture(gpatch->mipmap);
}
}
else
@@ -1370,19 +1371,16 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
p.spritexscale = FIXED_TO_FLOAT(spr->mobj->spritexscale);
p.spriteyscale = FIXED_TO_FLOAT(spr->mobj->spriteyscale);
angle_t sliptideroll = 0;
if (spr->mobj->player)
sliptideroll = ((cv_sloperoll.value && cv_sliptideroll.value) ? spr->mobj->player->sliproll : 0);
angle_t sliptideroll = ((cv_sloperoll.value && cv_sliptideroll.value && spr->mobj->player) ? spr->mobj->player->sliproll : 0);
if ((spr->mobj->rollangle)||(sliptideroll && cv_sliptideroll.value))
if (spr->mobj->rollangle || sliptideroll)
{
angle_t rollang = 0;
rollfactor = ((spr->mobj->rollmodel == true) ? 1 : 0);
rollang = (spr->mobj->player && sliptideroll && cv_sliptideroll.value)
? (spr->mobj->rollangle * rollfactor) + (sliptideroll * spr->mobj->player->sliptidemem)
rollang = sliptideroll
? (spr->mobj->rollangle * rollfactor) + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat])
: (spr->mobj->rollangle * rollfactor);
fixed_t anglef = AngleFixed(rollang);
@@ -1465,7 +1463,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
p.mirror = atransform.mirror; // from Kart
#endif
HWD.pfnSetShader(SHADER_MODEL); // model shader
GL_SetShader(SHADER_MODEL); // model shader
{
SINT8 flipfactor = flip ? -1 : 1;
@@ -1482,7 +1480,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
p.y += ox * gl_viewcos;
p.z += oy;
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, hflip, &Surf);
GL_DrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, hflip, &Surf);
}
}
}
+8 -4
View File
@@ -23,7 +23,7 @@
#include "../z_zone.h"
#include "hw_clip.h"
#include "hw_drv.h"
#include "hw_gl.h"
#include "hw_defs.h"
#include "hw_main.h"
#include "hw_portal.h"
@@ -132,7 +132,7 @@ void HWR_PortalFrame(gl_portal_t* portal)
{
portalclipline = NULL;
portalcullsector = NULL;
viewsector = R_PointInSubsector(viewx, viewy)->sector;
viewsector = R_PointInSubsectorFast(viewx, viewy)->sector;
}
}
@@ -140,16 +140,20 @@ void HWR_PortalFrame(gl_portal_t* portal)
static void HWR_RenderPortalSeg(gl_portal_t* portal, SINT8 state)
{
gl_drawing_stencil = true; // do not draw outside of the stencil buffer, idiot.
// set our portal state and prepare to render the seg
HWR_SetPortalState(state);
gl_curline = portal->seg;
gl_frontsector = portal->seg->frontsector;
gl_backsector = portal->seg->backsector;
HWR_ProcessSeg();
gl_drawing_stencil = false;
// need to work around the r_opengl PF_Invisible bug with this call
// similarly as in the linkdraw hack in HWR_DrawSprites
HWD.pfnSetBlend(PF_Translucent|PF_Occlude|PF_Masked);
GL_SetBlend(PF_Translucent|PF_Occlude|PF_Masked);
}
// Renders a single portal from the current viewpoint.
@@ -171,7 +175,7 @@ void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float
HWR_PortalFrame(rootportal);
else // current frame is not a portal frame but the main view!
{
R_SetupFrame(player, false);
R_SetupFrame(viewssnum, false);
portalclipline = NULL;
}
+5 -9
View File
@@ -13,7 +13,7 @@
#include "hw_main.h"
#include "hw_glob.h"
#include "hw_drv.h"
#include "hw_gl.h"
#include "hw_shaders.h"
#include "../z_zone.h"
@@ -29,9 +29,6 @@ static struct {
// Floor shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_FLOOR_FRAGMENT_SHADER},
// Shadow shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_SHADOW_FRAGMENT_SHADER},
// Wall shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER},
@@ -90,7 +87,7 @@ boolean HWR_InitShaders(void)
{
int i;
if (!HWD.pfnInitShaders())
if (!GL_InitShaders())
return false;
for (i = 0; i < NUMSHADERTARGETS; i++)
@@ -369,16 +366,16 @@ static void HWR_CompileShader(int index)
{
char *preprocessed = HWR_PreprocessShader(vertex_source);
if (!preprocessed) return;
HWD.pfnLoadShader(index, preprocessed, HWD_SHADERSTAGE_VERTEX);
GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_VERTEX);
}
if (fragment_source)
{
char *preprocessed = HWR_PreprocessShader(fragment_source);
if (!preprocessed) return;
HWD.pfnLoadShader(index, preprocessed, HWD_SHADERSTAGE_FRAGMENT);
GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_FRAGMENT);
}
gl_shaders[index].compiled = HWD.pfnCompileShader(index);
gl_shaders[index].compiled = GL_CompileShader(index);
}
// compile or recompile shaders
@@ -432,7 +429,6 @@ static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum)
customshaderxlat_t shaderxlat[] =
{
{"Flat", SHADER_FLOOR},
{"Shadow", SHADER_SHADOW},
{"WallTexture", SHADER_WALL},
{"Sprite", SHADER_SPRITE},
{"Model", SHADER_MODEL},
+1 -4
View File
@@ -99,6 +99,7 @@
GLSL_DOOM_COLORMAP_NODITHER \
"#endif\n" \
"}\n"
// lighting cap adjustment:
// first num (155.0), increase to make it start to go dark sooner
// second num (0.26), increase to make it go dark faster
@@ -211,10 +212,6 @@
GLSL_WALL_FUDGES \
GLSL_SOFTWARE_FRAGMENT_SHADER
#define GLSL_SHADOW_FRAGMENT_SHADER \
GLSL_FLOOR_FUDGES \
GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL
//
// Water surface shader
//
+3 -22
View File
@@ -358,8 +358,8 @@ static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode)
else
textureformatGL = GL_RGB5_A1;
SetModelView(lvid->width, lvid->height);
SetStates();
GL_SetModelView(lvid->width, lvid->height);
GL_SetStates();
// we need to clear the depth buffer. Very important!!!
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
@@ -526,7 +526,7 @@ EXPORT void HWRAPI(Shutdown) (void)
// -----------------+
// FinishUpdate : Swap front and back buffers
// -----------------+
EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl)
void GL_FinishUpdate (INT32 waitvbl)
{
#ifdef USE_WGL_SWAP
static INT32 oldwaitvbl = 0;
@@ -547,23 +547,4 @@ EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl)
SwapBuffers(hDC);
}
// -----------------+
// SetPalette : Set the color lookup table for paletted textures
// : in OpenGL, we store values for conversion of paletted graphics when
// : they are downloaded to the 3D card.
// -----------------+
EXPORT void HWRAPI(SetPalette) (RGBA_t *pal)
{
INT32 i;
for (i = 0; i < 256; i++)
{
myPaletteData[i].s.red = pal[i].s.red;
myPaletteData[i].s.green = pal[i].s.green;
myPaletteData[i].s.blue = pal[i].s.blue;
myPaletteData[i].s.alpha = pal[i].s.alpha;
}
}
#endif
File diff suppressed because it is too large. Load diff
+14 -10
View File
@@ -43,8 +43,9 @@
#endif
#define _CREATE_DLL_ // necessary for Unix AND Windows
#include "../../doomdef.h"
#include "../hw_drv.h"
#include "../hw_gl.h"
#include "../../z_zone.h"
// ==========================================================================
@@ -65,14 +66,15 @@ extern FILE *gllogstream;
// PROTOS
// ==========================================================================
boolean LoadGL(void);
FUNCPRINTF void GL_DBG_Printf(const char *format, ...);
void *GetGLFunc(const char *proc);
boolean SetupGLfunc(void);
void SetupGLFunc4(void);
void Flush(void);
INT32 isExtAvailable(const char *extension, const GLubyte *start);
void SetModelView(GLint w, GLint h);
void SetStates(void);
void GL_Flush(void);
INT32 GL_isExtAvailable(const char *extension, const GLubyte *start);
void GL_SetModelView(GLint w, GLint h);
void GL_SetStates(void);
#ifndef GL_EXT_texture_filter_anisotropic
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
@@ -101,11 +103,11 @@ extern PFNglGetString pglGetString;
#endif
#ifdef USE_FBO_OGL
void GLFramebuffer_DeleteAttachments(void);
void GL_Framebuffer_DeleteAttachments(void);
void GLFramebuffer_Unbind(void);
void GLFramebuffer_Enable(void);
void GLFramebuffer_Disable(void);
void GL_Framebuffer_Unbind(void);
void GL_Framebuffer_Enable(void);
void GL_Framebuffer_Disable(void);
extern GLuint FramebufferObject, FramebufferTexture, RenderbufferObject;
extern GLboolean FrameBufferEnabled, RenderToFramebuffer;
@@ -119,6 +121,8 @@ extern boolean supportFBO;
extern const GLubyte *gl_version;
extern const GLubyte *gl_renderer;
extern const GLubyte *gl_extensions;
extern const GLubyte *gl_vendor;
extern GLuint gl_num_extensions;
extern int majorGL, minorGL;
+18 -18
View File
@@ -289,7 +289,7 @@ int
HMS_register (void)
{
struct HMS_buffer *hms;
int ok;
int okay;
char post[256];
@@ -316,23 +316,23 @@ HMS_register (void)
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
okay = HMS_do(hms);
if (ok)
if (okay)
{
hms_server_token = strdup(strtok(hms->buffer, "\n"));
}
HMS_end(hms);
return ok;
return okay;
}
int
HMS_unlist (void)
{
struct HMS_buffer *hms;
int ok;
int okay;
hms = HMS_connect("servers/%s/unlist", hms_server_token);
@@ -342,19 +342,19 @@ HMS_unlist (void)
curl_easy_setopt(hms->curl, CURLOPT_POST, 1);
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDSIZE, 0);
ok = HMS_do(hms);
okay = HMS_do(hms);
HMS_end(hms);
free(hms_server_token);
return ok;
return okay;
}
int
HMS_update (void)
{
struct HMS_buffer *hms;
int ok;
int okay;
char post[256];
@@ -376,10 +376,10 @@ HMS_update (void)
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
okay = HMS_do(hms);
HMS_end(hms);
return ok;
return okay;
}
void
@@ -488,7 +488,7 @@ int
HMS_compare_mod_version (char *buffer, size_t buffer_size)
{
struct HMS_buffer *hms;
int ok;
int okay;
char *version;
char *version_name;
@@ -498,7 +498,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size)
if (! hms)
return 0;
ok = 0;
okay = 0;
if (HMS_do(hms))
{
@@ -510,16 +510,16 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size)
if (atoi(version) != MODVERSION)
{
strlcpy(buffer, version_name, buffer_size);
ok = 1;
okay = 1;
}
else
ok = -1;
okay = -1;
}
}
HMS_end(hms);
return ok;
return okay;
}
const char *
@@ -532,9 +532,9 @@ HMS_fetch_rules (char *buffer, size_t buffer_size)
if (! hms)
return NULL;
boolean ok = HMS_do(hms);
boolean okay = HMS_do(hms);
if (ok)
if (okay)
{
char *p = strstr(hms->buffer, "\n\n");
@@ -552,7 +552,7 @@ HMS_fetch_rules (char *buffer, size_t buffer_size)
HMS_end(hms);
if (!ok)
if (!okay)
return NULL;
return buffer;
+2 -2
View File
@@ -1003,7 +1003,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
if (LUAh_PlayerMsg(playernum, target, flags, msg, spam_eatmsg))
if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg))
return;
if (spam_eatmsg)
@@ -2274,7 +2274,7 @@ void HU_Drawer(void)
if (renderisnewtic)
{
LUA_HUD_ClearDrawList(luahuddrawlist_scores);
LUAh_ScoresHUD(luahuddrawlist_scores);
LUA_HUDHOOK(scores, luahuddrawlist_scores);
}
LUA_HUD_DrawList(luahuddrawlist_scores);
+1 -1
View File
@@ -53,6 +53,6 @@ typedef struct JoyType_s JoyType_t;
for palyer[sic] 1-4's joystick/gamepad
*/
extern JoyType_t Joystick, Joystick2, Joystick3, Joystick4;
extern JoyType_t Joystick[MAXSPLITSCREENPLAYERS];
#endif // __I_JOY_H__
-8
View File
@@ -82,18 +82,10 @@ extern holepunch_t *holepunchpacket;
*/
extern boolean (*I_NetGet)(void);
/** \brief ask to driver if there is data waiting
*/
extern boolean (*I_NetCanGet)(void);
/** \brief send packet within doomcom struct
*/
extern void (*I_NetSend)(void);
/** \brief ask to driver if all is ok to send data now
*/
extern boolean (*I_NetCanSend)(void);
/** \brief close a connection
\param nodenum node to be closed
+7 -15
View File
@@ -202,9 +202,13 @@ void I_JoyScale4(void);
// Called by D_SRB2Main.
/** \brief to startup joystick
*/
void I_InitJoystick(UINT8 index);
/** \brief to startup the first joystick
*/
void I_InitJoystick(void);
void I_InitJoystick1(void);
/** \brief to startup the second joystick
*/
@@ -307,21 +311,9 @@ INT32 I_mkdir(const char *dirname, INT32 unixright);
*/
const char *I_LocateWad(void);
/** \brief First Joystick's events
/** \brief Joystick events
*/
void I_GetJoystickEvents(void);
/** \brief Second Joystick's events
*/
void I_GetJoystick2Events(void);
/** \brief Third Joystick's events
*/
void I_GetJoystick3Events(void);
/** \brief Fourth Joystick's events
*/
void I_GetJoystick4Events(void);
void I_GetJoystickEvents(UINT8 index);
/** \brief Mouses events
*/
+6 -75
View File
@@ -168,7 +168,6 @@ static UINT8 UPNP_support = TRUE;
#endif
#include "i_addrinfo.h"
#define SELECTTEST
#define DEFAULTPORT "5029"
@@ -750,59 +749,6 @@ static boolean SOCK_Get(void)
}
#endif
// check if we can send (do not go over the buffer)
#ifndef NONET
static fd_set masterset;
#ifdef SELECTTEST
static boolean FD_CPY(fd_set *src, fd_set *dst, SOCKET_TYPE *fd, size_t len)
{
size_t i;
boolean testset = false;
FD_ZERO(dst);
for (i = 0; i < len;i++)
{
if(fd[i] != (SOCKET_TYPE)ERRSOCKET &&
FD_ISSET(fd[i], src) && !FD_ISSET(fd[i], dst)) // no checking for dups
{
FD_SET(fd[i], dst);
testset = true;
}
}
return testset;
}
static boolean SOCK_CanSend(void)
{
struct timeval timeval_for_select = {0, 0};
fd_set tset;
int wselect;
if(!FD_CPY(&masterset, &tset, mysockets, mysocketses))
return false;
wselect = select(255, NULL, &tset, NULL, &timeval_for_select);
if (wselect >= 1)
return true;
return false;
}
static boolean SOCK_CanGet(void)
{
struct timeval timeval_for_select = {0, 0};
fd_set tset;
int rselect;
if(!FD_CPY(&masterset, &tset, mysockets, mysocketses))
return false;
rselect = select(255, &tset, NULL, NULL, &timeval_for_select);
if (rselect >= 1)
return true;
return false;
}
#endif
#endif
#ifndef NONET
static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr)
{
@@ -877,7 +823,7 @@ static void SOCK_Send(void)
}
}
#undef ALLOWEDERROR
#endif
#endif //NONET
#ifndef NONET
static void SOCK_FreeNodenum(INT32 numnode)
@@ -1029,7 +975,6 @@ static boolean UDP_Socket(void)
mysockets[s] = ERRSOCKET;
for (s = 0; s < MAXNETNODES+1; s++)
nodesocket[s] = ERRSOCKET;
FD_ZERO(&masterset);
s = 0;
memset(&hints, 0x00, sizeof (hints));
@@ -1056,7 +1001,6 @@ static boolean UDP_Socket(void)
mysockets[s] = UDP_Bind(runp->ai_family, runp->ai_addr, (socklen_t)runp->ai_addrlen);
if (mysockets[s] != (SOCKET_TYPE)ERRSOCKET)
{
FD_SET(mysockets[s], &masterset);
myfamily[s] = hints.ai_family;
s++;
}
@@ -1077,7 +1021,6 @@ static boolean UDP_Socket(void)
mysockets[s] = UDP_Bind(runp->ai_family, runp->ai_addr, (socklen_t)runp->ai_addrlen);
if (mysockets[s] != (SOCKET_TYPE)ERRSOCKET)
{
FD_SET(mysockets[s], &masterset);
myfamily[s] = hints.ai_family;
s++;
#ifdef HAVE_MINIUPNPC
@@ -1110,7 +1053,6 @@ static boolean UDP_Socket(void)
mysockets[s] = UDP_Bind(runp->ai_family, runp->ai_addr, (socklen_t)runp->ai_addrlen);
if (mysockets[s] != (SOCKET_TYPE)ERRSOCKET)
{
FD_SET(mysockets[s], &masterset);
myfamily[s] = hints.ai_family;
s++;
}
@@ -1131,7 +1073,6 @@ static boolean UDP_Socket(void)
mysockets[s] = UDP_Bind(runp->ai_family, runp->ai_addr, (socklen_t)runp->ai_addrlen);
if (mysockets[s] != (SOCKET_TYPE)ERRSOCKET)
{
FD_SET(mysockets[s], &masterset);
myfamily[s] = hints.ai_family;
s++;
}
@@ -1298,16 +1239,15 @@ boolean I_InitTcpDriver(void)
static void SOCK_CloseSocket(void)
{
size_t i;
for (i=0; i < MAXNETNODES+1; i++)
for (i = 0; i < mysocketses; i++)
{
if (mysockets[i] != (SOCKET_TYPE)ERRSOCKET
&& FD_ISSET(mysockets[i], &masterset))
{
FD_CLR(mysockets[i], &masterset);
if (mysockets[i] != (SOCKET_TYPE)ERRSOCKET)
close(mysockets[i]);
}
mysockets[i] = ERRSOCKET;
}
mysocketses = 0;
}
#endif
@@ -1417,9 +1357,7 @@ static void rendezvous(int size)
if (tic == refreshtic)
{
#ifdef HOLEPUNCH
holepunchpacket->magic = hole_punch_magic;
#endif
sendto(mysockets[0], doomcom->data, size, 0, &rzv.any, sizeof rzv.ip4);
}
@@ -1444,7 +1382,6 @@ static void SOCK_RegisterHolePunch(void)
rendezvous(4);
}
#endif
#endif
static boolean SOCK_OpenSocket(void)
@@ -1464,13 +1401,7 @@ static boolean SOCK_OpenSocket(void)
I_NetFreeNodenum = SOCK_FreeNodenum;
I_NetMakeNodewPort = SOCK_NetMakeNodewPort;
#ifdef SELECTTEST
// seem like not work with libsocket : (
I_NetCanSend = SOCK_CanSend;
I_NetCanGet = SOCK_CanGet;
#endif
#ifdef HOLEPUNCH
I_NetRequestHolePunch = SOCK_RequestHolePunch;
I_NetRegisterHolePunch = SOCK_RegisterHolePunch;
#endif
+2 -3
View File
@@ -139,10 +139,9 @@ UINT32 I_GetRefreshRate(void);
boolean I_UseNativeKeyboard(void);
boolean I_CheckNativeRes(void);
#ifdef USE_FBO_OGL
#if defined (__unix__)
extern boolean xwaylandcrap;
#endif
void RefreshOGLSDLSurface(void);
void I_DownSample(void);
-1
View File
@@ -21,7 +21,6 @@
#include "d_player.h"
#include "lzf.h"
// Hey, moron! If you change this table, don't forget about the sprite enum in info.h and the sprite lights in hw_light.c!
char sprnames[NUMSPRITES + 1][5] =
{
"NULL","UNKN","THOK","PLAY","POSS","SPOS","FISH","BUZZ","RBUZ","JETB",
-4
View File
@@ -159,9 +159,6 @@ enum actionnum
A_SPAWNOBJECTRELATIVE,
A_CHANGEANGLERELATIVE,
A_CHANGEANGLEABSOLUTE,
A_ROLLANGLE,
A_CHANGEROLLANGLERELATIVE,
A_CHANGEROLLANGLEABSOLUTE,
A_PLAYSOUND,
A_FINDTARGET,
A_FINDTRACER,
@@ -460,7 +457,6 @@ extern boolean actionsoverridden[NUMACTIONS];
#define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS
#define NUMSTATEFREESLOTS (NUMMOBJFREESLOTS*8)
// Hey, moron! If you change this table, don't forget about sprnames in info.c and the sprite lights in hw_light.c!
typedef enum sprite
{
SPR_NULL, // invisible object
+97 -85
View File
@@ -12,6 +12,7 @@
//#include "k_kart.h"
#include "doomdef.h"
#include "doomstat.h"
#include "g_game.h"
#include "v_video.h"
#include "k_director.h"
@@ -19,6 +20,8 @@
#include "p_local.h"
#include "st_stuff.h"
#include "r_fps.h"
#define SWITCHTIME TICRATE * 5 // cooldown between unforced switches
#define BOREDOMTIME 3 * TICRATE / 2 // how long until players considered far apart?
#define TRANSFERTIME TICRATE // how long to delay reaction shots?
@@ -28,6 +31,8 @@
struct directorinfo
{
UINT8 viewnum;
player_t* viewplayer;
tic_t cooldown; // how long has it been since we last switched?
tic_t freeze; // when nonzero, fixed switch pending, freeze logic!
INT32 attacker; // who to switch to when freeze delay elapses
@@ -38,6 +43,8 @@ struct directorinfo
INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers?
} directorinfo;
struct directorinfo directorinfosplit[MAXSPLITSCREENPLAYERS];
boolean K_DirectorIsPlayerAlone(void)
{
UINT8 pingame = 0;
@@ -67,25 +74,38 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale)
return FixedMul(n, FixedDiv(scale, mapobjectscale));
}
static boolean K_DirectorIsEnabled(void)
boolean K_DirectorIsAvailable(UINT8 viewnum)
{
return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !demo.freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone());
if ((demo.playback && demo.title) || modeattacking)
return false;
return ((gamestate == GS_LEVEL) && (viewnum <= splitscreen) && (demo.playback || (players[g_localplayers[viewnum]].spectator && !K_DirectorIsPlayerAlone())));
}
static boolean K_DirectorIsEnabled(const UINT8 viewnum)
{
return (cv_director[viewnum].value && K_DirectorIsAvailable(viewnum));
}
void K_InitDirector(void)
{
INT32 playernum;
directorinfo.cooldown = SWITCHTIME;
directorinfo.freeze = 0;
directorinfo.attacker = 0;
directorinfo.maxdist = 0;
directorinfo.viewnum = 0;
for (playernum = 0; playernum < MAXPLAYERS; playernum++)
for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
directorinfo.sortedplayers[playernum] = -1;
directorinfo.gap[playernum] = INT32_MAX;
directorinfo.boredom[playernum] = 0;
directorinfosplit[i].cooldown = SWITCHTIME;
directorinfosplit[i].freeze = 0;
directorinfosplit[i].attacker = 0;
directorinfosplit[i].maxdist = 0;
directorinfosplit[i].viewplayer = NULL;
for (playernum = 0; playernum < MAXPLAYERS; playernum++)
{
directorinfosplit[i].sortedplayers[playernum] = -1;
directorinfosplit[i].gap[playernum] = INT32_MAX;
directorinfosplit[i].boredom[playernum] = 0;
}
}
}
@@ -104,8 +124,8 @@ static fixed_t K_GetDistanceToFinish(player_t player)
continue;
dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x,
mo->y - player.mo->y),
mo->z - player.mo->z) / FRACUNIT;
mo->y - player.mo->y),
mo->z - player.mo->z) / FRACUNIT;
break;
}
@@ -124,7 +144,7 @@ static fixed_t K_GetDistanceToFinish(player_t player)
dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x,
mo->y - player.mo->y),
mo->z - player.mo->z) / FRACUNIT;
mo->z - player.mo->z) / FRACUNIT;
break;
}
@@ -148,13 +168,13 @@ static fixed_t K_GetFinishGap(INT32 leader, INT32 follower)
}
}
static void K_UpdateDirectorPositions(void)
static void K_UpdateDirectorPositions(const UINT8 viewnum)
{
INT32 playernum;
INT32 position;
player_t* target;
memset(directorinfo.sortedplayers, -1, sizeof(directorinfo.sortedplayers));
memset(directorinfosplit[viewnum].sortedplayers, -1, sizeof(directorinfo.sortedplayers));
for (playernum = 0; playernum < MAXPLAYERS; playernum++)
{
@@ -162,43 +182,43 @@ static void K_UpdateDirectorPositions(void)
if (playeringame[playernum] && !target->spectator && target->kartstuff[k_position] > 0)
{
directorinfo.sortedplayers[target->kartstuff[k_position] - 1] = playernum;
directorinfosplit[viewnum].sortedplayers[target->kartstuff[k_position] - 1] = playernum;
}
}
for (position = 0; position < MAXPLAYERS - 1; position++)
{
directorinfo.gap[position] = INT32_MAX;
directorinfosplit[viewnum].gap[position] = INT32_MAX;
if (directorinfo.sortedplayers[position] == -1 || directorinfo.sortedplayers[position + 1] == -1)
if (directorinfosplit[viewnum].sortedplayers[position] == -1 || directorinfosplit[viewnum].sortedplayers[position + 1] == -1)
{
continue;
}
directorinfo.gap[position] = ScaleFromMap(K_GetFinishGap(directorinfo.sortedplayers[position], directorinfo.sortedplayers[position + 1]), FRACUNIT);
directorinfosplit[viewnum].gap[position] = ScaleFromMap(K_GetFinishGap(directorinfosplit[viewnum].sortedplayers[position], directorinfosplit[viewnum].sortedplayers[position + 1]), FRACUNIT);
if (directorinfo.gap[position] >= BREAKAWAYDIST)
if (directorinfosplit[viewnum].gap[position] >= BREAKAWAYDIST)
{
directorinfo.boredom[position] = (INT32)(min(BOREDOMTIME * 2, directorinfo.boredom[position] + 1));
directorinfosplit[viewnum].boredom[position] = (INT32)(min(BOREDOMTIME * 2, directorinfosplit[viewnum].boredom[position] + 1));
}
else if (directorinfo.boredom[position] > 0)
else if (directorinfosplit[viewnum].boredom[position] > 0)
{
directorinfo.boredom[position]--;
directorinfosplit[viewnum].boredom[position]--;
}
}
if (directorinfo.sortedplayers[0] == -1)
if (directorinfosplit[viewnum].sortedplayers[0] == -1)
{
directorinfo.maxdist = -1;
directorinfosplit[viewnum].maxdist = -1;
return;
}
directorinfo.maxdist = ScaleFromMap(K_GetDistanceToFinish(players[directorinfo.sortedplayers[0]]), FRACUNIT);
directorinfosplit[viewnum].maxdist = ScaleFromMap(K_GetDistanceToFinish(players[directorinfosplit[viewnum].sortedplayers[0]]), FRACUNIT);
}
static boolean K_CanSwitchDirector(void)
static boolean K_CanSwitchDirector(const UINT8 viewnum)
{
if (directorinfo.cooldown > 0)
if (directorinfosplit[viewnum].cooldown > 0)
{
return false;
}
@@ -206,14 +226,9 @@ static boolean K_CanSwitchDirector(void)
return true;
}
static void K_DirectorSwitch(INT32 player, boolean force)
static void K_DirectorSwitch(INT32 player, boolean force, const UINT8 viewnum)
{
if (!K_DirectorIsEnabled())
{
return;
}
if (P_IsDisplayPlayer(&players[player]))
if (!K_DirectorIsEnabled(viewnum))
{
return;
}
@@ -223,45 +238,45 @@ static void K_DirectorSwitch(INT32 player, boolean force)
return;
}
if (!force && !K_CanSwitchDirector())
if (!force && !K_CanSwitchDirector(viewnum))
{
return;
}
G_ResetView(1, player, true);
directorinfo.cooldown = SWITCHTIME;
G_ResetView(viewnum+1, player, true);
directorinfosplit[viewnum].cooldown = SWITCHTIME;
}
static void K_DirectorForceSwitch(INT32 player, INT32 time)
static void K_DirectorForceSwitch(INT32 player, INT32 time, const UINT8 viewnum)
{
if (players[player].exiting)
{
return;
}
directorinfo.attacker = player;
directorinfo.freeze = time;
directorinfosplit[viewnum].attacker = player;
directorinfosplit[viewnum].freeze = time;
}
void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source)
{
if (!K_DirectorIsEnabled())
if (!K_DirectorIsEnabled(directorinfo.viewnum))
{
return;
}
if (!P_IsDisplayPlayer(player))
if (directorinfosplit[directorinfo.viewnum].viewplayer != player)
{
return;
}
if (inflictor && inflictor->player)
{
K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME);
K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME, directorinfo.viewnum);
}
else if (source && source->player)
{
K_DirectorForceSwitch(source->player - players, TRANSFERTIME);
K_DirectorForceSwitch(source->player - players, TRANSFERTIME, directorinfo.viewnum);
}
}
@@ -281,14 +296,14 @@ void K_DrawDirectorDebugger(void)
V_DrawThinString(40, 0, V_70TRANS, va("CONF?"));
V_DrawThinString(80, 0, V_70TRANS, va("GAP"));
V_DrawThinString(120, 0, V_70TRANS, va("BORED"));
V_DrawThinString(150, 0, V_70TRANS, va("COOLDOWN: %d", directorinfo.cooldown));
V_DrawThinString(230, 0, V_70TRANS, va("MAXDIST: %d", directorinfo.maxdist));
V_DrawThinString(150, 0, V_70TRANS, va("COOLDOWN: %d", directorinfosplit[0].cooldown));
V_DrawThinString(230, 0, V_70TRANS, va("MAXDIST: %d", directorinfosplit[0].maxdist));
for (position = 0; position < MAXPLAYERS - 1; position++)
{
ytxt = 10 * (position + 1);
leader = directorinfo.sortedplayers[position];
follower = directorinfo.sortedplayers[position + 1];
leader = directorinfosplit[0].sortedplayers[position];
follower = directorinfosplit[0].sortedplayers[position + 1];
if (leader == -1 || follower == -1)
break;
@@ -301,15 +316,15 @@ void K_DrawDirectorDebugger(void)
V_DrawThinString(40, ytxt, V_70TRANS, va("NG"));
}
V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfo.gap[position]));
V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfosplit[0].gap[position]));
if (directorinfo.boredom[position] >= BOREDOMTIME)
if (directorinfosplit[0].boredom[position] >= BOREDOMTIME)
{
V_DrawThinString(120, ytxt, V_70TRANS, va("BORED"));
}
else
{
V_DrawThinString(120, ytxt, V_70TRANS, va("%d", directorinfo.boredom[position]));
V_DrawThinString(120, ytxt, V_70TRANS, va("%d", directorinfosplit[0].boredom[position]));
}
V_DrawThinString(150, ytxt, V_70TRANS, va("%s", player_names[leader]));
@@ -317,37 +332,38 @@ void K_DrawDirectorDebugger(void)
}
}
void K_UpdateDirector(void)
void K_UpdateDirector(const UINT8 viewnum)
{
INT32 *displayplayerp = &displayplayers[0];
INT32 targetposition;
directorinfo.viewnum = viewnum;
directorinfosplit[directorinfo.viewnum].viewplayer = &players[displayplayers[directorinfo.viewnum]];
if (!K_DirectorIsEnabled())
if (!K_DirectorIsEnabled(directorinfo.viewnum))
{
return;
}
K_UpdateDirectorPositions();
K_UpdateDirectorPositions(directorinfo.viewnum);
if (directorinfo.cooldown > 0) {
directorinfo.cooldown--;
if (directorinfosplit[directorinfo.viewnum].cooldown > 0) {
directorinfosplit[directorinfo.viewnum].cooldown--;
}
// handle pending forced switches
if (directorinfo.freeze > 0)
if (directorinfosplit[directorinfo.viewnum].freeze > 0)
{
if (!(--directorinfo.freeze))
K_DirectorSwitch(directorinfo.attacker, true);
if (!(--directorinfosplit[directorinfo.viewnum].freeze))
K_DirectorSwitch(directorinfosplit[directorinfo.viewnum].attacker, true, directorinfo.viewnum);
return;
}
// if there's only one player left in the list, just switch to that player
if (directorinfo.sortedplayers[0] != -1 && (directorinfo.sortedplayers[1] == -1 ||
if (directorinfosplit[directorinfo.viewnum].sortedplayers[0] != -1 && (directorinfosplit[directorinfo.viewnum].sortedplayers[1] == -1 ||
// TODO: Battle; I just threw this together quick. Focus on leader.
!race_rules()))
{
K_DirectorSwitch(directorinfo.sortedplayers[0], false);
K_DirectorSwitch(directorinfosplit[directorinfo.viewnum].sortedplayers[0], false, directorinfo.viewnum);
return;
}
@@ -359,76 +375,72 @@ void K_UpdateDirector(void)
INT32 target;
// you are out of players, try again
if (directorinfo.sortedplayers[targetposition] == -1)
if (directorinfosplit[directorinfo.viewnum].sortedplayers[targetposition] == -1)
{
break;
}
// pair too far apart? try the next one
if (directorinfo.boredom[targetposition - 1] >= BOREDOMTIME)
if (directorinfosplit[directorinfo.viewnum].boredom[targetposition - 1] >= BOREDOMTIME)
{
continue;
}
// pair finished? try the next one
if (players[directorinfo.sortedplayers[targetposition]].exiting)
if (players[directorinfosplit[directorinfo.viewnum].sortedplayers[targetposition]].exiting)
{
continue;
}
// don't risk switching away from forward pairs at race end, might miss something!
if (directorinfo.maxdist > PINCHDIST)
if (directorinfosplit[directorinfo.viewnum].maxdist > PINCHDIST)
{
// if the "next" player is close enough, they should be able to see everyone fine!
// walk back through the standings to find a vantage that gets everyone in frame.
// (also creates a pretty cool effect w/ overtakes at speed)
while (targetposition < MAXPLAYERS && directorinfo.gap[targetposition] < WALKBACKDIST)
while (targetposition < MAXPLAYERS && directorinfosplit[directorinfo.viewnum].gap[targetposition] < WALKBACKDIST)
{
targetposition++;
}
}
target = directorinfo.sortedplayers[targetposition];
target = directorinfosplit[directorinfo.viewnum].sortedplayers[targetposition];
// stop here since we're already viewing this player
if (*displayplayerp == target)
if (displayplayers[directorinfo.viewnum] == target)
{
break;
}
// if this is a splitscreen player, try next pair
if (P_IsDisplayPlayer(&players[target]))
{
continue;
}
// if we're certain the back half of the pair is actually in this position, try to switch
if (!players[target].kartstuff[k_positiondelay])
{
K_DirectorSwitch(target, false);
K_DirectorSwitch(target, false, directorinfo.viewnum);
}
// even if we're not certain, if we're certain we're watching the WRONG player, try to switch
if (players[*displayplayerp].kartstuff[k_position] != targetposition+1 && !players[*displayplayerp].kartstuff[k_positiondelay])
// even if we're not certain, if we're cetain we're watching the WRONG player, try to switch
if (directorinfosplit[directorinfo.viewnum].viewplayer->kartstuff[k_position] != targetposition+1 && !directorinfosplit[directorinfo.viewnum].viewplayer->kartstuff[k_positiondelay])
{
K_DirectorSwitch(target, false);
K_DirectorSwitch(target, false, directorinfo.viewnum);
}
break;
}
}
void K_ToggleDirector(void)
void K_ToggleDirector(const UINT8 viewnum)
{
if (!directortextactive)
if (!K_DirectorIsAvailable(viewnum))
return;
if (!K_DirectorIsEnabled())
G_AdjustView(viewnum+1, 1, true);
if (!K_DirectorIsEnabled(viewnum))
{
directorinfo.cooldown = 0; // switch immediately
directorinfosplit[viewnum].cooldown = 0; // switch immediately
}
directortoggletimer = 0;
COM_ImmedExecute("add director 1");
CV_SetValue(&cv_director[viewnum], (cv_director[viewnum].value ^ 1));
}
+3 -2
View File
@@ -10,8 +10,9 @@
/// \file k_director.h
/// \brief SRB2kart automatic spectator camera.
boolean K_DirectorIsAvailable(UINT8 viewnum);
void K_InitDirector(void);
void K_UpdateDirector(void);
void K_UpdateDirector(UINT8 viewnum);
void K_DrawDirectorDebugger(void);
void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source);
void K_ToggleDirector(void);
void K_ToggleDirector(UINT8 viewnum);
+177 -208
View File
@@ -497,10 +497,9 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = {
*/
void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor)
{
INT32 i;
INT32 i, j;
RGBA_t color;
UINT8 brightness;
INT32 j;
UINT8 colorbrightnesses[16];
UINT16 brightdif;
INT32 temp;
@@ -523,6 +522,7 @@ void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor)
color = V_GetColor(i);
SETBRIGHTNESS(brightness, color.s.red, color.s.green, color.s.blue);
brightdif = 256;
for (j = 0; j < 16; j++)
{
temp = abs((INT16)brightness - (INT16)colorbrightnesses[j]);
@@ -1233,7 +1233,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
dontforcespb = true;
// This makes the roulette produce the random noises.
if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player) && !demo.freecam)
if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player))
{
#define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8))
for (i = 0; i <= splitscreen; i++)
@@ -1267,7 +1267,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
//player->kartstuff[k_itemblinkmode] = 1;
player->kartstuff[k_itemroulette] = 0;
player->kartstuff[k_roulettetype] = 0;
if (P_IsDisplayPlayer(player) && !demo.freecam)
if (P_IsDisplayPlayer(player))
S_StartSound(NULL, sfx_itrole);
return;
}
@@ -1280,7 +1280,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
player->kartstuff[k_itemblinkmode] = 2;
player->kartstuff[k_itemroulette] = 0;
player->kartstuff[k_roulettetype] = 0;
if (P_IsDisplayPlayer(player) && !demo.freecam)
if (P_IsDisplayPlayer(player))
S_StartSound(NULL, sfx_dbgsal);
return;
}
@@ -1312,7 +1312,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
player->kartstuff[k_itemamount] = 1;
}
if (P_IsDisplayPlayer(player) && !demo.freecam)
if (P_IsDisplayPlayer(player))
S_StartSound(NULL, ((player->kartstuff[k_roulettetype] == 1) ? sfx_itrolk : (mashed ? sfx_itrolm : sfx_itrolf)));
player->kartstuff[k_itemblink] = TICRATE;
@@ -2060,6 +2060,38 @@ void K_MomentumToFacing(player_t *player)
player->mo->momy = FixedMul(player->mo->momy - player->cmomy, player->mo->friction) + player->cmomy;
}
static inline fixed_t K_GetProjectileSpeed(void)
{
switch (gamespeed)
{
case 0:
return 68*mapobjectscale; // Avg Speed is 34
break;
case 2:
return 96*mapobjectscale; // Avg Speed is 48
break;
default:
return 82*mapobjectscale; // Avg Speed is 41
break;
}
}
static inline fixed_t K_GetSneakerBoostSpeed(void)
{
switch (gamespeed)
{
case 0:
return 53740+768;
break;
case 2:
return 17294+768;
break;
default:
return 32768;
break;
}
}
// sets k_boostpower, k_speedboost, and k_accelboost to whatever we need it to be
static void K_GetKartBoostPower(player_t *player)
{
@@ -2093,18 +2125,7 @@ static void K_GetKartBoostPower(player_t *player)
if (player->kartstuff[k_sneakertimer]) // Sneaker
{
switch (gamespeed)
{
case 0:
speedboost = max(speedboost, 53740+768);
break;
case 2:
speedboost = max(speedboost, 17294+768);
break;
default:
speedboost = max(speedboost, 32768);
break;
}
speedboost = max(speedboost, K_GetSneakerBoostSpeed());
accelboost = max(accelboost, 8*FRACUNIT); // + 800%
}
@@ -2312,7 +2333,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto
UINT8 scoremultiply = 1;
// PS: Inflictor is unused for all purposes here and is actually only ever relevant to Lua. It may be nil too.
boolean force = false; // Used to check if Lua ShouldSpin should get us damaged reguardless of flashtics or heck knows what.
UINT8 shouldForce = LUAh_ShouldSpin(player, inflictor, source);
UINT8 shouldForce = LUA_HookShouldSpin(player, inflictor, source);
if (P_MobjWasRemoved(player->mo))
return; // mobj was removed (in theory that shouldn't happen)
@@ -2345,7 +2366,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto
}
}
if (LUAh_PlayerSpin(player, inflictor, source)) // Let Lua do its thing or overwrite if it wants to. Make sure to let any possible instashield happen because we didn't get "damaged" in this case.
if (LUA_HookPlayerSpin(player, inflictor, source)) // Let Lua do its thing or overwrite if it wants to. Make sure to let any possible instashield happen because we didn't get "damaged" in this case.
return;
if (source && source != player->mo && source->player)
@@ -2453,7 +2474,7 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor)
UINT8 scoremultiply = 1;
// PS: Inflictor is unused for all purposes here and is actually only ever relevant to Lua. It may be nil too.
boolean force = false; // Used to check if Lua ShouldSquish should get us damaged reguardless of flashtics or heck knows what.
UINT8 shouldForce = LUAh_ShouldSquish(player, inflictor, source);
UINT8 shouldForce = LUA_HookShouldSquish(player, inflictor, source);
if (P_MobjWasRemoved(player->mo))
return; // mobj was removed (in theory that shouldn't happen)
if (shouldForce == 1)
@@ -2483,7 +2504,7 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor)
}
}
if (LUAh_PlayerSquish(player, inflictor, source)) // Let Lua do its thing or overwrite if it wants to. Make sure to let any possible instashield happen because we didn't get "damaged" in this case.
if (LUA_HookPlayerSquish(player, inflictor, source)) // Let Lua do its thing or overwrite if it wants to. Make sure to let any possible instashield happen because we didn't get "damaged" in this case.
return;
player->kartstuff[k_sneakertimer] = 0;
@@ -2564,7 +2585,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b
fixed_t upgoer;
UINT8 scoremultiply = 1;
boolean force = false; // Used to check if Lua ShouldExplode should get us damaged reguardless of flashtics or heck knows what.
UINT8 shouldForce = LUAh_ShouldExplode(player, inflictor, source);
UINT8 shouldForce = LUA_HookShouldExplode(player, inflictor, source);
if (P_MobjWasRemoved(player->mo))
return; // mobj was removed (in theory that shouldn't happen)
@@ -2597,7 +2618,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b
}
}
if (LUAh_PlayerExplode(player, inflictor, source)) // Same thing. Also make sure to let Instashield happen blah blah
if (LUA_HookPlayerExplode(player, inflictor, source)) // Same thing. Also make sure to let Instashield happen blah blah
return;
if (source && source != player->mo && source->player)
@@ -3082,7 +3103,7 @@ static void K_SpawnDriftSparks(player_t *player)
//spark->momz = player->mo->momz/2;
// rotate the sparks based on pitch and roll; it just looks neat
if (cv_sparkroll.value == 1)
if (cv_sparkroll.value)
{
spark->slopepitch = player->mo->slopepitch;
spark->sloperoll = player->mo->sloperoll;
@@ -3296,20 +3317,22 @@ static void K_QuiteSaltyHop(player_t *p)
}
#define SLOPEROLL_DIV 3
void K_RollMobjBySlopes(mobj_t* mo, boolean usedistance)
{
if (P_MobjWasRemoved(mo))
return;
I_Assert(mo->subsector != NULL);
I_Assert(mo->subsector->sector != NULL);
angle_t an;
const boolean flip = mo->eflags & MFE_VERTICALFLIP;
const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0;
const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale;
// lifted from hw_md2
if (mo->standingslope)
{
angle_t an;
const boolean flip = (mo->eflags & MFE_VERTICALFLIP);
const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0;
const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale;
fixed_t tempz = mo->standingslope->normal.z;
fixed_t tempy = mo->standingslope->normal.y;
fixed_t tempx = mo->standingslope->normal.x;
@@ -3318,7 +3341,7 @@ void K_RollMobjBySlopes(mobj_t* mo, boolean usedistance)
// admittedly this is a very hacky way to do the pitch and roll easing
// pitch
if ((!usedistance) || (m_dist <= (rolldist)))
if (!usedistance || (m_dist <= (rolldist)))
{
an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV;
@@ -3401,7 +3424,7 @@ void K_SpawnBoostTrail(player_t *player)
flame->momx = 8;
// since you have to be on the ground for sneaker trails, this should be fine(?)
if (cv_sparkroll.value == 1)
if (cv_sparkroll.value)
{
flame->slopepitch = player->mo->slopepitch;
flame->sloperoll = player->mo->sloperoll;
@@ -3593,18 +3616,7 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map
}
else
{
switch (gamespeed)
{
case 0:
PROJSPEED = 68*mapobjectscale; // Avg Speed is 34
break;
case 2:
PROJSPEED = 96*mapobjectscale; // Avg Speed is 48
break;
default:
PROJSPEED = 82*mapobjectscale; // Avg Speed is 41
break;
}
PROJSPEED = K_GetProjectileSpeed();
}
if (altthrow)
@@ -3832,18 +3844,7 @@ void K_PuntMine(mobj_t *thismine, mobj_t *punter)
if (!mine || P_MobjWasRemoved(mine))
return;
switch (gamespeed)
{
case 0:
spd = 68*mapobjectscale; // Avg Speed is 34
break;
case 2:
spd = 96*mapobjectscale; // Avg Speed is 48
break;
default:
spd = 82*mapobjectscale; // Avg Speed is 41
break;
}
spd = K_GetProjectileSpeed();
mine->flags |= MF_NOCLIPTHING;
@@ -3990,20 +3991,7 @@ static void K_DoHyudoroSteal(player_t *player)
void K_DoSneaker(player_t *player, INT32 type)
{
fixed_t intendedboost;
switch (gamespeed)
{
case 0:
intendedboost = 53740+768;
break;
case 2:
intendedboost = 17294+768;
break;
default:
intendedboost = 32768;
break;
}
const fixed_t intendedboost = K_GetSneakerBoostSpeed();
if (!player->kartstuff[k_floorboost] || player->kartstuff[k_floorboost] == 3)
{
@@ -5350,7 +5338,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
// Plays the music during and after the starting countdown.
if (P_IsLocalPlayer(player))
S_StartMapMusic(false);
S_StartMapMusic();
}
void K_KartPlayerAfterThink(player_t *player)
@@ -5678,7 +5666,6 @@ static void K_KartDrift(player_t *player, boolean onground)
}
}
// Stop drifting
if (player->kartstuff[k_spinouttimer] > 0 || player->speed < minspeed)
{
@@ -5687,7 +5674,6 @@ static void K_KartDrift(player_t *player, boolean onground)
if (!player->sliproll)
{
player->sliptidemem = 0;
player->sliproll = 0;
}
@@ -5710,8 +5696,6 @@ static void K_KartDrift(player_t *player, boolean onground)
if (player->sliproll < (32*ANG1))
player->sliproll += (4*ANG1);
player->sliptidemem = player->kartstuff[k_aizdriftstrat];
}
if (player->kartstuff[k_drift]
@@ -6059,10 +6043,12 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
P_SetScale(overlay, player->mo->scale);
}
player->kartstuff[k_invincibilitytimer] = itemtime+(2*TICRATE); // 10 seconds
if (P_IsLocalPlayer(player) && cv_supermusic.value == 1 && cv_birdmusic.value)
S_ChangeMusicSpecial("kinvnc");
else
S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmi : sfx_kinvnc));
P_RestoreMusic(player);
K_PlayPowerGloatSound(player->mo);
player->kartstuff[k_itemamount]--;
@@ -6479,7 +6465,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
K_KartDrift(player, onground);
if ((!player->kartstuff[k_aizdriftstrat])||(!P_IsObjectOnGround(player->mo))||(player->kartstuff[k_drift]))
if ((!player->kartstuff[k_aizdriftstrat]) || (!P_IsObjectOnGround(player->mo)) || (player->kartstuff[k_drift]))
{
if (player->sliproll && (player->sliproll > 0))
player->sliproll -= (4*ANG1);
@@ -6493,10 +6479,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
player->mo->spriteyscale = player->mo->realyscale;
}
if (cv_spriteroll.value && cv_sloperoll.value)
if (cv_sloperoll.value && !player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky
{
if ((!player->mo->salty_jump)) // seeing a character rotate mid-hop looks really janky
K_RollMobjBySlopes(player->mo, (cv_sloperolldist.value && !splitscreen));
K_RollMobjBySlopes(player->mo, (cv_sloperolldist.value && !splitscreen));
}
else
{
@@ -6504,7 +6489,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
player->mo->slopepitch = FixedAngle(0);
}
// Quick Turning
// You can't turn your kart when you're not moving.
// So now it's time to burn some rubber!
@@ -7122,7 +7106,8 @@ void K_LoadKartHUDGraphics(void)
skp_speedpatchesachi[4] = W_CachePatchName("SP_APERC", PU_HUDGFX);
}
if (big_lap){
if (big_lap)
{
kp_lapstickerbig = W_CachePatchName("K_STLAPB", PU_HUDGFX);
kp_lapstickerbig2 = W_CachePatchName("K_STLA2B", PU_HUDGFX);
}
@@ -7187,14 +7172,14 @@ void K_LoadKartHUDGraphics(void)
// Nametags
if (nametaggfx)
{
nametagpic = W_CachePatchName("NTLINE", PU_HUDGFX);
nametagline = W_CachePatchName("NTLINEV", PU_HUDGFX);
nametagspeed = W_CachePatchName("NTSP", PU_HUDGFX);
nametagweight = W_CachePatchName("NTWH", PU_HUDGFX);
}
if (driftgaugegfx){
if (driftgaugegfx)
{
driftgauge = W_CachePatchName("K_DGAU", PU_HUDGFX);
driftgaugecolor = W_CachePatchName("K_DCAU", PU_HUDGFX);
driftgaugesmall = W_CachePatchName("K_DGSU", PU_HUDGFX);
@@ -7623,7 +7608,7 @@ static void K_initKartHUD(void)
// K_GetScreenCoords needs the right view* variables
R_SetViewContext(stplyrnum);
R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, !cv_uncappedhud.value);
R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, !cv_uncappedhud.value);
}
INT32 K_calcSplitFlags(INT32 snapflags)
@@ -7633,17 +7618,17 @@ INT32 K_calcSplitFlags(INT32 snapflags)
if (splitscreen == 0)
return snapflags;
if (stplyr != &players[displayplayers[0]])
if (stplyrnum != 0)
{
if (splitscreen == 1 && stplyr == &players[displayplayers[1]])
if (splitscreen == 1 && stplyrnum == 1)
{
splitflags |= V_SPLITSCREEN;
}
else if (splitscreen > 1)
{
if (stplyr == &players[displayplayers[2]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]]))
if (stplyrnum == 2 || (splitscreen == 3 && stplyrnum == 3))
splitflags |= V_SPLITSCREEN;
if (stplyr == &players[displayplayers[1]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]]))
if (stplyrnum == 1 || (splitscreen == 3 && stplyrnum == 3))
splitflags |= V_HORZSCREEN;
}
}
@@ -7763,7 +7748,7 @@ static void K_drawKartStats(void)
for (; splitnum < MAXSPLITSCREENPLAYERS; ++splitnum)
{
if (stplyr == &players[displayplayers[splitnum]])
if (stplyrnum == splitnum)
break;
}
@@ -8180,13 +8165,13 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
}
}
if (!K_UseColorHud())
V_DrawScaledPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwide : kp_timestickerwide));
else //Colourized hud
if (K_UseColorHud()) // Colourized hud
{
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE);
V_DrawMappedPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwideclr : kp_timestickerwideclr), colormap);
}
else
V_DrawScaledPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwide : kp_timestickerwide));
TX += 33;
@@ -8349,7 +8334,7 @@ static void K_DrawKartPositionNum(INT32 num)
else if (splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different.
{
fx = POSI_X;
if (stplyr == &players[displayplayers[0]]) // for player 1: display this at the top right, above the minimap.
if (stplyrnum == 0) // for player 1: display this at the top right, above the minimap.
{
fy = 30 + cv_posi_yoffset.value;
fflags = V_SNAPTOTOP|V_SNAPTORIGHT;
@@ -8364,11 +8349,11 @@ static void K_DrawKartPositionNum(INT32 num)
}
else
{
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3...
if (!(stplyrnum & 1)) // If we are P1 or P3...
{
fx = POSI_X;
fy = POSI_Y;
fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom.
fflags = V_SNAPTOLEFT|((stplyrnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom.
flipdraw = true;
if (num && num >= 10)
fx += W; // this seems dumb, but we need to do this in order for positions above 10 going off screen.
@@ -8377,7 +8362,7 @@ static void K_DrawKartPositionNum(INT32 num)
{
fx = POSI2_X;
fy = POSI2_Y;
fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom
fflags = V_SNAPTORIGHT|((stplyrnum == 3) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom
}
}
@@ -8689,12 +8674,9 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I
}
}
static boolean K_BigLapSticker(void)
static boolean K_BigLap(void)
{
if (K_UseColorHud())
return ((cv_numlaps.value > 9) && (big_lap_color) && (cv_biglaps.value) && (!stplyr->exiting));
else
return ((cv_numlaps.value > 9) && (big_lap) && (cv_biglaps.value) && (!stplyr->exiting));
return (cv_biglaps.value && (cv_numlaps.value > 9) && (K_UseColorHud() ? big_lap_color : big_lap) && (!stplyr->exiting));
}
static void K_drawKartLaps(void)
@@ -8733,20 +8715,16 @@ static void K_drawKartLaps(void)
}
else
{
if (!K_UseColorHud())
{
if (K_BigLapSticker())
V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig));
else
V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, kp_lapsticker);
}
else //Colourized hud
if (K_UseColorHud()) // Colourized hud
{
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE);
if (K_BigLapSticker())
V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr), colormap);
else
V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, kp_lapstickerclr, colormap);
patch_t *biglapclr = (K_BigLap() ? ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr) : kp_lapstickerclr);
V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, biglapclr, colormap);
}
else
{
patch_t *biglap = (K_BigLap() ? ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig) : kp_lapsticker);
V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, biglap);
}
if (stplyr->exiting)
@@ -8852,7 +8830,7 @@ static void K_drawKartSpeedometer(void)
{
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE);
V_DrawStretchyFixedPatch((SPDM_X-1)<<FRACBITS, (SPDM_Y + 5)<<FRACBITS, FRACUNIT*0.765, FRACUNIT*0.55, (V_HUDTRANS|splitflags), (skp_smallstickerclr3), colormap);
}
}
else
V_DrawStretchyFixedPatch((SPDM_X-1)<<FRACBITS, (SPDM_Y + 5)<<FRACBITS, FRACUNIT*0.765, FRACUNIT*0.55, (V_HUDTRANS|splitflags), (skp_smallsticker3), NULL);
@@ -8964,28 +8942,21 @@ static void K_drawKartBumpersOrKarma(void)
static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *target, fixed_t hofs, boolean dontclip)
{
fixed_t distfact;
fixed_t dist;
fixed_t xres;
fixed_t yres;
fixed_t fov;
fixed_t fovratio;
fixed_t offset;
boolean srcflip;
boolean targflip;
fixed_t y;
fixed_t x;
// this should never happen but its also kart so ¯\_(ツ)_/¯
if (!player || !target)
if (!player || P_MobjWasRemoved(target))
return false;
xres = vid.width<<(FRACBITS-1);
yres = vid.height<<(FRACBITS-1);
fov = FixedDiv(xres, FINETANGENT(((FixedAngle(cv_fov.value/2)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095));
const fixed_t xres = vid.width<<(FRACBITS-1);
const fixed_t yres = vid.height<<(FRACBITS-1);
const fixed_t fov = FixedDiv(xres, FINETANGENT(((FixedAngle(cv_fov.value/2)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095));
fixed_t targx = lerp(target->old_x, target->x);
fixed_t targy = lerp(target->old_y, target->y);
fixed_t targz = lerp(target->old_z, target->z);
const fixed_t targx = lerp(target->old_x, target->x);
const fixed_t targy = lerp(target->old_y, target->y);
const fixed_t targz = lerp(target->old_z, target->z);
// X coordinate
// get difference between camangle and angle towards target
@@ -9000,8 +8971,8 @@ static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *targe
return false;
// flipping
targflip = target->eflags & MFE_VERTICALFLIP;
srcflip = player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP;
const boolean targflip = target->eflags & MFE_VERTICALFLIP;
const boolean srcflip = player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP;
// Y coordinate
// getting the angle difference here is a bit more involved...
@@ -9011,7 +8982,7 @@ static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *targe
y = y - (targflip ? -hofs : hofs);
// then get the distance between camera and target
dist = R_PointToDist(targx, targy);
const fixed_t dist = R_PointToDist(targx, targy);
#ifdef HWRENDER
// NOW we can get the angle differnce
@@ -9033,7 +9004,7 @@ static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *targe
else
#endif
{
fovratio = FixedDiv(90*FRACUNIT, 180*FRACUNIT - FixedMul(cv_fov.value, 4*FRACUNIT/3)-FRACUNIT*-30);
const fixed_t fovratio = FixedDiv(90*FRACUNIT, 180*FRACUNIT - FixedMul(cv_fov.value, 4*FRACUNIT/3)-FRACUNIT*-30);
y = FixedDiv(y, FixedMul(dist, distfact));
if (srcflip)
@@ -9103,33 +9074,27 @@ static void K_drawNameTags(void)
fixed_t tagwidth;
fixed_t tagwidthsmall;
fixed_t namex,namey;
int dup = 0;
int tagcolor = 0;
int vflags = 0;
int flipped = 0;
int tagsdisplayed = 0;
char *tag;
patch_t *icon;
INT32 hudtransflag = V_LocalTransFlag();
boolean flipcam;
const INT32 hudtransflag = V_LocalTransFlag();
if (!stplyr->mo || (stplyr->spectator && !cv_shownametagspectator.value) || (stplyr->exiting && !cv_shownametagfinish.value))
if (P_MobjWasRemoved(stplyr->mo) || (stplyr->spectator && !cv_shownametagspectator.value) || (stplyr->exiting && !cv_shownametagfinish.value))
return;
// True if currently viewed player is flipped and has flipcam on
flipcam = (stplyr->pflags & PF_FLIPCAM) && (stplyr->mo->eflags & MFE_VERTICALFLIP);
const boolean flipcam = ((stplyr->pflags & PF_FLIPCAM) && (stplyr->mo->eflags & MFE_VERTICALFLIP));
for (i = 0; i < MAXPLAYERS; i++)
{
UINT8 *cm;
fixed_t distance = 0;
fixed_t maxdistance = (10*cv_nametagdist.value)* mapobjectscale;
flipped = 0;
const fixed_t maxdistance = ((10*cv_nametagdist.value)* mapobjectscale);
boolean flipped = 0;
fixed_t z;
if (i > PLAYERSMASK)
continue;
if (!players[i].mo || P_MobjWasRemoved(players[i].mo) || players[i].spectator || !playeringame[i])
if (P_MobjWasRemoved(players[i].mo) || players[i].spectator || !playeringame[i])
continue;
if (i == displayplayers[stplyrnum] && !cv_showownnametag.value && !(leveltime < 130))
continue;
@@ -9137,10 +9102,11 @@ static void K_drawNameTags(void)
continue;
if (players[i].kartstuff[k_hyudorotimer]) // player is invisible
continue;
distance = R_PointToDist(players[i].mo->x, players[i].mo->y);
if (maxdistance)
distance = R_PointToDist(players[i].mo->x, players[i].mo->y);
if (distance > maxdistance)
continue;
if (!P_CheckSight(stplyr->mo, players[i].mo))
if (!P_CheckSightFast(stplyr->mo, players[i].mo))
continue;
switch (cv_nametagtrans.value)
@@ -9178,7 +9144,7 @@ static void K_drawNameTags(void)
break;
}
dup = vid.dupx;
const INT32 dup = vid.dupx;
// If flipcam is on, other player is flipped relative to us when we have different
// verticalflip flag value. Otherwise, they are simply flipped when verticalflip flag says
@@ -9208,9 +9174,9 @@ static void K_drawNameTags(void)
tag = va("%s%s ", HU_SkinColorToConsoleColor(players[i].mo->color),player_names[i]);
icon = R_GetSkinFaceMini(players[i].mo->player);
cm = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE);
tagcolor = colortranslations[players[i].mo->color][7];
vflags = trans | V_NOSCALESTART;
const UINT8 *cm = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE);
const INT32 tagcolor = colortranslations[players[i].mo->color][7];
const INT32 vflags = trans | V_NOSCALESTART;
tagwidth = cv_smallnametags.value ? dup*V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : dup*V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE);
tagwidthsmall = cv_smallnametags.value ? V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE);
@@ -9323,13 +9289,10 @@ static void K_drawNameTags(void)
// Based on Driftgauge refactor by GenericHeroGuy ported from lua and expanded by NepDisk
static void K_drawDriftGauge(void)
{
INT32 driftval = K_GetKartDriftSparkValue(stplyr);
INT32 driftcharge = min(driftval*4, stplyr->kartstuff[k_driftcharge]);
vector2_t pos = {0};
fixed_t basex,basey;
INT32 drifttrans = 0;
INT32 hudtransflag = V_LocalTransFlag();
int dup = vid.dupx;
fixed_t basex, basey;
const INT32 hudtransflag = V_LocalTransFlag();
const int dup = vid.dupx;
int i;
UINT8 driftcolors[3][4] = {
@@ -9348,10 +9311,10 @@ static void K_drawDriftGauge(void)
0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247
};
if (demo.playback && demo.freecam)
if (camera[stplyrnum].freecam)
return;
if (!stplyr->mo || (!splitscreen && !camera->chase))
if (P_MobjWasRemoved(stplyr->mo) || (!splitscreen && !camera->chase))
return;
if (forceshowhud)
@@ -9365,6 +9328,9 @@ skipcrap:
if (!K_GetScreenCoords(&pos, stplyr, stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale), false))
return;
const INT32 driftval = K_GetKartDriftSparkValue(stplyr);
const INT32 driftcharge = min(driftval*4, stplyr->kartstuff[k_driftcharge]);
basex = pos.x>>FRACBITS;
basey = pos.y>>FRACBITS;
@@ -9372,19 +9338,21 @@ skipcrap:
fixed_t bary;
INT32 BAR_WIDTH;
if (cv_driftgaugetrans.value)
drifttrans = hudtransflag;
else
drifttrans = 0;
const INT32 drifttrans = ((cv_driftgaugetrans.value) ? hudtransflag : 0);
switch (cv_driftgaugestyle.value)
{
case 1:
case 2:
case 3:
if (driftgaugegfx)
case 5:
{
if (cv_driftgaugestyle.value == 1 || cv_driftgaugestyle.value == 3)
if (!driftgaugegfx)
break;
const boolean usescaledpatch = (cv_driftgaugestyle.value == 5 && xtra_speedo3);
if (cv_driftgaugestyle.value == 1 || cv_driftgaugestyle.value == 3 || usescaledpatch)
{
barx = basex - dup*23;
BAR_WIDTH = dup*47;
@@ -9397,17 +9365,31 @@ skipcrap:
bary = basey - dup*2;
INT32 limit = driftval * (driftcharge >= driftval*2 ? 2 : 1);
INT32 width = ((driftcharge - (driftcharge >= driftval ? limit : 0)) * BAR_WIDTH) / limit;
INT32 level = min(driftcharge / driftval, 2);
UINT8 *cmap;
const INT32 limit = driftval * (driftcharge >= driftval*2 ? 2 : 1);
const INT32 width = ((driftcharge - (driftcharge >= driftval ? limit : 0)) * BAR_WIDTH) / limit;
const INT32 level = min(driftcharge / driftval, 2);
if (!K_UseColorHud())
V_DrawMappedPatch(cv_driftgaugestyle.value == 2 ? basex + dup*11 : basex, basey, V_NOSCALESTART|V_OFFSET|drifttrans, cv_driftgaugestyle.value == 2 ? driftgaugesmall : driftgauge, NULL);
else //Colourized hud
if (usescaledpatch) // i hate hud code i hate hud code i hate hud code i hate hud code i hate hud code.....
{
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE);
V_DrawMappedPatch(cv_driftgaugestyle.value == 2 ? basex + dup*11 : basex, basey, V_NOSCALESTART|V_OFFSET|drifttrans, cv_driftgaugestyle.value == 2 ? driftgaugesmallcolor : driftgaugecolor, colormap);
if (K_UseColorHud() && xtra_speedo_clr3) // Colourized hud
{
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE);
V_DrawStretchyFixedPatch((basex - dup*30)<<FRACBITS, ((basey<<FRACBITS) - FixedMul(dup<<FRACBITS, 21*FRACUNIT/10)), FRACUNIT*0.765, FRACUNIT*0.55, V_NOSCALESTART|V_OFFSET|drifttrans, skp_smallstickerclr3, colormap);
}
else
V_DrawStretchyFixedPatch((basex - dup*30)<<FRACBITS, ((basey<<FRACBITS) - FixedMul(dup<<FRACBITS, 21*FRACUNIT/10)), FRACUNIT*0.765, FRACUNIT*0.55, V_NOSCALESTART|V_OFFSET|drifttrans, skp_smallsticker3, NULL);
}
else
{
if (K_UseColorHud()) // Colourized hud
{
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE);
V_DrawMappedPatch(cv_driftgaugestyle.value == 2 ? basex + dup*11 : basex, basey, V_NOSCALESTART|V_OFFSET|drifttrans, cv_driftgaugestyle.value == 2 ? driftgaugesmallcolor : driftgaugecolor, colormap);
}
else
V_DrawMappedPatch(cv_driftgaugestyle.value == 2 ? basex + dup*11 : basex, basey, V_NOSCALESTART|V_OFFSET|drifttrans, cv_driftgaugestyle.value == 2 ? driftgaugesmall : driftgauge, NULL);
}
if (driftcharge >= driftval*4) // rainbow sparks
@@ -9419,7 +9401,7 @@ skipcrap:
else // none/blue/red
{
cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[level],GTC_CACHE);
for (i = 0; i < 4; i++)
for (i = 0; i < 4; i++)
{
if (driftcharge >= driftval)
V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, driftcolors[level-1][i] | V_NOSCALESTART|drifttrans);
@@ -9439,7 +9421,7 @@ skipcrap:
case 4:
{
UINT8 *cmap;
INT32 level = min(driftcharge / driftval, 2);
const INT32 level = min(driftcharge / driftval, 2);
if (driftcharge >= driftval*4)
cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE);
else
@@ -9487,7 +9469,7 @@ static void K_drawKartWanted(void)
UINT8 *colormap = NULL;
INT32 basex = 0, basey = 0;
if (stplyr != &players[displayplayers[0]])
if (stplyrnum != 0)
return;
for (i = 0; i < 4; i++)
@@ -9684,7 +9666,7 @@ static void K_drawKartMinimap(void)
if (gamestate != GS_LEVEL)
return;
if (stplyr != &players[displayplayers[0]])
if (stplyrnum != 0)
return;
if (minimapinfo.minimap_pic == NULL)
@@ -9846,7 +9828,7 @@ static void K_drawKartFinish(void)
xval = (SHORT(kp_racefinish[pnum]->width)<<FRACBITS);
x = (FixedMul(((TICRATE - stplyr->kartstuff[k_cardanimation])<<FRACBITS) - R_GetHudUncap(), xval > x ? xval : x))/TICRATE;
if (splitscreen && stplyr == &players[displayplayers[1]])
if (splitscreen && stplyrnum == 1)
x = -x;
V_DrawFixedPatch(x + (STCD_X<<FRACBITS) - (xval>>1),
@@ -9959,13 +9941,14 @@ static void K_drawBattleFullscreen(void)
V_DrawString(x-txoff, ty, 0, va("%d", stplyr->kartstuff[k_comebacktimer]/TICRATE));
else
{
if (!K_UseColorHud())
V_DrawFixedPatch(x<<FRACBITS, ty<<FRACBITS, scale, 0, kp_timeoutsticker, NULL);
else //Colourized hud
if (K_UseColorHud()) // Colourized hud
{
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE);
V_DrawFixedPatch(x<<FRACBITS, ty<<FRACBITS, scale, 0, kp_timeoutstickerclr, colormap);
}
else
V_DrawFixedPatch(x<<FRACBITS, ty<<FRACBITS, scale, 0, kp_timeoutsticker, NULL);
V_DrawKartString(x-txoff, ty, 0, va("%d", stplyr->kartstuff[k_comebacktimer]/TICRATE));
}
@@ -10002,14 +9985,9 @@ static void K_drawKartFirstPerson(void)
if (stplyr->spectator || !stplyr->mo || (stplyr->mo->flags2 & MF2_DONTDRAW))
return;
if (stplyr == &players[displayplayers[1]] && splitscreen)
{ pn = pnum[1]; tn = turn[1]; dr = drift[1]; }
else if (stplyr == &players[displayplayers[2]] && splitscreen > 1)
{ pn = pnum[2]; tn = turn[2]; dr = drift[2]; }
else if (stplyr == &players[displayplayers[3]] && splitscreen > 2)
{ pn = pnum[3]; tn = turn[3]; dr = drift[3]; }
else
{ pn = pnum[0]; tn = turn[0]; dr = drift[0]; }
pn = pnum[stplyrnum];
tn = turn[stplyrnum];
dr = drift[stplyrnum];
if (splitscreen)
{
@@ -10131,14 +10109,9 @@ static void K_drawKartFirstPerson(void)
V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap);
if (stplyr == &players[displayplayers[1]] && splitscreen)
{ pnum[1] = pn; turn[1] = tn; drift[1] = dr; }
else if (stplyr == &players[displayplayers[2]] && splitscreen > 1)
{ pnum[2] = pn; turn[2] = tn; drift[2] = dr; }
else if (stplyr == &players[displayplayers[3]] && splitscreen > 2)
{ pnum[3] = pn; turn[3] = tn; drift[3] = dr; }
else
{ pnum[0] = pn; turn[0] = tn; drift[0] = dr; }
pnum[stplyrnum] = pn;
turn[stplyrnum] = tn;
drift[stplyrnum] = dr;
}
// doesn't need to ever support 4p
@@ -10358,7 +10331,7 @@ static void K_drawDistributionDebugger(void)
boolean dontforcespb = false;
boolean spbrush = false;
if (stplyr != &players[displayplayers[0]]) // only for p1
if (stplyrnum != 0) // only for p1
return;
// The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice
@@ -10422,7 +10395,7 @@ static void K_drawDistributionDebugger(void)
static void K_drawCheckpointDebugger(void)
{
if (stplyr != &players[displayplayers[0]]) // only for p1
if (stplyrnum != 0) // only for p1
return;
if (stplyr->starpostnum >= (numstarposts - (numstarposts/2)))
@@ -10436,22 +10409,18 @@ void K_drawKartHUD(void)
{
boolean isfreeplay = false;
boolean battlefullscreen = false;
boolean freecam = demo.freecam; //disable some hud elements w/ freecam
UINT8 i;
boolean freecam = camera[stplyrnum].freecam; //disable some hud elements w/ freecam
// Define the X and Y for each drawn object
// This is handled by console/menu values
K_initKartHUD();
// Draw that fun first person HUD! Drawn ASAP so it looks more "real".
for (i = 0; i <= splitscreen; i++)
{
if (stplyr == &players[displayplayers[i]] && !camera[i].chase && !freecam)
K_drawKartFirstPerson();
}
if (!camera[stplyrnum].chase && !freecam)
K_drawKartFirstPerson();
// Draw full screen stuff that turns off the rest of the HUD
if (mapreset && stplyr == &players[displayplayers[0]])
if (mapreset && stplyrnum == 0)
{
K_drawChallengerScreen();
return;
@@ -10544,7 +10513,7 @@ void K_drawKartHUD(void)
}
}
if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode
if (!stplyr->spectator && !freecam) // Bottom of the screen elements, don't need in spectate mode
{
if (!(splitscreen || demo.title))
{
+15 -3
View File
@@ -1109,6 +1109,18 @@ static int lib_pCheckSight(lua_State *L)
return 1;
}
// DONT USE THIS FOR ANYTHING GAMEPLAY, THIS WILL DESYNCH!
static int lib_pCheckSightFast(lua_State *L)
{
mobj_t *t1 = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *t2 = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
//HUDSAFE?
if (!t1 || !t2)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_CheckSightFast(t1, t2));
return 1;
}
static int lib_pCheckHoopPosition(lua_State *L)
{
mobj_t *hoopthing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@@ -1817,7 +1829,7 @@ static int lib_sStartSoundAtVolume(lua_State *L)
return LUA_ErrInvalid(L, "player_t");
}
if (!player || P_IsLocalPlayer(player))
S_StartSoundAtVolume(origin, sound_id, volume);
S_StartSoundAtVolume(origin, sound_id, volume);
return 0;
}
@@ -1919,7 +1931,7 @@ static int lib_sChangeMusic(lua_State *L)
music_flags = (UINT16)((music_num & 0x7FFF0000) >> 16);
else
#endif
music_flags = (UINT16)luaL_optinteger(L, 4, 0);
music_flags = (UINT16)luaL_optinteger(L, 4, 0);
position = (UINT32)luaL_optinteger(L, 5, 0);
prefadems = (UINT32)luaL_optinteger(L, 6, 0);
@@ -3154,7 +3166,6 @@ static luaL_Reg lib[] = {
{"P_LookForEnemies",lib_pLookForEnemies},
{"P_NukeEnemies",lib_pNukeEnemies},
{"P_HomingAttack",lib_pHomingAttack},
//{"P_SuperReady",lib_pSuperReady},
{"P_Telekinesis",lib_pTelekinesis},
// p_map
@@ -3167,6 +3178,7 @@ static luaL_Reg lib[] = {
{"P_SlideMove",lib_pSlideMove},
{"P_BounceMove",lib_pBounceMove},
{"P_CheckSight", lib_pCheckSight},
{"P_CheckSightFast", lib_pCheckSightFast},
{"P_CheckHoopPosition",lib_pCheckHoopPosition},
{"P_RadiusAttack",lib_pRadiusAttack},
{"P_FloorzAtPos",lib_pFloorzAtPos},
+1 -1
View File
@@ -169,7 +169,7 @@ void COM_Lua_f(void)
for (i = 0; i < argc; i++)
WRITESTRINGN(p, COM_Argv(i), 255);
if (flags & 2)
SendNetXCmd2(XD_LUACMD, buf, p-buf);
SendNetXCmdForPlayer(1, XD_LUACMD, buf, p-buf);
else
SendNetXCmd(XD_LUACMD, buf, p-buf);
free(buf);
+116 -92
View File
@@ -12,105 +12,129 @@
#include "r_defs.h"
#include "d_player.h"
#include "s_sound.h"
#include "lua_hudlib_drawlist.h"
enum hook {
hook_NetVars=0,
hook_MapChange,
hook_MapLoad,
hook_PlayerJoin,
hook_PreThinkFrame,
hook_ThinkFrame,
hook_PostThinkFrame,
hook_MobjSpawn,
hook_MobjCollide,
hook_MobjMoveCollide,
hook_TouchSpecial,
hook_MobjFuse,
hook_MobjThinker,
hook_BossThinker,
hook_ShouldDamage,
hook_MobjDamage,
hook_MobjDeath,
hook_BossDeath,
hook_MobjRemoved,
hook_JumpSpecial,
hook_AbilitySpecial,
hook_SpinSpecial,
hook_JumpSpinSpecial,
hook_BotTiccmd,
hook_BotAI,
hook_LinedefExecute,
hook_PlayerMsg,
hook_HurtMsg,
hook_PlayerSpawn,
hook_PlayerQuit,
hook_PlayerThink,
hook_MusicChange,
hook_ShouldSpin, //SRB2KART
hook_ShouldExplode, //SRB2KART
hook_ShouldSquish, //SRB2KART
hook_PlayerSpin, //SRB2KART
hook_PlayerExplode, //SRB2KART
hook_PlayerSquish, //SRB2KART
hook_PlayerCmd, //SRB2KART
hook_IntermissionThinker, //SRB2KART
hook_VoteThinker, //SRB2KART
hook_ServerJoin, // SRB2KART - Saturn 32p
/*
* Do you know what an 'X Macro' is? Such a macro is called over each element of
* a list and expands the input. I use it for the hook lists because both an enum
* and array of hook names need to be kept in order. The X Macro handles this
* automatically.
*/
hook_MAX // last hook
};
extern const char *const hookNames[];
#define MOBJ_HOOK_LIST(X) \
X (MobjSpawn),/* P_SpawnMobj */\
X (MobjCollide),/* PIT_CheckThing */\
X (MobjMoveCollide),/* tritto */\
X (TouchSpecial),/* P_TouchSpecialThing */\
X (MobjFuse),/* when mobj->fuse runs out */\
X (MobjThinker),/* P_MobjThinker, P_SceneryThinker */\
X (BossThinker),/* P_GenericBossThinker */\
X (ShouldDamage),/* P_DamageMobj (Should mobj take damage?) */\
X (MobjDamage),/* P_DamageMobj (Mobj actually takes damage!) */\
X (MobjDeath),/* P_KillMobj */\
X (BossDeath),/* A_BossDeath */\
X (MobjRemoved),/* P_RemoveMobj */\
X (HurtMsg),/* imhurttin */\
#define HOOK_LIST(X) \
X (NetVars),/* add to archive table (netsave) */\
X (MapChange),/* (before map load) */\
X (MapLoad),\
X (PlayerJoin),/* Got_AddPlayer */\
X (PreThinkFrame)/* frame (before mobj and player thinkers) */,\
X (ThinkFrame),/* frame (after mobj and player thinkers) */\
X (PostThinkFrame),/* frame (at end of tick, ie after overlays, precipitation, specials) */\
X (JumpSpecial),/* P_DoJumpStuff (Any-jumping) */\
X (AbilitySpecial),/* P_DoJumpStuff (Double-jumping) */\
X (SpinSpecial),/* P_DoSpinAbility (Spin button effect) */\
X (JumpSpinSpecial),/* P_DoJumpStuff (Spin button effect (mid-air)) */\
X (BotTiccmd),/* B_BuildTiccmd */\
X (PlayerMsg),/* chat messages */\
X (PlayerSpawn),/* G_SpawnPlayer */\
X (PlayerQuit),\
X (PlayerThink),/* P_PlayerThink */\
X (MusicChange),\
X (ShouldSpin),/*SRB2KART*/\
X (ShouldExplode),/*SRB2KART*/\
X (ShouldSquish),/*SRB2KART*/\
X (PlayerSpin),/*SRB2KART*/\
X (PlayerExplode),/*SRB2KART*/\
X (PlayerSquish),/*SRB2KART*/\
X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\
X (IntermissionThinker),/* Y_Ticker */\
X (VoteThinker),/*SRB2KART*/\
X (ServerJoin),/* SRB2KART - Saturn 32p*/\
#define STRING_HOOK_LIST(X) \
X (BotAI),/* B_BuildTailsTiccmd by skin name */\
X (LinedefExecute),\
#define HUD_HOOK_LIST(X) \
X (game),\
X (scores),/* emblems/multiplayer list */\
X (intermission),\
X (vote),\
/*
* I chose to access the hook enums through a macro as well. This could provide
* a hint to lookup the macro's definition instead of the enum's definition.
* (Since each enumeration is not defined in the source code, but by the list
* macros above, it is not greppable.) The name passed to the macro can also be
* grepped and found in the lists above.
*/
#define MOBJ_HOOK(name) mobjhook_ ## name
#define HOOK(name) hook_ ## name
#define HUD_HOOK(name) hudhook_ ## name
#define STRING_HOOK(name) stringhook_ ## name
#define ENUM(X) enum { X ## _LIST (X) X(MAX) }
ENUM (MOBJ_HOOK);
ENUM (HOOK);
ENUM (HUD_HOOK);
ENUM (STRING_HOOK);
#undef ENUM
/* dead simple, LUA_HOOK(GameQuit) */
#define LUA_HOOK(type) LUA_HookVoid(HOOK(type))
#define LUA_HUDHOOK(type,drawlist) LUA_HookHUD(HUD_HOOK(type),(drawlist))
extern boolean hook_cmd_running; // This is used by PlayerCmd and lua_playerlib to prevent anything from being wirtten to player while we run PlayerCmd.
extern int hook_defrosting;
void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load)
void LUAh_MapLoad(void); // Hook for map load
void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer
void LUAh_PreThinkFrame(void); // Hook for frame (before mobj and player thinkers)
void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers)
void LUAh_PostThinkFrame(void); // Hook for frame (at end of tick, ie after overlays, precipitation, specials)
boolean LUAh_MobjHook(mobj_t *mo, enum hook which);
boolean LUAh_PlayerHook(player_t *plr, enum hook which);
#define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type
UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which);
#define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type
#define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type
boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type
#define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type
boolean LUAh_MobjThinker(mobj_t *mo); // Hook for P_MobjThinker or P_SceneryThinker by mobj type
#define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type
UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Should mobj take damage?)
boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!)
boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source); // Hook for P_KillMobj by mobj type
#define LUAh_BossDeath(mo) LUAh_MobjHook(mo, hook_BossDeath) // Hook for A_BossDeath by mobj type
#define LUAh_MobjRemoved(mo) LUAh_MobjHook(mo, hook_MobjRemoved) // Hook for P_RemoveMobj by mobj type
#define LUAh_JumpSpecial(player) LUAh_PlayerHook(player, hook_JumpSpecial) // Hook for P_DoJumpStuff (Any-jumping)
#define LUAh_AbilitySpecial(player) LUAh_PlayerHook(player, hook_AbilitySpecial) // Hook for P_DoJumpStuff (Double-jumping)
#define LUAh_SpinSpecial(player) LUAh_PlayerHook(player, hook_SpinSpecial) // Hook for P_DoSpinDash (Spin button effect)
#define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air))
boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd); // Hook for B_BuildTiccmd
boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_BuildTailsTiccmd by skin name
boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors
boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute); // Hook for chat messages
boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
#define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping,
UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes
void LUA_HookVoid(int hook);
void LUA_HookHUD(int hook, huddrawlist_h drawlist);
UINT8 LUAh_ShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be spun out?
UINT8 LUAh_ShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be exploded?
UINT8 LUAh_ShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be squished?
int LUA_HookMobj(mobj_t *, int hook);
int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook);
void LUA_HookInt(INT32 integer, int hook);
//void LUA_HookBool(boolean value, int hook);
int LUA_HookPlayer(player_t *, int hook);
int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook);
boolean LUAh_PlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SpinPlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_ExplodePlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUAh_PlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SquishPlayer. Allows Lua to execute code and/or overwrite its behavior.
void LUA_HookPreThinkFrame(void);
void LUA_HookThinkFrame(void);
void LUA_HookPostThinkFrame(void);
int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher);
int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage);
int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage);
int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source);
int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd);
void LUA_HookLinedefExecute(line_t *, mobj_t *, sector_t *);
int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute);
int LUA_HookHurtMsg(player_t *, mobj_t *inflictor, mobj_t *source);
int LUA_HookPlayerCanDamage(player_t *, mobj_t *);
void LUA_HookPlayerQuit(player_t *, int);
int LUA_HookPlayerCmd(player_t *, ticcmd_t *);
int LUA_HookMusicChange(const char *oldname, struct MusicChange *);
void LUAh_ServerJoin(void); // SRB2KART - Saturn 32p: called by client when joining a server, allows lua to load any sort of config file
int LUA_HookShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be spun out?
int LUA_HookShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be exploded?
int LUA_HookShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be squished?
boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Allows to write to player cmd before the game does anything with them.
void LUAh_IntermissionThinker(void); // Hook for Y_Ticker
void LUAh_VoteThinker(void); // Hook for Y_VoteTicker
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
boolean LUA_HookPlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SpinPlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUA_HookPlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_ExplodePlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUA_HookPlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SquishPlayer. Allows Lua to execute code and/or overwrite its behavior.
+1007 -1827
View File
File diff suppressed because it is too large. Load diff
+1 -4
View File
@@ -50,9 +50,6 @@ extern boolean hud_interplatch; // string mode was toggled
boolean LUA_HudEnabled(enum hud option);
void LUAh_GameHUD(huddrawlist_h list);
void LUAh_ScoresHUD(huddrawlist_h list);
void LUAh_IntermissionHUD(huddrawlist_h list);
void LUAh_VoteHUD(huddrawlist_h list);
void LUA_SetHudHook(int hook, huddrawlist_h list);
#endif // __LUA_HUD_H__
+18 -196
View File
@@ -28,6 +28,7 @@
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h"
#include "lua_hook.h"
#define HUDONLY if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!");
@@ -40,8 +41,6 @@ boolean hud_interpstring = false;
boolean hud_interplatch = false;
static UINT8 hud_enabled[(hud_MAX/8)+1];
static UINT8 hudAvailable; // hud hooks field
static UINT8 camnum = 1;
// must match enum hud in lua_hud.h
@@ -93,19 +92,6 @@ static const char *const patch_opt[] = {
"topoffset",
NULL};
enum hudhook {
hudhook_game = 0,
hudhook_scores = 1,
hudhook_intermission = 2,
hudhook_vote = 3,
};
static const char *const hudhook_opt[] = {
"game",
"scores",
"intermission",
"vote",
NULL};
static int patch_fields_ref = LUA_NOREF;
// alignment types for v.drawString
@@ -503,7 +489,7 @@ static int libd_getSpritePatch(lua_State *L)
angle = (angle & 7); // modulus angle by 8
// rotsprite?????
if (lua_isnumber(L, 4) && (cv_spriteroll.value))
if (lua_isnumber(L, 4) && cv_sloperoll.value)
{
angle_t rollangle = luaL_checkangle(L, 4);
INT32 rot = R_GetRollAngle(rollangle);
@@ -663,7 +649,7 @@ static int libd_drawOnMinimap(lua_State *L)
if (gamestate != GS_LEVEL)
return 0;
if (stplyr != &players[displayplayers[0]])
if (stplyrnum != 0)
return 0;
AutomapPic = minimapinfo.minimap_pic;
@@ -1215,6 +1201,8 @@ static luaL_Reg lib_draw[] = {
{NULL, NULL}
};
static int lib_draw_ref;
//
// lib_hud
//
@@ -1248,25 +1236,7 @@ static int lib_hudenabled(lua_State *L)
}
// add a HUD element for rendering
static int lib_hudadd(lua_State *L)
{
enum hudhook field;
luaL_checktype(L, 1, LUA_TFUNCTION);
field = luaL_checkoption(L, 2, "game", hudhook_opt);
lua_getfield(L, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(L, -1));
lua_rawgeti(L, -1, field+2); // HUD[2+]
I_Assert(lua_istable(L, -1));
lua_remove(L, -2);
lua_pushvalue(L, 1);
lua_rawseti(L, -2, (int)(lua_objlen(L, -2) + 1));
hudAvailable |= 1<<field;
return 0;
}
extern int lib_hudadd(lua_State *L);
static int lib_hudsetvotebackground(lua_State *L)
{
@@ -1351,23 +1321,9 @@ int LUA_HudLib(lua_State *L)
{
memset(hud_enabled, 0xff, (hud_MAX/8)+1);
lua_newtable(L); // HUD registry table
lua_newtable(L);
luaL_register(L, NULL, lib_draw);
lua_rawseti(L, -2, 1); // HUD[1] = lib_draw
lua_newtable(L);
lua_rawseti(L, -2, 2); // HUD[2] = game rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 3); // HUD[3] = scores rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 4); // HUD[4] = intermission rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 5); // HUD[5] = vote rendering functions array
lua_setfield(L, LUA_REGISTRYINDEX, "HUD");
lua_newtable(L);
luaL_register(L, NULL, lib_draw);
lib_draw_ref = luaL_ref(L, LUA_REGISTRYINDEX);
luaL_newmetatable(L, META_HUDINFO);
lua_pushcfunction(L, hudinfo_get);
@@ -1423,153 +1379,19 @@ boolean LUA_HudEnabled(enum hud option)
return false;
}
// Hook for HUD rendering
void LUAh_GameHUD(huddrawlist_h list)
void LUA_SetHudHook(int hook, huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_game)))
return;
lua_getref(gL, lib_draw_ref);
lua_pushlightuserdata(gL, list);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
hud_running = true;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, hudhook_game+2); // HUD[2] = rendering funcs
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
LUA_PushUserdata(gL, stplyr, META_PLAYER);
LUA_PushUserdata(gL, &camera[stplyrnum], META_CAMERA);
camnum = stplyrnum + 1;
hud_interpcounter = 0;
lua_pushnil(gL);
while (lua_next(gL, -5) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -5); // graphics library (HUD[1])
lua_pushvalue(gL, -5); // stplyr
lua_pushvalue(gL, -5); // camera
LUA_Call(gL, 3, 0, 1);
// there used to be a switch statement here, its gone now.
if (hook == HUD_HOOK(game))
{
LUA_PushUserdata(gL, stplyr, META_PLAYER);
LUA_PushUserdata(gL, &camera[stplyrnum], META_CAMERA);
camnum = stplyrnum + 1; // for compatibility
}
lua_settop(gL, 0);
hud_running = false;
lua_pushlightuserdata(gL, NULL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
void LUAh_ScoresHUD(huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_scores)))
return;
lua_pushlightuserdata(gL, list);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
hud_running = true;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, hudhook_scores+2); // HUD[3] = rendering funcs
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
hud_interpcounter = 0;
while (lua_next(gL, -3) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1, 0, 1);
}
lua_settop(gL, 0);
hud_running = false;
lua_pushlightuserdata(gL, NULL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
void LUAh_IntermissionHUD(huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_intermission)))
return;
lua_pushlightuserdata(gL, list);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
hud_running = true;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, hudhook_intermission+2); // HUD[4] = rendering funcs
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
hud_interpcounter = 0;
while (lua_next(gL, -3) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1, 0, 1);
}
lua_settop(gL, 0);
hud_running = false;
lua_pushlightuserdata(gL, NULL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
void LUAh_VoteHUD(huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_vote)))
return;
lua_pushlightuserdata(gL, list);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
hud_running = true;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, hudhook_vote+2); // HUD[5] = rendering funcs
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
hud_interpcounter = 0;
while (lua_next(gL, -3) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1, 0, 1);
}
lua_settop(gL, 0);
hud_running = false;
lua_pushlightuserdata(gL, NULL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
+189 -573
View File
File diff suppressed because it is too large. Load diff
+5 -6
View File
@@ -13,6 +13,7 @@
#include "m_fixed.h"
#include "doomtype.h"
#include "d_player.h"
#include "p_saveg.h"
#include "blua/lua.h"
#include "blua/lualib.h"
@@ -55,17 +56,15 @@ void LUA_InvalidateLevel(void);
void LUA_InvalidateMapthings(void);
void LUA_InvalidatePlayer(player_t *player);
void LUA_Step(void);
void LUA_Archive(void);
void LUA_UnArchive(void);
void LUA_ArchiveDemo(void);
void LUA_UnArchiveDemo(void);
void LUA_Archive(savebuffer_t *save, boolean network);
void LUA_UnArchive(savebuffer_t *save, boolean network);
void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c
void LUA_CVarChanged(const char *name); // lua_consolelib.c
int Lua_optoption(lua_State *L, int narg, int def, int list_ref);
int Lua_CreateFieldTable(lua_State *L, const char *const lst[]);
void LUAh_NetArchiveHook(lua_CFunction archFunc);
void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save);
//void LUA_HookNetArchive(lua_CFunction archFunc);
// Console wrapper
void COM_Lua_f(void);
+1 -1
View File
@@ -1091,7 +1091,7 @@ void OP_ObjectplaceMovement(player_t *player)
{
ticcmd_t *cmd = &player->cmd;
if (!player->climbing && (netgame || !cv_analog.value || (player->pflags & PF_SPINNING)))
if (!player->climbing && (netgame || (player->pflags & PF_SPINNING)))
player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */);
ticruned++;
+29
View File
@@ -247,6 +247,35 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x)
return INT32_MAX;
}
/** \brief The xs_CRoundToInt function
\param val double number
\return Round toward nearest, but ties round toward even
*/
#if defined(SRB2_BIG_ENDIAN)
#define _xs_iexp_ 0
#define _xs_iman_ 1
#else
#define _xs_iexp_ 1 //intel is little endian
#define _xs_iman_ 0
#endif //BigEndian_
typedef double real64;
typedef union _xs_doubleints
{
real64 val;
unsigned ival[2];
} _xs_doubleints;
FUNCMATH FUNCINLINE static ATTRINLINE int xs_CRoundToInt(real64 val)
{
_xs_doubleints uval;
uval.val = val + 6755399441055744.0;
return uval.ival[_xs_iman_];
}
typedef struct
{
fixed_t x;
+311 -371
View File
File diff suppressed because it is too large. Load diff
+80
View File
@@ -27,6 +27,8 @@
// Extended map support.
#include <ctype.h>
#include "am_map.h"
#include "doomdef.h"
#include "g_game.h"
#include "m_misc.h"
@@ -1573,6 +1575,84 @@ boolean M_ScreenshotResponder(event_t *ev)
return true;
}
void M_MinimapGenerate(void)
{
#ifdef USE_PNG
char *filepath;
boolean ret = false;
minigen_t *minigen = NULL;
size_t option_scale;
INT32 mul = 1;
if (gamestate != GS_LEVEL)
{
CONS_Alert(CONS_ERROR, "You must be in a level to generate a preliminary minimap!\n");
return;
}
if (automapactive)
{
CONS_Alert(CONS_ERROR, "The automap is active! Please deactivate it and try again.\n");
return;
}
option_scale = COM_CheckPartialParm("-m");
if (option_scale)
{
if (COM_Argc() < option_scale + 2)/* no argument after? */
{
CONS_Alert(CONS_ERROR,
"No multiplier follows parameter '%s'.\n",
COM_Argv(option_scale));
return;
}
mul = atoi(COM_Argv(option_scale + 1));
if (mul < 1 || mul > 10)
{
CONS_Alert(CONS_ERROR,
"Multiplier %d must be within range 1-10.\n",
mul);
return;
}
filepath = va("%s" PATHSEP "%s-MINIMAP-%d.png", srb2home, G_BuildMapName(gamemap), mul);
}
else
{
filepath = va("%s" PATHSEP "%s-MINIMAP.png", srb2home, G_BuildMapName(gamemap));
}
minigen = AM_MinimapGenerate(mul);
if (minigen == NULL || minigen->buf == NULL)
goto failure;
M_CreateScreenShotPalette();
ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette);
failure:
if (minigen->buf != NULL)
free(minigen->buf);
if (ret)
{
CONS_Printf(M_GetText("%s saved.\nRemember that this is not a complete minimap,\nand must be edited before putting in-game.\n"), filepath);
if (mul != 1)
{
CONS_Printf("You should divide its size by %d!\n", mul);
}
}
else
{
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create %s\n"), filepath);
}
#endif //#ifdef USE_PNG
}
// ==========================================================================
// TRANSLATION FUNCTIONS
// ==========================================================================
+2
View File
@@ -69,6 +69,8 @@ void M_ScreenShot(void);
void M_DoScreenShot(void);
boolean M_ScreenshotResponder(event_t *ev);
void M_MinimapGenerate(void);
void Command_SaveConfig_f(void);
void Command_LoadConfig_f(void);
void Command_ChangeConfig_f(void);
+2
View File
@@ -140,6 +140,8 @@ void M_TextInputClear(textinput_t *input)
input->cursor = 0;
input->select = 0;
input->length = 0;
input->buffer[0] = 0;
}
void M_TextInputSetString(textinput_t *input, const char *c)
+1 -78
View File
@@ -165,9 +165,6 @@ void A_SpawnObjectAbsolute(mobj_t *actor);
void A_SpawnObjectRelative(mobj_t *actor);
void A_ChangeAngleRelative(mobj_t *actor);
void A_ChangeAngleAbsolute(mobj_t *actor);
void A_RollAngle(mobj_t *actor);
void A_ChangeRollAngleRelative(mobj_t *actor);
void A_ChangeRollAngleAbsolute(mobj_t *actor);
void A_PlaySound(mobj_t *actor);
void A_FindTarget(mobj_t *actor);
void A_FindTracer(mobj_t *actor);
@@ -2658,7 +2655,7 @@ void A_BossDeath(mobj_t *mo)
}
bossjustdie:
if (LUAh_BossDeath(mo))
if (LUA_HookMobj(mo, MOBJ_HOOK(BossDeath)))
return;
else if (P_MobjWasRemoved(mo))
return;
@@ -7183,80 +7180,6 @@ void A_ChangeAngleAbsolute(mobj_t *actor)
actor->angle = FixedAngle(P_RandomRange(amin, amax));
}
// Function: A_RollAngle
//
// Description: Changes the roll angle.
//
// var1 = angle
// var2 = relative? (default)
//
void A_RollAngle(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
const angle_t angle = FixedAngle(locvar1*FRACUNIT);
if (LUA_CallAction(A_ROLLANGLE, actor))
return;
// relative (default)
if (!locvar2)
actor->rollangle += angle;
// absolute
else
actor->rollangle = angle;
}
// Function: A_ChangeRollAngleRelative
//
// Description: Changes the roll angle to a random relative value between the min and max. Set min and max to the same value to eliminate randomness
//
// var1 = min
// var2 = max
//
void A_ChangeRollAngleRelative(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT;
if (LUA_CallAction(A_CHANGEROLLANGLERELATIVE, actor))
return;
#ifdef PARANOIA
if (amin > amax)
I_Error("A_ChangeRollAngleRelative: var1 is greater than var2");
#endif
actor->rollangle += FixedAngle(P_RandomRange(amin, amax));
}
// Function: A_ChangeRollAngleAbsolute
//
// Description: Changes the roll angle to a random absolute value between the min and max. Set min and max to the same value to eliminate randomness
//
// var1 = min
// var2 = max
//
void A_ChangeRollAngleAbsolute(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT;
if (LUA_CallAction(A_CHANGEROLLANGLEABSOLUTE, actor))
return;
#ifdef PARANOIA
if (amin > amax)
I_Error("A_ChangeRollAngleAbsolute: var1 is greater than var2");
#endif
actor->rollangle = FixedAngle(P_RandomRange(amin, amax));
}
// Function: A_PlaySound
//
// Description: Plays a sound
+36 -111
View File
@@ -2119,10 +2119,11 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
sec = &sectors[secnum];
FOFsector = false;
INT32 special = GETSECSPECIAL(sec->special, 2);
if (GETSECSPECIAL(sec->special, 2) == 3 || GETSECSPECIAL(sec->special, 2) == 5)
if (special == 3 || special == 5)
floortouch = true;
else if (GETSECSPECIAL(sec->special, 2) >= 1 && GETSECSPECIAL(sec->special, 2) <= 8)
else if (special >= 1 && special <= 8)
floortouch = false;
else
continue;
@@ -2254,7 +2255,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
continue;
if (!(players[i].mo->subsector->sector == sec
|| P_PlayerTouchingSectorSpecial(&players[i], 2, (GETSECSPECIAL(sec->special, 2))) == sec))
|| P_PlayerTouchingSectorSpecial(&players[i], 2, special) == sec))
continue;
if (floortouch == true && P_IsObjectOnRealGround(players[i].mo, sec))
@@ -2298,7 +2299,9 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
while ((affectPlayer = P_HavePlayersEnteredArea(playersArea, oldPlayersArea, inAndOut)) != -1)
{
if (GETSECSPECIAL(sec->special, 2) == 2 || GETSECSPECIAL(sec->special, 2) == 3)
INT32 special = GETSECSPECIAL(sec->special, 2);
if (special == 2 || special == 3)
{
for (i = 0; i < MAXPLAYERS; i++)
{
@@ -2507,123 +2510,44 @@ void T_CameraScanner(elevator_t *elevator)
{
// leveltime is compared to make multiple scanners in one map function correctly.
static tic_t lastleveltime = 32000; // any number other than 0 should do here
static boolean camerascanned, camerascanned2, camerascanned3, camerascanned4;
static boolean camerascanned[MAXSPLITSCREENPLAYERS];
static fixed_t t_cam_dist[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42};
static fixed_t t_cam_height[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42};
if (leveltime != lastleveltime) // Back on the first camera scanner
{
camerascanned = camerascanned2 = camerascanned3 = camerascanned4 = false;
memset(camerascanned, false, sizeof (camerascanned));
lastleveltime = leveltime;
}
if (players[displayplayers[0]].mo)
for (UINT8 i = 0; i <= splitscreen; i++)
{
if (players[displayplayers[0]].mo->subsector->sector == elevator->actionsector)
{
if (t_cam_dist == -42)
t_cam_dist = cv_cam_dist.value;
if (t_cam_height == -42)
t_cam_height = cv_cam_height.value;
if (t_cam_rotate == -42)
t_cam_rotate = cv_cam_rotate.value;
CV_SetValue(&cv_cam_height, FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam_dist, FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam_rotate, elevator->distance);
camerascanned = true;
}
else if (!camerascanned)
{
if (t_cam_height != -42 && cv_cam_height.value != t_cam_height)
CV_Set(&cv_cam_height, va("%f", (double)FIXED_TO_FLOAT(t_cam_height)));
if (t_cam_dist != -42 && cv_cam_dist.value != t_cam_dist)
CV_Set(&cv_cam_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam_dist)));
if (t_cam_rotate != -42 && cv_cam_rotate.value != t_cam_rotate)
CV_Set(&cv_cam_rotate, va("%f", (double)t_cam_rotate));
if (!players[displayplayers[i]].mo || P_MobjWasRemoved(players[displayplayers[i]].mo))
continue;
t_cam_dist = t_cam_height = t_cam_rotate = -42;
}
}
if (splitscreen && players[displayplayers[1]].mo)
{
if (players[displayplayers[1]].mo->subsector->sector == elevator->actionsector)
if (players[displayplayers[i]].mo->subsector->sector == elevator->actionsector)
{
if (t_cam2_rotate == -42)
t_cam2_dist = cv_cam2_dist.value;
if (t_cam2_rotate == -42)
t_cam2_height = cv_cam2_height.value;
if (t_cam2_rotate == -42)
t_cam2_rotate = cv_cam2_rotate.value;
CV_SetValue(&cv_cam2_height, FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam2_dist, FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam2_rotate, elevator->distance);
camerascanned2 = true;
if (t_cam_dist[i] == -42)
t_cam_dist[i] = cv_cam_dist[i].value;
if (t_cam_height[i] == -42)
t_cam_height[i] = cv_cam_height[i].value;
if (t_cam_rotate[i] == -42)
t_cam_rotate[i] = cv_cam_rotate[i].value;
CV_SetValue(&cv_cam_height[i], FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam_dist[i], FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam_rotate[i], elevator->distance);
camerascanned[i] = true;
}
else if (!camerascanned2)
else if (!camerascanned[i])
{
if (t_cam2_height != -42 && cv_cam2_height.value != t_cam2_height)
CV_Set(&cv_cam2_height, va("%f", (double)FIXED_TO_FLOAT(t_cam2_height)));
if (t_cam2_dist != -42 && cv_cam2_dist.value != t_cam2_dist)
CV_Set(&cv_cam2_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam2_dist)));
if (t_cam2_rotate != -42 && cv_cam2_rotate.value != t_cam2_rotate)
CV_Set(&cv_cam2_rotate, va("%f", (double)t_cam2_rotate));
if (t_cam_height[i] != -42 && cv_cam_height[i].value != t_cam_height[i])
CV_Set(&cv_cam_height[i], va("%f", (double)FIXED_TO_FLOAT(t_cam_height[i])));
if (t_cam_dist[i] != -42 && cv_cam_dist[i].value != t_cam_dist[i])
CV_Set(&cv_cam_dist[i], va("%f", (double)FIXED_TO_FLOAT(t_cam_dist[i])));
if (t_cam_rotate[i] != -42 && cv_cam_rotate[i].value != t_cam_rotate[i])
CV_Set(&cv_cam_rotate[i], va("%f", (double)t_cam_rotate[i]));
t_cam2_dist = t_cam2_height = t_cam2_rotate = -42;
}
}
if (splitscreen > 1 && players[displayplayers[2]].mo)
{
if (players[displayplayers[2]].mo->subsector->sector == elevator->actionsector)
{
if (t_cam3_rotate == -42)
t_cam3_dist = cv_cam3_dist.value;
if (t_cam3_rotate == -42)
t_cam3_height = cv_cam3_height.value;
if (t_cam3_rotate == -42)
t_cam3_rotate = cv_cam3_rotate.value;
CV_SetValue(&cv_cam3_height, FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam3_dist, FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam3_rotate, elevator->distance);
camerascanned3 = true;
}
else if (!camerascanned3)
{
if (t_cam3_height != -42 && cv_cam3_height.value != t_cam3_height)
CV_Set(&cv_cam3_height, va("%f", (double)FIXED_TO_FLOAT(t_cam3_height)));
if (t_cam3_dist != -42 && cv_cam3_dist.value != t_cam3_dist)
CV_Set(&cv_cam3_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam3_dist)));
if (t_cam3_rotate != -42 && cv_cam3_rotate.value != t_cam3_rotate)
CV_Set(&cv_cam3_rotate, va("%f", (double)t_cam3_rotate));
t_cam3_dist = t_cam3_height = t_cam3_rotate = -42;
}
}
if (splitscreen > 2 && players[displayplayers[3]].mo)
{
if (players[displayplayers[3]].mo->subsector->sector == elevator->actionsector)
{
if (t_cam4_rotate == -42)
t_cam4_dist = cv_cam4_dist.value;
if (t_cam4_rotate == -42)
t_cam4_height = cv_cam4_height.value;
if (t_cam4_rotate == -42)
t_cam4_rotate = cv_cam4_rotate.value;
CV_SetValue(&cv_cam4_height, FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam4_dist, FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam4_rotate, elevator->distance);
camerascanned4 = true;
}
else if (!camerascanned4)
{
if (t_cam4_height != -42 && cv_cam4_height.value != t_cam4_height)
CV_Set(&cv_cam4_height, va("%f", (double)FIXED_TO_FLOAT(t_cam4_height)));
if (t_cam4_dist != -42 && cv_cam4_dist.value != t_cam4_dist)
CV_Set(&cv_cam4_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam4_dist)));
if (t_cam4_rotate != -42 && cv_cam4_rotate.value != t_cam4_rotate)
CV_Set(&cv_cam4_rotate, va("%f", (double)t_cam4_rotate));
t_cam4_dist = t_cam4_height = t_cam4_rotate = -42;
t_cam_dist[i] = t_cam_height[i] = t_cam_rotate[i] = -42;
}
}
}
@@ -2996,11 +2920,12 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover)
fixed_t a, b, c;
mobjtype_t type = MT_ROCKCRUMBLE1;
const fixed_t spacing = 48*mapobjectscale;
INT32 special = GETSECSPECIAL(rover->master->frontsector->special, 3);
// If the control sector has a special
// of Section3:7-15, use the custom debris.
if (GETSECSPECIAL(rover->master->frontsector->special, 3) >= 8)
type = MT_ROCKCRUMBLE1+(GETSECSPECIAL(rover->master->frontsector->special, 3)-7);
if (special >= 8)
type = MT_ROCKCRUMBLE1+(special-7);
// soundorg z height never gets set normally, so MEH.
sec->soundorg.z = sec->floorheight;
+10 -11
View File
@@ -284,7 +284,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (special->flags & MF_BOSS && special->flags2 & MF2_FRET)
return;
if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special))
if (LUA_HookTouchSpecial(special, toucher) || P_MobjWasRemoved(special))
return;
if (special->flags & MF_BOSS)
@@ -976,11 +976,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
break;
case MT_HOOPCOLLIDE:
// This produces a kind of 'domino effect' with the hoop's pieces.
if (!midgamejoin)
for (; special->hprev != NULL; special = special->hprev); // Move to the first sprite in the hoop
for (; !P_MobjWasRemoved(special->hprev); special = special->hprev); // Move to the first sprite in the hoop
i = 0;
for (; special->type == MT_HOOP; special = special->hnext)
for (; !P_MobjWasRemoved(special->hnext) && special->type == MT_HOOP; special = special->hnext)
{
special->fuse = 11;
special->movedir = i;
@@ -1641,7 +1640,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL);
target->health = 0; // This makes it easy to check if something's dead elsewhere.
if (LUAh_MobjDeath(target, inflictor, source) || P_MobjWasRemoved(target))
if (LUA_HookMobjDeath(target, inflictor, source) || P_MobjWasRemoved(target))
return;
// SRB2kart
@@ -2397,7 +2396,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
// Everything above here can't be forced.
if (!metalrecording)
{
UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage);
UINT8 shouldForce = LUA_HookShouldDamage(target, inflictor, source, damage);
if (P_MobjWasRemoved(target))
return (shouldForce == 1); // mobj was removed
if (shouldForce == 1)
@@ -2438,7 +2437,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (!force && target->fuse) // Invincible
return false;
if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
if (LUA_HookMobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
return true;
if (target->health > 1)
@@ -2464,7 +2463,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (!force && target->flags2 & MF2_FRET) // Currently flashing from being hit
return false;
if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
if (LUA_HookMobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
return true;
if (target->health > 1)
@@ -2472,7 +2471,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
}
else if (target->flags & MF_ENEMY)
{
if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
if (LUA_HookMobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
return true;
}
@@ -2501,14 +2500,14 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
return false; // Don't run eachother over in special stages and team games and such
}
if (LUAh_MobjDamage(target, inflictor, source, damage))
if (LUA_HookMobjDamage(target, inflictor, source, damage))
return true;
P_NiGHTSDamage(target, source); // -5s :(
return true;
}
if (LUAh_MobjDamage(target, inflictor, source, damage))
if (LUA_HookMobjDamage(target, inflictor, source, damage))
return true;
if (!force && inflictor && (inflictor->flags & MF_FIRE))
+28 -33
View File
@@ -66,6 +66,7 @@
// both the head and tail of the thinker list
extern thinker_t thinkercap;
extern mobj_t *mobjcache;
void P_InitThinkers(void);
void P_AddThinker(thinker_t *thinker);
@@ -78,8 +79,19 @@ void P_UnlinkThinker(thinker_t *thinker);
typedef struct camera_s
{
boolean chase;
boolean freecam;
angle_t localangle;
INT32 localaiming;
angle_t aiming;
// Freecam: A button was held since entering from menu, so don't move camera
UINT8 button_a_held;
// Freecam: aiming needs to be reset after switching from chasecam
boolean reset_aiming;
// Things used by FS cameras.
fixed_t viewheight;
angle_t startangle;
@@ -111,32 +123,15 @@ typedef struct camera_s
fixed_t pan;
} camera_t;
// demo freecam or something before i commit die
struct demofreecam_s {
camera_t *cam; // this is useful when the game is paused, notably
mobj_t *soundmobj; // mobj to play sound from, used in s_sound
angle_t localangle; // keeps track of the cam angle for cmds
angle_t localaiming; // ditto with aiming
boolean turnheld; // holding turn button for gradual turn speed
boolean keyboardlook; // keyboard look
};
extern struct demofreecam_s democam;
extern camera_t camera[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_dist, cv_cam_still, cv_cam_height;
extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed;
extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_height[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam2_dist, cv_cam2_still, cv_cam2_height;
extern consvar_t cv_cam2_speed, cv_cam2_rotate, cv_cam2_rotspeed;
extern consvar_t cv_cam3_dist, cv_cam3_still, cv_cam3_height;
extern consvar_t cv_cam3_speed, cv_cam3_rotate, cv_cam3_rotspeed;
extern consvar_t cv_cam4_dist, cv_cam4_still, cv_cam4_height;
extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed;
extern consvar_t cv_freecam_speed;
extern consvar_t cv_tilting;
extern consvar_t cv_quaketilt;
@@ -146,10 +141,7 @@ extern consvar_t cv_actionmovie;
extern consvar_t cv_lookbackmom;
extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate;
extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate;
extern fixed_t t_cam3_dist, t_cam3_height, t_cam3_rotate;
extern fixed_t t_cam4_dist, t_cam4_height, t_cam4_rotate;
extern fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS];
fixed_t P_GetPlayerHeight(player_t *player);
fixed_t P_GetPlayerSpinHeight(player_t *player);
@@ -157,10 +149,10 @@ void P_AddPlayerScore(player_t *player, UINT32 amount);
void P_ResetCamera(player_t *player, camera_t *thiscam);
boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam);
void P_SlideCameraMove(camera_t *thiscam);
void P_DemoCameraMovement(camera_t *cam);
//void P_DemoCameraMovement(camera_t *cam, UINT8 num);
boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled);
void P_ResetLocalCamAiming(player_t *player);
void P_InitCameraCmd(void);
void P_ToggleDemoCamera(UINT8 viewnum);
boolean P_PlayerInPain(player_t *player);
void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor);
void P_ResetPlayer(player_t *player);
@@ -265,7 +257,7 @@ void P_SceneryThinker(mobj_t *mobj);
// To test it in Lua, check mobj.valid
FUNCINLINE static ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj)
{
return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker);
return (!mobj || mobj->thinker.function.acp1 != (actionf_p1)P_MobjThinker);
}
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);
@@ -375,7 +367,11 @@ boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z);
void P_SlideMove(mobj_t *mo, boolean forceslide);
void P_BouncePlayerMove(mobj_t *mo);
void P_BounceMove(mobj_t *mo);
boolean P_CheckSight(mobj_t *t1, mobj_t *t2);
#define P_CheckSight(t1, t2) P_CheckSight2(t1, t2, false)
#define P_CheckSightFast(t1, t2) P_CheckSight2(t1, t2, true)
boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast);
void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fixed_t radius);
boolean P_CheckSector(sector_t *sector, boolean crunch);
@@ -448,7 +444,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck);
void P_PlayerFlagBurst(player_t *player, boolean toss);
void P_CheckTimeLimit(void);
void P_CheckPointLimit(void);
//void P_CheckSurvivors(void);
boolean P_CheckRacers(void);
boolean P_CanPickupItem(player_t *player, UINT8 weapon);
+9 -5
View File
@@ -449,7 +449,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
}
{
UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type
UINT8 shouldCollide = LUA_Hook2Mobj(thing, tmthing, MOBJ_HOOK(MobjCollide)); // checks hook for thing's type
if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing))
return true; // one of them was removed???
if (shouldCollide == 1)
@@ -458,7 +458,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
return true; // force no collide
}
{
UINT8 shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type
UINT8 shouldCollide = LUA_Hook2Mobj(tmthing, thing, MOBJ_HOOK(MobjMoveCollide)); // checks hook for tmthing's type
if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing))
return true; // one of them was removed???
if (shouldCollide == 1)
@@ -1727,6 +1727,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
tmbbox[BOXLEFT] = x - tmthing->radius;
newsubsec = R_PointInSubsector(x, y);
ceilingline = blockingline = NULL;
// The base floor / ceiling is from the subsector
@@ -2391,16 +2392,19 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
{
//All things are affected by their scale.
fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale);
INT32 special = 0;
if (thing->player)
{
special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1);
// If using type Section1:13, double the maxstep.
if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 13)
|| special == 13)
maxstep <<= 1;
// If using type Section1:12, no maxstep. For ledges you don't want the player to climb! (see: Egg Zeppelin & SMK port walls)
else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 12)
|| special == 12)
maxstep = 0;
}
@@ -2446,7 +2450,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
else if (maxstep > 0 && !(
thing->player && (
P_PlayerTouchingSectorSpecial(thing->player, 1, 14)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14)
|| special == 14)
)) // Step down
{
// If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS
+125 -82
View File
@@ -48,6 +48,7 @@ actioncache_t actioncachehead;
static mobj_t *overlaycap = NULL;
static mobj_t *shadowcap = NULL;
mobj_t *waypointcap = NULL;
mobj_t *mobjcache = NULL;
void P_InitCachedActions(void)
{
@@ -1881,12 +1882,13 @@ boolean P_CheckDeathPitCollide(mobj_t *mo)
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
INT32 special = GETSECSPECIAL(mo->subsector->sector->special, 1);
if (((mo->z <= mo->subsector->sector->floorheight
&& !(mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR))
|| (mo->z + mo->height >= mo->subsector->sector->ceilingheight
&& (mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING)))
&& (GETSECSPECIAL(mo->subsector->sector->special, 1) == 6
|| GETSECSPECIAL(mo->subsector->sector->special, 1) == 7))
&& (special == 6 || special == 7))
return true;
return false;
@@ -1897,16 +1899,14 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover)
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
{
fixed_t topheight =
*rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) :
*rover->topheight;
fixed_t topheight =
*rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) :
*rover->topheight;
if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3
&& !(rover->master->flags & ML_BLOCKMONSTERS)
&& ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > topheight - FixedMul(16*FRACUNIT, mo->scale)))
return true;
}
if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3
&& !(rover->master->flags & ML_BLOCKMONSTERS)
&& ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > topheight - FixedMul(16*FRACUNIT, mo->scale)))
return true;
return false;
}
@@ -3284,12 +3284,30 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam)
// Process the mobj-ish required functions of the camera
boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled)
{
boolean itsatwodlevel = false;
UINT8 i;
// This can happen when joining
if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL)
return true;
P_CalcChasePostImg(player, thiscam);
if (twodlevel)
itsatwodlevel = true;
else
{
for (i = 0; i <= splitscreen; i++)
{
if (thiscam == &camera[i] && players[displayplayers[i]].mo
&& (players[displayplayers[i]].mo->flags2 & MF2_TWOD))
{
itsatwodlevel = true;
break;
}
}
}
if (thiscam->momx || thiscam->momy)
{
if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) // Never fails for 2D mode.
@@ -3306,7 +3324,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
if (player->pflags & PF_TIMEOVER)
player->kartstuff[k_timeovercam] = (2*TICRATE)+1;
if (!resetcalled && !(player->pflags & PF_NOCLIP || leveltime < introtime) && !P_CheckSight(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead.
if (!resetcalled && !(player->pflags & PF_NOCLIP || leveltime < introtime) && !P_CheckSightFast(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead.
P_ResetCamera(player, thiscam);
else
P_SlideCameraMove(thiscam);
@@ -3316,9 +3334,10 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
}
}
P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam);
if (!itsatwodlevel)
P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam);
thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y);
thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y);
thiscam->floorz = tmfloorz;
thiscam->ceilingz = tmceilingz;
@@ -3328,7 +3347,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
thiscam->z += thiscam->momz + player->mo->pmomz;
#ifndef NOCLIPCAM
if (!(player->pflags & PF_NOCLIP || leveltime < introtime))
if (!itsatwodlevel && !(player->pflags & PF_NOCLIP || leveltime < introtime))
{
// clip movement
if (thiscam->z <= thiscam->floorz) // hit the floor
@@ -3371,13 +3390,13 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
#endif
}
if (thiscam->ceilingz - thiscam->z < thiscam->height
&& thiscam->ceilingz >= thiscam->z)
if (itsatwodlevel
|| (thiscam->ceilingz - thiscam->z < thiscam->height
&& thiscam->ceilingz >= thiscam->z))
{
thiscam->ceilingz = thiscam->z + thiscam->height;
thiscam->floorz = thiscam->z;
}
return false;
}
@@ -6011,18 +6030,17 @@ static void P_KoopaThinker(mobj_t *koopa)
//
void P_RollPitchMobj(mobj_t* mobj)
{
if (!mobj || P_MobjWasRemoved(mobj))
if (P_MobjWasRemoved(mobj))
return;
if (cv_spriteroll.value && cv_sloperoll.value == 2)
{
K_RollMobjBySlopes(mobj, cv_sloperolldist.value && !splitscreen);
}
else
if (cv_sloperoll.value != 2)
{
mobj->sloperoll = FixedAngle(0);
mobj->slopepitch = FixedAngle(0);
return;
}
K_RollMobjBySlopes(mobj, cv_sloperolldist.value && !splitscreen);
}
angle_t P_MobjPitchAndRoll(mobj_t *mobj)
@@ -6033,14 +6051,17 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
angle_t camang = 0;
angle_t return_angle = 0;
if (!cv_spriteroll.value)
if (!cv_sloperoll.value)
return 0;
if (P_MobjWasRemoved(mobj))
return 0;
size_t rot = mobj->frame & FF_FRAMEMASK;
boolean papersprite = (mobj->frame & FF_PAPERSPRITE);
// if mobj doesent have any of those, no need to do the rest
if (mobj->roll == 0 && mobj->pitch == 0 && mobj->sloperoll == 0 && mobj->slopepitch == 0)
return 0;
size_t rot = (mobj->frame & FF_FRAMEMASK);
if (mobj->skin && mobj->sprite == SPR_PLAY)
{
@@ -6057,7 +6078,7 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
if (rot >= sprdef->numframes)
{
sprdef = &sprites[states[S_UNKNOWN].sprite];
rot = states[S_UNKNOWN].frame&FF_FRAMEMASK;
rot = (states[S_UNKNOWN].frame & FF_FRAMEMASK);
}
sprframe = &sprdef->spriteframes[rot];
@@ -6065,20 +6086,16 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
// No sprite frame? I guess it is possible
if (!sprframe) return 0;
if (sprframe->rotate != SRF_SINGLE || papersprite)
if (sprframe->rotate != SRF_SINGLE || (mobj->frame & FF_PAPERSPRITE))
{
ang = R_PointToAngle(mobj->x, mobj->y) - mobj->angle;
camang = R_PointToAngle(mobj->x, mobj->y);
}
return_angle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mobj->roll)
+ FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch);
if (cv_sloperoll.value)
{
return_angle += FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll)
+ FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch);
}
+ FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch)
+ FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll)
+ FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch);
return return_angle;
}
@@ -6165,7 +6182,7 @@ void P_MobjThinker(mobj_t *mobj)
// Special thinker for scenery objects
if (mobj->flags & MF_SCENERY)
{
if (LUAh_MobjThinker(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)))
return;
if (P_MobjWasRemoved(mobj))
@@ -6863,7 +6880,7 @@ void P_MobjThinker(mobj_t *mobj)
mobj->fuse--;
if (!mobj->fuse)
{
if (!LUAh_MobjFuse(mobj))
if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)))
P_RemoveMobj(mobj);
return;
}
@@ -6878,13 +6895,13 @@ void P_MobjThinker(mobj_t *mobj)
// Check for a Lua thinker first
if (!mobj->player)
{
if (LUAh_MobjThinker(mobj) || P_MobjWasRemoved(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)) || P_MobjWasRemoved(mobj))
return;
}
else if (!mobj->player->spectator)
{
// You cannot short-circuit the player thinker like you can other thinkers.
LUAh_MobjThinker(mobj);
LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker));
if (P_MobjWasRemoved(mobj))
return;
}
@@ -6909,7 +6926,7 @@ void P_MobjThinker(mobj_t *mobj)
}
else if (mobj->flags & MF_BOSS)
{
if (LUAh_BossThinker(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(BossThinker)))
{
if (P_MobjWasRemoved(mobj))
return;
@@ -8876,7 +8893,7 @@ void P_MobjThinker(mobj_t *mobj)
fixed_t x, y, z;
mobj_t *flagmo, *newmobj;
if (!LUAh_MobjFuse(mobj) && !P_MobjWasRemoved(mobj))
if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)) && !P_MobjWasRemoved(mobj))
{
switch (mobj->type)
{
@@ -9211,7 +9228,6 @@ void P_PushableThinker(mobj_t *mobj)
if (GETSECSPECIAL(sec->special, 2) == 1 && mobj->z == sec->floorheight)
P_LinedefExecute(sec->tag, mobj, sec);
// else if (GETSECSPECIAL(sec->special, 2) == 8)
{
sector_t *sec2;
@@ -9362,7 +9378,18 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
{
const mobjinfo_t *info = &mobjinfo[type];
state_t *st;
mobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
mobj_t *mobj;
if (mobjcache != NULL)
{
mobj = mobjcache;
mobjcache = mobjcache->hnext;
memset(mobj, 0, sizeof(*mobj));
}
else
{
mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
}
// this is officially a mobj, declared as soon as possible.
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker;
@@ -9467,7 +9494,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
// DANGER! This can cause P_SpawnMobj to return NULL!
// Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks!
if (LUAh_MobjSpawn(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjSpawn)))
{
if (P_MobjWasRemoved(mobj))
return NULL;
@@ -9823,7 +9850,18 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster)
{
const mobjinfo_t *info = &mobjinfo[MT_SHADOW];
state_t *st;
mobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
mobj_t *mobj;
if (mobjcache != NULL)
{
mobj = mobjcache;
mobjcache = mobjcache->hnext;
memset(mobj, 0, sizeof(*mobj));
}
else
{
mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
}
// this is officially a mobj, declared as soon as possible.
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker;
@@ -10002,7 +10040,7 @@ void P_RemoveMobj(mobj_t *mobj)
return; // something already removing this mobj.
mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing.
LUAh_MobjRemoved(mobj);
LUA_HookMobj(mobj, MOBJ_HOOK(MobjRemoved));
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work.
// Rings only, please!
@@ -10097,7 +10135,9 @@ void P_RemoveMobj(mobj_t *mobj)
// Invalidate mobj_t data to cause crashes if accessed!
memset(mobj, 0xff, sizeof(mobj_t));
#endif
Z_Free(mobj); // No refrences? Can be removed immediately! :D
// no references, dump it directly in the mobj cache
mobj->hnext = mobjcache;
mobjcache = mobj;
}
else
{ // Add thinker just to delay removing it until refrences are gone.
@@ -10190,19 +10230,26 @@ void P_SpawnPrecipitation(void)
if (dedicated || !cv_drawdist_precip.value || curWeather == PRECIP_NONE) // SRB2Kart
return;
fixed_t density = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT);
if (cv_lessprecip.value)
density *= 2; // just spawn half the precip
// Use the blockmap to narrow down our placing patterns
for (i = 0; i < bmapwidth*bmapheight; ++i)
{
basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE;
basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE;
for (j = 0; j < FRACUNIT; j += cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT)
// If mobjscale < FRACUNIT, each blockmap cell covers
// more area so spawn more precipitation in that area.
for (j = 0; j < FRACUNIT; j += density)
{
INT32 floorz;
INT32 ceilingz;
x = ((cv_lessprecip.value ? basex*1.5 : basex) + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3));
y = ((cv_lessprecip.value ? basey*1.5 : basey) + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3));
x = basex + ((M_RandomKey(MAPBLOCKUNITS << 3) << FRACBITS) >> 3);
y = basey + ((M_RandomKey(MAPBLOCKUNITS << 3) << FRACBITS) >> 3);
precipsector = R_IsPointInSubsector(x, y);
@@ -10368,7 +10415,7 @@ void P_PrecipitationEffects(void)
for (y = yl; y <= yh; y += RADIUSSTEP)
for (x = xl; x <= xh; x += RADIUSSTEP)
{
if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors!
if (R_PointInSubsectorFast((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors!
continue;
newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0);
@@ -10568,7 +10615,8 @@ void P_SpawnPlayer(INT32 playernum)
}
// spawn as spectator determination
if (multiplayer && demo.playback); // Don't mess with spectator values since the demo setup handles them already.
if (multiplayer && demo.playback)
; // Don't mess with spectator values since the demo setup handles them already.
else if (!G_GametypeHasSpectators())
p->spectator = false;
else if (netgame && p->jointime <= 1 && pcount)
@@ -10635,15 +10683,8 @@ void P_SpawnPlayer(INT32 playernum)
// (usefulness: when body mobj is detached from player (who respawns),
// the dead body mobj retains the skin through the 'spritedef' override).
mobj->skin = &skins[p->skin];
if (p->localskin > 0)
{
if (p->skinlocal)
mobj->localskin = &localskins[p->localskin - 1];
else
mobj->localskin = & skins[p->localskin - 1];
}
else
mobj->localskin = 0;
mobj->localskin = ((p->localskin > 0) ? (p->skinlocal ? &localskins[p->localskin - 1] : &skins[p->localskin - 1]) : 0);
mobj->skinlocal = p->skinlocal;
mobj->health = p->health;
@@ -10714,6 +10755,18 @@ void P_SpawnPlayer(INT32 playernum)
P_SetScale(karmahitbox, mobj->scale);
}
}
// TODO: handle splitscreen
// Spectators can switch to freecam. This should be
// disabled when they enter the race, or when the level
// changes.
if (!demo.playback)
{
if (!p->spectator)
{
camera[playernum].freecam = false;
}
}
}
void P_AfterPlayerSpawn(INT32 playernum)
@@ -10756,15 +10809,18 @@ void P_AfterPlayerSpawn(INT32 playernum)
SV_SpawnPlayer(playernum, mobj->x, mobj->y, mobj->angle);
for (i = 0; i <= splitscreen; i++)
if (p->spectator == false)
{
if (!camera[i].chase)
continue;
for (i = 0; i <= splitscreen; i++)
{
if (!camera[i].chase)
continue;
if (displayplayers[i] != playernum)
continue;
if (displayplayers[i] != playernum)
continue;
P_ResetCamera(p, &camera[i]);
P_ResetCamera(p, &camera[i]);
}
}
if (CheckForReverseGravity)
@@ -11786,12 +11842,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
z = mthing->options << FRACBITS;
hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER);
hoopcenter->spawnpoint = mthing;
// Screw these damn hoops, I need this thinker.
//hoopcenter->flags |= MF_NOTHINK;
z +=
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
sec->floorheight;
@@ -11837,10 +11889,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
mobj = P_SpawnMobj(finalx, finaly, finalz, MT_HOOP);
//if (maptol & TOL_XMAS)
//P_SetMobjState(mobj, mobj->info->seestate + (i & 1));
mobj->z -= mobj->height/2;
P_SetTarget(&mobj->target, hoopcenter); // Link the sprite to the center.
mobj->fuse = 0;
@@ -11977,9 +12027,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
mobj = P_SpawnMobj(finalx, finaly, finalz, MT_HOOP);
//if (maptol & TOL_XMAS)
//P_SetMobjState(mobj, mobj->info->seestate + (i & 1));
mobj->z -= mobj->height/2;
P_SetTarget(&mobj->target, hoopcenter); // Link the sprite to the center.
mobj->fuse = 0;
@@ -12350,10 +12397,6 @@ void P_ColorTeamMissile(mobj_t *missile, player_t *source)
else if (source->ctfteam == 1)
missile->color = skincolor_redring;
}
/*
else
missile->color = player->mo->color; //copy color
*/
}
//
+3
View File
@@ -153,6 +153,9 @@ FUNCINLINE static ATTRINLINE void PolyObj_AddThinker(thinker_t *th)
th->next = thinkercap.next;
th->prev = &thinkercap;
thinkercap.next = th;
th->references = 0;
th->cachable = false; // not initialising this made the mobjcache die thx!
}
static void FreeSideLists(void)
+991 -1022
View File
File diff suppressed because it is too large. Load diff
+16 -8
View File
@@ -21,13 +21,6 @@
// Persistent storage/archiving.
// These are the load / save game routines.
void P_SaveGame(void);
void P_SaveNetGame(boolean resending);
boolean P_LoadGame(INT16 mapoverride);
boolean P_LoadNetGame(boolean resending);
mobj_t *P_FindNewPosition(UINT32 oldposition);
typedef struct
{
UINT8 skincolor;
@@ -41,6 +34,21 @@ typedef struct
} savedata_t;
extern savedata_t savedata;
extern UINT8 *save_p;
typedef struct
{
UINT8 *buffer;
UINT8 *p;
} savebuffer_t;
// Persistent storage/archiving.
// These are the load / save game routines.
void P_SaveGame(savebuffer_t *save);
void P_SaveNetGame(savebuffer_t *save, boolean resending);
boolean P_LoadGame(savebuffer_t *save, INT16 mapoverride);
boolean P_LoadNetGame(savebuffer_t *save, boolean reloading);
mobj_t *P_FindNewPosition(UINT32 oldposition);
#endif
+57 -56
View File
@@ -63,7 +63,7 @@
#include "md5.h" // map MD5
// for LUAh_MapLoad
// for MapLoad hook
#include "lua_script.h"
#include "lua_hook.h"
@@ -460,7 +460,11 @@ FUNCINLINE static ATTRINLINE void P_LoadRawVertexes(UINT8 *data)
* \param seg Seg to compute length for.
* \return Length in fracunits.
*/
#if defined (WALLSPLATS) || defined (FLOORSPLATS)
fixed_t P_SegLength(seg_t *seg)
#else
static inline fixed_t P_SegLength(seg_t *seg)
#endif
{
INT64 dx = (seg->v2->x - seg->v1->x)>>1;
INT64 dy = (seg->v2->y - seg->v1->y)>>1;
@@ -997,14 +1001,14 @@ void P_WriteThings(lumpnum_t lumpnum)
size_t i, length;
mapthing_t *mt;
UINT8 *data;
UINT8 *savebuffer, *savebuf_p;
savebuffer_t save;
INT16 temp;
data = W_CacheLumpNum(lumpnum, PU_LEVEL);
savebuf_p = savebuffer = (UINT8 *)malloc(nummapthings * sizeof (mapthing_t));
save.p = save.buffer = (UINT8 *)malloc(nummapthings * sizeof (mapthing_t));
if (!savebuf_p)
if (!save.p)
{
CONS_Alert(CONS_ERROR, M_GetText("No more free memory for thing writing!\n"));
return;
@@ -1013,23 +1017,23 @@ void P_WriteThings(lumpnum_t lumpnum)
mt = mapthings;
for (i = 0; i < nummapthings; i++, mt++)
{
WRITEINT16(savebuf_p, mt->x);
WRITEINT16(savebuf_p, mt->y);
WRITEINT16(save.p, mt->x);
WRITEINT16(save.p, mt->y);
WRITEINT16(savebuf_p, mt->angle);
WRITEINT16(save.p, mt->angle);
temp = (INT16)(mt->type + ((INT16)mt->extrainfo << 12));
WRITEINT16(savebuf_p, temp);
WRITEUINT16(savebuf_p, mt->options);
WRITEINT16(save.p, temp);
WRITEUINT16(save.p, mt->options);
}
Z_Free(data);
length = savebuf_p - savebuffer;
length = save.p - save.buffer;
FIL_WriteFile(va("newthings%d.lmp", gamemap), savebuffer, length);
free(savebuffer);
savebuf_p = NULL;
FIL_WriteFile(va("newthings%d.lmp", gamemap), save.buffer, length);
free(save.buffer);
save.p = NULL;
CONS_Printf(M_GetText("newthings%d.lmp saved.\n"), gamemap);
}
@@ -1542,16 +1546,23 @@ static void P_CreateBlockMap(void)
// First find limits of map
for (i = 0; i < numvertexes; i++)
{
if (vertexes[i].x>>FRACBITS < minx)
minx = vertexes[i].x>>FRACBITS;
else if (vertexes[i].x>>FRACBITS > maxx)
maxx = vertexes[i].x>>FRACBITS;
if (vertexes[i].y>>FRACBITS < miny)
miny = vertexes[i].y>>FRACBITS;
else if (vertexes[i].y>>FRACBITS > maxy)
maxy = vertexes[i].y>>FRACBITS;
fixed_t t;
if ((t = vertexes[i].x) < minx)
minx = t;
else if (t > maxx)
maxx = t;
if ((t = vertexes[i].y) < miny)
miny = t;
else if (t > maxy)
maxy = t;
}
minx >>= FRACBITS;
maxx >>= FRACBITS;
miny >>= FRACBITS;
maxy >>= FRACBITS;
// Save blockmap parameters
bmaporgx = minx << FRACBITS;
bmaporgy = miny << FRACBITS;
@@ -2426,7 +2437,7 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam)
cam->y = players[pnum].mo->y;
cam->z = players[pnum].mo->z;
cam->angle = players[pnum].mo->angle;
cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
}
else
{
@@ -2451,8 +2462,10 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam)
cam->y = thing->y;
cam->z = thing->z;
cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS);
cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
}
cam->chase = false; // tell camera to reset its position next tic
}
static void P_InitCamera(void)
@@ -2461,22 +2474,20 @@ static void P_InitCamera(void)
if (!dedicated)
{
if (!demo.freecam)
for (i = 0; i <= splitscreen; i++)
{
if (camera[i].freecam)
continue;
P_SetupCamera(displayplayers[i], &camera[i]);
}
// Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P
if (!cv_cam_rotate.changed)
CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue);
if (!cv_cam2_rotate.changed)
CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue);
if (!cv_cam3_rotate.changed)
CV_Set(&cv_cam3_rotate, cv_cam3_rotate.defaultvalue);
if (!cv_cam4_rotate.changed)
CV_Set(&cv_cam4_rotate, cv_cam4_rotate.defaultvalue);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (!cv_cam_rotate[i].changed)
CV_Set(&cv_cam_rotate[i], cv_cam_rotate[i].defaultvalue);
}
displayplayers[0] = consoleplayer; // Start with your OWN view, please!
}
@@ -2607,18 +2618,11 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
if (!dedicated)
{
if (!cv_chasecam.changed)
CV_SetValue(&cv_chasecam, chase);
// same for second player
if (!cv_chasecam2.changed)
CV_SetValue(&cv_chasecam2, chase);
if (!cv_chasecam3.changed)
CV_SetValue(&cv_chasecam3, chase);
if (!cv_chasecam4.changed)
CV_SetValue(&cv_chasecam4, chase);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (!cv_chasecam[i].changed)
CV_SetValue(&cv_chasecam[i], chase);
}
}
// Initial height of PointOfView
@@ -2749,6 +2753,8 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
R_ClearLevelSplats();
#endif
mobjcache = NULL;
R_InitializeLevelInterpolators();
P_InitThinkers();
@@ -2908,8 +2914,9 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
: mapheaderinfo[gamemap - 1]->numlaps);
// Start recording replay in multiplayer with a temp filename
//Ensure dedis only record a replay if there is a player at the start of the map, otherwise we get invalid replays!
if (!demo.playback && multiplayer && D_NumPlayers()) {
// Ensure dedis only record a replay if there is a player at the start of the map, otherwise we get invalid replays!
if (!demo.playback && multiplayer && D_NumPlayers())
{
static char buf[256];
sprintf(buf, "replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap));
@@ -3013,12 +3020,11 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
}
P_PreTicker(2);
if (!reloadinggamestate)
LUAh_MapLoad();
LUA_HookInt(gamemap, HOOK(MapLoad));
}
if (rendermode != render_none && !reloadinggamestate)
{
R_ResetViewInterpolation(0);
R_ResetViewInterpolation(0);
R_UpdateMobjInterpolators();
}
@@ -3164,11 +3170,6 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
//
S_LoadMusicDefs(wadnum);
//
// edit music defs for stuff like musictest
//
S_LoadMTDefs(wadnum);
//
// search for maps
//
+5
View File
@@ -88,6 +88,11 @@ SINT8 P_PartialAddGetStage(void);
boolean P_RunSOC(const char *socfilename);
void P_WriteThings(lumpnum_t lump);
#if defined (WALLSPLATS) || defined (FLOORSPLATS)
fixed_t P_SegLength(seg_t *seg);
#endif
void P_UpdateSegLightOffset(seg_t *li);
size_t P_PrecacheLevelFlats(void);
void P_AllocMapHeader(INT16 i);
+40 -80
View File
@@ -38,66 +38,21 @@ static INT32 sightcounts[2];
//
// Returns side 0 (front), 1 (back), or 2 (on).
//
static INT32 P_DivlineSide(fixed_t x, fixed_t y, divline_t *node)
// killough 4/19/98: made static, cleaned up
static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node)
{
fixed_t dx, dy, left, right;
if (!node->dx)
{
if (x == node->x)
return 2;
if (x <= node->x)
return (node->dy > 0);
return (node->dy < 0);
}
if (!node->dy)
{
if (y == node->y)
return 2;
if (y <= node->y)
return (node->dx < 0);
return (node->dx > 0);
}
dx = x - node->x;
dy = y - node->y;
left = (node->dy>>FRACBITS) * (dx>>FRACBITS);
right = (dy>>FRACBITS) * (node->dx>>FRACBITS);
if (right < left)
return 0; // front side
if (left == right)
return 2;
return 1; // back side
fixed_t left, right;
return
!node->dx ? x == node->x ? 2 : x <= node->x ? node->dy > 0 : node->dy < 0 :
!node->dy ? y == node->y ? 2 : y <= node->y ? node->dx < 0 : node->dx > 0 :
(right = ((y - node->y) >> FRACBITS) * (node->dx >> FRACBITS)) <
(left = ((x - node->x) >> FRACBITS) * (node->dy >> FRACBITS)) ? 0 :
right == left ? 2 : 1;
}
//
// P_InterceptVector2
//
// Returns the fractional intercept point along the first divline.
// This is only called by the addthings and addlines traversers.
//
static fixed_t P_InterceptVector2(divline_t *v2, divline_t *v1)
static INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node)
{
fixed_t frac, num, den;
den = FixedMul(v1->dy>>8, v2->dx) - FixedMul(v1->dx>>8, v2->dy);
if (!den)
return 0;
num = FixedMul((v1->x - v2->x)>>8, v1->dy) + FixedMul((v2->y - v1->y)>>8, v1->dx);
frac = FixedDiv(num, den);
return frac;
return (P_DivlineSide(x1, y1, node) == P_DivlineSide(x2, y2, node));
}
static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los)
@@ -135,23 +90,21 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los)
v2 = line->v2;
// line isn't crossed?
if (P_DivlineSide(v1->x, v1->y, &los->strace) ==
P_DivlineSide(v2->x, v2->y, &los->strace))
if (P_DivlineCrossed(v1->x, v1->y, v2->x, v2->y, &los->strace))
continue;
divl.dx = v2->x - (divl.x = v1->x);
divl.dy = v2->y - (divl.y = v1->y);
// line isn't crossed?
if (P_DivlineSide(los->strace.x, los->strace.y, &divl) ==
P_DivlineSide(los->t2x, los->t2y, &divl))
if (P_DivlineCrossed(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl))
continue;
// stop because it is not two sided
//if (!(po->flags & POF_TESTHEIGHT))
//return false;
frac = P_InterceptVector2(&los->strace, &divl);
frac = P_InterceptVector(&los->strace, &divl);
// get slopes of top and bottom of this polyobject line
topslope = FixedDiv(polysec->ceilingheight - los->sightzstart , frac);
@@ -232,16 +185,14 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
v2 = line->v2;
// line isn't crossed?
if (P_DivlineSide(v1->x, v1->y, &los->strace) ==
P_DivlineSide(v2->x, v2->y, &los->strace))
if (P_DivlineCrossed(v1->x, v1->y, v2->x, v2->y, &los->strace))
continue;
divl.dx = v2->x - (divl.x = v1->x);
divl.dy = v2->y - (divl.y = v1->y);
// line isn't crossed?
if (P_DivlineSide(los->strace.x, los->strace.y, &divl) ==
P_DivlineSide(los->t2x, los->t2y, &divl))
if (P_DivlineCrossed(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl))
continue;
// stop because it is not two sided anyway
@@ -249,7 +200,7 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
return false;
// calculate fractional intercept (how far along we are divided by how far we are from t2)
frac = P_InterceptVector2(&los->strace, &divl);
frac = P_InterceptVector(&los->strace, &divl);
front = seg->frontsector;
back = seg->backsector;
@@ -348,25 +299,34 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
// if strace crosses the given node successfully.
//
// killough 4/20/98: rewritten to remove tail recursion, clean up, and optimize
static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los)
static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast)
{
while (!(bspnum & NF_SUBSECTOR))
{
register node_t *bsp = nodes + bspnum;
INT32 side = P_DivlineSide(los->strace.x,los->strace.y,(divline_t *)bsp)&1;
if (side == P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp))
bspnum = bsp->children[side]; // doesn't touch the other side
else // the partition plane is crossed here
INT32 side = (fast ? R_PointOnSideFast(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x,los->strace.y, (divline_t *)bsp) & 1));
INT32 side2 = (fast ? R_PointOnSideFast(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp));
if (side == side2)
{
if (!P_CrossBSPNode(bsp->children[side], los))
return 0; // cross the starting side
bspnum = bsp->children[side]; // doesn't touch the other side
}
else
{
// the partition plane is crossed here
if (!P_CrossBSPNode(bsp->children[side], los, fast))
{
return false; // cross the starting side
}
else
bspnum = bsp->children[side^1]; // cross the ending side
{
bspnum = bsp->children[side^1]; // cross the ending side
}
}
}
return
P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los);
return P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los);
}
//
@@ -375,7 +335,7 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los)
// Returns true if a straight line between t1 and t2 is unobstructed.
// Uses REJECT.
//
boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast)
{
const sector_t *s1, *s2;
size_t pnum;
@@ -492,5 +452,5 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
}
// the head node is the last node output
return P_CrossBSPNode((INT32)numnodes - 1, &los);
}
return (P_CrossBSPNode((INT32)numnodes - 1, &los, fast));
}
+34 -74
View File
@@ -364,11 +364,11 @@ void P_SpawnSlope_Line(int linenum)
// In P_SpawnSlopeLine the origin is the centerpoint of the sourcelinedef
fslope = line->frontsector->f_slope =
P_MakeSlope(&point, &direction, dz, flags);
P_MakeSlope(&point, &direction, dz, flags);
// Set up some shit
fslope->extent = extent;
fslope->refpos = 1;
// Set up some shit
fslope->extent = extent;
fslope->refpos = 1;
// Now remember that f_slope IS a vector
// fslope->o = origin 3D point 1 of the vector
@@ -425,11 +425,11 @@ void P_SpawnSlope_Line(int linenum)
dz = FixedDiv(origin.z - point.z, extent);
cslope = line->frontsector->c_slope =
P_MakeSlope(&point, &direction, dz, flags);
P_MakeSlope(&point, &direction, dz, flags);
// Set up some shit
cslope->extent = extent;
cslope->refpos = 2;
// Set up some shit
cslope->extent = extent;
cslope->refpos = 2;
// Sync the linedata of the line that started this slope
// TODO: Anything special for control sector based slopes later?
@@ -494,11 +494,11 @@ void P_SpawnSlope_Line(int linenum)
dz = FixedDiv(origin.z - point.z, extent);
fslope = line->backsector->f_slope =
P_MakeSlope(&point, &direction, dz, flags);
P_MakeSlope(&point, &direction, dz, flags);
// Set up some shit
fslope->extent = extent;
fslope->refpos = 3;
// Set up some shit
fslope->extent = extent;
fslope->refpos = 3;
// Sync the linedata of the line that started this slope
// TODO: Anything special for control sector based slopes later?
@@ -531,6 +531,7 @@ void P_SpawnSlope_Line(int linenum)
P_CalculateSlopeNormal(fslope);
}
if (backceil)
{
fixed_t highest, lowest;
@@ -540,11 +541,11 @@ void P_SpawnSlope_Line(int linenum)
dz = FixedDiv(origin.z - point.z, extent);
cslope = line->backsector->c_slope =
P_MakeSlope(&point, &direction, dz, flags);
P_MakeSlope(&point, &direction, dz, flags);
// Set up some shit
cslope->extent = extent;
cslope->refpos = 4;
// Set up some shit
cslope->extent = extent;
cslope->refpos = 4;
// Sync the linedata of the line that started this slope
// TODO: Anything special for control sector based slopes later?
@@ -604,7 +605,8 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag
memset(ret->vertices, 0, 3*sizeof(mapthing_t));
// And... look for the vertices in question.
for (i = 0; i < nummapthings; i++, mt++) {
for (i = 0; i < nummapthings; i++, mt++)
{
if (mt->type != 750) // Haha, I'm hijacking the old Chaos Spawn thingtype for something!
continue;
@@ -617,7 +619,8 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag
}
// Now set heights for each vertex, because they haven't been set yet
for (i = 0; i < 3; i++) {
for (i = 0; i < 3; i++)
{
mt = ret->vertices[i];
if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?)
I_Error("P_NewVertexSlope: Slope vertex %s (for linedef tag %d) not found!", sizeu1(i), tag1);
@@ -649,23 +652,23 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag
//
void P_CopySectorSlope(line_t *line)
{
sector_t *fsec = line->frontsector;
int i, special = line->special;
sector_t *fsec = line->frontsector;
int i, special = line->special;
// Check for copy linedefs
for(i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;)
{
sector_t *srcsec = sectors + i;
// Check for copy linedefs
for(i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;)
{
sector_t *srcsec = sectors + i;
if((special - 719) & 1 && !fsec->f_slope && srcsec->f_slope)
fsec->f_slope = srcsec->f_slope; //P_CopySlope(srcsec->f_slope);
if((special - 719) & 2 && !fsec->c_slope && srcsec->c_slope)
fsec->c_slope = srcsec->c_slope; //P_CopySlope(srcsec->c_slope);
}
if((special - 719) & 1 && !fsec->f_slope && srcsec->f_slope)
fsec->f_slope = srcsec->f_slope; //P_CopySlope(srcsec->f_slope);
if((special - 719) & 2 && !fsec->c_slope && srcsec->c_slope)
fsec->c_slope = srcsec->c_slope; //P_CopySlope(srcsec->c_slope);
}
fsec->hasslope = true;
fsec->hasslope = true;
line->special = 0; // Linedef was use to set slopes, it finished its job, so now make it a normal linedef
line->special = 0; // Linedef was use to set slopes, it finished its job, so now make it a normal linedef
}
//
@@ -790,49 +793,6 @@ void P_ResetDynamicSlopes(void)
// Various utilities related to slopes
//
//
// P_GetZAt
//
// Returns the height of the sloped plane at (x, y) as a fixed_t
//
fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y)
{
fixed_t dist = FixedMul(x - slope->o.x, slope->d.x) +
FixedMul(y - slope->o.y, slope->d.y);
return slope->o.z + FixedMul(dist, slope->zdelta);
}
// Returns the height of the sector floor at (x, y)
fixed_t P_GetSectorFloorZAt(const sector_t *sector, fixed_t x, fixed_t y)
{
return sector->f_slope ? P_GetZAt(sector->f_slope, x, y) : sector->floorheight;
}
// Returns the height of the sector ceiling at (x, y)
fixed_t P_GetSectorCeilingZAt(const sector_t *sector, fixed_t x, fixed_t y)
{
return sector->c_slope ? P_GetZAt(sector->c_slope, x, y) : sector->ceilingheight;
}
// Returns the height of the FOF top at (x, y)
fixed_t P_GetFFloorTopZAt(const ffloor_t *ffloor, fixed_t x, fixed_t y)
{
return *ffloor->t_slope ? P_GetZAt(*ffloor->t_slope, x, y) : *ffloor->topheight;
}
// Returns the height of the FOF bottom at (x, y)
fixed_t P_GetFFloorBottomZAt(const ffloor_t *ffloor, fixed_t x, fixed_t y)
{
return *ffloor->b_slope ? P_GetZAt(*ffloor->b_slope, x, y) : *ffloor->bottomheight;
}
// Returns the height of the light list at (x, y)
fixed_t P_GetLightZAt(const lightlist_t *light, fixed_t x, fixed_t y)
{
return light->slope ? P_GetZAt(light->slope, x, y) : light->height;
}
//
// P_QuantizeMomentumToSlope
//
+37 -8
View File
@@ -13,9 +13,12 @@
#ifndef P_SLOPES_H__
#define P_SLOPES_H__
#include "doomtype.h"
void P_CalculateSlopeNormal(pslope_t *slope);
void P_ResetDynamicSlopes(void);
void P_RunDynamicSlopes(void);
// P_SpawnSlope_Line
// Creates one or more slopes based on the given line type and front/back
// sectors.
@@ -30,19 +33,45 @@ void P_CopySectorSlope(line_t *line);
pslope_t *P_SlopeById(UINT16 id);
//
// P_GetZAt
//
// Returns the height of the sloped plane at (x, y) as a fixed_t
fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y);
FUNCINLINE static ATTRINLINE fixed_t P_GetZAt(pslope_t *z_slope, fixed_t x, fixed_t y)
{
return z_slope->o.z + FixedMul((FixedMul(x - z_slope->o.x, z_slope->d.x) + FixedMul(y - z_slope->o.y, z_slope->d.y)), z_slope->zdelta);
}
// Returns the height of the sector at (x, y)
fixed_t P_GetSectorFloorZAt (const sector_t *sector, fixed_t x, fixed_t y);
fixed_t P_GetSectorCeilingZAt(const sector_t *sector, fixed_t x, fixed_t y);
// Returns the height of the sector floor at (x, y)
FUNCINLINE static ATTRINLINE fixed_t P_GetSectorFloorZAt(const sector_t *z_sector, fixed_t x, fixed_t y)
{
return z_sector->f_slope ? P_GetZAt(z_sector->f_slope, x, y) : z_sector->floorheight;
}
// Returns the height of the FOF at (x, y)
fixed_t P_GetFFloorTopZAt (const ffloor_t *ffloor, fixed_t x, fixed_t y);
fixed_t P_GetFFloorBottomZAt(const ffloor_t *ffloor, fixed_t x, fixed_t y);
// Returns the height of the sector ceiling at (x, y)
FUNCINLINE static ATTRINLINE fixed_t P_GetSectorCeilingZAt(const sector_t *z_sector, fixed_t x, fixed_t y)
{
return z_sector->c_slope ? P_GetZAt(z_sector->c_slope, x, y) : z_sector->ceilingheight;
}
// Returns the height of the FOF top at (x, y)
FUNCINLINE static ATTRINLINE fixed_t P_GetFFloorTopZAt(const ffloor_t *z_ffloor, fixed_t x, fixed_t y)
{
return *z_ffloor->t_slope ? P_GetZAt(*z_ffloor->t_slope, x, y) : *z_ffloor->topheight;
}
// Returns the height of the FOF bottom at (x, y)
FUNCINLINE static ATTRINLINE fixed_t P_GetFFloorBottomZAt(const ffloor_t *z_ffloor, fixed_t x, fixed_t y)
{
return *z_ffloor->b_slope ? P_GetZAt(*z_ffloor->b_slope, x, y) : *z_ffloor->bottomheight;
}
// Returns the height of the light list at (x, y)
fixed_t P_GetLightZAt(const lightlist_t *light, fixed_t x, fixed_t y);
FUNCINLINE static ATTRINLINE fixed_t P_GetLightZAt(const lightlist_t *z_light, fixed_t x, fixed_t y)
{
return z_light->slope ? P_GetZAt(z_light->slope, x, y) : z_light->height;
}
// Lots of physics-based bullshit
void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope);
+41 -65
View File
@@ -35,7 +35,7 @@
#include "hu_stuff.h"
#include "m_misc.h"
#include "m_cond.h" //unlock triggers
#include "lua_hook.h" // LUAh_LinedefExecute
#include "lua_hook.h" // LUA_HookLinedefExecute
#include "k_kart.h" // SRB2kart
#include "console.h" // CON_LogMessage
@@ -1431,12 +1431,14 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
}
else if (caller)
{
if (GETSECSPECIAL(caller->special, 2) == 6)
INT32 special = GETSECSPECIAL(caller->special, 2);
if (special == 6)
{
if (!(ALL7EMERALDS(emeralds)))
return false;
}
else if (GETSECSPECIAL(caller->special, 2) == 7) // SRB2Kart: reusing for Race Lap executor
else if (special == 7) // SRB2Kart: reusing for Race Lap executor
{
UINT8 lap;
@@ -1470,7 +1472,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
// If we were not triggered by a sector type especially for the purpose,
// a Linedef Executor linedef trigger is not handling sector triggers properly, return.
else if ((!GETSECSPECIAL(caller->special, 2) || GETSECSPECIAL(caller->special, 2) > 7) && (specialtype > 322))
else if ((!special || special > 7) && (specialtype > 322))
{
CONS_Alert(CONS_WARNING,
M_GetText("Linedef executor trigger isn't handling sector triggers properly!\nspecialtype = %d, if you are not a dev, report this warning instance\nalong with the wad that caused it!\n"),
@@ -1805,27 +1807,23 @@ void P_SwitchWeather(INT32 weathernum)
precipmobj = (precipmobj_t *)think;
mobjtype_t type = 0;
INT32 z = 0;
if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse.
{
precipmobj->precipflags |= PCF_INVISIBLE;
continue;
}
if (swap == PRECIP_RAIN) // Snow To Rain
{
precipmobj->type = MT_RAIN; // proper set the type
precipmobj->info = &mobjinfo[MT_RAIN];
precipmobj->flags = mobjinfo[MT_RAIN].flags;
st = &states[mobjinfo[MT_RAIN].spawnstate];
precipmobj->state = st;
precipmobj->tics = st->tics;
precipmobj->sprite = st->sprite;
precipmobj->frame = st->frame;
precipmobj->momz = cv_mobjscaleprecip.value ? FixedMul(mobjinfo[MT_RAIN].speed, mapobjectscale) : mobjinfo[MT_RAIN].speed;
precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to
type = MT_RAIN;
}
else if (swap == PRECIP_SNOW) // Rain To Snow
{
INT32 z;
type = MT_SNOWFLAKE;
precipmobj->type = MT_SNOWFLAKE; // proper set the type
precipmobj->info = &mobjinfo[MT_SNOWFLAKE];
precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags;
z = M_RandomByte();
if (z < 64)
@@ -1834,92 +1832,69 @@ void P_SwitchWeather(INT32 weathernum)
z = 1;
else
z = 0;
st = &states[mobjinfo[MT_SNOWFLAKE].spawnstate+z];
precipmobj->state = st;
precipmobj->tics = st->tics;
precipmobj->sprite = st->sprite;
precipmobj->frame = st->frame;
precipmobj->momz = cv_mobjscaleprecip.value ? FixedMul(mobjinfo[MT_SNOWFLAKE].speed, mapobjectscale) : mobjinfo[MT_SNOWFLAKE].speed;
precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to
}
else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse.
{
precipmobj->precipflags |= PCF_INVISIBLE;
}
precipmobj->type = type; // proper set the type
precipmobj->info = &mobjinfo[type];
precipmobj->flags = mobjinfo[type].flags;
st = &states[mobjinfo[type].spawnstate+z];
precipmobj->state = st;
precipmobj->tics = st->tics;
precipmobj->sprite = st->sprite;
precipmobj->frame = st->frame;
precipmobj->momz = (cv_mobjscaleprecip.value ? FixedMul(mobjinfo[type].speed, mapobjectscale) : mobjinfo[type].speed);
precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to
}
}
boolean dontspawn = false;
switch (weathernum)
{
case PRECIP_SNOW: // snow
curWeather = PRECIP_SNOW;
if (!swap)
P_SpawnPrecipitation();
break;
case PRECIP_RAIN: // rain
{
boolean dontspawn = false;
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES)
dontspawn = true;
curWeather = PRECIP_RAIN;
if (!dontspawn && !swap)
P_SpawnPrecipitation();
break;
}
case PRECIP_STORM: // storm
{
boolean dontspawn = false;
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES)
dontspawn = true;
curWeather = PRECIP_STORM;
if (!dontspawn && !swap)
P_SpawnPrecipitation();
break;
}
case PRECIP_STORM_NOSTRIKES: // storm w/o lightning
{
boolean dontspawn = false;
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES)
dontspawn = true;
curWeather = PRECIP_STORM_NOSTRIKES;
if (!dontspawn && !swap)
P_SpawnPrecipitation();
break;
}
case PRECIP_STORM_NORAIN: // storm w/o rain
curWeather = PRECIP_STORM_NORAIN;
if (!swap)
P_SpawnPrecipitation();
break;
case PRECIP_BLANK:
curWeather = PRECIP_BLANK;
if (!swap)
P_SpawnPrecipitation();
break;
default:
dontspawn = true;
curWeather = PRECIP_NONE;
break;
}
if (!dontspawn && !swap)
P_SpawnPrecipitation();
}
/** Gets an object.
@@ -2084,6 +2059,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
mo->y += y;
mo->z += z;
P_SetThingPosition(mo);
mo->old_x = mo->x;
mo->old_y = mo->y;
mo->old_z = mo->z;
if (mo->player)
{
@@ -2102,7 +2080,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
camera[i].reset = true;
camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y);
R_RelativeTeleportViewInterpolation(i, x, y, z, 0);
R_ResetViewInterpolation(i + 1); // reset view interp as well
break;
}
}
@@ -2520,7 +2497,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (displayplayers[i] == (mo->player - players))
{
R_ResetViewInterpolation(i + 1);
R_ResetViewInterpolation(i + 1);
}
}
}
@@ -2855,7 +2831,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 443: // Calls a named Lua function
if (line->text)
LUAh_LinedefExecute(line, mo, callsec);
LUA_HookLinedefExecute(line, mo, callsec);
else
CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(line-lines));
break;
+69 -28
View File
@@ -196,6 +196,8 @@ void P_AddThinker(thinker_t *thinker)
thinkercap.prev = thinker;
thinker->references = 0; // killough 11/98: init reference counter to 0
thinker->cachable = (thinker->function.acp1 == (actionf_p1)P_MobjThinker);
}
//
@@ -235,7 +237,17 @@ void P_RemoveThinkerDelayed(thinker_t *thinker)
* thinker->prev->next = thinker->next */
(next->prev = currentthinker = thinker->prev)->next = next;
R_DestroyLevelInterpolators(thinker);
Z_Free(thinker);
if (thinker->cachable == true)
{
// put cachable thinkers in the mobj cache, so we can avoid allocations
((mobj_t *)thinker)->hnext = mobjcache;
mobjcache = (mobj_t *)thinker;
}
else
{
Z_Free(thinker);
}
}
//
@@ -250,9 +262,20 @@ void P_UnlinkThinker(thinker_t *thinker)
I_Assert(thinker->references == 0);
(next->prev = thinker->prev)->next = next;
Z_Free(thinker);
if (thinker->cachable == true)
{
// put cachable thinkers in the mobj cache, so we can avoid allocations
((mobj_t *)thinker)->hnext = mobjcache;
mobjcache = (mobj_t *)thinker;
}
else
{
Z_Free(thinker);
}
}
//
// P_RemoveThinker
//
@@ -327,7 +350,7 @@ static inline void P_RunThinkers(void)
}
}
static inline void P_DeviceRumbleTick(void)
static void P_DeviceRumbleTick(void)
{
UINT8 i;
@@ -345,7 +368,7 @@ static inline void P_DeviceRumbleTick(void)
if (!P_IsLocalPlayer(player))
continue;
if (G_GetDeviceForPlayer(i) == 0)
if (cv_usejoystick[i].value == 0)
continue;
if (!playeringame[displayplayers[i]] || player->spectator)
@@ -397,7 +420,7 @@ void P_RunChaseCameras(void)
}
}
static inline void P_RunQuakes(void)
static void P_RunQuakes(void)
{
fixed_t ir;
@@ -434,10 +457,21 @@ void P_Ticker(boolean run)
{
INT32 i;
//Increment jointime even if paused.
// Increment jointime even if paused
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
++players[i].jointime;
{
players[i].jointime++;
}
}
if (run)
{
// Update old view state BEFORE ticking so resetting
// the old interpolation state from game logic works.
R_UpdateViewInterpolation();
}
if (objectplacing)
{
@@ -463,8 +497,8 @@ void P_Ticker(boolean run)
timeinmap = (timeinmap-1) & ~3;
G_PreviewRewind(leveltime);
}
else if (demo.freecam && democam.cam) // special case: allow freecam to MOVE during pause!
P_DemoCameraMovement(democam.cam);
else
P_RunChaseCameras(); // special case: allow freecam to MOVE during pause!
return;
}
@@ -517,7 +551,7 @@ void P_Ticker(boolean run)
ps_checkposition_calls.value.i = 0;
PS_START_TIMING(ps_lua_prethinkframe_time);
LUAh_PreThinkFrame();
LUA_HookPreThinkFrame();
PS_STOP_TIMING(ps_lua_prethinkframe_time);
PS_START_TIMING(ps_playerthink_time);
@@ -553,7 +587,7 @@ void P_Ticker(boolean run)
}
PS_START_TIMING(ps_lua_thinkframe_time);
LUAh_ThinkFrame();
LUA_HookThinkFrame();
PS_STOP_TIMING(ps_lua_thinkframe_time);
}
@@ -629,14 +663,17 @@ void P_Ticker(boolean run)
G_WriteAllGhostTics();
if (cv_recordmultiplayerdemos.value && (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE))
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (cv_usejoystick.value && axis > 0)))
demo.savemode = DSM_TITLEENTRY;
if (cv_recordmultiplayerdemos.value)
{
if (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE)
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (cv_usejoystick[0].value && axis > 0)))
demo.savemode = DSM_TITLEENTRY;
//if there are no players left at all, stop demo recording
//Demos that that dont have any players crash during playback, which can happen with dedicated servers
if (cv_recordmultiplayerdemos.value && demo.savemode == DSM_WILLAUTOSAVE && !D_NumPlayers())
G_SaveDemo();
// if there are no players left at all, stop demo recording
// Demos that that dont have any players crash during playback, which can happen with dedicated servers
if (demo.savemode == DSM_WILLAUTOSAVE && !D_NumPlayers())
G_ResetDemoRecording();
}
}
else if (demo.playback) // Use Ghost data for consistency checks.
{
@@ -657,11 +694,14 @@ void P_Ticker(boolean run)
D_MapChange(gamemap, gametype, encoremode, true, 0, false, false);
PS_START_TIMING(ps_lua_postthinkframe_time);
LUAh_PostThinkFrame();
LUA_HookPostThinkFrame();
PS_STOP_TIMING(ps_lua_postthinkframe_time);
}
K_UpdateDirector();
for (i = 0; i <= splitscreen; i++)
{
K_UpdateDirector(i);
}
// Always move the camera.
P_RunChaseCameras();
@@ -669,7 +709,6 @@ void P_Ticker(boolean run)
if (run)
{
R_UpdateLevelInterpolators();
R_UpdateViewInterpolation();
// Hack: ensure newview is assigned every tic.
// Ensures view interpolation is T-1 to T in poor network conditions
@@ -679,16 +718,18 @@ void P_Ticker(boolean run)
for (i = 0; i <= splitscreen; i++)
{
player_t *player = &players[displayplayers[i]];
boolean isSkyVisibleForPlayer = skyVisiblePerPlayer[i];
if (!player->mo)
continue;
if (isSkyVisibleForPlayer && skyboxmo[0] && cv_skybox.value)
const boolean skybox = (skyboxmo[0] && cv_skybox.value);
if (skyVisiblePerPlayer[i] && skybox)
{
R_SkyboxFrame(player);
R_SkyboxFrame(i);
}
R_SetupFrame(player, (skyboxmo[0] && cv_skybox.value));
R_SetupFrame(i, skybox);
}
}
}
@@ -713,7 +754,7 @@ void P_PreTicker(INT32 frames)
R_UpdateMobjInterpolators();
LUAh_PreThinkFrame();
LUA_HOOK(PreThinkFrame);
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
@@ -742,7 +783,7 @@ void P_PreTicker(INT32 frames)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
P_PlayerAfterThink(&players[i]);
LUAh_ThinkFrame();
LUA_HookThinkFrame();
P_RunOverlays();
P_RunShadows();
@@ -750,7 +791,7 @@ void P_PreTicker(INT32 frames)
P_UpdateSpecials();
P_RespawnSpecials();
LUAh_PostThinkFrame();
LUA_HOOK(PostThinkFrame);
R_UpdateLevelInterpolators();
R_UpdateViewInterpolation();
+309 -282
View File
@@ -427,8 +427,6 @@ void P_ResetPlayer(player_t *player)
player->powers[pw_tailsfly] = 0;
player->onconveyor = 0;
player->skidtime = 0;
/*if (player-players == consoleplayer && botingame)
CV_SetValue(&cv_analog2, true);*/
}
//
@@ -508,8 +506,6 @@ void P_DoSuperTransformation(player_t *player, boolean giverings)
// Adds to the player's score
void P_AddPlayerScore(player_t *player, UINT32 amount)
{
//UINT32 oldscore;
if (!(G_BattleGametype()))
return;
@@ -519,8 +515,6 @@ void P_AddPlayerScore(player_t *player, UINT32 amount)
if (player->exiting) // srb2kart
return;
//oldscore = player->score;
// Don't go above MAXSCORE.
if (player->marescore + amount < MAXSCORE)
player->marescore += amount;
@@ -743,7 +737,7 @@ void P_RestoreMusic(player_t *player)
return;
if (leveltime < MUSICSTARTTIME)
S_StartMapMusic(true);
S_StartMapMusic();
else // see also where time overs are handled - search for "lives = 2" in this file
{
INT32 wantedmus = 0; // 0 is level music, 1 is invincibility, 2 is grow
@@ -1064,6 +1058,15 @@ boolean P_IsDisplayPlayer(const player_t *player)
for (i = 0; i <= splitscreen; i++) // DON'T skip P1
{
if (camera[i].freecam)
{
// Freecam still techically has a player in
// displayplayers. But since the camera is
// detached, it would be weird if sounds were
// heard from that player's perspective.
continue;
}
if (player == &players[displayplayers[i]])
return true;
}
@@ -2341,8 +2344,6 @@ static void P_MovePlayer(player_t *player)
if (maptol & TOL_2D)
runspd = FixedMul(runspd, 2*FRACUNIT/3);
//P_SkidStuff(player);
/////////////////////////
// MOVEMENT ANIMATIONS //
/////////////////////////
@@ -2976,34 +2977,34 @@ camera_t camera[MAXSPLITSCREENPLAYERS]; // Four cameras, three for splitscreen
static void CV_CamRotate_OnChange(void)
{
if (cv_cam_rotate.value < 0)
CV_SetValue(&cv_cam_rotate, cv_cam_rotate.value + 360);
else if (cv_cam_rotate.value > 359)
CV_SetValue(&cv_cam_rotate, cv_cam_rotate.value % 360);
if (cv_cam_rotate[0].value < 0)
CV_SetValue(&cv_cam_rotate[0], cv_cam_rotate[0].value + 360);
else if (cv_cam_rotate[0].value > 359)
CV_SetValue(&cv_cam_rotate[0], cv_cam_rotate[0].value % 360);
}
static void CV_CamRotate2_OnChange(void)
{
if (cv_cam2_rotate.value < 0)
CV_SetValue(&cv_cam2_rotate, cv_cam2_rotate.value + 360);
else if (cv_cam2_rotate.value > 359)
CV_SetValue(&cv_cam2_rotate, cv_cam2_rotate.value % 360);
if (cv_cam_rotate[1].value < 0)
CV_SetValue(&cv_cam_rotate[1], cv_cam_rotate[1].value + 360);
else if (cv_cam_rotate[1].value > 359)
CV_SetValue(&cv_cam_rotate[1], cv_cam_rotate[1].value % 360);
}
static void CV_CamRotate3_OnChange(void)
{
if (cv_cam3_rotate.value < 0)
CV_SetValue(&cv_cam3_rotate, cv_cam3_rotate.value + 360);
else if (cv_cam3_rotate.value > 359)
CV_SetValue(&cv_cam3_rotate, cv_cam3_rotate.value % 360);
if (cv_cam_rotate[2].value < 0)
CV_SetValue(&cv_cam_rotate[2], cv_cam_rotate[2].value + 360);
else if (cv_cam_rotate[2].value > 359)
CV_SetValue(&cv_cam_rotate[2], cv_cam_rotate[2].value % 360);
}
static void CV_CamRotate4_OnChange(void)
{
if (cv_cam4_rotate.value < 0)
CV_SetValue(&cv_cam4_rotate, cv_cam4_rotate.value + 360);
else if (cv_cam4_rotate.value > 359)
CV_SetValue(&cv_cam4_rotate, cv_cam4_rotate.value % 360);
if (cv_cam_rotate[3].value < 0)
CV_SetValue(&cv_cam_rotate[3], cv_cam_rotate[3].value + 360);
else if (cv_cam_rotate[3].value > 359)
CV_SetValue(&cv_cam_rotate[3], cv_cam_rotate[3].value % 360);
}
static CV_PossibleValue_t CV_CamSpeed[] = {{0, "MIN"}, {1*FRACUNIT, "MAX"}, {0, NULL}};
@@ -3074,33 +3075,50 @@ static void CV_PlayerCam4_OnChange(void)
P_ResetCamera(&players[displayplayers[3]], &camera[3]);
}
consvar_t cv_cam_dist = {"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_height = {"cam_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_still = {"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_speed = {"cam_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_rotate = {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_rotspeed = {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS] = {
{"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam3_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam4_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_cam2_dist = {"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_height = {"cam2_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_still = {"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_speed = {"cam2_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_rotate = {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_rotspeed = {"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_height[MAXSPLITSCREENPLAYERS] = {
{"cam_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam2_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam3_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam4_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL},
};
consvar_t cv_cam3_dist = {"cam3_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_height = {"cam3_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_still = {"cam3_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_speed = {"cam3_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_rotate = {"cam3_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_rotspeed = {"cam3_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS] = {
{"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam3_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam4_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_cam4_dist = {"cam4_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_height = {"cam4_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_still = {"cam4_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_speed = {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_rotspeed = {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS] = {
{"cam_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam3_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS] = {
{"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam3_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS] = {
{"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam3_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}
};
static CV_PossibleValue_t freecam_speed_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}};
consvar_t cv_freecam_speed = {"freecam_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_tilting = {"tilting", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_quaketilt = {"quaketilt", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -3111,76 +3129,83 @@ consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NU
static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Double"}, {0, NULL}};
consvar_t cv_lookbackmom = {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
fixed_t t_cam_dist = -42;
fixed_t t_cam_height = -42;
fixed_t t_cam_rotate = -42;
fixed_t t_cam2_dist = -42;
fixed_t t_cam2_height = -42;
fixed_t t_cam2_rotate = -42;
fixed_t t_cam3_dist = -42;
fixed_t t_cam3_height = -42;
fixed_t t_cam3_rotate = -42;
fixed_t t_cam4_dist = -42;
fixed_t t_cam4_height = -42;
fixed_t t_cam4_rotate = -42;
fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42};
#define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode)
// Heavily simplified version of G_BuildTicCmd that only takes the local first player's control input and converts it to readable ticcmd_t
// we then throw that ticcmd garbage in the camera and make it move
// redefine this
static fixed_t forwardmove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16};
static fixed_t sidemove[2] = {2<<FRACBITS>>16, 4<<FRACBITS>>16};
static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn
static ticcmd_t cameracmd;
struct demofreecam_s democam;
// called by m_menu to reinit cam input every time it's toggled
void P_InitCameraCmd(void)
void P_ToggleDemoCamera(UINT8 viewnum)
{
memset(&cameracmd, 0, sizeof(ticcmd_t)); // initialize cmd
camera_t *cam = &camera[viewnum];
// dont let freecam be toggled when in spec lel
if (players[displayplayers[viewnum]].spectator)
return;
if (!cam->freecam) // toggle on
{
cam->freecam = true;
cam->button_a_held = 2;
cam->reset_aiming = true;
}
else // toggle off
{
cam->freecam = false;
}
}
static ticcmd_t *P_CameraCmd(camera_t *cam)
static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS];
static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num)
{
INT32 laim, th, tspeed, forward, side, axis; //i
const INT32 speed = 1;
INT32 laim, forward, side, axis;
// these ones used for multiple conditions
boolean turnleft, turnright, mouseaiming;
boolean invertmouse, lookaxis, usejoystick, kbl;
boolean turnleft, turnright;
boolean usejoystick;
angle_t lang;
INT32 player_invert;
INT32 screen_invert;
const UINT8 forplayer = num+1;
ticcmd_t *cmd = &cameracmd;
memset(&cameracmd[num], 0, sizeof(ticcmd_t)); // initialize cmd
(void)cam;
ticcmd_t *cmd = &cameracmd[num];
if (!demo.playback)
return cmd; // empty cmd, no.
lang = cam->localangle;
laim = cam->localaiming;
lang = democam.localangle;
laim = democam.localaiming;
th = democam.turnheld;
kbl = democam.keyboardlook;
G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver
switch (num)
{
case 1:
G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1);
break;
case 2:
G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1);
break;
case 3:
G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1);
break;
case 0:
default:
G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver
break;
}
cmd->angleturn = (INT16)(lang >> 16);
cmd->aiming = G_ClipAimingPitch(&laim);
mouseaiming = true;
invertmouse = cv_invertmouse.value;
lookaxis = cv_lookaxis.value;
const boolean lookaxis = cv_lookaxis[num].value;
const boolean analogjoystickmove = cv_usejoystick[num].value && !Joystick[num].bGamepadStyle;
const boolean gamepadjoystickmove = cv_usejoystick[num].value && Joystick[num].bGamepadStyle;
usejoystick = true;
turnright = InputDown(gc_turnright, 1);
turnleft = InputDown(gc_turnleft, 1);
usejoystick = (analogjoystickmove || gamepadjoystickmove);
axis = JoyAxis(AXISTURN, 1);
turnright = InputDown(gc_turnright, forplayer);
turnleft = InputDown(gc_turnleft, forplayer);
axis = JoyAxis(AXISTURN, forplayer);
if (encoremode)
{
@@ -3190,84 +3215,65 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
axis = -axis;
}
if (axis != 0)
if (gamepadjoystickmove && axis != 0)
{
turnright = turnright || (axis > 0);
turnleft = turnleft || (axis < 0);
}
forward = side = 0;
// use two stage accelerative turning
// on the keyboard and joystick
if (turnleft || turnright)
th += 1;
else
th = 0;
if (th < SLOWTURNTICS)
tspeed = 2; // slow turn
else
tspeed = speed;
// let movement keys cancel each other out
if (turnright && !(turnleft))
{
cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed]));
cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1]));
side += sidemove[1];
}
else if (turnleft && !(turnright))
{
cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed]));
cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1]));
side -= sidemove[1];
}
if (analogjoystickmove && axis != 0)
{
// JOYAXISRANGE should be 1023 (divide by 1024)
cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG!
side += ((axis * sidemove[0]) >> 10);
}
cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8)));
axis = JoyAxis(AXISMOVE, 1);
if (InputDown(gc_accelerate, 1) || (usejoystick && axis > 0))
cmd->buttons |= BT_ACCELERATE;
axis = JoyAxis(AXISBRAKE, 1);
if (InputDown(gc_brake, 1) || (usejoystick && axis > 0))
cmd->buttons |= BT_BRAKE;
axis = JoyAxis(AXISAIM, 1);
if (InputDown(gc_aimforward, 1) || (usejoystick && axis < 0))
axis = JoyAxis(AXISAIM, forplayer);
if (InputDown(gc_aimforward, forplayer) || (usejoystick && axis < 0))
forward += forwardmove[1];
if (InputDown(gc_aimbackward, 1) || (usejoystick && axis > 0))
if (InputDown(gc_aimbackward, forplayer) || (usejoystick && axis > 0))
forward -= forwardmove[1];
// fire with any button/key
axis = JoyAxis(AXISFIRE, 1);
axis = JoyAxis(AXISFIRE, forplayer);
if (InputDown(gc_fire, 1) || (usejoystick && axis > 0))
cmd->buttons |= BT_ATTACK;
// spectator aiming shit, ahhhh...
player_invert = invertmouse ? -1 : 1;
screen_invert = 1; // nope
// mouse look stuff (mouse look is not the same as mouse aim)
kbl = false;
// looking up/down
laim += (mlooky<<19)*player_invert*screen_invert;
laim += (mlooky<<19);
axis = JoyAxis(AXISLOOK, 1);
axis = JoyAxis(AXISLOOK, forplayer);
// spring back if not using keyboard neither mouselookin'
if (!kbl && !lookaxis && !mouseaiming)
laim = 0;
if (analogjoystickmove && axis != 0 && lookaxis)
laim += (axis<<16);
if (InputDown(gc_lookup, 1) || (axis < 0))
if (InputDown(gc_lookup, forplayer) || (gamepadjoystickmove && axis < 0))
{
laim += KB_LOOKSPEED * screen_invert;
kbl = true;
laim += KB_LOOKSPEED;
}
else if (InputDown(gc_lookdown, 1) || (axis > 0))
else if (InputDown(gc_lookdown, forplayer) || (gamepadjoystickmove && axis > 0))
{
laim -= KB_LOOKSPEED * screen_invert;
kbl = true;
laim -= KB_LOOKSPEED;
}
if (InputDown(gc_centerview, 1)) // No need to put a spectator limit on this one though :V
if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V
laim = 0;
cmd->aiming = G_ClipAimingPitch(&laim);
@@ -3292,38 +3298,66 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
lang += (cmd->angleturn<<16);
democam.localangle = lang;
democam.localaiming = laim;
democam.turnheld = th;
democam.keyboardlook = kbl;
cam->localangle = lang;
cam->localaiming = laim;
return cmd;
}
void P_DemoCameraMovement(camera_t *cam)
#define intsign(n) \
((n) < 0 ? -1 : (n) > 0 ? 1 : 0)
static void P_DemoCameraMovement(camera_t *cam, UINT8 num)
{
ticcmd_t *cmd;
angle_t thrustangle;
mobj_t *awayviewmobj_hack;
player_t *lastp;
const UINT8 forplayer = num+1;
boolean moving = false;
// update democam stuff with what we got here:
democam.cam = cam;
democam.localangle = cam->angle;
democam.localaiming = cam->aiming;
cam->localangle = cam->angle;
cam->localaiming = cam->aiming;
// first off we need to get button input
cmd = P_CameraCmd(cam);
cmd = P_CameraCmd(cam, num);
cam->aiming = cmd->aiming<<FRACBITS;
cam->angle = cmd->angleturn<<16;
// let centerview work proper
if (InputDown(gc_centerview, forplayer))
cam->aiming = 0;
if (cmd->aiming != 0)
{
cam->aiming = cmd->aiming << FRACBITS;
cam->reset_aiming = false;
}
cam->angle = cmd->angleturn << 16;
// camera movement:
if (!cam->button_a_held)
{
fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value;
int dir = ((InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((InputDown(gc_camsink, forplayer)) ? -1 : 0);
if (cmd->buttons & BT_ACCELERATE)
cam->z += 32*mapobjectscale;
else if (cmd->buttons & BT_BRAKE)
cam->z -= 32*mapobjectscale;
switch (dir)
{
case 1:
cam->z += spd;
moving = true;
break;
case -1:
cam->z -= spd;
moving = true;
break;
}
}
if (!(InputDown(gc_camfloat, forplayer) || InputDown(gc_camsink, forplayer)) && cam->button_a_held)
{
cam->button_a_held--;
}
// if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"")
if (cmd->buttons & BT_ATTACK)
@@ -3331,41 +3365,70 @@ void P_DemoCameraMovement(camera_t *cam)
lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot.
cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y);
cam->aiming = R_PointToAngle2(0, cam->z, R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y), lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads.
cam->reset_aiming = false;
}
if (cmd->forwardmove != 0)
{
moving = true;
}
// After switching to democam, the vertical angle of
// chasecam is inherited. This is intentional because it
// creates a smooth transition. However, moving
// forward/back will have a slope. So, as long as democam
// controls haven't been used to alter the vertical angle,
// slowly reset it to flat.
if ((cam->reset_aiming && moving) || ((InputDown(gc_camsink, forplayer)) && !cam->button_a_held))
{
INT32 aiming = cam->aiming;
INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming));
if (abs(smooth) < abs(aiming))
{
cam->aiming -= smooth * intsign(aiming);
}
else
{
cam->aiming = 0;
cam->reset_aiming = false; // completely smoothed out
}
}
cam->momx = cam->momy = cam->momz = 0;
if (cmd->forwardmove != 0)
{
fixed_t spd = cmd->forwardmove*mapobjectscale*cv_freecam_speed.value;
thrustangle = cam->angle >> ANGLETOFINESHIFT;
cam->x += FixedMul(cmd->forwardmove*mapobjectscale, FINECOSINE(thrustangle));
cam->y += FixedMul(cmd->forwardmove*mapobjectscale, FINESINE(thrustangle));
cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming));
cam->x += FixedMul(spd, FINECOSINE(thrustangle));
cam->y += FixedMul(spd, FINESINE(thrustangle));
if (!cam->reset_aiming)
{
cam->z += FixedMul(spd, AIMINGTOSLOPE(cam->aiming));
}
// momentums are useless here, directly add to the coordinates
// this.......... doesn't actually check for floors and walls and whatnot but the function to do that is a pure mess so fuck that.
// besides freecam going inside walls sounds pretty cool on paper.
}
// awayviewmobj hack; this is to prevent us from hearing sounds from the player's perspective
awayviewmobj_hack = P_SpawnMobj(cam->x, cam->y, cam->z, MT_THOK);
awayviewmobj_hack->tics = 2;
awayviewmobj_hack->flags2 |= MF2_DONTDRAW;
democam.soundmobj = awayviewmobj_hack;
// update subsector to avoid crashes;
cam->subsector = R_PointInSubsector(cam->x, cam->y);
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y);
}
#undef intsign
void P_ResetCamera(player_t *player, camera_t *thiscam)
{
tic_t tries = 0;
fixed_t x, y, z;
if (demo.freecam)
if (thiscam->freecam)
return; // do not reset the camera there.
if (!player->mo)
@@ -3388,21 +3451,24 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
thiscam->z = z;
thiscam->reset = true;
if (!(thiscam == &camera[0] && (cv_cam_still.value || cv_analog.value))
&& !(thiscam == &camera[1] && (cv_cam2_still.value || cv_analog2.value))
&& !(thiscam == &camera[2] && (cv_cam3_still.value || cv_analog3.value))
&& !(thiscam == &camera[3] && (cv_cam4_still.value || cv_analog4.value)))
if (!(thiscam == &camera[0] && (cv_cam_still[0].value))
&& !(thiscam == &camera[1] && (cv_cam_still[1].value))
&& !(thiscam == &camera[2] && (cv_cam_still[2].value))
&& !(thiscam == &camera[3] && (cv_cam_still[3].value)))
{
thiscam->angle = player->mo->angle;
thiscam->aiming = 0;
}
thiscam->relativex = 0;
thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y);
thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y);
thiscam->radius = 20*FRACUNIT;
thiscam->height = 16*FRACUNIT;
thiscam->reset_aiming = true;
while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE);
}
@@ -3410,7 +3476,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
{
static boolean lookbackactive[MAXSPLITSCREENPLAYERS];
static UINT8 lookbackdelay[MAXSPLITSCREENPLAYERS];
UINT8 num;
UINT8 num, plyrnum;
angle_t angle = 0, focusangle = 0, focusaiming = 0;
fixed_t x, y, z, dist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight;
fixed_t pan, xpan, ypan;
@@ -3424,8 +3490,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
subsector_t *newsubsec;
#endif
democam.soundmobj = NULL; // reset this each frame, we don't want the game crashing for stupid reasons now do we
// We probably shouldn't move the camera if there is no player or player mobj somehow
if (!player || !player->mo)
return true;
@@ -3434,12 +3498,53 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL)
return true;
if (demo.freecam)
if (thiscam == &camera[1]) // Camera 2
{
P_DemoCameraMovement(thiscam);
num = 1;
}
else if (thiscam == &camera[2]) // Camera 3
{
num = 2;
}
else if (thiscam == &camera[3]) // Camera 4
{
num = 3;
}
else // Camera 1
{
num = 0;
}
if (thiscam->freecam || player->spectator)
{
P_DemoCameraMovement(thiscam, num);
return true;
}
if (paused || P_AutoPause())
return true;
if (player == &players[consoleplayer])
{
plyrnum = 0;
}
else if (player == &players[displayplayers[1]])
{
plyrnum = 1;
}
else if (player == &players[displayplayers[2]])
{
plyrnum = 2;
}
else if (player == &players[displayplayers[3]])
{
plyrnum = 3;
}
else
{
plyrnum = 255;
}
mo = player->mo;
#ifndef NOCLIPCAM
@@ -3458,40 +3563,23 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (player->spectator) // force cam off for spectators
return true;
if (!cv_chasecam.value && thiscam == &camera[0])
return true;
if (!cv_chasecam2.value && thiscam == &camera[1])
return true;
if (!cv_chasecam3.value && thiscam == &camera[2])
return true;
if (!cv_chasecam4.value && thiscam == &camera[3])
if (!cv_chasecam[num].value && thiscam == &camera[num])
return true;
}
if (!thiscam->chase && !resetcalled)
{
if (player == &players[consoleplayer])
focusangle = localangle[0];
else if (player == &players[displayplayers[1]])
focusangle = localangle[1];
else if (player == &players[displayplayers[2]])
focusangle = localangle[2];
else if (player == &players[displayplayers[3]])
focusangle = localangle[3];
if (plyrnum != 255)
{
focusangle = localangle[plyrnum];
}
else
{
focusangle = mo->angle;
}
if (thiscam == &camera[0])
camrotate = cv_cam_rotate.value;
else if (thiscam == &camera[1])
camrotate = cv_cam2_rotate.value;
else if (thiscam == &camera[2])
camrotate = cv_cam3_rotate.value;
else if (thiscam == &camera[3])
camrotate = cv_cam4_rotate.value;
if (thiscam == &camera[num])
camrotate = cv_cam_rotate[num].value;
else
camrotate = 0;
@@ -3509,35 +3597,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
thiscam->radius = 20*mapobjectscale;
thiscam->height = 16*mapobjectscale;
// Don't run while respawning from a starpost
// Inu 4/8/13 Why not?!
// if (leveltime > 0 && timeinmap <= 0)
// return true;
if (demo.playback)
{
focusangle = mo->angle;
focusaiming = 0;
}
else if (player == &players[consoleplayer])
else if (plyrnum != 255)
{
focusangle = localangle[0];
focusaiming = localaiming[0];
}
else if (player == &players[displayplayers[1]])
{
focusangle = localangle[1];
focusaiming = localaiming[1];
}
else if (player == &players[displayplayers[2]])
{
focusangle = localangle[2];
focusaiming = localaiming[2];
}
else if (player == &players[displayplayers[3]])
{
focusangle = localangle[3];
focusaiming = localaiming[3];
focusangle = localangle[plyrnum];
focusaiming = localaiming[plyrnum];
}
else
{
@@ -3548,46 +3616,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (P_CameraThinker(player, thiscam, resetcalled))
return true;
if (thiscam == &camera[1]) // Camera 2
{
num = 1;
camspeed = cv_cam2_speed.value;
camstill = cv_cam2_still.value;
camrotate = cv_cam2_rotate.value;
camdist = FixedMul(cv_cam2_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam2_height.value, mapobjectscale);
lookback = camspin[1];
}
else if (thiscam == &camera[2]) // Camera 3
{
num = 2;
camspeed = cv_cam3_speed.value;
camstill = cv_cam3_still.value;
camrotate = cv_cam3_rotate.value;
camdist = FixedMul(cv_cam3_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam3_height.value, mapobjectscale);
lookback = camspin[2];
}
else if (thiscam == &camera[3]) // Camera 4
{
num = 3;
camspeed = cv_cam4_speed.value;
camstill = cv_cam4_still.value;
camrotate = cv_cam4_rotate.value;
camdist = FixedMul(cv_cam4_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam4_height.value, mapobjectscale);
lookback = camspin[3];
}
else // Camera 1
{
num = 0;
camspeed = cv_cam_speed.value;
camstill = cv_cam_still.value;
camrotate = cv_cam_rotate.value;
camdist = FixedMul(cv_cam_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam_height.value, mapobjectscale);
lookback = camspin[0];
}
camspeed = cv_cam_speed[num].value;
camstill = cv_cam_still[num].value;
camrotate = cv_cam_rotate[num].value;
camdist = FixedMul(cv_cam_dist[num].value, mapobjectscale);
camheight = FixedMul(cv_cam_height[num].value, mapobjectscale);
lookback = camspin[num];
if (timeover)
{
@@ -3651,10 +3685,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
}
if (!resetcalled && (leveltime > starttime && timeover != 2)
&& ((thiscam == &camera[0] && t_cam_rotate != -42)
|| (thiscam == &camera[1] && t_cam2_rotate != -42)
|| (thiscam == &camera[2] && t_cam3_rotate != -42)
|| (thiscam == &camera[3] && t_cam4_rotate != -42)))
&& (thiscam == &camera[num] && t_cam_rotate[num] != -42))
{
angle = FixedAngle(camrotate*FRACUNIT);
thiscam->angle = angle;
@@ -3995,7 +4026,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
{
P_MoveChaseCamera(player, thiscam, false);
R_ResetViewInterpolation(num + 1);
R_ResetViewInterpolation(num + 1);
}
return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming);
@@ -4020,7 +4050,6 @@ boolean P_SpectatorJoinGame(player_t *player)
{
if (P_IsLocalPlayer(player))
CONS_Printf(M_GetText("Server does not allow team change.\n"));
//player->powers[pw_flashing] = TICRATE + 1; //to prevent message spam.
}
// Team changing in Team Match and CTF
// Pressing fire assigns you to a team that needs players if allowed.
@@ -4214,6 +4243,8 @@ void P_DoTimeOver(player_t *player)
player->pflags |= PF_TIMEOVER;
demo.savebutton = leveltime;
if (P_IsLocalPlayer(player) && !demo.playback)
legitimateexit = true; // SRB2kart: losing a race is still seeing it through to the end :p
@@ -4367,7 +4398,7 @@ void P_PlayerThink(player_t *player)
}
if (player->playerstate == PST_REBORN)
{
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
return;
}
}
@@ -4474,7 +4505,7 @@ void P_PlayerThink(player_t *player)
if (player->playerstate == PST_DEAD)
{
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
return;
}
}
@@ -4540,7 +4571,7 @@ void P_PlayerThink(player_t *player)
else
player->mo->flags2 &= ~MF2_SHADOW;
P_DeathThink(player);
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
return;
}
@@ -4712,7 +4743,7 @@ void P_PlayerThink(player_t *player)
if (!player->mo)
{
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
return; // P_MovePlayer removed player->mo.
}
@@ -4724,10 +4755,7 @@ void P_PlayerThink(player_t *player)
if (player->onconveyor == 1)
player->cmomy = player->cmomx = 0;
//P_DoSuperStuff(player);
//P_CheckSneakerAndLivesTimer(player);
P_DoBubbleBreath(player); // Spawn Sonic's bubbles
//P_CheckUnderwaterAndSpaceTimer(player); // Display the countdown drown numbers!
P_CheckInvincibilityTimer(player); // Spawn Invincibility Sparkles
P_DoPlayerHeadSigns(player); // Spawn Tag/CTF signs over player's head
@@ -4895,7 +4923,7 @@ void P_PlayerThink(player_t *player)
if (rendermode != render_none)
DoABarrelRoll(player);
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
}
//
@@ -4946,7 +4974,6 @@ void P_PlayerAfterThink(player_t *player)
if (player->pflags & PF_NIGHTSMODE)
{
player->powers[pw_gravityboots] = 0;
//player->mo->eflags &= ~MFE_VERTICALFLIP;
}
if (player->pflags & PF_SLIDING)
+24 -18
View File
@@ -263,21 +263,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
mobj_t *pviewmobj = viewplayer->mo;
INT32 heightsec;
boolean underwater;
UINT8 i;
for (i = 0; i <= splitscreen; i++)
{
if (viewplayer != &players[displayplayers[i]])
continue;
if (!camera[i].chase)
continue;
UINT8 i = R_GetViewNumber();
if (camera[i].chase)
heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec;
break;
}
if (i > splitscreen && pviewmobj)
else if (i > splitscreen && viewmobj)
heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec;
else
return sec;
@@ -583,10 +573,10 @@ static void R_AddLine(seg_t *line)
clippass:
g_walloffscreen = false;
R_ClipPassWallSegment(x1, x2 - 1, false);
if (g_walloffscreen)
R_ClipPassWallSegment(x1, x2 - 1, true);
else
R_ClipPassWallSegment(x1, x2 - 1, false);
return;
clipsolid:
@@ -627,7 +617,21 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
cliprange_t *start;
// Find the corners of the box that define the edges from current viewpoint.
if ((boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT] ? 1 : 2) + (viewy >= bspcoord[BOXTOP] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8)) == 5)
if (viewx <= bspcoord[BOXLEFT])
boxpos = 0;
else if (viewx < bspcoord[BOXRIGHT])
boxpos = 1;
else
boxpos = 2;
if (viewy >= bspcoord[BOXTOP])
boxpos |= 0;
else if (viewy > bspcoord[BOXBOTTOM])
boxpos |= 1<<2;
else
boxpos |= 2<<2;
if (boxpos == 5)
return true;
check = checkcoord[boxpos];
@@ -656,7 +660,8 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
sx2 = viewangletox[angle2];
// Does not cross a pixel.
if (sx1 >= sx2) return false;
if (sx1 >= sx2)
return false;
start = solidsegs;
while (start->last < sx2)
@@ -1320,7 +1325,8 @@ void R_RenderBSPNode(INT32 bspnum)
bsp = &nodes[bspnum];
// Decide which side the view point is on.
side = R_PointOnSide(viewx, viewy, bsp);
side = R_PointOnSideFast(viewx, viewy, bsp);
// Recursively divide front space.
R_RenderBSPNode(bsp->children[side]);
+34 -23
View File
@@ -23,6 +23,7 @@
#include "r_state.h"
#include "z_zone.h"
#include "console.h" // con_startup_loadprogress
#include "i_time.h"
#ifdef HWRENDER
#include "hardware/hw_main.h" // for cv_grshearing
@@ -79,6 +80,7 @@ static viewvars_t skyview_old[MAXSPLITSCREENPLAYERS];
static viewvars_t skyview_new[MAXSPLITSCREENPLAYERS];
static viewvars_t *oldview = &pview_old[0];
static tic_t last_view_update;
static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
viewvars_t *newview = &pview_new[0];
@@ -89,19 +91,24 @@ static levelinterpolator_t **levelinterpolators;
static size_t levelinterpolators_len;
static size_t levelinterpolators_size;
static inline fixed_t R_LerpFixedView(fixed_t from, fixed_t to, fixed_t frac)
{
return from + FixedMul(frac, to - from);
}
static inline angle_t R_LerpAngleView(angle_t from, angle_t to, fixed_t frac)
{
return from + FixedMul(frac, to - from);
}
static inline fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac)
{
if (from == to)
return to;
return from + FixedMul(frac, to - from);
return ((from == to) ? to : (from + FixedMul(frac, to - from)));
}
static inline angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac)
{
if (from == to)
return to;
return from + FixedMul(frac, to - from);
return ((from == to) ? to : (from + FixedMul(frac, to - from)));
}
/*static vector2_t *R_LerpVector2(const vector2_t *from, const vector2_t *to, fixed_t frac, vector2_t *out)
@@ -151,7 +158,7 @@ static void R_SetupFreelook(void)
void R_InterpolateViewRollAngle(fixed_t frac)
{
viewroll = R_LerpAngle(oldview->roll, newview->roll, frac);
viewroll = R_LerpAngleView(oldview->roll, newview->roll, frac);
}
void R_InterpolateView(fixed_t frac, boolean forceinvalid)
@@ -179,19 +186,19 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid)
prevview = newview;
}
viewx = R_LerpFixed(prevview->x, newview->x, frac);
viewy = R_LerpFixed(prevview->y, newview->y, frac);
viewz = R_LerpFixed(prevview->z, newview->z, frac);
viewx = R_LerpFixedView(prevview->x, newview->x, frac);
viewy = R_LerpFixedView(prevview->y, newview->y, frac);
viewz = R_LerpFixedView(prevview->z, newview->z, frac);
viewangle = R_LerpAngle(prevview->angle, newview->angle, frac);
aimingangle = R_LerpAngle(prevview->aim, newview->aim, frac);
viewroll = R_LerpAngle(prevview->roll, newview->roll, frac);
viewangle = R_LerpAngleView(prevview->angle, newview->angle, frac);
aimingangle = R_LerpAngleView(prevview->aim, newview->aim, frac);
viewroll = R_LerpAngleView(prevview->roll, newview->roll, frac);
viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT);
viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT);
viewplayer = newview->player;
viewsector = R_PointInSubsector(viewx, viewy)->sector;
viewsector = R_PointInSubsectorFast(viewx, viewy)->sector;
R_SetupFreelook();
}
@@ -207,21 +214,27 @@ void R_UpdateViewInterpolation(void)
if (oldview_invalid[i]) oldview_invalid[i]--;
}
last_view_update = I_GetTime();
}
void R_ResetViewInterpolation(UINT8 p)
{
// Wait an extra tic if the interpolation state hasn't
// updated yet.
int t = ((last_view_update == I_GetTime()) ? 1 : 2);
if (p == 0)
{
UINT8 i;
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
oldview_invalid[i]++;
oldview_invalid[i] = t;
}
}
else
{
oldview_invalid[p - 1]++;
oldview_invalid[p - 1] = t;
}
}
@@ -293,7 +306,7 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
out->y = mobj->y;
out->z = mobj->z;
out->scale = mobj->scale;
out->subsector = mobj->subsector;
//out->subsector = mobj->subsector;
out->angle = mobj->player ? mobj->player->frameangle : mobj->angle;
out->pitch = mobj->pitch;
out->roll = mobj->roll;
@@ -314,8 +327,7 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac);
out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac);
out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac);
//out->subsector = R_PointInSubsector(out->x, out->y); // why was this even done?
out->subsector = mobj->subsector;
//out->subsector = R_PointInSubsector(out->x, out->y); // this is unused
if (mobj->player)
out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac);
@@ -323,7 +335,7 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac);
#ifdef HWRENDER
if (cv_glmdls.value)
if (rendermode == render_opengl && cv_glmdls.value)
{
// pitch roll stuff
out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac);
@@ -351,7 +363,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
out->y = mobj->y;
out->z = mobj->z;
out->scale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT;
out->subsector = mobj->subsector;
//out->subsector = mobj->subsector;
out->angle = mobj->angle;
out->spritexscale = mobj->spritexscale;
out->spriteyscale = mobj->spriteyscale;
@@ -368,9 +380,8 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
out->spriteyscale = mobj->spriteyscale;
out->spritexoffset = mobj->spritexoffset;
out->spriteyoffset = mobj->spriteyoffset;
//out->subsector = R_PointInSubsector(out->x, out->y); // this is unused
//out->subsector = R_PointInSubsector(out->x, out->y); // i dont understand lol
out->subsector = mobj->subsector;
out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac);
}
+5 -1
View File
@@ -37,6 +37,10 @@ enum viewcontext_e
VIEWCONTEXT_SKY4
};
extern enum viewcontext_e viewcontext;
#define R_GetViewNumber() ((viewcontext - VIEWCONTEXT_PLAYER1) & 3)
typedef struct {
fixed_t x;
fixed_t y;
@@ -59,7 +63,7 @@ typedef struct {
fixed_t x;
fixed_t y;
fixed_t z;
subsector_t *subsector;
//subsector_t *subsector;
angle_t angle;
fixed_t scale;
fixed_t spritexscale;
+190 -391
View File
@@ -161,14 +161,20 @@ void SendWeaponPref4(void);
static void Precipstuff_OnChange(void);
consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chasecam = {"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chasecam2 = {"chasecam2", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chasecam3 = {"chasecam3", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chasecam4 = {"chasecam4", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_flipcam = {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_flipcam2 = {"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_flipcam3 = {"flipcam3", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam3_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_flipcam4 = {"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam4_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS] = {
{"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"chasecam2", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"chasecam3", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"chasecam4", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS] = {
{"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"flipcam3", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam3_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -292,32 +298,6 @@ static void Precipstuff_OnChange(void)
P_SpawnPrecipitation();
}
//
// R_PointOnSide
// Traverse BSP (sub) tree,
// check point against partition plane.
// Returns side 0 (front) or 1 (back).
//
// killough 5/2/98: reformatted
//
PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *restrict node)
{
if (!node->dx)
return x <= node->x ? node->dy > 0 : node->dy < 0;
if (!node->dy)
return y <= node->y ? node->dx < 0 : node->dx > 0;
x -= node->x;
y -= node->y;
// Try to quickly decide by looking at sign bits.
// also use a mask to avoid branch prediction
INT32 mask = (node->dy ^ node->dx ^ x ^ y) >> 31;
return (mask & ((node->dy ^ x) < 0)) | // (left is negative)
(~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x)));
}
//
// R_PointToAngle
// To get a global angle from cartesian coordinates,
@@ -383,17 +363,19 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y)
angle_t R_PlayerSliptideAngle(player_t *player)
{
mobj_t *mo;
spritedef_t *sprdef;
spriteframe_t *sprframe;
angle_t ang = 0;
spritedef_t *sprdef;
spriteframe_t *sprframe;
angle_t ang = 0;
if (!cv_sliptideroll.value || !player || P_MobjWasRemoved(player->mo))
return 0;
if (!cv_sloperoll.value || !cv_sliptideroll.value || !player || P_MobjWasRemoved(player->mo))
return 0;
mo = player->mo;
mo = player->mo;
size_t rot = mo->frame & FF_FRAMEMASK;
boolean papersprite = (mo->frame & FF_PAPERSPRITE);
if (mo->player->sliproll == 0 || mo->player->kartstuff[k_aizdriftstrat] == 0)
return 0;
size_t rot = (mo->frame & FF_FRAMEMASK);
if (mo->skin && mo->sprite == SPR_PLAY)
{
@@ -410,7 +392,7 @@ angle_t R_PlayerSliptideAngle(player_t *player)
if (rot >= sprdef->numframes)
{
sprdef = &sprites[states[S_UNKNOWN].sprite];
rot = states[S_UNKNOWN].frame&FF_FRAMEMASK;
rot = (states[S_UNKNOWN].frame & FF_FRAMEMASK);
}
sprframe = &sprdef->spriteframes[rot];
@@ -418,10 +400,10 @@ angle_t R_PlayerSliptideAngle(player_t *player)
// No sprite frame? I guess it is possible
if (!sprframe) return 0;
if (sprframe->rotate != SRF_SINGLE || papersprite)
if (sprframe->rotate != SRF_SINGLE || (mo->frame & FF_PAPERSPRITE))
ang = R_PointToAngle(mo->x, mo->y) - mo->angle;
return FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mo->player->sliproll*(mo->player->sliptidemem));
return FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mo->player->sliproll * mo->player->kartstuff[k_aizdriftstrat]);
}
INT32 R_GetHudUncap(void)
@@ -859,6 +841,7 @@ static inline int intsign(int n) {
angle_t R_ViewRollAngle(const player_t *player)
{
angle_t roll = 0;
const UINT8 viewnum = R_GetViewNumber();
if (gamestate != GS_LEVEL)
{
@@ -877,7 +860,7 @@ angle_t R_ViewRollAngle(const player_t *player)
if (cv_tilting.value)
{
if (!player->spectator && !demo.freecam)
if (!player->spectator && !camera[viewnum].freecam)
roll += player->tilt;
if (cv_actionmovie.value)
@@ -1044,19 +1027,6 @@ void R_Init(void)
framecount = 0;
}
//
// R_PointInSubsector
//
subsector_t *R_PointInSubsector(fixed_t x, fixed_t y)
{
size_t nodenum = numnodes-1;
while (!(nodenum & NF_SUBSECTOR))
nodenum = nodes[nodenum].children[R_PointOnSide(x, y, nodes+nodenum)];
return &subsectors[nodenum & ~NF_SUBSECTOR];
}
//
// R_IsPointInSubsector, same as above but returns 0 if not in subsector
//
@@ -1067,16 +1037,13 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
size_t nodenum;
subsector_t *ret;
// single subsector is a special case
//if (numnodes == 0)
//return subsectors;
nodenum = numnodes - 1;
while (!(nodenum & NF_SUBSECTOR))
{
node = &nodes[nodenum];
side = R_PointOnSide(x, y, node);
//side = R_PointOnSide(x, y, node);
side = R_PointOnSideFast(x, y, node); // this is fine since R_IsPointInSubsector is only used for precip spawn unless you disable noclipcam lol
nodenum = node->children[side];
}
@@ -1094,38 +1061,29 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
mobj_t *viewmobj;
void R_SkyboxFrame(player_t *player)
static void
R_SetupCommonFrame
( player_t * player,
subsector_t * subsector)
{
camera_t *thiscam = &camera[0];
UINT8 i;
newview->player = player;
if (splitscreen)
{
for (i = 0; i <= splitscreen; i++)
{
if (player == &players[displayplayers[i]])
{
thiscam = &camera[i];
R_SetViewContext(VIEWCONTEXT_SKY1 + i);
break;
}
}
}
newview->x += quake.x;
newview->y += quake.y;
newview->z += quake.z;
newview->roll = R_ViewRollAngle(player);
if (subsector)
newview->sector = subsector->sector;
else
{
R_SetViewContext(VIEWCONTEXT_SKY1);
}
newview->sector = R_PointInSubsector(newview->x, newview->y)->sector;
// cut-away view stuff
newview->sky = true;
viewmobj = skyboxmo[0];
#ifdef PARANOIA
if (!viewmobj)
{
const size_t playeri = (size_t)(player - players);
I_Error("R_SkyboxFrame: viewmobj null (player %s)", sizeu1(playeri));
}
#endif
R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false);
}
static void R_SetupAimingFrame(player_t *player, camera_t *thiscam)
{
if (player->awayviewtics)
{
newview->aim = player->awayviewaiming;
@@ -1140,31 +1098,43 @@ void R_SkyboxFrame(player_t *player)
{
newview->aim = player->aiming;
newview->angle = player->mo->angle;
if (!demo.playback && player->playerstate != PST_DEAD)
{
if (player == &players[consoleplayer])
for (UINT8 i = 0; i <= splitscreen; i++)
{
newview->angle = localangle[0]; // WARNING: camera uses this
newview->aim = localaiming[0];
}
else if (splitscreen)
{
for (i = 1; i <= splitscreen; i++)
if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]]))
{
if (player == &players[displayplayers[i]])
{
newview->angle = localangle[i];
newview->aim = localaiming[i];
break;
}
newview->angle = localangle[i];
newview->aim = localaiming[i];
break;
}
}
}
}
newview->angle += viewmobj->angle;
newview->roll = R_ViewRollAngle(player);
}
newview->player = player;
void R_SkyboxFrame(int s)
{
player_t *player = &players[displayplayers[s]];
camera_t *thiscam = &camera[s];
subsector_t * subsector = NULL;
R_SetViewContext(VIEWCONTEXT_SKY1 + s);
// cut-away view stuff
newview->sky = true;
viewmobj = skyboxmo[0];
#ifdef PARANOIA
if (P_MobjWasRemoved(viewmobj))
{
const size_t playeri = (size_t)(player - players);
I_Error("R_SkyboxFrame: viewmobj null (player %s)", sizeu1(playeri));
}
#endif
R_SetupAimingFrame(player, thiscam);
newview->angle += viewmobj->angle;
newview->x = viewmobj->x;
newview->y = viewmobj->y;
@@ -1172,216 +1142,97 @@ void R_SkyboxFrame(player_t *player)
if (viewmobj->spawnpoint)
newview->z = ((fixed_t)viewmobj->spawnpoint->angle)<<FRACBITS;
newview->x += quake.x;
newview->y += quake.y;
newview->z += quake.z;
#define SETUPSKYVIEW(viewmo, zscale)\
if (skyboxmo[1])\
{\
fixed_t x = 0, y = 0;\
if (mh->skybox_scalex > 0)\
x = (viewmo->x - skyboxmo[1]->x) / mh->skybox_scalex;\
else if (mh->skybox_scalex < 0)\
x = (viewmo->x - skyboxmo[1]->x) * -mh->skybox_scalex;\
if (mh->skybox_scaley > 0)\
y = (viewmo->y - skyboxmo[1]->y) / mh->skybox_scaley;\
else if (mh->skybox_scaley < 0)\
y = (viewmo->y - skyboxmo[1]->y) * -mh->skybox_scaley;\
if (viewmobj->angle == 0)\
{\
newview->x += x;\
newview->y += y;\
}\
else if (viewmobj->angle == ANGLE_90)\
{\
newview->x -= y;\
newview->y += x;\
}\
else if (viewmobj->angle == ANGLE_180)\
{\
newview->x -= x;\
newview->y -= y;\
}\
else if (viewmobj->angle == ANGLE_270)\
{\
newview->x += y;\
newview->y -= x;\
}\
else\
{\
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;\
newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));\
newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));\
}\
}\
if (mh->skybox_scalez > 0)\
newview->z += zscale / mh->skybox_scalez;\
else if (mh->skybox_scalez < 0)\
newview->z += zscale * -mh->skybox_scalez;
if (mapheaderinfo[gamemap-1])
{
mapheader_t *mh = mapheaderinfo[gamemap-1];
if (player->awayviewtics)
{
if (skyboxmo[1])
{
fixed_t x = 0, y = 0;
if (mh->skybox_scalex > 0)
x = (player->awayviewmobj->x - skyboxmo[1]->x) / mh->skybox_scalex;
else if (mh->skybox_scalex < 0)
x = (player->awayviewmobj->x - skyboxmo[1]->x) * -mh->skybox_scalex;
if (mh->skybox_scaley > 0)
y = (player->awayviewmobj->y - skyboxmo[1]->y) / mh->skybox_scaley;
else if (mh->skybox_scaley < 0)
y = (player->awayviewmobj->y - skyboxmo[1]->y) * -mh->skybox_scaley;
if (viewmobj->angle == 0)
{
newview->x += x;
newview->y += y;
}
else if (viewmobj->angle == ANGLE_90)
{
newview->x -= y;
newview->y += x;
}
else if (viewmobj->angle == ANGLE_180)
{
newview->x -= x;
newview->y -= y;
}
else if (viewmobj->angle == ANGLE_270)
{
newview->x += y;
newview->y -= x;
}
else
{
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
}
}
if (mh->skybox_scalez > 0)
newview->z += (player->awayviewmobj->z + 20*FRACUNIT) / mh->skybox_scalez;
else if (mh->skybox_scalez < 0)
newview->z += (player->awayviewmobj->z + 20*FRACUNIT) * -mh->skybox_scalez;
SETUPSKYVIEW(player->awayviewmobj, (player->awayviewmobj->z + 20*FRACUNIT));
}
else if (thiscam->chase)
{
if (skyboxmo[1])
{
fixed_t x = 0, y = 0;
if (mh->skybox_scalex > 0)
x = (thiscam->x - skyboxmo[1]->x) / mh->skybox_scalex;
else if (mh->skybox_scalex < 0)
x = (thiscam->x - skyboxmo[1]->x) * -mh->skybox_scalex;
if (mh->skybox_scaley > 0)
y = (thiscam->y - skyboxmo[1]->y) / mh->skybox_scaley;
else if (mh->skybox_scaley < 0)
y = (thiscam->y - skyboxmo[1]->y) * -mh->skybox_scaley;
if (viewmobj->angle == 0)
{
newview->x += x;
newview->y += y;
}
else if (viewmobj->angle == ANGLE_90)
{
newview->x -= y;
newview->y += x;
}
else if (viewmobj->angle == ANGLE_180)
{
newview->x -= x;
newview->y -= y;
}
else if (viewmobj->angle == ANGLE_270)
{
newview->x += y;
newview->y -= x;
}
else
{
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
}
}
if (mh->skybox_scalez > 0)
newview->z += (thiscam->z + (thiscam->height>>1)) / mh->skybox_scalez;
else if (mh->skybox_scalez < 0)
newview->z += (thiscam->z + (thiscam->height>>1)) * -mh->skybox_scalez;
SETUPSKYVIEW(thiscam, (thiscam->z + (thiscam->height>>1)));
}
else
{
if (skyboxmo[1])
{
fixed_t x = 0, y = 0;
if (mh->skybox_scalex > 0)
x = (player->mo->x - skyboxmo[1]->x) / mh->skybox_scalex;
else if (mh->skybox_scalex < 0)
x = (player->mo->x - skyboxmo[1]->x) * -mh->skybox_scalex;
if (mh->skybox_scaley > 0)
y = (player->mo->y - skyboxmo[1]->y) / mh->skybox_scaley;
else if (mh->skybox_scaley < 0)
y = (player->mo->y - skyboxmo[1]->y) * -mh->skybox_scaley;
if (viewmobj->angle == 0)
{
newview->x += x;
newview->y += y;
}
else if (viewmobj->angle == ANGLE_90)
{
newview->x -= y;
newview->y += x;
}
else if (viewmobj->angle == ANGLE_180)
{
newview->x -= x;
newview->y -= y;
}
else if (viewmobj->angle == ANGLE_270)
{
newview->x += y;
newview->y -= x;
}
else
{
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
}
}
if (mh->skybox_scalez > 0)
newview->z += player->viewz / mh->skybox_scalez;
else if (mh->skybox_scalez < 0)
newview->z += player->viewz * -mh->skybox_scalez;
SETUPSKYVIEW(player->mo, player->viewz);
}
}
#undef SETUPSKYVIEW
if (viewmobj->subsector)
newview->sector = viewmobj->subsector->sector;
else
newview->sector = R_PointInSubsector(newview->x, newview->y)->sector;
if (!P_MobjWasRemoved(viewmobj))
subsector = viewmobj->subsector;
R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false);
R_SetupCommonFrame(player, subsector);
}
void R_SetupFrame(player_t *player, boolean skybox)
void R_SetupFrame(int s, boolean skybox)
{
camera_t *thiscam;
boolean chasecam = false;
player_t *player = &players[displayplayers[s]];
camera_t *thiscam = &camera[s];
boolean chasecam = (cv_chasecam[s].value != 0);
subsector_t * subsector = NULL;
if (splitscreen > 2 && player == &players[displayplayers[3]])
R_SetViewContext(VIEWCONTEXT_PLAYER1 + s);
if (thiscam->reset)
{
thiscam = &camera[3];
chasecam = (cv_chasecam4.value != 0);
R_SetViewContext(VIEWCONTEXT_PLAYER4);
if (thiscam->reset)
{
R_ResetViewInterpolation(4);
thiscam->reset = false;
}
}
else if (splitscreen > 1 && player == &players[displayplayers[2]])
{
thiscam = &camera[2];
chasecam = (cv_chasecam3.value != 0);
R_SetViewContext(VIEWCONTEXT_PLAYER3);
if (thiscam->reset)
{
R_ResetViewInterpolation(3);
thiscam->reset = false;
}
}
else if (splitscreen && player == &players[displayplayers[1]])
{
thiscam = &camera[1];
chasecam = (cv_chasecam2.value != 0);
R_SetViewContext(VIEWCONTEXT_PLAYER2);
if (thiscam->reset)
{
R_ResetViewInterpolation(2);
thiscam->reset = false;
}
}
else
{
thiscam = &camera[0];
chasecam = (cv_chasecam.value != 0);
R_SetViewContext(VIEWCONTEXT_PLAYER1);
if (thiscam->reset)
{
R_ResetViewInterpolation(1);
thiscam->reset = false;
}
R_ResetViewInterpolation(s);
thiscam->reset = false;
}
if (player->spectator) // no spectator chasecam
chasecam = false; // force chasecam off
else if (player->playerstate == PST_DEAD || player->exiting)
if (player->spectator)
{
// Free flying spectator uses demo freecam. This
// requires chasecam to be enabled.
chasecam = true;
}
if (player->playerstate == PST_DEAD || player->exiting)
chasecam = true; // force chasecam on
if (chasecam && (thiscam && !thiscam->chase))
@@ -1394,84 +1245,46 @@ void R_SetupFrame(player_t *player, boolean skybox)
newview->sky = !skybox;
R_SetupAimingFrame(player, thiscam);
if (player->awayviewtics) // cut-away view stuff
{
viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN
I_Assert(viewmobj != NULL);
newview->x = viewmobj->x;
newview->y = viewmobj->y;
newview->z = viewmobj->z + 20*FRACUNIT;
newview->aim = player->awayviewaiming;
newview->angle = viewmobj->angle;
if (!P_MobjWasRemoved(viewmobj))
subsector = viewmobj->subsector;
R_SetupCommonFrame(player, subsector);
}
else if (!player->spectator && (thiscam && chasecam)) // use outside cam view
else if (thiscam && chasecam) // use outside cam view
{
viewmobj = NULL;
newview->x = thiscam->x;
newview->y = thiscam->y;
newview->z = thiscam->z + (thiscam->height>>1);
newview->aim = thiscam->aiming;
newview->angle = thiscam->angle;
R_SetupCommonFrame(player, thiscam->subsector);
}
else // use the player's eyes view
{
newview->z = player->viewz;
viewmobj = player->mo;
I_Assert(viewmobj != NULL);
newview->aim = player->aiming;
newview->angle = viewmobj->angle;
if (!demo.playback && player->playerstate != PST_DEAD)
{
if (player == &players[consoleplayer])
{
newview->angle = localangle[0]; // WARNING: camera uses this
newview->aim = localaiming[0];
}
else if (splitscreen)
{
UINT8 i;
for (i = 1; i <= splitscreen; i++)
{
if (player == &players[displayplayers[i]])
{
newview->angle = localangle[i];
newview->aim = localaiming[i];
break;
}
}
}
}
}
newview->roll = R_ViewRollAngle(player);
newview->z += quake.z;
newview->player = player;
if ((thiscam && chasecam) && !player->awayviewtics && !player->spectator)
{
newview->x = thiscam->x;
newview->y = thiscam->y;
newview->x += quake.x;
newview->y += quake.y;
if (thiscam->subsector && thiscam->subsector->sector)
newview->sector = thiscam->subsector->sector;
else
newview->sector = R_PointInSubsector(newview->x, newview->y)->sector;
}
else
{
newview->x = viewmobj->x;
newview->y = viewmobj->y;
newview->x += quake.x;
newview->y += quake.y;
newview->z = player->viewz;
if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && thiscam && thiscam->subsector->sector)
newview->sector = viewmobj->subsector->sector;
else
newview->sector = R_PointInSubsector(newview->x, newview->y)->sector;
if (!P_MobjWasRemoved(viewmobj))
subsector = viewmobj->subsector;
R_SetupCommonFrame(player, subsector);
}
R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false);
}
static void R_PortalFrame(portal_t *portal)
@@ -1554,7 +1367,7 @@ void R_RenderPlayerView(player_t *player)
PS_START_TIMING(ps_skyboxtime);
if (skybox && skyVisible)
{
R_SkyboxFrame(player);
R_SkyboxFrame(viewssnum);
R_ClearClipSegs();
R_ClearDrawSegs();
@@ -1574,7 +1387,7 @@ void R_RenderPlayerView(player_t *player)
}
PS_STOP_TIMING(ps_skyboxtime);
R_SetupFrame(player, skybox);
R_SetupFrame(viewssnum, skybox);
skyVisible = false;
framecount++;
validcount++;
@@ -1680,15 +1493,18 @@ void R_RenderPlayerView(player_t *player)
void R_RegisterEngineStuff(void)
{
INT32 i;
CV_RegisterVar(&cv_gravity);
CV_RegisterVar(&cv_tailspickup);
CV_RegisterVar(&cv_soniccd);
CV_RegisterVar(&cv_allowmlook);
CV_RegisterVar(&cv_homremoval);
CV_RegisterVar(&cv_flipcam);
CV_RegisterVar(&cv_flipcam2);
CV_RegisterVar(&cv_flipcam3);
CV_RegisterVar(&cv_flipcam4);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_flipcam[i]);
}
// Enough for dedicated server
if (dedicated)
@@ -1701,43 +1517,27 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_mobjscaleprecip);
CV_RegisterVar(&cv_fov);
CV_RegisterVar(&cv_chasecam);
CV_RegisterVar(&cv_chasecam2);
CV_RegisterVar(&cv_chasecam3);
CV_RegisterVar(&cv_chasecam4);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_chasecam[i]);
}
CV_RegisterVar(&cv_shadow);
CV_RegisterVar(&cv_shadowoffs);
CV_RegisterVar(&cv_skybox);
CV_RegisterVar(&cv_ffloorclip);
CV_RegisterVar(&cv_spriteclip);
CV_RegisterVar(&cv_cam_dist);
CV_RegisterVar(&cv_cam_still);
CV_RegisterVar(&cv_cam_height);
CV_RegisterVar(&cv_cam_speed);
CV_RegisterVar(&cv_cam_rotate);
CV_RegisterVar(&cv_cam_rotspeed);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_cam_dist[i]);
CV_RegisterVar(&cv_cam_still[i]);
CV_RegisterVar(&cv_cam_height[i]);
CV_RegisterVar(&cv_cam_speed[i]);
CV_RegisterVar(&cv_cam_rotate[i]);
CV_RegisterVar(&cv_cam_rotspeed[i]);
}
CV_RegisterVar(&cv_cam2_dist);
CV_RegisterVar(&cv_cam2_still);
CV_RegisterVar(&cv_cam2_height);
CV_RegisterVar(&cv_cam2_speed);
CV_RegisterVar(&cv_cam2_rotate);
CV_RegisterVar(&cv_cam2_rotspeed);
CV_RegisterVar(&cv_cam3_dist);
CV_RegisterVar(&cv_cam3_still);
CV_RegisterVar(&cv_cam3_height);
CV_RegisterVar(&cv_cam3_speed);
CV_RegisterVar(&cv_cam3_rotate);
CV_RegisterVar(&cv_cam3_rotspeed);
CV_RegisterVar(&cv_cam4_dist);
CV_RegisterVar(&cv_cam4_still);
CV_RegisterVar(&cv_cam4_height);
CV_RegisterVar(&cv_cam4_speed);
CV_RegisterVar(&cv_cam4_rotate);
CV_RegisterVar(&cv_cam4_rotspeed);
CV_RegisterVar(&cv_freecam_speed);
CV_RegisterVar(&cv_tilting);
CV_RegisterVar(&cv_quaketilt);
@@ -1749,7 +1549,6 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_driftsparkpulse);
CV_RegisterVar(&cv_gravstretch);
CV_RegisterVar(&cv_sloperoll);
CV_RegisterVar(&cv_spriteroll);
CV_RegisterVar(&cv_sliptideroll);
CV_RegisterVar(&cv_sloperolldist);
CV_RegisterVar(&cv_sparkroll);
+65 -8
View File
@@ -72,7 +72,40 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
#define COLORMAP_REMAPOFFSET COLORMAP_SIZE
// Utility functions.
INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *node);
//
// R_PointOnSide
// Traverse BSP (sub) tree,
// check point against partition plane.
// Returns side 0 (front) or 1 (back).
//
// killough 5/2/98: reformatted
//
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *restrict node)
{
if (!node->dx)
return x <= node->x ? node->dy > 0 : node->dy < 0;
if (!node->dy)
return y <= node->y ? node->dx < 0 : node->dx > 0;
x -= node->x;
y -= node->y;
// Try to quickly decide by looking at sign bits.
// also use a mask to avoid branch prediction
INT32 mask = (node->dy ^ node->dx ^ x ^ y) >> 31;
return (mask & ((node->dy ^ x) < 0)) | // (left is negative)
(~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x)));
}
// This is not as accurate
// SHOULD NOT BE USED FOR ANYTHING GAMEPLAY RELATED!!
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSideFast(fixed_t x, fixed_t y, const node_t *node)
{
// use cross product to determine side quickly
return ((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy > 0;
}
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line)
{
@@ -82,7 +115,7 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t
fixed_t ldy = line->v2->y - ly;
// use cross product to determine side quickly
return (INT64)(y - ly) * ldx - (INT64)(x - lx) * ldy > 0;
return ((INT64)y - ly) * ldx - ((INT64)x - lx) * ldy > 0;
}
angle_t R_PointToAngle(fixed_t x, fixed_t y);
@@ -91,13 +124,37 @@ angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
angle_t R_PlayerSliptideAngle(player_t *player);
fixed_t R_ScaleFromGlobalAngle(angle_t visangle);
subsector_t *R_PointInSubsector(fixed_t x, fixed_t y);
subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y);
//
// R_PointInSubsector
//
FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t y)
{
size_t nodenum = numnodes-1;
while (!(nodenum & NF_SUBSECTOR))
nodenum = nodes[nodenum].children[R_PointOnSide(x, y, nodes+nodenum)];
return &subsectors[nodenum & ~NF_SUBSECTOR];
}
// uses R_PointOnSideFast
// SHOULD NOT BE USED FOR ANYTHING GAMEPLAY RELATED!!
FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsectorFast(fixed_t x, fixed_t y)
{
size_t nodenum = numnodes-1;
while (!(nodenum & NF_SUBSECTOR))
nodenum = nodes[nodenum].children[R_PointOnSideFast(x, y, nodes+nodenum)];
return &subsectors[nodenum & ~NF_SUBSECTOR];
}
#define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y)
#define R_PointToDist2(px2, py2, px1, py1) FixedHypot((px1) - (px2), (py1) - (py2))
boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph);
void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh);
@@ -127,8 +184,8 @@ extern ps_metric_t ps_numpolyobjects;
extern consvar_t cv_showhud, cv_translucenthud, cv_uncappedhud;
extern consvar_t cv_homremoval;
extern consvar_t cv_chasecam, cv_chasecam2, cv_chasecam3, cv_chasecam4;
extern consvar_t cv_flipcam, cv_flipcam2, cv_flipcam3, cv_flipcam4;
extern consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_shadow, cv_shadowoffs;
extern consvar_t cv_ffloorclip, cv_spriteclip;
extern consvar_t cv_translucency;
@@ -153,9 +210,9 @@ void R_SetViewSize(void);
// do it (sometimes explicitly called)
void R_ExecuteSetViewSize(void);
void R_SkyboxFrame(player_t *player);
void R_SkyboxFrame(int s);
void R_SetupFrame(int s, boolean skybox);
void R_SetupFrame(player_t *player, boolean skybox);
// Called by G_Drawer.
void R_RenderPlayerView(player_t *player);
+16 -6
View File
@@ -14,9 +14,11 @@
#include "byteptr.h"
#include "dehacked.h"
#include "doomdef.h"
#include "i_video.h"
#include "r_data.h"
#include "r_draw.h"
#include "r_fps.h"
#include "r_patch.h"
#include "r_things.h"
#include "z_zone.h"
@@ -803,6 +805,14 @@ INT32 R_GetRollAngle(angle_t rollangle)
return ra;
}
angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp)
{
return FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), interp->roll) +
FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), interp->pitch) +
FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), interp->sloperoll) +
FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), interp->slopepitch);
}
patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, boolean adjustfeet, void *info, INT32 rotationangle)
{
rotsprite_t *rotsprite;
@@ -842,8 +852,8 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri
}
else
{
xpivot = patch->leftoffset;
ypivot = patch->height / 2;
xpivot = SHORT(patch->leftoffset);
ypivot = SHORT(patch->height) / 2;
}
RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip);
@@ -902,9 +912,9 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
size_t size;
INT32 bflip = (flip != 0x00);
INT32 width = patch->width;
INT32 height = patch->height;
INT32 leftoffset = patch->leftoffset;
INT32 width = SHORT(patch->width);
INT32 height = SHORT(patch->height);
INT32 leftoffset = SHORT(patch->leftoffset);
INT32 newwidth, newheight;
fixed_t ca = rollcosang[angle];
@@ -975,7 +985,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
}
ox = (newwidth / 2) + (leftoffset - xpivot);
oy = (newheight / 2) + (patch->topoffset - ypivot);
oy = (newheight / 2) + (SHORT(patch->topoffset) - ypivot);
width = (maxx - minx);
height = (maxy - miny);
+3
View File
@@ -15,6 +15,7 @@
#define __R_PATCH__
#include "r_defs.h"
#include "r_fps.h"
#include "doomdef.h"
// Structs
@@ -53,6 +54,8 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum);
// Sprite rotation
#ifdef ROTSPRITE
INT32 R_GetRollAngle(angle_t rollangle);
angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp);
patch_t *Patch_GetRotatedSprite(
spriteframe_t *sprite,
size_t frame, size_t spriteangle,
+23 -29
View File
@@ -661,13 +661,13 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor)
// Renders all the thick sides in the given range.
void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
size_t pindex;
size_t pindex = 0;
column_t * col;
INT32 lightnum;
INT32 texnum;
INT32 lightnum;
INT32 texnum;
sector_t tempsec;
INT32 templight;
INT32 i, p;
INT32 templight;
INT32 i, p;
fixed_t bottombounds = viewheight << FRACBITS;
fixed_t topbounds = (con_clipviewtop - 1) << FRACBITS;
fixed_t offsetvalue = 0;
@@ -1036,6 +1036,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
// Check if the current light effects the colormap/lightlevel
rlight = &dc_lightlist[i];
lighteffect = !(dc_lightlist[i].flags & FF_NOSHADE);
if (lighteffect)
{
lightnum = rlight->lightnum;
@@ -1233,7 +1234,6 @@ static void R_RenderSegLoop (void)
}
}
yh = bottomfrac>>HEIGHTBITS;
bottom = floorclip[rw_x]-1;
@@ -1244,13 +1244,14 @@ static void R_RenderSegLoop (void)
if (markfloor)
{
top = yh < ceilingclip[rw_x] ? ceilingclip[rw_x] : yh;
if (++top <= bottom && floorplane)
{
floorplane->top[rw_x] = (INT16)top;
floorplane->bottom[rw_x] = (INT16)bottom;
}
}
rw_floormarked = false;
rw_ceilingmarked = false;
@@ -1591,6 +1592,8 @@ static void R_RenderSegLoop (void)
topfrac += topstep;
bottomfrac += bottomstep;
}
//colfunc = wallcolfunc;
}
// Uses precalculated seg->length
@@ -1853,21 +1856,19 @@ void R_StoreWallRange(INT32 start, INT32 stop)
rw_toptextureslide = rw_midtextureslide = rw_bottomtextureslide = 0;
ceilingfrontslide = floorfrontslide = ceilingbackslide = floorbackslide = 0;
{
angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y);
angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y);
if (frontsector->f_slope)
floorfrontslide = FixedMul(frontsector->f_slope->zdelta, FINECOSINE((lineangle-frontsector->f_slope->xydirection)>>ANGLETOFINESHIFT));
if (frontsector->f_slope)
floorfrontslide = FixedMul(frontsector->f_slope->zdelta, FINECOSINE((lineangle-frontsector->f_slope->xydirection)>>ANGLETOFINESHIFT));
if (frontsector->c_slope)
ceilingfrontslide = FixedMul(frontsector->c_slope->zdelta, FINECOSINE((lineangle-frontsector->c_slope->xydirection)>>ANGLETOFINESHIFT));
if (frontsector->c_slope)
ceilingfrontslide = FixedMul(frontsector->c_slope->zdelta, FINECOSINE((lineangle-frontsector->c_slope->xydirection)>>ANGLETOFINESHIFT));
if (backsector && backsector->f_slope)
floorbackslide = FixedMul(backsector->f_slope->zdelta, FINECOSINE((lineangle-backsector->f_slope->xydirection)>>ANGLETOFINESHIFT));
if (backsector && backsector->f_slope)
floorbackslide = FixedMul(backsector->f_slope->zdelta, FINECOSINE((lineangle-backsector->f_slope->xydirection)>>ANGLETOFINESHIFT));
if (backsector && backsector->c_slope)
ceilingbackslide = FixedMul(backsector->c_slope->zdelta, FINECOSINE((lineangle-backsector->c_slope->xydirection)>>ANGLETOFINESHIFT));
}
if (backsector && backsector->c_slope)
ceilingbackslide = FixedMul(backsector->c_slope->zdelta, FINECOSINE((lineangle-backsector->c_slope->xydirection)>>ANGLETOFINESHIFT));
if (!backsector)
{
@@ -1936,9 +1937,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
ds_p->sprtopclip = ds_p->sprbottomclip = NULL;
ds_p->silhouette = 0;
if (
worldbottomslope > worldlowslope ||
worldbottom > worldlow)
if (worldbottomslope > worldlowslope || worldbottom > worldlow)
{
ds_p->silhouette = SIL_BOTTOM;
if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz)
@@ -1953,9 +1952,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// ds_p->sprbottomclip = negonearray;
}
if (
worldtopslope < worldhighslope ||
worldtop < worldhigh)
if (worldtopslope < worldhighslope || worldtop < worldhigh)
{
ds_p->silhouette |= SIL_TOP;
if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz)
@@ -2029,7 +2026,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|| frontsector->extra_colormap != backsector->extra_colormap
|| (frontsector->ffloors != backsector->ffloors && frontsector->tag != backsector->tag))
{
markceiling = true;
markceiling = true;
}
else
{
@@ -2045,9 +2042,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
// check TOP TEXTURE
if (worldhigh < worldtop
|| worldhighslope < worldtopslope
)
if (worldhigh < worldtop || worldhighslope < worldtopslope)
{
fixed_t texheight;
// top texture
@@ -2124,7 +2119,6 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// Used for height comparisons and etc across FOFs and slopes
fixed_t high1, highslope1, low1, lowslope1, high2, highslope2, low2, lowslope2;
//markceiling = markfloor = true;
maskedtexture = true;
ds_p->thicksidecol = maskedtexturecol = lastopening - rw_x;
-3
View File
@@ -59,9 +59,6 @@ typedef struct floorsplat_s
struct floorsplat_s *nextvis;
} floorsplat_t;
// p_setup.c
fixed_t P_SegLength(seg_t *seg);
// call at P_SetupLevel()
void R_ClearLevelSplats(void);
+51 -41
View File
@@ -965,7 +965,8 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
//
// R_SplitSprite
// runs through a sector's lightlist and
// runs through a sector's lightlist and splits the sprite according to the heights
//
static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
{
INT32 i, lightnum, lindex;
@@ -1115,8 +1116,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
//
static void R_ProjectSprite(mobj_t *thing)
{
mobj_t *oldthing = thing;
fixed_t tr_x, tr_y;
fixed_t gxt, gyt;
fixed_t tx, tz;
@@ -1134,24 +1133,23 @@ static void R_ProjectSprite(mobj_t *thing)
size_t rot;
UINT8 flip;
boolean mirrored = thing->mirrored;
boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
INT32 lindex;
vissprite_t *vis;
angle_t ang = 0; // gcc 4.6 and lower fix
#ifdef ROTSPRITE
angle_t camang = 0;
#endif
fixed_t iscale;
fixed_t scalestep; // toast '16
fixed_t offset, offset2;
boolean papersprite = (thing->frame & FF_PAPERSPRITE);
fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0;
//SoM: 3/17/2000
fixed_t gz, gzt;
INT32 heightsec, phs;
INT32 dist = -1;
INT32 light = 0;
fixed_t this_scale;
fixed_t spritexscale, spriteyscale;
@@ -1163,12 +1161,19 @@ static void R_ProjectSprite(mobj_t *thing)
#ifdef ROTSPRITE
patch_t *rotsprite = NULL;
INT32 rollangle = 0;
angle_t rollsum = 0;
angle_t pitchnroll = 0;
angle_t sliptiderollangle = 0;
#endif
INT32 dist = -1;
if (P_MobjWasRemoved(thing) || thing->subsector == NULL)
return;
mobj_t *oldthing = thing;
const boolean mirrored = thing->mirrored;
const boolean vflip = (thing->eflags & MFE_VERTICALFLIP);
const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
const boolean papersprite = (thing->frame & FF_PAPERSPRITE);
if (cv_maxinterpdist.value)
dist = R_QuickCamDist(thing->x, thing->y);
@@ -1206,7 +1211,7 @@ static void R_ProjectSprite(mobj_t *thing)
tx = -(gyt + gxt);
// too far off the side?
if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later
if (!papersprite && abs(tx) > (INT64)tz<<2) // papersprite clipping is handled later
return;
// aspect ratio stuff
@@ -1219,7 +1224,13 @@ static void R_ProjectSprite(mobj_t *thing)
I_Error("R_ProjectSprite: invalid sprite number %d ", thing->sprite);
#endif
rot = thing->frame&FF_FRAMEMASK;
rot = (thing->frame & FF_FRAMEMASK);
#ifdef ROTSPRITE
// determine here if sprite should rotate for optimization
const boolean sliprollrotate = (cv_sloperoll.value && cv_sliptideroll.value && (thing->player && thing->player->sliproll));
const boolean shouldrotate = (cv_sloperoll.value && (interp.roll || interp.pitch || interp.sloperoll || interp.slopepitch || thing->rollangle || sliprollrotate));
#endif
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
if ((thing->skin || thing->localskin) && thing->sprite == SPR_PLAY)
@@ -1250,7 +1261,7 @@ static void R_ProjectSprite(mobj_t *thing)
#ifdef ROTSPRITE
sprinfo = &spriteinfo[thing->sprite];
#endif
rot = thing->frame&FF_FRAMEMASK;
rot = (thing->frame & FF_FRAMEMASK);
if (!thing->skin)
{
thing->state->sprite = thing->sprite;
@@ -1265,10 +1276,17 @@ static void R_ProjectSprite(mobj_t *thing)
I_Error("R_ProjectSprite: sprframes NULL for sprite %d\n", thing->sprite);
#endif
if (sprframe->rotate != SRF_SINGLE || papersprite || (cv_sloperoll.value == 2 && cv_spriteroll.value))
if (sprframe->rotate != SRF_SINGLE || papersprite ||
#ifdef ROTSPRITE
(shouldrotate)
#endif
)
{
ang = R_PointToAngle (interp.x, interp.y) - interp.angle;
camang = R_PointToAngle (interp.x, interp.y);
ang = R_PointToAngle(interp.x, interp.y);
#ifdef ROTSPRITE
camang = ang;
#endif
ang -= interp.angle;
if (mirrored)
ang = InvAngle(ang);
@@ -1311,9 +1329,7 @@ static void R_ProjectSprite(mobj_t *thing)
spr_topoffset = spritecachedinfo[lump].topoffset;
#ifdef ROTSPRITE
pitchnroll = 0; // set this to 0, non-paper sprites will affect this value
if (cv_spriteroll.value)
if (shouldrotate)
{
if (papersprite)
{
@@ -1331,29 +1347,21 @@ static void R_ProjectSprite(mobj_t *thing)
{
// this is very messy, but it on-the-fly calculates rotations for all the
// pitch and roll variables
pitchnroll = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), interp.roll) +
FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), interp.pitch) +
FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), interp.sloperoll) +
FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), interp.slopepitch);
pitchnroll = R_RotationAngle(ang, camang, &interp);
rollangle = thing->rollangle;
}
if (rollangle || pitchnroll || (thing->player && thing->player->sliproll))
if (rollangle || pitchnroll || sliprollrotate)
{
rollsum = pitchnroll;
if (thing->player)
if (sliprollrotate)
{
sliptiderollangle =
cv_sliptideroll.value ? thing->player->sliproll * (thing->player->sliptidemem) : 0;
rollsum += thing->rollangle +
FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), sliptiderollangle);
sliptiderollangle = thing->player->sliproll * thing->player->kartstuff[k_aizdriftstrat];
pitchnroll += rollangle + FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), sliptiderollangle);
}
else
rollsum += thing->rollangle;
pitchnroll += rollangle;
rollangle = R_GetRollAngle(rollsum);
rollangle = R_GetRollAngle(pitchnroll);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
if (rotsprite != NULL)
@@ -1536,7 +1544,7 @@ static void R_ProjectSprite(mobj_t *thing)
}
//SoM: 3/17/2000: Disregard sprites that are out of view..
if (thing->eflags & MFE_VERTICALFLIP)
if (vflip)
{
// When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned.
// sprite height - sprite topoffset is the proper inverse of the vertical offset, of course.
@@ -1664,7 +1672,7 @@ static void R_ProjectSprite(mobj_t *thing)
//Fab: lumppat is the lump number of the patch to use, this is different
// than lumpid for sprites-in-pwad : the graphics are patched
#ifdef ROTSPRITE
if ((rotsprite != NULL) && (cv_spriteroll.value))
if (rotsprite != NULL)
vis->patch = rotsprite;
else
#endif
@@ -1702,10 +1710,7 @@ static void R_ProjectSprite(mobj_t *thing)
vis->precip = false;
if (thing->eflags & MFE_VERTICALFLIP)
vis->vflip = true;
else
vis->vflip = false;
vis->vflip = vflip;
vis->isScaled = false;
@@ -1739,6 +1744,9 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
INT32 dist = 1;
if (!thing || thing->subsector == NULL)
return;
if (cv_maxinterpdist.value)
dist = R_QuickCamDist(thing->x, thing->y);
@@ -1941,6 +1949,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
// Handle all things in sector.
// If a limit exists, handle things a tiny bit different.
const fixed_t limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale;
for (thing = sec->thinglist; thing; thing = thing->snext)
{
if (!R_ThingWithinDist(thing, limit_dist))
@@ -1960,7 +1969,8 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
//
void R_AddPrecipitationSprites(void)
{
fixed_t drawdist = (fixed_t)(cv_drawdist_precip.value) * (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT);
fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT);
fixed_t drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale);
INT32 xl, xh, yl, yh, bx, by;
precipmobj_t *th, *next;
@@ -2759,7 +2769,7 @@ boolean R_ThingVisible (mobj_t *thing)
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)
return false;
if (viewmobj && (thing == viewmobj))
if (!P_MobjWasRemoved(viewmobj) && (thing == viewmobj))
return false;
if (splitscreen)
+212 -354
View File
@@ -491,11 +491,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
memset(&listener[i], 0, sizeof (listener[i]));
listenmobj[i] = NULL;
if (i == 0 && democam.soundmobj)
{
listenmobj[i] = democam.soundmobj;
}
else if (player->awayviewtics)
if (player->awayviewtics)
{
listenmobj[i] = player->awayviewmobj;
}
@@ -504,7 +500,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
listenmobj[i] = player->mo;
}
if (origin && origin == listenmobj[i])
if (origin && origin == listenmobj[i] && !camera[i].freecam)
{
itsUs = true;
}
@@ -656,12 +652,6 @@ void S_StartSound(const void *origin, sfxenum_t sfx_id)
{
switch (sfx_id)
{
// case sfx_altow1:
// case sfx_altow2:
// case sfx_altow3:
// case sfx_altow4:
// sfx_id = sfx_mario8;
// break;
case sfx_thok:
sfx_id = sfx_mario7;
break;
@@ -677,15 +667,6 @@ void S_StartSound(const void *origin, sfxenum_t sfx_id)
case sfx_itemup:
sfx_id = sfx_mario4;
break;
// case sfx_tink:
// sfx_id = sfx_mario1;
// break;
// case sfx_cgot:
// sfx_id = sfx_mario9;
// break;
// case sfx_lose:
// sfx_id = sfx_mario2;
// break;
default:
break;
}
@@ -790,12 +771,6 @@ void S_UpdateSounds(void)
memset(&listener[i], 0, sizeof (listener[i]));
listenmobj[i] = NULL;
if (i == 0 && democam.soundmobj)
{
listenmobj[i] = democam.soundmobj;
continue;
}
if (player->awayviewtics)
{
listenmobj[i] = player->awayviewmobj;
@@ -860,6 +835,9 @@ void S_UpdateSounds(void)
for (i = splitscreen; i >= 0; i--)
{
if (camera[i].freecam)
continue;
if (c->origin != listenmobj[i])
continue;
@@ -1046,7 +1024,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32
INT64 x, y, yl, yh, xl, xh;
fixed_t newdist;
if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum)
if (R_PointInSubsectorFast(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum)
approx_dist = 0;
else
{
@@ -1059,7 +1037,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32
for (y = yl; y <= yh; y += FRACUNIT*64)
for (x = xl; x <= xh; x += FRACUNIT*64)
{
if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum)
if (R_PointInSubsectorFast(x, y)->sector->ceilingpic == skyflatnum)
{
// Found the outdoors!
newdist = S_CalculateSoundDistance(listensource.x, listensource.y, 0, x, y, 0);
@@ -1317,175 +1295,191 @@ static UINT32 queue_fadeinms;
musicdef_t *musicdefstart = NULL; // First music definition
struct cursongcredit cursongcredit; // Currently displayed song credit info
//
// search for music definition in wad
//
static UINT16 W_CheckForMusicDefInPwad(UINT16 wadid)
static boolean
ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp)
{
UINT16 i;
lumpinfo_t *lump_p;
musicdef_t *def;
lump_p = wadfiles[wadid]->lumpinfo;
for (i = 0; i < wadfiles[wadid]->numlumps; i++, lump_p++)
if (memcmp(lump_p->name, "MUSICDEF", 8) == 0)
return i;
return INT16_MAX; // not found
}
void S_LoadMusicDefs(UINT16 wadnum)
{
UINT16 lump;
char *buf;
char *buf2;
char *stoken;
char *value;
size_t size;
musicdef_t *def, *prev;
UINT16 line = 1; // for better error msgs
char *textline;
lump = W_CheckForMusicDefInPwad(wadnum);
if (lump == INT16_MAX)
return;
buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
size = W_LumpLengthPwad(wadnum, lump);
// for strtok
buf2 = malloc(size+1);
if (!buf2)
I_Error("S_LoadMusicDefs: No more free memory\n");
M_Memcpy(buf2,buf,size);
buf2[size] = '\0';
def = prev = NULL;
stoken = strtok (buf2, "\r\n ");
// Find music def
while (stoken)
if (!stricmp(stoken, "lump"))
{
if (!stricmp(stoken, "lump"))
value = strtok(NULL, " ");
if (!value)
{
value = strtok(NULL, "\r\n ");
if (!value)
{
CONS_Alert(CONS_WARNING, "MUSICDEF: Lump '%s' is missing name. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_lump;
}
// No existing musicdefs
if (!musicdefstart)
{
musicdefstart = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
STRBUFCPY(musicdefstart->name, value);
strlwr(musicdefstart->name);
def = musicdefstart;
//CONS_Printf("S_LoadMusicDefs: Initialized musicdef w/ song '%s'\n", def->name);
}
else
{
def = musicdefstart;
// Search if this is a replacement
//CONS_Printf("S_LoadMusicDefs: Searching for song replacement...\n");
while (def)
{
if (!stricmp(def->name, value))
{
//CONS_Printf("S_LoadMusicDefs: Found song replacement '%s'\n", def->name);
break;
}
prev = def;
def = def->next;
}
// Nothing found, add to the end.
if (!def)
{
def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
STRBUFCPY(def->name, value);
strlwr(def->name);
if (prev != NULL)
prev->next = def;
//CONS_Printf("S_LoadMusicDefs: Added song '%s'\n", def->name);
}
}
strncpy(def->filename, wadfiles[wadnum]->filename, 256);
def->filename[256] = '\0';
skip_lump:
stoken = strtok(NULL, "\r\n ");
line++;
CONS_Alert(CONS_WARNING,
"MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n",
stoken, wadfiles[wadnum]->filename, line);
return false;
}
else
{
value = strtok(NULL, "\r\n= ");
def = S_FindMusicCredit(value);
if (!value)
// Nothing found, add to the end.
if (!def)
{
CONS_Alert(CONS_WARNING, "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_field;
def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
STRBUFCPY(def->name, value);
strlwr(def->name);
def->hash = quickncasehash (def->name, 6);
def->next = musicdefstart;
musicdefstart = def;
}
(*defp) = def;
}
}
else
{
value = strtok(NULL, "");
if (value)
{
// Find the equals sign.
value = strchr(value, '=');
}
if (!value)
{
CONS_Alert(CONS_WARNING,
"MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n",
stoken, wadfiles[wadnum]->filename, line);
return false;
}
else
{
def = (*defp);
if (!def)
{
CONS_Alert(CONS_ERROR, "MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
free(buf2);
return;
CONS_Alert(CONS_ERROR,
"MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n",
stoken, wadfiles[wadnum]->filename, line);
return false;
}
// Skip the equals sign.
value++;
// Now skip funny whitespace.
value += strspn(value, "\t ");
textline = value;
// turn _ into spaces.
#define ADDDEF(field)\
STRBUFCPY(def->field, textline);\
for (textline = def->field; *textline; textline++)\
if (*textline == '_') *textline = ' ';
if (!stricmp(stoken, "usage"))
{
STRBUFCPY(def->usage, value);
for (value = def->usage; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces.
//CONS_Printf("S_LoadMusicDefs: Set usage to '%s'\n", def->usage);
ADDDEF(usage);
}
else if (!stricmp(stoken, "source"))
{
STRBUFCPY(def->source, value);
for (value = def->source; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces.
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
ADDDEF(source);
}
else if (!stricmp(stoken, "title"))
{
def->use_info = true;
STRBUFCPY(def->title, value);
for (value = def->title; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces.
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
ADDDEF(title);
}
else if (!stricmp(stoken, "alttitle"))
{
STRBUFCPY(def->alttitle, value);
for (value = def->alttitle; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces.
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
ADDDEF(alttitle);
}
else if (!stricmp(stoken, "authors"))
{
STRBUFCPY(def->authors, value);
for (value = def->authors; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces.
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
ADDDEF(authors);
}
else
CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
skip_field:
stoken = strtok(NULL, "\r\n= ");
line++;
#undef ADDDEF
}
}
free(buf2);
return;
return true;
}
void S_LoadMusicDefs(UINT16 wadnum)
{
UINT16 lumpnum;
char *lump;
char *musdeftext;
size_t size;
char *lf;
char *stoken;
size_t nlf;
size_t ncr;
musicdef_t *def = NULL;
int line = 1; // for better error msgs
for (int k = 0; k < 2; k++)
{
lumpnum = W_CheckNumForNamePwad((k == 1 ? "MUSCINFO" : "MUSICDEF") , wadnum, 0); //check for MUSCINFO lump on 2nd iteration
if (lumpnum == INT16_MAX)
continue;
lump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
size = W_LumpLengthPwad(wadnum, lumpnum);
// Null-terminated MUSICDEF lump.
musdeftext = malloc(size+1);
if (!musdeftext)
I_Error("S_LoadMusicDefs: No more free memory for the parser\n");
M_Memcpy(musdeftext, lump, size);
musdeftext[size] = '\0';
// Find music def
stoken = musdeftext;
for (;;)
{
lf = strpbrk(stoken, "\r\n");
if (lf)
{
if (*lf == '\n')
nlf = 1;
else
nlf = 0;
*lf++ = '\0';/* now we can delimit to here */
}
stoken = strtok(stoken, " ");
if (stoken)
{
if (! ReadMusicDefFields(wadnum, line, stoken, &def))
break;
}
if (lf)
{
do
{
line += nlf;
ncr = strspn(lf, "\r");/* skip CR */
lf += ncr;
nlf = strspn(lf, "\n");
lf += nlf;
}
while (nlf || ncr) ;
stoken = lf;/* now the next nonempty line */
}
else
break;/* EOF */
}
free(musdeftext);
}
}
//
@@ -1500,164 +1494,6 @@ void S_InitMusicDefs(void)
S_LoadMusicDefs(i);
}
//
// search for music definition in wad
//
static UINT16 W_CheckForMusicInfoInPwad(UINT16 wadid)
{
UINT16 i;
lumpinfo_t *lump_p;
lump_p = wadfiles[wadid]->lumpinfo;
for (i = 0; i < wadfiles[wadid]->numlumps; i++, lump_p++)
if (memcmp(lump_p->name, "MUSCINFO", 8) == 0)
return i;
return INT16_MAX; // not found
}
void S_LoadMTDefs(UINT16 wadnum)
{
UINT16 lump;
char *buf;
char *buf2;
char *stoken;
char *value;
size_t size;
musicdef_t *def, *prev;
UINT16 line = 1; // for better error msgs
lump = W_CheckForMusicInfoInPwad(wadnum);
if (lump == INT16_MAX)
return;
buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
size = W_LumpLengthPwad(wadnum, lump);
// for strtok
buf2 = malloc(size+1);
if (!buf2)
I_Error("S_LoadMTDefs: No more free memory\n");
M_Memcpy(buf2,buf,size);
buf2[size] = '\0';
def = prev = NULL;
stoken = strtok (buf2, "\r\n ");
// Find music def
while (stoken)
{
if (!stricmp(stoken, "lump"))
{
value = strtok(NULL, "\r\n ");
if (!value)
{
CONS_Alert(CONS_WARNING, "MUSICDEF: Lump '%s' is missing name. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_lump;
}
// No existing musicdefs
if (!musicdefstart)
{
musicdefstart = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
STRBUFCPY(musicdefstart->name, value);
strlwr(musicdefstart->name);
def = musicdefstart;
//CONS_Printf("S_LoadMusicDefs: Initialized musicdef w/ song '%s'\n", def->name);
}
else
{
def = musicdefstart;
// Search if this is a replacement
//CONS_Printf("S_LoadMusicDefs: Searching for song replacement...\n");
while (def)
{
if (!stricmp(def->name, value))
{
//CONS_Printf("S_LoadMusicDefs: Found song replacement '%s'\n", def->name);
break;
}
prev = def;
def = def->next;
}
// Nothing found, abort.
if (!def)
{
CONS_Alert(CONS_WARNING, "MUSCINFO: Music def for '%s' does not exist. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
free(buf2);
return;
}
}
skip_lump:
stoken = strtok(NULL, "\r\n ");
line++;
}
else
{
value = strtok(NULL, "\r\n= ");
if (!value)
{
CONS_Alert(CONS_WARNING, "MUSCINFO: Field '%s' is missing value. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_field;
}
if (!def)
{
CONS_Alert(CONS_ERROR, "MUSCINFO: No music definition before field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
free(buf2);
return;
}
if (!stricmp(stoken, "title"))
{
def->use_info = true;
STRBUFCPY(def->title, value);
for (value = def->title; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces.
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
}
else if (!stricmp(stoken, "alttitle"))
{
STRBUFCPY(def->alttitle, value);
for (value = def->alttitle; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces.
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
}
else if (!stricmp(stoken, "authors"))
{
STRBUFCPY(def->authors, value);
for (value = def->authors; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces.
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
}
else
CONS_Alert(CONS_WARNING, "MUSCINFO: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
skip_field:
stoken = strtok(NULL, "\r\n= ");
line++;
}
}
free(buf2);
return;
}
void S_InitMTDefs(void)
{
UINT16 i;
for (i = 0; i < numwadfiles; i++)
S_LoadMTDefs(i);
}
//
// S_FindMusicCredit
//
@@ -1665,19 +1501,17 @@ void S_InitMTDefs(void)
//
musicdef_t *S_FindMusicCredit(const char *musname)
{
musicdef_t *def = musicdefstart;
UINT32 hash = quickncasehash (musname, 6);
musicdef_t *def;
if (!def) // No definitions
return NULL;
while (def)
for (def = musicdefstart; def; def = def->next)
{
if (!stricmp(def->name, musname))
{
return def;
}
else
def = def->next;
if (hash != def->hash)
continue;
if (stricmp(def->name, musname))
continue;
return def;
}
return NULL;
@@ -1966,6 +1800,15 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
{
char newmusic[7] = {0};
struct MusicChange hook_param = {
newmusic,
&mflags,
&looping,
&position,
&prefadems,
&fadeinms
};
if (S_MusicDisabled()
|| demo.rewinding // Don't mess with music while rewinding!
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music
@@ -1975,7 +1818,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
S_CheckEventMus(newmusic);
if (LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms))
if (LUA_HookMusicChange(music_name, &hook_param))
return;
// No Music (empty string)
@@ -2048,10 +1891,7 @@ void S_StopMusic(void)
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music
return;
if (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0))
mapmusresume = I_GetSongPosition();
else
mapmusresume = 0;
mapmusresume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0)) ? I_GetSongPosition() : 0;
if (I_SongPaused())
I_ResumeSong();
@@ -2186,18 +2026,21 @@ boolean S_FadeOutStopMusic(UINT32 ms)
return false;
}*/
static INT16 oldmap = 0;
static boolean oldencore = false;
static boolean skipmusic = false;
boolean skipintromus = false;
static const char *musicexception_list[16] = {
static const char *musicexception_list[17] = {
"vote", "voteea", "voteeb", "racent", "krwin",
"krok", "krlose", "krfail", "kbwin", "kbok",
"kblose", "kstart", "estart", "wait2j", "CHRSHP",
"CHRSHF"
"kblose", "kstart", "estart", "wait2j", "titles",
"CHRSHF", "CHRSHP" // no clue what those are tbh
};
void S_ResetKeepAndSpecialMus(void)
{
keepmusic = skipintromus = false;
}
//checks for any kind of event music like intermission, vote etc.
//always runs when musicchange gets invoked
static void S_CheckEventMus(const char *newmus)
@@ -2207,22 +2050,25 @@ static void S_CheckEventMus(const char *newmus)
if (!cv_keepmusic.value)
return;
for (int i = 0; i < 16; i++)
for (int i = 0; i < 17; i++)
if (stricmp(music_name, musicexception_list[i]) == 0 || stricmp(newmus, musicexception_list[i]) == 0) // weird? sure! but were lucky enough newmus reflects whats being replaced
{
skipmusic = true;
break;
}
//CONS_Printf("musname = %s\n", music_name);
//CONS_Printf("music_name = %s\n", music_name);
//CONS_Printf("newmus = %s\n", newmus);
//CONS_Printf("newmus = %d\n", skipmusic);
//CONS_Printf("skipmusic = %d\n", skipmusic);
}
//this one compares map and encoremode instead of the music itself
//makes tunes work and stuff
void S_CheckMap(void)
{
static INT16 oldmap = 0;
static boolean oldencore = false;
if (!cv_keepmusic.value)
{
keepmusic = false;
@@ -2231,6 +2077,8 @@ void S_CheckMap(void)
keepmusic = (!skipmusic && gamestate == GS_LEVEL && oldmap == gamemap && oldencore == encoremode);
//CONS_Printf("keepmusic = %s\n", keepmusic);
oldencore = encoremode;
oldmap = gamemap;
}
@@ -2242,15 +2090,7 @@ void S_CheckMap(void)
//
void S_InitMapMusic(void)
{
if (!cv_skipintromusic.value)
skipintromus = false;
else
{
char *maptitle = G_BuildMapTitle(gamemap);
skipintromus = cv_skipintromusic.value && stricmp(maptitle, "Wandering Falls") != 0; // thanks diggle!
if (maptitle)
Z_Free(maptitle);
}
skipintromus = false;
if (mapmusflags & MUSIC_RELOADRESET)
{
@@ -2268,6 +2108,15 @@ void S_InitMapMusic(void)
// lug: but not when we keep the map music lol
S_StopMusic();
if (cv_skipintromusic.value)
{
char *maptitle = G_BuildMapTitle(gamemap);
// for some reason, occasionally the title screen music doesent seem to be reset in time, so skipping the intro may make it just continue playing it instead, weird..
skipintromus = (stricmp(music_name, "titles") != 0) && (maptitle && (stricmp(maptitle, "Wandering Falls") != 0)); // thanks diggle!
if (maptitle)
Z_Free(maptitle);
}
if (skipintromus)
return;
@@ -2276,13 +2125,13 @@ void S_InitMapMusic(void)
//S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusposition, 0, 0);
}
void S_StartMapMusic(boolean restore)
void S_StartMapMusic(void)
{
//no need to constantly run this after race has started
if (leveltime > MUSICSTARTTIME)
return;
if (keepmusic && !restore) // make sure this doesent kill the music when its called from P_RestoreMusic in some cases
if (keepmusic)
return;
if (skipintromus)
@@ -2317,6 +2166,8 @@ void S_RestartMusic(void)
S_SetMusicVolume(cv_digmusicvolume.value, cv_midimusicvolume.value);
#endif
S_ResetKeepAndSpecialMus();
if (Playing()) // Gotta make sure the player is in a level
P_RestoreMusic(&players[consoleplayer]);
else
@@ -2421,6 +2272,8 @@ static void Command_RestartAudio_f(void)
S_StartSound(NULL, sfx_strpst);
S_ResetKeepAndSpecialMus();
if (Playing()) // Gotta make sure the player is in a level
P_RestoreMusic(&players[consoleplayer]);
else
@@ -2498,6 +2351,8 @@ static void GameDigiMusic_OnChange(void)
I_StartupSound(); // will return early if initialised
I_InitMusic();
S_ResetKeepAndSpecialMus();
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
else
@@ -2583,6 +2438,9 @@ static void GameMIDIMusic_OnChange(void)
{
midi_disabled = false;
I_InitMusic();
S_ResetKeepAndSpecialMus();
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
else
+14 -1
View File
@@ -109,8 +109,10 @@ void S_InitSfxChannels(INT32 sfxVolume);
void S_StopSounds(void);
void S_ClearSfx(void);
void S_ResetKeepAndSpecialMus(void);
void S_InitMapMusic(void);
void S_StartMapMusic(boolean restore);
void S_StartMapMusic(void);
void S_CheckMap(void);
@@ -168,6 +170,7 @@ boolean S_SpeedMusic(float speed);
typedef struct musicdef_s
{
char name[7];
UINT32 hash;
char usage[256];
char source[256];
char filename[256+1];
@@ -228,6 +231,16 @@ UINT32 S_GetMusicPosition(void);
// Music Playback
//
/* this is for the sake of the hook */
struct MusicChange {
char * newname;
UINT16 * mflags;
boolean * looping;
UINT32 * position;
UINT32 * prefadems;
UINT32 * fadeinms;
};
// Start music track, arbitrary, given its name, and set whether looping
// note: music flags 12 bits for tracknum (gme, other formats with more than one track)
// 13-15 aren't used yet
+5 -2
View File
@@ -273,10 +273,13 @@ void SCR_Recalc(void)
vid.fsmalldupy = vid.smalldupy*FRACUNIT;
#endif
// toggle off automap because some screensize-dependent values will
// toggle off (then back on) the automap because some screensize-dependent values will
// be calculated next time the automap is activated.
if (automapactive)
AM_Stop();
{
am_recalc = true;
AM_Start();
}
// set the screen[x] ptrs on the new vidbuffers
V_Init();
Loaded 100 of 116 files, more files were not shown because too many files have changed in this diff. Show more