Hi Gerd, Ticker

For ImgFileWriter I think we should just have put1(int), put2(int), put3(int)
and put4(int) and remove put(byte), putChar(char) and putInt(int).

So each method takes an int, so no casting is needed.  There is no
difference between writing unisigned and signed for any value
that fits into an int.

To write unsigned values greater than 2G then technically you
need a long, so an unsigned version could be added as a
default method on the interface put4u(long val) rather than
having to implement across multiple implementations.

Although I don't think it is necessary if you want to add
signed/unsigned methods that range check the value, then
again add them as default method on the interface.

I've attached a patch that implements this.

Reading is different, we do need signed/unsigned versions.
I'd suggest that again have get{1,2,3,4} and remove getChar and
getInt special cases, and then get1u() etc for unsigned results.
All of these returning int probably, depending on what results
in the best looking code.  I have not done a patch for that.

..Steve

we have various methods to write an integer with 1, 2, 3, or 4 bytes to an img 
file.
I always feel unsure what method to use because none of them makes
clear what happens with negative values.

Besides that some of the existing routines seem to throw misleading exceptions,
e.g. FileBackedImgFileWriter seems to assume that it is only used for the mdr 
tmp file and creates texts like this:
throw new MapFailedException("could not write3 to mdr tmp file");
throw new MapFailedException("could not write put3 to mdr tmp file");

Only the javadoc for put1() and put2() tell me the range (0..255 or 0..65535) .

If I got that right put3() allows negative values, so I think it is NOT 
0..16777215 but -8388608 .. 8388607 ?

I'd like to improve the readability of the code, but I don't want to mess up 
anything.
Would it be possible to add comments to all the methods?

Gerd



_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


Index: src/uk/me/parabola/imgfmt/app/dem/DEMHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/dem/DEMHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/dem/DEMHeader.java	(date 1518972751000)
@@ -55,12 +55,12 @@
 		}
 		writer.position(pos);
 		
-		writer.putInt(0); // 0: elevation in metres, 1: foot
+		writer.put4(0); // 0: elevation in metres, 1: foot
 		writer.put2(zoomLevels.size());
-		writer.putInt(0); // unknown
+		writer.put4(0); // unknown
 		writer.put2(60); // size of zoom level record
-		writer.putInt(offset); // offset to first DemSection header (they appear at the end of the file!)
-		writer.putInt(1); // unknown, 0 and 1 spotted
+		writer.put4(offset); // offset to first DemSection header (they appear at the end of the file!)
+		writer.put4(1); // unknown, 0 and 1 spotted
 		
 	}
 
Index: src/uk/me/parabola/imgfmt/app/dem/DEMSection.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/dem/DEMSection.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/dem/DEMSection.java	(date 1518972751000)
@@ -183,28 +183,28 @@
 	}
 
 	public void writeHeader(ImgFileWriter writer) {
-		writer.put(unknown1);	//0x00 
-		writer.put1(zoomLevel);	//0x01 
-		writer.putInt(pointsPerLat);	//0x02
-		writer.putInt(pointsPerLon);	//0x06 
-		writer.putInt(nonStdHeight - 1);	//0x0A
-		writer.putInt(nonStdWidth - 1);	//0x0E 
+		writer.put1(unknown1);	//0x00
+		writer.put1(zoomLevel);	//0x01
+		writer.put4(pointsPerLat);	//0x02
+		writer.put4(pointsPerLon);	//0x06
+		writer.put4(nonStdHeight - 1);	//0x0A
+		writer.put4(nonStdWidth - 1);	//0x0E
 		writer.put2(flags1);	//0x12
-		writer.putInt(tilesLon - 1);	//0x14
-		writer.putInt(tilesLat - 1);	//0x18
+		writer.put4(tilesLon - 1);	//0x14
+		writer.put4(tilesLat - 1);	//0x18
 		
 		writer.put2(recordDesc);	//0x1c
 		writer.put2(tileDescSize);	//0x1e
-		writer.putInt(dataOffset);	//0x20
-		writer.putInt(dataOffset2);	//0x24
-		writer.putInt(left);	//0x28 
-		writer.putInt(top);	//0x2c 
-		writer.putInt(pointsDistanceLat);	//0x30
-		writer.putInt(pointsDistanceLon);	//0x34
+		writer.put4(dataOffset);	//0x20
+		writer.put4(dataOffset2);	//0x24
+		writer.put4(left);	//0x28
+		writer.put4(top);	//0x2c
+		writer.put4(pointsDistanceLat);	//0x30
+		writer.put4(pointsDistanceLon);	//0x34
 		assert minHeight >= Short.MIN_VALUE && minHeight <= Short.MAX_VALUE; 
-		writer.putChar((char) minHeight);	//0x38
+		writer.put2(minHeight);	//0x38
 		assert maxHeight >= Short.MIN_VALUE && maxHeight <= Short.MAX_VALUE; 
-		writer.putChar((char) maxHeight);	//0x3a
+		writer.put2(maxHeight);	//0x3a
 	}
 
 	public void writeRest(ImgFileWriter writer) {
Index: src/uk/me/parabola/imgfmt/app/dem/DEMTile.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/dem/DEMTile.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/dem/DEMTile.java	(date 1518972751000)
@@ -406,15 +406,15 @@
 			writer.put3(offset);
 			break;
 		default:
-			writer.putInt(offset);
+			writer.put4(offset);
 		}
 		if (baseSize == 1)
-			writer.put((byte) baseHeight);
+			writer.put1(baseHeight);
 		else 
-			writer.putChar((char) baseHeight);
+			writer.put2(baseHeight);
 		writer.putN(deltaSize, maxDeltaHeight);
 		if (hasExtra)
-			writer.put(encodingType);
+			writer.put1(encodingType);
 	}
 
 	public void writeBitStreamData(ImgFileWriter writer) {
Index: src/uk/me/parabola/imgfmt/app/lbl/City.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/City.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/City.java	(date 1518971130000)
@@ -63,8 +63,8 @@
 		//writer.put3()
 		if (pointRef) {
 		    //		    System.err.println("City point = " + (int)pointIndex + " div = " + subdivision.getNumber());
-			writer.put(pointIndex);
-			writer.putChar((char)subdivision.getNumber());
+			writer.put1(pointIndex);
+			writer.put2(subdivision.getNumber());
 		} else {
 			writer.put3(label.getOffset());
 		}
@@ -77,7 +77,7 @@
 		if (pointRef)
 			info |= POINT_REF;
 
-		writer.putChar(info);
+		writer.put2(info);
 	}
 
 	public int getIndex() {
Index: src/uk/me/parabola/imgfmt/app/lbl/ExitFacility.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/ExitFacility.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/ExitFacility.java	(date 1518971137000)
@@ -51,9 +51,9 @@
 		word |= type << 24;	 // 24:27 = 4 bit type
 		// 28 = unknown
 		word |= direction << 29; // 29:31 = 3 bit direction
-		writer.putChar((char)word);
-		writer.putChar((char)(word >> 16));
-		writer.put((byte)facilities);
+		writer.put2(word);
+		writer.put2(word >> 16);
+		writer.put1(facilities);
 	}
 
 	public int getIndex() {
Index: src/uk/me/parabola/imgfmt/app/lbl/Highway.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/Highway.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/Highway.java	(date 1518971130000)
@@ -63,19 +63,19 @@
 
 	void write(ImgFileWriter writer, boolean extraData) {
 		if(extraData) {
-			writer.put((byte)0);
-			writer.putChar(region == null? 0 : region.getIndex());
+			writer.put1(0);
+			writer.put2(region == null? 0 : region.getIndex());
 			Collections.sort(exits);
 			for(ExitPoint ep : exits) {
-			    writer.put(ep.index);
-			    writer.putChar((char)ep.div.getNumber());
+			    writer.put1(ep.index);
+			    writer.put2(ep.div.getNumber());
 			}
 		}
 		else {
 			assert extraDataOffset != 0;
 			writer.put3(label.getOffset());
-			writer.putChar((char)extraDataOffset);
-			writer.put((byte)0); // unknown (setting any of 0x3f stops exits being found)
+			writer.put2(extraDataOffset);
+			writer.put1(0); // unknown (setting any of 0x3f stops exits being found)
 		}
 	}
 
Index: src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java	(date 1518971532000)
@@ -71,7 +71,7 @@
 		position(LBLHeader.HEADER_LEN + lblHeader.getSortDescriptionLength());
 
 		// The zero offset is for no label.
-		getWriter().put((byte) 0);
+		getWriter().put1(0);
 		alignForNext();
 
 		places.init(this, lblHeader.getPlaceHeader());
@@ -91,7 +91,7 @@
 
 		// Text can be put between the header and the body of the file.
 		writer.put(Utils.toBytes(sort.getDescription()));
-		writer.put((byte) 0);
+		writer.put1(0);
 		assert writer.position() == LBLHeader.HEADER_LEN + lblHeader.getSortDescriptionLength();
 	}
 
