Skip to content

Commit

Permalink
Fixed access violations, timeouts, and tolerances.
Browse files Browse the repository at this point in the history
Fixed function timeouts and access violations caused by nil^.

Added angle tolerance.

Made function timeouts customizable with ogl.setTimeOut() and
ogl.setDefaultTimeout().
  • Loading branch information
ObscuritySRL committed Apr 6, 2015
1 parent 6f7e587 commit 14e82b1
Show file tree
Hide file tree
Showing 11 changed files with 293 additions and 109 deletions.
2 changes: 2 additions & 0 deletions lib/core/core.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[default]
oglAngleTolerance=0.26179938779914943653855361527335
oglCacheTime=60
oglColourTolerance=4
oglControlAutoRetaliate=
oglControlFamiliarAction=
oglControlQuickPrayer=
oglClientHeight=600
oglClientWidth=800
oglTimeout=2000
51 changes: 49 additions & 2 deletions lib/core/core.simba
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,20 @@ function ogl.setDefaultControlQuickPrayer(funcControlQuickPrayer:ansiString):ans



function ogl.getAngleTolerance():double;
begin result:=oglAngleTolerance;end;

function ogl.setAngleTolerance(funcAngleTolerance:int32):double;
begin oglAngleTolerance:=result:=funcAngleTolerance;end;

function ogl.setDefaultAngleTolerance(funcAngleTolerance:int32):double;
begin
writeINI('default','oglAngleTolerance',toStr(funcAngleTolerance),'includes/ogLib/lib/core/core.ini');
oglAngleTolerance:=result:=funcAngleTolerance;
end;



function ogl.getColourTolerance():int32;
begin result:=oglColourTolerance;end;

Expand All @@ -764,16 +778,35 @@ function ogl.setDefaultColourTolerance(funcColourTolerance:int32):int32;



function ogl.getTimeout():uInt32;
begin result:=oglTimeout;end;

function ogl.setTimeout(funcTimeout:uInt32):uInt32;
begin
glxSetTimeout(funcTimeout);
exit(result:=funcTimeout);
end;

function ogl.setDefaultTimeout(funcTimeout:uInt32):uInt32;
begin
writeINI('default','oglTimeout',toStr(funcTimeout),'includes/ogLib/lib/core/core.ini');
oglTimeout:=result:=funcTimeout;
end;



procedure ogl.save();
begin
ogl.getClientDimensions(oglClientWidth,oglClientHeight);
writeINI('default','oglAngleTolerance',toStr(oglAngleTolerance),'includes/ogLib/lib/core/core.ini');
writeINI('default','oglCacheTime',toStr(oglCacheTime),'includes/ogLib/lib/core/core.ini');
writeINI('default','oglColourTolerance',toStr(oglColourTolerance),'includes/ogLib/lib/core/core.ini');
writeINI('default','oglControlAutoRetaliate',oglControlAutoRetaliate,'includes/ogLib/lib/core/core.ini');
writeINI('default','oglControlFamiliarAction',oglControlFamiliarAction,'includes/ogLib/lib/core/core.ini');
writeINI('default','oglControlQuickPrayer',oglControlQuickPrayer,'includes/ogLib/lib/core/core.ini');
writeINI('default','oglClientHeight',toStr(oglClientHeight),'includes/ogLib/lib/core/core.ini');
writeINI('default','oglClientWidth',toStr(oglClientWidth),'includes/ogLib/lib/core/core.ini');
writeINI('default','oglTimeout',toStr(oglTimeout),'includes/ogLib/lib/core/core.ini');
end;

function ogl.setup(funcClientWidth,funcClientHeight:int32=0):boolean;
Expand All @@ -782,16 +815,30 @@ function ogl.setup(funcClientWidth,funcClientHeight:int32=0):boolean;
funcClientHeight:=strToInt(replaceRegExpr('^$',readINI('Default','oglClientHeight','includes/ogLib/lib/core/core.ini'),'600',false));
if funcClientWidth=0 then
funcClientWidth:=strToInt(replaceRegExpr('^$',readINI('Default','oglClientWidth','includes/ogLib/lib/core/core.ini'),'800',false));

oglAngleTolerance:=strToFloat(replaceRegExpr('^$',readINI('Default','oglAngleTolerance','includes/ogLib/lib/core/core.ini'),'0.26179938779914943653855361527335',false));
oglCacheTime:=strToInt(replaceRegExpr('^$',readINI('Default','oglCacheTime','includes/ogLib/lib/core/core.ini'),'60',false));
oglColourTolerance:=strToInt(replaceRegExpr('^$',readINI('Default','oglColourTolerance','includes/ogLib/lib/core/core.ini'),'4',false));
oglControlAutoRetaliate:=replaceRegExpr('^$',readINI('Default','oglControlAutoRetaliate','includes/ogLib/lib/core/core.ini'),'',false);
oglControlFamiliarAction:=replaceRegExpr('^$',readINI('Default','oglControlFamiliarAction','includes/ogLib/lib/core/core.ini'),'',false);
oglControlQuickPrayer:=replaceRegExpr('^$',readINI('Default','oglControlQuickPrayer','includes/ogLib/lib/core/core.ini'),'',false);

