diff Events.cpp @ 336:ea55d6414029

Event_proceccor preliminary
author Gloval
date Thu, 21 Feb 2013 00:33:12 +0400
parents 4c2cdda88562
children edd2d8b7e3c4
line wrap: on
line diff
--- a/Events.cpp	Wed Feb 20 21:35:13 2013 +0400
+++ b/Events.cpp	Thu Feb 21 00:33:12 2013 +0400
@@ -122,11 +122,11 @@
 	if (!uLevelEVT_Size)
 		return;
 
-	memset(array_5B5928, 0, 3200);
-	memset(pLevelEVT_Index, 80, 52800);
+	memset(array_5B5928_timers, 0, 3200);
+	memset(pLevelEVT_Index, 80, sizeof(EventIndex)*4400);
 
 	uLevelEVT_NumEvents = 0;
-	dword_5B65C8 = 0;
+	dword_5B65C8_timers_count = 0;
 
 	for (uint i = 0, j = 0; j < uLevelEVT_Size; ++i)
 		{
@@ -143,7 +143,7 @@
 void  EventProcessor(int uEventID, int a2, int a3)
 	{
 	unsigned int v3; // eax@5
-	//signed int v4; // esi@7
+	signed int v4; // esi@7
 	//char *v5; // eax@8
 	Player *v6; // ecx@8
 	//char *v7; // ebp@8
@@ -263,10 +263,10 @@
 	int v121; // [sp-4h] [bp-4ACh]@294
 	int curr_seq_num; // [sp+10h] [bp-498h]@4
 	//char *v123; // [sp+14h] [bp-494h]@0
-	//signed int v124; // [sp+18h] [bp-490h]@7
+	signed int v124; // [sp+18h] [bp-490h]@7
 	signed int v125; // [sp+1Ch] [bp-48Ch]@155
 	int v126; // [sp+1Ch] [bp-48Ch]@262
-	int v127; // [sp+20h] [bp-488h]@4
+	int player_choose; // [sp+20h] [bp-488h]@4
 	int v128; // [sp+24h] [bp-484h]@21
 	int v129; // [sp+24h] [bp-484h]@262
 	signed int v130; // [sp+28h] [bp-480h]@0
@@ -294,54 +294,57 @@
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here
 		return;
 		}
-	v127 = 2 * (uActiveCharacter == 0) + 4;  //4 and 6
-	curr_seq_num = dword_597F18;
+	player_choose = (uActiveCharacter == 0)?6:4;  //4 - active or  6 - random player if active =0
+	curr_seq_num = start_event_seq_number;
 	if ( _5C3420_pDecoration )
 		{
 		uSomeEVT_NumEvents = uGlobalEVT_NumEvents;
 		pSomeEVT = pGlobalEVT;
-		memcpy(pSomeEVT_Events, pGlobalEVT_Index, 52800); //4400 evts
+		memcpy(pSomeEVT_Events, pGlobalEVT_Index, sizeof(EventIndex)*4400); //4400 evts
 		}
 	else
 		{
 		uSomeEVT_NumEvents = uLevelEVT_NumEvents;
 		pSomeEVT = pLevelEVT;
-		memcpy(pSomeEVT_Events, pLevelEVT_Index, 52800);
+		memcpy(pSomeEVT_Events, pLevelEVT_Index, sizeof(EventIndex)*4400);
 		}
 
 
-	//v4 = 0;
-	//v124 = 0;
-	for (uint i = 0; i < uSomeEVT_NumEvents; ++i)
-		{
-		//v5 = pSomeEVT;
+	v4 = 0;
+	v124 = 0;
+	//for (uint i = 0; i < uSomeEVT_NumEvents; ++i)
+	//	{
+		
 		//v6 = v123;
 		//v7 = "";
-		//while ( 1 )
-		//{
+		while ( 1 )
+		{
 		if ( dword_5B65C4 )
 			goto LABEL_301;
 		//v8 = v4;
-		if ( pSomeEVT_Events[i/*v4*/].uEventID == uEventID && pSomeEVT_Events[i/*v4*/].event_sequence_num == curr_seq_num )
+		if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num )
 			{
 			//v9 = pSomeEVT_Events[v8].uEventOffsetInEVT;
 			//v10 = (ByteArray *)&v5[v9];
-			auto _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[i/*v4*/].uEventOffsetInEVT);
+			auto _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[v4].uEventOffsetInEVT);
 
 			switch (_evt->_e_type)
 				{
 			case EVENT_CheckSeason:
+				//
 				if ( !sub_4465DF_check_season(_evt->v5) )
 					{
 					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
 					break;
 					}
-				v11 = _evt->v6;
-				goto LABEL_130;
+				v124 = -1;
+				curr_seq_num = _evt->v6 - 1;
+			    ++curr_seq_num;
+				break;
 			case EVENT_ShowMovie:
 				{
 				strcpy(Source, (char *)&_evt->v7);
@@ -380,8 +383,8 @@
 					if (pAsyncMouse)
 						pAsyncMouse->Resume();
 					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
 					break;
@@ -403,8 +406,8 @@
 					if (pAsyncMouse)
 						pAsyncMouse->Resume();
 					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
 
@@ -427,8 +430,8 @@
 				if (pAsyncMouse)
 					pAsyncMouse->Resume();
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				}
@@ -436,21 +439,21 @@
 			case EVENT_CheckSkill:
 				{
 				v19 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((unsigned int)_evt->v10 << 8)) << 8)) << 8);