@@ -157,7 +157,7 @@
 	private void alignForNext() {
 		// Align ready for next label
 		while ((getCurrentLabelOffset() & ((1 << offsetMultiplier) - 1)) != 0)
-			getWriter().put((byte) 0);
+			getWriter().put1(0);
 	}
 
 	private int getNextLabelOffset() {
Index: src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java	(date 1518972751000)
@@ -109,32 +109,32 @@
 	 */
 	protected void writeFileHeader(ImgFileWriter writer) {
 		// LBL1 section, these are regular labels
-		writer.putInt(HEADER_LEN + sortDescriptionLength);
-		writer.putInt(getLabelSize());
+		writer.put4(HEADER_LEN + sortDescriptionLength);
+		writer.put4(getLabelSize());
 
-		writer.put((byte) offsetMultiplier);
-		writer.put((byte) encodingType);
+		writer.put1(offsetMultiplier);
+		writer.put1(encodingType);
 
 		placeHeader.writeFileHeader(writer);
 
-		writer.putChar((char) getCodePage());
+		writer.put2(getCodePage());
 
 		// Identifying the sort
 		char id1 = (char) sort.getId1();
-		writer.putChar(id1);
+		writer.put2(id1);
 		
 		char id2 = (char) sort.getId2();
 		if (id1 != 0 && id2 != 0)
 			id2 |= 0x8000;
-		writer.putChar(id2);
+		writer.put2(id2);
 
-		writer.putInt(HEADER_LEN);
-		writer.putInt(sortDescriptionLength);
+		writer.put4(HEADER_LEN);
+		writer.put4(sortDescriptionLength);
 
-		writer.putInt(placeHeader.getLastPos());
-		writer.putInt(0);
-		writer.putChar(UNK3_REC_LEN);
-		writer.putChar((char) 0);
+		writer.put4(placeHeader.getLastPos());
+		writer.put4(0);
+		writer.put2(UNK3_REC_LEN);
+		writer.put2(0);
 	}
 
 	protected int getEncodingType() {
Index: src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java	(date 1518970533000)
@@ -117,7 +117,7 @@
 		int numPoiIndexEntries = 0;
 		for (int i = 0; i < 256; ++i) {
 			if(poiIndex[i] != null) {
-				writer.put((byte)i);
+				writer.put1(i);
 				writer.put3(numPoiIndexEntries + 1);
 				numPoiIndexEntries += poiIndex[i].size();
 			}
Index: src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java	(date 1518972751000)
@@ -60,29 +60,29 @@
 	}
 
 	void writeFileHeader(ImgFileWriter writer) {
-		writer.putInt(country.getPosition());
-		writer.putInt(country.getSize());
-		writer.putChar(country.getItemSize());
-		writer.putInt(0);
+		writer.put4(country.getPosition());
+		writer.put4(country.getSize());
+		writer.put2(country.getItemSize());
+		writer.put4(0);
 
-		writer.putInt(region.getPosition());
-		writer.putInt(region.getSize());
-		writer.putChar(region.getItemSize());
-		writer.putInt(0);
+		writer.put4(region.getPosition());
+		writer.put4(region.getSize());
+		writer.put2(region.getItemSize());
+		writer.put4(0);
 
-		writer.putInt(city.getPosition());
-		writer.putInt(city.getSize());
-		writer.putChar(city.getItemSize());
-		writer.putInt(0);
+		writer.put4(city.getPosition());
+		writer.put4(city.getSize());
+		writer.put2(city.getItemSize());
+		writer.put4(0);
 
-		writer.putInt(poiIndex.getPosition());
-		writer.putInt(poiIndex.getSize());
-		writer.putChar(poiIndex.getItemSize());
-		writer.putInt(0);
+		writer.put4(poiIndex.getPosition());
+		writer.put4(poiIndex.getSize());
+		writer.put2(poiIndex.getItemSize());
+		writer.put4(0);
 
-		writer.putInt(poiProperties.getPosition());
-		writer.putInt(poiProperties.getSize());
-		writer.put((byte) 0); // offset multiplier
+		writer.put4(poiProperties.getPosition());
+		writer.put4(poiProperties.getSize());
+		writer.put1(0); // offset multiplier
 
 		// mb 5/9/2009 - discovered that Garmin maps can contain more
 		// than 8 bits of POI global flags - have seen the 9th bit set
@@ -91,34 +91,34 @@
 		// of further bytes to read << 1) - therefore, this group
 		// should probably be: 16 bits of POI global flags followed by
 		// 16 zero bits rather than 8 bits of flags and 24 zero bits
-		writer.put(POIGlobalFlags); // properties global mask
-		writer.putChar((char) 0);
-		writer.put((byte) 0);
+		writer.put1(POIGlobalFlags); // properties global mask
+		writer.put2(0);
+		writer.put1(0);
 
-		writer.putInt(poiTypeIndex.getPosition());
-		writer.putInt(poiTypeIndex.getSize());
-		writer.putChar(poiTypeIndex.getItemSize());
-		writer.putInt(0);
+		writer.put4(poiTypeIndex.getPosition());
+		writer.put4(poiTypeIndex.getSize());
+		writer.put2(poiTypeIndex.getItemSize());
+		writer.put4(0);
 
-		writer.putInt(zip.getPosition());
-		writer.putInt(zip.getSize());
-		writer.putChar(zip.getItemSize());
-		writer.putInt(0);
+		writer.put4(zip.getPosition());
+		writer.put4(zip.getSize());
+		writer.put2(zip.getItemSize());
+		writer.put4(0);
 
-		writer.putInt(highway.getPosition());
-		writer.putInt(highway.getSize());
-		writer.putChar(highway.getItemSize());
-		writer.putInt(0);
+		writer.put4(highway.getPosition());
+		writer.put4(highway.getSize());
+		writer.put2(highway.getItemSize());
+		writer.put4(0);
 
-		writer.putInt(exitFacility.getPosition());
-		writer.putInt(exitFacility.getSize());
-		writer.putChar(exitFacility.getItemSize());
-		writer.putInt(0);
+		writer.put4(exitFacility.getPosition());
+		writer.put4(exitFacility.getSize());
+		writer.put2(exitFacility.getItemSize());
+		writer.put4(0);
 
-		writer.putInt(highwayData.getPosition());
-		writer.putInt(highwayData.getSize());
-		writer.putChar(highwayData.getItemSize());
-		writer.putInt(0);
+		writer.put4(highwayData.getPosition());
+		writer.put4(highwayData.getSize());
+		writer.put2(highwayData.getItemSize());
+		writer.put4(0);
 	}
 
 	void readFileHeader(ImgFileReader reader) {
Index: src/uk/me/parabola/imgfmt/app/lbl/POIIndex.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/POIIndex.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/POIIndex.java	(date 1518971130000)
@@ -39,9 +39,9 @@
 	}
 
 	void write(ImgFileWriter writer) {
-		writer.put(poiIndex);
-		writer.putChar((char)group.getNumber());
-		writer.put(subType);
+		writer.put1(poiIndex);
+		writer.put2(group.getNumber());
+		writer.put1(subType);
 	}
 
 	public String getName() {
Index: src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java	(date 1518970612000)
@@ -114,13 +114,13 @@
 		writer.put3(ptr);
 
 		if (POIGlobalFlags != getPOIFlags())
-			writer.put(getWrittenPOIFlags(POIGlobalFlags));
+			writer.put1(getWrittenPOIFlags(POIGlobalFlags));
 
 		if (streetNumberName != null)
 		{
 			int labOff = streetNumberName.getOffset();
-			writer.put((byte)((labOff & 0x7F0000) >> 16));
-			writer.putChar((char)(labOff & 0xFFFF));
+			writer.put1((labOff & 0x7F0000) >> 16);
+			writer.put2(labOff);
 		}
 		else if (simpleStreetNumber.isUsed())
 			simpleStreetNumber.write(writer);
@@ -142,8 +142,8 @@
 		if (complexPhoneNumber != null)
 		{
 			int labOff = complexPhoneNumber.getOffset();
-			writer.put((byte)((labOff & 0x7F0000) >> 16));
-			writer.putChar((char)(labOff & 0xFFFF));
+			writer.put1((labOff & 0x7F0000) >> 16);
+			writer.put2(labOff);
 		}
 		else if (simplePhoneNumber.isUsed())
 			simplePhoneNumber.write(writer);
@@ -341,7 +341,7 @@
 		public void write(ImgFileWriter writer)
 		{
 			for(int i = 0; i < encodedSize; i++)
-				writer.put(encodedNumber[i]);
+				writer.put1(encodedNumber[i]);
 		}
 
 		public boolean isUsed()
Index: src/uk/me/parabola/imgfmt/app/lbl/Region.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/Region.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/lbl/Region.java	(date 1518969113000)
@@ -35,7 +35,7 @@
 	}
 
 	public void write(ImgFileWriter writer) {
-		writer.putChar(country.getIndex());
+		writer.put2(country.getIndex());
 		writer.put3(label.getOffset());
 	}
 
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr1.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr1.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr1.java	(date 1518972751000)
@@ -85,9 +85,9 @@
 	public void writeSectData(ImgFileWriter writer) {
 		boolean revIndex = (getExtraValue() & 1) != 0;
 		for (Mdr1Record rec : maps) {
-			writer.putInt(rec.getMapNumber());
+			writer.put4(rec.getMapNumber());
 			if (revIndex)
-				writer.putInt(rec.getIndexOffset());
+				writer.put4(rec.getIndexOffset());
 		}
 	}
 
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java	(date 1518970637000)
@@ -80,7 +80,7 @@
 				Mdr11Record mdr11ref = t.getMdr11ref();
 				addIndexPointer(mdr11ref.getMapIndex(), count);
 				
-				writer.put((byte) t.getSubtype());
+				writer.put1(t.getSubtype());
 				int offset = mdr11ref.getRecordNumber();
 
 				// Top bit actually represents a non-repeated name.  ie if
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr11.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr11.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr11.java	(date 1518970645000)
@@ -82,8 +82,8 @@
 			poi.setRecordNumber(count++);
 
 			putMapIndex(writer, poi.getMapIndex());
-			writer.put((byte) poi.getPointIndex());
-			writer.putChar((char) poi.getSubdiv());
+			writer.put1(poi.getPointIndex());
+			writer.put2(poi.getSubdiv());
 			writer.put3(poi.getLblOffset());
 			if (poi.isCity())
 				putRegionIndex(writer, poi.getRegionIndex());
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr13.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr13.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr13.java	(date 1518971130000)
@@ -39,8 +39,8 @@
 
 		for (Mdr13Record region : regions) {
 			putMapIndex(writer, region.getMapIndex());
-			writer.putChar((char) region.getRegionIndex());
-			writer.putChar((char) region.getCountryIndex());
+			writer.put2(region.getRegionIndex());
+			writer.put2(region.getCountryIndex());
 			putStringOffset(writer, region.getStrOffset());
 		}
 	}
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr14.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr14.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr14.java	(date 1518971130000)
@@ -35,7 +35,7 @@
 		
 		for (Mdr14Record country : countries) {
 			putMapIndex(writer, country.getMapIndex());
-			writer.putChar((char) country.getCountryIndex());
+			writer.put2(country.getCountryIndex());
 			putStringOffset(writer, country.getStrOff());
 		}
 	}
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr17.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr17.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr17.java	(date 1518971130000)
@@ -73,7 +73,7 @@
 		header += (prefixLength + 1) * (prefixLength + 1);
 		header += (index.getItemSize() - prefixLength - 1) * 0xa;
 
