basic support for 1.13.0 client (#15)

- add GetUnselectedPetByTypes
- block update avatar in calls SetAvatar from too old clients
- add support for call GetUserProfileByUserID with viking apiToken
This commit is contained in:
rpaciorek 2023-08-14 12:36:33 +00:00 committed by GitHub
parent 725f8e22c1
commit 0ef87a61ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 2 deletions

View File

@ -72,6 +72,7 @@ Then run School of Dragons.
- GetUserUpcomingMissionState
- GetUserCompletedMissionState
- GetChildList
- GetUnselectedPetByTypes
- UseInventory
#### Implemented enough (probably)

View File

@ -66,6 +66,7 @@ methods = [
'SetNextItemState',
'SetUserRoom',
'GetChildList',
'GetUnselectedPetByTypes',
'GetUserGameCurrency',
'SetAchievementByEntityIDs',
'UseInventory'

View File

@ -262,6 +262,23 @@ public class ContentController : Controller {
});
}
AvatarData avatarData = XmlUtil.DeserializeXml<AvatarData>(contentXML);
foreach (AvatarDataPart part in avatarData.Part) {
if (part.PartType == "Version") {
if (part.Offsets[0].X < 6 || part.Offsets[0].X == 6 && part.Offsets[0].Y < 1) {
// do not allow to save avatar data from old clients (avatar data version < 6.1) ... it's broke profile on 3.31
// but return as true to trick the client to avoid re-show change viking name dialog
// TODO: maybe better set pair AvatarNameCustomizationDone -> 1 (in "2017" pairs) and return error here?
return Ok(new SetAvatarResult {
Success = true,
DisplayName = viking.Name,
StatusCode = AvatarValidationResult.Valid
});
}
break;
}
}
viking.AvatarSerialized = contentXML;
ctx.SaveChanges();
@ -402,6 +419,39 @@ public class ContentController : Controller {
return dragons;
}
[HttpPost]
[Produces("application/xml")]
[Route("ContentWebService.asmx/GetUnselectedPetByTypes")]
public RaisedPetData[]? GetUnselectedPetByTypes([FromForm] string apiToken, [FromForm] string petTypeIDs, [FromForm] bool active) {
Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking;
if (viking is null) {
return null;
}
RaisedPetData[] dragons = viking.Dragons
.Where(d => d.RaisedPetData is not null)
.Select(GetRaisedPetDataFromDragon)
.ToArray();
if (dragons.Length == 0) {
return null;
}
List<RaisedPetData> filteredDragons = new List<RaisedPetData>();
int[] petTypeIDsInt = Array.ConvertAll(petTypeIDs.Split(','), s => int.Parse(s));
foreach (RaisedPetData dragon in dragons) {
if (petTypeIDsInt.Contains(dragon.PetTypeID)) {
filteredDragons.Add(dragon);
}
}
if (filteredDragons.Count == 0) {
return null;
}
return filteredDragons.ToArray();
}
[HttpPost]
[Produces("application/xml")]
[Route("ContentWebService.asmx/GetSelectedRaisedPet")]

View File

@ -16,8 +16,8 @@ public class ProfileController : Controller {
[Produces("application/xml")]
[Route("ProfileWebService.asmx/GetUserProfileByUserID")]
public IActionResult GetUserProfileByUserID([FromForm] string apiToken, [FromForm] string userId) {
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
if (user is null) {
Session session = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken);
if (session?.User is null && session?.Viking is null) {
// TODO: what response for not logged in?
return Ok();
}