ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/Global/Functions.pas
(Generate patch)

Comparing oup/current/Global/Functions.pas (file contents):
Revision 111 by alloc, Wed Feb 21 03:28:48 2007 UTC vs.
Revision 321 by alloc, Wed May 6 13:47:23 2009 UTC

# Line 5 | Line 5 | interface
5   uses TypeDefs, Classes;
6  
7   function BoolToStr(bool: Boolean): String;
8 function HexToLong(hex: String): LongWord;
8   function Decode_Int(buffer: TByteData): LongWord;
9   function Encode_Int(input: LongWord): TByteData;
10   function Decode_Float(buffer: TByteData): Single;
# Line 13 | Line 12 | function Encode_Float(input: Single): TB
12   function IntToBin(Value: Byte): String;
13   function DataToBin(Data: TByteData): String;
14   function BinToInt(bin: String): Byte;
15 + function MakeDatLink(FileID: Integer): Integer;
16 +
17 + function ReadString(Stream: TStream; Offset: Integer): String;
18  
19   function StringSmaller(string1, string2: String): Boolean;
20  
# Line 48 | Line 50 | begin
50   end;
51  
52  
51 function HexToLong(hex: String): LongWord;
52
53  function NormalizeHexString(var hex: String): Boolean;
54  var
55    i: Byte;
56  begin
57    Result := True;
58    if hex[1] = '$' then
59    begin
60      for i := 1 to Length(hex) - 1 do
61        hex[i] := hex[i + 1];
62      SetLength(hex, Length(hex) - 1);
63    end;
64    if (hex[1] = '0') and (UpCase(hex[2]) = 'X') then
65    begin
66      for i := 1 to Length(hex) - 2 do
67        hex[i] := hex[i + 2];
68      SetLength(hex, Length(hex) - 2);
69    end;
70    if Length(hex) = 0 then
71      Result := False;
72  end;
73
74 begin
75  if NormalizeHexString(hex) then
76    Result := StrToInt(hex)
77  else
78    Result := 0;
79 end;
80
81
53   function Decode_Int(buffer: TByteData): LongWord;
54   begin
55    Result := buffer[0] + buffer[1] * 256 + buffer[2] * 256 * 256 + buffer[3] * 256 * 256 * 256;
# Line 168 | Line 139 | begin
139    end;
140   end;
141  
142 +
143 + function MakeDatLink(FileID: Integer): Integer;
144 + begin
145 +  Result := FileID * 256 + 1;
146 + end;
147 +
148 +
149 +
150 +
151 + function ReadString(Stream: TStream; Offset: Integer): String;
152 + var
153 +  c: Char;
154 + begin
155 +  if Assigned(Stream) then
156 +  begin
157 +    if Offset >= 0 then
158 +    begin
159 +      Result := '';
160 +      Stream.Seek(Offset, soFromBeginning);
161 +      repeat
162 +        Stream.Read(c, 1);
163 +        if Ord(c) > 0 then
164 +          Result := Result + c;
165 +      until Ord(c) = 0;
166 +    end;
167 +  end;
168 + end;
169 +
170  
171  
172   function FormatNumber(Value: LongWord; Width: Byte; leadingzeros: Char): String;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)