Exemple #1
0
static void orxFASTCALL Exit()
{
  // Has font name?
  if(sstFontGen.zFontName)
  {
    // Frees its string
    orxString_Delete(sstFontGen.zFontName);
    sstFontGen.zFontName = orxNULL;
  }

  // Deletes character table
  orxHashTable_Delete(sstFontGen.pstCharacterTable);

  // Deletes glyph bank
  orxBank_Delete(sstFontGen.pstGlyphBank);

  // Has face?
  if(sstFontGen.pstFontFace)
  {
    // Deletes it
    FT_Done_Face(sstFontGen.pstFontFace);
  }

  // Has library?
  if(sstFontGen.pstFontLibrary)
  {
    // Exits from it
    FT_Done_FreeType(sstFontGen.pstFontLibrary);
  }
}
Exemple #2
0
/** Creates a plugin info
 * @return orxPLUGIN_INFO / orxNULL
 */
static orxPLUGIN_INFO *orxFASTCALL orxPlugin_CreatePluginInfo()
{
  orxPLUGIN_INFO *pstPluginInfo;

  /* Creates a plugin info */
  pstPluginInfo = (orxPLUGIN_INFO *)orxBank_Allocate(sstPlugin.pstPluginBank);

  /* Valid? */
  if(pstPluginInfo != orxNULL)
  {
    /* Inits it */
    orxMemory_Zero(pstPluginInfo, sizeof(orxPLUGIN_INFO));

    /* Undefines plugin handle */
    pstPluginInfo->hPluginHandle      = orxHANDLE_UNDEFINED;

    /* Creates function bank */
    pstPluginInfo->pstFunctionBank    = orxBank_Create(orxPLUGIN_KU32_FUNCTION_BANK_SIZE, sizeof(orxPLUGIN_FUNCTION_INFO), orxBANK_KU32_FLAG_NONE, orxMEMORY_TYPE_MAIN);

    /* Valid? */
    if(pstPluginInfo->pstFunctionBank != orxNULL)
    {
      /* Creates function hash table */
      pstPluginInfo->pstFunctionTable = orxHashTable_Create(orxPLUGIN_KU32_FUNCTION_BANK_SIZE, orxHASHTABLE_KU32_FLAG_NONE, orxMEMORY_TYPE_MAIN);

      /* Invalid? */
      if(pstPluginInfo->pstFunctionTable == orxNULL)
      {
        /* Logs message */
        orxDEBUG_PRINT(orxDEBUG_LEVEL_PLUGIN, "Invalid function hash table.");

        /* Frees previously allocated data */
        orxBank_Delete(pstPluginInfo->pstFunctionBank);
        orxBank_Free(sstPlugin.pstPluginBank, pstPluginInfo);

        /* Not successful */
        pstPluginInfo = orxNULL;
      }
    }
    else
    {
      /* Logs message */
      orxDEBUG_PRINT(orxDEBUG_LEVEL_PLUGIN, "Invalid function bank.");

      /* Frees previously allocated data */
      orxBank_Free(sstPlugin.pstPluginBank, pstPluginInfo);

      /* Not successful */
      pstPluginInfo = orxNULL;
    }
  }

  /* Done! */
  return pstPluginInfo;
}
Exemple #3
0
/** Deletes a plugin info
 * @param[in] _pstPluginInfo          Concerned plugin info
 */
static void orxFASTCALL orxPlugin_DeletePluginInfo(orxPLUGIN_INFO *_pstPluginInfo)
{
  orxPLUGIN_FUNCTION_INFO *pstFunctionInfo;

  /* Checks */
  orxASSERT(_pstPluginInfo != orxNULL);

  /* Deletes all function info */
  for(pstFunctionInfo = (orxPLUGIN_FUNCTION_INFO *)orxBank_GetNext(_pstPluginInfo->pstFunctionBank, orxNULL);
      pstFunctionInfo != orxNULL;
      pstFunctionInfo = (orxPLUGIN_FUNCTION_INFO *)orxBank_GetNext(_pstPluginInfo->pstFunctionBank, orxNULL))
  {
    /* Is it a core function? */
    if(pstFunctionInfo->eFunctionID & orxPLUGIN_KU32_FLAG_CORE_ID)
    {
      /* Registers core function */
      orxPlugin_UnregisterCoreFunction(pstFunctionInfo);
    }

    /* Deletes it */
    orxPlugin_DeleteFunctionInfo(_pstPluginInfo, pstFunctionInfo);
  }

  /* Updates all modules */
  orxPlugin_UpdateAllModule();

  /* Deletes function hash table */
  orxHashTable_Delete(_pstPluginInfo->pstFunctionTable);

  /* Deletes function bank */
  orxBank_Delete(_pstPluginInfo->pstFunctionBank);

  /* Deletes plugin info */
  orxBank_Free(sstPlugin.pstPluginBank, _pstPluginInfo);

#ifdef __orxPLUGIN_DYNAMIC__

  /* Linked to system plugin? */
  if(_pstPluginInfo->pstSysPlugin != orxNULL)
  {
    /* Closes it */
    orxPLUGIN_CLOSE(_pstPluginInfo->pstSysPlugin);
    _pstPluginInfo->pstSysPlugin = orxNULL;
  }

#endif /* __orxPLUGIN_DYNAMIC__ */

  /* Done */
  return;
}
Exemple #4
0
/** Exits from the event module
 */
