Skip to content

Commit

Permalink
Rename object flags according to Sfall (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanSimek authored Jun 8, 2022
1 parent 9cad93c commit e27f72f
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 104 deletions.
4 changes: 2 additions & 2 deletions src/actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ int _compute_explosion_damage(int min, int max, Object* a3, int* a4)
}

if (a4 != NULL) {
if ((a3->flags & OBJECT_FLAG_0x800) == 0) {
if ((a3->flags & OBJECT_MULTIHEX) == 0) {
*a4 = v7 / 10;
}
}
Expand Down Expand Up @@ -1892,7 +1892,7 @@ int _compute_dmg_damage(int min, int max, Object* obj, int* a4, int damageType)
}

if (a4 != NULL) {
if ((obj->flags & OBJECT_FLAG_0x800) == 0 && damageType != DAMAGE_TYPE_ELECTRICAL) {
if ((obj->flags & OBJECT_MULTIHEX) == 0 && damageType != DAMAGE_TYPE_ELECTRICAL) {
*a4 = v10 / 10;
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/animation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4,
if (a5 != NULL) {
Object* v11 = a7(a1, from, a1->elevation);
if (v11 != NULL) {
if (v11 != *a5 && (a6 != 32 || (v11->flags & OBJECT_FLAG_0x80000000) == 0)) {
if (v11 != *a5 && (a6 != 32 || (v11->flags & OBJECT_SHOOT_THRU) == 0)) {
*a5 = v11;
return 0;
}
Expand Down Expand Up @@ -1774,7 +1774,7 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4,
if (a5 != NULL) {
Object* obj = a7(a1, tile, a1->elevation);
if (obj != NULL) {
if (obj != *a5 && (a6 != 32 || (obj->flags & OBJECT_FLAG_0x80000000) == 0)) {
if (obj != *a5 && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
*a5 = obj;
break;
}
Expand Down Expand Up @@ -1827,7 +1827,7 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4,
if (a5 != NULL) {
Object* obj = a7(a1, tile, a1->elevation);
if (obj != NULL) {
if (obj != *a5 && (a6 != 32 || (obj->flags & OBJECT_FLAG_0x80000000) == 0)) {
if (obj != *a5 && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
*a5 = obj;
break;
}
Expand Down Expand Up @@ -1864,35 +1864,35 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4,
}

// 0x4167F8
int animateMoveObjectToObject(Object* a1, Object* a2, int a3, int anim, int animationSequenceIndex)
int animateMoveObjectToObject(Object* from, Object* to, int a3, int anim, int animationSequenceIndex)
{
int v10;
int v13;
STRUCT_530014* ptr;

int hidden = (a2->flags & OBJECT_HIDDEN);
a2->flags |= OBJECT_HIDDEN;
int hidden = (to->flags & OBJECT_HIDDEN);
to->flags |= OBJECT_HIDDEN;

v10 = _anim_move(a1, a2->tile, a2->elevation, -1, anim, 0, animationSequenceIndex);
v10 = _anim_move(from, to->tile, to->elevation, -1, anim, 0, animationSequenceIndex);

if (hidden == 0) {
a2->flags &= ~OBJECT_HIDDEN;
to->flags &= ~OBJECT_HIDDEN;
}

if (v10 == -1) {
return -1;
}

ptr = &(_sad[v10]);
v13 = (((a1->flags & OBJECT_FLAG_0x800) != 0) + 1); // TODO: What the hell is this?
v13 = (((from->flags & OBJECT_MULTIHEX) != 0) + 1); // TODO: What the hell is this?
ptr->field_1C -= v13;
if (ptr->field_1C <= 0) {
ptr->field_20 = -1000;
_anim_set_continue(animationSequenceIndex, 0);
}

if (v13) {
ptr->field_24 = tileGetTileInDirection(a2->tile, ptr->field_24 + v13 + ptr->field_1C + 3, 1);
ptr->field_24 = tileGetTileInDirection(to->tile, ptr->field_24 + v13 + ptr->field_1C + 3, 1);
}

if (v13 == 2) {
Expand Down
2 changes: 1 addition & 1 deletion src/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int _idist(int a1, int a2, int a3, int a4);
int _tile_idistance(int tile1, int tile2);
int _make_straight_path(Object* a1, int from, int to, STRUCT_530014_28* pathNodes, Object** a5, int a6);
int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4, Object** a5, int a6, Object* (*a7)(Object*, int, int));
int animateMoveObjectToObject(Object* a1, Object* a2, int a3, int a4, int a5);
int animateMoveObjectToObject(Object* from, Object* to, int a3, int a4, int a5);
int animateMoveObjectToTile(Object* obj, int tile_num, int elev, int a4, int a5, int a6);
int _anim_move(Object* obj, int tile, int elev, int a3, int a4, int a5, int animationSequenceIndex);
int _anim_move_straight_to_tile(Object* obj, int a2, int a3, int fid, int a5, int a6);
Expand Down
4 changes: 2 additions & 2 deletions src/automap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ void automapRenderInMapWindow(int window, int elevation, unsigned char* backgrou
&& (object->data.critter.combat.results & DAM_DEAD) == 0) {
objectColor = _colorTable[31744];
} else {
if ((object->flags & OBJECT_FLAG_0x40000000) == 0) {
if ((object->flags & OBJECT_SEEN) == 0) {
continue;
}

Expand Down Expand Up @@ -1011,7 +1011,7 @@ void _decode_map_data(int elevation)

Object* object = objectFindFirstAtElevation(elevation);
while (object != NULL) {
if (object->tile != -1 && (object->flags & OBJECT_FLAG_0x40000000) != 0) {
if (object->tile != -1 && (object->flags & OBJECT_SEEN) != 0) {
int contentType;

int objectType = (object->fid & 0xF000000) >> 24;
Expand Down
18 changes: 9 additions & 9 deletions src/combat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2542,7 +2542,7 @@ void _combat_update_critter_outline_for_los(Object* critter, bool a2)
} else {
int v7 = objectGetDistanceBetween(gDude, critter);
int v8 = critterGetStat(gDude, STAT_PERCEPTION) * 5;
if ((critter->flags & OBJECT_FLAG_0x20000) != 0) {
if ((critter->flags & OBJECT_TRANS_GLASS) != 0) {
v8 /= 2;
}

Expand Down Expand Up @@ -3382,7 +3382,7 @@ bool _check_ranged_miss(Attack* attack)
while (curr != to) {
_make_straight_path_func(attack->attacker, curr, to, NULL, &critter, 32, _obj_shoot_blocking_at);
if (critter != NULL) {
if ((critter->flags & OBJECT_FLAG_0x80000000) == 0) {
if ((critter->flags & OBJECT_SHOOT_THRU) == 0) {
if ((critter->fid & 0xF000000) >> 24 != OBJ_TYPE_CRITTER) {
roll = ROLL_SUCCESS;
break;
Expand Down Expand Up @@ -3412,7 +3412,7 @@ bool _check_ranged_miss(Attack* attack)

attack->defenderHitLocation = HIT_LOCATION_TORSO;

if (roll < ROLL_SUCCESS || critter == NULL || (critter->flags & OBJECT_FLAG_0x80000000) == 0) {
if (roll < ROLL_SUCCESS || critter == NULL || (critter->flags & OBJECT_SHOOT_THRU) == 0) {
return false;
}

Expand Down Expand Up @@ -3747,7 +3747,7 @@ int attackCompute(Attack* attack)
v25 = _obj_blocking_at(NULL, attack->tile, attack->defender->elevation);
}

if (v25 != NULL && (v25->flags & OBJECT_FLAG_0x80000000) == 0) {
if (v25 != NULL && (v25->flags & OBJECT_SHOOT_THRU) == 0) {
attack->attackerFlags |= DAM_HIT;
attack->defender = v25;
attackComputeDamage(attack, 1, 2);
Expand Down Expand Up @@ -3834,7 +3834,7 @@ void _compute_explosion_on_extras(Attack* attack, int a2, int a3, int a4)
if (v11 != NULL
&& (v11->fid & 0xF000000) >> 24 == OBJ_TYPE_CRITTER
&& (v11->data.critter.combat.results & DAM_DEAD) == 0
&& (v11->flags & OBJECT_FLAG_0x80000000) == 0
&& (v11->flags & OBJECT_SHOOT_THRU) == 0
&& !_combat_is_shot_blocked(v11, v11->tile, tile, NULL, NULL)) {
if (v11 == attack->attacker) {
attack->attackerFlags &= ~DAM_HIT;
Expand Down Expand Up @@ -4224,7 +4224,7 @@ int attackDetermineToHit(Object* attacker, int tile, Object* defender, int hitLo
accuracy += _hit_location_penalty[hitLocation] / 2;
}

if (defender != NULL && (defender->flags & OBJECT_FLAG_0x800) != 0) {
if (defender != NULL && (defender->flags & OBJECT_MULTIHEX) != 0) {
accuracy += 15;
}

Expand Down Expand Up @@ -4406,7 +4406,7 @@ void attackComputeDamage(Attack* attack, int ammoQuantity, int a3)
}

if (knockbackDistancePtr != NULL
&& (critter->flags & OBJECT_FLAG_0x800) == 0
&& (critter->flags & OBJECT_MULTIHEX) == 0
&& (damageType == DAMAGE_TYPE_EXPLOSION || attack->weapon == NULL || weaponGetAttackTypeForHitMode(attack->weapon, attack->hitMode) == ATTACK_TYPE_MELEE)
&& (critter->pid >> 24) == OBJ_TYPE_CRITTER
&& _critter_flag_check(critter->pid, 0x4000) == 0) {
Expand Down Expand Up @@ -5686,15 +5686,15 @@ bool _combat_is_shot_blocked(Object* a1, int from, int to, Object* a4, int* a5)
if ((obstacle->data.critter.combat.results & (DAM_DEAD | DAM_KNOCKED_DOWN | DAM_KNOCKED_OUT)) == 0) {
*a5 += 1;

if ((obstacle->flags & OBJECT_FLAG_0x800) != 0) {
if ((obstacle->flags & OBJECT_MULTIHEX) != 0) {
*a5 += 1;
}
}
}
}
}

if ((obstacle->flags & OBJECT_FLAG_0x800) != 0) {
if ((obstacle->flags & OBJECT_MULTIHEX) != 0) {
int rotation = tileGetRotationTo(current, to);
current = tileGetTileInDirection(current, rotation, 1);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/combat_ai.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2143,13 +2143,13 @@ int _ai_move_steps_closer(Object* a1, Object* a2, int actionPoints, int a4)
}

if (actionPoints >= critterGetStat(a1, STAT_MAXIMUM_ACTION_POINTS) / 2 && artCritterFidShouldRun(a1->fid)) {
if ((a2->flags & OBJECT_FLAG_0x800) != 0) {
if ((a2->flags & OBJECT_MULTIHEX) != 0) {
reg_anim_obj_run_to_obj(a1, a2, actionPoints, 0);
} else {
reg_anim_obj_run_to_tile(a1, tile, a1->elevation, actionPoints, 0);
}
} else {
if ((a2->flags & OBJECT_FLAG_0x800) != 0) {
if ((a2->flags & OBJECT_MULTIHEX) != 0) {
reg_anim_obj_move_to_obj(a1, a2, actionPoints, 0);
} else {
reg_anim_obj_move_to_tile(a1, tile, a1->elevation, actionPoints, 0);
Expand Down Expand Up @@ -3198,7 +3198,7 @@ bool objectCanHearObject(Object* a1, Object* a2)
int sneak = skillGetValue(a2, SKILL_SNEAK);
if (_can_see(a1, a2)) {
int v8 = perception * 5;
if ((a2->flags & OBJECT_FLAG_0x20000) != 0) {
if ((a2->flags & OBJECT_TRANS_GLASS) != 0) {
v8 /= 2;
}

Expand Down
8 changes: 4 additions & 4 deletions src/game_mouse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1927,16 +1927,16 @@ int gameMouseObjectsInit()
return -1;
}

gGameMouseBouncingCursor->flags |= OBJECT_FLAG_0x20000000;
gGameMouseBouncingCursor->flags |= OBJECT_LIGHT_THRU;
gGameMouseBouncingCursor->flags |= OBJECT_TEMPORARY;
gGameMouseBouncingCursor->flags |= OBJECT_FLAG_0x400;
gGameMouseBouncingCursor->flags |= OBJECT_FLAG_0x80000000;
gGameMouseBouncingCursor->flags |= OBJECT_SHOOT_THRU;
gGameMouseBouncingCursor->flags |= OBJECT_NO_BLOCK;

gGameMouseHexCursor->flags |= OBJECT_FLAG_0x400;
gGameMouseHexCursor->flags |= OBJECT_TEMPORARY;
gGameMouseHexCursor->flags |= OBJECT_FLAG_0x20000000;
gGameMouseHexCursor->flags |= OBJECT_FLAG_0x80000000;
gGameMouseHexCursor->flags |= OBJECT_LIGHT_THRU;
gGameMouseHexCursor->flags |= OBJECT_SHOOT_THRU;
gGameMouseHexCursor->flags |= OBJECT_NO_BLOCK;

_obj_toggle_flat(gGameMouseHexCursor, NULL);
Expand Down
16 changes: 8 additions & 8 deletions src/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,11 @@ bool _item_identical(Object* a1, Object* a2)
return false;
}

if ((a1->flags & (OBJECT_EQUIPPED | OBJECT_FLAG_0x2000)) != 0) {
if ((a1->flags & (OBJECT_EQUIPPED | OBJECT_USED)) != 0) {
return false;
}

if ((a2->flags & (OBJECT_EQUIPPED | OBJECT_FLAG_0x2000)) != 0) {
if ((a2->flags & (OBJECT_EQUIPPED | OBJECT_USED)) != 0) {
return false;
}

Expand Down Expand Up @@ -989,14 +989,14 @@ int _item_queued(Object* obj)
return false;
}

if ((obj->flags & OBJECT_FLAG_0x2000) != 0) {
if ((obj->flags & OBJECT_USED) != 0) {
return true;
}

Inventory* inventory = &(obj->data.inventory);
for (int index = 0; index < inventory->length; index++) {
InventoryItem* inventoryItem = &(inventory->items[index]);
if ((inventoryItem->item->flags & OBJECT_FLAG_0x2000) != 0) {
if ((inventoryItem->item->flags & OBJECT_USED) != 0) {
return true;
}

Expand Down Expand Up @@ -2402,11 +2402,11 @@ int _item_m_turn_off_from_queue(Object* obj, void* data)
// 0x479960
int stealthBoyTurnOn(Object* object)
{
if ((object->flags & OBJECT_FLAG_0x20000) != 0) {
if ((object->flags & OBJECT_TRANS_GLASS) != 0) {
return -1;
}

object->flags |= OBJECT_FLAG_0x20000;
object->flags |= OBJECT_TRANS_GLASS;

Rect rect;
objectGetRect(object, &rect);
Expand All @@ -2428,11 +2428,11 @@ int stealthBoyTurnOff(Object* critter, Object* item)
return -1;
}

if ((critter->flags & OBJECT_FLAG_0x20000) == 0) {
if ((critter->flags & OBJECT_TRANS_GLASS) == 0) {
return -1;
}

critter->flags &= ~OBJECT_FLAG_0x20000;
critter->flags &= ~OBJECT_TRANS_GLASS;

Rect rect;
objectGetRect(critter, &rect);
Expand Down
4 changes: 2 additions & 2 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ int falloutMain(int argc, char** argv)
mainMenuWindowHide(true);
mainMenuWindowFree();
_game_user_wants_to_quit = 0;
gDude->flags &= ~OBJECT_FLAG_0x08;
gDude->flags &= ~OBJECT_FLAT;
_main_show_death_scene = 0;
objectShow(gDude, NULL);
mouseHideCursor();
Expand Down Expand Up @@ -301,7 +301,7 @@ int _main_load_new(char* mapFileName)
{
_game_user_wants_to_quit = 0;
_main_show_death_scene = 0;
gDude->flags &= ~OBJECT_FLAG_0x08;
gDude->flags &= ~OBJECT_FLAT;
objectShow(gDude, NULL);
mouseHideCursor();

Expand Down
2 changes: 1 addition & 1 deletion src/map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ int mapLoad(File* stream)
Object* object;
int fid = buildFid(5, 12, 0, 0, 0);
objectCreateWithFidPid(&object, fid, -1);
object->flags |= (OBJECT_FLAG_0x20000000 | OBJECT_TEMPORARY | OBJECT_HIDDEN);
object->flags |= (OBJECT_LIGHT_THRU | OBJECT_TEMPORARY | OBJECT_HIDDEN);
objectSetLocation(object, 1, 0, NULL);
object->sid = gMapSid;
scriptSetFixedParam(gMapSid, (gMapHeader.flags & 1) == 0);
Expand Down
34 changes: 17 additions & 17 deletions src/obj_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@ typedef enum OutlineType {
typedef enum ObjectFlags {
OBJECT_HIDDEN = 0x01,
OBJECT_TEMPORARY = 0x04,
OBJECT_FLAG_0x08 = 0x08,
OBJECT_FLAT = 0x08,
OBJECT_NO_BLOCK = 0x10,
OBJECT_LIGHTING = 0x20,
OBJECT_FLAG_0x400 = 0x400,
OBJECT_FLAG_0x800 = 0x800,
OBJECT_FLAG_0x1000 = 0x1000,
OBJECT_FLAG_0x2000 = 0x2000,
OBJECT_FLAG_0x4000 = 0x4000,
OBJECT_FLAG_0x8000 = 0x8000,
OBJECT_FLAG_0x10000 = 0x10000,
OBJECT_FLAG_0x20000 = 0x20000,
OBJECT_FLAG_0x40000 = 0x40000,
OBJECT_FLAG_0x80000 = 0x80000,
OBJECT_FLAG_0x400 = 0x400, // ???
OBJECT_MULTIHEX = 0x800,
OBJECT_NO_HIGHLIGHT = 0x1000,
OBJECT_USED = 0x2000, // set if there was/is any event for the object
OBJECT_TRANS_RED = 0x4000,
OBJECT_TRANS_NONE = 0x8000,
OBJECT_TRANS_WALL = 0x10000,
OBJECT_TRANS_GLASS = 0x20000,
OBJECT_TRANS_STEAM = 0x40000,
OBJECT_TRANS_ENERGY = 0x80000,
OBJECT_IN_LEFT_HAND = 0x1000000,
OBJECT_IN_RIGHT_HAND = 0x2000000,
OBJECT_WORN = 0x4000000,
OBJECT_FLAG_0x10000000 = 0x10000000,
OBJECT_FLAG_0x20000000 = 0x20000000,
OBJECT_FLAG_0x40000000 = 0x40000000,
OBJECT_FLAG_0x80000000 = 0x80000000,
OBJECT_WALL_TRANS_END = 0x10000000,
OBJECT_LIGHT_THRU = 0x20000000,
OBJECT_SEEN = 0x40000000,
OBJECT_SHOOT_THRU = 0x80000000,

OBJECT_IN_ANY_HAND = OBJECT_IN_LEFT_HAND | OBJECT_IN_RIGHT_HAND,
OBJECT_EQUIPPED = OBJECT_IN_ANY_HAND | OBJECT_WORN,
OBJECT_FLAG_0xFC000 = OBJECT_FLAG_0x80000 | OBJECT_FLAG_0x40000 | OBJECT_FLAG_0x20000 | OBJECT_FLAG_0x10000 | OBJECT_FLAG_0x8000 | OBJECT_FLAG_0x4000,
OBJECT_OPEN_DOOR = OBJECT_FLAG_0x80000000 | OBJECT_FLAG_0x20000000 | OBJECT_NO_BLOCK,
OBJECT_FLAG_0xFC000 = OBJECT_TRANS_ENERGY | OBJECT_TRANS_STEAM | OBJECT_TRANS_GLASS | OBJECT_TRANS_WALL | OBJECT_TRANS_NONE | OBJECT_TRANS_RED,
OBJECT_OPEN_DOOR = OBJECT_SHOOT_THRU | OBJECT_LIGHT_THRU | OBJECT_NO_BLOCK,
} ObjectFlags;

#define OUTLINE_TYPE_MASK 0xFFFFFF
Expand Down
Loading

0 comments on commit e27f72f

Please sign in to comment.