diff mm7_5.cpp @ 456:20d96ec810c8

Слияние
author Ritor1
date Sun, 24 Feb 2013 13:53:18 +0600
parents 0a1ea44b4a0a
children e5cf03a3d98e
line wrap: on
line diff
--- a/mm7_5.cpp	Sun Feb 24 13:52:57 2013 +0600
+++ b/mm7_5.cpp	Sun Feb 24 13:53:18 2013 +0600
@@ -77,7 +77,7 @@
   unsigned int v8; // edx@59
   unsigned int v9; // ecx@60
   unsigned int v10; // ecx@73
-  unsigned int v11; // eax@75
+  //unsigned int v11; // eax@75
   unsigned __int8 v12; // sf@75
   unsigned __int8 v13; // of@75
   int v14; // eax@98
@@ -489,23 +489,25 @@
             v10 = pSaveListPosition + uMessageParam;
             if ( dword_6BE138 == pSaveListPosition + uMessageParam )
             {
-              if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+              pMessageQueue_50CBD0->AddMessage(UIMSG_LoadSlot, 0, 0);
+              pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0);
+              /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
               {
-                pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)164;
+                pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_LoadSlot;
                 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
                 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-                v11 = pMessageQueue_50CBD0->uNumMessages + 1;
-                v13 = pMessageQueue_50CBD0->uNumMessages + 1 > 40;
-                v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0;
+                //v11 = pMessageQueue_50CBD0->uNumMessages + 1;
+                //v13 = pMessageQueue_50CBD0->uNumMessages + 1 > 40;
+                //v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0;
                 ++pMessageQueue_50CBD0->uNumMessages;
                 if ( v12 ^ v13 )
                 {
-                  pMessageQueue_50CBD0->pMessages[v11].eType = (UIMessageType)82;
+                  pMessageQueue_50CBD0->pMessages[v11].eType = UIMSG_LoadGame;
                   pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
                   *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
                   ++pMessageQueue_50CBD0->uNumMessages;
                 }
-              }
+              }*/
             }
             uLoadGameUI_SelectedSlot = v10;
             dword_6BE138 = v10;
@@ -1918,13 +1920,14 @@
           }
           sub_4BD8B5();
           //goto LABEL_434;
-          if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           {
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
             *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
             ++pMessageQueue_50CBD0->uNumMessages;
-          }
+          }*/
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v0, 0);
           continue;
         case UIMSG_C3:
           pAudioPlayer->StopChannels(-1, -1);
@@ -1987,12 +1990,13 @@
         case UIMSG_B5:
           dword_50CDC8 = v0;
           //goto LABEL_453;
-          if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
           *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-          ++pMessageQueue_50CBD0->uNumMessages;
+          ++pMessageQueue_50CBD0->uNumMessages;*/
           continue;
         case UIMSG_B3:
           pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1];
@@ -2038,13 +2042,14 @@
               pParty->sRotationY = LOWORD(pNPCData4->Location2D);
               pParty->sRotationX = HIWORD(pNPCData4->Location2D);
             }
-            if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+            pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v0, 0);
+            /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
             {
               pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
               pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
               *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
               ++pMessageQueue_50CBD0->uNumMessages;
-            }
+            }*/
             //crt_deconstruct_ptr_6A0118();
             pBooksWindow->Release();
             pGUIWindow_CurrentMenu->Release();
@@ -2135,14 +2140,15 @@
                   else
                     pParty->pPlayers[(unsigned __int8)byte_50C0C0].CanCastSpell(0x14u);
 //LABEL_434:
-                  if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+                  /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
                   {
                     pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
                     pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
 //LABEL_771:
                     *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
                     ++pMessageQueue_50CBD0->uNumMessages;
-                  }
+                  }*/
+                  pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v0, 0);
                   continue;
                 }
                 v63 = 210;
@@ -2688,13 +2694,14 @@
                 Rest(v95 % 6 + 60);
                 _506F18_num_hours_to_sleep = 0;
                 dword_506F14 = 0;
-                if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+                /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
                 {
                   pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
                   pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
                   *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
                   ++pMessageQueue_50CBD0->uNumMessages;
-                }
+                }*/
+                pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
                 ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2u);// "Encounter!"
                 v165 = 0;
                 v151 = 0;
