<commit_before>#include <Internal/DoremiEngineImplementation.hpp>
#include <Subsystem/EngineModuleEnum.hpp>

#include <DoremiEngine/Audio/Include/AudioModule.hpp>
#include <DoremiEngine/Physics/Include/PhysicsModule.hpp>
#include <DoremiEngine/Graphic/Include/GraphicModule.hpp>
#include <DoremiEngine/Network/Include/NetworkModule.hpp>
#include <DoremiEngine/Input/Include/InputModule.hpp>
#include <DoremiEngine/AI/Include/AIModule.hpp>
#include <Utility/DynamicLoader/Include/DynamicLoader.hpp>

#include <Internal/SharedContextImplementation.hpp>
#include <Windows.h>
namespace DoremiEngine
{
    namespace Core
    {
        DoremiEngineImplementation::DoremiEngineImplementation()
            : m_audioLibrary(nullptr),
              m_graphicLibrary(nullptr),
              m_networkLibrary(nullptr),
              m_physicsLibrary(nullptr),
              m_inputLibrary(nullptr),
              m_audioModule(nullptr),
              m_graphicModule(nullptr),
              m_networkModule(nullptr),
              m_physicsModule(nullptr),
              m_inputModule(nullptr),
              m_aiModule(nullptr)
        {
        }

