Select Git revision
fire.c 4.46 KiB
#include "fire.h"
#include "map.h"
listchainfire_t fireList;
int markov[SIZEMARKOV][SIZEMARKOV];
listchainfire_t initFire (void)
{
return NULL;
}
booleen_t emptyListFire(listchainfire_t listFire)
{
booleen_t result = false;
if (listFire==NULL)
{
result=true;
}
return (result);
}
listchainfire_t insertAheadFire(fire_t fire,listchainfire_t listFire)
{
chainfire_t *m;
m=(chainfire_t*)malloc(sizeof(chainfire_t));
if (m==NULL)
{
printf("problème d'allocation \n");
exit(1);
}
if (!searchFire(listFire,fire.x,fire.y)){
m->fire=fire;
m->next= listFire;
listFire=m;}
return listFire;
}
listchainfire_t startFire(listchainfire_t listFire,int numberFire, int mapSize){
int i;
int xFire=0;
int yFire=0;
srand(time(NULL));
fire_t fire;
if (emptyListFire(listFire)){
for (i=0;i<numberFire;i++){
xFire= rand()%mapSize;
yFire= rand()%mapSize;
//printf("xf:%d,yf:%d\n",xFire,yFire);
fire.x= xFire;
fire.y= yFire;
fire.state=1;
listFire=insertAheadFire(fire, listFire);
}
}
return (listFire);
}