Page 4 of 17
Re: [Release] marketObserver 1.6.1
Posted: Wed Feb 13, 2013 10:11 am
by spara
Wildeblood wrote:
I wonder... (ignore what follows, it's just me thinking out loud)... is it because gatherMarketValues (?) is writing the array and printValues is reading the array at the same time...?
I'm suspecting something like this. Could it depend on the OS? Have to windows install somewhere and test. I'm so out of my league here
.
Re: [Release] marketObserver 1.6.1
Posted: Wed Feb 13, 2013 6:40 pm
by JeX
I can also confirm that the "stuck HUD" persists on MarketObserver 1.6.1 with the newest AI trading assistant installed (not sure this is what affects it as the stuck HUD has occurred before I played with AI T assistant).
It was reproducable simply by reloading a game, then pressing F8 and then F4.
Also, it takes a long while to actually get to the market screen after pressing F8 (at least 1-2 seconds), while with only AI trading assistant the lag was unnoticeable.
Re: [Release] marketObserver 1.6.1
Posted: Wed Feb 13, 2013 6:59 pm
by spara
JeX wrote:I can also confirm that the "stuck HUD" persists on MarketObserver 1.6.1 with the newest AI trading assistant installed (not sure this is what affects it as the stuck HUD has occurred before I played with AI T assistant).
It was reproducable simply by reloading a game, then pressing F8 and then F4.
Also, it takes a long while to actually get to the market screen after pressing F8 (at least 1-2 seconds), while with only AI trading assistant the lag was unnoticeable.
There's something strange going on when switching to market screen. Wierdest thing is that it behaves just ok in my installation, except that 'var j' bug that Wildeblood noted of course (I'm using Linux, that might have something to do with it). Wildeblood's note about array-handling makes sense, I wasn't thinking in objects when I should have, instead procedurally. I have passed a test version (changes in object and array handling) to Solonar, let's see if that solves something.
This seems to be a tough nut to crack.
Thanks a lot for helping and reporting.
Re: [Release] marketObserver 1.6.1
Posted: Thu Feb 14, 2013 2:24 pm
by Wildeblood
JeX wrote:Also, it takes a long while to actually get to the market screen after pressing F8 (at least 1-2 seconds), while with only AI trading assistant the lag was unnoticeable.
I wouldn't go as far as saying a second or two, but there's a definite 1/2 second or so lag here. The lag is longer with marketObserver on its own than with both OXPs together, so I assume it's caused by loading the images for the adverts. Anyway, this one fixes all the problems for me:
Edit: link removed.
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 11:51 am
by spara
It seems that the market check for min-max prices, switching to the hud with ads and writing the message overlay is just too much as Solonar reported that it still timeouts despite I corrected reading and writing an array at the same time problem. This probably means that the ads must go as they are there only for athmosphere
. It's a shame as I really liked them. Maybe I'll release two versions of the oxp. One with the ads and one without. Glad Wildeblood has already done a hud for me to use
.
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 12:00 pm
by Wildeblood
Meanwhile I've implemented multiple display modes in Trading Assistant, and
ripped off, um,
copy/pasted, err, re-invented in a sealed room the purchase book display. I had to rip your playerSoldCargo function because javascript array manipulation mystifies me. What's the difference between unshift and push? I dunno, so I just copied yours.
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 12:09 pm
by cim
Wildeblood wrote:What's the difference between unshift and push?
The end it adds to.
Code: Select all
arr = [1,2,3,4];
arr.push(5); // arr = [1,2,3,4,5];
arr.unshift(0); // arr = [0,1,2,3,4,5];
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 12:22 pm
by Wildeblood
cim wrote:Wildeblood wrote:What's the difference between unshift and push?
The end it adds to.
Code: Select all
arr = [1,2,3,4];
arr.push(5); // arr = [1,2,3,4,5];
arr.unshift(0); // arr = [0,1,2,3,4,5];
Okay (?), what's the difference between shift and push then?
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 12:31 pm
by cim
Wildeblood wrote:cim wrote:Wildeblood wrote:What's the difference between unshift and push?
The end it adds to.
Code: Select all
arr = [1,2,3,4];
arr.push(5); // arr = [1,2,3,4,5];
arr.unshift(0); // arr = [0,1,2,3,4,5];
Okay (?), what's the difference between shift and push then?
Code: Select all
arr = [1,2,3,4];
arr.push(5); // arr = [1,2,3,4,5];
arr.unshift(0); // arr = [0,1,2,3,4,5];
v = arr.shift(); // arr = [1,2,3,4,5]; v = 0;
v = arr.pop(); // arr = [1,2,3,4]; v = 5;
See
https://developer.mozilla.org/en-US/doc ... ects/Array for the full reference: there's also 'splice' for adding or removing entries from the middle of the array.
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 12:57 pm
by Wildeblood
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 1:07 pm
by spara
Sorry? We must be having a communication problem. Are you talking of playerSoldCargo -function?
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 1:13 pm
by GGShinobi
*<shivers>* oh oh...
updating obsolete comments is not my strength, either...
I'll try to do better in the future! (don't wanna be the target of a furious Wildeblood)
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 1:19 pm
by Wildeblood
That first comment, "enough purchases in one log entry":-
Code: Select all
while(unitCount > 0 && this.$buyLog[commIndex].length > 0) { //purge buys from log
currentElement = this.$buyLog[commIndex].shift();
if (currentElement[0] > unitCount) { //enough purchases in one log entry
if (this.$traderRankFeat)
this.$profit = this.$profit + unitCount * (price - currentElement[1]);
currentElement[0] = currentElement[0] - unitCount;
this.$buyLog[commIndex].unshift(currentElement);
unitCount = 0;
}
else { //not enough puchases in one log entry
if (this.$traderRankFeat)
this.$profit = this.$profit + currentElement[0] * (price - currentElement[1]);
unitCount = unitCount - currentElement[0];
}
}
It should say, "
More than enough purchases in one log entry."
And the second one, "not enough puchases in one log entry", should say, "May or may not be enough."
Anyway, on a more useful note, javascxript includes a handy array sorting function you seem to be unaware of:-
Code: Select all
this.$sortPurchaseBook = function()
{
function descendingSort(a,b) {return b[1] - a[1]}
for (var i = 0; i < this.$purchaseBook.length; i++)
{
if (this.$purchaseBook[i].length > 1)
{
this.$purchaseBook[i].sort(descendingSort);
}
}
}
Re: [Release] marketObserver 1.6.1
Posted: Fri Feb 15, 2013 1:43 pm
by spara
Wildeblood wrote:That first comment, "enough purchases in one log entry":-
...
It should say, "More than enough purchases in one log entry."
Perfectly clear to me. But I can quite understand someone else has hard time understanding it.
Wildeblood wrote:
Anyway, on a more useful note, javascxript includes a handy array sorting function you seem to be unaware of:-
Code: Select all
this.$sortPurchaseBook = function()
{
function descendingSort(a,b) {return b[1] - a[1]}
for (var i = 0; i < this.$purchaseBook.length; i++)
{
if (this.$purchaseBook[i].length > 1)
{
this.$purchaseBook[i].sort(descendingSort);
}
}
}
I have used sort function in Trophy Collector, where it was straightforward ordering by the first element of array in array. I seem to have missed the sortfunction parameter. Looks quite handy. It looks so handy, that I'll have to rewrite the ordering function. Thanks for the tip.
Re: [Release] marketObserver 1.6.1
Posted: Sat Feb 16, 2013 2:09 pm
by spara
Quick update on this one. I have found the problem. It's the plist-file that is used for market hud. In that file I have defined ~130 equipment images that are the ads. In script I toggle the visibility of those equipments to show ads (by adding and removing equipment). The problem is the timeout that kicks in when I read the plist file in fro the first time. I'm now pondering the next solutions:
1. Remove ads. (Ouch. I really like those ads. I find them very athmospheric)
2. Reduce the number of ads. (There are already some ads that are already ruined after resizing. But what would be the amount that would work? Trial and error I guess)
3. Somehow preload the hud when all is quiet. (I've been experimenting with this one and I'm not very optimistic with it. It seems to cause timeout whenever I read it. Solonar is also trying this for me.)
4. Write a different plist hud-file for all ad-pairs. Without reducing the number of ads that would meant ~130 hud-files. Would that be a problem somehow? That would probably also mean that I need to do some compatibility stuff for AI Trading Assistant.
Number 3 seems to be dead end. And number 1 is the last resort. That means its either number 2 or 4. I think I'll go with the 4th solution, it's probably the easiest for me, just coding. If there is some problem with the large number (~130) of hud files, please let me know.
Time to dust off my Bash and Gawk skillz and split the plist-file
.