-				if ( v127 < 0 )
+				if ( player_choose < 0 )
 					goto LABEL_47;
-				if ( v127 <= 3 )
+				if ( player_choose <= 3 )
 					{
-					v24 = pParty->pPlayers[0].pActiveSkills[3486 * v127 + _evt->v5];
+					v24 = pParty->pPlayers[0].pActiveSkills[3486 * player_choose + _evt->v5];
 					}
 				else
 					{
-					if ( v127 == 4 )
+					if ( player_choose == 4 )
 						{
 						v24 = pPlayers[uActiveCharacter]->pActiveSkills[_evt->v5];
 						}
 					else
 						{
-						if ( v127 == 5 )
+						if ( player_choose == 5 )
 							{
 							v20 = 0;
 							v21 = 3486 * v130 + _evt->v5;
@@ -467,8 +470,8 @@
 								if ( v20 >= 4 )
 									{
 									++curr_seq_num;
-									//v4 = v124;
-									//v5 = pSomeEVT;
+									v4 = v124;
+									
 									//v6 = v123;
 									//v7 = "";
 									break;
@@ -492,8 +495,8 @@
 					goto LABEL_130;
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				}
@@ -517,8 +520,8 @@
 						+ ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8);
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -535,8 +538,8 @@
 					LOBYTE(v26->field_2) |= 0x20u;
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -546,8 +549,8 @@
 				pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu;
 				pNPCStats->pNewNPCData[v27].greet = v28;
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -605,25 +608,25 @@
 					if ( v30 == 78 )
 						{
 						sub_4BD8B5();
-						ptr_507BC0->Release();
+						window_SpeakInHouse->Release();
 						pParty->uFlags &= 0xFFFFFFFDu;
 						if ( EnterHouse((enum HOUSE_TYPE)170) )
 							{
 							pAudioPlayer->StopChannels(-1, -1);
-							ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
-							ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
-							ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
-							ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
-							ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
-							ptr_507BC0->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
+							window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
+							window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+							window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+							window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+							window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+							window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
 							ptr_F8B1E8 = pNPCTopics[90].pText;
 							}
 						}
 					}
 				++curr_seq_num;
 				}
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -631,8 +634,8 @@
 				sub_448518_npc_set_item(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
 					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -640,16 +643,16 @@
 				Actor::GiveItem(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
 					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
 			case EVENT_SetNPCGroupNews:
 				pNPCStats->pGroups_copy[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)] = _evt->v9 + ((uint)_evt->v10 << 8);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -657,8 +660,8 @@
 				__debugbreak();
 				*(&pActors[0].uGroup + 0x11000000 * _evt->v8 + 209 * (_evt->v5 + ((_evt->v6 + ((uint)_evt->v7 << 8)) << 8))) = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -680,8 +683,8 @@
 						while ( v40 );
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -703,8 +706,8 @@
 						while ( v44 );
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -712,21 +715,21 @@
 				{
 
 				pNPCStats->pNewNPCData[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)].Location2D = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
-				if ( ptr_507BC0 )
+				if ( window_SpeakInHouse )
 					{
-					v46 = ptr_507BC0->ptr_1C;
+					v46 = window_SpeakInHouse->ptr_1C;
 					if ( v46 == (void *)165 )
 						{
 						sub_4BD8B5();
 						pVideoPlayer->Unload();
-						ptr_507BC0->Release();
+						window_SpeakInHouse->Release();
 						pParty->uFlags &= 0xFFFFFFFDu;
 						_5C3420_pDecoration = (LevelDecoration *)1;
 						if ( EnterHouse((enum HOUSE_TYPE)165) )
 							{
 							pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
 							v47 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
-							ptr_507BC0 = v47;
+							window_SpeakInHouse = v47;
 							v48 = v47->pControlsHead;
 							if ( v48 )
 								{
@@ -737,11 +740,11 @@
 									v48 = v49;
 									}
 									while ( v49 );
-									v47 = ptr_507BC0;
+									v47 = window_SpeakInHouse;
 								}
 							v47->pControlsHead = 0;
-							ptr_507BC0->pControlsTail = 0;
-							ptr_507BC0->uNumControls = 0;
+							window_SpeakInHouse->pControlsTail = 0;
+							window_SpeakInHouse->uNumControls = 0;
 							}
 						}
 					else
@@ -752,127 +755,58 @@
 					}
 				++curr_seq_num;
 				}
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
 			case EVENT_Jmp:
