void unignore(int cn, int attempt) { fpsent *d = game::getclient(cn); if(attempt == 0) {error("please connect to a server to ignore");} else if(!d) {error("please enter a valid client number");} else if(d == game::player1) {error("you cannot ignore yourself");} else if(!isignored(cn)) {error("user %s is not ignored", d->name);} else { info("stopped ignoring %s", d->name); ignores.removeobj(cn); } }
void ignore(int cn, int attempt) { fpsent *d = game::getclient(cn); if(attempt == 0) {error("please connect to a server to ignore");} else if(!d) {error("please enter a valid client number");} else if(d == game::player1) {error("you cannot ignore yourself");} else if(isignored(cn)) {error("user %s is already being ignored", d->name);} else { info("ignoring %s", d->name); if(ignores.find(cn) < 0) ignores.add(cn); } }
int parse_file(const char *srcfile) { // read source file void *buffer; UINT32 length; file_error filerr = core_fload(srcfile, &buffer, &length); if (filerr != FILERR_NONE) { fprintf(stderr, "Unable to read source file '%s'\n", srcfile); return 1; } // rip through it to find all drivers char *srcptr = (char *)buffer; char *endptr = srcptr + length; int linenum = 1; bool in_comment = false; while (srcptr < endptr) { char c = *srcptr++; // count newlines if (c == 13 || c == 10) { if (c == 13 && *srcptr == 10) srcptr++; linenum++; continue; } // skip any spaces if (isspace(c)) continue; // look for end of C comment if (in_comment && c == '*' && *srcptr == '/') { srcptr++; in_comment = false; continue; } // skip anything else inside a C comment if (in_comment) continue; // look for start of C comment if (c == '/' && *srcptr == '*') { srcptr++; in_comment = true; continue; } // if we hit a C++ comment, scan to the end of line if (c == '/' && *srcptr == '/') { while (srcptr < endptr && *srcptr != 13 && *srcptr != 10) srcptr++; continue; } // look for an import directive if (c == '#') { char filename[256]; filename[0] = 0; for (int pos = 0; srcptr < endptr && pos < ARRAY_LENGTH(filename) - 1 && !isspace(*srcptr); pos++) { filename[pos] = *srcptr++; filename[pos+1] = 0; } fprintf(stderr, "Importing drivers from '%s'\n", filename); parse_file(filename); continue; } if (c == '!') { char drivname[256]; drivname[0] = 0; for (int pos = 0; srcptr < endptr && pos < ARRAY_LENGTH(drivname) - 1 && !isspace(*srcptr); pos++) { drivname[pos] = *srcptr++; drivname[pos+1] = 0; } fprintf(stderr, "Place driver '%s' to ignore list\n", drivname); char *name = (char *)malloc(strlen(drivname) + 1); strcpy(name, drivname); ignorelst[ignorecount++] = name; continue; } // otherwise treat as a driver name char drivname[32]; drivname[0] = 0; srcptr--; for (int pos = 0; srcptr < endptr && pos < ARRAY_LENGTH(drivname) - 1 && !isspace(*srcptr); pos++) { drivname[pos] = *srcptr++; drivname[pos+1] = 0; } // verify the name as valid for (char *drivch = drivname; *drivch != 0; drivch++) { if ((*drivch >= 'a' && *drivch <= 'z') || (*drivch >= '0' && *drivch <= '9') || *drivch == '_') continue; fprintf(stderr, "%s:%d - Invalid character '%c' in driver \"%s\"\n", srcfile, linenum, *drivch, drivname); return 1; } // add it to the list if(!isignored(drivname)) { char *name = (char *)malloc(strlen(drivname) + 1); strcpy(name, drivname); drivlist[drivcount++] = name; } } osd_free(buffer); return 0; }
bool isignored(int cn, const char *text) { return isignored(game::getclient(cn), text); }