comparison mm7_5.cpp @ 198:e6e348d66a75

Some work on spellbook
author Nomad
date Sat, 16 Feb 2013 21:46:07 +0200
parents 4813b57396ba
children 66db86fa4ed2
comparison
equal deleted inserted replaced
197:5979fc0de9ae 198:e6e348d66a75
2960 _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute; 2960 _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
2961 continue; 2961 continue;
2962 case UIMSG_4E: 2962 case UIMSG_4E:
2963 if ( dword_50654C && byte_506550 ) 2963 if ( dword_50654C && byte_506550 )
2964 { 2964 {
2965 v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage].pName; 2965 v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName;
2966 v157 = pGlobalTXT_LocalizationStrings[483]; 2966 v157 = pGlobalTXT_LocalizationStrings[483];
2967 _sprintex_2args_draw_status_and_continue: 2967 _sprintex_2args_draw_status_and_continue:
2968 sprintf(pTmpBuf, v157, v173); 2968 sprintf(pTmpBuf, v157, v173);
2969 } 2969 }
2970 else 2970 else
3017 v130 = 0; 3017 v130 = 0;
3018 dword_50654C = 0; 3018 dword_50654C = 0;
3019 v127 = 203; 3019 v127 = 203;
3020 goto _play_sound_and_continue; 3020 goto _play_sound_and_continue;
3021 } 3021 }
3022 v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage; 3022 v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage;
3023 pPlayers[uActiveCharacter]->uQuickSpell = v99; 3023 pPlayers[uActiveCharacter]->uQuickSpell = v99;
3024 stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter); 3024 stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter);
3025 if ( uActiveCharacter ) 3025 if ( uActiveCharacter )
3026 pPlayer10->PlaySound(SPEECH_12, 0); 3026 pPlayer10->PlaySound(SPEECH_12, 0);
3027 byte_506550 = 0; 3027 byte_506550 = 0;
3036 thisl = (int)&pPlayer3->pActiveSkills[12]; 3036 thisl = (int)&pPlayer3->pActiveSkills[12];
3037 do 3037 do
3038 { 3038 {
3039 if ( *(short *)thisl ) 3039 if ( *(short *)thisl )
3040 { 3040 {
3041 if ( pPlayer3->pNumSpellBookPage == v101 ) 3041 if ( pPlayer3->lastOpenedSpellbookPage == v101 )
3042 uAction = (int)pNPCData4; 3042 uAction = (int)pNPCData4;
3043 v102 = (int)pNPCData4; 3043 v102 = (int)pNPCData4;
3044 pNPCData4 = (NPCData *)((char *)pNPCData4 + 1); 3044 pNPCData4 = (NPCData *)((char *)pNPCData4 + 1);
3045 v217[v102] = v101; 3045 v217[v102] = v101;
3046 } 3046 }
3071 ++uAction; 3071 ++uAction;
3072 if ( uAction >= (signed int)pNPCData4 ) 3072 if ( uAction >= (signed int)pNPCData4 )
3073 uAction = 0; 3073 uAction = 0;
3074 } 3074 }
3075 sub_41140B(); 3075 sub_41140B();
3076 pPlayers[uActiveCharacter]->pNumSpellBookPage = LOBYTE(v217[uAction]); 3076 pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]);
3077 pGUIWindow_CurrentMenu->OpenSpellBook(); 3077 pGUIWindow_CurrentMenu->OpenSpellBook();
3078 v165 = 0; 3078 v165 = 0;
3079 v151 = 0; 3079 v151 = 0;
3080 v144 = 0; 3080 v144 = 0;
3081 v139 = 0; 3081 v139 = 0;
3083 v132 = 0; 3083 v132 = 0;
3084 v130 = 0; 3084 v130 = 0;
3085 v127 = rand() % 2 + 204; 3085 v127 = rand() % 2 + 204;
3086 goto _play_sound_and_continue; 3086 goto _play_sound_and_continue;
3087 case UIMSG_57: 3087 case UIMSG_57:
3088 if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->pNumSpellBookPage ) 3088 if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage )
3089 continue; 3089 continue;
3090 sub_41140B(); 3090 sub_41140B();
3091 pPlayers[uActiveCharacter]->pNumSpellBookPage = uMessageParam; 3091 pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam;
3092 pGUIWindow_CurrentMenu->OpenSpellBook(); 3092 pGUIWindow_CurrentMenu->OpenSpellBook();
3093 v165 = 0; 3093 v165 = 0;
3094 v151 = 0; 3094 v151 = 0;
3095 v144 = 0; 3095 v144 = 0;
3096 v139 = 0; 3096 v139 = 0;
12736 int v12; // [sp+6Ch] [bp-8h]@4 12736 int v12; // [sp+6Ch] [bp-8h]@4
12737 int v13; // [sp+70h] [bp-4h]@4 12737 int v13; // [sp+70h] [bp-4h]@4
12738 12738
12739 v1 = pPlayers[uActiveCharacter]; 12739 v1 = pPlayers[uActiveCharacter];
12740 v10 = _this; 12740 v10 = _this;
12741 v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->pNumSpellBookPage) + 1]; 12741 v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->lastOpenedSpellbookPage) + 1];
12742 if ( pMouse->GetCursorPos(&a2)->y <= 250 ) 12742 if ( pMouse->GetCursorPos(&a2)->y <= 250 )
12743 v3 = pMouse->GetCursorPos(&a2)->y + 30; 12743 v3 = pMouse->GetCursorPos(&a2)->y + 30;
12744 else 12744 else
12745 v3 = 30; 12745 v3 = 30;
12746 a1.uFrameY = v3; 12746 a1.uFrameY = v3;
12795 v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); 12795 v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
12796 a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u); 12796 a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
12797 a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0); 12797 a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
12798 a1.uFrameWidth = 108; 12798 a1.uFrameWidth = 108;
12799 a1.uFrameZ = a1.uFrameX + 107; 12799 a1.uFrameZ = a1.uFrameX + 107;
12800 a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->pNumSpellBookPage + 12], 3u); 12800 a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->lastOpenedSpellbookPage + 12], 3u);
12801 sprintf( 12801 sprintf(
12802 pTmpBuf, 12802 pTmpBuf,
12803 "%s\n%d", 12803 "%s\n%d",
12804 pGlobalTXT_LocalizationStrings[522], 12804 pGlobalTXT_LocalizationStrings[522],
12805 *(&pSpellDatas[0].field_12 //temp_fix field_14 12805 *(&pSpellDatas[0].field_12 //temp_fix field_14
12806 + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->pNumSpellBookPage + 12]) >> 6) 12806 + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->lastOpenedSpellbookPage + 12]) >> 6)
12807 + 10 * (int)((char *)v10 + 11 * v1->pNumSpellBookPage))); 12807 + 10 * (int)((char *)v10 + 11 * v1->lastOpenedSpellbookPage)));
12808 a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf, 3u); 12808 a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf, 3u);
12809 dword_507B00_spell_info_to_draw_in_popup = 0; 12809 dword_507B00_spell_info_to_draw_in_popup = 0;
12810 } 12810 }
12811 // 507B00: using guessed type int dword_507B00_spell_info_to_draw_in_popup; 12811 // 507B00: using guessed type int dword_507B00_spell_info_to_draw_in_popup;
12812 12812
13128 return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); 13128 return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
13129 } 13129 }
13130 // 4E1D3A: using guessed type __int16 word_4E1D3A[]; 13130 // 4E1D3A: using guessed type __int16 word_4E1D3A[];
13131 13131
13132 //----- (00411300) -------------------------------------------------------- 13132 //----- (00411300) --------------------------------------------------------
13133 Texture *__fastcall LoadSpellbook(unsigned int uID) 13133 void LoadSpellbook(unsigned int school)
13134 { 13134 {
13135 unsigned int v1; // esi@1 13135 //unsigned int v1; // esi@1
13136 Player *pPlayer; // ecx@1 13136 Player *pPlayer; // ecx@1
13137 char v3; // al@1 13137 char v3; // al@1
13138 int v4; // edi@5 13138 //int v4; // edi@5
13139 Texture *result; // eax@6 13139 //Texture *result; // eax@6
13140 char *v6; // edi@7 13140 //unsigned char *v6; // edi@7
13141 unsigned int v7; // eax@7 13141 //unsigned int v7; // eax@7
13142 unsigned __int8 v8; // sf@8 13142 //unsigned __int8 v8; // sf@8
13143 unsigned __int8 v9; // of@8 13143 //unsigned __int8 v9; // of@8
13144 char pContainer[20]; // [sp+Ch] [bp-1Ch]@7 13144 char pContainer[20]; // [sp+Ch] [bp-1Ch]@7
13145 Texture *v11; // [sp+20h] [bp-8h]@5 13145 Texture *v11; // [sp+20h] [bp-8h]@5
13146 int v12; // [sp+24h] [bp-4h]@5 13146 //int v12; // [sp+24h] [bp-4h]@5
13147 13147
13148 byte_506550 = 0; 13148 byte_506550 = 0;
13149 v1 = uID; 13149 //v1 = uID;
13150 pPlayer = pPlayers[uActiveCharacter]; 13150 pPlayer = pPlayers[uActiveCharacter];
13151 v3 = pPlayer->uQuickSpell; 13151 v3 = pPlayer->uQuickSpell;
13152 if ( v3 && (unsigned __int8)v3 / 11 == v1 ) 13152 if ( v3 && (unsigned __int8)v3 / 11 == school )
13153 dword_50654C = (unsigned __int8)v3 - 11 * v1; 13153 dword_50654C = (unsigned __int8)v3 - 11 * school;
13154 else 13154 else
13155 dword_50654C = 0; 13155 dword_50654C = 0;
13156 v4 = 1; 13156
13157 v12 = 1; 13157 v11 = (Texture *)&pPlayer->field_152[11 * school + 63];
13158 v11 = (Texture *)&pPlayer->field_152[11 * v1 + 63]; 13158
13159 do 13159 for (uint i = 1; i < 12; ++i)
13160 { 13160 {
13161 result = v11; 13161 if ( v11->pName[i] )
13162 if ( v11->pName[v4] ) 13162 {
13163 { 13163 sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[school], pSpellbookSpellIndices[school][i]);
13164 v6 = &byte_4E2430[12 * v1] + v4; 13164 dword_506408[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
13165 sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6); 13165
13166 v7 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); 13166 sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[school], pSpellbookSpellIndices[school][i]);
13167 dword_506408[v12] = &pIcons_LOD->pTextures[v7]; 13167 dword_5063D8[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
13168 sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6); 13168 }
13169 result = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)]; 13169 }
13170 dword_5063D8[v12] = result;
13171 }
13172 v4 = v12 + 1;
13173 v9 = v12++ > 12;//v9 = __OFSUB__(v12 + 1, 12);
13174 v8 = v12++ - 11 < 0;
13175 }
13176 while ( v8 ^ v9 );
13177 return result;
13178 } 13170 }
13179 // 4E1D18: using guessed type char *spellbook_texture_filename_suffices[8];
13180 // 506408: using guessed type int dword_506408[];
13181 // 50654C: using guessed type int dword_50654C;
13182 // 506550: using guessed type char byte_506550;
13183 13171
13184 //----- (0041140B) -------------------------------------------------------- 13172 //----- (0041140B) --------------------------------------------------------
13185 GUIWindow *__cdecl sub_41140B() 13173 GUIWindow *__cdecl sub_41140B()
13186 { 13174 {
13187 signed int v0; // esi@1 13175 signed int v0; // esi@1
13277 { 13265 {
13278 int v0; // ecx@1 13266 int v0; // ecx@1
13279 13267
13280 v0 = 0; 13268 v0 = 0;
13281 if ( uActiveCharacter ) 13269 if ( uActiveCharacter )
13282 v0 = pParty->pPlayers[uActiveCharacter-1].pNumSpellBookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2); 13270 v0 = pParty->pPlayers[uActiveCharacter-1].lastOpenedSpellbookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
13283 pRenderer->DrawTextureIndexed(8u, 8u, pTextures_5064A0[v0]); 13271 pRenderer->DrawTextureIndexed(8u, 8u, pTextures_5064A0[v0]);
13284 pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C); 13272 pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C);
13285 pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448); 13273 pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448);
13286 } 13274 }
13287 13275
13316 POINT v24; 13304 POINT v24;
13317 int v25; 13305 int v25;
13318 13306
13319 sub_412AF9(); 13307 sub_412AF9();
13320 v0 = pPlayers[uActiveCharacter]; 13308 v0 = pPlayers[uActiveCharacter];
13321 v1 = 11 * v0->pNumSpellBookPage; 13309 v1 = 11 * v0->lastOpenedSpellbookPage;
13322 v2 = pIcons_LOD->FindTextureByName("Pending"); 13310 v2 = pIcons_LOD->FindTextureByName("Pending");
13323 v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0); 13311 v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
13324 pRenderer->ClearZBuffer(0, 479); 13312 pRenderer->ClearZBuffer(0, 479);
13325 v4 = 1; 13313 v4 = 1;
13326 if ( __OFSUB__(v1, v1 + 11) ^ 1 ) 13314 if ( __OFSUB__(v1, v1 + 11) ^ 1 )
13342 v23 = dword_506408[v4]; 13330 v23 = dword_506408[v4];
13343 v6 = v5; 13331 v6 = v5;
13344 } 13332 }
13345 if ( v6->pLevelOfDetail0 ) 13333 if ( v6->pLevelOfDetail0 )
13346 { 13334 {
13347 v7 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage + v4])); 13335 v7 = 2 * (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]);
13348 v19 = pViewport->uViewportY + dword_4E20D0[v7 + 1]; 13336 v19 = pViewport->uViewportY + dword_4E20D0[v7 + 1];
13349 v17 = pViewport->uViewportX + dword_4E20D0[v7]; 13337 v17 = pViewport->uViewportX + dword_4E20D0[v7];
13350 if ( BYTE1(v6->pBits) & 2 ) 13338 if ( BYTE1(v6->pBits) & 2 )
13351 pRenderer->DrawTextureTransparent(v17, v19, v6); 13339 pRenderer->DrawTextureTransparent(v17, v19, v6);
13352 else 13340 else
13353 pRenderer->DrawTextureIndexed(v17, v19, v6); 13341 pRenderer->DrawTextureIndexed(v17, v19, v6);
13354 v8 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v4)); 13342 v8 = 2 * (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]);
13355 pRenderer->_4A612A(dword_4E20D0[v8], dword_4E20D0[v8 + 1], v23, v4); 13343 pRenderer->_4A612A(dword_4E20D0[v8], dword_4E20D0[v8 + 1], v23, v4);
13356 } 13344 }
13357 } 13345 }
13358 } 13346 }
13359 ++v4; 13347 ++v4;
13366 { 13354 {
13367 v11 = dword_5063D8[v10]; 13355 v11 = dword_5063D8[v10];
13368 if ( v11->pLevelOfDetail0 ) 13356 if ( v11->pLevelOfDetail0 )
13369 { 13357 {
13370 v21 = dword_5063D8[v10]; 13358 v21 = dword_5063D8[v10];
13371 v12 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v10)); 13359 v12 = 2 * (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v10]);
13372 v20 = pViewport->uViewportY + dword_4E20D0[v12 + 1]; 13360 v20 = pViewport->uViewportY + dword_4E20D0[v12 + 1];
13373 v18 = pViewport->uViewportX + dword_4E20D0[v12]; 13361 v18 = pViewport->uViewportX + dword_4E20D0[v12];
13374 if ( BYTE1(v11->pBits) & 2 ) 13362 if ( BYTE1(v11->pBits) & 2 )
13375 pRenderer->DrawTextureTransparent(v18, v20, v21); 13363 pRenderer->DrawTextureTransparent(v18, v20, v21);
13376 else 13364 else
13384 v25 = 0; 13372 v25 = 0;
13385 do 13373 do
13386 { 13374 {
13387 if ( *(short *)a2.x ) 13375 if ( *(short *)a2.x )
13388 { 13376 {
13389 if ( v0->pNumSpellBookPage == v13 ) 13377 if ( v0->lastOpenedSpellbookPage == v13 )
13390 { 13378 {
13391 pPageTexture = pTextures_tabs[v13][1]; 13379 pPageTexture = pTextures_tabs[v13][1];
13392 switch ( v13 ) 13380 switch ( v13 )
13393 { 13381 {
13394 case 0: 13382 case 0: