Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Engine.VoiceChatReplicationInfo


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
//==============================================================================
//	Contains information about the existing voice chat channels on the server.
//	This class is simply a placeholder for the VoiceReplicationInfo, and should
//	be implemented in a multi-player capable subclass.
//
//	Created by Ron Prestenback
//	© 2003, Epic Games, Inc.  All Rights Reserved
//==============================================================================
class VoiceChatReplicationInfo extends ReplicationInfo
    config
    abstract
    notplaceable
    native
    nativereplication;

// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)

const NUMPROPS = 6;

struct native VoiceChatCodec
{
    var string Codec;
    var localized string CodecName;
    var localized string CodecDescription;
};

var int PublicMask, LocalMask;

// Array of chatroom channels
var protected array<VoiceChatRoom>  Channels;
var localized array<string> PublicChannelNames;
var localized string VCDisplayText[NUMPROPS], VCDescText[NUMPROPS];

var GameReplicationInfo GRI;

var class<VoiceChatRoom>    ChatRoomClass;
var array<VoiceChatCodec>  InstalledCodec;

var globalconfig array<string>  VoIPInternetCodecs;
var globalconfig array<string>  VoIPLANCodecs;

var globalconfig bool       bEnableVoiceChat;         // Whether voice over IP is enabled on this server
var globalconfig bool       bAllowLocalBroadcast;     // Whether this server allows local channels
var globalconfig int        MaxChatters;              // Max number of chatters allowed in a chatroom (0 - unlimited)
var              int        DefaultChannel;           // Channel that should be the default active channel for incoming clients that don't specify a default active channel

var globalconfig float      LocalBroadcastRange;      // Maximum distance a local broadcast can be heard
var globalconfig float      DefaultBroadcastRadius;   // Distance at which broadcast volume begins to fade
var float                   BroadcastRadius;

var bool                    bPrivateChat;             // Set by UnrealMPGameInfo.InitVoiceReplicationInfo()
var bool                    bRefresh;                 // Indicates a chat room has destroyed itself

replication
{
    reliable if ( Role == ROLE_Authority && bNetInitial )
        bEnableVoiceChat;

    reliable if ( Role == ROLE_Authority && bNetInitial && bEnableVoiceChat )
        bPrivateChat;

    reliable if ( Role == ROLE_Authority && bNetInitial && bEnableVoiceChat && bAllowLocalBroadcast )
        BroadcastRadius;

    reliable if ( Role == ROLE_Authority && bNetDirty && bEnableVoiceChat )
        PublicMask, LocalMask;

    reliable if ( Role == ROLE_Authority && (bNetInitial || bNetDirty) && bEnableVoiceChat )
        DefaultChannel;
}

event Timer()
{
    // One of our channels has destroyed itself
    if (bRefresh)
        CheckChannels();
}

event PostBeginPlay()
{
    Super.PostBeginPlay();

    if ( bAllowLocalBroadcast )
        BroadcastRadius = FMin(LocalBroadcastRange, FClamp(DefaultBroadcastRadius, 10, 1000));
}

simulated event PostNetBeginPlay()
{
    // Initialize all public channels.
    if ( bEnableVoiceChat )
    {
        InitChannels();
        SetTimer(1.0, True);
    }
}
simulated function InitChannels();

// This is called when a new player has logged into the server.
simulated function              AddVoiceChatter(PlayerReplicationInfo    NewPRI);
// Called when a player logs out
simulated function              RemoveVoiceChatter(PlayerReplicationInfo    PRI);
// Used to prescreen whether 'PRI' would be allowed to join channel with title 'ChannelTitle'
simulated function bool         CanJoinChannel(string ChannelTitle, PlayerReplicationInfo PRI) { return true; }

// Joins / Leaves
// Called when player requests to join channel
function VoiceChatRoom.EJoinChatResult        JoinChannel(string ChannelTitle, PlayerReplicationInfo PRI, string Password) { return JCR_Invalid;  }
function VoiceChatRoom.EJoinChatResult        JoinChannelAt(int ChannelIndex, PlayerReplicationInfo PRI, string Password)  { return JCR_Invalid;  }
// Called when player leaves channel
function bool                   LeaveChannel(string ChannelTitle, PlayerReplicationInfo PRI)                 { return true; }

