Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 Explosion sound per bomb #99

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading