From fb7cbe979ad53948b5bf75ba7dd44379bb2e9121 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sun, 13 Aug 2023 11:15:35 +0000 Subject: [PATCH] script: marked all unsafe pointer operations with `cast([unsafe])` FossilOrigin-Name: ae3b6f2778566d7e1345d6694ac76f31db860db2e422f19483e2fa45be057fdf --- progs/common/botai/BotPlayer_base.vc | 32 ++++++++---- progs/common/botai/BotPlayer_pather.vc | 45 +++++++++++----- progs/common/engine/GameInfo.vc | 6 +-- progs/common/engine/Level.vc | 12 +++-- progs/common/engine/LevelInfo.vc | 4 +- progs/common/engine/LevelMapFixer.vc | 60 +++++++++++----------- progs/common/engine/Object_ccd.vc | 2 +- progs/common/linespec/LightningThinker.vc | 6 +-- progs/common/linespec/PlaneWatcher.vc | 4 +- progs/common/linespec/Pusher.vc | 8 +-- .../linespec/actor/Actor.FlagsAndAppearance.vc | 4 +- .../linespec/dynlight/BaseStaticLightSource.vc | 2 +- progs/common/linespec/dynlight/DynamicLight.vc | 2 +- .../linespec/entityex/EntityEx.LineAttack.Debug.vc | 23 +++++---- progs/common/linespec/entityex/EntityEx.Misc.vc | 17 ++++-- .../linespec/linespec/LineSpecialGameInfo.vc | 52 +++++++++---------- .../linespec/LineSpecialGameInfo_LDef_Main.vc | 4 +- .../linespec/linespec/LineSpecialLevelInfo.vc | 52 +++++++++---------- progs/common/linespec/player/PlayerEx.vc | 6 +-- progs/common/linespec/secthink/Scroller.vc | 16 +++--- .../common/linespec/secthink/WallLightTransfer.vc | 6 +-- .../common/linespec/secthink/movers/SectorMover.vc | 4 +- .../uibase/client/StatusBarShared.notifymsg.vc | 4 +- progs/common/uibase/condlg/ConDialog.vc | 4 +- progs/doom/cgame/IntermissionScreen.vc | 18 +++---- progs/heretic/cgame/IntermissionScreen.vc | 18 +++---- progs/hexen/cgame/IntermissionScreen.vc | 4 +- progs/strife/cgame/IntermissionScreen.vc | 4 +- progs/strife/game/StrifeLevelInfo.vc | 4 +- 29 files changed, 233 insertions(+), 190 deletions(-) diff --git a/progs/common/botai/BotPlayer_base.vc b/progs/common/botai/BotPlayer_base.vc index 56391163f..b9e2905cc 100644 --- a/progs/common/botai/BotPlayer_base.vc +++ b/progs/common/botai/BotPlayer_base.vc @@ -417,9 +417,13 @@ final void TestFindPathTo (TVec dest) { pather.debugDump = true; scope(exit) pather.debugDump = false; if (!HavePathToPoint(dest, ss)) { - printmsg(PMSG.BotDev, "bot '%s' cannot find path from #%s to #%s", player.PlayerName, botmo.SubSector-&botmo.XLevel.Subsectors[0], ss-&botmo.XLevel.Subsectors[0]); + printmsg(PMSG.BotDev, "bot '%s' cannot find path from #%s to #%s", player.PlayerName, + cast([unsafe])(botmo.SubSector-&botmo.XLevel.Subsectors[0]), + cast([unsafe])(ss-&botmo.XLevel.Subsectors[0])); } else { - printmsg(PMSG.BotDev, "bot '%s' found path from #%s to #%s", player.PlayerName, botmo.SubSector-&botmo.XLevel.Subsectors[0], ss-&botmo.XLevel.Subsectors[0]); + printmsg(PMSG.BotDev, "bot '%s' found path from #%s to #%s", player.PlayerName, + cast([unsafe])(botmo.SubSector-&botmo.XLevel.Subsectors[0]), + cast([unsafe])(ss-&botmo.XLevel.Subsectors[0])); UseCurrentPath(); // do not give up for 20 seconds currPathAllyForceTimeout = botmo.XLevel.Time+6; @@ -941,11 +945,19 @@ Actor FindAllyToSupport (bool allowESP) { if (!plr) continue; if (!plr.bIsBot && plr.bSpawned && plr.MO.Health > 0 && botmo != plr.MO) { if (HavePathToPoint(plr.MO.Origin, plr.MO.SubSector)) { - if (bot_developer_messages_roam) printmsg(PMSG.BotDevRoam, "*** ESP activated! src=%d, dst=%d", botmo.SubSector-&botmo.XLevel.Subsectors[0], plr.MO.SubSector-&botmo.XLevel.Subsectors[0]); + if (bot_developer_messages_roam) { + printmsg(PMSG.BotDevRoam, "*** ESP activated! src=%d, dst=%d", + cast([unsafe])(botmo.SubSector-&botmo.XLevel.Subsectors[0]), + cast([unsafe])(plr.MO.SubSector-&botmo.XLevel.Subsectors[0])); + } UseCurrentPath(); break; } else { - if (bot_developer_messages_roam) printmsg(PMSG.BotDevRoam, "*** CANNOT activate ESP! src=%d, dst=%d", botmo.SubSector-&botmo.XLevel.Subsectors[0], plr.MO.SubSector-&botmo.XLevel.Subsectors[0]); + if (bot_developer_messages_roam) { + printmsg(PMSG.BotDevRoam, "*** CANNOT activate ESP! src=%d, dst=%d", + cast([unsafe])(botmo.SubSector-&botmo.XLevel.Subsectors[0]), + cast([unsafe])(plr.MO.SubSector-&botmo.XLevel.Subsectors[0])); + } } } } @@ -1182,14 +1194,14 @@ final void onThingUsed (EntityEx th) { } final bool checkLineUse (line_t *ld) { - int lidx = ld-&botmo.XLevel.Lines[0]; + int lidx = cast([unsafe])(ld-&botmo.XLevel.Lines[0]); auto tlt = lastUsedLines.find(lidx); if (tlt && *tlt > botmo.XLevel.Time) return false; // cooldown is not complete return true; } final void onLineUsed (line_t *ld) { - int lidx = ld-&botmo.XLevel.Lines[0]; + int lidx = cast([unsafe])(ld-&botmo.XLevel.Lines[0]); printmsg(PMSG.BotDevAI, "bot '%s' used line #%s", player.PlayerName, lidx); lastUsedLines.put(lidx, botmo.XLevel.Time+UseCooldown); } @@ -1730,7 +1742,7 @@ void RoamRandom (out TVec dest) { //========================================================================== final bool FollowPath () { float currTime = botmo.XLevel.Time; - int ssnum = botmo.SubSector-&botmo.XLevel.Subsectors[0]; + int ssnum = cast([unsafe])(botmo.SubSector-&botmo.XLevel.Subsectors[0]); EntityEx::PathInfo pi; // check if we are staying in the same node for too long @@ -1814,7 +1826,7 @@ final bool FollowPath () { if (currTime-currAlienNodeTime > 3) { // yes, replan path if (bot_developer_messages_path) printmsg(PMSG.BotDevPath, "bot '%s' is staying away from its destination ss #%s (at #%s) for #%s, replanning", player.PlayerName, ptnode.index, ssnum, currTime-currAlienNodeTime); - if (!HavePathToSS(&botmo.XLevel.Subsectors[currPath[$-1]])) { + if (!HavePathToSS(cast([unsafe])(&botmo.XLevel.Subsectors[currPath[$-1]]))) { // alas, no path if (bot_developer_messages_path) printmsg(PMSG.BotDevPath, "bot '%s' cannot replan its path to #%d from #%s", player.PlayerName, currPath[$-1], ssnum); ResetCurrPath(); @@ -2609,7 +2621,7 @@ void BotTick (float deltaTime) { lastThinkTic = currTic; - int ssnum = botmo.SubSector-&botmo.XLevel.Subsectors[0]; + int ssnum = cast([unsafe])(botmo.SubSector-&botmo.XLevel.Subsectors[0]); if (ssnum != lastSubsector) { lastSubsector = ssnum; lastSSChangeTime = botmo.XLevel.Time; @@ -2712,7 +2724,7 @@ void OnBeginPlay () { //print("bottype=%s; name='%s'", bottype, player.PlayerName); - binfo = &MainGameInfo(player.Level.Game).botinfo[bottype]; + binfo = cast([unsafe])(&MainGameInfo(player.Level.Game).botinfo[bottype]); t_strafe = 1.0; diff --git a/progs/common/botai/BotPlayer_pather.vc b/progs/common/botai/BotPlayer_pather.vc index 2cf73d4f1..ded89504c 100644 --- a/progs/common/botai/BotPlayer_pather.vc +++ b/progs/common/botai/BotPlayer_pather.vc @@ -204,7 +204,10 @@ final void queueRefreshNode (BotPathNode node, optional bool forced) { if (refreshMap.find(node.index)) return; if (bot_developer_messages_path) printmsg(PMSG.BotDevPath, "queueRefreshNode(2): #%d", node.index); // queue this node, and all adjacent nodes - if (bot_developer_messages_path) printmsg(PMSG.BotDevPath, "queuing node #%d (sector #%d) for refresh", node.index, node.sub.sector-&bot.player.MO.XLevel.Sectors[0]); + if (bot_developer_messages_path) { + printmsg(PMSG.BotDevPath, "queuing node #%d (sector #%d) for refresh", + node.index, cast([unsafe])(node.sub.sector-&bot.player.MO.XLevel.Sectors[0])); + } refreshMap.put(node.index, true); //node.queryCounter = queryCounter; } @@ -224,7 +227,10 @@ final void refreshNovePassability (BotPathNode node) { EntityEx::FakeDoorInfo savedPlane; VLevel lev = bot.player.MO.XLevel; - if (bot_developer_messages_path) printmsg(PMSG.BotDevPath, "updating sub #%d (sector #%d) passability (old is %B)", node.index, node.sub.sector-&lev.Sectors[0], node.passable); + if (bot_developer_messages_path) { + printmsg(PMSG.BotDevPath, "updating sub #%d (sector #%d) passability (old is %B)", + node.index, cast([unsafe])(node.sub.sector-&lev.Sectors[0]), node.passable); + } fakeOpenDoor(node, out savedPlane); scope(exit) restoreFakeOpenDoor(savedPlane); @@ -239,7 +245,7 @@ final void refreshNovePassability (BotPathNode node) { node.passable = false; TVec center = lev.GetSubsectorCenter(sub); foreach (auto lidx; sub.firstline..sub.firstline+sub.numlines) { - auto seg = &lev.Segs[lidx]; + auto seg = cast([unsafe])(&lev.Segs[lidx]); TVec dir = center-(*seg->v1); if (dir.length2DSquared < 4*4) continue; cpos = (*seg->v1)+(dir.normalise2D)*3.5; @@ -259,7 +265,11 @@ final void refreshNovePassability (BotPathNode node) { } if (node.passable != oldPassable) { - if (bot_developer_messages_path) printmsg(PMSG.BotDevPath, "node #%d becomes %svalid (door:%B; sector: %s)", node.index, (node.passable ? "" : "in"), node.door, node.sub.sector-&lev.Sectors[0]); + if (bot_developer_messages_path) { + printmsg(PMSG.BotDevPath, "node #%d becomes %svalid (door:%B; sector: %s)", node.index, + (node.passable ? "" : "in"), node.door, + cast([unsafe])(node.sub.sector-&lev.Sectors[0])); + } } } @@ -271,7 +281,7 @@ transient dictionary!(int, int) twoWayRefresh; final void refreshNodeExit (BotPathNode node, int exitnum) { EntityEx botmo = EntityEx(bot.player.MO); VLevel lev = botmo.XLevel; - auto tr = &node.exits[exitnum]; + auto tr = cast([unsafe])(&node.exits[exitnum]); auto sec = tr.sub.sector; //if (sec.floor.dist == tr.floorDist && sec.ceiling.dist == tr.ceilDist) return; @@ -355,7 +365,10 @@ final void refreshAllNodesInMap () { int key = refreshMap.keyAtIndex(idx); auto node = nodes[key]; node.queryCounter = 0; - if (bot_developer_messages_path) printmsg(PMSG.BotDevPath, "refreshing node #%d (sector #%d)", node.index, node.sub.sector-&bot.player.MO.XLevel.Sectors[0]); + if (bot_developer_messages_path) { + printmsg(PMSG.BotDevPath, "refreshing node #%d (sector #%d)", node.index, + cast([unsafe])(node.sub.sector-&bot.player.MO.XLevel.Sectors[0])); + } refreshNode(node); } @@ -376,7 +389,10 @@ final void refreshAllNodesInMap () { if (!tmpNodeInds.length) break; foreach (auto nidx; tmpNodeInds) { auto node = nodes[nidx]; - if (bot_developer_messages_path) printmsg(PMSG.BotDevPath, "secondary refreshing node #%d (sector #%d)", node.index, node.sub.sector-&bot.player.MO.XLevel.Sectors[0]); + if (bot_developer_messages_path) { + printmsg(PMSG.BotDevPath, "secondary refreshing node #%d (sector #%d)", node.index, + cast([unsafe])(node.sub.sector-&bot.player.MO.XLevel.Sectors[0])); + } refreshNode(node); } } @@ -399,7 +415,7 @@ final void Setup (BotPlayerBase abot) { // create nodes nodes.length = lev.Subsectors.length; foreach (auto idx, ref auto node; nodes) { - GameObject::subsector_t *sub = &lev.Subsectors[idx]; + GameObject::subsector_t *sub = cast([unsafe])(&lev.Subsectors[idx]); node = BotPathNode.CreateNew(lev); node.sub = sub; node.index = idx; @@ -423,7 +439,7 @@ final void Setup (BotPlayerBase abot) { // create exits foreach (auto lidx; sub.firstline..sub.firstline+sub.numlines) { - auto seg = &lev.Segs[lidx]; + auto seg = cast([unsafe])(&lev.Segs[lidx]); if (!seg.partner || seg.partner.frontsub == seg.frontsub) continue; // not interesting GameObject::line_t *ld = seg.linedef; @@ -436,7 +452,7 @@ final void Setup (BotPlayerBase abot) { auto tr = node.exits.alloc(); tr.seg = seg; tr.sub = seg.partner.frontsub; - tr.subnum = tr.sub-&lev.Subsectors[0]; + tr.subnum = cast([unsafe])(tr.sub-&lev.Subsectors[0]); //if (tr.sub.sector != sub.sector) node.sectorExits[$] = node.exits.length-1; @@ -501,17 +517,18 @@ final bool BuildPath (TVec from, GameObject::subsector_t *fromsub, TVec dest, Ga // early exit: same subsector is always reachable if (fromsub == destsub) { PathArrayClear(); - PathArrayPushNode(nodes[fromsub-&lev.Subsectors[0]]); + PathArrayPushNode(nodes[cast([unsafe])(fromsub-&lev.Subsectors[0])]); pathCost = 0; return true; } - queueRefreshNode(nodes[fromsub-&lev.Subsectors[0]]); - queueRefreshNode(nodes[destsub-&lev.Subsectors[0]]); + queueRefreshNode(nodes[cast([unsafe])(fromsub-&lev.Subsectors[0])]); + queueRefreshNode(nodes[cast([unsafe])(destsub-&lev.Subsectors[0])]); for (;;) { refreshAllNodesInMap(); - bool res = Solve(nodes[fromsub-&lev.Subsectors[0]], nodes[destsub-&lev.Subsectors[0]]); + bool res = Solve(nodes[cast([unsafe])(fromsub-&lev.Subsectors[0])], + nodes[cast([unsafe])(destsub-&lev.Subsectors[0])]); if (refreshMap.length == 0) return res; if (bot_developer_messages_path) printmsg(PMSG.BotDevPath, "*** MAP CHANGED! ***"); } diff --git a/progs/common/engine/GameInfo.vc b/progs/common/engine/GameInfo.vc index 4946fc4a0..3e85f6e80 100644 --- a/progs/common/engine/GameInfo.vc +++ b/progs/common/engine/GameInfo.vc @@ -348,9 +348,9 @@ void TranslateSpecialActions (VLevel InLevel, LevelInfo Level) { // //========================================================================== void TranslateLevel (VLevel InLevel) { - foreach (auto i; 0..InLevel.Lines.length) TranslateLine(InLevel, &InLevel.Lines[i]); - foreach (auto i; 0..InLevel.Sectors.length) TranslateSector(InLevel, &InLevel.Sectors[i]); - foreach (auto i; 0..InLevel.Things.length) TranslateThing(InLevel, &InLevel.Things[i]); + foreach (auto i; 0..InLevel.Lines.length) TranslateLine(InLevel, cast([unsafe])(&InLevel.Lines[i])); + foreach (auto i; 0..InLevel.Sectors.length) TranslateSector(InLevel, cast([unsafe])(&InLevel.Sectors[i])); + foreach (auto i; 0..InLevel.Things.length) TranslateThing(InLevel, cast([unsafe])(&InLevel.Things[i])); } diff --git a/progs/common/engine/Level.vc b/progs/common/engine/Level.vc index c52ed9125..5757749e9 100644 --- a/progs/common/engine/Level.vc +++ b/progs/common/engine/Level.vc @@ -480,7 +480,7 @@ native void doRecursiveSound (ref array!Entity elist, sector_t *sec, Entity soun //========================================================================== final int calcSecIdx (sector_t *sec) { if (!sec) return -1; - return sec-&Sectors[0]; + return cast([unsafe])(sec-&Sectors[0]); } @@ -686,7 +686,7 @@ final TVec GetSubsectorCenter (const subsector_t *sub) { ssCenters.length = Subsectors.length; foreach (ref TVec ssc; ssCenters) ssc = vector(float.max, float.max, float.max); // impossibiru } - int ssnum = sub-&Subsectors[0]; + int ssnum = cast([unsafe])(sub-&Subsectors[0]); TVec res = ssCenters[ssnum]; if (res.x != float.max) return res; // calculate it @@ -710,7 +710,7 @@ final TVec GetSubsectorCenter (const subsector_t *sub) { // //========================================================================== MapMarkerInfo *MapMarkerWithId (int markerid) { - return (markerid > 0 && markerid <= MapMarkers.length ? &MapMarkers[markerid-1] : nullptr); + return (markerid > 0 && markerid <= MapMarkers.length ? cast([unsafe])(&MapMarkers[markerid-1]) : nullptr); } @@ -726,7 +726,7 @@ int AddMapMarker () { MapMarkerInfo *nmk = nullptr; foreach (auto idx, ref MapMarkerInfo mk; MapMarkers) { if (mk.id == -1) { - nmk = &MapMarkers[idx]; + nmk = cast([unsafe])(&MapMarkers[idx]); nmk.id = idx+1; break; } @@ -802,7 +802,9 @@ bool Do_LineAlignFlatByLine (line_t *line, int side, bool doFloor, bool doCeilin float normAngle = angle+90.0; float dist = -(cos(normAngle)*v2.x+sin(normAngle)*v2.y); - printdebug("flat align: line #%s, side=%s; floor=%B; ceiling=%B; scale=%s (%B); angle=%s; normAngle=%s; dist=%s (%s)", line-&Lines[0], side, doFloor, doCeiling, scale, specified_scale, angle, normAngle, dist, fmod(dist, 4096.0)); + printdebug("flat align: line #%s, side=%s; floor=%B; ceiling=%B; scale=%s (%B); angle=%s; normAngle=%s; dist=%s (%s)", + cast([unsafe])(line-&Lines[0]), + side, doFloor, doCeiling, scale, specified_scale, angle, normAngle, dist, fmod(dist, 4096.0)); if (doFloor) { sec->floor.BaseAngle = angle; diff --git a/progs/common/engine/LevelInfo.vc b/progs/common/engine/LevelInfo.vc index 0b4bb9cf6..cd99a0a66 100644 --- a/progs/common/engine/LevelInfo.vc +++ b/progs/common/engine/LevelInfo.vc @@ -1277,8 +1277,8 @@ mthing_t *GetPlayerStart (int PNum, int Position, optional bool failIfNotFound) mthing_t *Best = nullptr; foreach (int i; 0..PlayerStarts.length; reverse) { if (PlayerStarts[i].type != PNum) continue; - if (PlayerStarts[i].args[0] == Position) return &PlayerStarts[i]; - if (!Best) Best = &PlayerStarts[i]; + if (PlayerStarts[i].args[0] == Position) return cast([unsafe])(&PlayerStarts[i]); + if (!Best) Best = cast([unsafe])(&PlayerStarts[i]); } if (failIfNotFound) { if (!Best) Error("Player %d has no start spots (GetPlayerStart)", PNum); diff --git a/progs/common/engine/LevelMapFixer.vc b/progs/common/engine/LevelMapFixer.vc index 6e68fca05..50468d5f0 100644 --- a/progs/common/engine/LevelMapFixer.vc +++ b/progs/common/engine/LevelMapFixer.vc @@ -20,11 +20,10 @@ enum { // LdrSectorOffsetFloor // //========================================================================== -private static final void LdrSectorOffsetFloor (sector_t *sec, float ofs) { - if (!sec) return; - sec->floor.TexZ += ofs; - sec->floor.minz += ofs; - sec->floor.maxz += ofs; +private static final void LdrSectorOffsetFloor (ref sector_t sec, float ofs) { + sec.floor.TexZ += ofs; + sec.floor.minz += ofs; + sec.floor.maxz += ofs; } @@ -33,11 +32,10 @@ private static final void LdrSectorOffsetFloor (sector_t *sec, float ofs) { // LdrSectorOffsetCeiling // //========================================================================== -private static final void LdrSectorOffsetCeiling (sector_t *sec, float ofs) { - if (!sec) return; - sec->ceiling.TexZ += ofs; - sec->ceiling.minz += ofs; - sec->ceiling.maxz += ofs; +private static final void LdrSectorOffsetCeiling (ref sector_t sec, float ofs) { + sec.ceiling.TexZ += ofs; + sec.ceiling.minz += ofs; + sec.ceiling.maxz += ofs; } @@ -54,10 +52,10 @@ void KnownMapBugFixer () { // missing textures Sides[Lines[693].sidenum[1]].TopTexture = LdrTexNumForName("BROWN1", TEXTYPE_Wall); // fix HOM errors with sectors too low - LdrSectorOffsetFloor(&Sectors[9], 8); - LdrSectorOffsetFloor(&Sectors[105], 8); - LdrSectorOffsetFloor(&Sectors[132], 8); - LdrSectorOffsetFloor(&Sectors[137], 8); + LdrSectorOffsetFloor(ref Sectors[9], 8); + LdrSectorOffsetFloor(ref Sectors[105], 8); + LdrSectorOffsetFloor(ref Sectors[132], 8); + LdrSectorOffsetFloor(ref Sectors[137], 8); printwarn("MAPFIX: Doom: E1M4 detected and fixed"); return; } @@ -130,9 +128,9 @@ void KnownMapBugFixer () { // invalid line sectors assert(Sides[Lines[21].sidenum[0]].Sector); assert(Sides[Lines[57].sidenum[1]].Sector); - Lines[21].frontsector = &Sectors[1]; + Lines[21].frontsector = cast([unsafe])(&Sectors[1]); Sides[Lines[21].sidenum[0]].Sector = Lines[21].frontsector; - Lines[57].backsector = &Sectors[1]; + Lines[57].backsector = cast([unsafe])(&Sectors[1]); Sides[Lines[57].sidenum[1]].Sector = Lines[57].backsector; printwarn("MAPFIX: Doom: E3M8 detected and fixed"); return; @@ -245,8 +243,8 @@ void KnownMapBugFixer () { // Doom II: MAP21 if (MapHashMD5 == "ebdac00e9d25d884b2c8f4b1f0390539") { // push ceiling down in glitchy sectors above the stair switches - LdrSectorOffsetCeiling(&Sectors[50], -56); - LdrSectorOffsetCeiling(&Sectors[54], -56); + LdrSectorOffsetCeiling(ref Sectors[50], -56); + LdrSectorOffsetCeiling(ref Sectors[54], -56); printwarn("MAPFIX: Doom II: MAP21 detected and fixed"); return; } @@ -333,8 +331,8 @@ void KnownMapBugFixer () { if (MapHashMD5 == "add0fac41afb0b3c9b9f3c0006f93805") { // Broken door between the hallway that leads to a Torch // and the passage that has a Bag of Holding at its end - LdrSectorOffsetFloor(&Sectors[86], -128); - LdrSectorOffsetCeiling(&Sectors[86], -128); + LdrSectorOffsetFloor(ref Sectors[86], -128); + LdrSectorOffsetCeiling(ref Sectors[86], -128); printwarn("MAPFIX: Heretic: E1M3 detected and fixed"); return; } @@ -342,17 +340,17 @@ void KnownMapBugFixer () { // Heretic: E1M4 if (MapHashMD5 == "916318d8b06dac2d83424b23e4b66531") { // wrong sector offsets - LdrSectorOffsetCeiling(&Sectors[0], 8); - LdrSectorOffsetCeiling(&Sectors[1], 8); - LdrSectorOffsetCeiling(&Sectors[2], 8); - LdrSectorOffsetCeiling(&Sectors[3], 8); - LdrSectorOffsetCeiling(&Sectors[4], 8); - LdrSectorOffsetCeiling(&Sectors[6], 8); - LdrSectorOffsetFloor(&Sectors[6], 8); - LdrSectorOffsetCeiling(&Sectors[17], 8); + LdrSectorOffsetCeiling(ref Sectors[0], 8); + LdrSectorOffsetCeiling(ref Sectors[1], 8); + LdrSectorOffsetCeiling(ref Sectors[2], 8); + LdrSectorOffsetCeiling(ref Sectors[3], 8); + LdrSectorOffsetCeiling(ref Sectors[4], 8); + LdrSectorOffsetCeiling(ref Sectors[6], 8); + LdrSectorOffsetFloor(ref Sectors[6], 8); + LdrSectorOffsetCeiling(ref Sectors[17], 8); // yellow key door - LdrSectorOffsetFloor(&Sectors[284], -8); - LdrSectorOffsetCeiling(&Sectors[284], -8); + LdrSectorOffsetFloor(ref Sectors[284], -8); + LdrSectorOffsetCeiling(ref Sectors[284], -8); // missing textures Sides[Lines[490].sidenum[1]].BottomTexture = LdrTexNumForName("GRSTNPB", TEXTYPE_Wall); Sides[Lines[722].sidenum[0]].BottomTexture = LdrTexNumForName("WOODWL", TEXTYPE_Wall); @@ -587,7 +585,7 @@ void KnownMapBugFixer () { // fix sectors foreach (auto idx, auto ref sec; Sectors) { if (sec.sectorTag == oldtag && idx != 3686) { - //printdebug(" sector #%s has tag #%s", &sec-&Sectors[0], sec.sectorTag); + //printdebug(" sector #%s has tag #%s", cast([unsafe])(&sec-&Sectors[0]), sec.sectorTag); sec.sectorTag = newtag; } } diff --git a/progs/common/engine/Object_ccd.vc b/progs/common/engine/Object_ccd.vc index 19ada5255..2a40715f0 100644 --- a/progs/common/engine/Object_ccd.vc +++ b/progs/common/engine/Object_ccd.vc @@ -149,7 +149,7 @@ static final float CD_SweepLineAABBlpl (const ref CD_LinePlanes linePlanes, TVec int phit = -1; foreach (auto pidx; 0..linePlanes.count) { - TPlane *plane = &linePlanes.planes[pidx]; + TPlane plane = linePlanes.planes[pidx]; // box // line plane normal z is always zero, so don't bother checking it TVec offset = vector((plane.normal.x < 0.0f ? bmax.x : bmin.x), (plane.normal.y < 0.0f ? bmax.y : bmin.y), /*(plane.normal.z < 0.0f ? bmax.z : bmin.z)*/bmin.z); diff --git a/progs/common/linespec/LightningThinker.vc b/progs/common/linespec/LightningThinker.vc index a74afd498..807ff6011 100644 --- a/progs/common/linespec/LightningThinker.vc +++ b/progs/common/linespec/LightningThinker.vc @@ -81,7 +81,7 @@ void DoLightningFlash (float DeltaTime) { LightningFlash -= DeltaTime; if (LightningFlash > 0.0) { foreach (auto i; 0..XLevel.Sectors.length) { - tempSec = &XLevel.Sectors[i]; + tempSec = cast([unsafe])(&XLevel.Sectors[i]); if (LightningSectors[i/8]&(1<<(i&7))) { if (LightningLightLevels[i] < tempSec->params.lightlevel-4) { tempSec->params.lightlevel -= 4; @@ -92,7 +92,7 @@ void DoLightningFlash (float DeltaTime) { // remove the alternate lightning flash special LightningFlash = 0.0; foreach (auto i; 0..XLevel.Sectors.length) { - tempSec = &XLevel.Sectors[i]; + tempSec = cast([unsafe])(&XLevel.Sectors[i]); if (LightningSectors[i/8]&(1<<(i&7))) { tempSec->params.lightlevel = LightningLightLevels[i]; } @@ -107,7 +107,7 @@ void DoLightningFlash (float DeltaTime) { foundSec = false; for (int i = (XLevel.Sectors.length+7)/8-1; i >= 0; --i) LightningSectors[i] = 0; foreach (auto i; 0..XLevel.Sectors.length) { - tempSec = &XLevel.Sectors[i]; + tempSec = cast([unsafe])(&XLevel.Sectors[i]); int Spec = tempSec->special&SECSPEC_BASE_MASK; if (tempSec->ceiling.pic == Level.Game.skyflatnum || Spec == SECSPEC_LightningOutdoor || diff --git a/progs/common/linespec/PlaneWatcher.vc b/progs/common/linespec/PlaneWatcher.vc index 1a5c72ec6..2c0eddc94 100644 --- a/progs/common/linespec/PlaneWatcher.vc +++ b/progs/common/linespec/PlaneWatcher.vc @@ -64,9 +64,9 @@ void Start (Entity it, line_t *aline, int alineSide, bool ceiling, int tag, if (XLevel.FindSectorFromTag(out Sector, tag) >= 0) { //Sector = &XLevel.Sectors[secnum]; if (bCeiling) { - plane = &Sector->ceiling; + plane = cast([unsafe])(&Sector->ceiling); } else { - plane = &Sector->floor; + plane = cast([unsafe])(&Sector->floor); } LastD = plane->dist; //FIXME plane.ChangeHeight(); diff --git a/progs/common/linespec/Pusher.vc b/progs/common/linespec/Pusher.vc index 42b62209e..a86cc8e3b 100644 --- a/progs/common/linespec/Pusher.vc +++ b/progs/common/linespec/Pusher.vc @@ -123,7 +123,7 @@ void Init (int InType, line_t *l, int amagnitude, int angle, EntityEx asource, i // //========================================================================== int CheckForSectorMatch (int atype, int tag) { - if (Type == atype && IsSectorTagEqual(&XLevel.Sectors[Affectee], tag)) return Affectee; + if (Type == atype && IsSectorTagEqual(cast([unsafe])(&XLevel.Sectors[Affectee]), tag)) return Affectee; return -1; } @@ -160,7 +160,7 @@ override void Tick (float DeltaTime) { //if (!var_pushers) return; - sec = &XLevel.Sectors[Affectee]; + sec = cast([unsafe])(&XLevel.Sectors[Affectee]); // be sure the special sector type is still turned on; if so, proceed // else, bail out; the sector type has been changed on us @@ -264,10 +264,10 @@ override void Tick (float DeltaTime) { // PUSHER_Current if (!sec->heightsec || sec->heightsec->bIgnoreHeightSec) { // not special water sector - floor = &sec->floor; + floor = cast([unsafe])(&sec->floor); } else { // special water sector - floor = &sec->heightsec->floor; + floor = cast([unsafe])(&sec->heightsec->floor); } if (!thing.WaterLevel && thing.Origin.z > GetPlanePointZ(ref *floor, thing.Origin)) { // above ground diff --git a/progs/common/linespec/actor/Actor.FlagsAndAppearance.vc b/progs/common/linespec/actor/Actor.FlagsAndAppearance.vc index d7a3f9817..1598ad890 100644 --- a/progs/common/linespec/actor/Actor.FlagsAndAppearance.vc +++ b/progs/common/linespec/actor/Actor.FlagsAndAppearance.vc @@ -225,9 +225,9 @@ if (SpeechNum) { // drop stuff as determined by conversation if (SpeechNum < 0) { - Speech = &XLevel.GenericSpeeches[-SpeechNum-1]; + Speech = cast([unsafe])(&XLevel.GenericSpeeches[-SpeechNum-1]); } else { - Speech = &XLevel.LevelSpeeches[SpeechNum-1]; + Speech = cast([unsafe])(&XLevel.LevelSpeeches[SpeechNum-1]); } DropItemType = LineSpecialLevelInfo(Level).GetClassFromID(Speech->DropItem); if (DropItemType && drop) { diff --git a/progs/common/linespec/dynlight/BaseStaticLightSource.vc b/progs/common/linespec/dynlight/BaseStaticLightSource.vc index 3728de299..824dc968f 100644 --- a/progs/common/linespec/dynlight/BaseStaticLightSource.vc +++ b/progs/common/linespec/dynlight/BaseStaticLightSource.vc @@ -29,7 +29,7 @@ class BaseStaticLightSource : Actor; TVec GetAdjustedPosition (mthing_t *mthing) { TVec pos = vector(mthing->x, mthing->y, mthing->height); sector_t *sec = XLevel.PointInSector(pos); - if (sec) FixLightPosition(sec, ref pos, mthing-&XLevel.Things[0]); + if (sec) FixLightPosition(sec, ref pos, cast([unsafe])(mthing-&XLevel.Things[0])); return pos; } diff --git a/progs/common/linespec/dynlight/DynamicLight.vc b/progs/common/linespec/dynlight/DynamicLight.vc index 71eb2ea78..b30b2cb41 100644 --- a/progs/common/linespec/dynlight/DynamicLight.vc +++ b/progs/common/linespec/dynlight/DynamicLight.vc @@ -105,7 +105,7 @@ override void OnMapSpawn (mthing_t *mthing) { // adjust Z position (why not?) // people loves to put lights into the floor/ceiling, and our tracer is not happy with those - if (mthing && Sector) FixLightPosition(Sector, ref Origin, mthing-&XLevel.Things[0]); + if (mthing && Sector) FixLightPosition(Sector, ref Origin, cast([unsafe])(mthing-&XLevel.Things[0])); //if (LightType&DLTYPE_Spot) printdebug("%C: Angles=%s; [1]=%s; [2]=%s", self, Angles, Args[1], Args[2]); diff --git a/progs/common/linespec/entityex/EntityEx.LineAttack.Debug.vc b/progs/common/linespec/entityex/EntityEx.LineAttack.Debug.vc index 1a7db58ba..f46dc25d3 100644 --- a/progs/common/linespec/entityex/EntityEx.LineAttack.Debug.vc +++ b/progs/common/linespec/entityex/EntityEx.LineAttack.Debug.vc @@ -93,14 +93,19 @@ final void DebugCheckMidTex () { float bcz2 = tr.line.backsector.ceiling.GetPointZClamped(*tr.line.v2); //if (bcz1 != bcz2) Error("OOPS(back ceiling)"); printdebug("linedef %d: (f/b secs=%d/%d); ffz=(%f:%f); fcz=(%f:%f); bfz=(%f:%f); bcz=(%f:%f); alpha=%f; special=%s<%s>; arg=(%s,%s,%s,%s,%s)", - tr.line-&XLevel.Lines[0], - tr.line.frontsector-&XLevel.Sectors[0], tr.line.backsector-&XLevel.Sectors[0], + cast([unsafe])(tr.line-&XLevel.Lines[0]), + cast([unsafe])(tr.line.frontsector-&XLevel.Sectors[0]), + cast([unsafe])(tr.line.backsector-&XLevel.Sectors[0]), ffz1, ffz2, fcz1, fcz2, bfz1, bfz2, bcz1, bcz2, tr.line.alpha, tr.line.special, LineSpecial2Str(tr.line.special), tr.line.arg1, tr.line.arg2, tr.line.arg3, tr.line.arg4, tr.line.arg5); - printdebug("fsec(%d): ceiling=%f; floor=%f", tr.line.frontsector-&XLevel.Sectors[0], tr.line.frontsector.ceiling.minz, tr.line.frontsector.floor.maxz); - printdebug("bsec(%d): ceiling=%f; floor=%f", tr.line.backsector-&XLevel.Sectors[0], tr.line.backsector.ceiling.minz, tr.line.backsector.floor.maxz); + printdebug("fsec(%d): ceiling=%f; floor=%f", + cast([unsafe])(tr.line.frontsector-&XLevel.Sectors[0]), + tr.line.frontsector.ceiling.minz, tr.line.frontsector.floor.maxz); + printdebug("bsec(%d): ceiling=%f; floor=%f", + cast([unsafe])(tr.line.backsector-&XLevel.Sectors[0]), + tr.line.backsector.ceiling.minz, tr.line.backsector.floor.maxz); } else { float ffz1 = tr.line.frontsector.floor.GetPointZClamped(*tr.line.v1); float ffz2 = tr.line.frontsector.floor.GetPointZClamped(*tr.line.v2); @@ -109,15 +114,15 @@ final void DebugCheckMidTex () { float fcz2 = tr.line.frontsector.ceiling.GetPointZClamped(*tr.line.v2); //if (fcz1 != fcz2) Error("OOPS(front ceiling)"); printdebug("linedef %d: (f sec=%d); ffz=(%f:%f); fcz=(%f:%f); special=%s<%s>; arg=(%s,%s,%s,%s,%s)", - tr.line-&XLevel.Lines[0], - tr.line.frontsector-&XLevel.Sectors[0], + cast([unsafe])(tr.line-&XLevel.Lines[0]), + cast([unsafe])(tr.line.frontsector-&XLevel.Sectors[0]), ffz1, ffz2, fcz1, fcz2, tr.line.special, LineSpecial2Str(tr.line.special), tr.line.arg1, tr.line.arg2, tr.line.arg3, tr.line.arg4, tr.line.arg5); } foreach (auto snum; 0..2) { if (tr.line.sidenum[snum] < 0) continue; - side_t *sd = &XLevel.Sides[tr.line.sidenum[snum]]; + side_t *sd = cast([unsafe])(&XLevel.Sides[tr.line.sidenum[snum]]); printdebug("side %s: toptex(%d)=%s; midtex(%d)=%s; bottex(%d)=%s", snum, sd.TopTexture, GetTextureName(sd.TopTexture), sd.MidTexture, GetTextureName(sd.MidTexture), @@ -196,10 +201,10 @@ private final bool DebugTraceLineEx (TVec org, TVec dir, float distance, bool al opening_t *open = XLevel.LineOpenings(li, hitPoint, SPF_NOBLOCKING, stopat3dmidtex); if (open) { printdebug("SKYFLAT: %d (%s)", Level.Game.skyflatnum, GetTextureName(Level.Game.skyflatnum)); - printdebug(":: line #%d (flags=0x%08x) ::", li-&XLevel.Lines[0], li->flags); + printdebug(":: line #%d (flags=0x%08x) ::", cast([unsafe])(li-&XLevel.Lines[0]), li->flags); foreach (auto snum; 0..2) { if (li.sidenum[snum] < 0) continue; - side_t *sd = &XLevel.Sides[li.sidenum[snum]]; + side_t *sd = cast([unsafe])(&XLevel.Sides[li.sidenum[snum]]); printdebug("side %s: toptex(%d)=%s; midtex(%d)=%s; bottex(%d)=%s", snum, sd.TopTexture, GetTextureName(sd.TopTexture), sd.MidTexture, GetTextureName(sd.MidTexture), diff --git a/progs/common/linespec/entityex/EntityEx.Misc.vc b/progs/common/linespec/entityex/EntityEx.Misc.vc index 0f2e1c154..d3775fb69 100644 --- a/progs/common/linespec/entityex/EntityEx.Misc.vc +++ b/progs/common/linespec/entityex/EntityEx.Misc.vc @@ -183,10 +183,17 @@ void FixLightPosition (sector_t *asector, ref TVec org, optional int thingidx) { float pdist = DotProduct(org, ldef.normal)-ldef.dist; if (fabs(pdist) >= 1.0f) continue; mdir = (mdir+ldef.normal)/2; - if (specified_thingidx) printdebug("sector #%d: line #%d: light #%d in the wall!", asector-&XLevel.Sectors[0], ldef-&XLevel.Lines[0], thingidx); + if (thingidx!specified) { + printdebug("sector #%d: line #%d: light #%d in the wall!", + cast([unsafe])(asector-&XLevel.Sectors[0]), + cast([unsafe])(ldef-&XLevel.Lines[0]), thingidx); + } } if (mdir) { - if (specified_thingidx) printdebug("sector #%d: move light #%d out of the walls with %s!", asector-&XLevel.Sectors[0], thingidx, mdir); + if (thingidx!specified) { + printdebug("sector #%d: move light #%d out of the walls with %s!", + cast([unsafe])(asector-&XLevel.Sectors[0]), thingidx, mdir); + } org += mdir*4; } } @@ -1041,7 +1048,7 @@ final void NightmareRespawn () { // inherit attributes from deceased one A = SpawnEntityChecked(class!EntityEx, class!EntityEx(Class), vector(x, y, z), default, default, AllowReplace:false); if (A) { - Level.CopyMThing(&SpawnPoint, &A.SpawnPoint); + Level.CopyMThing(cast([unsafe])(&SpawnPoint), cast([unsafe])(&A.SpawnPoint)); A.Angles.yaw = float(45*(SpawnPoint.angle/45)); if (SpawnPoint.options&LineSpecialLevelInfo::MTF_AMBUSH) A.bAmbush = true; @@ -1795,7 +1802,7 @@ override void OnMapSpawn (mthing_t *mthing) { return; } - Level.CopyMThing(mthing, &SpawnPoint); + Level.CopyMThing(mthing, cast([unsafe])(&SpawnPoint)); float x = mthing->x; float y = mthing->y; @@ -4329,7 +4336,7 @@ final bool UseLinesOld (float UseRange, float UseThingRange, name FailSound, //========================================================================== final bool CheckSwitchRange (line_t *ld, int side, TVec hitpoint, ref bool failSound) { if (ld.sidenum[side] < 0) return false; // wtf?! - side_t *sd = &XLevel.Sides[ld.sidenum[side]]; + side_t *sd = cast([unsafe])(&XLevel.Sides[ld.sidenum[side]]); float ehgt = fmax(0.0, Height); //float ez0 = Origin.z; diff --git a/progs/common/linespec/linespec/LineSpecialGameInfo.vc b/progs/common/linespec/linespec/LineSpecialGameInfo.vc index 81a7f5745..94a6c37d3 100644 --- a/progs/common/linespec/linespec/LineSpecialGameInfo.vc +++ b/progs/common/linespec/linespec/LineSpecialGameInfo.vc @@ -494,11 +494,11 @@ void MakeSlope (VLevel InLevel, mthing_t *mthing, bool IsCeiling) { line_t *line = sec->lines[i]; if (mthing->tid == line->arg1) { if (!IsCeiling) { - plane = &sec->floor; + plane = cast([unsafe])(&sec->floor); p1 = vector(line->v1->x, line->v1->y, plane->minz); p2 = vector(line->v2->x, line->v2->y, plane->minz); } else { - plane = &sec->ceiling; + plane = cast([unsafe])(&sec->ceiling); p1 = vector(line->v1->x, line->v1->y, plane->maxz); p2 = vector(line->v2->x, line->v2->y, plane->maxz); } @@ -533,23 +533,23 @@ void SlopeLineToPoint (VLevel InLevel, mthing_t *mthing, bool IsCeiling) { sector_t *sec = InLevel.PointInSector(vector(mthing->x, mthing->y, 0.0)); if (!IsCeiling) { - plane = &sec->floor; + plane = cast([unsafe])(&sec->floor); } else { - plane = &sec->ceiling; + plane = cast([unsafe])(&sec->ceiling); } p1 = vector(mthing->x, mthing->y, 0.0); p1.z = GetPlanePointZ(ref *plane, p1)+mthing->height; foreach (auto i; 0..InLevel.Lines.length) { - line_t *line = &InLevel.Lines[i]; + line_t *line = cast([unsafe])(&InLevel.Lines[i]); if (!IsLineTagEqual(line, mthing->args[1-1])) continue; sec = (PointOnPlaneSide(p1, *line) == 0 ? line->frontsector : line->backsector); if (sec == nullptr) continue; if (!IsCeiling) { - plane = &sec->floor; + plane = cast([unsafe])(&sec->floor); } else { - plane = &sec->ceiling; + plane = cast([unsafe])(&sec->ceiling); } p2 = *line->v1; @@ -590,11 +590,11 @@ void SetSlope (VLevel InLevel, mthing_t *mthing, bool IsCeiling) { sector_t *sec = InLevel.PointInSector(vector(mthing->x, mthing->y, 0.0)); if (!sec) FatalError("point (%f,%f) is not in level", mthing->x, mthing->y); if (!IsCeiling) { - plane = &sec->floor; + plane = cast([unsafe])(&sec->floor); //if (plane.normal.z == 0) FatalError("SetSlope: invalid floor in sector #%d (%v)", calcSecIdx(InLevel, sec), plane.normal); //print("SetSlope; sector %d (floor); %s; plane.dist=%f; plane.normal=%v", calcSecIdx(InLevel, sec), plane, plane.dist, plane.normal); } else { - plane = &sec->ceiling; + plane = cast([unsafe])(&sec->ceiling); //if (plane.normal.z == 0) FatalError("SetSlope: invalid ceiling in sector #%d (%v)", calcSecIdx(InLevel, sec), plane.normal); //print("SetSlope; sector %d (ceiling); %s; plane.dist=%f; plane.normal=%v", calcSecIdx(InLevel, sec), plane, plane.dist, plane.normal); } @@ -622,7 +622,7 @@ void SetSlope (VLevel InLevel, mthing_t *mthing, bool IsCeiling) { foreach (auto lidx, line_t *ln; sec.lines) { foreach (int snum; 0..2) { if (ln.sidenum[snum] >= 0) { - side_t *sd = &InLevel.Sides[ln.sidenum[snum]]; + side_t *sd = cast([unsafe])(&InLevel.Sides[ln.sidenum[snum]]); // floor if (!IsCeiling && sd.BottomTexture <= 0) { //print("F-FUUUUUUUU! (%s:%s) %s", lidx, snum, sec.floor.pic); @@ -652,7 +652,7 @@ bool SetVertexHeights (VLevel InLevel, int ThingID) { foreach (auto i; 0..InLevel.Vertexes.length) InLevel.Vertexes[i].z = 0.1; foreach (auto j; 0..InLevel.Things.length) { - mthing_t *mthing = &InLevel.Things[j]; + mthing_t *mthing = cast([unsafe])(&InLevel.Things[j]); if (mthing->type == ThingID) { foreach (auto i; 0..InLevel.Vertexes.length) { if (InLevel.Vertexes[i].x == mthing->x && @@ -692,7 +692,7 @@ void MakeVertexFloorHeights (VLevel InLevel) { if (!SetVertexHeights(InLevel, FLOOR_VERTEX_HEIGHT_TYPE)) return; foreach (auto i; 0..InLevel.Sectors.length) { - sector_t *sec = &InLevel.Sectors[i]; + sector_t *sec = cast([unsafe])(&InLevel.Sectors[i]); if (sec.lines.length != 3) continue; p1 = *sec->lines[0]->v1; p2 = *sec->lines[0]->v2; @@ -733,7 +733,7 @@ void MakeVertexCeilingHeights (VLevel InLevel) { if (!SetVertexHeights(InLevel, CEILING_VERTEX_HEIGHT_TYPE)) return; foreach (auto i; 0..InLevel.Sectors.length) { - sector_t *sec = &InLevel.Sectors[i]; + sector_t *sec = cast([unsafe])(&InLevel.Sectors[i]); if (sec.lines.length != 3) continue; p1 = *sec->lines[0]->v1; p2 = *sec->lines[0]->v2; @@ -795,7 +795,7 @@ void AlignPlane (VLevel InLevel, sector_t *sec, line_t *line, int which, int lin sector_t *refsec = (line.frontsector == sec ? line.backsector : line.frontsector); - sec_plane_t *srcplane = (which == 0 ? &sec.floor : &sec.ceiling); + sec_plane_t *srcplane = (which == 0 ? cast([unsafe])(&sec.floor) : cast([unsafe])(&sec.ceiling)); float srcheight = (which == 0 ? sec.floor.TexZ : sec.ceiling.TexZ); float destheight = (which == 0 ? refsec.floor.TexZ : refsec.ceiling.TexZ); @@ -823,7 +823,7 @@ void AlignPlane (VLevel InLevel, sector_t *sec, line_t *line, int which, int lin foreach (auto lidx, line_t *ln; sec.lines) { foreach (int snum; 0..2) { if (ln.sidenum[snum] >= 0) { - side_t *sd = &InLevel.Sides[ln.sidenum[snum]]; + side_t *sd = cast([unsafe])(&InLevel.Sides[ln.sidenum[snum]]); // floor if (which == 0 && sd.BottomTexture <= 0) { //print("F-FUUUUUUUU! (%s:%s) %s", lidx, snum, sec.floor.pic); @@ -848,7 +848,7 @@ void AlignPlane (VLevel InLevel, sector_t *sec, line_t *line, int which, int lin //========================================================================== void SetSlopes (VLevel InLevel) { foreach (auto i; 0..InLevel.Lines.length) { - line_t *line = &InLevel.Lines[i]; + line_t *line = cast([unsafe])(&InLevel.Lines[i]); if (line.special == LNSPEC_PlaneAlign) { line.special = 0; line.lineTag = InLevel.Lines[i].arg3; @@ -884,7 +884,7 @@ void SetSlopes (VLevel InLevel) { //========================================================================== void ProcessCopySlopes (VLevel InLevel) { foreach (auto i; 0..InLevel.Lines.length) { - line_t *line = &InLevel.Lines[i]; + line_t *line = cast([unsafe])(&InLevel.Lines[i]); if (line.special == LNSPEC_PlaneCopy) { line.special = 0; CopyPlaneBetweenTaggedSectors(InLevel, line.frontsector, line.arg1, IsCeiling:false); // front floor @@ -971,8 +971,8 @@ void SpawnExtraFloors (VLevel InLevel, line_t *line, bool isEDGE) { } int tag = line->arg1+(line->arg1&8 ? 0 : line->arg5); foreach (auto j; 0..InLevel.Sectors.length) { - if (IsSectorTagEqual(&InLevel.Sectors[j], tag)) { - InLevel.AddExtraFloor(line, &InLevel.Sectors[j]); + if (IsSectorTagEqual(cast([unsafe])(&InLevel.Sectors[j]), tag)) { + InLevel.AddExtraFloor(line, cast([unsafe])(&InLevel.Sectors[j])); } } } @@ -1267,7 +1267,7 @@ override void SpawnWorld (VLevel InLevel) { // set up tagged lines if (!InLevel.bTextMap) { foreach (auto i; 0..InLevel.Lines.length) { - line_t *line = &InLevel.Lines[i]; + line_t *line = cast([unsafe])(&InLevel.Lines[i]); switch (line->special) { case LNSPEC_LineSetIdentification: line->special = 0; @@ -1320,7 +1320,7 @@ override void SpawnWorld (VLevel InLevel) { // CEILING_VERTEX_HEIGHT_TYPE foreach (auto i; 0..InLevel.Things.length) { - mthing_t *mthing = &InLevel.Things[i]; + mthing_t *mthing = cast([unsafe])(&InLevel.Things[i]); switch (mthing->type) { case FLOOR_SLOPE_TYPE: //print("SLOPE: FLOOR_SLOPE_TYPE"); @@ -1356,7 +1356,7 @@ override void SpawnWorld (VLevel InLevel) { } foreach (auto i; 0..InLevel.Things.length) { - mthing_t *mthing = &InLevel.Things[i]; + mthing_t *mthing = cast([unsafe])(&InLevel.Things[i]); if (mthing->type == COPY_FLOOR_PLANE_TYPE || mthing->type == COPY_CEILING_PLANE_TYPE) { @@ -1376,7 +1376,7 @@ override void SpawnWorld (VLevel InLevel) { // set up 3D floors, transfers of light, etc. foreach (auto i; 0..InLevel.Lines.length) { - line_t *line = &InLevel.Lines[i]; + line_t *line = cast([unsafe])(&InLevel.Lines[i]); switch (line->special) { // arg5 is non-zero for EDGE "thin floors" // we need to set ceiling height equal to floor height in their control sector @@ -1494,13 +1494,13 @@ override void SpawnWorld (VLevel InLevel) { // process translucent lines foreach (auto i; 0..InLevel.Lines.length) { - line_t *line = &InLevel.Lines[i]; + line_t *line = cast([unsafe])(&InLevel.Lines[i]); switch (line->special) { case LNSPEC_LineTranslucent: alpha = fclamp(float(line->arg2)/255.0, 0, 255); if (line->arg1) { foreach (auto j; 0..InLevel.Lines.length) { - if (IsLineTagEqual(&InLevel.Lines[j], line->arg1)) { + if (IsLineTagEqual(cast([unsafe])(&InLevel.Lines[j]), line->arg1)) { InLevel.Lines[j].alpha = alpha; if (line->arg3 == 1) InLevel.Lines[j].flags |= ML_ADDITIVE; } @@ -1519,7 +1519,7 @@ override void SpawnWorld (VLevel InLevel) { // spawn polyobjects foreach (auto i; 0..InLevel.Things.length) { - mthing_t *mthing = &InLevel.Things[i]; + mthing_t *mthing = cast([unsafe])(&InLevel.Things[i]); switch (mthing->type) { case PO_SPAWN_TYPE_HEXEN: case PO_SPAWNCRUSH_TYPE_HEXEN: diff --git a/progs/common/linespec/linespec/LineSpecialGameInfo_LDef_Main.vc b/progs/common/linespec/linespec/LineSpecialGameInfo_LDef_Main.vc index 300d7eadf..3c573ed4e 100644 --- a/progs/common/linespec/linespec/LineSpecialGameInfo_LDef_Main.vc +++ b/progs/common/linespec/linespec/LineSpecialGameInfo_LDef_Main.vc @@ -118,10 +118,10 @@ void PerformLDefSpecialTranslation (VLevel InLevel, int OldSpec, spec_trans_t *t line->SpacFlags = 0; line->flags &= ~(ML_REPEAT_SPECIAL|ML_MONSTERSCANACTIVATE|ML_KEEPDATA); - printwarn("TRANSLATION: linedef #%s, special %d -- NOT FOUND!", line-&InLevel.Lines[0], OldSpec); + printwarn("TRANSLATION: linedef #%s, special %d -- NOT FOUND!", cast([unsafe])(line-&InLevel.Lines[0]), OldSpec); if (GetCvarB('trans_debug_log')) { print("================================================="); - print("***TRANS: linedef #%s, special %d -- NOT FOUND!", line-&InLevel.Lines[0], OldSpec); + print("***TRANS: linedef #%s, special %d -- NOT FOUND!", cast([unsafe])(line-&InLevel.Lines[0]), OldSpec); print("%s items in translation table", spec_trans_tab.length); for (auto idx = spec_trans_tab.firstIndex(); spec_trans_tab.isValidIndex(idx); idx = spec_trans_tab.nextIndex(idx)) { auto key = spec_trans_tab.keyAtIndex(idx); // pointer to key diff --git a/progs/common/linespec/linespec/LineSpecialLevelInfo.vc b/progs/common/linespec/linespec/LineSpecialLevelInfo.vc index 91bf24786..2ad36f05e 100644 --- a/progs/common/linespec/linespec/LineSpecialLevelInfo.vc +++ b/progs/common/linespec/linespec/LineSpecialLevelInfo.vc @@ -210,7 +210,7 @@ override void SpawnSpecials () { // init special sectors foreach (i; 0..XLevel.Sectors.length) { - sector = &XLevel.Sectors[i]; + sector = cast([unsafe])(&XLevel.Sectors[i]); if (!sector->special) continue; if (sector->special&SECSPEC_SECRET_MASK) ++TotalSecret; // secret sector switch (sector->special&SECSPEC_BASE_MASK) { @@ -316,7 +316,7 @@ override void SpawnSpecials () { // init line effects foreach (i; 0..XLevel.Lines.length) { - line_t *line = &XLevel.Lines[i]; + line_t *line = cast([unsafe])(&XLevel.Lines[i]); if (!line.special) continue; bool notinteresting = false; switch (line.special) { @@ -383,7 +383,7 @@ override void SpawnSpecials () { if (frontClosed != backClosed && (frontClosed || backClosed)) { // ok, some sector is closed, check if we need to transfer texture int sdidx = (backClosed ? 0 : 1); - side_t *fside = &XLevel.Sides[line.sidenum[sdidx]]; + side_t *fside = cast([unsafe])(&XLevel.Sides[line.sidenum[sdidx]]); if (!fside.TopTexture && fside.MidTexture && !fside.BottomTexture) { //print("ldef #%s: toptex=%s; csn=%s; midtex=%s; bottex=%s", line-&XLevel.Lines[0], fside.TopTexture, sdidx, fside.MidTexture, fside.BottomTexture); fside.TopTexture = fside.MidTexture; @@ -1711,14 +1711,14 @@ override void StartPlaneWatcher (Entity it, line_t *line, int lineSide, int SecNum; if (Arg1) { foreach (SecNum; 0..XLevel.Sectors.length) { - if (IsSectorTagEqual(&XLevel.Sectors[SecNum], Arg1)) break; + if (IsSectorTagEqual(cast([unsafe])(&XLevel.Sectors[SecNum]), Arg1)) break; } } else { SecNum = 1; } while (SecNum >= 0 && SecNum < XLevel.Sectors.length) { - sec = (Arg1 ? &XLevel.Sectors[SecNum] : Line->backsector); + sec = (Arg1 ? cast([unsafe])(&XLevel.Sectors[SecNum]) : Line->backsector); //OldSecNum = /*SecNum*/Sec-&XLevel.Sectors[0]; //jff 3/4/98 preserve loop index //int SecNum = OldSecNum; @@ -1762,7 +1762,7 @@ override void StartPlaneWatcher (Entity it, line_t *line, int lineSide, } sec = TSec; - SecNum = TSec-&XLevel.Sectors[0]; + SecNum = cast([unsafe])(TSec-&XLevel.Sectors[0]); Floor = SpawnThinker(FloorMover); Floor.InitStair(sec, Arg1, Arg2, Arg3, Arg4, Arg5, Generic, Height); @@ -1780,7 +1780,7 @@ override void StartPlaneWatcher (Entity it, line_t *line, int lineSide, ++SecNum; if (SecNum < 0 || SecNum > XLevel.Sectors.length) break; while (SecNum < XLevel.Sectors.length) { - if (IsSectorTagEqual(&XLevel.Sectors[SecNum], Arg1)) break; + if (IsSectorTagEqual(cast([unsafe])(&XLevel.Sectors[SecNum]), Arg1)) break; ++SecNum; } } @@ -2882,7 +2882,7 @@ override int AcsPolyRotateEx (int po, int speed, float deltaangle, int moveflags for (int hidx = XLevel.FindSectorFromTag(out sec, Line->arg1); hidx >= 0; hidx = XLevel.FindSectorFromTag(out sec, Line->arg1, hidx)) { - int secnum = sec-&XLevel.Sectors[0]; + int secnum = cast([unsafe])(sec-&XLevel.Sectors[0]); Scroller Scroll = SpawnThinker(Scroller); if (Scroll && !Scroll.IsDestroyed) { Scroll.InitGen(Scroller::SCROLLEV_Ceiling, Line, secnum); @@ -2902,7 +2902,7 @@ override int AcsPolyRotateEx (int po, int speed, float deltaangle, int moveflags for (int hidx = XLevel.FindSectorFromTag(out sec, Line->arg1); hidx >= 0; hidx = XLevel.FindSectorFromTag(out sec, Line->arg1, hidx)) { - int secnum = sec-&XLevel.Sectors[0]; + int secnum = cast([unsafe])(sec-&XLevel.Sectors[0]); if (Line->arg3 != 1) { // scroll the floor texture Scroller Scroll = SpawnThinker(Scroller); @@ -3099,7 +3099,7 @@ override int AcsPolyRotateEx (int po, int speed, float deltaangle, int moveflags for (int hidx = XLevel.FindSectorFromTag(out sec, Arg1); hidx >= 0; hidx = XLevel.FindSectorFromTag(out sec, Arg1, hidx)) { - int secnum = sec-&XLevel.Sectors[0]; + int secnum = cast([unsafe])(sec-&XLevel.Sectors[0]); Sc = SpawnThinker(Scroller); if (Sc && !Sc.IsDestroyed) { Sc.InitScripted(Type, Arg2, Arg3, secnum); @@ -3384,7 +3384,7 @@ name ConvertSpecialDamageType (int mod) { { sec.floor.xoffs = XOffs; sec.floor.yoffs = YOffs; - ClampSecPlaneOffsets(&sec.floor); + ClampSecPlaneOffsets(cast([unsafe])(&sec.floor)); } return true; } @@ -3404,7 +3404,7 @@ name ConvertSpecialDamageType (int mod) { { sec.ceiling.xoffs = XOffs; sec.ceiling.yoffs = YOffs; - ClampSecPlaneOffsets(&sec.ceiling); + ClampSecPlaneOffsets(cast([unsafe])(&sec.ceiling)); } return true; } @@ -3621,7 +3621,7 @@ name ConvertSpecialDamageType (int mod) { Line = XLevel.FindLine(Arg1, ref Searcher)) { if (Line->sidenum[Arg4] < 0) continue; - side_t *Side = &XLevel.Sides[Line->sidenum[Arg4]]; + side_t *Side = cast([unsafe])(&XLevel.Sides[Line->sidenum[Arg4]]); // X offset if (Arg2 != NoChange) { @@ -5086,7 +5086,7 @@ private transient array!Entity recSoundSectorEntities; // will be collected in n sector_t *sec; foreach (int i; 0..XLevel.Lines.length) { - line_t *l = &XLevel.Lines[i]; + line_t *l = cast([unsafe])(&XLevel.Lines[i]); switch (l->special) { case LNSPEC_SectorSetWind: // wind for (int hidx = XLevel.FindSectorFromTag(out sec, l->arg1); hidx >= 0; @@ -5094,7 +5094,7 @@ private transient array!Entity recSoundSectorEntities; // will be collected in n { Pusher P = SpawnThinker(Pusher); if (P && !P.IsDestroyed) { - P.Init(Pusher::PUSHER_Wind, l->arg4 ? l : nullptr, l->arg2, l->arg3, none, sec-&XLevel.Sectors[0]); + P.Init(Pusher::PUSHER_Wind, l->arg4 ? l : nullptr, l->arg2, l->arg3, none, cast([unsafe])(sec-&XLevel.Sectors[0])); } } break; @@ -5105,7 +5105,7 @@ private transient array!Entity recSoundSectorEntities; // will be collected in n { Pusher P = SpawnThinker(Pusher); if (P && !P.IsDestroyed) { - P.Init(Pusher::PUSHER_Current, l->arg4 ? l : nullptr, l->arg2, l->arg3, none, sec-&XLevel.Sectors[0]); + P.Init(Pusher::PUSHER_Current, l->arg4 ? l : nullptr, l->arg2, l->arg3, none, cast([unsafe])(sec-&XLevel.Sectors[0])); } } break; @@ -5116,7 +5116,7 @@ private transient array!Entity recSoundSectorEntities; // will be collected in n for (int hidx = XLevel.FindSectorFromTag(out sec, l->arg1); hidx >= 0; hidx = XLevel.FindSectorFromTag(out sec, l->arg1, hidx)) { - int ssnum = sec-&XLevel.Sectors[0]; + int ssnum = cast([unsafe])(sec-&XLevel.Sectors[0]); EntityEx thing = GetPushThing(ssnum); if (thing) { // No MT_P* means no effect @@ -5138,7 +5138,7 @@ private transient array!Entity recSoundSectorEntities; // will be collected in n for (s = 0; s < XLevel.Sectors.length; ++s) if (&XLevel.Sectors[s] == thing.Sector) break; */ if (!thing.Sector) continue; - int s = thing.Sector-&XLevel.Sectors[0]; + int s = cast([unsafe])(thing.Sector-&XLevel.Sectors[0]); Pusher P = SpawnThinker(Pusher); if (P && !P.IsDestroyed) { P.Init(Pusher::PUSHER_Push, l->arg4 ? l : nullptr, l->arg3, 0, thing, s); @@ -5180,7 +5180,7 @@ private transient array!Entity recSoundSectorEntities; // will be collected in n for (int hidx = XLevel.FindSectorFromTag(out sec, tag); hidx >= 0; hidx = XLevel.FindSectorFromTag(out sec, tag, hidx)) { - int secnum = sec-&XLevel.Sectors[0]; + int secnum = cast([unsafe])(sec-&XLevel.Sectors[0]); for (P = Collection; P; P = P.AdjustLink) { if (P.Affectee == secnum) break; } @@ -5793,7 +5793,7 @@ override void SpawnMapThing (mthing_t *mthing) { // count deathmatch start positions if (mthing.type == 11) { DeathmatchStarts.length += 1; - CopyMThing(mthing, &DeathmatchStarts[$-1]); + CopyMThing(mthing, cast([unsafe])(&DeathmatchStarts[$-1])); return; } @@ -5850,7 +5850,7 @@ override void SpawnMapThing (mthing_t *mthing) { if (IsPlayerStart) { // save spots for respawning in network games PlayerStarts.length += 1; - CopyMThing(mthing, &PlayerStarts[$-1]); + CopyMThing(mthing, cast([unsafe])(&PlayerStarts[$-1])); return; } @@ -6061,9 +6061,9 @@ bool StartConversation (EntityEx User, EntityEx UseOn) { } if (SpeechNum < 0) { - Speech = &XLevel.GenericSpeeches[-SpeechNum-1]; + Speech = cast([unsafe])(&XLevel.GenericSpeeches[-SpeechNum-1]); } else { - Speech = &XLevel.LevelSpeeches[SpeechNum-1]; + Speech = cast([unsafe])(&XLevel.LevelSpeeches[SpeechNum-1]); } if (Speech->JumpToConv && @@ -6174,12 +6174,12 @@ final class!EntityEx GetClassFromID (int ID) { } if (CurrentSpeechIndex < 0) { - Speech = &XLevel.GenericSpeeches[-CurrentSpeechIndex-1]; + Speech = cast([unsafe])(&XLevel.GenericSpeeches[-CurrentSpeechIndex-1]); } else { - Speech = &XLevel.LevelSpeeches[CurrentSpeechIndex-1]; + Speech = cast([unsafe])(&XLevel.LevelSpeeches[CurrentSpeechIndex-1]); } - Choice = &Speech->Choices[ChoiceNum-1]; + Choice = cast([unsafe])(&Speech->Choices[ChoiceNum-1]); // check if player has needed items Item1 = CheckForNeededItem(CurrentSpeakingTo, Choice->NeedItem1, Choice->NeedAmount1); Item2 = CheckForNeededItem(CurrentSpeakingTo, Choice->NeedItem2, Choice->NeedAmount2); diff --git a/progs/common/linespec/player/PlayerEx.vc b/progs/common/linespec/player/PlayerEx.vc index 8f8375510..ee8c25b43 100644 --- a/progs/common/linespec/player/PlayerEx.vc +++ b/progs/common/linespec/player/PlayerEx.vc @@ -2737,7 +2737,7 @@ void DecalEffect (TVec org, name dectype, int side, int lineidx, optional int tr { if (!dectype || lineidx < 0 || !Level.XLevel) return; // just in case if (lineidx >= Level.XLevel.Lines.length) return; - Level.XLevel.AddDecal(org, dectype, side, &Level.XLevel.Lines[lineidx], + Level.XLevel.AddDecal(org, dectype, side, cast([unsafe])(&Level.XLevel.Lines[lineidx]), translation:translation!optional, shadeclr:shadeclr!optional, alpha:alpha!optional, animator:animator!optional, permanent:permanent!optional, angle:angle!optional, forceFlipX:forceFlipX!optional); } @@ -3420,7 +3420,7 @@ mthing_t *PerformRebornSpawn () { mthing_t *bestOther = nullptr; float bestOtherDist = float.max; foreach (auto i; 0..Level.PlayerStarts.length) { - auto sp = &Level.PlayerStarts[i]; + auto sp = cast([unsafe])(&Level.PlayerStarts[i]); if (sp.type == GetPlayerNum()+1) { if (sp.args[0] == Level.Game.RebornPosition) { // i found her! @@ -3662,7 +3662,7 @@ void DeathMatchSpawnPlayer () { } foreach (int i; dms) { - auto sp = &Level.DeathmatchStarts[i]; + auto sp = cast([unsafe])(&Level.DeathmatchStarts[i]); if (CheckSpot(sp)) { SpawnPlayer(sp, false); return; diff --git a/progs/common/linespec/secthink/Scroller.vc b/progs/common/linespec/secthink/Scroller.vc index b6e089fd5..5dc282491 100644 --- a/progs/common/linespec/secthink/Scroller.vc +++ b/progs/common/linespec/secthink/Scroller.vc @@ -55,7 +55,7 @@ int SideParts; void InitFloor (sector_t *InSector, int XDir, int YDir, int InSpeed) { if (!InSector || (XDir|YDir) == 0 || InSpeed < 0) { Destroy(); return; } Sector = InSector; - Affectee = Sector-&XLevel.Sectors[0]; + Affectee = cast([unsafe])(Sector-&XLevel.Sectors[0]); Type = SCROLLEV_Floor; //InSpeed = min(InSpeed, 31); //FIXME //float spd = float(1<frontsector) { + if (cast([unsafe])(&XLevel.Sectors[i]) == SrcLine->frontsector) { Control = i; break; } @@ -233,7 +233,7 @@ void InitGen (int InType, line_t *SrcLine, int InAffectee) { if (!SrcLine || InAffectee < 0 || InAffectee >= XLevel.Sectors.length) { Destroy(); return; } Type = InType; Affectee = InAffectee; - Sector = &XLevel.Sectors[Affectee]; + Sector = cast([unsafe])(&XLevel.Sectors[Affectee]); if (SrcLine->arg2&4) { // the line housing the special controls the direction and speed of scrolling XSpeed = (SrcLine->v2->x-SrcLine->v1->x); @@ -260,7 +260,7 @@ void InitGen (int InType, line_t *SrcLine, int InAffectee) { if (SrcLine->arg2&3) { // if 1, then displacement // if 2, then accelerative (also if 3) - Control = (SrcLine->frontsector ? SrcLine->frontsector-&XLevel.Sectors[0] : -1); + Control = (SrcLine->frontsector ? cast([unsafe])(SrcLine->frontsector-&XLevel.Sectors[0]) : -1); if (SrcLine->arg2&2) bAccel = true; } if (Control != -1) { @@ -282,7 +282,7 @@ void InitScripted (int InType, int Arg2, int Arg3, int InAffectee) { if (InAffectee < 0 || InAffectee >= XLevel.Sectors.length) { Destroy(); return; } Type = InType; Affectee = InAffectee; - Sector = &XLevel.Sectors[Affectee]; + Sector = cast([unsafe])(&XLevel.Sectors[Affectee]); // the speed and direction are parameters to the special XSpeed = float(Arg2)*35.0/32.0; YSpeed = float(Arg3)*35.0/32.0; @@ -368,17 +368,17 @@ override void Tick (float DeltaTime) { XLevel.Sides[Affectee].Bot.TextureOffset += XDelta; XLevel.Sides[Affectee].Bot.RowOffset += YDelta; } - LineSpecialLevelInfo(Level).ClampSideOffsets(&XLevel.Sides[Affectee]); + LineSpecialLevelInfo(Level).ClampSideOffsets(cast([unsafe])(&XLevel.Sides[Affectee])); break; case SCROLLEV_Floor: XLevel.Sectors[Affectee].floor.xoffs += XDelta; XLevel.Sectors[Affectee].floor.yoffs += YDelta; - LineSpecialLevelInfo(Level).ClampSecPlaneOffsets(&XLevel.Sectors[Affectee].floor); + LineSpecialLevelInfo(Level).ClampSecPlaneOffsets(cast([unsafe])(&XLevel.Sectors[Affectee].floor)); break; case SCROLLEV_Ceiling: XLevel.Sectors[Affectee].ceiling.xoffs += XDelta; XLevel.Sectors[Affectee].ceiling.yoffs += YDelta; - LineSpecialLevelInfo(Level).ClampSecPlaneOffsets(&XLevel.Sectors[Affectee].ceiling); + LineSpecialLevelInfo(Level).ClampSecPlaneOffsets(cast([unsafe])(&XLevel.Sectors[Affectee].ceiling)); break; case SCROLLEV_Carry: CarryScrollX = XDelta; diff --git a/progs/common/linespec/secthink/WallLightTransfer.vc b/progs/common/linespec/secthink/WallLightTransfer.vc index d9559fb54..887f00680 100644 --- a/progs/common/linespec/secthink/WallLightTransfer.vc +++ b/progs/common/linespec/secthink/WallLightTransfer.vc @@ -49,13 +49,13 @@ void Init (sector_t *InSector, int Arg1, int Arg2, int Arg3, int Arg4, int Arg5) // do a manual search, because tags hash is not yet set up. foreach (auto i; 0..XLevel.Lines.length) { - if (IsLineTagEqual(&XLevel.Lines[i], TargetId)) { - line_t *Line = &XLevel.Lines[i]; + if (IsLineTagEqual(cast([unsafe])(&XLevel.Lines[i]), TargetId)) { + line_t *Line = cast([unsafe])(&XLevel.Lines[i]); snums[0] = (Flags&WLF_SIDE1 ? Line->sidenum[0] : -1); snums[1] = (Flags&WLF_SIDE2 ? Line->sidenum[1] : -1); foreach (auto sidx; snums) { if (sidx < 0) continue; - side_t *side = &XLevel.Sides[sidx]; + side_t *side = cast([unsafe])(&XLevel.Sides[sidx]); side.Light = Sector->params.lightlevel; side.bAbsLight = true; } diff --git a/progs/common/linespec/secthink/movers/SectorMover.vc b/progs/common/linespec/secthink/movers/SectorMover.vc index fe25ef811..216b96f09 100644 --- a/progs/common/linespec/secthink/movers/SectorMover.vc +++ b/progs/common/linespec/secthink/movers/SectorMover.vc @@ -125,14 +125,14 @@ final bool MoveLinkedSectorsPlane (sector_t *sec, int floorOrCeiling, const ref if (!floordelta) return true; float texdelta = (!floorOrCeiling ? sec->floor.TexZ-saved.lastTexZ : sec->ceiling.TexZ-saved.lastTexZ); - int sidx = sec-&XLevel.Sectors[0]; + int sidx = cast([unsafe])(sec-&XLevel.Sectors[0]); if (sidx >= XLevel.sectorlinkStart.length) return true; origLinkPlanes.reset(); // so we would be able to restore them int snum = XLevel.sectorlinkStart[sidx]; while (snum >= 0) { //print("moving linked sector #%d (control is #%d)", XLevel.sectorlinks[snum].index, sidx); - sector_t *sc = &XLevel.Sectors[XLevel.sectorlinks[snum].index]; + sector_t *sc = cast([unsafe])(&XLevel.Sectors[XLevel.sectorlinks[snum].index]); if (!forced) { auto sv = origLinkPlanes.alloc(); if (!floorOrCeiling) { diff --git a/progs/common/uibase/client/StatusBarShared.notifymsg.vc b/progs/common/uibase/client/StatusBarShared.notifymsg.vc index d665a338f..10276b686 100644 --- a/progs/common/uibase/client/StatusBarShared.notifymsg.vc +++ b/progs/common/uibase/client/StatusBarShared.notifymsg.vc @@ -74,7 +74,7 @@ void AllocMessageSlot (int maxcount, ref array!NotifyMessage list, ref int count // find existing message NotifyMessage *msg; for (int n = count-1; n >= 0; --n) { - msg = &list[n]; + msg = cast([unsafe])(&list[n]); assert(msg.time > 0.0); if (msg.nick == nick && msg.text == s) { ++msg.dupcount; @@ -91,7 +91,7 @@ void AllocMessageSlot (int maxcount, ref array!NotifyMessage list, ref int count if (list.length < maxcount) list.length = maxcount; ++count; } - msg = &list[count-1]; + msg = cast([unsafe])(&list[count-1]); msg.dupcount = 1; msg.nick = nick; msg.text = s; diff --git a/progs/common/uibase/condlg/ConDialog.vc b/progs/common/uibase/condlg/ConDialog.vc index 551f77a06..66d0169a2 100644 --- a/progs/common/uibase/condlg/ConDialog.vc +++ b/progs/common/uibase/condlg/ConDialog.vc @@ -65,10 +65,10 @@ void SetSpeech (EntityEx Speaker, int SpeechNum) { if (SpeechNum < 0) { SpeechNum = -SpeechNum; if (SpeechNum > ClGame.GLevel.GenericSpeeches.length) return; - Speech = &ClGame.GLevel.GenericSpeeches[SpeechNum-1]; + Speech = cast([unsafe])(&ClGame.GLevel.GenericSpeeches[SpeechNum-1]); } else { if (SpeechNum > ClGame.GLevel.LevelSpeeches.length) return; - Speech = &ClGame.GLevel.LevelSpeeches[SpeechNum-1]; + Speech = cast([unsafe])(&ClGame.GLevel.LevelSpeeches[SpeechNum-1]); } if (Speech.BackPic) BackPic = R_RegisterPic(Speech.BackPic); diff --git a/progs/doom/cgame/IntermissionScreen.vc b/progs/doom/cgame/IntermissionScreen.vc index b7361a488..d2a4ddcfa 100644 --- a/progs/doom/cgame/IntermissionScreen.vc +++ b/progs/doom/cgame/IntermissionScreen.vc @@ -198,8 +198,8 @@ void Start () { */ if (!checkForDoom2()) { - FindEpisodeAndMap(ClGame.im.LeaveMap, &im_episode, &im_map); - FindEpisodeAndMap(ClGame.im.EnterMap, &im_nextepisode, &im_nextmap); + FindEpisodeAndMap(ClGame.im.LeaveMap, out im_episode, out im_map); + FindEpisodeAndMap(ClGame.im.EnterMap, out im_nextepisode, out im_nextmap); } IM_InitAnimatedBack(); @@ -237,18 +237,18 @@ void Start () { // FindEpisodeAndMap // //========================================================================== -void FindEpisodeAndMap (name Name, int *epi, int *map) { +void FindEpisodeAndMap (name Name, out int epi, out int map) { foreach (auto e; 1..4) { foreach (auto m; 1..10) { if (Name == name(va("e%dm%d", e, m))) { - *epi = e; - *map = m; + epi = e; + map = m; return; } } } - *epi = 4; - *map = 1; + epi = 4; + map = 1; } @@ -1075,8 +1075,8 @@ void IM_InitText () { //printdebug("phase=%s; next=%s", ClGame.intermissionPhase, ClGame.GLevel.LevelInfo.NextMap); IntermissionText *itext = - ClGame.intermissionPhase == ClientGame::IM_Phase.Leave ? &ClGame.im.LeaveText : - ClGame.intermissionPhase == ClientGame::IM_Phase.Enter ? &ClGame.im.EnterText : + ClGame.intermissionPhase == ClientGame::IM_Phase.Leave ? cast([unsafe])(&ClGame.im.LeaveText) : + ClGame.intermissionPhase == ClientGame::IM_Phase.Enter ? cast([unsafe])(&ClGame.im.EnterText) : nullptr; // do not skip exit text diff --git a/progs/heretic/cgame/IntermissionScreen.vc b/progs/heretic/cgame/IntermissionScreen.vc index ba5095216..b5d48ba22 100644 --- a/progs/heretic/cgame/IntermissionScreen.vc +++ b/progs/heretic/cgame/IntermissionScreen.vc @@ -88,8 +88,8 @@ IntermissionBackground Background; //========================================================================== void Start () { StopAllSounds(keepLastSwitch:true); - FindEpisodeAndMap(ClGame.im.LeaveMap, &im_episode, &im_map); - FindEpisodeAndMap(ClGame.im.EnterMap, &im_nextepisode, &im_nextmap); + FindEpisodeAndMap(ClGame.im.LeaveMap, out im_episode, out im_map); + FindEpisodeAndMap(ClGame.im.EnterMap, out im_nextepisode, out im_nextmap); if (!Background) { Background = NewChild(IntermissionBackground); @@ -107,19 +107,19 @@ void Start () { // FindEpisodeAndMap // //========================================================================== -void FindEpisodeAndMap (name Name, int *epi, int *map) { +void FindEpisodeAndMap (name Name, out int epi, out int map) { string sn = string(Name); foreach (auto e; 1..6) { foreach (auto m; 1..10) { if (sn == va("e%dm%d", e, m)) { - *epi = e; - *map = m; + epi = e; + map = m; return; } } } - *epi = 4; - *map = 1; + epi = 4; + map = 1; } @@ -601,8 +601,8 @@ void IM_InitText () { } IntermissionText *itext = - ClGame.intermissionPhase == ClientGame::IM_Phase.Leave ? &ClGame.im.LeaveText : - ClGame.intermissionPhase == ClientGame::IM_Phase.Enter ? &ClGame.im.EnterText : + ClGame.intermissionPhase == ClientGame::IM_Phase.Leave ? cast([unsafe])(&ClGame.im.LeaveText) : + ClGame.intermissionPhase == ClientGame::IM_Phase.Enter ? cast([unsafe])(&ClGame.im.EnterText) : nullptr; if (ClGame.cl.Level.bNoIntermission) itext = nullptr; diff --git a/progs/hexen/cgame/IntermissionScreen.vc b/progs/hexen/cgame/IntermissionScreen.vc index efe3d5f62..f1cd6ba00 100644 --- a/progs/hexen/cgame/IntermissionScreen.vc +++ b/progs/hexen/cgame/IntermissionScreen.vc @@ -211,8 +211,8 @@ void IM_InitStats () { //======================================================================== void IM_InitHubText () { IntermissionText *itext = - ClGame.intermissionPhase == ClientGame::IM_Phase.Leave ? &ClGame.im.LeaveText : - ClGame.intermissionPhase == ClientGame::IM_Phase.Enter ? &ClGame.im.EnterText : + ClGame.intermissionPhase == ClientGame::IM_Phase.Leave ? cast([unsafe])(&ClGame.im.LeaveText) : + ClGame.intermissionPhase == ClientGame::IM_Phase.Enter ? cast([unsafe])(&ClGame.im.EnterText) : nullptr; if (ClGame.cl.Level.bNoIntermission) { diff --git a/progs/strife/cgame/IntermissionScreen.vc b/progs/strife/cgame/IntermissionScreen.vc index a6c1c9c5e..ce7f804e0 100644 --- a/progs/strife/cgame/IntermissionScreen.vc +++ b/progs/strife/cgame/IntermissionScreen.vc @@ -117,8 +117,8 @@ override void OnDraw() void IM_InitHubText() { IntermissionText *itext = - ClGame.intermissionPhase == ClientGame::IM_Phase.Leave ? &ClGame.im.LeaveText : - ClGame.intermissionPhase == ClientGame::IM_Phase.Enter ? &ClGame.im.EnterText : + ClGame.intermissionPhase == ClientGame::IM_Phase.Leave ? cast([unsafe])(&ClGame.im.LeaveText) : + ClGame.intermissionPhase == ClientGame::IM_Phase.Enter ? cast([unsafe])(&ClGame.im.EnterText) : nullptr; if (!itext.Text) diff --git a/progs/strife/game/StrifeLevelInfo.vc b/progs/strife/game/StrifeLevelInfo.vc index 7b8a92688..93d974658 100644 --- a/progs/strife/game/StrifeLevelInfo.vc +++ b/progs/strife/game/StrifeLevelInfo.vc @@ -182,7 +182,9 @@ override int ExecuteActionSpecial (int Special, int Arg1, int Arg2, int Arg3, // Arg3 is tag bool isdm = (Level.Game.netgame && Level.Game.deathmatch); EntityEx e = EntityEx(ent); - printdebug("%C: exec special #%d (%d,%d,%d,%d,%d) (A=%C; line=%d; side=%d)", self, Special, Arg1, Arg2, Arg3, Arg4, Arg5, ent, (line ? line-&XLevel.Lines[0] : -1), side); + printdebug("%C: exec special #%d (%d,%d,%d,%d,%d) (A=%C; line=%d; side=%d)", self, Special, + Arg1, Arg2, Arg3, Arg4, Arg5, ent, + (line ? cast([unsafe])(line-&XLevel.Lines[0]) : -1), side); int type = Arg2; int tag = Arg3; int res = 0; -- 2.11.4.GIT