Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for hedit 'x' crash, v.2 #745

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5542,25 +5542,14 @@ void free_host(struct host_data * host)
host->trigger = NULL;
}

{ // Clean up associated entrances.
for (struct exit_data *exit = host->exit; exit; exit = exit->next) {
// Find the exit's matching entrance in the destination host.
rnum_t dest_rnum = real_host(exit->host);
if (dest_rnum >= 0) {
struct entrance_data *entrance = NULL, *temp;
for (entrance = matrix[dest_rnum].entrance; entrance; entrance = entrance->next) {
if (entrance->host == host)
break;
}
// Remove that entrance.
if (entrance) {
REMOVE_FROM_LIST(entrance, matrix[dest_rnum].entrance, next);
DELETE_AND_NULL(entrance);
} else {
log("SYSERR: Found no associated entrance in free_host()! ('x' option during hedit?)");
}
}
{ // Clean up entrances in this host that lead to other hosts.
// Entrances in other hosts that lead to this host are rebuilt by collate_host_entrances().
struct entrance_data *entrance = NULL, *next = NULL;
for (entrance = host->entrance; entrance; entrance = next) {
next = entrance->next;
delete entrance;
}
host->entrance = NULL;
}

{ // Clean up the exits.
Expand Down
15 changes: 1 addition & 14 deletions src/hedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,6 @@ void hedit_parse(struct descriptor_data *d, const char *arg)
case 'N':
STATE(d) = CON_PLAYING;
if (d->edit_host) {
// Drop our exits, they have no pair to remove so no further cleanup is needed.
for (struct entrance_data *entrance = d->edit_host->entrance, *next; entrance; entrance = next) {
next = entrance->next;
delete entrance;
}
d->edit_host->entrance = NULL;
Mem->DeleteHost(d->edit_host);
}
d->edit_host = NULL;
Expand Down Expand Up @@ -307,8 +301,7 @@ void hedit_parse(struct descriptor_data *d, const char *arg)
send_to_char("Writing host to disk.\r\n", d->character);
write_host_to_disk(d->character->player_specials->saved.zonenum);
send_to_char("Saved.\r\n", CH);
clear_host(d->edit_host);
delete d->edit_host;
Mem->DeleteHost(d->edit_host);
jdevnull marked this conversation as resolved.
Show resolved Hide resolved
d->edit_host = NULL;
PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
STATE(d) = CON_PLAYING;
Expand All @@ -320,12 +313,6 @@ void hedit_parse(struct descriptor_data *d, const char *arg)
send_to_char("Host not saved, aborting.\r\n", d->character);
STATE(d) = CON_PLAYING;
if (d->edit_host) {
// Drop our exits, they have no pair to remove so no further cleanup is needed.
for (struct entrance_data *entrance = d->edit_host->entrance, *next; entrance; entrance = next) {
next = entrance->next;
delete entrance;
}
d->edit_host->entrance = NULL;
Mem->DeleteHost(d->edit_host);
}
d->edit_host = NULL;
Expand Down
3 changes: 3 additions & 0 deletions src/olc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,9 @@ ACMD(do_hedit)
}
}

// Don't duplicate entrances, since we rebuild them after changes are saved
host->entrance = NULL;

d->edit_host = host;
#ifdef CONFIRM_EXISTING

Expand Down