        DoremiEngineImplementation::~DoremiEngineImplementation()
        {
            if(m_audioModule != nullptr)
            {
                delete m_audioModule;
            }

            if(m_graphicModule != nullptr)
            {
                delete m_graphicModule;
            }

            // TODORT
            //    if (m_networkModule != nullptr)
            //    {
            //        delete m_networkModule;
            //    }

            if(m_physicsModule != nullptr)
            {
                delete m_physicsModule;
            }

            if(m_audioLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_audioLibrary);
            }
            if(m_graphicLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_graphicLibrary);
            }
            if(m_networkLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_networkLibrary);
            }
            if(m_physicsLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_physicsLibrary);
            }
            if(m_aiLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_aiLibrary);
            }
        }

        SharedContext& DoremiEngineImplementation::Start(const size_t& p_flags)
        {
            m_sharedContext = new SharedContextImplementation();
            m_sharedContext->SetCoreModule(this);
            BuildWorkingDirectory(*m_sharedContext);

            if((p_flags & EngineModuleEnum::AUDIO) == EngineModuleEnum::AUDIO)
            {
                LoadAudioModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::GRAPHIC) == EngineModuleEnum::GRAPHIC)
            {
                LoadGraphicModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::NETWORK) == EngineModuleEnum::NETWORK)
            {
                LoadNetworkModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::PHYSICS) == EngineModuleEnum::PHYSICS)
            {
                LoadPhysicsModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::INPUT) == EngineModuleEnum::INPUT)
            {
                LoadInputModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::AI) == EngineModuleEnum::AI)
            {
                LoadAIModule(*m_sharedContext);
            }
            return *m_sharedContext;
        }

        void DoremiEngineImplementation::Stop()
        {
            if(m_audioModule != nullptr)
            {
                m_audioModule->Shutdown();
            }

            if(m_graphicModule != nullptr)
            {
                m_graphicModule->Shutdown();
            }

            // TODORT
            //    if (m_networkModule != nullptr)
            //    {
            //        m_networkModule->Shutdown();
            //    }

            if(m_physicsModule != nullptr)
            {
                m_physicsModule->Shutdown();
            }

            if(m_aiModule != nullptr)
            {
                m_aiModule->Shutdown();
            }
        }

        void DoremiEngineImplementation::BuildWorkingDirectory(SharedContextImplementation& o_sharedContext)
        {
            char path[254];
            GetModuleFileNameA(NULL, path, 254);
            std::string* directoryPath = new std::string(path);
            o_sharedContext.SetWorkingDirectory(directoryPath->substr(0, directoryPath->length() - 10));
        }

        void DoremiEngineImplementation::LoadAudioModule(SharedContextImplementation& o_sharedContext)
        {
            m_audioLibrary = DynamicLoader::LoadSharedLibrary("Audio.dll");<commit_msg>Properly shutting down network module on shutdown<commit_after>#include <Internal/DoremiEngineImplementation.hpp>
#include <Subsystem/EngineModuleEnum.hpp>

#include <DoremiEngine/Audio/Include/AudioModule.hpp>
#include <DoremiEngine/Physics/Include/PhysicsModule.hpp>
#include <DoremiEngine/Graphic/Include/GraphicModule.hpp>
#include <DoremiEngine/Network/Include/NetworkModule.hpp>
#include <DoremiEngine/Input/Include/InputModule.hpp>
#include <DoremiEngine/AI/Include/AIModule.hpp>
#include <Utility/DynamicLoader/Include/DynamicLoader.hpp>

#include <Internal/SharedContextImplementation.hpp>
#include <Windows.h>
namespace DoremiEngine
{
    namespace Core
    {
        DoremiEngineImplementation::DoremiEngineImplementation()
            : m_audioLibrary(nullptr),
              m_graphicLibrary(nullptr),
              m_networkLibrary(nullptr),
              m_physicsLibrary(nullptr),
              m_inputLibrary(nullptr),
              m_audioModule(nullptr),
              m_graphicModule(nullptr),
              m_networkModule(nullptr),
              m_physicsModule(nullptr),
              m_inputModule(nullptr),
              m_aiModule(nullptr)
        {
        }

        DoremiEngineImplementation::~DoremiEngineImplementation()
        {
            if(m_audioModule != nullptr)
            {
                delete m_audioModule;
            }

            if(m_graphicModule != nullptr)
            {
                delete m_graphicModule;
            }

            if(m_networkModule != nullptr)
            {
                delete m_networkModule;
            }

            if(m_physicsModule != nullptr)
            {
                delete m_physicsModule;
            }

            if(m_audioLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_audioLibrary);
            }
            if(m_graphicLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_graphicLibrary);
            }
            if(m_networkLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_networkLibrary);
            }
            if(m_physicsLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_physicsLibrary);
            }
            if(m_aiLibrary != nullptr)
            {
                DynamicLoader::FreeSharedLibrary(m_aiLibrary);
            }
        }

        SharedContext& DoremiEngineImplementation::Start(const size_t& p_flags)
        {
            m_sharedContext = new SharedContextImplementation();
            m_sharedContext->SetCoreModule(this);
            BuildWorkingDirectory(*m_sharedContext);

            if((p_flags & EngineModuleEnum::AUDIO) == EngineModuleEnum::AUDIO)
            {
                LoadAudioModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::GRAPHIC) == EngineModuleEnum::GRAPHIC)
            {
                LoadGraphicModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::NETWORK) == EngineModuleEnum::NETWORK)
            {
                LoadNetworkModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::PHYSICS) == EngineModuleEnum::PHYSICS)
            {
                LoadPhysicsModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::INPUT) == EngineModuleEnum::INPUT)
            {
                LoadInputModule(*m_sharedContext);
            }

            if((p_flags & EngineModuleEnum::AI) == EngineModuleEnum::AI)
            {
                LoadAIModule(*m_sharedContext);
            }
            return *m_sharedContext;
        }

        void DoremiEngineImplementation::Stop()
        {
            if(m_audioModule != nullptr)
            {
                m_audioModule->Shutdown();
            }

            if(m_graphicModule != nullptr)
            {
                m_graphicModule->Shutdown();
            }

            if(m_networkModule != nullptr)
            {
                m_networkModule->Shutdown();
            }

            if(m_physicsModule != nullptr)
            {
                m_physicsModule->Shutdown();
            }

            if(m_aiModule != nullptr)
            {
                m_aiModule->Shutdown();
            }
        }

        void DoremiEngineImplementation::BuildWorkingDirectory(SharedContextImplementation& o_sharedContext)
        {
            char path[254];
            GetModuleFileNameA(NULL, path, 254);
            std::string* directoryPath = new std::string(path);
            o_sharedContext.SetWorkingDirectory(directoryPath->substr(0, directoryPath->length() - 10));
        }

        void DoremiEngineImplementation::LoadAudioModule(SharedContextImplementation& o_sharedContext)
        {
            m_audioLibrary = DynamicLoader::LoadSharedLibrary("Audio.dll");
{'fraction_non_alphanumeric': 0.09194699286442405, 'fraction_numerical': 0.001834862385321101, 'mean_word_length': 1.7551249648975007, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5935589', 'n_tokens_mistral': 2603, 'n_tokens_neox': 2514, 'n_words': 293}