[Circle] [CODE] ahem.. help!

From: Søren Peter skou (tigerdyr@internet.dk)
Date: 11/01/96


Help!!! I'm STUCK, I mean this little piece of code is giving me ulcers
and other *VERY* strange things, could someone run it through and see
what on earth I'm missing out on??

The code is as follows 

ASPELL(spell_portal)
{

static char *arc[5][2][11] = {
 {
  {"ba", "bo", "di", "fo", "gu", "hy", "ja", "ke", "li", "mu", "\n"},
  {"ny", "cu", "qe", "ri", "so", "tu", "vy", "wa", "xe", "zi", "\n"},
 },
 {
 {"b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "\n"},
 {"n", "p", "q", "r", "s", "t", "v", "w", "x", "z", "\n"},
 },
 {
 {"ab", "ae", "ai", "ao", "au", "ay", "ea", "ec", "ei", "eo", "\n"},
 {"oi", "of", "ou", "oy", "ac", "ec", "ed", "ug", "uz", "uq", "\n"},
 },
 {
 {"z", "c", "x", "f", "w", "h", "v", "k", "s", "m", "\n"},
 {"n", "b", "q", "d", "k", "t", "j", "g", "r", "p", "\n"},
 },
 {
 {"aq", "as", "av", "au", "an", "ef", "eg", "et", "en", "ep", "\n"},
 {"re", "ru", "us", "ut", "at", "ur", "yr", "yr", "er", "ea", "\n"},
 }
};

char *arc_name = tar_str;
char *tmp = 0;
int arc_found = 0;
int nr, icount;
sh_int location;

int dicechance = 0;
extern int top_of_world;


 if (ch == NULL)
  return;
  
/* It takes *SOME* kind of Intelligence to portal!! */

 if (GET_INT(ch) < 7) {
  send_to_char("Sorry, you're too stupid to portal anywhere", ch);
  return;
 }

 if (arc_name == NULL) {
  send_to_char("Portal to where?", ch);
  return;
 }

 for (nr = 0; nr < 5;nr++) 
 {
  arc_found = FALSE;
  icount = 0;
  for (icount = 0; icount < 9;icount++) 
  {
   if (!arc_found) 
   {
    tmp = arc[nr][0][icount];
    if(!strncmp(arc_name, tmp, strlen(tmp))) 
    {
     arc_found = TRUE;
     arc_name = arc_name + strlen(tmp);
     location = location * 10 + icount;
    }
    if (!arc_found) 
    {
     tmp = arc[nr][1][icount];
     if(!strncmp(arc_name, tmp, strlen(tmp))) 
     {
      arc_found = TRUE;
      arc_name = arc_name + strlen(tmp);
      location = location * 10 + icount;
     }
    }
   }
  }
 } /* End decode roomno */
 /* At this point all have been successful! now, let's make magic */
/* The portal spell takes a persons int and wisdom, and uses them for a
saving throw */
/* Beware it *IS* possible to die from this spell!!! (should happen once
out of 1000 or so */
/*
   
  if (ROOM_FLAGGED(location, ROOM_TUNNEL | ROOM_PRIVATE | ROOM_DEATH |
ROOM_GODROOM)) {
   act("You feel a disturbance in the magic aura, and your portal
fails.", FALSE, 0, 0, 0, TO_CHAR);
   do {
   location = number(0, top_of_world);
   } while (ROOM_FLAGGED(location, ROOM_PRIVATE | ROOM_DEATH |
ROOM_GODROOM));
   act("$n fails a portal terribly, and is sent off to somewhere.",
FALSE, ch, 0, 0, TO_ROOM);
   char_from_room(ch);
   char_to_room(ch, location);
   act("A portal opens, and $n tumbles into the room, clearly
confused.", FALSE, ch, 0, 0, TO_ROOM);
   look_at_room(ch, 0);
   return;
 }
*/

 act("$n opens a portal, steps into it and vanishes.", FALSE, ch, 0, 0,
TO_ROOM);

 char_from_room(ch);
 char_to_room(ch, location);

 act("A portal opens, and $n steps out of it.", FALSE, ch, 0, 0,
TO_ROOM);
 look_at_room(ch, 0);
}  

Okay, it decodes the room-no correctly (dependant on another spell
Arcane Name :) which will be posted when they're both working and done)
as for instance roomno 1208 is nypainer, fine no problemo there, the
problem lies in the char_from_room(ch, location); but why I fail to see.
if I change that part to something like :

 location = 1208;
 char_from_room(ch);
 char_to_room(ch, real_room(location));

Then everything is fine and I end up in room 1208 as planned, but if I
remove the location = 1208; then I end up in the void! whereafter the
mud crashes cause location suddenly became 0 (Still, a sprintf tells me
that I decode the roomno right) 

If someone has the answer to this one, I'll be bouncing with joy. This
is driving me NUTS! 


/Soren Has lost his brain somewhere....
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST