.mm: try to simplify load of .mm files

This commit is contained in:
C.W. Betts
2021-10-02 17:12:45 +02:00
committed by Celtic Minstrel
parent cd39a11f93
commit 1ce5edaa91
3 changed files with 10 additions and 25 deletions

View File

@@ -29,7 +29,8 @@ extern bool change_made, ae_loading;
void set_up_apple_events(int argc, char* argv[]); // Suppress "no prototype" warning
void set_up_apple_events(int, char*[]) {
AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init];
static AppleEventHandler* aeHandler;
aeHandler = [[AppleEventHandler alloc] init];
[[NSApplication sharedApplication] setDelegate: aeHandler];
}
@@ -43,13 +44,8 @@ void set_up_apple_events(int, char*[]) {
return FALSE;
}
unsigned long len = [file length], sz = len + 1;
auto msg = std::shared_ptr<unichar>(new unichar[sz], std::default_delete<unichar[]>());
std::fill(msg.get(), msg.get() + sz, 0);
[file getCharacters: msg.get() range: (NSRange){0, len}];
std::string fileName;
std::copy(msg.get(), msg.get() + len, std::inserter(fileName, fileName.begin()));
std::string fileName=file.fileSystemRepresentation;
if(load_scenario(fileName, scenario)) {
set_current_town(scenario.last_town_edited);
cur_out = scenario.last_out_edited;