Skip to content

Commit

Permalink
Rename MissileData fields to match the TSV
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Aug 14, 2024
1 parent 0f13d95 commit bb6787c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions Source/misdat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ void LoadMisdat()
RecordReader reader { record, filename };
MissileData &item = MissilesData.emplace_back();
reader.advance(); // skip id
reader.read("addFn", item.mAddProc, ParseMissileAddFn);
reader.read("processFn", item.mProc, ParseMissileProcessFn);
reader.read("castSound", item.mlSFX, ParseCastSound);
reader.read("hitSound", item.miSFX, ParseHitSound);
reader.read("graphicId", item.mFileNum, ParseMissileGraphicID);
reader.read("addFn", item.addFn, ParseMissileAddFn);
reader.read("processFn", item.processFn, ParseMissileProcessFn);
reader.read("castSound", item.castSound, ParseCastSound);
reader.read("hitSound", item.hitSound, ParseHitSound);
reader.read("graphic", item.graphic, ParseMissileGraphicID);
reader.readEnumList("flags", item.flags, ParseMissileDataFlag);
reader.read("movementDistribution", item.movementDistribution, ParseMissileMovementDistribution);
}
Expand Down
10 changes: 5 additions & 5 deletions Source/misdat.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,18 @@ struct MissileData {
using AddFn = void (*)(Missile &, AddMissileParameter &);
using ProcessFn = void (*)(Missile &);

AddFn mAddProc;
ProcessFn mProc;
AddFn addFn;
ProcessFn processFn;

/**
* @brief Sound emitted when cast.
*/
SfxID mlSFX;
SfxID castSound;
/**
* @brief Sound emitted on impact.
*/
SfxID miSFX;
MissileGraphicID mFileNum;
SfxID hitSound;
MissileGraphicID graphic;
MissileDataFlags flags;
MissileMovementDistribution movementDistribution;

Expand Down
14 changes: 7 additions & 7 deletions Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ void CheckMissileCol(Missile &missile, DamageType damageType, int minDamage, int
}

const MissileData &missileData = GetMissileData(missile._mitype);
if (missile._mirange == 0 && missileData.miSFX != SfxID::None)
PlaySfxLoc(missileData.miSFX, missile.position.tile);
if (missile._mirange == 0 && missileData.hitSound != SfxID::None)
PlaySfxLoc(missileData.hitSound, missile.position.tile);
}

bool MoveMissile(Missile &missile, tl::function_ref<bool(Point)> checkTile, bool ifCheckTileFailsDontMoveToTile = false)
Expand Down Expand Up @@ -2727,7 +2727,7 @@ Missile *AddMissile(WorldTilePosition src, WorldTilePosition dst, Direction midi
missile.position.tile = src;
missile.position.start = src;
missile._miAnimAdd = 1;
missile._miAnimType = missileData.mFileNum;
missile._miAnimType = missileData.graphic;
missile._miDrawFlag = missileData.isDrawn();
missile._mlid = NO_LIGHT;
missile.lastCollisionTargetHash = 0;
Expand All @@ -2745,15 +2745,15 @@ Missile *AddMissile(WorldTilePosition src, WorldTilePosition dst, Direction midi
SetMissDir(missile, midir);

if (!lSFX) {
lSFX = missileData.mlSFX;
lSFX = missileData.castSound;
}

if (*lSFX != SfxID::None) {
PlaySfxLoc(*lSFX, missile.position.start);
}

AddMissileParameter parameter = { dst, midir, parent, false };
missileData.mAddProc(missile, parameter);
missileData.addFn(missile, parameter);
if (parameter.spellFizzled) {
return nullptr;
}
Expand Down Expand Up @@ -4155,8 +4155,8 @@ void ProcessMissiles()

for (auto &missile : Missiles) {
const MissileData &missileData = GetMissileData(missile._mitype);
if (missileData.mProc != nullptr)
missileData.mProc(missile);
if (missileData.processFn != nullptr)
missileData.processFn(missile);
if (missile._miAnimFlags == MissileGraphicsFlags::NotAnimated)
continue;

Expand Down
2 changes: 1 addition & 1 deletion assets/txtdata/missiles/misdat.tsv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id addFn processFn castSound hitSound graphicId flags movementDistribution
id addFn processFn castSound hitSound graphic flags movementDistribution
Arrow AddArrow ProcessArrow Arrow Physical,Arrow Blockable
Firebolt AddFirebolt ProcessGenericProjectile SpellFirebolt SpellFireHit Fireball Fire Blockable
Guardian AddGuardian ProcessGuardian SpellGuardian Guardian Physical
Expand Down

0 comments on commit bb6787c

Please sign in to comment.