MCPcopy Create free account
hub / github.com/boazy/TWEditorEnhanced / decodeStruct

Method decodeStruct

src/main/java/Database.java:409–438  ·  view source on GitHub ↗
(String label, int index)

Source from the content-addressed store, hash-verified

407 }
408
409 private DBElement decodeStruct(String label, int index)
410 throws DBException
411 {
412 if (index >= this.structArrayCount) {
413 throw new DBException(this.name + ": Structure index " + index + " exceeds array size");
414 }
415
416 int offset = 12 * index;
417 int id = getInteger(this.structBuffer, offset);
418 int fieldIndex = getInteger(this.structBuffer, offset + 4);
419 int fieldCount = getInteger(this.structBuffer, offset + 8);
420 DBList list = new DBList(fieldCount);
421 if (fieldCount == 1) {
422 DBElement field = decodeField(fieldIndex);
423 list.addElement(field);
424 } else if (fieldCount > 1) {
425 offset = fieldIndex;
426 for (int i = 0; i < fieldCount; i++) {
427 if (offset + 4 > this.fieldIndicesLength) {
428 throw new DBException("Field indices offset " + offset + " exceeds indices size");
429 }
430 fieldIndex = getInteger(this.fieldIndicesBuffer, offset);
431 offset += 4;
432 DBElement field = decodeField(fieldIndex);
433 list.addElement(field);
434 }
435 }
436
437 return new DBElement(14, id, label, list);
438 }
439
440 private DBElement decodeList(String label, int offset)
441 throws DBException

Callers 3

loadMethod · 0.95
decodeFieldMethod · 0.95
decodeListMethod · 0.95

Calls 3

getIntegerMethod · 0.95
decodeFieldMethod · 0.95
addElementMethod · 0.95

Tested by

no test coverage detected