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

[fixed] Bugs when spawning a music #2272

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion Entities/Meta/CTFMusic.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#define CLIENT_ONLY

#include "MusicCommon.as";

const string[] classList = {"knight", "archer", "builder"};
const string[] blobList = {"knight", "archer", "builder", "ballista", "tunnel", "keg"};

Expand All @@ -28,7 +30,12 @@ void onInit(CBlob@ this)
if (mixer is null)
return;

mixer.ResetMixer();
if (musicAlreadyExists(this))
{
this.server_Die();
this.getCurrentScript().runFlags |= Script::remove_after_this;
}

this.set_bool("initialized game", false);

this.getCurrentScript().tickFrequency = 10;
Expand Down
8 changes: 8 additions & 0 deletions Entities/Meta/ChallengeMusic.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#define CLIENT_ONLY

#include "MusicCommon.as";

enum GameMusicTags
{
world_ambient,
Expand All @@ -22,6 +24,12 @@ void onInit(CBlob@ this)
CMixer@ mixer = getMixer();
if (mixer is null) { return; } //prevents aids on server

if (musicAlreadyExists(this))
{
this.server_Die();
this.getCurrentScript().runFlags |= Script::remove_after_this;
}

this.set_bool("initialized game", false);
}

Expand Down
21 changes: 21 additions & 0 deletions Entities/Meta/MusicCommon.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

#define CLIENT_ONLY

bool musicAlreadyExists(CBlob@ this)
{
CBlob@[] musics;
getBlobsByName("music", @musics);
getBlobsByName("ctf_music", @musics);
getBlobsByName("war_music", @musics);
getBlobsByName("challenge_music", @musics);

for (uint i = 0; i < musics.length; i++)
{
CBlob@ music = musics[i];
if (music is null || music is this) continue;

return true;
}

return false;
}
8 changes: 8 additions & 0 deletions Entities/Meta/TDMMusic.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#define CLIENT_ONLY

#include "MusicCommon.as";

enum GameMusicTags
{
world_intro,
Expand All @@ -19,6 +21,12 @@ void onInit(CBlob@ this)
if (mixer is null)
return;

if (musicAlreadyExists(this))
{
this.server_Die();
this.getCurrentScript().runFlags |= Script::remove_after_this;
}

this.set_bool("initialized game", false);
}

Expand Down
11 changes: 8 additions & 3 deletions Entities/Meta/WARMusic.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define CLIENT_ONLY

#include "RulesCore.as";
#include "MusicCommon.as";

enum GameMusicTag
{
Expand Down Expand Up @@ -33,10 +34,14 @@ string base_blob_name = "hall";
void onInit(CBlob@ this)
{
CMixer@ mixer = getMixer();
if (mixer is null)
return;
if (mixer is null) { return; } //prevents aids on server

if (musicAlreadyExists(this))
{
this.server_Die();
this.getCurrentScript().runFlags |= Script::remove_after_this;
}

mixer.ResetMixer();
this.set_bool("initialized game", false);

CRules@ rules = getRules();
Expand Down