src/newgrf.cpp
changeset 8887 4bc5c9811562
parent 8868 822816ce1fcb
child 8889 a3633be104ff
equal deleted inserted replaced
8886:9f2c7ebc7fc9 8887:4bc5c9811562
    42 #include "sound_func.h"
    42 #include "sound_func.h"
    43 #include "string_func.h"
    43 #include "string_func.h"
    44 #include "road_func.h"
    44 #include "road_func.h"
    45 #include "player_base.h"
    45 #include "player_base.h"
    46 #include "settings_type.h"
    46 #include "settings_type.h"
       
    47 #include "map_func.h"
    47 
    48 
    48 #include "table/strings.h"
    49 #include "table/strings.h"
    49 #include "table/sprites.h"
    50 #include "table/sprites.h"
    50 #include "table/town_land.h"
    51 #include "table/town_land.h"
    51 #include "table/build_industry.h"
    52 #include "table/build_industry.h"
  4023 static uint32 GetPatchVariable(uint8 param)
  4024 static uint32 GetPatchVariable(uint8 param)
  4024 {
  4025 {
  4025 	switch (param) {
  4026 	switch (param) {
  4026 		/* start year - 1920 */
  4027 		/* start year - 1920 */
  4027 		case 0x0B: return max(_patches.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR;
  4028 		case 0x0B: return max(_patches.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR;
       
  4029 
  4028 		/* freight trains weight factor */
  4030 		/* freight trains weight factor */
  4029 		case 0x0E: return _patches.freight_trains;
  4031 		case 0x0E: return _patches.freight_trains;
       
  4032 
  4030 		/* empty wagon speed increase */
  4033 		/* empty wagon speed increase */
  4031 		case 0x0F: return 0;
  4034 		case 0x0F: return 0;
       
  4035 
  4032 		/* plane speed factor */
  4036 		/* plane speed factor */
  4033 		case 0x10: return 4;
  4037 		case 0x10: return 4;
       
  4038 
  4034 		/* 2CC colormap base sprite */
  4039 		/* 2CC colormap base sprite */
  4035 		case 0x11: return SPR_2CCMAP_BASE;
  4040 		case 0x11: return SPR_2CCMAP_BASE;
       
  4041 
       
  4042 		/* map size: format = -MABXYSS
       
  4043 		 * M  : the type of map
       
  4044 		 *       bit 0 : set   : squared map. Bit 1 is now not relevant
       
  4045 		 *               clear : rectangle map. Bit 1 will indicate the bigger edge of the map
       
  4046 		 *       bit 1 : set   : Y is the bigger edge. Bit 0 is clear
       
  4047 		 *               clear : X is the bigger edge.
       
  4048 		 * A  : minimum edge(log2) of the map
       
  4049 		 * B  : maximum edge(log2) of the map
       
  4050 		 * XY : edges(log2) of each side of the map.
       
  4051 		 * SS : combination of both X and Y, thus giving the size(log2) of the map
       
  4052 		 */
       
  4053 		case 0x13: {
       
  4054 			byte map_bits = 0;
       
  4055 			byte log_X = MapLogX() - 6;
       
  4056 			byte log_Y = MapLogY() - 6;
       
  4057 			byte max_edge = max(log_X, log_Y);
       
  4058 
       
  4059 			if (log_X == log_Y) { // we have a squared map, since both edges are identical
       
  4060 				SetBit(map_bits ,0);
       
  4061 			} else {
       
  4062 				if (max_edge == log_Y) SetBit(map_bits, 1); // edge Y been the biggest, mark it
       
  4063 			}
       
  4064 
       
  4065 			return (map_bits << 24) | (min(log_X, log_Y) << 20) | (max_edge << 16) |
       
  4066 				(log_X << 12) | (log_Y << 8) | (log_X + log_Y);
       
  4067 		}
  4036 
  4068 
  4037 		default:
  4069 		default:
  4038 			grfmsg(2, "ParamSet: Unknown Patch variable 0x%02X.", param);
  4070 			grfmsg(2, "ParamSet: Unknown Patch variable 0x%02X.", param);
  4039 			return 0;
  4071 			return 0;
  4040 	}
  4072 	}