Ok habs... alles was im struct unter "public byte[] Test;" steht geht verloren.... :|
Klar, deine Converterfunktion berücksichtigt diesen Teil der Daten nicht.
Wenn hinter der Referenz tatsächlich ein Array steckt hast du doch mindestens zwei Speicherblöcke. Ich sehe bis jetzt nicht wo ConvertToByte dies berücksichtigen würde.
Struct's kannst du nur mit fester groesse in ein byte array kopieren.
string und byte[] sind dynamisch.
So handhabe ich es:
PHP Code:
[StructLayout(LayoutKind.Sequential, Pack = 1)] public unsafe struct MsgFriendInfo { public ushort Size; public ushort Id; public uint UniqId; public uint Look; public byte Level; public byte Profession; public ushort PkPoints; public ushort GuildUID; public byte Unknow; public byte Position; public fixed byte Spouse [16];
public static byte[] Create(Player target) { var packet = new MsgFriendInfo {Size = 36, Id = 2033, UniqId = target.UniqueId, Look = (uint)target.Look, Level = target.Level, Profession = target.Class, PkPoints = target.PkPoints, GuildUID = (ushort)target.Guild.UniqueId, Unknow = 0, Position = (byte)target.GuildRank,}; for (byte i = 0; i < target.Partner.Length; i++) packet.Spouse[i] = (byte)target.Partner[i]; return packet; }
public static implicit operator byte[](MsgFriendInfo msg) { var buffer = BufferPool.GetBigBuffer(); fixed (byte* p = buffer) *(MsgFriendInfo*)p = *&msg; return buffer; } }
Spouse ist ein string der maximal 16 zeichen lang ist.
DDJ to Byte array 02/16/2016 - SRO Coding Corner - 2 Replies I'm using "FreeImage" library to get the ddj files from iSro Media file. I got the library from another project.
It seems to be working fine , but some icons doesn't appear to be normal it is like shifted or something for example: "Media\icon64\item\avatar\mall_avarat_m_sns_2 013.ddj".
The icon should be like the first one 45x45 , But I got the second icon with 44x44
So did anyone face this problem before? and if there is anyone open source library or so for convertion between ddj <->...
C# struct value (string) ändern 10/07/2015 - .NET Languages - 6 Replies Hey,
Ich möchte einen string in einem struct ändern... aber es passiert leider nichts (kein fehler, keine änderung)
private List<MyStruct> TestList= new List<MyStruct>();
public struct MyStruct
{
public string Name;
boolean array in struct - help 06/02/2013 - C/C++ - 9 Replies Well, i have a struct with an boolean array in it... like this:
struct abc{
bool mnzc;
};
how can i declare MAX? Because if i do it, jut like "int MAX=12;" it wont work...