summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2009-10-03 12:06:47 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:41 +0000
commit5230a896570005a68dc0c7dd82215f01f9ee6c86 (patch)
treec56a0b94b59cb1d235d4c49e38e5714784f15ff7 /src/game
parent706c4fbac3b80c5499d5e09df9087a5af65e84e7 (diff)
* (bug 3606) Partial fix for this bug: spawns explode when near other buildables
* Prevent building a spawn in a place where it would explode by unbreaking such checks during G_CheckSpawnPoint() (thanks DevHC) * When a new buildable is created that blocks an existing spawn, have the spawn kill the new buildable instead of killing itself. * Ideally someone would be prevented from building something to cause this case, but as no one has yet come up with an acceptable implementation, this change is an improvement to prevent griefer use of the bug until then.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_buildable.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 8e5d0ad4..e9434056 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -691,8 +691,14 @@ void ASpawn_Think( gentity_t *self )
if( ( ent = G_CheckSpawnPoint( self->s.number, self->s.origin,
self->s.origin2, BA_A_SPAWN, NULL ) ) != NULL )
{
- if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD ||
- ent->s.eType == ET_MOVER )
+ // If the thing blocking the spawn is a buildable, kill it.
+ // If it's part of the map, kill self.
+ if( ent->s.eType == ET_BUILDABLE )
+ {
+ G_Damage( ent, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE );
+ G_SetBuildableAnim( self, BANIM_SPAWN1, qtrue );
+ }
+ else if( ent->s.number == ENTITYNUM_WORLD || ent->s.eType == ET_MOVER )
{
G_Damage( self, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE );
return;
@@ -2304,8 +2310,14 @@ void HSpawn_Think( gentity_t *self )
if( ( ent = G_CheckSpawnPoint( self->s.number, self->s.origin,
self->s.origin2, BA_H_SPAWN, NULL ) ) != NULL )
{
- if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD ||
- ent->s.eType == ET_MOVER )
+ // If the thing blocking the spawn is a buildable, kill it.
+ // If it's part of the map, kill self.
+ if( ent->s.eType == ET_BUILDABLE )
+ {
+ G_Damage( ent, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE );
+ G_SetBuildableAnim( self, BANIM_SPAWN1, qtrue );
+ }
+ else if( ent->s.number == ENTITYNUM_WORLD || ent->s.eType == ET_MOVER )
{
G_Damage( self, NULL, NULL, NULL, NULL, self->health, 0, MOD_SUICIDE );
return;
@@ -2940,10 +2952,6 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
if( tr1.entityNum != ENTITYNUM_WORLD )
reason = IBE_NORMAL;
- //check there is enough room to spawn from (presuming this is a spawn)
- if( G_CheckSpawnPoint( -1, origin, normal, buildable, NULL ) != NULL )
- reason = IBE_NORMAL;
-
contents = trap_PointContents( entity_origin, -1 );
buildPoints = BG_Buildable( buildable )->buildPoints;
@@ -3050,6 +3058,13 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
if( ( tempReason = G_SufficientBPAvailable( buildable, origin ) ) != IBE_NONE )
reason = tempReason;
+ // Relink buildables
+ G_SetBuildableLinkState( qtrue );
+
+ //check there is enough room to spawn from (presuming this is a spawn)
+ if( G_CheckSpawnPoint( ENTITYNUM_NONE, origin, normal, buildable, NULL ) != NULL )
+ reason = IBE_NORMAL;
+
//this item does not fit here
if( reason == IBE_NONE && ( tr2.fraction < 1.0 || tr3.fraction < 1.0 ) )
reason = IBE_NOROOM;
@@ -3057,9 +3072,6 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
if( reason != IBE_NONE )
level.numBuildablesForRemoval = 0;
- // Relink buildables
- G_SetBuildableLinkState( qtrue );
-
return reason;
}