Esempio n. 1
0
BOOLEAN
GlobalContainersTable::ReleaseOverlayContainer(
    __in OverlayLogFreeService& OC
    )
{
    BOOLEAN RemoveFromList = FALSE;
    OverlayLogFreeService::SPtr overlayContainer = &OC;
    
    K_LOCK_BLOCK(GetLock())
    {
        RemoveFromList = overlayContainer->DecrementOnListCount();
        if (RemoveFromList)
        {
            NTSTATUS status;
            OverlayLogFreeService::SPtr oc;

            status = RemoveObjectNoLock(oc, overlayContainer->GetContainerId());
#if DBG
            KAssert(NT_SUCCESS(status));
            KAssert(oc.RawPtr() == overlayContainer.RawPtr());
#else
            UNREFERENCED_PARAMETER(status);
#endif
        }
    }

    return(RemoveFromList);
}
Esempio n. 2
0
BOOLEAN
GlobalStreamsTable::ReleaseOverlayStream(
    __in OverlayStreamFreeService& OS
    )
{
    BOOLEAN RemoveFromList = FALSE;
    OverlayStreamFreeService::SPtr overlayStream = &OS;
    
    K_LOCK_BLOCK(GetLock())
    {
        RemoveFromList = overlayStream->DecrementOnListCount();
        if (RemoveFromList)
        {
            NTSTATUS status;
            OverlayStreamFreeService::SPtr os;

            status = RemoveObjectNoLock(os, overlayStream->GetStreamId());
#if DBG
            KAssert(NT_SUCCESS(status));
            KAssert(os.RawPtr() == overlayStream.RawPtr());
#else
            UNREFERENCED_PARAMETER(status);
#endif
        }
    }

    return(RemoveFromList);
}
Esempio n. 3
0
void EInventory::AddItem(EInventoryItem *lpItem, bool preload)
{
#ifdef DEBUG
   K_LOG("AddItem(EInventoryItem *lpItem) start for %s",lpItem->_szItemName);
   if (SCENEDIRECTOR != NULL && SCENEDIRECTOR->GetCurrentEScene() != NULL)
      K_LOG("InventoryItem: additem, scene:%s, object:%s, invimg:%s",
                  SCENEDIRECTOR->GetCurrentEScene()->_strSceneName.c_str(),
                  lpItem->_szItemName,
                  EImageBank::GetCache(lpItem->_lpsimgImage->getGraphic())->GetImgPath());
#endif

   // Ajoute l'item
   EInventoryItem *lpItemAlready = NULL;
   lpItemAlready = getItemFromInventory(lpItem->_szItemName);
   
   if (lpItemAlready != NULL && lpItemAlready->_nNbPartNeeded > 1)
   {
      XDELETE(lpItem);
      // Oui, on a bien cet objet et il est incomplet
      if (lpItemAlready->_nNbPartCurrent < lpItemAlready->_nNbPartNeeded)
      {
         lpItemAlready->_nNbPartCurrent++;
         K_LOG("AddItem _nNbPartCurrent incremented for %s (now is %d)", lpItemAlready->_szItemName, lpItemAlready->_nNbPartCurrent);
         KAssert(lpItemAlready->_nNbPartCurrent <= lpItemAlready->_nNbPartNeeded);
         if (lpItemAlready->_nNbPartCurrent >= lpItemAlready->_nNbPartNeeded)
         {
            K_LOG("AddItem %s is now completed (%d)", lpItemAlready->_szItemName, lpItemAlready->_nNbPartCurrent);
            ESoundBank::getSound("success")->playSample();
            int x,y;
            int nCell;
            nCell = getItemCell(lpItemAlready->_szItemName);
            x = _InventoryCells[nCell]->getPosX() + INVENTORY_CELLWIDTH/2;
            y = _InventoryCells[nCell]->getPosY() + INVENTORY_CELLHEIGHT/2;
            // Effet objet terminé
            // Objet complété ? On en informe le director.
            if (!preload) {
               _lpSceneDirector->ItemIsFull(lpItemAlready->_szItemName);
            }
         }
      }
      else
      {
         // Aucune raison qu'on dépasse le nombre de morceaux
         K_LOG("AddItem(EInventoryItem *lpItem) error: lpItemAlready->_nNbPartCurrent > lpItemAlready->_nNbPartNeeded for %s",lpItem->_szItemName);
         KAssert(false);
      }
   }
   else {
      // Ajout réel dans l'inventaire
      K_LOG("AddItem(EInventoryItem *lpItem) addToTail for %s",lpItem->_szItemName);
      // Reprend l'image originale
      lpItem->initImage();
      EInventoryItem::g_ListInventoryItem.addToTail(lpItem);
   }
   Order();
}
void ESceneSequencer::MiniGame(const char *szSequenceName, const char *szName, EMiniJeuBase *lpMinigame)
{
   KAssert(szName != NULL);
   /* Vérifie que cette même séquence n'est pas déjà dans la pile */
   if (szSequenceName) {
      if (isAlready(szSequenceName)) {
         XDELETE(lpMinigame);
         return;
      }
   } else if (isAlready(szName)) {
      XDELETE(lpMinigame);
      return;
   }
   
   /* Un container */
   ESequenceContainer *oc = new ESequenceContainer(_lpSceneDirector->getCurrentSceneName(), "", SCENESEQUENCE_MINIGAME);
   /* Une séquence */
   ESequenceMinigame *o = new ESequenceMinigame(lpMinigame, szName, _lpSceneDirector);
   /* On relie les 2 */
   if (szSequenceName) {
      strcpy(oc->_szSequenceName, szSequenceName);
   }
   else {
      strcpy(oc->_szSequenceName, szName);
   }
   oc->_lpSequenceMinigame = o;
   /* On ajoute au séquenceur */
   ESequenceContainer::g_ListSequence.addToTail(oc);
}
void SceneObjectImage::SetMousePointer(const char *szMousePointer)
{
   KAssert(szMousePointer != NULL);
   strcpy(_szMousePointer, szMousePointer);
   // Les zones ayant un pointer spécifique ont un glitch
   if (strlen(szMousePointer) > 0 && (strcmp(szMousePointer, "arrow_puzzle") == 0 || strcmp(szMousePointer, "arrow_look") == 0 || strcmp(szMousePointer, "arrow_action") == 0 ) ) {
      // En mode aventure, pas de glit
      if (TestGlobal("__mode_adventure__")) {
         // Nothing
      }
      else {
         SetGlitch();
      }

   }
   // Les objets à ramasser ont un glit différé
   if (strlen(szMousePointer) > 0 && strcmp(szMousePointer, "arrow_take") == 0) {
      // En mode aventure, pas de glit
      if (TestGlobal("__mode_adventure__")) {
         // Nothing
      }
      else {
         SetGlitchTempo();
      }
      
   }
}
Esempio n. 6
0
void EInventory::ReplaceItem(const char *szFromItemName, const char *szToItemName)
{
   EInventoryItem *oOld;
   EInventoryItem *oNew;
   int nCell;

   setItemVisible(szFromItemName);
   nCell = getItemCell(szFromItemName);
   if (nCell == -1) {
      K_LOG("EInventory::ReplaceItem Error:%s not found",szFromItemName);
   }
   if (nCell != -1) {
      oOld = getItemFromInventory(szFromItemName);
      KAssert(oOld != NULL);
      if (oOld) {
         oNew = new EInventoryItem(oOld->_szUniverseName, szToItemName, 1, 1);
         _InventoryCells[nCell]->setItem(oNew);
         EInventoryItem::g_ListInventoryItem.addBefore(oOld,oNew);
         DropItem(szFromItemName);
         BlingItem(szToItemName);
      }
   }
   else {
      // On fait à l'ancienne !
      // !!!:dmekersa:20110615 Un bug semble faire que parfois l'item n'est pas visible parmis les 6 cellules de l'inventaire !
      // !!!:dmekersa:20110701 2ème correction car j'utilisais oOld pour récupérer l'univers et sans l'initialiser
      K_LOG("EInventory::ReplaceItem workaround for %s",szFromItemName);
      DropItem(szFromItemName);
      // Ligne supprimée car oOld non initialisé :
      //oNew = new EInventoryItem(oOld->_szUniverseName, szToItemName, 1, 1);
      oNew = new EInventoryItem(_szUniverseName, szToItemName, 1, 1);
      AddItem(oNew);
   }

}
Esempio n. 7
0
	Coord LineIntersection(float Ax, float Ay, float Bx, float By, float Cx, float Cy, float Dx, float Dy) {
		double A1 = By - Ay;
		double B1 = Ax - Bx;
		double C1 = A1*Ax + B1*Ay;

		double A2 = Dy - Cy;
		double B2 = Cx - Dx;
		double C2 = A2*Cx + B2*Cy;

		double det = A1*B2 - A2*B1;
		KAssert(det!=0);

		double x = (B2*C1 - B1*C2)/det;
		double y = (A1*C2 - A2*C1)/det;

		return Coord((float)x,(float)y);
	}
