Fix Sec Codes

This commit is contained in:
SilicaAndPina 2020-11-05 13:17:35 +13:00
parent 73b4e073ff
commit e22eca485d
4 changed files with 675 additions and 674 deletions

File diff suppressed because it is too large Load diff

View file

@ -68,17 +68,21 @@ namespace HISP.Game
if ((!terrainPassable && overlayPassable) && otileId == 0)
return false;
bool passable = false;
if (!overlayPassable)
return false;
passable = false;
if (!terrainPassable)
return false;
passable = false;
if (!passable && overlayPassable)
passable = true;
Logger.DebugPrint("Overlay: " + otileId + " Terrain: " + tileId);
return true;
return passable;
}
public static void OpenMap()

View file

@ -166,6 +166,7 @@ namespace HISP.Player
SecCode[1] = (byte)(SecCodeSeeds[1] + 33);
SecCode[2] = (byte)(SecCodeSeeds[2] + 33);
SecCode[3] = (byte)(i + 33);
Logger.DebugPrint("Expecting "+Username+" To send Sec Code: "+BitConverter.ToString(SecCode).Replace("-", " "));
return SecCode;
}
@ -203,11 +204,11 @@ namespace HISP.Player
// Generate SecCodes
Random rng = new Random();
SecCodeSeeds[0] = (byte)rng.Next(40, 140);
SecCodeSeeds[1] = (byte)rng.Next(40, 140);
SecCodeSeeds[2] = (byte)rng.Next(40, 140);
SecCodeInc = (byte)rng.Next(0, 99);
SecCodeSeeds[0] = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
SecCodeSeeds[1] = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
SecCodeSeeds[2] = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
SecCodeInc = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
// Make some friends! (Get a life!)

View file

@ -165,17 +165,14 @@ namespace HISP.Server
}
else if(method == PacketBuilder.SECCODE_QUEST)
{
byte[] SecCode = sender.LoggedinUser.GenerateSecCode();
bool correctSecCode = true;
for(int i = 0; i < SecCode.Length; i++)
{
if (packet[i + 2] != SecCode[i])
correctSecCode = false;
}
if(correctSecCode)
byte[] ExpectedSecCode = sender.LoggedinUser.GenerateSecCode();
byte[] GotSecCode = new byte[4];
Array.ConstrainedCopy(packet, 2, GotSecCode, 0, GotSecCode.Length);
Logger.DebugPrint(sender.LoggedinUser.Username+" Sent sec code: " + BitConverter.ToString(GotSecCode).Replace("-"," "));
if(ExpectedSecCode.SequenceEqual(GotSecCode))
{
string packetStr = Encoding.UTF8.GetString(packet);
string intStr = packetStr.Substring(8, packetStr.Length - 2);
string intStr = packetStr.Substring(6,packetStr.Length - 6 - 2);
int value = -1;
try
{
@ -187,19 +184,18 @@ namespace HISP.Server
return;
}
if (packet[3] == PacketBuilder.SECCODE_QUEST)
if (Quest.DoesQuestExist(value))
{
if (Quest.DoesQuestExist(value))
{
Quest.QuestEntry questEntry = Quest.GetQuestById(value);
Quest.ActivateQuest(sender.LoggedinUser, questEntry);
}
else
{
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent correct sec code, but tried to activate a non existant quest");
return;
}
Quest.QuestEntry questEntry = Quest.GetQuestById(value);
Quest.ActivateQuest(sender.LoggedinUser, questEntry);
}
else
{
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent correct sec code, but tried to activate a non existant quest");
return;
}
}
else