Esempio n. 1
0
void
ELIST2::internal_clear (         //destroy all links
void (*zapper) (ELIST2_LINK *)) {
                                 //ptr to zapper functn
  ELIST2_LINK *ptr;
  ELIST2_LINK *next;

  if (!empty ()) {
    ptr = last->next;            //set to first
    last->next = NULL;           //break circle
    last = NULL;                 //set list empty
    while (ptr) {
      next = ptr->next;
      zapper(ptr);
      ptr = next;
    }
  }
}
Esempio n. 2
0
void
ELIST::internal_clear (          //destroy all links
void (*zapper) (ELIST_LINK *)) {
                                 //ptr to zapper functn
  ELIST_LINK *ptr;
  ELIST_LINK *next;

  #ifndef NDEBUG
  if (!this)
    NULL_OBJECT.error ("ELIST::internal_clear", ABORT, NULL);
  #endif

  if (!empty ()) {
    ptr = last->next;            //set to first
    last->next = NULL;           //break circle
    last = NULL;                 //set list empty
    while (ptr) {
      next = ptr->next;
      zapper(ptr);
      ptr = next;
    }
  }
}
Esempio n. 3
0
int main() {
    int fin=0, touche, action;
    Partie partie;
    Dalek *daleks = NULL;
    Doc doc;
    Surfaces surfce;
    
    /*Initialisations*/
    SDL_Init(SDL_INIT_VIDEO);
    TTF_Init();
    srand(time(NULL));
    #ifdef PSP
    pspDebugScreenInit();
    SetupCallbacks();
    #endif
    
    /*Initialisation de l'ecran principal*/
    surfce.screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
    #ifndef PSP /*Titre si pas sur le PSP*/
        SDL_WM_SetCaption("Daleks-SDL", NULL);
    #endif
    
    /*Affichage de l'intro, sert de loading Screen*/
    afficherIntro(surfce.screen);
    
    /*Creation de la partie*/
    partie = nouvellePartie();
    
    /*Initialisation des personnages*/
    initNiveau(partie, &doc, &daleks);
    
    /*Initialisation des surfaces SDL*/
    if (initialiserSurfaces(&surfce) != 0) {
        exit(EXIT_FAILURE);
    }
    
    /*Le loading est fini, on attend une touche de l'utilisateur*/
    while (lireTouche() == -1) {
    }
    
    /*Sert a annuler la touche enfoncee precedement*/
    afficherPartie(partie, surfce, doc, daleks);
    
    while (!fin) {
        /**********
            ETAPES
            1. Lire la touche
            2. Effectuer l'action
            3. Bouger les daleks
            4. Verifier les morts
            5. Verifier l'etat de la partie
            6. Afficher le jeu
          **********/
        action = 1; /*Pour savoir si il y a eu une action ce tour*/
        touche = lireTouche();
        switch (touche) {
            case KEY_UP:
                if (moveDoc(0, -1, &doc, daleks, partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_DOWN:
                if (moveDoc(0, 1, &doc, daleks, partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_LEFT:
                if (moveDoc(-1, 0, &doc, daleks, partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_RIGHT:
                if (moveDoc(1, 0, &doc, daleks, partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_UP_LEFT:
                if (moveDoc(-1, -1, &doc, daleks, partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_UP_RIGHT:
                if (moveDoc(1, -1, &doc, daleks, partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_DOWN_LEFT:
                if (moveDoc(-1, 1, &doc, daleks, partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_DOWN_RIGHT:
                if (moveDoc(1, 1, &doc, daleks, partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_STAY:
                if (moveDoc(0, 0, &doc, daleks, partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_ZAP:
                if (zapper(doc, daleks, &partie) != 0) {
                    action = 0;
                }
                break;
            case KEY_TELEPORT:
                teleportDoc(&doc, daleks, partie);
                break;
            case KEY_RUN:
                run(&doc, daleks, &partie, surfce);
                action = 0; /*Les daleks ont deja bouge*/
                break;
            case KEY_QUIT:
                fin = 1;
            default: /*aucune action*/
                action = 0;
        }
        
        /*Les daleks bougent seulement si le doc a fait une action*/
        if (action) {
            moveDaleks(daleks, doc, partie);
            checkMorts(&doc, daleks, &partie);
        }
        
        if (getStatutPartie(doc, daleks, partie) == 1) {
            afficherPartie(partie, surfce, doc, daleks); /*Affichage de la partie avant d'afficher lvlUp*/
            afficherLevelUp(surfce.screen);                 /*Parce que l'affichage est long*/
            monterNiveau(&partie);
            initNiveau(partie, &doc, &daleks);
        } else if (getStatutPartie(doc, daleks, partie) == 2) {
            afficherPartie(partie, surfce, doc, daleks); /*Affichage de la partie avant d'afficher la mort*/
            afficherDead(surfce.screen);                    /*Parce que l'affichage est long*/
            reset(&partie);
            initNiveau(partie, &doc, &daleks);
        }
        
        afficherPartie(partie, surfce, doc, daleks);
    }
    
    libererSurfaces(surfce);
    TTF_Quit();
    SDL_Quit();
    
    #ifdef PSP
        sceKernelExitGame();
    #endif
    return 0;
}
Esempio n. 4
0
void TabManager::closeTab(pp_int32 index/* = -1*/)
{
#ifndef __LOWRES__
	TabHeaderControl* tabHeader = getTabHeaderControl();

	// when there is only a single tab open
	// we zap the module if it has changed or is not empty
	if (tabHeader->getNumTabs() <= 1)
	{
		if (tracker.moduleEditor->hasChanged() ||
			!tracker.moduleEditor->isEmpty())
		{
			Zapper zapper(tracker);
			zapper.zapAll();
			tracker.updateSongInfo(false);
			tracker.screen->paint();
		}
		return;
	}

	if (index == -1)
		index = tabHeader->getSelectedTabIndex();

	pp_int32 moduleIndex = tabHeader->getTab(index)->ID;

	bool res = tracker.checkForChanges(documents->get(moduleIndex)->moduleEditor);
	if (!res)
		return;

	TabHeaderControl::TabHeader* tabs = new TabHeaderControl::TabHeader[tabHeader->getNumTabs()];

	pp_int32 j = 0;
	pp_int32 i;
	for (i = 0; i < (signed)tabHeader->getNumTabs(); i++)
	{
		if (i != index)
		{
			tabs[j] = *tabHeader->getTab(i);
			j++;
		}
	}
	
	tabHeader->clear();

	for (i = 0; i < j; i++)
	{
		if ((signed)tabs[i].ID > moduleIndex)	
			tabs[i].ID--;
	}
	
	Document* doc = documents->removeNoDestroy(moduleIndex);
	
	if (index >= documents->size())
		index = documents->size()-1;
	
	for (i = 0; i < j; i++)
	{
		tabHeader->addTab(tabs[i]);
	}
	
	delete[] tabs;

	tabHeader->setSelectedTab(index);

	switchToTab(tabHeader->getTab(index)->ID);
	
	if (doc->moduleEditor != tracker.moduleEditor)
	{
		tracker.playerMaster->destroyPlayerController(doc->playerController);
		delete doc;
	}
#endif
}