SRL Archive - SRL Archives

GamTab Stuff


NiCbaZ

2009-05-12 14:37:08

[PHP]{*******************************************************************************
function GetCurrentTab: Integer;
By: Wizzup?
Description: Returns current tab
*******************************************************************************}
function GetCurrentTab: Integer;
var
b: Boolean;
IntArr: TIntegerArray;
begin
b := False;

IntArr[543,178,1580634,570, 17,1778795,604, 174,1910385,632, 172, 1910385
,666, 182, 1647204,699, 177, 1910385,735, 177,1778795,569, 471, 1910385
598, 471, 1910385,633, 478, 1778795,668, 476, 1778795,703, 481, 1580634
740, 471, 1778795,555, 275, 2070783,533, 475 1581150]
for Result := 1 to 15 do
begin
B:= GetColor(IntArr[Result],IntArr[Result + 1]) = IntArr[Result + 2]
if b then
Exit;
end;
Result := 0;
end;


{*******************************************************************************
function TabExists(TabNumber: Integer): Boolean;
By: Flyboy
Description: Returns true if tab exists.
Very useful for tutorial Is. as well as a simple double check to make sure
your fully logged in.
*******************************************************************************}

function TabExists(TabNumber: Integer): Boolean;
var
IntArr: TIntegerArray;

begin
IntArr[543,178,1580634,570, 17,1778795,604, 174,1910385,632, 172, 1910385
,666, 182, 1647204,699, 177, 1910385,735, 177,1778795,569, 471, 1910385
598, 471, 1910385,633, 478, 1778795,668, 476, 1778795,703, 481, 1580634
740, 471, 1778795,555, 275, 2070783,533, 475 1581150]
Result:= GetColor(IntArr[TabNumber],IntArr[TabNumber + 1]) = IntArr[TabNumber + 2]
end;
[/PHP]

Just shortened a bit, needs testing, commit if you wish.

Nava2

2009-05-12 16:34:06

Its really… messy…

Why not setup a TPointArray, and an Integer array, then cycle through that way. Would clean up the code.

Gu3st...

2009-05-12 17:49:08

I think it looks neat, I like it.
Not hard to understand at all

Naum

2009-05-12 18:37:24

Looks good, someone should commit this :)

Sir R. M8gic1an

2009-05-12 18:55:10

although your method is very efficient, it is indeed very messy.

It is so messy indeed, that you didn't even notice you have it wrong.

however, if you were to do it like this:


function GetCurrentTab: Integer;
var
IntArr: TIntegerArray;
begin

IntArr[
//Coord x, Coord y, Color
543, 178, 1580634, // Gametab 1
570, 17, 1778795, // Gametab 2
604, 174, 1910385, // Gametab 3
632, 172, 1910385, // Gametab 4
666, 182, 1647204, // Gametab 5
699, 177, 1910385, // Gametab 6
735, 177, 1778795, // Gametab 7
569, 471, 1910385, // Gametab 8
598, 471, 1910385, // Gametab 9
633, 478, 1778795, // Gametab 10
668, 476, 1778795, // Gametab 11
703, 481, 1580634, // Gametab 12
740, 471, 1778795, // Gametab 13
555, 275, 2070783, // Gametab 14
533, 475, 1581150 // Gametab 15
];
{ wrong
for Result := 1 to 15 do
begin
B:= GetColor(IntArr[Result],IntArr[Result + 1]) = IntArr[Result + 2]
if b then
Exit;
end;
}
for Result := 1 to 15 do
begin
if GetColor(IntArr[((Result - 1)* 3)],IntArr[((Result - 1)* 3)+ 1]) = IntArr[((Result - 1)* 3) + 2] then
exit;
end;
Result := 0;
end;

~RM

Naum

2009-05-12 23:14:11

Rasta Commit!!!

Sir R. M8gic1an

2009-05-13 00:04:20

nai. With all the checking array values and small math it ends up being slower. If not slower, pretty much the same speed. and the current way it is done is much cleaner.

~RM

NiCbaZ

2009-05-13 01:26:23

Aw well, it was worth a try.