• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Problem - What's wrong with this code?

s0lusek

New member
Joined
Feb 1, 2015
RedCents
20¢
I'm getting consistent crashes and I'm completely unable to pinpoint what's going on. It's incredibly frustrating that it's crashing instead of just throwing macro errors to the output window now. It makes it very difficult to debug. Would someone mind skimming this and telling me whether I'm perhaps, misusing any TLO that have changed or anything? I went through all of the change logs for the past 12 months and can't find anything that indicates this code is misusing any major components.


Rich (BB code):
|----------------------------
Sub IndexThisString(string strStringToIndex,int intSegmentsToIndex)
|----------------------------
	|receives a string and breaks it up using a break character(_), then sets each segment
	|as an outer variable accessible by other macros. To ensure these variables aren't used 
	|erroneously without being wiped they are cleaned when this macro is called.

	|clean vars
	/varset strWorkingString 		""
	/varset n 					0
	/varset intIndexBreak[9] 		0
	/varset strIndexPart[9] 		0

	|Indexing Loop
	/varset strWorkingString ${strStringToIndex}
	/for n 1 to ${intSegmentsToIndex}
		/delay 0.5
		/if (${n} < ${intSegmentsToIndex}) {
			/varset intIndexBreak[${n}] ${strWorkingString.Find[_]}
			/varset strIndexPart[${n}] ${strWorkingString.Left[${Math.Calc[${intIndexBreak[${n}]}-1]}]}
			/varset strWorkingString ${strWorkingString.Right[-${intIndexBreak[${n}]}]}
		} else /if (${n} == ${intSegmentsToIndex}) {
			/varset strIndexPart[${n}] ${strWorkingString}
		}
	/next n
/return
 
I'm getting consistent crashes and I'm completely unable to pinpoint what's going on. It's incredibly frustrating that it's crashing instead of just throwing macro errors to the output window now. It makes it very difficult to debug. Would someone mind skimming this and telling me whether I'm perhaps, misusing any TLO that have changed or anything? I went through all of the change logs for the past 12 months and can't find anything that indicates this code is misusing any major components.


Rich (BB code):
|----------------------------
Sub IndexThisString(string strStringToIndex,int intSegmentsToIndex)
|----------------------------
	|receives a string and breaks it up using a break character(_), then sets each segment
	|as an outer variable accessible by other macros. To ensure these variables aren't used 
	|erroneously without being wiped they are cleaned when this macro is called.

	|clean vars
	/varset strWorkingString 		""
	/varset n 					0
	/varset intIndexBreak[9] 		0
	/varset strIndexPart[9] 		0

	|Indexing Loop
	/varset strWorkingString ${strStringToIndex}
	/for n 1 to ${intSegmentsToIndex}
		/delay 0.5
		/if (${n} < ${intSegmentsToIndex}) {
			/varset intIndexBreak[${n}] ${strWorkingString.Find[_]}
			/varset strIndexPart[${n}] ${strWorkingString.Left[${Math.Calc[${intIndexBreak[${n}]}-1]}]}
			/varset strWorkingString ${strWorkingString.Right[-${intIndexBreak[${n}]}]}
		} else /if (${n} == ${intSegmentsToIndex}) {
			/varset strIndexPart[${n}] ${strWorkingString}
		}
	/next n
/return

You aren't even using any TLOs just string modifications. What are you trying to do exactly and what errors are you getting? where are you declaring the variables you are using in the top (I only see 2 being decalred in the Sub at the top)? This is messy to say the least working with this many strings in an array in a macro.
 
You aren't even using any TLOs just string modifications. What are you trying to do exactly and what errors are you getting? where are you declaring the variables you are using in the top (I only see 2 being decalred in the Sub at the top)? This is messy to say the least working with this many strings in an array in a macro.

I think it is pseudo code because he is tryng to make sure the way he is working with strings is sensible... I dont know the answer =)
 
This is actual code. This macro works like this:

My toons have spellbook and buffing lines written out, and I use the following format when I declare settings in the .ini files.

/declare strMyBuff1 string outer Spirit of Wolf_AllMelee_60_Spell

When I call the buffing routine, this toon will examine his buffs, find this string, and call the index function. The index function once complete, will load an array as follows:

strIndexPart[1] Spirit of Wolf
strIndexPart[2] AllMelee
strIndexPart[3] 60
strIndexPart[4] Spell

The results are then available globally for that toon, and he can reference them to cast spells, to a certain group of people, if the duration for these buffs matches, and with considerations for how we should cast (ie: spell vs item vs aa).

I'm not getting any errors. It works exactly as it should most of the time, then randomly on certain toons everything crashes. It doesn't produce any MQ2 output errors, it's a full crash of MQ2 and that EQ instance. When I've used /echos to try and pinpoint the issue it seems it might be happening just as this function is called. I can post more if you like, but I have over a hundred vars declared, all done the same, I can't see any issues with how I've declared these.

Would you like more posted or does this help?
 
Last edited:
The things I would check for in the code would be not to use 0(zero) or a higher number than the arrays were /declared for. There is no zero element in MQ2 arrays and trying to access the [0] element can cause issues. The other thing is the .Find[] will return NULL and not zero so that can be an issue. I would change the Following:

Rich (BB code):
		/if (${n} < ${intSegmentsToIndex}) {
                    /if (${Int[${strWorkingString.Find[_]}]}>0) {
			/varset intIndexBreak[${n}] ${strWorkingString.Find[_]}
			/varset strIndexPart[${n}] ${strWorkingString.Left[${Math.Calc[${intIndexBreak[${n}]}-1]}]}
			/varset strWorkingString ${strWorkingString.Right[-${intIndexBreak[${n}]}]}
                   } else {
			/varset strIndexPart[${n}] ${strWorkingString}
                   }
		} else /if (${n} == ${intSegmentsToIndex}) {
			/varset strIndexPart[${n}] ${strWorkingString}
		}

Those would be my recommendations for now.
 
Success. I have figured it out. It came after spending about 2 more hours (bringing the grand total damn year 10 hours on this one.) The problem ended up being a line in which I pass a portion of the string which I've whittled down to the duration of the spell, to an int variable. The 'whittled down version' was contained in a string, and I was passing directly to an int variable. Added a converting ${Int[]} function to it to convert over, and that seemed to have done the trick. It was a weird one as some of the toons didn't mind it and it must have been partially working.

Been running it through the gears, can't get it to fail now. Hopefully fixed!

Thanks for the help folks, definitely narrowed the target.
 
Problem - What's wrong with this code?

Users who are viewing this thread

Back
Top
Cart