mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
yet more IE stuff
This commit is contained in:
parent
f840a44981
commit
62813111a0
2 changed files with 52 additions and 11 deletions
|
@ -64,13 +64,12 @@ typedef struct ie_timevaluepair_s {
|
|||
|
||||
typedef struct ie_translation_table_s {
|
||||
int maxevents;
|
||||
ie_event_t *events;
|
||||
ie_event_t **events;
|
||||
} ie_translation_table_t;
|
||||
|
||||
typedef struct ie_translation_index_s {
|
||||
// FIXME: I don't like this organization
|
||||
struct ie_translation_index_s *next;
|
||||
ie_translation_table_t *table;
|
||||
int maxtables;
|
||||
ie_translation_table_t **tables;
|
||||
} ie_translation_index_t;
|
||||
|
||||
typedef struct ie_translation_data_s {
|
||||
|
@ -91,6 +90,9 @@ void IE_Multiplier_Event (ie_event_t *event, float value);
|
|||
|
||||
void IE_CallHandler (ie_handler handler, ie_event_t *event, float value);
|
||||
|
||||
ie_translation_table_t *IE_Translation_Table_Create ();
|
||||
void IE_Translation_Table_Modify (ie_translation_table_t *table, int offset, ie_event_t *event);
|
||||
ie_translation_index_t *IE_Translation_Index_Create ();
|
||||
|
||||
/*
|
||||
typedef struct {
|
||||
|
|
|
@ -82,20 +82,59 @@ IE_Translation_Event (ie_event_t *event, float value)
|
|||
ie_translation_data_t *data = event->data.p;
|
||||
ie_translation_index_t *index = data->index;
|
||||
ie_event_t *nextevent = 0;
|
||||
int i;
|
||||
|
||||
while (!nextevent) {
|
||||
if (!index)
|
||||
break;
|
||||
if (index->table->maxevents > data->offset)
|
||||
nextevent = &index->table->events[data->offset];
|
||||
index = index->next;
|
||||
}
|
||||
for (i = 0; !nextevent && i < index->maxtables; i++)
|
||||
if (index->tables[i]->maxevents > data->offset)
|
||||
nextevent = index->tables[i]->events[data->offset];
|
||||
if (!nextevent) // no handler for it
|
||||
return;
|
||||
|
||||
IE_CallHandler (nextevent->handler, nextevent, value);
|
||||
}
|
||||
|
||||
ie_translation_table_t *
|
||||
IE_Translation_Table_Create ()
|
||||
{
|
||||
ie_translation_table_t *table;
|
||||
|
||||
table = malloc (sizeof (ie_translation_table_t));
|
||||
if (!table)
|
||||
Sys_Error ("IE_Translation_Table_Create: memory allocation failure");
|
||||
|
||||
table->maxevents = 0;
|
||||
table->events = 0;
|
||||
return table;
|
||||
}
|
||||
|
||||
void
|
||||
IE_Translation_Table_Modify (ie_translation_table_t *table, int offset, ie_event_t *event)
|
||||
{
|
||||
if (offset >= table->maxevents) {
|
||||
table->maxevents++;
|
||||
table->events = realloc (table->events, sizeof (ie_translation_table_t *) * table->maxevents);
|
||||
if (!table->events)
|
||||
Sys_Error ("IE_Translation_Table_Modify: memory allocation failure");
|
||||
}
|
||||
table->events[offset] = event;
|
||||
}
|
||||
|
||||
ie_translation_index_t *
|
||||
IE_Translation_Index_Create ()
|
||||
{
|
||||
ie_translation_index_t *index;
|
||||
|
||||
index = malloc (sizeof (ie_translation_index_t));
|
||||
if (!index)
|
||||
Sys_Error ("IE_Translation_Index_Create: memory allocation failure");
|
||||
|
||||
index->maxtables = 0;
|
||||
index->tables = 0;
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
IE_Multiplier_Event (ie_event_t *event, float value)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue