All pastes #781455 Raw Edit

Untitled

public text v1 · immutable
·published 2007-11-18 21:34 UTC
rendered paste body
procedure loadCoords(mapname: string);
var
  	fileContents, name: string;
  	parts: tStringArray;
  	x, y: single;
 	i: byte;

begin
	if fileExists(mapname+COORDSFILE) = false then 
	begin
    		writeln('[Teleport] Missing file "' + mapname+COORDSFILE + '"... creating...');
		writeFile(mapname+COORDSFILE, ' ');
  	end else
	begin 
		fileContents := readFile(mapname+COORDSFILE);
  		parts := xSplit(fileContents, #10);
  		count := 0;
  
  		for i := 0 to getArrayLength(coords) - 1 do 
		begin
			if maskCheck(parts[i], '*///*///*///*') then 
			begin
		        	x := strToFloat(getPiece(parts[i], '///', 0));
				y := strToFloat(getPiece(parts[i], '///', 1));
			        name := getPiece(parts[i], '///', 2);
    
			        coords[count].lable := name;
			        coords[count].x     := x;
			        coords[count].y     := y;    
    
			        count := count + 1;
		  	        setArrayLength(coords, count+1);
    			end
		end
	end
    writeln('[Teleport] Loaded ' + intToStr(count) + ' coordinates from ' + mapname+COORDSFILE);
end;

procedure ActivateServer();
begin
	setArrayLength(coords, 1);
	broadcast := false;
  	writeln('[Teleport] Loading coordinates...');
  
  	if currentMap = nil then 
	begin
    		loadCoords('./init');
  	end else 
	begin
    		loadCoords('./'+currentMap);
  	end
  writeln('[Teleport] Loading complete.');
end;