|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T d
Length: 3492 (0xda4) Types: TextFile Names: »docommand.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Gb/docommand.c«
/* * Galactic Bloodshed (Robert Chansky, smq@b) * docommand.c -- figures out what command it is and the arguments, * executes the command via the proper subroutine */ #include "vars.h" #include <strings.h> #include <ctype.h> extern int God; int docommand(commstring) char commstring[]; { int i,argn=0; bool parse_exit=0; char args[MAXARGS][COMMANDSIZE]; char *string; string=commstring; /* make pointers the same */ while (!parse_exit) { i=0; while ( !isspace(*string) && (*string!='\0') && (i<COMMANDSIZE) ) args[argn][i++]=(*string++); args[argn][i]='\0'; /*printf("arg %d |%s|\n",argn,args[argn]);*/ while ((*string)==' ') string++; if ( (*string=='\0') || (argn>=MAXARGS)) parse_exit=1; argn++; } for (i=argn; i<MAXARGS; i++) args[i][0]='\0'; if (args[0][0]=='\0') /* just pressed return */ return(1); /* go back and wait again */ i=strlen(args[0]); if (!strncmp(args[0],"quit",i)) return(0); /* quit game */ /* return quit status */ else if (!strncmp(args[0],"autoreport",i)) autoreport(0,argn,args); else if (!strncmp(args[0],"build",i)) build(2,argn,args); else if (!strncmp(args[0],"survey",i)) survey(0,argn,args); else if (!strncmp(args[0],"cs",i)) cs(0,argn,args); else if (!strncmp(args[0],"assault",i)) land(2,argn,args,1); else if (!strncmp(args[0],"dock",i)) land(1,argn,args,0); else if (!strncmp(args[0],"fire",i)) fire(2,argn,args); else if (!strncmp(args[0],"help",i)) help(0,argn,args); else if (!strncmp(args[0],"land",i)) land(1,argn,args,0); else if (!strncmp(args[0],"launch",i)) launch(1,argn,args); else if (!strncmp(args[0],"load",i)) load(1,argn,args); else if (!strncmp(args[0],"map",i)) map(0,argn,args); else if (!strncmp(args[0],"mobilize",i)) mobilize(2,argn,args); else if (!strncmp(args[0],"name",i)) name(2,argn,args); else if (!strncmp(args[0],"orbit",i)) orbit(0,argn,args); else if (!strncmp(args[0],"order",i)) order(1,argn,args); else if (!strncmp(args[0],"profile",i)) profile(0,argn,args); else if (!strncmp(args[0],"read",i)) teleg_read(0,argn,args); else if (!strncmp(args[0],"report",i)) rst(0,argn,args,0); else if (!strncmp(args[0],"stock",i)) rst(0,argn,args,1); else if (!strncmp(args[0],"tactical",i)) rst(0,argn,args,2); else if (!strncmp(args[0],"ship",i)) rst(0,argn,args,3); else if (!strncmp(args[0],"object",i)) rst(0,argn,args,4); else if (!strncmp(args[0],"power",i)) power(0,argn,args); else if (!strncmp(args[0],"telegram",i)) telegram(2,argn,args); else if (!strncmp(args[0],"undock",i)) launch(1,argn,args); else if (!strncmp(args[0],"declare",i)) declare(1,argn,args); else if (!strncmp(args[0],"scrap",i)) scrap(1,argn,args); else if (!strncmp(args[0],"examine",i)) examine(1,argn,args); else if (!strncmp(args[0],"zoom",i)) zoom(0,argn,args); #if SHELL_DOTURN /* only do this if compiler option to save disk space.. */ /* only owning player can do turns */ else if (!strncmp(args[0],"doturn",i)) { if (God) { doturn(1); /* from shell */ docommand("cs :"); } else printf("You are not empowered to do that.\n"); } #endif /* only owning player can use fix */ else if (!strncmp(args[0],"fix",i)) { if (God) { fix(argn,args); docommand("cs :"); } else printf("You are not empowered to do that.\n"); } else printf("'%s':illegal command error(%d).\n",args[0],*args[0]); /* grab extraneous return chars if there are any */ return(1); /* main() knows user is not quitting */ }