Skip to content

Commit

Permalink
Request evidence is more leniant
Browse files Browse the repository at this point in the history
  • Loading branch information
Enovale committed Oct 17, 2020
1 parent 25b7a19 commit 6980755
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
1 change: 0 additions & 1 deletion .idea/.idea.Alibi/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions .idea/.idea.Alibi/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Alibi.Plugins.API/Attributes/RequireStateAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ namespace Alibi.Plugins.API.Attributes
public class RequireStateAttribute : Attribute
{
public ClientState State { get; }
public bool Kick { get; }

public RequireStateAttribute(ClientState requiredState) => State = requiredState;
public RequireStateAttribute(ClientState requiredState, bool kickIfFalse = true)
{
State = requiredState;
Kick = kickIfFalse;
}
}
}
4 changes: 3 additions & 1 deletion Alibi/Protocol/MessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public static void HandleMessage(IClient client, IAOPacket packet)
var stateAttr = Handlers[packet.Type].Method.GetCustomAttribute<RequireStateAttribute>();

if (stateAttr != null)
if (client.CurrentState != stateAttr.State)
if (client.CurrentState != stateAttr.State && stateAttr.Kick)
{
client.Kick("Protocol violation.");
return;
}
else if(client.CurrentState != stateAttr.State)
return;

Handlers[packet.Type].Method.Invoke(Handlers[packet.Type].Target, new object[] {client, packet});
}
Expand Down
2 changes: 1 addition & 1 deletion Alibi/Protocol/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ internal static void RequestCharacters(IClient client, IAOPacket packet)
}

[MessageHandler("RE")]
[RequireState(ClientState.Identified)]
[RequireState(ClientState.InArea, false)]
internal static void RequestEvidence(IClient client, IAOPacket packet)
{
string[] evidenceList = new string[client.Area!.EvidenceList.Count];
Expand Down

0 comments on commit 6980755

Please sign in to comment.