compute_explosion_on_extras: code readability

This commit is contained in:
phobos2077 2023-06-29 22:22:09 +02:00
parent fe035d8514
commit deb1afe4f1
7 changed files with 86 additions and 86 deletions

View File

@ -1939,18 +1939,18 @@ static int _tile_idistance(int tile1, int tile2)
} }
// 0x4163AC // 0x4163AC
int _make_straight_path(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6) int _make_straight_path(Object* obj, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6)
{ {
return _make_straight_path_func(a1, from, to, straightPathNodeList, obstaclePtr, a6, _obj_blocking_at); return _make_straight_path_func(obj, from, to, straightPathNodeList, obstaclePtr, a6, _obj_blocking_at);
} }
// TODO: Rather complex, but understandable, needs testing. // TODO: Rather complex, but understandable, needs testing.
// //
// 0x4163C8 // 0x4163C8
int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback) int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback)
{ {
if (obstaclePtr != NULL) { if (obstaclePtr != NULL) {
Object* obstacle = callback(a1, from, a1->elevation); Object* obstacle = callback(obj, from, obj->elevation);
if (obstacle != NULL) { if (obstacle != NULL) {
if (obstacle != *obstaclePtr && (a6 != 32 || (obstacle->flags & OBJECT_SHOOT_THRU) == 0)) { if (obstacle != *obstaclePtr && (a6 != 32 || (obstacle->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obstacle; *obstaclePtr = obstacle;
@ -1961,13 +1961,13 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
int fromX; int fromX;
int fromY; int fromY;
tileToScreenXY(from, &fromX, &fromY, a1->elevation); tileToScreenXY(from, &fromX, &fromY, obj->elevation);
fromX += 16; fromX += 16;
fromY += 8; fromY += 8;
int toX; int toX;
int toY; int toY;
tileToScreenXY(to, &toX, &toY, a1->elevation); tileToScreenXY(to, &toX, &toY, obj->elevation);
toX += 16; toX += 16;
toY += 8; toY += 8;
@ -2005,7 +2005,7 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (ddx <= ddy) { if (ddx <= ddy) {
int middle = ddx - ddy / 2; int middle = ddx - ddy / 2;
while (true) { while (true) {
tile = tileFromScreenXY(tileX, tileY, a1->elevation); tile = tileFromScreenXY(tileX, tileY, obj->elevation);
v22 += 1; v22 += 1;
if (v22 == a6) { if (v22 == a6) {
@ -2016,9 +2016,9 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (straightPathNodeList != NULL) { if (straightPathNodeList != NULL) {
StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]); StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]);
pathNode->tile = tile; pathNode->tile = tile;
pathNode->elevation = a1->elevation; pathNode->elevation = obj->elevation;
tileToScreenXY(tile, &fromX, &fromY, a1->elevation); tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
pathNode->x = tileX - fromX - 16; pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8; pathNode->y = tileY - fromY - 8;
} }
@ -2044,7 +2044,7 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (tile != prevTile) { if (tile != prevTile) {
if (obstaclePtr != NULL) { if (obstaclePtr != NULL) {
Object* obj = callback(a1, tile, a1->elevation); Object* obj = callback(obj, tile, obj->elevation);
if (obj != NULL) { if (obj != NULL) {
if (obj != *obstaclePtr && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) { if (obj != *obstaclePtr && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obj; *obstaclePtr = obj;
@ -2058,7 +2058,7 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
} else { } else {
int middle = ddy - ddx / 2; int middle = ddy - ddx / 2;
while (true) { while (true) {
tile = tileFromScreenXY(tileX, tileY, a1->elevation); tile = tileFromScreenXY(tileX, tileY, obj->elevation);
v22 += 1; v22 += 1;
if (v22 == a6) { if (v22 == a6) {
@ -2069,9 +2069,9 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (straightPathNodeList != NULL) { if (straightPathNodeList != NULL) {
StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]); StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]);
pathNode->tile = tile; pathNode->tile = tile;
pathNode->elevation = a1->elevation; pathNode->elevation = obj->elevation;
tileToScreenXY(tile, &fromX, &fromY, a1->elevation); tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
pathNode->x = tileX - fromX - 16; pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8; pathNode->y = tileY - fromY - 8;
} }
@ -2097,7 +2097,7 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (tile != prevTile) { if (tile != prevTile) {
if (obstaclePtr != NULL) { if (obstaclePtr != NULL) {
Object* obj = callback(a1, tile, a1->elevation); Object* obj = callback(obj, tile, obj->elevation);
if (obj != NULL) { if (obj != NULL) {
if (obj != *obstaclePtr && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) { if (obj != *obstaclePtr && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obj; *obstaclePtr = obj;
@ -2118,9 +2118,9 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (straightPathNodeList != NULL) { if (straightPathNodeList != NULL) {
StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]); StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]);
pathNode->tile = tile; pathNode->tile = tile;
pathNode->elevation = a1->elevation; pathNode->elevation = obj->elevation;
tileToScreenXY(tile, &fromX, &fromY, a1->elevation); tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
pathNode->x = tileX - fromX - 16; pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8; pathNode->y = tileY - fromY - 8;
} }
@ -2128,7 +2128,7 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
pathNodeIndex += 1; pathNodeIndex += 1;
} else { } else {
if (pathNodeIndex > 0 && straightPathNodeList != NULL) { if (pathNodeIndex > 0 && straightPathNodeList != NULL) {
straightPathNodeList[pathNodeIndex - 1].elevation = a1->elevation; straightPathNodeList[pathNodeIndex - 1].elevation = obj->elevation;
} }
} }

View File

@ -145,8 +145,8 @@ int animationRegisterAnimateForever(Object* owner, int anim, int delay);
int animationRegisterPing(int flags, int delay); int animationRegisterPing(int flags, int delay);
int _make_path(Object* object, int from, int to, unsigned char* a4, int a5); int _make_path(Object* object, int from, int to, unsigned char* a4, int a5);
int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotations, int a5, PathBuilderCallback* callback); int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotations, int a5, PathBuilderCallback* callback);
int _make_straight_path(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6); int _make_straight_path(Object* object, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6);
int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback); int _make_straight_path_func(Object* object, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback);
void _object_animate(); void _object_animate();
int _check_move(int* actionPointsPtr); int _check_move(int* actionPointsPtr);
int _dude_move(int actionPoints); int _dude_move(int actionPoints);

View File

@ -3942,17 +3942,17 @@ static int attackCompute(Attack* attack)
attack->tile = tile; attack->tile = tile;
Object* v25 = attack->defender; Object* accidentalTarget = attack->defender;
_make_straight_path_func(v25, attack->defender->tile, attack->tile, NULL, &v25, 32, _obj_shoot_blocking_at); _make_straight_path_func(accidentalTarget, attack->defender->tile, attack->tile, NULL, &accidentalTarget, 32, _obj_shoot_blocking_at);
if (v25 != NULL && v25 != attack->defender) { if (accidentalTarget != NULL && accidentalTarget != attack->defender) {
attack->tile = v25->tile; attack->tile = accidentalTarget->tile;
} else { } else {
v25 = _obj_blocking_at(NULL, attack->tile, attack->defender->elevation); accidentalTarget = _obj_blocking_at(NULL, attack->tile, attack->defender->elevation);
} }
if (v25 != NULL && (v25->flags & OBJECT_SHOOT_THRU) == 0) { if (accidentalTarget != NULL && (accidentalTarget->flags & OBJECT_SHOOT_THRU) == 0) {
attack->attackerFlags |= DAM_HIT; attack->attackerFlags |= DAM_HIT;
attack->defender = v25; attack->defender = accidentalTarget;
attackComputeDamage(attack, 1, 2); attackComputeDamage(attack, 1, 2);
} }
} }
@ -3974,75 +3974,75 @@ static int attackCompute(Attack* attack)
// compute_explosion_on_extras // compute_explosion_on_extras
// 0x423C10 // 0x423C10
void _compute_explosion_on_extras(Attack* attack, int a2, bool isGrenade, int a4) void _compute_explosion_on_extras(Attack* attack, bool isFromAttacker, bool isGrenade, bool noDamage)
{ {
Object* attacker; Object* targetObj;
if (a2) { if (isFromAttacker) {
attacker = attack->attacker; targetObj = attack->attacker;
} else { } else {
if ((attack->attackerFlags & DAM_HIT) != 0) { if ((attack->attackerFlags & DAM_HIT) != 0) {
attacker = attack->defender; targetObj = attack->defender;
} else { } else {
attacker = NULL; targetObj = NULL;
} }
} }
int tile; int explosionTile;
if (attacker != NULL) { if (targetObj != NULL) {
tile = attacker->tile; explosionTile = targetObj->tile;
} else { } else {
tile = attack->tile; explosionTile = attack->tile;
} }
if (tile == -1) { if (explosionTile == -1) {
debugPrint("\nError: compute_explosion_on_extras: Called with bad target/tileNum"); debugPrint("\nError: compute_explosion_on_extras: Called with bad target/tileNum");
return; return;
} }
// TODO: The math in this loop is rather complex and hard to understand. int ringTileIdx;
int v20; int radius = 0;
int v22 = 0;
int rotation = 0; int rotation = 0;
int v5 = -1; int tile = -1;
int v19 = tile; int ringFirstTile = explosionTile;
// SFALL // SFALL
int maxTargets = explosionGetMaxTargets(); int maxTargets = explosionGetMaxTargets();
// Check adjacent tiles for possible targets, going ring-by-ring
while (attack->extrasLength < maxTargets) { while (attack->extrasLength < maxTargets) {
if (v22 != 0 && (v5 == -1 || (v5 = tileGetTileInDirection(v5, rotation, 1)) != v19)) { if (radius != 0 && (tile == -1 || (tile = tileGetTileInDirection(tile, rotation, 1)) != ringFirstTile)) {
v20++; ringTileIdx++;
if (v20 % v22 == 0) { if (ringTileIdx % radius == 0) { // the larger the radius, the slower we rotate
rotation += 1; rotation += 1;
if (rotation == ROTATION_COUNT) { if (rotation == ROTATION_COUNT) {
rotation = ROTATION_NE; rotation = ROTATION_NE;
} }
} }
} else { } else {
v22++; radius++; // go to the next ring
if (isGrenade && weaponGetGrenadeExplosionRadius(attack->weapon) < v22) { if (isGrenade && weaponGetGrenadeExplosionRadius(attack->weapon) < radius) {
v5 = -1; tile = -1;
} else if (isGrenade || weaponGetRocketExplosionRadius(attack->weapon) >= v22) { } else if (isGrenade || weaponGetRocketExplosionRadius(attack->weapon) >= radius) {
v5 = tileGetTileInDirection(v19, ROTATION_NE, 1); tile = tileGetTileInDirection(ringFirstTile, ROTATION_NE, 1);
} else { } else {
v5 = -1; tile = -1;
} }
v19 = v5; ringFirstTile = tile;
rotation = ROTATION_SE; rotation = ROTATION_SE;
v20 = 0; ringTileIdx = 0;
} }
if (v5 == -1) { if (tile == -1) {
break; break;
} }
Object* obstacle = _obj_blocking_at(attacker, v5, attack->attacker->elevation); Object* obstacle = _obj_blocking_at(targetObj, tile, attack->attacker->elevation);
if (obstacle != NULL if (obstacle != NULL
&& FID_TYPE(obstacle->fid) == OBJ_TYPE_CRITTER && FID_TYPE(obstacle->fid) == OBJ_TYPE_CRITTER
&& (obstacle->data.critter.combat.results & DAM_DEAD) == 0 && (obstacle->data.critter.combat.results & DAM_DEAD) == 0
&& (obstacle->flags & OBJECT_SHOOT_THRU) == 0 && (obstacle->flags & OBJECT_SHOOT_THRU) == 0
&& !_combat_is_shot_blocked(obstacle, obstacle->tile, tile, NULL, NULL)) { && !_combat_is_shot_blocked(obstacle, obstacle->tile, explosionTile, NULL, NULL)) {
if (obstacle == attack->attacker) { if (obstacle == attack->attacker) {
attack->attackerFlags &= ~DAM_HIT; attack->attackerFlags &= ~DAM_HIT;
attackComputeDamage(attack, 1, 2); attackComputeDamage(attack, 1, 2);
@ -4060,7 +4060,7 @@ void _compute_explosion_on_extras(Attack* attack, int a2, bool isGrenade, int a4
attack->extrasHitLocation[index] = HIT_LOCATION_TORSO; attack->extrasHitLocation[index] = HIT_LOCATION_TORSO;
attack->extras[index] = obstacle; attack->extras[index] = obstacle;
attackInit(&_explosion_ctd, attack->attacker, obstacle, attack->hitMode, HIT_LOCATION_TORSO); attackInit(&_explosion_ctd, attack->attacker, obstacle, attack->hitMode, HIT_LOCATION_TORSO);
if (!a4) { if (!noDamage) {
_explosion_ctd.attackerFlags |= DAM_HIT; _explosion_ctd.attackerFlags |= DAM_HIT;
attackComputeDamage(&_explosion_ctd, 1, 2); attackComputeDamage(&_explosion_ctd, 1, 2);
} }

View File

@ -37,7 +37,7 @@ void _combat(STRUCT_664980* attack);
void attackInit(Attack* attack, Object* a2, Object* a3, int a4, int a5); void attackInit(Attack* attack, Object* a2, Object* a3, int a4, int a5);
int _combat_attack(Object* a1, Object* a2, int a3, int a4); int _combat_attack(Object* a1, Object* a2, int a3, int a4);
int _combat_bullet_start(const Object* a1, const Object* a2); int _combat_bullet_start(const Object* a1, const Object* a2);
void _compute_explosion_on_extras(Attack* attack, int a2, bool isGrenade, int a4); void _compute_explosion_on_extras(Attack* attack, bool isFromAttacker, bool isGrenade, bool noDamage);
int _determine_to_hit(Object* a1, Object* a2, int hitLocation, int hitMode); int _determine_to_hit(Object* a1, Object* a2, int hitLocation, int hitMode);
int _determine_to_hit_no_range(Object* a1, Object* a2, int a3, int a4, unsigned char* a5); int _determine_to_hit_no_range(Object* a1, Object* a2, int a3, int a4, unsigned char* a5);
int _determine_to_hit_from_tile(Object* a1, int a2, Object* a3, int a4, int a5); int _determine_to_hit_from_tile(Object* a1, int a2, Object* a3, int a4, int a5);

View File

@ -51,7 +51,7 @@ static void opPush(Program* program);
static void opPushBase(Program* program); static void opPushBase(Program* program);
static void opPopBase(Program* program); static void opPopBase(Program* program);
static void opPopToBase(Program* program); static void opPopToBase(Program* program);
static void op802C(Program* program); static void opSetGlobal(Program* program);
static void opDump(Program* program); static void opDump(Program* program);
static void opDelayedCall(Program* program); static void opDelayedCall(Program* program);
static void opConditionalCall(Program* program); static void opConditionalCall(Program* program);
@ -712,7 +712,7 @@ static void opPopToBase(Program* program)
} }
// 0x467DE0 // 0x467DE0
static void op802C(Program* program) static void opSetGlobal(Program* program)
{ {
program->basePointer = program->stackValues->size(); program->basePointer = program->stackValues->size();
} }
@ -2556,7 +2556,7 @@ void interpreterRegisterOpcodeHandlers()
interpreterRegisterOpcode(OPCODE_POP_BASE, opPopBase); interpreterRegisterOpcode(OPCODE_POP_BASE, opPopBase);
interpreterRegisterOpcode(OPCODE_POP_TO_BASE, opPopToBase); interpreterRegisterOpcode(OPCODE_POP_TO_BASE, opPopToBase);
interpreterRegisterOpcode(OPCODE_PUSH_BASE, opPushBase); interpreterRegisterOpcode(OPCODE_PUSH_BASE, opPushBase);
interpreterRegisterOpcode(OPCODE_SET_GLOBAL, op802C); interpreterRegisterOpcode(OPCODE_SET_GLOBAL, opSetGlobal);
interpreterRegisterOpcode(OPCODE_FETCH_PROCEDURE_ADDRESS, opFetchProcedureAddress); interpreterRegisterOpcode(OPCODE_FETCH_PROCEDURE_ADDRESS, opFetchProcedureAddress);
interpreterRegisterOpcode(OPCODE_DUMP, opDump); interpreterRegisterOpcode(OPCODE_DUMP, opDump);
interpreterRegisterOpcode(OPCODE_IF, opIf); interpreterRegisterOpcode(OPCODE_IF, opIf);

View File

@ -2375,10 +2375,10 @@ bool _obj_occupied(int tile, int elevation)
} }
// 0x48B848 // 0x48B848
Object* _obj_blocking_at(Object* a1, int tile, int elev) Object* _obj_blocking_at(Object* excludeObj, int tile, int elev)
{ {
ObjectListNode* objectListNode; ObjectListNode* objectListNode;
Object* v7; Object* obj;
int type; int type;
if (!hexGridTileIsValid(tile)) { if (!hexGridTileIsValid(tile)) {
@ -2387,14 +2387,14 @@ Object* _obj_blocking_at(Object* a1, int tile, int elev)
objectListNode = gObjectListHeadByTile[tile]; objectListNode = gObjectListHeadByTile[tile];
while (objectListNode != NULL) { while (objectListNode != NULL) {
v7 = objectListNode->obj; obj = objectListNode->obj;
if (v7->elevation == elev) { if (obj->elevation == elev) {
if ((v7->flags & OBJECT_HIDDEN) == 0 && (v7->flags & OBJECT_NO_BLOCK) == 0 && v7 != a1) { if ((obj->flags & OBJECT_HIDDEN) == 0 && (obj->flags & OBJECT_NO_BLOCK) == 0 && obj != excludeObj) {
type = FID_TYPE(v7->fid); type = FID_TYPE(obj->fid);
if (type == OBJ_TYPE_CRITTER if (type == OBJ_TYPE_CRITTER
|| type == OBJ_TYPE_SCENERY || type == OBJ_TYPE_SCENERY
|| type == OBJ_TYPE_WALL) { || type == OBJ_TYPE_WALL) {
return v7; return obj;
} }
} }
} }
@ -2406,15 +2406,15 @@ Object* _obj_blocking_at(Object* a1, int tile, int elev)
if (hexGridTileIsValid(neighboor)) { if (hexGridTileIsValid(neighboor)) {
objectListNode = gObjectListHeadByTile[neighboor]; objectListNode = gObjectListHeadByTile[neighboor];
while (objectListNode != NULL) { while (objectListNode != NULL) {
v7 = objectListNode->obj; obj = objectListNode->obj;
if ((v7->flags & OBJECT_MULTIHEX) != 0) { if ((obj->flags & OBJECT_MULTIHEX) != 0) {
if (v7->elevation == elev) { if (obj->elevation == elev) {
if ((v7->flags & OBJECT_HIDDEN) == 0 && (v7->flags & OBJECT_NO_BLOCK) == 0 && v7 != a1) { if ((obj->flags & OBJECT_HIDDEN) == 0 && (obj->flags & OBJECT_NO_BLOCK) == 0 && obj != excludeObj) {
type = FID_TYPE(v7->fid); type = FID_TYPE(obj->fid);
if (type == OBJ_TYPE_CRITTER if (type == OBJ_TYPE_CRITTER
|| type == OBJ_TYPE_SCENERY || type == OBJ_TYPE_SCENERY
|| type == OBJ_TYPE_WALL) { || type == OBJ_TYPE_WALL) {
return v7; return obj;
} }
} }
} }
@ -2428,7 +2428,7 @@ Object* _obj_blocking_at(Object* a1, int tile, int elev)
} }
// 0x48B930 // 0x48B930
Object* _obj_shoot_blocking_at(Object* obj, int tile, int elev) Object* _obj_shoot_blocking_at(Object* excludeObj, int tile, int elev)
{ {
if (!hexGridTileIsValid(tile)) { if (!hexGridTileIsValid(tile)) {
return NULL; return NULL;
@ -2439,7 +2439,7 @@ Object* _obj_shoot_blocking_at(Object* obj, int tile, int elev)
Object* candidate = objectListItem->obj; Object* candidate = objectListItem->obj;
if (candidate->elevation == elev) { if (candidate->elevation == elev) {
unsigned int flags = candidate->flags; unsigned int flags = candidate->flags;
if ((flags & OBJECT_HIDDEN) == 0 && ((flags & OBJECT_NO_BLOCK) == 0 || (flags & OBJECT_SHOOT_THRU) == 0) && candidate != obj) { if ((flags & OBJECT_HIDDEN) == 0 && ((flags & OBJECT_NO_BLOCK) == 0 || (flags & OBJECT_SHOOT_THRU) == 0) && candidate != excludeObj) {
int type = FID_TYPE(candidate->fid); int type = FID_TYPE(candidate->fid);
// SFALL: Fix to prevent corpses from blocking line of fire. // SFALL: Fix to prevent corpses from blocking line of fire.
if ((type == OBJ_TYPE_CRITTER && !critterIsDead(candidate)) if ((type == OBJ_TYPE_CRITTER && !critterIsDead(candidate))
@ -2464,7 +2464,7 @@ Object* _obj_shoot_blocking_at(Object* obj, int tile, int elev)
unsigned int flags = candidate->flags; unsigned int flags = candidate->flags;
if ((flags & OBJECT_MULTIHEX) != 0) { if ((flags & OBJECT_MULTIHEX) != 0) {
if (candidate->elevation == elev) { if (candidate->elevation == elev) {
if ((flags & OBJECT_HIDDEN) == 0 && (flags & OBJECT_NO_BLOCK) == 0 && candidate != obj) { if ((flags & OBJECT_HIDDEN) == 0 && (flags & OBJECT_NO_BLOCK) == 0 && candidate != excludeObj) {
int type = FID_TYPE(candidate->fid); int type = FID_TYPE(candidate->fid);
// SFALL: Fix to prevent corpses from blocking line of // SFALL: Fix to prevent corpses from blocking line of
// fire. // fire.
@ -2484,7 +2484,7 @@ Object* _obj_shoot_blocking_at(Object* obj, int tile, int elev)
} }
// 0x48BA20 // 0x48BA20
Object* _obj_ai_blocking_at(Object* a1, int tile, int elevation) Object* _obj_ai_blocking_at(Object* excludeObj, int tile, int elevation)
{ {
if (!hexGridTileIsValid(tile)) { if (!hexGridTileIsValid(tile)) {
return NULL; return NULL;
@ -2496,7 +2496,7 @@ Object* _obj_ai_blocking_at(Object* a1, int tile, int elevation)
if (object->elevation == elevation) { if (object->elevation == elevation) {
if ((object->flags & OBJECT_HIDDEN) == 0 if ((object->flags & OBJECT_HIDDEN) == 0
&& (object->flags & OBJECT_NO_BLOCK) == 0 && (object->flags & OBJECT_NO_BLOCK) == 0
&& object != a1) { && object != excludeObj) {
int objectType = FID_TYPE(object->fid); int objectType = FID_TYPE(object->fid);
if (objectType == OBJ_TYPE_CRITTER if (objectType == OBJ_TYPE_CRITTER
|| objectType == OBJ_TYPE_SCENERY || objectType == OBJ_TYPE_SCENERY
@ -2525,7 +2525,7 @@ Object* _obj_ai_blocking_at(Object* a1, int tile, int elevation)
if (object->elevation == elevation) { if (object->elevation == elevation) {
if ((object->flags & OBJECT_HIDDEN) == 0 if ((object->flags & OBJECT_HIDDEN) == 0
&& (object->flags & OBJECT_NO_BLOCK) == 0 && (object->flags & OBJECT_NO_BLOCK) == 0
&& object != a1) { && object != excludeObj) {
int objectType = FID_TYPE(object->fid); int objectType = FID_TYPE(object->fid);
if (objectType == OBJ_TYPE_CRITTER if (objectType == OBJ_TYPE_CRITTER
|| objectType == OBJ_TYPE_SCENERY || objectType == OBJ_TYPE_SCENERY
@ -2571,7 +2571,7 @@ int _obj_scroll_blocking_at(int tile, int elev)
} }
// 0x48BB88 // 0x48BB88
Object* _obj_sight_blocking_at(Object* a1, int tile, int elevation) Object* _obj_sight_blocking_at(Object* excludeObj, int tile, int elevation)
{ {
ObjectListNode* objectListNode = gObjectListHeadByTile[tile]; ObjectListNode* objectListNode = gObjectListHeadByTile[tile];
while (objectListNode != NULL) { while (objectListNode != NULL) {
@ -2579,7 +2579,7 @@ Object* _obj_sight_blocking_at(Object* a1, int tile, int elevation)
if (object->elevation == elevation if (object->elevation == elevation
&& (object->flags & OBJECT_HIDDEN) == 0 && (object->flags & OBJECT_HIDDEN) == 0
&& (object->flags & OBJECT_LIGHT_THRU) == 0 && (object->flags & OBJECT_LIGHT_THRU) == 0
&& object != a1) { && object != excludeObj) {
int objectType = FID_TYPE(object->fid); int objectType = FID_TYPE(object->fid);
if (objectType == OBJ_TYPE_SCENERY || objectType == OBJ_TYPE_WALL) { if (objectType == OBJ_TYPE_SCENERY || objectType == OBJ_TYPE_WALL) {
return object; return object;

View File

@ -71,11 +71,11 @@ Object* objectFindFirstAtLocation(int elevation, int tile);
Object* objectFindNextAtLocation(); Object* objectFindNextAtLocation();
void objectGetRect(Object* obj, Rect* rect); void objectGetRect(Object* obj, Rect* rect);
bool _obj_occupied(int tile_num, int elev); bool _obj_occupied(int tile_num, int elev);
Object* _obj_blocking_at(Object* a1, int tile_num, int elev); Object* _obj_blocking_at(Object* excludeObj, int tile_num, int elev);
Object* _obj_shoot_blocking_at(Object* obj, int tile, int elev); Object* _obj_shoot_blocking_at(Object* excludeObj, int tile, int elev);
Object* _obj_ai_blocking_at(Object* a1, int tile, int elevation); Object* _obj_ai_blocking_at(Object* excludeObj, int tile, int elevation);
int _obj_scroll_blocking_at(int tile_num, int elev); int _obj_scroll_blocking_at(int tile_num, int elev);
Object* _obj_sight_blocking_at(Object* a1, int tile_num, int elev); Object* _obj_sight_blocking_at(Object* excludeObj, int tile_num, int elev);
int objectGetDistanceBetween(Object* object1, Object* object2); int objectGetDistanceBetween(Object* object1, Object* object2);
int objectGetDistanceBetweenTiles(Object* object1, int tile1, Object* object2, int tile2); int objectGetDistanceBetweenTiles(Object* object1, int tile1, Object* object2, int tile2);
int objectListCreate(int tile, int elevation, int objectType, Object*** objectsPtr); int objectListCreate(int tile, int elevation, int objectType, Object*** objectsPtr);