Skip to content

Commit

Permalink
Add config setting for gateway delimiter
Browse files Browse the repository at this point in the history
The setting goes under [Emulation], GatewayDelimiter.

Blizzard recently changed this from @ to #, breaking naming conventions
and messing up user databases. This setting is by default the new
delimiter (#), but can be changed should Blizzard decide to reverse
their decision.

All instances of @ when dealing with gateways/realms has been updated to
use this value.

Fixes #33
  • Loading branch information
Davnit committed Feb 24, 2017
1 parent 7b461a4 commit 480b515
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 35 deletions.
12 changes: 12 additions & 0 deletions trunk/clsConfig.cls
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Private m_ProductLanguage As String
Private m_ServerCommandList As String
Private m_VersionBytes(8) As Long 'XXVerByte
Private m_LogonSystems(8) As Long 'XXLogonSystem
Private m_GatewayDelimiter As String

'[DEBUG]
Private m_DebugWarden As Boolean
Expand Down Expand Up @@ -1470,6 +1471,14 @@ Public Property Let ServerCommandList(ByVal sValue As String)
m_ServerCommandList = sValue
End Property

Public Property Get GatewayDelimiter() As String
GatewayDelimiter = m_GatewayDelimiter
End Property

Public Property Let GatewayDelimiter(ByVal sValue As String)
m_GatewayDelimiter = sValue
End Property


'-------------------------
' SECTION: DEBUG
Expand Down Expand Up @@ -1777,6 +1786,7 @@ Public Sub Save(Optional ByVal sFilePath As String = vbNullString)
WriteSetting SECTION_EMULATION, "PlatformID", m_PlatformID
WriteSetting SECTION_EMULATION, "ProductLanguage", m_ProductLanguage
WriteSetting SECTION_EMULATION, "ServerCommandList", m_ServerCommandList
WriteSetting SECTION_EMULATION, "GatewayDelimiter", m_GatewayDelimiter

WriteSetting SECTION_DEBUG, "Warden", m_DebugWarden

Expand Down Expand Up @@ -1969,6 +1979,7 @@ Private Sub LoadDefaults()
m_PlatformID = "IX86"
m_ProductLanguage = vbNullString
m_ServerCommandList = "w %,whisper %,m %,msg %,f m,clan mail,c mail,clan motd,c motd,away,dnd,ban %,kick %,j,join,channel,me,emote"
m_GatewayDelimiter = "#"

Dim i As Integer
For i = LBound(m_ProductKeys) To UBound(m_ProductKeys)
Expand Down Expand Up @@ -2301,6 +2312,7 @@ Private Sub LoadVersion6Config()
m_PlatformID = ReadSetting(SECTION_EMULATION, "PlatformID", m_PlatformID)
m_ProductLanguage = ReadSetting(SECTION_EMULATION, "ProductLanguage", m_ProductLanguage)
m_ServerCommandList = ReadSetting(SECTION_EMULATION, "ServerCommandList", m_ServerCommandList)
m_GatewayDelimiter = ReadSetting(SECTION_EMULATION, "GatewayDelimiter", m_GatewayDelimiter)

m_DebugWarden = ReadSettingB(SECTION_DEBUG, "Warden", m_DebugWarden)

Expand Down
2 changes: 1 addition & 1 deletion trunk/frmChat.frm
Original file line number Diff line number Diff line change
Expand Up @@ -7778,7 +7778,7 @@ Function MatchClosest(ByVal toMatch As String, Optional startIndex As Long = 1)
End If
End With

atChar = InStr(1, toMatch, "@", vbBinaryCompare)
atChar = InStr(1, toMatch, Config.GatewayDelimiter, vbBinaryCompare)

If (atChar <> 0) Then
Dim tmp As String
Expand Down
24 changes: 12 additions & 12 deletions trunk/modCommands.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1392,15 +1392,15 @@ Private Function CheckUser(ByVal User As String, Optional ByVal allow_illegal As
User = Mid$(User, 2)
End If

User = Replace(User, "@USWest", vbNullString, 1)
User = Replace(User, "@USEast", vbNullString, 1)
User = Replace(User, "@Asia", vbNullString, 1)
User = Replace(User, "@Europe", vbNullString, 1)
User = Replace(User, Config.GatewayDelimiter & "USWest", vbNullString, 1)
User = Replace(User, Config.GatewayDelimiter & "USEast", vbNullString, 1)
User = Replace(User, Config.GatewayDelimiter & "Asia", vbNullString, 1)
User = Replace(User, Config.GatewayDelimiter & "Europe", vbNullString, 1)

User = Replace(User, "@Lordaeron", vbNullString, 1)
User = Replace(User, "@Azeroth", vbNullString, 1)
User = Replace(User, "@Kalimdor", vbNullString, 1)
User = Replace(User, "@Northrend", vbNullString, 1)
User = Replace(User, Config.GatewayDelimiter & "Lordaeron", vbNullString, 1)
User = Replace(User, Config.GatewayDelimiter & "Azeroth", vbNullString, 1)
User = Replace(User, Config.GatewayDelimiter & "Kalimdor", vbNullString, 1)
User = Replace(User, Config.GatewayDelimiter & "Northrend", vbNullString, 1)

If (Len(User) = 0) Then
invalid = True
Expand Down Expand Up @@ -1546,7 +1546,7 @@ Public Function ConvertUsernameGateway(ByVal Username As String, Optional ByVal
Next i

' is user on other namespace?
Index = InStr(1, Username, "@" & Gateways(i, IIf(MyGatewayIndex = 0, 1, 0)), vbTextCompare)
Index = InStr(1, Username, Config.GatewayDelimiter & Gateways(i, IIf(MyGatewayIndex = 0, 1, 0)), vbTextCompare)

' store whether user is on other namespace
' (whether the other @gateway was found)
Expand All @@ -1573,7 +1573,7 @@ Public Function ConvertUsernameGateway(ByVal Username As String, Optional ByVal
ConvertUsernameGateway = Left$(Username, Index - 1)
Else
' return username with our namespace
ConvertUsernameGateway = Username & "@" & BotVars.Gateway
ConvertUsernameGateway = Username & Config.GatewayDelimiter & BotVars.Gateway
End If
Else
' we are not converting, leave it alone
Expand Down Expand Up @@ -1744,7 +1744,7 @@ Public Function ReverseConvertUsernameGateway(ByVal Username As String) As Strin
Next i

' is user on this namespace?
Index = InStr(1, Username, "@" & MyGateway, vbTextCompare)
Index = InStr(1, Username, Config.GatewayDelimiter & MyGateway, vbTextCompare)

' store whether user is on this namespace
' (whether this @gateway was found)
Expand All @@ -1771,7 +1771,7 @@ Public Function ReverseConvertUsernameGateway(ByVal Username As String) As Strin
ReverseConvertUsernameGateway = Left$(Username, Index - 1)
Else
' return username with their namespace
ReverseConvertUsernameGateway = Username & "@" & Gateways(i, IIf(MyGatewayIndex = 0, 1, 0))
ReverseConvertUsernameGateway = Username & Config.GatewayDelimiter & Gateways(i, IIf(MyGatewayIndex = 0, 1, 0))
End If
Else
' we are not converting, leave it alone
Expand Down
2 changes: 1 addition & 1 deletion trunk/modCommandsOps.bas
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ Public Sub OnIPBan(Command As clsCommandObj)
sTarget = StripInvalidNameChars(Command.Argument("Username"))

If (LenB(sTarget) > 0) Then
If (InStr(1, sTarget, "@") > 0) Then sTarget = StripRealm(sTarget)
If (InStr(1, sTarget, Config.GatewayDelimiter) > 0) Then sTarget = StripRealm(sTarget)

If (dbAccess.Rank < 101) Then
If (GetSafelist(sTarget) Or GetSafelist(Command.Argument("Username"))) Then
Expand Down
42 changes: 21 additions & 21 deletions trunk/modOtherCode.bas
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ Public Function StripAccountNumber(ByVal Username As String) As String

numpos = InStr(1, Username, "#", vbBinaryCompare)
If numpos > 0 Then
atpos = InStr(numpos, Username, "@", vbBinaryCompare)
atpos = InStr(numpos, Username, Config.GatewayDelimiter, vbBinaryCompare)
If atpos > 0 Then
StripAccountNumber = Left$(Username, numpos - 1) & Mid$(Username, atpos)
Else
Expand All @@ -465,20 +465,20 @@ Public Function StripAccountNumber(ByVal Username As String) As String
End Function

Public Function StripRealm(ByVal Username As String) As String
If (InStr(1, Username, "@", vbBinaryCompare) > 0) Then
Username = Replace(Username, "@USWest", vbNullString, 1)
Username = Replace(Username, "@USEast", vbNullString, 1)
Username = Replace(Username, "@Asia", vbNullString, 1)
Username = Replace(Username, "@Euruope", vbNullString, 1)
Username = Replace(Username, "@Beta", vbNullString, 1)
If (InStr(1, Username, Config.GatewayDelimiter, vbBinaryCompare) > 0) Then
Username = Replace(Username, Config.GatewayDelimiter & "USWest", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "USEast", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "Asia", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "Euruope", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "Beta", vbNullString, 1)

Username = Replace(Username, "@Lordaeron", vbNullString, 1)
Username = Replace(Username, "@Azeroth", vbNullString, 1)
Username = Replace(Username, "@Kalimdor", vbNullString, 1)
Username = Replace(Username, "@Northrend", vbNullString, 1)
Username = Replace(Username, "@Westfall", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "Lordaeron", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "Azeroth", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "Kalimdor", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "Northrend", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "Westfall", vbNullString, 1)

Username = Replace(Username, "@Blizzard", vbNullString, 1)
Username = Replace(Username, Config.GatewayDelimiter & "Blizzard", vbNullString, 1)
End If

StripRealm = Username
Expand Down Expand Up @@ -1601,8 +1601,8 @@ Public Function NameWithoutRealm(ByVal Username As String, Optional ByVal Strict
If ((IsW3) And (Strict = 0)) Then
NameWithoutRealm = Username
Else
If (InStr(1, Username, "@", vbBinaryCompare) > 0) Then
NameWithoutRealm = Left$(Username, InStr(1, Username, "@") - 1)
If (InStr(1, Username, Config.GatewayDelimiter, vbBinaryCompare) > 0) Then
NameWithoutRealm = Left$(Username, InStr(1, Username, Config.GatewayDelimiter) - 1)
Else
NameWithoutRealm = Username
End If
Expand All @@ -1619,8 +1619,8 @@ Public Function GetW3Realm(Optional ByVal Username As String) As String
If (LenB(Username) = 0) Then
GetW3Realm = BotVars.Gateway
Else
If (InStr(1, Username, "@", vbBinaryCompare) > 0) Then
GetW3Realm = Mid$(Username, InStr(1, Username, "@", _
If (InStr(1, Username, Config.GatewayDelimiter, vbBinaryCompare) > 0) Then
GetW3Realm = Mid$(Username, InStr(1, Username, Config.GatewayDelimiter, _
vbBinaryCompare) + 1)
Else
GetW3Realm = BotVars.Gateway
Expand Down Expand Up @@ -1768,10 +1768,10 @@ Public Sub RemoveBanFromQueue(ByVal sUser As String)
Dim strGateway As String

Select Case (BotVars.Gateway)
Case "Lordaeron": strGateway = "@USWest"
Case "Azeroth": strGateway = "@USEast"
Case "Kalimdor": strGateway = "@Asia"
Case "Northrend": strGateway = "@Europe"
Case "Lordaeron": strGateway = Config.GatewayDelimiter & "USWest"
Case "Azeroth": strGateway = Config.GatewayDelimiter & "USEast"
Case "Kalimdor": strGateway = Config.GatewayDelimiter & "Asia"
Case "Northrend": strGateway = Config.GatewayDelimiter & "Europe"
End Select

If (InStr(1, tmp, strGateway, vbTextCompare) = 0) Then
Expand Down

0 comments on commit 480b515

Please sign in to comment.