File diff r27883:ddbd33508a8a → r27884:803962be0328
src/newgrf.cpp
Show inline comments
 
@@ -993,13 +993,13 @@ typedef ChangeInfoResult (*VCI_Handler)(
 
 * @return ChangeInfoResult.
 
 */
 
static ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, ByteReader *buf)
 
{
 
	switch (prop) {
 
		case 0x00: // Introduction date
 
			ei->base_intro = buf->ReadWord() + DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			ei->base_intro = buf->ReadWord() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			break;
 

	
 
		case 0x02: // Decay speed
 
			ei->decay_speed = buf->ReadByte();
 
			break;
 

	
 
@@ -2194,13 +2194,13 @@ static ChangeInfoResult BridgeChangeInfo
 
		BridgeSpec *bridge = &_bridge[brid + i];
 

	
 
		switch (prop) {
 
			case 0x08: { // Year of availability
 
				/* We treat '0' as always available */
 
				byte year = buf->ReadByte();
 
				bridge->avail_year = (year > 0 ? ORIGINAL_BASE_YEAR + year : 0);
 
				bridge->avail_year = (year > 0 ? CalendarTime::ORIGINAL_BASE_YEAR + year : 0);
 
				break;
 
			}
 

	
 
			case 0x09: // Minimum length
 
				bridge->min_length = buf->ReadByte();
 
				break;
 
@@ -2254,13 +2254,13 @@ static ChangeInfoResult BridgeChangeInfo
 

	
 
			case 0x0E: // Flags; bit 0 - disable far pillars
 
				bridge->flags = buf->ReadByte();
 
				break;
 

	
 
			case 0x0F: // Long format year of availability (year since year 0)
 
				bridge->avail_year = Clamp(TimerGameCalendar::Year(buf->ReadDWord()), MIN_YEAR, MAX_YEAR);
 
				bridge->avail_year = Clamp(TimerGameCalendar::Year(buf->ReadDWord()), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
 
				break;
 

	
 
			case 0x10: { // purchase string
 
				StringID newone = GetGRFStringID(_cur.grffile->grfid, buf->ReadWord());
 
				if (newone != STR_UNDEFINED) bridge->material = newone;
 
				break;
 
@@ -2427,14 +2427,14 @@ static ChangeInfoResult TownHouseChangeI
 
			case 0x09: // Building flags
 
				housespec->building_flags = (BuildingFlags)buf->ReadByte();
 
				break;
 

	
 
			case 0x0A: { // Availability years
 
				uint16_t years = buf->ReadWord();
 
				housespec->min_year = GB(years, 0, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 0, 8);
 
				housespec->max_year = GB(years, 8, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 8, 8);
 
				housespec->min_year = GB(years, 0, 8) > 150 ? CalendarTime::MAX_YEAR : CalendarTime::ORIGINAL_BASE_YEAR + GB(years, 0, 8);
 
				housespec->max_year = GB(years, 8, 8) > 150 ? CalendarTime::MAX_YEAR : CalendarTime::ORIGINAL_BASE_YEAR + GB(years, 8, 8);
 
				break;
 
			}
 

	
 
			case 0x0B: // Population
 
				housespec->population = buf->ReadByte();
 
				break;
 
@@ -3988,13 +3988,13 @@ static ChangeInfoResult AirportChangeInf
 
				break;
 
			}
 

	
 
			case 0x0C:
 
				as->min_year = buf->ReadWord();
 
				as->max_year = buf->ReadWord();
 
				if (as->max_year == 0xFFFF) as->max_year = MAX_YEAR;
 
				if (as->max_year == 0xFFFF) as->max_year = CalendarTime::MAX_YEAR;
 
				break;
 

	
 
			case 0x0D:
 
				as->ttd_airport_type = (TTDPAirportType)buf->ReadByte();
 
				break;
 

	
 
@@ -6509,17 +6509,17 @@ static void SkipAct5(ByteReader *buf)
 
 * @return true iff the variable is known and the value is returned in 'value'.
 
 */
 
bool GetGlobalVariable(byte param, uint32_t *value, const GRFFile *grffile)
 
{
 
	switch (param) {
 
		case 0x00: // current date
 
			*value = static_cast<int32_t>(std::max(TimerGameCalendar::date - DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameCalendar::Date(0)));
 
			*value = static_cast<int32_t>(std::max(TimerGameCalendar::date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameCalendar::Date(0)));
 
			return true;
 

	
 
		case 0x01: // current year
 
			*value = static_cast<int32_t>(Clamp(TimerGameCalendar::year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR);
 
			*value = static_cast<int32_t>(Clamp(TimerGameCalendar::year, CalendarTime::ORIGINAL_BASE_YEAR, CalendarTime::ORIGINAL_MAX_YEAR) - CalendarTime::ORIGINAL_BASE_YEAR);
 
			return true;
 

	
 
		case 0x02: { // detailed date information: month of year (bit 0-7), day of month (bit 8-12), leap year (bit 15), day of year (bit 16-24)
 
			TimerGameCalendar::YearMonthDay ymd;
 
			TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::date, &ymd);
 
			TimerGameCalendar::Date start_of_year = TimerGameCalendar::ConvertYMDToDate(ymd.year, 0, 1);
 
@@ -7225,13 +7225,13 @@ static void SafeParamSet(ByteReader *buf
 

	
 

	
 
static uint32_t GetPatchVariable(uint8_t param)
 
{
 
	switch (param) {
 
		/* start year - 1920 */
 
		case 0x0B: return static_cast<int32_t>(std::max(_settings_game.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR);
 
		case 0x0B: return static_cast<int32_t>(std::max(_settings_game.game_creation.starting_year, CalendarTime::ORIGINAL_BASE_YEAR) - CalendarTime::ORIGINAL_BASE_YEAR);
 

	
 
		/* freight trains weight factor */
 
		case 0x0E: return _settings_game.vehicle.freight_trains;
 

	
 
		/* empty wagon speed increase */
 
		case 0x0F: return 0;
 
@@ -9234,13 +9234,13 @@ static bool IsHouseSpecValid(HouseSpec *
 
 * climate / housezone combination.
 
 * @param bitmask The climate and housezone to check for. Exactly one climate
 
 *   bit and one housezone bit should be set.
 
 */
 
static void EnsureEarlyHouse(HouseZones bitmask)
 
{
 
	TimerGameCalendar::Year min_year = MAX_YEAR;
 
	TimerGameCalendar::Year min_year = CalendarTime::MAX_YEAR;
 

	
 
	for (int i = 0; i < NUM_HOUSES; i++) {
 
		HouseSpec *hs = HouseSpec::Get(i);
 
		if (hs == nullptr || !hs->enabled) continue;
 
		if ((hs->building_availability & bitmask) != bitmask) continue;
 
		if (hs->min_year < min_year) min_year = hs->min_year;