All pastes #573923 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-06-18 10:17 UTC
rendered paste body
void load_hiscore()
{
	ostringstream filepath;
	
	#ifndef ALLEGRO_LINUX
	filepath << "./data/hiscore.dat";
	#else
	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(&hiscore,stuff_to_read,sizeof(hiscore));
	
	//hiscore=*hiscore2;
	
	delete[] stuff_to_read;
	//delete hiscore2;
}