-				//v124 = -1;
 				curr_seq_num = _evt->v5 - 1;
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				//v4 = -1;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
 			case EVENT_ShowFace:
-				v50 = _evt->v5;
-				if ( (unsigned __int8)v50 <= 3u )
+				if ( _evt->v5 <= 3u ) //someone 
+					pParty->pPlayers[_evt->v5].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0);
+				else if ( _evt->v5 == 4 ) //active
+					pParty->pPlayers[uActiveCharacter].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0);
+				else if ( _evt->v5 == 5 ) //all players
 					{
-					v117 = 0;
-					v113 = _evt->v6;
-					v53 = (unsigned __int8)v50;
-					v52 = &pParty->pPlayers[v53];
-					v52->PlayEmotion((CHARACTER_EXPRESSION_ID)v113, v117);
-					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
-					//v6 = v123;
-					//v7 = "";
-					break;
+					for(int i=0; i<4; ++i) 
+						pParty->pPlayers[i].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0);
 					}
-				if ( v50 == 4 )
-					{
-					v117 = 0;
-					v113 = _evt->v6;
-					v52 = pPlayers[uActiveCharacter];
-					v52->PlayEmotion((CHARACTER_EXPRESSION_ID)v113, v117);
+				else	//random player	  
+					pParty->pPlayers[rand() % 4].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0);
 					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
-					//v6 = v123;
-					//v7 = "";
-					break;
-					}
-				if ( v50 != 5 )
-					{
-					v117 = 0;
-					v113 = _evt->v6;
-					v53 = rand() % 4;
-					v52 = &pParty->pPlayers[v53];
-					v52->PlayEmotion((CHARACTER_EXPRESSION_ID)v113, v117);
-					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
-					//v6 = v123;
-					//v7 = "";
-					break;
-					}
-				v51 = pParty->pPlayers;
-				do
-					{
-					v51->PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0);
-					++v51;
-					}
-					while ( (signed int)v51 < (signed int)pParty->pHirelings );
-					//LABEL_291:
-					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
 					break;
 			case EVENT_CharacterAnimation:
