comparison mm7_3.cpp @ 2386:41c36ecc9f32

MapsLongTimer.h
author Ritor1
date Mon, 23 Jun 2014 23:45:14 +0600
parents b4a79e3ef2f0
children eba7123e4a2d
comparison
equal deleted inserted replaced
2381:cb84b457527c 2386:41c36ecc9f32
24 #include "PaletteManager.h" 24 #include "PaletteManager.h"
25 #include "DecorationList.h" 25 #include "DecorationList.h"
26 #include "Timer.h" 26 #include "Timer.h"
27 #include "TurnEngine.h" 27 #include "TurnEngine.h"
28 #include "Events2D.h" 28 #include "Events2D.h"
29 #include "stru176.h" 29 #include "MapsLongTimer.h"
30 #include "stru298.h" 30 #include "stru298.h"
31 #include "texts.h" 31 #include "texts.h"
32 #include "Level/Decoration.h" 32 #include "Level/Decoration.h"
33 #include "mm7_unsorted_subs.h" 33 #include "mm7_unsorted_subs.h"
34 #include "mm7_data.h" 34 #include "mm7_data.h"
3442 } 3442 }
3443 3443
3444 //----- (00443FDC) -------------------------------------------------------- 3444 //----- (00443FDC) --------------------------------------------------------
3445 void OnMapLoad() 3445 void OnMapLoad()
3446 { 3446 {
3447 // __int16 v4; // cx@9
3448 int v6; // eax@9 3447 int v6; // eax@9
3449 unsigned __int64 v8; // qax@26 3448 unsigned __int64 v8; // qax@26
3450 // unsigned int v9; // ecx@26
3451 unsigned __int64 v10; // qax@26
3452 unsigned __int64 v11; // qax@26
3453 unsigned __int64 v13; // qax@26
3454 unsigned __int64 v14; // qax@26
3455 // int v15; // ST58_4@26
3456 unsigned __int64 v16; // qax@26
3457 int hours; // ebx@26 3449 int hours; // ebx@26
3458 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 3450 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12
3459 unsigned int seconds; // [sp+14h] [bp-3Ch]@26 3451 unsigned int seconds; // [sp+14h] [bp-3Ch]@26
3460 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 3452 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7
3461 unsigned int minutes; // [sp+2Ch] [bp-24h]@26 3453 unsigned int minutes; // [sp+2Ch] [bp-24h]@26
3462 unsigned int years; // [sp+34h] [bp-1Ch]@26 3454 unsigned int years; // [sp+34h] [bp-1Ch]@26
3463 unsigned int weeks; // [sp+38h] [bp-18h]@26 3455 unsigned int weeks; // [sp+38h] [bp-18h]@26
3464 int v26; // [sp+3Ch] [bp-14h]@15 3456 int v26; // [sp+3Ch] [bp-14h]@15
3465 unsigned int days; // [sp+3Ch] [bp-14h]@26 3457 unsigned int days; // [sp+3Ch] [bp-14h]@26
3466 unsigned int months; // [sp+40h] [bp-10h]@26 3458 unsigned int months; // [sp+40h] [bp-10h]@26
3467 // __int16 v29; // [sp+46h] [bp-Ah]@9
3468 // __int16 v30; // [sp+48h] [bp-8h]@9
3469 // __int16 v32; // [sp+4Ch] [bp-4h]@9
3470 // __int16 v33; // [sp+4Eh] [bp-2h]@9
3471 3459
3472 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) 3460 for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
3473 { 3461 {
3474 EventIndex pEvent = pLevelEVT_Index[i]; 3462 EventIndex pEvent = pLevelEVT_Index[i];
3475 3463
3479 pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0); 3467 pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0);
3480 else if (_evt->_e_type == EVENT_OnMapReload) 3468 else if (_evt->_e_type == EVENT_OnMapReload)
3481 EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num); 3469 EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num);
3482 else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize) 3470 else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize)
3483 { 3471 {
3484 //v3 = &array_5B5928_timers[dword_5B65C8_timers_count]; 3472 //v3 = &MapsLongTimersList[MapsLongTimers_count];
3485 v20 = pOutdoor->loc_time.uLastVisitDay; 3473 v20 = pOutdoor->loc_time.uLastVisitDay;
3486 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) 3474 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
3487 v20 = pIndoor->stru1.uLastVisitDay; 3475 v20 = pIndoor->stru1.uLastVisitDay;
3488 3476
3489 array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_type = _evt->_e_type; 3477 MapsLongTimersList[MapsLongTimers_count].timer_evt_type = _evt->_e_type;
3490 array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_ID = pEvent.uEventID; 3478 MapsLongTimersList[MapsLongTimers_count].timer_evt_ID = pEvent.uEventID;
3491 array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_seq_num = pEvent.event_sequence_num; 3479 MapsLongTimersList[MapsLongTimers_count].timer_evt_seq_num = pEvent.event_sequence_num;
3492 3480
3493 array_5B5928_timers[dword_5B65C8_timers_count].field_10 = _evt->v5; 3481 MapsLongTimersList[MapsLongTimers_count].YearsInterval = _evt->v5;
3494 array_5B5928_timers[dword_5B65C8_timers_count].field_12 = _evt->v6; 3482 MapsLongTimersList[MapsLongTimers_count].MonthsInterval = _evt->v6;
3495 array_5B5928_timers[dword_5B65C8_timers_count].field_14 = _evt->v7; 3483 MapsLongTimersList[MapsLongTimers_count].WeeksInterval = _evt->v7;
3496 array_5B5928_timers[dword_5B65C8_timers_count].field_16 = _evt->v8; 3484 MapsLongTimersList[MapsLongTimers_count].HoursInterval = _evt->v8;
3497 array_5B5928_timers[dword_5B65C8_timers_count].field_18 = _evt->v9; 3485 MapsLongTimersList[MapsLongTimers_count].MinutesInterval = _evt->v9;
3498 array_5B5928_timers[dword_5B65C8_timers_count].field_1A = _evt->v10; 3486 MapsLongTimersList[MapsLongTimers_count].SecondsInterval = _evt->v10;
3499 3487
3500 3488
3501 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; 3489 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11;
3502 3490
3503 array_5B5928_timers[dword_5B65C8_timers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11; 3491 MapsLongTimersList[MapsLongTimers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11;
3504 array_5B5928_timers[dword_5B65C8_timers_count].fire_interval = ((unsigned short)_evt->v12 << 8) + _evt->v11; 3492 MapsLongTimersList[MapsLongTimers_count].IntervalHalfMins = ((unsigned short)_evt->v12 << 8) + _evt->v11;
3505 if (array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_type == EVENT_Initialize && !(short)v6 ) 3493 if (MapsLongTimersList[MapsLongTimers_count].timer_evt_type == EVENT_Initialize && !(short)v6 )
3506 { 3494 {
3507 if ( v20 ) 3495 if ( v20 )
3508 v18 = pParty->uTimePlayed - v20; 3496 v18 = pParty->uTimePlayed - v20;
3509 else 3497 else
3510 v18 = 0; 3498 v18 = 0;
3511 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; 3499 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24;
3512 3500
3513 if ( v26 / 7 / 4 / 12 != 0 && array_5B5928_timers[dword_5B65C8_timers_count].field_10 || 3501 if ( v26 / 7 / 4 / 12 != 0 && MapsLongTimersList[MapsLongTimers_count].YearsInterval ||
3514 v26 / 7 / 4 != 0 && array_5B5928_timers[dword_5B65C8_timers_count].field_12 != 0 || 3502 v26 / 7 / 4 != 0 && MapsLongTimersList[MapsLongTimers_count].MonthsInterval != 0 ||
3515 v26 / 7 != 0 && array_5B5928_timers[dword_5B65C8_timers_count].field_14 != 0 || 3503 v26 / 7 != 0 && MapsLongTimersList[MapsLongTimers_count].WeeksInterval != 0 ||
3516 v26 != 0 || !v20) 3504 v26 != 0 || !v20)
3517 { 3505 {
3518 ++dword_5B65C8_timers_count; 3506 ++MapsLongTimers_count;
3519 array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = 0; 3507 MapsLongTimersList[MapsLongTimers_count].NextStartTime = 0;
3520 continue; 3508 continue;
3521 } 3509 }
3522 } 3510 }
3523 else 3511 else
3524 { 3512 {
3525 v8 = (__int64)((double)pParty->uTimePlayed * 0.234375); 3513 v8 = (__int64)((double)pParty->uTimePlayed * 0.234375);
3526 seconds = v8 % 60; 3514 seconds = v8 % 60;
3527 v10 = v8 / 60; 3515 minutes = (v8 / 60) % 60;
3528 minutes = v10 % 60; 3516 hours = ((v8 / 60) / 60) % 24;
3529 v11 = v10 / 60; 3517 days = (((v8 / 60) / 60) / 24) % 7;
3530 hours = v11 % 24; 3518 weeks = ((((v8 / 60) / 60) / 24) / 7) % 4;
3531 v13 = v11 / 24; 3519 months = (((((v8 / 60) / 60) / 24) / 7) / 4) % 12;
3532 days = v13 % 7; 3520 years = (((((v8 / 60) / 60) / 24) / 7) / 4) / 12;
3533 v14 = v13 / 7; 3521
3534 weeks = v14 % 4; 3522 if ( MapsLongTimersList[MapsLongTimers_count].YearsInterval )
3535 v16 = v14 / 4;
3536 months = v16 % 12;
3537 years = v16 / 12;
3538
3539 if ( array_5B5928_timers[dword_5B65C8_timers_count].field_10 )
3540 ++years; 3523 ++years;
3541 else if ( array_5B5928_timers[dword_5B65C8_timers_count].field_12 ) 3524 else if ( MapsLongTimersList[MapsLongTimers_count].MonthsInterval )
3542 ++months; 3525 ++months;
3543 else if ( array_5B5928_timers[dword_5B65C8_timers_count].field_14 ) 3526 else if ( MapsLongTimersList[MapsLongTimers_count].WeeksInterval )
3544 ++weeks; 3527 ++weeks;
3545 else 3528 else
3546 { 3529 {
3547 ++days; 3530 ++days;
3548 minutes = array_5B5928_timers[dword_5B65C8_timers_count].field_18; 3531 hours = MapsLongTimersList[MapsLongTimers_count].HoursInterval;
3549 hours = array_5B5928_timers[dword_5B65C8_timers_count].field_16; 3532 minutes = MapsLongTimersList[MapsLongTimers_count].MinutesInterval;
3550 seconds = array_5B5928_timers[dword_5B65C8_timers_count].field_1A; 3533 seconds = MapsLongTimersList[MapsLongTimers_count].SecondsInterval;
3551 } 3534 }
3552 array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = (signed __int64)((double)((seconds 3535 MapsLongTimersList[MapsLongTimers_count].NextStartTime = (signed __int64)((double)((seconds
3553 + 60 * minutes 3536 + 60 * minutes
3554 + 3600 * hours 3537 + 3600 * hours
3555 + 86400 * days 3538 + 86400 * days
3556 + 604800 * weeks 3539 + 604800 * weeks
3557 + 2419200 * months 3540 + 2419200 * months
3558 + 29030400 * years) << 7) 3541 + 29030400 * years) << 7)
3559 * 0.033333335); 3542 * 0.033333335);
3560 3543
3561 ++dword_5B65C8_timers_count; 3544 ++MapsLongTimers_count;
3562 } 3545 }
3563 } 3546 }
3564 } 3547 }
3565 } 3548 }
3566 3549
3795 //v3 = HIDWORD(pParty->uTimePlayed); 3778 //v3 = HIDWORD(pParty->uTimePlayed);
3796 //v2 = LODWORD(pParty->uTimePlayed); 3779 //v2 = LODWORD(pParty->uTimePlayed);
3797 3780
3798 _5773B8_event_timer = pParty->uTimePlayed; 3781 _5773B8_event_timer = pParty->uTimePlayed;
3799 3782
3800 for (uint i = 0; i < dword_5B65C8_timers_count; ++i) 3783 for (uint i = 0; i < MapsLongTimers_count; ++i)
3801 { 3784 {
3802 //v4 = (char *)&array_5B5928_timers[0].field_C; 3785 //v4 = (char *)&array_5B5928_timers[0].field_C;
3803 stru176* timer = &array_5B5928_timers[i]; 3786 MapsLongTimer* timer = &MapsLongTimersList[i];
3804 //while ( 1 ) 3787 //while ( 1 )
3805 //{ 3788 //{
3806 //v5 = *(short *)v4; 3789 //v5 = *(short *)v4;
3807 if (timer->time_left_to_fire) 3790 if (timer->time_left_to_fire)
3808 { 3791 {
3809 if (v13 < timer->time_left_to_fire) 3792 if (v13 < timer->time_left_to_fire)
3810 timer->time_left_to_fire -= v13; 3793 timer->time_left_to_fire -= v13;
3811 else 3794 else
3812 { 3795 {
3813 timer->time_left_to_fire = timer->fire_interval; 3796 timer->time_left_to_fire = timer->IntervalHalfMins;
3814 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); 3797 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num);
3815 } 3798 }
3816 } 3799 }
3817 else 3800 else
3818 { 3801 {
3819 if (timer->next_fire_time < pParty->uTimePlayed) 3802 if (timer->NextStartTime < pParty->uTimePlayed)
3820 { 3803 {
3821 uint next_trigger_time = 1 * 60 * 60 * 24; // 1 day 3804 uint next_trigger_time = 1 * 60 * 60 * 24; // 1 day
3822 if (timer->field_10) 3805 if (timer->YearsInterval)
3823 next_trigger_time = 336 * 60 * 60 * 24; // 1 year 3806 next_trigger_time = 336 * 60 * 60 * 24; // 1 year
3824 else if (timer->field_12) 3807 else if (timer->MonthsInterval)
3825 next_trigger_time = 28 * 60 * 60 * 24; // 1 month 3808 next_trigger_time = 28 * 60 * 60 * 24; // 1 month
3826 else if (timer->field_14) 3809 else if (timer->WeeksInterval)
3827 next_trigger_time = 7 * 60 * 60 * 24; // 1 week 3810 next_trigger_time = 7 * 60 * 60 * 24; // 1 week
3828 3811
3829 timer->next_fire_time += (next_trigger_time * 128) / 3.0f; 3812 timer->NextStartTime += (next_trigger_time * 128) / 3.0f;
3830 if (timer->next_fire_time < pParty->uTimePlayed) // make sure in wont fire several times in a row if big time interval has lapsed 3813 if (timer->NextStartTime < pParty->uTimePlayed) // make sure in wont fire several times in a row if big time interval has lapsed
3831 timer->next_fire_time = pParty->uTimePlayed; 3814 timer->NextStartTime = pParty->uTimePlayed;
3832 3815
3833 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); 3816 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num);
3834 } 3817 }
3835 } 3818 }
3836 } 3819 }