[CODE] binaryflags_conv

From: The Merciless Lord of Everything (serces@mud.dk)
Date: 05/27/00

Hey All

Having been confused a lot while converting from the Binary playerfile
format into a SQL base. I know that you're supposed to look at the number
for e.g. preferences as a binary number, but it confused be quite a bit
seeing -1340051072 in the database. I'd like to have something like the
asciiflag_con function, just reverse, that is take a number and conver it
to letters.

Scouring through the archives I didn't find a function to do the opposite
of asciiflag_conv, so I sat down and wrote one :). My idea is to enter
this one into the different editors (medit,sedit and so forth), so the
worldfiles can be sent to a builder without having him/her to be confused
and go "Erh, when I see 213154143141 what does that mean?" :), instead
having himnovCDF instead. Also, my SQL will be using this for pref's, act
& affected_by (And everything else that contains flags.. :)

Suggestions are very welcome. (Flames will be directed to /dev/null :).

Code is quite simple:
char *binaryflag_conv(long flags)
  int i;
  char *retval;
  char *flag_letters[32] = { "a","b","c","d","e","f","g","h",
                            "y","z","A","B","C","D","E","F" };
  retval = strdup("");
  for (i = 0;i<32;i++) {
    if (flags & (1 <<i)) {
  return retval;

I've dropped it in db.c just above asciiflag_conv :) After that it is a
matter of declaring it where you need it and .. whoop.. :)

(And now I'll go try the autosubmit thingie.. :))


"The Law of Self Sacrifice"
When you starve with a tiger, the tiger starves last.

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |

This archive was generated by hypermail 2b30 : 04/10/01 PDT