From e816f16a5007798968f4c9003b3159a45485e88f Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sun, 26 Oct 2014 18:20:28 +0000 Subject: game: remove useless checks it is safe to pass a null pointer to SDL_FreeSurface() BTW: change the format of the files from dos to unix Signed-off-by: Olivier Gayot --- constantes.h | 338 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 169 insertions(+), 169 deletions(-) (limited to 'constantes.h') diff --git a/constantes.h b/constantes.h index 9607c66..415074b 100644 --- a/constantes.h +++ b/constantes.h @@ -1,169 +1,169 @@ -#ifndef CONSTANTES_H -#define CONSTANTES_H -#define JOUER 0 -#define OPTIONS 1 -#define QUITTER 2 -#define XWIN 1024 -#define YWIN 768 -#define PALADIN 0 -#define PRETRE 1 -#define VOLEUR 2 -#define GUERRIER_GOBELIN 10 -#define VIE 1 -#define MORT 0 - -//type de sort -#define FEU 0 -#define GLACE 1 -#define EAU 2 -#define TONNERRE 3 -#define CHOC 4 -#define NON_ELEMENTAIRE 4 -#define SOIN 0 - -//caractéristiques -#define SENSIBILITE 1 -#define RESISTANCE 2 -#define INVULNERABILITE 3 -#define ABSORBTION 4 - -//active / desactivé -#define ACTIVE 1 -#define DESACTIVE 0 - - -#define ATTAQUE 0 -#define MAGIE_BLANCHE 1 -#define MAGIE_NOIRE 2 -#define TECHNIQUES 3 -#define OBJETS 4 -#define POTION 0 -#define ETHER 1 -#define POTIONPLUS 2 -#define ETHERPLUS 3 -#define ACTIONS 5 -#define DEGATS 0 -#define SOINS 1 -#define ALLIE 1 -#define ENNEMI 0 -#define TYPE_ATTAQUE 0 -#define TYPE_MAGIE 1 - - -#define SELECTION(nb,nb2) if (selection == nb)\ - {\ - if(nb2==ALLIE)\ - {\ - positions->Vpositioncurseurallies.x = positions->Vpositionpersos[nb].x + 20 + surfaces->Tperso[nb]->w;\ - positions->Vpositioncurseurallies.y = positions->Vpositionpersos[nb].y + surfaces->Tperso[nb]->h/2 - surfaces->Pcurseurallies->h/2;\ - SDL_BlitSurface (surfaces->Pcurseurallies,NULL,surfaces->Pecran,&positions->Vpositioncurseurallies);\ - }\ - else\ - {\ - SDL_BlitSurface (surfaces->Pcadrecible,NULL,surfaces->Pecran,&positions->Vpositioncadrecible);\ - positions->Vpositioncurseurennemis.x=positions->Vpositionennemis[nb].x-20-surfaces->Pcurseurennemis->w;\ - positions->Vpositioncurseurennemis.y=positions->Vpositionennemis[nb].y+surfaces->Tennemi[nb]->h/2 - surfaces->Pcurseurennemis->h/2;\ - SDL_BlitSurface (surfaces->Pcurseurennemis,NULL,surfaces->Pecran,&positions->Vpositioncurseurennemis);\ - }\ - } -#define ECRIRE(texte,id)sprintf(chaine[id],texte);\ - surfaces->Pnomactions[id]=TTF_RenderText_Blended(police,chaine[id],couleur);\ - SDL_BlitSurface (surfaces->Pnomactions[id],NULL,surfaces->Pecran,&positions->Vpositionnomactions[id]); - -//map -#define SOL 0 -#define MUR 1 -#define COFFRE 2 -#define GUS 3 - - - -#define SELECTION_CIBLE() case SDLK_RIGHT:\ - if(clan==ALLIE)\ - {\ - selection=0;\ - while(ennemis[selection].etat==MORT)\ - selection++;\ - inverse(&clan);\ - SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies);\ - Fchangercurseurennemis (surfaces,positions,selection,ennemis);\ - }\ - break;\ - case SDLK_LEFT:\ - if(clan==ENNEMI)\ - {\ - SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);\ - selection=0;\ - while(persos[selection].etat==MORT)\ - selection++;\ - inverse(&clan);\ - SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositioncurseurennemis,surfaces->Pecran,&positions->Vpositioncurseurennemis);\ - Fchangercurseurpersos(surfaces,positions,selection,persos);\ - }\ - break;\ - case SDLK_UP:\ - if(clan==ENNEMI)\ - {\ - if (selection!=0)\ - selection--;\ - else\ - selection=Vnbennemis;\ - while(ennemis[selection].etat==MORT)\ - {\ - if(selection!=0)\ - selection--;\ - else\ - selection=Vnbennemis;\ - }\ - Fchangercurseurennemis (surfaces,positions,selection,ennemis);\ - }\ - else\ - {\ - if (selection!=0)\ - selection--;\ - else\ - selection=2;\ - while(persos[selection].etat==MORT)\ - {\ - if(selection!=0)\ - selection--;\ - else\ - selection=2;\ - }\ - Fchangercurseurpersos(surfaces,positions,selection,ennemis);\ - }\ - break;\ - case SDLK_DOWN:\ - if(clan==ENNEMI)\ - {\ - if(selection!=Vnbennemis)\ - selection++;\ - else\ - selection=0;\ - while(ennemis[selection].etat==MORT)\ - {\ - if(selection!=Vnbennemis)\ - selection++;\ - else\ - selection=0;\ - }\ - Fchangercurseurennemis(surfaces,positions,selection,ennemis);\ - }\ - else\ - {\ - if(selection!=2)\ - selection++;\ - else\ - selection=0;\ - while(persos[selection].etat==MORT)\ - {\ - if(selection!=2)\ - selection++;\ - else\ - selection=0;\ - }\ - Fchangercurseurpersos(surfaces,positions,selection,ennemis);\ - }\ - break; - -#endif +#ifndef CONSTANTES_H +#define CONSTANTES_H +#define JOUER 0 +#define OPTIONS 1 +#define QUITTER 2 +#define XWIN 1024 +#define YWIN 768 +#define PALADIN 0 +#define PRETRE 1 +#define VOLEUR 2 +#define GUERRIER_GOBELIN 10 +#define VIE 1 +#define MORT 0 + +//type de sort +#define FEU 0 +#define GLACE 1 +#define EAU 2 +#define TONNERRE 3 +#define CHOC 4 +#define NON_ELEMENTAIRE 4 +#define SOIN 0 + +//caractéristiques +#define SENSIBILITE 1 +#define RESISTANCE 2 +#define INVULNERABILITE 3 +#define ABSORBTION 4 + +//active / desactivé +#define ACTIVE 1 +#define DESACTIVE 0 + + +#define ATTAQUE 0 +#define MAGIE_BLANCHE 1 +#define MAGIE_NOIRE 2 +#define TECHNIQUES 3 +#define OBJETS 4 +#define POTION 0 +#define ETHER 1 +#define POTIONPLUS 2 +#define ETHERPLUS 3 +#define ACTIONS 5 +#define DEGATS 0 +#define SOINS 1 +#define ALLIE 1 +#define ENNEMI 0 +#define TYPE_ATTAQUE 0 +#define TYPE_MAGIE 1 + + +#define SELECTION(nb,nb2) if (selection == nb)\ + {\ + if(nb2==ALLIE)\ + {\ + positions->Vpositioncurseurallies.x = positions->Vpositionpersos[nb].x + 20 + surfaces->Tperso[nb]->w;\ + positions->Vpositioncurseurallies.y = positions->Vpositionpersos[nb].y + surfaces->Tperso[nb]->h/2 - surfaces->Pcurseurallies->h/2;\ + SDL_BlitSurface (surfaces->Pcurseurallies,NULL,surfaces->Pecran,&positions->Vpositioncurseurallies);\ + }\ + else\ + {\ + SDL_BlitSurface (surfaces->Pcadrecible,NULL,surfaces->Pecran,&positions->Vpositioncadrecible);\ + positions->Vpositioncurseurennemis.x=positions->Vpositionennemis[nb].x-20-surfaces->Pcurseurennemis->w;\ + positions->Vpositioncurseurennemis.y=positions->Vpositionennemis[nb].y+surfaces->Tennemi[nb]->h/2 - surfaces->Pcurseurennemis->h/2;\ + SDL_BlitSurface (surfaces->Pcurseurennemis,NULL,surfaces->Pecran,&positions->Vpositioncurseurennemis);\ + }\ + } +#define ECRIRE(texte,id)sprintf(chaine[id],texte);\ + surfaces->Pnomactions[id]=TTF_RenderText_Blended(police,chaine[id],couleur);\ + SDL_BlitSurface (surfaces->Pnomactions[id],NULL,surfaces->Pecran,&positions->Vpositionnomactions[id]); + +//map +#define SOL 0 +#define MUR 1 +#define COFFRE 2 +#define GUS 3 + + + +#define SELECTION_CIBLE() case SDLK_RIGHT:\ + if(clan==ALLIE)\ + {\ + selection=0;\ + while(ennemis[selection].etat==MORT)\ + selection++;\ + inverse(&clan);\ + SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies);\ + Fchangercurseurennemis (surfaces,positions,selection,ennemis);\ + }\ + break;\ + case SDLK_LEFT:\ + if(clan==ENNEMI)\ + {\ + SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);\ + selection=0;\ + while(persos[selection].etat==MORT)\ + selection++;\ + inverse(&clan);\ + SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositioncurseurennemis,surfaces->Pecran,&positions->Vpositioncurseurennemis);\ + Fchangercurseurpersos(surfaces,positions,selection,persos);\ + }\ + break;\ + case SDLK_UP:\ + if(clan==ENNEMI)\ + {\ + if (selection!=0)\ + selection--;\ + else\ + selection=Vnbennemis;\ + while(ennemis[selection].etat==MORT)\ + {\ + if(selection!=0)\ + selection--;\ + else\ + selection=Vnbennemis;\ + }\ + Fchangercurseurennemis (surfaces,positions,selection,ennemis);\ + }\ + else\ + {\ + if (selection!=0)\ + selection--;\ + else\ + selection=2;\ + while(persos[selection].etat==MORT)\ + {\ + if(selection!=0)\ + selection--;\ + else\ + selection=2;\ + }\ + Fchangercurseurpersos(surfaces,positions,selection,ennemis);\ + }\ + break;\ + case SDLK_DOWN:\ + if(clan==ENNEMI)\ + {\ + if(selection!=Vnbennemis)\ + selection++;\ + else\ + selection=0;\ + while(ennemis[selection].etat==MORT)\ + {\ + if(selection!=Vnbennemis)\ + selection++;\ + else\ + selection=0;\ + }\ + Fchangercurseurennemis(surfaces,positions,selection,ennemis);\ + }\ + else\ + {\ + if(selection!=2)\ + selection++;\ + else\ + selection=0;\ + while(persos[selection].etat==MORT)\ + {\ + if(selection!=2)\ + selection++;\ + else\ + selection=0;\ + }\ + Fchangercurseurpersos(surfaces,positions,selection,ennemis);\ + }\ + break; + +#endif -- cgit v1.2.3