-				v54 = _evt->v5;
-				if ( (unsigned __int8)v54 <= 3u )
-					{
-					v118 = 0;
-					v114 = _evt->v6;
-					v57 = (unsigned __int8)v54;
-					goto LABEL_119;
-					}
-				if ( v54 == 4 )
-					{
-					v118 = 0;
-					v114 = _evt->v6;
-					v56 = pPlayers[uActiveCharacter];
-					goto LABEL_120;
-					}
-				if ( v54 != 5 )
-					{
-					v118 = 0;
-					v114 = _evt->v6;
-					v57 = rand() % 4;
-LABEL_119:
-					v56 = &pParty->pPlayers[v57];
-LABEL_120:
-					v56->PlaySound((PlayerSpeech)v114, v118);
-					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+				if ( _evt->v5 <= 3u ) //someone
+					pParty->pPlayers[_evt->v5].PlaySound((PlayerSpeech) _evt->v6, 0);
+				else if ( _evt->v5 == 4 ) //active
+					pParty->pPlayers[uActiveCharacter].PlaySound((PlayerSpeech) _evt->v6, 0);
+				else if ( _evt->v5 == 5 ) //all
+					for(int i=0; i<4; ++i) 
+						pParty->pPlayers[i].PlaySound((PlayerSpeech) _evt->v6, 0);
+				else	//random
+					pParty->pPlayers[rand() % 4].PlaySound((PlayerSpeech) _evt->v6, 0);
+				++curr_seq_num;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
-					break;
-					}
-				v55 = pParty->pPlayers;
-				for (int iii = 0; iii < 4; ++iii)
-					{
-					v55->PlaySound((PlayerSpeech)_evt->v6, 0);
-					++v55;
-					}
-				//while ( (signed int)v55 < (signed int)pParty->pHirelings );
-				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
-				//v6 = v123;
-				//v7 = "";
 				break;
 			case EVENT_ForPartyMember:
-				v127 = _evt->v5;
+				player_choose = _evt->v5;
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -884,14 +818,14 @@
 					_evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8),
 					_evt->v25, _evt->v26, 0, 0);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
 			case EVENT_Compare:
 				v58 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
