diff mm7_2.cpp @ 23:509744251c8e

Player-related members
author Nomad
date Sun, 14 Oct 2012 00:27:38 +0200
parents 17150bdf321e
children 93bf1d5f6a6d
line wrap: on
line diff
--- a/mm7_2.cpp	Sat Oct 13 20:18:28 2012 +0200
+++ b/mm7_2.cpp	Sun Oct 14 00:27:38 2012 +0200
@@ -1307,11 +1307,11 @@
                 v85 = 0;
                 v83 = 5;
                 v81 = ptr_507BC0->ptr_1C;
-                v79 = (ItemGen *)&_this->pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5];
+                v79 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5];
                 v28 = (int)ptr_507BC0->ptr_1C;
                 v110 = uActiveCharacter - 1;
                 v29 = _this->_490EEE(
-                        (ItemGen *)&_this->pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5],
+                        (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5],
                         1,
                         v28,
                         5);
@@ -1405,7 +1405,7 @@
                 v85 = 0;
                 v83 = 3;
                 v81 = ptr_507BC0->ptr_1C;
-                v79 = (ItemGen *)&_this->pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
+                v79 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
                 v12 = (int)ptr_507BC0->ptr_1C;
                 v110 = uActiveCharacter - 1;
                 v13 = _this->_490EEE(v79, 1, v12, 3);
@@ -1442,8 +1442,8 @@
                 {
                   v85 = 0;
                   v83 = 4;
-                  v4 = (ItemGen *)&_this->pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
-                  if ( !(v4->uAttributtes & 1) )
+                  v4 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
+                  if ( !(v4->uAttributes & 1) )
                   {
                     v81 = ptr_507BC0->ptr_1C;
                     v79 = v4;
@@ -1817,7 +1817,7 @@
         v93 = 0;
         v91 = 3;
         v89 = ptr_507BC0->ptr_1C;
-        v87 = (ItemGen *)&_this->pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
+        v87 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
         v44 = (int)ptr_507BC0->ptr_1C;
         v113 = uActiveCharacter - 1;
         v45 = _this->_490EEE(v87, 4, v44, 3);
@@ -1841,8 +1841,8 @@
           return result;
         v93 = 0;
         v91 = 4;
-        v37 = (ItemGen *)&_this->pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
-        if ( !(v37->uAttributtes & 1) )
+        v37 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
+        if ( !(v37->uAttributes & 1) )
         {
           v89 = ptr_507BC0->ptr_1C;
           v87 = v37;
@@ -2788,10 +2788,10 @@
     v124 = 0;
     v122 = 5;
     v120 = ptr_507BC0->ptr_1C;
-    v116 = (ItemGen *)&v0->pDarkSpellbook.bIsSpellAvailable[4 * v33 + 5];
+    v116 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * v33 + 5];
     v34 = (int)ptr_507BC0->ptr_1C;
     uPlayerID = uActiveCharacter - 1;
-    v35 = v0->_490EEE((ItemGen *)&v0->pDarkSpellbook.bIsSpellAvailable[4 * v33 + 5], 2, v34, 5);
+    v35 = v0->_490EEE((ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * v33 + 5], 2, v34, 5);
     v14 = uPlayerID;
     v15 = (char *)pMerchantsRepairPhrases[v35];
     goto LABEL_36;
@@ -2866,7 +2866,7 @@
     v124 = 0;
     v122 = 3;
     v120 = ptr_507BC0->ptr_1C;
-    v116 = (ItemGen *)&v0->pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5];
+    v116 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5];
     v12 = (int)ptr_507BC0->ptr_1C;
     uPlayerID = uActiveCharacter - 1;
     v13 = v0->_490EEE(v116, 2, v12, 3);
