map.c
author viric@llimona
Fri, 16 Feb 2007 23:53:32 +0100
changeset 27 545f73869d65
parent 26 95fccfcbd04c
permissions -rw-r--r--
Added USR1 status shower.
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include "general.h"

void CopyMap (struct Map *Mdest, const struct Map *Morig)
{
	memcpy((void *) Mdest, (void *) Morig, sizeof (struct Map));
}

static int are_boxes_equal(const struct Position b1[], const struct Position b2[],
	int n)
{
	int i;
	char tmp[MAX_Y][MAX_X]; /* !!!argh */

	for (i=0; i < n; i++)
	{
		tmp[b2[i].y][b2[i].x] = 0;
	}
	for (i=0; i < n; i++)
	{
		tmp[b1[i].y][b1[i].x] = 1;
	}
	for (i=0; i < n; i++)
	{
		if (tmp[b2[i].y][b2[i].x] != 1)
			return FALSE;
	}
	return TRUE;
}

int is_new_map(const struct Map maps[], const int depth)
{
	const struct Map *m = &maps[depth];
	int i;
	extern int max_depth; 

	for(i=0; i<max_depth; i++)
	{
		/* No l'hem de comparar amb ell mateix */
		if (i == depth)
			continue;

		if (m->NumBoxesInPlatform != maps[i].NumBoxesInPlatform)
			continue;
		else
		{
			if (!are_boxes_equal(m->Box, maps[i].Box, m->NumBoxes))
				continue;
		}
		return FALSE;
	}
	return TRUE;
}