Skip to content

Commit

Permalink
set defaults as default values, in case the properties can not be read
Browse files Browse the repository at this point in the history
* use booleans instead of 1/0
  • Loading branch information
eregon committed Aug 12, 2011
1 parent c498d77 commit 794fccb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
6 changes: 2 additions & 4 deletions assets/Configuration/config.properties
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ screen.height=640
ai.depth=4 ai.depth=4


# if it runs too slow # if it runs too slow
# boolean: 1:true, 0:false graphics.low=false
graphics.low=0


# network setup # network setup
rmi.port=1723 rmi.port=1723
# in ms # in ms
rmi.timeout=5000 rmi.timeout=5000


# if you want to be able to play for the other player, even when he is not local # if you want to be able to play for the other player, even when he is not local
# boolean: 1:true, 0:false game.canMoveOther=false
game.canMoveOther=0
28 changes: 14 additions & 14 deletions src/pylos/Config.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import java.util.logging.SimpleFormatter; import java.util.logging.SimpleFormatter;


public class Config { public class Config {
public static int[] RESOLUTION = new int[2]; public static int[] RESOLUTION = { 800, 640 };
public static int AI_DEPTH; public static int AI_DEPTH = 4;
public static boolean LOW_GRAPHICS; public static boolean LOW_GRAPHICS = false;
public static int RMI_PORT; public static int RMI_PORT = 1723;
public static long CREATE_RMI_REGISTRY_TIMEOUT; public static long CREATE_RMI_REGISTRY_TIMEOUT = 5000;
public static boolean CAN_MOVE_OTHER; public static boolean CAN_MOVE_OTHER = false;
public static boolean FIRE; public static boolean FIRE = false;


static final File logDir = new File(Pylos.rootPath + "/log"); static final File logDir = new File(Pylos.rootPath + "/log");
static final File defaultPropertiesFile = new File(Pylos.rootPath + "/assets/Configuration/config.properties"); static final File defaultPropertiesFile = new File(Pylos.rootPath + "/assets/Configuration/config.properties");
Expand Down Expand Up @@ -50,13 +50,13 @@ public static void configureProject() {


try { try {
properties.load(new FileInputStream(propertiesFile)); properties.load(new FileInputStream(propertiesFile));
RESOLUTION[0] = Integer.valueOf(properties.getProperty("screen.width", "800")); RESOLUTION[0] = Integer.valueOf(properties.getProperty("screen.width", Integer.toString(RESOLUTION[0])));
RESOLUTION[1] = Integer.valueOf(properties.getProperty("screen.height", "640")); RESOLUTION[1] = Integer.valueOf(properties.getProperty("screen.height", Integer.toString(RESOLUTION[1])));
AI_DEPTH = Integer.valueOf(properties.getProperty("ai.depth", "4")); AI_DEPTH = Integer.valueOf(properties.getProperty("ai.depth", Integer.toString(AI_DEPTH)));
LOW_GRAPHICS = Integer.valueOf(properties.getProperty("graphics.low", "0")) == 1; LOW_GRAPHICS = Boolean.valueOf(properties.getProperty("graphics.low", Boolean.toString(LOW_GRAPHICS)));
RMI_PORT = Integer.valueOf(properties.getProperty("rmi.port", "1723")); RMI_PORT = Integer.valueOf(properties.getProperty("rmi.port", Integer.toString(RMI_PORT)));
CREATE_RMI_REGISTRY_TIMEOUT = Integer.valueOf(properties.getProperty("rmi.timeout", "5000")); CREATE_RMI_REGISTRY_TIMEOUT = Integer.valueOf(properties.getProperty("rmi.timeout", Long.toString(CREATE_RMI_REGISTRY_TIMEOUT)));
CAN_MOVE_OTHER = Integer.valueOf(properties.getProperty("game.canMoveOther", "0")) == 1; CAN_MOVE_OTHER = Boolean.valueOf(properties.getProperty("game.canMoveOther", Boolean.toString(CAN_MOVE_OTHER)));
// Not quite ready yet // Not quite ready yet
FIRE = false; // Integer.valueOf(properties.getProperty("extra.fire", "0")) == 1; FIRE = false; // Integer.valueOf(properties.getProperty("extra.fire", "0")) == 1;
} catch (Exception e) { } catch (Exception e) {
Expand Down

0 comments on commit 794fccb

Please sign in to comment.