SRL Archive - Development

Possible simba bug


Bobzilla69

2011-02-01 04:28:54

i am not sure if this is a simba bug or a function bug but its very weird.

i am running this script

program new;
{$DEFINE SMART}
{$i SRL\SRL.scar}
{$i Reflection\Reflection.simba}
{==============================================================================\
| MSI Group Scripting Include |
| CharacterStats.Simba |
|==============================================================================|
| For Storing Player Skill levels after Time/Loads are reached |
| |
| * procedure CheckFile; * by Bobzilla69 |
| * procedure WriteFile(); * by Bobzilla69 |
| * procedure GetData; * by Bobzilla69 |
| * procedure WriteData; * by Bobzilla69 |
| * procedure StoreCharacterLevels; * by Bobzilla69 |
\_____________________________________________________________________________}


var
Accounts:Integer;
newInfo:String;
Skills:TStringArray;
Skills2:TStringArray;

Const
Path = IncludePath + 'MSI\MSI\Extras\Accounts\';

{******************************************************************************}
{ procedure CheckFile; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Check if File exists if it doent creates file. }
{ Also handles if file will be added to or rewritten }
{******************************************************************************}
Procedure Bobzilla_CheckFile;
begin
if FileExists(Path + 'Characters.xml') then
begin
//Writeln('File all ready created');
Accounts:= OpenFile(Path + 'Characters.xml' , False);
CloseFile(Accounts);
end else
begin
//WriteLn('File not Found, Creating new file')
Accounts := CreateFile(Path + 'Characters.xml');
CloseFile(Accounts);
end;
end;

{******************************************************************************}
{ procedure WriteFile(New, Old:string); }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Writes Character data to the file. }
{ New is new data to be added to file. }
{ Old is data that was in file to be re writen }
{******************************************************************************}
Procedure Bobzilla_WriteFile(New:String);
begin
Accounts := RewriteFile(Path + 'Characters.xml', False);
WriteFileString(Accounts, New);
CloseFile(Accounts);
end;

{******************************************************************************}
{ procedure GetData; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Using reflection gets all character skill levels }
{ and stores it to a Array for that character }
{******************************************************************************}
Procedure Bobzilla_GetData;
begin
Players[CurrentPlayer].Arrays[1]:= [
R_GetSkillLevel(SKILL_ATTACK), R_GetSkillLevel(SKILL_DEFENCE), R_GetSkillLevel(SKILL_STRENGTH),
R_GetSkillLevel(SKILL_HITPOINTS), R_GetSkillLevel(SKILL_RANGE), R_GetSkillLevel(SKILL_PRAYER),
R_GetSkillLevel(SKILL_MAGIC), R_GetSkillLevel(SKILL_COOKING), R_GetSkillLevel(SKILL_WOODCUTTING),
R_GetSkillLevel(SKILL_FLETCHING), R_GetSkillLevel(SKILL_FISHING), R_GetSkillLevel(SKILL_FIREMAKING),
R_GetSkillLevel(SKILL_CRAFTING), R_GetSkillLevel(SKILL_SMITHING), R_GetSkillLevel(SKILL_MINING),
R_GetSkillLevel(SKILL_HERBLORE), R_GetSkillLevel(SKILL_AGILITY), R_GetSkillLevel(SKILL_THIEVING),
R_GetSkillLevel(SKILL_SLAYER), R_GetSkillLevel(SKILL_FARMING), R_GetSkillLevel(SKILL_RUNECRAFTING),
R_GetSkillLevel(SKILL_HUNTER), R_GetSkillLevel(SKILL_CONSTRUCTION), R_GetSkillLevel(SKILL_SUMMONING),
R_GetSkillLevel(SKILL_DUNGEONEERING)]
end;

{******************************************************************************}
{ procedure WriteData; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Handles extracting data from array and sending to WriteFile; }
{******************************************************************************}
Procedure Bobzilla_WriteData;
var
B, I:integer;
begin
Bobzilla_CheckFile;
newInfo:= '<Characters>'+#13; //start of xml file
for I:=0 to HowManyPlayers - 1 do
begin
newInfo:= newInfo + '<Character>' + #13; //start for a palyer
newInfo := newInfo + '<Name>'+Players[I].Name+'</Name>'+#13;
Skills:= ['<Attack>','<Defence>','<Strength>','<Hitpoints>','<Range>','<Prayer>','<Magic>','<Cooking>','<Woodcutting>','<Fletching>','<Fishing>','<Firemaking>','<Crafting>','<Smithing>','<Mining>','<Herblore>','<Agility>','<Thieving>','<Slayer>','<Farming>','<Runercrafting>','<Hunter>','<Conctruction>','<Summining>','<Dungeoneering>'];
Skills2:= ['</Attack>','</Defence>','</Strength>','</Hitpoints>','</Range>','</Prayer>','</Magic>','</Cooking>','</Woodcutting>','</Fletching>','</Fishing>','</Firemaking>','</Crafting>','</Smithing>','</Mining>','</Herblore>','</Agility>','</Thieving>','</Slayer>','</Farming>','</Runercrafting>','</Hunter>','</Conctruction>','</Summining>','</Dungeoneering>'];
for B:=0 to high(Players[I].Arrays[1]) do
begin
newInfo := newInfo + Skills[B] + IntToStr(Players[I].Arrays[1][B]) + Skills2[B] + #13;
end; //IntToStr(Players[CurrentPlayer].Arrays[1][B]
newInfo:= newInfo + '</Character>' + #13; //end of character
end;
newInfo:= newInfo + '</Characters>'
Bobzilla_WriteFile(newInfo);
end;

