Core/bnetserver: Add compatibility for classic clients
Port From (https://github.com/TrinityCore/TrinityCore/commit/89652bd78f3e6333e0f7b8ff5fe65ee144a173a8)
This commit is contained in:
@@ -23,13 +23,25 @@ namespace BNetServer.Networking
|
|||||||
|
|
||||||
Bgs.Protocol.Attribute command = null;
|
Bgs.Protocol.Attribute command = null;
|
||||||
Dictionary<string, Variant> Params = new();
|
Dictionary<string, Variant> Params = new();
|
||||||
|
string removeSuffix(string str)
|
||||||
|
{
|
||||||
|
var pos = str.LastIndexOf('_');
|
||||||
|
if (pos != -1)
|
||||||
|
return str.Substring(0, pos);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < request.Attribute.Count; ++i)
|
for (int i = 0; i < request.Attribute.Count; ++i)
|
||||||
{
|
{
|
||||||
Bgs.Protocol.Attribute attr = request.Attribute[i];
|
Bgs.Protocol.Attribute attr = request.Attribute[i];
|
||||||
Params[attr.Name] = attr.Value;
|
|
||||||
if (attr.Name.Contains("Command_"))
|
if (attr.Name.Contains("Command_"))
|
||||||
|
{
|
||||||
command = attr;
|
command = attr;
|
||||||
|
Params[removeSuffix(attr.Name)] = attr.Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Params[attr.Name] = attr.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == null)
|
if (command == null)
|
||||||
@@ -38,12 +50,12 @@ namespace BNetServer.Networking
|
|||||||
return BattlenetRpcErrorCode.RpcMalformedRequest;
|
return BattlenetRpcErrorCode.RpcMalformedRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
return command.Name switch
|
return removeSuffix(command.Name) switch
|
||||||
{
|
{
|
||||||
"Command_RealmListTicketRequest_v1_b9" => GetRealmListTicket(Params, response),
|
"Command_RealmListTicketRequest_v1" => GetRealmListTicket(Params, response),
|
||||||
"Command_LastCharPlayedRequest_v1_b9" => GetLastCharPlayed(Params, response),
|
"Command_LastCharPlayedRequest_v1" => GetLastCharPlayed(Params, response),
|
||||||
"Command_RealmListRequest_v1_b9" => GetRealmList(Params, response),
|
"Command_RealmListRequest_v1" => GetRealmList(Params, response),
|
||||||
"Command_RealmJoinRequest_v1_b9" => JoinRealm(Params, response),
|
"Command_RealmJoinRequest_v1" => JoinRealm(Params, response),
|
||||||
_ => BattlenetRpcErrorCode.RpcNotImplemented
|
_ => BattlenetRpcErrorCode.RpcNotImplemented
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -54,7 +66,7 @@ namespace BNetServer.Networking
|
|||||||
if (!authed)
|
if (!authed)
|
||||||
return BattlenetRpcErrorCode.Denied;
|
return BattlenetRpcErrorCode.Denied;
|
||||||
|
|
||||||
if (request.AttributeKey == "Command_RealmListRequest_v1_b9")
|
if (request.AttributeKey == "Command_RealmListRequest_v1")
|
||||||
{
|
{
|
||||||
Global.RealmMgr.WriteSubRegions(response);
|
Global.RealmMgr.WriteSubRegions(response);
|
||||||
return BattlenetRpcErrorCode.Ok;
|
return BattlenetRpcErrorCode.Ok;
|
||||||
@@ -115,7 +127,7 @@ namespace BNetServer.Networking
|
|||||||
|
|
||||||
BattlenetRpcErrorCode GetLastCharPlayed(Dictionary<string, Variant> Params, ClientResponse response)
|
BattlenetRpcErrorCode GetLastCharPlayed(Dictionary<string, Variant> Params, ClientResponse response)
|
||||||
{
|
{
|
||||||
Variant subRegion = Params.LookupByKey("Command_LastCharPlayedRequest_v1_b9");
|
Variant subRegion = Params.LookupByKey("Command_LastCharPlayedRequest_v1");
|
||||||
if (subRegion != null)
|
if (subRegion != null)
|
||||||
{
|
{
|
||||||
var lastPlayerChar = gameAccountInfo.LastPlayedCharacters.LookupByKey(subRegion.StringValue);
|
var lastPlayerChar = gameAccountInfo.LastPlayedCharacters.LookupByKey(subRegion.StringValue);
|
||||||
@@ -162,7 +174,7 @@ namespace BNetServer.Networking
|
|||||||
return BattlenetRpcErrorCode.UserServerBadWowAccount;
|
return BattlenetRpcErrorCode.UserServerBadWowAccount;
|
||||||
|
|
||||||
string subRegionId = "";
|
string subRegionId = "";
|
||||||
Variant subRegion = Params.LookupByKey("Command_RealmListRequest_v1_b9");
|
Variant subRegion = Params.LookupByKey("Command_RealmListRequest_v1");
|
||||||
if (subRegion != null)
|
if (subRegion != null)
|
||||||
subRegionId = subRegion.StringValue;
|
subRegionId = subRegion.StringValue;
|
||||||
|
|
||||||
|
|||||||
@@ -32,13 +32,25 @@ namespace Game
|
|||||||
{
|
{
|
||||||
Bgs.Protocol.Attribute command = null;
|
Bgs.Protocol.Attribute command = null;
|
||||||
Dictionary<string, Bgs.Protocol.Variant> Params = new();
|
Dictionary<string, Bgs.Protocol.Variant> Params = new();
|
||||||
|
string removeSuffix(string str)
|
||||||
|
{
|
||||||
|
var pos = str.IndexOf('_');
|
||||||
|
if (pos != -1)
|
||||||
|
return str.Substring(0, pos);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < request.Attribute.Count; ++i)
|
for (int i = 0; i < request.Attribute.Count; ++i)
|
||||||
{
|
{
|
||||||
Bgs.Protocol.Attribute attr = request.Attribute[i];
|
Bgs.Protocol.Attribute attr = request.Attribute[i];
|
||||||
Params[attr.Name] = attr.Value;
|
|
||||||
if (attr.Name.Contains("Command_"))
|
if (attr.Name.Contains("Command_"))
|
||||||
|
{
|
||||||
command = attr;
|
command = attr;
|
||||||
|
Params[removeSuffix(attr.Name)] = attr.Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Params[attr.Name] = attr.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == null)
|
if (command == null)
|
||||||
@@ -47,18 +59,18 @@ namespace Game
|
|||||||
return BattlenetRpcErrorCode.RpcMalformedRequest;
|
return BattlenetRpcErrorCode.RpcMalformedRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Name == "Command_RealmListRequest_v1_b9")
|
return removeSuffix(command.Name) switch
|
||||||
return HandleRealmListRequest(Params, response);
|
{
|
||||||
else if (command.Name == "Command_RealmJoinRequest_v1_b9")
|
"Command_RealmListRequest_v1" => HandleRealmListRequest(Params, response),
|
||||||
return HandleRealmJoinRequest(Params, response);
|
"Command_RealmJoinRequest_v1" => HandleRealmJoinRequest(Params, response),
|
||||||
|
_ => BattlenetRpcErrorCode.RpcNotImplemented
|
||||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[Service(OriginalHash.GameUtilitiesService, 10)]
|
[Service(OriginalHash.GameUtilitiesService, 10)]
|
||||||
BattlenetRpcErrorCode HandleGetAllValuesForAttribute(GetAllValuesForAttributeRequest request, GetAllValuesForAttributeResponse response)
|
BattlenetRpcErrorCode HandleGetAllValuesForAttribute(GetAllValuesForAttributeRequest request, GetAllValuesForAttributeResponse response)
|
||||||
{
|
{
|
||||||
if (request.AttributeKey == "Command_RealmListRequest_v1_b9")
|
if (request.AttributeKey == "Command_RealmListRequest_v1")
|
||||||
{
|
{
|
||||||
Global.RealmMgr.WriteSubRegions(response);
|
Global.RealmMgr.WriteSubRegions(response);
|
||||||
return BattlenetRpcErrorCode.Ok;
|
return BattlenetRpcErrorCode.Ok;
|
||||||
@@ -70,7 +82,7 @@ namespace Game
|
|||||||
BattlenetRpcErrorCode HandleRealmListRequest(Dictionary<string, Bgs.Protocol.Variant> Params, ClientResponse response)
|
BattlenetRpcErrorCode HandleRealmListRequest(Dictionary<string, Bgs.Protocol.Variant> Params, ClientResponse response)
|
||||||
{
|
{
|
||||||
string subRegionId = "";
|
string subRegionId = "";
|
||||||
var subRegion = Params.LookupByKey("Command_RealmListRequest_v1_b9");
|
var subRegion = Params.LookupByKey("Command_RealmListRequest_v1");
|
||||||
if (subRegion != null)
|
if (subRegion != null)
|
||||||
subRegionId = subRegion.StringValue;
|
subRegionId = subRegion.StringValue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user