src/newgrf_station.cpp
branchgamebalance
changeset 9908 0fa543611bbe
parent 9906 6f41b8713b65
child 9909 dce9a6923bb7
equal deleted inserted replaced
9907:3b068c3a1c74 9908:0fa543611bbe
   182 
   182 
   183 	for (StationClassID i = STAT_CLASS_BEGIN; i < STAT_CLASS_MAX; i++) {
   183 	for (StationClassID i = STAT_CLASS_BEGIN; i < STAT_CLASS_MAX; i++) {
   184 		for (j = 0; j < station_classes[i].stations; j++) {
   184 		for (j = 0; j < station_classes[i].stations; j++) {
   185 			const StationSpec *statspec = station_classes[i].spec[j];
   185 			const StationSpec *statspec = station_classes[i].spec[j];
   186 			if (statspec == NULL) continue;
   186 			if (statspec == NULL) continue;
   187 			if (statspec->grfid == grfid && statspec->localidx == localidx) return statspec;
   187 			if (statspec->grffile->grfid == grfid && statspec->localidx == localidx) return statspec;
   188 		}
   188 		}
   189 	}
   189 	}
   190 
   190 
   191 	return NULL;
   191 	return NULL;
   192 }
   192 }
   407 			return value;
   407 			return value;
   408 		}
   408 		}
   409 		case 0x49: return GetPlatformInfoHelper(tile, false, true, false);
   409 		case 0x49: return GetPlatformInfoHelper(tile, false, true, false);
   410 
   410 
   411 		/* Variables which use the parameter */
   411 		/* Variables which use the parameter */
   412 		case 0x60: return GB(st->goods[parameter].waiting_acceptance, 0, 12);
   412 		/* Variables 0x60 to 0x65 are handled separately below */
   413 		case 0x61: return st->goods[parameter].days_since_pickup;
       
   414 		case 0x62: return st->goods[parameter].rating;
       
   415 		case 0x63: return st->goods[parameter].enroute_time;
       
   416 		case 0x64: return st->goods[parameter].last_speed | (st->goods[parameter].last_age << 8);
       
   417 		case 0x65: return GB(st->goods[parameter].waiting_acceptance, 12, 4);
       
   418 
   413 
   419 		/* General station properties */
   414 		/* General station properties */
   420 		case 0x82: return 50;
   415 		case 0x82: return 50;
   421 		case 0x84: return st->string_id;
   416 		case 0x84: return st->string_id;
   422 		case 0x86: return 0;
   417 		case 0x86: return 0;
   428 		case 0xF6: return st->airport_flags;
   423 		case 0xF6: return st->airport_flags;
   429 		case 0xF7: return GB(st->airport_flags, 8, 8);
   424 		case 0xF7: return GB(st->airport_flags, 8, 8);
   430 		case 0xFA: return max(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
   425 		case 0xFA: return max(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
   431 	}
   426 	}
   432 
   427 
       
   428 	/* Handle cargo variables with parameter, 0x60 to 0x65 */
       
   429 	if (variable >= 0x60 && variable <= 0x65) {
       
   430 		CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile);
       
   431 
       
   432 		if (c == CT_INVALID) return 0;
       
   433 		const GoodsEntry *ge = &st->goods[c];
       
   434 
       
   435 		switch (variable) {
       
   436 			case 0x60: return GB(ge->waiting_acceptance, 0, 12);
       
   437 			case 0x61: return ge->days_since_pickup;
       
   438 			case 0x62: return ge->rating;
       
   439 			case 0x63: return ge->enroute_time;
       
   440 			case 0x64: return ge->last_speed | (ge->last_age << 8);
       
   441 			case 0x65: return GB(ge->waiting_acceptance, 12, 4);
       
   442 		}
       
   443 	}
       
   444 
   433 	/* Handle cargo variables (deprecated) */
   445 	/* Handle cargo variables (deprecated) */
   434 	if (variable >= 0x8C && variable <= 0xEC) {
   446 	if (variable >= 0x8C && variable <= 0xEC) {
   435 		const GoodsEntry *g = &st->goods[GB(variable - 0x8C, 3, 4)];
   447 		const GoodsEntry *g = &st->goods[GB(variable - 0x8C, 3, 4)];
   436 		switch (GB(variable - 0x8C, 0, 3)) {
   448 		switch (GB(variable - 0x8C, 0, 3)) {
   437 			case 0: return g->waiting_acceptance;
   449 			case 0: return g->waiting_acceptance;
   636 				st->speclist[0].localidx = 0;
   648 				st->speclist[0].localidx = 0;
   637 			}
   649 			}
   638 		}
   650 		}
   639 
   651 
   640 		st->speclist[i].spec     = statspec;
   652 		st->speclist[i].spec     = statspec;
   641 		st->speclist[i].grfid    = statspec->grfid;
   653 		st->speclist[i].grfid    = statspec->grffile->grfid;
   642 		st->speclist[i].localidx = statspec->localidx;
   654 		st->speclist[i].localidx = statspec->localidx;
   643 	}
   655 	}
   644 
   656 
   645 	return i;
   657 	return i;
   646 }
   658 }