oglTimeout:=strToInt(replaceRegExpr('^$',readINI('Default','oglTimeout','includes/ogLib/lib/core/core.ini'),'2000',false));
glxSetTimeout(oglTimeout);
smart.create(oglClientWidth:=funcClientWidth,oglClientHeight:=funcClientHeight,'',['OpenGL32.dll']);
if glxMapHooks(smart.ID) then
writeLN('glxMapHooks was successful.')
else
writeLN('glxMapHooks was successful.');
end;

var
a,b:array[0..3] of single;

begin
ogl.setup();
ogl.setTimeout(0);
repeat
inventory.getItem(123);
//mainScreen.setRadians(randomE()*6.283185307179586476925286766559,randomE()*0.9);
//wait(random(500));
until false;
end;
9 changes: 6 additions & 3 deletions lib/core/glFonts.simba
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ function glFonts(var funcPointerSize:uInt32):pointer;
begin
if (funcSystemTime:=getSystemTime())-oglFontTimeLast>oglCacheTime then
begin
oglFontPointer:=result:=glxFonts(funcPointerSize);
oglFontPointerSize:=funcPointerSize;
oglFontTimeLast:=funcSystemTime;
if (result:=glxFonts(funcPointerSize))<>nil then
begin
oglFontPointer:=result;
oglFontPointerSize:=funcPointerSize;
oglFontTimeLast:=funcSystemTime;
end;
end
else
begin
Expand Down
11 changes: 7 additions & 4 deletions lib/core/glMapCoords.simba
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ function glMapCoords(var funcX,funcY:array[0..3] of single):boolean;
begin
if (funcSystemTime:=getSystemTime())-oglMapCoordsTimeLast>oglCacheTime then
begin
oglMapCoords:=result:=glxMapCoords(funcX,funcY);
oglMapCoordsParameters[0]:=funcX;
oglMapCoordsParameters[1]:=funcY;
oglMapCoordsTimeLast:=funcSystemTime;
if result:=glxMapCoords(funcX,funcY) then
begin
oglMapCoords:=result;
oglMapCoordsParameters[0]:=funcX;
oglMapCoordsParameters[1]:=funcY;
oglMapCoordsTimeLast:=funcSystemTime;
end;
end
else
begin
Expand Down
7 changes: 5 additions & 2 deletions lib/core/glMatrices.simba
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ function glMatrices():pointer;
begin
if (funcSystemTime:=getSystemTime())-oglMatricesTimeLast>oglCacheTime then
begin
oglMatrices:=result:=glxMatrices();
oglMatricesTimeLast:=funcSystemTime;
if (result:=glxMatrices())<>nil then
begin
oglMatrices:=result;
oglMatricesTimeLast:=funcSystemTime;
end;
end
else
result:=oglMatrices;
Expand Down
9 changes: 6 additions & 3 deletions lib/core/glModels.simba
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ function glModels(var funcPointerSize:uInt32):pointer;
begin
if (funcSystemTime:=getSystemTime())-oglModelTimeLast>oglCacheTime then
begin
oglModelPointer:=result:=glxModels(funcPointerSize);
oglModelPointerSize:=funcPointerSize;
oglModelTimeLast:=funcSystemTime;
if (result:=glxModels(funcPointerSize))<>nil then
begin
oglModelPointer:=result;
oglModelPointerSize:=funcPointerSize;
oglModelTimeLast:=funcSystemTime;
end;
end
else
begin
Expand Down
9 changes: 6 additions & 3 deletions lib/core/glTextures.simba
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ function glTextures(var funcPointerSize:uInt32):pointer;
begin
if (funcSystemTime:=getSystemTime())-oglTextureTimeLast>oglCacheTime then
begin
oglTexturePointer:=result:=glxTextures(funcPointerSize);
oglTexturePointerSize:=funcPointerSize;
oglTextureTimeLast:=funcSystemTime;
if (result:=glxTextures(funcPointerSize))<>nil then
begin
oglTexturePointer:=result;
oglTexturePointerSize:=funcPointerSize;
oglTextureTimeLast:=funcSystemTime;
end;
end
else
begin
Expand Down
2 changes: 2 additions & 0 deletions lib/core/type.simba
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ type countDown=record
end;

var
oglAngleTolerance:double;
oglCacheTime:int32;
oglClientHeight:int32;
oglClientWidth:int32;
Expand All @@ -25,6 +26,7 @@ var
oglTexturePointer:pointer;
oglTexturePointerSize:uInt32;
oglTextureTimeLast:uInt32;
oglTimeout:uInt32;
smart:tSmart;

type glTexture=record
Expand Down
Loading

0 comments on commit 14e82b1

Please sign in to comment.