Skip to content

Commit

Permalink
Excluded PlaySound(uint8 soundType, uint8 soundTypeExt, uint8 soundId…
Browse files Browse the repository at this point in the history
…, uint8 soundIdExt, bool sendSelf).

git-svn-id: https://cvet.by:8443/svn/FOnlineSource/Main@1203 c2c6a35e-ad2b-4e1f-bb64-97b989be360b

Former-commit-id: a115d4d90e0b44904eee62eaf08db9afbc86f4f3
  • Loading branch information
cvet authored and cvet committed Oct 30, 2018
1 parent 3bc7be0 commit 0b6c0dd
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 158 deletions.
5 changes: 0 additions & 5 deletions Source/BufferManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ bool BufferManager::NeedProcess()
return ( NETMSG_FLY_EFFECT_SIZE + bufReadPos <= bufEndPos );
case NETMSG_PLAY_SOUND:
return ( NETMSG_PLAY_SOUND_SIZE + bufReadPos <= bufEndPos );
case NETMSG_PLAY_SOUND_TYPE:
return ( NETMSG_PLAY_SOUND_TYPE_SIZE + bufReadPos <= bufEndPos );
case NETMSG_SEND_TALK_NPC:
return ( NETMSG_SEND_TALK_NPC_SIZE + bufReadPos <= bufEndPos );
case NETMSG_SEND_SAY_NPC:
Expand Down Expand Up @@ -511,9 +509,6 @@ void BufferManager::SkipMsg( uint msg )
case NETMSG_PLAY_SOUND:
size = NETMSG_PLAY_SOUND_SIZE;
break;
case NETMSG_PLAY_SOUND_TYPE:
size = NETMSG_PLAY_SOUND_TYPE_SIZE;
break;
case NETMSG_SEND_TALK_NPC:
size = NETMSG_SEND_TALK_NPC_SIZE;
break;
Expand Down
41 changes: 8 additions & 33 deletions Source/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2028,10 +2028,7 @@ void FOClient::NetProcess()
Net_OnFlyEffect();
break;
case NETMSG_PLAY_SOUND:
Net_OnPlaySound( false );
break;
case NETMSG_PLAY_SOUND_TYPE:
Net_OnPlaySound( true );
Net_OnPlaySound();
break;

case NETMSG_UPDATE_FILES_LIST:
Expand Down Expand Up @@ -3676,31 +3673,14 @@ void FOClient::Net_OnFlyEffect()
}
}

void FOClient::Net_OnPlaySound( bool by_type )
void FOClient::Net_OnPlaySound()
{
if( !by_type )
{
uint synchronize_crid;
char sound_name[ 101 ];
Bin >> synchronize_crid;
Bin.Pop( sound_name, 100 );
sound_name[ 100 ] = 0;
SndMngr.PlaySound( sound_name );
}
else
{
uint synchronize_crid;
uchar sound_type;
uchar sound_type_ext;
uchar sound_id;
uchar sound_id_ext;
Bin >> synchronize_crid;
Bin >> sound_type;
Bin >> sound_type_ext;
Bin >> sound_id;
Bin >> sound_id_ext;
SndMngr.PlaySoundType( sound_type, sound_type_ext, sound_id, sound_id_ext );
}
uint synchronize_crid;
char sound_name[ 101 ];
Bin >> synchronize_crid;
Bin.Pop( sound_name, 100 );
sound_name[ 100 ] = 0;
SndMngr.PlaySound( sound_name );

CHECK_IN_BUFF_ERROR;
}
Expand Down Expand Up @@ -7851,11 +7831,6 @@ bool FOClient::SScriptFunc::Global_PlaySound( ScriptString& sound_name )
return SndMngr.PlaySound( sound_name.c_str() );
}

bool FOClient::SScriptFunc::Global_PlaySoundType( uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext )
{
return SndMngr.PlaySoundType( sound_type, sound_type_ext, sound_id, sound_id_ext );
}

