New Group System, Room Events, and Event System Efficiency Upgrade... and a couple bug fixes.
This commit is contained in:
@@ -23,7 +23,8 @@ struct list_data * world_events = NULL;
|
||||
struct mud_event_list mud_event_index[] = {
|
||||
{ "Null" , NULL , -1 }, /* eNULL */
|
||||
{ "Protocol" , get_protocols , EVENT_DESC }, /* ePROTOCOLS */
|
||||
{ "Whirlwind" , event_whirlwind, EVENT_CHAR } /* eWHIRLWIND */
|
||||
{ "Whirlwind" , event_whirlwind, EVENT_CHAR }, /* eWHIRLWIND */
|
||||
{ "Spell:Darkness",event_countdown, EVENT_ROOM } /* eSPL_DARKNESS */
|
||||
};
|
||||
|
||||
/* init_events() is the ideal function for starting global events. This
|
||||
@@ -54,6 +55,8 @@ EVENTFUNC(event_countdown)
|
||||
{
|
||||
struct mud_event_data * pMudEvent;
|
||||
struct char_data * ch = NULL;
|
||||
struct room_data * room = NULL;
|
||||
room_rnum rnum = NOWHERE;
|
||||
|
||||
pMudEvent = (struct mud_event_data * ) event_obj;
|
||||
|
||||
@@ -61,11 +64,19 @@ EVENTFUNC(event_countdown)
|
||||
case EVENT_CHAR:
|
||||
ch = (struct char_data * ) pMudEvent->pStruct;
|
||||
break;
|
||||
case EVENT_ROOM:
|
||||
room = (struct room_data * ) pMudEvent->pStruct;
|
||||
rnum = real_room(room->number);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (pMudEvent->iId) {
|
||||
case eSPL_DARKNESS:
|
||||
REMOVE_BIT_AR(ROOM_FLAGS(rnum), ROOM_DARK);
|
||||
send_to_room(rnum, "The dark shroud disappates.\r\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -82,6 +93,7 @@ void attach_mud_event(struct mud_event_data *pMudEvent, long time)
|
||||
struct event * pEvent;
|
||||
struct descriptor_data * d;
|
||||
struct char_data * ch;
|
||||
struct room_data * room;
|
||||
|
||||
pEvent = event_create(mud_event_index[pMudEvent->iId].func, pMudEvent, time);
|
||||
pEvent->isMudEvent = TRUE;
|
||||
@@ -97,8 +109,20 @@ void attach_mud_event(struct mud_event_data *pMudEvent, long time)
|
||||
break;
|
||||
case EVENT_CHAR:
|
||||
ch = (struct char_data *) pMudEvent->pStruct;
|
||||
|
||||
if (ch->events == NULL)
|
||||
ch->events = create_list();
|
||||
|
||||
add_to_list(pEvent, ch->events);
|
||||
break;
|
||||
case EVENT_ROOM:
|
||||
room = (struct room_data *) pMudEvent->pStruct;
|
||||
|
||||
if (room->events == NULL)
|
||||
room->events = create_list();
|
||||
|
||||
add_to_list(pEvent, room->events);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +146,7 @@ void free_mud_event(struct mud_event_data *pMudEvent)
|
||||
{
|
||||
struct descriptor_data * d;
|
||||
struct char_data * ch;
|
||||
struct room_data * room;
|
||||
|
||||
switch (mud_event_index[pMudEvent->iId].iEvent_Type) {
|
||||
case EVENT_WORLD:
|
||||
@@ -134,6 +159,20 @@ void free_mud_event(struct mud_event_data *pMudEvent)
|
||||
case EVENT_CHAR:
|
||||
ch = (struct char_data *) pMudEvent->pStruct;
|
||||
remove_from_list(pMudEvent->pEvent, ch->events);
|
||||
|
||||
if (ch->events->iSize == 0) {
|
||||
free_list(ch->events);
|
||||
ch->events = NULL;
|
||||
}
|
||||
break;
|
||||
case EVENT_ROOM:
|
||||
room = (struct room_data *) pMudEvent->pStruct;
|
||||
remove_from_list(pMudEvent->pEvent, room->events);
|
||||
|
||||
if (room->events->iSize == 0) {
|
||||
free_list(room->events);
|
||||
room->events = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -150,10 +189,13 @@ struct mud_event_data * char_has_mud_event(struct char_data * ch, event_id iId)
|
||||
struct mud_event_data * pMudEvent;
|
||||
bool found = FALSE;
|
||||
|
||||
if (ch->events == NULL)
|
||||
return NULL;
|
||||
|
||||
if (ch->events->iSize == 0)
|
||||
return NULL;
|
||||
|
||||
simple_list(NULL);
|
||||
clear_simple_list();
|
||||
|
||||
while ((pEvent = (struct event *) simple_list(ch->events)) != NULL) {
|
||||
if (!pEvent->isMudEvent)
|
||||
@@ -164,9 +206,7 @@ struct mud_event_data * char_has_mud_event(struct char_data * ch, event_id iId)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
simple_list(NULL);
|
||||
|
||||
|
||||
if (found)
|
||||
return (pMudEvent);
|
||||
|
||||
@@ -183,11 +223,46 @@ void clear_char_event_list(struct char_data * ch)
|
||||
if (ch->events->iSize == 0)
|
||||
return;
|
||||
|
||||
simple_list(NULL);
|
||||
clear_simple_list();
|
||||
|
||||
while ((pEvent = (struct event *) simple_list(ch->events)) != NULL) {
|
||||
event_cancel(pEvent);
|
||||
}
|
||||
|
||||
simple_list(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* change_event_duration contributed by Ripley */
|
||||
void change_event_duration(struct char_data * ch, event_id iId, long time) {
|
||||
|
||||
struct event * pEvent;
|
||||
struct mud_event_data * pMudEvent;
|
||||
bool found = FALSE;
|
||||
|
||||
if (ch->events == NULL);
|
||||
return;
|
||||
|
||||
if (ch->events->iSize == 0)
|
||||
return;
|
||||
|
||||
clear_simple_list();
|
||||
|
||||
while ((pEvent = (struct event *) simple_list(ch->events)) != NULL) {
|
||||
|
||||
if (!pEvent->isMudEvent)
|
||||
continue;
|
||||
|
||||
pMudEvent = (struct mud_event_data * ) pEvent->event_obj;
|
||||
|
||||
if (pMudEvent->iId == iId) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
/* So we found the offending event, now build a new one, with the new time */
|
||||
attach_mud_event(new_mud_event(iId, pMudEvent->pStruct, pMudEvent->sVariables), time);
|
||||
event_cancel(pEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user