Skip to content

Commit 498448c

Browse files
committed
replace magic sound numbers
uses static ints defined by ruleset
1 parent 30dd33c commit 498448c

16 files changed

Lines changed: 124 additions & 40 deletions

‎src/Battlescape/BattlescapeGame.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ void BattlescapeGame::endTurn()
375375
_currentAction.targeting = false;
376376
_AISecondMove = false;
377377

378-
if (_save->getTileEngine()->closeUfoDoors())
378+
if (_save->getTileEngine()->closeUfoDoors() && ResourcePack::SLIDING_DOOR_CLOSE != -1)
379379
{
380-
getResourcePack()->getSound("BATTLE.CAT", 21)->play(); // ufo door closed
380+
getResourcePack()->getSound("BATTLE.CAT", ResourcePack::SLIDING_DOOR_CLOSE)->play(); // ufo door closed
381381
}
382382

383383
// check for hot grenades on the ground

‎src/Battlescape/BattlescapeState.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ void BattlescapeState::btnReloadClick(Action *)
12151215
{
12161216
if (playableUnitSelected() && _save->getSelectedUnit()->checkAmmo())
12171217
{
1218-
_game->getResourcePack()->getSound("BATTLE.CAT", 17)->play();
1218+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_RELOAD)->play();
12191219
updateSoldierInfo();
12201220
}
12211221
}

‎src/Battlescape/ExplosionBState.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ void ExplosionBState::init()
129129
_parent->setStateInterval(BattlescapeState::DEFAULT_ANIM_SPEED/2);
130130
// explosion sound
131131
if (_power <= 80)
132-
_parent->getResourcePack()->getSound("BATTLE.CAT", 2)->play();
132+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::SMALL_EXPLOSION)->play();
133133
else
134-
_parent->getResourcePack()->getSound("BATTLE.CAT", 5)->play();
134+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::LARGE_EXPLOSION)->play();
135135

136136
_parent->getMap()->getCamera()->centerOnPosition(t->getPosition(), false);
137137
}

‎src/Battlescape/Inventory.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ void Inventory::mouseClick(Action *action, State *state)
587587
{
588588
placed = true;
589589
moveItem(item, newSlot, 0, 0);
590-
_game->getResourcePack()->getSound("BATTLE.CAT", 38)->play();
590+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_DROP)->play();
591591
arrangeGround(false);
592592
}
593593
else
@@ -641,7 +641,7 @@ void Inventory::mouseClick(Action *action, State *state)
641641
_stackLevel[x][y] += 1;
642642
}
643643
setSelectedItem(0);
644-
_game->getResourcePack()->getSound("BATTLE.CAT", 38)->play();
644+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_DROP)->play();
645645
}
646646
else
647647
{
@@ -655,7 +655,7 @@ void Inventory::mouseClick(Action *action, State *state)
655655
moveItem(_selItem, slot, item->getSlotX(), item->getSlotY());
656656
_stackLevel[item->getSlotX()][item->getSlotY()] += 1;
657657
setSelectedItem(0);
658-
_game->getResourcePack()->getSound("BATTLE.CAT", 38)->play();
658+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_DROP)->play();
659659
}
660660
else
661661
{
@@ -691,7 +691,7 @@ void Inventory::mouseClick(Action *action, State *state)
691691
item->setAmmoItem(_selItem);
692692
_selItem->moveToOwner(0);
693693
setSelectedItem(0);
694-
_game->getResourcePack()->getSound("BATTLE.CAT", 17)->play();
694+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_RELOAD)->play();
695695
if (item->getSlot()->getType() == INV_GROUND)
696696
{
697697
arrangeGround(false);
@@ -722,7 +722,7 @@ void Inventory::mouseClick(Action *action, State *state)
722722
moveItem(_selItem, slot, item->getSlotX(), item->getSlotY());
723723
_stackLevel[item->getSlotX()][item->getSlotY()] += 1;
724724
setSelectedItem(0);
725-
_game->getResourcePack()->getSound("BATTLE.CAT", 38)->play();
725+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_DROP)->play();
726726
}
727727
else
728728
{
@@ -960,7 +960,7 @@ bool Inventory::fitItem(RuleInventory *newSlot, BattleItem *item, std::string &w
960960
{
961961
placed = true;
962962
moveItem(item, newSlot, x2, y2);
963-
_game->getResourcePack()->getSound("BATTLE.CAT", 38)->play();
963+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_DROP)->play();
964964
drawItems();
965965
}
966966
else

‎src/Battlescape/InventoryState.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ void InventoryState::btnCreateTemplateClick(Action *action)
596596
}
597597

598598
// give audio feedback
599-
_game->getResourcePack()->getSound("BATTLE.CAT", 38)->play();
599+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_DROP)->play();
600600
_refreshMouse();
601601
}
602602

@@ -730,7 +730,7 @@ void InventoryState::btnApplyTemplateClick(Action *action)
730730
_refreshMouse();
731731

732732
// give audio feedback
733-
_game->getResourcePack()->getSound("BATTLE.CAT", 38)->play();
733+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_DROP)->play();
734734
}
735735

736736
void InventoryState::_refreshMouse()
@@ -764,7 +764,7 @@ void InventoryState::onClearInventory(Action *action)
764764
_refreshMouse();
765765

766766
// give audio feedback
767-
_game->getResourcePack()->getSound("BATTLE.CAT", 38)->play();
767+
_game->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_DROP)->play();
768768
}
769769

