Use std::default_delete<Mission> for Mission_ptr

This commit is contained in:
Kp 2014-08-16 04:22:01 +00:00
parent 621f947241
commit d945a95d47
2 changed files with 7 additions and 19 deletions

View file

@ -94,19 +94,10 @@ struct Mission {
ubyte enhanced; // 0: mission has "name", 1:"xname", 2:"zname"
std::unique_ptr<d_fname> alternate_ham_file;
#endif
~Mission();
};
void free_mission(std::unique_ptr<Mission>);
struct mission_delete
{
void operator()(Mission *p) const
{
free_mission(std::unique_ptr<Mission>(p));
}
};
typedef std::unique_ptr<Mission, mission_delete> Mission_ptr;
typedef std::unique_ptr<Mission> Mission_ptr;
extern Mission_ptr Current_mission; // current mission
#define Current_mission_longname Current_mission->mission_name

View file

@ -587,22 +587,19 @@ static void promote (mle *mission_list, const char * mission_name, int * top_pla
}
}
void free_mission(std::unique_ptr<Mission> Current_mission)
Mission::~Mission()
{
// May become more complex with the editor
if (Current_mission)
{
if (Current_mission->path && !PLAYING_BUILTIN_MISSION)
if (path && !PLAYING_BUILTIN_MISSION)
{
char hogpath[PATH_MAX];
sprintf(hogpath, MISSION_DIR "%s.hog", Current_mission->path);
snprintf(hogpath, sizeof(hogpath), MISSION_DIR "%s.hog", path);
PHYSFSX_contfile_close(hogpath);
}
if (Current_mission->path)
d_free(Current_mission->path);
}
if (path)
d_free(path);
}