mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-21 20:18:14 +07:00
Fixed item Type class adding incorrect bits
Fixed item Type class adding incorrect bits Removed support for Type adding it's own children in favor of a static method that can recurse better
This commit is contained in:
parent
abdaa45db0
commit
90c992899f
@ -9,48 +9,55 @@ public class Type extends Bits {
|
|||||||
static {
|
static {
|
||||||
TYPES = new Type[128];
|
TYPES = new Type[128];
|
||||||
for (int i = 0, size = Riiablo.files.ItemTypes.size(); i < size; i++) {
|
for (int i = 0, size = Riiablo.files.ItemTypes.size(); i < size; i++) {
|
||||||
if (TYPES[i] == null) TYPES[i] = new Type(Riiablo.files.ItemTypes.get(i));
|
build(TYPES, Riiablo.files.ItemTypes.get(i).Code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Type build(Type[] types, String type) {
|
||||||
|
int id = Riiablo.files.ItemTypes.index(type);
|
||||||
|
if (types[id] != null) {
|
||||||
|
return types[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
Type t = types[id] = new Type();
|
||||||
|
t.set(id);
|
||||||
|
|
||||||
|
ItemTypes.Entry entry = Riiablo.files.ItemTypes.get(id);
|
||||||
|
for (String equiv : entry.Equiv) {
|
||||||
|
if (equiv.isEmpty()) break;
|
||||||
|
t.or(build(types, equiv));
|
||||||
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
public static Type get(ItemTypes.Entry type) {
|
public static Type get(ItemTypes.Entry type) {
|
||||||
return get(type.Code);
|
return get(type.Code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type get(String type) {
|
public static Type get(String type) {
|
||||||
return TYPES[Riiablo.files.ItemTypes.index(type)];
|
|
||||||
}
|
|
||||||
|
|
||||||
Type(String type) {
|
|
||||||
super(128);
|
|
||||||
setAll(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
Type(ItemTypes.Entry type) {
|
|
||||||
this(type.Code);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setAll(String type) {
|
|
||||||
int id = Riiablo.files.ItemTypes.index(type);
|
int id = Riiablo.files.ItemTypes.index(type);
|
||||||
if (TYPES[id] != null) {
|
return TYPES[id];
|
||||||
or(TYPES[id]);
|
}
|
||||||
return;
|
|
||||||
} else {
|
Type() {
|
||||||
TYPES[id] = this;
|
super(128);
|
||||||
set(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemTypes.Entry entry = Riiablo.files.ItemTypes.get(id);
|
|
||||||
for (String equiv : entry.Equiv) {
|
|
||||||
if (equiv.isEmpty()) break;
|
|
||||||
setAll(equiv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean is(int index) {
|
public boolean is(int index) {
|
||||||
return get(index);
|
return get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (int i = -1; (i = nextSetBit(i + 1)) != -1;) {
|
||||||
|
builder.append(Riiablo.files.ItemTypes.get(i).Code).append(',');
|
||||||
|
}
|
||||||
|
if (builder.length() > 0) builder.setLength(builder.length() - 1);
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public static final int SHIE = Riiablo.files.ItemTypes.index("shie");
|
public static final int SHIE = Riiablo.files.ItemTypes.index("shie");
|
||||||
public static final int TORS = Riiablo.files.ItemTypes.index("tors");
|
public static final int TORS = Riiablo.files.ItemTypes.index("tors");
|
||||||
public static final int GOLD = Riiablo.files.ItemTypes.index("gold");
|
public static final int GOLD = Riiablo.files.ItemTypes.index("gold");
|
||||||
|
Loading…
Reference in New Issue
Block a user