On Sat, 1 Dec 2001, The Arrow wrote:
>In CircleMUD 3.0 (patchlevel 19), when a new player creates a character,
>and gets assigned an already existing slot in the player_table (that was
>used by a now deleted player), player_table[x].name is not free'd.
Right, because it reuses the slot.
>The solution I made, was to do it in create_entry() (db.c), where I put
>an else at the end of the if, and in there free the name if it's not
>NULL.
The new character is written to the same spot as the old one so the player
table does not need updated:
if ((player_i = load_char(tmp_name, &tmp_store)) > -1) {
store_to_char(&tmp_store, d->character);
GET_PFILEPOS(d->character) = player_i;
if (PLR_FLAGGED(d->character, PLR_DELETED)) {
/* We get a false positive from the original deleted character. */
free_char(d->character);
/* Check for multiple creations... */
if (!Valid_Name(tmp_name)) {
SEND_TO_Q("Invalid name, please try another.\r\nName: ", d);
return;
}
CREATE(d->character, struct char_data, 1);
clear_char(d->character);
CREATE(d->character->player_specials, struct player_special_data, 1);
d->character->desc = d;
CREATE(d->character->player.name, char, strlen(tmp_name) + 1);
strcpy(d->character->player.name, CAP(tmp_name));
>>>>> GET_PFILEPOS(d->character) = player_i;
sprintf(buf, "Did I get that right, %s (Y/N)? ", tmp_name);
SEND_TO_Q(buf, d);
STATE(d) = CON_NAME_CNFRM;
} else {
So create_entry() will not be called again:
if (GET_PFILEPOS(d->character) < 0)
GET_PFILEPOS(d->character) = create_entry(GET_PC_NAME(d->character));
Subtle, but correct.
--
George Greer
greerga@circlemud.org
--
+---------------------------------------------------------------+
| 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 : 06/24/03 PDT