From f4e6004b7fc318258d4e1a7adb7e46da9703c902 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sun, 27 Jan 2019 23:55:35 +0000 Subject: [PATCH] small fixes for API changes FossilOrigin-Name: afc116b3fb97e8fdf3537adb93b43c888700146d003ff19e3bdca45dabc369a4 --- packages/Generator/RoomGenT0B.vc | 2 +- packages/Sprites/BackTileStore.vc | 10 +++++----- packages/Sprites/SpriteStore.vc | 6 +++--- pxcdtest.vc | 2 +- pxcdtest1.vc | 2 +- spelunky_main.vc | 12 +++++++++--- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/packages/Generator/RoomGenT0B.vc b/packages/Generator/RoomGenT0B.vc index b7d4d06..fc3516a 100644 --- a/packages/Generator/RoomGenT0B.vc +++ b/packages/Generator/RoomGenT0B.vc @@ -529,7 +529,7 @@ int bizGetProbBase (name aname) { int bizGetProb (name aname) { if (!aname) return 0; - int aid = NameToInt(aname); + int aid = NameToIIndex(aname); if (aid > 0 && aid < bzprobs.length && bzprobs[aid] >= 0) return bzprobs[aid]; auto global = levgen.global; diff --git a/packages/Sprites/BackTileStore.vc b/packages/Sprites/BackTileStore.vc index a4fc8ed..fe02f15 100644 --- a/packages/Sprites/BackTileStore.vc +++ b/packages/Sprites/BackTileStore.vc @@ -209,16 +209,16 @@ private final void loadTile (name Name) { auto bgtile = BackTileImage.Load(va("%s/%n.tile", tilePath, Name)); if (!bgtile) FatalError("cannot load sprite '%n'", Name); - bgbyid[NameToInt(bgtile.Name)] = bgtile; + bgbyid[NameToIIndex(bgtile.Name)] = bgtile; if (bDumpLoaded) { - writeln("bgtile: <", bgtile.Name, ">, id=", NameToInt(bgtile.Name), "; size=", bgtile.tex.width, "x", bgtile.tex.height); + writeln("bgtile: <", bgtile.Name, ">, id=", NameToIIndex(bgtile.Name), "; size=", bgtile.tex.width, "x", bgtile.tex.height); } } final BackTileImage opIndex (name Name) { - int id = NameToInt(Name); + int id = NameToIIndex(Name); if (id <= 0) return none; // just in case if (id >= bgbyid.length || !bgbyid[id]) loadTile(Name); return (id >= 0 && id < bgbyid.length ? bgbyid[id] : none); @@ -227,7 +227,7 @@ final BackTileImage opIndex (name Name) { final BackTileImage lightTexture (name aname, int radius) { if (!aname || radius < 8) return none; - int id = NameToInt(aname); + int id = NameToIIndex(aname); if (id <= 0) return none; // just in case if (id >= bgbyid.length || !bgbyid[id]) { writeln("creating light texture with raduis ", radius); @@ -240,7 +240,7 @@ final BackTileImage lightTexture (name aname, int radius) { final BackTileImage circleTexture (name aname, int radius) { if (!aname || radius < 8) return none; - int id = NameToInt(aname); + int id = NameToIIndex(aname); if (id <= 0) return none; // just in case if (id >= bgbyid.length || !bgbyid[id]) { auto bi = BackTileImage.buildCircleTexture(aname, radius); diff --git a/packages/Sprites/SpriteStore.vc b/packages/Sprites/SpriteStore.vc index 64e4833..3358620 100644 --- a/packages/Sprites/SpriteStore.vc +++ b/packages/Sprites/SpriteStore.vc @@ -563,10 +563,10 @@ private final void loadSprite (name Name) { auto spr = SpriteImage.Load(va("%s/%n.spr", sprPath, Name), (allowNPot > 0)); if (!spr) FatalError("cannot load sprite '%n'", Name); - sprbyid[NameToInt(/*spr.*/Name)] = spr; + sprbyid[NameToIIndex(/*spr.*/Name)] = spr; if (bDumpLoaded) { - writeln("sprite: <", spr.Name, ">, ", spr.frames.length, " frames; id=", NameToInt(spr.Name)); + writeln("sprite: <", spr.Name, ">, ", spr.frames.length, " frames; id=", NameToIIndex(spr.Name)); foreach (auto fidx, SpriteFrame frm; spr.frames) { writeln(" === FRAME #", fidx, " ==="); //writeln(" name: <", frm.Name, ">"); @@ -874,7 +874,7 @@ final void renderMultilineText (int x, int y, string str, optional int scale, op final SpriteImage opIndex (name Name) { - int id = NameToInt(Name); + int id = NameToIIndex(Name); if (id <= 0) return none; // just in case if (id >= sprbyid.length || !sprbyid[id]) loadSprite(Name); return (id >= 0 && id < sprbyid.length ? sprbyid[id] : none); diff --git a/pxcdtest.vc b/pxcdtest.vc index 1ad3bd3..9b03082 100644 --- a/pxcdtest.vc +++ b/pxcdtest.vc @@ -184,7 +184,7 @@ final void onEvent (ref event_t evt) { return; } - if (evt.type == ev_mouse) { + if (evt.type == ev_uimouse) { //writeln("!!!! x=", evt.x, "; y=", evt.y); spr0x = (evt.x&~1)-16*3; spr0y = (evt.y&~1)-16*3; diff --git a/pxcdtest1.vc b/pxcdtest1.vc index f5e863a..4ae1d51 100644 --- a/pxcdtest1.vc +++ b/pxcdtest1.vc @@ -216,7 +216,7 @@ final void onEvent (ref event_t evt) { return; } - if (evt.type == ev_mouse) { + if (evt.type == ev_uimouse) { //writeln("!!!! x=", evt.x, "; y=", evt.y); spr0x = evt.x; spr0y = evt.y; diff --git a/spelunky_main.vc b/spelunky_main.vc index 5352163..77d53bc 100644 --- a/spelunky_main.vc +++ b/spelunky_main.vc @@ -1676,7 +1676,7 @@ final void onEvent (ref event_t evt) { return; } - if (evt.type == ev_mouse) { + if (evt.type == ev_uimouse) { mouseX = evt.x; mouseY = evt.y; calcMouseMapCoords(); @@ -1719,7 +1719,7 @@ final void onEvent (ref event_t evt) { } #ifdef MASK_TEST - if (evt.type == ev_mouse) { + if (evt.type == ev_uimouse) { maskSX = evt.x/global.config.scale; maskSY = evt.y/global.config.scale; return; @@ -2323,7 +2323,7 @@ final void checkGameObjNames () { auto gn = GetClassGameObjName(cc); if (gn) { //writeln("'", gn, "' is `", GetClassName(cc), "`"); - auto nid = NameToInt(gn); + auto nid = NameToIIndex(gn); if (nid < known.length && known[nid]) FatalError("duplicate game object name '%n' (defined for class is '%n', redefined in class '%n')", gn, GetClassName(known[nid]), GetClassName(cc)); known[nid] = cc; ++namedCount; @@ -2513,5 +2513,11 @@ void main (ref array!string args) { loadGameOptions(); loadKeyboardBindings(); + + // force "immediate delete" mode, it is faster + GC_ImmediateDelete = false; + GC_CollectGarbage(true); // destroy delayed objects too + GC_ImmediateDelete = true; + runGameLoop(); } -- 2.11.4.GIT