|
You last visited: Today at 13:15
Advertisement
[Help] Weather Packet (My First Packet)
Discussion on [Help] Weather Packet (My First Packet) within the CO2 Private Server forum part of the Conquer Online 2 category.
05/02/2010, 00:51
|
#1
|
elite*gold: 0
Join Date: Mar 2010
Posts: 126
Received Thanks: 14
|
[Help] Weather Packet (My First Packet)
delete this thread.
|
|
|
05/02/2010, 01:22
|
#2
|
elite*gold: 0
Join Date: Mar 2010
Posts: 133
Received Thanks: 22
|
If I'm not mistaken there is two packets for weather ( well. its atleast what I have had )
1. Type (Rain, FireFlies, Snow, Leaves, etc.)
2. On/Off
|
|
|
05/02/2010, 01:29
|
#3
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
|
P.WriteInt16((ushort)(Packet.Length - 13));
Should read:
P.WriteInt16((ushort)(Packet.Length));
|
|
|
05/02/2010, 04:18
|
#4
|
elite*gold: 0
Join Date: Mar 2010
Posts: 126
Received Thanks: 14
|
delete this thread.
|
|
|
05/02/2010, 11:36
|
#5
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
|
Actually you dont need that at all.
The pointer is where you write data that is actually going to be sent, im not sure what you were trying to do but there is nothing before the length and type, they are the start of the packet.
|
|
|
05/02/2010, 14:53
|
#6
|
elite*gold: 20
Join Date: Aug 2005
Posts: 1,734
Received Thanks: 1,000
|
Pseudo code for packets:
PHP Code:
struct HEADER { ushort Size; ushort Type; } struct NET_MSG { HEADER Header; ByteArray Data; }
NET_MSG is the packet you send/receive which consists of header and the data it contains. Header contains the size of packet and also the type of the packet. This means that the first two bytes are the size and the next two bytes are the type of the message (packet).
PHP Code:
public static COPacket Weather(byte Type, uint Intensity, uint Direction, uint Appearance) { COPacket Packet = new COPacket(new byte[17]) Packet.WriteInt16(Packet.Length); Packet.WriteInt16(1016); Packet.WriteByte(Type); Packet.WriteInt32(Intensity); Packet.WriteInt32(Direction); Packet.WriteInt32(Appearance); return Packet; }
First of all, scratch all those conversions to uint:
PHP Code:
P.WriteInt32((uint)(Weather_Intensity));
You're already passing the param Weather_Intensity as uint, no need to cast it to uint again. Oh and why are you doing (ushort)1016, it can already be counted as ushort since the value 1016 isn't magically going to change the type.
When creating a new instance of COPacket you can start writing the size/type and data to it immetiadly since it contains self incrementing counter/indexer. (WriteInt16 increases it by 2 and WriteInt32 by 4 and so on.)
|
|
|
05/03/2010, 23:53
|
#7
|
elite*gold: 0
Join Date: Mar 2010
Posts: 126
Received Thanks: 14
|
delete this thread.
|
|
|
05/05/2010, 02:38
|
#8
|
elite*gold: 0
Join Date: Feb 2010
Posts: 378
Received Thanks: 86
|
#bumped.
unsolved
|
|
|
05/05/2010, 03:34
|
#9
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,434
Received Thanks: 1,147
|
Wrong structure... The length should be 20 and the type 0x3f8 (1017?).
Code:
Length -> Int16
Type -> Int16
Look -> Int32
Intensity -> Int32
Direction -> Int32
Color -> Int32
|
|
|
05/08/2010, 03:39
|
#10
|
elite*gold: 0
Join Date: Mar 2010
Posts: 126
Received Thanks: 14
|
delete this thread.
|
|
|
05/08/2010, 11:06
|
#11
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
|
Which client is this for?
|
|
|
05/08/2010, 11:08
|
#12
|
elite*gold: 0
Join Date: Oct 2009
Posts: 8,765
Received Thanks: 5,291
|
5165.
|
|
|
05/08/2010, 11:40
|
#13
|
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
|
public static COPacket Weather(byte Type, uint Intensity, uint Direction, uint Appearance)
{
byte[] Packet = new byte[28];
COPacket P = new COPacket(Packet);
P.WriteInt16((ushort)(Packet.Length - 8));
P.WriteInt16(1016);
P.WriteInt16(Type);
P.WriteInt32(Intensity);
P.WriteInt32(Direction);
P.WriteInt32(Appearance);
return P;
}
[/code]
You gotta add 8 bytes for "TQServer" string. When the client receives a packet it verifies it's 8 last bytes, and if it's not TQServer the client will dc its self. Anyway, you don't need to add TQServer string when you build the packet(the string will be added when client.Send(COPacket) is accessed), but you need to give 8 bytes for the string in buffer.
|
|
|
05/08/2010, 14:11
|
#14
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,434
Received Thanks: 1,147
|
Sorry, wrong conversion The packet type is 0x3f8 in hexadecimal, but it's 1016 in decimal, not 1017. And you need the TQServer at the end for new client.
|
|
|
05/08/2010, 15:53
|
#15
|
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
|
Code:
public static COPacket Weather(byte Type, uint Intensity, uint Direction, uint Appearance)
{
byte[] Packet = new byte[20];
COPacket P = new COPacket(Packet);
P.WriteInt16((ushort)(Packet.Length));
P.WriteInt16((ushort)(1017));
P.WriteInt16(Type);
P.WriteInt32(Intensity);
P.WriteInt32(Direction);
P.WriteInt32(Appearance);
return P;
}
Okay, I'll give you one hint.
First thing I do when I get a disconnection error when I just added a new packet structure, is count the Length.
Code:
byte[20] >> 20
Int16 >> 18
Int16 >> 16
Int16 >> 14
Int32 >> 10
Int32 >> 6
Int32 >> 2
Change the Length to 18.
Also another thing, I am pretty sure you should make the PacketType 1016.
Not sure if this is the correct structure though.
|
|
|
Similar Threads
|
[help]weather packet
11/25/2009 - CO2 Private Server - 2 Replies
staff, I need the packet of the weather, someone has?
|
All times are GMT +2. The time now is 13:15.
|
|