-		writer.putChar((char) header);
+		writer.put2(header);
 		index.writeSectData(writer);
 	}
 
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr18.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr18.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr18.java	(date 1518971296000)
@@ -34,7 +34,7 @@
 	public void writeSectData(ImgFileWriter writer) {
 		int poiSize = getSizes().getSize(19);
 		for (Mdr18Record pt : poiTypes) {
-			writer.putChar((char) (pt.getType() | 0x4000));
+			writer.put2(pt.getType() | 0x4000);
 			writer.putN(poiSize, pt.getRecord());
 		}
 	}
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr1SubHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr1SubHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr1SubHeader.java	(date 1518972751000)
@@ -42,22 +42,22 @@
 	}
 
 	protected void writeFileHeader(ImgFileWriter writer) {
-		writer.putChar((char) HEADER_SIZE);
+		writer.put2(HEADER_SIZE);
 		for (int n = 1; n <= MAX_SECTION; n++) {
 			Section section = sections[n];
 
 			// The second subsection does not have a length, because it always
 			// has the same length as subsection 1.
 			if (n == 2)
-				writer.putInt(section.getPosition());
+				writer.put4(section.getPosition());
 			else {
 				//section.writeSectionInfo(writer);
-				writer.putInt(section.getPosition());
+				writer.put4(section.getPosition());
 				int size = section.getSize();
 				if (size == 0)
-					writer.putInt(0);
+					writer.put4(0);
 				else
-					writer.putInt(size / section.getItemSize());
+					writer.put4(size / section.getItemSize());
 			}
 		}
 	}
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr23.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr23.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr23.java	(date 1518971130000)
@@ -77,8 +77,8 @@
 				lastName = name;
 			}
 
-			writer.putChar((char) reg.getRegionIndex());
-			writer.putChar((char) reg.getCountryIndex());
+			writer.put2(reg.getRegionIndex());
+			writer.put2(reg.getCountryIndex());
 			writer.put3(reg.getLblOffset() | flag);
 		}
 	}
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr24.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr24.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr24.java	(date 1518971130000)
@@ -79,7 +79,7 @@
 				lastName = name;
 			}
 
-			writer.putChar((char) c.getCountryIndex());
+			writer.put2(c.getCountryIndex());
 			writer.put3(c.getLblOffset() | flag);
 		}
 	}
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java	(date 1518969014000)
@@ -64,7 +64,7 @@
 
 				writer.put3(offset);
 				if (writeNameOffset)
-					writer.put(street.getOutNameOffset());
+					writer.put1(street.getOutNameOffset());
 
 				if (partialInfoSize > 0) {
 					int trailingFlags = ((rr & 1) == 0) ? 1 : 0;
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr4.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr4.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr4.java	(date 1518970657000)
@@ -40,9 +40,9 @@
 		Collections.sort(list);
 
 		for (Mdr4Record r : list) {
-			writer.put((byte) r.getType());
-			writer.put((byte) r.getUnknown());
-			writer.put((byte) r.getSubtype());
+			writer.put1(r.getType());
+			writer.put1(r.getUnknown());
+			writer.put1(r.getSubtype());
 		}
 	}
 
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java	(date 1518971130000)
@@ -214,7 +214,7 @@
 			putLocalCityIndex(writer, city.getCityIndex());
 			writer.put3(flag | city.getLblOffset());
 			if (hasRegion)
-				writer.putChar((char) region);
+				writer.put2(region);
 			if (hasString)
 				putStringOffset(writer, city.getStringOffset());
 			writer.putN(size20, city.getMdr20());
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java	(date 1518969014000)
@@ -362,7 +362,7 @@
 				putStringOffset(writer, s.getStringOffset());
 
 			if (hasNameOffset)
-				writer.put(s.getOutNameOffset());
+				writer.put1(s.getOutNameOffset());
 			if (partialInfoSize > 0) {
 				int trailingFlags = ((rr & 1) == 0) ? 1 : 0;
 				// trailingFlags |= s.getB() << 1;
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr8.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr8.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr8.java	(date 1518970665000)
@@ -42,7 +42,7 @@
 		int size = associatedSize();
 		for (Mdr8Record s : index) {
 			for (int i = 0; i< STRING_WIDTH; i++) {
-				writer.put((byte) s.getPrefix()[i]);
+				writer.put1(s.getPrefix()[i]);
 			}
 			writer.putN(size, s.getRecordNumber());
 		}
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr9.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr9.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr9.java	(date 1518970670000)
@@ -35,7 +35,7 @@
 		int poiSize = getSizes().getPoiSize();
 		for (Map.Entry<Integer, Integer> ent : index.entrySet()) {
 			int group = ent.getKey();
-			writer.put((byte) group);
+			writer.put1(group);
 			writer.putN(poiSize, ent.getValue());
 		}
 	}
