Originally Posted by -impulse-
The nobility icon did not appear because you didn't send the packet you should have.
Basic knowledge
There are specific packets and specific data sets (structs) for each feature that the client can handle.
For nobility the packet id is 2064 and an example of struct for nobility is:
Code:
public class NobilityInformation
{
public string Name;
public uint EntityUID;
public uint Mesh;
public ulong Donation;
public byte Gender;
public int Position;
public NobilityRank Rank;
}
Whereas NobilityRank is:
Code:
public enum NobilityRank : byte
{
Serf = 0,
Knight = 1,
Baron = 3,
Earl = 5,
Duke = 7,
Prince = 9,
King = 12
}
NB: There are lots of sources nowadays that have nobility added including the leaked trinity source for version 5335. You can get it from there.
Packet (for Impulse(and/or Trinity) like sources)
Code:
public class NobilityInfo : Writer, Interfaces.IPacket
{
public const uint
Donate = 1,
List = 2,
Icon = 3,
NextRank = 4;
byte[] Buffer;
public NobilityInfo(bool Create)
{
if (Create)
{
Buffer = new byte[33 + 8];
WriteUInt16(33, 0, Buffer);
WriteUInt16(2064, 2, Buffer);
}
Strings = new List<string>();
}
public uint Type
{
get { return BitConverter.ToUInt32(Buffer, 4); }
set { WriteUInt32(value, 4, Buffer); }
}
public uint dwParam
{
get { return BitConverter.ToUInt32(Buffer, 8); }
set { WriteUInt32(value, 8, Buffer); }
}
public ulong qwParam
{
get { return BitConverter.ToUInt64(Buffer, 8); }
set { WriteUInt64(value, 8, Buffer); }
}
public ushort wParam1
{
get { return BitConverter.ToUInt16(Buffer, 8); }
set { WriteUInt16(value, 8, Buffer); }
}
public ushort wParam2
{
get { return BitConverter.ToUInt16(Buffer, 10); }
set { WriteUInt16(value, 10, Buffer); }
}
public uint dwParam2
{
get { return BitConverter.ToUInt32(Buffer, 16); }
set { WriteUInt32(value, 16, Buffer); }
}
public uint dwParam3
{
get { return BitConverter.ToUInt32(Buffer, 20); }
set { WriteUInt32(value, 20, Buffer); }
}
public uint dwParam4
{
get { return BitConverter.ToUInt32(Buffer, 24); }
set { WriteUInt32(value, 24, Buffer); }
}
public byte StringCount
{
get { return Buffer[32]; }
set { Buffer[32] = value; }
}
public List<string> DecodedStrings
{
get
{
List<string> list = new List<string>(StringCount);
int offset = 33;
for (int count = 0; count < StringCount; count++)
{
byte stringLength = Buffer[offset]; offset++;
string String = Encoding.Default.GetString(Buffer, offset, stringLength);
offset += stringLength;
list.Add(String);
}
return list;
}
}
public List<string> Strings;
public void UpdateString(Game.ConquerStructures.NobilityInformation info)
{
string buildString = info.EntityUID + " " + info.Donation + " " + (byte)info.Rank + " " + info.Position;
buildString = (char)buildString.Length + buildString;
Strings.Add(buildString);
}
public void ListString(Game.ConquerStructures.NobilityInformation info)
{
string buildString = info.EntityUID + " " + info.Gender + " 0 " + info.Name + " " + info.Donation + " " + (byte)info.Rank + " " + info.Position;
buildString = (char)buildString.Length + buildString;
Strings.Add(buildString);
}
public void Send(Client.GameClient client)
{
client.Send(ToArray());
}
public byte[] ToArray()
{
if (Strings.Count == 0)
return Buffer;
string theString = "";
for (int count = 0; count < Strings.Count; count++)
{
theString += Strings[count];
}
byte[] newBuffer = new byte[33 + 8 + theString.Length];
Buffer.CopyTo(newBuffer, 0);
WriteUInt16((ushort)(newBuffer.Length - 8), 0, newBuffer);
newBuffer[32] = (byte)Strings.Count;
WriteString(theString, 33, newBuffer);
return newBuffer;
}
public void Deserialize(byte[] buffer)
{
Buffer = buffer;
}
}
Pseudo-tutorial
First you have to add the packet and the specific data set into the source.
Considering this step is finished, you have to make database entries(a table for the data set) to store information for each character.
Once that is done (including save/load) you go on and send the icon in the body of the 'LoginMessages' function that can be found in PacketHandler.cs.
Code:
NobilityInfo update = new NobilityInfo(true);
update.Type = NobilityInfo.Icon;
update.dwParam = client.NobilityInformation.EntityUID;
update.UpdateString(client.NobilityInformation);
client.Send(update);
Whereas client.NobilityInformation is a variable of the specific data set named 'NobilityInformation'.
The rest will be a lot harder, but that's all I am willing to write about.
As of 'Nobility.dat.svn-base', nevermind that. It wouldn't work for a source that didn't use a SVN software while it was developed.
Regards.
|