NotJustin / SkillAutoBalance

12 stars 3 forks source link

error log #18

Closed xhaooy closed 4 years ago

xhaooy commented 4 years ago

hi, i found on my server this error:

L 06/13/2020 - 00:38:46: Info (map "mg_pudding_multigames_v3_2") (file "/csgo/addons/sourcemod/logs/errors_20200613.log") L 06/13/2020 - 00:38:46: [SM] Exception reported: Array index out-of-bounds (index 64, limit 64) L 06/13/2020 - 00:38:46: [SM] Blaming: skillautobalance.smx L 06/13/2020 - 00:38:46: [SM] Call stack trace: L 06/13/2020 - 00:38:46: [SM] [1] Line 194, xx\1.11\skillautobalance.sp::OnPluginStart

im not sure if this is because of me (i deleted 2 incs cuz i couldnt compile on 1.11: NCIncs/nc_rpg.inc and smrpg) sm 1.11.0.6541 linux sm used to compile: 1.11.0.6541 windows version of plugin: downloaded from(couple of hrs after u posted it) https://forums.alliedmods.net/showpost.php?p=2705153&postcount=75

NotJustin commented 4 years ago

Let me know if this most recent push fixes it.

I am surprised I do not get the error myself.

xhaooy commented 4 years ago

ok ill let you know asap. btw in version b4 this happend i did the same thing(removed incs and worked well)

xhaooy commented 4 years ago

looks like its fixed(i'm not sure though cuz players on my server didnt play mg/surf* that much)

*only there is your plugin loaded ill close this and reopen if something come out

WhyFaust commented 4 years ago

L 06/21/2020 - 08:41:15: [SM] Exception reported: Array index out-of-bounds (index -1, limit 64) L 06/21/2020 - 08:41:15: [SM] Blaming: skillautobalance-ncrpg.smx L 06/21/2020 - 08:41:15: [SM] Call stack trace: L 06/21/2020 - 08:41:15: [SM] [1] Line 124, SkillAutoBalance/funcs_balance.sp::RemoveOutliers L 06/21/2020 - 08:41:15: [SM] [2] Line 27, SkillAutoBalance/funcs_balance.sp::BalanceSkill L 06/21/2020 - 08:41:15: [SM] [3] Line 23, SkillAutoBalance/timers.sp::Timer_CheckScore

NotJustin commented 4 years ago

Can you show me SkillAutoBalance.cfg? I will change my settings to be the same as yours so I can replicate. You can ignore what I write below if you want, I am writing it so I can think about the error.

In the line with the error, the plugin tries to access g_iClient[-1]. I need to figure out why it is -1.

In the beginning of RemoveOutliers, I have "size" = number of T's + number of CT's. I check if size is even or odd. In your error, size is odd.

This part is hard to explain. See the picture. The players are sorted in a list, and I want to search the list for the players who are at the circled positions. image

To get the first circle, I need to find the farthest left line and the middle line. The left line is index 0 an middle is at "size / 2 - 1". I set "q1Size" to be the size of this section from left to middle. q1Size = q1End - q1Start + 1.

From here, I find the middle of this section "q1". In the error you have, q1Size is even. When a number is even, there is no middle, so I need to find the average of the two players closest to the middle. I try to do this with "g_iClient[q1Size / 2 - 1 + q1Start]"

q1Size is the size of q1. I divide by 2 to get the middle. I subtract one to get the player to the left of the middle (because q1Size is an even number). I add q1Start in case we did not start from index 0 (even though, it always will be 0, so it does not matter).

So, it really looks like this: "g_iClient[q1Size / 2 - 1]". Clearly, it is because of q1Size. We know q1Size is an even number. What number will q1Size be, to result in -1? q1Size would need to be -1, 0, or 1. We know it is 0 though, because we know q1Size is an even number.

Now we know, somehow, q1Size is 0. Let's go back. What is q1Size? q1Size = q1End - q1Start + 1. Again, we know q1Start is always 0, so q1Size = q1End + 1.

Now another weird thing. For q1Size to be 0, it means q1End is somehow -1. Let's see what q1End is.

q1End = size / 2 - 1. Okay, it comes back to "size". Somehow, size / 2 - 1 equals -1. For this to happen, size needs to either be -1, 0, or 1. Again, what is size? Size is the # of T's + # of CT's. It is impossible for it to be -1. The size, therefore, is somehow either 0 or 1.

My question now is, how does a balance occur when there are only 0 or 1 players on a team? It should be impossible. I have a convar that requires a minimum number of players to be on server before balance occurs, and you cannot set the convar to be lower than 2. Somehow, a team balance is being triggered, skipping this check. The only time this can happen is when a client joins the server. My idea is that the new thing I added here https://github.com/NotJustin/SkillAutoBalance/issues/16#issuecomment-645915357 could cause it.

I am not sure though. Even if I ask for your config, I cannot test myself because I use gameME and I could not implement the above thing with gameME. Still, I can do more testing and see if the bug happens anyway.