// Channel management
simulated function VoiceChatRoom        AddVoiceChannel(optional PlayerReplicationInfo PRI)    { return None; }
simulated function bool                 RemoveVoiceChannel(PlayerReplicationInfo PRI) { return true; }
// Called on all voice channels when a player switches teams.  Disregarded by voice channel if TeamIndex doesn't match channel's teamindex
simulated function                      NotifyTeamChange(PlayerReplicationInfo PRI, int TeamIndex);

// Query Functions
simulated event    int                  GetChannelCount()                                            { return 0;    }
simulated event    int                  GetChannelIndex(string ChannelTitle, optional int TeamIndex) { return -1;   }

simulated function VoiceChatRoom        GetChannel(string ChatRoomName, optional int TeamIndex)      { return None; }
simulated function VoiceChatRoom        GetChannelAt(int Index)                                      { return None; }
// Returns a list of members in the specified channel
simulated function array<int>           GetChannelMembers(string ChatRoomName, optional int TeamIndex);
simulated function array<int>           GetChannelMembersAt(int Index);
// Returns a list of channels that the specified player is a member of
simulated function array<int>           GetMemberChannels( PlayerReplicationInfo PRI );

simulated function string               GetDefaultChannel()
{
    return PublicChannelNames[Clamp(DefaultChannel,0,PublicChannelNames.Length - 1)];
}

simulated function array<VoiceChatRoom> GetChannels();
simulated function array<VoiceChatRoom> GetPublicChannels();
simulated function array<VoiceChatRoom> GetPlayerChannels();
simulated function int                  GetPublicChannelCount(optional bool bSingleTeam);
simulated function int                  GetPlayerChannelCount();
// Returns whether 'TestPRI' is a member of this channel.  If bNoCacade is false, will return true if player is member of child channels
simulated function bool                 IsMember(PlayerReplicationInfo TestPRI, int ChannelIndex, optional bool bNoCascade) { return false; }
// Internal functions
simulated protected function VoiceChatRoom  CreateNewVoiceChannel(optional PlayerReplicationInfo PRI) { return None; }
// Called from RemoveVoiceChatter()
simulated protected function                        DestroyVoiceChannel(VoiceChatRoom Channel);
simulated private   function            CheckChannels()
{
    local int i;

    for (i = Channels.Length - 1; i >= 0; i--)
        if (Channels[i] == None)
            Channels.Remove(i,1);

    bRefresh = False;
}

static function FillPlayInfo( PlayInfo PlayInfo )
{
    Super.FillPlayInfo( PlayInfo );

    PlayInfo.AddSetting( default.ChatGroup, "bEnableVoiceChat",        default.VCDisplayText[0], 250, 1, "Check",            , "Xv", True, True);
    PlayInfo.AddSetting( default.ChatGroup, "bAllowLocalBroadcast",    default.VCDisplayText[1], 250, 1, "Check",            , "Xv", True, True);
    PlayInfo.AddSetting( default.ChatGroup, "LocalBroadcastRange",     default.VCDisplayText[2], 100, 1,  "Text", "4;10:3000", "Xv", True, True);
    PlayInfo.AddSetting( default.ChatGroup, "DefaultBroadcastRadius",  default.VCDisplayText[3], 100, 1,  "Text", "4;10:1000", "Xv", True, True);
    PlayInfo.AddSetting( default.ChatGroup, "VoIPInternetCodecs",      default.VCDisplayText[4], 254, 1,  "Text",            , "Xv", True, True);
    PlayInfo.AddSetting( default.ChatGroup, "VoIPLANCodecs",           default.VCDisplayText[5], 254, 1,  "Text",            , "Xv", True, True);
}