@@ -2874,14 +2881,18 @@
           v130 = 0;
           v127 = rand() % 2 + 204;
           goto _play_sound_and_continue;
-        case UIMSG_56:
-          if ( pTurnEngine->field_4 != 3 )
-          {
-            if ( uActiveCharacter )
-            {
-              uNumSeconds = (unsigned int)pPlayers[uActiveCharacter];
-              if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402) )
-              {
+        case UIMSG_SelectSpell:
+        {
+          if (pTurnEngine->field_4 == 3)
+            continue;
+          if (!uActiveCharacter)
+            continue;
+
+            //  uNumSeconds = (unsigned int)pPlayers[uActiveCharacter];
+          auto player = pPlayers[uActiveCharacter];
+          if (player->spellbook.pChapters[player->lastOpenedSpellbookPage].bIsSpellAvailable[uMessageParam])
+              //if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + &lastOpenedSpellbookPage) + uMessageParam + 402) )
+          {
                 if ( dword_50654C - 1 == uMessageParam )
                 {
                   pGUIWindow_CurrentMenu->Release();
@@ -2889,12 +2900,12 @@
                   viewparams->bRedrawGameUI = v0;
                   pCurrentScreen = SCREEN_GAME;
                   pIcons_LOD->_4114F2();
-                  v103 = dword_50654C + 11 * *(char *)(uNumSeconds + 6734);
+                  v103 = dword_50654C + 11 * player->lastOpenedSpellbookPage;
                   if ( dword_50C9E8 < 40 )
                   {
-                    dword_50C9EC[3 * dword_50C9E8] = 142;
-                    dword_50C9F0[3 * dword_50C9E8] = v103;
-                    *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = uActiveCharacter - 1;
+                    dword_50C9EC[3 * dword_50C9E8] = UIMSG_CastSpellFromBook;
+                    dword_50C9EC[3 * dword_50C9E8 + 1] = v103;
+                    dword_50C9EC[3 * dword_50C9E8 + 2] = uActiveCharacter - 1;
                     ++dword_50C9E8;
                   }
                 }
@@ -2903,10 +2914,9 @@
                   byte_506550 = 1;
                   dword_50654C = uMessageParam + 1;
                 }
-              }
-            }
-          }
-          continue;
+          }
+        }
+        continue;
 
         case UIMSG_CastSpellFromBook:
           if ( pTurnEngine->field_4 != 3 )
@@ -3013,13 +3023,14 @@
           GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0);
           uNumVisibleWindows = uNumVisibleWindows - 1; //Ritor1: Insert
 //LABEL_453:
-          if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
+          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
           //goto LABEL_770;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
           *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-          ++pMessageQueue_50CBD0->uNumMessages;
+          ++pMessageQueue_50CBD0->uNumMessages;*/
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
           continue;
         case UIMSG_C0:
           dword_50651C = v0;
@@ -3309,7 +3320,8 @@
           if ( !pMessageQueue_50CBD0->uNumMessages )
             //goto LABEL_768;
           {
-            if ( (signed int)v115 < 40 )
+            pMessageQueue_50CBD0->AddMessage(UIMSG_E, 0, 0);
+            /*if ( (signed int)v115 < 40 )
             //goto LABEL_769;
             {
               pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
@@ -3317,12 +3329,14 @@
               *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
               ++pMessageQueue_50CBD0->uNumMessages;
               continue;
-            }
+            }*/
             continue;
           }
           if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
           {
-            v115 = v0;
+            pMessageQueue_50CBD0->uNumMessages = v0;
+            pMessageQueue_50CBD0->AddMessage(UIMSG_E, 0, 0);
+            /*v115 = v0;
             pMessageQueue_50CBD0->uNumMessages = v0;
 //LABEL_769:
             pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
@@ -3330,13 +3344,14 @@
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
             //goto LABEL_771;
             *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-            ++pMessageQueue_50CBD0->uNumMessages;
+            ++pMessageQueue_50CBD0->uNumMessages;*/
             continue;
           }
           v115 = 0;
           pMessageQueue_50CBD0->uNumMessages = 0;
 //LABEL_768:
