Server Help

LVZ/LVL Questions - Y does this lvz crash cntm?

k0zy - Sat Jan 25, 2003 1:37 pm
Post subject: Y does this lvz crash cntm?
Code: Show/Hide
OutFile=water.lvz

File=animwater.bmp
File=cntr.bmp

[objectimages]
IMAGE0=animwater.bmp,8,1,800
IMAGE1=cntr.bmp

[mapobjects]
8192,8192,IMAGE1,AfterTiles

[screenobjects]
0,0,IMAGE0,AfterGauges


y?
It works fine without MapObjects...

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Mine GO BOOM - Sat Jan 25, 2003 3:34 pm
Post subject:
Post your .lvz, since it might be because that file doesn't exist in the .lvz, or its some weird invalid thing.
k0zy - Sat Jan 25, 2003 4:07 pm
Post subject:
I changed some code, but it still crashes, when i have mapabject and screenobject... When i have only mapobjects its working, same when i only have screenobjects!

Here the ini and the lvz it created.

Maybe cntm cant display the screenobjects over the mapobjects...

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....

[EDIT: For some reason opera7 beta uploaded the file twice]
SuSE - Sat Jan 25, 2003 7:32 pm
Post subject:
Try using buildlevel.
Makelevel is very picky...or buggy, whichever.
k0zy - Sat Jan 25, 2003 8:04 pm
Post subject:
U should fix this, mgb!!!
It works with buildlevel!

And with my Compiler (CLC), too!!! tongue.gif tongue.gif tongue.gif tongue.gif

And CLC makes smaller lvz than buildlevel.
So, i just compiled it with clc...
Hey, wait... it looks like its actually the best choice. biggrin.gif

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Helicon - Sat Jan 25, 2003 9:14 pm
Post subject:
competition... maybe? let the bloodwar begin icon_twisted.gif
nintendo64 - Sun Jan 26, 2003 7:12 pm
Post subject:
I liked Kozy's CLC, it was some nice work but it was kind of like BuildLevel and i preferred a MakeLevel look alike so i modified for it, the credit belongs all to kozy.

-nintendo64

EDIT: I didn't fix the datetime problem i couldn't find it neither, but i added an error like BuildLevel does for it.
Mine GO BOOM - Sun Jan 26, 2003 9:09 pm
Post subject:
When i did a test run with your exe, i used the Example.ini file, removed the File= stuff, and did a build. Then i DeBuildLevel it, and kaboom, crashed the exe. I take a look at the debug display of the crash, it turns out that one of the timer modes (ShowAlways, EnterZone, etc) was set to 11, while they max out at 6 (0 through 5). Might want to fix.
k0zy - Mon Jan 27, 2003 7:07 am
Post subject:
I recognized the problem...
But i'm unalbe to locate it.
It's impossible that ObjectMode was set to 11 by loading the ini, so it must happen by writing it into the lvz.

This is how i wrote it:

Code: Show/Hide

// Display Time + Display Mode
i32 = MapTime; // Save The Display Time into i32
i32 = (i32 * 16) + MapMode;  // (i12 Display Time + i4 Display Mode)
Objects.Write(i32,2);  //Write i32, but just 2 bytes (as i16)


Any ideas?
The prob is maybe that i use an i32 to calculate all this stuff.

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
SOS - Mon Jan 27, 2003 8:15 am
Post subject:
Seems right to me
k0zy - Mon Jan 27, 2003 10:13 am
Post subject:
btw:
sos, can u compile ur mervbot plugins against the lastet mervbot sourcecode?
So they will work properly again?

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
(Still unable to find the problem)
SOS - Mon Jan 27, 2003 2:34 pm
Post subject:
My plugins? Err I think I am too lazy. I'll see tomorrow.
k0zy - Mon Jan 27, 2003 5:17 pm
Post subject:
@sos: PLZ! (hehe)

The CLC Console version is great, thx nintendo64 icon_smile.gif

