Cleanup queue.h

See #42
This commit is contained in:
Alexander Batalov 2022-06-19 08:39:08 +03:00
parent d329149d88
commit 8ff5781b11
2 changed files with 32 additions and 35 deletions

View File

@ -15,17 +15,41 @@
#include "proto_instance.h" #include "proto_instance.h"
#include "scripts.h" #include "scripts.h"
typedef struct QueueListNode {
// TODO: Make unsigned.
int time;
int type;
Object* owner;
void* data;
struct QueueListNode* next;
} QueueListNode;
typedef struct EventTypeDescription {
QueueEventHandler* handlerProc;
QueueEventDataFreeProc* freeProc;
QueueEventDataReadProc* readProc;
QueueEventDataWriteProc* writeProc;
bool field_10;
QueueEventHandler* field_14;
} EventTypeDescription;
static int flareEventProcess(Object* obj, void* data);
static int explosionEventProcess(Object* obj, void* data);
static int _queue_explode_exit(Object* obj, void* data);
static int _queue_do_explosion_(Object* obj, bool a2);
static int explosionFailureEventProcess(Object* obj, void* data);
// Last queue list node found during [queueFindFirstEvent] and // Last queue list node found during [queueFindFirstEvent] and
// [queueFindNextEvent] calls. // [queueFindNextEvent] calls.
// //
// 0x51C690 // 0x51C690
QueueListNode* gLastFoundQueueListNode = NULL; static QueueListNode* gLastFoundQueueListNode = NULL;
// 0x6648C0 // 0x6648C0
QueueListNode* gQueueListHead; static QueueListNode* gQueueListHead;
// 0x51C540 // 0x51C540
EventTypeDescription gEventTypeDescriptions[EVENT_TYPE_COUNT] = { static EventTypeDescription gEventTypeDescriptions[EVENT_TYPE_COUNT] = {
{ drugEffectEventProcess, internal_free, drugEffectEventRead, drugEffectEventWrite, true, _item_d_clear }, { drugEffectEventProcess, internal_free, drugEffectEventRead, drugEffectEventWrite, true, _item_d_clear },
{ knockoutEventProcess, NULL, NULL, NULL, true, _critter_wake_clear }, { knockoutEventProcess, NULL, NULL, NULL, true, _critter_wake_clear },
{ withdrawalEventProcess, internal_free, withdrawalEventRead, withdrawalEventWrite, true, _item_wd_clear }, { withdrawalEventProcess, internal_free, withdrawalEventRead, withdrawalEventWrite, true, _item_wd_clear },
@ -419,26 +443,26 @@ int queueGetNextEventTime()
} }
// 0x4A281C // 0x4A281C
int flareEventProcess(Object* obj, void* data) static int flareEventProcess(Object* obj, void* data)
{ {
_obj_destroy(obj); _obj_destroy(obj);
return 1; return 1;
} }
// 0x4A2828 // 0x4A2828
int explosionEventProcess(Object* obj, void* data) static int explosionEventProcess(Object* obj, void* data)
{ {
return _queue_do_explosion_(obj, true); return _queue_do_explosion_(obj, true);
} }
// 0x4A2830 // 0x4A2830
int _queue_explode_exit(Object* obj, void* data) static int _queue_explode_exit(Object* obj, void* data)
{ {
return _queue_do_explosion_(obj, false); return _queue_do_explosion_(obj, false);
} }
// 0x4A2834 // 0x4A2834
int _queue_do_explosion_(Object* explosive, bool a2) static int _queue_do_explosion_(Object* explosive, bool a2)
{ {
int tile; int tile;
int elevation; int elevation;
@ -483,7 +507,7 @@ int _queue_do_explosion_(Object* explosive, bool a2)
} }
// 0x4A28E4 // 0x4A28E4
int explosionFailureEventProcess(Object* obj, void* data) static int explosionFailureEventProcess(Object* obj, void* data)
{ {
MessageListItem msg; MessageListItem msg;

View File

@ -48,33 +48,11 @@ typedef struct AmbientSoundEffectEvent {
int ambientSoundEffectIndex; int ambientSoundEffectIndex;
} AmbientSoundEffectEvent; } AmbientSoundEffectEvent;
typedef struct QueueListNode {
// TODO: Make unsigned.
int time;
int type;
Object* owner;
void* data;
struct QueueListNode* next;
} QueueListNode;
typedef int QueueEventHandler(Object* owner, void* data); typedef int QueueEventHandler(Object* owner, void* data);
typedef void QueueEventDataFreeProc(void* data); typedef void QueueEventDataFreeProc(void* data);
typedef int QueueEventDataReadProc(File* stream, void** dataPtr); typedef int QueueEventDataReadProc(File* stream, void** dataPtr);
typedef int QueueEventDataWriteProc(File* stream, void* data); typedef int QueueEventDataWriteProc(File* stream, void* data);
typedef struct EventTypeDescription {
QueueEventHandler* handlerProc;
QueueEventDataFreeProc* freeProc;
QueueEventDataReadProc* readProc;
QueueEventDataWriteProc* writeProc;
bool field_10;
QueueEventHandler* field_14;
} EventTypeDescription;
extern QueueListNode* gLastFoundQueueListNode;
extern QueueListNode* gQueueListHead;
extern EventTypeDescription gEventTypeDescriptions[EVENT_TYPE_COUNT];
void queueInit(); void queueInit();
int queueExit(); int queueExit();
int queueLoad(File* stream); int queueLoad(File* stream);
@ -87,11 +65,6 @@ int queueProcessEvents();
void queueClear(); void queueClear();
void _queue_clear_type(int eventType, QueueEventHandler* fn); void _queue_clear_type(int eventType, QueueEventHandler* fn);
int queueGetNextEventTime(); int queueGetNextEventTime();
int flareEventProcess(Object* obj, void* data);
int explosionEventProcess(Object* obj, void* data);
int _queue_explode_exit(Object* obj, void* data);
int _queue_do_explosion_(Object* obj, bool a2);
int explosionFailureEventProcess(Object* obj, void* data);
void _queue_leaving_map(); void _queue_leaving_map();
bool queueIsEmpty(); bool queueIsEmpty();
void* queueFindFirstEvent(Object* owner, int eventType); void* queueFindFirstEvent(Object* owner, int eventType);