On Thu, 12 Jul 2001, Welcor wrote: > The issue arises, since 'set' works on mobs as well as players. A solution > would be to add a 'mob' flag instead of the 'file' flag: The in-game entity would be targetted by default, since it's the path of least resistence (no allocate, load, and free necessary). A 'player' flag already exists that would address your concern. There's also already a 'mob' flag, but it doesn't actually do anything. The following Mailer Code(tm) represents my suggestion for how 'set' should work without the 'file' flag. The recommended changes are surmised: keep is_file to indicate whether we should attempt to load from the pfiles; remove the 'file' flag; make 'mob' set is_file FALSE (at the minimum, more on this later); look for the target online (using either get_player_vis() is is_player is TRUE or get_char_vis() otherwise); if no online target was found and is_file is true, try loading; if there's no target after all of this, give an error message and return. So the first changes occur at the top - char is_file = 0, is_player = 0; + bool is_file = TRUE, is_player = FALSE; - if (!strcmp(name, "file")) { - is_file = 1; - half_chop(buf, name, buf); - } else if (!str_cmp(name, "player")) { + if (!str_cmp(name, "player")) { - } else if (!str_cmp(name, "mob")) + } else if (!str_cmp(name, "mob")) { + is_file = FALSE; /* Never try loading from file. */ half_chop(buf, name, buf); + } Also include this little gem, which I thought was quite bizarre - half_chop(buf, field, buf); - strcpy(val_arg, buf); + half_chop(buf, field, val_arg); Finally, we replace our target finding and character loading code with something like if (is_player) vict = get_player_vis(ch, name, NULL, FIND_CHAR_WORLD); else vict = get_char_vis(ch, name, NULL, FIND_CHAR_WORLD); if (!vict) { if (!is_file) { send_to_char("Who's that?\r\n", ch); return; } CREATE(cbuf, struct char_data, 1); clear_char(cbuf); if ((player_i = load_char(name, &tmp_store)) != -1) { store_to_char(&tmp_store, cbuf); if (GET_LEVEL(cbuf) >= GET_LEVEL(ch)) { free_char(cbuf); send_to_char("Sorry, you can't do that.\r\n", ch); return; } vict = cbuf; } else { free(cbuf); send_to_char("Who's that?\r\n", ch); return; } /* Let them know that we've loaded the player. */ sprintf(buf, "Loaded player '%s' from disk.\r\n", GET_NAME(vict)); send_to_char(buf, ch); } That's just about it. Any thoughts (on the idea -- the code's just for demonstration purposes and not guaranteed to be of working quality)? -dak -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/06/01 PST