bool FOClient::SScriptFunc::Global_PlayMusic( ScriptString& music_name, uint pos, uint repeat )
{
return SndMngr.PlayMusic( music_name.c_str(), pos, repeat );
Expand Down
3 changes: 1 addition & 2 deletions Source/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class FOClient
void Net_OnCombatResult();
void Net_OnEffect();
void Net_OnFlyEffect();
void Net_OnPlaySound( bool by_type );
void Net_OnPlaySound();
void Net_OnPing();
void Net_OnEndParseToGame();
void Net_OnCheckUID0();
Expand Down Expand Up @@ -423,7 +423,6 @@ class FOClient
static void Global_FlushScreen( uint from_color, uint to_color, uint ms );
static void Global_QuakeScreen( uint noise, uint ms );
static bool Global_PlaySound( ScriptString& sound_name );
static bool Global_PlaySoundType( uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext );
static bool Global_PlayMusic( ScriptString& music_name, uint pos, uint repeat );
static void Global_PlayVideo( ScriptString& video_name, bool can_stop );

Expand Down
20 changes: 0 additions & 20 deletions Source/Critter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1767,11 +1767,6 @@ void Critter::Send_PlaySound( uint crid_synchronize, const char* sound_name )
if( IsPlayer() )
( (Client*) this )->Send_PlaySound( crid_synchronize, sound_name );
}
void Critter::Send_PlaySoundType( uint crid_synchronize, uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext )
{
if( IsPlayer() )
( (Client*) this )->Send_PlaySoundType( crid_synchronize, sound_type, sound_type_ext, sound_id, sound_id_ext );
}

void Critter::SendA_Property( NetProperty::Type type, Property* prop, Entity* entity )
{
Expand Down Expand Up @@ -3686,21 +3681,6 @@ void Client::Send_PlaySound( uint crid_synchronize, const char* sound_name )
BOUT_END( this );
}

void Client::Send_PlaySoundType( uint crid_synchronize, uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext )
{
if( IsSendDisabled() || IsOffline() )
return;

BOUT_BEGIN( this );
Bout << NETMSG_PLAY_SOUND_TYPE;
Bout << crid_synchronize;
Bout << sound_type;
Bout << sound_type_ext;
Bout << sound_id;
Bout << sound_id_ext;
BOUT_END( this );
}

