some small additions to the event and list system, and some retractions of previously changed code.
This commit is contained in:
@@ -17,7 +17,7 @@ The Immortal Postmaster is hard at work here.
|
|||||||
~
|
~
|
||||||
Scary... A postal worker... Working?
|
Scary... A postal worker... Working?
|
||||||
~
|
~
|
||||||
712714 0 0 0 65536 0 0 0 0 E
|
188426 0 0 0 65536 0 0 0 0 E
|
||||||
14 16 1 2d2+140 2d2+2
|
14 16 1 2d2+140 2d2+2
|
||||||
140 19600
|
140 19600
|
||||||
8 8 2
|
8 8 2
|
||||||
@@ -214,9 +214,9 @@ the test mob~
|
|||||||
~
|
~
|
||||||
Test mobs can be whatever you want them to be.
|
Test mobs can be whatever you want them to be.
|
||||||
~
|
~
|
||||||
61454 0 0 0 983040 0 0 0 0 E
|
8 0 0 0 0 0 0 0 0 E
|
||||||
3 19 8 0d0+30 1d2+0
|
0 20 10 1d1+0 1d1+0
|
||||||
30 900
|
0 0
|
||||||
8 8 0
|
8 8 0
|
||||||
E
|
E
|
||||||
$
|
$
|
||||||
|
|||||||
@@ -1263,19 +1263,11 @@ ACMD(do_who)
|
|||||||
CCNRM(ch, C_SPR), ((!(++num_can_see % 4)) ? "\r\n" : ""));
|
CCNRM(ch, C_SPR), ((!(++num_can_see % 4)) ? "\r\n" : ""));
|
||||||
} else {
|
} else {
|
||||||
num_can_see++;
|
num_can_see++;
|
||||||
if (GET_LEVEL(tch) >= LVL_IMMORT) {
|
|
||||||
send_to_char(ch, "%s%s%s%s%s",
|
|
||||||
(GET_LEVEL(tch) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
|
|
||||||
GET_NAME(tch), (*GET_TITLE(tch) ? " " : ""), GET_TITLE(tch),
|
|
||||||
CCNRM(ch, C_SPR));
|
|
||||||
} else {
|
|
||||||
send_to_char(ch, "%s[%2d %s] %s%s%s%s",
|
send_to_char(ch, "%s[%2d %s] %s%s%s%s",
|
||||||
(GET_LEVEL(tch) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
|
(GET_LEVEL(tch) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
|
||||||
GET_LEVEL(tch), CLASS_ABBR(tch),
|
GET_LEVEL(tch), CLASS_ABBR(tch),
|
||||||
GET_NAME(tch), (*GET_TITLE(tch) ? " " : ""), GET_TITLE(tch),
|
GET_NAME(tch), (*GET_TITLE(tch) ? " " : ""), GET_TITLE(tch),
|
||||||
CCNRM(ch, C_SPR));
|
CCNRM(ch, C_SPR));
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (GET_INVIS_LEV(tch))
|
if (GET_INVIS_LEV(tch))
|
||||||
send_to_char(ch, " (i%d)", GET_INVIS_LEV(tch));
|
send_to_char(ch, " (i%d)", GET_INVIS_LEV(tch));
|
||||||
@@ -2377,6 +2369,10 @@ ACMD(do_whois)
|
|||||||
{
|
{
|
||||||
CREATE(victim, struct char_data, 1);
|
CREATE(victim, struct char_data, 1);
|
||||||
clear_char(victim);
|
clear_char(victim);
|
||||||
|
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
victim->events = create_list();
|
||||||
|
|
||||||
CREATE(victim->player_specials, struct player_special_data, 1);
|
CREATE(victim->player_specials, struct player_special_data, 1);
|
||||||
|
|
||||||
if (load_char(buf, victim) > -1)
|
if (load_char(buf, victim) > -1)
|
||||||
|
|||||||
@@ -1008,6 +1008,8 @@ ACMD(do_stat)
|
|||||||
CREATE(victim, struct char_data, 1);
|
CREATE(victim, struct char_data, 1);
|
||||||
clear_char(victim);
|
clear_char(victim);
|
||||||
CREATE(victim->player_specials, struct player_special_data, 1);
|
CREATE(victim->player_specials, struct player_special_data, 1);
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
victim->events = create_list();
|
||||||
if (load_char(buf2, victim) >= 0) {
|
if (load_char(buf2, victim) >= 0) {
|
||||||
char_to_room(victim, 0);
|
char_to_room(victim, 0);
|
||||||
if (GET_LEVEL(victim) > GET_LEVEL(ch))
|
if (GET_LEVEL(victim) > GET_LEVEL(ch))
|
||||||
@@ -2047,6 +2049,8 @@ ACMD(do_last)
|
|||||||
CREATE(vict, struct char_data, 1);
|
CREATE(vict, struct char_data, 1);
|
||||||
clear_char(vict);
|
clear_char(vict);
|
||||||
CREATE(vict->player_specials, struct player_special_data, 1);
|
CREATE(vict->player_specials, struct player_special_data, 1);
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
vict->events = create_list();
|
||||||
if (load_char(name, vict) < 0) {
|
if (load_char(name, vict) < 0) {
|
||||||
send_to_char(ch, "There is no such player.\r\n");
|
send_to_char(ch, "There is no such player.\r\n");
|
||||||
free_char(vict);
|
free_char(vict);
|
||||||
@@ -2567,6 +2571,8 @@ ACMD(do_show)
|
|||||||
CREATE(vict, struct char_data, 1);
|
CREATE(vict, struct char_data, 1);
|
||||||
clear_char(vict);
|
clear_char(vict);
|
||||||
CREATE(vict->player_specials, struct player_special_data, 1);
|
CREATE(vict->player_specials, struct player_special_data, 1);
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
vict->events = create_list();
|
||||||
if (load_char(value, vict) < 0) {
|
if (load_char(value, vict) < 0) {
|
||||||
send_to_char(ch, "There is no such player.\r\n");
|
send_to_char(ch, "There is no such player.\r\n");
|
||||||
free_char(vict);
|
free_char(vict);
|
||||||
@@ -3347,6 +3353,8 @@ ACMD(do_set)
|
|||||||
CREATE(cbuf, struct char_data, 1);
|
CREATE(cbuf, struct char_data, 1);
|
||||||
clear_char(cbuf);
|
clear_char(cbuf);
|
||||||
CREATE(cbuf->player_specials, struct player_special_data, 1);
|
CREATE(cbuf->player_specials, struct player_special_data, 1);
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
cbuf->events = create_list();
|
||||||
if ((player_i = load_char(name, cbuf)) > -1) {
|
if ((player_i = load_char(name, cbuf)) > -1) {
|
||||||
if (GET_LEVEL(cbuf) > GET_LEVEL(ch)) {
|
if (GET_LEVEL(cbuf) > GET_LEVEL(ch)) {
|
||||||
free_char(cbuf);
|
free_char(cbuf);
|
||||||
@@ -4613,6 +4621,8 @@ bool change_player_name(struct char_data *ch, struct char_data *vict, char *new_
|
|||||||
CREATE(temp_ch, struct char_data, 1);
|
CREATE(temp_ch, struct char_data, 1);
|
||||||
clear_char(temp_ch);
|
clear_char(temp_ch);
|
||||||
CREATE(temp_ch->player_specials, struct player_special_data, 1);
|
CREATE(temp_ch->player_specials, struct player_special_data, 1);
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
temp_ch->events = create_list();
|
||||||
if ((plr_i = load_char(new_name, temp_ch)) > -1) {
|
if ((plr_i = load_char(new_name, temp_ch)) > -1) {
|
||||||
free_char(temp_ch);
|
free_char(temp_ch);
|
||||||
send_to_char(ch, "Sorry, the new name already exists.\r\n");
|
send_to_char(ch, "Sorry, the new name already exists.\r\n");
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ int main(int argc, char **argv)
|
|||||||
free_save_list(); /* genolc.c */
|
free_save_list(); /* genolc.c */
|
||||||
free_strings(&config_info, OASIS_CFG); /* oasis_delete.c */
|
free_strings(&config_info, OASIS_CFG); /* oasis_delete.c */
|
||||||
free_ibt_lists(); /* ibt.c */
|
free_ibt_lists(); /* ibt.c */
|
||||||
|
free_list(world_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_act_message)
|
if (last_act_message)
|
||||||
@@ -444,6 +445,10 @@ void copyover_recover()
|
|||||||
CREATE(d->character, struct char_data, 1);
|
CREATE(d->character, struct char_data, 1);
|
||||||
clear_char(d->character);
|
clear_char(d->character);
|
||||||
CREATE(d->character->player_specials, struct player_special_data, 1);
|
CREATE(d->character->player_specials, struct player_special_data, 1);
|
||||||
|
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
d->character->events = create_list();
|
||||||
|
|
||||||
d->character->desc = d;
|
d->character->desc = d;
|
||||||
|
|
||||||
if ((player_i = load_char(name, d->character)) >= 0) {
|
if ((player_i = load_char(name, d->character)) >= 0) {
|
||||||
@@ -1589,7 +1594,7 @@ static int new_descriptor(socket_t s)
|
|||||||
descriptor_list = newd;
|
descriptor_list = newd;
|
||||||
|
|
||||||
/* Attach Event */
|
/* Attach Event */
|
||||||
attach_mud_event(get_protocols, new_mud_event(EVENT_DESC, newd, NULL), 1.5 * PASSES_PER_SEC);
|
attach_mud_event(new_mud_event(ePROTOCOLS, newd, NULL), 1.5 * PASSES_PER_SEC);
|
||||||
|
|
||||||
/* KaVir's plugin*/
|
/* KaVir's plugin*/
|
||||||
write_to_output(newd, "Attempting to Detect Client, Please Wait...\r\n");
|
write_to_output(newd, "Attempting to Detect Client, Please Wait...\r\n");
|
||||||
|
|||||||
23
src/db.c
23
src/db.c
@@ -629,9 +629,6 @@ void destroy_db(void)
|
|||||||
/* Events */
|
/* Events */
|
||||||
event_free_all();
|
event_free_all();
|
||||||
|
|
||||||
/* Lists */
|
|
||||||
free_list(world_events);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* body of the booting system */
|
/* body of the booting system */
|
||||||
@@ -2324,6 +2321,10 @@ struct char_data *create_char(void)
|
|||||||
|
|
||||||
CREATE(ch, struct char_data, 1);
|
CREATE(ch, struct char_data, 1);
|
||||||
clear_char(ch);
|
clear_char(ch);
|
||||||
|
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
ch->events = create_list();
|
||||||
|
|
||||||
ch->next = character_list;
|
ch->next = character_list;
|
||||||
character_list = ch;
|
character_list = ch;
|
||||||
|
|
||||||
@@ -2350,10 +2351,14 @@ struct char_data *read_mobile(mob_vnum nr, int type) /* and mob_rnum */
|
|||||||
|
|
||||||
CREATE(mob, struct char_data, 1);
|
CREATE(mob, struct char_data, 1);
|
||||||
clear_char(mob);
|
clear_char(mob);
|
||||||
|
|
||||||
*mob = mob_proto[i];
|
*mob = mob_proto[i];
|
||||||
mob->next = character_list;
|
mob->next = character_list;
|
||||||
character_list = mob;
|
character_list = mob;
|
||||||
|
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
mob->events = create_list();
|
||||||
|
|
||||||
if (!mob->points.max_hit) {
|
if (!mob->points.max_hit) {
|
||||||
mob->points.max_hit = dice(mob->points.hit, mob->points.mana) +
|
mob->points.max_hit = dice(mob->points.hit, mob->points.mana) +
|
||||||
mob->points.move;
|
mob->points.move;
|
||||||
@@ -3191,6 +3196,17 @@ void free_char(struct char_data *ch)
|
|||||||
if (SCRIPT(ch))
|
if (SCRIPT(ch))
|
||||||
extract_script(ch, MOB_TRIGGER);
|
extract_script(ch, MOB_TRIGGER);
|
||||||
|
|
||||||
|
/* Mud Events */
|
||||||
|
if (ch->events != NULL) {
|
||||||
|
if (ch->events->iSize > 0) {
|
||||||
|
struct event * pEvent;
|
||||||
|
|
||||||
|
while ((pEvent = simple_list(ch->events)) != NULL)
|
||||||
|
event_cancel(pEvent);
|
||||||
|
}
|
||||||
|
free_list(ch->events);
|
||||||
|
}
|
||||||
|
|
||||||
/* new version of free_followers take the followers pointer as arg */
|
/* new version of free_followers take the followers pointer as arg */
|
||||||
free_followers(ch->followers);
|
free_followers(ch->followers);
|
||||||
|
|
||||||
@@ -3359,6 +3375,7 @@ void clear_char(struct char_data *ch)
|
|||||||
GET_WAS_IN(ch) = NOWHERE;
|
GET_WAS_IN(ch) = NOWHERE;
|
||||||
GET_POS(ch) = POS_STANDING;
|
GET_POS(ch) = POS_STANDING;
|
||||||
ch->mob_specials.default_pos = POS_STANDING;
|
ch->mob_specials.default_pos = POS_STANDING;
|
||||||
|
ch->events = NULL;
|
||||||
|
|
||||||
GET_AC(ch) = 100; /* Basic Armor */
|
GET_AC(ch) = 100; /* Basic Armor */
|
||||||
if (ch->points.max_mana < 100)
|
if (ch->points.max_mana < 100)
|
||||||
|
|||||||
@@ -1352,6 +1352,10 @@ void nanny(struct descriptor_data *d, char *arg)
|
|||||||
CREATE(d->character, struct char_data, 1);
|
CREATE(d->character, struct char_data, 1);
|
||||||
clear_char(d->character);
|
clear_char(d->character);
|
||||||
CREATE(d->character->player_specials, struct player_special_data, 1);
|
CREATE(d->character->player_specials, struct player_special_data, 1);
|
||||||
|
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
d->character->events = create_list();
|
||||||
|
|
||||||
GET_HOST(d->character) = strdup(d->host);
|
GET_HOST(d->character) = strdup(d->host);
|
||||||
d->character->desc = d;
|
d->character->desc = d;
|
||||||
}
|
}
|
||||||
@@ -1387,6 +1391,9 @@ void nanny(struct descriptor_data *d, char *arg)
|
|||||||
clear_char(d->character);
|
clear_char(d->character);
|
||||||
CREATE(d->character->player_specials, struct player_special_data, 1);
|
CREATE(d->character->player_specials, struct player_special_data, 1);
|
||||||
|
|
||||||
|
/* Allocate mobile event list */
|
||||||
|
d->character->events = create_list();
|
||||||
|
|
||||||
if (GET_HOST(d->character))
|
if (GET_HOST(d->character))
|
||||||
free(GET_HOST(d->character));
|
free(GET_HOST(d->character));
|
||||||
GET_HOST(d->character) = strdup(d->host);
|
GET_HOST(d->character) = strdup(d->host);
|
||||||
|
|||||||
25
src/lists.c
25
src/lists.c
@@ -1,12 +1,8 @@
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* File: lists.c Part of tbaMUD *
|
* File: lists.c Part of tbaMUD *
|
||||||
* Usage: Loading/saving/editing of Ideas, Bugs and Typos lists *
|
* Usage: Handling of in-game lists *
|
||||||
* *
|
* *
|
||||||
* All rights reserved. See license for complete information. *
|
* By Vatiken. Copyright 2012 by Joseph Arnusch *
|
||||||
* *
|
|
||||||
* Written by Joseph Arnusch (Vatiken) for the tbaMUD codebase *
|
|
||||||
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
|
|
||||||
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
|
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
@@ -32,10 +28,9 @@ struct list_data * create_list(void)
|
|||||||
pNewList->iSize = 0;
|
pNewList->iSize = 0;
|
||||||
|
|
||||||
/* Add to global lists, primarily for debugging purposes */
|
/* Add to global lists, primarily for debugging purposes */
|
||||||
if (first_list == FALSE) {
|
if (first_list == FALSE)
|
||||||
mudlog(CMP, LVL_GOD, TRUE, "Adding to global list.");
|
|
||||||
add_to_list(pNewList, global_lists);
|
add_to_list(pNewList, global_lists);
|
||||||
} else
|
else
|
||||||
first_list = FALSE;
|
first_list = FALSE;
|
||||||
|
|
||||||
return (pNewList);
|
return (pNewList);
|
||||||
@@ -58,6 +53,8 @@ void free_list(struct list_data * pList)
|
|||||||
{
|
{
|
||||||
void * pContent;
|
void * pContent;
|
||||||
|
|
||||||
|
simple_list(NULL);
|
||||||
|
|
||||||
if (pList->iSize)
|
if (pList->iSize)
|
||||||
while ((pContent = simple_list(pList)))
|
while ((pContent = simple_list(pList)))
|
||||||
remove_from_list(pContent, pList);
|
remove_from_list(pContent, pList);
|
||||||
@@ -66,7 +63,6 @@ void free_list(struct list_data * pList)
|
|||||||
mudlog(CMP, LVL_GOD, TRUE, "List being freed while not empty.");
|
mudlog(CMP, LVL_GOD, TRUE, "List being freed while not empty.");
|
||||||
|
|
||||||
/* Global List for debugging */
|
/* Global List for debugging */
|
||||||
mudlog(CMP, LVL_GOD, TRUE, "Removing from global list.");
|
|
||||||
remove_from_list(pList, global_lists);
|
remove_from_list(pList, global_lists);
|
||||||
|
|
||||||
free(pList);
|
free(pList);
|
||||||
@@ -249,8 +245,15 @@ void * simple_list(struct list_data * pList)
|
|||||||
static struct list_data *pLastList = NULL;
|
static struct list_data *pLastList = NULL;
|
||||||
void * pContent;
|
void * pContent;
|
||||||
|
|
||||||
|
/* Reset List */
|
||||||
|
if (pList == NULL) {
|
||||||
|
loop = FALSE;
|
||||||
|
pLastList = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!loop || pLastList != pList) {
|
if (!loop || pLastList != pList) {
|
||||||
if (pLastList != pList)
|
if (loop && pLastList != pList)
|
||||||
mudlog(CMP, LVL_GRGOD, TRUE, "SYSERR: simple_list() forced to reset itself.");
|
mudlog(CMP, LVL_GRGOD, TRUE, "SYSERR: simple_list() forced to reset itself.");
|
||||||
|
|
||||||
pContent = merge_iterator(&Iterator, pList);
|
pContent = merge_iterator(&Iterator, pList);
|
||||||
|
|||||||
17
src/lists.h
17
src/lists.h
@@ -1,4 +1,13 @@
|
|||||||
/* file: list.h
|
/**
|
||||||
|
* @file lists.h
|
||||||
|
* Lists Header file.
|
||||||
|
*
|
||||||
|
* Part of the core tbaMUD source code distribution, which is a derivative
|
||||||
|
* of, and continuation of, CircleMUD.
|
||||||
|
*
|
||||||
|
* This source code, which was not part of the CircleMUD legacy code,
|
||||||
|
* is attributed to:
|
||||||
|
* Copyright 2012 by Joseph Arnusch.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LISTS_HEADER
|
#ifndef _LISTS_HEADER
|
||||||
@@ -13,8 +22,8 @@ struct item_data {
|
|||||||
struct list_data {
|
struct list_data {
|
||||||
struct item_data * pFirstItem;
|
struct item_data * pFirstItem;
|
||||||
struct item_data * pLastItem;
|
struct item_data * pLastItem;
|
||||||
int iIterators;
|
unsigned short int iIterators;
|
||||||
int iSize;
|
unsigned short int iSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct iterator_data {
|
struct iterator_data {
|
||||||
@@ -25,7 +34,7 @@ struct iterator_data {
|
|||||||
/* Externals */
|
/* Externals */
|
||||||
extern struct list_data * global_lists;
|
extern struct list_data * global_lists;
|
||||||
extern struct list_data * ticker_list;
|
extern struct list_data * ticker_list;
|
||||||
|
extern int total_lists;
|
||||||
/* Locals */
|
/* Locals */
|
||||||
void add_to_list(void * pContent, struct list_data * pList);
|
void add_to_list(void * pContent, struct list_data * pList);
|
||||||
void * random_from_list(struct list_data * pList);
|
void * random_from_list(struct list_data * pList);
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
* File: mud_event.c Part of tbaMUD *
|
||||||
|
* Usage: Handling of the mud event system *
|
||||||
|
* *
|
||||||
|
* By Vatiken. Copyright 2012 by Joseph Arnusch *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "sysdep.h"
|
#include "sysdep.h"
|
||||||
@@ -12,38 +18,70 @@
|
|||||||
/* Global List */
|
/* Global List */
|
||||||
struct list_data * world_events = NULL;
|
struct list_data * world_events = NULL;
|
||||||
|
|
||||||
|
struct mud_event_list mud_event_index[] = {
|
||||||
|
{ "Null" , NULL , -1 }, /* eNULL */
|
||||||
|
{ "Protocol" , get_protocols, EVENT_DESC } /* ePROTOCOLS */
|
||||||
|
};
|
||||||
|
|
||||||
void init_events(void)
|
void init_events(void)
|
||||||
{
|
{
|
||||||
/* Allocate Event List */
|
/* Allocate Event List */
|
||||||
world_events = create_list();
|
world_events = create_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
void attach_mud_event(void (*func), struct mud_event_data *pMudEvent, long time)
|
EVENTFUNC(event_countdown)
|
||||||
|
{
|
||||||
|
struct mud_event_data * pMudEvent;
|
||||||
|
struct char_data * ch = NULL;
|
||||||
|
|
||||||
|
pMudEvent = (struct mud_event_data * ) event_obj;
|
||||||
|
|
||||||
|
switch (mud_event_index[pMudEvent->iId].iEvent_Type) {
|
||||||
|
case EVENT_CHAR:
|
||||||
|
ch = (struct char_data * ) pMudEvent->pStruct;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pMudEvent->iId) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
free_mud_event(pMudEvent);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void attach_mud_event(struct mud_event_data *pMudEvent, long time)
|
||||||
{
|
{
|
||||||
struct event * pEvent;
|
struct event * pEvent;
|
||||||
struct descriptor_data * d;
|
struct descriptor_data * d;
|
||||||
struct char_data * ch;
|
struct char_data * ch;
|
||||||
|
|
||||||
pEvent = event_create(func, pMudEvent, time);
|
pEvent = event_create(mud_event_index[pMudEvent->iId].func, pMudEvent, time);
|
||||||
pEvent->isMudEvent = TRUE;
|
pEvent->isMudEvent = TRUE;
|
||||||
pMudEvent->pEvent = pEvent;
|
pMudEvent->pEvent = pEvent;
|
||||||
|
|
||||||
switch (pMudEvent->iEvent_Type) {
|
switch (mud_event_index[pMudEvent->iId].iEvent_Type) {
|
||||||
case EVENT_WORLD:
|
case EVENT_WORLD:
|
||||||
add_to_list(pEvent, world_events);
|
add_to_list(pEvent, world_events);
|
||||||
|
mudlog(CMP, LVL_GRGOD, TRUE, "INFO: Mud Event '%s' added to world", mud_event_index[pMudEvent->iId].event_name);
|
||||||
break;
|
break;
|
||||||
case EVENT_DESC:
|
case EVENT_DESC:
|
||||||
d = (struct descriptor_data *) pMudEvent->pStruct;
|
d = (struct descriptor_data *) pMudEvent->pStruct;
|
||||||
add_to_list(pEvent, d->events);
|
add_to_list(pEvent, d->events);
|
||||||
|
mudlog(CMP, LVL_GRGOD, TRUE, "INFO: Mud Event '%s' added to %s", mud_event_index[pMudEvent->iId].event_name, d->host ? d->host : "descriptor");
|
||||||
break;
|
break;
|
||||||
case EVENT_CHAR:
|
case EVENT_CHAR:
|
||||||
ch = (struct char_data *) pMudEvent->pStruct;
|
ch = (struct char_data *) pMudEvent->pStruct;
|
||||||
add_to_list(pEvent, ch->events);
|
add_to_list(pEvent, ch->events);
|
||||||
|
mudlog(CMP, LVL_GRGOD, TRUE, "INFO: Mud Event '%s' added to %s", mud_event_index[pMudEvent->iId].event_name, GET_NAME(ch));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mud_event_data *new_mud_event(int iEvent_Type, void *pStruct, char *sVariables)
|
struct mud_event_data *new_mud_event(event_id iId, void *pStruct, char *sVariables)
|
||||||
{
|
{
|
||||||
struct mud_event_data *pMudEvent;
|
struct mud_event_data *pMudEvent;
|
||||||
char *varString;
|
char *varString;
|
||||||
@@ -51,7 +89,7 @@ struct mud_event_data *new_mud_event(int iEvent_Type, void *pStruct, char *sVari
|
|||||||
CREATE(pMudEvent, struct mud_event_data, 1);
|
CREATE(pMudEvent, struct mud_event_data, 1);
|
||||||
varString = (sVariables != NULL) ? strdup(sVariables) : NULL;
|
varString = (sVariables != NULL) ? strdup(sVariables) : NULL;
|
||||||
|
|
||||||
pMudEvent->iEvent_Type = iEvent_Type;
|
pMudEvent->iId = iId;
|
||||||
pMudEvent->pStruct = pStruct;
|
pMudEvent->pStruct = pStruct;
|
||||||
pMudEvent->sVariables = varString;
|
pMudEvent->sVariables = varString;
|
||||||
pMudEvent->pEvent = NULL;
|
pMudEvent->pEvent = NULL;
|
||||||
@@ -64,7 +102,9 @@ void free_mud_event(struct mud_event_data *pMudEvent)
|
|||||||
struct descriptor_data * d;
|
struct descriptor_data * d;
|
||||||
struct char_data * ch;
|
struct char_data * ch;
|
||||||
|
|
||||||
switch (pMudEvent->iEvent_Type) {
|
mudlog(CMP, LVL_GRGOD, TRUE, "INFO: Freeing mud event '%s' : %d", mud_event_index[pMudEvent->iId].event_name, pMudEvent->iId);
|
||||||
|
|
||||||
|
switch (mud_event_index[pMudEvent->iId].iEvent_Type) {
|
||||||
case EVENT_WORLD:
|
case EVENT_WORLD:
|
||||||
remove_from_list(pMudEvent->pEvent, world_events);
|
remove_from_list(pMudEvent->pEvent, world_events);
|
||||||
break;
|
break;
|
||||||
@@ -84,3 +124,29 @@ void free_mud_event(struct mud_event_data *pMudEvent)
|
|||||||
pMudEvent->pEvent->event_obj = NULL;
|
pMudEvent->pEvent->event_obj = NULL;
|
||||||
free(pMudEvent);
|
free(pMudEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct mud_event_data * char_has_mud_event(struct char_data * ch, event_id iId)
|
||||||
|
{
|
||||||
|
struct event * pEvent;
|
||||||
|
struct mud_event_data * pMudEvent;
|
||||||
|
bool found = FALSE;
|
||||||
|
|
||||||
|
simple_list(NULL);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
simple_list(NULL);
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
return (pMudEvent);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* @file mud_event.h
|
* @file mud_event.h
|
||||||
|
* Mud_Event Header file.
|
||||||
*
|
*
|
||||||
* Part of the core tbaMUD source code distribution, which is a derivative
|
* Part of the core tbaMUD source code distribution, which is a derivative
|
||||||
* of, and continuation of, CircleMUD.
|
* of, and continuation of, CircleMUD.
|
||||||
|
*
|
||||||
|
* This source code, which was not part of the CircleMUD legacy code,
|
||||||
|
* is attributed to:
|
||||||
|
* Copyright 2012 by Joseph Arnusch.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MUD_EVENT_H_
|
#ifndef _MUD_EVENT_H_
|
||||||
#define _MUD_EVENT_H_
|
#define _MUD_EVENT_H_
|
||||||
|
|
||||||
@@ -13,23 +19,36 @@
|
|||||||
#define EVENT_DESC 1
|
#define EVENT_DESC 1
|
||||||
#define EVENT_CHAR 2
|
#define EVENT_CHAR 2
|
||||||
|
|
||||||
struct mud_event_data {
|
typedef enum {
|
||||||
struct event * pEvent;
|
eNULL,
|
||||||
|
ePROTOCOLS,
|
||||||
|
} event_id;
|
||||||
|
|
||||||
|
struct mud_event_list {
|
||||||
|
const char * event_name;
|
||||||
|
EVENTFUNC(*func);
|
||||||
int iEvent_Type;
|
int iEvent_Type;
|
||||||
void * pStruct;
|
};
|
||||||
char * sVariables;
|
|
||||||
|
struct mud_event_data {
|
||||||
|
struct event * pEvent; /***< Pointer reference to the event */
|
||||||
|
event_id iId; /***< General ID reference */
|
||||||
|
void * pStruct; /***< Pointer to NULL, Descriptor, Character .... */
|
||||||
|
char * sVariables; /***< String variable */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Externals */
|
/* Externals */
|
||||||
extern struct list_data * world_events;
|
extern struct list_data * world_events;
|
||||||
|
extern struct mud_event_list mud_event_index[];
|
||||||
/* Local Functions */
|
/* Local Functions */
|
||||||
void init_events(void);
|
void init_events(void);
|
||||||
struct mud_event_data *new_mud_event(int iEvent_Type, void *pStruct, char *sVariables);
|
struct mud_event_data *new_mud_event(event_id iId, void *pStruct, char *sVariables);
|
||||||
void attach_mud_event(void (*func), struct mud_event_data *pMudEvent, long time);
|
void attach_mud_event(struct mud_event_data *pMudEvent, long time);
|
||||||
void free_mud_event(struct mud_event_data *pMudEvent);
|
void free_mud_event(struct mud_event_data *pMudEvent);
|
||||||
|
struct mud_event_data * char_has_mud_event(struct char_data * ch, event_id iId);
|
||||||
|
|
||||||
/* Events */
|
/* Events */
|
||||||
|
EVENTFUNC(event_countdown);
|
||||||
EVENTFUNC(get_protocols);
|
EVENTFUNC(get_protocols);
|
||||||
|
|
||||||
#endif /* _MUD_EVENT_H_ */
|
#endif /* _MUD_EVENT_H_ */
|
||||||
|
|||||||
@@ -344,6 +344,7 @@ void ProtocolDestroy( protocol_t *apProtocol )
|
|||||||
|
|
||||||
for ( i = eMSDP_NONE+1; i < eMSDP_MAX; ++i )
|
for ( i = eMSDP_NONE+1; i < eMSDP_MAX; ++i )
|
||||||
{
|
{
|
||||||
|
if (apProtocol->pVariables[i]->pValueString)
|
||||||
free(apProtocol->pVariables[i]->pValueString);
|
free(apProtocol->pVariables[i]->pValueString);
|
||||||
free(apProtocol->pVariables[i]);
|
free(apProtocol->pVariables[i]);
|
||||||
}
|
}
|
||||||
@@ -1730,6 +1731,7 @@ static void PerformSubnegotiation( descriptor_t *apDescriptor, char aCmd, char *
|
|||||||
const char *pStartPos = strstr( pClientName, "-" );
|
const char *pStartPos = strstr( pClientName, "-" );
|
||||||
|
|
||||||
/* Store the TTYPE */
|
/* Store the TTYPE */
|
||||||
|
if (pProtocol->pLastTTYPE)
|
||||||
free(pProtocol->pLastTTYPE);
|
free(pProtocol->pLastTTYPE);
|
||||||
pProtocol->pLastTTYPE = AllocString(pClientName);
|
pProtocol->pLastTTYPE = AllocString(pClientName);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user