TONPPAMF

The Official NPPAngband And NPPMoria Forum

You are not logged in.

Announcement

November 28, 2016 - NPPAngband forum has been migrated to a new host. SSL has been enabled so please use https:// if possible.

#1 2013-11-16 21:51:53

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Convert flags to array

In the various structs, convert the flags1, flags2, flags3, etc to flags[].  To keep things sane and not have the numbers shift, make the "native" flags variable into flags[0].

So, in object_kind, the following

	u32b k_flags1;		/* Flags, set 1 */
	u32b k_flags2;		/* Flags, set 2 */
	u32b k_flags3;		/* Flags, set 3 */
	u32b k_native;		/* Flags, native */

into

 	u32b k_flags[4];	/* Flags */

where k_flags[0] is k_native.

Offline

#2 2013-11-18 08:01:19

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: Convert flags to array

That is probably a coding improvement, but that would be an awful lot of work.  Would also have to do it in the object, ego item, and artifact structures as well.  It would be replacing thousands of lines of code. 

I like the idea of, when the code is in C++, adding functions to the structure to replace all the bitflags.  You could just have if (r_ptr->unique) with a function checking the bitflag for the monster race.

Offline

#3 2013-11-18 21:38:37

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: Convert flags to array

Also useful would be adding the feat_ffn_match to all of the other types.

Offline

#4 2013-11-22 13:59:59

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: Convert flags to array

Is there a better solution when this becomes a C++ codebase?

Offline

#5 2013-12-01 01:42:42

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: Convert flags to array

Sure.

You make the flags a virtual class, define a 'flags' array, write a match function "ffMatch(int group, int flag)" where 'group' corresponds to n in FFn in it, then inherit this class in all of the classes that use flags.

Offline

Board footer

Powered by FluxBB