comparison Player.cpp @ 1012:9e823ad5eaa6

second msg_queue returned
author Gloval
date Sun, 19 May 2013 12:13:42 +0400
parents f73e1a219d38
children a704435d3285
comparison
equal deleted inserted replaced
1011:f85a8305a57c 1012:9e823ad5eaa6
477 } 477 }
478 478
479 479
480 480
481 //----- (00421E75) -------------------------------------------------------- 481 //----- (00421E75) --------------------------------------------------------
482 unsigned int Player::GetItemIDAtInventoryIndex(int *a2) 482 unsigned int Player::GetItemIDAtInventoryIndex(int *pitem_index)
483 { 483 {
484 int v2; // eax@1 484 int item_idx; // eax@1
485 unsigned int result; // eax@3 485 int inv_index; // eax@3
486 486
487 v2 = *a2; 487 item_idx = *pitem_index;
488 if ( *a2 >= 126 || v2 < 0 ) 488 if ( item_idx >125 || item_idx < 0 )
489 { 489 {
490 result = 0; 490 return 0;
491 } 491 }
492 else 492
493 { 493 inv_index = this->pInventoryIndices[item_idx];
494 result = this->pInventoryIndices[v2]; 494 if ( inv_index < 0 )
495 if ( (result & 0x80000000u) != 0 ) 495 {
496 { 496 *pitem_index = -1 - inv_index;
497 *a2 = -1 - result; 497 inv_index = this->pInventoryIndices[-1 - inv_index];
498 result = this->pInventoryIndices[-1 - result]; 498 }
499 } 499
500 } 500 return inv_index;
501 return result;
502 } 501 }
503 502
504 503
505 504
506 //----- (004160CA) -------------------------------------------------------- 505 //----- (004160CA) --------------------------------------------------------
507 char Player::_4160CA(int a2) 506 void Player::ItemsEnchant( int enchant_count )
508 { 507 {
509 Player *v2; // esi@1 508 int avalible_items; // ebx@1
510 signed int v3; // edx@1 509 int i; // edx@8
511 signed int v4; // ebx@1 510 __int16 item_index_tabl[138]; // [sp+Ch] [bp-118h]@1
512 ItemGen *v5; // eax@1 511
513 int v6; // edi@2 512 avalible_items = 0;
514 signed int i; // edx@8 513 memset (item_index_tabl,0,sizeof(item_index_tabl));
515 ItemGen **v8; // ecx@9 514
516 __int16 v10[137]; // [sp+Ch] [bp-118h]@1 515 for (i=0; i<138; ++i)
517 __int16 v11; // [sp+11Eh] [bp-6h]@1 516 {
518 int v12; // [sp+120h] [bp-4h]@1 517 if (( pOwnItems[i].uItemID>0)&&(pOwnItems[i].uItemID<= 134))
519 518 item_index_tabl[avalible_items++] = i;
520 auto a1 = this; 519 }
521 520
522 v12 = a2; 521 if ( avalible_items )
523 v2 = a1; 522 {
524 v3 = 0; 523 if ( enchant_count )
525 v10[0] = 0; 524 {
526 v4 = 0; 525 for ( i = 0; i < enchant_count; ++i )
527 memset(&v10[1], 0, 0x110u);
528 v11 = 0;
529 v5 = a1->pInventoryItems;
530 do
531 {
532 v6 = 0;
533 if ( (signed int)v5->uItemID > 0 && (signed int)v5->uItemID <= 134 )
534 v10[v4++] = v3;
535 ++v3;
536 ++v5;
537 }
538 while ( v3 < 138 );
539 if ( v4 )
540 {
541 if ( v12 )
542 {
543 if ( v12 > 0 )
544 {
545 do
546 { 526 {
547 LOWORD(v5) = 9 * v10[v6]; 527 if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED))
548 if ( !(BYTE1(v2->pInventoryItems[v10[v6]].uAttributes) & 2) ) 528 pInventoryItems[item_index_tabl[rand() % avalible_items]].uAttributes|=ITEM_ENCHANTED;
549 {
550 v5 = (ItemGen *)((char *)&v2->pInventoryItems[v10[rand() % v4]] + 20);
551 v5->uItemID |= 2u;
552 }
553 ++v6;
554 } 529 }
555 while ( v6 < v12 ); 530
556 }
557 } 531 }
558 else 532 else
559 { 533 {
560 for ( i = 0; i < v4; ++i ) 534 for ( i = 0; i < avalible_items; ++i )
561 { 535 {
562 v8 = (ItemGen **)&v2->pInventoryItems[v10[i]].uAttributes; 536 if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED))
563 v5 = *v8; 537 pInventoryItems[item_index_tabl[i]].uAttributes|=ITEM_ENCHANTED;
564 if ( !(BYTE1(v5) & 2) ) 538 }
565 { 539 }
566 LOBYTE(v5) = (unsigned __int8)v5 | 2; 540 }
567 *v8 = v5; 541 ;
568 }
569 }
570 }
571 }
572 return (char)v5;
573 } 542 }
574 543
575 //----- (004948B1) -------------------------------------------------------- 544 //----- (004948B1) --------------------------------------------------------
576 void Player::PlaySound(PlayerSpeech speech, int a3) 545 void Player::PlaySound(PlayerSpeech speech, int a3)
577 { 546 {
7773 dword_50C9EC[3 * dword_50C9E8] = 146; 7742 dword_50C9EC[3 * dword_50C9E8] = 146;
7774 dword_50C9EC[3 * dword_50C9E8 + 1] = v24; 7743 dword_50C9EC[3 * dword_50C9E8 + 1] = v24;
7775 dword_50C9EC[3 * dword_50C9E8 + 2] = a2 - 1; 7744 dword_50C9EC[3 * dword_50C9E8 + 2] = a2 - 1;
7776 ++dword_50C9E8; 7745 ++dword_50C9E8;
7777 }*/ 7746 }*/
7778 pMessageQueue_50CBD0->AddMessage(UIMSG_92, 0, 0); 7747 pMessageQueue_50C9E8->AddMessage(UIMSG_92, v24, a2 - 1);
7779 if ( pCurrentScreen 7748 if ( pCurrentScreen
7780 && pGUIWindow_CurrentMenu 7749 && pGUIWindow_CurrentMenu
7781 && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) 7750 && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
7782 //&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) 7751 //&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
7783 { 7752 {