Bug Tracker – Bug 409

r567 Spectator check

Last modified: 2008-05-16 05:34:56 UTC
Bug 409 - r567 Spectator check
Summary: r567 Spectator check
Status: RESOLVED FIXED
Alias: None
Product: Odamex
Classification: Unclassified
Component: Server & Client (show other bugs)
Version: (old) 0.x Alpha
Hardware: All All
: P2 normal
Assignee: Nes
URL:
Depends on:
Blocks:
 
Reported: 2008-04-13 16:31 UTC by Nes
Modified: 2008-05-16 05:34 UTC (History)
3 users (show)

See Also:

Attachments

Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this bug.
Description Nes 2008-04-13 16:31:27 UTC
This bug is for the recently committed spectator code. If you see any spectator-related problems, feel free to comment in this bug.

One bug I can't figure out how to solve is an obvious one (when playing): Spectators joining the game will show WHERE the joined by a corpse dying at their location. It would be pretty funny to see someone freaking out because a corpse died in front of him, but it's not supposed to happen.
Comment 1 GhostlyDeath 2008-04-13 18:58:20 UTC
About crushers crushing specs spewing blood everywhere and the crushers being slowed, adding the following to common/p_map.cc:1774 seems to fix it (in PIT_ChangeSector)

================================================================================
	// GhostlyDeath -- if it's a spectator, keep checking
	if (thing->player && thing->player->spectator)
		return true;
================================================================================
Comment 2 Nes 2008-04-13 19:11:47 UTC
(In reply to comment #1)
> About crushers crushing specs spewing blood everywhere and the crushers being
> slowed, adding the following to common/p_map.cc:1774 seems to fix it (in
> PIT_ChangeSector)
> 
> ================================================================================
>         // GhostlyDeath -- if it's a spectator, keep checking
>         if (thing->player && thing->player->spectator)
>                 return true;
> ================================================================================
> 

Fix r569. Thanks.
Comment 3 GhostlyDeath 2008-04-14 01:11:04 UTC
Fixed the body bug, hopefully I didn't screw up when I made the patch...

================================================================================
diff -u -r client/src/p_interaction.cpp client/src/p_interaction.cpp
--- client/src/p_interaction.cpp	2008-04-14 04:07:20.000000000 -0400
+++ client/src/p_interaction.cpp	2008-04-14 03:48:34.000000000 -0400
@@ -992,6 +992,10 @@
 
 	target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY);
 
+	// GhostlyDeath -- Joinkill is only set on players, so we should be safe!
+	if (joinkill)
+		target->flags |= MF_SPECTATOR;
+
 	if (target->type != MT_SKULL)
 		target->flags &= ~MF_NOGRAVITY;
 
diff -u -r client/src/p_mobj.cpp client/src/p_mobj.cpp
--- client/src/p_mobj.cpp	2008-04-14 04:07:21.000000000 -0400
+++ client/src/p_mobj.cpp	2008-04-14 03:42:08.000000000 -0400
@@ -775,6 +775,10 @@
 {
 	if(!subsector)
 		return;
+		
+	// GhostlyDeath -- Was a spectator but now it's nothing!
+	if ((this->flags & MF_SPECTATOR ) && !player)
+		P_SetMobjState(this, S_NULL);
 
 	// [RH] Fade a stealth monster in and out of visibility
 	if (visdir > 0)
@@ -1115,7 +1119,7 @@
 	P_SetupPsprites (p);
 
 	if (p->spectator)
-		p->mo->flags |= MF_INVISIBLE;
+		p->mo->flags |= MF_SPECTATOR;
 
 	// give all cards in death match mode
 	if (deathmatch)
diff -u -r client/src/r_things.cpp client/src/r_things.cpp
--- client/src/r_things.cpp	2008-04-14 04:07:20.000000000 -0400
+++ client/src/r_things.cpp	2008-04-14 03:38:51.000000000 -0400
@@ -683,7 +683,7 @@
 	// [RH] Tutti-Frutti fix (also allows sprites up to 256 pixels tall)
 	dc_mask = 0xff;
 
-	if (vis->mobjflags & MF_INVISIBLE)
+	if (vis->mobjflags & MF_SPECTATOR)
 		return;
 
 	if (vis->patch == -1)
diff -u -r common/actor.h common/actor.h
--- common/actor.h	2008-04-14 04:06:59.000000000 -0400
+++ common/actor.h	2008-04-14 03:35:56.000000000 -0400
@@ -197,8 +197,8 @@
     //  use a translation table for player colormaps
     MF_TRANSLATION  	= 0xc000000,
 
-    // GhostlyDeath -- thing is invisible and can't be seen!
-    MF_INVISIBLE		= 0x40000000,
+    // GhostlyDeath -- thing is/was a spectator and can't be seen!
+    MF_SPECTATOR		= 0x40000000,
 	
 	// a frozen corpse (for blasting) [RH] was 0x800000
 	MF_ICECORPSE		= 0x80000000
diff -u -r common/p_map.cpp common/p_map.cpp
--- common/p_map.cpp	2008-04-14 04:06:59.000000000 -0400
+++ common/p_map.cpp	2008-04-14 03:38:46.000000000 -0400
@@ -399,7 +399,7 @@
 	if (thing == tmthing)
 		return true;
 
-	if (thing->flags & MF_INVISIBLE)
+	if (thing->flags & MF_SPECTATOR)
 		return true;
 
 	if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_SHOOTABLE)) )
