new call cost system

TODO: change all the ctrls from latency to amount per tick.
This commit is contained in:
2025-07-03 12:36:47 +02:00
parent 3b733e0708
commit 3546fe1093
6 changed files with 33 additions and 16 deletions

View File

@@ -219,24 +219,29 @@ bool nn_isUser(nn_computer *computer, const char *name) {
return false;
}
void nn_setCallBudget(nn_computer *computer, size_t callBudget) {
void nn_setCallBudget(nn_computer *computer, double callBudget) {
computer->callBudget = callBudget;
}
size_t nn_getCallBudget(nn_computer *computer) {
double nn_getCallBudget(nn_computer *computer) {
return computer->callBudget;
}
void nn_callCost(nn_computer *computer, size_t cost) {
void nn_callCost(nn_computer *computer, double cost) {
computer->callCost += cost;
if(computer->callCost >= computer->callBudget) nn_triggerIndirect(computer);
}
size_t nn_getCallCost(nn_computer *computer) {
double nn_getCallCost(nn_computer *computer) {
return computer->callCost;
}
bool nn_isOverworked(nn_computer *computer) {
return computer->callCost >= computer->callBudget;
return computer->state == NN_STATE_OVERWORKED;
}
void nn_triggerIndirect(nn_computer *computer) {
computer->state = NN_STATE_OVERWORKED;
}
int nn_getState(nn_computer *computer) {