(Latest version includes 2 files, .exe and .dpr, but the .dpr allone without .dfm and .pas is pretty useless)

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
nintendo64 - Mon Jan 27, 2003 9:57 pm
Post subject:
Code: Show/Hide
program CLCConsole;
{  - Delphi Fast Zlib is required for compression:
    http://www.dellapasqua.com/delphizlib/ }

    {$APPTYPE CONSOLE}

uses
  Windows, SysUtils, Classes, ZlibEx;


var
  OutFile,Path: String;
  Files,ImageFile: TStringList;
  FileCount,MapCount,ScreenCount,ImageCount: Integer;
  Images,ImageX,ImageY,ImageT: Array of Integer;
  MapX,MapY,MapImage,MapLayer,MapMode,MapTime,MapID: Array of Integer;
  ScreenX,ScreenY,ScreenImage,ScreenLayer,ScreenMode,ScreenTime,ScreenID: Array of Integer;



//Main-procedure, runs when the form is created
procedure MainLVZProc;
begin
  Files := TStringList.Create;
  ImageFile := TStringList.Create;
end;

//free the StringLists when the form closes
procedure CloseLVZProc;
begin
  Files.Free;
  ImageFile.Free;
end;

// A cool function that gets the text between 2 ','!
//Output is an integer, so it modifies the text to fit lvz-format :)
function GetOption(Source:String;Commas:Integer;Image:Boolean):Integer;
var CommasCount,i: Integer;
    Help,Part: String;
begin
  Source := Source + ',';
  CommasCount := 0;
  For i := 1 to Length(Source) do
  begin
    Part := Copy(Source,i,1);
    If Part = ',' then CommasCount := CommasCount + 1;
    If CommasCount = Commas then
    begin
      Help := Help + Part;
    end;
    If CommasCount = (Commas + 1) then
    begin
      If Commas <> 0 then Help := Copy(Help,2,Length(Help));

      Help := Lowercase(Help);

      If (Copy(Help,1,2) = 'c+') or (Copy(Help,1,2) = 'c-') then
      begin
        If (Copy(Help,2,1) = '+') then
        begin
          Help := IntToStr(20000 + StrToInt(Copy(Help,3,Length(Help))));
        end;
        If (Copy(Help,2,1) = '-') then
        begin
          Help := IntToStr(20000 - StrToInt(Copy(Help,3,Length(Help))));
        end;
      end;

      If (Copy(Help,1,5) = 'image') and (Image = False) then Help := Copy(Help,6,Length(Help)-5);

      If Help = 'belowall' then Help := '0';
      If Help = 'afterbackground' then Help := '1';
      If Help = 'aftertiles' then Help := '2';
      If Help = 'afterweapons' then Help := '3';
      If Help = 'afterships' then Help := '4';
      If Help = 'aftergauges' then Help := '5';
      If Help = 'afterchat' then Help := '6';
      If Help = 'topmost' then Help := '7';

      If Help = 'showalways' then Help := '0';
      If Help = 'enterzone' then Help := '1';
      If Help = 'enterarena' then Help := '2';
      If Help = 'kill' then Help := '3';
      If Help = 'death' then Help := '4';
      If Help = 'servercontrolled' then Help := '5';

      GetOption := StrToInt(Help);
      exit;
    end;
  end;
  GetOption := 0;
  If Image then GetOption := 1;
end;

//function to get the file out of one image-line
function GetImageFile(Source:String):String;
var i: Integer;
    Help: String;
    iFile: Boolean;
begin
  iFile := False;
  For i := 1 to Length(Source) do
  begin
    If Copy(Source,i,1) = ',' then iFile := False;
    If iFile then
    begin
      Help := Help + Copy(Source,i,1);
    end;
    If Copy(Source,i,1) = '=' then iFile := True;
  end;
  GetImageFile := Help;
end;

function DateTimeToUnixTime(const DateTime: TDateTime): Integer;
var
FileTime: TFileTime;
SystemTime: TSystemTime;
I: Int64;
begin
// first convert datetime to Win32 file time
DateTimeToSystemTime(DateTime, SystemTime);
SystemTimeToFileTime(SystemTime, FileTime);
// simple maths to go from Win32 time to Unix time
I := Int64(FileTime.dwHighDateTime) shl 32 + FileTime.dwLowDateTime;
Result := (I - 116444736000000000) div Int64(10000000);
end;

//function to get FileTime in time_t
function GetTime_t(Datei:String):Integer;
var Res: Integer;
    Dat: TDateTime;
begin
  Res := FileAge(Datei);
  Dat := FileDateToDateTime(Res);
  GetTime_t := DateTimeToUnixTime(Dat);
end;

procedure NoFilesErr;
begin
writeln('Error: Could not load the files.');
writeln('Error: Cannot build lvz while .ini contains errors.');
writeln(' -- < PRESS ANY KEY TO EXIT > -- ');
CloseLVZProc;
readln;
halt(0);
end;

procedure Nodatadefined;
begin
writeln('Error: No data to write.');
writeln('Error: Cannot build lvz while .ini contains errors.');
writeln(' -- < PRESS ANY KEY TO EXIT > -- ');
CloseLVZProc;
readln;
halt(0);
end;

//these functions belong together

//procedure that compiles the arrays read-in by
//the open-procedure into a lvz file
procedure Compile(LVZFile:String);
var i,w,size: integer; //i32
    Datei: String; //Datei = German for File
    s: String;
    ms,objects: TMemoryStream;
    Input,LVZ: TFileStream;
    CompressionStream: TZCompressionStream;  //Zlib
begin

  if LVZFile = Path then nodatadefined;
  LVZ := TFileStream.Create(LVZFile,fmCreate);

  {LVZ-Header}
  LVZ.Write('CONT',4);

  {Count of Sections in the LVZ, inc if objects are avaible}

  i := Files.Count;
  If ((MapCount > 0) or (ScreenCount > 0)) then i := i + 1;
  LVZ.Write(i,4);

  FileCount := Files.Count;
  If ((MapCount > 0) or (ScreenCount > 0)) then FileCount := FileCount + 1;
  if FileCount = 1 then Nodatadefined;
  if FileCount = 0 then Nodatadefined;

  {Add the files}
  For w := 0 to Files.Count - 1 do
  begin
    Datei := Path + Files[w];
    LVZ.Write('CONT',4);

    ms := TMemoryStream.Create;
    if FileExists(Datei) = false then NoFilesErr;
    Input := TFileStream.Create(Datei,fmOpenRead);

    {Compress Input into ms (MemoryStream)}
    CompressionStream := TZCompressionStream.Create(ms, zcMax);
    CompressionStream.CopyFrom(Input, Input.Size);
    CompressionStream.Free;

    {Decompressed Size / Filesize}
    i := Input.Size;
    LVZ.Write(i,4);

    {File Time in time_t}
    i := GetTime_t(Datei);
    LVZ.Write(i,4);

    {Compressed Size}
    i := ms.Size;
    LVZ.Write(i,4);

    {File Name}
    s := Files[w];
    size := Length(s);
    LVZ.Write(s[1],size);

    {NULL}
    i := 0;
    LVZ.Write(i,1);

    {* data *}
    ms.SaveToStream(LVZ);

    ms.Free;
    Input.Free;

  end;

  If ((MapCount > 0) or (ScreenCount > 0)) then
  begin
    Objects := TMemoryStream.Create;

    {Objects Header}
    Objects.Write('CLV1',4);
    i := MapCount + ScreenCount;
    Objects.Write(i,4);
    Objects.Write(ImageCount,4);

    {MapObjects}
    For w := 0 to Mapcount - 1 do
    begin

      {MapObject + ObjectID}
      i := MapID[w];
      i := (i * 2) + 1;
      Objects.Write(i,2);

      {X Coord}
      i := MapX[w];
      Objects.Write(i,2);

      {Y Coord}
      i := MapY[w];
      Objects.Write(i,2);

      {Image Number}
      i := MapImage[w];
      Objects.Write(i,1);

      {Layer}
      i := MapLayer[w];
      Objects.Write(i,1);

      {Display Time + Display Mode}
      i := MapTime[w];
      i := (i * 16) + MapMode[w];
      Objects.Write(i,2);
    end;

    {ScreenObjects}
    For w := 0 to ScreenCount - 1 do
    begin

      {ScreenObject + ObjectID}
      i := ScreenID[w];
      i := (i * 2);
      Objects.Write(i,2);

      {X Coord}
      i := ScreenX[w];
      Objects.Write(i,2);

      {Y Coord}
      i := ScreenY[w];
      Objects.Write(i,2);

      {Image Number}
      i := ScreenImage[w];
      Objects.Write(i,1);

      {Layer}
      i := ScreenLayer[w];
      Objects.Write(i,1);

      {Display Time + Display Mode}
      i := ScreenTime[w];
      i := (i * 16) + ScreenMode[w];
      Objects.Write(i,2);
    end;

    {Add Images}
    For w := 0 to ImageCount - 1 do
    begin
      {X Coords}
      i := ImageX[w];
      Objects.Write(i,2);
      {Y Coords}
      i := ImageY[w];
      Objects.Write(i,2);
      {Display Time}
      i := ImageT[w];
      Objects.Write(i,2);
      {File Name}
      s := ImageFile[w];
      size := Length(s);
      Objects.Write(s[1],size);
      {NULL}
      i := 0;
      Objects.Write(i,1);
    end;

    {Add Objects to the LVZ}

    ms := TMemoryStream.Create;

    {Compress Objects into ms (MemoryStream)}
    CompressionStream := TZCompressionStream.Create(ms, zcMax);
    objects.SaveToStream(CompressionStream);
    CompressionStream.Free;

    LVZ.Write('CONT',4);
    {Decompressed Size}
    i := Objects.Size;
    LVZ.Write(i,4);
    {File Time = 0}
    i := 0;
    LVZ.Write(i,4);
    {Compressed Size}
    i := ms.Size;
    LVZ.Write(i,4);
    {FileName Length = 0, so just NULL}
    i := 0;
    LVZ.Write(i,1);
    {* data * (Compressed Objects)}
    ms.SaveToStream(LVZ);

    ms.Free;
    Objects.Free;
  end;
  LVZ.Free;

end;

//procedure that reads the ini into several arrays
procedure INIOpen(Datei:String);
var f: TextFile;
    section,Flag,i: integer;
    Line,Help: string;
begin
  MapCount := 0;
  ScreenCount := 0;
  ImageCount := 0;
  section := 0;
  AssignFile(f,Datei);
  Reset(f);
  while not EOF(f) do
  begin
    Flag := 0;
    ReadLn(f,Line);
    If (LowerCase(Copy(Line,1,7)) = 'outfile') then
    begin
      OutFile := Copy(Line,9,Length(Line)-8);
    end;
    If (LowerCase(Copy(Line,1,4)) = 'file') then
    begin
      Files.Add(Copy(Line,6,Length(Line)-5))
    end;
    If (LowerCase(Copy(Line,1,14)) = '[objectimages]') then
    begin
      section := 1;
      Flag := 1;
    end;
    If (LowerCase(Copy(Line,1,12)) = '[mapobjects]') then
    begin
      section := 2;
      Flag := 1;
    end;
    If (LowerCase(Copy(Line,1,15)) = '[screenobjects]') then
    begin
      section := 3;
      Flag := 1;
    end;
    If (Flag = 0) then
    begin
      if (section = 1) and (Copy(Line,1,1) <> ';') and (Length(Line) <> 0) then
      begin
        // ObjectImages
        ImageCount := ImageCount + 1;

        {Get ImageNumber / Set ImageCount}
        Help := '';
        For i := 1 to Length(Line) do
        begin
          Help := Help + Copy(Line,i,1);
          If Copy(Line,i,1) = '=' then
          begin
            Help := Copy(Help,1,Length(Help)-1);
            Help := Copy(Help,6,Length(Help)-5);
            SetLength(Images,ImageCount);
            SetLength(ImageT,ImageCount);
            SetLength(ImageY,ImageCount);
            SetLength(ImageX,ImageCount);
            Images[ImageCount-1] := StrToInt(Help);
          end;
        end;

        {Get File of the Image}
        Help := GetImageFile(Line);
        ImageFile.Add(Help);

        {Other attributes}
        ImageX[ImageCount-1] := GetOption(Line,1,True);
        ImageY[ImageCount-1] := GetOption(Line,2,True);
        ImageT[ImageCount-1] := GetOption(Line,3,True);
        If (ImageT[ImageCount-1] = 1) or (ImageT[ImageCount-1] = 0) then ImageT[ImageCount-1] := 100;

      end;
      if (section = 2) and (Copy(Line,1,1) <> ';') and (Length(Line) <> 0) then
      begin
        // MapObjects
        MapCount := MapCount + 1;

        SetLength(MapX,MapCount);
        SetLength(MapY,MapCount);
        SetLength(MapImage,MapCount);
        SetLength(MapLayer,MapCount);
        SetLength(MapMode,MapCount);
        SetLength(MapTime,MapCount);
        SetLength(MapID,MapCount);

        MapX[MapCount-1] := GetOption(Line,0,False);
        MapY[MapCount-1] := GetOption(Line,1,False);
        MapImage[MapCount-1] := GetOption(Line,2,False);
        MapLayer[MapCount-1] := GetOption(Line,3,False);
        MapMode[MapCount-1] := GetOption(Line,4,False);
        MapTime[MapCount-1] := GetOption(Line,5,False);
        MapID[MapCount-1] := GetOption(Line,6,False);
      end;
      if (section = 3) and (Copy(Line,1,1) <> ';') and (Length(Line) <> 0) then
      begin
        // ScreenObjects
        ScreenCount := ScreenCount + 1;

        SetLength(ScreenX,ScreenCount);
        SetLength(ScreenY,ScreenCount);
        SetLength(ScreenImage,ScreenCount);
        SetLength(ScreenLayer,ScreenCount);
        SetLength(ScreenMode,ScreenCount);
        SetLength(ScreenTime,ScreenCount);
        SetLength(ScreenID,ScreenCount);

        ScreenX[ScreenCount-1] := GetOption(Line,0,False);
        ScreenY[ScreenCount-1] := GetOption(Line,1,False);
        ScreenImage[ScreenCount-1] := GetOption(Line,2,False);
        ScreenLayer[ScreenCount-1] := GetOption(Line,3,False);
        ScreenMode[ScreenCount-1] := GetOption(Line,4,False);
        ScreenTime[ScreenCount-1] := GetOption(Line,5,False);
        ScreenID[ScreenCount-1] := GetOption(Line,6,False);
      end;
    end;
  end;
  CloseFile(f);
end;

var
msgtoread, extholder: string;
begin
MainLVZProc;
write('Please type in an .ini to work with: ');
readln(msgtoread);
extholder:=ExtractFileExt(msgtoread);
if msgtoread = EmptyStr then
begin
writeln('Error: No Filename Provided.');
writeln(' -- < PRESS ANY KEY TO EXIT > -- ');
CloseLVZProc;
readln;
halt(0);
end
else if FileExists(msgtoread) = false  then
begin
writeln('Error: Filename does not exist.');
writeln(' -- < PRESS ANY KEY TO EXIT > -- ');
CloseLVZProc;
readln;
halt(0);
end
else if extholder <> '.ini'  then
begin
writeln('Error: Invalid Filename.');
writeln(' -- < PRESS ANY KEY TO EXIT > -- ');
CloseLVZProc;
readln;
halt(0);
end
else
INIOpen(msgtoread);
Path:=ExtractFilePath(msgtoread);
Compile(Path+Outfile);
writeln('Finished Making '+Outfile+ '  Count: '+inttostr(Filecount));
writeln(' -- < PRESS ANY KEY TO EXIT > -- ');
CloseLVZProc;
readln;
halt(0);
end.


Well... i use Delphi 6 and it reads the source code just fine, here it is the code anyway.

-nintendo64
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group