Author |
Message |
grazzhoppa (nopswd) Guest
Offline
|
Posted: Sun Aug 16, 2009 4:25 pm Post subject: S2C weapons packet - weapon info |
|
|
|
|
I am using two sources to get info about how S2C packets are constructed.
1) http://d1st0rt.sscentral.com/packets.html
2) ASSS 1.4.4 source
Inside the packets that send weapons info, there are conflicting constructions between my sources. ASSS has 2 bits being "shrap level", but d1st0rt's page says those 2 bits are indicate "Is Bomb" and is "EMP".
Are these saying the same thing with different wording, or are they contradictory?
Anyone mind explaining what those 2 particular bit indicate?
Weapon type :5 bits
Weapon level :2 bits
Bouncing (Boolean) :1 bit
EMP (Boolean) :1 bit <<---
Is bomb (Boolean) :1 bit <<---
Shrapnel :5 bits
Alternate (Boolean) :1 bit |
struct Weapons /* 2 bytes */
{
u16 type : 5;
u16 level : 2;
u16 shrapbouncing : 1;
u16 shraplevel : 2; <<---
u16 shrap : 5;
u16 alternate : 1;
};
|
|
|
Back to top |
|
|
Initrd.gz Seasoned Helper
Joined: Sep 18 2008 Posts: 134 Location: Over there ---> Offline
|
Posted: Sun Aug 16, 2009 4:28 pm Post subject: Re: S2C weapons packet - weapon info |
|
|
|
|
grazzhoppa (nopswd) wrote: |
Weapon type :5 bits
Weapon level :2 bits
Bouncing (Boolean) :1 bit
EMP (Boolean) :1 bit <<---
Is bomb (Boolean) :1 bit <<---
Shrapnel :5 bits
Alternate (Boolean) :1 bit |
|
If emp is 1, the bomb is an EMP bomb
If Is bomb is 0 (i think) then the bomb is actually a mine, not a bomb
grazzhoppa (nopswd) wrote: | struct Weapons /* 2 bytes */
{
u16 type : 5;
u16 level : 2;
u16 shrapbouncing : 1;
u16 shraplevel : 2; <<---
u16 shrap : 5;
u16 alternate : 1;
};
|
|
What level the shrapnel is on the bomb. Say the player firing the bomb has L2 bullets. Then shraplevel would be 2 |
|
Back to top |
|
|
grazzhoppa (nopswd) Guest
Offline
|
Posted: Sun Aug 16, 2009 4:46 pm Post subject: |
|
|
|
|
Quote: | If emp is 1, the bomb is an EMP bomb
...What level the shrapnel is on the bomb. Say the player firing the bomb has L2 bullets. Then shraplevel would be 2 |
Those 2 structures are proposed for the same type of packet. So does the 9th bit indicate the EMP status of the bomb, or does it is part of the shrap level? It can't be both.
Quote: | If Is bomb is 0 (i think) then the bomb is actually a mine, not a bomb |
Doesn't the "Alternate" bit indicate whether it's a mine rather than a bomb? So the bit indicating "is a bomb" would seem superfluous. |
|
Back to top |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Sun Aug 16, 2009 4:47 pm Post subject: |
|
|
|
|
I think you misunderstood, those are the same struct!
here's what I got from mervbot:
union weaponInfo
{
struct
{
Uint16 type : 5; // enum Projectile_Types
Uint16 level : 2; // Only for bombs/bullets
Uint16 shrapBounce : 1; // Bouncing shrapnel?
Uint16 shrapLevel : 2; // Shrapnel level 0..3
Uint16 shrapCount : 5; // 0-31
Uint16 fireType : 1; // Bombs -> Mines, Bullets -> Multifire
};
Uint16 n;
};
// Weapon types for weaponInfo.type
enum Projectile_Types
{
// Seen "in the wild"
PROJ_None,
PROJ_Bullet,
PROJ_BBullet,
PROJ_Bomb,
PROJ_PBomb,
PROJ_Repel,
PROJ_Decoy,
PROJ_Burst,
PROJ_Thor,
// Internal to the bot
PROJ_InactiveBullet,
PROJ_Shrapnel
}; |
The asss version is right. Bomb is a property of the weapon type, EMP is a settings property of the ship doing the firing _________________ SubSpace Discretion: A Third Generation SubSpace Client |
|
Back to top |
|
|
grazzhoppa (nopswd) Guest
Offline
|
Posted: Sun Aug 16, 2009 4:52 pm Post subject: |
|
|
|
|
thank you.
Another question:
Both ASSS and mervbot use unsigned 2 byte ints for that struct. Is there a technical reason for that? Why not use unsigned 1 byte ints? |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sun Aug 16, 2009 5:06 pm Post subject: |
|
|
|
|
Mostly because two bytes of information won't fit into one byte. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
|
grazzhoppa (nopswd) Guest
Offline
|
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sun Aug 16, 2009 5:21 pm Post subject: |
|
|
|
|
You don't understand how bitfields work. I don't blame you, they're not seen much outside of embedded and network code. The : afterwards makes it use that many bits. Total all of the #s and you'll get 16, meaning the type needs to have two bytes.
The ENTIRE struct takes 2 bytes, not 12. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sun Aug 16, 2009 9:18 pm Post subject: |
|
|
|
|
Yeah, so all of the uint16 fields actually use THE SAME uint16 _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
grazzhoppa (nopswd) Guest
Offline
|
Posted: Sun Aug 16, 2009 9:44 pm Post subject: |
|
|
|
|
I see now. thanks! |
|
Back to top |
|
|
|