summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/bg_misc.c31
-rw-r--r--src/game/bg_public.h1
-rw-r--r--src/game/g_buildable.c55
-rw-r--r--src/game/g_cmds.c36
-rw-r--r--src/game/g_local.h13
5 files changed, 102 insertions, 34 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 77265f7e..e805fb2d 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -939,6 +939,7 @@ buildableAttributes_t bg_buildableList[ ] =
BIT_DROIDS,
EV_ITEM_GROW,
100,
+ qfalse,
qfalse
},
{
@@ -955,7 +956,8 @@ buildableAttributes_t bg_buildableList[ ] =
BIT_DROIDS,
EV_ITEM_GROW,
100,
- qtrue
+ qtrue,
+ qfalse
},
{
BA_H_SPAWN,
@@ -971,6 +973,7 @@ buildableAttributes_t bg_buildableList[ ] =
BIT_HUMANS,
EV_NONE,
-1,
+ qfalse,
qfalse
},
{
@@ -987,6 +990,7 @@ buildableAttributes_t bg_buildableList[ ] =
BIT_HUMANS,
EV_NONE,
50,
+ qfalse,
qfalse
},
{
@@ -1003,6 +1007,7 @@ buildableAttributes_t bg_buildableList[ ] =
BIT_HUMANS,
EV_NONE,
-1,
+ qfalse,
qfalse
},
{
@@ -1019,7 +1024,8 @@ buildableAttributes_t bg_buildableList[ ] =
BIT_HUMANS,
EV_NONE,
-1,
- qfalse
+ qfalse,
+ qtrue
},
{
BA_H_REPEATER,
@@ -1035,6 +1041,7 @@ buildableAttributes_t bg_buildableList[ ] =
BIT_HUMANS,
EV_NONE,
-1,
+ qfalse,
qfalse
}
};
@@ -1308,6 +1315,26 @@ int BG_FindCreepTestForBuildable( int bclass )
return qfalse;
}
+/*
+==============
+BG_FindReactorTestForBuildable
+==============
+*/
+int BG_FindReactorTestForBuildable( int bclass )
+{
+ int i;
+
+ for( i = 0; i < bg_numBuildables; i++ )
+ {
+ if( bg_buildableList[ i ].buildNum == bclass )
+ {
+ return bg_buildableList[ i ].reactorTest;
+ }
+ }
+
+ return qfalse;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////
classAttributes_t bg_classList[ ] =
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 67dc864b..dfdf86a3 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -764,6 +764,7 @@ typedef struct
int nextthink;
qboolean creepTest;
+ qboolean reactorTest;
} buildableAttributes_t;
// included in both the game dll and the client
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 8b5c0b82..388e8edc 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -448,18 +448,17 @@ itemFits
Checks to see if an item fits in a specific area
================
*/
-qboolean itemFits( gentity_t *ent, buildable_t buildable, int distance )
+itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance )
{
- vec3_t forward;
- vec3_t angles;
- vec3_t player_origin, entity_origin;
- vec3_t mins, maxs;
- vec3_t temp_v;
- trace_t tr1, tr2;
- int i;
- gentity_t *creepent;
- qboolean creeptest;
- qboolean nearcreep = qfalse;
+ vec3_t forward;
+ vec3_t angles;
+ vec3_t player_origin, entity_origin;
+ vec3_t mins, maxs;
+ vec3_t temp_v;
+ trace_t tr1, tr2;
+ int i;
+ itemBuildError_t reason = IBE_NONE;
+ gentity_t *tempent;
VectorCopy( ent->s.apos.trBase, angles );
angles[PITCH] = 0; // always forward
@@ -473,28 +472,38 @@ qboolean itemFits( gentity_t *ent, buildable_t buildable, int distance )
trap_Trace( &tr1, entity_origin, mins, maxs, entity_origin, ent->s.number, MASK_PLAYERSOLID );
trap_Trace( &tr2, player_origin, NULL, NULL, entity_origin, ent->s.number, MASK_PLAYERSOLID );
+ if( tr1.fraction < 1.0 || tr2.fraction < 1.0 )
+ reason = IBE_NOROOM;
+
if( BG_FindCreepTestForBuildable( buildable ) )
{
- for ( i = 1, creepent = g_entities + i; i < level.num_entities; i++, creepent++ )
+ for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ )
{
- if( !Q_stricmp( creepent->classname, "team_droid_spawn" ) )
+ if( !Q_stricmp( tempent->classname, "team_droid_spawn" ) )
{
- VectorSubtract( entity_origin, creepent->s.origin, temp_v );
+ VectorSubtract( entity_origin, tempent->s.origin, temp_v );
if( VectorLength( temp_v ) <= ( CREEP_BASESIZE * 3 ) )
- {
- nearcreep = qtrue;
break;
- }
+ }
+ }
+
+ if( i >= level.num_entities )
+ reason = IBE_NOCREEP;
+ }
+
+ if( BG_FindReactorTestForBuildable( buildable ) )
+ {
+ for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ )
+ {
+ if( !Q_stricmp( tempent->classname, "team_human_reactor" ) )
+ {
+ reason = IBE_REACTOR;
+ break;
}
}
}
- else
- nearcreep = qtrue;
- if( tr1.fraction >= 1.0 && tr2.fraction >= 1.0 && nearcreep )
- return qtrue;
- else
- return qfalse;
+ return reason;
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 1687504f..759ac058 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1918,10 +1918,20 @@ void Cmd_Build_f( gentity_t *ent )
trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
else
{
- if( itemFits( ent, buildable, -50 ) )
- Build_Item( ent, buildable, -50 );
- else
- trap_SendServerCommand( ent-g_entities, va("print \"Location is not suitable\n\"" ) );
+ switch( itemFits( ent, buildable, -50 ) )
+ {
+ case IBE_NONE:
+ Build_Item( ent, buildable, -50 );
+ break;
+
+ case IBE_NOCREEP:
+ trap_SendServerCommand( ent-g_entities, va("print \"No creep to build on\n\"" ) );
+ break;
+
+ case IBE_NOROOM:
+ trap_SendServerCommand( ent-g_entities, va("print \"Not enough room\n\"" ) );
+ break;
+ }
}
}
else if( ( ent->client->pers.pteam == PTE_HUMANS ) &&
@@ -1934,10 +1944,20 @@ void Cmd_Build_f( gentity_t *ent )
trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
else
{
- if( itemFits( ent, buildable, 80 ) )
- Build_Item( ent, buildable, 80 );
- else
- trap_SendServerCommand( ent-g_entities, va("print \"Location is not suitable\n\"" ) );
+ switch( itemFits( ent, buildable, 80 ) )
+ {
+ case IBE_NONE:
+ Build_Item( ent, buildable, 80 );
+ break;
+
+ case IBE_REACTOR:
+ trap_SendServerCommand( ent-g_entities, va("print \"Only one reactor per map\n\"" ) );
+ break;
+
+ case IBE_NOROOM:
+ trap_SendServerCommand( ent-g_entities, va("print \"Not enough room\n\"" ) );
+ break;
+ }
}
}
else if( ent->client->pers.pteam == PTE_NONE )
diff --git a/src/game/g_local.h b/src/game/g_local.h
index c4fb81a6..1ce85c83 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -468,7 +468,18 @@ void SaveRegisteredItems( void );
//
// g_buildable.c
//
-qboolean itemFits( gentity_t *ent, buildable_t buildable, int distance );
+typedef enum
+{
+ IBE_NONE,
+
+ IBE_NOROOM,
+ IBE_NOCREEP,
+ IBE_REACTOR,
+
+ IBE_MAXERRORS
+} itemBuildError_t;
+
+itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance );
gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance );
//