mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
(svn r16603) -Codechange: enumify map size limits (based on a patch by Bilbo)
This commit is contained in:
parent
67485b5c76
commit
d65963a48f
@ -34,9 +34,9 @@ TileExtended *_me = NULL; ///< Extended Tiles of the map
|
|||||||
void AllocateMap(uint size_x, uint size_y)
|
void AllocateMap(uint size_x, uint size_y)
|
||||||
{
|
{
|
||||||
/* Make sure that the map size is within the limits and that
|
/* Make sure that the map size is within the limits and that
|
||||||
* the x axis size is a power of 2. */
|
* size of both axes is a power of 2. */
|
||||||
if (size_x < 64 || size_x > 2048 ||
|
if (!IsInsideMM(size_x, MIN_MAP_SIZE, MAX_MAP_SIZE + 1) ||
|
||||||
size_y < 64 || size_y > 2048 ||
|
!IsInsideMM(size_y, MIN_MAP_SIZE, MAX_MAP_SIZE + 1) ||
|
||||||
(size_x & (size_x - 1)) != 0 ||
|
(size_x & (size_x - 1)) != 0 ||
|
||||||
(size_y & (size_y - 1)) != 0)
|
(size_y & (size_y - 1)) != 0)
|
||||||
error("Invalid map size");
|
error("Invalid map size");
|
||||||
|
@ -50,6 +50,14 @@ struct TileIndexDiffC {
|
|||||||
int16 y; ///< The y value of the coordinate
|
int16 y; ///< The y value of the coordinate
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Minimal and maximal map width and height */
|
||||||
|
enum {
|
||||||
|
MIN_MAP_SIZE_BITS = 6, ///< Minimal size of map is equal to 2 ^ MIN_MAP_SIZE_BITS
|
||||||
|
MAX_MAP_SIZE_BITS = 11, ///< Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS
|
||||||
|
MIN_MAP_SIZE = 1 << MIN_MAP_SIZE_BITS, ///< Minimal map size = 64
|
||||||
|
MAX_MAP_SIZE = 1 << MAX_MAP_SIZE_BITS, ///< Maximal map size = 2048
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Approximation of the length of a straight track, relative to a diagonal
|
* Approximation of the length of a straight track, relative to a diagonal
|
||||||
* track (ie the size of a tile side).
|
* track (ie the size of a tile side).
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include "gfxinit.h"
|
#include "gfxinit.h"
|
||||||
#include "gamelog.h"
|
#include "gamelog.h"
|
||||||
#include "station_func.h"
|
#include "station_func.h"
|
||||||
|
#include "map_type.h"
|
||||||
#include "settings_func.h"
|
#include "settings_func.h"
|
||||||
#include "ini_type.h"
|
#include "ini_type.h"
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
|
@ -500,8 +500,8 @@ const SettingDesc _settings[] = {
|
|||||||
SDT_VAR(GameSettings, game_creation.heightmap_rotation, SLE_UINT8, S,MS, 0, 0, 1, 0, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION, NULL),
|
SDT_VAR(GameSettings, game_creation.heightmap_rotation, SLE_UINT8, S,MS, 0, 0, 1, 0, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION, NULL),
|
||||||
SDT_VAR(GameSettings, game_creation.se_flat_world_height, SLE_UINT8, S, 0, 1, 0, 15, 0, STR_CONFIG_SETTING_SE_FLAT_WORLD_HEIGHT, NULL),
|
SDT_VAR(GameSettings, game_creation.se_flat_world_height, SLE_UINT8, S, 0, 1, 0, 15, 0, STR_CONFIG_SETTING_SE_FLAT_WORLD_HEIGHT, NULL),
|
||||||
|
|
||||||
SDT_VAR(GameSettings, game_creation.map_x, SLE_UINT8, S, 0, 8, 6, 11, 0, STR_CONFIG_SETTING_MAP_X, NULL),
|
SDT_VAR(GameSettings, game_creation.map_x, SLE_UINT8, S, 0, 8, MIN_MAP_SIZE_BITS, MAX_MAP_SIZE_BITS, 0, STR_CONFIG_SETTING_MAP_X, NULL),
|
||||||
SDT_VAR(GameSettings, game_creation.map_y, SLE_UINT8, S, 0, 8, 6, 11, 0, STR_CONFIG_SETTING_MAP_Y, NULL),
|
SDT_VAR(GameSettings, game_creation.map_y, SLE_UINT8, S, 0, 8, MIN_MAP_SIZE_BITS, MAX_MAP_SIZE_BITS, 0, STR_CONFIG_SETTING_MAP_Y, NULL),
|
||||||
SDT_CONDBOOL(GameSettings, construction.freeform_edges, 111, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_SETTING_ENABLE_FREEFORM_EDGES, CheckFreeformEdges),
|
SDT_CONDBOOL(GameSettings, construction.freeform_edges, 111, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_SETTING_ENABLE_FREEFORM_EDGES, CheckFreeformEdges),
|
||||||
SDT_CONDVAR(GameSettings, game_creation.water_borders, SLE_UINT8,111, SL_MAX_VERSION, 0, 0, 15, 0, 16, 0, STR_NULL, NULL),
|
SDT_CONDVAR(GameSettings, game_creation.water_borders, SLE_UINT8,111, SL_MAX_VERSION, 0, 0, 15, 0, 16, 0, STR_NULL, NULL),
|
||||||
SDT_CONDVAR(GameSettings, game_creation.custom_town_number, SLE_UINT16,115, SL_MAX_VERSION, 0, 0, 1, 1, 5000, 0, STR_NULL, NULL),
|
SDT_CONDVAR(GameSettings, game_creation.custom_town_number, SLE_UINT16,115, SL_MAX_VERSION, 0, 0, 1, 1, 5000, 0, STR_NULL, NULL),
|
||||||
|
Loading…
Reference in New Issue
Block a user