hedgewars/uTeams.pas
changeset 9466 8b48c27201af
parent 9464 901e363d5837
child 9468 3d07fd84c39d
equal deleted inserted replaced
9464:901e363d5837 9466:8b48c27201af
    41 procedure TeamGoneEffect(var Team: TTeam);
    41 procedure TeamGoneEffect(var Team: TTeam);
    42 procedure SwitchCurrentHedgehog(newHog: PHedgehog);
    42 procedure SwitchCurrentHedgehog(newHog: PHedgehog);
    43 
    43 
    44 implementation
    44 implementation
    45 uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug,
    45 uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug,
    46     uGearsUtils, uGearsList, uVisualGearsList, uPhysFSLayer
    46     uGearsUtils, uGearsList, uVisualGearsList
    47     {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
    47     {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
    48 
    48 
    49 var MaxTeamHealth: LongInt;
    49 var MaxTeamHealth: LongInt;
    50     GameOver: boolean;
    50     GameOver: boolean;
    51     NextClan: boolean;
    51     NextClan: boolean;
   568     end
   568     end
   569 end;
   569 end;
   570 
   570 
   571 procedure loadTeamBinds(s: shortstring);
   571 procedure loadTeamBinds(s: shortstring);
   572 var i: LongInt;
   572 var i: LongInt;
   573     f: PFSFile;
   573 begin
   574     p, l: shortstring;
       
   575     b: byte;
       
   576 begin
       
   577     l:= '';
       
   578     
       
   579     for i:= 1 to length(s) do
   574     for i:= 1 to length(s) do
   580         if s[i] in ['\', '/', ':'] then s[i]:= '_';
   575         if s[i] in ['\', '/', ':'] then s[i]:= '_';
   581         
   576 
   582     s:= cPathz[ptTeams] + '/' + s + '.hwt';
   577     s:= cPathz[ptTeams] + '/' + s + '.hwt';
   583     if pfsExists(s) then
   578 
   584         begin
   579     loadBinds('bind', s);
   585         AddFileLog('Loading binds from: ' + s);
       
   586         f:= pfsOpenRead(s);
       
   587         while (not pfsEOF(f)) and (l <> '[Binds]') do
       
   588             pfsReadLn(f, l);
       
   589 
       
   590         while (not pfsEOF(f)) and (l <> '') do
       
   591             begin
       
   592             pfsReadLn(f, l);
       
   593 
       
   594             p:= '';
       
   595             i:= 1;
       
   596             while (i <= length(l)) and (l[i] <> '=') do
       
   597                 begin
       
   598                 if l[i] <> '%' then
       
   599                     begin
       
   600                     p:= p + l[i];
       
   601                     inc(i)
       
   602                     end else
       
   603                     begin
       
   604                     l[i]:= '$';
       
   605                     val(copy(l, i, 3), b);
       
   606                     p:= p + char(b);
       
   607                     inc(i, 3)
       
   608                     end;
       
   609                 end;
       
   610 
       
   611             if i < length(l) then
       
   612                 begin
       
   613                 l:= copy(l, i + 1, length(l) - i);
       
   614                 if l <> 'default' then
       
   615                     begin
       
   616                     p:= 'bind ' + l + ' ' + p;
       
   617                     ParseCommand(p, true)
       
   618                     end
       
   619                 end
       
   620             end;
       
   621 
       
   622         pfsClose(f)
       
   623         end
       
   624 end;
   580 end;
   625 
   581 
   626 procedure chAddTeam(var s: shortstring);
   582 procedure chAddTeam(var s: shortstring);
   627 var Color: Longword;
   583 var Color: Longword;
   628     ts, cs: shortstring;
   584     ts, cs: shortstring;
   663     t:= StrToInt(y);
   619     t:= StrToInt(y);
   664     CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
   620     CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
   665 end;
   621 end;
   666 
   622 
   667 procedure chBind(var id: shortstring);
   623 procedure chBind(var id: shortstring);
   668 var KeyName, Modifier, tmp: shortstring;
   624 begin
   669     i, b: LongInt;
   625     if CurrentTeam = nil then
   670 begin
   626         exit;
   671 KeyName:= '';
   627 
   672 Modifier:= '';
   628     addBind(CurrentTeam^.Binds, id)
   673 
       
   674 if CurrentTeam = nil then
       
   675     exit;
       
   676 
       
   677 if(Pos('mod:', id) <> 0)then
       
   678     begin
       
   679     tmp:= '';
       
   680     SplitBySpace(id, tmp);
       
   681     Modifier:= id;
       
   682     id:= tmp;
       
   683     end;
       
   684 
       
   685 SplitBySpace(id, KeyName);
       
   686 if KeyName[1]='"' then
       
   687     Delete(KeyName, 1, 1);
       
   688 if KeyName[byte(KeyName[0])]='"' then
       
   689     Delete(KeyName, byte(KeyName[0]), 1);
       
   690 b:= KeyNameToCode(id, Modifier);
       
   691 if b = 0 then
       
   692     OutError(errmsgUnknownVariable + ' "' + id + '"', false)
       
   693 else
       
   694     begin 
       
   695     // add bind: first check if this cmd is already bound, and remove old bind
       
   696     i:= cKbdMaxIndex;
       
   697     repeat
       
   698         dec(i)
       
   699     until (i < 0) or (CurrentTeam^.Binds[i] = KeyName);
       
   700     if (i >= 0) then
       
   701         CurrentTeam^.Binds[i]:= '';
       
   702 
       
   703     CurrentTeam^.Binds[b]:= KeyName;
       
   704     end
       
   705 end;
   629 end;
   706 
   630 
   707 procedure chTeamGone(var s:shortstring);
   631 procedure chTeamGone(var s:shortstring);
   708 var t: LongInt;
   632 var t: LongInt;
   709 begin
   633 begin