Changeset - r165:ad6b8e77ad62
[Not reviewed]
master
0 4 0
darkvater - 20 years ago 2004-09-06 18:22:25
darkvater@openttd.org
(svn r166) -Codechange: change 74 for constant DAY_TICKS
4 files changed with 8 insertions and 9 deletions:
0 comments (0 inline, 0 general)
ai.h
Show inline comments
 
@@ -131,13 +131,13 @@
 
#define AI_STATION_REUSE_MULTIPLER 2
 

	
 
// No more then this amount of vehicles per station..
 
#define AI_CHECK_MAX_VEHICLE_PER_STATION 10
 

	
 
// How many thick between building 2 vehicles
 
#define AI_BUILD_VEHICLE_TIME_BETWEEN 74
 
#define AI_BUILD_VEHICLE_TIME_BETWEEN DAY_TICKS
 

	
 
// How many days must there between vehicle checks
 
//  The more often, the less non-money-making lines there will be
 
//   but the unfair it may seem to a human player
 
#define AI_DAYS_BETWEEN_VEHICLE_CHECKS 30
 

	
ai_new.c
Show inline comments
 
@@ -62,14 +62,13 @@ static void AiNew_State_FirstTime(Player
 
//
 
// Let's say, we sleep between one and three days if the AI is put on Very Fast.
 
//  This means that on Very Slow it will be between 16 and 48 days.. slow enough?
 
static void AiNew_State_Nothing(Player *p) {
 
    assert(p->ainew.state == AI_STATE_NOTHING);
 
    // If we are done idling, start over again
 
    // There go 74 ticks in a day
 
	if (p->ainew.idle == 0) p->ainew.idle = RandomRange(74 * 2) + 74;
 
	if (p->ainew.idle == 0) p->ainew.idle = RandomRange(DAY_TICKS * 2) + DAY_TICKS;
 
	if (--p->ainew.idle == 0) {
 
		// We are done idling.. what you say? Let's do something!
 
		// I mean.. the next tick ;)
 
		p->ainew.state = AI_STATE_WAKE_UP;
 
	}
 
}
 
@@ -828,13 +827,13 @@ static int AiNew_HowManyVehicles(Player 
 
		i = AiNew_PickVehicle(p);
 
		if (i == -1) return 0;
 
    	// Passenger run.. how long is the route?
 
    	length = p->ainew.path_info.route_length;
 
    	// Calculating tiles a day a vehicle moves is not easy.. this is how it must be done!
 
    	// ROAD_ENGINES_INDEX is because the first roadveh engine is ROAD_ENGINES_INDEX, and _roadveh_speed starts from 0
 
    	tiles_a_day = _roadveh_speed[i-ROAD_ENGINES_INDEX] * 74 / 256 / 16;
 
    	tiles_a_day = _roadveh_speed[i-ROAD_ENGINES_INDEX] * DAY_TICKS / 256 / 16;
 
    	// We want a vehicle in a station once a month at least, so, calculate it!
 
    	// (the * 2 is because we have 2 stations ;))
 
    	amount = ((int)(((float)length / (float)tiles_a_day / 30 * 2))) * 2;
 
    	if (amount == 0) amount = 1;
 
   		return amount;
 
	} else if (p->ainew.tbt == AI_TRUCK) {
 
@@ -844,13 +843,13 @@ static int AiNew_HowManyVehicles(Player 
 
		i = AiNew_PickVehicle(p);
 
		if (i == -1) return 0;
 
    	// Passenger run.. how long is the route?
 
    	length = p->ainew.path_info.route_length;
 
    	// Calculating tiles a day a vehicle moves is not easy.. this is how it must be done!
 
    	// ROAD_ENGINES_INDEX is because the first roadveh engine is ROAD_ENGINES_INDEX, and _roadveh_speed starts from 0
 
    	tiles_a_day = _roadveh_speed[i-ROAD_ENGINES_INDEX] * 74 / 256 / 16;
 
    	tiles_a_day = _roadveh_speed[i-ROAD_ENGINES_INDEX] * DAY_TICKS / 256 / 16;
 
    	if (p->ainew.from_deliver)
 
    		max_cargo = DEREF_INDUSTRY(p->ainew.from_ic)->total_production[0];
 
    	else
 
    		max_cargo = DEREF_INDUSTRY(p->ainew.to_ic)->total_production[0];
 

	
 
    	// This is because moving 60% is more then we can dream of!
graph_gui.c
Show inline comments
 
@@ -664,25 +664,25 @@ static void PerformanceRatingDetailWndPr
 
        	// Update all player stats with the current data
 
        	//  (this is because _score_info is not saved to a savegame)
 
        	FOR_ALL_PLAYERS(p2)
 
        		if (p2->is_active)
 
        			UpdateCompanyRatingAndValue(p2, false);
 
        		
 
        	w->custom[0] = 74;
 
        	w->custom[0] = DAY_TICKS;
 
        	w->custom[1] = 5;
 
        	
 
        	w->click_state = 1 << 13;
 
        	
 
			SetWindowDirty(w);
 
        }
 
    	break;
 
    case WE_TICK:
 
        {
 
        	// Update the player score every 5 days
 
            if (--w->custom[0] == 0) {
 
            	w->custom[0] = 74;
 
            	w->custom[0] = DAY_TICKS;
 
            	if (--w->custom[1] == 0) {
 
            		Player *p2;
 
            		w->custom[1] = 5;
 
            		FOR_ALL_PLAYERS(p2)
 
            			// Skip if player is not active
 
            			if (p2->is_active)
players.c
Show inline comments
 
@@ -491,13 +491,13 @@ Player *DoStartupNewPlayer(bool is_ai)
 
	return p;
 
}
 

	
 
void StartupPlayers()
 
{
 
	// The AI starts like in the setting with +2 month max
 
	_next_competitor_start = _opt.diff.competitor_start_time * 90 * 74 + RandomRange(60 * 74) + 1;
 
	_next_competitor_start = _opt.diff.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1;
 
}
 

	
 
static void MaybeStartNewPlayer()
 
{
 
	uint n;
 
	Player *p;
 
@@ -510,13 +510,13 @@ static void MaybeStartNewPlayer()
 

	
 
	// when there's a lot of computers in game, the probability that a new one starts is lower
 
	if (n < (uint)_opt.diff.max_no_competitors && n < RandomRange(_opt.diff.max_no_competitors + 2))
 
		DoStartupNewPlayer(true);
 
	
 
	// The next AI starts like the difficulty setting said, with +2 month max
 
	_next_competitor_start = _opt.diff.competitor_start_time * 90 * 74 + RandomRange(60 * 74) + 1;
 
	_next_competitor_start = _opt.diff.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1;
 
}
 

	
 
void InitializePlayers()
 
{
 
	int i;
 
	memset(_players, 0, sizeof(_players));
0 comments (0 inline, 0 general)