diff options
author | Nipun Garg | 2019-06-27 22:29:49 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:02 +0200 |
commit | 761c90e62a1c7f01d38420834119a4fa697a3950 (patch) | |
tree | 19337206cdb0b9b95db108b358188cb613a20f49 | |
parent | dbfddba4cfbcfee8e588e68cd2ce92c7e1d898de (diff) | |
download | scummvm-rg350-761c90e62a1c7f01d38420834119a4fa697a3950.tar.gz scummvm-rg350-761c90e62a1c7f01d38420834119a4fa697a3950.tar.bz2 scummvm-rg350-761c90e62a1c7f01d38420834119a4fa697a3950.zip |
HDB: Add functions related to _callbacks
-rw-r--r-- | engines/hdb/ai-lists.cpp | 29 | ||||
-rw-r--r-- | engines/hdb/ai.h | 2 |
2 files changed, 31 insertions, 0 deletions
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp index 389b3ab880..a8598863a2 100644 --- a/engines/hdb/ai-lists.cpp +++ b/engines/hdb/ai-lists.cpp @@ -434,6 +434,35 @@ bool AI::autoActive(int x, int y) { return false; } +CallbackDef allCallbacks[] = { + {NO_FUNCTION, NULL}, + {AI_BARREL_EXPLOSION_END, aiBarrelExplosionEnd}, + {CALLBACK_DOOR_OPEN_CLOSE, callbackDoorOpenClose}, + {CALLBACK_AUTODOOR_OPEN_CLOSE, callbackAutoDoorOpenClose}, + {CALLBACK_END, NULL} +}; + +void AI::addCallback(CallbackType type, int x, int y, int delay) { + for(int i= kMaxCallbacks; i >= 0; i--) + if (_callbacks[i].type == NO_FUNCTION) { + _callbacks[i].type = type; + _callbacks[i].x = x; + _callbacks[i].y = y; + _callbacks[i].delay = delay; + return; + } +} + +void AI::processCallbackList() { + for (int i = 0; i < kMaxCallbacks; i++) + if (_callbacks[i].type != NO_FUNCTION) { + allCallbacks[_callbacks[i].type].function(_callbacks[i].x, _callbacks[i].y); + _callbacks[i].type = NO_FUNCTION; + _callbacks[i].x = _callbacks[i].y = 0; + return; + } +} + void AI::addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, char *luaFuncAction, char *luaFuncUse) { for (int i = 0; i < kMaxLuaEnts; i++) { if (!_luaList[i].luaFuncInit[0] && !_luaList[i].luaFuncAction[0] && !_luaList[i].luaFuncUse[0]) { diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h index 6f5653ad6c..690e868fa7 100644 --- a/engines/hdb/ai.h +++ b/engines/hdb/ai.h @@ -752,6 +752,8 @@ public: bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY); bool checkAutoList(AIEntity *e, int x, int y); bool autoActive(int x, int y); + void addCallback(CallbackType type, int x, int y, int delay); + void processCallbackList(); void addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, char *luaFuncAction, char *luaFuncUse); bool checkLuaList(AIEntity *e, int x, int y); bool luaExistAtXY(int x, int y); |