Server Help

ASSS Questions - Detaching bug + fix, Asss-1.1.7, Linux

Jackmn - Fri Apr 02, 2004 3:47 pm
Post subject: Detaching bug + fix, Asss-1.1.7, Linux
Sorry, couldn't decide whether to post this here or in the custom code section.

Problem:
With Continuum 0.38 ( other versions untested ), detaching doesn't appear to work. While the detaching client sees itself as being detached, the other players view the said client as remaining attached.

This creates some rather spectacular problems when the client starts shooting, as others see his/her bullets appearing out of nowhere.

Diagnosis:
Code: Show/Hide
game.c
=======
local void PAttach(Player *p, byte *pkt2, int len)
{
   int pid2 = ((struct SimplePacket*)pkt2)->d1;
   Arena *arena = p->arena;

   if (len != 3)
   {
      lm->LogP(L_MALICIOUS, "game", p, "bad attach req packet len=%i", len);
      return;
   }

   if (p->status != S_PLAYING || !arena)
      return;

   if (pid2 == -1)
   {
      Player *to = pd->PidToPlayer(pid2);
      if (!to ||
          to->status != S_PLAYING ||
          to == p ||
          p->arena != to->arena ||
          p->p_freq != to->p_freq)
      {
         lm->LogP(L_MALICIOUS, "game", p, "tried to attach to bad pid %d", pid2);
         return;
      }
<snip>
}


When a client detaches, it sends a 'attach' message with a PID of -1. Since that isn't a valid player, the warning gets logged and the function returns without storing ( and later broadcasting ) the detach. Since the game is client based, the client believes it has detached, while nobody else recieves notification of this.

Solution:
Thankfully very simple.

In the above function, change the line
Quote:
if (pid2 == -1)

to
Quote:
if (pid2 == -1 && p->p_attached != -1)


As far as I have seen, this works. No guarantees though.
Grelminar - Fri Apr 02, 2004 4:20 pm
Post subject:
Actually the correct fix is to just reverse the comparison and change it to:
if (pid2 != -1)
Jackmn - Fri Apr 02, 2004 4:35 pm
Post subject:
That makes sense, I wasn't thinking.
CypherJF - Fri Apr 02, 2004 5:48 pm
Post subject:
table is farked up :/
Mine GO BOOM - Fri Apr 02, 2004 7:02 pm
Post subject:
CypherJF wrote:
table is farked up :/

I'm working on school first, the forums second. Almost got the archives ready, and when I do, I'll globally update the main forums too.
CypherJF - Tue Apr 06, 2004 10:33 am
Post subject:
lol its not a problem; the html tables were a tad messed up, im assuming cause of an unclosed table tag biggrin.gif but it anywho its all good icon_smile.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group