Jump to content
LordJashin

OSI Change Log!

Is OSI going anywhere?  

1 member has voted

  1. 1. Is OSI going anywhere?

    • Yes
      1
    • No
      0
    • Never has...
      0


Recommended Posts

One thing me and Shadow did good with GMRL was having a change log. I modeled this one after Freddy's for SCAR a bit. IMHO It looks easy enough to read without being overkill in most situations.

 

OSI's Change Log is located on Github: https://github.com/OSI1/OSI1/blob/master/Change%20Log.txt

 

Recent Changes:

 

Lots of additions from MSSL, Thanks Jani! Maybe I should've mentioned that in the recent changes, but all the functions in the files have your credits so its all good there.

 

-------------------------
LordJashin - 10/23/2012 :
-------------------------

Added:

Divi/Bitmap.scar:
   - function GetBitmapSize(bmp: TSCARBitmap; var width, height: Integer): Boolean;

Divi/Integer.scar:
   - function StrIsInt(s: string): Boolean;

Divi/Math.scar:
   - function RandomAbs(Range: Integer): Integer;
   - function RandomRangeAbs(AFrom, ATo: Integer): Integer;

Divi/Point.scar:
   - function PointToStr(P: TPoint): string;

Divi/String.scar:
   - function StrCount(SubStr, s: string; overlap: Boolean): Integer;
   - function StrSplit(text, separator: string; ID: Integer): string;
   - function StrSplitEx(text, separator: string; IDs: TIntArray): TStrArray;
   - function StrReplaceEx(Text, FindS, ReplaceS: string; Offset: Integer): string;
   - function StrClosestPos(SubStr, s: string; iFrom: Integer): Integer;
   - function StrFarthestPos(SubStr, s: string; iFrom: Integer): Integer;
   - function StrContainsC(x: Char; s: string): Boolean;

File:
  - Divi/Extended.scar:
                     - function StrIsExt(s: string): Boolean;
  - Change Log.txt !!!

Improvements:
          - StrInStr => StrContains
          - StrInStrMulti => StrContainsEx
          - StrCopy => StrCopyEx
          - StrBetween => StrBetweenEx
          - StrStuff:
                   - StrStuff(SubStr, s: string; iFrom, iCount: Integer): string;
          - StrStuffEx:
                   - StrStuffEx(SubStr, s: string; pos1, pos2: Integer): string;
          - Other param name changes, mostly from s => SubStr, and str => s
          - Updated OSI with new function/procedure names
          - Updated Dates

-------------------------

Edited by LordJashin
Link to comment
Share on other sites

Thanks, about those string functions.

 

There is one called I think: StrEndsWith, but I never found the StrBeginsWith or StrStartsWith. lol. Thought maybe you should add that. What I've been doing with the naming is since it is like almost the same as StartsWith function, I'll add Ex to the end of them if I add them to OSI. That's what I did with StrCopy, StrReplace, etc. that I got from MSSL's string functions.

 

Also I've been wondering about all the array functions there is. There is like TPAAdd, TExtAdd, and etc. forever and ever. Could we make one function that could handle most of the array types? I think Variant array functions are good, but could we make a larger function to do it for all of them? Maybe like if Type(Arr) = TPA then x;

 

You too!

-LJ

Link to comment
Share on other sites

Also I've been wondering about all the array functions there is. There is like TPAAdd, TExtAdd, and etc. forever and ever. Could we make one function that could handle most of the array types? I think Variant array functions are good, but could we make a larger function to do it for all of them? Maybe like if Type(Arr) = TPA then x;
I really wish we could do that, but so far I haven't found out a way. :(

 

TVariantArray is simply an array of Integers/Strings/Booleans/Extendeds, whereas, what you (and me) are dreaming about is something totally different, only Freddy could do that.. But yeah, it would be great in future to have functions with combination of variables/array types (built-in to SCAR). It would be just AWESOME. :)

 

Here is StrStartWith:

 

function StrStartWith(suffix: string; var s: string): Boolean;
var
 p, l: Integer;
begin
 l := Length(suffix);
 if ((s = '') or (l > Length(s))) then
   Exit;
 p := Pos(suffix, s);
 Result := (p > 0);
 if Result then
   s := Copy(s, p, (Length(s) - (p - 1)));
end;

var
 str: string;

begin
 ClearDebug;
 str := 'Janilabo is a newbie! TEST to see if this works, so TESTING now...'; 
 if StrStartWith('TEST', str) then
   WriteLn('YAY, str now: "' + str + '"')
 else
   WriteLn('FAIL!');
end.

Edited by Janilabo
Link to comment
Share on other sites

What about these functions?

 

VarArrayGet

VarType

 

Nice I will add those to OSI!

 

EDIT: VarType, I dont think works for arrays, keep getting 8204 as result. But couldn't we do that to figure out if its an array? Then do Arr[0] to find out what type of array?

 

[scar]

program New;

var

bbb: TStrArray;

aaa: String;

begin

SetLength(bbb, 1);

WriteLn(VarType(bbb));

WriteLn(VarType(bbb[0]));

WriteLn(VarType(aaa));

end.

 

[/scar]

 

Still need some clarification, going to google it.

 

http://www.delphibasics.co.uk/RTL.asp?Name=VarType

Edited by LordJashin
Link to comment
Share on other sites

Good thinking there, but what if the array is TVariantArray or just an empty array of [string, Integer, Extended, Boolean, etc..], then we couldn't use Arr[*]. :(

+ array of TVarType <> TVariantArray / TStrArray / TIntArray / TExtArray / etc..

 

Also, TVariantArray doesn't work with TPoints/TBoxes:

 

var
 p: TPoint;
 v: TVariantArray;

begin
 p := Point(1, 1);
 v := [p];
end.

 

EDIT: We would need some functions/procedures like this in SCAR.. +Variant would need to have full support for arrays. But but, I am sure adding these in SCAR is not very easy task, at all.

Maybe for SCAR Titan in future? :)

Edited by Janilabo
Link to comment
Share on other sites

http://www.delphibasics.co.uk/RTL.asp?Name=VarType

This works great! But I haven't figured out how to tell if a variable is a Variant. I don't think you can. Also I read that operations with variables of Variant type are more intensive.

Yeah we would have to create our own thing for this. Looks challenging - http://docwiki.embarcadero.com/RADStudio/XE3/en/Creating_a_Class_to_Enable_the_Custom_Variant_Type

 

But hey not all is lost here. This is still a great idea! It just would fail if there was ever a Variant passed into it.

 

 

Anyway, got so close to loading RSC into SMART:

 

[scar]

program TestRSC;

{$DEFINE RS2}

{$DEFINE SMART}

{$I OSI/OSI.scar}

 

var

SMART_RSCClient: TSCARClient;

i: Integer;

 

begin

 

if InitSmartLib(IncludesPath + 'OSI\RS2\Misc\libsmartremote32.dll') then

SMART_Path := IncludesPath + 'OSI\RS2\Misc\'

else if InitSmartLib(ScriptPath + 'OSI\RS2\Misc\libsmartremote32.dll') then

SMART_Path := ScriptPath + 'OSI\RS2\Misc\'

else if InitSmartLib(ScriptPath + 'RS2\Misc\libsmartremote32.dll') then

SMART_Path := ScriptPath + 'RS2\Misc\'

else

begin

OSI_WriteAndLog('OSI: RS2: Couldn''t load SMART (libsmartremote32.dll)');

OSI_WriteAndLog('OSI: RS2: Try restarting SCAR Divi, SMART, or Re-installing OSI');

OSI_WriteAndLog('OSI: RS2: If problems persist post a thread on the forums at http://www.scar-divi.com');

TerminateScript;

end;

 

 

 

 

 

 

i := SmartSpawnClient(SMART_Path, 'http://classic3.runescape.com/', 'j0,a1', 500, 500, 's', '', '', -1);

 

WriteLn(ExceptionToString(ExceptionType, ExceptionParam));

SMART_RSCClient := CreateSmartClient(i);

 

end.

[/scar]

Link to comment
Share on other sites

Only got to this point with the RSC loading into SMART:

 

Shared Memory mapped to 0x88
Trying port 4200
Remote socket listening
Client socket connected: 152
Running SMART Constructor
SMART Initialized!
Library: 0x6c780000
SmartSetup Entered
Attempting to load default server JVM
Attempting to load default client JVM
Created a Java Runtime Environment object
reading decrypting defining: smart/Client$4 = 0x25e8f38
reading decrypting defining: smart/Client$3 = 0x25e8f3c
reading decrypting defining: smart/Client = 0x25e8f40
reading decrypting defining: smart/EventNazi = 0x25e8f44
reading decrypting defining: smart/UnblockedEvent = 0x25e8f48
reading decrypting defining: smart/EventRedirect = 0x25e8f4c
reading decrypting defining: java/awt/Canvas$AccessibleAWTCanvas = 0x25e8f50
reading decrypting defining: smart/EventNazi$KeySender = 0x25e8f54
reading decrypting defining: smart/Client$1 = 0x25e8f58
reading decrypting defining: smart/Client$2 = 0x25e8f5c
reading decrypting defining: java/awt/Canvas = 0x25e8f60
reading decrypting defining: smart/ClientStub = 0x25e8f64
reading decrypting defining: smart/BlockingEventQueue = 0x25e8f68
Classes unpacked, loaded, and reflected
Using preallocated image swap area(s)
Registration Response: 38
JVM Garbage Collection Invoked
Java Initilized - SMART Starting
Applet Loader Parsed
Using jar: http://classic3.runescape.com/rsclassic68603135.jar
Applet Parameters Forwarded
Setting up Frame
Client INIT
GET PARAM: nodeid=>5003
GET PARAM: modewhere=>0
GET PARAM: modewhat=>0
Started applet
Client START
Client WAITING

 

Anyway, the VarType thing is a good idea, but hard to implement and doesn't support Variant and maybe other issues.

 

I think we should put the common array functions all in one file though. So then if we have like TExtAdd, TSAAdd, we could put them both in Array.scar or w/e.

Link to comment
Share on other sites

Anyway, the VarType thing is a good idea, but hard to implement and doesn't support Variant and maybe other issues.

 

I think we should put the common array functions all in one file though. So then if we have like TExtAdd, TSAAdd, we could put them both in Array.scar or w/e.

Yeah, I agree it is indeed a great idea - maybe something for the future? :P Involves a little too many problems for now (+speed would become way slower, if we would have to check arrays for the types manually, looping through every item).

 

Agree with you on Array.scar, that definitely would work. Not sure how big the file would grow, though. :D (In MSSL String.scar & Point.scar are already a little too big)

 

-Jani

Link to comment
Share on other sites

The idea would definitely work! But if anyone puts in there a variant type or array of variant, the function will collapse and die lol. I'm not gonna make it loop through each thing lol, that is wasteful. The array of variant would kill it. But I think variant would do fine. Because variant won't change, while the variant array could have different types in every slot.

 

EDIT: Seems much harder, probably impossible. Because we can't see if the type is a TPoint for example. And TPoint can't be put into a variant. As I think you said above. I though you could make your own type some how though...

Edited by LordJashin
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...