it seems to me the dailycrewupdate has become very sluggish.
Maybe we should take a look at it and see if things are happening which should happen or optimize some stuff.
While taking a quick look I saw for example at one point the food usage was calculated but a while later this happens again but in a if statement this time. I haven't had time to look at this good but maybe the other part should be in the else instead of also in there.
Also I noticed things like this:
so you see the same foreloop is done here twice but they do other things.
this could be made like this:
this would reduce the time it takes to run this script a bit and probally makes the code more clear.
I dont have time for this yet, but if someone wants feel free to begin on this, all small bit help. so if you find improvements on the script please submit them here.
if you need a place to start, then start with this
haven't had time to look at it well but I think what happens here could be done WAY better and actually takes up quite some time like this.
Maybe we should take a look at it and see if things are happening which should happen or optimize some stuff.
While taking a quick look I saw for example at one point the food usage was calculated but a while later this happens again but in a if statement this time. I haven't had time to look at this good but maybe the other part should be in the else instead of also in there.
Also I noticed things like this:
Code:
for(i=0; i<4; i++){cn = GetCompanionIndex(&pchar,i);if(cn!=-1) ft[i] = makeint(makefloat(foodQ)*foodRatio[i]);} ....
for(i=0; i<4; i++)
{
cn = GetCompanionIndex(&pchar,i);
if(cn!=-1) SetCharacterGoods(&Characters[cn],GOOD_WHEAT, ft[i]);
}
so you see the same foreloop is done here twice but they do other things.
this could be made like this:
Code:
for(i=0; i<4; i++)
{
cn = GetCompanionIndex(&pchar,i);
if(cn!=-1)
{
ft[i] = makeint(makefloat(foodQ)*foodRatio[i]);
SetCharacterGoods(&Characters[cn],GOOD_WHEAT, ft[i]);
}
}
I dont have time for this yet, but if someone wants feel free to begin on this, all small bit help. so if you find improvements on the script please submit them here.
if you need a place to start, then start with this
Code:
//if food doesn't divide evenly:
while(ft[0]+ft[1]+ft[2]+ft[3] != foodQ)
{
for(i=0; i<4; i++)
{
if(ft[i] > 0)
//Ship had food
{
if(ft[0]+ft[1]+ft[2]+ft[3] > foodQ) //too much food alocated, so remove some
{
ft[i]--;
}
if(ft[0]+ft[1]+ft[2]+ft[3] < foodQ)
//not enough food alocated, so add some
{
ft[i]++;
}
}
}
}