From a41780caa21c6b7af3f5d0f8b3ee325ddb63db32 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Thu, 18 Aug 2022 08:41:15 +0300 Subject: [PATCH] Rename some item functions --- src/actions.cc | 6 +- src/animation.cc | 2 +- src/combat.cc | 36 +++---- src/combat_ai.cc | 38 +++---- src/critter.cc | 2 +- src/game_dialog.cc | 12 +-- src/game_mouse.cc | 2 +- src/interface.cc | 24 ++--- src/interpreter_extra.cc | 10 +- src/inventory.cc | 42 ++++---- src/item.cc | 218 ++++++++++++++++----------------------- src/item.h | 62 +++++------ src/map.cc | 2 +- src/obj_types.h | 2 +- src/object.cc | 2 +- src/proto_instance.cc | 8 +- src/proto_types.h | 2 +- src/queue.cc | 2 +- 18 files changed, 218 insertions(+), 254 deletions(-) diff --git a/src/actions.cc b/src/actions.cc index a570d85..598d4c6 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -472,7 +472,7 @@ int _show_death(Object* obj, int anim) } if (anim >= 30 && anim <= 31 && _critter_flag_check(obj->pid, CRITTER_FLAG_0x1000) == 0 && _critter_flag_check(obj->pid, CRITTER_FLAG_0x40) == 0) { - _item_drop_all(obj, obj->tile); + itemDropAll(obj, obj->tile); } tileWindowRefreshRect(&v8, obj->elevation); @@ -713,7 +713,7 @@ int _action_ranged(Attack* attack, int anim) int actionFrame = (art != NULL) ? artGetActionFrame(art) : 0; artUnlock(artHandle); - _item_w_range(attack->attacker, attack->hitMode); + weaponGetRange(attack->attacker, attack->hitMode); int damageType = weaponGetDamageType(attack->attacker, attack->weapon); @@ -760,7 +760,7 @@ int _action_ranged(Attack* attack, int anim) interfaceGetItemActions(&leftItemAction, &rightItemAction); itemRemove(attack->attacker, weapon, 1); - v50 = _item_replace(attack->attacker, weapon, weaponFlags & OBJECT_IN_ANY_HAND); + v50 = itemReplace(attack->attacker, weapon, weaponFlags & OBJECT_IN_ANY_HAND); objectSetFid(projectile, projectileProto->fid, NULL); _cAIPrepWeaponItem(attack->attacker, weapon); diff --git a/src/animation.cc b/src/animation.cc index 682f810..ab555e4 100644 --- a/src/animation.cc +++ b/src/animation.cc @@ -3005,7 +3005,7 @@ int _check_move(int* a1) bool aiming; interfaceGetCurrentHitMode(&hitMode, &aiming); - int v6 = _item_mp_cost(gDude, hitMode, aiming); + int v6 = itemGetActionPointCost(gDude, hitMode, aiming); *a1 = *a1 - v6; if (*a1 <= 0) { return -1; diff --git a/src/combat.cc b/src/combat.cc index 3e48336..485505a 100644 --- a/src/combat.cc +++ b/src/combat.cc @@ -2261,7 +2261,7 @@ static bool _combat_safety_invalidate_weapon_func(Object* critter, Object* weapo int intelligence = critterGetStat(critter, STAT_INTELLIGENCE); int team = critter->data.critter.combat.team; - int v41 = _item_w_area_damage_radius(weapon, hitMode); + int v41 = weaponGetDamageRadius(weapon, hitMode); int maxDamage; weaponGetDamageMinMax(weapon, NULL, &maxDamage); int damageType = weaponGetDamageType(critter, weapon); @@ -3468,7 +3468,7 @@ int _combat_attack(Object* a1, Object* a2, int hitMode, int hitLocation) aiming = true; } - int actionPoints = _item_w_mp_cost(a1, _main_ctd.hitMode, aiming); + int actionPoints = weaponGetActionPointCost(a1, _main_ctd.hitMode, aiming); debugPrint("sequencing attack...\n"); if (_action_attack(&_main_ctd) == -1) { @@ -3509,7 +3509,7 @@ int _combat_bullet_start(const Object* a1, const Object* a2) // 0x423128 static bool _check_ranged_miss(Attack* attack) { - int range = _item_w_range(attack->attacker, attack->hitMode); + int range = weaponGetRange(attack->attacker, attack->hitMode); int to = _tile_num_beyond(attack->attacker->tile, attack->defender->tile, range); int roll = ROLL_FAILURE; @@ -3698,7 +3698,7 @@ static int _compute_spray(Attack* attack, int accuracy, int* a3, int* a4, int an *a3 = 1; } - int range = _item_w_range(attack->attacker, attack->hitMode); + int range = weaponGetRange(attack->attacker, attack->hitMode); int mainTargetEndTile = _tile_num_beyond(attack->attacker->tile, attack->defender->tile, range); *a3 += _shoot_along_path(attack, mainTargetEndTile, centerRounds - *a3, anim); @@ -3754,7 +3754,7 @@ static int attackComputeEnhancedKnockout(Attack* attack) // 0x42378C static int attackCompute(Attack* attack) { - int range = _item_w_range(attack->attacker, attack->hitMode); + int range = weaponGetRange(attack->attacker, attack->hitMode); int distance = objectGetDistanceBetween(attack->attacker, attack->defender); if (range < distance) { @@ -3966,9 +3966,9 @@ void _compute_explosion_on_extras(Attack* attack, int a2, bool isGrenade, int a4 } } else { v22++; - if (isGrenade && _item_w_grenade_dmg_radius(attack->weapon) < v22) { + if (isGrenade && weaponGetGrenadeExplosionRadius(attack->weapon) < v22) { v5 = -1; - } else if (isGrenade || _item_w_rocket_dmg_radius(attack->weapon) >= v22) { + } else if (isGrenade || weaponGetRocketExplosionRadius(attack->weapon) >= v22) { v5 = tileGetTileInDirection(v19, ROTATION_NE, 1); } else { v5 = -1; @@ -4117,7 +4117,7 @@ static int _attackFindInvalidFlags(Object* critter, Object* item) flags |= DAM_DROP; } - if (item != NULL && weaponIsNatural(item)) { + if (item != NULL && itemIsHidden(item)) { flags |= DAM_DROP; } @@ -4268,7 +4268,7 @@ static int attackDetermineToHit(Object* attacker, int tile, Object* defender, in if (weapon == NULL || isUnarmedHitMode(hitMode)) { accuracy = skillGetValue(attacker, SKILL_UNARMED); } else { - accuracy = _item_w_skill_level(attacker, hitMode); + accuracy = weaponGetSkillValue(attacker, hitMode); int modifier = 0; @@ -4534,7 +4534,7 @@ static void attackComputeDamage(Attack* attack, int ammoQuantity, int bonusDamag int damageDivisor = weaponGetAmmoDamageDivisor(attack->weapon); for (int index = 0; index < ammoQuantity; index++) { - int damage = weaponGetMeleeDamage(attack->attacker, attack->hitMode); + int damage = weaponGetDamage(attack->attacker, attack->hitMode); damage += damageBonus; @@ -4799,7 +4799,7 @@ static void _damage_object(Object* a1, int damage, bool animated, int a4, Object if ((a1->data.critter.combat.results & DAM_DEAD) != 0) { scriptSetObjects(a1->sid, a1->data.critter.combat.whoHitMe, NULL); scriptExecProc(a1->sid, SCRIPT_PROC_DESTROY); - _item_destroy_all_hidden(a1); + itemDestroyAllHidden(a1); if (a1 != gDude) { Object* whoHitMe = a1->data.critter.combat.whoHitMe; @@ -5600,11 +5600,11 @@ int _combat_check_bad_shot(Object* attacker, Object* defender, int hitMode, bool } } - if (_item_w_mp_cost(attacker, hitMode, aiming) > attacker->data.critter.combat.ap) { + if (weaponGetActionPointCost(attacker, hitMode, aiming) > attacker->data.critter.combat.ap) { return 3; // not enough action points } - if (_item_w_range(attacker, hitMode) < range) { + if (weaponGetRange(attacker, hitMode) < range) { return 2; // target out of range } @@ -5618,7 +5618,7 @@ int _combat_check_bad_shot(Object* attacker, Object* defender, int hitMode, bool if (attackType == ATTACK_TYPE_RANGED || attackType == ATTACK_TYPE_THROW - || _item_w_range(attacker, hitMode) > 1) { + || weaponGetRange(attacker, hitMode) > 1) { if (_combat_is_shot_blocked(attacker, attacker->tile, tile, defender, NULL)) { return 5; // Your aim is blocked } @@ -5689,7 +5689,7 @@ void _combat_attack_this(Object* a1) item = critterGetWeaponForHitMode(gDude, hitMode); messageListItem.num = 100; // You need %d action points. if (messageListGetItem(&gCombatMessageList, &messageListItem)) { - int actionPointsRequired = _item_w_mp_cost(gDude, hitMode, aiming); + int actionPointsRequired = weaponGetActionPointCost(gDude, hitMode, aiming); sprintf(formattedText, messageListItem.text, actionPointsRequired); displayMonitorAddMessage(formattedText); } @@ -5895,7 +5895,7 @@ int _combat_player_knocked_out_by() // 0x426DB8 int _combat_explode_scenery(Object* a1, Object* a2) { - _scr_explode_scenery(a1, a1->tile, _item_w_rocket_dmg_radius(NULL), a1->elevation); + _scr_explode_scenery(a1, a1->tile, weaponGetRocketExplosionRadius(NULL), a1->elevation); return 0; } @@ -6631,7 +6631,7 @@ static void damageModCalculateGlovz(DamageCalculationContext* context) } for (int index = 0; index < context->ammoQuantity; index++) { - int damage = weaponGetMeleeDamage(context->attack->attacker, context->attack->hitMode); + int damage = weaponGetDamage(context->attack->attacker, context->attack->hitMode); damage += context->damageBonus; if (damage <= 0) { @@ -6721,7 +6721,7 @@ static void damageModCalculateYaam(DamageCalculationContext* context) } for (int index = 0; index < context->ammoQuantity; index++) { - int damage = weaponGetMeleeDamage(context->attack->weapon, context->attack->hitMode); + int damage = weaponGetDamage(context->attack->weapon, context->attack->hitMode); damage += context->damageBonus; damage -= calculatedDamageThreshold; diff --git a/src/combat_ai.cc b/src/combat_ai.cc index 9a42bd8..0c55356 100644 --- a/src/combat_ai.cc +++ b/src/combat_ai.cc @@ -1648,7 +1648,7 @@ static int _ai_have_ammo(Object* critter_obj, Object* weapon_obj, Object** out_a } if (weaponGetAnimationCode(weapon_obj)) { - if (_item_w_range(critter_obj, 2) < 3) { + if (weaponGetRange(critter_obj, 2) < 3) { _inven_unwield(critter_obj, 1); } } else { @@ -1716,7 +1716,7 @@ static Object* _ai_best_weapon(Object* attacker, Object* weapon1, Object* weapon // SFALL: Fix avg damage calculation. avgDamage1 = (maxDamage + minDamage) / 2; - if (_item_w_area_damage_radius(weapon1, HIT_MODE_RIGHT_WEAPON_PRIMARY) > 0 && defender != NULL) { + if (weaponGetDamageRadius(weapon1, HIT_MODE_RIGHT_WEAPON_PRIMARY) > 0 && defender != NULL) { attack.weapon = weapon1; _compute_explosion_on_extras(&attack, 0, weaponIsGrenade(weapon1), 1); avgDamage1 *= attack.extrasLength + 1; @@ -1734,12 +1734,12 @@ static Object* _ai_best_weapon(Object* attacker, Object* weapon1, Object* weapon } } - if (weaponIsNatural(weapon1)) { + if (itemIsHidden(weapon1)) { return weapon1; } } else { distance = objectGetDistanceBetween(attacker, defender); - if (_item_w_range(attacker, HIT_MODE_PUNCH) >= distance) { + if (weaponGetRange(attacker, HIT_MODE_PUNCH) >= distance) { attackType1 = ATTACK_TYPE_UNARMED; } } @@ -1761,7 +1761,7 @@ static Object* _ai_best_weapon(Object* attacker, Object* weapon1, Object* weapon // SFALL: Fix avg damage calculation. avgDamage2 = (maxDamage + minDamage) / 2; - if (_item_w_area_damage_radius(weapon2, HIT_MODE_RIGHT_WEAPON_PRIMARY) > 0 && defender != NULL) { + if (weaponGetDamageRadius(weapon2, HIT_MODE_RIGHT_WEAPON_PRIMARY) > 0 && defender != NULL) { attack.weapon = weapon2; _compute_explosion_on_extras(&attack, 0, weaponIsGrenade(weapon2), 1); avgDamage2 *= attack.extrasLength + 1; @@ -1778,7 +1778,7 @@ static Object* _ai_best_weapon(Object* attacker, Object* weapon1, Object* weapon } } - if (weaponIsNatural(weapon2)) { + if (itemIsHidden(weapon2)) { return weapon2; } } else { @@ -1786,7 +1786,7 @@ static Object* _ai_best_weapon(Object* attacker, Object* weapon1, Object* weapon distance = objectGetDistanceBetween(attacker, weapon1); } - if (_item_w_range(attacker, HIT_MODE_PUNCH) >= distance) { + if (weaponGetRange(attacker, HIT_MODE_PUNCH) >= distance) { attackType2 = ATTACK_TYPE_UNARMED; } } @@ -1882,7 +1882,7 @@ Object* _ai_search_inven_weap(Object* critter, int a2, Object* a3) } if (a2) { - if (weaponGetActionPointCost1(weapon) > critter->data.critter.combat.ap) { + if (weaponGetPrimaryActionPointCost(weapon) > critter->data.critter.combat.ap) { continue; } } @@ -2388,7 +2388,7 @@ static bool _cai_attackWouldIntersect(Object* a1, Object* a2, Object* a3, int ti return false; } - if (_item_w_range(a1, hitMode) < 1) { + if (weaponGetRange(a1, hitMode) < 1) { return false; } @@ -2416,7 +2416,7 @@ static int _ai_switch_weapons(Object* a1, int* hitMode, Object** weapon, Object* } else { Object* v8 = _ai_search_environ(a1, ITEM_TYPE_WEAPON); if (v8 == NULL) { - if (_item_w_mp_cost(a1, *hitMode, 0) <= a1->data.critter.combat.ap) { + if (weaponGetActionPointCost(a1, *hitMode, 0) <= a1->data.critter.combat.ap) { return 0; } @@ -2433,7 +2433,7 @@ static int _ai_switch_weapons(Object* a1, int* hitMode, Object** weapon, Object* if (*weapon != NULL) { _inven_wield(a1, *weapon, 1); _combat_turn_run(); - if (_item_w_mp_cost(a1, *hitMode, 0) <= a1->data.critter.combat.ap) { + if (weaponGetActionPointCost(a1, *hitMode, 0) <= a1->data.critter.combat.ap) { return 0; } } @@ -2452,8 +2452,8 @@ static int _ai_called_shot(Object* a1, Object* a2, int a3) v5 = 3; - if (_item_w_mp_cost(a1, a3, 1) <= a1->data.critter.combat.ap) { - if (_item_w_called_shot(a1, a3)) { + if (weaponGetActionPointCost(a1, a3, 1) <= a1->data.critter.combat.ap) { + if (critterCanAim(a1, a3)) { ai = aiGetPacket(a1); if (randomBetween(1, ai->called_freq) == 1) { combat_difficulty = 1; @@ -2546,7 +2546,7 @@ static int _ai_try_attack(Object* a1, Object* a2) if (reason == 1) { // out of ammo if (_ai_have_ammo(a1, weapon, &ammo)) { - int v9 = _item_w_reload(weapon, ammo); + int v9 = weaponReload(weapon, ammo); if (v9 == 0 && ammo != NULL) { _obj_destroy(ammo); } @@ -2569,7 +2569,7 @@ static int _ai_try_attack(Object* a1, Object* a2) if (ammo != NULL) { ammo = _ai_retrieve_object(a1, ammo); if (ammo != NULL) { - int v15 = _item_w_reload(weapon, ammo); + int v15 = weaponReload(weapon, ammo); if (v15 == 0) { _obj_destroy(ammo); } @@ -2690,11 +2690,11 @@ static int _ai_try_attack(Object* a1, Object* a2) } v38 = 0; - if (_ai_attack(a1, a2, hitMode) == -1 || _item_w_mp_cost(a1, hitMode, 0) > a1->data.critter.combat.ap) { + if (_ai_attack(a1, a2, hitMode) == -1 || weaponGetActionPointCost(a1, hitMode, 0) > a1->data.critter.combat.ap) { return -1; } } else { - if (_ai_attack(a1, a2, hitMode) == -1 || _item_w_mp_cost(a1, hitMode, 0) > a1->data.critter.combat.ap) { + if (_ai_attack(a1, a2, hitMode) == -1 || weaponGetActionPointCost(a1, hitMode, 0) > a1->data.critter.combat.ap) { return -1; } } @@ -2732,7 +2732,7 @@ void _cai_attempt_w_reload(Object* critter_obj, int a2) v5 = ammoGetQuantity(weapon_obj); if (v5 < ammoGetCapacity(weapon_obj) && _ai_have_ammo(critter_obj, weapon_obj, &ammo_obj)) { - v9 = _item_w_reload(weapon_obj, ammo_obj); + v9 = weaponReload(weapon_obj, ammo_obj); if (v9 == 0) { _obj_destroy(ammo_obj); } @@ -3202,7 +3202,7 @@ Object* _combat_ai_random_target(Attack* attack) // Looks like this function does nothing because it's result is not used. I // suppose it was planned to use range as a condition below, but it was // later moved into 0x426614, but remained here. - _item_w_range(attack->attacker, attack->hitMode); + weaponGetRange(attack->attacker, attack->hitMode); Object* critter = NULL; diff --git a/src/critter.cc b/src/critter.cc index 9cb9c1b..edfb375 100644 --- a/src/critter.cc +++ b/src/critter.cc @@ -883,7 +883,7 @@ void critterKill(Object* critter, int anim, bool a3) _critterClearObj = critter; _queue_clear_type(EVENT_TYPE_DRUG, _critterClearObjDrugs); - _item_destroy_all_hidden(critter); + itemDestroyAllHidden(critter); if (a3) { tileWindowRefreshRect(&updatedRect, elevation); diff --git a/src/game_dialog.cc b/src/game_dialog.cc index 1e55248..bab70fd 100644 --- a/src/game_dialog.cc +++ b/src/game_dialog.cc @@ -3258,16 +3258,16 @@ void _gdialog_barter_cleanup_tables() length = inventory->length; for (int index = 0; index < length; index++) { Object* item = inventory->items->item; - int quantity = _item_count(_peon_table_obj, item); - _item_move_force(_peon_table_obj, gDude, item, quantity); + int quantity = itemGetQuantity(_peon_table_obj, item); + itemMoveForce(_peon_table_obj, gDude, item, quantity); } inventory = &(_barterer_table_obj->data.inventory); length = inventory->length; for (int index = 0; index < length; index++) { Object* item = inventory->items->item; - int quantity = _item_count(_barterer_table_obj, item); - _item_move_force(_barterer_table_obj, gGameDialogSpeaker, item, quantity); + int quantity = itemGetQuantity(_barterer_table_obj, item); + itemMoveForce(_barterer_table_obj, gGameDialogSpeaker, item, quantity); } if (_barterer_temp_obj != NULL) { @@ -3275,8 +3275,8 @@ void _gdialog_barter_cleanup_tables() length = inventory->length; for (int index = 0; index < length; index++) { Object* item = inventory->items->item; - int quantity = _item_count(_barterer_temp_obj, item); - _item_move_force(_barterer_temp_obj, gGameDialogSpeaker, item, quantity); + int quantity = itemGetQuantity(_barterer_temp_obj, item); + itemMoveForce(_barterer_temp_obj, gGameDialogSpeaker, item, quantity); } } } diff --git a/src/game_mouse.cc b/src/game_mouse.cc index aa2ae58..1cd3c23 100644 --- a/src/game_mouse.cc +++ b/src/game_mouse.cc @@ -1016,7 +1016,7 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState) ? HIT_MODE_RIGHT_WEAPON_PRIMARY : HIT_MODE_LEFT_WEAPON_PRIMARY; - int actionPointsRequired = _item_mp_cost(gDude, hitMode, false); + int actionPointsRequired = itemGetActionPointCost(gDude, hitMode, false); if (actionPointsRequired <= gDude->data.critter.combat.ap) { if (_action_use_an_item_on_object(gDude, object, weapon) != -1) { int actionPoints = gDude->data.critter.combat.ap; diff --git a/src/interface.cc b/src/interface.cc index f0f9e35..c2c5f1c 100644 --- a/src/interface.cc +++ b/src/interface.cc @@ -1236,7 +1236,7 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction) Object* item1 = critterGetItem1(gDude); if (item1 == leftItemState->item && leftItemState->item != NULL) { if (leftItemState->item != NULL) { - leftItemState->isDisabled = _can_use_weapon(item1); + leftItemState->isDisabled = dudeIsWeaponDisabled(item1); leftItemState->itemFid = itemGetInventoryFid(item1); } } else { @@ -1246,7 +1246,7 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction) leftItemState->item = item1; if (item1 != NULL) { - leftItemState->isDisabled = _can_use_weapon(item1); + leftItemState->isDisabled = dudeIsWeaponDisabled(item1); leftItemState->primaryHitMode = HIT_MODE_LEFT_WEAPON_PRIMARY; leftItemState->secondaryHitMode = HIT_MODE_LEFT_WEAPON_SECONDARY; leftItemState->isWeapon = itemGetType(item1) == ITEM_TYPE_WEAPON; @@ -1285,7 +1285,7 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction) Object* item2 = critterGetItem2(gDude); if (item2 == rightItemState->item && rightItemState->item != NULL) { if (rightItemState->item != NULL) { - rightItemState->isDisabled = _can_use_weapon(rightItemState->item); + rightItemState->isDisabled = dudeIsWeaponDisabled(rightItemState->item); rightItemState->itemFid = itemGetInventoryFid(rightItemState->item); } } else { @@ -1295,7 +1295,7 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction) rightItemState->item = item2; if (item2 != NULL) { - rightItemState->isDisabled = _can_use_weapon(item2); + rightItemState->isDisabled = dudeIsWeaponDisabled(item2); rightItemState->primaryHitMode = HIT_MODE_RIGHT_WEAPON_PRIMARY; rightItemState->secondaryHitMode = HIT_MODE_RIGHT_WEAPON_SECONDARY; rightItemState->isWeapon = itemGetType(item2) == ITEM_TYPE_WEAPON; @@ -1407,7 +1407,7 @@ int interfaceCycleItemAction() done = true; break; case INTERFACE_ITEM_ACTION_PRIMARY_AIMING: - if (_item_w_called_shot(gDude, itemState->primaryHitMode)) { + if (critterCanAim(gDude, itemState->primaryHitMode)) { done = true; } break; @@ -1422,7 +1422,7 @@ int interfaceCycleItemAction() if (itemState->secondaryHitMode != HIT_MODE_PUNCH && itemState->secondaryHitMode != HIT_MODE_KICK && weaponGetAttackTypeForHitMode(itemState->item, itemState->secondaryHitMode) != ATTACK_TYPE_NONE - && _item_w_called_shot(gDude, itemState->secondaryHitMode)) { + && critterCanAim(gDude, itemState->secondaryHitMode)) { done = true; } break; @@ -1461,7 +1461,7 @@ void _intface_use_item() ? HIT_MODE_LEFT_WEAPON_RELOAD : HIT_MODE_RIGHT_WEAPON_RELOAD; - int actionPointsRequired = _item_mp_cost(gDude, hitMode, false); + int actionPointsRequired = itemGetActionPointCost(gDude, hitMode, false); if (actionPointsRequired <= gDude->data.critter.combat.ap) { if (_intface_item_reload() == 0) { if (actionPointsRequired > gDude->data.critter.combat.ap) { @@ -1487,7 +1487,7 @@ void _intface_use_item() gameMouseSetMode(GAME_MOUSE_MODE_USE_CROSSHAIR); } else if (_obj_action_can_use(ptr->item)) { if (isInCombat()) { - int actionPointsRequired = _item_mp_cost(gDude, ptr->secondaryHitMode, false); + int actionPointsRequired = itemGetActionPointCost(gDude, ptr->secondaryHitMode, false); if (actionPointsRequired <= gDude->data.critter.combat.ap) { _obj_use_item(gDude, ptr->item); interfaceUpdateItems(false, INTERFACE_ITEM_ACTION_DEFAULT, INTERFACE_ITEM_ACTION_DEFAULT); @@ -1748,7 +1748,7 @@ static int interfaceBarRefreshMainAction() artUnlock(useTextFrmHandle); } - actionPoints = _item_mp_cost(gDude, itemState->primaryHitMode, false); + actionPoints = itemGetActionPointCost(gDude, itemState->primaryHitMode, false); } } else { int primaryFid = -1; @@ -1771,7 +1771,7 @@ static int interfaceBarRefreshMainAction() hitMode = itemState->secondaryHitMode; break; case INTERFACE_ITEM_ACTION_RELOAD: - actionPoints = _item_mp_cost(gDude, gInterfaceCurrentHand == HAND_LEFT ? HIT_MODE_LEFT_WEAPON_RELOAD : HIT_MODE_RIGHT_WEAPON_RELOAD, false); + actionPoints = itemGetActionPointCost(gDude, gInterfaceCurrentHand == HAND_LEFT ? HIT_MODE_LEFT_WEAPON_RELOAD : HIT_MODE_RIGHT_WEAPON_RELOAD, false); primaryFid = buildFid(OBJ_TYPE_INTERFACE, 291, 0, 0, 0); break; } @@ -1797,7 +1797,7 @@ static int interfaceBarRefreshMainAction() } if (hitMode != -1) { - actionPoints = _item_w_mp_cost(gDude, hitMode, bullseyeFid != -1); + actionPoints = weaponGetActionPointCost(gDude, hitMode, bullseyeFid != -1); int id; int anim = critterGetAnimationForHitMode(gDude, hitMode); @@ -2218,7 +2218,7 @@ static int _intface_item_reload() } bool v0 = false; - while (_item_w_try_reload(gDude, gInterfaceItemStates[gInterfaceCurrentHand].item) != -1) { + while (weaponAttemptReload(gDude, gInterfaceItemStates[gInterfaceCurrentHand].item) != -1) { v0 = true; } diff --git a/src/interpreter_extra.cc b/src/interpreter_extra.cc index 4decf4c..6824ea1 100644 --- a/src/interpreter_extra.cc +++ b/src/interpreter_extra.cc @@ -1035,7 +1035,7 @@ static void opDestroyObject(Program* program) Object* owner = objectGetOwner(object); if (owner != NULL) { - int quantity = _item_count(owner, object); + int quantity = itemGetQuantity(owner, object); itemRemove(owner, object, quantity); if (owner == gDude) { @@ -3236,7 +3236,7 @@ static void opMetarule(Program* program) case METARULE_DROP_ALL_INVEN: if (1) { Object* object = static_cast(param.pointerValue); - result = _item_drop_all(object, object->tile); + result = itemDropAll(object, object->tile); if (gDude == object) { interfaceUpdateItems(false, INTERFACE_ITEM_ACTION_DEFAULT, INTERFACE_ITEM_ACTION_DEFAULT); interfaceRenderArmorClass(false); @@ -3630,7 +3630,7 @@ static void opRemoveMultipleObjectsFromInventory(Program* program) bool itemWasEquipped = (item->flags & OBJECT_EQUIPPED) != 0; - int quantity = _item_count(owner, item); + int quantity = itemGetQuantity(owner, item); if (quantity > quantityToRemove) { quantity = quantityToRemove; } @@ -4459,7 +4459,7 @@ static void opDestroyMultipleObjects(Program* program) Object* owner = objectGetOwner(object); if (owner != NULL) { - int quantityToDestroy = _item_count(owner, object); + int quantityToDestroy = itemGetQuantity(owner, object); if (quantityToDestroy > quantity) { quantityToDestroy = quantity; } @@ -4579,7 +4579,7 @@ static void opMoveObjectInventoryToObject(Program* program) _correctFidForRemovedItem(object1, item2, flags); } - _item_move_all(object1, object2); + itemMoveAll(object1, object2); if (object1 == gDude) { if (oldArmor != NULL) { diff --git a/src/inventory.cc b/src/inventory.cc index e4dbabc..14ef6fa 100644 --- a/src/inventory.cc +++ b/src/inventory.cc @@ -2612,7 +2612,7 @@ static void inventoryRenderSummary() } } - // Formula is the same as in `weaponGetMeleeDamage`. + // Formula is the same as in `weaponGetDamage`. int minDamage; int maxDamage; int bonusDamage = unarmedGetDamage(hitMode, &minDamage, &maxDamage); @@ -2663,7 +2663,7 @@ static void inventoryRenderSummary() } } - int range = _item_w_range(_stack[0], hitMode); + int range = weaponGetRange(_stack[0], hitMode); int damageMin; int damageMax; @@ -2696,7 +2696,7 @@ static void inventoryRenderSummary() // like we cannot be here with anything besides melee or // unarmed. if (_stack[0] == gDude && (attackType == ATTACK_TYPE_MELEE || attackType == ATTACK_TYPE_UNARMED)) { - // See explanation in `weaponGetMeleeDamage`. + // See explanation in `weaponGetDamage`. damageMin += 2 * perkGetRank(gDude, PERK_BONUS_HTH_DAMAGE); } } @@ -3347,7 +3347,7 @@ static void inventoryWindowOpenContextMenu(int keyCode, int inventoryWindowType) int actionMenuItemsLength; const int* actionMenuItems; - if (itemType == ITEM_TYPE_WEAPON && _item_w_can_unload(item)) { + if (itemType == ITEM_TYPE_WEAPON && weaponCanBeUnloaded(item)) { if (inventoryWindowType != INVENTORY_WINDOW_TYPE_NORMAL && objectGetOwner(item) != gDude) { actionMenuItemsLength = 3; actionMenuItems = _act_weap2; @@ -3597,7 +3597,7 @@ static void inventoryWindowOpenContextMenu(int keyCode, int inventoryWindowType) } for (;;) { - Object* ammo = _item_w_unload(item); + Object* ammo = weaponUnload(item); if (ammo == NULL) { break; } @@ -3704,7 +3704,7 @@ int inventoryOpenLooting(Object* a1, Object* a2) return 0; } - _item_move_all_hidden(a2, a1a); + itemMoveAllHidden(a2, a1a); Object* item1 = NULL; Object* item2 = NULL; @@ -3834,7 +3834,7 @@ int inventoryOpenLooting(Object* a1, Object* a2) int currentWeight = objectGetInventoryWeight(a1); int newInventoryWeight = objectGetInventoryWeight(a2); if (newInventoryWeight <= maxCarryWeight - currentWeight) { - _item_move_all(a2, a1); + itemMoveAll(a2, a1); _display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_LOOT); _display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_LOOT); } else { @@ -4025,7 +4025,7 @@ int inventoryOpenLooting(Object* a1, Object* a2) } } - _item_move_all(a1a, a2); + itemMoveAll(a1a, a2); objectDestroy(a1a, NULL); if (_gIsSteal) { @@ -4181,7 +4181,7 @@ static int _move_inventory(Object* a1, int a2, Object* a3, bool a4) } if (rc != 1) { - if (_item_move(_inven_dude, a3, a1, quantityToMove) != -1) { + if (itemMove(_inven_dude, a3, a1, quantityToMove) != -1) { rc = 2; } else { // There is no space left for that item. @@ -4210,7 +4210,7 @@ static int _move_inventory(Object* a1, int a2, Object* a3, bool a4) } if (rc != 1) { - if (_item_move(a3, _inven_dude, a1, quantityToMove) == 0) { + if (itemMove(a3, _inven_dude, a1, quantityToMove) == 0) { if ((a1->flags & OBJECT_IN_RIGHT_HAND) != 0) { a3->fid = buildFid(FID_TYPE(a3->fid), a3->fid & 0xFFF, FID_ANIM_TYPE(a3->fid), 0, a3->rotation + 1); } @@ -4298,7 +4298,7 @@ static int _barter_attempt_transaction(Object* a1, Object* a2, Object* a3, Objec if (a2->data.inventory.length == 0) { v11 = true; } else { - if (_item_queued(a2)) { + if (itemIsQueued(a2)) { if (a2->pid != PROTO_ID_GEIGER_COUNTER_I || miscItemTurnOff(a2) == -1) { v11 = true; } @@ -4322,8 +4322,8 @@ static int _barter_attempt_transaction(Object* a1, Object* a2, Object* a3, Objec } } - _item_move_all(a4, a1); - _item_move_all(a2, a3); + itemMoveAll(a4, a1); + itemMoveAll(a2, a3); return 0; } @@ -4383,7 +4383,7 @@ static void _barter_move_inventory(Object* a1, int quantity, int a3, int a4, Obj if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_TRADE_INNER_LEFT_SCROLLER_TRACKING_X, INVENTORY_TRADE_INNER_LEFT_SCROLLER_TRACKING_Y, INVENTORY_TRADE_INNER_LEFT_SCROLLER_TRACKING_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_INNER_LEFT_SCROLLER_TRACKING_Y)) { int quantityToMove = quantity > 1 ? inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, a1, quantity) : 1; if (quantityToMove != -1) { - if (_item_move_force(_inven_dude, a6, a1, quantityToMove) == -1) { + if (itemMoveForce(_inven_dude, a6, a1, quantityToMove) == -1) { // There is no space left for that item. messageListItem.num = 26; if (messageListGetItem(&gInventoryMessageList, &messageListItem)) { @@ -4396,7 +4396,7 @@ static void _barter_move_inventory(Object* a1, int quantity, int a3, int a4, Obj if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_TRADE_INNER_RIGHT_SCROLLER_TRACKING_X, INVENTORY_TRADE_INNER_RIGHT_SCROLLER_TRACKING_Y, INVENTORY_TRADE_INNER_RIGHT_SCROLLER_TRACKING_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_INNER_RIGHT_SCROLLER_TRACKING_Y)) { int quantityToMove = quantity > 1 ? inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, a1, quantity) : 1; if (quantityToMove != -1) { - if (_item_move_force(a5, a6, a1, quantityToMove) == -1) { + if (itemMoveForce(a5, a6, a1, quantityToMove) == -1) { // You cannot pick that up. You are at your maximum weight capacity. messageListItem.num = 25; if (messageListGetItem(&gInventoryMessageList, &messageListItem)) { @@ -4466,7 +4466,7 @@ static void _barter_move_from_table_inventory(Object* a1, int quantity, int a3, if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_X, INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_Y, INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_Y)) { int quantityToMove = quantity > 1 ? inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, a1, quantity) : 1; if (quantityToMove != -1) { - if (_item_move_force(a5, _inven_dude, a1, quantityToMove) == -1) { + if (itemMoveForce(a5, _inven_dude, a1, quantityToMove) == -1) { // There is no space left for that item. messageListItem.num = 26; if (messageListGetItem(&gInventoryMessageList, &messageListItem)) { @@ -4479,7 +4479,7 @@ static void _barter_move_from_table_inventory(Object* a1, int quantity, int a3, if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_X, INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_Y, INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_Y)) { int quantityToMove = quantity > 1 ? inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, a1, quantity) : 1; if (quantityToMove != -1) { - if (_item_move_force(a5, a4, a1, quantityToMove) == -1) { + if (itemMoveForce(a5, a4, a1, quantityToMove) == -1) { // You cannot pick that up. You are at your maximum weight capacity. messageListItem.num = 25; if (messageListGetItem(&gInventoryMessageList, &messageListItem)) { @@ -4678,8 +4678,8 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5) _barter_mod = a5 + modifier; if (keyCode == KEY_LOWERCASE_T || modifier <= -30) { - _item_move_all(a4, a2); - _item_move_all(a3, gDude); + itemMoveAll(a4, a2); + itemMoveAll(a3, gDude); _barter_end_to_talk_to(); break; } else if (keyCode == KEY_LOWERCASE_M) { @@ -4886,7 +4886,7 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5) } } - _item_move_all(a1a, a2); + itemMoveAll(a1a, a2); objectDestroy(a1a, NULL); if (armor != NULL) { @@ -5042,7 +5042,7 @@ static int _drop_ammo_into_weapon(Object* weapon, Object* ammo, Object** a3, int bool v17 = false; int rc = itemRemove(_inven_dude, weapon, 1); for (int index = 0; index < quantityToMove; index++) { - int v11 = _item_w_reload(weapon, v14); + int v11 = weaponReload(weapon, v14); if (v11 == 0) { if (a3 != NULL) { *a3 = NULL; diff --git a/src/item.cc b/src/item.cc index 405a645..0553bab 100644 --- a/src/item.cc +++ b/src/item.cc @@ -505,93 +505,64 @@ static int _item_move_func(Object* a1, Object* a2, Object* a3, int quantity, boo } // 0x47769C -int _item_move(Object* a1, Object* a2, Object* a3, int quantity) +int itemMove(Object* from, Object* to, Object* item, int quantity) { - return _item_move_func(a1, a2, a3, quantity, false); + return _item_move_func(from, to, item, quantity, false); } // 0x4776A4 -int _item_move_force(Object* a1, Object* a2, Object* a3, int quantity) +int itemMoveForce(Object* from, Object* to, Object* item, int quantity) { - return _item_move_func(a1, a2, a3, quantity, true); + return _item_move_func(from, to, item, quantity, true); } // 0x4776AC -void _item_move_all(Object* a1, Object* a2) +void itemMoveAll(Object* from, Object* to) { - Inventory* inventory = &(a1->data.inventory); + Inventory* inventory = &(from->data.inventory); while (inventory->length > 0) { InventoryItem* inventoryItem = &(inventory->items[0]); - _item_move_func(a1, a2, inventoryItem->item, inventoryItem->quantity, true); + // NOTE: Uninline. + itemMoveForce(from, to, inventoryItem->item, inventoryItem->quantity); } } // 0x4776E0 -int _item_move_all_hidden(Object* a1, Object* a2) +int itemMoveAllHidden(Object* from, Object* to) { - Inventory* inventory = &(a1->data.inventory); - // TODO: Not sure about two loops. - for (int i = 0; i < inventory->length;) { - for (int j = i; j < inventory->length;) { - bool v5; - InventoryItem* inventoryItem = &(inventory->items[j]); - if (PID_TYPE(inventoryItem->item->pid) == OBJ_TYPE_ITEM) { - Proto* proto; - if (protoGetProto(inventoryItem->item->pid, &proto) != -1) { - v5 = (proto->item.extendedFlags & ItemProtoExtendedFlags_NaturalWeapon) == 0; - } else { - v5 = true; - } - } else { - v5 = true; - } - - if (!v5) { - _item_move_func(a1, a2, inventoryItem->item, inventoryItem->quantity, true); - } else { - i++; - j++; - } + Inventory* inventory = &(from->data.inventory); + for (int index = 0; index < inventory->length;) { + InventoryItem* inventoryItem = &(inventory->items[index]); + // NOTE: Uninline. + if (itemIsHidden(inventoryItem->item)) { + // NOTE: Uninline. + itemMoveForce(from, to, inventoryItem->item, inventoryItem->quantity); + } else { + index++; } } return 0; } // 0x477770 -int _item_destroy_all_hidden(Object* a1) +int itemDestroyAllHidden(Object* owner) { - Inventory* inventory = &(a1->data.inventory); - // TODO: Not sure about this one. Why two loops? - for (int i = 0; i < inventory->length;) { - // TODO: Probably wrong, something with two loops. - for (int j = i; j < inventory->length;) { - bool v5; - InventoryItem* inventoryItem = &(inventory->items[j]); - if (PID_TYPE(inventoryItem->item->pid) == OBJ_TYPE_ITEM) { - Proto* proto; - if (protoGetProto(inventoryItem->item->pid, &proto) != -1) { - v5 = (proto->item.extendedFlags & ItemProtoExtendedFlags_NaturalWeapon) == 0; - } else { - v5 = true; - } - } else { - v5 = true; - } - - if (!v5) { - itemRemove(a1, inventoryItem->item, 1); - _obj_destroy(inventoryItem->item); - } else { - i++; - j++; - } + Inventory* inventory = &(owner->data.inventory); + for (int index = 0; index < inventory->length;) { + InventoryItem* inventoryItem = &(inventory->items[index]); + // NOTE: Uninline. + if (itemIsHidden(inventoryItem->item)) { + itemRemove(owner, inventoryItem->item, 1); + _obj_destroy(inventoryItem->item); + } else { + index++; } } return 0; } // 0x477804 -int _item_drop_all(Object* critter, int tile) +int itemDropAll(Object* critter, int tile) { bool hasEquippedItems = false; @@ -667,11 +638,11 @@ static bool _item_identical(Object* a1, Object* a2) return false; } - if ((a1->flags & (OBJECT_EQUIPPED | OBJECT_USED)) != 0) { + if ((a1->flags & (OBJECT_EQUIPPED | OBJECT_QUEUED)) != 0) { return false; } - if ((a2->flags & (OBJECT_EQUIPPED | OBJECT_USED)) != 0) { + if ((a2->flags & (OBJECT_EQUIPPED | OBJECT_QUEUED)) != 0) { return false; } @@ -779,7 +750,7 @@ int itemGetWeight(Object* item) int weight = proto->item.weight; // NOTE: Uninline. - if (weaponIsNatural(item)) { + if (itemIsHidden(item)) { weight = 0; } @@ -972,7 +943,7 @@ int objectGetInventoryWeight(Object* obj) } // 0x477F3C -bool _can_use_weapon(Object* weapon) +bool dudeIsWeaponDisabled(Object* weapon) { if (weapon == NULL) { return false; @@ -1001,12 +972,11 @@ bool _can_use_weapon(Object* weapon) // 0x477FB0 int itemGetInventoryFid(Object* item) { - Proto* proto; - if (item == NULL) { return -1; } + Proto* proto; protoGetProto(item->pid, &proto); return proto->item.inventoryFid; @@ -1030,7 +1000,7 @@ Object* critterGetWeaponForHitMode(Object* critter, int hitMode) } // 0x478040 -int _item_mp_cost(Object* obj, int hitMode, bool aiming) +int itemGetActionPointCost(Object* obj, int hitMode, bool aiming) { if (obj == NULL) { return 0; @@ -1042,25 +1012,24 @@ int _item_mp_cost(Object* obj, int hitMode, bool aiming) return 2; } - return _item_w_mp_cost(obj, hitMode, aiming); + return weaponGetActionPointCost(obj, hitMode, aiming); } -// Returns quantity of [a2] in [obj]s inventory. +// Returns quantity of [item] in [obj]s inventory. // // 0x47808C -int _item_count(Object* obj, Object* a2) +int itemGetQuantity(Object* obj, Object* item) { int quantity = 0; Inventory* inventory = &(obj->data.inventory); for (int index = 0; index < inventory->length; index++) { InventoryItem* inventoryItem = &(inventory->items[index]); - Object* item = inventoryItem->item; - if (item == a2) { + if (inventoryItem->item == item) { quantity = inventoryItem->quantity; } else { - if (itemGetType(item) == ITEM_TYPE_CONTAINER) { - quantity = _item_count(item, a2); + if (itemGetType(inventoryItem->item) == ITEM_TYPE_CONTAINER) { + quantity = itemGetQuantity(inventoryItem->item, item); if (quantity > 0) { return quantity; } @@ -1074,25 +1043,25 @@ int _item_count(Object* obj, Object* a2) // Returns true if [a1] posesses an item with 0x2000 flag. // // 0x4780E4 -int _item_queued(Object* obj) +int itemIsQueued(Object* obj) { if (obj == NULL) { return false; } - if ((obj->flags & OBJECT_USED) != 0) { + if ((obj->flags & OBJECT_QUEUED) != 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_USED) != 0) { + if ((inventoryItem->item->flags & OBJECT_QUEUED) != 0) { return true; } if (itemGetType(inventoryItem->item) == ITEM_TYPE_CONTAINER) { - if (_item_queued(inventoryItem->item)) { + if (itemIsQueued(inventoryItem->item)) { return true; } } @@ -1102,36 +1071,36 @@ int _item_queued(Object* obj) } // 0x478154 -Object* _item_replace(Object* a1, Object* a2, int a3) +Object* itemReplace(Object* owner, Object* itemToReplace, int flags) { - if (a1 == NULL) { + if (owner == NULL) { return NULL; } - if (a2 == NULL) { + if (itemToReplace == NULL) { return NULL; } - Inventory* inventory = &(a1->data.inventory); + Inventory* inventory = &(owner->data.inventory); for (int index = 0; index < inventory->length; index++) { InventoryItem* inventoryItem = &(inventory->items[index]); - if (_item_identical(inventoryItem->item, a2)) { + if (_item_identical(inventoryItem->item, itemToReplace)) { Object* item = inventoryItem->item; - if (itemRemove(a1, item, 1) == 0) { - item->flags |= a3; - if (itemAdd(a1, item, 1) == 0) { + if (itemRemove(owner, item, 1) == 0) { + item->flags |= flags; + if (itemAdd(owner, item, 1) == 0) { return item; } - item->flags &= ~a3; - if (itemAdd(a1, item, 1) != 0) { + item->flags &= ~flags; + if (itemAdd(owner, item, 1) != 0) { _obj_destroy(item); } } } if (itemGetType(inventoryItem->item) == ITEM_TYPE_CONTAINER) { - Object* obj = _item_replace(inventoryItem->item, a2, a3); + Object* obj = itemReplace(inventoryItem->item, itemToReplace, flags); if (obj != NULL) { return obj; } @@ -1141,24 +1110,19 @@ Object* _item_replace(Object* a1, Object* a2, int a3) return NULL; } -// Returns true if [item] is an natural weapon of it's owner. -// -// See [ItemProtoExtendedFlags_NaturalWeapon] for more details on natural weapons. -// // 0x478244 -int weaponIsNatural(Object* obj) +bool itemIsHidden(Object* item) { + if (PID_TYPE(item->pid) != OBJ_TYPE_ITEM) { + return false; + } + Proto* proto; - - if (PID_TYPE(obj->pid) != OBJ_TYPE_ITEM) { - return 0; + if (protoGetProto(item->pid, &proto) == -1) { + return false; } - if (protoGetProto(obj->pid, &proto) == -1) { - return 0; - } - - return proto->item.extendedFlags & ItemProtoExtendedFlags_NaturalWeapon; + return (proto->item.extendedFlags & ITEM_HIDDEN) != 0; } // 0x478280 @@ -1217,7 +1181,7 @@ int weaponGetSkillForHitMode(Object* weapon, int hitMode) // Returns skill value when critter is about to perform hitMode. // // 0x478370 -int _item_w_skill_level(Object* critter, int hitMode) +int weaponGetSkillValue(Object* critter, int hitMode) { if (critter == NULL) { return 0; @@ -1258,7 +1222,7 @@ int weaponGetDamageMinMax(Object* weapon, int* minDamagePtr, int* maxDamagePtr) } // 0x478448 -int weaponGetMeleeDamage(Object* critter, int hitMode) +int weaponGetDamage(Object* critter, int hitMode) { if (critter == NULL) { return 0; @@ -1452,7 +1416,7 @@ void ammoSetQuantity(Object* ammoOrWeapon, int quantity) } // 0x478768 -int _item_w_try_reload(Object* critter, Object* weapon) +int weaponAttemptReload(Object* critter, Object* weapon) { // NOTE: Uninline. int quantity = ammoGetQuantity(weapon); @@ -1471,7 +1435,7 @@ int _item_w_try_reload(Object* critter, Object* weapon) if (weapon->data.item.weapon.ammoTypePid == ammo->pid) { if (weaponCanBeReloadedWith(weapon, ammo) != 0) { - int rc = _item_w_reload(weapon, ammo); + int rc = weaponReload(weapon, ammo); if (rc == 0) { _obj_destroy(ammo); } @@ -1493,7 +1457,7 @@ int _item_w_try_reload(Object* critter, Object* weapon) } if (weaponCanBeReloadedWith(weapon, ammo) != 0) { - int rc = _item_w_reload(weapon, ammo); + int rc = weaponReload(weapon, ammo); if (rc == 0) { _obj_destroy(ammo); } @@ -1507,7 +1471,7 @@ int _item_w_try_reload(Object* critter, Object* weapon) } } - if (_item_w_reload(weapon, NULL) != 0) { + if (weaponReload(weapon, NULL) != 0) { return -1; } @@ -1567,7 +1531,7 @@ bool weaponCanBeReloadedWith(Object* weapon, Object* ammo) } // 0x478918 -int _item_w_reload(Object* weapon, Object* ammo) +int weaponReload(Object* weapon, Object* ammo) { if (!weaponCanBeReloadedWith(weapon, ammo)) { return -1; @@ -1608,7 +1572,7 @@ int _item_w_reload(Object* weapon, Object* ammo) } // 0x478A1C -int _item_w_range(Object* critter, int hitMode) +int weaponGetRange(Object* critter, int hitMode) { int range; int v12; @@ -1651,7 +1615,7 @@ int _item_w_range(Object* critter, int hitMode) // Returns action points required for hit mode. // // 0x478B24 -int _item_w_mp_cost(Object* critter, int hitMode, bool aiming) +int weaponGetActionPointCost(Object* critter, int hitMode, bool aiming) { int actionPoints; @@ -1680,15 +1644,15 @@ int _item_w_mp_cost(Object* critter, int hitMode, bool aiming) if (weapon != NULL) { if (hitMode == HIT_MODE_LEFT_WEAPON_PRIMARY || hitMode == HIT_MODE_RIGHT_WEAPON_PRIMARY) { // NOTE: Uninline. - actionPoints = weaponGetActionPointCost1(weapon); + actionPoints = weaponGetPrimaryActionPointCost(weapon); } else { // NOTE: Uninline. - actionPoints = weaponGetActionPointCost2(weapon); + actionPoints = weaponGetSecondaryActionPointCost(weapon); } if (critter == gDude) { if (traitIsSelected(TRAIT_FAST_SHOT)) { - if (_item_w_range(critter, hitMode) > 2) { + if (weaponGetRange(critter, hitMode) > 2) { actionPoints--; } } @@ -1831,16 +1795,16 @@ char weaponGetSoundId(Object* weapon) } // 0x478E5C -int _item_w_called_shot(Object* critter, int hitMode) +bool critterCanAim(Object* critter, int hitMode) { if (critter == gDude && traitIsSelected(TRAIT_FAST_SHOT)) { - return 0; + return false; } // NOTE: Uninline. int anim = critterGetAnimationForHitMode(critter, hitMode); if (anim == ANIM_FIRE_BURST || anim == ANIM_FIRE_CONTINUOUS) { - return 0; + return false; } // NOTE: Uninline. @@ -1854,7 +1818,7 @@ int _item_w_called_shot(Object* critter, int hitMode) } // 0x478EF4 -int _item_w_can_unload(Object* weapon) +int weaponCanBeUnloaded(Object* weapon) { if (weapon == NULL) { return false; @@ -1888,9 +1852,9 @@ int _item_w_can_unload(Object* weapon) } // 0x478F80 -Object* _item_w_unload(Object* weapon) +Object* weaponUnload(Object* weapon) { - if (!_item_w_can_unload(weapon)) { + if (!weaponCanBeUnloaded(weapon)) { return NULL; } @@ -1927,7 +1891,7 @@ Object* _item_w_unload(Object* weapon) } // 0x47905C -int weaponGetActionPointCost1(Object* weapon) +int weaponGetPrimaryActionPointCost(Object* weapon) { if (weapon == NULL) { return -1; @@ -1942,7 +1906,7 @@ int weaponGetActionPointCost1(Object* weapon) // NOTE: Inlined. // // 0x479084 -int weaponGetActionPointCost2(Object* weapon) +int weaponGetSecondaryActionPointCost(Object* weapon) { if (weapon == NULL) { return -1; @@ -1983,30 +1947,30 @@ bool weaponIsGrenade(Object* weapon) } // 0x47910C -int _item_w_area_damage_radius(Object* weapon, int hitMode) +int weaponGetDamageRadius(Object* weapon, int hitMode) { int attackType = weaponGetAttackTypeForHitMode(weapon, hitMode); int anim = weaponGetAnimationForHitMode(weapon, hitMode); int damageType = weaponGetDamageType(NULL, weapon); - int v1 = 0; + int radius = 0; if (attackType == ATTACK_TYPE_RANGED) { if (anim == ANIM_FIRE_SINGLE && damageType == DAMAGE_TYPE_EXPLOSION) { // NOTE: Uninline. - v1 = _item_w_rocket_dmg_radius(weapon); + radius = weaponGetRocketExplosionRadius(weapon); } } else if (attackType == ATTACK_TYPE_THROW) { // NOTE: Uninline. if (weaponIsGrenade(weapon)) { // NOTE: Uninline. - v1 = _item_w_grenade_dmg_radius(weapon); + radius = weaponGetGrenadeExplosionRadius(weapon); } } - return v1; + return radius; } // 0x479180 -int _item_w_grenade_dmg_radius(Object* weapon) +int weaponGetGrenadeExplosionRadius(Object* weapon) { // SFALL if (gExplosionRadius != -1) { @@ -2017,7 +1981,7 @@ int _item_w_grenade_dmg_radius(Object* weapon) } // 0x479188 -int _item_w_rocket_dmg_radius(Object* weapon) +int weaponGetRocketExplosionRadius(Object* weapon) { // SFALL if (gExplosionRadius != -1) { diff --git a/src/item.h b/src/item.h index 012590d..538f8f5 100644 --- a/src/item.h +++ b/src/item.h @@ -4,14 +4,14 @@ #include "db.h" #include "obj_types.h" -typedef enum _WeaponClass { +typedef enum AttackType { ATTACK_TYPE_NONE, - ATTACK_TYPE_UNARMED, // unarmed - ATTACK_TYPE_MELEE, // melee + ATTACK_TYPE_UNARMED, + ATTACK_TYPE_MELEE, ATTACK_TYPE_THROW, ATTACK_TYPE_RANGED, ATTACK_TYPE_COUNT, -} WeaponClass; +} AttackType; typedef enum HealingItem { HEALING_ITEM_STIMPACK, @@ -27,13 +27,13 @@ int itemsLoad(File* stream); int itemsSave(File* stream); int itemAttemptAdd(Object* owner, Object* itemToAdd, int quantity); int itemAdd(Object* owner, Object* itemToAdd, int quantity); -int itemRemove(Object* a1, Object* a2, int quantity); -int _item_move(Object* a1, Object* a2, Object* a3, int quantity); -int _item_move_force(Object* a1, Object* a2, Object* a3, int quantity); -void _item_move_all(Object* a1, Object* a2); -int _item_move_all_hidden(Object* a1, Object* a2); -int _item_destroy_all_hidden(Object* a1); -int _item_drop_all(Object* critter, int tile); +int itemRemove(Object* owner, Object* itemToRemove, int quantity); +int itemMove(Object* from, Object* to, Object* item, int quantity); +int itemMoveForce(Object* from, Object* to, Object* item, int quantity); +void itemMoveAll(Object* from, Object* to); +int itemMoveAllHidden(Object* from, Object* to); +int itemDestroyAllHidden(Object* owner); +int itemDropAll(Object* critter, int tile); char* itemGetName(Object* obj); char* itemGetDescription(Object* obj); int itemGetType(Object* item); @@ -43,19 +43,19 @@ int itemGetWeight(Object* item); int itemGetCost(Object* obj); int objectGetCost(Object* obj); int objectGetInventoryWeight(Object* obj); -bool _can_use_weapon(Object* item_obj); +bool dudeIsWeaponDisabled(Object* weapon); int itemGetInventoryFid(Object* obj); Object* critterGetWeaponForHitMode(Object* critter, int hitMode); -int _item_mp_cost(Object* obj, int hitMode, bool aiming); -int _item_count(Object* obj, Object* a2); -int _item_queued(Object* obj); -Object* _item_replace(Object* a1, Object* a2, int a3); -int weaponIsNatural(Object* obj); +int itemGetActionPointCost(Object* obj, int hitMode, bool aiming); +int itemGetQuantity(Object* obj, Object* a2); +int itemIsQueued(Object* obj); +Object* itemReplace(Object* a1, Object* a2, int a3); +bool itemIsHidden(Object* obj); int weaponGetAttackTypeForHitMode(Object* a1, int a2); int weaponGetSkillForHitMode(Object* a1, int a2); -int _item_w_skill_level(Object* a1, int a2); +int weaponGetSkillValue(Object* a1, int a2); int weaponGetDamageMinMax(Object* weapon, int* minDamagePtr, int* maxDamagePtr); -int weaponGetMeleeDamage(Object* critter, int hitMode); +int weaponGetDamage(Object* critter, int hitMode); int weaponGetDamageType(Object* critter, Object* weapon); int weaponIsTwoHanded(Object* weapon); int critterGetAnimationForHitMode(Object* critter, int hitMode); @@ -64,11 +64,11 @@ int ammoGetCapacity(Object* ammoOrWeapon); int ammoGetQuantity(Object* ammoOrWeapon); int ammoGetCaliber(Object* ammoOrWeapon); void ammoSetQuantity(Object* ammoOrWeapon, int quantity); -int _item_w_try_reload(Object* critter, Object* weapon); +int weaponAttemptReload(Object* critter, Object* weapon); bool weaponCanBeReloadedWith(Object* weapon, Object* ammo); -int _item_w_reload(Object* weapon, Object* ammo); -int _item_w_range(Object* critter, int hitMode); -int _item_w_mp_cost(Object* critter, int hitMode, bool aiming); +int weaponReload(Object* weapon, Object* ammo); +int weaponGetRange(Object* critter, int hitMode); +int weaponGetActionPointCost(Object* critter, int hitMode, bool aiming); int weaponGetMinStrengthRequired(Object* weapon); int weaponGetCriticalFailureType(Object* weapon); int weaponGetPerk(Object* weapon); @@ -77,16 +77,16 @@ int weaponGetAnimationCode(Object* weapon); int weaponGetProjectilePid(Object* weapon); int weaponGetAmmoTypePid(Object* weapon); char weaponGetSoundId(Object* weapon); -int _item_w_called_shot(Object* critter, int hitMode); -int _item_w_can_unload(Object* weapon); -Object* _item_w_unload(Object* weapon); -int weaponGetActionPointCost1(Object* weapon); -int weaponGetActionPointCost2(Object* weapon); +bool critterCanAim(Object* critter, int hitMode); +int weaponCanBeUnloaded(Object* weapon); +Object* weaponUnload(Object* weapon); +int weaponGetPrimaryActionPointCost(Object* weapon); +int weaponGetSecondaryActionPointCost(Object* weapon); int _item_w_compute_ammo_cost(Object* obj, int* inout_a2); bool weaponIsGrenade(Object* weapon); -int _item_w_area_damage_radius(Object* weapon, int hitMode); -int _item_w_grenade_dmg_radius(Object* weapon); -int _item_w_rocket_dmg_radius(Object* weapon); +int weaponGetDamageRadius(Object* weapon, int hitMode); +int weaponGetGrenadeExplosionRadius(Object* weapon); +int weaponGetRocketExplosionRadius(Object* weapon); int weaponGetAmmoArmorClassModifier(Object* weapon); int weaponGetAmmoDamageResistanceModifier(Object* weapon); int weaponGetAmmoDamageMultiplier(Object* weapon); diff --git a/src/map.cc b/src/map.cc index 9a5ff53..7ba156f 100644 --- a/src/map.cc +++ b/src/map.cc @@ -1135,7 +1135,7 @@ static int _map_age_dead_critters() Object* obj = objects[index]; if (PID_TYPE(obj->pid) == OBJ_TYPE_CRITTER) { if (_critter_flag_check(obj->pid, CRITTER_FLAG_0x40) == 0) { - _item_drop_all(obj, obj->tile); + itemDropAll(obj, obj->tile); } Object* blood; diff --git a/src/obj_types.h b/src/obj_types.h index 41f5478..c63e14c 100644 --- a/src/obj_types.h +++ b/src/obj_types.h @@ -49,7 +49,7 @@ typedef enum ObjectFlags { 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_QUEUED = 0x2000, // set if there was/is any event for the object OBJECT_TRANS_RED = 0x4000, OBJECT_TRANS_NONE = 0x8000, OBJECT_TRANS_WALL = 0x10000, diff --git a/src/object.cc b/src/object.cc index 5a1f908..0ed6844 100644 --- a/src/object.cc +++ b/src/object.cc @@ -1088,7 +1088,7 @@ int _obj_copy(Object** a1, Object* a2) return -1; } - objectListNode->obj->flags &= ~OBJECT_USED; + objectListNode->obj->flags &= ~OBJECT_QUEUED; Inventory* newInventory = &(objectListNode->obj->data.inventory); newInventory->length = 0; diff --git a/src/proto_instance.cc b/src/proto_instance.cc index 72be2e6..8b8e7b3 100644 --- a/src/proto_instance.cc +++ b/src/proto_instance.cc @@ -816,7 +816,7 @@ static int _obj_use_flare(Object* critter_obj, Object* flare) return -1; } - if ((flare->flags & OBJECT_USED) != 0) { + if ((flare->flags & OBJECT_QUEUED) != 0) { if (critter_obj == gDude) { // The flare is already lit. messageListItem.num = 588; @@ -872,7 +872,7 @@ static int _obj_use_explosive(Object* explosive) return -1; } - if ((explosive->flags & OBJECT_USED) != 0) { + if ((explosive->flags & OBJECT_QUEUED) != 0) { // The timer is already ticking. messageListItem.num = 590; if (messageListGetItem(&gProtoMessageList, &messageListItem)) { @@ -1118,7 +1118,7 @@ int _obj_use_item(Object* a1, Object* a2) if (root != NULL) { int flags = a2->flags & OBJECT_IN_ANY_HAND; itemRemove(root, a2, 1); - Object* v8 = _item_replace(root, a2, flags); + Object* v8 = itemReplace(root, a2, flags); if (root == gDude) { int leftItemAction; int rightItemAction; @@ -1360,7 +1360,7 @@ int _obj_use_item_on(Object* a1, Object* a2, Object* a3) int flags = a3->flags & OBJECT_IN_ANY_HAND; itemRemove(a1, a3, 1); - Object* v7 = _item_replace(a1, a3, flags); + Object* v7 = itemReplace(a1, a3, flags); int leftItemAction; int rightItemAction; diff --git a/src/proto_types.h b/src/proto_types.h index 8caa346..e42fb46 100644 --- a/src/proto_types.h +++ b/src/proto_types.h @@ -221,7 +221,7 @@ typedef enum ItemProtoExtendedFlags { // This flag is used on weapons to indicate that's an natural (integral) // part of it's owner, for example Claw, or Robot's Rocket Launcher. Items // with this flag on do count toward total weight and cannot be dropped. - ItemProtoExtendedFlags_NaturalWeapon = 0x08000000, + ITEM_HIDDEN = 0x08000000, } ItemProtoExtendedFlags; typedef struct { diff --git a/src/queue.cc b/src/queue.cc index c2379eb..091640d 100644 --- a/src/queue.cc +++ b/src/queue.cc @@ -256,7 +256,7 @@ int queueAddEvent(int delay, Object* obj, void* data, int eventType) newQueueListNode->data = data; if (obj != NULL) { - obj->flags |= OBJECT_USED; + obj->flags |= OBJECT_QUEUED; } QueueListNode** v3 = &gQueueListHead;