All pastes #779326 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-11-18 10:05 UTC
rendered paste body
type
  coord = record
    x, y: single;
    lable, map: string;
  end;

const
  COORDSFILE = 'coords.txt';
  MAXCOORDS = 20;
var
  coords: array[1 .. MAXCOORDS] of coord;

function XSplit(const Source: string; const Delimiter: string): tstringarray;
var
  i,x,d: integer;
  s: string;
begin
  d := Length(Delimiter);
  x := 0;
  i := 1;
  SetArrayLength(Result,1);
  while i <= Length(source) do begin
    s := Copy(Source,i,d);
    if s = Delimiter then begin
      Inc(i,d);
      Inc(x,1);
      SetArrayLength(result,x + 1);
    end else begin
      Result[x] := Result[x] + Copy(s,1,1);
      Inc(i,1);
    end;
  end;
end;

procedure loadCoords();
var
  fileContents: string;
  parts: tStringArray;  
begin
  fileContents = readFile(COORDSFILE);
  parts := xSplit(fileContents, #10);
end;

procedure ActivateServer();
begin
  if fileExists(COORDSFILE) then begin
    writeln('[Teleport] Loading coordinates...');
    loadCoords();
    writeln('[Teleport] Loading complete.');
  end else begin
    writeln('[Teleport] Failed loading preset coordinates: File does not exist!');
  end;
end;