Skip to content

Commit

Permalink
Clarify csd
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbatalov committed Jan 16, 2024
1 parent f39518c commit dd4655c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/combat.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void _combat_update_critter_outline_for_los(Object* critter, bool a2);
void _combat_over_from_load();
void _combat_give_exps(int exp_points);
void _combat_turn_run();
void _combat(CombatStartData* attack);
void _combat(CombatStartData* csd);
void attackInit(Attack* attack, Object* attacker, Object* defender, int hitMode, int hitLocation);
int _combat_attack(Object* attacker, Object* defender, int hitMode, int hitLocation);
int _combat_bullet_start(const Object* attacker, const Object* target);
Expand Down
48 changes: 24 additions & 24 deletions src/interpreter_extra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1868,27 +1868,27 @@ static void opAttackComplex(Program* program)
combatData->whoHitMe = target;
}
} else {
CombatStartData attack;
attack.attacker = self;
attack.defender = target;
attack.actionPointsBonus = 0;
attack.accuracyBonus = data[4];
attack.damageBonus = 0;
attack.minDamage = data[3];
attack.maxDamage = data[2];
CombatStartData combat;
combat.attacker = self;
combat.defender = target;
combat.actionPointsBonus = 0;
combat.accuracyBonus = data[4];
combat.damageBonus = 0;
combat.minDamage = data[3];
combat.maxDamage = data[2];

// TODO: Something is probably broken here, why it wants
// flags to be the same? Maybe because both of them
// are applied to defender because of the bug in 0x422F3C?
if (data[1] == data[0]) {
attack.overrideAttackResults = 1;
attack.targetResults = data[0];
attack.attackerResults = data[1];
combat.overrideAttackResults = 1;
combat.targetResults = data[0];
combat.attackerResults = data[1];
} else {
attack.overrideAttackResults = 0;
combat.overrideAttackResults = 0;
}

scriptsRequestCombat(&attack);
scriptsRequestCombat(&combat);
}

program->flags &= ~PROGRAM_FLAG_0x20;
Expand Down Expand Up @@ -4455,17 +4455,17 @@ static void opAttackSetup(Program* program)
attacker->data.critter.combat.whoHitMe = defender;
}
} else {
CombatStartData attack;
attack.attacker = attacker;
attack.defender = defender;
attack.actionPointsBonus = 0;
attack.accuracyBonus = 0;
attack.damageBonus = 0;
attack.minDamage = 0;
attack.maxDamage = INT_MAX;
attack.overrideAttackResults = 0;

scriptsRequestCombat(&attack);
CombatStartData combat;
combat.attacker = attacker;
combat.defender = defender;
combat.actionPointsBonus = 0;
combat.accuracyBonus = 0;
combat.damageBonus = 0;
combat.minDamage = 0;
combat.maxDamage = INT_MAX;
combat.overrideAttackResults = 0;

scriptsRequestCombat(&combat);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/scripts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1117,10 +1117,10 @@ int scriptsRequestCombat(CombatStartData* combat)
// Likely related to random encounter, ala scriptsRequestRandomEncounter RELEASE
//
// 0x4A45D4
void _scripts_request_combat_locked(CombatStartData* a1)
void _scripts_request_combat_locked(CombatStartData* combat)
{
if (a1 != NULL) {
memcpy(&gScriptsRequestedCSD, a1, sizeof(gScriptsRequestedCSD));
if (combat != NULL) {
memcpy(&gScriptsRequestedCSD, combat, sizeof(gScriptsRequestedCSD));
} else {
gScriptsRequests |= SCRIPT_REQUEST_0x40;
}
Expand Down

0 comments on commit dd4655c

Please sign in to comment.