void Client::Send_ViewMap()
{
if( IsSendDisabled() || IsOffline() )
Expand Down
2 changes: 0 additions & 2 deletions Source/Critter.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ class Critter: public Entity
void Send_Effect( hash eff_pid, ushort hx, ushort hy, ushort radius );
void Send_FlyEffect( hash eff_pid, uint from_crid, uint to_crid, ushort from_hx, ushort from_hy, ushort to_hx, ushort to_hy );
void Send_PlaySound( uint crid_synchronize, const char* sound_name );
void Send_PlaySoundType( uint crid_synchronize, uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext );

// Send all
void SendA_Property( NetProperty::Type type, Property* prop, Entity* entity );
Expand Down Expand Up @@ -512,7 +511,6 @@ class Client: public Critter
void Send_Effect( hash eff_pid, ushort hx, ushort hy, ushort radius );
void Send_FlyEffect( hash eff_pid, uint from_crid, uint to_crid, ushort from_hx, ushort from_hy, ushort to_hx, ushort to_hy );
void Send_PlaySound( uint crid_synchronize, const char* sound_name );
void Send_PlaySoundType( uint crid_synchronize, uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext );
void Send_MapText( ushort hx, ushort hy, uint color, const char* text, ushort text_len, bool unsafe_text );
void Send_MapTextMsg( ushort hx, ushort hy, uint color, ushort num_msg, uint num_str );
void Send_MapTextMsgLex( ushort hx, ushort hy, uint color, ushort num_msg, uint num_str, const char* lexems, ushort lexems_len );
Expand Down
2 changes: 0 additions & 2 deletions Source/DummyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ struct BindClass
static void Crit_Animate() {}
static void Crit_SetAnims() {}
static void Crit_PlaySound() {}
static void Crit_PlaySoundType() {}

static void Crit_IsKnownLoc() {}
static void Crit_SetKnownLoc() {}
Expand Down Expand Up @@ -447,7 +446,6 @@ struct BindClass
static void Global_FlushScreen() {}
static void Global_QuakeScreen() {}
static void Global_PlaySound() {}
static void Global_PlaySoundType() {}
static void Global_PlayMusic() {}
static void Global_PlayVideo() {}
static void Global_GetCurrentMapPid() {}
Expand Down
12 changes: 0 additions & 12 deletions Source/NetProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,18 +595,6 @@
// char sound_name[16]
// ////////////////////////////////////////////////////////////////////////

#define NETMSG_PLAY_SOUND_TYPE MAKE_NETMSG_HEADER( 102 )
#define NETMSG_PLAY_SOUND_TYPE_SIZE ( sizeof( uint ) + sizeof( uint ) + sizeof( uchar ) * 4 )
// ////////////////////////////////////////////////////////////////////////
//
// Params:
// uint crid_synchronize
// uchar sound_type
// uchar sound_type_ext
// uchar sound_id
// uchar sound_id_ext
// ////////////////////////////////////////////////////////////////////////

// ************************************************************************
// TALK&BARTER NPC
// ************************************************************************
Expand Down
2 changes: 0 additions & 2 deletions Source/ScriptBind.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ BIND_ASSERT( engine->RegisterObjectMethod( "Critter", "void Action(int action, i
BIND_ASSERT( engine->RegisterObjectMethod( "Critter", "void Animate(uint anim1, uint anim2, const Item@+ item, bool clearSequence, bool delayPlay)", asFUNCTION( BIND_CLASS Crit_Animate ), asCALL_CDECL_OBJFIRST ) );
BIND_ASSERT( engine->RegisterObjectMethod( "Critter", "void SetAnims(int cond, uint anim1, uint anim2)", asFUNCTION( BIND_CLASS Crit_SetAnims ), asCALL_CDECL_OBJFIRST ) );
BIND_ASSERT( engine->RegisterObjectMethod( "Critter", "void PlaySound(string& soundName, bool sendSelf)", asFUNCTION( BIND_CLASS Crit_PlaySound ), asCALL_CDECL_OBJFIRST ) );
BIND_ASSERT( engine->RegisterObjectMethod( "Critter", "void PlaySound(uint8 soundType, uint8 soundTypeExt, uint8 soundId, uint8 soundIdExt, bool sendSelf)", asFUNCTION( BIND_CLASS Crit_PlaySoundType ), asCALL_CDECL_OBJFIRST ) );

BIND_ASSERT( engine->RegisterObjectMethod( "Critter", "void SendCombatResult(array<uint>& combatResult)", asFUNCTION( BIND_CLASS Crit_SendCombatResult ), asCALL_CDECL_OBJFIRST ) );
BIND_ASSERT( engine->RegisterObjectMethod( "Critter", "bool IsKnownLoc(bool byId, uint locNum) const", asFUNCTION( BIND_CLASS Crit_IsKnownLoc ), asCALL_CDECL_OBJFIRST ) );
Expand Down Expand Up @@ -515,7 +514,6 @@ BIND_ASSERT( engine->RegisterGlobalFunction( "uint GetPathLength(Critter& cr, ui
BIND_ASSERT( engine->RegisterGlobalFunction( "void FlushScreen(uint fromColor, uint toColor, uint timeMs)", asFUNCTION( BIND_CLASS Global_FlushScreen ), asCALL_CDECL ) );
BIND_ASSERT( engine->RegisterGlobalFunction( "void QuakeScreen(uint noise, uint timeMs)", asFUNCTION( BIND_CLASS Global_QuakeScreen ), asCALL_CDECL ) );
BIND_ASSERT( engine->RegisterGlobalFunction( "bool PlaySound(string& soundName)", asFUNCTION( BIND_CLASS Global_PlaySound ), asCALL_CDECL ) );
BIND_ASSERT( engine->RegisterGlobalFunction( "bool PlaySound(uint8 soundType, uint8 soundTypeExt, uint8 soundId, uint8 soundIdExt)", asFUNCTION( BIND_CLASS Global_PlaySoundType ), asCALL_CDECL ) );
BIND_ASSERT( engine->RegisterGlobalFunction( "bool PlayMusic(string& musicName, uint pos, uint repeat)", asFUNCTION( BIND_CLASS Global_PlayMusic ), asCALL_CDECL ) );
BIND_ASSERT( engine->RegisterGlobalFunction( "void PlayVideo(string& videoName, bool canStop)", asFUNCTION( BIND_CLASS Global_PlayVideo ), asCALL_CDECL ) );
BIND_ASSERT( engine->RegisterGlobalFunction( "hash GetCurrentMapPid()", asFUNCTION( BIND_CLASS Global_GetCurrentMapPid ), asCALL_CDECL ) );
Expand Down
1 change: 0 additions & 1 deletion Source/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ class FOServer
static void Crit_Animate( Critter* cr, uint anim1, uint anim2, Item* item, bool clear_sequence, bool delay_play );
static void Crit_SetAnims( Critter* cr, int cond, uint anim1, uint anim2 );
static void Crit_PlaySound( Critter* cr, ScriptString& sound_name, bool send_self );
static void Crit_PlaySoundType( Critter* cr, uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext, bool send_self );

static bool Crit_IsKnownLoc( Critter* cr, bool by_id, uint loc_num );
static bool Crit_SetKnownLoc( Critter* cr, bool by_id, uint loc_num );
Expand Down
15 changes: 0 additions & 15 deletions Source/ServerScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1709,21 +1709,6 @@ void FOServer::SScriptFunc::Crit_PlaySound( Critter* cr, ScriptString& sound_nam
}
}

void FOServer::SScriptFunc::Crit_PlaySoundType( Critter* cr, uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext, bool send_self )
{
if( cr->IsDestroyed )
SCRIPT_ERROR_R( "Attempt to call method on destroyed object." );

uint crid = cr->GetId();
if( send_self )
cr->Send_PlaySoundType( crid, sound_type, sound_type_ext, sound_id, sound_id_ext );
for( auto it = cr->VisCr.begin(), end = cr->VisCr.end(); it != end; ++it )
{
Critter* cr_ = *it;
cr_->Send_PlaySoundType( crid, sound_type, sound_type_ext, sound_id, sound_id_ext );
}
}

bool FOServer::SScriptFunc::Crit_IsKnownLoc( Critter* cr, bool by_id, uint loc_num )
{
if( cr->IsDestroyed )
Expand Down
63 changes: 0 additions & 63 deletions Source/SoundManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,69 +641,6 @@ bool SoundManager::PlaySound( const char* name )
return false;
}

bool SoundManager::PlaySoundType( uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext )
{
if( !isActive || !GameOpt.SoundVolume )
return true;

// Generate name of the sound
StrMap& names = ResMngr.GetSoundNames();
char name[ 9 ];
if( sound_type == 'W' ) // Weapon, W123XXXR
{
name[ 0 ] = 'W';
name[ 1 ] = sound_type_ext;
name[ 2 ] = sound_id;
name[ 3 ] = sound_id_ext;
name[ 4 ] = 'X';
name[ 5 ] = 'X';
name[ 6 ] = 'X';
name[ 7 ] = '1';
name[ 8 ] = '\0';

// Try count dublier
if( !Random( 0, 1 ) )
{
name[ 7 ] = '2';
Str::Upper( name );
if( !names.count( name ) )
name[ 7 ] = '1';
}
}
else if( sound_type == 'S' ) // Door
{
name[ 0 ] = 'S';
name[ 1 ] = sound_type_ext;
name[ 2 ] = 'D';
name[ 3 ] = 'O';
name[ 4 ] = 'O';
name[ 5 ] = 'R';
name[ 6 ] = 'S';
name[ 7 ] = sound_id;
name[ 8 ] = '\0';
}
else // Other
{
name[ 0 ] = sound_type;
name[ 1 ] = sound_type_ext;
name[ 2 ] = sound_id;
name[ 3 ] = sound_id_ext;
name[ 4 ] = 'X';
name[ 5 ] = 'X';
name[ 6 ] = 'X';
name[ 7 ] = 'X';
name[ 8 ] = '\0';
}
Str::Upper( name );

auto it = names.find( name );
if( it == names.end() )
return false;

// Play
return PlaySound( it->second.c_str() );
}

bool SoundManager::PlayMusic( const char* fname, uint pos, uint repeat )
{
if( !isActive )
Expand Down
1 change: 0 additions & 1 deletion Source/SoundManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class SoundManager
void ClearSounds();

bool PlaySound( const char* name );
bool PlaySoundType( uchar sound_type, uchar sound_type_ext, uchar sound_id, uchar sound_id_ext );
bool PlayMusic( const char* fname, uint pos = 0, uint repeat = MUSIC_REPEAT_TIME );
void StopMusic();
void PlayAmbient( const char* str );
Expand Down

0 comments on commit 0b6c0dd

Please sign in to comment.