Question about affected_type structure

Login to reply  Page: « < 1 of 1 > »
08 Mar 2010 - 20:332413
Question about affected_type structure
In structs.h, the affected data type includes this declaration for the affect.bitvector variable:
long /*bitvector_t*/bitvector; /**< Tells which bits to set (AFF_XXX). */
It appears that bitvector_t (which was defined above as an unsigned long int) is commented out, so an accurate declaration (I think) would be:
long bitvector;
Is this "long variable" really "long int variable"? If so, this means that affected_by structs are only supported for up to 32 AFF_ types.

Also, the player "affected_by" variable is an array:
int affected_by[AF_ARRAY_MAX]
Since the player affect variable is an array of size 4 (default), this means that players can be affected by up to 32*4 (128) different affects. This is supported by the utilities SET_BIT_AR, REMOVE_BIT_AR, and IS_SET_AR.

So if affected_type.bitvector only supports 32 different affect flags, why does affected_by support 128?

And, more importantly, is there an easy way to expand affected_type.bitvector to support 128 different affect types?

Thanks


11 Mar 2010 - 21:082416
You are right. THe affected structure only supports 32 bits.

What's needed for expanding it, you say?

Let's give it a thought:
Affect bitvectors are stored in a couple of places:
They're stored to mobs. This already supports affects in 128 bits.
They're stored on objects as "PERM" flags. This already supports 128 bits.
They're used on players (AFF_FLAGS). This already supports 128 bits.
They're stored as affects in the player files. This only supports 32 bits.
They're used in the affect struct, as you discovered. This only supports 32 bits.

The 32-bit data from the affect struct are added and subtracted from mobs and players through affect_modify() which is called some 4 different places in the code. A 128 bit solution for this, called affect_modify_ar(), exists but does not seem to be in use.

The affects are saved with 32 bits in save_char() and read as 32 bits in load_char().


To sum it up - apparently only things dealing directly with the affected structure need to be changed:
The affected structure needs to switch to int[AF_ARRAY_MAX] instead of long
Calls to affect_modify() needs to be using affect_modify_ar() instead.
save_char() and load_char() needs updating, so affects are saved correctly with all 4 ints.

So, in short, it's not very complicated.

disclaimer: I have no performed the task...


__________________
You know who I am.
Login to reply  Page: « < 1 of 1 > »