#include "file.h" int scanInt(char *str) { int start=0; int i=0; int number=0; while((str[start]<'0' || str[start]>'9')) { start++; } i=start; while(str[i]>='0' && str[i]<='9') { number*=10; number+=str[i]-'0'; i++; } return number; } void* readLine(FILE *filein, char *text) { do { if(fgets(text,512,filein)==NULL) return NULL; }while((text[0]=='/') || (text[0]=='\n')); return 0; } /* void listFiles(char **files,int *nbFiles) { } */ char loadWorld(void *buffer,char *name,uint8_t *world,pos *playerPos,float *angleX,float *angleZ) { //"loading chunks" screen memset(buffer,0,SCREEN_BYTES_SIZE); drawStringCenter(buffer,"Loading chunks",(has_colors) ? 0xFFFF : 0xF,100); FILE *worldFile=NULL; worldFile=fopen(name,"r"); int i,j,k,l,m; //iterators char line[512]; char value[5]; if(worldFile==NULL) { sleep(500); show_msgbox("Error","No existing world.\nPlease create one."); return 0; } else { readLine(worldFile,line); if(strstr(line,"NCW1")==NULL) { fclose(worldFile); return 0; } else { //position readLine(worldFile,line); playerPos->x=(float)scanInt(line); readLine(worldFile,line); playerPos->y=(float)scanInt(line); readLine(worldFile,line); playerPos->z=(float)scanInt(line); //rotation readLine(worldFile,line); *angleX=(float)scanInt(line); readLine(worldFile,line); *angleZ=(float)scanInt(line); //correct playerPos->x/=1000; playerPos->y/=1000; playerPos->z/=1000; *angleX/=1000; *angleZ/=1000; //cube world for(i=0;i