hedgewars/uTeams.pas
changeset 9407 860f959f92c9
parent 9295 f8819c3dde54
child 9464 901e363d5837
equal deleted inserted replaced
9405:efc5409a141d 9407:860f959f92c9
    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
    46     uGearsUtils, uGearsList, uVisualGearsList, uPhysFSLayer
    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;
   566     CurrHedgehog:= HedgehogsNumber;
   566     CurrHedgehog:= HedgehogsNumber;
   567     inc(HedgehogsNumber)
   567     inc(HedgehogsNumber)
   568     end
   568     end
   569 end;
   569 end;
   570 
   570 
       
   571 procedure loadTeamBinds(s: shortstring);
       
   572 var i: LongInt;
       
   573     f: PFSFile;
       
   574     p, l: shortstring;
       
   575     b: byte;
       
   576 begin
       
   577     l:= '';
       
   578     
       
   579     for i:= 1 to length(s) do
       
   580         if s[i] in ['\', '/', ':'] then s[i]:= '_';
       
   581         
       
   582     s:= cPathz[ptTeams] + '/' + s + '.hwt';
       
   583     if pfsExists(s) then
       
   584         begin
       
   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;
       
   625 
   571 procedure chAddTeam(var s: shortstring);
   626 procedure chAddTeam(var s: shortstring);
   572 var Color: Longword;
   627 var Color: Longword;
   573     ts, cs: shortstring;
   628     ts, cs: shortstring;
   574 begin
   629 begin
   575 cs:= '';
   630 cs:= '';
   584     // color is always little endian so the mask must be constant also in big endian archs
   639     // color is always little endian so the mask must be constant also in big endian archs
   585     Color:= Color or $FF000000;
   640     Color:= Color or $FF000000;
   586     AddTeam(Color);
   641     AddTeam(Color);
   587     CurrentTeam^.TeamName:= ts;
   642     CurrentTeam^.TeamName:= ts;
   588     CurrentTeam^.PlayerHash:= s;
   643     CurrentTeam^.PlayerHash:= s;
       
   644     loadTeamBinds(ts);
       
   645     
   589     if GameType in [gmtDemo, gmtSave, gmtRecord] then
   646     if GameType in [gmtDemo, gmtSave, gmtRecord] then
   590         CurrentTeam^.ExtDriven:= true;
   647         CurrentTeam^.ExtDriven:= true;
   591 
   648 
   592     CurrentTeam^.voicepack:= AskForVoicepack('Default')
   649     CurrentTeam^.voicepack:= AskForVoicepack('Default')
   593     end
   650     end