Skip to content

Commit

Permalink
1.修復拾取物品
Browse files Browse the repository at this point in the history
2.修復怪物移動
3.修復怪物AI
4.修復多人連線
5.其他...too many說不完...
  • Loading branch information
a12182565 committed May 27, 2016
1 parent 1001578 commit feba383
Show file tree
Hide file tree
Showing 30 changed files with 795 additions and 373 deletions.
27 changes: 26 additions & 1 deletion Server/CharServer/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,19 @@ public short Quantity
public Item(int itemID, byte slot, byte type, short quantity = 1)
{
this.ItemID = itemID;
this.MaxPerStack = this.MaxPerStack;
this.MaxPerStack = 1;
switch (type) {
case 0:
case 1:
case 2:
case 5:
this.MaxPerStack = 1;
break;
case 3:
case 4:
this.MaxPerStack = 100;
break;
}
this.Quantity = quantity;
this.slot = slot;
this.type = type;
Expand All @@ -83,6 +95,19 @@ public Item(dynamic datum)

this.ItemID = datum.itemId;
this.MaxPerStack = 1;
switch ((byte)(datum.type))
{
case 0:
case 1:
case 2:
case 5:
this.MaxPerStack = 1;
break;
case 3:
case 4:
this.MaxPerStack = 100;
break;
}
this.Quantity = (short)datum.quantity;
this.slot = (byte)datum.slot;
this.type = (byte)datum.type;
Expand Down
15 changes: 9 additions & 6 deletions Server/CharServer/Net/CharHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ public static void MyChar_Info_Req(InPacket lea, Client gc)
try
{
gc.Account.Load(username);
var pe = new PasswordEncrypt(encryptKey);
string encryptPassword = pe.encrypt(gc.Account.Password);
if (!password.Equals(encryptPassword))
//var pe = new PasswordEncrypt(encryptKey);
//string encryptPassword = pe.encrypt(gc.Account.Password, password.ToCharArray());

if (!password.Equals(gc.Account.Password))
{
gc.Dispose();
Log.Error("Login Fail!");
Expand All @@ -47,9 +48,9 @@ public static void MyChar_Info_Req(InPacket lea, Client gc)
CharPacket.MyChar_Info_Ack(gc, gc.Account.Characters);
Log.Success("Login Success!");
}
Log.Inform("Password = {0}", password);
Log.Inform("encryptKey = {0}", encryptKey);
Log.Inform("encryptPassword = {0}", encryptPassword);
Log.Inform("密碼 = {0}", password);
//Log.Inform("encryptKey = {0}", encryptKey);
//Log.Inform("encryptPassword = {0}", encryptPassword);
}
catch (NoAccountException)
{
Expand Down Expand Up @@ -126,6 +127,8 @@ public static void Create_MyChar_Req(InPacket lea, Client gc)
chr.Items.Add(new Item(weapon, (byte)InventoryType.EquipType.Weapon, (byte)InventoryType.ItemType.Equip));
chr.Items.Add(new Item(outfit, (byte)InventoryType.EquipType.Outfit, (byte)InventoryType.ItemType.Equip));
chr.Items.Add(new Item(seal, (byte)InventoryType.EquipType.Seal, (byte)InventoryType.ItemType.Equip));
chr.Items.Add(new Item(8810011, (byte)0, (byte)InventoryType.ItemType.Spend3, 10));
chr.Items.Add(new Item(8820011, (byte)1, (byte)InventoryType.ItemType.Spend3, 10));
chr.Storages.Add(new Storage(0));
chr.Skills.Add(new Skill(1 , 1, 0, 0));
chr.Skills.Add(new Skill(2, 1, 0, 1));
Expand Down
1 change: 1 addition & 0 deletions Server/Common/Constants/ServerConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class ServerConstants
{
public static readonly string SERVER_IP = "127.0.0.1";
public static readonly bool AUTO_REGISTRATION = true;
public static readonly int CHANNEL_DEFAULT = 18;
public static readonly int CHANNEL_LOAD = 300;
public static readonly int CLIENT_VERSION = 309022824;
Expand Down
8 changes: 8 additions & 0 deletions Server/Common/IO/Packet/OutPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ public void WriteLong(long value = 0)
this.ThrowIfDisposed();

this.Append(value, 8);
}

public void WriteFloat(float value = 0)
{
this.ThrowIfDisposed();

byte[] x = BitConverter.GetBytes(value);
this._stream.Write(x, 0, x.Length);
}

public void WriteString(string value)
Expand Down
1 change: 1 addition & 0 deletions Server/Common/Net/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public enum ClientOpcode : ushort
MOVE_ITEM_STORAGE = 0xAC,
SAVE_MONEY = 0xAE,
GIVE_MONEY = 0xAF,
P_MOVE = 0xDD,
INVEN_USESPEND_SHOUT_REQ = 0xFA,
INVEN_USESPEND_SHOUT_ALL_REQ = 0x16B,
PET_MOVE_C = 0x10B,
Expand Down
4 changes: 2 additions & 2 deletions Server/Common/Security/PacketCrypt.cs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public byte[] Decrypt2(byte[] encryptPacket, int length)
int v10 = 0;
int v11 = 0;
int v12 = 0;
label:
label:
if (j >= 0x20000 || i >= length)
{
goto label2;
Expand Down Expand Up @@ -167,7 +167,7 @@ public byte[] Decrypt2(byte[] encryptPacket, int length)
} while (v12 > 0);
goto label;
}
label2:
label2:
byte[] ret = new byte[j];
Array.Copy(v7, ret, ret.Length);
return ret;
Expand Down
134 changes: 67 additions & 67 deletions Server/Common/Security/PasswordEncrypt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,86 @@ namespace Server.Common.Security
{
public class PasswordEncrypt
{
private char[] result = new char[14];
private int resultPosition = 0;
private int ps;
private int Length;
private char[] Result = new char[0];
public static char[] Data2;
private int Position = 0;
private int ResultPosition = 0;
private int Password;

public PasswordEncrypt(int ps)
{
this.ps = ps;
this.Password = ps;
}

public string encrypt(string password)
public string encrypt(string Password, char[] EncryptPassword)
{
int position = 0;
int encryptResult = 0;
int length = password.Length;
char[] passwordArray = password.ToCharArray();
Array.Reverse(passwordArray);
char[] passwordReverse = new char[256];
passwordArray.CopyTo(passwordReverse, 256 - length);
if (length > 0)
int EncryptResult = 0;
Length = Password.Length;
char[] PasswordChar = Password.ToCharArray();
Array.Resize(ref PasswordChar, 256);
Array.Resize(ref EncryptPassword, 256);
Array.Resize(ref Data2 , 256);
Array.Copy(PasswordChar, Data2, Length);
if (Length > 0)
{
do
{
int data = passwordReverse[255 - position] | passwordReverse[254 - position] << 8 | passwordReverse[253 - position] << 16 | passwordReverse[252 - position] << 24;
encryptResult = encrypt(ps + data, 1);
encrypt2((uint)encryptResult);
position += 4;
resultPosition += 7;
} while (position < length);
int data = Convert.ToInt32(Data2[Position]) | Convert.ToInt32(Data2[Position + 1]) << 8 | Convert.ToInt32(Data2[Position + 2]) << 16 | Convert.ToInt32(Data2[Position + 3]) << 24;
EncryptResult = encrypt((uint)(this.Password + data), 1);
encrypt2((uint)EncryptResult);
Position += 4;
ResultPosition += 7;
} while (Position < Length);
for (int i = 1; i < 256 - Length; i++)
Data2[Length + i] = EncryptPassword[Length + i];
}
return new string(result);
return new string(Result);
}

private int encrypt(int data, int mode)
private int encrypt(uint data, int mode)
{
byte[] key = {
0x1A, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x11, 0x00,
0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1C, 0x00,
0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x17, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
0x0E, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x06, 0x00,
0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x19, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x12, 0x00,
0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x19, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1F, 0x00,
0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
0x0E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x0B, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x17, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0A, 0x00,
0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00,
0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1E, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
0x1A, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00,
0x1C, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00,
0x1B, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
0x15, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x19, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
0x1D, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00,
0x0F, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
0x1B, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
0x0E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0x1C, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00 };
int result = 0;
uint v2 = 0;
v2 = data;
int v6 = 0;
if (data != 0)
if (data > 0)
{
int position = 0;
do
{
int v5 = data - (int)((long)data & 0xFFFFFFFE);
data = data >> 1;
if (v5 != 0)
uint v5 = v2 - (v2 & 0xFFFFFFFE);
v2 = v2 >> 1;
if (v5 > 0)
{
if (mode != 0)
{
v6 = key[position];
}
else {
v6 = key[position];
}
result = result + (v5 << v6);
v6 = key[position];
result = (int)(result + (v5 << v6));
}
position += 4;
} while (data != 0);
} while (v2 > 0);
}
return result;
}
Expand All @@ -97,20 +94,23 @@ private void encrypt2(uint a1)
uint v2, temp, temp2, temp3;
char[] table = new char[36];
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".CopyTo(0, table, 0, 36);
result[0 + resultPosition] = table[a1 % 0x24];

Array.Resize(ref Result, Result.Length + 7);

Result[0 + ResultPosition] = table[a1 % 0x24];
v2 = a1 / 0x24 / 0x24;
result[1 + resultPosition] = table[a1 / 0x24 % 0x24];
Result[1 + ResultPosition] = table[a1 / 0x24 % 0x24];
temp = v2;
v2 /= 0x24;
result[2 + resultPosition] = table[temp - 36 * v2];
Result[2 + ResultPosition] = table[temp - 36 * v2];
temp2 = v2;
v2 /= 0x24;
result[3 + resultPosition] = table[temp2 - 36 * v2];
Result[3 + ResultPosition] = table[temp2 - 36 * v2];
temp3 = v2;
v2 /= 0x24;
result[4 + resultPosition] = table[temp3 - 36 * v2];
result[5 + resultPosition] = table[v2 % 0x24];
result[6 + resultPosition] = table[v2 / 0x24 % 0x24];
Result[4 + ResultPosition] = table[temp3 - 36 * v2];
Result[5 + ResultPosition] = table[v2 % 0x24];
Result[6 + ResultPosition] = table[v2 / 0x24 % 0x24];
}
}
}
12 changes: 5 additions & 7 deletions Server/GameServer/Ghost/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Server.Net;
using Server.Packet;
using System.Collections.Generic;
using System.Net;

