Conversation started Oct 13, 2014 at 7:24.
Oct 13, 2014 07:24
@William'MindWorX'Mariagerhey there! you are the creator of sharpcraft right? may i ask you some questions here from time to time? for the start my first question is: how to use "null" in a sharpcraft c# plugin.
i want to use following func: native GroupEnumUnitsOfType takes group whichGroup, string unitname, boolexpr filter returns nothing i already inititialized delegates for GroupEnumUnitsOfType & CreateGroup, but im having problems with the JassBooleanExpression. how can i set this to null?
Hmm
@SourceSeeker, Try out new JassBooleanExpression(IntPtr.Zero).
I recall that's what I used when I wanted to get all units in a region.
(still using sharpcraft 1.2.4.0) will immediately try it, thx
Also, you're always welcome to get help here. Although, if it's larger questions, we should move it into a separate room. :)
wew, thats very very nice of you! already contacted TriggerHappy & he also helped me, but he's busy he said and so it was hard to ask him some more things frequently poping up.
Oct 13, 2014 07:42
just tried it & after successfully loading the map & firing the plugin trigger, i get a fatal error. in the plugin i added this: GroupEnumUnitsOfType(g, "peasant", new JassBooleanExpression(IntPtr.Zero));
Hrm
What does the log say?
in the plugins folder there is no new log as the plugins compiled succesfully, another log-file?
oh found it
wait a sec
Throw it on pastebin and link it :)
Oct 13, 2014 07:49
ok, here it is:
expires in 1 day
That's not the log I was thinking. Don't you have a debug.log in the SharpCraft folder?
yes, i have, wait, will upload it too
expires in 1 day
but this only shows that the plugins were loaded successfully right? it doesnt contain any infos about the fatal error
True
I don't know what could cause that error.
Could be the string, "peasant". Strings have been giving me problems. Not sure why.
Oct 13, 2014 08:06
will also upload my plugin :)
Oct 13, 2014 08:18
this is TriggerHappy's Input.cs with many comments from me, pls, just search for "private void ExecuteWheelTriggers(Int32 delta) {" & have a look at the code. near above the mentioned line is the delegate i wrote for "GroupEnumUnitsOfType". by the way, im not sure what to use for the string -> JassStringRet or JassStringArg...
expires in 1 day
JassStringRet for return
JassStringArg for arguments
So in this case, it's JassStringArg
ok, changed the delegate & the code from JassStringRet to JassStringArg, but still the fatal error crashes wc3
Hmm
I'll look into it.
when i comment out "GroupEnumUnitsOfType(g, js, new JassBooleanExpression(IntPtr.Zero));" i can use my scroll wheel without any fatal error, so it must be this func causing it...
Yeah
Did you fix line 321?
Line 244 should be private delegate void GroupEnumUnitsOfTypePrototype(JassGroup whichGroup, JassStringArg unitName, JassBooleanExpression filter);//bool? b);
Oct 13, 2014 08:31
you said that strings caused problems. im still using 1.2.4.0, should i try to update to your current version? i changed #312 to: "JassStringArg js = "peasant";"
And you don't have to use JassStringArg in variables. It converts automatically. :)
You just have to use it in the delegate definition.
and changed line #244 from JassStringRet to JassStringArg yes.
I think I've found the problem.
And it is likely the string like I mentioned. Problem is, when you scroll the wheel, it happens outside the JASS thread. Outside the JASS thread, JASS strings tend to break.
I think you need to find a way to enum units based on something other than strings.
Like, GroupEnumUnitsInRect, and then use a FirstOfGroup loop to check all unit types.
is it worth a try to keep the "GroupEnumUnitsOfType" func but using "UnitId2String" instead of a string directly?
That wouldn't work no.
Oct 13, 2014 08:38
ok
I've been trying to solve the whole string issue several times, but I usually end up introducing more errors instead.
The most recent version wreaks havok on things. :/
Which is why I've decided to make a more bare-bone version, and then move the new/experimental things intro plugins. :)
Also, interesting idea with syncing the mouse events. :)
Selecting isn't the best, but it beats the TriggerSync stuff.
hehe, you read the comments? :) not that this answer with bugged strings is what i wished, but it is an answer! finally a clarification! this means very much for me, i wasted the whole sunday trying to figure out whats wrong. now i sigh with relief.
What I'd do was add a new native along the lines of "native UpdateInput takes nothing returns nothing".
Inside the UpdateInput native, you check for and trigger the events you've caught.
Lemme make a quick example.
private ConcurrentBag<Int32> deltas = new ConcurrentBag<Int32>();

private void ExecuteWheelTriggers(Int32 delta) {
    this.deltas.Add(delta);
}

private void UpdateInput() {
    Int32 delta;
    while(this.deltas.TryTake(out delta)){
         // invoke delta event here.
    }
}
I hope it makes sense.
The only downside is that people need to call your UpdateInput native to get events. But it's the most reliable way of doing it.
hmm, if i understood right, i would have to use a timer and call UpdateInput in the necessary period...
Yup
Just have a 0.01 timer and you'll get plenty of updates. And the ConcurrentBag will hold all events, so you don't miss anything.
Oct 13, 2014 08:54
well, it will be useful in predictable situations, but at the moment i want to react to mouse wheel of players during the whole game to be able to adjust cam data. i guess in this case the timer would produce too much traffic?
That shouldn't be a problem.
:) ok, i will save your example to my comments, but first of all i want to try to sync it by selecting by using another EnumFunc. Okay, everything cleared now for the moment :-) thank you so much, your words really calmed me down.
 
Conversation ended Oct 13, 2014 at 8:58.