Mailing List
Home
Forum Home
Mac Game - Mac game development
Rivers of MUD - a Diku and Merc based multiuser dungeon
SMAUG
Subjects
Getting UDP through NAT/firewalls/whatever for a game
Getting UDP through NAT/firewalls/whatever for a game
QuickTime errors
Python script as stand alone MUD server
Various sound problems
Fragment Shaders & GL TEXTURE RECTANGLE EXT
Timers and global variables
Re: Language and platform for Text MUD server
Apparent acquisition of Yantis (mysupersales) by IDE
HID keyboard
Getting UDP through NAT/firewalls/whatever for a game
Microsoft Sparkle
Director MX
Congratulations Horizons
Yet more problems fullscreen mode
Apple Dev Kitchen Them 's tasty vittles, Maw!
NSOpenGLContext, Pbuffers, and drawables
More DCR "theft " naughtiness
dynamic sprite creation and imaging lingo
Re: Find stuff in Flash array?
Effects of skill imbalances?
QuickTime errors
Rom 2 4/Quickmud Enhancement/Bug fix
Working with XML files/CFURL
smooth scrolling/subpixel tweening
RE: (Ron help me?) Flash text
Flash Racing
MudDev FAQ 2
Browser based games
Installing GLUT
Special character in Flash XML
 
Input: The somewhat finished version

Input: The somewhat finished version

2005-01-19       - By dayrinni@(protected)

 Back
So this is what I have so far. It works, but there are some problems with it.
Basically, it puts a lot of \n\r's into the buffer and I can't seem to get them
out. Also, at times it crashes the game, and at times it does not display the
prompt and the buffer just gets destroyed. Finally, this is a good one: what is
occuring in the game to said player displays in the shell. I literally laughed
at that one. So, this is what I have:

bool read_from_descriptor( DESCRIPTOR_DATA *d )
{

      int iStart;

       /* Hold horses if pending command already. */
      if ( d->incomm[0] != '\0' )
    return TRUE;

   /* Check for overflow. */
   iStart = strlen(d->inbuf);
   if ( iStart >= sizeof(d->inbuf) - 10 )
   {
  sprintf( log_buf, "%s input overflow!", d->host );
  log_string( log_buf );
  write_to_descriptor( d->descriptor,
     "\n\r*** PUT A LID ON IT!!! ***\n\r", 0 );
  return FALSE;
   }




   /* Snarf input. */
#if defined(macintosh)
   for ( ; ; )
   {
  int c;
  c = getc( stdin );
  if ( c == '\0' || c == EOF )
     break;
  putc( c, stdout );
  if ( c == '\r' )
     putc( '\n', stdout );
  d->inbuf[iStart++] = c;
  if ( iStart > sizeof(d->inbuf) - 10 )
     break;
   }
#endif


#if defined(MSDOS) || defined(unix)
   for ( ; ; )
   {
  int nRead;

  nRead = read( d->descriptor, d->inbuf + iStart,
     sizeof(d->inbuf) - 10 - iStart );

  if ( nRead > 0 )
  {
     iStart += nRead;
     if ( d->inbuf[iStart-1 (See http://art-1.ora-code.com)] == '\n' || d->inbuf[iStart-1 (See http://art-1.ora-code.com)] == '\r' )
    break;
  }
  else if ( nRead == 0 )
  {
     log_string( "EOF encountered on read." );
     return FALSE;
  }
  else if ( errno == EWOULDBLOCK )
     break;
  else
  {
     perror( "Read_from_descriptor" );
     return FALSE;
  }
   }
#endif

   d->inbuf[iStart] = '\0';

  //return TRUE;


  if(d)
  {
    char command[MSL];
               int x, i, y,temp, z = 0;
               int csize;
    bool character = FALSE;

               csize = strlen(d->inbuf);
               command[0] = '\0';

    if(d->character)
      character = TRUE;   //we have a character
    if(character)
    {
      if(d->character->wait < 1) //don't do this if there is no wait.
        return TRUE;
    }

    for(x = 0, i = 0;x <= csize;x++)
               {
      if(d->character)
                         character = TRUE;       //we have a character
                 if(d->inbuf[x] == '\n' || d->inbuf[x] == '\r' || d->inbuf[x]
=='\0')
      //dont copy this.
      {
        if(command[0] != '\0')
          found = TRUE;   //we have a command.
      }
      else
      {
        command[i] = d->inbuf[x]; //lets copy the next element.
        i++;       //increment the command by 1
        continue;     //lets get the rest of the command.
      }

      if(found && character) //we have the command. let's see if we can execute it.
      {
        //execute it.
        interpret(d->character, command);
        //lets check to see if we executed it. if we did, let's remove it.
        if(d->character->remove_command)
        {
          //shift contents of the array.
          temp = x - strlen(command);
          //move previous items over the item that you're trying to delete
          for(z = 0; z < csize;z++, temp++)
          {
            d->inbuf[temp] = d->inbuf[temp+strlen(command)];
          }
          //lets set the remove command to false.
          if(d->character)
            d->character->remove_command = FALSE;
          //set found to false
          found = FALSE;
          //set i to 0 in the command.
          i = 0;
          //set the new csize
          csize = strlen(d->inbuf);
          /*We executed the command during a wait state. We also
          removed the command. So let's check the next one.*/
        }

        //clear out the command.
        for(y = 0;command[y] != '\0';y++)
                                  command[y] = '\0';
        //set i to be 0 in the command.
        i = 0;
        //set found to false
        found = FALSE;
      }
    }
  }

  return TRUE;
}

Maybe someone can lend me a hand. THANKS!


--
ROM mailing list
ROM@(protected)
http://www.rom.org/cgi-bin/mailman/listinfo/rom