void orxFASTCALL orxEvent_Exit()
{
  /* Initialized? */
  if(orxFLAG_TEST(sstEvent.u32Flags, orxEVENT_KU32_STATIC_FLAG_READY))
  {
    /* Deletes hashtable */
    orxHashTable_Delete(sstEvent.pstHandlerStorageTable);

    /* Deletes bank */
    orxBank_Delete(sstEvent.pstHandlerStorageBank);

    /* Updates flags */
    orxFLAG_SET(sstEvent.u32Flags, orxEVENT_KU32_STATIC_FLAG_NONE, orxEVENT_KU32_STATIC_MASK_ALL);
  }

  return;
}
Exemple #5
0
/** Delete a hash table.
 * @param[in] _pstHashTable  Hash table to delete.
 * @return      orxSTATUS_SUCCESS / orxSTATUS_FAILURE
 */
orxSTATUS orxFASTCALL orxHashTable_Delete(orxHASHTABLE *_pstHashTable)
{
  /* Checks */
  orxASSERT(_pstHashTable != orxNULL);

  /* Clear hash table (unallocate cells) */
  orxHashTable_Clear(_pstHashTable);

  /* Free bank */
  orxBank_Delete(_pstHashTable->pstBank);

  /* Unallocate memory */
  orxMemory_Free(_pstHashTable);

  /* Done ! */
  return orxSTATUS_SUCCESS;
}
Exemple #6
0
/** Exits from the plugin module
 */
void orxFASTCALL orxPlugin_Exit()
{
  /* Initialized? */
  if(sstPlugin.u32Flags & orxPLUGIN_KU32_STATIC_FLAG_READY)
  {
    /* Deletes plugin list */
    orxPlugin_DeleteAll();

    /* Destroys plugin bank */
    orxBank_Delete(sstPlugin.pstPluginBank);
    sstPlugin.pstPluginBank = orxNULL;

    /* Updates flags */
    sstPlugin.u32Flags &= ~orxPLUGIN_KU32_STATIC_FLAG_READY;
  }
  else
  {
    /* Logs message */
    orxDEBUG_PRINT(orxDEBUG_LEVEL_PLUGIN, "Tried to exit plugin module when it wasn't initialized.");
  }

  return;
}
Exemple #7
0
/** Exits from clock module
 */
void orxFASTCALL orxClock_Exit()
{
  /* Initialized? */
  if(sstClock.u32Flags & orxCLOCK_KU32_STATIC_FLAG_READY)
  {
    /* Deletes all the clocks */
    orxClock_DeleteAll();

    /* Deletes timer bank */
    orxBank_Delete(sstClock.pstTimerBank);
    sstClock.pstTimerBank = orxNULL;

    /* Deletes reference table */
    orxHashTable_Delete(sstClock.pstReferenceTable);

    /* Unregisters structure type */
    orxStructure_Unregister(orxSTRUCTURE_ID_CLOCK);

    /* Updates flags */
    sstClock.u32Flags &= ~orxCLOCK_KU32_STATIC_FLAG_READY;
  }

  return;
}
Exemple #8
0
/** Adds an event handler with user-defined context
 * @param[in] _eEventType           Concerned type of event
 * @param[in] _pfnHandler           Event handler to add
 * @param[in] _pContext             Context that will be stored in events sent to this handler
 * return orxSTATUS_SUCCESS / orxSTATUS_FAILURE
 */
