From: <wha...@us...> - 2012-02-06 01:52:59
|
Revision: 8063 http://planeshift.svn.sourceforge.net/planeshift/?rev=8063&view=rev Author: whacko88 Date: 2012-02-06 01:52:53 +0000 (Mon, 06 Feb 2012) Log Message: ----------- fixed bug when served stop the song before the end tab style fixes Modified Paths: -------------- trunk/src/plugins/common/soundmanager/handle.cpp trunk/src/plugins/common/soundmanager/instrument.cpp trunk/src/server/bulkobjects/pscharacter.h trunk/src/server/serversongmngr.cpp trunk/src/server/serversongmngr.h Modified: trunk/src/plugins/common/soundmanager/handle.cpp =================================================================== --- trunk/src/plugins/common/soundmanager/handle.cpp 2012-02-06 00:26:47 UTC (rev 8062) +++ trunk/src/plugins/common/soundmanager/handle.cpp 2012-02-06 01:52:53 UTC (rev 8063) @@ -171,15 +171,15 @@ fadeSteps = -time / FADE_TIMESTEP; } - // checking boundaries - if(currentVolume < VOLUME_ZERO) - { - currentVolume = VOLUME_ZERO; - } - else if(currentVolume > VOLUME_MAX) - { - currentVolume = VOLUME_MAX; - } + // checking boundaries + if(currentVolume < VOLUME_ZERO) + { + currentVolume = VOLUME_ZERO; + } + else if(currentVolume > VOLUME_MAX) + { + currentVolume = VOLUME_MAX; + } // there must be at least one step or the volume don't change if(fadeSteps == 0) Modified: trunk/src/plugins/common/soundmanager/instrument.cpp =================================================================== --- trunk/src/plugins/common/soundmanager/instrument.cpp 2012-02-06 00:26:47 UTC (rev 8062) +++ trunk/src/plugins/common/soundmanager/instrument.cpp 2012-02-06 01:52:53 UTC (rev 8063) @@ -105,11 +105,11 @@ // * number of bytes per sample * number of channels requestedBytes = format->Freq * duration * (format->Bits / 8) * format->Channels; - // if the frame has 16 bits we must return an even number of bytes - if(requestedBytes % 2 != 0 && format->Bits / 8 == 2) - { - requestedBytes--; - } + // if the frame has 16 bits we must return an even number of bytes + if(requestedBytes % 2 != 0 && format->Bits / 8 == 2) + { + requestedBytes--; + } // checking if this note is defined or if it's a rest if((oct = notes.Get(octave, 0)) != 0) @@ -188,18 +188,18 @@ requestedBytes = format->Freq * duration * (format->Bits / 8) * format->Channels; phaseShift = format->Freq * 0.3 * (format->Bits / 8) * format->Channels; - // if the frame has 16 bits we must return an even number of bytes - if(format->Bits / 8 == 2) - { - if(requestedBytes % 2 != 0) - { - requestedBytes--; - } - if(phaseShift % 2 != 0) - { - phaseShift--; - } - } + // if the frame has 16 bits we must return an even number of bytes + if(format->Bits / 8 == 2) + { + if(requestedBytes % 2 != 0) + { + requestedBytes--; + } + if(phaseShift % 2 != 0) + { + phaseShift--; + } + } // selecting the note switch(alter) Modified: trunk/src/server/bulkobjects/pscharacter.h =================================================================== --- trunk/src/server/bulkobjects/pscharacter.h 2012-02-06 00:26:47 UTC (rev 8062) +++ trunk/src/server/bulkobjects/pscharacter.h 2012-02-06 01:52:53 UTC (rev 8063) @@ -937,9 +937,9 @@ void EndSong(csTicks bonusTime); /** - * Gets the execution time of the song that the player is currently playing. + * Gets the starting time of the song that the player is currently playing. */ - csTicks GetPlayingTime() const { return csGetTicks() - songExecutionTime; } + csTicks GetSongStartTime() const { return songExecutionTime; } /** Check if the character is a banker */ bool IsBanker() const { return banker; } Modified: trunk/src/server/serversongmngr.cpp =================================================================== --- trunk/src/server/serversongmngr.cpp 2012-02-06 00:26:47 UTC (rev 8062) +++ trunk/src/server/serversongmngr.cpp 2012-02-06 01:52:53 UTC (rev 8063) @@ -44,6 +44,16 @@ : psGameEvent(0, songLength, "psEndSongEvent") { charActor = actor; + + if(charActor->GetMode() == PSCHARACTER_MODE_PLAY) + { + valid = true; + startingTime = charActor->GetCharacterData()->GetSongStartTime(); + } + else + { + valid = false; + } } psEndSongEvent::~psEndSongEvent() @@ -53,7 +63,16 @@ bool psEndSongEvent::CheckTrigger() { - return charActor->GetMode() == PSCHARACTER_MODE_PLAY; + // if the starting time is not the same it means that the player + // stopped the song and now he's playing another one + if(valid + && charActor->GetMode() == PSCHARACTER_MODE_PLAY + && charActor->GetCharacterData()->GetSongStartTime() == startingTime) + { + return true;; + } + + return false; } void psEndSongEvent::Trigger() @@ -319,7 +338,7 @@ // input variables mathEnv.Define("Player", charActor); mathEnv.Define("Instrument", instrItem); - mathEnv.Define("SongTime", charData->GetPlayingTime() / 1000); + mathEnv.Define("SongTime", (csGetTicks() - charData->GetSongStartTime()) / 1000); mathEnv.Define("ScoreRank", scoreRank); // scripts evaluation Modified: trunk/src/server/serversongmngr.h =================================================================== --- trunk/src/server/serversongmngr.h 2012-02-06 00:26:47 UTC (rev 8062) +++ trunk/src/server/serversongmngr.h 2012-02-06 01:52:53 UTC (rev 8063) @@ -46,8 +46,6 @@ class psEndSongEvent: public psGameEvent { public: - gemActor* charActor; ///< The player that plays this song. - /** * Constructor. * @param charActor the player that plays this song. @@ -65,6 +63,10 @@ //------------------ virtual bool CheckTrigger(); virtual void Trigger(); + +private: + gemActor* charActor; ///< The player that plays this song. + csTicks startingTime; ///< The time when the song started. }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |