On Fri, Mar 2, 2012 at 00:13, Stephen LARROQUE <lrq3...@gmail.com> wrote: > Hello, > > I am currently trying to make a server-side demos patch for OpenArena which > should be completely compatible with standard ioquake3. > > My goal is almost achieved, but I face one last problem: the health is not > updated in the HUD when spectating a democlient. Every other stat is (eg: > ammos, armor, etc.), except health. > > I could track down the problem, and it seems that even if there is a > playerState_t->stats[STAT_HEALTH] field, contrary to the others such as > STAT_ARMOR, this one is not directly used, and most of the time it's > gentity_t->health that is taken in account for damage processing and health > drawing. > > I know I can edit the gamecode, but I would like the patch to be fully > managed server-side to ensure a full compatibility with mods. > > My question is: do you guys know of a way to access, and set, the health > field from gentity_t from the engine? > > I tried to cast a sharedEntity_t into a gentity_t, but without much result, > the values are completely off. > > Thank you for reading me, > Stephen L.
How and where do you cast it? It should (could!) work provided that you take the field offset into account. Your code should look something like this: #define offset_of(type, member) \ ((intptr_t) ((char *) &(((type *) 8)->member) - 8)) #define container_of(ptr, type, member) \ ((type *) ((char *) (ptr) - offset_of(type, member))) gentity_t *as_gent(entityShared_t *shared_ent) { return container_of(shared_ent, entityShared_t, r); } _______________________________________________ ioquake3 mailing list ioquake3@lists.ioquake.org http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org By sending this message I agree to love ioquake3 and libsdl.