procedure Bobzilla_UpdatePlayer;
var
text:String;
i:integer;
begin
Accounts:= OpenFile(Path + '1.xml' , False);

ReadFileString(Accounts, text, 1000); //problem is here, try changing it to 2000 or 8000

writeln(text);

CloseFile(Accounts);
end;

begin
Smart_Server := 149;
Smart_Signed := True;
SetupSRL;
Bobzilla_UpdatePlayer;
end.

XML file that should be saved in "Includes\msi\MSI\Extras\Accounts" make folders if not there. and call the file 1.xml

<Characters>
<Character>
<Name>test</Name>
<Attack>42</Attack>
<Defence>13</Defence>
<Strength>31</Strength>
<Hitpoints>34</Hitpoints>
<Range>3</Range>
<Prayer>1</Prayer>
<Magic>1</Magic>
<Cooking>1</Cooking>
<Woodcutting>6</Woodcutting>
<Fletching>1</Fletching>
<Fishing>1</Fishing>
<Firemaking>1</Firemaking>
<Crafting>1</Crafting>
<Smithing>50</Smithing>
<Mining>60</Mining>
<Herblore>1</Herblore>
<Agility>1</Agility>
<Thieving>1</Thieving>
<Slayer>1</Slayer>
<Farming>1</Farming>
<Runercrafting>1</Runercrafting>
<Hunter>1</Hunter>
<Conctruction>1</Conctruction>
<Summining>1</Summining>
<Dungeoneering>1</Dungeoneering>
</Character>
</Characters>

so when i run my script as i posted i get the following output

<Characters>
<Character>
<Name>test</Name>
<Attack>42</Attack>
<Defence>13</Defence>
<Strength>31</Strength>
<Hitpoints>34</Hitpoints>
<Range>3</Range>
<Prayer>1</Prayer>
<Magic>1</Magic>
<Cooking>1</Cooking>
<Woodcutting>6</Woodcutting>
<Fletching>1</Fletching>
<Fishing>1</Fishing>
<Firemaking>1</Firemaking>
<Crafting>1</Crafting>
<Smithing>50</Smithing>
<Mining>60</Mining>
<Herblore>1</Herblore>
<Agility>1</Agility>
<Thieving>1</Thieving>
<Slayer>1</Slayer>
<Farming>1</Farming>
<Runercrafting>1</Runercrafting>
<Hunter>1</Hunter>
<Conctruction>1</Conctruction>
<Summining>1</Summining>
<Dungeoneering>1</Dungeoneering>
</Character>
</Characters>
which is as i expect it to be, but once you increase the number past 1000, so say we have 2000 it outputs this
<Characters>
<Character>
<Name>test</Name>
<Attack>42</Attack>
<Defence>13</Defence>
<Strength>31</Strength>
<Hitpoints>34</Hitpoints>
<Range>3</Range>
<Prayer>1</Prayer>
<Magic>1</Magic>
<Cooking>1</Cooking>
<Woodcutting>6</Woodcutting>
<Fletching>1</Fletching>
<Fishing>1</Fishing>
<Firemaking>1</Firemaking>
<Crafting>1</Crafting>
<Smithing>50</Smithing>
<Mining>60</Mining>
<Herblore>1</Herblore>
<Agility>1</Agility>
<Thieving>1</Thieving>
<Slayer>1</Slayer>
<Farming>1</Farming>
<Runercrafting>1</Runercrafting>
<Hunter>1</Hunter>
<Conctruction>1</Conctruction>
<Summining>1</Summining>
<Dungeoneering>1</Dungeoneering>
</Character>
</Characters>d6
Activity=Barbarian Assault
Type=Members
Location=Activity
LootShare=False
QuickChat=False
PvP=False

[World7]
Prefix=world7
Activity=Dungeoneering
Type=Free
Location=Activity
LootShare=True
QuickChat=False
PvP=False

[World8]
Prefix=world8
Activity=
Type=Free
Location=United States
LootShare=False
QuickChat=False
PvP=False

[World9]
Prefix=world9
Activity=
Type=Members
Location=United States
LootShare=True
QuickChat=False
PvP=False

[World10]
Prefix=world10
Activity=
Type=Free
Location=Netherlands
LootShare=True
QuickChat=False
PvP=False

[World11]
Prefix=world11
Activity=
Type=Free
Location=UK
LootShare=True
QuickChat=False
PvP=False

[World12]
Prefix=world12
Activity=
Type=Members
Location=New Zealand
LootShare=True
QuickChat=False
PvP=False

[World13]
Prefix=world13
Activity=
Type=Free
Location=United States
LootShare=False
QuickChat=False
PvP=False

[World14]
Prefix=world14
Activity=
Type=Free
Location=United States
LootShare=True
QuickChat=False
PvP=False

[World15]
Prefix=world15
Activity=Castle Wars
Type=Members
Location=Activity
LootShare=False
QuickChat=False
PvP=False

[World16]
Prefix=world16
Activity=Running - Air Runes
Type=Free
Location=Activity
LootShare=False
QuickChat=False
PvP=False

i am pretty sure it shouldn't output the world info…..

Edit:

once you get to 1740 its outputs world info anything below it (1739) wont

mastaraymond

2011-02-01 04:32:07

That's because you are reading more than the size of the file.. And because the way the file system is designed, you read the last few lines from an other loaded file apparently.

Try: FileSize

Bobzilla69

2011-02-01 04:35:03

wont filesize just give me the files size?

its still kinda weird isnt it? its a pretty weird number where it starts to read other files

Edit: never mind it worked thanks