mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
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:
parent
725f8e22c1
commit
0ef87a61ff
@ -72,6 +72,7 @@ Then run School of Dragons.
|
||||
- GetUserUpcomingMissionState
|
||||
- GetUserCompletedMissionState
|
||||
- GetChildList
|
||||
- GetUnselectedPetByTypes
|
||||
- UseInventory
|
||||
|
||||
#### Implemented enough (probably)
|
||||
|
@ -66,6 +66,7 @@ methods = [
|
||||
'SetNextItemState',
|
||||
'SetUserRoom',
|
||||
'GetChildList',
|
||||
'GetUnselectedPetByTypes',
|
||||
'GetUserGameCurrency',
|
||||
'SetAchievementByEntityIDs',
|
||||
'UseInventory'
|
||||
|
@ -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")]
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user