- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
Assign(F, FileName);
IOResult;
Reset(F);
if IOResult = 0 then begin
for i := 0 to MaxModelNamesCount-1 do ModelKind[i] := mkVagon;
Result := True;
BlockRead(F, W, 2);
if W = OldWDim then begin // старый формат
// 20 строк пропущено
end else if W = WDim then begin // новый формат
BlockRead(F, FormatVersion, 4); // версия нового формата
if FormatVersion <= 4 then begin
BlockRead(F, EditorDate, 4);
BlockRead(F, C, 4);
LCount := C;
for i := 0 to LCount - 1 do begin
BlockReadLine(F, Lines[i], 16);
if (FormatVersion <= 2) and (Lines[i].Attr[3] and $0F = 5) then Lines[i].Attr[0] := 0
else if (Lines[i].Attr[3] and $0F = k3DObject) then ModelKind[Lines[i].IntAttr[1]] := mkStatic;
end;
if FormatVersion <= 1 then begin
ModelNamesCount := 8; // для 1й версии список жёстко задан
ModelNames[0] := 'ГЗРВ-10';
ModelNames[1] := 'ГЗРВ-10М';
ModelNames[2] := 'КТМ-5М3';
ModelNames[3] := 'ЛМ-68';
ModelNames[4] := 'ЛМ-68М';
ModelNames[5] := 'ЛМ-68ММ';
ModelNames[6] := 'ЛВС-86';
ModelNames[7] := 'ЛВС-97';
for i := 8 to MaxModelNamesCount-1 do ModelNames[i] := '';
end else if FormatVersion <= 3 then begin
ModelNamesCount := 0;
for i := 0 to 255 do begin
j := 0;
BlockRead(F, j, 1);
SetLength(ModelNames[i], j);
for j := 1 to Length(ModelNames[i]) do Read(F, byte(ModelNames[i, j]));
if ModelNames[i] <> '' then Inc(ModelNamesCount);
end;
end else begin
BlockRead(F, ModelNamesCount, 4); // кол-во моделей
for i := 0 to MaxModelNamesCount - 1 do ModelNames[i] := '';
for i := 0 to ModelNamesCount-1 do begin
BlockRead(F, k, 4); // номер считываемой модели
j := 0;
BlockRead(F, j, 1); // длина имени, не более 255
SetLength(ModelNames[k], j);
for j := 1 to Length(ModelNames[k]) do Read(F, byte(ModelNames[k, j]));
end;
end;
for i := 0 to 8 do
for j := 0 to 12 + Byte(FormatVersion >= 2) do with Routes[i, j] do begin
BlockRead(F, PCount, 2);
SetAllowedModels(Routes[i,j], 0, -1);
if FormatVersion <= 1 then begin
BS := [];
BlockRead(F, BS, 4);
AllowedModelsCount := 0;
for k := 0 to 255 do if k in BS then begin
Inc(AllowedModelsCount);
AllowedModels[k] := True;
end;
end else if FormatVersion <= 3 then begin
BlockRead(F, BS, 32);
AllowedModelsCount := 0;
for k := 0 to 255 do if k in BS then begin
Inc(AllowedModelsCount);
AllowedModels[k] := True;
end;
end else begin
BlockRead(F, AllowedModelsCount, 4);
for k := 0 to AllowedModelsCount-1 do begin
BlockRead(F, n, 4); // номер модели
AllowedModels[n] := True;
end;
end;
for k := 0 to PCount - 1 do begin
if FormatVersion >= 3 then BlockRead(F, c, 4)
else begin
c := 0;
BlockRead(F, c, 2);
end;
Points[k] := c;
end;
BlockRead(F, DefVagons, 1);
SpeedRoute := boolean(DefVagons shr 4);
DefVagons := DefVagons and $0F;
BlockRead(F, Interval, 1);
end;
end else Result := False;
end else Result := False;
Close(F);
Короче, лапша из if FormatVesion такой-то...
Обратная совместимость формата файла.
Формату уже 4 года.