Skip to content

Commit

Permalink
Merge pull request #99 from joeyshuttleworth/fix/explosion
Browse files Browse the repository at this point in the history
1 Explosion sound per bomb
  • Loading branch information
harveynw committed Jan 31, 2024
2 parents c3e5e05 + c8ba62e commit d38489b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 7 additions & 5 deletions common/Explosion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Explosion::Explosion()
return;

/* Create sound objects for explosion sound effects */
for (int i = 0; i < N_EXPLOSION_SOUNDS; i++) {
std::shared_ptr<Sound> sound =
soundManager.createSound(mExplosionSoundNames[i]);
sound->mGroup = SOUND_FX;
mExplosionSounds[i] = sound;
if(mSound) {
for (int i = 0; i < N_EXPLOSION_SOUNDS; i++) {
std::shared_ptr<Sound> sound =
soundManager.createSound(mExplosionSoundNames[i]);
sound->mGroup = SOUND_FX;
mExplosionSounds[i] = sound;
}
}

/* We need to tell the BLOKE engine to get textures ready if we need them */
Expand Down
5 changes: 4 additions & 1 deletion common/bomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@ bomb::explode()
/*Iterate over all the squares the bomb can reach and kill the ones if they
* are in the right (wrong) zone.*/
std::vector<BombPath> targets = identifyTargetSquares();
bool withSound = true;
for(const auto& path : targets) {
for(const auto& coord : path.squares) {
explosionEffects.push_back(
std::make_shared<Explosion>(coord.first, coord.second, 1, 1, false)
std::make_shared<Explosion>(coord.first, coord.second, 1, 1, false, 30, 64, 0, withSound)
);
if(withSound)
withSound = false; // Only one explosion needs to generate a sound effect

auto square = std::make_shared<actor>(coord.first, coord.second,
1, 1, false);
Expand Down
7 changes: 1 addition & 6 deletions engine/network/NetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@ parseAddress(const std::string &address, std::string &ip, ushort &port)
/* Attempt to parse the first argument as address:port.
If no ':' is present, the port number defaults to 8888.
*/
long unsigned int delim_pos = address.find(':');
long unsigned int delim_pos = address.rfind(':');

if (delim_pos == std::string::npos) {
ip = address;
port = 8888;
} else if (address.substr(delim_pos + 1).find(':') != std::string::npos) {
std::stringstream msg;
msg << "Couldn't parse address, " << address;
log_message(ERR, msg.str());
return false;
} else {
ip = address.substr(0, delim_pos);
try {
Expand Down

0 comments on commit d38489b

Please sign in to comment.