diff --git a/source/src/client.cpp b/source/src/client.cpp index 74e790e0..0af31bf0 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -154,7 +154,7 @@ void disconnect(int onlyclean, int async) kickallbots(); loopv(players) zapplayer(players[i]); clearvote(); - clearsounds(); + clearworldsounds(); localdisconnect(); } if(!connpeer && clienthost) diff --git a/source/src/protos.h b/source/src/protos.h index b5e987f3..8564d86e 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -500,7 +500,7 @@ extern void checkmapsounds(); extern void checkplayerloopsounds(); extern void musicsuggest(int id, int millis = 0, bool rndofs = false); extern void musicfadeout(int id); -extern void clearsounds(); +extern void clearworldsounds(); extern void detachsounds(playerent *owner); extern void updateaudio(); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index fd8ff403..4b387742 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -122,10 +122,11 @@ COMMAND(loadcrosshair, ARG_1STR); void drawcrosshair(playerent *p, bool showteamwarning) { - glBlendFunc(GL_ONE, GL_ONE); static Texture *teammatetex = NULL; if(!teammatetex) teammatetex = textureload("packages/misc/teammate.png"); if(!crosshair) crosshair = textureload("packages/misc/crosshairs/default.png"); + if(crosshair->bpp==32) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + else glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, showteamwarning ? teammatetex->id : crosshair->id); glBegin(GL_QUADS); glColor3ub(255,255,255); diff --git a/source/src/sound.cpp b/source/src/sound.cpp index cf7ed2d4..ec0d38cd 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -461,6 +461,7 @@ struct oggstream : sourceowner { src->stop(); src->unqueueallbuffers(); + src->buffer(NULL); } format = AL_NONE; @@ -474,7 +475,7 @@ struct oggstream : sourceowner // default settings startmillis = endmillis = startfademillis = endfademillis = 0; - gain = volume = 1.0f; + gain = 1.0f; // reset gain but not volume setting looping = false; } @@ -548,6 +549,7 @@ struct oggstream : sourceowner alBufferData(bufid, format, pcm, size, info->rate); return !alerr(); } + return false; } @@ -574,8 +576,11 @@ struct oggstream : sourceowner if(startmillis > 0) { const float start = (lastmillis-startmillis)/(float)startfademillis; - if(start>=0.00f && start<=1.00001f) setgain(start); - return true; + if(start>=0.00f && start<=1.00001f) + { + setgain(start); + return true; + } } // fade out @@ -584,8 +589,11 @@ struct oggstream : sourceowner if(lastmillis<=endmillis) // set gain { const float end = (endmillis-lastmillis)/(float)endfademillis; - if(end>=-0.00001f && end<=1.00f) setgain(end); - return true; + if(end>=-0.00001f && end<=1.00f) + { + setgain(end); + return true; + } } else // stop { @@ -643,14 +651,14 @@ struct oggstream : sourceowner { ASSERT(valid); if(playing()) return true; - if(!src || !stream(bufferids[0]) || !stream(bufferids[1])) return false; + this->looping = looping; + if(!stream(bufferids[0]) || !stream(bufferids[1])) return false; if(startmillis == endmillis == startfademillis == endfademillis == 0) setgain(1.0f); updategain(); src->queuebuffers(2, bufferids); src->play(); - this->looping = looping; return true; } @@ -1027,6 +1035,24 @@ struct locvector : vector if(l->src && l->src->locked) l->src->pitch(pitch); } } + + // delete all sounds except world-neutral sounds like GUI/notifacation + void deleteworldobjsounds() + { + loopv(*this) + { + location *l = buf[i]; + if(!l) continue; + // world-neutral sounds + if(l->cfg == &gamesounds[S_MENUENTER] || + l->cfg == &gamesounds[S_MENUSELECT] || + l->cfg == &gamesounds[S_CALLVOTE] || + l->cfg == &gamesounds[S_VOTEPASS] || + l->cfg == &gamesounds[S_VOTEFAIL]) continue; + + delete_(i--); + } + } }; locvector locations; @@ -1249,9 +1275,10 @@ void soundcleanup() // destroy consuming code stopsound(); - clearsounds(); - gamesounds.setsize(0); DELETEP(gamemusic); + mapsounds.setsize(0); + locations.deletecontentsp(); + gamesounds.setsize(0); // kill scheduler scheduler.reset(); @@ -1262,10 +1289,12 @@ void soundcleanup() if(device) alcCloseDevice(device); } -void clearsounds() +// clear world-related sounds, called on mapchange +void clearworldsounds() { + stopsound(); mapsounds.setsize(0); - locations.deletecontentsp(); + locations.deleteworldobjsounds(); } VAR(footsteps, 0, 1, 1); diff --git a/source/src/world.cpp b/source/src/world.cpp index 6c1d06df..0bae1240 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -275,7 +275,7 @@ void empty_world(int factor, bool force) // main empty world creation routine if(!force && noteditmode()) return; cleardlights(); pruneundos(); - clearsounds(); + clearworldsounds(); sqr *oldworld = world; bool copy = false; if(oldworld && factor<0) { factor = sfactor+1; copy = true; } diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index aee3f26b..1889ca12 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -234,7 +234,7 @@ bool load_world(char *mname) // still supports all map formats that have preparectf(true); cleardlights(); pruneundos(); - clearsounds(); + clearworldsounds(); setnames(mname); gzFile f = opengzfile(cgzname, "rb9"); if(!f) { conoutf("\f3could not read map %s", cgzname); return false; }