Beispiel #1
0
/**
 * deactivate a set of patterns.
 *
 * if the setid does not exist, this will silently return
 */
static void deactivate_pcreset(struct npc_data* nd, int setid)
{
	struct pcrematch_set *pcreset;
	struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
	if (npcParse == NULL)
		return; // Nothing to deactivate...
	if (setid == -1) {
		while(npcParse->active != NULL)
			deactivate_pcreset(nd, npcParse->active->setid);
		return;
	}
	pcreset = npcParse->active;
	while (pcreset != NULL) {
		if (pcreset->setid == setid)
			break;
		pcreset = pcreset->next;
	}
	if (pcreset == NULL)
		return; // not in active list
	if (pcreset->next != NULL)
		pcreset->next->prev = pcreset->prev;
	if (pcreset->prev != NULL)
		pcreset->prev->next = pcreset->next;
	else
		npcParse->active = pcreset->next;

	pcreset->prev = NULL;
	pcreset->next = npcParse->inactive;
	if (pcreset->next != NULL)
		pcreset->next->prev = pcreset;
	npcParse->inactive = pcreset;
}
Beispiel #2
0
int buildin_deactivatepset (struct script_state *st)
{
	int setid = conv_num (st, & (st->stack->stack_data[st->start + 2]));
	struct npc_data *nd = (struct npc_data *) map_id2bl (st->oid);
	deactivate_pcreset (nd, setid);
	return 0;
}