Fix for the use of WorldInfo
Simba Code:
WorldInfo: TVariantArray; // * [Members {Boolean}, World {Integer}, PVP {Boolean}]
This is a piece of the players record that is rarely used, but is very useful and should be actually a regular option in every script. I added it to my miner in its last update, but my script wouldn't log into the specified world even though I had set up the array correctly. Then, I decided to check out the code, only to see the following:
Simba Code:
case Length(Players[CurrentPlayer].WorldInfo) of
2: SelectWorld(Players[CurrentPlayer].WorldInfo[1]);
3: begin
if (Players[CurrentPlayer].WorldInfo[0]) then
B := True
else
B := False;
if (Players[CurrentPlayer].WorldInfo[2]) then
BB := True
else
BB := False;
SelectWorld(RandomWorld(B, BB));
Here, you can see that if there is no specified info for PVP in WorldInfo, it automatically logs into the world as it should. BUT, if the array is complete, it just logs into a random world with the given properties! So, I came up with a fix for it:
Simba Code:
case Length(Players[CurrentPlayer].WorldInfo) of
2: SelectWorld(Players[CurrentPlayer].WorldInfo[1]);
3: begin
{ if (Players[CurrentPlayer].WorldInfo[0]) then
B := True
else
B := False;
if (Players[CurrentPlayer].WorldInfo[2]) then
BB := True
else
BB := False;} //i moved this part of the code somewhere up there
if (WorldArray[BBB].PVP = BB) and (WorldArray[BBB].Members = B) then
//BBB is an integer, it is equal to Players[CurrentPlayer].WorldInfo[1]
SelectWorld(BBB)
else
SelectWorld(RandomWorld(B, BB));
With my edits, now it checks whether the world we want fits our description, and if it does, it logs into the world properly. If the user falsely stated that a world is P2P, when it is actually F2P, it will login to a random P2P world, and it will do the same sort of fix for the PVP situation.
I sent a pull request, see it here.
Would be nice if someone could test it. I only tested whether it compiles, it should work in theory.