Charge scripts for use of ScriptList::FillList
See: https://github.com/OpenTTD/OpenTTD/issues/12128
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#define SCRIPT_LIST_HPP
|
#define SCRIPT_LIST_HPP
|
||||||
|
|
||||||
#include "script_object.hpp"
|
#include "script_object.hpp"
|
||||||
|
#include "script_controller.hpp"
|
||||||
#include "../../3rdparty/cpp-btree/safe_btree_set.h"
|
#include "../../3rdparty/cpp-btree/safe_btree_set.h"
|
||||||
#include "../../3rdparty/cpp-btree/safe_btree_map.h"
|
#include "../../3rdparty/cpp-btree/safe_btree_map.h"
|
||||||
|
|
||||||
@@ -62,11 +63,14 @@ protected:
|
|||||||
template<typename T, class ItemValid, class ItemFilter>
|
template<typename T, class ItemValid, class ItemFilter>
|
||||||
static void FillList(ScriptList *list, ItemValid item_valid, ItemFilter item_filter)
|
static void FillList(ScriptList *list, ItemValid item_valid, ItemFilter item_filter)
|
||||||
{
|
{
|
||||||
|
int opcode_charge = 0;
|
||||||
for (const T *item : T::Iterate()) {
|
for (const T *item : T::Iterate()) {
|
||||||
if (!item_valid(item)) continue;
|
if (!item_valid(item)) continue;
|
||||||
if (!item_filter(item)) continue;
|
if (!item_filter(item)) continue;
|
||||||
list->AddItem(item->index);
|
list->AddItem(item->index);
|
||||||
|
opcode_charge += 3;
|
||||||
}
|
}
|
||||||
|
ScriptController::DecreaseOps(opcode_charge + (T::GetNumItems() / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, class ItemValid>
|
template<typename T, class ItemValid>
|
||||||
|
Reference in New Issue
Block a user