A potentially growing list of bugs that apply to 1.4 and likely earlier versions.

EQNX

Terrarian
Steam or GOG
Steam
Single Player/Multiplayer
Both
Operating System
Windows 10
Terraria Version
1.4.2.3
Controls Used
Keyboard/Mouse
Hey Team,

I've been poking around in Terraria's code with ILSpy, learning specifics of various mechanics for a custom map that I've been working on. I was instructed to post my bug findings here. Hopefully this format works well for you.

Terraria.Projectile.GetFishingPondState():
Problem: while (Main.tile[i, num].liquid > 0 && !WorldGen.SolidTile(i, num) && num < Main.maxTilesY - 10)
Reason: Immediately inside this loop is numWaters++ followed by num++. This num++ needs to be moved to after the if statement that immediately follows it. Its current structure allows players to fish for water rewards from honey and lava pools that are 1 tile tall.

Terraria.NPC.AI(): aistyle == 27 (WoF)
Problem: while (num352 < 15 && num353 > Main.UnderworldLayer) and while (num352 < 15 && num353 < Main.maxTilesY - 10)
Reason: The [> Main.UnderworldLayer] and [< Main.maxTilesY - 10] should be swapped. It's currently always true, as it's written. Swapping the two would limit the WoF to 190 tiles tall, which I believe was intended. WoF is currently able to span the entire height of the world. Kinda strange being able to win the fight from the surface by attacking the upper eye.

Terraria.Liquid.SettleWaterAt():
Problem: if ((tile3.liquid != 0 && (!flag2 || num4 != 1)) || (tile3.nactive() && Main.tileSolid[tile3.type] && !Main.tileSolidTop[tile3.type]))
Reason: should not contain the || num4 != 1. This would help to drastically reduce load times for worlds with large horizontal lines of liquid. It unneccessarily checks tiles to the right, when it should be stopping immediately as it does with the left.

Minor:

Terraria.NPC.SpawnOnPlayer():
Problem: if ((Main.wallHouse[Main.tile[num20, num21].wall] && m < 999) || (Type == 50 && m < 500 && Main.tile[num21, num21].wall > 0))
Reason: Main.tile[num21, num21].wall should be [num20, num21]. Currently checking [y, y] instead of [x, y], potentially failing the first 500 attempts.

Multiple methods that result in a couple thousand useless checks performed each time an attempt is made to spawn an Underground Desert enemy.
 
Terraria.WorldGen.DropMeteor():
Problem: while ((float)num7 > (float)Main.spawnTileX - num6 && (float)num7 < (float)Main.spawnTileX + num6)
Reason: Should be "while ((float)num7 > (float)Main.spawnTileX - num6 || (float)num7 < num6)." Currently, only the left 150 tiles of a world are protected, instead of the apparently intended 336/504/672 tiles in small/medium/large worlds, respectively. The current code allows meteors to drop within the left-side ocean, even on small worlds.

Edit: Honestly, just replacing "int num7 = Main.rand.Next(150, Main.maxTilesX - 150)" with "int num7 = Main.rand.Next(num6, Main.maxTilesX - num6)" would eliminate the need for the while loop check, anyway.
 
Considering SpawnSpaceX and SpawnSpaceY are both 3, the space required to spawn a standard enemy should be 3x3, right? It's actually 2x3..

Terraria.NPC.SpawnNPC():
Problem: for (int num26 = num22; num26 < num23; num26++)
Reason: Should be " for (int num26 = num22; num26 <= num23; num26++)" num22 is spawn tile -1, num 23 is spawn tile +1. The < instead of <= causes it to only check two tiles wide, instead of three, as is apparently intended.
 
(Aaaaah!! Don't mind me, just a random player, but THANK YOU for sharing what you find! There's still so much stability and efficiency tweaking that can be done for this game, so I'm super glad someone's able to point some of this out! :dryadgrin: I love this game and want it to work as well as it can. So I just want to share my appreciation for you offering to help that happen~! :dryadpassionate:)
 
(Aaaaah!! Don't mind me, just a random player, but THANK YOU for sharing what you find! There's still so much stability and efficiency tweaking that can be done for this game, so I'm super glad someone's able to point some of this out! :dryadgrin: I love this game and want it to work as well as it can. So I just want to share my appreciation for you offering to help that happen~! :dryadpassionate:)
Thanks for showing your appreciation! I feel the same way, I've been brought so much fun from this game, so I'm more than happy to try to help the devs in any way possible.
 
Just gonna casually necro this thread -- hoping the team might just see it and include some more bug fixes in 1.4.4 ;)
 
there might be copyright issues that prevent relogic from applying your fixes as they are, and also the game source is not public which means posting parts of it as you did here is already on a gray area
i suggest contacting one of the devs in private and describing the issue there instead
 
Well there wouldn't be any copyright issue, as I haven't copyrighted anything in the thread.. What I posted isn't actually source code, it's decompiled. It's cobbled together enough that they'll be able to understand what I'm suggesting, but none of the proposed fixes I listed here could actually be implemented as-is.

That being said, I've got no idea how I would even go about contacting any of the devs ;) If anyone has any suggestions, please let me know.
 
Might as well report the broken hitbox for Brain of Cthulhu when fighting it in the Celebration seed. Not sure if it's been fixed since some time last year when I played it.
 
Nice idea to list some source code issues. There should be some explicit place to post (potential) bugs like this. Some 100% legal way to include some source code would be nice. E.g. something like a spoiler but only visible to mods and dev team.
Also found many of those in last years but haven't reported most of them.
Sometimes you also dont know if it is intended or not.

E.g. I guess
Terraria.WorldGen.DropMeteor():
Problem: while ((float)num7 > (float)Main.spawnTileX - num6 && (float)num7 < (float)Main.spawnTileX + num6)
Reason: Should be "while ((float)num7 > (float)Main.spawnTileX - num6 || (float)num7 < num6)." Currently, only the left 150 tiles of a world are protected, instead of the apparently intended 336/504/672 tiles in
is intended. It's 'spawnTileX' not 'maxTilesX'. It does save your current spawn location and not the ocean.

-------------------------------------------------------------------

Here another potential source code bug:
Many stuff doesn't get scaled properly with medium size worlds.
(edit: decided to do some extra thread about this)

-------
Or the snow biome shape depends at its side

Similar issue with Dungeon but haven't found the related source code yet. Dungeon entrance shape at the left side | and on the right side \ but can also be | in some cases. But never seen / shape at the left side.

But snow and dungeon dissimilarity aren't that important. They actually bring some more variety to world gen.
 
Last edited:
Nice idea to list some source code issues. There should be some explicit place to post (potential) bugs like this. Some 100% legal way to include some source code would be nice. E.g. something like a spoiler but only visible to mods and dev team.
Also found many of those in last years but haven't reported most of them.
Sometimes you also dont know if it is intended or not.

E.g. I guess

is intended. It's 'spawnTileX' not 'maxTilesX'. It does save your current spawn location and not the ocean.

-------------------------------------------------------------------

Here another potential source code bug:
Many stuff doesn't get scaled properly with medium size worlds.
(edit: decided to do some extra thread about this)

-------
Or the snow biome shape depends at its side

Similar issue with Dungeon but haven't found the related source code yet. Dungeon entrance shape at the left side | and on the right side \ but can also be | in some cases. But never seen / shape at the left side.

But snow and dungeon dissimilarity aren't that important. They actually bring some more variety to world gen.
... I had a brain fart? :) haha thanks for pointing that out.
 
Back
Top Bottom