Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: level loading

  1. #1

    level loading

    System: Windows XP, AMD Sempron +2800 , nVidia GeForce FX 5500
    Compiler/IDE: Delphi 2006 for Win32
    API: DelphiX

    Did not find any info, so I'm going to ask here:
    I'm loading my main map from a text file in the onFormCreate event:
    [pascal]procedure TForm22.FormCreate(Sender: TObject);
    begin
    form22.setupmap(mapfile);
    end;[/pascal]

    with this procedure:
    [pascal]
    procedure tform22.SetupMap(MapFile:string);
    var stream:TFilestream;
    C : Char;
    x, y : Word;
    tempbuffer : array[ 0..32, 0..24 ] of Char;
    begin
    Stream:=tfilestream.Create(mapfile, fmopenread);

    try
    try
    for y:=0 to 24 do
    begin
    for x := 0 to 31 do
    begin
    stream.ReadBuffer(C, SizeOf(C));
    tempbuffer[x][y]:=c;

    end;
    end;
    except on e:exception do
    messagedlg(e.Message, mterror, [mbok], 0);
    end;
    finally
    stream.free
    end;

    for y := 0 to 25 do
    begin
    for x := 0 to 32 do
    begin
    case tempbuffer[x][y] of
    //grass
    '0':
    begin
    map[x][y].Tile:=0;
    end;
    //path
    '1' :
    begin
    map[x][y].Tile:=1;
    end;
    //water
    '2' :
    begin
    map[x][y].Tile:=2;
    end;
    end;
    end;
    end;


    end;
    [/pascal]

    but since one map in game is not good, I want to load different maps. I tried loading them in doLoad procedure, like this:
    [pascal]
    procedure doLoad;
    begin
    form22.SetupMap('map.map');
    gamestate:= gsgame;
    end;


    //and I try to engage the doLoad procedure like this

    procedure TForm22.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    begin
    ...
    //other keys that control menu
    ...
    if (key = vk_space) and (gamestate = gsgame) then
    begin
    gamestate:= gsload;
    end;
    end;
    [/pascal]

    but everytime I only get a "stream read error".
    I guess I'm could use some kind of simple procedure, but I can't think of any.
    Cheers, leniz[/pascal]

  2. #2

    level loading

    As usual, give us more information and some source code. Compiler, Platform, and a simple sample that shows your problem is about the minimum to get an answer. Otherwise no one knows what your talking about. If your referencing a previous posts source, then place a link (we don't fish for your source).

  3. #3

    level loading

    Does Map.map exist in your exe path?

  4. #4

    level loading

    Yes it does. And no matter what filename or filetype I use, it's all the same error.

  5. #5

    level loading

    What happens when you step through the code? where do you get the error? Is it when it does the Stream:=tfilestream.Create(mapfile, fmopenread);

    or on one of the stream.ReadBuffer(C, SizeOf(C)); statements?

    If it is on the file open, then there's a problem with the file location/filename and the app can't find it.

    If it's on one of the ReadBuffers then the file isn't big enough for the array..

    I'm not at a Delphi PC at the moment, so I can't test anything.

  6. #6

    level loading

    Yes like jason said maybe map.map doesn't exist?

    I think the procedure could better be something like this...

    [code]
    procedure doLoad(MapName: string);
    begin
    form22.SetupMap(MapName+'.map');
    gamestate:= gsgame;
    end;
    "What we cannot speak about we must pass over in silence."

  7. #7

    level loading

    I get my error in the doLoad procedure:
    [pascal]procedure doLoad;
    begin
    form22.SetupMap('map.map'); <---- right about here is the error
    gamestate:= gsgame;
    end;[/pascal]

    Then I can't go further, because my BDS2006 locks up and I have to "ctrl+alt+del" it.

  8. #8

    level loading

    but you can step into that function before it locks up and see what line of code causes the problem...

  9. #9

    level loading

    that "lock-up" is partially a bug, go to BDS->Tools->Debugger Options->BDS Debuggers (I have CodeGear Debuggers here)->Native OS Exception->Select all and toggle "Handled by debugger" and "Run unhandled"...no longer an exception should lock up the IDE....

  10. #10

    level loading

    If the error occurs there, it means that inside the procedure is an error.

    Go to debugger options...

    EDIT: Argh someone was already before me...
    &quot;What we cannot speak about we must pass over in silence.&quot;

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •