20.02.2016, 13:40
I have very weird problem with foreach. Sometimes values in Player iterator (array Player@YSII_Ag) changes automatically and this make a big problem. I don't know why this happens, I log every Iter_Add/Iter_Remove function related to Player iterator, but few seconds later some values in array changes without my interference. In callback OnRuntimeError I print full array and these values really change. Server logs:
As you can see some values changed 3 seconds after Iter_Add function. I don't know why the heck there are values like 122, 105 - array size is 51 (iterator size is 50). Line 5628 is foreach definition
There is callback OnRuntimeError
I have definitely no idea why this happens, I will appreciate every (rational) post.
Код:
[20.02.2016 14:25:51] [join] Nobit0. has joined the server (20:90.190.232.65) [20.02.2016 14:25:51] Iter_Add(20, size: 50, count: 36); [20.02.2016 14:25:51] a:{100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 70, 32, 33, 34, 35, 36, 38, 63, 39, 50, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 1}; [20.02.2016 14:25:52] [connection] incoming connection: 83.4.196.47:64420 id: 30 [20.02.2016 14:25:53] [join] XmarieXoo14 has joined the server (30:83.4.196.47) [20.02.2016 14:25:53] Iter_Add(30, size: 50, count: 37); [20.02.2016 14:25:53] a:{100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 38, 63, 39, 50, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 1}; //and there is values' change [20.02.2016 14:25:56] Player:{100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 115, 105, 122, 101, 58, 32, 37, 100, 44, 32, 99, 111, 117, 110, 116, 58, 32, 37, 100, 41, }; [20.02.2016 14:25:56] [debug] Run time error 4: "Array index out of bounds" [20.02.2016 14:25:56] [debug] AMX backtrace: [20.02.2016 14:25:56] [debug] #0 0017ea4c in public secondTimer (time=1455974756) at new2.pwn:5628 [20.02.2016 14:25:56] [debug] Run time error 4: "Array index out of bounds" [20.02.2016 14:25:56] [debug] AMX backtrace:
Код:
foreach(new playerid: Player)
Код:
public OnRuntimeError(code, &bool:suppress) { static bool:first_crash; if(first_crash == false) { new s[512] = "Player:{"; first_crash = true; for(new slotid, size = sizeof Player@YSII_Ag; slotid != size; slotid++) { format(s, 512, "%s%d, ", s, Player@YSII_Ag[slotid]); } strcat(s, "};"); print(s); } }