static event string GetDescriptionText( string PropName )
{
    switch ( PropName )
    {
    case "bEnableVoiceChat":        return default.VCDescText[0];
    case "bAllowLocalBroadcast":    return default.VCDescText[1];
    case "LocalBroadcastRange":     return default.VCDescText[2];
    case "DefaultBroadcastRadius":  return default.VCDescText[3];
    case "VoIPInternetCodecs":      return default.VCDescText[4];
    case "VoIPLANCodecs":           return default.VCDescText[5];
    }

    return Super.GetDescriptionText(PropName);
}

static function GetInstalledCodecs( out array<string> Codecs )
{
    local int i;

    Codecs.Length = default.InstalledCodec.Length;
    for ( i = 0; i < default.InstalledCodec.Length; i++ )
        Codecs[i] = default.InstalledCodec[i].Codec;
}

static function bool GetCodecInfo( string Codec, out string CodecName, out string CodecDescription )
{
    local int i;

    for ( i = 0; i < default.InstalledCodec.Length; i++ )
    {
        if ( Codec ~= default.InstalledCodec[i].Codec )
        {
            CodecName = default.InstalledCodec[i].CodecName;
            CodecDescription = default.InstalledCodec[i].CodecDescription;
            return true;
        }
    }

    return false;
}

simulated function bool ValidRoom( VoiceChatRoom Room )
{
    return bEnableVoiceChat && Room != None && Room.ChannelIndex < 2 && Room.Owner == Self;
}

function SetMask( VoiceChatRoom Room, int NewMask )
{
    if ( !ValidRoom(Room) )
        return;

    if ( Room.ChannelIndex == 0 )
        PublicMask = NewMask;

    else if ( Room.ChannelIndex == 1 )
        LocalMask = NewMask;
}

simulated function int GetMask( VoiceChatRoom Room )
{
    if ( !ValidRoom(Room) )
        return 0;

    if ( Room.ChannelIndex == 0 )
        return PublicMask;

    if ( Room.ChannelIndex == 1 )
        return LocalMask;

    return 0;
}

simulated function string GetTitle( VoiceChatRoom Room )
{
    if ( !ValidRoom(Room) )
        return "";

    return PublicChannelNames[Room.ChannelIndex];
}

defaultproperties
{
     PublicChannelNames(0)="Public"
     PublicChannelNames(1)="Local"
     VCDisplayText(0)="Enable Voice Chat"
     VCDisplayText(1)="Enable local Channel"
     VCDisplayText(2)="Local Chat Range"
     VCDisplayText(3)="Local Chat Radius"
     VCDisplayText(4)="Allowed VoIP Codecs"
     VCDisplayText(5)="Allowed VoIP LAN Codecs"
     VCDescText(0)="Enable voice chat on the server."
     VCDescText(1)="Determines whether the "local" voice chat channel is created, which allows players to broadcast voice transmissions to all players in the immediate vicinity."
     VCDescText(2)="Maximum distance at which a broadcast on the local channel may be heard"
     VCDescText(3)="Distance at which local broadcasts begin to fade"
     VCDescText(4)="Configure which codecs exist on the server and should be used in Internet games."
     VCDescText(5)="Configure which codecs exist on the server and should be used in LAN games."
     ChatRoomClass=Class'Engine.VoiceChatRoom'
     InstalledCodec(0)=(Codec="CODEC_48NB",CodecName="Less Bandwidth",CodecDescription="(4.8kbps) - Uses less bandwidth, but sound is not as clear.")
     InstalledCodec(1)=(Codec="CODEC_96WB",CodecName="Better Quality",CodecDescription="(9.6kbps) - Uses more bandwidth, but sound is much clearer.")
     VoIPInternetCodecs(0)="CODEC_48NB"
     VoIPLANCodecs(0)="CODEC_48NB"
     VoIPLANCodecs(1)="CODEC_96WB"
     bEnableVoiceChat=True
     bAllowLocalBroadcast=True
     LocalBroadcastRange=1000.000000
     DefaultBroadcastRadius=20.000000
     NetPriority=3.001000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 23/10/2006 20:25:16.000 - Creation time: Wed 7/2/2007 19:16:58.500 - Created with UnCodeX