// load a list of triggers static BOOL eventLoadTriggerList(WZ_DECL_UNUSED const SDWORD version, char *pBuffer, UDWORD *pSize) { UDWORD size, event, offset, time; char *pPos; SDWORD numTriggers, context, type, trigger, i; SCRIPT_CONTEXT *psContext; size = 0; pPos = pBuffer; // get the number of triggers endian_sdword((SDWORD*)pPos); numTriggers = *((SDWORD*)pPos); pPos += sizeof(SDWORD); size += sizeof(SDWORD); for(i=0; i<numTriggers; i+= 1) { endian_udword((UDWORD*)pPos); time = *((UDWORD*)pPos); pPos += sizeof(UDWORD); endian_sword((SWORD*)pPos); context = *((SWORD*)pPos); pPos += sizeof(SWORD); if (!eventFindContext(context, &psContext)) { debug( LOG_FATAL, "eventLoadTriggerList: couldn't find context" ); abort(); return false; } endian_sword((SWORD*)pPos); type = *((SWORD*)pPos); pPos += sizeof(SWORD); endian_sword((SWORD*)pPos); trigger = *((SWORD*)pPos); pPos += sizeof(SWORD); endian_uword((UWORD*)pPos); event = *((UWORD*)pPos); pPos += sizeof(UWORD); endian_uword((UWORD*)pPos); offset = *((UWORD*)pPos); pPos += sizeof(UWORD); size += sizeof(UDWORD) + sizeof(SWORD)*3 + sizeof(UWORD)*2; if (!eventLoadTrigger(time, psContext, type, trigger, event, offset)) { return false; } } *pSize = size; return true; }
// load a list of triggers static bool eventLoadTriggerList(WzConfig &ini, QString tname) { UDWORD event, offset, time; int numTriggers, context, type, trigger; SCRIPT_CONTEXT *psContext; numTriggers = ini.value("general/num" + tname).toInt(); for (int i = 0; i < numTriggers; i++) { ini.beginGroup(tname + "_" + QString::number(i)); time = ini.value("time").toInt(); context = ini.value("context").toInt(); if (!eventFindContext(context, &psContext)) { debug(LOG_FATAL, "could not find context"); return false; } type = ini.value("type").toInt(); trigger = ini.value("trigger").toInt(); event = ini.value("event").toInt(); offset = ini.value("offset").toInt(); if (!eventLoadTrigger(time, psContext, type, trigger, event, offset)) { debug(LOG_FATAL, "Failed to create trigger"); return false; } ini.endGroup(); } return true; }