13 .StatusEffects statuseffects;
15 .StatusEffects statuseffects_store;
19 const int StatusEffects_groups_minor = 8;
20 const int StatusEffects_groups_major = 4;
27 if (StatusEffects_groups_minor / 8 !=
floor(StatusEffects_groups_minor / 8))
28 error(
"StatusEffects_groups_minor is not a multiple of 8.");
30 if (StatusEffects_groups_major < min_major_value)
31 error(sprintf(
"StatusEffects_groups_major can not be < %d.", min_major_value));
36 #define G_MAJOR(id) (floor((id) / StatusEffects_groups_minor)) 37 #define G_MINOR(id) ((id) % StatusEffects_groups_minor) 42 void StatusEffects_entremove(
entity this)
44 if(g_statuseffects ==
this)
45 g_statuseffects =
NULL;
48 NET_HANDLE(ENT_CLIENT_STATUSEFFECTS,
bool isnew)
51 g_statuseffects =
this;
52 this.entremove = StatusEffects_entremove;
53 const int majorBits = Readbits(StatusEffects_groups_major);
54 for (
int i = 0; i < StatusEffects_groups_major; ++i) {
55 if (!(majorBits &
BIT(i))) {
58 const int minorBits = Readbits(StatusEffects_groups_minor);
59 for (
int j = 0; j < StatusEffects_groups_minor; ++j) {
60 if (!(minorBits &
BIT(j))) {
64 this.statuseffect_time[it.
m_id] = ReadFloat();
65 this.statuseffect_flags[it.
m_id] = ReadByte();
73 int SEFminorBitsArr[StatusEffects_groups_major];
82 for (
int i = 0; i < StatusEffects_groups_major; ++i)
83 SEFminorBitsArr[i] = 0;
87 .float fld = statuseffect_time[it.m_id];
88 .int flg = statuseffect_flags[it.m_id];
89 const bool changed = (store.(fld) != data.(fld) || store.(flg) != data.(flg));
90 store.(fld) = data.(fld);
91 store.(flg) = data.(flg);
93 int maj = G_MAJOR(it.m_id);
94 majorBits =
BITSET(majorBits,
BIT(maj),
true);
95 SEFminorBitsArr[maj] =
BITSET(SEFminorBitsArr[maj],
BIT(G_MINOR(it.m_id)),
true);
99 Writebits(MSG_ENTITY, majorBits, StatusEffects_groups_major);
100 for (
int i = 0; i < StatusEffects_groups_major; ++i)
102 if (!(majorBits &
BIT(i)))
105 const int minorBits = SEFminorBitsArr[i];
106 Writebits(MSG_ENTITY, minorBits, StatusEffects_groups_minor);
107 for (
int j = 0; j < StatusEffects_groups_minor; ++j)
109 if (!(minorBits &
BIT(j)))
113 WriteFloat(MSG_ENTITY, data.statuseffect_time[it.m_id]);
114 WriteByte(MSG_ENTITY, data.statuseffect_flags[it.m_id]);
127 WriteHeader(MSG_ENTITY, ENT_CLIENT_STATUSEFFECTS);
128 StatusEffects_Write(
this, to.statuseffects_store);
132 bool StatusEffects_customize(
entity this,
entity client)
135 return (client.statuseffects ==
this);
138 void StatusEffects_new(
entity this)
141 this.statuseffects = eff;
143 if(this.statuseffects_store)
145 setcefc(eff, StatusEffects_customize);
146 Net_LinkEntity(eff,
false, 0, StatusEffects_Send);
149 void StatusEffects_delete(
entity e) {
delete(e.statuseffects); e.statuseffects =
NULL; }
151 void StatusEffects_update(
entity e) { e.statuseffects.SendFlags = 0xFFFFFF; }
154 void StatusEffects_clearall(
entity store)
161 store.statuseffect_time[it.m_id] = 0;
162 store.statuseffect_flags[it.m_id] = 0;
166 void StatusEffectsStorage_attach(
entity e) { e.statuseffects_store =
NEW(
StatusEffects); e.statuseffects_store.drawonlytoclient = e; }
167 void StatusEffectsStorage_delete(
entity e) {
delete(e.statuseffects_store); e.statuseffects_store =
NULL; }
174 if(this.statuseffects && this.statuseffects.owner ==
this)
175 StatusEffects_delete(
this);
184 void StatusEffects_tick(
entity actor);
202 void StatusEffects_removeall(
entity actor,
int removal_type);
#define REGISTER_NET_LINKED(id)
#define REGISTER_MUTATOR(id, dependence)
#define REGISTRY_GET(id, i)
#define NET_HANDLE(id, param)
#define STATIC_INIT(func)
during worldspawn
#define REGISTRY_COUNT(id)
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
#define BITSET(var, mask, flag)
void ONREMOVE(entity this)
#define FOREACH(list, cond, body)