Index: src/uk/me/parabola/imgfmt/app/mdr/MDRHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/MDRHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/MDRHeader.java	(date 1518971130000)
@@ -57,10 +57,10 @@
 	 * Write out the application header.
 	 */
 	protected void writeFileHeader(ImgFileWriter writer) {
-		writer.putChar((char) sort.getCodepage());
-		writer.putChar((char) sort.getId1());
-		writer.putChar((char) sort.getId2());
-		writer.putChar((char) 14);
+		writer.put2(sort.getCodepage());
+		writer.put2(sort.getId1());
+		writer.put2(sort.getId2());
+		writer.put2(14);
 
 		sections[1].writeSectionInfo(writer, true, true);
 		sections[2].writeSectionInfo(writer, true, true);
@@ -77,7 +77,7 @@
 		sections[13].writeSectionInfo(writer, true, true);
 		sections[14].writeSectionInfo(writer, true, true);
 		sections[15].writeSectionInfo(writer);
-		writer.put((byte) 0);
+		writer.put1(0);
 
 		sections[16].writeSectionInfo(writer, true, true);
 		sections[17].writeSectionInfo(writer, false, true);
Index: src/uk/me/parabola/imgfmt/app/mdr/PrefixIndex.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/PrefixIndex.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/mdr/PrefixIndex.java	(date 1518970682000)
@@ -118,7 +118,7 @@
 		int size = Utils.numberToPointerSize(maxIndex);
 		for (Mdr8Record s : index) {
 			for (int i = 0; i< prefixLength; i++) {
-				writer.put((byte) s.getPrefix()[i]);
+				writer.put1(s.getPrefix()[i]);
 			}
 			writer.putN(size, s.getRecordNumber());
 		}
Index: src/uk/me/parabola/imgfmt/app/net/NETHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/NETHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/NETHeader.java	(date 1518972751000)
@@ -74,17 +74,17 @@
 	protected void writeFileHeader(ImgFileWriter writer) {
 		roadDefinitions.writeSectionInfo(writer);
 
-		writer.put(roadShift); // offset multiplier
+		writer.put1(roadShift); // offset multiplier
 
 		segmentedRoads.writeSectionInfo(writer);
 
-		writer.put(segmentShift); // offset multiplier
+		writer.put1(segmentShift); // offset multiplier
 
 		sortedRoads.writeSectionInfo(writer);
 
-		writer.putInt(0);
-		writer.put((byte) 1);
-		writer.put((byte) 0);
+		writer.put4(0);
+		writer.put1(1);
+		writer.put1(0);
 	}
 
 	ImgFileWriter makeRoadWriter(ImgFileWriter writer) {
Index: src/uk/me/parabola/imgfmt/app/net/NODFile.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/NODFile.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/NODFile.java	(date 1518970696000)
@@ -164,7 +164,7 @@
 		pos = (pos + 0x200) & ~0x1ff; // align on 0x200  
 		int numBytesToWrite = pos - section.getPosition();
 		for (int i = 0; i < numBytesToWrite; i++)
-			getWriter().put((byte)0); 
+			getWriter().put1(0);
 		section.setPosition(pos);
 		ImgFileWriter writer = new SectionWriter(getWriter(), section);
 		
Index: src/uk/me/parabola/imgfmt/app/net/NODHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/NODHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/NODHeader.java	(date 1518972751000)
@@ -109,23 +109,23 @@
 		if(driveOnLeft)
 			flags |= 0x0100;
 		
-		writer.putInt(flags);
+		writer.put4(flags);
 
 		byte align = DEF_ALIGN;
-		writer.put(align);
-		writer.put((byte) 0); // pointer multiplier
-		writer.putChar((char) 5);
+		writer.put1(align);
+		writer.put1(0); // pointer multiplier
+		writer.put2(5);
 
 		roads.writeSectionInfo(writer);
-		writer.putInt(0);
+		writer.put4(0);
 
 		boundary.writeSectionInfo(writer);
 		// new fields for header length > 0x3f
-		writer.putInt(2); // no other value spotted, meaning ?
+		writer.put4(2); // no other value spotted, meaning ?
 		highClassBoundary.writeSectionInfo(writer);
-		writer.putInt(classBoundaries[0]);
+		writer.put4(classBoundaries[0]);
 		for (int i = 1; i < classBoundaries.length; i++){
-			writer.putInt(classBoundaries[i] - classBoundaries[i-1]);
+			writer.put4(classBoundaries[i] - classBoundaries[i-1]);
 		}
 	}
 
Index: src/uk/me/parabola/imgfmt/app/net/RoadDef.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/RoadDef.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/RoadDef.java	(date 1518971532000)
@@ -223,7 +223,7 @@
 		if (numbers != null && numbers.getSwapped()) {
 			netFlags |= 0x20; // swapped default; left=even, right=odd
 		}
-		writer.put((byte) netFlags);
+		writer.put1(netFlags);
 		writer.put3(roadLength);
 
 		int maxlevel = writeLevelCount(writer);
@@ -235,9 +235,9 @@
 			if (nodeCount + 2 != nnodes){
 				log.error("internal error? The nodeCount doesn't match value calculated by RoadNetWork:",this);
 			}
-			writer.put((byte) (nodeCount & 0xff)); // lo bits of node count
+			writer.put1(nodeCount); // lo bits of node count
 
-			int code = ((nodeCount >> 8) & 0x3); // top bits of node count
+			int code = (nodeCount >> 8) & 0x3; // top bits of node count
 			int len, flag;
 			
 			ByteArrayOutputStream zipBuf = null, cityBuf = null;
@@ -264,7 +264,7 @@
 				flag = 3;
 			code |= flag << 6;
 			
-			writer.put((byte)code);
+			writer.put1(code);
 //			System.out.printf("%d %d %d\n", (code >> 2 & 0x3), (code >> 4 & 0x3), (code >> 6 & 0x3));  
 			
 			if (zipBuf != null){
@@ -298,10 +298,10 @@
 			// This is the offset of an entry in NOD2
 			int val = offsetNod2;
 			if (val < 0x7fff) {
-				writer.put((byte) 1);
-				writer.putChar((char) val);
+				writer.put1(1);
+				writer.put2(val);
 			} else {
-				writer.put((byte) 2);
+				writer.put1(2);
 				writer.put3(val);
 			}
 		}
@@ -334,7 +334,7 @@
 			assert b < 0x80 : "too many polylines at level " + i;
 			if (i == maxlevel)
 				b |= 0x80;
-			writer.put((byte) b);
+			writer.put1(b);
 		}
 		return maxlevel;
 	}
@@ -561,7 +561,7 @@
 
 		offsetNod2 = writer.position();
 
-		writer.put((byte) nod2Flags);
+		writer.put1(nod2Flags);
 		writer.put3(node.getOffsetNod1()); // offset in nod1
 
 		// this is related to the number of nodes, but there
@@ -573,7 +573,7 @@
 		int nbits = nnodes;
 		if (!startsWithNode)
 			nbits++;
-		writer.putChar((char) nbits);
+		writer.put2(nbits);
 		boolean[] bits = new boolean[nbits];
 		
 		if (hasHouseNumbers()){
@@ -593,7 +593,7 @@
             for (int j = 0; j < 8 && j < bits.length - i; j++)
 				if (bits[i+j])
 					b |= 1 << j;
-			writer.put((byte) b);
+			writer.put1(b);
 		}
 	}
 
Index: src/uk/me/parabola/imgfmt/app/net/RoadIndex.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/RoadIndex.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/RoadIndex.java	(date 1518970784000)
@@ -43,8 +43,8 @@
 	void write(ImgFileWriter writer) {
 		int roadnum = linkedRoad.getNumber();
 		assert roadnum < 256;
-		writer.put((byte) roadnum);
+		writer.put1(roadnum);
 		char subdivnum = (char) getSubdiv().getNumber();
-		writer.putChar(subdivnum);
+		writer.put2(subdivnum);
 	}
 }
Index: src/uk/me/parabola/imgfmt/app/net/RouteArc.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/RouteArc.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/RouteArc.java	(date 1518970834000)
@@ -258,43 +258,43 @@
 		// determine how to write length and curve bit
 		int[] lendat = encodeLength();
 
-		writer.put(flagA);
+		writer.put1(flagA);
 		if (isInternal()) {
 			// space for 14 bit node offset, written in writeSecond.
-			writer.put(flagB);
-			writer.put((byte) 0);
+			writer.put1(flagB);
+			writer.put1(0);
 		} else {
 			if(indexB < 0 || indexB >= 0x3f) {
-				writer.put((byte) (flagB | 0x3f));
-				writer.put(indexB);
+				writer.put1(flagB | 0x3f);
+				writer.put1(indexB);
 			}
 			else
-				writer.put((byte) (flagB | indexB));
+				writer.put1(flagB | indexB);
 		}
 		
 		 // only write out the local net index if it is the first arc or else if newDir is set.
 		if (first || lastArc.indexA != this.indexA)
-			writer.put(indexA);
+			writer.put1(indexA);
 
 		if(log.isDebugEnabled())
 			log.debug("writing length", length);
 		for (int aLendat : lendat)
-			writer.put((byte) aLendat);
+			writer.put1(aLendat);
 
 		if (first || lastArc.indexA != this.indexA || lastArc.isForward != isForward){
 			if (useCompactDirs){
 				// determine if we have to write direction info
 				if (compactedDir != null)
-					writer.put(compactedDir);
+					writer.put1(compactedDir);
 			} else 
-				writer.put(directionFromDegrees(initialHeading));
+				writer.put1(directionFromDegrees(initialHeading));
 		} else {
 //			System.out.println("skipped writing of initial dir");
 		}
 		if (haveCurve) {
 			int[] curvedat = encodeCurve();
 			for (int aCurvedat : curvedat)
-				writer.put((byte) aCurvedat);
+				writer.put1(aCurvedat);
 		}
 	}
 
@@ -317,8 +317,8 @@
 		// We write this big endian
 		if(log.isDebugEnabled())
 			log.debug("val is", Integer.toHexString((int)val));
-		writer.put((byte) (val >> 8));
-		writer.put((byte) val);
+		writer.put1(val >> 8);
+		writer.put1(val);
 	}
 
 	/*
Index: src/uk/me/parabola/imgfmt/app/net/RouteCenter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/RouteCenter.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/RouteCenter.java	(date 1518969014000)
@@ -124,7 +124,7 @@
 
 			writer.position(pos);
 			log.debug("rewrite taba offset", writer.position(), bo);
-			writer.put(bo);
+			writer.put1(bo);
 
 			// fill in arc pointers
 			node.writeSecond(writer);
@@ -133,11 +133,11 @@
 		writer.position(tablesOffset);
 
 		// Write the tables header
-		writer.put(tabC.getFormat());
+		writer.put1(tabC.getFormat());
 		writer.put3(centralPoint.getLongitude());
 		writer.put3(centralPoint.getLatitude());
-		writer.put(tabA.getNumberOfItems());
-		writer.put(tabB.getNumberOfItems());
+		writer.put1(tabA.getNumberOfItems());
+		writer.put1(tabB.getNumberOfItems());
 
 		tabA.write(writer);
 		tabB.write(writer);
Index: src/uk/me/parabola/imgfmt/app/net/RouteNode.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/RouteNode.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/RouteNode.java	(date 1518972751000)
@@ -195,12 +195,12 @@
 
 		assert (flags & F_DISCARDED) == 0 : "attempt to write discarded node";
 
-		writer.put((byte) 0);  // will be overwritten later
+		writer.put1(0);  // will be overwritten later
 		flags |= (nodeClass & MAX_DEST_CLASS_MASK); // max. road class of any outgoing road
-		writer.put((byte) flags);
+		writer.put1(flags);
 
 		if (haveLargeOffsets()) {
-			writer.putInt((latOff << 16) | (lonOff & 0xffff));
+			writer.put4((latOff << 16) | (lonOff & 0xffff));
 		} else {
 			writer.put3((latOff << 12) | (lonOff & 0xfff));
 		}
Index: src/uk/me/parabola/imgfmt/app/net/RouteRestriction.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/RouteRestriction.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/RouteRestriction.java	(date 1518971130000)
@@ -147,13 +147,13 @@
 	 * 
 	 */
 	public void write(ImgFileWriter writer, int tableOffset) {
-		writer.put(RESTRICTION_TYPE); 
+		writer.put1(RESTRICTION_TYPE);
 
-		writer.put(flags);
-		writer.put((byte)0); // meaning ?
+		writer.put1(flags);
+		writer.put1(0); // meaning ?
 
 		if(exceptMask != 0)
-			writer.put(exceptMask);
+			writer.put1(exceptMask);
 
 		int numArcs = arcs.size();
 		int[] offsets = new int[numArcs+1];
@@ -180,10 +180,10 @@
 		}
 
 		for (int offset : offsets)
