Intermediate report. The function npc_price seems to be implicated in the stack overflow. I will look at that but it may be a mafia problem rather than an ED problem.
Point on programming style. In the ancient days when computers were powered by dinosaurs running on treadmills, calling a function was very expensive. Calling a function in a loop or other iteration was many times more expensive. Thus calling a function multiple times in a loop when the value of the function was not changing was a way to become the bait that ran on the treadmill to keep the dino moving.
There were at least three loops where npc_price(i) was called but i did not change. So calling it once, storing it and using the stored value is a more elegant practice even if we don't have enough data to see whether there is a noticeable time difference between the two implementations.
Point on programming style. In the ancient days when computers were powered by dinosaurs running on treadmills, calling a function was very expensive. Calling a function in a loop or other iteration was many times more expensive. Thus calling a function multiple times in a loop when the value of the function was not changing was a way to become the bait that ran on the treadmill to keep the dino moving.
There were at least three loops where npc_price(i) was called but i did not change. So calling it once, storing it and using the stored value is a more elegant practice even if we don't have enough data to see whether there is a noticeable time difference between the two implementations.
Code:
int npcp = 0;
foreach i in working
{
npcp = npc_price(i);
while ((working[i] < 0) && EAT_SHOP && (npcp > 0) && (get_meat(1) >= npcp))
{
working[i] = working[i] + 1;
makeusedmeat = makeusedmeat + npcp;
}