Commits

Roi Atalla committed 66d7b4a

Discovered that all the parse<Type> methods throw NumberFormatException if the number is out of range. This is problematic for unsigned values whose positive values may exceed the range. The fix is to just parse them all as Long's then cast down to their respective types. This preserves all data.

  • Participants
  • Parent commits 14b2c0b

Comments (0)

Files changed (1)

src/com/ra4king/opengl/util/Mesh.java

 		UBYTE("ubyte", GL_UNSIGNED_BYTE, 1) {
 			public void store(ByteBuffer b, String[] data) {
 				for(String s : data)
-					b.put(Byte.parseByte(s));
+					b.put((byte)Long.parseLong(s));
 			}
 		},
 		USHORT("ushort", GL_UNSIGNED_SHORT, 2) {
 			public void store(ByteBuffer b, String[] data) {
 				for(String s : data)
-					b.putShort(Short.parseShort(s));
+					b.putShort((short)Long.parseLong(s));
 			}
 		},
 		UINT("uint", GL_UNSIGNED_INT, 4) {
 			public void store(ByteBuffer b, String[] data) {
 				for(String s : data)
-					b.putInt(Integer.parseInt(s));
+					b.putInt((int)Long.parseLong(s));
 			}
 		};
 		
 				case GL_INT:
 				case GL_UNSIGNED_INT:
 					for(String s : data)
-						b.putInt(Integer.parseInt(s));
+						b.putInt((int)Long.parseLong(s));
 					break;
 				case GL_SHORT:
 				case GL_UNSIGNED_SHORT:
 					for(String s : data)
-						b.putShort(Short.parseShort(s));
+						b.putShort((short)Long.parseLong(s));
 					break;
 				case GL_BYTE:
 				case GL_UNSIGNED_BYTE:
 					for(String s : data)
-						b.put(Byte.parseByte(s));
+						b.put((byte)Long.parseLong(s));
 					break;
 			}
 		}