-			writer.putChar((char) offset);
+			writer.put2(offset);
 
 		for (RouteArc arc: arcs)
-			writer.put(arc.getIndexA());
+			writer.put1(arc.getIndexA());
 	}
 
 	/**
@@ -196,12 +196,12 @@
 			assert offset < 0x80;
 			if (last)
 				offset |= 0x80;
-			writer.put((byte) offset);
+			writer.put1(offset);
 		} else {
 			assert offset < 0x8000;
 			if (last)
 				offset |= 0x8000;
-			writer.putChar((char) offset);
+			writer.put2(offset);
 		}
 	}
 
Index: src/uk/me/parabola/imgfmt/app/net/TableA.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/TableA.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/TableA.java	(date 1518970874000)
@@ -174,7 +174,7 @@
 		log.debug("tab a offset", offset, "tab a size", size);
 	
 		for (int i = 0; i < size; i++)
-			writer.put((byte) 0);
+			writer.put1(0);
 	}
 
 	/**
@@ -209,7 +209,7 @@
 		pos |= (access & ACCESS_TOP_BITS) << 8;
 		access &= ~ACCESS_TOP_BITS;
 		writer.put3(pos);
-		writer.put((byte) rd.getTabAInfo());
-		writer.put((byte) access);
+		writer.put1(rd.getTabAInfo());
+		writer.put1(access);
 	}
 }
Index: src/uk/me/parabola/imgfmt/app/net/TableB.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/TableB.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/TableB.java	(date 1518970879000)
@@ -87,7 +87,7 @@
 		offset = writer.position();
 		int size = nodes.size() * ITEM_SIZE;
 		for (int i = 0; i < size; i++)
-			writer.put((byte) 0);
+			writer.put1(0);
 	}
 
 	/**
Index: src/uk/me/parabola/imgfmt/app/net/TableC.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/TableC.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/net/TableC.java	(date 1518970896000)
@@ -43,18 +43,18 @@
 	public void write(ImgFileWriter writer, int tablesOffset) {
 		if (!restrictions.isEmpty()) {
 			if (size < 0x100)
-				writer.put((byte) size);
+				writer.put1(size);
 			else
-				writer.putChar((char) size);
+				writer.put2(size);
 			for (RouteRestriction restr : restrictions)
 				restr.write(writer, tablesOffset);
 		}
 		if(tabA.numRoundaboutArcs() > 0)
-			writer.put((byte)tabA.numRoundaboutArcs());
+			writer.put1(tabA.numRoundaboutArcs());
 		if(tabA.numUnpavedArcs() > 0)
-			writer.put((byte)tabA.numUnpavedArcs());
+			writer.put1(tabA.numUnpavedArcs());
 		if(tabA.numFerryArcs() > 0)
-			writer.put((byte)tabA.numFerryArcs());
+			writer.put1(tabA.numFerryArcs());
 	}
 
 	/**
Index: src/uk/me/parabola/imgfmt/app/srt/SRTFile.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/SRTFile.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/srt/SRTFile.java	(date 1518972751000)
@@ -84,7 +84,7 @@
 	private void writeDescription(ImgFileWriter writer) {
 		writer.position(header.getHeaderLength() + SRTHeader.HEADER2_LEN);
 		writer.put(description.getBytes(Charset.forName("ascii")));
-		writer.put((byte) 0);
+		writer.put1( 0);
 		header.endDescription(writer.position());
 	}
 
@@ -95,7 +95,7 @@
 	 */
 	private void writeSrt4Chars(ImgFileWriter writer) {
 		for (int i = 1; i < 256; i++) {
-			writer.put(sort.getFlags(i));
+			writer.put1(sort.getFlags(i));
 			writeWeights(writer, i);
 		}
 		header.endCharTable(writer.position());
@@ -109,15 +109,15 @@
 			assert primary <= 0xffff;
 			assert secondary <= 0xff;
 			assert tertiary <= 0xff;
-			writer.putChar((char) primary);
-			writer.put((byte) secondary);
-			writer.put((byte) tertiary);
+			writer.put2(primary);
+			writer.put1(secondary);
+			writer.put1(tertiary);
 		} else {
 			assert primary <= 0xff;
 			assert secondary <= 0xf;
 			assert tertiary <= 0xf;
-			writer.put((byte) primary);
-			writer.put((byte) ((tertiary << 4) | (secondary & 0xf)));
+			writer.put1(primary);
+			writer.put1((tertiary << 4) | (secondary & 0xf));
 		}
 	}
 
@@ -133,12 +133,12 @@
 		for (int j = 1; j <= size; j++) {
 			CodePosition b = sort.getExpansion(j);
 			if (isMulti) {
-				writer.putChar(b.getPrimary());
-				writer.put(b.getSecondary());
-				writer.put(b.getTertiary());
+				writer.put2(b.getPrimary());
+				writer.put1(b.getSecondary());
+				writer.put1(b.getTertiary());
 			} else {
-				writer.put((byte) b.getPrimary());
-				writer.put((byte) ((b.getTertiary() << 4) | (b.getSecondary() & 0xf)));
+				writer.put1(b.getPrimary());
+				writer.put1((b.getTertiary() << 4) | (b.getSecondary() & 0xf));
 			}
 		}
 
@@ -148,7 +148,7 @@
 	private void writeSrt7(SectionWriter writer) {
 		assert sort.isMulti();
 		for (int i = 1; i <= sort.getMaxPage(); i++) {
-			writer.putInt(srt8Starts.get(i));
+			writer.put4(srt8Starts.get(i));
 		}
 		header.endSrt7(writer.position());
 	}
@@ -162,7 +162,7 @@
 				srt8Starts.set(p, offset);
 				for (int j = 0; j < 256; j++) {
 					int ch = p * 256 + j;
-					writer.put(sort.getFlags(ch));
+					writer.put1(sort.getFlags(ch));
 					writeWeights(writer, ch);
 					offset += 5;
 				}