-				if ( v127 == 5 )
+				if ( player_choose == 5 )
 					{
 					v130 = 0;
 					v59 = pParty->pPlayers;
@@ -905,8 +839,8 @@
 						if ( (signed int)v59 >= (signed int)pParty->pHirelings )
 							{
 							++curr_seq_num;
-							//v4 = v124;
-							//v5 = pSomeEVT;
+							v4 = v124;
+							
 							//v6 = v123;
 							//v7 = "";
 							break;
@@ -916,12 +850,12 @@
 					v11 = _evt->v11;
 					goto LABEL_130;
 					}
-				if ( v127 < 0 )
+				if ( player_choose < 0 )
 					goto LABEL_139;
-				v61 = v127;
-				if ( v127 <= 3 )
+				v61 = player_choose;
+				if ( player_choose <= 3 )
 					goto LABEL_137;
-				if ( v127 == 4 )
+				if ( player_choose == 4 )
 					{
 					if ( uActiveCharacter )
 						{
@@ -931,11 +865,11 @@
 					}
 				else
 					{
-					if ( v127 != 6 )
+					if ( player_choose != 6 )
 						goto LABEL_139;
 					}
 				v61 = rand() % 4;
-				//v5 = pSomeEVT;
+				
 LABEL_137:
 				v6 = &pParty->pPlayers[v61];
 LABEL_138:
@@ -948,8 +882,8 @@
 				if ( v62 )
 					goto LABEL_129;
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -968,8 +902,8 @@
 						{
 						pMouse->RemoveHoldingItem();
 						++curr_seq_num;
-						//v4 = v124;
-						//v5 = pSomeEVT;
+						v4 = v124;
+						
 						//v6 = v123;
 						//v7 = "";
 						break;
@@ -983,8 +917,8 @@
 							{
 							v66->RemoveItemAtInventoryIndex(v65);
 							++curr_seq_num;
-							//v4 = v124;
-							//v5 = pSomeEVT;
+							v4 = v124;
+							
 							//v6 = v123;
 							//v7 = "";
 							break;
@@ -1001,8 +935,8 @@
 								{
 								*(&v66->pEquipment.uOffHand + v68) = 0;
 								++curr_seq_num;
-								//v4 = v124;
-								//v5 = pSomeEVT;
+								v4 = v124;
+								
 								//v6 = v123;
 								//v7 = "";
 								break;
@@ -1049,30 +983,30 @@
 								if ( v125 > (signed int)&pPlayers[4] )
 									{
 									++curr_seq_num;
-									//v4 = v124;
-									//v5 = pSomeEVT;
+									v4 = v124;
+									
 									//v6 = v123;
 									//v7 = "";
 									break;
 									}
 								}
 					}
-				v75 = v127;
-				if ( v127 != 5 )
+				v75 = player_choose;
+				if ( player_choose != 5 )
 					{
-					if ( v127 < 0 )
+					if ( player_choose < 0 )
 						goto LABEL_183;
-					if ( v127 > 3 )
+					if ( player_choose > 3 )
 						{
-						if ( v127 != 4 )
+						if ( player_choose != 4 )
 							{
-							if ( v127 == 6 )
+							if ( player_choose == 6 )
 								goto LABEL_180;
 LABEL_183:
 							((Player *)v6)->SubtractVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v63);
 							++curr_seq_num;
-							//v4 = v124;
-							//v5 = pSomeEVT;
+							v4 = v124;
+							
 							//v6 = v123;
 							//v7 = "";
 							break;
@@ -1084,7 +1018,7 @@
 							}
 LABEL_180:
 						v75 = rand() % 4;
-						//v5 = pSomeEVT;
+						
 						}
 					v6 = &pParty->pPlayers[v75];
 LABEL_182:
@@ -1102,29 +1036,29 @@
 					}
 					while ( (signed int)v76 < (signed int)pParty->pHirelings );
 					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
 					break;
 			case EVENT_Set:
 				v77 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
-				v78 = v127;
-				if ( v127 != 5 )
+				v78 = player_choose;
+				if ( player_choose != 5 )
 					{
-					if ( v127 < 0 )
+					if ( player_choose < 0 )
 						goto LABEL_197;
-					if ( v127 > 3 )
+					if ( player_choose > 3 )
 						{
-						if ( v127 != 4 )
+						if ( player_choose != 4 )
 							{
-							if ( v127 == 6 )
+							if ( player_choose == 6 )
 								goto LABEL_194;
 LABEL_197:
 							((Player *)v6)->SetVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v77);
 							++curr_seq_num;
-							//v4 = v124;
-							//v5 = pSomeEVT;
+							v4 = v124;
+							
 							//v6 = v123;
 							//v7 = "";
 							break;
@@ -1136,7 +1070,7 @@
 							}
 LABEL_194:
 						v78 = rand() % 4;
-						//v5 = pSomeEVT;
+						
 						}
 					v6 = &pParty->pPlayers[v78];
 LABEL_196:
@@ -1154,23 +1088,23 @@
 					}
 					while ( (signed int)v79 < (signed int)pParty->pHirelings );
 					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
 					break;
 			case EVENT_Add:
 				v80 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
-				v81 = v127;
-				if ( v127 != 5 )
+				v81 = player_choose;
+				if ( player_choose != 5 )
 					{
-					if ( v127 < 0 )
+					if ( player_choose < 0 )
 						goto LABEL_211;
-					if ( v127 > 3 )
+					if ( player_choose > 3 )
 						{
-						if ( v127 != 4 )
+						if ( player_choose != 4 )
 							{
-							if ( v127 == 6 )
+							if ( player_choose == 6 )
 								goto LABEL_208;
 LABEL_211:
 							((Player *)v6)->AddVariable(
@@ -1185,7 +1119,7 @@
 							}
 LABEL_208:
 						v81 = rand() % 4;
-						//v5 = pSomeEVT;
+						
 						}
 					v6 = &pParty->pPlayers[v81];
 LABEL_210:
@@ -1207,13 +1141,13 @@
 					if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
 						viewparams->bRedrawGameUI = 1;
 					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
 					break;
 			case EVENT_InputString:
-				if ( !dword_597F18 )
+				if ( !start_event_seq_number )
 					{
 					strcpy(
 						GameUI_StatusBar_TimedString,
@@ -1244,8 +1178,8 @@
 					curr_seq_num = v11 - 1;
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1269,8 +1203,8 @@
 					if ( !uActiveCharacter )
 						{
 						++curr_seq_num;
-						//v4 = v124;
-						//v5 = pSomeEVT;
+						v4 = v124;
+						
 						//v6 = v123;
 						//v7 = "";
 						break;
@@ -1290,8 +1224,8 @@
 LABEL_234:
 					v88->ReceiveDamage(v115, v119);
 					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
 					break;
@@ -1304,16 +1238,16 @@
 					}
 					while ( (signed int)v87 < (signed int)pParty->pHirelings );
 					++curr_seq_num;
-					//v4 = v124;
-					//v5 = pSomeEVT;
+					v4 = v124;
+					
 					//v6 = v123;
 					//v7 = "";
 					break;
 			case EVENT_ToggleIndoorLight:
 				pIndoor->ToggleLight(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), _evt->v9);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1321,8 +1255,8 @@
 				sub_44892E_set_faces_bit(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
 					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1330,8 +1264,8 @@
 				Chest::ToggleFlag(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
 					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1339,8 +1273,8 @@
 				Actor::ToggleFlag(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
 					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1350,8 +1284,8 @@
 					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
 					_evt->v13);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1359,8 +1293,8 @@
 				if ( !_evt->v5 )
 					pWeather->bRenderSnow = _evt->v6 != 0;
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1372,8 +1306,8 @@
 						{
 						ptr_F8B1E8 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90];
 						++curr_seq_num;
-						//v4 = v124;
-						//v5 = pSomeEVT;
+						v4 = v124;
+						
 						//v6 = v123;
 						//v7 = "";
 						break;
@@ -1384,8 +1318,8 @@
 						//LABEL_248:
 						ShowStatusBarString(v91, 2u);
 						++curr_seq_num;
-						//v4 = v124;
-						//v5 = pSomeEVT;
+						v4 = v124;
+						
 						//v6 = v123;
 						//v7 = "";
 						break;
@@ -1398,16 +1332,16 @@
 						v91 = &pLevelStr[pLevelStrOffsets[v90]];
 						ShowStatusBarString(v91, 2u);
 						++curr_seq_num;
-						//v4 = v124;
-						//v5 = pSomeEVT;
+						v4 = v124;
+						
 						//v6 = v123;
 						//v7 = "";
 						break;
 						}
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1424,8 +1358,8 @@
 					strcpy(byte_5B0938, &pLevelStr[pLevelStrOffsets[v92]]);
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1437,24 +1371,24 @@
 					_evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8),
 					_evt->v28 + ((_evt->v29 + ((_evt->v30 + ((uint)_evt->v31 << 8)) << 8)) << 8));
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
 			case EVENT_SetTexture:
 				sub_44861E_set_texture(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), (char *)&_evt->v9);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
 			case EVENT_SetSprite:
 				SetDecorationSprite(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), _evt->v9, (char *)&_evt->v10);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1466,8 +1400,8 @@
 					_evt->v20 + ((_evt->v21 + ((_evt->v22 + ((uint)_evt->v23 << 8)) << 8)) << 8),
 					_evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8));
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1475,16 +1409,16 @@
 			case EVENT_LocationName:
 				--curr_seq_num;
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
 			case EVENT_ChangeDoorState:
 				sub_449A49_door_switch_animation(_evt->v5, _evt->v6);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1492,8 +1426,8 @@
 				if ( !Chest::Open(_evt->v5) )
 					goto LABEL_301;
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1578,8 +1512,8 @@
 							while ( sub_4BD8B5() )
 								;
 							pVideoPlayer->Unload();