-          if ( (signed int)v115 < 40 )
+          pMessageQueue_50CBD0->AddMessage(UIMSG_E, 0, 0);
+          /*if ( (signed int)v115 < 40 )
             //goto LABEL_769;
           {
             pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
@@ -3344,7 +3359,7 @@
             *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
             ++pMessageQueue_50CBD0->uNumMessages;
             continue;
-          }
+          }*/
           continue;
         case UIMSG_E:
 //LABEL_772:
@@ -3455,13 +3470,14 @@
   dword_50C9E8 = 0;
   if ( dword_50C9DC )
   {
-    if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+    /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
     {
       pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9DC;
       pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = (int)ptr_50C9E0;
       *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
       ++pMessageQueue_50CBD0->uNumMessages;
-    }
+    }*/
+    pMessageQueue_50CBD0->AddMessage((UIMessageType)dword_50C9DC, (int)ptr_50C9E0, 0);
     dword_50C9DC = 0;
   }
   else
@@ -3471,13 +3487,14 @@
       dword_50C9D8 -= pEventTimer->uTimeElapsed;
       if ( dword_50C9D8 <= 0 )
       {
-        if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+        /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
         {
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9D0;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = dword_50C9D4;
           *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
           ++pMessageQueue_50CBD0->uNumMessages;
-        }
+        }*/
+        pMessageQueue_50CBD0->AddMessage((UIMessageType)dword_50C9D0, dword_50C9D4, 0);
         dword_50C9D0 = 0;
         dword_50C9D4 = 0;
         dword_50C9D8 = 0;
@@ -3699,8 +3716,8 @@
               v26 = uNum + pSaveListPosition;
               if ( dword_6BE138 == uNum + pSaveListPosition )
               {
-                pMessageQueue_50CBD0->SendMessage(UIMSG_LoadSlot, 0, 0);
-                pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0);
+                pMessageQueue_50CBD0->AddMessage(UIMSG_LoadSlot, 0, 0);
+                pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0);
               }
               uLoadGameUI_SelectedSlot = v26;
               dword_6BE138 = v26;
@@ -3777,12 +3794,13 @@
             viewparams->bRedrawGameUI = 1;
           }
           GUIWindow::Create(602, 450, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0);
-          if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
+          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
           *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-          ++pMessageQueue_50CBD0->uNumMessages;
+          ++pMessageQueue_50CBD0->uNumMessages;*/
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
           continue;
         }
         if ( pUIMessageType == UIMSG_Escape )
@@ -3813,7 +3831,7 @@
               SetCurrentMenuID(MENU_CREDITSCLOSE);
               continue;
             }
-            if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+            /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
             {
               pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)5;
 //LABEL_93:
@@ -3821,7 +3839,8 @@
               *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
               ++pMessageQueue_50CBD0->uNumMessages;
               continue;
-            }
+            }*/
+            pMessageQueue_50CBD0->AddMessage(UIMSG_ChangeGameState, 0, 0);
             continue;
           }
           v16 = GetCurrentMenuID() == 8;
@@ -13107,7 +13126,7 @@
 LABEL_30:
   if ( byte_506360 )
   {
-    result = pMessageQueue_50CBD0->uNumMessages;
+    /*result = pMessageQueue_50CBD0->uNumMessages;
     if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
     {
       pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)181;
@@ -13115,7 +13134,8 @@
       result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
       *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
       ++pMessageQueue_50CBD0->uNumMessages;
-    }
+    }*/
+    pMessageQueue_50CBD0->AddMessage(UIMSG_B5, 0, 0);
   }
   return result;
 }
@@ -14476,13 +14496,14 @@
   GUIWindow *v0; // ecx@1
 
   v0 = ptr_507BDC;
-  if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+  pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BDC->ptr_1C, 0, 0);
+  /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
   {
     pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)(int)ptr_507BDC->ptr_1C;
     pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
     *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
     ++pMessageQueue_50CBD0->uNumMessages;
-  }
+  }*/
   v0->Release();
   ptr_507BDC = 0;
   pCurrentScreen = dword_506F0C[0];