Index: src/uk/me/parabola/imgfmt/app/srt/SRTHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/SRTHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/srt/SRTHeader.java	(date 1518972751000)
@@ -71,18 +71,18 @@
 	 */
 	protected void writeFileHeader(ImgFileWriter writer) {
 		if (getHeaderLength() <= 29) {
-			writer.putChar((char) 1);
+			writer.put2(1);
 
-			writer.putInt(header2.getPosition());
-			writer.putChar((char) header2.getSize());
+			writer.put4(header2.getPosition());
+			writer.put2(header2.getSize());
 		} else {
 			// this appears in unicode maps dated 2016 and 2017
-			writer.putChar((char) 0);
-			writer.putInt(header2.getPosition());
-			writer.putChar((char) header2.getSize());
-			writer.putChar((char) 1);
-			writer.putInt(header2.getPosition());
-			writer.putChar((char) header2.getSize());
+			writer.put2(0);
+			writer.put4(header2.getPosition());
+			writer.put2(header2.getSize());
+			writer.put2(1);
+			writer.put4(header2.getPosition());
+			writer.put2(header2.getSize());
 			
 			// older maps contain this variant (note the different order)
 //			writer.putChar((char) 1);
@@ -122,40 +122,40 @@
 	 */
 	protected void writeHeader3(ImgFileWriter writer) {
 		if (sort.isMulti()) {
-			writer.putChar((char) HEADER3_MULTI_LEN);
+			writer.put2(HEADER3_MULTI_LEN);
 		} else {
-			writer.putChar((char) HEADER3_LEN);
+			writer.put2(HEADER3_LEN);
 		}
 
-		writer.putChar((char) sort.getId1());
-		writer.putChar((char) sort.getId2());
-		writer.putChar((char) sort.getCodepage());
+		writer.put2(sort.getId1());
+		writer.put2(sort.getId2());
+		writer.put2(sort.getCodepage());
 		if (sort.isMulti())
-			writer.putInt(0x6f02);
+			writer.put4(0x6f02);
 		else
-			writer.putInt(0x2002);
+			writer.put4(0x2002);
 
 		chartab.writeSectionInfo(writer, true, true);
-		writer.putChar((char) 0);
+		writer.put2(0);
 
 		expansions.writeSectionInfo(writer, true, true);
-		writer.putChar((char) 0);
+		writer.put2(0);
 
 		// SRT6 A repeat pointer to the single byte character table
-		writer.putInt(chartab.getPosition());
-		writer.putInt(0);
+		writer.put4(chartab.getPosition());
+		writer.put4(0);
 
 		if (sort.isMulti()) {
-			writer.putInt(1);
-			writer.putInt(sort.getMaxPage());  // max block in srt7
+			writer.put4(1);
+			writer.put4(sort.getMaxPage());  // max block in srt7
 
 			srt7.writeSectionInfo(writer, true);
-			writer.putChar((char) 0);
-			writer.putInt(0);
+			writer.put2(0);
+			writer.put4(0);
 			srt8.writeSectionInfo(writer, true);
 
-			writer.putChar((char) 0);
-			writer.putInt(0);
+			writer.put2(0);
+			writer.put4(0);
 		}
 	}
 
Index: src/uk/me/parabola/imgfmt/app/trergn/Overview.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/Overview.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/trergn/Overview.java	(date 1518971422000)
@@ -57,15 +57,15 @@
 
 	public void write(ImgFileWriter file) {
 		if (extType == 0) {
-			file.put((byte) (type & 0xff));
-			file.put((byte) maxLevel);
+			file.put1(type & 0xff);
+			file.put1(maxLevel);
 			if (size > 2)
-				file.put((byte) (subType & 0xff));
+				file.put1(subType & 0xff);
 		} else {
-			file.put((byte) type);
-			file.put((byte) maxLevel);
-			file.put((byte) subType);
-			file.put((byte) 0);
+			file.put1(type);
+			file.put1(maxLevel);
+			file.put1(subType);
+			file.put1(0);
 		}
 	}
 
Index: src/uk/me/parabola/imgfmt/app/trergn/Point.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/Point.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/trergn/Point.java	(date 1518971130000)
@@ -58,7 +58,7 @@
 			type >>= 8;
 		}
 
-		file.put((byte) type);
+		file.put1(type);
 
 		int off = getLabel().getOffset();
 		if (poi != null) {
@@ -69,10 +69,10 @@
 			off |= 0x800000;
 
 		file.put3(off);
-		file.putChar((char) getDeltaLong());
-		file.putChar((char) getDeltaLat());
+		file.put2(getDeltaLong());
+		file.put2(getDeltaLat());
 		if (hasSubtype)
-			file.put(subtype);
+			file.put1(subtype);
 	}
 
 	/*
Index: src/uk/me/parabola/imgfmt/app/trergn/Polyline.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/Polyline.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/trergn/Polyline.java	(date 1518971532000)
@@ -111,7 +111,7 @@
 		if (blen >= 0x100)
 			b1 |= FLAG_2BYTE_LEN;
 
-		file.put(b1);
+		file.put1(b1);
 
 		// The label, contains a couple of flags within it.
 		int loff = getLabel().getOffset();
@@ -134,15 +134,15 @@
 
 		// The delta of the longitude from the subdivision centre point
 		// note that this has already been calculated.
-		file.putChar((char) getDeltaLong());
-		file.putChar((char) getDeltaLat());
+		file.put2(getDeltaLong());
+		file.put2(getDeltaLat());
 		if(log.isDebugEnabled())
 			log.debug("out center", getDeltaLat(), getDeltaLong());
 
 		if (blen < 0x100)
-			file.put((byte) (blen & 0xff));
+			file.put1(blen & 0xff);
 		else
-			file.putChar((char) (blen & 0xffff));
+			file.put2(blen & 0xffff);
 
 		file.put(bw.getBytes(), 0, blen+1);
 	}
Index: src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java	(date 1518971532000)
@@ -149,7 +149,7 @@
 			if (off > 0xffff)
 				throw new IllegalStateException("IndPoint offset too large: " + off);
 
-			getWriter().putChar((char) off);
+			getWriter().put2((int) off);
 			position(currPos);
 		}
 	}
@@ -164,7 +164,7 @@
 
 			if (log.isDebugEnabled())
 				log.debug("setting polyline offset to", off);
-			getWriter().putChar((char) off);
+			getWriter().put2((int) off);
 
 			position(currPos);
 		}
@@ -181,7 +181,7 @@
 			if (log.isDebugEnabled())
 				log.debug("setting polygon offset to ", off, " @", polygonPtrOff);
 			position(polygonPtrOff);
-			getWriter().putChar((char) off);
+			getWriter().put2((int) off);
 			position(currPos);
 		}
 	}
@@ -203,8 +203,8 @@
 	}
 
 	public boolean haveExtendedTypes() {
-		return (extTypePointsData != null ||
+		return extTypePointsData != null ||
 				extTypeLinesData != null ||
-				extTypeAreasData != null);
+				extTypeAreasData != null;
 	}
 }
Index: src/uk/me/parabola/imgfmt/app/trergn/RGNHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/RGNHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/trergn/RGNHeader.java	(date 1518972751000)
@@ -91,32 +91,32 @@
 		data.writeSectionInfo(writer, false);
 
 		if (getHeaderLength() > 29) {
-			writer.putInt(extTypeAreasOffset);
-			writer.putInt(extTypeAreasSize);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
+			writer.put4(extTypeAreasOffset);
+			writer.put4(extTypeAreasSize);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
 
-			writer.putInt(extTypeLinesOffset);
-			writer.putInt(extTypeLinesSize);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
+			writer.put4(extTypeLinesOffset);
+			writer.put4(extTypeLinesSize);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
 
-			writer.putInt(extTypePointsOffset);
-			writer.putInt(extTypePointsSize);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
+			writer.put4(extTypePointsOffset);
+			writer.put4(extTypePointsSize);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
 		}
 	}
 
@@ -165,4 +165,4 @@
 	public int getExtTypePointsSize() {
 		return extTypePointsSize;
 	}
-}
\ No newline at end of file
+}
Index: src/uk/me/parabola/imgfmt/app/trergn/Subdivision.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/Subdivision.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/trergn/Subdivision.java	(date 1518972751000)
@@ -260,17 +260,17 @@
 	public void write(ImgFileWriter file) {
 		log.debug("write subdiv", latitude, longitude);
 		file.put3(startRgnPointer);
-		file.put(getType());
+		file.put1(getType());
 		file.put3(longitude);
 		file.put3(latitude);
 		
 		assert width <= 0x7fff;
 		assert height <= 0xffff;
-		file.putChar((char) (width | ((last) ? 0x8000 : 0)));
-		file.putChar((char) height);
+		file.put2(width | ((last) ? 0x8000 : 0));
+		file.put2(height);
 
 		if (!divisions.isEmpty()) {
-			file.putChar((char) getNextLevel());
+			file.put2(getNextLevel());
 		}
 	}
 
@@ -511,9 +511,9 @@
 	}
 
 	public void writeExtTypeOffsetsRecord(ImgFileWriter file) {
-		file.putInt(extTypeAreasOffset);
-		file.putInt(extTypeLinesOffset);
-		file.putInt(extTypePointsOffset);
+		file.put4(extTypeAreasOffset);
+		file.put4(extTypeLinesOffset);
+		file.put4(extTypePointsOffset);
 		int kinds = 0;
 		if(extTypeAreasSize != 0)
 			++kinds;
@@ -521,14 +521,14 @@
 			++kinds;
 		if(extTypePointsSize != 0)
 			++kinds;
-		file.put((byte)kinds);
+		file.put1(kinds);
 	}
 
 	public void writeLastExtTypeOffsetsRecord(ImgFileWriter file) {
-		file.putInt(rgnFile.getExtTypeAreasSize());
-		file.putInt(rgnFile.getExtTypeLinesSize());
-		file.putInt(rgnFile.getExtTypePointsSize());
-		file.put((byte)0);
+		file.put4(rgnFile.getExtTypeAreasSize());
+		file.put4(rgnFile.getExtTypeLinesSize());
+		file.put4(rgnFile.getExtTypePointsSize());
+		file.put1(0);
 	}
 
 	/**
Index: src/uk/me/parabola/imgfmt/app/trergn/TREFile.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/TREFile.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/trergn/TREFile.java	(date 1518972751000)
@@ -91,7 +91,7 @@
 
 		header.setMapInfoSize(header.getMapInfoSize() + enc.getLength() + 1);
 		getWriter().put(val);
-		getWriter().put((byte) 0);
+		getWriter().put1(0);
 	}
 
 	public void addCopyright(Label cr) {
@@ -175,7 +175,7 @@
 					header.setSubdivSize(header.getSubdivSize() + TREHeader.SUBDIV_REC_SIZE);
 			}
 		}
-		getWriter().putInt(lastRgnPos);
+		getWriter().put4(lastRgnPos);
 		header.setSubdivSize(header.getSubdivSize() + 4);
 	}
 
Index: src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java	(date 1518972751000)
@@ -166,39 +166,39 @@
 		writer.put3(area.getMinLat());
 		writer.put3(area.getMinLong());
 
-		writer.putInt(getMapLevelsPos());
-		writer.putInt(getMapLevelsSize());
+		writer.put4(getMapLevelsPos());
+		writer.put4(getMapLevelsSize());
 
-		writer.putInt(getSubdivPos());
-		writer.putInt(getSubdivSize());
+		writer.put4(getSubdivPos());
+		writer.put4(getSubdivSize());
 
 		copyright.writeSectionInfo(writer);
-		writer.putInt(0);
+		writer.put4(0);
 
-		writer.put(getPoiDisplayFlags());
+		writer.put1(getPoiDisplayFlags());
 
 		writer.put3(displayPriority);
 		if (custom)
-			writer.putInt(0x170401);
+			writer.put4(0x170401);
 		else
-			writer.putInt(0x110301);
+			writer.put4(0x110301);
 		
-		writer.putChar((char) 1);
-		writer.put((byte) 0);
+		writer.put2(1);
+		writer.put1(0);
 
 		polyline.writeSectionInfo(writer);
-		writer.putInt(0);
+		writer.put4(0);
 		polygon.writeSectionInfo(writer);
-		writer.putInt(0);
+		writer.put4(0);
 		points.writeSectionInfo(writer);
-		writer.putInt(0);
+		writer.put4(0);
 
 		// There are a number of versions of the header with increasing lengths
 		if (getHeaderLength() > 116)
-			writer.putInt(getMapId());
+			writer.put4(getMapId());
 
 		if (getHeaderLength() > 120) {
-			writer.putInt(0);
+			writer.put4(0);
 
 			// The record size must be zero if the section is empty for compatibility
 			// with cpreview.
@@ -213,27 +213,27 @@
 			// bottom byte could possibly be a bitmask to say which
 			// types are present (line, area, point) but this is just
 			// conjecture
-			writer.putInt(0x0607);
+			writer.put4(0x0607);
 
 			extTypeOverviews.writeSectionInfo(writer);
-			writer.putChar((char)numExtTypeLineTypes);
-			writer.putChar((char)numExtTypeAreaTypes);
-			writer.putChar((char)numExtTypePointTypes);
+			writer.put2(numExtTypeLineTypes);
+			writer.put2(numExtTypeAreaTypes);
+			writer.put2(numExtTypePointTypes);
 		}
 
 		if (getHeaderLength() > 154) {
 			MapValues mv = new MapValues(mapId, getHeaderLength());
 			mv.calculate();
-			writer.putInt(mv.value(0));
-			writer.putInt(mv.value(1));
-			writer.putInt(mv.value(2));
-			writer.putInt(mv.value(3));
+			writer.put4(mv.value(0));
+			writer.put4(mv.value(1));
+			writer.put4(mv.value(2));
+			writer.put4(mv.value(3));
 
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putInt(0);
-			writer.putChar((char) 0);
-			writer.putInt(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put4(0);
+			writer.put2(0);
+			writer.put4(0);
 		}
 		
 		writer.position(getHeaderLength());
Index: src/uk/me/parabola/imgfmt/app/trergn/Zoom.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/Zoom.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/trergn/Zoom.java	(date 1518971422000)
@@ -76,9 +76,9 @@
 	}
 
 	public void write(ImgFileWriter file) {
-		file.put((byte) ((level & 0xf) | (inherited ? 0x80 : 0)));
-		file.put((byte) resolution);
-		file.putChar((char) subdivs.size());
+		file.put1((level & 0xf) | (inherited ? 0x80 : 0));
+		file.put1(resolution);
+		file.put2(subdivs.size());
 	}
 
 	public String toString() {
Index: src/uk/me/parabola/imgfmt/app/typ/DrawOrder.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/DrawOrder.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/DrawOrder.java	(date 1518972751000)
@@ -21,8 +21,8 @@
 	}
 
 	public void write(ImgFileWriter writer) {
-		writer.put(type);
-		writer.putInt(subTypes);
+		writer.put1(type);
+		writer.put4(subTypes);
 	}
 
 	public void addSubtype(int subtype) {
Index: src/uk/me/parabola/imgfmt/app/typ/Rgb.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/Rgb.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/Rgb.java	(date 1518971097000)
@@ -53,9 +53,9 @@
 	public void write(ImgFileWriter writer, byte type) {
 		if (type != 0x10)
 			throw new FormatException("Invalid color deep");
-		writer.put((byte) b);
-		writer.put((byte) g);
-		writer.put((byte) r);
+		writer.put1(b);
+		writer.put1(g);
+		writer.put1(r);
 	}
 
 	public boolean isTransparent() {
Index: src/uk/me/parabola/imgfmt/app/typ/TrueImage.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/TrueImage.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/TrueImage.java	(date 1518971532000)
@@ -51,9 +51,9 @@
 
 		// For mode 16, the transparent pixel precedes the pixmap data.
 		if (mode == 16) {
-			writer.put((byte) (transparentPixel>>8));
-			writer.put((byte) (transparentPixel>>16));
-			writer.put((byte) (transparentPixel>>24));
+			writer.put1(transparentPixel>>8);
+			writer.put1(transparentPixel>>16);
+			writer.put1(transparentPixel>>24);
 		}
 
 		boolean hasAlpha = mode == 32;
Index: src/uk/me/parabola/imgfmt/app/typ/TypElement.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/TypElement.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/TypElement.java	(date 1518971532000)
@@ -159,9 +159,9 @@
 
 		// write out the length, I'm assuming that it will be 1 or 2 bytes
 		if (len > 0xff)
-			writer.putChar((char) len);
+			writer.put2(len);
 		else
-			writer.put((byte) len);
+			writer.put1(len);
 
 		// Prepare and write buffer
 		out.flip();
@@ -181,7 +181,7 @@
 		if (nightFontColour != null)
 			fontExt |= 0x10;
 
-		writer.put(fontExt);
+		writer.put1(fontExt);
 
 		if (dayFontColour != null)
 			dayFontColour.write(writer, (byte) 0x10);
@@ -199,8 +199,8 @@
 	protected void writeImage(ImgFileWriter writer, Xpm xpm) {
 		ColourInfo colourInfo = xpm.getColourInfo();
 
-		writer.put((byte) colourInfo.getNumberOfSColoursForCM());
-		writer.put((byte) colourInfo.getColourMode());
+		writer.put1(colourInfo.getNumberOfSColoursForCM());
+		writer.put1(colourInfo.getColourMode());
 
 		colourInfo.write(writer);
 		xpm.writeImage(writer);
Index: src/uk/me/parabola/imgfmt/app/typ/TYPFile.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/TYPFile.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/TYPFile.java	(date 1518971532000)
@@ -104,7 +104,7 @@
 		Collections.sort(keys);
 
 		// Offset 0 is reserved to mean no label.
-		writer.put((byte) 0);
+		writer.put1((byte) 0);
 
 		for (SortKey<TypIconSet> key : keys) {
 			int off = writer.position();
@@ -127,7 +127,7 @@
 					String name = encoder.charset().name();
 					throw new TypLabelException(name);
 				}
-				writer.put((byte) 0);
+				writer.put1((byte) 0);
 			}
 		}
 		Utils.closeFile(writer);
Index: src/uk/me/parabola/imgfmt/app/typ/TYPHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/TYPHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/TYPHeader.java	(date 1518972751000)
@@ -103,14 +103,14 @@
 	 * @param writer The header is written here.
 	 */
 	protected void writeFileHeader(ImgFileWriter writer) {
-		writer.putChar(codePage);
+		writer.put2(codePage);
 
 		pointData.writeSectionInfo(writer);
 		lineData.writeSectionInfo(writer);
 		polygonData.writeSectionInfo(writer);
 
-		writer.putChar(familyId);
-		writer.putChar(productId);
+		writer.put2(familyId);
+		writer.put2(productId);
 
 		// Can't use Section.writeSectionInfo here as there is an unusual layout.
 		writeSectionInfo(writer, pointIndex);
@@ -120,26 +120,26 @@
 
 		if (getHeaderLength() > 0x5b) {
 			writeSectionInfo(writer, iconIndex);
-			writer.put((byte) 0x13);
+			writer.put1(0x13);
 			iconData.writeSectionInfo(writer);
-			writer.putInt(0);
+			writer.put4(0);
 		}
 
 		if (getHeaderLength() > 0x6e) {
 			labels.writeSectionInfo(writer);
 
 			// not known, guessing. Different layout to other files.
-			writer.putInt(stringIndex.getItemSize());
-			writer.putInt(0x1b);
-			writer.putInt(stringIndex.getPosition());
-			writer.putInt(stringIndex.getSize());
+			writer.put4(stringIndex.getItemSize());
+			writer.put4(0x1b);
+			writer.put4(stringIndex.getPosition());
+			writer.put4(stringIndex.getSize());
 
-			writer.putInt(typeIndex.getItemSize());
-			writer.putInt(0x1b);
-			writer.putInt(typeIndex.getPosition());
-			writer.putInt(typeIndex.getSize());
+			writer.put4(typeIndex.getItemSize());
+			writer.put4(0x1b);
+			writer.put4(typeIndex.getPosition());
+			writer.put4(typeIndex.getSize());
 
-			writer.putChar((char) 0);
+			writer.put2(0);
 		}
 	}
 
@@ -148,9 +148,9 @@
 	 * that have an item size.
 	 */
 	private void writeSectionInfo(ImgFileWriter writer, Section section) {
-		writer.putInt(section.getPosition());
-		writer.putChar(section.getItemSize());
-		writer.putInt(section.getSize());
+		writer.put4(section.getPosition());
+		writer.put2(section.getItemSize());
+		writer.put4(section.getSize());
 	}
 
 	void setCodePage(char codePage) {
Index: src/uk/me/parabola/imgfmt/app/typ/TypIconSet.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/TypIconSet.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/TypIconSet.java	(date 1518971296000)
@@ -31,15 +31,15 @@
 		offset = writer.position();
 
 		// Start with the number of icons
-		writer.put((byte) icons.size());
+		writer.put1(icons.size());
 
 		for (Xpm xpm : icons) {
 			ColourInfo colourInfo = xpm.getColourInfo();
 			int nbits = calcBits(colourInfo);
-			writer.putChar((char) (nbits/2));
-			writer.put((byte) 1);
-			writer.put((byte) colourInfo.getWidth());
-			writer.put((byte) colourInfo.getHeight());
+			writer.put2(nbits/2);
+			writer.put1(1);
+			writer.put1(colourInfo.getWidth());
+			writer.put1(colourInfo.getHeight());
 			writeImage(writer, xpm);
 		}
 	}
Index: src/uk/me/parabola/imgfmt/app/typ/TypLine.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/TypLine.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/TypLine.java	(date 1518971422000)
@@ -60,17 +60,17 @@
 		ColourInfo colourInfo = xpm.getColourInfo();
 		int scheme = colourInfo.getColourScheme() & 0x7;
 
-		writer.put((byte) ((scheme & 0x7) | (height << 3)));
-		writer.put(flags);
+		writer.put1((scheme & 0x7) | (height << 3));
+		writer.put1(flags);
 
 		colourInfo.write(writer);
 		if (xpm.hasImage())
 			xpm.writeImage(writer);
 
 		if (height == 0) {
-			writer.put(lineWidth);
+			writer.put1(lineWidth);
 			if ((scheme&~1) != 6)
-				writer.put((byte) (lineWidth + 2*borderWidth));
+				writer.put1(lineWidth + 2*borderWidth);
 		}
 
 		// The labels have a length byte to show the number of bytes following. There is
Index: src/uk/me/parabola/imgfmt/app/typ/TypPoint.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/TypPoint.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/TypPoint.java	(date 1518971097000)
@@ -42,12 +42,12 @@
 		if (fontStyle != 0 || dayFontColour != null || nightFontColour != null)
 			flags |= F_EXTENDED_FONT;
 
-		writer.put(flags);
+		writer.put1(flags);
 
 		// Width and height is the same for day and night images, so it is written once only.
 		ColourInfo colourInfo = xpm.getColourInfo();
-		writer.put((byte) colourInfo.getWidth());
-		writer.put((byte) colourInfo.getHeight());
+		writer.put1(colourInfo.getWidth());
+		writer.put1(colourInfo.getHeight());
 
 		// Day or only image
 		writeImage(writer, xpm);
Index: src/uk/me/parabola/imgfmt/app/typ/TypPolygon.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/TypPolygon.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/typ/TypPolygon.java	(date 1518971097000)
@@ -36,7 +36,7 @@
 		if (fontStyle != 0 || dayFontColour != null)
 			scheme |= F_EXTENDED;
 
-		writer.put((byte) scheme);
+		writer.put1(scheme);
 
 		colourInfo.write(writer);
 		if (xpm.hasImage())
Index: src/uk/me/parabola/imgfmt/app/BufferedImgFileWriter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/BufferedImgFileWriter.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/BufferedImgFileWriter.java	(date 1518972751000)
@@ -104,33 +104,12 @@
 		sync();
 	}
 
