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 .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...?
[Release] Market Observer
Moderators: winston, another_commander
Re: [Release] marketObserver 1.6.1
Re: [Release] marketObserver 1.6.1
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.
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
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.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.
This seems to be a tough nut to crack. Thanks a lot for helping and reporting.
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: [Release] marketObserver 1.6.1
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: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.
Edit: link removed.
Last edited by Wildeblood on Sun Feb 17, 2013 3:17 am, edited 1 time in total.
Re: [Release] marketObserver 1.6.1
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 .
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: [Release] marketObserver 1.6.1
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
The end it adds to.Wildeblood wrote:What's the difference between unshift and push?
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];
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: [Release] marketObserver 1.6.1
Okay (?), what's the difference between shift and push then?cim wrote:The end it adds to.Wildeblood wrote:What's the difference between unshift and push?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
Wildeblood wrote:Okay (?), what's the difference between shift and push then?cim wrote:The end it adds to.Wildeblood wrote:What's the difference between unshift and push?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];
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;
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: [Release] marketObserver 1.6.1
Bloody Spara! I've just looked at it again and realized the reason I couldn't understand how it works is because his in-line comments explaining how it works are wrong.
Re: [Release] marketObserver 1.6.1
Sorry? We must be having a communication problem. Are you talking of playerSoldCargo -function?Wildeblood wrote:Bloody Spara! I've just looked at it again and realized the reason I couldn't understand how it works is because his in-line comments explaining how it works are wrong.
Re: [Release] marketObserver 1.6.1
*<shivers>* oh oh...Wildeblood wrote:Bloody Spara! I've just looked at it again and realized the reason I couldn't understand how it works is because his in-line comments explaining how it works are wrong.
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)
忍 knowing that enough is enough, you'll always have enough.
Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: [Release] marketObserver 1.6.1
That first comment, "enough purchases in one log entry":-
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
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];
}
}
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
Perfectly clear to me. But I can quite understand someone else has hard time understanding it.Wildeblood wrote:That first comment, "enough purchases in one log entry":-
...
It should say, "More than enough purchases in one log entry."
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.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); } } }
Re: [Release] marketObserver 1.6.1
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 .
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 .