441 // base date. |
441 // base date. |
442 return (year >> 2) * (365+365+365+366) + rem; |
442 return (year >> 2) * (365+365+365+366) + rem; |
443 } |
443 } |
444 |
444 |
445 // convert a date on the form |
445 // convert a date on the form |
446 // 1920 - 2090 |
446 // 1920 - 2090 (MAX_YEAR_END_REAL) |
447 // 192001 - 209012 |
447 // 192001 - 209012 |
448 // 19200101 - 20901231 |
448 // 19200101 - 20901231 |
449 // or if > 2090 and below 65536, treat it as a daycount |
449 // or if > 2090 and below 65536, treat it as a daycount |
450 // returns -1 if no conversion was possible |
450 // returns -1 if no conversion was possible |
451 uint ConvertIntDate(uint date) |
451 uint ConvertIntDate(uint date) |
452 { |
452 { |
453 uint year, month = 0, day = 1; |
453 uint year, month = 0, day = 1; |
454 |
454 |
455 if (IS_INT_INSIDE(date, 1920, 2090 + 1)) { |
455 if (IS_INT_INSIDE(date, 1920, MAX_YEAR_END_REAL + 1)) { |
456 year = date - 1920; |
456 year = date - 1920; |
457 } else if (IS_INT_INSIDE(date, 192001, 209012+1)) { |
457 } else if (IS_INT_INSIDE(date, 192001, 209012+1)) { |
458 month = date % 100 - 1; |
458 month = date % 100 - 1; |
459 year = date / 100 - 1920; |
459 year = date / 100 - 1920; |
460 } else if (IS_INT_INSIDE(date, 19200101, 20901231+1)) { |
460 } else if (IS_INT_INSIDE(date, 19200101, 20901231+1)) { |
698 #ifdef ENABLE_NETWORK |
698 #ifdef ENABLE_NETWORK |
699 if (_network_server) |
699 if (_network_server) |
700 NetworkServerYearlyLoop(); |
700 NetworkServerYearlyLoop(); |
701 #endif /* ENABLE_NETWORK */ |
701 #endif /* ENABLE_NETWORK */ |
702 |
702 |
703 /* check if we reached 2090, that's the maximum year. */ |
703 /* check if we reached 2090 (MAX_YEAR_END_REAL), that's the maximum year. */ |
704 if (_cur_year == 171) { |
704 if (_cur_year == (MAX_YEAR_END + 1)) { |
705 Vehicle *v; |
705 Vehicle *v; |
706 _cur_year = 170; |
706 _cur_year = MAX_YEAR_END; |
707 _date = 62093; |
707 _date = 62093; |
708 FOR_ALL_VEHICLES(v) { |
708 FOR_ALL_VEHICLES(v) { |
709 v->date_of_last_service -= 365; // 1 year is 365 days long |
709 v->date_of_last_service -= 365; // 1 year is 365 days long |
710 } |
710 } |
711 } |
711 } |