我正在将我的程序移植到 C++,但我遇到了一些麻烦。我在 C# 中有这个代码创建一个 byte[] :
writer.New(0x484700C0);
{
writer += Functions.PadString("PTEmu", 0x10);
writer += new byte[] { 0xC9, 0x32, 0xE0, 0x4D, 0xEB, 0x01 };
writer.SkipBytes(6);
writer += 1;
writer += channels.Count; // sub count
for (int i = 0; i < channels.Count; i++)
{
writer += Functions.PadString(channels[i].Item4, 0x20); // len = 0x20
writer += Functions.PadString(channels[i].Item2, 0x14);
writer += Functions.PadString(channels[i].Item2, 0x14);
writer += Functions.PadString(channels[i].Item2, 0x14);
writer += channels[i].Item3; // int, size = 4
writer += channels[i].Item3;
writer += channels[i].Item3;
writer += 0;
}
writer += Functions.PadString("Clan", 32);
writer += Functions.PadString("127.0.0.1", 0x14);
writer += Functions.PadString("127.0.0.1", 0x14);
writer += Functions.PadString("127.0.0.1", 0x14);
writer += 80;
writer += 80;
writer += 80;
writer.SkipBytes(12);
}
我想过做类似的事情:
struct PT_ServerList{
int size;
int opcode;
char server[0x10];
char bla[6];
int reserved1;
short reserved2;
int unknow;
int serverCount;
ServerInfo servers[];
};
但是在服务器 [] 之后,我需要添加更多变量,但是编译器不接受该结构。我能做些什么来解决这个问题?