diff mm7_3.cpp @ 336:ea55d6414029

Event_proceccor preliminary
author Gloval
date Thu, 21 Feb 2013 00:33:12 +0400
parents f76027321087
children 672b83584b0f
line wrap: on
line diff
--- a/mm7_3.cpp	Wed Feb 20 21:35:13 2013 +0400
+++ b/mm7_3.cpp	Thu Feb 21 00:33:12 2013 +0400
@@ -14170,7 +14170,7 @@
   max_string_length = 0;
   string_num = 1;
   prev_string_offset = 0;
-
+  pLevelStrOffsets[0]=0;
   for (uint i = 0; i < uLevelStrFileSize; ++i)
   {
       if ( !pLevelStr[i] )
@@ -14192,7 +14192,7 @@
 
   if ( uLevelStrNumStrings > 0 )
   {
-    for(uint i = 1; i <uLevelStrNumStrings ; ++i) 
+    for(uint i = 0; i <uLevelStrNumStrings ; ++i) 
     {
       if ( RemoveQuotes(&pLevelStr[pLevelStrOffsets[i]]) != &pLevelStr[pLevelStrOffsets[i]] )
         ++pLevelStrOffsets[i]; 
@@ -14204,27 +14204,19 @@
 //----- (00443F95) --------------------------------------------------------
 void __cdecl OnMapLeave()
 {
-  signed int v0; // edi@1
-  char *v1; // esi@2
-  int v2; // ecx@4
-
-  v0 = 0;
-  if ( (signed int)uLevelEVT_NumEvents > 0 )
-  {
-    v1 = (char *)&pLevelEVT_Index[0].event_sequence_num;
-    do
-    {
-      if ( pLevelEVT[*((short *)v1 + 2) + 4] == 53 )
-      {
-        v2 = *((int *)v1 - 1);
-        dword_597F18 = *(int *)v1;
-        EventProcessor(v2, 0, 1);
-        dword_597F18 = 0;
-      }
-      ++v0;
-      v1 += 12;
-    }
-    while ( v0 < (signed int)uLevelEVT_NumEvents );
+ _evt_raw *test_event;
+  if ( uLevelEVT_NumEvents > 0 )
+  {
+    for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
+    {
+		test_event=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT];
+      if ( test_event->_e_type== EVENT_OnMapLeave )
+      {
+        start_event_seq_number = pLevelEVT_Index[i].event_sequence_num;
+        EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1);
+        start_event_seq_number = 0;
+      }
+    }
   }
 }
 
@@ -14276,38 +14268,34 @@
     }
     else if (_evt->_e_type == EVENT_OnMapReload)
     {
-      dword_597F18 = pEvent.event_sequence_num;
+      start_event_seq_number = pEvent.event_sequence_num;
       EventProcessor(pEvent.uEventID, 0, 0);
-      dword_597F18 = 0;
+      start_event_seq_number = 0;
     }
     else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_OnLongTimer)
     {
-      v3 = &array_5B5928[dword_5B65C8];
+      v3 = &array_5B5928_timers[dword_5B65C8_timers_count];
       v20 = pOutdoor->uLastVisitDay;
       if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
         v20 = pIndoor->stru1.uLastVisitDay;
 
-      v4 = _evt->_e_type;
-      v3->field_1C = v4;
-      v3->field_8 = pEvent.uEventID;
-      v3->field_A = pEvent.event_sequence_num;
-      v33 = _evt->v6;
-      v3->field_12 = v33;
-      v32 = _evt->v7;
-      v3->field_14 = v32;
-      v31 = _evt->v8;
-      v3->field_16 = v31;
-      v5 = _evt->v5;
-      v30 = _evt->v9;
-      v3->field_18 = v30;
-      v29 = _evt->v10;
-      v3->field_1A = v29;
+      v3->timer_evt_type = _evt->_e_type;
+      v3->timer_evt_ID = pEvent.uEventID;
+      v3->timer_evt_seq_num = pEvent.event_sequence_num;
+
+	  v3->field_10 = _evt->v5;
+      v3->field_12 = _evt->v6;
+      v3->field_14 = _evt->v7;
+      v3->field_16 = _evt->v8;
+	  v3->field_18 = _evt->v9;
+	  v3->field_1A = _evt->v10;
+      
 
       v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11;
-      v3->field_10 = v5;
-      v3->field_C = v6;
-      v3->field_E = v6;
-      if ( v4 == 38 && !(short)v6 )
+     
+      v3->field_C = ((unsigned short)_evt->v12 << 8) + _evt->v11;
+      v3->field_E = ((unsigned short)_evt->v12 << 8) + _evt->v11;
+      if (v3->timer_evt_type  == EVENT_OnLongTimer && !(short)v6 )
       {
         if ( v20 )
           v18 = pParty->uTimePlayed - v20;
@@ -14319,7 +14307,7 @@
         {
           if ( v5 )
           {
-            ++dword_5B65C8;
+            ++dword_5B65C8_timers_count;
             v3->field_0_time = 0;
             continue;
           }
@@ -14328,12 +14316,13 @@
             v26 / 7 != 0 && v32 != 0 ||
             v26 != 0 || !v20)
         {
-          ++dword_5B65C8;
+          ++dword_5B65C8_timers_count;
           v3->field_0_time = 0;
           continue;
         }
       }
-
+	  else
+		  {
       v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
       v9 = v8;
       v10 = (signed int)v8 / 60;
@@ -14391,7 +14380,8 @@
                                 + 0x24EA00 * (v28 + 12i64 * month)) << 7)
                       * 0.033333335);
 