orxSTATUS orxFASTCALL orxEvent_AddHandlerWithContext(orxEVENT_TYPE _eEventType, orxEVENT_HANDLER _pfnEventHandler, void *_pContext)
{
  orxEVENT_HANDLER_STORAGE *pstStorage;
  orxSTATUS                 eResult = orxSTATUS_FAILURE;

  /* Checks */
  orxASSERT(orxFLAG_TEST(sstEvent.u32Flags, orxEVENT_KU32_STATIC_FLAG_READY));
  orxASSERT(_pfnEventHandler != orxNULL);

  /* Gets corresponding storage */
  pstStorage = (_eEventType < orxEVENT_TYPE_CORE_NUMBER) ? sstEvent.astCoreHandlerStorageList[_eEventType] : (orxEVENT_HANDLER_STORAGE *)orxHashTable_Get(sstEvent.pstHandlerStorageTable, _eEventType);

  /* No storage yet? */
  if(pstStorage == orxNULL)
  {
    /* Allocates it */
    pstStorage = (orxEVENT_HANDLER_STORAGE *)orxBank_Allocate(sstEvent.pstHandlerStorageBank);

    /* Success? */
    if(pstStorage != orxNULL)
    {
      /* Creates its bank */
      pstStorage->pstBank = orxBank_Create(orxEVENT_KU32_HANDLER_BANK_SIZE, sizeof(orxEVENT_HANDLER_INFO), orxBANK_KU32_FLAG_NONE, orxMEMORY_TYPE_MAIN);

      /* Success? */
      if(pstStorage->pstBank != orxNULL)
      {
        /* Clears its list */
        orxMemory_Zero(&(pstStorage->stList), sizeof(orxLINKLIST));

        /* Is a core event handler? */
        if(_eEventType < orxEVENT_TYPE_CORE_NUMBER)
        {
          /* Stores it */
          sstEvent.astCoreHandlerStorageList[_eEventType] = pstStorage;
        }
        else
        {
          /* Tries to add it to the table */
          if(orxHashTable_Add(sstEvent.pstHandlerStorageTable, _eEventType, pstStorage) == orxSTATUS_FAILURE)
          {
            /* Deletes its bank */
            orxBank_Delete(pstStorage->pstBank);

            /* Frees storage */
            orxBank_Free(sstEvent.pstHandlerStorageBank, pstStorage);
            pstStorage = orxNULL;
          }
        }
      }
      else
      {
        /* Frees storage */
        orxBank_Free(sstEvent.pstHandlerStorageBank, pstStorage);
        pstStorage = orxNULL;
      }
    }
  }

  /* Valid? */
  if(pstStorage != orxNULL)
  {
    orxEVENT_HANDLER_INFO *pstInfo;

    /* Allocates a new handler info */
    pstInfo = (orxEVENT_HANDLER_INFO *)orxBank_Allocate(pstStorage->pstBank);

    /* Valid? */
    if(pstInfo != orxNULL)
    {
      /* Clears its node */
      orxMemory_Zero(&(pstInfo->stNode), sizeof(orxLINKLIST_NODE));

      /* Stores its handler */
      pstInfo->pfnHandler = _pfnEventHandler;

      /* Stores context */
      pstInfo->pContext = _pContext;

      /* Adds it to the list */
      eResult = orxLinkList_AddEnd(&(pstStorage->stList), &(pstInfo->stNode));
    }
  }

  /* Done! */
  return eResult;
}
Exemple #9
0
/** Deletes a clock
 * @param[in]   _pstClock                             Concerned clock
 * @return      orxSTATUS_SUCCESS / orxSTATUS_FAILURE
 */
orxSTATUS orxFASTCALL orxClock_Delete(orxCLOCK *_pstClock)
{
  orxSTATUS eResult = orxSTATUS_SUCCESS;

  /* Checks */
  orxASSERT(sstClock.u32Flags & orxCLOCK_KU32_STATIC_FLAG_READY);
  orxSTRUCTURE_ASSERT(_pstClock);

  /* Decreases counter */
  orxStructure_DecreaseCounter(_pstClock);

  /* Not referenced? */
  if(orxStructure_GetRefCounter(_pstClock) == 0)
  {
    /* Not locked? */
    if(!orxStructure_TestFlags(_pstClock, orxCLOCK_KU32_FLAG_UPDATE_LOCK))
    {
      orxCLOCK_TIMER_STORAGE *pstTimerStorage;

      /* For all stored timers */
      for(pstTimerStorage = (orxCLOCK_TIMER_STORAGE *)orxLinkList_GetFirst(&(_pstClock->stTimerList));
          pstTimerStorage != orxNULL;
          pstTimerStorage = (orxCLOCK_TIMER_STORAGE *)orxLinkList_GetFirst(&(_pstClock->stTimerList)))
      {
        /* Removes it */
        orxLinkList_Remove(&(pstTimerStorage->stNode));

        /* Deletes it */
        orxBank_Free(sstClock.pstTimerBank, pstTimerStorage);
      }

      /* Deletes function bank */
      orxBank_Delete(_pstClock->pstFunctionBank);

      /* Is referenced? */
      if(orxStructure_TestFlags(_pstClock, orxCLOCK_KU32_FLAG_REFERENCED))
      {
        /* Removes it from reference table */
        orxHashTable_Remove(sstClock.pstReferenceTable, orxString_ToCRC(_pstClock->zReference));
      }

      /* Has reference? */
      if(_pstClock->zReference != orxNULL)
      {
        /* Unprotects it */
        orxConfig_ProtectSection(_pstClock->zReference, orxFALSE);
      }

      /* Deletes clock */
      orxStructure_Delete(_pstClock);
    }
    else
    {
      /* Increases counter */
      orxStructure_IncreaseCounter(_pstClock);

      /* Logs message */
      orxDEBUG_PRINT(orxDEBUG_LEVEL_CLOCK, "Can't delete clock <%s> as it's currently locked for processing!", orxStructure_TestFlags(_pstClock, orxCLOCK_KU32_FLAG_REFERENCED) ? _pstClock->zReference : orxSTRING_EMPTY);

      /* Updates result */
      eResult = orxSTATUS_FAILURE;
    }
  }
  else
  {
    /* Referenced by others */
    eResult = orxSTATUS_FAILURE;
  }

  /* Done! */
  return eResult;
}
Exemple #10
0
/** Inits clock module
 * @return orxSTATUS_SUCCESS / orxSTATUS_FAILURE
 */
