changeset 601:d59398528e4f

level events loading fix
author Gloval
date Thu, 07 Mar 2013 01:07:45 +0400
parents db4a23580e6c
children 628694cd5744
files Events.cpp mm7_3.cpp mm7_data.h
diffstat 3 files changed, 29 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Thu Mar 07 00:35:10 2013 +0400
+++ b/Events.cpp	Thu Mar 07 01:07:45 2013 +0400
@@ -121,6 +121,17 @@
 //----- (00443EF8) --------------------------------------------------------
 void  LoadLevel_InitializeLevelEvt()
 	{
+    struct raw_event_header
+        { 
+        unsigned char evt_size;
+        unsigned char evt_id_l;
+        unsigned char evt_id_h;
+        unsigned char evt_sequence_num;
+        } ;
+    uint events_count;
+    unsigned int offset_in; 
+    raw_event_header *current_hdr; 
+
 	if (!uLevelEVT_Size)
 		return;
 
@@ -130,6 +141,19 @@
 	uLevelEVT_NumEvents = 0;
 	dword_5B65C8_timers_count = 0;
 
+    current_hdr=(raw_event_header *)pLevelEVT;
+    offset_in=0;
+    for (events_count = 0, offset_in = 0; offset_in < uLevelEVT_Size; ++events_count)
+        {
+        pLevelEVT_Index[events_count].uEventID=current_hdr->evt_id_l+(current_hdr->evt_id_h<<8);
+        pLevelEVT_Index[events_count].event_sequence_num=current_hdr->evt_sequence_num;
+        pLevelEVT_Index[events_count].uEventOffsetInEVT=offset_in;			
+        offset_in+=current_hdr->evt_size+1;
+        current_hdr=(raw_event_header *)&pLevelEVT[offset_in];
+        }
+    uLevelEVT_NumEvents = events_count;
+
+/*
 	for (uint i = 0, j = 0; j < uLevelEVT_Size; ++i)
 		{
 		pLevelEVT_Index[i].uEventID = pLevelEVT[j + 1] + ((unsigned short)pLevelEVT[j + 2] << 8);
@@ -137,7 +161,7 @@
 		pLevelEVT_Index[i].uEventOffsetInEVT = j;
 		j += pLevelEVT[j] + 1;
 		uLevelEVT_NumEvents++;
-		}
+		}*/
 	}
 
 
--- a/mm7_3.cpp	Thu Mar 07 00:35:10 2013 +0400
+++ b/mm7_3.cpp	Thu Mar 07 01:07:45 2013 +0400
@@ -13310,8 +13310,8 @@
 
 
 //----- (00443E31) --------------------------------------------------------
-void __cdecl LoadLevel_InitializeLevelStr()
-{
+void LoadLevel_InitializeLevelStr()
+    {
   
   char Args[100]; 
   int string_num;
@@ -13417,10 +13417,7 @@
 
 		if (_evt->_e_type == EVENT_PlaySound)
 			{
-			pSoundList->LoadSound(
-				_evt->v5 +
-				((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8),
-				0);
+			pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0);
 			}
 		else if (_evt->_e_type == EVENT_OnMapReload)
 			{
--- a/mm7_data.h	Thu Mar 07 00:35:10 2013 +0400
+++ b/mm7_data.h	Thu Mar 07 01:07:45 2013 +0400
@@ -2002,7 +2002,7 @@
 int __fastcall DrawBook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb
 void Initialize2DA();
 
-void __cdecl LoadLevel_InitializeLevelStr();
+void  LoadLevel_InitializeLevelStr();
 
 void __cdecl OnMapLeave();
 void /*__usercall*/ OnMapLoad();