-	/**
-	 * Write out a single byte.
-	 *
-	 * @param b The byte to write.
-	 */
-	public void put(byte b) {
-		ensureSize(1);
-		buf.put(b);
-	}
-
-	/**
-	 * Write out two bytes.  Done in the correct byte order.
-	 *
-	 * @param c The value to write.
-	 */
-	public void putChar(char c) {
-		ensureSize(2);
-		buf.putChar(c);
-	}
-
 	/**
 	 * Write out int in range 0..255 as single byte.
 	 * Use instead of put() for unsigned for clarity.
 	 * @param val The value to write.
 	 */
 	public void put1(int val) {
-		assert val >= 0 && val <= 255 : val;
 		ensureSize(1);
 		buf.put((byte)val);
 	}
@@ -141,7 +120,6 @@
 	 * @param val The value to write.
 	 */
 	public void put2(int val) {
-		assert val >= 0 && val <= 65535 : val;
 		ensureSize(2);
 		buf.putShort((short)val);
 	}
@@ -162,7 +140,7 @@
 	 *
 	 * @param val The value to write.
 	 */
-	public void putInt(int val) {
+	public void put4(int val) {
 		ensureSize(4);
 		buf.putInt(val);
 	}
Index: src/uk/me/parabola/imgfmt/app/CommonHeader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/CommonHeader.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/CommonHeader.java	(date 1518971532000)
@@ -61,11 +61,11 @@
 
 		writer.position(0);
 
-		writer.putChar((char) headerLength);
+		writer.put2(headerLength);
 		writer.put(Utils.toBytes(type, TYPE_LEN, (byte) 0));
 
-		writer.put((byte) 1);  // unknown
-		writer.put((byte) 0);  // not locked
+		writer.put1(1);  // unknown
+		writer.put1(0);  // not locked
 
 		byte[] date = Utils.makeCreationTime(new Date());
 		writer.put(date);
Index: src/uk/me/parabola/imgfmt/app/FileBackedImgFileWriter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/FileBackedImgFileWriter.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/FileBackedImgFileWriter.java	(date 1518972751000)
@@ -103,41 +103,12 @@
 		}
 	}
 
