PDA

View Full Version : LoggedIn ~ change



Getdropped
10-27-2012, 01:30 AM
Here is what I think would work a tad bit better ;)

(*
LoggedIn
~~~~~~~~

.. code-block:: pascal

function LoggedIn: Boolean;

Returns True if Logged in.

.. note::

by WT-Fakawi, Getdropped

Example:

.. code-block:: pascal

*)
function LoggedIn: Boolean;
begin
//White text on Report Abuse Button
if (GetColor(472, 490) = 16777215) then
begin
Result := true;
Exit;//no need to do anything to the navbar
end;
SRL_ResetNavBar;
Result := (GetColor(472, 490) = 16777215);
end;

It was :
(*
LoggedIn
~~~~~~~~

.. code-block:: pascal

function LoggedIn: Boolean;

Returns True if Logged in.

.. note::

by WT-Fakawi

Example:

.. code-block:: pascal

*)
function LoggedIn: Boolean;
begin
//White text on Report Abuse Button
SRL_ResetNavBar;
Result := (GetColor(472, 490) = 16777215);
end;

It would be more efficient to not check for the nav bar if you already found the report button wouldn't it? just a thought ;)

PS. Not sure if this is the right place but throught it looked right ;)
Reason I made the change is because it was being buggy when banking see : http://villavu.com/forum/showthread.php?t=91755

~Getdropped :cool:

Enslaved
10-27-2012, 01:32 AM
good job, now let the major testing begin

riwu
10-27-2012, 02:05 AM
Yeah i guess that would be slightly more efficient, good work.

Though it might be better to use a loop instead of repeating GetColor:

function LoggedIn: Boolean;
var
i: Integer;
begin
for i:=1 to 2 do
begin
//White text on Report Abuse Button
if (GetColor(472, 490) = 16777215) then
begin
Result := true;
Exit;//no need to do anything to the navbar
end;

if (i = 1) then
SRL_ResetNavBar;
end;
end;

Getdropped
10-27-2012, 02:41 AM
Yeah i guess that would be slightly more efficient, good work.

Though it might be better to use a loop instead of repeating GetColor:

function LoggedIn: Boolean;
var
i: Integer;
begin
for i:=1 to 2 do
begin
//White text on Report Abuse Button
if (GetColor(472, 490) = 16777215) then
begin
Result := true;
Exit;//no need to do anything to the navbar
end;

if (i = 1) then
SRL_ResetNavBar;
end;
end;

no because it still needs to search the same point for the colors to see if you were logged in and it found that the navbar needed to be reset... else that would work, it is like an extra check ;) plus in theory you wouldnt even need a counter just an else wasted var :p

~Getdropped :cool:

riwu
10-27-2012, 02:46 AM
no because it still needs to search the same point for the colors to see if you were logged in and it found that the navbar needed to be reset... else that would work, it is like an extra check ;) plus in theory you wouldnt even need a counter just an else wasted var :p

~Getdropped :cool:
Not sure what you mean but my code should do exactly as yours, just that some people may find it slightly untidy to repeat 2 identical GetColor check within a function. Not a big deal though.

P1ng
10-27-2012, 03:02 AM
Why not just?
function LoggedIn: Boolean;
begin
//White text on Report Abuse Button
Result := GetColor(472, 490) = 16777215;
if Result then
Exit else
begin
SRL_ResetNavBar;
Result := (GetColor(472, 490) = 16777215);
end;
end;

Getdropped
10-27-2012, 03:04 AM
Not sure what you mean but my code should do exactly as yours, just that some people may find it slightly untidy to repeat 2 identical GetColor check within a function. Not a big deal though.

oh i see what you are saying, What i was trying to say it that it would just be safer to have it recheck the point after it resets the nav bar

Edit:

Why not just?
function LoggedIn: Boolean;
begin
//White text on Report Abuse Button
Result := GetColor(472, 490) = 16777215;
if Result then
Exit else
begin
SRL_ResetNavBar;
Result := (GetColor(472, 490) = 16777215);
end;
end;

There are a lot of ways i guess you could write it lol

P1ng
10-27-2012, 03:07 AM
I just figured there is no point performing the extra check if it's already found that you are logged in. But other than that it doesn't do anything differently.

Getdropped
10-27-2012, 03:18 AM
I just figured there is no point performing the extra check if it's already found that you are logged in. But other than that it doesn't do anything differently.

NO look again it only checks again if it doesnt find it lol I even wrote it in the function -.-
I checks before it resets the nav bar and if not found it checks again and returns the varient....

Ashaman88
10-27-2012, 03:20 AM
I don't care which version we use but support!

P1ng
10-27-2012, 03:33 AM
NO look again it only checks again if it doesnt find it lol I even wrote it in the function -.-
I checks before it resets the nav bar and if not found it checks again and returns the varient....

My apologies, hungover and skimming past things like exits :P Either way, I also support this change to the include :)

riwu
10-27-2012, 03:39 AM
oh i see what you are saying, What i was trying to say it that it would just be safer to have it recheck the point after it resets the nav bar
Yeah it does recheck, that's what the loop is for.
Also i'm assuming it's just done for slight efficiency and FoundBar is not broken?


I just figured there is no point performing the extra check if it's already found that you are logged in. But other than that it doesn't do anything differently.
Yeah it's exiting if found so i guess makes not much difference to add an else.
Although i've been pondering over this:
if Condition then
begin
Result:= True;
Actions;
end;


Result:= Condition;
if Result then
Actions;
which of them is more efficient? The difference is probably negligible but i'm interested to know which is more 'standard'?

P1ng
10-27-2012, 05:08 AM
I personally prefer the latter, but I am not aware as to whether or not it makes a difference. Just how I prefer to read the code.

litoris
10-27-2012, 07:56 AM
Why not just?
function LoggedIn: Boolean;
begin
//White text on Report Abuse Button
Result := GetColor(472, 490) = 16777215;
if Result then
Exit else
begin
SRL_ResetNavBar;
Result := (GetColor(472, 490) = 16777215);
end;
end;

Send a pull req for this pl0x.

Getdropped
10-27-2012, 05:28 PM
Send a pull req for this pl0x.

How do you send pull reqs?