Charge scripts for use of ScriptList::FillList

See: https://github.com/OpenTTD/OpenTTD/issues/12128
pull/661/head
Jonathan G Rennison 4 months ago
parent 351c607dad
commit d512602369

@ -12,6 +12,7 @@
#define SCRIPT_LIST_HPP
#include "script_object.hpp"
#include "script_controller.hpp"
#include "../../3rdparty/cpp-btree/safe_btree_set.h"
#include "../../3rdparty/cpp-btree/safe_btree_map.h"
@ -62,11 +63,14 @@ protected:
template<typename T, class ItemValid, class ItemFilter>
static void FillList(ScriptList *list, ItemValid item_valid, ItemFilter item_filter)
{
int opcode_charge = 0;
for (const T *item : T::Iterate()) {
if (!item_valid(item)) continue;
if (!item_filter(item)) continue;
list->AddItem(item->index);
opcode_charge += 3;
}
ScriptController::DecreaseOps(opcode_charge + (T::GetNumItems() / 2));
}
template<typename T, class ItemValid>

Loading…
Cancel
Save