@@ -2890,8 +2890,8 @@
           v2 = v0->GetItemIDAtInventoryIndex((int *)&v149);
           if ( v2 )
           {
-            v3 = (ItemGen *)&v0->pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
-            if ( v3->uAttributtes & 1 )
+            v3 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
+            if ( v3->uAttributes & 1 )
             {
               v118 = ptr_507BC0->ptr_1C;
               v4 = uActiveCharacter - 1;
@@ -4170,7 +4170,16 @@
               v37 = v36 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
               if ( v37 < v36 / 3 )
                 v37 = v36 / 3;
-              if ( *(&byte_4ED94C[37 * v35->uClass] + v55) )
+              
+              __debugbreak();
+              //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
+              // or
+              //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
+              // or
+              //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
+
+              if (false)
+              //if ( *(&byte_4ED94C[37 * v35->uClass] + v55) )
               {
                 v38 = (int)(&v35->uIntelligence + v55);
                 if ( !*(short *)v38 )
@@ -4608,8 +4617,8 @@
     if ( v25 )
     {
       v26 = 1;
-      v20->uAttributtes |= 1u;
-      memcpy(&v0->pDarkSpellbook.bIsSpellAvailable[36 * v25 + 5], v20, 0x24u);
+      v20->uAttributes |= 1u;
+      memcpy(&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v25 + 5], v20, 0x24u);
       goto LABEL_42;
     }
     v0->PlaySound(15, 0);
@@ -4676,7 +4685,7 @@
     v39 = v0->AddItem(0xFFFFFFFFu, v32->uItemID);
     if ( v39 )
     {
-      v32->uAttributtes |= 1u;
+      v32->uAttributes |= 1u;
       v7 = v73 == 1;
       v40 = (int)((char *)v0 + 36 * v39);
       memcpy((void *)(v40 + 496), v32, 0x24u);
@@ -4720,7 +4729,7 @@
       || (v15 = v0->GetItemIDAtInventoryIndex((int *)&v79), (v77 = (Player *)v15) == 0) )
       return;
     v16 = ptr_507BC0;
-    if ( sub_4BDAAF((ItemGen *)&v0->pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5], (int)ptr_507BC0->ptr_1C) )
+    if ( sub_4BDAAF((ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5], (int)ptr_507BC0->ptr_1C) )
     {
       dword_F8B1E4 = 1;
       v0->_4BE2DD(v79, (int)((char *)v77 - 1), (int)v16->ptr_1C);
@@ -4755,7 +4764,7 @@
         {
           //v80 = v0->_4B8179(p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]);
           v80 = v0->_4B8179(p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier);
-          v12 = (int)&v0->pDarkSpellbook.bIsSpellAvailable[36 * v11 + 5];
+          v12 = (int)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v11 + 5];
           if ( !(*(char *)(v12 + 20) & 1) )
           {
             _this = (ItemGen *)ptr_507BC0->ptr_1C;
@@ -4797,11 +4806,11 @@
           v2 = v0->GetItemIDAtInventoryIndex((int *)&v79);
           if ( v2 )
           {
-            v3 = (int)&v0->pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
+            v3 = (int)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
             //v4 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
             v4 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier;
 
-            auto _v = (ItemGen *)&v0->pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
+            auto _v = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
             v5 = _v->GetValue();
 
             v6 = v0->_4B81C3(v5, v4);
@@ -8021,7 +8030,7 @@
                   }
                   v18 = v15;
                 }
-                a1a.stru_24.uAttributtes |= 1u;
+                a1a.stru_24.uAttributes |= 1u;
                 a1a.uObjectDescID = v18;
                 a1a.stru_24.uAdditionalValue = v34;
                 goto LABEL_35;
@@ -8180,7 +8189,7 @@
                     }
                   }
 LABEL_23:
-                  v3->uAttributtes |= 1u;
+                  v3->uAttributes |= 1u;
                   v3->uAdditionalValue = v10;
 LABEL_25:
                   v11 = v4 - 1;
@@ -15217,6 +15226,8 @@
 
   if (MM7_Initialize())
   {
+    Log::Warning(L"MM init: ok");
+
     pEventTimer->Pause();
     if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
     {
@@ -15235,6 +15246,8 @@
     SecondaryInitialization();
     pRenderer->Clip_v2(0, 0, 639u, 479u);
     FinalInitialization();
+
+    Log::Warning(L"MM: entering main loop");
     while ( 1 )
     {
       MainMenu_Loop();
@@ -15330,7 +15343,7 @@
         {
           v12 = 1;
 LABEL_57:
-          SetCurrentMenuID(v12);
+          SetCurrentMenuID((MENU_STATE)v12);
           goto LABEL_21;
         }
         if ( uGameState == 7 )
@@ -15359,6 +15372,8 @@
       }
     }
   }
