Created
October 2, 2023 09:08
-
-
Save jkoppel/a38161c3d0c1f5fc07b93cd38679fc5f to your computer and use it in GitHub Desktop.
army::Walk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void __thiscall army::Walk(army *ecx0, signed int dir, int last, int notFirst) | |
| { | |
| int v4; // ST3C_4@78 | |
| int v6; // [sp+1Ch] [bp-24h]@26 | |
| int v7; // [sp+20h] [bp-20h]@80 | |
| int i; // [sp+24h] [bp-1Ch]@47 | |
| int v9; // [sp+28h] [bp-18h]@77 | |
| signed int targCell; // [sp+30h] [bp-10h]@1 | |
| int offsetY; // [sp+34h] [bp-Ch]@26 | |
| int v12; // [sp+38h] [bp-8h]@26 | |
| int offsetX; // [sp+3Ch] [bp-4h]@26 | |
| targCell = army::GetAdjacentCellIndex(ecx0, ecx0->occupiedHex, dir); // fetches data, used for multiple purposes | |
| if ( ecx0->owningSide == 1 | |
| && gpCombatManager->isCastleBattle | |
| && (targCell == 58 || targCell == 59 || targCell == 60 && ecx0->owningSide == 1 && ecx0->creature.creature_flags & 1) | |
| && gpCombatManager->drawBridgePosition == BRIDGE_CLOSED ) | |
| { // isCastleBattle, drawBridgePosition, and BRIDGE_CLOSED are all associated with siege combat. | |
| ecx0->animationType = ANIMATION_TYPE_STANDING; // concept: animation, standing | |
| ecx0->animationFrame = 0; // concept: animation | |
| combatManager::DrawFrame(gpCombatManager, 1, 0, 0, 0, 75, 1, 1); // concept: drawing, animation | |
| combatManager::LowerDoor(gpCombatManager); // concept: siege combat | |
| notFirst = 0; // ??? | |
| } | |
| giWalkingFrom = ecx0->occupiedHex; | |
| if ( ecx0->creature.creature_flags & 1 ) // this implements two-hexers | |
| giWalkingFrom2 = ecx0->occupiedHex + ((unsigned int)(ecx0->facingRight - 1) < 1 ? 1 : -1); | |
| else | |
| giWalkingFrom2 = -1; | |
| giWalkingTo = targCell; | |
| if ( ecx0->creature.creature_flags & 1 ) | |
| giWalkingTo2 = targCell + ((unsigned int)(ecx0->facingRight - 1) < 1 ? 1 : -1); | |
| else | |
| giWalkingTo2 = -1; | |
| giWalkingYMod = 0; | |
| BuildTempWalkSeq(&ecx0->frameInfo, last, notFirst); | |
| ecx0->field_8A = dir; | |
| if ( !notFirst ) | |
| { | |
| giMinExtentY = 640; | |
| giMinExtentX = 640; | |
| giMaxExtentY = 0; | |
| giMaxExtentX = 0; | |
| gbComputeExtent = 1; | |
| gbSaveBiggestExtent = 1; | |
| gbReturnAfterComputeExtent = 1; | |
| army::DrawToBuffer( | |
| ecx0, | |
| gpCombatManager->combatGrid[ecx0->occupiedHex].centerX, | |
| gpCombatManager->combatGrid[ecx0->occupiedHex].occupyingCreatureBottomY, | |
| 0); | |
| gbReturnAfterComputeExtent = 0; | |
| gbSaveBiggestExtent = 0; | |
| gbComputeExtent = 0; | |
| } | |
| if ( giMinExtentX < 0 ) | |
| giMinExtentX = 0; | |
| if ( giMinExtentY < 0 ) | |
| giMinExtentY = 0; | |
| if ( giMaxExtentX > 639 ) | |
| giMaxExtentX = 639; | |
| if ( giMaxExtentY > 442 ) | |
| giMaxExtentY = 442; | |
| offsetX = giMinExtentX; | |
| offsetY = giMinExtentY; | |
| v12 = giMaxExtentX; | |
| v6 = giMaxExtentY; | |
| ecx0->field_8E = 0; | |
| if ( dir >= 3 ) | |
| { | |
| if ( ecx0->facingRight == 1 ) | |
| { | |
| ecx0->field_8E = 1; | |
| ecx0->facingRight = 1 - ecx0->facingRight; | |
| if ( ecx0->creature.creature_flags & TWO_HEXER ) | |
| ++ecx0->occupiedHex; | |
| } | |
| } | |
| else if ( !ecx0->facingRight ) | |
| { | |
| ecx0->field_8E = 1; | |
| ecx0->facingRight = 1 - ecx0->facingRight; | |
| if ( ecx0->creature.creature_flags & TWO_HEXER ) | |
| --ecx0->occupiedHex; | |
| } | |
| if ( !dir || dir == 5 ) | |
| ecx0->field_6 = 0; | |
| if ( dir == 2 || dir == 3 ) | |
| ecx0->field_6 = 3; | |
| ecx0->animationFrame = 0; | |
| ecx0->animationType = 6; | |
| if ( !gbNoShowCombat ) | |
| soundManager::MemorySample((soundManager *)gpSoundManager, ecx0->combatSounds[0]); | |
| if ( !notFirst ) | |
| { | |
| gpCombatManager->combatGrid[ecx0->occupiedHex].unitOwner = -1; | |
| combatManager::DrawFrame(gpCombatManager, 0, 0, 0, 0, 75, 1, 1); | |
| gpCombatManager->combatGrid[ecx0->occupiedHex].unitOwner = LOBYTE(gpCombatManager->activeStackOwner); | |
| if ( !gbNoShowCombat ) | |
| bitmap::CopyTo( | |
| gpWindowManager->screenBuffer, | |
| gpCombatManager->probablyBitmapForCombatScreen, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0x280u, | |
| 443); | |
| gpCombatManager->zeroedAfterAnimatingDeathAndHolySpells = 0; | |
| } | |
| if ( !gbNoShowCombat ) | |
| { | |
| for ( i = 0; ecx0->frameInfo.animationLengths[6] > i; ++i ) | |
| { | |
| ecx0->animationFrame = i; | |
| if ( notFirst || i ) | |
| { | |
| bitmap::CopyTo( | |
| gpCombatManager->probablyBitmapForCombatScreen, | |
| gpWindowManager->screenBuffer, | |
| giMinExtentX, | |
| giMinExtentY, | |
| giMinExtentX, | |
| giMinExtentY, | |
| giMaxExtentX - giMinExtentX + 1, | |
| giMaxExtentY - giMinExtentY + 1); | |
| if ( giMinExtentX < 0 ) | |
| giMinExtentX = 0; | |
| if ( giMinExtentY < 0 ) | |
| giMinExtentY = 0; | |
| if ( giMaxExtentX > 639 ) | |
| giMaxExtentX = 639; | |
| if ( giMaxExtentY > 442 ) | |
| giMaxExtentY = 442; | |
| offsetX = giMinExtentX; | |
| offsetY = giMinExtentY; | |
| v12 = giMaxExtentX; | |
| v6 = giMaxExtentY; | |
| } | |
| giMinExtentY = 640; | |
| giMinExtentX = 640; | |
| giMaxExtentY = 0; | |
| giMaxExtentX = 0; | |
| gbComputeExtent = 1; | |
| gbSaveBiggestExtent = 1; | |
| gbReturnAfterComputeExtent = 1; | |
| army::DrawToBuffer( | |
| ecx0, | |
| gpCombatManager->combatGrid[ecx0->occupiedHex].centerX, | |
| gpCombatManager->combatGrid[ecx0->occupiedHex].occupyingCreatureBottomY, | |
| 0); | |
| gbReturnAfterComputeExtent = 0; | |
| gbComputeExtent = 0; | |
| gbSaveBiggestExtent = 0; | |
| if ( giMinExtentX < 0 ) | |
| giMinExtentX = 0; | |
| if ( giMinExtentY < 0 ) | |
| giMinExtentY = 0; | |
| if ( giMaxExtentX > 639 ) | |
| giMaxExtentX = 639; | |
| if ( giMaxExtentY > 442 ) | |
| giMaxExtentY = 442; | |
| gbCurrArmyDrawn = 0; | |
| gbComputeExtent = 1; | |
| gbLimitToExtent = 1; | |
| ecx0->field_11D = 0; | |
| combatManager::DrawFrame(gpCombatManager, 0, 0, 0, 0, 75, 0, 1); | |
| ecx0->field_11D = 1; | |
| gbLimitToExtent = 0; | |
| gbComputeExtent = 0; | |
| gbCurrArmyDrawn = 1; | |
| if ( giMinExtentX < offsetX ) | |
| offsetX = giMinExtentX; | |
| if ( offsetY > giMinExtentY ) | |
| offsetY = giMinExtentY; | |
| if ( giMaxExtentX > v12 ) | |
| v12 = giMaxExtentX; | |
| if ( giMaxExtentY > v6 ) | |
| v6 = giMaxExtentY; | |
| DelayTil(&glTimers); | |
| glTimers = (signed __int64)((double)KBTickCount() | |
| + (double)ecx0->frameInfo.stepTime | |
| * gfCombatSpeedMod[giCombatSpeed] | |
| / (double)ecx0->frameInfo.animationLengths[6]); | |
| heroWindowManager::UpdateScreenRegion(gpWindowManager, offsetX, offsetY, v12 - offsetX + 1, v6 - offsetY + 1); | |
| } | |
| } | |
| v9 = army::GetAdjacentCellIndex(ecx0, ecx0->occupiedHex, dir); | |
| gpCombatManager->combatGrid[ecx0->occupiedHex].stackIdx = -1; | |
| gpCombatManager->combatGrid[ecx0->occupiedHex].unitOwner = -1; | |
| gpCombatManager->combatGrid[ecx0->occupiedHex].occupiersOtherHexIsToLeft = -1; | |
| if ( ecx0->creature.creature_flags & 1 ) | |
| { | |
| v4 = ecx0->occupiedHex + ((unsigned int)(ecx0->facingRight - 1) < 1 ? 1 : -1); | |
| gpCombatManager->combatGrid[v4].stackIdx = -1; | |
| gpCombatManager->combatGrid[v4].unitOwner = -1; | |
| gpCombatManager->combatGrid[v4].occupiersOtherHexIsToLeft = -1; | |
| } | |
| gpCombatManager->combatGrid[v9].unitOwner = LOBYTE(ecx0->owningSide); | |
| gpCombatManager->combatGrid[v9].stackIdx = LOBYTE(ecx0->stackIdx); | |
| gpCombatManager->combatGrid[v9].occupiersOtherHexIsToLeft = -1; | |
| if ( ecx0->creature.creature_flags & 1 ) | |
| { | |
| v7 = v9 + ((unsigned int)(ecx0->facingRight - 1) < 1 ? 1 : -1); | |
| gpCombatManager->combatGrid[v7].unitOwner = LOBYTE(ecx0->owningSide); | |
| gpCombatManager->combatGrid[v7].stackIdx = LOBYTE(ecx0->stackIdx); | |
| gpCombatManager->combatGrid[v7].occupiersOtherHexIsToLeft = v9 <= v7; | |
| gpCombatManager->combatGrid[v9].occupiersOtherHexIsToLeft = v9 >= v7; | |
| } | |
| ecx0->occupiedHex = v9; | |
| if ( ecx0->field_8E ) | |
| { | |
| ecx0->facingRight = 1 - ecx0->facingRight; | |
| if ( ecx0->creature.creature_flags & TWO_HEXER ) | |
| { | |
| if ( ecx0->facingRight ) | |
| --ecx0->occupiedHex; | |
| else | |
| ++ecx0->occupiedHex; | |
| } | |
| ecx0->field_8E = 0; | |
| } | |
| giWalkingFrom = -1; | |
| giWalkingFrom2 = -1; | |
| giWalkingTo = -1; | |
| giWalkingTo2 = -1; | |
| ecx0->field_6 = 1; | |
| if ( last == 1 ) | |
| { | |
| ecx0->animationType = 7; | |
| ecx0->animationFrame = 0; | |
| combatManager::DrawFrame(gpCombatManager, 1, 1, 0, 0, 75, 1, 1); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment