#include #ifdef __WIN32__ char file_path[50] = "C:\\Program Files\\Pengpong\\"; char config_file_path[50] = "C:\\Program Files\\Pengpong\\config_file"; #endif #ifdef __GNUG__ char file_path[50] = "/usr/local/share/games/pengpong/"; char config_file_path[50] = "/.pengpong/config_file"; char config_file_dir[50] = "/.pengpong/"; #endif extern object adam, david,ball; extern int ai; extern int difficult; void read_config_file() { ifstream a_file; char *temp_string1, *temp_string2; char *temp_config_path; temp_string1 = new char[50]; temp_string2 = new char[50]; temp_config_path = new char[80]; #ifdef __GNUG__ char temp_dir[100]; char temp_command[50]; sprintf(temp_config_path, "%s%s", getenv("HOME"), config_file_path); sprintf(temp_dir, "%s%s", getenv("HOME"), config_file_dir); sprintf(temp_command, "mkdir %s", temp_dir); system(temp_command); sprintf(temp_command, "touch %s", temp_config_path); system(temp_command); #endif #ifdef __WIN32__ strcpy(temp_config_path, config_file_path); #endif a_file.open(temp_config_path); while(!a_file.eof()) { a_file.getline(temp_string1, 50, ':'); a_file.getline(temp_string2, 50); if(!strcmp(temp_string1,"player1_name")) { strcpy(adam.name, temp_string2); } if(!strcmp(temp_string1, "player2_name")) { strcpy(david.name, temp_string2); } if(!strcmp(temp_string1, "have_ai")) { if(!strcmp(temp_string2,"1")) ai = 1; else ai = 0; } if(!strcmp(temp_string1, "difficult")) { int temp_diff; temp_diff = atoi(temp_string2); difficult = temp_diff; } } a_file.close(); } void write_config_file() { ofstream b_file; char *temp_config_path; char *temp_config_data; temp_config_data = new char[80]; temp_config_path = new char[80]; #ifdef __GNUG__ sprintf(temp_config_path, "%s%s", getenv("HOME"), config_file_path); #endif #ifdef __WIN32__ strcpy(temp_config_path, config_file_path); #endif b_file.open(temp_config_path, ios::trunc); sprintf(temp_config_data, "player1_name:%s\n", adam.name); b_file<