Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Item Locations #6427

Merged
merged 7 commits into from
Aug 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Source/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,28 @@ bool UnPackNetPlayer(const PlayerNetPack &packed, Player &player)
for (int i = 0; i < NUM_INVLOC; i++) {
if (!UnPackNetItem(player, packed.InvBody[i], player.InvBody[i]))
return false;
if (player.InvBody[i].isEmpty())
continue;
auto loc = static_cast<int8_t>(player.GetItemLocation(player.InvBody[i]));
switch (i) {
case INVLOC_HEAD:
ValidateField(loc, loc == ILOC_HELM);
break;
case INVLOC_RING_LEFT:
case INVLOC_RING_RIGHT:
ValidateField(loc, loc == ILOC_RING);
break;
case INVLOC_AMULET:
ValidateField(loc, loc == ILOC_AMULET);
break;
case INVLOC_HAND_LEFT:
case INVLOC_HAND_RIGHT:
ValidateField(loc, IsAnyOf(loc, ILOC_ONEHAND, ILOC_TWOHAND));
break;
case INVLOC_CHEST:
ValidateField(loc, loc == ILOC_ARMOR);
break;
}
}

player._pNumInv = packed._pNumInv;
Expand All @@ -570,6 +592,10 @@ bool UnPackNetPlayer(const PlayerNetPack &packed, Player &player)
for (int i = 0; i < MaxBeltItems; i++) {
if (!UnPackNetItem(player, packed.SpdList[i], player.SpdList[i]))
return false;
if (player.SpdList[i].isEmpty())
continue;
auto loc = static_cast<int8_t>(player.GetItemLocation(player.SpdList[i]));
ValidateField(loc, loc == ILOC_BELT);
}

CalcPlrInv(player, false);
Expand Down
Loading