# HG changeset patch # User matthijs # Date 1146476063 0 # Node ID 15e473a194ef20b86414fceb4c4f2813523a59ab # Parent 3c584402327e09813158d2befe31d2febccef77c (svn r4640) - Add: IsValidDiagDirection, IsValidDirection and IsValidAxis functions. - Codechange: Use IsValidDiagDirection() in CmdBuildRoadStop(). diff -r 3c584402327e -r 15e473a194ef direction.h --- a/direction.h Mon May 01 09:25:23 2006 +0000 +++ b/direction.h Mon May 01 09:34:23 2006 +0000 @@ -93,7 +93,8 @@ /* the 2 axis */ typedef enum Axis { AXIS_X = 0, - AXIS_Y = 1 + AXIS_Y = 1, + AXIS_END } Axis; @@ -112,4 +113,19 @@ return (DiagDirection)(2 - a); } +static inline bool IsValidDiagDirection(DiagDirection d) +{ + return d < DIAGDIR_END; +} + +static inline bool IsValidDirection(DiagDirection d) +{ + return d < DIR_END; +} + +static inline bool IsValidAxis(DiagDirection d) +{ + return d < AXIS_END; +} + #endif diff -r 3c584402327e -r 15e473a194ef station_cmd.c --- a/station_cmd.c Mon May 01 09:25:23 2006 +0000 +++ b/station_cmd.c Mon May 01 09:34:23 2006 +0000 @@ -1360,7 +1360,7 @@ bool type = !!p2; /* Saveguard the parameters */ - if (p1 > 3) return CMD_ERROR; + if (!IsValidDiagDirection(p1)) return CMD_ERROR; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);