hedgewars/CCHandlers.inc
changeset 615 b646b3c43369
parent 613 e8cf72d0e0f7
child 626 a30171dbcd19
equal deleted inserted replaced
614:0e04504bc140 615:b646b3c43369
   465 begin
   465 begin
   466 cTagsMask:= map[cTagsMask]
   466 cTagsMask:= map[cTagsMask]
   467 end;
   467 end;
   468 
   468 
   469 procedure chAddTrigger(var s: shortstring);
   469 procedure chAddTrigger(var s: shortstring);
   470 var ttype, gt, geartrig, Ticks, Lives: LongWord;
   470 const MAXPARAMS = 16;
   471     X, Y: LongInt;
   471 var params: array[0..Pred(MAXPARAMS)] of Longword;
       
   472     i: LongInt;
   472     c: char;
   473     c: char;
   473     tmp: shortstring;
   474     tmp: shortstring;
   474 begin
   475 begin
   475 c:= s[1];
   476 c:= s[1];
   476 Delete(s, 1, 1);
   477 Delete(s, 1, 1);
       
   478 
       
   479 i:= 0;
       
   480 while (i < MAXPARAMS) and
       
   481       (Length(s) > 0) do
       
   482     begin
       
   483     SplitBySpace(s, tmp);
       
   484     val(s, params[i]);
       
   485     s:= tmp;
       
   486     inc(i)
       
   487     end;
       
   488 
   477 case c of
   489 case c of
   478   's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER
   490   's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER
   479        SplitBySpace(s, tmp);
   491        TryDo(i = 7, errmsgWrongNumber, true);
   480        val(s, ttype);
   492        AddTriggerSpawner(params[0], params[1], params[2], TGearType(params[3]), params[4], params[5], params[6]);
   481        SplitBySpace(tmp, s);
       
   482        val(tmp, Ticks);
       
   483        SplitBySpace(s, tmp);
       
   484        val(s, Lives);
       
   485        SplitBySpace(tmp, s);
       
   486        val(tmp, gt);
       
   487        SplitBySpace(s, tmp);
       
   488        val(s, X);
       
   489        SplitBySpace(tmp, s);
       
   490        val(tmp, Y);
       
   491        SplitBySpace(s, tmp);
       
   492        val(s, geartrig);
       
   493        AddTriggerSpawner(ttype, Ticks, Lives, X, Y, TGearType(gt), geartrig);
       
   494        end;
   493        end;
   495   'C': begin
   494   'C': begin
   496        val(s, ttype);
   495        TryDo(i = 3, errmsgWrongNumber, true);
   497        AddTriggerSuccess(ttype);
   496        AddTriggerSuccess(params[0], params[1], params[2]);
       
   497        end;
       
   498   'F': begin
       
   499        TryDo(i = 3, errmsgWrongNumber, true);
       
   500        AddTriggerFail(params[0], params[1], params[2]);
   498        end;
   501        end;
   499   end
   502   end
   500 end;
   503 end;