Mercurial > mm7
comparison mm7_3.cpp @ 1331:f0be1fecd642
turn_based start fixed
author | Gloval |
---|---|
date | Wed, 03 Jul 2013 23:21:29 +0400 |
parents | 82431a85b28e |
children | 1e35cfed7928 9749edd941c6 |
comparison
equal
deleted
inserted
replaced
1330:82431a85b28e | 1331:f0be1fecd642 |
---|---|
12417 else | 12417 else |
12418 return pCosTable[v2]; | 12418 return pCosTable[v2]; |
12419 } | 12419 } |
12420 | 12420 |
12421 //----- (00404544) -------------------------------------------------------- | 12421 //----- (00404544) -------------------------------------------------------- |
12422 signed int stru262_TurnBased::_404544() | 12422 void stru262_TurnBased::_404544() |
12423 { | 12423 { |
12424 stru262_TurnBased *v1; // ebx@1 | 12424 stru262_TurnBased *v1; // ebx@1 |
12425 TurnBased_QueueElem *v2; // esi@2 | 12425 TurnBased_QueueElem *v2; // esi@2 |
12426 Actor *v3; // edi@4 | 12426 Actor *v3; // edi@4 |
12427 Actor *v4; // ecx@4 | 12427 Actor *v4; // ecx@4 |
12428 Player *v5; // eax@7 | 12428 Player *v5; // eax@7 |
12442 int v19; // [sp+24h] [bp-8h]@1 | 12442 int v19; // [sp+24h] [bp-8h]@1 |
12443 int v20; // [sp+28h] [bp-4h]@1 | 12443 int v20; // [sp+28h] [bp-4h]@1 |
12444 signed int v21; // [sp+28h] [bp-4h]@16 | 12444 signed int v21; // [sp+28h] [bp-4h]@16 |
12445 int v22; // [sp+28h] [bp-4h]@31 | 12445 int v22; // [sp+28h] [bp-4h]@31 |
12446 | 12446 |
12447 int i; | |
12448 | |
12447 v20 = 0; | 12449 v20 = 0; |
12448 v1 = this; | 12450 v1 = this; |
12449 v19 = this->uActorQueueSize; | 12451 v19 = this->uActorQueueSize; |
12450 if ( this->uActorQueueSize > 0 ) | 12452 if ( this->uActorQueueSize > 0 ) |
12451 { | 12453 { |
12462 --v19; | 12464 --v19; |
12463 v2->field_4 = 1001; | 12465 v2->field_4 = 1001; |
12464 LOBYTE(v3->uAttributes) &= 0x7Fu; | 12466 LOBYTE(v3->uAttributes) &= 0x7Fu; |
12465 } | 12467 } |
12466 } | 12468 } |
12469 | |
12467 if ( PID_TYPE(v2->uPackedID) == OBJECT_Player) | 12470 if ( PID_TYPE(v2->uPackedID) == OBJECT_Player) |
12468 { | 12471 { |
12469 v5 = &pParty->pPlayers[v2->uPackedID >> 3]; | 12472 v5 = &pParty->pPlayers[v2->uPackedID >> 3]; |
12470 if ( v5->pConditions[14] | 12473 if ( v5->pConditions[Player::Condition_Dead] |
12471 || v5->pConditions[16] | 12474 || v5->pConditions[Player::Condition_Eradicated] |
12472 || v5->pConditions[15] | 12475 || v5->pConditions[Player::Condition_Pertified] |
12473 || v5->pConditions[13] | 12476 || v5->pConditions[Player::Condition_Unconcious] |
12474 || v5->pConditions[12] | 12477 || v5->pConditions[Player::Condition_Paralyzed] |
12475 || v5->pConditions[2] ) | 12478 || v5->pConditions[Player::Condition_Sleep] ) |
12476 { | 12479 { |
12477 --v19; | 12480 --v19; |
12478 v2->field_4 = 1001; | 12481 v2->field_4 = 1001; |
12479 } | 12482 } |
12480 } | 12483 } |
12481 ++v20; | 12484 ++v20; |
12482 ++v2; | 12485 ++v2; |
12483 } | 12486 } |
12484 while ( v20 < v1->uActorQueueSize ); | 12487 while ( v20 < v1->uActorQueueSize ); |
12485 } | 12488 } |
12489 | |
12490 //sort | |
12486 v6 = v1->uActorQueueSize; | 12491 v6 = v1->uActorQueueSize; |
12487 if ( v6 > 0 ) | 12492 if ( v6 > 0 ) |
12488 { | 12493 { |
12489 v21 = 1; | 12494 v21 = 1; |
12490 v7 = v1->pQueue; | 12495 v7 = v1->pQueue; |
12496 v8 = v7 + 1; | 12501 v8 = v7 + 1; |
12497 do | 12502 do |
12498 { | 12503 { |
12499 v9 = v8->field_4; | 12504 v9 = v8->field_4; |
12500 v10 = v7->field_4; | 12505 v10 = v7->field_4; |
12501 if ( v9 < v10 | 12506 if ( v8->field_4 < v7->field_4 || v8->field_4 == v7->field_4 |
12502 || v9 == v10 | 12507 && (( PID_TYPE(v8->uPackedID) == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor |
12503 && ((v11 = PID_TYPE(v8->uPackedID), v11 == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor | 12508 || PID_TYPE(v8->uPackedID) == PID_TYPE(v7->uPackedID) && |
12504 || v11 == PID_TYPE(v7->uPackedID) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) | 12509 (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) |
12505 { | 12510 { |
12506 v12 = v7->uPackedID; | 12511 v12 = v7->uPackedID; |
12507 v13 = v7->field_4; | 12512 v13 = v7->field_4; |
12508 v14 = v7->uActionLength; | 12513 v14 = v7->uActionLength; |
12509 v15 = v7->field_C; | 12514 v15 = v7->field_C; |
12526 ++v7; | 12531 ++v7; |
12527 } | 12532 } |
12528 while ( v21 - 1 < v6 ); | 12533 while ( v21 - 1 < v6 ); |
12529 } | 12534 } |
12530 v1->uActorQueueSize = v19; | 12535 v1->uActorQueueSize = v19; |
12531 result = v1->pQueue[0].uPackedID; | 12536 |
12532 if ( PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) | 12537 |
12533 { | 12538 if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) |
12534 result = PID_ID(result) + 1; | 12539 { |
12535 uActiveCharacter = result; | 12540 uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1; |
12536 v1->field_18 |= 4u; | 12541 field_18 |= 4u; |
12537 } | 12542 } |
12538 else | 12543 else |
12539 { | 12544 { |
12540 uActiveCharacter = 0; | 12545 uActiveCharacter = 0; |
12541 v1->field_18 &= 0xFFFFFFFBu; | 12546 field_18 &= 0xFFFFFFFBu; |
12542 } | 12547 } |
12543 v22 = 0; | 12548 |
12544 if ( v1->uActorQueueSize > 0 ) | 12549 for(i=0; i<uActorQueueSize; ++i) |
12545 { | 12550 { |
12546 v17 = v1->pQueue; | 12551 if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) |
12547 do | 12552 pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 0.46875); |
12548 { | 12553 } |
12549 if ( PID_TYPE(v17->uPackedID) == OBJECT_Player) | 12554 |
12550 pParty->pPlayers[PID_ID(v17->uPackedID)].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); | 12555 |
12551 ++v22; | |
12552 ++v17; | |
12553 result = v22; | |
12554 } | |
12555 while ( v22 < v1->uActorQueueSize ); | |
12556 } | |
12557 return result; | |
12558 } | 12556 } |
12559 | 12557 |
12560 //----- (0040471C) -------------------------------------------------------- | 12558 //----- (0040471C) -------------------------------------------------------- |
12561 void stru262_TurnBased::_40471C() | 12559 void stru262_TurnBased::_40471C() |
12562 { | 12560 { |
12566 _406457(0); | 12564 _406457(0); |
12567 } | 12565 } |
12568 } | 12566 } |
12569 | 12567 |
12570 //----- (004059DB) -------------------------------------------------------- | 12568 //----- (004059DB) -------------------------------------------------------- |
12571 signed int stru262_TurnBased::Start() | 12569 void stru262_TurnBased::Start() |
12572 { | 12570 { |
12573 //stru262_TurnBased *v1; // ebx@1 | 12571 //stru262_TurnBased *v1; // ebx@1 |
12574 int v3; // esi@1 | 12572 int v3; // esi@1 |
12575 int v4; // eax@5 | 12573 int v4; // eax@5 |
12576 unsigned int actor_id; // esi@7 | 12574 unsigned int actor_id; // esi@7 |
12607 int v40b; | 12605 int v40b; |
12608 unsigned int v37; // [sp+70h] [bp-4h]@7 | 12606 unsigned int v37; // [sp+70h] [bp-4h]@7 |
12609 int activ_players[4]; | 12607 int activ_players[4]; |
12610 int players_recovery_time[4]; | 12608 int players_recovery_time[4]; |
12611 int a_players_count; | 12609 int a_players_count; |
12612 int i; | 12610 int i,j; |
12611 int temp; | |
12613 | 12612 |
12614 | 12613 |
12615 pTurnEngine->field_18 &= 0xFFFFFFFDu; | 12614 pTurnEngine->field_18 &= 0xFFFFFFFDu; |
12616 //v1 = this; | 12615 //v1 = this; |
12617 pEventTimer->TrackGameTime(); | 12616 pEventTimer->TrackGameTime(); |
12698 if ( a_players_count > 0 ) | 12697 if ( a_players_count > 0 ) |
12699 { | 12698 { |
12700 for (i=0; i<a_players_count; ++i) | 12699 for (i=0; i<a_players_count; ++i) |
12701 players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0); | 12700 players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0); |
12702 //sort players by recovery time | 12701 //sort players by recovery time |
12703 for (i=0; i<a_players_count; ++i) | 12702 for (i=0; i < a_players_count; ++i) |
12704 { //to fix | 12703 { |
12705 //v35 = v2; | 12704 for(j=i+1; j<a_players_count;++j ) |
12706 //v34 = (int *)1; | 12705 { |
12707 //do | 12706 if (players_recovery_time[j] < players_recovery_time[i]) //swap values |
12708 // { | 12707 { |
12709 // v40b = (int)v34; | 12708 temp = players_recovery_time[i]; |
12710 // if ( (signed int)v34 < (signed int)v37 ) | 12709 players_recovery_time[i] = players_recovery_time[j]; |
12711 // { | 12710 players_recovery_time[j] = temp; |
12712 // v19 = (char *)&v31.uDistance + v35; | 12711 |
12713 // do | 12712 temp = activ_players[i]; |
12714 // { | 12713 activ_players[i] = activ_players[j]; |
12715 // v20 = *(int *)v19; | 12714 activ_players[j] = temp; |
12716 // //v33 = 4 * v40b; | 12715 } |
12717 // v21 = (char *)(&v31.uDistance + v40b); | 12716 } |
12718 // v22 = *(int *)v21; | |
12719 // if ( *(int *)v21 < v20 ) | |
12720 // { | |
12721 // *(int *)v21 = v20; | |
12722 // v23 = 4 * v40b; | |
12723 // *(int *)v19 = v22; | |
12724 // v24 = (char *)&a3.uDistance + v23; | |
12725 // v25 = (char *)&a3.uDistance + v35; | |
12726 // v26 = *(int *)v24; | |
12727 // *(int *)v24 = *(unsigned int *)((char *)&a3.uDistance + v35); | |
12728 // *(int *)v25 = v26; | |
12729 // v2 = 0; | |
12730 // } | |
12731 // ++v40b; | |
12732 // } | |
12733 // while ( v40b < (signed int)v37 ); | |
12734 // } | |
12735 // v34 = (int *)((char *)v34 + 1); | |
12736 // v35 += 4; | |
12737 // } | |
12738 // while ( (signed int)((char *)v34 - 1) < (signed int)v37 ); | |
12739 } | 12717 } |
12718 | |
12740 for (i=0; i<a_players_count; ++i) | 12719 for (i=0; i<a_players_count; ++i) |
12741 { | 12720 { |
12742 this->pQueue[activ_players[i]].field_4 = i+2; | 12721 this->pQueue[activ_players[i]].field_4 = i+2; |
12743 } | 12722 } |
12744 } | 12723 } |
12745 return this->_404544(); | 12724 this->_404544(); |
12746 } | 12725 } |