Esempio n. 8
0
void ETextBox::SetText(const char *text) {
	int l = strlen(text) +1;

	if (_cText != NULL) {
		free(_cText);
		_cText = NULL;
	}

	_cText = (char *) malloc(l*sizeof(char));
	KAssert(_cText != NULL);
	memset(_cText,0,l*sizeof(char));

	strcpy(_cText,text);

	_fMinTextWidth = 0;
	SetMinWidth();
	UpdateGeometry();
}
/*
 Ajoute une séquence de Talk
 szText : Texte à afficher
 szVoice : désigne le fichier son à jouer en //
 */
void ESceneSequencer::Talk(const char *szSequenceName, int nFromX, int nFromY, const char *szText, const char *szVoice, bool bCheckAllowed, bool bDialogMode, KSound *lpSoundStream)
{
   /* Vérifie que cette même séquence n'est pas déjà dans la pile */
   if (szSequenceName) {
      if (isAlready(szSequenceName)) {
         return;
      }
   }

   /* Vérifie le texte */
   KAssert(szText != NULL);
   if (!szText)
   {
      return;
   }

   /* Termine la séquence en cours si c'est un Talk ou un Voiceover */
   if (_lpCurrentSequence) {
      if (_lpCurrentSequence->_type == SCENESEQUENCE_VOICEOVER || _lpCurrentSequence->_type == SCENESEQUENCE_TALK) {
         ESequenceContainer::g_ListSequence.remove(_lpCurrentSequence);
         _lpCurrentSequence->DeleteContent();
         XDELETE(_lpCurrentSequence);
      }
   }
   
   /* Un container */
   ESequenceContainer *oc = new ESequenceContainer(_lpSceneDirector->getCurrentSceneName(), "", SCENESEQUENCE_TALK);
   /* Une séquence Talk */
   ESequenceTalk *o = new ESequenceTalk(nFromX, nFromY, szText, szVoice, bCheckAllowed, bDialogMode, lpSoundStream);
   /* On relie les 2 */
   if (szSequenceName) {
      strcpy(oc->_szSequenceName, szSequenceName);
   }
   else {
      strcpy(oc->_szSequenceName, "");
   }

   oc->_lpSequenceTalk = o;
   /* On ajoute au séquenceur */
   ESequenceContainer::g_ListSequence.addToTail(oc);
}
Esempio n. 10
0
void EInventory::setItemVisible(const char *szItemName)
{
   // L'item est déjà visible
   if (getItemCell(szItemName) >= 0)
      return;

   // Compte la position de l'item dans la liste globale
   bool bFind = false;
   int nPosInList = 0;
   EInventoryItem *o = NULL;
   bool bGotNext = EInventoryItem::g_ListInventoryItem.getHead (o);
   if (bGotNext) {
      while (bGotNext) {
         if (strcmp(o->_szItemName, szItemName) == 0) {
            bFind = true;
            break;
         }
         if (strcmp(o->_szUniverseName, _szUniverseName) == 0) {
            nPosInList++;
         }
         bGotNext = EInventoryItem::g_ListInventoryItem.getNext (o);
      }
   }

   // Pas de raison qu'on demande à rendre visible un item qui n'est pas dans l'inventaire
   KAssert(bFind == true);
   if (!bFind) return;

   // On scrolle jusqu'à que cet item soit dans les items visibles
   // Scroll vers les éléments de droite
   if (nPosInList > INVENTORY_CELLMAX)
   {
      _nFirstCell = (nPosInList - INVENTORY_CELLMAX) + 1;
   }
   else
   if (nPosInList < INVENTORY_CELLMAX)
   {
      _nFirstCell = nPosInList;
   }
   Order(true);
}
/*
 Ajoute une séquence de Voice Over
 szText : Texte à afficher
 szVoice : désigne le fichier son à jouer en //
*/
void ESceneSequencer::VoiceOver(const char *szSequenceName, const char *szText, const char *szVoice, SequenceVoiceOverColor Color)
{
   /* Vérifie que cette même séquence n'est pas déjà dans la pile */
   if (szSequenceName) {
      if (isAlready(szSequenceName)) {
         return;
      }
   }
   
   /* Vérifie le texte */
   KAssert(szText != NULL);
   if (!szText)
   {
      return;
   }
   
   /* Termine la séquence en cours si c'est un Talk ou un Voiceover */
   if (_lpCurrentSequence) {
      if (_lpCurrentSequence->_type == SCENESEQUENCE_VOICEOVER || _lpCurrentSequence->_type == SCENESEQUENCE_TALK) {
         ESequenceContainer::g_ListSequence.remove(_lpCurrentSequence);
         _lpCurrentSequence->DeleteContent();
         XDELETE(_lpCurrentSequence);
      }
   }
   
   /* Un container */
   ESequenceContainer *oc = new ESequenceContainer(_lpSceneDirector->getCurrentSceneName(), "", SCENESEQUENCE_VOICEOVER);
   /* Une séquence VoiceOver */
   ESequenceVoiceOver *o = new ESequenceVoiceOver(szText, szVoice, Color);
   /* On relie les 2 */
   if (szSequenceName) {
      strcpy(oc->_szSequenceName, szSequenceName);
   }
   else {
      strcpy(oc->_szSequenceName, "");
   }
   oc->_lpSequenceVoiceOver = o;
   /* On ajoute au séquenceur */
   ESequenceContainer::g_ListSequence.addToTail(oc);
}
Esempio n. 12
0
void EInventory::BlingItem(const char *szItemName)
{
   EInventoryItem *lpItemAlready = NULL;
   lpItemAlready = getItemFromInventory(szItemName);
   if (lpItemAlready) {
      setItemVisible(szItemName);
      ESoundBank::getSound("success")->playSample();
      int x,y;
      int nCell;
      nCell = getItemCell(lpItemAlready->_szItemName);
      if (nCell != -1) {
         KAssert(_InventoryCells[nCell]->getItem() != NULL);
         x = _InventoryCells[nCell]->getPosX() + INVENTORY_CELLWIDTH/2;
         y = _InventoryCells[nCell]->getPosY() + INVENTORY_CELLHEIGHT/2;
         _lpGlow->setPos(x,y);
         _lpGlow->Start();
      }
      else {
         K_LOG("BlingItem failed for %s",szItemName);
      }
   }
}
Esempio n. 13
0
void KPhysicalAllocatorRelease(UIntPtr alloc_base, UInt32 ownerID)
{
    int first_page = alloc_base >> 12;

    KAssert(AllocationHeader[first_page].AllocBase == alloc_base);

    for (int i=first_page; ; i++)
    {
        if (((AllocationHeader[i].Flags&0xC0) == 0x80) &&
                (AllocationHeader[i].OwnerID == ownerID) &&
                (AllocationHeader[i].AllocBase == alloc_base))
        {
            AllocationHeader[i].BlockSize = 0;
            AllocationHeader[i].Flags = 0;
            AllocationHeader[i].OwnerID = 0;
            AllocationHeader[i].AllocBase = 0;
        }
        else break;
    }

    KAllocatorMergeBuddies();
}
void Vignette_Hands::Logic()
{
	EScene::Logic();

   SceneObjectImage *objimg;
   objimg = _lpSceneDirector->GetCurrentScene()->GetObjectImageByName(_szHandName);
   KAssert(objimg != NULL);
   if (objimg) {
      // Anime de la main terminée
      if (objimg->GetSmartImage()->isAnimateP2P() == false && _State == SCENE_STABLE && !_bGotoDone) {
         _lpSceneDirector->getSequencer()->Reset();
         _lpSceneDirector->getSequencer()->Wait(NULL, 500);
         _lpSceneDirector->getSequencer()->PlaySound(NULL, "vortex");
         SetVisible("blank", true, false);
         _bGotoDone = true;
         if (_strSceneAdditionalName == "island") {
            _lpSceneDirector->getSequencer()->GotoVideo(NULL, "videos/soul_tunnel.ogv", "tunnel");
            _lpSceneDirector->getSequencer()->GoToScene(NULL,"island_beach","arrival",false);
         }
         else if (_strSceneAdditionalName == "japan") {
            _lpSceneDirector->getSequencer()->GotoVideo(NULL, "videos/soul_tunnel.ogv", "tunnel");
            _lpSceneDirector->getSequencer()->GoToScene(NULL,"japan_mainscreen","arrival",false);
         }
         else if (_strSceneAdditionalName == "inca") {
            _lpSceneDirector->getSequencer()->GotoVideo(NULL, "videos/soul_tunnel.ogv", "tunnel");
            _lpSceneDirector->getSequencer()->GoToScene(NULL,"inca_mainscreen","arrival",false);
         }
         else if (_strSceneAdditionalName == "egypt") {
            _lpSceneDirector->getSequencer()->GotoVideo(NULL, "videos/soul_tunnel.ogv", "tunnel");
            _lpSceneDirector->getSequencer()->GoToScene(NULL,"egypt_land","arrival",false);
         }
         else if (_strSceneAdditionalName == "middleage") {
            _lpSceneDirector->getSequencer()->GotoVideo(NULL, "videos/soul_tunnel.ogv", "tunnel");
            _lpSceneDirector->getSequencer()->GoToScene(NULL,"middleage_mainscreen","arrival",false);
         }
      }
   }
}
void Scene_House_IncaBook::PageSet(int page) {
	KAssert(page < _nPages && page >= 0);
	
	_nCurrentPage = page;

	// Activation des zone pour tourner les pages
	SetVisible("livingroom_book_left",true);
	SetVisible("livingroom_book_right",true);
	if (_nCurrentPage == 0)
		SetVisible("livingroom_book_left",false);
	if (_nCurrentPage == _nPages -1)
		SetVisible("livingroom_book_right",false);

   // Efface tout
   SetVisible("livingroom_book_page1", false);
   SetVisible("txt_title_left_page1", false);
   SetVisible("txt_subtitle_left_page1", false);

   SetVisible("livingroom_book_page2", false);
   SetVisible("txt_title_left_page2", false);
   SetVisible("txt_subtitle_left_page2", false);
   SetVisible("txt_text_page2", false);

   SetVisible("livingroom_book_page3", false);
   SetVisible("txt_title_left_page3", false);
   SetVisible("txt_subtitle_left_page3", false);
   SetVisible("txt_text_page3", false);

   SetVisible("livingroom_book_page4", false);
   SetVisible("txt_title_left_page4", false);
   SetVisible("txt_subtitle_left_page4", false);
   SetVisible("txt_text_page4", false);

   SetVisible("livingroom_book_page5", false);
   SetVisible("txt_title_left_page5", false);
   SetVisible("txt_subtitle_left_page5", false);
   SetVisible("txt_text_page5", false);

   SetVisible("livingroom_book_page6", false);
   SetVisible("txt_title_left_page6", false);
   SetVisible("txt_subtitle_left_page6", false);
   SetVisible("txt_text_page6", false);
   
   switch (_nCurrentPage) {
      case 0:
         SetVisible("livingroom_book_page1", true);
         SetVisible("txt_subtitle_left_page1", true);
         SetVisible("txt_title_left_page1", true);
         break;
      case 1:
         SetVisible("livingroom_book_page2", true);
         SetVisible("txt_subtitle_left_page2", true);
         SetVisible("txt_title_left_page2", true);
         SetVisible("txt_text_page2", true);
         break;
      case 2:
         SetVisible("livingroom_book_page3", true);
         SetVisible("txt_subtitle_left_page3", true);
         SetVisible("txt_title_left_page3", true);
         SetVisible("txt_text_page3", true);
         break;
      case 3:
         SetVisible("livingroom_book_page4", true);
         SetVisible("txt_subtitle_left_page4", true);
         SetVisible("txt_title_left_page4", true);
         SetVisible("txt_text_page4", true);
         break;
      case 4:
         SetVisible("livingroom_book_page5", true);
         SetVisible("txt_subtitle_left_page5", true);
         SetVisible("txt_title_left_page5", true);
         SetVisible("txt_text_page5", true);
         break;
      case 5:
         SetVisible("livingroom_book_page6", true);
         SetVisible("txt_subtitle_left_page6", true);
         SetVisible("txt_title_left_page6", true);
         SetVisible("txt_text_page6", true);
         break;
      default:
         break;
   }

	// Mémorisation de la page courante
	SetGlobal(HOUSE_BOOK_CURRENT_PAGE,itos(_nCurrentPage).c_str());
	
}
Esempio n. 16
0
void SceneObjectImage::SetData(const char *szFileName, int scene_id, const char *szObjectName, const char *szType, int nNbFrame, bool bFade, int nFadeDuration, float fx, float fy, int iWidth, int iHeight, bool bVis, bool bDisable, bool bHalo, float fHaloSpeed, bool bLoop, float fMaxBlend, const char *szInvImage, const char *baseDir)
{
   _type = SCENEOBJECT_IMAGE;
   strcpy(_szImageFileName, szFileName);
   strcpy(_szObjectName, szObjectName);
   strcpy(_szType, szType);
   strcpy(_szInvImageName, szInvImage);
   _bVisible = bVis;
   _bDisable = bDisable;
   _bHalo = bHalo;
   
   if ( strlen(szFileName)>0 ) {
      KAssert(_lpSmartImage == NULL);
      if ((strstr(szFileName,".") == NULL)) { 
         int nFPS = 24;
         if (nNbFrame > 1)
            nFPS = nNbFrame;
         _lpSmartImage = new ESmartImage((char *)szFileName, fx, fy, _bVisible, bFade, nFadeDuration, bLoop, nFPS);
      } else if (strstr(szFileName,".ogv") != NULL) {
         _lpVideo = EImageBank::getVideo(_szImageFileName,bLoop);
         _lpSmartImage = new ESmartImage(_lpVideo, fx, fy, _bVisible, bFade, nFadeDuration);
      } else {
         if (baseDir == NULL) {
            _lpImageGraphic = EImageBank::getImage(_szImageFileName);
         } else {
            _lpImageGraphic = EImageBank::getImage(_szImageFileName,".png",false,false,false,baseDir);
         }
         _lpSmartImage = new ESmartImage(_lpImageGraphic, fx, fy, nNbFrame, _bVisible, bFade, nFadeDuration);
      }
      assert(_lpSmartImage->IsValid());
      K_LOG("ESceneObject: create smart image %s, id:%08x",_szImageFileName,_lpSmartImage);
      if (_lpSmartImage) {
         _lpSmartImage->setFixedBlend(fMaxBlend);
         _lpSmartImage->ForceVisible(_bVisible);
         _lpSmartImage->setHalo(bHalo, fHaloSpeed);
      }
   }
   
   if (strlen(_szInvImageName) >0 && strstr(_szInvImageName,".") == NULL) {
      char szPattern[K_MAXPATH];
      memset(szPattern, 0, K_MAXPATH);
      strcpy(szPattern, _szInvImageName);
      strcat(szPattern,"_%d.png");
      int nindex = GetIndex(_szObjectName);
      sprintf(_szInvImageName, szPattern, nindex);
   }

   // Coordonnées et taille
   _x = fx;
   _y = fy;
   // Conserve une coordonnée de référence (utile pour SetPosition/RestorePosition)
   _originalx = fx;
   _originaly = fy;
   // Si les tailles ne sont pas précisées, on prend l'image
   if (iWidth != 0 && iHeight != 0) {
      _w = iWidth;
      _h = iHeight;
   }
   else if (_lpSmartImage != NULL) {
      _w = _lpSmartImage->getWidth();
      _h = _lpSmartImage->getHeight();      
   }
   // Destination
   _bExit = false;
   memset(_szDestination, 0, 256);
   // Info text
   _bInfoText = false;
   memset(_szInfoText, 0, 256);
}