From b670be61fe78af85d7d5a0a51e66dc0cd635b35c Mon Sep 17 00:00:00 2001 From: dpethes Date: Wed, 15 Oct 2014 22:54:25 +0200 Subject: [PATCH] hmt parser: split into main program & parsing unit --HG-- rename : hmt_parser/hmt_parser.lpr => hmt_parser/hmt_parser.pas --- hmt_parser/hmt_parser.lpi | 12 +++++-- hmt_parser/{hmt_parser.lpr => hmt_parser.pas} | 32 +++++++------------ 2 files changed, 20 insertions(+), 24 deletions(-) rename hmt_parser/{hmt_parser.lpr => hmt_parser.pas} (84%) diff --git a/hmt_parser/hmt_parser.lpi b/hmt_parser/hmt_parser.lpi index 01381d3..0a79a1a 100644 --- a/hmt_parser/hmt_parser.lpi +++ b/hmt_parser/hmt_parser.lpi @@ -5,6 +5,7 @@ + @@ -31,12 +32,17 @@ - + - + + + + + + - + diff --git a/hmt_parser/hmt_parser.lpr b/hmt_parser/hmt_parser.pas similarity index 84% rename from hmt_parser/hmt_parser.lpr rename to hmt_parser/hmt_parser.pas index f715d40..f487459 100644 --- a/hmt_parser/hmt_parser.lpr +++ b/hmt_parser/hmt_parser.pas @@ -1,7 +1,10 @@ -program hmt_parser; +unit hmt_parser; +{$mode objfpc}{$H+} - uses - Classes; +interface + +uses + sysutils, Classes; type THmtMaterial = record @@ -25,6 +28,10 @@ type textures: array of THmtTexture; end; +procedure ParseHmtFile(const fname: string); + +//************************************************************************************************** +implementation function NameToString(name: array of byte): string; var @@ -82,7 +89,7 @@ begin //read textures if hmt.texture_count = 0 then exit; - f.Seek(hmt.texture_offset + sizeof(hmt.texture_count), TSeekOrigin.soBeginning); + f.Seek(hmt.texture_offset + sizeof(hmt.texture_count), fsFromCurrent); SetLength(hmt.textures, hmt.texture_count); for i := 0 to hmt.texture_count - 1 do begin tex.data_offset := f.ReadDWord; @@ -92,22 +99,5 @@ begin f.Free; end; -var - fname: string; - -begin - if ParamCount < 1 then begin - writeln ('no input file specified'); - exit; - end; - - fname := ParamStr(1); - writeln('parsing file: ', fname); - try - ParseHmtFile(fname); - except - writeln('parsing failed!'); - end; - writeln('done.'); end.