From 4804cc49c3e0308ddd47756c46c56dc43c8ecb00 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Wed, 22 Dec 2010 20:19:15 +0000 Subject: Le code recompile maintenant. J'avais fait ça dans le train dimanche, et j'ai oublié de commiter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///var/svn/2010-netlemmings/trunk@208 077b3477-7977-48bd-8428-443f22f7bfda --- scripts/compil.sh | 8 ++++---- src/game.c | 4 ++-- src/graphic.c | 34 ++++++++++++++++++---------------- src/include/data_localgame.h | 6 ++++-- src/include/graphic.h | 4 ++-- src/netlem.c | 14 ++++++++++---- 6 files changed, 40 insertions(+), 30 deletions(-) diff --git a/scripts/compil.sh b/scripts/compil.sh index 865da98..e1906ee 100755 --- a/scripts/compil.sh +++ b/scripts/compil.sh @@ -32,11 +32,11 @@ then case $1 in gnome-terminal -t SERVEUR --hide-menubar --geometry 48x15+10+0 -e "bash -c 'src/netlem_ds ; echo \"WAITING 15s\" ; sleep 15'"& echo "WAITING FEW SECONDS" sleep 5; - echo -e "\tV. Client 1 execution" - gnome-terminal -t CLIENT1 --hide-menubar --geometry 48x15+10+310 -e "bash -c 'src/netlem localhost; echo \"WAITING 15s\" ; sleep 15'"& + echo -e "\tVI. Client 1 execution (with valgrind)" + gnome-terminal -t CLIENT1 --hide-menubar --geometry 48x15+10+600 -e "bash -c 'valgrind src/netlem localhost; echo \"Press ENTER TO CLOSE\" ; read line'"& sleep 1; - echo -e "\tVI. Client 2 execution (with valgrind)" - gnome-terminal -t CLIENT2 --hide-menubar --geometry 48x15+10+600 -e "bash -c 'valgrind src/netlem localhost; echo \"Press ENTER TO CLOSE\" ; read line'"& + echo -e "\tV. Client 2 execution" + gnome-terminal -t CLIENT2 --hide-menubar --geometry 48x15+10+310 -e "bash -c 'src/netlem localhost; echo \"WAITING 15s\" ; sleep 15'"& ;; esac else diff --git a/src/game.c b/src/game.c index 63f61a3..a51b015 100644 --- a/src/game.c +++ b/src/game.c @@ -4,12 +4,12 @@ #include "game.h" #include "utils.h" -void play(tick_t tick, int *dirtRectsCount, SDL_Rect **directRects ) { +void play(tick_t tick, gameObjectsState_t *objStates) { if (tick%100==0) { } //printf("tick==%i\n",tick); } //TODO : boucle de jeu principale ici (maj état de jeu) - printf("%p - %i\n", (void *) *directRects, *dirtRectsCount); + printf("%p\r", (void *) objStates); SDL_Delay(rand()%8); } diff --git a/src/graphic.c b/src/graphic.c index 576cbfa..802fd5d 100644 --- a/src/graphic.c +++ b/src/graphic.c @@ -221,45 +221,47 @@ int paintTerrain(gameIni_t *gIni, gameRess_t *gRess, gameGraphics_t *gGraph) { return 0; } -int repaint(gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect dstRect) { - int objToRepaintCount, i, res; - gameGraphObjState_t *objToRepaint; +int repaint(gameObjectsState_t *objStates, gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect dstRect) { + int res; + gameObjectsState_t objToRepaint; +// int i; - objToRepaintCount=findAndZSortObjects(srcSurfs->objectsStat, srcRect, &objToRepaint); + findAndZSortObjects(objStates, srcRect, &objToRepaint); - for(i=0;i0) break; - res=paintObject(objToRepaint+i, srcRect, dstSurf, &dstRect); +/* + for(i=0;i0) break; + res=paintObject(objToRepaint.allObj+i, srcRect, dstSurf, &dstRect); if ( res!=0 ) { logs(LOG_DEBUG, "repaint(), paintObject() failed"); } } - +*/ res=SDL_BlitSurface(srcSurfs->terrain, srcRect, dstSurf, &dstRect); if ( res!=0 ) { logs2(LOG_DEBUG, "repaint(), SDL_BlitSurface()", SDL_GetError()); } - - for(;iobjCount=0; return 0; } -int paintObject(gameGraphObjState_t *obj, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect *dstRect) { +int paintObject(struct gameObjectState *obj, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect *dstRect) { //TODO fprintf(stderr, "TODO paintObject(%p, %p, %p, %p)\n", (void *)obj,(void *)srcRect,(void *)dstSurf, (void *)dstRect); return 0; } + diff --git a/src/include/data_localgame.h b/src/include/data_localgame.h index b4716f7..989444b 100644 --- a/src/include/data_localgame.h +++ b/src/include/data_localgame.h @@ -10,7 +10,7 @@ // Ensemble des buffers graphiques du jeu (sauf l'écran) typedef struct { - SDL_Surface *screen, *terrain, *stencil, *tmpSurf; + SDL_Surface *terrain, *stencil, *tmpSurf; } gameGraphSurfaces_t; // Gestion de l'écran et de la caméra @@ -45,7 +45,9 @@ struct gameObjectState { }; typedef struct { - int objCount; + int objCount; // allObj array item count + // allObj is a list of all objects of the map (objects, lemmings, other GUI objects, all except cursor) + // cursor is the mouse cursor for selecting lemmings struct gameObjectState *allObj, cursor; } gameObjectsState_t; diff --git a/src/include/graphic.h b/src/include/graphic.h index 13ac889..7160b43 100644 --- a/src/include/graphic.h +++ b/src/include/graphic.h @@ -22,7 +22,7 @@ int init(char *winCaption, gameConfig_t *conf, gameGraphics_t *gGraph); int paintTerrain(gameIni_t *gIni, gameRess_t *gRess, gameGraphics_t *gGraph); int repaint(gameObjectsState_t *objStates, gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect dstRect); -int findAndZSortObjects(gameObjectsState_t *objectsStat, SDL_Rect *offsetRect, gameObjectsState_t **objectsFound); -int paintObject(gameObjectsState_t *obj, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect *dstRect); +int findAndZSortObjects(gameObjectsState_t *objectsStat, SDL_Rect *offsetRect, gameObjectsState_t *objectsFound); +int paintObject(struct gameObjectState *obj, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect *dstRect); #endif /*GRAPHIC_H*/ diff --git a/src/netlem.c b/src/netlem.c index 32b339d..8b6b3da 100644 --- a/src/netlem.c +++ b/src/netlem.c @@ -105,6 +105,8 @@ int main(int argc, char **argv) { // Config file loading loadGameConfig(&conf); + memset(&localParams, 0, sizeof(localParams_t)); + // Libraries initialization result=init(WIN_CAPTION, &conf, &gGraph); if(result!=0) { @@ -179,7 +181,7 @@ int main(int argc, char **argv) { fps=(STATS_TICKCOUNT*1000.0)/(timeBefore_ms[t]-timeBefore_ms[(t+1)%STATS_TICKCOUNT]); wantWaitMean=0; for(;tsurfaces.objectsSurf[i]); @@ -514,11 +516,15 @@ int updateGraphics(gameObjectsState_t *objStates, localParams_t *params, gameGra tmpSurf=gGraph->surfaces.tmpSurf; if ( lastViewport.x != gGraph->viewport.x ) { lastViewport.x=gGraph->viewport.x; + dstRect.x=0; + dstRect.y=0; + dstRect.w=0; + dstRect.h=0; srcRect.x=lastViewport.x; srcRect.y=lastViewport.y; srcRect.w=gGraph->screen->clip_rect.w; srcRect.h=gGraph->screen->clip_rect.h; - res=repaint(objStates, &gGraph->surfaces, &srcRect, tmpSurf, srcRect); + res=repaint(objStates, &gGraph->surfaces, &srcRect, tmpSurf, dstRect); if ( res != 0 ) { logs(LOG_WARN, "updateGraphics(), repaint() failed"); } -- cgit v1.2.3