home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2004 #2 / K-CD-2-2004.ISO / Fire Chief / data1.cab / Program_Executable_Files / Logic / tools / Cache_Func.scp next >
Encoding:
Text File  |  2003-05-28  |  3.8 KB  |  191 lines

  1. s32 CheckCache(mcString CacheName, mcString id1, mcString id2,mcString id3,mcString id4)
  2. {
  3.     RESIDENTMAISON rm;
  4.     WORLDRESIDENT Cache;    
  5.     mcString cachetemp;
  6.     s32 Go;
  7.  
  8.     Go = 1;         
  9.     cachetemp = CacheName;
  10.  
  11.     if( id1 != "" )
  12.     {
  13.  
  14.         rm = GetResidentMaison( id1);
  15.         Go = RM_GetNbCompound(rm);
  16.  
  17.         if( Go == 0 ) 
  18.         {
  19.             Cache = GetWorldResident(cachetemp);
  20.             WR_Visible(Cache,0);
  21.             return 0;
  22.         }
  23.     }
  24.  
  25.     if( id2 != "" )
  26.     {
  27.         rm = GetResidentMaison( id2);
  28.         Go = RM_GetNbCompound(rm);
  29.  
  30.         if( Go == 0 ) 
  31.         {
  32.             Cache = GetWorldResident(cachetemp);
  33.             WR_Visible(Cache,0);
  34.             return 0;
  35.         }
  36.     }
  37.  
  38.     if( id3 != "" )
  39.     {
  40.         rm = GetResidentMaison( id3);
  41.         Go = RM_GetNbCompound(rm);
  42.  
  43.         if( Go == 0 ) 
  44.         {
  45.             Cache = GetWorldResident(cachetemp);
  46.             WR_Visible(Cache,0);
  47.             return 0;
  48.         }
  49.     }
  50.  
  51.     if( id4 != "" )
  52.     {
  53.         rm = GetResidentMaison( id4);
  54.         Go = RM_GetNbCompound(rm);
  55.  
  56.         if( Go == 0 ) 
  57.         {
  58.             Cache = GetWorldResident(cachetemp);
  59.             WR_Visible(Cache,0);
  60.             return 0;
  61.         }
  62.     }
  63.     
  64.     return 1;
  65. }
  66.  
  67. s32 CheckStatus(mcString nom)
  68. {
  69.     WORLDRESIDENT wr;
  70.     wr = GetWorldResident(nom);
  71.     
  72.     if( GetCurrPDV(wr) == 0.0 )
  73.         return -2;
  74.  
  75.     if( GetSaved(wr) == 1 )
  76.         return 1;
  77.  
  78.     return 0;
  79. }
  80.  
  81. // ajoute une porte
  82. s32 addDoor (s32 doorId)
  83. {
  84.     s32 nbDoors;
  85.     nbDoors = GetVariable("nbDoors");
  86.     
  87.     // on crΘe la variable avec son nombre de caches et son nombre de link
  88.     AddVariable( "tabDoors" + nbDoors ,doorId);
  89.     AddVariable( "d" + doorId + "NbCaches" ,0);
  90.     AddVariable( "d" + doorId + "NbLinks" ,0);
  91.     
  92.     // et hop un cache de plus
  93.     SetVariable("nbDoors", nbDoors+1 );
  94.  
  95.     return 0;
  96. }
  97.  
  98. // ajoute un cache liΘ α la derniΦre porte
  99. s32 enqueueCache (s32 cacheId)
  100. {
  101.     s32 lastDoorId;
  102.     s32 nbCaches;
  103.     
  104.     lastDoorId = GetVariable( "tabDoors" + ( GetVariable("nbDoors")-1 ) );
  105.     nbCaches = GetVariable("d" + lastDoorId + "nbCaches");
  106.     
  107.     AddVariable( "d" + lastDoorId + "c" + nbCaches ,cacheId);
  108.     
  109.     // on incrΘmente nbCaches
  110.     SetVariable( "d" + lastDoorId + "nbCaches" , nbCaches+1 );
  111.     
  112.     return 0;
  113. }
  114.  
  115. // ajoute un hp_link liΘ α la derniΦre porte
  116. s32 enqueueLink (s32 linkId)
  117. {
  118.     s32 lastDoorId;
  119.     s32 nbLinks;
  120.     
  121.     lastDoorId = GetVariable( "tabDoors" + ( GetVariable("nbDoors")-1 ) );
  122.     nbLinks = GetVariable("d" + lastDoorId + "NbLinks");
  123.     
  124.     AddVariable( "d" + lastDoorId + "l" + nbLinks ,linkId);
  125.     
  126.     // on incrΘmente nbLinks
  127.     SetVariable( "d" + lastDoorId + "NbLinks" , nbLinks+1 );
  128.     
  129.     return 0;
  130. }
  131.  
  132. // vΘrifie toutes les portes
  133. s32 checkAllDoors ()
  134. {
  135.     s32 nbDoors;
  136.     s32 nbCaches;
  137.     s32 nbLinks;
  138.     s32 doorId;
  139.     s32 i;
  140.     s32 j;
  141.     s32 butine;
  142.     
  143.     nbDoors = GetVariable("nbDoors");
  144.     
  145.     // on dΘfile toutes les portes
  146.     for (i=0; i<nbDoors; i+=1)
  147.     {
  148.         doorId = GetVariable( "tabDoors"+i );
  149.         
  150.         butine = RM_GetNbCompound( GetResidentMaison( "porte" + doorId ) );
  151.         
  152.         // si la porte est butinΘe
  153.         if (butine == 0)
  154.         {
  155.             nbCaches = GetVariable("d" + doorId + "nbCaches");
  156.             nbLinks = GetVariable("d" + doorId + "NbLinks");
  157.             
  158.             // on lance la fonction liΘe (porte)
  159.             AddFunction_Events("doorOnBreak" + doorId,0,1);
  160.             
  161.             // on dΘfile ses caches
  162.             for (j=0; j<nbCaches; j+=1)
  163.             {
  164.                 // on retire le cache
  165.                 if ( ActivateHiddenZone( "cache" + GetVariable( "d" + doorId + "c" + j ) ) )
  166.                 {
  167.                     // on lance la fonction liΘe (cache)
  168.                     AddFunction_Events("cacheOnShow" + GetVariable( "d" + doorId + "c" + j ),0,1);
  169.                 }
  170.             }
  171.             
  172.             // on dΘfile ses hplinks et on les dΘsactive
  173.             for (j=0; j<nbLinks; j+=1)
  174.             {
  175.                 SetHotpointLinkActivated( GetVariable("d" + doorId + "l" + j) ,0);
  176.             }
  177.             
  178.             // pour finir on la retire du tableau (on met la derniΦre α sa place...)
  179.             if (i != (nbDoors-1))
  180.             {
  181.                 SetVariable( "tabDoors" + i , GetVariable("tabDoors" + (nbDoors-1) ) );
  182.             
  183.             }
  184.             SetVariable("nbDoors", (nbDoors-1) );
  185.  
  186.         }
  187.     }
  188.  
  189.     return 0;
  190. }
  191.