SRL Archive - Devs' Corner

Updating old procedures


Cstrike

2010-12-03 13:42:30

Heres an old procedure that is nice:
{*******************************************************************************
function R_ClickToContinue: boolean;
By: Drags111
Description: Does as the name suggests. Clicks the 'click here to continue' crap
*******************************************************************************}
function R_ClickToContinue: boolean;
var
inter, i, z, L, x, y, w, h: integer;
str: String;
begin
Result := False;
for i := 0 to High(INTERFACE_TALKS) do
begin
inter := SmartGetFieldArrayObject(0, hook_static_GetInterfaces, INTERFACE_TALKS[i]);
L := SmartGetFieldArraySize(inter, '', 1);
SmartFreeObject(inter);

for z := 0 to L-1 do
begin
str := GetInterfaceText(INTERFACE_TALKS[i], z);
if(pos(lowercase(trim('click here to conti')), lowercase(trim(str))) > 0)then
begin
//Writeln('Found CTC at interface '+ToStr(INTERFACE_TALKS[i])+', '+ToStr(z));
inter := GetInterface(INTERFACE_TALKS[i], z);
x := SmartGetFieldInt(inter, hook_interface_GetX) + 7;
y := SmartGetFieldInt(inter, hook_interface_GetY) + 347;
w := SmartGetFieldInt(inter, hook_interface_GetWidth);
h := SmartGetFieldInt(inter, hook_interface_GetHeight);
MouseBox(x, y, x+w, y+h, 1);
SmartFreeObject(inter);
Result := true;
Exit;
end;
end;
end;
end;

Am I allowed to take:
        x := SmartGetFieldInt(inter, hook_interface_GetX) + 7;
y := SmartGetFieldInt(inter, hook_interface_GetY) + 347;
w := SmartGetFieldInt(inter, hook_interface_GetWidth);
h := SmartGetFieldInt(inter, hook_interface_GetHeight);

And change that part into something like

GetInterfacePoint (IntI, ChildI, x, y, w, h);


Is there an objection to this or are we not allowed to (would only be done if it works just as perfectly as before, no less)? What about reshuffling the core as well? Interfaces should be on top since they're uber developed now and are pretty much independent of everything else. Or should we follow the Not broken don't fix it rule?
Just a suggestion, tell me what you think.

Sir R. M8gic1an

2010-12-03 13:58:50

I would say that if these two methods achieve the same results differently,
keep both.

This is to mean keep both if this is true:
Method 1 breaks - Method 2 still works

R_ClickToContinue
if not Method1 then
if not Method2 then
//...

If not just use whatever is best.

I'd suggest expanding reflection tho, as Drags' code is not that all and unlikely needs cleaning up just yet

In the end this is not my call anyway :p

~RM