/// Callback for npc OnTimer*: labels. /// This will be called later if you call npc_timerevent_start. /// This function may only expire, but not deactivate, the counter. static void npc_timerevent(TimerData *, tick_t tick, BlockId id, interval_t data) { dumb_ptr<npc_data_script> nd = map_id2bl(id)->is_npc()->is_script(); assert (nd != nullptr); assert (nd->npc_subtype == NpcSubtype::SCRIPT); assert (nd->scr.next_event != nd->scr.timer_eventv.end()); nd->scr.timertick = tick; const auto te = nd->scr.next_event; // nd->scr.timerid = nullptr; // er, isn't this the same as nd->scr.timer = te->timer? interval_t t = nd->scr.timer += data; assert (t == te->timer); ++nd->scr.next_event; if (nd->scr.next_event != nd->scr.timer_eventv.end()) { interval_t next = nd->scr.next_event->timer - t; nd->scr.timerid = Timer(tick + next, std::bind(npc_timerevent, ph::_1, ph::_2, id, next)); } run_script(ScriptPointer(borrow(*nd->scr.script), te->pos), BlockId(), nd->bl_id); }
/*========================================== * 全てのNPCのOn*イベント実行 *------------------------------------------ */ static void npc_event_doall_sub(NpcEvent key, struct event_data *ev, int *c, ScriptLabel name, BlockId rid, Slice<argrec_t> argv) { ScriptLabel p = key.label; nullpo_retv(ev); if (name == p) { if (ev->nd->scr.parent != BlockId()) return; // temporary npcs only respond to commands directly issued to them run_script_l(ScriptPointer(script_or_parent(ev->nd), ev->pos), rid, ev->nd->bl_id, argv); (*c)++; } }
/*========================================== * イベントキューのイベント処理 *------------------------------------------ */ int npc_event_dequeue(dumb_ptr<map_session_data> sd) { nullpo_retz(sd); sd->npc_id = BlockId(); if (!sd->eventqueuel.empty()) { if (!pc_addeventtimer(sd, 100_ms, sd->eventqueuel.front())) { PRINTF("npc_event_dequeue(): Event timer is full.\n"_fmt); return 0; } sd->eventqueuel.pop_front(); return 1; } return 0; }
void BlockManager::gen(const BlockId& id, int rank, const int pos, std::vector<int> prefix /*pass by value*/, int to_append, std::vector<BlockId>& list) { if (pos != 0) { prefix.push_back(to_append); } if (pos < rank) { int curr_index = id.index_values(pos); if (curr_index == wild_card_value) { int index_slot = sip_tables_.selectors(id.array_id())[pos]; int lower = sip_tables_.lower_seg(index_slot); int upper = lower + sip_tables_.num_segments(index_slot); for (int i = lower; i < upper; ++i) { gen(id, rank, pos + 1, prefix, i, list); } } else { gen(id, rank, pos + 1, prefix, curr_index, list); } } else { list.push_back(BlockId(id.array_id(), rank, prefix)); } }
MemDatabase::MemDatabase() { storeBlock(BlockId(), Block::Zero()); }