namespace Server.Ghost.Characters
{
Expand Down Expand Up @@ -56,8 +57,8 @@ public sealed class Character
public short SkillBonus { get; set; }
public byte JumpHeight { get; set; }
public byte Position { get; set; }
public IPAddress IP { get; set; }

public Map Map { get; private set; }
public CharacterItems Items { get; private set; }
public CharacterStorages Storages { get; private set; }
public CharacterSkills Skills { get; private set; }
Expand Down Expand Up @@ -221,11 +222,6 @@ public void Delete()
this.Assigned = false;
}

public Map SetMap(Map map)
{
return this.Map = map;
}

public void LevelUp()
{
this.Level++;
Expand All @@ -236,7 +232,9 @@ public void LevelUp()
this.Mp = this.MaxMp;
this.AbilityBonus += 4;
this.SkillBonus += 2;
StatusPacket.levelUp(Client, this.Level);
Map map = Maps.GetMap(this.MapX, this.MapY);
foreach (Character all in map.Characters)
StatusPacket.levelUp(Client, this.Level);
StatusPacket.getStatusInfo(Client);
}
}
Expand Down
21 changes: 10 additions & 11 deletions Server/GameServer/Ghost/Characters/CharacterItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,9 @@ public void RemoveItem(InventoryType.ItemType type, byte slot)
item.Delete();
}

public IEnumerator<Item> GetEnumerator()
{
return this.Items.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)this.Items).GetEnumerator();
}

public byte GetNextFreeSlot(InventoryType.ItemType type)
{
for (byte i = 1; i <= this.MaxSlots[type]; i++)
for (byte i = 0; i < this.MaxSlots[type]; i++)
{
if (this[type, i] == null)
{
Expand Down Expand Up @@ -157,5 +147,14 @@ public bool IsFull(InventoryType.ItemType type)
}
}

public IEnumerator<Item> GetEnumerator()
{
return this.Items.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)this.Items).GetEnumerator();
}
}
}
Loading

0 comments on commit feba383

Please sign in to comment.