-
Notifications
You must be signed in to change notification settings - Fork 4
/
PacketLocation.cs
86 lines (78 loc) · 2.61 KB
/
PacketLocation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.Text;
namespace PacketLogConverter
{
public struct PacketLocation : IEquatable<PacketLocation>
{
public static PacketLocation UNKNOWN = new PacketLocation(-1, -1);
public int LogIndex;
public int PacketIndex;
/// <summary>
/// Initializes a new instance of the <see cref="T:PacketLocation"/> class.
/// </summary>
/// <param name="logIndex">Index of the log.</param>
/// <param name="packetIndex">Index of the packet.</param>
public PacketLocation(int logIndex, int packetIndex)
{
LogIndex = logIndex;
PacketIndex = packetIndex;
}
/// <summary>
/// Compares 2 packet locations.
/// </summary>
/// <param name="location1">The location1.</param>
/// <param name="location2">The location2.</param>
/// <returns><c>true</c> if both locations are equal.</returns>
public static bool operator ==(PacketLocation location1, PacketLocation location2)
{
bool ret = location1.PacketIndex == location2.PacketIndex;
ret &= location1.LogIndex == location2.LogIndex;
return ret;
}
/// <summary>
/// Compares 2 packet locations.
/// </summary>
/// <param name="location1">The location1.</param>
/// <param name="location2">The location2.</param>
/// <returns><c>true</c> if both locations are equal.</returns>
public static bool operator !=(PacketLocation location1, PacketLocation location2)
{
bool ret = location1 == location2;
return !ret;
}
/// <summary>
/// Indicates whether this instance and a specified object are equal.
/// </summary>
/// <param name="packetLocation">The packet location.</param>
/// <returns>
/// true if obj and this instance are the same type and represent the same value; otherwise, false.
/// </returns>
public bool Equals(PacketLocation packetLocation)
{
return this == packetLocation;
}
/// <summary>
/// Indicates whether this instance and a specified object are equal.
/// </summary>
/// <param name="obj">Another object to compare to.</param>
/// <returns>
/// true if obj and this instance are the same type and represent the same value; otherwise, false.
/// </returns>
public override bool Equals(object obj)
{
if (!(obj is PacketLocation)) return false;
return Equals((PacketLocation) obj);
}
/// <summary>
/// Returns the hash code for this instance.
/// </summary>
/// <returns>
/// A 32-bit signed integer that is the hash code for this instance.
/// </returns>
public override int GetHashCode()
{
return LogIndex + 29*PacketIndex;
}
}
}