SRL Archive - MSI Archives

Changes to core


Sir R. M8gic1an

2010-06-28 20:48:41

[php]
PlayerScripts[0] := [SCRIPT_VE_TREES];
PlayerObjects[0] := [[]];
PlayerLocation[0] := LOC_VE_TREES;
[/php]

I was looking at these and thinking:


{ type TUser;
Description: The User Record. }
type
TUser = record
Name: string; // * User Name
Pass: string; // * User Pass

Loc: string; // * User Location

Integers: array of Integer; // * For reports, etc.

Arrays: array of TVariantArray; // * For custom arrays.
end;

I guess we aren't using Loc for the location, due to it being a string. I'd find it more organized if we had a LocToString and StringToLoc function, rather than having a new array. That's another array that we're forcing onto memory.

As for Scripts: Players.Integers[I_SCRIPS]
As for Objects: Players.Arrays[I_OBJ]
I'm not entirely sure a variant array will be all that happy to take a TIntegerArray as its variant, but it should be possible.

These changes would also save us an awful lot of code like
[php]
SetLength(PlayerItems[j], Length(PlayerObjects[j]));
SetLength(PlayerItemNames[j], Length(PlayerItems[j]));
SetLength(PlayerExperiences[j], Length(PlayerObjects[j]));
[/php]

If not these changes, at least lets make a TPlayerInfo and have
[php]
PInfo: TPlayerInfo;
with PInfo do
begin
ALength := Length(Objects);
SetLength(Items[j], ALength);
SetLength(ItemNames, ALength);
SetLength(Experiences[j], ALength);
end;
[/php]

This would help clear a lot of code, and saving some ms too.

Also, some things need better separation,
eg.

{ procedure MSI_SetPlayerInfo; }
ProgressReportArray[i].PlayerName := Players[i].Name;
ProgressReportArray[i].PlayerStatus := Players[i].Active;
ProgressReportArray[i].PlayerLoc := PlayerLocation[i];


Progress Report stuff could be in a GetReportInfo function. They don't need to be here, better keep them separate. Easier to find.

Just some changes I thought of, while I looked for that lil problem with the proggie.

~RM

Coh3n

2010-06-28 21:55:55

From: Rasta Magician

I guess we aren't using Loc for the location, due to it being a string. I'd find it more organized if we had a LocToString and StringToLoc function, rather than having a new array. That's another array that we're forcing onto memory.

You mean using Players.Loc and just converting back and forth?

From: Rasta Magician

As for Scripts: Players.Integers[I_SCRIPS]
As for Objects: Players.Arrays[I_OBJ]
I'm not entirely sure a variant array will be all that happy to take a TIntegerArray as its variant, but it should be possible.

I would have used those if I could, but they need to be 2D and 3D arrays. Players.Arrays could work for PlayerScripts, but not for PlayerObjects. I just created all new arrays to stay consistent. Honestly, I would love for MSI to have it's own Players type/array. That would make everything much cleaner, but we'd have to set certain attributes to the SRL one so it works with the include (Which is pretty much what you did below :p).

From: Rasta Magician

Also, some things need better separation,
eg.

{ procedure MSI_SetPlayerInfo; }
ProgressReportArray[i].PlayerName := Players[i].Name;
ProgressReportArray[i].PlayerStatus := Players[i].Active;
ProgressReportArray[i].PlayerLoc := PlayerLocation[i];


Progress Report stuff could be in a GetReportInfo function. They don't need to be here, better keep them separate. Easier to find.

I think SetReportInfo would be a better name, and yeah I agree with that also. Now that I look over what I did, there's so much that could have been done better, but ya know, you get stuck in a "zone" and do whatever it takes to make it work. :p

Sir R. M8gic1an

2010-06-29 06:44:08

Ok, let's make a TPlayerInfo and SetReportInfo.

~RM

Coh3n

2010-06-29 18:28:19

From: Rasta Magician
Ok, let's make a TPlayerInfo and SetReportInfo.

~RM

Alright, here's what I came up with quick:

type
TPlayerInfo = record
UserInfo: TUser;
PlayerLocation: integer;
PlayerScripts: TVariantArray;
PlayerObjects: array of TVariantArray;
PlayerItems: array of TVariantArray;
PlayerItemNames: array of TVariantArray;
PlayerExperiences: array of TVariantArray;
end;

var
MSI_Players: array of TPlayerInfo;

(**
* Sets all the SRL required progress report information (TUser specific)
*)
procedure MSI_SetTUserInfo;
begin
end;

(**
* Sets all the other report information (scripts, objects, etc.)
*)
procedure MSI_SetReportInfo;
begin
MSI_SetTUserInfo;
end;
I would really love to make it work without variant arrays, but I haven't been able to so far. =\

Sir R. M8gic1an

2010-06-29 19:24:10

PlayerScripts can be a TIntegerArray, no? It's only the Script constants, no?
And if strings, it can be a TStringArray ;)

~RM

Coh3n

2010-06-29 19:36:34

From: Rasta Magician
PlayerScripts can be a TIntegerArray, no? It's only the Script constants, no?
And if strings, it can be a TStringArray ;)

~RM

Scripts should be able to be a TIntegerArray, so should PlayerItems. PlayerExperiences should be able to be a TExtendedArray, and PlayerItemNames should be able to be a TStringArray. The thing is, the interpreter doesn't allow you to declare a 3D array (that's not variant) like this:

PlayerObjects[0] := [ [ITEM_LOGS_NORMAL], [ITEM_ROCK_IRON] ];
Which I guess PlayerObjects is the only one declared like that, so the others should work, but when I tried I got all sorts of errors. Lol

Sir R. M8gic1an

2010-06-29 19:45:21

Well, leave any 3D arrays as they are. That's why I only mentioned the first one.
Won't kill us, and there's not much we can do about it anyway. I heard Wizzup is still waiting on Ben for his interpreter, so maybe when that comes things will be better.

~RM

Coh3n

2010-06-29 19:47:06

From: Rasta Magician
Well, leave any 3D arrays as they are. That's why I only mentioned the first one.
Won't kill us, and there's not much we can do about it anyway. I heard Wizzup is still waiting on Ben for his interpreter, so maybe when that comes things will be better.

~RM

I guess we'll see. :)

Coh3n

2010-07-03 20:49:16

I figured I'd make a post here. Here's a list of what I've changed, and I'm testing it right now:
  • Added the TPlayerInfo type, along with an MSI_Players variable and MSI_SetPlayerInfo/MSI_SetReportInfo. Things are now 1000x times more orgainized around the include.
  • Added three Global Arrays
  • Removed 'ITEM_' and 'OBJ_' prefixes for items and objects.
  • Added MSI_GetItemNames and MSI_GetItemExperiences. The reason I made it ItemExperiences instead of Object is because some objects produce more than one item. For example, when net fishing you can catch shrimp, crayfish and anchovies, which all have different experiences.
  • The attribute AssociatedItems for the TMSObject type is now a TVariantArray because you can have multiple items for a single object. This also required to add an extra dimension to the TScript attributes Items, ItemNames and Experiences.
  • Plus many more small details, that don't really change anything.
I will be committing these changes as soon as I've tested everything to make sure it works properly. :)

E: Committed.