diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_misc.c | 105 | ||||
-rw-r--r-- | src/game/bg_public.h | 3 | ||||
-rw-r--r-- | src/game/g_weapon.c | 17 |
3 files changed, 113 insertions, 12 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 8ce10291..d969fea1 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -3464,6 +3464,111 @@ int atoi_neg( char *token, qboolean allowNegative ) /* =============== +BG_PackZapTargets + +pack up to 12 entityNums into an entityState_t +=============== +*/ +void BG_PackZapTargets( entityState_t *es, int *entityNums, int count ) +{ + int i; + es->misc = es->time = es->time2 = es->constantLight = 0; + for( i = 0; i < MAX_GENTITYNUM_PACK; i++ ) + { + int entityNum = ENTITYNUM_NONE; + if( i < count ) + entityNum = entityNums[i]; + if( entityNum & ~(GENTITYNUM_MASK) ) + { + Com_Printf("Warning: BG_PackZapTargets: entityNums[%d] (%d) doesn't fit in %d bits, using ENTITYNUM_NONE", + i, entityNums[i], GENTITYNUM_BITS); + entityNum = ENTITYNUM_NONE; + } + switch( i ) + { + case 0: + es->misc |= entityNum; + break; + case 1: + es->time |= entityNum; + break; + case 2: + es->time |= entityNum << GENTITYNUM_BITS; + break; + case 3: + es->time |= entityNum << (GENTITYNUM_BITS * 2); + break; + case 4: + es->time2 |= entityNum; + break; + case 5: + es->time2 |= entityNum << GENTITYNUM_BITS; + break; + case 6: + es->time2 |= entityNum << (GENTITYNUM_BITS * 2); + break; + case 7: + es->constantLight |= entityNum; + break; + case 8: + es->constantLight |= entityNum << GENTITYNUM_BITS; + break; + case 9: + es->constantLight |= entityNum << (GENTITYNUM_BITS * 2); + } + } +} + +/* +=============== +BG_UnpackZapTargets + +unpacks the 12 entityNums in an entityState_t +=============== +*/ +void BG_UnpackZapTargets( entityState_t *es, int *entityNums, int count ) +{ + int i; + for( i = 0; i < count; i++ ) + { + switch( i ) + { + case 0: + entityNums[i] = es->misc & GENTITYNUM_MASK; + break; + case 1: + entityNums[i] = es->time & GENTITYNUM_MASK; + break; + case 2: + entityNums[i] = (es->time >> GENTITYNUM_BITS) & GENTITYNUM_MASK; + break; + case 3: + entityNums[i] = (es->time >> (GENTITYNUM_BITS * 2)) & GENTITYNUM_MASK; + break; + case 4: + entityNums[i] = es->time2 & GENTITYNUM_MASK; + break; + case 5: + entityNums[i] = (es->time2 >> GENTITYNUM_BITS) & GENTITYNUM_MASK; + break; + case 6: + entityNums[i] = (es->time2 >> (GENTITYNUM_BITS * 2)) & GENTITYNUM_MASK; + break; + case 7: + entityNums[i] = es->constantLight & GENTITYNUM_MASK; + break; + case 8: + entityNums[i] = (es->constantLight >> GENTITYNUM_BITS) & GENTITYNUM_MASK; + break; + case 9: + entityNums[i] = (es->constantLight >> (GENTITYNUM_BITS * 2)) & GENTITYNUM_MASK; + break; + } + } +} + +/* +=============== BG_ParseCSVEquipmentList =============== */ diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 57803a24..2ec0435d 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -1114,6 +1114,9 @@ int BG_PlayerPoisonCloudTime( playerState_t *ps ); weapon_t BG_GetPlayerWeapon( playerState_t *ps ); qboolean BG_HasEnergyWeapon( playerState_t *ps ); +void BG_PackZapTargets( entityState_t *es, int *entityNums, int count ); +void BG_UnpackZapTargets( entityState_t *es, int *entityNums, int count ); + const buildableAttributes_t *BG_BuildableByName( const char *name ); const buildableAttributes_t *BG_BuildableByEntityName( const char *name ); const buildableAttributes_t *BG_Buildable( buildable_t buildable ); diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index 1c58e212..a9849572 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -1149,7 +1149,7 @@ static gentity_t *G_FindNewZapTarget( gentity_t *ent ) } } - return NULL; + return &g_entities[ ENTITYNUM_NONE ]; } /* @@ -1161,27 +1161,20 @@ static void G_UpdateZapEffect( zap_t *zap ) { int j; gentity_t *effect = zap->effectChannel; + int targets[MAX_ZAP_TARGETS + 1]; effect->s.eType = ET_LEV2_ZAP_CHAIN; effect->classname = "lev2zapchain"; G_SetOrigin( effect, zap->creator->s.origin ); - effect->s.misc = zap->creator->s.number; - - effect->s.time = effect->s.time2 = effect->s.constantLight = -1; + targets[ 0 ] = zap->creator->s.number; for( j = 0; j < zap->numTargets; j++ ) { int number = zap->targets[ j ]->s.number; - - switch( j ) - { - case 0: effect->s.time = number; break; - case 1: effect->s.time2 = number; break; - case 2: effect->s.constantLight = number; break; - default: break; - } + targets[ j + 1 ] = number; } + BG_PackZapTargets( &effect->s, targets, zap->numTargets ); trap_LinkEntity( effect ); } |