diff -u -r server/src/p_interaction.cpp server/src/p_interaction.cpp
--- server/src/p_interaction.cpp	2008-04-14 04:07:08.000000000 -0400
+++ server/src/p_interaction.cpp	2008-04-14 03:48:22.000000000 -0400
@@ -954,6 +954,10 @@
 	AActor *mo;
 
 	target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY);
+	
+	// GhostlyDeath -- Joinkill is only set on players, so we should be safe!
+	if (joinkill)
+		target->flags |= MF_SPECTATOR;
 
 	if (target->type != MT_SKULL)
 		target->flags &= ~MF_NOGRAVITY;
diff -u -r server/src/p_mobj.cpp server/src/p_mobj.cpp
--- server/src/p_mobj.cpp	2008-04-14 04:07:08.000000000 -0400
+++ server/src/p_mobj.cpp	2008-04-14 03:41:57.000000000 -0400
@@ -781,6 +781,10 @@
 {
 	if (type == MT_PLAYER && health <= 0)
 		deadtic++;
+		
+	// GhostlyDeath -- Was a spectator but now it's nothing!
+	if ((this->flags & MF_SPECTATOR ) && !player)
+		P_SetMobjState(this, S_NULL);
 
 	// remove dead players but don't tell clients about it
 	if (type == MT_PLAYER && !player && deadtic >= REMOVECOPRSESTIC)
@@ -1145,7 +1149,7 @@
 	}
 
 	if (p->spectator)
-		p->mo->flags |= MF_INVISIBLE;
+		p->mo->flags |= MF_SPECTATOR;
 
 	if(serverside)
 	{
diff -u -r server/src/sv_main.cpp server/src/sv_main.cpp
--- server/src/sv_main.cpp	2008-04-14 04:07:08.000000000 -0400
+++ server/src/sv_main.cpp	2008-04-14 03:57:09.000000000 -0400
@@ -973,6 +973,8 @@
 		ok = true;
 	else if(!mo->player)
 		ok = true;
+	else if (mo->flags & MF_SPECTATOR)	// GhostlyDeath -- Spectating things
+		ok = false;
 	else if(player.mo && mo->player && mo->player->spectator)
 		ok = false;
 	else if(player.mo && mo->player && SV_IsTeammate(player, *mo->player))
@@ -1045,7 +1047,10 @@
 //
 bool SV_IsPlayerAllowedToSee(player_t &p, AActor *mo)
 {
-	return std::find(mo->players_aware.begin(), mo->players_aware.end(), p.id) != mo->players_aware.end();
+	if (mo->flags & MF_SPECTATOR)
+		return false; // GhostlyDeath -- always false, as usual!
+	else
+		return std::find(mo->players_aware.begin(), mo->players_aware.end(), p.id) != mo->players_aware.end();
 }
 
 #define HARDWARE_CAPABILITY 1000

================================================================================

Comment 4 Russell Rice 2008-04-14 01:12:30 UTC
Please make it an attachment of the bug.. don't post it directly in here.

Also, spectator breaks demos in singleplayer
Comment 5 Nes 2008-04-14 12:32:32 UTC
(In reply to comment #3)
> Fixed the body bug, hopefully I didn't screw up when I made the patch...
> 
> ================================================================================
> STUFF
> ================================================================================
> 

Looks like you didn't screw up. (But please upload patches rather than posting it here)

Fix r572.
Comment 6 Denis Lukianov 2008-05-03 06:13:37 UTC
reassigning to Nes
Comment 7 Denis Lukianov 2008-05-16 05:34:56 UTC
marking fixed