-	/**
-	 * Write out a single byte.
-	 *
-	 * @param b The byte to write.
-	 */
-	public void put(byte b) {
-		try {
-			file.write(b);
-		} catch (IOException e) {
-			throw new MapFailedException("could not write byte to mdr tmp file");
-		}
-	}
-
-	/**
-	 * Write out two bytes. Can't use writeChar() since need to reverse the byte
-	 * order.
-	 *
-	 * @param c The value to write.
-	 */
-	public void putChar(char c) {
-		try {
-			file.write(c);
-			file.write(c >> 8);
-		} catch (IOException e) {
-			throw new MapFailedException("could not write char to mdr tmp file");
-		}
-	}
-
 	/**
 	 * Write out int in range 0..255 as single byte.
 	 * Use instead of put() for unsigned for clarity.
 	 * @param val The value to write.
 	 */
 	public void put1(int val) {
-		assert val >= 0 && val <= 255 : val;
  		try {
 			file.write(val);
 		} catch (IOException e) {
@@ -151,7 +122,6 @@
 	 * @param val The value to write.
 	 */
 	public void put2(int val) {
-		assert val >= 0 && val <= 65535 : val;
  		try {
 			file.write(val);
 			file.write(val >> 8);
@@ -204,7 +174,7 @@
 	 *
 	 * @param val The value to write.
 	 */
-	public void putInt(int val) {
+	public void put4(int val) {
 		try {
 			file.write(val);
 			file.write(val >> 8);
Index: src/uk/me/parabola/imgfmt/app/ImgFileWriter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/ImgFileWriter.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/ImgFileWriter.java	(date 1518974950000)
@@ -53,27 +53,15 @@
 
 	/**
 	 * Write out a single byte.
-	 * @param b The byte to write.
-	 */
-	public void put(byte b);
-
-	/**
-	 * Write out two bytes.  Done in the correct byte order.
-	 * @param c The value to write.
-	 */
-	public void putChar(char c);
-
-	/**
-	 * Write out int in range 0..255 as single byte.
-	 * Use instead of put() for unsigned for clarity.
-	 * @param val The value to write.
+	 *
+	 * @param val The value to write, only the bottom byte will be written.
 	 */
 	public void put1(int val);
 
 	/**
-	 * Write out int in range 0..65535 as two bytes in correct byte order.
-	 * Use instead of putChar() for unsigned for clarity.
-	 * @param val The value to write.
+	 * Write out two bytes in the correct byte order.
+	 *
+	 * @param val The value to write only the bottom 2 bytes will be written.
 	 */
 	public void put2(int val);
 
@@ -97,7 +85,11 @@
 	 * Write out 4 byte value.
 	 * @param val The value to write.
 	 */
-	public void putInt(int val);
+	public void put4(int val);
+
+	public default void put4u(long val) {
+		put4((int) val);
+	}
 
 	/**
 	 * Write out an arbitrary length sequence of bytes.
Index: src/uk/me/parabola/imgfmt/app/Section.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/Section.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/Section.java	(date 1518975186000)
@@ -137,19 +137,19 @@
 	}
 
 	public void writeSectionInfo(ImgFileWriter writer, boolean withItemSize, boolean withExtraValue) {
-		writer.putInt(getPosition());
-		writer.putInt(getSize());
+		writer.put4(getPosition());
+		writer.put4(getSize());
 		if (withItemSize || getItemSize() > 0)
-			writer.putChar(getItemSize());
+			writer.put2(getItemSize());
 		if (withExtraValue)
-			writer.putInt(getExtraValue());
+			writer.put4(getExtraValue());
 	}
 
 	public static void close(ImgFileWriter writer) {
 		assert writer instanceof SectionWriter;
 		try {
 			writer.close();
-		} catch (IOException e) {
+		} catch (IOException ignore) {
 			// ignore as this is only for section writers.
 		}
 	}
Index: src/uk/me/parabola/imgfmt/app/SectionWriter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/SectionWriter.java	(revision 4123)
+++ src/uk/me/parabola/imgfmt/app/SectionWriter.java	(date 1518972751000)
@@ -58,14 +58,6 @@
 		writer.position(pos + secStart);
 	}
 
-	public void put(byte b) {
-		writer.put(b);
-	}
-
-	public void putChar(char c) {
-		writer.putChar(c);
-	}
-
 	public void put1(int val) {
 		writer.put1(val);
 	};
@@ -82,8 +74,8 @@
 		writer.putN(nBytes, val);
 	}
 
-	public void putInt(int val) {
-		writer.putInt(val);
+	public void put4(int val) {
+		writer.put4(val);
 	}
 
 	public void put(byte[] val) {
Index: test/func/lib/ArrayImgWriter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/func/lib/ArrayImgWriter.java	(revision 4123)
+++ test/func/lib/ArrayImgWriter.java	(date 1518972751000)
@@ -37,15 +37,6 @@
 		throw new UnsupportedOperationException();
 	}
 
-	public void put(byte b) {
-		out.write(b);
-	}
-
-	public void putChar(char c) {
-		out.write(c & 0xff);
-		out.write((c >> 8) & 0xff);
-	}
-
 	public void put1(int val) {
 		out.write(val & 0xff);
 	}
@@ -74,7 +65,7 @@
 		out.write((val >> 24) & 0xff);
 	}
 
-	public void putInt(int val) {
+	public void put4(int val) {
 		out.write(val & 0xff);
 		out.write((val >> 8) & 0xff);
 		out.write((val >> 16) & 0xff);
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to