Skip to content

Commit

Permalink
Changed magic number from last commit to a constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamedgecombe committed Jun 2, 2011
1 parent 06e4b59 commit 328105c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/net/lightstone/model/Mob.java
Expand Up @@ -17,7 +17,7 @@ public abstract class Mob extends Entity {
/**
* The mob's metadata.
*/
protected final Parameter<?>[] metadata = new Parameter<?>[32];
protected final Parameter<?>[] metadata = new Parameter<?>[Parameter.METADATA_SIZE];

/**
* Creates a mob within the specified world.
Expand Down
2 changes: 1 addition & 1 deletion src/net/lightstone/util/ChannelBufferUtils.java
Expand Up @@ -74,7 +74,7 @@ public static void writeParameters(ChannelBuffer buf, Parameter<?>[] parameters)
* @return The parameters.
*/
public static Parameter<?>[] readParameters(ChannelBuffer buf) {
Parameter<?>[] parameters = new Parameter<?>[32];
Parameter<?>[] parameters = new Parameter<?>[Parameter.METADATA_SIZE];

int b;
while ((b = buf.readUnsignedByte()) != 0x7F) {
Expand Down
5 changes: 5 additions & 0 deletions src/net/lightstone/util/Parameter.java
Expand Up @@ -7,6 +7,11 @@
*/
public class Parameter<T> {

/**
* The maximum number of parameters in each group.
*/
public static final int METADATA_SIZE = 32;

/**
* The id which represents a byte parameter.
*/
Expand Down
2 changes: 1 addition & 1 deletion test/net/lightstone/util/ChannelBufferUtilsTest.java
Expand Up @@ -24,7 +24,7 @@ public final class ChannelBufferUtilsTest {
*/
@Test
public void testWriteParameters() {
Parameter<?>[] params = new Parameter<?>[32];
Parameter<?>[] params = new Parameter<?>[Parameter.METADATA_SIZE];
params[0] = new Parameter<Byte>(Parameter.TYPE_BYTE, 0, (byte) 0x12);
params[1] = new Parameter<Short>(Parameter.TYPE_SHORT, 1, (short) 0x1234);
params[2] = new Parameter<Integer>(Parameter.TYPE_INT, 2, (int) 0x12345678);
Expand Down

0 comments on commit 328105c

Please sign in to comment.