Quite a simple question, I have a datum proc that is used quite a lot (Roughly 500 times a second?)
And I want to locate what's calling the proc. Is there any 'simple' way to do so without adding large bits of code?
That's pretty inaccurate, Koshiga.
usr is not the caller of a proc. usr is the mob that activated a verb, or click. If you have a proc calling a proc, calling another proc...usr is always the same unless you change it yourself. If you want to see what is calling a proc, the best thing you can do is: handle it yourself. pass the caller of the proc as an argument. or. CRASH() it. This'll show you every proc involved, should be easy enough to follow what's calling what. |
Yeah, I've tried usr, but most of them came out on null.
I decided to skip looking for the source, and just optimize the code all around. |
Sorry I think I misunderstood the question. I thought you were looking for a person who ultimately caused a proc to be called through their action.
So, lets say you have a proc called by various sources of logic (IE: Not players), you would need to provide your own way of tracking said information. test_datum So, you pass the procedure an argument that tells you exactly what called it. It's just up to you to remember to tell it in the code ;) |
As SSX said, CRASH() it. If you want a conditional crash, then ASSERT() it.
It displays the call stack like any other error. The top of the stack is the datum and proc that called the crasher. runtime error: Crash me! |
It's ridiculous that BYOND has access to this information and doesn't allow you to see it without crashing the proc.
|
totally time to bump id:1288032 then, MisterPerson.
|
Here is a very useless test that demonstrates how the "usr" variable can show who is the origination that lead to this procedure being called.