619 old max was i!= 12. But with that and a bigger number of vehicles (2560), per day only |
620 old max was i!= 12. But with that and a bigger number of vehicles (2560), per day only |
620 a part of it could be done, namely: function called max_size date_fract (uint16) / 885 x 12 ==> |
621 a part of it could be done, namely: function called max_size date_fract (uint16) / 885 x 12 ==> |
621 65536 / 885 = 74; 74x12 = 888. So max 888. Any vehicles above that were not _on_new_vehicle_day_proc'd |
622 65536 / 885 = 74; 74x12 = 888. So max 888. Any vehicles above that were not _on_new_vehicle_day_proc'd |
622 eg. aged. |
623 eg. aged. |
623 So new code updates it for max vehicles. |
624 So new code updates it for max vehicles. |
624 (NUM_VEHICLES / maximum number of times ctr is incremented before reset ) + 1 (to get last vehicles too) |
625 (_vehicles_size / maximum number of times ctr is incremented before reset ) + 1 (to get last vehicles too) |
625 max size of _date_fract / 885 (added each tick) is number of times before ctr is reset. |
626 max size of _date_fract / 885 (added each tick) is number of times before ctr is reset. |
626 Calculation might look complicated, but compiler just replaces it with 35, so that's ok |
627 Calculation might look complicated, but compiler just replaces it with 35, so that's ok |
627 */ |
628 */ |
628 |
629 |
629 ctr = _vehicle_id_ctr_day; |
630 ctr = _vehicle_id_ctr_day; |
630 for(i=0; i!=(NUM_VEHICLES / ((1<<sizeof(_date_fract)*8) / 885)) + 1 && ctr != lengthof(_vehicles); i++) { |
631 for (i = 0; i != (_vehicles_size / vehicles_per_day) + 1 && ctr != _vehicles_size; i++) { |
631 Vehicle *v = &_vehicles[ctr++]; |
632 Vehicle *v = GetVehicle(ctr++); |
632 if ((t=v->type) != 0) |
633 if ((t = v->type) != 0) |
633 _on_new_vehicle_day_proc[t - 0x10](v); |
634 _on_new_vehicle_day_proc[t - 0x10](v); |
634 } |
635 } |
635 _vehicle_id_ctr_day = ctr; |
636 _vehicle_id_ctr_day = ctr; |
636 |
637 |
637 /* increase day, and check if a new day is there? */ |
638 /* increase day, and check if a new day is there? */ |
638 _tick_counter++; |
639 _tick_counter++; |
639 |
640 |
640 if ( (_date_fract += 885) >= 885) |
641 _date_fract += 885; |
|
642 if (_date_fract >= 885) |
641 return; |
643 return; |
642 |
644 |
643 /* yeah, increse day counter and call various daily loops */ |
645 /* yeah, increse day counter and call various daily loops */ |
644 _date++; |
646 _date++; |
645 |
647 |