770770
/**

‎src/Battlescape/ProjectileFlyBState.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ bool ProjectileFlyBState::createNewProjectile()
312312
_projectileItem->moveToOwner(0);
313313
_unit->setCache(0);
314314
_parent->getMap()->cacheUnit(_unit);
315-
_parent->getResourcePack()->getSound("BATTLE.CAT", 39)->play();
315+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_THROW)->play();
316316
_unit->addThrowingExp();
317317
}
318318
else
@@ -482,7 +482,7 @@ void ProjectileFlyBState::think()
482482
pos.x--;
483483
}
484484
BattleItem *item = _parent->getMap()->getProjectile()->getItem();
485-
_parent->getResourcePack()->getSound("BATTLE.CAT", 38)->play();
485+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::ITEM_DROP)->play();
486486

487487
if (Options::battleInstantGrenade && item->getRules()->getBattleType() == BT_GRENADE && item->getFuseTimer() == 0)
488488
{

‎src/Battlescape/UnitDieBState.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,11 @@ void UnitDieBState::playDeathSound()
296296
{
297297
if ((_unit->getType() == "SOLDIER" && _unit->getGender() == GENDER_MALE) || _unit->getType() == "MALE_CIVILIAN")
298298
{
299-
_parent->getResourcePack()->getSound("BATTLE.CAT", RNG::generate(41,43))->play();
299+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::MALE_SCREAM[RNG::generate(0, 2)])->play();
300300
}
301301
else if ((_unit->getType() == "SOLDIER" && _unit->getGender() == GENDER_FEMALE) || _unit->getType() == "FEMALE_CIVILIAN")
302302
{
303-
_parent->getResourcePack()->getSound("BATTLE.CAT", RNG::generate(44,46))->play();
303+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::FEMALE_SCREAM[RNG::generate(0, 2)])->play();
304304
}
305305
else
306306
{

‎src/Battlescape/UnitTurnBState.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ void UnitTurnBState::init()
7575
int door = _parent->getTileEngine()->unitOpensDoor(_unit, true);
7676
if (door == 0)
7777
{
78-
_parent->getResourcePack()->getSound("BATTLE.CAT", 3)->play(); // normal door
78+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::DOOR_OPEN)->play(); // normal door
7979
}
8080
if (door == 1)
8181
{
82-
_parent->getResourcePack()->getSound("BATTLE.CAT", RNG::generate(20,21))->play(); // ufo door
82+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::SLIDING_DOOR_OPEN)->play(); // ufo door
8383
}
8484
if (door == 4)
8585
{

‎src/Battlescape/UnitWalkBState.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,11 @@ void UnitWalkBState::think()
350350
}
351351
if (door == 0)
352352
{
353-
_parent->getResourcePack()->getSound("BATTLE.CAT", 3)->play(); // normal door
353+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::DOOR_OPEN)->play(); // normal door
354354
}
355355
if (door == 1)
356356
{
357-
_parent->getResourcePack()->getSound("BATTLE.CAT", 20)->play(); // ufo door
357+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::SLIDING_DOOR_OPEN)->play(); // ufo door
358358
return; // don't start walking yet, wait for the ufo door to open
359359
}
360360
}
@@ -568,15 +568,15 @@ void UnitWalkBState::playMovementSound()
568568
{
569569
if (tile->getFootstepSound(tileBelow))
570570
{
571-
_parent->getResourcePack()->getSound("BATTLE.CAT", 22 + (tile->getFootstepSound(tileBelow)*2))->play();
571+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::WALK_OFFSET + (tile->getFootstepSound(tileBelow)*2))->play();
572572
}
573573
}
574574
// play footstep sound 2
575575
if (_unit->getWalkingPhase() == 7)
576576
{
577577
if (tile->getFootstepSound(tileBelow))
578578
{
579-
_parent->getResourcePack()->getSound("BATTLE.CAT", 23 + (tile->getFootstepSound(tileBelow)*2))->play();
579+
_parent->getResourcePack()->getSound("BATTLE.CAT", 1 + ResourcePack::WALK_OFFSET + (tile->getFootstepSound(tileBelow)*2))->play();
580580
}
581581
}
582582
}
@@ -585,7 +585,7 @@ void UnitWalkBState::playMovementSound()
585585
// play default flying sound
586586
if (_unit->getWalkingPhase() == 1 && !_falling)
587587
{
588-
_parent->getResourcePack()->getSound("BATTLE.CAT", 15)->play();
588+
_parent->getResourcePack()->getSound("BATTLE.CAT", ResourcePack::FLYING_SOUND)->play();
589589
}
590590
}
591591
}

‎src/Geoscape/BaseDefenseState.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,16 @@ void BaseDefenseState::nextStep()
138138
{
139139
case BDA_DESTROY:
140140
_lstDefenses->addRow(2, tr("STR_UFO_DESTROYED").c_str(),L" ",L" ");
141-
_game->getResourcePack()->getSound("GEO.CAT", 11)->play();
141+
_game->getResourcePack()->getSound("GEO.CAT", ResourcePack::UFO_EXPLODE)->play();
142142
_timer->setInterval(100);
143143
_action = BDA_EXPLODING1;
144144
return;
145145
case BDA_EXPLODING1:
146-
_game->getResourcePack()->getSound("GEO.CAT", 11)->play();
146+
_game->getResourcePack()->getSound("GEO.CAT", ResourcePack::UFO_EXPLODE)->play();
147147
_action = BDA_EXPLODING2;
148148
return;
149149
case BDA_EXPLODING2:
150-
_game->getResourcePack()->getSound("GEO.CAT", 11)->play();
150+
_game->getResourcePack()->getSound("GEO.CAT", ResourcePack::UFO_EXPLODE)->play();
151151
_timer->setInterval(250);
152152
_action = BDA_END;
153153
return;

0 commit comments

Comments
 (0)