-      ++dword_5B65C8;
+      ++dword_5B65C8_timers_count;
+		  }
     }
   }
 }
@@ -14880,7 +14870,7 @@
   {
     if ( pParty->uFlags & 2 )
       pGame->Draw();
-    if ( !dword_597F18 )
+    if ( !start_event_seq_number )
       pAudioPlayer->StopChannels(-1, -1);
     pMiscTimer->Pause();
     pEventTimer->Pause();
@@ -14901,9 +14891,9 @@
   pGUIWindow2->Release();
   pGUIWindow2 = 0;
   _5C3420_pDecoration = _591094_decoration;
-  dword_597F18 = dword_5C341C;
+  start_event_seq_number = dword_5C341C;
   EventProcessor(dword_5C3418, 0, 1);
-  dword_597F18 = 0;
+  start_event_seq_number = 0;
   _5C3420_pDecoration = 0;
   pEventTimer->Resume();
 }
@@ -15709,7 +15699,7 @@
   v13 = _this;
   if ( !_this )
     return 0;
-  v3 = dword_597F18;
+  v3 = start_event_seq_number;
   pSomeOtherEVT = pGlobalEVT;
   uSomeOtherEVT_NumEvents = uGlobalEVT_NumEvents;
   memcpy(pSomeOtherEVT_Events, pGlobalEVT_Index, 0xCE40u);
@@ -16200,9 +16190,9 @@
     {
       _5773B8_event_timer = pParty->uTimePlayed;
       v12 = 0;
-      if ( dword_5B65C8 > 0 )
-      {
-        v4 = (char *)&array_5B5928[0].field_C;
+      if ( dword_5B65C8_timers_count > 0 )
+      {
+        v4 = (char *)&array_5B5928_timers[0].field_C;
         while ( 1 )
         {
           v5 = *(short *)v4;
@@ -16236,9 +16226,9 @@
               *((int *)v4 - 2) = v3;
             }
             v11 = *((short *)v4 - 2);
-            dword_597F18 = *((short *)v4 - 1);
+            start_event_seq_number = *((short *)v4 - 1);
             EventProcessor(v11, 0, 1);
-            dword_597F18 = 0;
+            start_event_seq_number = 0;
 LABEL_25:
             v3 = HIDWORD(pParty->uTimePlayed);
             v2 = LODWORD(pParty->uTimePlayed);
@@ -16246,7 +16236,7 @@
 LABEL_26:
           ++v12;
           v4 += 32;
-          if ( v12 >= dword_5B65C8 )
+          if ( v12 >= dword_5B65C8_timers_count )
             return;
           v1 = 0;
         }
@@ -16257,9 +16247,9 @@
         }
         v6 = *((short *)v4 - 2);
         *(short *)v4 = *((short *)v4 + 1);
-        dword_597F18 = *((short *)v4 - 1);
+        start_event_seq_number = *((short *)v4 - 1);
         EventProcessor(v6, 0, 1);
-        dword_597F18 = v1;
+        start_event_seq_number = v1;
         goto LABEL_25;
       }
     }