Dyshay / Bot-Dofus-Retro

Dofus Retro - Bot (Not updated)
https://discord.gg/PdvteG5
36 stars 32 forks source link

Bug: The Bot sometimes crashes during combat with only one spell #39

Open Fortier006 opened 4 years ago

Fortier006 commented 4 years ago

When using the bot to fight, and having only one spell set up, the bot sometimes crashes.

The crash happens in PeleaExtensiones.cs , Specifically on line 131 or 127. The index is out of bounds. It tries to do things with a spell at index 1 in the possible spells, but there is only one spell so this is out of bounds.

I saw that in another method in the same file, the index is checked before being used. This check is not present in this method, get_Procesar_Hechizo_Lanzado.

I added the check manually, as seen here:

image

This seemed to fix the issue for now.

For those curious, here was the stacktrace of the crash:

System.ArgumentOutOfRangeException HResult=0x80131502 Message=Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Source=mscorlib StackTrace: at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.Collections.Generic.List`1.get_Item(Int32 index) at Bot_Dofus_1._29._1.Otros.Peleas.PeleaExtensiones.d__15.MoveNext() in D:\Users\Joel\Documents\GitHub\Bot-Dofus-Retro-Master\Otros\Peleas\PeleaExtensiones.cs:line 125 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch()