예제 #1
0
파일: game.c 프로젝트: auduchinok/homework
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);	
}
예제 #2
0
// template spectialisation : CBuffer::put
    template <> bool CBuffer::put<char>(const char& data) { return put_template(data) ; }  
예제 #3
0
template <> bool CBuffer::put<long double>(const long double* data, size_t n) { return put_template(data,n) ;}  
예제 #4
0
template <> bool CBuffer::put<float>(const float* data, size_t n) { return put_template(data,n) ; }  
예제 #5
0
template <> bool CBuffer::put<ulong>(const ulong* data, size_t n) { return put_template(data,n) ; }  
예제 #6
0
template <> bool CBuffer::put<ushort>(const ushort* data, size_t n) { return put_template(data,n) ; }  
예제 #7
0
template <> bool CBuffer::put<int>(const int* data, size_t n)   { return put_template(data,n) ; }
예제 #8
0
template <> bool CBuffer::put<char>(const char* data, size_t n) { return put_template(data,n) ; }  
예제 #9
0
template <> bool CBuffer::put<long double>(const long double& data) { return put_template(data) ;}  
예제 #10
0
template <> bool CBuffer::put<float>(const float& data) { return put_template(data) ; }  
예제 #11
0
template <> bool CBuffer::put<ulong>(const ulong& data) { return put_template(data) ; }  
예제 #12
0
template <> bool CBuffer::put<ushort>(const ushort& data) { return put_template(data) ; }  
예제 #13
0
template <> bool CBuffer::put<uint>(const uint& data)  { return put_template(data) ; }