void create_game(char *filename) { FILE *in = fopen(filename, "r"); if (!in) { printf("Can't open the file. Quitting.\n"); exit(1); } fscanf(in, "%d %d", &width, &height); field = (int **) malloc(sizeof(int *) * height); field_data = (int *) malloc(sizeof(int) * width * height); field_turn = (int **) malloc(sizeof(int *) * height); field_data_turn = (int *) malloc(sizeof(int) * width * height); int i = 0; for (i = 0; i < height; i++) { field[i] = &field_data[i * width]; field_turn[i] = &field_data_turn[i * width]; } memset(field_data, 0, sizeof(int) * width * height); char template_name[MAX_WORD_LENGTH]; memset(template_name, 0, sizeof(char) * MAX_WORD_LENGTH); int template_x = 0; int template_y = 0; while (!feof(in)) { fscanf(in, "%s %d %d", template_name, &template_x, &template_y); put_template(template_name, template_x, template_y); } fclose(in); }
// template spectialisation : CBuffer::put template <> bool CBuffer::put<char>(const char& data) { return put_template(data) ; }
template <> bool CBuffer::put<long double>(const long double* data, size_t n) { return put_template(data,n) ;}
template <> bool CBuffer::put<float>(const float* data, size_t n) { return put_template(data,n) ; }
template <> bool CBuffer::put<ulong>(const ulong* data, size_t n) { return put_template(data,n) ; }
template <> bool CBuffer::put<ushort>(const ushort* data, size_t n) { return put_template(data,n) ; }
template <> bool CBuffer::put<int>(const int* data, size_t n) { return put_template(data,n) ; }
template <> bool CBuffer::put<char>(const char* data, size_t n) { return put_template(data,n) ; }
template <> bool CBuffer::put<long double>(const long double& data) { return put_template(data) ;}
template <> bool CBuffer::put<float>(const float& data) { return put_template(data) ; }
template <> bool CBuffer::put<ulong>(const ulong& data) { return put_template(data) ; }
template <> bool CBuffer::put<ushort>(const ushort& data) { return put_template(data) ; }
template <> bool CBuffer::put<uint>(const uint& data) { return put_template(data) ; }