src/newgrf_fsmports.cpp
branchNewGRF_ports
changeset 6871 5a9dc001e1ad
parent 6868 7eb395287b3d
child 6872 1c4a4a609f85
equal deleted inserted replaced
6870:ca3fd1fbe311 6871:5a9dc001e1ad
   297 			case 0x47:
   297 			case 0x47:
   298 			case 0x49: return 0x2110000;       // Platforms, tracks & position
   298 			case 0x49: return 0x2110000;       // Platforms, tracks & position
   299 			case 0x42: return 0;               // Rail type (XXX Get current type from GUI?)
   299 			case 0x42: return 0;               // Rail type (XXX Get current type from GUI?)
   300 			case 0x43: return _current_player; // Station owner
   300 			case 0x43: return _current_player; // Station owner
   301 			case 0x44: return 2;               // PBS status
   301 			case 0x44: return 2;               // PBS status
   302 			case 0xFA: return clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value
   302 			case 0xFA: return Clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, Clamped to a 16 bit value
   303 		}
   303 		}
   304 
   304 
   305 		*available = false;
   305 		*available = false;
   306 		return UINT_MAX;
   306 		return UINT_MAX;
   307 	}
   307 	}
   313 		case 0x48: { // Accepted cargo types
   313 		case 0x48: { // Accepted cargo types
   314 			CargoID cargo_type;
   314 			CargoID cargo_type;
   315 			uint32 value = 0;
   315 			uint32 value = 0;
   316 
   316 
   317 			for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
   317 			for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
   318 				if (HASBIT(st->goods[cargo_type].acceptance_pickup, GoodsEntry::ACCEPTANCE)) SETBIT(value, cargo_type);
   318 				if (HasBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::ACCEPTANCE)) SetBit(value, cargo_type);
   319 			}
   319 			}
   320 			return value;
   320 			return value;
   321 		}
   321 		}
   322 		/* Variables which use the parameter */
   322 		/* Variables which use the parameter */
   323 		/* Variables 0x60 to 0x65 are handled separately below */
   323 		/* Variables 0x60 to 0x65 are handled separately below */
   332 		case 0xF2: return st->truck_stops->status;
   332 		case 0xF2: return st->truck_stops->status;
   333 		case 0xF3: return st->bus_stops->status;
   333 		case 0xF3: return st->bus_stops->status;
   334 		//TODO: need to decide how/what to return
   334 		//TODO: need to decide how/what to return
   335 		//case 0xF6: return st->airport_flags;
   335 		//case 0xF6: return st->airport_flags;
   336 		//case 0xF7: return GB(st->airport_flags, 8, 8);
   336 		//case 0xF7: return GB(st->airport_flags, 8, 8);
   337 		case 0xFA: return clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535);
   337 		case 0xFA: return Clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535);
   338 	}
   338 	}
   339 
   339 
   340 	/* Handle cargo variables with parameter, 0x60 to 0x65 */
   340 	/* Handle cargo variables with parameter, 0x60 to 0x65 */
   341 	if (variable >= 0x60 && variable <= 0x65) {
   341 	if (variable >= 0x60 && variable <= 0x65) {
   342 		CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile);
   342 		CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile);
   405 		default:
   405 		default:
   406 			cargo = st->goods[cargo_type].cargo.Count();
   406 			cargo = st->goods[cargo_type].cargo.Count();
   407 			break;
   407 			break;
   408 	}
   408 	}
   409 
   409 
   410 	if (HASBIT(fsmportspec->flags, 1)) cargo /= (st->trainst_w + st->trainst_h);
   410 	if (HasBit(fsmportspec->flags, 1)) cargo /= (st->trainst_w + st->trainst_h);
   411 	cargo = min(0xfff, cargo);
   411 	cargo = min(0xfff, cargo);
   412 
   412 
   413 	if (cargo > fsmportspec->cargo_threshold) {
   413 	if (cargo > fsmportspec->cargo_threshold) {
   414 		if (group->g.real.num_loading > 0) {
   414 		if (group->g.real.num_loading > 0) {
   415 			set = ((cargo - fsmportspec->cargo_threshold) * group->g.real.num_loading) / (4096 - fsmportspec->cargo_threshold);
   415 			set = ((cargo - fsmportspec->cargo_threshold) * group->g.real.num_loading) / (4096 - fsmportspec->cargo_threshold);