[Fix] On the rare occasion, accepting a mission has caused a segfault.
This should sort it out.
This commit is contained in:
parent
1ab4ad1b7a
commit
1d811a613f
@ -1040,7 +1040,7 @@ static void misn_accept(unsigned int wid, char* str) {
|
|||||||
misn = &mission_computer[pos];
|
misn = &mission_computer[pos];
|
||||||
if(mission_accept(misn)) {
|
if(mission_accept(misn)) {
|
||||||
/* Success is accepting the mission. */
|
/* Success is accepting the mission. */
|
||||||
memmove(misn, &mission_computer[pos+1],
|
memmove(&mission_computer[pos], &mission_computer[pos+1],
|
||||||
sizeof(Mission) * (mission_ncomputer-pos-1));
|
sizeof(Mission) * (mission_ncomputer-pos-1));
|
||||||
mission_ncomputer--;
|
mission_ncomputer--;
|
||||||
misn_genList(wid, 0);
|
misn_genList(wid, 0);
|
||||||
@ -1056,7 +1056,7 @@ static void misn_genList(unsigned int wid, int first) {
|
|||||||
window_destroyWidget(wid, "lstMission");
|
window_destroyWidget(wid, "lstMission");
|
||||||
|
|
||||||
/* List. */
|
/* List. */
|
||||||
if(mission_ncomputer != 0) {
|
if(mission_ncomputer > 0) {
|
||||||
/* there are missions. */
|
/* there are missions. */
|
||||||
misn_names = malloc(sizeof(char*) * mission_ncomputer);
|
misn_names = malloc(sizeof(char*) * mission_ncomputer);
|
||||||
j = 0;
|
j = 0;
|
||||||
|
@ -131,8 +131,13 @@ static int mission_init(Mission* mission, MissionData* misn, int load) {
|
|||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
/* Run create function. */
|
/* Run create function. */
|
||||||
if(load == 0) /* Never run when loading. */
|
if(load == 0) { /* Never run when loading. */
|
||||||
misn_run(mission, "create");
|
/* Failed to create. */
|
||||||
|
if(misn_run(mission, "create")) {
|
||||||
|
mission_cleanup(mission);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return mission->id;
|
return mission->id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user