fougerite / Fougerite

Fougerite Project is unofficial fork of Magma. Forked to develop it with community.
http://fougerite.com/
Other
4 stars 19 forks source link

CreateTimer() issue #63

Closed linkpad closed 10 years ago

linkpad commented 10 years ago

Hello, here is the issue : Plugin.CreateTimer("test", 1000).Start(); is working great.

But

var params = new ParamsList();
params.Add(Player.SteamID);
params.Add(Player.Name);
Plugin.CreateTimer("test", 1000, params).Start();

give this error : No matching overload found CreateTimer()

Looks like https://github.com/fougerite/Fougerite/blob/master/MagmaPlugin/MagmaPlugin.cs#L272 is all the time call.

mikecrews commented 10 years ago

That's weird. ParamsList has always returned a List<object> not a object[] as the argument list for CreateTimer specifies.

mikecrews commented 10 years ago

Good catch.

Magma:

    public TimedEvent CreateTimer(string name, int timeoutDelay, ParamsList args)
    {
      TimedEvent timer = this.CreateTimer(name, timeoutDelay);
      timer.Args = args;
      timer.OnFire -= new TimedEvent.TimedEventFireDelegate(this.OnTimerCB);
      timer.OnFireArgs += new TimedEvent.TimedEventFireArgsDelegate(this.OnTimerCBArgs);
      return timer;
    }

Fougerite:

        public TimedEvent CreateTimer(string name, int timeoutDelay, object[] args)
        {
            TimedEvent timer = CreateTimer(name, timeoutDelay);
            timer.Args = args;
            timer.OnFire -= OnTimerCB;
            timer.OnFireArgs += OnTimerCBArgs;
            return timer;
        }

Fix:

        public TimedEvent CreateTimer(string name, int timeoutDelay, object[] args)
        {
            TimedEvent timer = CreateTimer(name, timeoutDelay);
            timer.Args = args;
            timer.OnFire -= OnTimerCB;
            timer.OnFireArgs += OnTimerCBArgs;
            return timer;
        }

        public TimedEvent CreateTimer(string name, int timeoutDelay, List<object> args)
        {
            return this.CreateTimer(name, timeoutDelay, args.ToArray<object>());
        }

        public TimedEvent CreateTimer(string name, int timeoutDelay, ParamsList args)
        {
            return this.CreateTimer(name, timeoutDelay, args.ToArray<object>());
        }

whatever's clever

mikecrews commented 10 years ago

7a8ebd6b6bd29d702568de7ccece3b824324e1fb