Thread: item db
View Single Post
  #7  
Old 10-15-2003, 10:49 AM
Merth
Dragon
 
Join Date: May 2003
Location: Seattle, WA
Posts: 609
Default

Hmm, I don't believe that algorithm will work. Go with the post above by LethalEncounter. The field is a bitfield, and you can use bitmask operators to determine the classes that can use it.

I don't feel like writing a novel to explain bitfield operators, so hopefully sample code will do. Bitfield operators differ from language to language, but here they are in c++:

Code:
// Class number from classes.h
#define ROGUE        9

// Create a number with only the rogue bit turned on
uint32 rogue_mask = (1 << (ROGUE-1));

// Apply mask to 'classes' field to see if rogue bit is turned on
uint32 val = (rogue_mask & MyClassesValue);

if (val == rogue_mask)
   // .. item can be used by rogues
Reply With Quote