summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--misc.c39
-rw-r--r--oldloader.c2
-rw-r--r--variables.h2
-rw-r--r--vehicle.c3
4 files changed, 7 insertions, 39 deletions
diff --git a/misc.c b/misc.c
index 0601de81d..4fdd7740f 100644
--- a/misc.c
+++ b/misc.c
@@ -138,7 +138,6 @@ void InitializeGame(uint size_x, uint size_y)
_tick_counter = 0;
_date_fract = 0;
_cur_tileloop_tile = 0;
- _vehicle_id_ctr_day = 0;
{
uint starting = ConvertIntDate(_patches.starting_date);
@@ -485,40 +484,21 @@ static const uint16 _autosave_months[] = {
};
/**
- * Runs the day_proc of 'amount' vehicles.
+ * Runs the day_proc for every DAY_TICKS vehicle starting at daytick.
*/
-static void RunVehicleDayProc(uint amount)
+static void RunVehicleDayProc(uint daytick)
{
- Vehicle *v;
- VehicleID ctr;
- uint i;
-
- ctr = _vehicle_id_ctr_day;
-
- /* If the CTR is already over the size of the pool, don't even run the for-loop */
- if (ctr >= GetVehiclePoolSize()) {
- _vehicle_id_ctr_day += amount;
- return;
- }
+ uint i, total = _vehicle_pool.total_items;
- for (i = 0; i < amount; i++, ctr++) {
- /* Skip non-existing vehicles */
- if (ctr >= GetVehiclePoolSize()) {
- _vehicle_id_ctr_day += amount;
- return;
- }
-
- v = GetVehicle(ctr);
+ for (i = daytick; i < total; i += DAY_TICKS) {
+ Vehicle *v = GetVehicle(i);
if (v->type != 0)
_on_new_vehicle_day_proc[v->type - 0x10](v);
}
-
- _vehicle_id_ctr_day = ctr;
}
void IncreaseDate(void)
{
- uint32 total_vehicles = (1 << _vehicle_pool.block_size_bits) * _vehicle_pool.max_blocks;
YearMonthDay ymd;
if (_game_mode == GM_MENU) {
@@ -526,7 +506,7 @@ void IncreaseDate(void)
return;
}
- RunVehicleDayProc(total_vehicles / DAY_TICKS);
+ RunVehicleDayProc(_date_fract);
/* increase day, and check if a new day is there? */
_tick_counter++;
@@ -539,13 +519,6 @@ void IncreaseDate(void)
/* yeah, increse day counter and call various daily loops */
_date++;
- /* We have a hole because of rounding errors, between the last vehicle checked and the max amount
- * of vehicles.. correct for that problem here */
- RunVehicleDayProc(total_vehicles - _vehicle_id_ctr_day);
-
- assert(_vehicle_id_ctr_day == total_vehicles);
- _vehicle_id_ctr_day = 0;
-
TextMessageDailyLoop();
DisasterDailyLoop();
diff --git a/oldloader.c b/oldloader.c
index 1d1f8188f..882292170 100644
--- a/oldloader.c
+++ b/oldloader.c
@@ -422,8 +422,6 @@ static void FixOldVehicles(void)
}
}
}
-
- _vehicle_id_ctr_day = 0;
}
/*
diff --git a/variables.h b/variables.h
index 55502c3e2..acb69d162 100644
--- a/variables.h
+++ b/variables.h
@@ -62,7 +62,7 @@ VARDEF uint16 _date_fract;
// Amount of game ticks
VARDEF uint16 _tick_counter;
-// Used when calling OnNewDay
+// This one is not used anymore.
VARDEF VehicleID _vehicle_id_ctr_day;
// Skip aging of cargo?
diff --git a/vehicle.c b/vehicle.c
index e47e6d8bb..6eae858ed 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -2149,9 +2149,6 @@ static void Load_VEHS(void)
}
}
}
-
- if (_sl.full_version < 0x0B01)
- _vehicle_id_ctr_day = 0;
}
const ChunkHandler _veh_chunk_handlers[] = {