src/newgrf_town.cpp
branchNewGRF_ports
changeset 6878 7d1ff2f621c7
parent 6872 1c4a4a609f85
child 10184 fcf5fb2548eb
equal deleted inserted replaced
6877:889301acc299 6878:7d1ff2f621c7
     5 #include "stdafx.h"
     5 #include "stdafx.h"
     6 #include "openttd.h"
     6 #include "openttd.h"
     7 #include "settings_type.h"
     7 #include "settings_type.h"
     8 #include "debug.h"
     8 #include "debug.h"
     9 #include "core/bitmath_func.hpp"
     9 #include "core/bitmath_func.hpp"
       
    10 #include "core/math_func.hpp"
    10 #include "town.h"
    11 #include "town.h"
    11 
    12 
    12 /** This function implements the town variables that newGRF defines.
    13 /** This function implements the town variables that newGRF defines.
    13  * @param variable that is queried
    14  * @param variable that is queried
    14  * @param parameter unused
    15  * @param parameter unused
    28 		case 0x41: return t->index;
    29 		case 0x41: return t->index;
    29 
    30 
    30 		/* Town properties */
    31 		/* Town properties */
    31 		case 0x80: return t->xy;
    32 		case 0x80: return t->xy;
    32 		case 0x81: return GB(t->xy, 8, 8);
    33 		case 0x81: return GB(t->xy, 8, 8);
    33 		case 0x82: return t->population;
    34 		case 0x82: return ClampToU16(t->population);
    34 		case 0x83: return GB(t->population, 8, 8);
    35 		case 0x83: return GB(ClampToU16(t->population), 8, 8);
    35 		case 0x8A: return t->grow_counter;
    36 		case 0x8A: return t->grow_counter;
    36 		case 0x92: return t->flags12;  // In original game, 0x92 and 0x93 are really one word. Since flags12 is a byte, this is to adjust
    37 		case 0x92: return t->flags12;  // In original game, 0x92 and 0x93 are really one word. Since flags12 is a byte, this is to adjust
    37 		case 0x93: return 0;
    38 		case 0x93: return 0;
    38 		case 0x94: return t->radius[0];
    39 		case 0x94: return t->radius[0];
    39 		case 0x95: return GB(t->radius[0], 8, 8);
    40 		case 0x95: return GB(t->radius[0], 8, 8);
    44 		case 0x9A: return t->radius[3];
    45 		case 0x9A: return t->radius[3];
    45 		case 0x9B: return GB(t->radius[3], 8, 8);
    46 		case 0x9B: return GB(t->radius[3], 8, 8);
    46 		case 0x9C: return t->radius[4];
    47 		case 0x9C: return t->radius[4];
    47 		case 0x9D: return GB(t->radius[4], 8, 8);
    48 		case 0x9D: return GB(t->radius[4], 8, 8);
    48 		case 0x9E: return t->ratings[0];
    49 		case 0x9E: return t->ratings[0];
    49 		case 0x9F: return t->ratings[1];
    50 		case 0x9F: return GB(t->ratings[0], 8, 8);
    50 		case 0xA0: return t->ratings[2];
    51 		case 0xA0: return t->ratings[1];
    51 		case 0xA1: return t->ratings[3];
    52 		case 0xA1: return GB(t->ratings[1], 8, 8);
    52 		case 0xA2: return t->ratings[4];
    53 		case 0xA2: return t->ratings[2];
    53 		case 0xA3: return t->ratings[5];
    54 		case 0xA3: return GB(t->ratings[2], 8, 8);
    54 		case 0xA4: return t->ratings[6];
    55 		case 0xA4: return t->ratings[3];
    55 		case 0xA5: return t->ratings[7];
    56 		case 0xA5: return GB(t->ratings[3], 8, 8);
       
    57 		case 0xA6: return t->ratings[4];
       
    58 		case 0xA7: return GB(t->ratings[4], 8, 8);
       
    59 		case 0xA8: return t->ratings[5];
       
    60 		case 0xA9: return GB(t->ratings[5], 8, 8);
       
    61 		case 0xAA: return t->ratings[6];
       
    62 		case 0xAB: return GB(t->ratings[6], 8, 8);
       
    63 		case 0xAC: return t->ratings[7];
       
    64 		case 0xAD: return GB(t->ratings[7], 8, 8);
    56 		case 0xAE: return t->have_ratings;
    65 		case 0xAE: return t->have_ratings;
    57 		case 0xB2: return t->statues;
    66 		case 0xB2: return t->statues;
    58 		case 0xB6: return t->num_houses;
    67 		case 0xB6: return t->num_houses;
    59 		case 0xB9: return t->growth_rate;
    68 		case 0xB9: return t->growth_rate;
    60 		case 0xBA: return t->new_max_pass;
    69 		case 0xBA: return ClampToU16(t->new_max_pass);
    61 		case 0xBB: return GB(t->new_max_pass, 8, 8);
    70 		case 0xBB: return GB(ClampToU16(t->new_max_pass), 8, 8);
    62 		case 0xBC: return t->new_max_mail;
    71 		case 0xBC: return ClampToU16(t->new_max_mail);
    63 		case 0xBD: return GB(t->new_max_mail, 8, 8);
    72 		case 0xBD: return GB(ClampToU16(t->new_max_mail), 8, 8);
    64 		case 0xBE: return t->new_act_pass;
    73 		case 0xBE: return ClampToU16(t->new_act_pass);
    65 		case 0xBF: return GB(t->new_act_pass, 8, 8);
    74 		case 0xBF: return GB(ClampToU16(t->new_act_pass), 8, 8);
    66 		case 0xC0: return t->new_act_mail;
    75 		case 0xC0: return ClampToU16(t->new_act_mail);
    67 		case 0xC1: return GB(t->new_act_mail, 8, 8);
    76 		case 0xC1: return GB(ClampToU16(t->new_act_mail), 8, 8);
    68 		case 0xC2: return t->max_pass;
    77 		case 0xC2: return ClampToU16(t->max_pass);
    69 		case 0xC3: return GB(t->max_pass, 8, 8);
    78 		case 0xC3: return GB(ClampToU16(t->max_pass), 8, 8);
    70 		case 0xC4: return t->max_mail;
    79 		case 0xC4: return ClampToU16(t->max_mail);
    71 		case 0xC5: return GB(t->max_mail, 8, 8);
    80 		case 0xC5: return GB(ClampToU16(t->max_mail), 8, 8);
    72 		case 0xC6: return t->act_pass;
    81 		case 0xC6: return ClampToU16(t->act_pass);
    73 		case 0xC7: return GB(t->act_pass, 8, 8);
    82 		case 0xC7: return GB(ClampToU16(t->act_pass), 8, 8);
    74 		case 0xC8: return t->act_mail;
    83 		case 0xC8: return ClampToU16(t->act_mail);
    75 		case 0xC9: return GB(t->act_mail, 8, 8);
    84 		case 0xC9: return GB(ClampToU16(t->act_mail), 8, 8);
    76 		case 0xCA: return t->pct_pass_transported;
    85 		case 0xCA: return t->pct_pass_transported;
    77 		case 0xCB: return t->pct_mail_transported;
    86 		case 0xCB: return t->pct_mail_transported;
    78 		case 0xCC: return t->new_act_food;
    87 		case 0xCC: return t->new_act_food;
    79 		case 0xCD: return GB(t->new_act_food, 8, 8);
    88 		case 0xCD: return GB(t->new_act_food, 8, 8);
    80 		case 0xCE: return t->new_act_water;
    89 		case 0xCE: return t->new_act_water;