orxSTATUS orxFASTCALL orxClock_Init()
{
  orxSTATUS eResult = orxSTATUS_FAILURE;

  /* Not already Initialized? */
  if(!(sstClock.u32Flags & orxCLOCK_KU32_STATIC_FLAG_READY))
  {
    /* Registers structure type */
    eResult = orxSTRUCTURE_REGISTER(CLOCK, orxSTRUCTURE_STORAGE_TYPE_LINKLIST, orxMEMORY_TYPE_MAIN, orxCLOCK_KU32_BANK_SIZE, orxNULL);

    /* Successful? */
    if(eResult != orxSTATUS_FAILURE)
    {
      /* Cleans control structure */
      orxMemory_Zero(&sstClock, sizeof(orxCLOCK_STATIC));

      /* Creates timer bank */
      sstClock.pstTimerBank = orxBank_Create(orxCLOCK_KU32_TIMER_BANK_SIZE, sizeof(orxCLOCK_TIMER_STORAGE), orxBANK_KU32_FLAG_NONE, orxMEMORY_TYPE_MAIN);

      /* Valid? */
      if(sstClock.pstTimerBank != orxNULL)
      {
        /* Creates reference table */
        sstClock.pstReferenceTable = orxHashTable_Create(orxCLOCK_KU32_REFERENCE_TABLE_SIZE, orxHASHTABLE_KU32_FLAG_NONE, orxMEMORY_TYPE_MAIN);

        /* Valid? */
        if(sstClock.pstReferenceTable != orxNULL)
        {
          orxCLOCK *pstClock;

          /* No mod type by default */
          sstClock.eModType = orxCLOCK_MOD_TYPE_NONE;

          /* Gets init time */
          sstClock.dTime  = orxSystem_GetTime();

          /* Inits Flags */
          sstClock.u32Flags = orxCLOCK_KU32_STATIC_FLAG_READY;

          /* Gets main clock tick size */
          orxConfig_PushSection(orxCLOCK_KZ_CONFIG_SECTION);
          sstClock.fMainClockTickSize = (orxConfig_HasValue(orxCLOCK_KZ_CONFIG_MAIN_CLOCK_FREQUENCY) && orxConfig_GetFloat(orxCLOCK_KZ_CONFIG_MAIN_CLOCK_FREQUENCY) > orxFLOAT_0) ? (orxFLOAT_1 / orxConfig_GetFloat(orxCLOCK_KZ_CONFIG_MAIN_CLOCK_FREQUENCY)) : orxFLOAT_0;
          orxConfig_PopSection();

          /* Creates default full speed core clock */
          pstClock = orxClock_Create(sstClock.fMainClockTickSize, orxCLOCK_TYPE_CORE);

          /* Success? */
          if(pstClock != orxNULL)
          {
            /* Sets it as its own owner */
            orxStructure_SetOwner(pstClock, pstClock);

            /* Updates result */
            eResult = orxSTATUS_SUCCESS;
          }
          else
          {
            /* Updates result */
            eResult = orxSTATUS_FAILURE;
          }
        }
        else
        {
          /* Deletes timer bank */
          orxBank_Delete(sstClock.pstTimerBank);
          sstClock.pstTimerBank = orxNULL;

          /* Updates result */
          eResult = orxSTATUS_FAILURE;
        }
      }
      else
      {
        /* Logs message */
        orxDEBUG_PRINT(orxDEBUG_LEVEL_CLOCK, "Failed creating clock bank.");

        /* Clock bank not created */
        eResult = orxSTATUS_FAILURE;
      }
    }
    else
    {
      /* Logs message */
      orxDEBUG_PRINT(orxDEBUG_LEVEL_OBJECT, "Failed to register link list structure.");
    }
  }
  else
  {
    /* Logs message */
    orxDEBUG_PRINT(orxDEBUG_LEVEL_CLOCK, "Tried to initialize clock module when it was already initialized.");

    /* Already initialized */
    eResult = orxSTATUS_SUCCESS;
  }

  /* Done! */
  return eResult;
}