-							ptr_507BC0->Release();
-							ptr_507BC0 = 0;
+							window_SpeakInHouse->Release();
+							window_SpeakInHouse = 0;
 							if ( pMessageQueue_50CBD0->uNumMessages )
 								pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
 							pCurrentScreen = SCREEN_GAME;
@@ -1594,8 +1528,8 @@
 						}
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1619,13 +1553,12 @@
 					item.uItemID = v102;
 				pParty->SetHoldingItem(&item);
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
-			case EVENT_SpeakInHouse:
-				v103 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
+			case EVENT_SpeakInHouse: 
 				if ( EnterHouse((enum HOUSE_TYPE)(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8))) )
 					{
 					if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
@@ -1634,17 +1567,17 @@
 					pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0);
 					v104 = 187;
 					if ( uCurrentHouse_Animation != 167 )
-						v104 = v103;
-					ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
-					ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
-					ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
-					ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
-					ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
-					ptr_507BC0->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
+						v104 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
+					window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
+					window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+					window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+					window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+					window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+					window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
 					}
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
@@ -1656,17 +1589,17 @@
 				goto LABEL_301;
 			default:
 				++curr_seq_num;
-				//v4 = v124;
-				//v5 = pSomeEVT;
+				v4 = v124;
+				
 				//v6 = v123;
 				//v7 = "";
 				break;
 				}
 			}
-		//++v4;
-		//v124 = v4;
-		//if ( v4 >= (signed int)uSomeEVT_NumEvents )
-		//goto LABEL_301;
+		++v4;
+		v124 = v4;
+		if ( v4 >= uSomeEVT_NumEvents )
+		   goto LABEL_301;
 		//}
 		}
 	}