Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
S2C weapons packet - weapon info

 
Post new topic   Reply to topic Printable version
 View previous topic  A little confused... Post :: Post Managing flag id transfers between pla...  View next topic  
Author Message
grazzhoppa (nopswd)
Guest


Offline

PostPosted: Sun Aug 16, 2009 4:25 pm    Post subject: S2C weapons packet - weapon info Reply to topic Reply with quote

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?


Code: Show/Hide
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
Code: Show/Hide
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

PostPosted: Sun Aug 16, 2009 4:28 pm    Post subject: Re: S2C weapons packet - weapon info Reply to topic Reply with quote

grazzhoppa (nopswd) wrote:

Code: Show/Hide
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:
Code: Show/Hide
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
View users profile Send private message Add User to Ignore List AIM Address
grazzhoppa (nopswd)
Guest


Offline

PostPosted: Sun Aug 16, 2009 4:46 pm    Post subject: Reply to topic Reply with quote

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:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sun Aug 16, 2009 4:47 pm    Post subject: Reply to topic Reply with quote

I think you misunderstood, those are the same struct!

here's what I got from mervbot:
Code: Show/Hide
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
View users profile Send private message Add User to Ignore List AIM Address
grazzhoppa (nopswd)
Guest


Offline

PostPosted: Sun Aug 16, 2009 4:52 pm    Post subject: Reply to topic Reply with quote

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:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Aug 16, 2009 5:06 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
grazzhoppa (nopswd)
Guest


Offline

PostPosted: Sun Aug 16, 2009 5:16 pm    Post subject: Reply to topic Reply with quote

Quote:
Mostly because two bytes of information won't fit into one byte.

A yes/no true/false 0/1 value can fit into 1 byte. There are a few of those in that struct. The highest value in that struct is 32, so each field could fit into just 1 byte instead of 2 bytes.

Another way to ask the same question: Why not use a struct like this with unisigned 1 byte integers (uint8) rather than (uint16)?
Code: Show/Hide

struct WEAPONS_ {
    uint8_t type      : 5;
    uint8_t level     : 2;
    uint8_t shrap_bounce : 1;
    uint8_t shrap_level  : 2; /* bullet/gun level */
    uint8_t shrap     : 5;
    uint8_t alternate : 1; /* Bombs -> Mines or Bullets -> Multifire */
}
Back to top
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Aug 16, 2009 5:21 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Aug 16, 2009 9:18 pm    Post subject: Reply to topic Reply with quote

Yeah, so all of the uint16 fields actually use THE SAME uint16
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
grazzhoppa (nopswd)
Guest


Offline

PostPosted: Sun Aug 16, 2009 9:44 pm    Post subject: Reply to topic Reply with quote

I see now. thanks!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 410 page(s) served in previous 5 minutes.

phpBB Created this page in 0.581548 seconds : 35 queries executed (77.1%): GZIP compression disabled