void ScriptComponent::Initialize() { if (m_pFileName != nullptr) { IFile *pFile = MediaManager::Instance().FindMedia(m_pFileName, false); SetScriptFromBuffer(pFile->GetBuffer(), pFile->GetBufferLength()); DELETE_AO pFile; //TODO crash //Game::Instance()->GetScriptEngine()->SetField(GetEntity(), "entity"); //call function OnScriptInitialize() //Game::Instance()->GetScriptEngine()->CallFunction("OnScriptInitialize"); } }
//! OGG callback to read from a binary stream in memory. size_t AudioEngine::OggRead(void *ptr, size_t size, size_t read, void *memory_ptr) { unsigned int seof, pos; IFile *file = (IFile *) memory_ptr; seof = file->GetBufferLength() - file->Position(); pos = ((read * size) < seof) ? pos = read * size : pos = seof; if (pos) { //memcpy(ptr, memory->buffer + memory->position, pos ); //memory->position += pos; } return pos; }