Re: help with a strange runtime in bgt

2019-03-16 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: help with a strange runtime in bgt

If you remove something at i, and there's something else after that bit in the loop, it will crash as described.I would add a continue after the removals, unless you have some other cleanup to do. Possiblyi--;continue;Since leaving out the i-- can have weird results, since it might skip the former i+1.

URL: https://forum.audiogames.net/post/419467/#p419467




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: help with a strange runtime in bgt

2019-03-16 Thread AudioGames . net Forum — Developers room : keithwipf1 via Audiogames-reflector


  


Re: help with a strange runtime in bgt

Wouldn't it just require an if statement?

URL: https://forum.audiogames.net/post/419440/#p419440




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: help with a strange runtime in bgt

2019-03-16 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: help with a strange runtime in bgt

rory-games wrote:I'd try restarting the loop if a cannonball got removed, so then the for loop counter  will  go back to 0, and no more runtime will occur.Thats one way, but a rather costly one, that would mean wrapping this loop inside another loop which costs alot of calculation time which you don't need to apply if you do things like the loop I posted above.Best Regards.Hijacker

URL: https://forum.audiogames.net/post/419373/#p419373




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: help with a strange runtime in bgt

2019-03-15 Thread AudioGames . net Forum — Developers room : rory-games via Audiogames-reflector


  


Re: help with a strange runtime in bgt

I'd try restarting the loop if a cannonball got removed, so then the for loop counter  will  go back to 0, and no more runtime will occur.

URL: https://forum.audiogames.net/post/419234/#p419234




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: help with a strange runtime in bgt

2019-03-15 Thread AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector


  


Re: help with a strange runtime in bgt

that and you have to paste the contents of the dialog using something like NVDA's review cursor to copy the text out, that call stack stuff is useless.

URL: https://forum.audiogames.net/post/419215/#p419215




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: help with a strange runtime in bgt

2019-03-15 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: help with a strange runtime in bgt

Well, that code doesn't seem to be enough, I guess there is actually a loop ment to run around this code, so without that one we cannot help you. If its a for loop, manually removing entries from an array will end you up accessing higher indices which don't exist anymore and skipping earlier ones, but thats just me guessing what might be wrong here.I'll try to explain my thoughts to you. Lets just say your array has 10 entries right now, and thus you run a for loop from 0 to 9. Now, while i is 0, your code kicks in. Your first if is correct, thus the sound plays and the variable with index 0 is removed from your array, its now 9 items large, ranging from index 0 to 8, but your loop will still run from 0 to 9. Now, your loop continues and will check your 1'st entry. Note that that already skipped one entry, entry 0, the former entry 1, because you deleted the 0th entry, thus making entry 1 become entry 0. Even if your if-clauses now will always not be true, as soon as i becomes 9, you'll encounter a runtime error, because an item with i = 9 doesn't exist anymore within your array, because the largest one is now 8.TL;DR: Loops reducing the array's size are usually done by using do-while-loops incrementing the index manually, something like:int[] arr={0,1,2,3,4,5,6,7,8,9};
i = 0;
do
{
  if(arr[i] == 0)
  {
arr.remove_at(i);
continue;
  }
  i++;
}
while(i < arr.length());Best Regards.Hijacker

URL: https://forum.audiogames.net/post/419180/#p419180




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: help with a strange runtime in bgt

2019-03-15 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: help with a strange runtime in bgt

Well, that code doesn't seem to be enough, I guess there is actually a loop ment to run around this code, so without that one we cannot help you. If its a for loop, manually removing entries from an array will end you up accessing higher indices which don't exist anymore and skipping earlier ones, but thats just me guessing what might be wrong here.I'll try to explain my thoughts to you. Lets just say your array has 10 entries right now, and thus you run a for loop from 0 to 9. Now, while i is 0, your code kicks in. Your first if is correct, thus the sound plays and the variable with index 0 is removed from your array, its now 9 items large, ranging from index 0 to 8, but your loop will still run from 0 to 9. Now, your loop continues and will check your 1'st entry. Note that that already skipped one entry, entry 0, the former entry 1, because you deleted the 0th entry, thus making entry 1 become entry 0. Even if your if-clauses now will always not be true, as soon as i becomes 9, you'll encounter a runtime error, because an item with i = 9 doesn't exist anymore within your array, because the largest one is now 8.TL;DR: Loops reducing the array's size are usually done by using do-while-loops incrementing the index manually, something like:int[] arr={0,1,2,3,4,5,6,7,8,9,10};
i = 0;
do
{
  if(arr[i] == 0)
  {
arr.remove_at(i);
continue;
  }
  i++;
}
while(i < arr.length());Best Regards.Hijacker

URL: https://forum.audiogames.net/post/419180/#p419180




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector