Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
LOOK MA NO MORE WARNINGS
Browse files Browse the repository at this point in the history
  • Loading branch information
SlejmUr committed Feb 28, 2024
1 parent 55f2ce8 commit ea5cfc4
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions ServerLib/Controllers/MoveActionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,16 @@ public static ProfileChanges TransferItem(string SessionId, ProfileChanges chang

public static ProfileChanges ReadEncyclopedia(string SessionId, ProfileChanges changes, JObject action)
{
Inventory.ReadEncyclopedia readEncyclopedia = action.ToObject<Inventory.ReadEncyclopedia>();
Inventory.ReadEncyclopedia? readEncyclopedia = action.ToObject<Inventory.ReadEncyclopedia>();
ArgumentNullException.ThrowIfNull(readEncyclopedia, nameof(readEncyclopedia));
bool IsScav = false;
var character = CharacterController.GetPmcCharacter(SessionId);
if (readEncyclopedia.fromOwner != null && readEncyclopedia.fromOwner.type.ToLower() == "profile")
{
character = CharacterController.GetScavCharacter(SessionId);
IsScav = true;
}

ArgumentNullException.ThrowIfNull(character, nameof(character));
foreach (var item in readEncyclopedia.ids)
{
character.Encyclopedia.Add(item, true);
Expand All @@ -442,15 +443,16 @@ public static ProfileChanges ReadEncyclopedia(string SessionId, ProfileChanges c

public static ProfileChanges BindItem(string SessionId, ProfileChanges changes, JObject action)
{
Inventory.Bind bindAction = action.ToObject<Inventory.Bind>();
Inventory.Bind? bindAction = action.ToObject<Inventory.Bind>();
ArgumentNullException.ThrowIfNull(bindAction, nameof(bindAction));
bool IsScav = false;
var character = CharacterController.GetPmcCharacter(SessionId);
if (bindAction.fromOwner != null && bindAction.fromOwner.type.ToLower() == "profile")
{
character = CharacterController.GetScavCharacter(SessionId);
IsScav = true;
}

ArgumentNullException.ThrowIfNull(character, nameof(character));
if (character.Inventory.FastPanel.ContainsKey(bindAction.index))
{
character.Inventory.FastPanel[bindAction.index] = bindAction.item;
Expand All @@ -470,17 +472,18 @@ public static ProfileChanges BindItem(string SessionId, ProfileChanges changes,

public static ProfileChanges TagItem(string SessionId, ProfileChanges changes, JObject action)
{
Inventory.Tag tagAction = action.ToObject<Inventory.Tag>();
Inventory.Tag? tagAction = action.ToObject<Inventory.Tag>();
ArgumentNullException.ThrowIfNull(tagAction, nameof(tagAction));
bool IsScav = false;
var character = CharacterController.GetPmcCharacter(SessionId);
if (tagAction.fromOwner != null && tagAction.fromOwner.type.ToLower() == "profile")
{
character = CharacterController.GetScavCharacter(SessionId);
IsScav = true;
}

ArgumentNullException.ThrowIfNull(character, nameof(character));
var item = character.Inventory.Items.Find(x=>x.Id == tagAction.item);

ArgumentNullException.ThrowIfNull(item, nameof(item));
if (item.Upd == null)
{
item.Upd = new()
Expand All @@ -500,7 +503,7 @@ public static ProfileChanges TagItem(string SessionId, ProfileChanges changes, J
Name = tagAction.TagName
};
}
else
else if (item.Upd != null && item.Upd.Tag != null)
{
item.Upd.Tag.Color = tagAction.TagColor;
item.Upd.Tag.Name = tagAction.TagName;
Expand All @@ -515,17 +518,18 @@ public static ProfileChanges TagItem(string SessionId, ProfileChanges changes, J

public static ProfileChanges ToggleItem(string SessionId, ProfileChanges changes, JObject action)
{
Inventory.Toggle toggleAction = action.ToObject<Inventory.Toggle>();
Inventory.Toggle? toggleAction = action.ToObject<Inventory.Toggle>();
ArgumentNullException.ThrowIfNull(toggleAction, nameof(toggleAction));
bool IsScav = false;
var character = CharacterController.GetPmcCharacter(SessionId);
if (toggleAction.fromOwner != null && toggleAction.fromOwner.type.ToLower() == "profile")
{
character = CharacterController.GetScavCharacter(SessionId);
IsScav = true;
}

ArgumentNullException.ThrowIfNull(character, nameof(character));
var item = character.Inventory.Items.Find(x => x.Id == toggleAction.item);

ArgumentNullException.ThrowIfNull(item, nameof(item));
if (item.Upd == null)
{
item.Upd = new()
Expand All @@ -543,7 +547,7 @@ public static ProfileChanges ToggleItem(string SessionId, ProfileChanges changes
On = toggleAction.value
};
}
else
else if (item.Upd != null && item.Upd.Togglable != null)
{
item.Upd.Togglable.On = toggleAction.value;
}
Expand Down

0 comments on commit ea5cfc4

Please sign in to comment.