1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-23 07:48:50 -05:00

libMML: Commit patch by iluffsyew.

This commit is contained in:
Merlijn Wajer 2010-12-03 14:25:58 +01:00
parent 8697cf3091
commit 273579297a

View File

@ -235,27 +235,31 @@ end;
{ Colour }
function get_color(C: TClient; x, y: integer; var color: integer): integer;
function get_color(C: TClient; x, y: Integer;
out color: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
color := C.IOManager.GetColor(x, y);
except on e : exception do
begin
color := C.IOManager.GetColor(x, y);
if color > -1 then
result := RESULT_OK
else
result := RESULT_FALSE;
end;
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
set_last_error(e.Message);
end;
end;
result := RESULT_OK;
end;
{ Find color on client C in area (x1,y1,x2,y2) and return coordinate (if any) in x, y }
function find_color(C: TClient; var x, y: integer; color, x1, y1, x2, y2: integer): integer; cdecl;
function find_color(C: TClient; var x, y: Integer;
color, x1, y1, x2, y2: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
@ -269,14 +273,14 @@ begin
result := RESULT_FALSE;
except on e : Exception do
begin
result := RESULT_ERROR;
set_last_error(e.Message);
result := RESULT_ERROR;
end;
end;
end;
function find_color_tolerance(C: TClient; var x, y: integer; color, tol, x1, y1, x2, y2: integer): integer; cdecl;
function find_color_tolerance(C: TClient; var x, y: Integer; color: Integer;
tol, x1, y1, x2, y2: Integer): Integer; cdecl;
begin
if not validate_client(C) then
@ -291,13 +295,37 @@ begin
result := RESULT_FALSE;
except on e : Exception do
begin
result := RESULT_ERROR;
set_last_error(e.Message);
result := RESULT_ERROR;
end;
end;
end;
function find_colors(C: TClient; var ptr: PPoint; var len: integer; color, x1, y1, x2, y2: integer): integer; cdecl;
function find_color_tolerance_optimised(C: TClient; var x, y: Integer;
var len: Integer; col: Integer;
x1, y1, x2, y2: Integer;
tol: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
if C.MFinder.FindColorToleranceOptimised(x, y, col, x1, y1, x2, y2,
tol) then
result := RESULT_OK
else
result := RESULT_FALSE;
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
end;
function find_colors(C: TClient; var ptr: PPoint; var len: Integer;
color, x1, y1, x2, y2: Integer): Integer; cdecl;
var
TPA: TPointArray;
begin
@ -311,19 +339,22 @@ begin
C.MFinder.FindColors(TPA, color, x1, y1, x2, y2);
except on e : Exception do
begin
result := RESULT_ERROR;
set_last_error(e.Message);
result := RESULT_ERROR;
end;
end;
len := Length(TPA);
ptr := array_to_ptr(Pointer(@TPA[0]), len, sizeof(TPoint));
result := RESULT_OK;
if len > 0 then
result := RESULT_OK
else
result := RESULT_FALSE;
setlength(tpa, 0);
end;
function find_colors_tolerance(C: TClient; var ptr: PPoint; var len: Integer;
color, tol, x1, y1, x2, y2: integer): integer; cdecl;
color, tol, x1, y1, x2, y2: Integer): Integer; cdecl;
var
TPA: TPointArray;
begin
@ -336,13 +367,248 @@ begin
C.MFinder.FindColorsTolerance(TPA, color, x1, y1, x2, y2, tol);
except on e : Exception do
begin
result := RESULT_ERROR;
set_last_error(e.Message);
result := RESULT_ERROR;
end;
end;
len := Length(TPA);
ptr := array_to_ptr(Pointer(@TPA[0]), len, sizeof(TPoint));
if len > 0 then
result := RESULT_OK
else
result := RESULT_FALSE;
setlength(TPA, 0);
end;
function find_colors_tolerance_optimised(C: TClient; var ptr: PPoint;
var len: Integer; col: Integer;
x1, y1, x2, y2: Integer;
tol: Integer): Integer; cdecl;
var
TPA: TPointArray;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
C.MFinder.FindColorsToleranceOptimised(TPA, col, x1, y1, x2, y2, tol);
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
len := Length(TPA);
ptr := array_to_ptr(Pointer(@TPA[0]), len, sizeof(TPoint));
if len > 0 then
result := RESULT_OK
else
result := RESULT_FALSE;
end;
function similar_colors(C: TClient; col1, col2, tol: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
if C.MFinder.SimilarColors(col1, col2, tol) then
result := RESULT_OK
else
result := RESULT_FALSE;
end;
function count_color(C: TClient; out count: Integer;
Color, xs, ys, xe, ye: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
begin
count := C.MFinder.CountColor(Color, xs, ys, xe, ye);
if count > 0 then
result := RESULT_OK
else
result := RESULT_FALSE;
end;
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
end;
function count_color_tolerance(C: TClient; out count: Integer; col: Integer;
xs, ys, xe, ye, tol: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
count := C.MFinder.CountColorTolerance(col, xs, ys, xe, ye, tol);
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
if count > 0 then
result := RESULT_OK
else
result := RESULT_FALSE;
end;
function find_color_spiral(C: TClient; var x, y: Integer;
col, xs, ys, xe, ye: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
if C.MFinder.FindColorSpiral(x, y, col, xs, ys, xe, ye) then
result := RESULT_OK
else
result := RESULT_FALSE;
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
end;
function find_color_spiral_tolerance(C: TClient; var x, y: Integer;
col, xs, ys, xe, ye: Integer;
tol: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
if C.MFinder.FindColorSpiralTolerance(x, y, col, xs, ys, xe, ye, tol) then
result := RESULT_OK
else
result := RESULT_FALSE;
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
end;
function find_colored_area(C: TClient; var x, y: Integer;
col, xs, ys, xe, ye, minA: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
if C.MFinder.FindColoredArea(x, y, col, xs, ys, xe, ye, minA) then
result := RESULT_OK
else
result := RESULT_FALSE;
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
end;
function find_colored_area_tolerance(C: TClient; var x, y: Integer;
col, xs, ys, xe, ye, minA: Integer;
tol: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
if C.MFinder.FindColoredAreaTolerance(x, y, col,
xs, ys, xe, ye, minA, tol) then
result := RESULT_OK
else
result := RESULT_FALSE;
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
end;
function set_tolerance_speed(C: TClient; nCTS: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
begin
C.MFinder.SetToleranceSpeed(nCTS);
result := RESULT_OK;
end;
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
end;
function get_tolerance_speed(C: TClient; out cts: Integer): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
cts := C.MFinder.GetToleranceSpeed;
result := RESULT_OK;
end;
function set_tolerance_speed_2_modifiers(C: TClient;
nHue, nSat: Extended): Integer; cdecl;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
try
begin
C.MFinder.SetToleranceSpeed2Modifiers(nHue, nSat);
result := RESULT_OK;
end;
except on e : Exception do
begin
set_last_error(e.message);
result := RESULT_ERROR;
end;
end;
end;
function get_tolerance_speed_2_modifiers(C: TClient; out hueMod: Extended;
out satMod: Extended): Integer; cdecl;
var
h, s: Extended;
begin
if not validate_client(C) then
begin
exit(RESULT_ERROR);
end;
C.MFinder.GetToleranceSpeed2Modifiers(h, s);
hueMod := h;
satMod := s;
result := RESULT_OK;
end;
@ -452,6 +718,7 @@ begin
exit(RESULT_FALSE);
end;
// FIXME: Catch exceptions.
C.IOManager.SetTarget(Arr, Size);
result := RESULT_OK;
@ -486,5 +753,4 @@ exports
begin
end.
end.