Skip to content

Instantly share code, notes, and snippets.

@jkoppel
Created Oct 10, 2017
Embed
What would you like to do?
Find the rectangles!
void army::Walk(signed int dir, int last, int notFirst) {
int targCell = this->GetAdjacentCellIndex(this->occupiedHex, dir);
gCloseMove = IsCloseMove(targCell);
// Bridge opening
if (this->owningSide == 1
&& gpCombatManager->isCastleBattle
&& (targCell == 58 || targCell == 59 || targCell == 60 && this->owningSide == 1 && this->creature.creature_flags & TWO_HEXER)
&& gpCombatManager->drawBridgePosition == BRIDGE_CLOSED) {
this->animationType = ANIMATION_TYPE_STANDING;
this->animationFrame = 0;
gpCombatManager->DrawFrame(1, 0, 0, 0, 75, 1, 1);
gpCombatManager->LowerDoor();
notFirst = 0;
}
giWalkingFrom = this->occupiedHex;
giWalkingTo = targCell;
if (this->creature.creature_flags & TWO_HEXER) {
giWalkingFrom2 = this->occupiedHex + ((unsigned int)(this->facingRight - 1) < 1 ? 1 : -1);
giWalkingTo2 = targCell + ((unsigned int)(this->facingRight - 1) < 1 ? 1 : -1);
} else {
giWalkingFrom2 = -1;
giWalkingTo2 = -1;
}
giWalkingYMod = 0;
BuildTempWalkSeq(&this->frameInfo, last, notFirst);
this->field_8A = dir;
if (!notFirst) {
giMinExtentY = 640;
giMinExtentX = 640;
giMaxExtentY = 0;
giMaxExtentX = 0;
gbComputeExtent = 1;
gbSaveBiggestExtent = 1;
gbReturnAfterComputeExtent = 1;
this->DrawToBuffer(gpCombatManager->combatGrid[this->occupiedHex].centerX, gpCombatManager->combatGrid[this->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;
int offsetX = giMinExtentX;
int offsetY = giMinExtentY;
int v12 = giMaxExtentX;
int v6 = giMaxExtentY;
this->field_8E = 0;
if (dir >= 3) {
if (this->facingRight == 1) {
this->field_8E = 1;
this->facingRight = 1 - this->facingRight;
if (this->creature.creature_flags & TWO_HEXER)
++this->occupiedHex;
}
} else if (!this->facingRight) {
this->field_8E = 1;
this->facingRight = 1 - this->facingRight;
if (this->creature.creature_flags & TWO_HEXER)
--this->occupiedHex;
}
if (!dir || dir == 5)
this->field_6 = 0;
if (dir == 2 || dir == 3)
this->field_6 = 3;
this->animationFrame = 0;
this->animationType = ANIMATION_TYPE_WALKING;
if (!gbNoShowCombat)
gpSoundManager->MemorySample(this->combatSounds[0]);
if (!notFirst) {
gpCombatManager->combatGrid[this->occupiedHex].unitOwner = -1;
gpCombatManager->DrawFrame(0, 0, 0, 0, 75, 1, 1);
gpCombatManager->combatGrid[this->occupiedHex].unitOwner = gpCombatManager->otherCurrentSideThing;
if (!gbNoShowCombat)
gpWindowManager->screenBuffer->CopyTo(gpCombatManager->probablyBitmapForCombatScreen, 0, 0, 0, 0, 0x280u, 443);
gpCombatManager->zeroedAfterAnimatingDeathAndHolySpells = 0;
}
if (!gbNoShowCombat) {
for (int i = 0; this->frameInfo.animationLengths[6] > i; ++i) {
this->animationFrame = i;
if (notFirst || i) {
gpCombatManager->probablyBitmapForCombatScreen->CopyTo(
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;
this->DrawToBuffer(
gpCombatManager->combatGrid[this->occupiedHex].centerX,
gpCombatManager->combatGrid[this->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;
this->field_11D = 0;
gpCombatManager->DrawFrame(0, 0, 0, 0, 75, 0, 1);
this->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)this->frameInfo.stepTime
* gfCombatSpeedMod[giCombatSpeed]
/ (double)this->frameInfo.animationLengths[6]);
gpWindowManager->UpdateScreenRegion(offsetX, offsetY, v12 - offsetX + 1, v6 - offsetY + 1);
}
}
int adjCell = this->GetAdjacentCellIndex(this->occupiedHex, dir);
gpCombatManager->combatGrid[this->occupiedHex].stackIdx = -1;
gpCombatManager->combatGrid[this->occupiedHex].unitOwner = -1;
gpCombatManager->combatGrid[this->occupiedHex].occupiersOtherHexIsToLeft = -1;
if (this->creature.creature_flags & TWO_HEXER) {
int v4 = this->occupiedHex + ((unsigned int)(this->facingRight - 1) < 1 ? 1 : -1);
gpCombatManager->combatGrid[v4].stackIdx = -1;
gpCombatManager->combatGrid[v4].unitOwner = -1;
gpCombatManager->combatGrid[v4].occupiersOtherHexIsToLeft = -1;
}
gpCombatManager->combatGrid[adjCell].unitOwner = LOBYTE(this->owningSide);
gpCombatManager->combatGrid[adjCell].stackIdx = LOBYTE(this->stackIdx);
gpCombatManager->combatGrid[adjCell].occupiersOtherHexIsToLeft = -1;
if (this->creature.creature_flags & TWO_HEXER) {
int v7 = adjCell + ((unsigned int)(this->facingRight - 1) < 1 ? 1 : -1);
gpCombatManager->combatGrid[v7].unitOwner = LOBYTE(this->owningSide);
gpCombatManager->combatGrid[v7].stackIdx = LOBYTE(this->stackIdx);
gpCombatManager->combatGrid[v7].occupiersOtherHexIsToLeft = adjCell <= v7;
gpCombatManager->combatGrid[adjCell].occupiersOtherHexIsToLeft = adjCell >= v7;
}
this->occupiedHex = adjCell;
if (this->field_8E) {
this->facingRight = 1 - this->facingRight;
OccupyHexes(this);
this->field_8E = 0;
}
giWalkingFrom = -1;
giWalkingFrom2 = -1;
giWalkingTo = -1;
giWalkingTo2 = -1;
this->field_6 = 1;
if (last == 1) {
this->animationType = ANIMATION_TYPE_STANDING;
this->animationFrame = 0;
gpCombatManager->DrawFrame(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