fuzzball icon indicating copy to clipboard operation
fuzzball copied to clipboard

MPI Support for Boolexp (Locks)

Open tanabi opened this issue 6 years ago • 0 comments

Okay, as a player, I've wanted this for a really long time. Even as a server admin, this would be super handy. I would love for @ lock to parse MPI. There's no particular reason for it not to, and in fact, this is a fairly easy change. If anyone wants to contribute to Fuzzball but has been shy about it, this is an easy(ish) one to implement.

  1. Create a BOOLEXP_MPI define in boolexp.h
  2. Add a char* to struct boolexp for the MPI text to parse. Bonus points if you turn thing/prop_check/mpi into a struct union -- that's more work since you'll have to convert the code in boolexp.c to use a union, but it actually reduces the memory footprint of struct boolexp instead of increasing it :) If you chose not to go for the bonus points, please put an @ TODO comment reminding us to come back and turn it into a union later.
  3. Add support for the MPI string to copy_bool
  4. In eval_boolexp_rec add a case BOOLEXP_MPI and have it evaluate the MPI. Make sure to run it in PREEMPT. There's plenty of example codes of how run MPI. The results of the evaluation should be either "0" or anything else -- anything else will be counted as true, similar to how the MUF evaluation under BOOLEXP_CONST works.
  5. Updat eparse_boolexp_F to look for a '{' in the big case statement there. The way this should work is roughly as follows:
case '{':
  int brace_count = 1;
  char* mpi_start = *parsebuf;
  (*parsebuff)++;
  for( ; *parsebuf ! = '\0' && brace_count ; (*parsebuf) ++) {
      if *parsebuf == '{' then brace_count++;
      if *parsebuff == '}' then brace_count --;
   }
   if *parsebuf == '\0' then return TRUE_BOOLEXP <-- did not find last brace
   else create boolexp node for MPI with string that starts at mpi_start and ends at *parsebuf
   (*parsebuf)++   // not sure if this is needed or not.
   return new boolexp node
  1. Update size_boolexp to support BOOLEXP_MPI
  2. Update free_boolexp to support BOOLEXP_MPI
  3. Update unparse_boolexp1 to support BOOLEXP_MPI
  4. Update the @ lock documentation ... muckhelp.raw

That should be it ... most of those are pretty small changes. If nobody beats me to it, I'll do it when I'm done with the documentation project.

tanabi avatar Feb 16 '19 20:02 tanabi