Don't set TextsCount manually... There SHOULD be an .Add method which handles this all for you.
That and the string count would be TWO now seeing as there was one element in there (at index zero) and now there are two.
I think when you try to read it back out it's using the stringcount to determine the length of the packet and such. Look inside your string packer and look for an add method that handles all the under the hood work (or write a new one)
Many of our enums are ripped from the eudemons official tq client and server source codes so many do not fully relate to conquer but these are mostly/all correct I feel.
Many of our enums are ripped from the eudemons official tq client and server source codes so many do not fully relate to conquer but these are mostly/all correct I feel.
Well you seem to have the string count correct now. Not sure why it wouldn't be displaying :S
I tried manually reading through the packet. Seems you may be off like 1 byte count.. I could have made a mistake but the final 30 was not part of the string count.
The two blank bytes at the end ARE intentional though. I have it in my structure as well.
Well you seem to have the string count correct now. Not sure why it wouldn't be displaying :S
I tried manually reading through the packet. Seems you may be off like 1 byte count.. I could have made a mistake but the final 30 was not part of the string count.
The two blank bytes at the end ARE intentional though. I have it in my structure as well.
yeah i will try to work on it again and i will tell you the result
Quote:
Originally Posted by CptSky
If it can help, here my MsgName packet.
Code:
using System;
using System.Runtime.InteropServices;
using COServer.Entities;
namespace COServer.Network
{
public unsafe class MsgName : Msg
{
public const Int16 Id = _MSG_NAME;
public enum Action
{
None = 0,
Fireworks = 1,
CreateSyn = 2,
Syndicate = 3,
ChangeTitle = 4,
DelRole = 5,
Spouse = 6,
QueryNPC = 7, //To client, To Server
Wanted = 8, //To client
MapEffect = 9, //To client
RoleEffect = 10, //To client
MemberList = 11, //To client, To Server, dwData is index
KickOut_SynMem = 12,
QueryWanted = 13,
QueryPoliceWanted = 14,
PoliceWanted = 15,
QuerySpouse = 16,
AddDice_Player = 17, //BcastClient(INCLUDE_SELF) Ôö¼Ó÷»×ÓÍæ¼Ò// dwDataΪ÷»×Ó̯ID // To Server ¼ÓÈë ÐèÒªÔ*ÏûÏ¢·µ»Ø
DelDice_Player = 18, //BcastClient(INCLUDE_SELF) ɾ³ý÷»×ÓÍæ¼Ò// dwDataΪ÷»×Ó̯ID // To Server À뿪 ÐèÒªÔ*ÏûÏ¢·µ»Ø
DiceBonus = 19, //dwDataΪMoney
Sound = 20,
SynEnemie = 21,
SynAlly = 22,
Bavarder = 26,
};
public struct MsgInfo
{
public MsgHeader Header;
public Int32 Data;
public Byte Action;
public Byte Count;
public String[] Params;
};
public static Byte[] Create(Int32 Data, String Param, Action Action)
{
try
{
if (Param == null || Param.Length > _MAX_WORDSSIZE)
return null;
Byte[] Out = new Byte[13 + Param.Length];
fixed (Byte* p = Out)
{
*((Int16*)(p + 0)) = (Int16)Out.Length;
*((Int16*)(p + 2)) = (Int16)Id;
*((Int32*)(p + 4)) = (Int32)Data;
*((Byte*)(p + 8)) = (Byte)Action;
*((Byte*)(p + 9)) = (Byte)0x01;
*((Byte*)(p + 10)) = (Byte)Param.Length;
for (Byte i = 0; i < (Byte)Param.Length; i++)
*((Byte*)(p + 11 + i)) = (Byte)Param[i];
}
return Out;
}
catch (Exception Exc) { Program.WriteLine(Exc); return null; }
}
public static Byte[] Create(Int32 Data, String[] Params, Action Action)
{
try
{
if (Params == null || Params.Length < 1)
return null;
Int32 StrLength = 0;
for (Int32 i = 0; i < Params.Length; i++)
{
if (Params[i] == null || Params[i].Length > _MAX_WORDSSIZE)
return null;
StrLength += Params[i].Length + 1;
}
Byte[] Out = new Byte[12 + StrLength];
fixed (Byte* p = Out)
{
*((Int16*)(p + 0)) = (Int16)Out.Length;
*((Int16*)(p + 2)) = (Int16)Id;
*((Int32*)(p + 4)) = (Int32)Data;
*((Byte*)(p + 8)) = (Byte)Action;
*((Byte*)(p + 9)) = (Byte)Params.Length;
Int32 Pos = 10;
for (Int32 x = 0; x < Params.Length; x++)
{
*((Byte*)(p + Pos)) = (Byte)Params[x].Length;
for (Byte i = 0; i < (Byte)Params[x].Length; i++)
*((Byte*)(p + Pos + 1 + i)) = (Byte)Params[x][i];
Pos += Params[x].Length + 1;
}
}
return Out;
}
catch (Exception Exc) { Program.WriteLine(Exc); return null; }
}
public static void Process(Client Client, Byte[] Buffer)
{
try
{
Int16 MsgLength = (Int16)((Buffer[0x01] << 8) + Buffer[0x00]);
Int16 MsgId = (Int16)((Buffer[0x03] << 8) + Buffer[0x02]);
Int32 Data = (Int32)((Buffer[0x07] << 24) + (Buffer[0x06] << 16) + (Buffer[0x05] << 8) + Buffer[0x04]);
Action Action = (Action)Buffer[0x08];
Byte Count = Buffer[0x09];
String[] Params = new String[Count];
Int32 Pos = 10;
for (Int32 i = 0; i < Count; i++)
{
Params[i] = Program.Encoding.GetString(Buffer, Pos + 1, Buffer[Pos]);
Pos = Params[i].Length + 1;
}
switch (Action)
{
case Action.MemberList:
{
Player Player = Client.User;
if (Player == null)
return;
Console.WriteLine(Program.Dump(Buffer));
break;
}
case Action.QuerySpouse:
{
Player Player = Client.User;
if (Player == null)
return;
Player Target = null;
if (!World.AllPlayers.TryGetValue(Data, out Target))
return;
Player.Send(MsgName.Create(Target.UniqId, Target.Spouse, Action.QuerySpouse));
break;
}
case Action.Bavarder:
{
Player Target = null;
foreach (Player Player in World.AllPlayers.Values)
{
if (Player.Name == Params[0])
{
Target = Player;
break;
}
}
if (Target == null)
return;
String TargetInfo =
Target.UniqId + " " +
Target.Level + " " +
Target.Potency + " #" +
"GuildName" + " #" +
"FamilyName" + " " +
Target.Spouse + " " +
Target.Nobility.Rank + " " +
(Target.IsMan() ? (Byte)1 : (Byte)0);
Client.Send(MsgName.Create(0, new String[] { Target.Name, TargetInfo }, Action.Bavarder));
break;
}
default:
{
Console.WriteLine("Msg[{0}], Action[{1}] not implemented yet!", MsgId, (Int16)Action);
break;
}
}
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
}
}
thnx mate i will test it and tell you if it works "i like ur style ur remembering me of C++ "
--------------------------------------------------------------------------- EDIT:
okey well i fixed it :P
how!
Code:
public StringPacket(string str, string other)
: base(0x3F7, (ushort)(14 + str.Length + other.Length))
{
Texts = new List<string>() { str, other };
WriteStringList(9, Texts);
}
because add isn't really a good way plus , it's not right to Pass Texts as A public field :P