Changeset 55


Ignore:
Timestamp:
Jan 12, 2017, 9:52:50 PM (7 years ago)
Author:
chronos
Message:
  • Fixed: Bad allocation memory during loading sound files under 64-bit architecture.
  • Added: Ubuntu packaging files.
Location:
trunk
Files:
17 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/AI/StdAI.ai.txt

    r44 r55  
    55#PATH_WIN32 StdAI-win32.dll
    66#PATH_WIN64 StdAI-win64.dll
    7 #PATH_LINUX32 libstdai-linux32.so
    8 #PATH_LINUX64 libstdai-linux64.so
     7#PATH_LINUX32 libstdai-i386.so
     8#PATH_LINUX64 libstdai-amd64.so
    99#CREDITS Standard AI by Steffen Gerlach.
  • trunk/Integrated.lpi

    r52 r55  
    1515      <UseAppBundle Value="False"/>
    1616      <ResourceType Value="res"/>
     17      <Icon Value="0"/>
    1718    </General>
    1819    <i18n>
     
    4647          <CodeGeneration>
    4748            <SmartLinkUnit Value="True"/>
    48             <TargetCPU Value="i386"/>
    49             <TargetOS Value="win32"/>
    5049            <Optimizations>
    5150              <OptimizationLevel Value="3"/>
  • trunk/Integrated.lpr

    r38 r55  
    5252{$ENDIF}
    5353
     54{$R *.res}
     55
    5456begin
    5557  {$IFDEF DEBUG}
  • trunk/LocalPlayer/Help.pas

    r53 r55  
    437437  HelpLineInfo: THelpLineInfo;
    438438begin
    439   MainText.SaveToFile('MainText.txt');
    440439  inherited;
    441440  CaptionColor := Colors.Canvas.Pixels[clkMisc, cliPaperCaption];
  • trunk/Sound.pas

    r21 r55  
    44
    55uses
    6   Messages, SysUtils, Classes, Graphics, Controls, Forms {$IFDEF WINDOWS}, MMSystem, Windows{$ENDIF};
     6  Messages, SysUtils, Classes, Graphics, Controls, Forms, fgl
     7  {$IFDEF WINDOWS}, MMSystem, Windows{$ENDIF};
    78
    89function PrepareSound(FileName: string): integer;
     
    9293end;
    9394
    94 type
    95   TSoundList = array [0 .. 99999] of TSound;
    9695
    9796var
    98   nSoundList: integer;
    9997  SoundPlayer: TSoundPlayer;
    100   SoundList: ^TSoundList;
     98  SoundList: TFPGObjectList<TSound>;
    10199  PlayingSound: TSound;
    102100
     
    114112function PrepareSound(FileName: string): integer;
    115113begin
    116   for result := 1 to Length(FileName) do
    117     FileName[result] := upcase(FileName[result]);
    118   result := 0;
    119   while (result < nSoundList) and (SoundList[result].FFileName <> FileName) do
     114  Result := 0;
     115  while (result < SoundList.Count) and (SoundList[result].FFileName <> FileName) do
    120116    inc(result);
    121   if result = nSoundList then
    122   begin // first time this sound is played
    123     if nSoundList = 0 then
    124       ReallocMem(SoundList, 16 * 4)
    125     else if (nSoundList >= 16) and (nSoundList and (nSoundList - 1) = 0) then
    126       ReallocMem(SoundList, nSoundList * (2 * 4));
    127     inc(nSoundList);
    128     SoundList[result] := TSound.Create(FileName);
     117  if result = SoundList.Count then begin
     118    // first time this sound is played
     119    SoundList.Add(TSound.Create(FileName));
     120    Result := SoundList.Count - 1;
    129121  end;
    130122end;
     
    146138  i: integer;
    147139
     140procedure UnitInit;
     141begin
     142  SoundList := TFPGObjectList<TSound>.Create;
     143  PlayingSound := nil;
     144  SoundPlayer := nil;
     145end;
     146
     147procedure UnitDone;
     148begin
     149  if PlayingSound <> nil then begin
     150    PlayingSound.Stop;
     151    Sleep(222);
     152  end;
     153  FreeAndNil(SoundList);
     154end;
     155
    148156initialization
    149157
    150 nSoundList := 0;
    151 SoundList := nil;
    152 PlayingSound := nil;
    153 SoundPlayer := nil;
     158UnitInit;
    154159
    155160finalization
    156161
    157 if PlayingSound <> nil then
    158 begin
    159   PlayingSound.Stop;
    160   Sleep(222);
    161 end;
    162 for i := 0 to nSoundList - 1 do
    163   SoundList[i].Free;
    164 ReallocMem(SoundList, 0);
     162UnitDone;
    165163
    166164end.
Note: See TracChangeset for help on using the changeset viewer.