diff options
author | Damien Appert <dappert> | 2010-11-06 21:59:15 +0000 |
---|---|---|
committer | Damien Appert <dappert> | 2010-11-06 21:59:15 +0000 |
commit | bb8d3f0f67234d333dcce265dbc3b1f844c8f4bc (patch) | |
tree | cf168de46c63f487893feae4079bf496c5ebd4a1 /sdl-test | |
parent | 2598ac50d60e5c38538fb9da01f2b30942e5be9d (diff) | |
download | 2010-netlemmings-bb8d3f0f67234d333dcce265dbc3b1f844c8f4bc.tar.gz 2010-netlemmings-bb8d3f0f67234d333dcce265dbc3b1f844c8f4bc.tar.bz2 2010-netlemmings-bb8d3f0f67234d333dcce265dbc3b1f844c8f4bc.zip |
Un peu d'intégration du parseur dans le tronc de code principal
git-svn-id: file:///var/svn/2010-netlemmings/trunk@141 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'sdl-test')
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c | 54 | ||||
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c | 53 |
2 files changed, 54 insertions, 53 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c index 6d115b4..d8bd6e0 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c @@ -51,3 +51,57 @@ int init() return 0; } +Uint32 string_to_Uint32 (char* c,int taille){ + + Uint32 u32c; + int i,n,lc = strlen(c); + int t[taille]; + if(lc-3 != taille){ + //-DEBUG-printf("ERREUR: wrong format .. expect (strlen[%s] - 3)==%d but it's = %d\n",c,taille,lc-3); + return(ccc_error); + } + u32c = 0; + for(i=0;i<taille;++i){ + n = c[i+2]; + //-DEBUG-printf("n = %d, %c\n",n); + if (n > 47 && n < 58 ) { t[i]=(n - 48) ;} + if (n > 64 && n < 71 ) { t[i]=(n - 55) ;} + if (n > 96 && n < 103 ){ t[i]=(n - 87) ;} + } + n=0; + for(i=0;i<taille;++i){ + //-DEBUG-printf("t[%d]= %d, *(%d), %d\n",i,t[i],(1<<(4*(taille-i-1))),t[i]*(1<<(4*(taille-i-1))) ); + + n+=t[i]*(1<<(4*(taille-i-1))); + + + //-DEBUG-printf("n= %d\n",n); + } + u32c= n & 0xffffff; + return u32c; +} + + +// "4,5,6,7" -> un tableau de Uint32 +Uint32* tab_of_string_to_Uint32 (char* c, int taille){ + int i,lc = strlen(c); + char t[10]; + int cpt=0; + int cpt2=0; + Uint32* tab=malloc(sizeof(Uint32)*(lc/(taille+3))); + t[0]='0';t[1]='x';t[8]=',';t[9]=0; + + for(i=0;i<lc;++i){ + // token + if(c[i]=='x'){cpt=0;} + if(cpt<6){ + t[cpt+2]=c[i+1]; + ++cpt; + if(cpt==6){ + tab[cpt2]=string_to_Uint32(t,taille); + cpt2++; + } + } + } + return tab; +} diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c index 26e1699..47e0379 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c @@ -1,58 +1,5 @@ // Est inclus en direct dans parse_ini.yy -Uint32 string_to_Uint32 (char* c,int taille){ - - Uint32 u32c; - int i,n,lc = strlen(c); - int t[taille]; - if(lc-3 != taille){ - //-DEBUG-printf("ERREUR: wrong format .. expect (strlen[%s] - 3)==%d but it's = %d\n",c,taille,lc-3); - return(ccc_error); - } - u32c = 0; - for(i=0;i<taille;++i){ - n = c[i+2]; - //-DEBUG-printf("n = %d, %c\n",n); - if (n > 47 && n < 58 ) { t[i]=(n - 48) ;} - if (n > 64 && n < 71 ) { t[i]=(n - 55) ;} - if (n > 96 && n < 103 ){ t[i]=(n - 87) ;} - } - n=0; - for(i=0;i<taille;++i){ - //-DEBUG-printf("t[%d]= %d, *(%d), %d\n",i,t[i],(1<<(4*(taille-i-1))),t[i]*(1<<(4*(taille-i-1))) ); - - n+=t[i]*(1<<(4*(taille-i-1))); - - - //-DEBUG-printf("n= %d\n",n); - } - u32c= n & 0xffffff; - return u32c; -} - - -Uint32* tab_of_string_to_Uint32 (char* c, int taille){ - int i,lc = strlen(c); - char t[10]; - int cpt=0; - int cpt2=0; - Uint32* tab=malloc(sizeof(Uint32)*(lc/(taille+3))); - t[0]='0';t[1]='x';t[8]=',';t[9]=0; - - for(i=0;i<lc;++i){ - // token - if(c[i]=='x'){cpt=0;} - if(cpt<6){ - t[cpt+2]=c[i+1]; - ++cpt; - if(cpt==6){ - tab[cpt2]=string_to_Uint32(t,taille); - cpt2++; - } - } - } - return tab; -} /* inverse la liste fournie en parametre et la renvoie */ struct listeSimplementChainee* rev_listeO (struct listeSimplementChainee* liste) |