Crossfire Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CF: patch for both clients, 0.95.1: improves compound command handling




If like me you like to do your compound bindings like this 'cmd1 ;
cmd2' (with space on either side of the colon, for readability then
you run into trouble as the second command is not recognized. The
server does not like any blanks at the front of a command, and so
these must be stripped before sending.

I also cleaned up the code around there a bit, made it easier to read.

This is a patch to common client code, v 0.95.1, file: players.c

*** player.c.orig	Sun Nov 29 20:39:47 1998
--- player.c	Wed Dec  9 19:36:47 1998
***************
*** 257,273 ****
      }
      else if (!strcmp(cp,"inv")) /* inventory command is sended to server
  				   for debugging purposes */
  	print_inventory (cpl.ob);
      else {
! 	cp = ocommand;
! 	while ((cpnext = strchr(cp, ';')) != NULL) {
! 	    strncpy(command, cp, cpnext - cp);
! 	    command[cpnext - cp] = '\0';
! 	    cpnext++;
! 	    send_command(command, cpl.count, 0);
! 	    cp = cpnext;
  	}
- 	send_command(cp, cpl.count, 0);
      }
  }
   
--- 257,274 ----
      }
      else if (!strcmp(cp,"inv")) /* inventory command is sended to server
  				   for debugging purposes */
  	print_inventory (cpl.ob);
      else {
! 	/* just send the command(s)  (if `ocommand' is a compound command */
! 	/* then split it and send each part seperately */
!         strcpy(command, ocommand);
! 	cp = strtok(command, ";");
! 	while ( cp ) {
! 	  while( *cp == ' ' ) cp++; /* throw out leading spaces; server
! 				       does not like them */
! 	  send_command(cp, cpl.count, 0);
! 	  cp = strtok(NULL, ";");
  	}
      }
  }
   

-- 
                                                         Maciej Kalisiak
Fear the Penguin......                               mac@dgp.utoronto.ca
                                                   mac@elecom97.mail.net
                                               www.eecg.utoronto.ca/~mac