**REPORTED** [1.4.3]Wrong room evil check range

westgrass

Terrarian
Steam or GOG
Steam
Single Player/Multiplayer
Both
Operating System
Windows 10
Terraria Version
1.4.2.3
Controls Used
Keyboard/Mouse
In Terraria.WorldGen, method ScoreRoom(), there is:
Code:
            int num4 = roomX1 - Main.buffScanAreaWidth / 2 / 16 - 1 - num3;
            int num5 = roomX2 + Main.buffScanAreaWidth / 2 / 16 + 1 + num3;
            int num6 = roomY1 - Main.buffScanAreaHeight / 2 / 16 - 1 - num3;
            int num7 = roomY2 + Main.buffScanAreaHeight / 2 / 16 + 1 + num3;
It is used to determine the check range for room evil score. The /16 is used to convert length values in pixels to in blocks.
But, Main.buffScanAreaWidth and Main.buffScanAreaHeight are already in blocks:
Code:
        public static int buffScanAreaWidth = (maxScreenW + 800) / 16 - 1;
        public static int buffScanAreaHeight = (maxScreenH + 800) / 16 - 1;
Therefore, the check range is much small then intented. The right code here should be(without /16 ):
Code:
            int num4 = roomX1 - Main.buffScanAreaWidth / 2 - 1 - num3;
            int num5 = roomX2 + Main.buffScanAreaWidth / 2 + 1 + num3;
            int num6 = roomY1 - Main.buffScanAreaHeight / 2 - 1 - num3;
            int num7 = roomY2 + Main.buffScanAreaHeight / 2 + 1 + num3;

This can be further proved by the old code. In v1.0.0.0, the code here was:
Code:
            int num5 = roomX1 - Main.screenWidth / 2 / 16 - 1 - 21;
            int num6 = roomX2 + Main.screenWidth / 2 / 16 + 1 + 21;
            int num7 = roomY1 - Main.screenHeight / 2 / 16 - 1 - 21;
            int num8 = roomY2 + Main.screenHeight / 2 / 16 + 1 + 21;
here Main.screenWidth and Main.screenHeight were in pixels:
Code:
        public static int screenWidth = 800;
        public static int screenHeight = 600;
 
Last edited:
So, we took a look at this, and it has been like this at LEAST since 1.2.4, if not longer, though you are correct that the code is faulty.

Whether or not the original detection size was meant to be much larger or not, fixing this is a dramatic increase (a nerf, from the player's perspective) to the size of the detection, and has been the standard for Terraria for the better part of it's history, so we the current size detected is our "intended" size, for all intents and purposes.

The code is going to be reworked to be less confusing and properly detect for the current range which is being checked.
 
Back
Top Bottom