@@ -15091,9 +15112,9 @@
           pGUIButton3->DrawLabel(pHint, pFontCreate, 0, 0);
         pWindow->Release();
         if (pCurrentScreen == SCREEN_SAVEGAME)
-          pMessageQueue_50CBD0->SendMessage(UIMSG_SaveGame, 0, 0);
+          pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0);
         else
-          pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0);
+          pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0);
       }
       continue;
     }
@@ -15113,7 +15134,7 @@
           if ( pHint && pHint != (char *)1 )
             pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0);
           pWindow->Release();
-          if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
+          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           pNumMessages = pMessageQueue_50CBD0->uNumMessages;
 //LABEL_151:
@@ -15121,7 +15142,8 @@
 //LABEL_152:
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
           *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-          ++pMessageQueue_50CBD0->uNumMessages;
+          ++pMessageQueue_50CBD0->uNumMessages;*/
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
           continue;
         }
         v34 = v33 - 1;
@@ -15208,14 +15230,15 @@
           ((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0);
         pWindow->Release();
         pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+        /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
         {
          pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
          ++pMessageQueue_50CBD0->uNumMessages;
          continue;
-        }
+        }*/
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
         continue;
       }
 
@@ -15233,7 +15256,7 @@
         pWindow->Release();
 //LABEL_142:
         pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+        /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           //goto LABEL_151;
         {
          pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113; //0x71
@@ -15241,7 +15264,8 @@
          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
          ++pMessageQueue_50CBD0->uNumMessages;
          continue;
-        }
+        }*/
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
         continue;
       }
       v14 = pWindowType - 80;
@@ -15410,13 +15434,14 @@
         {
           v29 = pMessageQueue_50CBD0->uNumMessages;
           pWindow->field_40 = 0;
-          if ( (signed int)v29 < 40 )
+          /*if ( (signed int)v29 < 40 )
           {
             pMessageQueue_50CBD0->pMessages[v29].eType = (UIMessageType)(int)ptr_507BD0->ptr_1C;
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
             *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
             ++pMessageQueue_50CBD0->uNumMessages;
-          }
+          }*/
+          pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0);
           pEventTimer->Resume();
           ptr_507BD0->Release();
           pCurrentScreen = SCREEN_GAME;
@@ -15538,14 +15563,15 @@
         }
         //goto LABEL_142;
         pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+        /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
         {
          pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
          ++pMessageQueue_50CBD0->uNumMessages;
          continue;
-        }
+        }*/
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
         continue;
       }
       if ( pWindowType == WINDOW_SpellBook )
@@ -15906,13 +15932,15 @@
       v26 = rand();
       v0->ReceiveDamage(v26 % 11 + 10, 0);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
-      if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
       {
         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
         *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
         ++pMessageQueue_50CBD0->uNumMessages;
-      }
+      }*/
       v42 = (int *)&a2.y;
       v41 = (int *)&y.y;
       v40 = (int *)&pOut;
@@ -15980,13 +16008,15 @@
       }
       v0->_4160CA(v23);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
-      if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
       {
         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
         *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
         ++pMessageQueue_50CBD0->uNumMessages;
-      }
+      }*/
       v42 = (int *)&a2.y;
       v41 = (int *)&y.y;
       v40 = (int *)&pOut;
@@ -16636,7 +16666,7 @@
         pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
       }
       //v11 = i->uControlParam;
-      pMessageQueue_50CBD0->SendMessage((UIMessageType)i->uControlID, i->uControlParam, 0);
+      pMessageQueue_50CBD0->AddMessage((UIMessageType)i->uControlID, i->uControlParam, 0);
       return;
     }
     goto LABEL_45;
@@ -16655,13 +16685,15 @@
     && pPlayers[uActiveCharacter]->CanAct()
     && pPlayers[uActiveCharacter]->CanSteal() )
   {
-    if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+    /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
     {
       pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)27;
       pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3;
       *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
       ++pMessageQueue_50CBD0->uNumMessages;
-    }
+    }*/
+    pMessageQueue_50CBD0->AddMessage(UIMSG_1B, v6 >> 3, 0);
+
     if ( pParty->bTurnBasedModeOn == 1 )
     {
       if ( pTurnEngine->field_4 == 3 )