diff --git a/language.version b/language.version index 702eb85a7..da8d16070 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\chSWWM \czGZ\c- \cw1.2pre r7 \cu(Sun 3 Oct 14:36:51 CEST 2021)\c-"; -SWWM_SHORTVER="\cw1.2pre r7 \cu(2021-10-03 14:36:51)\c-"; +SWWM_MODVER="\chSWWM \czGZ\c- \cw1.2pre r7 \cu(Sun 3 Oct 23:49:20 CEST 2021)\c-"; +SWWM_SHORTVER="\cw1.2pre r7 \cu(2021-10-03 23:49:20)\c-"; diff --git a/zscript/handler/swwm_handler_worldtick.zsc b/zscript/handler/swwm_handler_worldtick.zsc index 61f5d20b1..f3224011f 100644 --- a/zscript/handler/swwm_handler_worldtick.zsc +++ b/zscript/handler/swwm_handler_worldtick.zsc @@ -18,6 +18,7 @@ extend Class SWWMHandler String lastmus; int lastorder; bool lastloop; + transient ThinkerIterator cti; private void LangRefresh() { @@ -94,9 +95,10 @@ extend Class SWWMHandler } bool enteredcombat = false; // add new entries - let ti = ThinkerIterator.Create("Actor"); + if ( !cti ) cti = ThinkerIterator.Create("Actor"); + else cti.Reinit(); Actor a; - while ( a = Actor(ti.Next()) ) + while ( a = Actor(cti.Next()) ) { if ( !a.player && !a.bISMONSTER ) continue; // ignore the dead @@ -221,7 +223,7 @@ extend Class SWWMHandler // "simple" tracking (used by the minimap) private void SimpleTracking() { - if ( !swwm_mm_enable ) + if ( (gamestate != GS_LEVEL) || !swwm_mm_enable ) { while ( strackers ) { @@ -283,6 +285,7 @@ extend Class SWWMHandler continue; SWWMSimpleTracker.Track(a); } + bt.Destroy(); if ( swwm_mm_portaloverlay && (psectors.Size() > 1) ) { // oh boy here we go @@ -291,6 +294,7 @@ extend Class SWWMHandler { if ( i == thisgroup ) continue; Vector2 relpos = players[consoleplayer].Camera.pos.xy+SWWMUtility.PortalDisplacement(level.Sectors[psectors[thisgroup]],level.Sectors[psectors[i]]); + if ( bt ) bt.Destroy(); bt = BlockThingsIterator.CreateFromPos(relpos.x,relpos.y,players[consoleplayer].Camera.pos.z,players[consoleplayer].Camera.pos.z+players[consoleplayer].Camera.height,viewdist,false); while ( bt.Next() ) { diff --git a/zscript/hud/swwm_hud.zsc b/zscript/hud/swwm_hud.zsc index 7a20f4034..63db785b9 100644 --- a/zscript/hud/swwm_hud.zsc +++ b/zscript/hud/swwm_hud.zsc @@ -2490,6 +2490,7 @@ Class SWWMStatusBar : BaseStatusBar Screen.DrawText(fnt,msg0color,xx,yy+2,l.StringAt(j),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); yy -= h; } + l.Destroy(); yy -= 6; } } @@ -2520,6 +2521,7 @@ Class SWWMStatusBar : BaseStatusBar Screen.DrawText(fnt,col,int(xx),yy+2,l.StringAt(i),DTA_VirtualWidthF,ss.x*ssp,DTA_VirtualHeightF,ss.y*ssp,DTA_KeepRatio,true,DTA_Alpha,alph); yy += h; } + l.Destroy(); } if ( MainQueue.Size() <= 0 ) return; int mstart = max(0,MainQueue.Size()-((chatopen>=gametic)?swwm_maxshownbig:swwm_maxshown)); @@ -2547,6 +2549,7 @@ Class SWWMStatusBar : BaseStatusBar Screen.DrawText(fnt,col,xx+4,yy,l.StringAt(j),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); yy += 13; } + l.Destroy(); } Screen.DrawTexture(ChatTex[smol?5:2],false,xx,yy,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,boxalph); } diff --git a/zscript/hud/swwm_hudextra.zsc b/zscript/hud/swwm_hudextra.zsc index 2e29e2cf7..e91ac9701 100644 --- a/zscript/hud/swwm_hudextra.zsc +++ b/zscript/hud/swwm_hudextra.zsc @@ -111,6 +111,7 @@ Class SWWMOneLiner : HUDMessageBase Screen.DrawText(fnt,Font.CR_FIRE,int((ss.x-len)/2.),(bottom/hs.y)-yy,l.StringAt(i),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); yy -= h; } + l.Destroy(); } } @@ -214,6 +215,7 @@ Class SWWMAchievementNotification : HUDMessageBase Screen.DrawText(fnt2,Font.CR_WHITE,pos.x+44,pos.y+yy,l.StringAt(i),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alpha); yy += 9; } + l.Destroy(); } } @@ -379,6 +381,7 @@ Class SWWMDirectMessage : HUDMessageBase txt = String.Format(StringTable.Localize("$SWWM_"..seqname..seqnum),nyears); } else txt = StringTable.Localize("$SWWM_"..seqname..seqnum); + if ( l ) l.Destroy(); l = fnt.BreakLines(txt,220); // append to the player's chat log (if it's valid) if ( (seqnum < 1) || (seqnum > seqcnt) ) return; diff --git a/zscript/kbase/OLD_swwm_kbase.zsc b/zscript/kbase/OLD_swwm_kbase.zsc index 375d4d789..b32beedf6 100644 --- a/zscript/kbase/OLD_swwm_kbase.zsc +++ b/zscript/kbase/OLD_swwm_kbase.zsc @@ -516,12 +516,17 @@ Class DemolitionistMenu : GenericMenu else kstr = self.mkey[0]; String str = String.Format(StringTable.Localize("$SWWM_HELPTXT"),kstr); BrokenLines l = fnt.BreakLines(str,629); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,620); + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,620); + } if ( (l.Count() > 28) && (sel0 < l.Count()-28) ) { MenuSound("menu/demoscroll"); sel0++; } + l.Destroy(); } else if ( tabs[curtab] == TAB_MISSION ) { @@ -529,12 +534,17 @@ Class DemolitionistMenu : GenericMenu if ( sel1 == 0 ) str = StringTable.Localize(missionstr); else str = StringTable.Localize(missionbacklog[sel1-1]); BrokenLines l = fnt.BreakLines(str,629); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,620); + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,620); + } if ( (l.Count() > 28) && (sel0 < l.Count()-28) ) { MenuSound("menu/demoscroll"); ofs0 = ++sel0; } + l.Destroy(); } else if ( (tabs[curtab] == TAB_CHAT) && (StatusBar is 'SWWMStatusBar') && (sel0 > 0) ) { @@ -549,12 +559,17 @@ Class DemolitionistMenu : GenericMenu int ofs = (language~=="jp")?212:132; if ( lorelist.Size() > 26 ) ofs += 8; BrokenLines l = fnt.BreakLines(str,635-ofs); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,626-ofs); + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,626-ofs); + } if ( (l.Count() > 28) && (sel2 < l.Count()-28) ) { MenuSound("menu/demoscroll"); ofs2 = ++sel2; } + l.Destroy(); } else { @@ -1069,10 +1084,19 @@ Class DemolitionistMenu : GenericMenu if ( sel1 == 0 ) str = StringTable.Localize(missionstr); else str = StringTable.Localize(missionbacklog[sel1-1]); BrokenLines l = fnt.BreakLines(str,629); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,620); - else return res; // no scrollbar + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,620); + } + else + { + l.Destroy(); + return res; // no scrollbar + } // calculate offset int szr = l.Count()-28; + l.Destroy(); int step = clamp(rnd((mpos.y-24.)/(353./szr)),0,szr); if ( step != sel0 ) MenuSound("menu/demoscroll"); ofs0 = sel0 = step; @@ -1451,10 +1475,19 @@ Class DemolitionistMenu : GenericMenu int ofs = (language~=="jp")?212:132; if ( lorelist.Size() > 26 ) ofs += 8; BrokenLines l = fnt.BreakLines(str,635-ofs); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,626-ofs); - else return res; // no scrollbar + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,626-ofs); + } + else + { + l.Destroy(); + return res; // no scrollbar + } // calculate offset int szr = l.Count()-28; + l.Destroy(); int step = clamp(rnd((mpos.y-24.)/(353./szr)),0,szr); if ( step != sel2 ) MenuSound("menu/demoscroll"); ofs2 = sel2 = step; @@ -1566,10 +1599,19 @@ Class DemolitionistMenu : GenericMenu else kstr = mkey[0]; str = String.Format(StringTable.Localize("$SWWM_HELPTXT"),kstr); BrokenLines l = fnt.BreakLines(str,629); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,620); - else return res; // no scrollbar + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,620); + } + else + { + l.Destroy(); + return res; // no scrollbar + } // calculate offset int szr = l.Count()-28; + l.Destroy(); int step = clamp(rnd((mpos.y-24.)/(353./szr)),0,szr); if ( step != sel0 ) MenuSound("menu/demoscroll"); ofs0 = sel0 = step; @@ -1629,10 +1671,19 @@ Class DemolitionistMenu : GenericMenu if ( sel1 == 0 ) str = StringTable.Localize(missionstr); else str = StringTable.Localize(missionbacklog[sel1-1]); BrokenLines l = fnt.BreakLines(str,629); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,620); - else return res; // no scrollbar + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,620); + } + else + { + l.Destroy(); + return res; // no scrollbar + } // calculate offset int szr = l.Count()-28; + l.Destroy(); int step = clamp(rnd((mpos.y-24.)/(353./szr)),0,szr); if ( step != sel0 ) MenuSound("menu/demoscroll"); ofs0 = sel0 = step; @@ -1740,10 +1791,19 @@ Class DemolitionistMenu : GenericMenu int ofs = (language~=="jp")?212:132; if ( lorelist.Size() > 26 ) ofs += 8; BrokenLines l = fnt.BreakLines(str,635-ofs); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,626-ofs); - else return res; // no scrollbar + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,626-ofs); + } + else + { + l.Destroy(); + return res; // no scrollbar + } // calculate offset int szr = l.Count()-28; + l.Destroy(); int step = clamp(rnd((mpos.y-24.)/(353./szr)),0,szr); if ( step != sel2 ) MenuSound("menu/demoscroll"); ofs2 = sel2 = step; @@ -1800,10 +1860,19 @@ Class DemolitionistMenu : GenericMenu String kstr = bindings.NameKeys(k1,k2); str = String.Format(StringTable.Localize("$SWWM_HELPTXT"),kstr); BrokenLines l = fnt.BreakLines(str,629); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,620); - else return res; // no scrollbar + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,620); + } + else + { + l.Destroy(); + return res; // no scrollbar + } // calculate offset int szr = l.Count()-28; + l.Destroy(); int step = clamp(rnd((mpos.y-24.)/(353./szr)),0,szr); if ( step != sel0 ) MenuSound("menu/demoscroll"); ofs0 = sel0 = step; @@ -2942,7 +3011,11 @@ Class DemolitionistMenu : GenericMenu if ( sel1 == 0 ) str = StringTable.Localize(missionstr); else str = StringTable.Localize(missionbacklog[sel1-1]); BrokenLines l = fnt.BreakLines(str,629); - if ( l.Count() > 28 ) l = fnt.BreakLines(str,620); + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,620); + } xx = 6; yy = 17; int ofs = clamp(sel0,0,max(0,l.Count()-28)); @@ -2973,6 +3046,7 @@ Class DemolitionistMenu : GenericMenu str = String.Format("%d \cf/\c- %d",sel1+1,csiz+1); Screen.DrawText(MiniwiFont,Font.CR_FIRE,(origin.x+637)-MiniwiFont.StringWidth(str),origin.y+375,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); } + l.Destroy(); } else if ( tabs[curtab] == TAB_STATS ) { @@ -3172,6 +3246,7 @@ Class DemolitionistMenu : GenericMenu Screen.DrawText(fnt,completed?Font.CR_GREEN:Font.CR_DARKGRAY,origin.x+xx+36,origin.y+yy+oy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); for ( int j=0; j 28 ) l = fnt.BreakLines(str,int(626-xx)); + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,int(626-xx)); + } yy = 17; ofs = clamp(sel2,0,max(0,l.Count()-28)); for ( int i=ofs; i 28 ) l = fnt.BreakLines(str,620); + if ( l.Count() > 28 ) + { + l.Destroy(); + l = fnt.BreakLines(str,620); + } xx = 6; yy = 17; int ofs = clamp(sel0,0,max(0,l.Count()-28)); @@ -3723,6 +3813,7 @@ Class DemolitionistMenu : GenericMenu yy = floor(ofs*(353./szr))+17; Screen.DrawText(TewiFont,Font.CR_FIRE,origin.x+xx,origin.y+yy,"▮",DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); } + l.Destroy(); } } } diff --git a/zscript/menu/swwm_credits.zsc b/zscript/menu/swwm_credits.zsc index a715c0d71..2d1417d91 100644 --- a/zscript/menu/swwm_credits.zsc +++ b/zscript/menu/swwm_credits.zsc @@ -37,6 +37,12 @@ Class SWWMCreditsEntry ui return self; } + override void OnDestroy() + { + Super.OnDestroy(); + if ( btext ) btext.Destroy(); + } + private int CalcWidth() { int len = fnt.StringWidth(title); diff --git a/zscript/menu/swwm_help.zsc b/zscript/menu/swwm_help.zsc index 1d600ab61..c54911811 100644 --- a/zscript/menu/swwm_help.zsc +++ b/zscript/menu/swwm_help.zsc @@ -187,6 +187,7 @@ Class SWWMHelpMenu : GenericMenu Screen.DrawText(fnt,Font.CR_WHITE,origin.x+320-maxlen/2,origin.y+133-lh/2+y,l.StringAt(i),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alpha); y += h; } + l.Destroy(); return; } txt = String.Format("(Unknown help page #%d)",page); diff --git a/zscript/menu/swwm_inter.zsc b/zscript/menu/swwm_inter.zsc index 8b3025d83..78a90acca 100644 --- a/zscript/menu/swwm_inter.zsc +++ b/zscript/menu/swwm_inter.zsc @@ -161,6 +161,7 @@ Class SWWMStatScreen : StatusScreen abstract yy += fnt.GetHeight(); xx = 12; } + l.Destroy(); } override int DrawLF() { diff --git a/zscript/swwm_handler.zsc b/zscript/swwm_handler.zsc index 584753777..b2cfc26ef 100644 --- a/zscript/swwm_handler.zsc +++ b/zscript/swwm_handler.zsc @@ -180,6 +180,7 @@ Class SWWMHandler : EventHandler Screen.DrawText(newsmallfont,Font.CR_UNTRANSLATED,xx,yy,l.StringAt(i),DTA_Clean,true,DTA_Alpha,alph); yy += newsmallfont.GetHeight(); } + l.Destroy(); } // weapon underlays if ( players[consoleplayer].ReadyWeapon is 'SWWMWeapon' ) diff --git a/zscript/swwm_player.zsc b/zscript/swwm_player.zsc index 06c888b84..e1eb1ca30 100644 --- a/zscript/swwm_player.zsc +++ b/zscript/swwm_player.zsc @@ -949,6 +949,7 @@ Class Demolitionist : PlayerPawn PoisonPeriodReceived = 0; PoisonDamageReceived = 0; Super.Tick(); + if ( gamestate != GS_LEVEL ) return; if ( hasteleported ) { // we just got teleported, don't count the travel distance diff --git a/zscript/weapons/swwm_cbt_ui.zsc b/zscript/weapons/swwm_cbt_ui.zsc index 87c177b55..fed868595 100644 --- a/zscript/weapons/swwm_cbt_ui.zsc +++ b/zscript/weapons/swwm_cbt_ui.zsc @@ -364,5 +364,6 @@ Class WallbusterReloadMenu : GenericMenu Screen.DrawText(fnt,Font.CR_WHITE,x,y,l.StringAt(i),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); y += 9; } + l.Destroy(); } } diff --git a/zscript/weapons/swwm_deathlydeathcannon_fx.zsc b/zscript/weapons/swwm_deathlydeathcannon_fx.zsc index 00891eef7..0180eb629 100644 --- a/zscript/weapons/swwm_deathlydeathcannon_fx.zsc +++ b/zscript/weapons/swwm_deathlydeathcannon_fx.zsc @@ -722,6 +722,7 @@ Class YnykronBeam : Actor { // goodbye nospread = true; + speed = t.Results.Distance; // shortens in minimap return; } if ( t.Results.HitType != TRACE_HitNone ) @@ -819,6 +820,7 @@ Class YnykronBeam : Actor YnykronShot(master).blastcount++; } nospread = true; + speed = t.Results.Distance; // shortens in minimap return; } if ( ((special1%256) < speed) && !Random[Ynykron](0,20) ) @@ -1646,6 +1648,7 @@ Class YnykronLightningArc : Actor } invoker.nextpos = t.Results.HitPos; bAMBUSH = true; + speed = t.Results.Distance; // shortens in minimap return; } invoker.nextpos = level.Vec3Offset(pos,x*speed); @@ -2729,6 +2732,7 @@ Class YnykronAltBeam : Actor { // goodbye nospread = true; + speed = t.Results.Distance; // shortens in minimap return; } if ( t.Results.HitType != TRACE_HitNone ) @@ -2756,6 +2760,7 @@ Class YnykronAltBeam : Actor b.angle = atan2(norm.y,norm.x); b.pitch = asin(-norm.z); nospread = true; + speed = t.Results.Distance; // shortens in minimap return; } if ( special1 >= 25600 ) diff --git a/zscript/weapons/swwm_shot_fx.zsc b/zscript/weapons/swwm_shot_fx.zsc index 3d2e0e048..884f3a790 100644 --- a/zscript/weapons/swwm_shot_fx.zsc +++ b/zscript/weapons/swwm_shot_fx.zsc @@ -535,6 +535,7 @@ Class SaltBeam : Actor i.special2 = Accuracy; i.args[0] = args[1]; } + speed = t.Results.Distance; // shortens in minimap return; } else if ( (args[0] > 20) && !Random[Spreadgun](0,800/args[0]) ) diff --git a/zscript/weapons/swwm_sparkyboi_fx.zsc b/zscript/weapons/swwm_sparkyboi_fx.zsc index 9cd789564..770a111c3 100644 --- a/zscript/weapons/swwm_sparkyboi_fx.zsc +++ b/zscript/weapons/swwm_sparkyboi_fx.zsc @@ -1165,6 +1165,7 @@ Class BiosparkBeam : Actor if ( t.Results.HitType == TRACE_HasHitSky ) { bAMBUSH = true; + speed = t.Results.Distance; // shortens in minimap return; } if ( t.Results.HitType != TRACE_HitNone ) @@ -1175,6 +1176,7 @@ Class BiosparkBeam : Actor s.pitch = asin(-normal.z); bAMBUSH = true; if ( swwm_omnibust ) BusterWall.Bust(t.Results,GetMissileDamage(0,0),target,t.Results.HitVector,t.Results.HitPos.z); + speed = t.Results.Distance; // shortens in minimap return; } double closest = double.infinity; @@ -1506,9 +1508,11 @@ Class BiosparkArc : Actor normal *= 0; } invoker.nextpos = level.Vec3Offset(t.Results.HitPos,normal); + if ( t.Results.HitType != TRACE_HitNone ) speed = t.Results.Distance; // shortens in minimap if ( t.Results.HitType == TRACE_HasHitSky ) { bAMBUSH = true; + speed = t.Results.Distance; // shortens in minimap return; } double a = FRandom[Sparkster](0,360), s = FRandom[Sparkster](0.,.8); diff --git a/zscript/weapons/swwm_tastytreat_fx.zsc b/zscript/weapons/swwm_tastytreat_fx.zsc index 34f4fd74d..8734392b0 100644 --- a/zscript/weapons/swwm_tastytreat_fx.zsc +++ b/zscript/weapons/swwm_tastytreat_fx.zsc @@ -136,6 +136,7 @@ Class CandyBeam : Actor t.Results.HitPos = level.Vec3Offset(pos,x*speed); normal *= 0; } + if ( t.Results.HitType != TRACE_HitNone ) speed = t.Results.Distance; // shortens in minimap double a = FRandom[Candy](0,360), s = FRandom[Candy](0.,.8); invoker.nextpos = level.Vec3Offset(t.Results.HitPos,normal); invoker.nextdir = (dir+cos(a)*y*s+sin(a)*z*s).unit();