summaryrefslogtreecommitdiff
path: root/src/game/bg_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/bg_misc.c')
-rw-r--r--src/game/bg_misc.c105
1 files changed, 105 insertions, 0 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
===============
*/