void load_hiscore() { ostringstream filepath; #ifndef ALLEGRO_LINUX filepath << "./data/hiscore.dat"; #endif #ifdef ALLEGRO_LINUX filepath << getenv("HOME") << "/.openinvaders/hiscore"; #endif char hiscore_buffer[sizeof(hiscore)]; ifstream hiscorefile; hiscorefile.open(filepath.str().c_str(),ios::binary); if(!hiscorefile.read(hiscore_buffer,sizeof(hiscore))) { cout << "Error reading highscore file\n"; } hiscorefile.close(); char *stuff_to_read = new char[sizeof(hiscore)]; int *hiscore2 = new int; stuff_to_read=hiscore_buffer; memcpy(hiscore2,stuff_to_read,sizeof(hiscore)); hiscore=*hiscore2; delete[] stuff_to_read; delete hiscore2; }