Debian Codegraph @

src/uk/me/parabola/imgfmt/app/mdr/Mdr13.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2009.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 or
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13 package uk.me.parabola.imgfmt.app.mdr;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import uk.me.parabola.imgfmt.app.ImgFileWriter;
19
20 /**
21 * Holds all the regions for each map.
22 *
23 * @author Steve Ratcliffe
24 */
25 public class Mdr13 extends MdrSection implements HasHeaderFlags {
26 private final List<Mdr13Record> regions = new ArrayList<>();
27
28 public Mdr13(MdrConfig config) {
29 setConfig(config);
30 }
31
32 public void addRegion(Mdr13Record rec) {
33 regions.add(rec);
34 }
35
36 public void writeSectData(ImgFileWriter writer) {
37 regions.sort(null);
38
39 for (Mdr13Record region : regions) {
40 putMapIndex(writer, region.getMapIndex());
41 writer.put2u(region.getRegionIndex());
42 writer.put2u(region.getCountryIndex());
43 putStringOffset(writer, region.getStrOffset());
44 }
45 }
46
47 public int getItemSize() {
48 return getSizes().getMapSize() + 4 + getSizes().getStrOffSize();
49 }
50
51 /**
52 * The number of records in this section.
53 *
54 * @return The number of items in the section.
55 */
56 protected int numberOfItems() {
57 return regions.size();
58 }
59
60 @Override
61 public int getExtraValue() {
62 return 0x00;
63 }
64
65 public List<Mdr13Record> getRegions() {
66 return regions;
67 }
68 }