//===========================================================================//
// File:	 MFCPlatform.cpp												 //
// Project:  GameOS					                                         //
// Contents: Setup GameOS with MFC											 //
//---------------------------------------------------------------------------//
// Date      Who    Modification                                             //
// 02/15/99  AG     Created													 //
//===========================================================================//
#include "MFCPlatform.hpp"

// [editor modern-Windows fix] Disable DirectInput joystick enumeration for the hosted
// (MFC/editor) platform. On Win11, the legacy IDirectInput7 joystick enumeration path
// corrupts the heap inside modern dinput.dll while Release()-ing a phantom/virtual HID
// device (see ControlManager.cpp CMCreateJoystick7), crashing editor startup. Setting this
// here avoids needing the /gosnojoystick command-line switch, which is fragile in LAB_ONLY
// builds (WinMain.cpp line ~398 shows a help dialog and exits if any leftover "/gos" token
// remains on the command line). The game uses a different platform path and is unaffected.
extern DWORD gDisableJoystick;

void InitGameOS( HINSTANCE hInstance, HWND hWnd, char* CommandLine )
{
	Platform=Platform_MFC;
	gDisableJoystick=1;
	RunFromOtherApp( hInstance, hWnd, CommandLine );
}

//
// Memory management API's shouldn't occur in DLLPlatform project.
//
void* __cdecl operator new (size_t size, HGOSHEAP Heap)
{
	return gos_Malloc( size , Heap );
}

void* __cdecl operator new (size_t size)
{
	// 0xffffffff specifies use of the heap set by CurrentHeapLevel
	return gos_Malloc( size , (HGOSHEAP) 0xffffffff );
}


void __cdecl operator delete ( void* ptr )
{
	gos_Free((char*) ptr);
}


