splitscreen: tweak view drawing: use player's cursectnum and simulate z clamping.

Using the players's cursectnum instead of "updating" the sectnum means that it
won't glitch on SoS.  The z clamping (basically a port of some code from
G_DrawRooms) is so that the view won't be drawn from under the floor when shrunk.

git-svn-id: https://svn.eduke32.com/eduke32@2939 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-08-20 21:23:48 +00:00
parent 627476541b
commit d24aad08dc
3 changed files with 49 additions and 26 deletions

View file

@ -40,6 +40,7 @@ gamevar pid 1 0 // This hold player 2 id
gamevar pnum 0 0 // This is set to player 2 sprite number gamevar pnum 0 0 // This is set to player 2 sprite number
// Temp variables // Temp variables
gamevar tmp 0 0
gamevar px 0 0 // Player (both 1 and 2) X coordinate gamevar px 0 0 // Player (both 1 and 2) X coordinate
gamevar py 0 0 // Player Y coordinate gamevar py 0 0 // Player Y coordinate
gamevar pz 0 0 // Player Z coordinate gamevar pz 0 0 // Player Z coordinate
@ -269,37 +270,55 @@ define ORIENT 1032 // 26
define P1X 4 define P1X 4
define P2X 164 define P2X 164
gamevar arg_player_id 0 0
state show_player_view
getplayer[arg_player_id].posx px
getplayer[arg_player_id].posy py
getplayer[arg_player_id].posz pz
getplayer[arg_player_id].ang pang
getplayer[arg_player_id].horiz phoriz
getplayer[arg_player_id].horizoff phorizoff
addvarvar phoriz phorizoff
// simulate corresponding part in G_DrawRooms (almost)
ifvarvare player[arg_player_id].spritebridge 0
{
setvarvar tmp player[arg_player_id].truecz
addvar tmp 1024
ifvarvarl pz tmp
setvarvar pz tmp
else
{
setvarvar tmp player[arg_player_id].truefz
subvar tmp 1024
ifvarvarg pz tmp
setvarvar pz tmp
}
}
getplayer[arg_player_id].cursectnum psect
ifvarg psect -1
{
ifvare arg_player_id 0
showviewunbiased px py pz pang phoriz psect 0 0 160 199
else
showviewunbiased px py pz pang phoriz psect 160 0 319 199
}
ends
onevent EVENT_DISPLAYROOMS onevent EVENT_DISPLAYROOMS
setvar RETURN 1 // don't draw them setvar RETURN 1 // don't draw them
// an EDuke32 hack now: // an EDuke32 hack now:
// setplayer[THISACTOR].rotscrnang 0 // (almost) Prevent the screen rotation when player 1 die // setplayer[THISACTOR].rotscrnang 0 // (almost) Prevent the screen rotation when player 1 die
// Took this code from the wiki // DRAW THE PLAYER VIEWS!
// It show player 1 view setvar arg_player_id 0
getplayer[THISACTOR].posx px state show_player_view
getplayer[THISACTOR].posy py setvar arg_player_id 1
getplayer[THISACTOR].posz pz state show_player_view
getplayer[THISACTOR].ang pang
getplayer[THISACTOR].horiz phoriz
getplayer[THISACTOR].horizoff phorizoff
addvarvar phoriz phorizoff
updatesector px py psect
ifvarg psect -1
showviewunbiased px py pz pang phoriz psect 0 0 160 199
// -------------------------------------
// Player 2 view
getplayer[pid].posx px
getplayer[pid].posy py
getplayer[pid].posz pz
getplayer[pid].ang pang
getplayer[pid].horiz phoriz
getplayer[pid].horizoff phorizoff
addvarvar phoriz phorizoff
updatesector px py psect
ifvarg psect -1
showviewunbiased px py pz pang phoriz psect 160 0 319 199
// -------------------------------------
// Draw crosshairs if they are enabled // Draw crosshairs if they are enabled
getuserdef[THISACTOR].crosshair pcrosshair getuserdef[THISACTOR].crosshair pcrosshair

View file

@ -3574,6 +3574,9 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
ud.camerahoriz = 100+sprite[p->newowner].shade; ud.camerahoriz = 100+sprite[p->newowner].shade;
else if (p->spritebridge == 0) else if (p->spritebridge == 0)
{ {
// NOTE: when shrunk, p->pos.z can be below the floor. This puts the
// camera into the sector again then.
if (ud.camera.z < (p->truecz + (4<<8))) if (ud.camera.z < (p->truecz + (4<<8)))
ud.camera.z = cz + (4<<8); ud.camera.z = cz + (4<<8);
else if (ud.camera.z > (p->truefz - (4<<8))) else if (ud.camera.z > (p->truefz - (4<<8)))

View file

@ -5022,7 +5022,6 @@ void P_ProcessInput(int32_t snum)
} }
} }
} }
else else
{ {
p->falling_counter = 0; p->falling_counter = 0;
@ -5308,6 +5307,8 @@ HORIZONLY:
P_CheckTouchDamage(p, j); P_CheckTouchDamage(p, j);
} }
// This makes the player view lower when shrunk. NOTE that it can get the
// view below the sector floor (and does, when on the ground).
if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk)
p->pos.z += 32<<8; p->pos.z += 32<<8;