+  else
+    Log::Warning(L"MM init: failed");
 
   pGame->Deinitialize();
 }
@@ -15625,32 +15640,39 @@
 }
 
 //----- (00466C40) --------------------------------------------------------
-// #define MENU_MAIN        0
-// #define MENU_NEWGAME     1
-// #define MENU_CREDITS     2
-// #define MENU_LOAD        3
-// #define MENU_CREATEPARTY 6
-// #define MENU_MAINMENULOAD    9
-void __thiscall SetCurrentMenuID(unsigned int uMenu)
-{
-  unsigned int v1; // esi@1
-
-  v1 = uMenu;
-  if ( uCurrentMenuID == -1 )
-  {
-    if ( uMenu != -1 && LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard )
-      pAsyncKeyboard->Suspend();
-  }
-  else
-  {
-    if ( uMenu == -1 && LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard )
+const wchar_t *MENU_STATE_to_string(MENU_STATE m)
+{
+  switch (m)
+  {
+    case -1:               return L"-1";
+    case MENU_MAIN:        return L"MENU_MAIN";
+    case MENU_NEWGAME:     return L"MENU_NEWGAME";
+    case MENU_CREDITS:     return L"MENU_CREDITS";
+    case MENU_SAVELOAD:    return L"MENU_SAVELOAD";
+    case MENU_FINISHED:    return L"MENU_FINISHED";
+    case MENU_5:           return L"MENU_5";
+    case MENU_CREATEPARTY: return L"MENU_CREATEPARTY";
+    case MENU_7:           return L"MENU_7";
+    case MENU_Credits:     return L"MENU_Credits";
+    case MENU_LOAD:        return L"MENU_LOAD";
+    case MENU_10:          return L"MENU_10";
+    default:               return L"unk";
+  };
+};
+void SetCurrentMenuID(MENU_STATE uMenu)
+{
+  if ((int)uCurrentMenuID != -1)
+  {
+    if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard)
       pAsyncKeyboard->Resume();
   }
-  uCurrentMenuID = v1;
+  uCurrentMenuID = uMenu;
+
+  Log::Warning(L"CurrentMenu = %s", MENU_STATE_to_string(uMenu));
 }
 
 //----- (00466CA0) --------------------------------------------------------
-unsigned int GetCurrentMenuID()
+MENU_STATE GetCurrentMenuID()
 {
   return uCurrentMenuID;
 }
@@ -16361,7 +16383,7 @@
   v2 = v0->pEquipment.uOffHand;
   v54 = v0->pEquipment.uOffHand;
   v53 = v1;
-  if ( v1 && pItemsTable->pItems[*(int *)&v0->pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uEquipType == 1 )
+  if ( v1 && pItemsTable->pItems[*(int *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uEquipType == 1 )
     v51 = v1;
   v3 = pParty->pPickedItem.uItemID;
   if ( pParty->pPickedItem.uItemID )
@@ -16388,7 +16410,7 @@
     {
       if ( (v4 == 8 || v4 == 1 || v4 == 2)
         && v1
-        && pItemsTable->pItems[*(int *)&v0->pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uSkillType == 4 )
+        && pItemsTable->pItems[*(int *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uSkillType == 4 )
         goto LABEL_7;
     }
 LABEL_16:
@@ -16733,7 +16755,7 @@
     v35 = v0->pEquipment.uBow;
     if ( v35 )
     {
-      auto _a = (ItemGen *)&v0->pDarkSpellbook.bIsSpellAvailable[36 * v35 + 5];
+      auto _a = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v35 + 5];
       pParty->SetHoldingItem(_a);
       _a->Reset();
       v0->pEquipment.uBow = 0;