From 8754a5d6c9414aa914e887b086e71b86a78f36b6 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Wed, 5 Oct 2022 13:06:49 +0300 Subject: [PATCH] Rename critter flags --- src/actions.cc | 12 ++++++------ src/combat.cc | 14 +++++++------- src/critter.cc | 8 ++++---- src/game_dialog.cc | 4 ++-- src/game_mouse.cc | 4 ++-- src/interpreter_extra.cc | 2 +- src/inventory.cc | 2 +- src/item.cc | 2 +- src/map.cc | 8 ++++---- src/obj_types.h | 24 +++++++++++++----------- 10 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/actions.cc b/src/actions.cc index 87a2999..133c39e 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -96,7 +96,7 @@ static int _compute_dmg_damage(int min, int max, Object* obj, int* a4, int damag // 0x410468 int actionKnockdown(Object* obj, int* anim, int maxDistance, int rotation, int delay) { - if (_critter_flag_check(obj->pid, CRITTER_FLAG_0x4000)) { + if (_critter_flag_check(obj->pid, CRITTER_NO_KNOCKBACK)) { return -1; } @@ -196,7 +196,7 @@ int _pick_death(Object* attacker, Object* defender, Object* weapon, int damage, int violenceLevel = VIOLENCE_LEVEL_MAXIMUM_BLOOD; configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_VIOLENCE_LEVEL_KEY, &violenceLevel); - if (_critter_flag_check(defender->pid, CRITTER_FLAG_0x1000)) { + if (_critter_flag_check(defender->pid, CRITTER_SPECIAL_DEATH)) { return _check_death(defender, ANIM_EXPLODED_TO_NOTHING, VIOLENCE_LEVEL_NORMAL, isFallingBack); } @@ -287,7 +287,7 @@ void _show_damage_to_object(Object* a1, int damage, int flags, Object* weapon, b int fid; const char* sfx_name; - if (_critter_flag_check(a1->pid, CRITTER_FLAG_0x4000)) { + if (_critter_flag_check(a1->pid, CRITTER_NO_KNOCKBACK)) { knockbackDistance = 0; } @@ -463,7 +463,7 @@ int _show_death(Object* obj, int anim) } } - if (_critter_flag_check(obj->pid, CRITTER_FLAG_0x800) == 0) { + if (!_critter_flag_check(obj->pid, CRITTER_FLAT)) { obj->flags |= OBJECT_NO_BLOCK; if (_obj_toggle_flat(obj, &v7) == 0) { rectUnion(&v8, &v7, &v8); @@ -474,7 +474,7 @@ int _show_death(Object* obj, int anim) rectUnion(&v8, &v7, &v8); } - if (anim >= 30 && anim <= 31 && _critter_flag_check(obj->pid, CRITTER_FLAG_0x1000) == 0 && _critter_flag_check(obj->pid, CRITTER_FLAG_0x40) == 0) { + if (anim >= 30 && anim <= 31 && !_critter_flag_check(obj->pid, CRITTER_SPECIAL_DEATH) && !_critter_flag_check(obj->pid, CRITTER_NO_DROP)) { itemDropAll(obj, obj->tile); } @@ -1960,7 +1960,7 @@ int _report_dmg(Attack* attack, Object* a2) // 0x413660 int _compute_dmg_damage(int min, int max, Object* obj, int* a4, int damageType) { - if (!_critter_flag_check(obj->pid, CRITTER_FLAG_0x4000)) { + if (!_critter_flag_check(obj->pid, CRITTER_NO_KNOCKBACK)) { a4 = NULL; } diff --git a/src/combat.cc b/src/combat.cc index caf5f11..263fbb4 100644 --- a/src/combat.cc +++ b/src/combat.cc @@ -4069,7 +4069,7 @@ void _compute_explosion_on_extras(Attack* attack, int a2, bool isGrenade, int a4 static int attackComputeCriticalHit(Attack* attack) { Object* defender = attack->defender; - if (defender != NULL && _critter_flag_check(defender->pid, CRITTER_FLAG_0x400)) { + if (defender != NULL && _critter_flag_check(defender->pid, CRITTER_INVULNERABLE)) { return 2; } @@ -4143,7 +4143,7 @@ static int _attackFindInvalidFlags(Object* critter, Object* item) { int flags = 0; - if (critter != NULL && PID_TYPE(critter->pid) == OBJ_TYPE_CRITTER && _critter_flag_check(critter->pid, CRITTER_FLAG_0x40)) { + if (critter != NULL && PID_TYPE(critter->pid) == OBJ_TYPE_CRITTER && _critter_flag_check(critter->pid, CRITTER_NO_DROP)) { flags |= DAM_DROP; } @@ -4159,7 +4159,7 @@ static int attackComputeCriticalFailure(Attack* attack) { attack->attackerFlags |= DAM_HIT; - if (attack->attacker != NULL && _critter_flag_check(attack->attacker->pid, CRITTER_FLAG_0x400)) { + if (attack->attacker != NULL && _critter_flag_check(attack->attacker->pid, CRITTER_INVULNERABLE)) { return 0; } @@ -4620,7 +4620,7 @@ static void attackComputeDamage(Attack* attack, int ammoQuantity, int bonusDamag && (critter->flags & OBJECT_MULTIHEX) == 0 && (damageType == DAMAGE_TYPE_EXPLOSION || attack->weapon == NULL || weaponGetAttackTypeForHitMode(attack->weapon, attack->hitMode) == ATTACK_TYPE_MELEE) && PID_TYPE(critter->pid) == OBJ_TYPE_CRITTER - && _critter_flag_check(critter->pid, CRITTER_FLAG_0x4000) == 0) { + && !_critter_flag_check(critter->pid, CRITTER_NO_KNOCKBACK)) { bool shouldKnockback = true; bool hasStonewall = false; if (critter == gDude) { @@ -4751,7 +4751,7 @@ void _apply_damage(Attack* attack, bool animated) // 0x424EE8 static void _check_for_death(Object* object, int damage, int* flags) { - if (object == NULL || !_critter_flag_check(object->pid, CRITTER_FLAG_0x400)) { + if (object == NULL || !_critter_flag_check(object->pid, CRITTER_INVULNERABLE)) { if (object == NULL || PID_TYPE(object->pid) == OBJ_TYPE_CRITTER) { if (damage > 0) { if (critterGetHitPoints(object) - damage <= 0) { @@ -4773,7 +4773,7 @@ static void _set_new_results(Object* critter, int flags) return; } - if (_critter_flag_check(critter->pid, CRITTER_FLAG_0x400)) { + if (_critter_flag_check(critter->pid, CRITTER_INVULNERABLE)) { return; } @@ -4811,7 +4811,7 @@ static void _damage_object(Object* a1, int damage, bool animated, int a4, Object return; } - if (_critter_flag_check(a1->pid, CRITTER_FLAG_0x400)) { + if (_critter_flag_check(a1->pid, CRITTER_INVULNERABLE)) { return; } diff --git a/src/critter.cc b/src/critter.cc index d61c261..f351e5a 100644 --- a/src/critter.cc +++ b/src/critter.cc @@ -422,7 +422,7 @@ int critterAdjustRadiation(Object* obj, int amount) } if (amount > 0) { - proto->critter.data.flags |= CRITTER_FLAG_0x2; + proto->critter.data.flags |= CRITTER_RADIATED; } if (amount > 0) { @@ -489,7 +489,7 @@ int _critter_check_rads(Object* obj) Proto* proto; protoGetProto(obj->pid, &proto); - if ((proto->critter.data.flags & CRITTER_FLAG_0x2) == 0) { + if ((proto->critter.data.flags & CRITTER_RADIATED) == 0) { return 0; } @@ -530,7 +530,7 @@ int _critter_check_rads(Object* obj) queueAddEvent(GAME_TIME_TICKS_PER_HOUR * randomBetween(4, 18), obj, radiationEvent, EVENT_TYPE_RADIATION); } - proto->critter.data.flags &= ~(CRITTER_FLAG_0x2); + proto->critter.data.flags &= ~CRITTER_RADIATED; return 0; } @@ -876,7 +876,7 @@ void critterKill(Object* critter, int anim, bool a3) rectUnion(&updatedRect, &tempRect, &updatedRect); } - if (!_critter_flag_check(critter->pid, CRITTER_FLAG_0x800)) { + if (!_critter_flag_check(critter->pid, CRITTER_FLAT)) { critter->flags |= OBJECT_NO_BLOCK; _obj_toggle_flat(critter, &tempRect); } diff --git a/src/game_dialog.cc b/src/game_dialog.cc index 7098f26..d6ca346 100644 --- a/src/game_dialog.cc +++ b/src/game_dialog.cc @@ -3594,7 +3594,7 @@ int _gdCanBarter() return 1; } - if (proto->critter.data.flags & CRITTER_FLAG_0x2) { + if (proto->critter.data.flags & CRITTER_BARTER) { return 1; } @@ -4194,7 +4194,7 @@ void gameDialogBarterButtonUpMouseUp(int btn, int keyCode) Proto* proto; protoGetProto(gGameDialogSpeaker->pid, &proto); - if (proto->critter.data.flags & CRITTER_FLAG_0x2) { + if (proto->critter.data.flags & CRITTER_BARTER) { if (gGameDialogLipSyncStarted) { if (soundIsPlaying(gLipsData.sound)) { gameDialogEndLips(); diff --git a/src/game_mouse.cc b/src/game_mouse.cc index a43a92e..424d138 100644 --- a/src/game_mouse.cc +++ b/src/game_mouse.cc @@ -692,7 +692,7 @@ void gameMouseRefresh() primaryAction = GAME_MOUSE_ACTION_MENU_ITEM_TALK; } } else { - if (_critter_flag_check(pointedObject->pid, CRITTER_FLAG_0x20)) { + if (_critter_flag_check(pointedObject->pid, CRITTER_NO_STEAL)) { primaryAction = GAME_MOUSE_ACTION_MENU_ITEM_LOOK; } else { primaryAction = GAME_MOUSE_ACTION_MENU_ITEM_USE; @@ -1096,7 +1096,7 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState) actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_TALK; } } else { - if (!_critter_flag_check(v16->pid, CRITTER_FLAG_0x20)) { + if (!_critter_flag_check(v16->pid, CRITTER_NO_STEAL)) { actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_USE; } } diff --git a/src/interpreter_extra.cc b/src/interpreter_extra.cc index e54ce4e..077ce6c 100644 --- a/src/interpreter_extra.cc +++ b/src/interpreter_extra.cc @@ -3314,7 +3314,7 @@ static void opMetarule(Program* program) if (PID_TYPE(object->pid) == OBJ_TYPE_CRITTER) { Proto* proto; protoGetProto(object->pid, &proto); - if ((proto->critter.data.flags & CRITTER_FLAG_0x2) != 0) { + if ((proto->critter.data.flags & CRITTER_BARTER) != 0) { result = 1; } } diff --git a/src/inventory.cc b/src/inventory.cc index 1f2ee80..9e1251a 100644 --- a/src/inventory.cc +++ b/src/inventory.cc @@ -4020,7 +4020,7 @@ int inventoryOpenLooting(Object* a1, Object* a2) } if (FID_TYPE(a2->fid) == OBJ_TYPE_CRITTER) { - if (_critter_flag_check(a2->pid, CRITTER_FLAG_0x20)) { + if (_critter_flag_check(a2->pid, CRITTER_NO_STEAL)) { // You can't find anything to take from that. messageListItem.num = 50; if (messageListGetItem(&gInventoryMessageList, &messageListItem)) { diff --git a/src/item.cc b/src/item.cc index 383fd18..735f635 100644 --- a/src/item.cc +++ b/src/item.cc @@ -1607,7 +1607,7 @@ int weaponGetRange(Object* critter, int hitMode) return range; } - if (_critter_flag_check(critter->pid, CRITTER_FLAG_0x2000)) { + if (_critter_flag_check(critter->pid, CRITTER_LONG_LIMBS)) { return 2; } diff --git a/src/map.cc b/src/map.cc index fe809ad..575143d 100644 --- a/src/map.cc +++ b/src/map.cc @@ -1082,7 +1082,7 @@ static int _map_age_dead_critters() && !objectIsPartyMember(obj) && !critterIsDead(obj)) { obj->data.critter.combat.maneuver &= ~CRITTER_MANUEVER_FLEEING; - if (critterGetKillType(obj) != KILL_TYPE_ROBOT && _critter_flag_check(obj->pid, CRITTER_FLAG_0x200) == 0) { + if (critterGetKillType(obj) != KILL_TYPE_ROBOT && !_critter_flag_check(obj->pid, CRITTER_NO_HEAL)) { _critter_heal_hours(obj, hoursSinceLastVisit); } } @@ -1107,7 +1107,7 @@ static int _map_age_dead_critters() int type = PID_TYPE(obj->pid); if (type == OBJ_TYPE_CRITTER) { if (obj != gDude && critterIsDead(obj)) { - if (critterGetKillType(obj) != KILL_TYPE_ROBOT && _critter_flag_check(obj->pid, CRITTER_FLAG_0x200) == 0) { + if (critterGetKillType(obj) != KILL_TYPE_ROBOT && !_critter_flag_check(obj->pid, CRITTER_NO_HEAL)) { objects[count++] = obj; if (count >= capacity) { @@ -1138,7 +1138,7 @@ static int _map_age_dead_critters() for (int index = 0; index < count; index++) { Object* obj = objects[index]; if (PID_TYPE(obj->pid) == OBJ_TYPE_CRITTER) { - if (_critter_flag_check(obj->pid, CRITTER_FLAG_0x40) == 0) { + if (!_critter_flag_check(obj->pid, CRITTER_NO_DROP)) { itemDropAll(obj, obj->tile); } @@ -1154,7 +1154,7 @@ static int _map_age_dead_critters() protoGetProto(obj->pid, &proto); int frame = randomBetween(0, 3); - if ((proto->critter.flags & 0x800)) { + if ((proto->critter.flags & CRITTER_FLAT)) { frame += 6; } else { if (critterGetKillType(obj) != KILL_TYPE_RAT diff --git a/src/obj_types.h b/src/obj_types.h index 28824dc..158d789 100644 --- a/src/obj_types.h +++ b/src/obj_types.h @@ -73,19 +73,21 @@ typedef enum ObjectFlags { } ObjectFlags; typedef enum CritterFlags { - CRITTER_FLAG_0x2 = 0x2, - CRITTER_FLAG_0x20 = 0x20, - CRITTER_FLAG_0x40 = 0x40, - CRITTER_FLAG_0x80 = 0x80, - CRITTER_FLAG_0x100 = 0x100, - CRITTER_FLAG_0x200 = 0x200, - CRITTER_FLAG_0x400 = 0x400, - CRITTER_FLAG_0x800 = 0x800, - CRITTER_FLAG_0x1000 = 0x1000, - CRITTER_FLAG_0x2000 = 0x2000, - CRITTER_FLAG_0x4000 = 0x4000, + CRITTER_BARTER = 0x02, + CRITTER_NO_STEAL = 0x20, + CRITTER_NO_DROP = 0x40, + CRITTER_NO_LIMBS = 0x80, + CRITTER_NO_AGE = 0x100, + CRITTER_NO_HEAL = 0x200, + CRITTER_INVULNERABLE = 0x400, + CRITTER_FLAT = 0x800, + CRITTER_SPECIAL_DEATH = 0x1000, + CRITTER_LONG_LIMBS = 0x2000, + CRITTER_NO_KNOCKBACK = 0x4000, } CritterFlags; +#define CRITTER_RADIATED 0x02 + #define OUTLINE_TYPE_MASK 0xFFFFFF #define OUTLINE_PALETTED 0x40000000 #define OUTLINE_DISABLED 0x80000000