src/newgrf_town.cpp
branchnoai
changeset 9476 1d1ed96f32ad
child 6308 646711c5feaa
child 6719 4cc327ad39d5
equal deleted inserted replaced
9475:58c20c0e394f 9476:1d1ed96f32ad
       
     1 /* $Id$ */
       
     2 
       
     3 /** @file newgrf_town.cpp */
       
     4 
       
     5 #include "stdafx.h"
       
     6 #include "openttd.h"
       
     7 #include "debug.h"
       
     8 #include "functions.h"
       
     9 #include "town.h"
       
    10 
       
    11 /** This function implements the town variables that newGRF defines.
       
    12  * @param variable that is queried
       
    13  * @param parameter unused
       
    14  * @param available will return false if ever the variable asked for does not exist
       
    15  * @param t is of course the town we are inquiring
       
    16  * @return the value stored in the corresponding variable*/
       
    17 uint32 TownGetVariable(byte variable, byte parameter, bool *available, const Town *t)
       
    18 {
       
    19 	switch (variable) {
       
    20 		/* Larger towns */
       
    21 		case 0x40: return 1;
       
    22 
       
    23 		/* Town index */
       
    24 		case 0x41: return t->index;
       
    25 
       
    26 		/* Town properties */
       
    27 		case 0x80: return t->xy;
       
    28 		case 0x81: return GB(t->xy, 8, 8);
       
    29 		case 0x82: return t->population;
       
    30 		case 0x83: return GB(t->population, 8, 8);
       
    31 		case 0x8A: return t->grow_counter;
       
    32 		case 0x92: return t->flags12;  // In original game, 0x92 and 0x93 are really one word. Since flags12 is a byte, this is to adjust
       
    33 		case 0x93: return 0;
       
    34 		case 0x94: return t->radius[0];
       
    35 		case 0x95: return GB(t->radius[0], 8, 8);
       
    36 		case 0x96: return t->radius[1];
       
    37 		case 0x97: return GB(t->radius[1], 8, 8);
       
    38 		case 0x98: return t->radius[2];
       
    39 		case 0x99: return GB(t->radius[2], 8, 8);
       
    40 		case 0x9A: return t->radius[3];
       
    41 		case 0x9B: return GB(t->radius[3], 8, 8);
       
    42 		case 0x9C: return t->radius[4];
       
    43 		case 0x9D: return GB(t->radius[4], 8, 8);
       
    44 		case 0x9E: return t->ratings[0];
       
    45 		case 0x9F: return t->ratings[1];
       
    46 		case 0xA0: return t->ratings[2];
       
    47 		case 0xA1: return t->ratings[3];
       
    48 		case 0xA2: return t->ratings[4];
       
    49 		case 0xA3: return t->ratings[5];
       
    50 		case 0xA4: return t->ratings[6];
       
    51 		case 0xA5: return t->ratings[7];
       
    52 		case 0xA6: return t->ratings[8];
       
    53 		case 0xAE: return t->have_ratings;
       
    54 		case 0xB2: return t->statues;
       
    55 		case 0xB6: return t->num_houses;
       
    56 		case 0xB9: return t->growth_rate;
       
    57 		case 0xBA: return t->new_max_pass;
       
    58 		case 0xBB: return GB(t->new_max_pass, 8, 8);
       
    59 		case 0xBC: return t->new_max_mail;
       
    60 		case 0xBD: return GB(t->new_max_mail, 8, 8);
       
    61 		case 0xBE: return t->new_act_pass;
       
    62 		case 0xBF: return GB(t->new_act_pass, 8, 8);
       
    63 		case 0xC0: return t->new_act_mail;
       
    64 		case 0xC1: return GB(t->new_act_mail, 8, 8);
       
    65 		case 0xC2: return t->max_pass;
       
    66 		case 0xC3: return GB(t->max_pass, 8, 8);
       
    67 		case 0xC4: return t->max_mail;
       
    68 		case 0xC5: return GB(t->max_mail, 8, 8);
       
    69 		case 0xC6: return t->act_pass;
       
    70 		case 0xC7: return GB(t->act_pass, 8, 8);
       
    71 		case 0xC8: return t->act_mail;
       
    72 		case 0xC9: return GB(t->act_mail, 8, 8);
       
    73 		case 0xCA: return t->pct_pass_transported;
       
    74 		case 0xCB: return t->pct_mail_transported;
       
    75 		case 0xCC: return t->new_act_food;
       
    76 		case 0xCD: return GB(t->new_act_food, 8, 8);
       
    77 		case 0xCE: return t->new_act_water;
       
    78 		case 0xCF: return GB(t->new_act_water, 8, 8);
       
    79 		case 0xD0: return t->act_food;
       
    80 		case 0xD1: return GB(t->act_food, 8, 8);
       
    81 		case 0xD2: return t->act_water;
       
    82 		case 0xD3: return GB(t->act_water, 8, 8);
       
    83 		case 0xD4: return t->road_build_months;
       
    84 		case 0xD5: return t->fund_buildings_months;
       
    85 	}
       
    86 
       
    87 	DEBUG(grf, 1, "Unhandled town property 0x%X", variable);
       
    88 
       
    89 	*available = false;
       
    90 	return (uint32)-1;
       
    91 }