• PC NEWS: 1.4.2.3 update is out! More info here. Report bugs here
  • CONSOLE 1.4 NEWS: On Aug 25 Journey's End was submitted to Microsoft and Sony! The timing of the review process is a bit unpredictable, so we cannot give you a specific "launch date" just yet. Click here for more info. The plan is to have the update on Switch out later this year. Stay up to date with console news here
  • MOBILE NEWS: Stay up to date with the latest mobile news here. Report mobile bugs here

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:
Top Bottom