Skip to content

Commit dada6cb

Browse files
committed
Merge branch 'AP-CustomEx' of https://github.com/Z11Coding/Mixtape-Engine-Rework into AP-CustomEx
2 parents e6cf07f + 4a97631 commit dada6cb

File tree

17 files changed

+524
-312
lines changed

17 files changed

+524
-312
lines changed

Project.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@
223223
<!--Disable the Flixel sound management code-->
224224
<!--<haxedef name="FLX_NO_SOUND_SYSTEM" />-->
225225

226+
<haxedef name="analyzer-optimize" unless="debug" />
227+
226228
<!--Optimise inputs, be careful you will get null errors if you don't use conditionals in your game-->
227229
<haxedef name="FLX_NO_TOUCH" if="desktop" />
228230

@@ -240,11 +242,12 @@
240242

241243
<!--Used for Izzy Engine's crash handler-->
242244
<section if="cpp">
245+
<haxedef name="HXCPP_M32" if="32bit" />
246+
<haxedef name="HXCPP_DEBUG_LINK" if="debug" />
243247
<haxedef name="HXCPP_CHECK_POINTER" />
244248
<haxedef name="HXCPP_STACK_LINE" />
245249
<haxedef name="HXCPP_STACK_TRACE" />
246250
<haxedef name="HXCPP_CATCH_SEGV" />
247-
<haxedef name="HXCPP_GC_DISABLE" />
248251
</section>
249252

250253
<section if="desktop">

source/Main.hx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ class Main extends Sprite
296296
// "NativeTrace works with double quotes too!".NativeTrace(true);
297297
// testArray.NativeTrace(true, false);
298298

299+
#if windows
300+
backend.window.CppAPI.setWindowOpacity(1);
301+
#end
299302

300303

301304

source/backend/Paths.hx

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ import openfl.system.System;
1919
import openfl.utils.AssetType;
2020
import openfl.utils.Assets as OpenFlAssets;
2121

22+
#if cpp
23+
import cpp.vm.Gc;
24+
#elseif hl
25+
import hl.Gc;
26+
#end
27+
2228
#if MODS_ALLOWED
2329
import backend.Mods;
2430
#end
@@ -223,21 +229,57 @@ class Paths
223229
}
224230

225231
// The "If All Else Fails" option
226-
public static function nukeMemory(){
227-
try {
232+
// The "If All Else Fails" option
233+
public static function nukeMemory(?useAlt:Bool = true){
234+
if (useAlt) {
228235
clearStoredWithoutStickers();
229-
freeGraphicsFromMemory();
230-
Paths.clearStoredMemory();
231-
Paths.clearUnusedMemory();
232-
//MemoryUtilBase.compact();
233-
//MemoryUtilBase.collect(true);
234-
currentTrackedSounds.clear();
235-
@:privateAccess {
236-
for (key => asset in FlxG.bitmap._cache)
237-
asset.destroy();
236+
237+
#if cpp
238+
var killZombies:Bool = true;
239+
240+
while (killZombies)
241+
{
242+
var zombie = Gc.getNextZombie();
243+
244+
if (zombie == null)
245+
{
246+
killZombies = false;
247+
} else {
248+
var closeMethod = Reflect.field(zombie, "close");
249+
250+
if (closeMethod != null && Reflect.isFunction(closeMethod))
251+
closeMethod.call(zombie, []);
252+
}
253+
}
254+
255+
Gc.run(true);
256+
Gc.compact();
257+
#end
258+
259+
#if hl
260+
Gc.major();
261+
#end
262+
263+
FlxG.bitmap.clearUnused();
264+
FlxG.bitmap.clearCache();
265+
266+
//super.destroy();
267+
} else {
268+
try {
269+
clearStoredWithoutStickers();
270+
freeGraphicsFromMemory();
271+
Paths.clearStoredMemory();
272+
Paths.clearUnusedMemory();
273+
//MemoryUtilBase.compact();
274+
//MemoryUtilBase.collect(true);
275+
currentTrackedSounds.clear();
276+
@:privateAccess {
277+
for (key => asset in FlxG.bitmap._cache)
278+
asset.destroy();
279+
}
280+
} catch(e) {
281+
trace('ERROR: Couldn\'t' );
238282
}
239-
} catch(e) {
240-
trace('ERROR: Couldn\'t' );
241283
}
242284
}
243285

0 commit comments

Comments
 (0)