Just some cosmetic code cleanup

This commit is contained in:
Vatiken 2012-06-19 21:11:14 +00:00
parent 12c506c89a
commit 58ec913b46
12 changed files with 230 additions and 254 deletions

View file

@ -26,15 +26,15 @@ static bool legal_communication(char * arg);
static bool legal_communication(char * arg)
{
while (*arg) {
if (*arg == '@') {
arg++;
if (*arg == '(' || *arg == ')' || *arg == '<' || *arg == '>')
return FALSE;
}
arg++;
}
return TRUE;
while (*arg) {
if (*arg == '@') {
arg++;
if (*arg == '(' || *arg == ')' || *arg == '<' || *arg == '>')
return FALSE;
}
arg++;
}
return TRUE;
}
ACMD(do_say)

View file

@ -505,16 +505,11 @@ void look_at_room(struct char_data *ch, int ignore_brief)
send_to_char(ch, "%s\r\n", CCNRM(ch, C_NRM));
if ((!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_BRIEF)) || ignore_brief ||
ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH))
{
if(!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOMAP) && can_see_map(ch))
{
ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH)) {
if(!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOMAP) && can_see_map(ch))
str_and_map(world[target_room].description, ch, target_room);
}
else
{
send_to_char(ch, "%s", world[IN_ROOM(ch)].description);
}
else
send_to_char(ch, "%s", world[IN_ROOM(ch)].description);
}
/* autoexits */
@ -1040,7 +1035,7 @@ int search_help(const char *argument, int level)
// if (strn_cmp(argument, help_table[mid].keywords, minlen) || level < help_table[mid].min_level)
if (strn_cmp(argument, help_table[mid].keywords, minlen))
break;
break;
return mid;
}
@ -1481,8 +1476,7 @@ ACMD(do_users)
sprintf(line2, "%s%s%s", CCGRN(ch, C_SPR), line, CCNRM(ch, C_SPR));
strcpy(line, line2);
}
if (STATE(d) != CON_PLAYING ||
(STATE(d) == CON_PLAYING && CAN_SEE(ch, d->character))) {
if (STATE(d) != CON_PLAYING || (STATE(d) == CON_PLAYING && CAN_SEE(ch, d->character))) {
send_to_char(ch, "%s", line);
num_can_see++;
}
@ -2035,7 +2029,7 @@ ACMD(do_toggle)
return;
}
len = strlen(arg);
len = strlen(arg);
for (toggle = 0; *tog_messages[toggle].command != '\n'; toggle++)
if (!strncmp(arg, tog_messages[toggle].command, len))
break;
@ -2043,7 +2037,7 @@ ACMD(do_toggle)
if (*tog_messages[toggle].command == '\n' || tog_messages[toggle].min_level > GET_LEVEL(ch)) {
send_to_char(ch, "You can't toggle that!\r\n");
return;
}
}
switch (toggle) {
case SCMD_COLOR:
@ -2093,13 +2087,13 @@ ACMD(do_toggle)
}
result = PRF_TOG_CHK(ch, PRF_BUILDWALK);
if (PRF_FLAGGED(ch, PRF_BUILDWALK)) {
for (i=0; *arg2 && *(sector_types[i]) != '\n'; i++)
if (is_abbrev(arg2, sector_types[i]))
break;
if (*(sector_types[i]) == '\n')
i=0;
GET_BUILDWALK_SECTOR(ch) = i;
send_to_char(ch, "Default sector type is %s\r\n", sector_types[i]);
for (i=0; *arg2 && *(sector_types[i]) != '\n'; i++)
if (is_abbrev(arg2, sector_types[i]))
break;
if (*(sector_types[i]) == '\n')
i=0;
GET_BUILDWALK_SECTOR(ch) = i;
send_to_char(ch, "Default sector type is %s\r\n", sector_types[i]);
mudlog(CMP, GET_LEVEL(ch), TRUE,
"OLC: %s turned buildwalk on. Allowed zone %d", GET_NAME(ch), GET_OLC_ZONE(ch));
} else
@ -2393,40 +2387,29 @@ ACMD(do_whois)
send_to_char(ch, "Level: %d\r\n", GET_LEVEL(victim));
if (!(GET_LEVEL(victim) < LVL_IMMORT) || (GET_LEVEL(ch) >= GET_LEVEL(victim)))
{
if (!(GET_LEVEL(victim) < LVL_IMMORT) || (GET_LEVEL(ch) >= GET_LEVEL(victim))) {
strcpy (buf, (char *) asctime(localtime(&(victim->player.time.logon))));
buf[10] = '\0';
hours = (time(0) - victim->player.time.logon) / 3600;
if (!got_from_file)
{
if (!got_from_file) {
send_to_char(ch, "Last Logon: They're playing now! (Idle %d Minutes)",
victim->char_specials.timer * SECS_PER_MUD_HOUR / SECS_PER_REAL_MIN);
if (!victim->desc)
{
send_to_char(ch, " (Linkless)\r\n");
}
else
{
send_to_char(ch, "\r\n");
}
if (PRF_FLAGGED(victim, PRF_AFK))
{
send_to_char(ch, "%s%s is afk right now, so %s may not respond to communication.%s\r\n", CBGRN(ch, C_NRM), GET_NAME(victim), GET_SEX(victim) == SEX_NEUTRAL ? "it" : (GET_SEX(victim) == SEX_MALE ? "he" : "she"), CCNRM(ch, C_NRM));
}
}
else if (hours > 0)
{
send_to_char(ch, "Last Logon: %s (%d days & %d hours ago.)\r\n", buf, hours/24, hours%24);
}
else
{
send_to_char(ch, "Last Logon: %s (0 hours & %d minutes ago.)\r\n",
buf, (int)(time(0) - victim->player.time.logon)/60);
}
}
if (has_mail(GET_IDNUM(victim)))

View file

@ -385,19 +385,19 @@ static int find_door(struct char_data *ch, const char *type, char *dir, const ch
int door;
if (*dir) { /* a direction was specified */
if ((door = search_block(dir, dirs, FALSE)) == -1) { /* Partial Match */
if ((door = search_block(dir, autoexits, FALSE)) == -1) { /* Check 'short' dirs too */
send_to_char(ch, "That's not a direction.\r\n");
return (-1);
}
if ((door = search_block(dir, dirs, FALSE)) == -1) { /* Partial Match */
if ((door = search_block(dir, autoexits, FALSE)) == -1) { /* Check 'short' dirs too */
send_to_char(ch, "That's not a direction.\r\n");
return (-1);
}
}
if (EXIT(ch, door)) { /* Braces added according to indent. -gg */
if (EXIT(ch, door)->keyword) {
if (is_name(type, EXIT(ch, door)->keyword))
return (door);
else {
send_to_char(ch, "I see no %s there.\r\n", type);
return (-1);
if (is_name(type, EXIT(ch, door)->keyword))
return (door);
else {
send_to_char(ch, "I see no %s there.\r\n", type);
return (-1);
}
} else
return (door);
@ -530,7 +530,7 @@ static void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int
if (!obj && ((other_room = EXIT(ch, door)->to_room) != NOWHERE))
if ((back = world[other_room].dir_option[rev_dir[door]]) != NULL)
if (back->to_room != IN_ROOM(ch))
back = NULL;
back = NULL;
switch (scmd) {
case SCMD_OPEN:
@ -573,15 +573,15 @@ static void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int
/* Notify the room. */
if (len < sizeof(buf))
snprintf(buf + len, sizeof(buf) - len, "%s%s.",
obj ? "" : "the ", obj ? "$p" : EXIT(ch, door)->keyword ? "$F" : "door");
obj ? "" : "the ", obj ? "$p" : EXIT(ch, door)->keyword ? "$F" : "door");
if (!obj || IN_ROOM(obj) != NOWHERE)
act(buf, FALSE, ch, obj, obj ? 0 : EXIT(ch, door)->keyword, TO_ROOM);
/* Notify the other room */
if (back && (scmd == SCMD_OPEN || scmd == SCMD_CLOSE))
send_to_room(EXIT(ch, door)->to_room, "The %s is %s%s from the other side.\r\n",
back->keyword ? fname(back->keyword) : "door", cmd_door[scmd],
scmd == SCMD_CLOSE ? "d" : "ed");
back->keyword ? fname(back->keyword) : "door", cmd_door[scmd],
scmd == SCMD_CLOSE ? "d" : "ed");
}
static int ok_pick(struct char_data *ch, obj_vnum keynum, int pickproof, int scmd)
@ -646,14 +646,11 @@ ACMD(do_gen_door)
keynum = DOOR_KEY(ch, obj, door);
if (!(DOOR_IS_OPENABLE(ch, obj, door)))
send_to_char(ch, "You can't %s that!\r\n", cmd_door[subcmd]);
else if (!DOOR_IS_OPEN(ch, obj, door) &&
IS_SET(flags_door[subcmd], NEED_OPEN))
else if (!DOOR_IS_OPEN(ch, obj, door) && IS_SET(flags_door[subcmd], NEED_OPEN))
send_to_char(ch, "But it's already closed!\r\n");
else if (!DOOR_IS_CLOSED(ch, obj, door) &&
IS_SET(flags_door[subcmd], NEED_CLOSED))
else if (!DOOR_IS_CLOSED(ch, obj, door) && IS_SET(flags_door[subcmd], NEED_CLOSED))
send_to_char(ch, "But it's currently open!\r\n");
else if (!(DOOR_IS_LOCKED(ch, obj, door)) &&
IS_SET(flags_door[subcmd], NEED_LOCKED))
else if (!(DOOR_IS_LOCKED(ch, obj, door)) && IS_SET(flags_door[subcmd], NEED_LOCKED))
send_to_char(ch, "Oh.. it wasn't locked, after all..\r\n");
else if (!(DOOR_IS_UNLOCKED(ch, obj, door)) && IS_SET(flags_door[subcmd], NEED_UNLOCKED) && ((!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOKEY))) && (has_key(ch, keynum)) )
{
@ -665,12 +662,10 @@ ACMD(do_gen_door)
{
send_to_char(ch, "It is locked, and you do not have the key!\r\n");
}
else if (!(DOOR_IS_UNLOCKED(ch, obj, door)) &&
IS_SET(flags_door[subcmd], NEED_UNLOCKED) &&
else if (!(DOOR_IS_UNLOCKED(ch, obj, door)) && IS_SET(flags_door[subcmd], NEED_UNLOCKED) &&
(GET_LEVEL(ch) < LVL_IMMORT || (!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_NOHASSLE))))
send_to_char(ch, "It seems to be locked.\r\n");
else if (!has_key(ch, keynum) && (GET_LEVEL(ch) < LVL_GOD) &&
((subcmd == SCMD_LOCK) || (subcmd == SCMD_UNLOCK)))
else if (!has_key(ch, keynum) && (GET_LEVEL(ch) < LVL_GOD) && ((subcmd == SCMD_LOCK) || (subcmd == SCMD_UNLOCK)))
send_to_char(ch, "You don't seem to have the proper key.\r\n");
else if (ok_pick(ch, keynum, DOOR_IS_PICKPROOF(ch, obj, door), subcmd))
do_doorcmd(ch, obj, door, subcmd);
@ -689,11 +684,11 @@ ACMD(do_enter)
* keyword */
for (door = 0; door < DIR_COUNT; door++)
if (EXIT(ch, door))
if (EXIT(ch, door)->keyword)
if (!str_cmp(EXIT(ch, door)->keyword, buf)) {
perform_move(ch, door, 1);
return;
}
if (EXIT(ch, door)->keyword)
if (!str_cmp(EXIT(ch, door)->keyword, buf)) {
perform_move(ch, door, 1);
return;
}
send_to_char(ch, "There is no %s here.\r\n", buf);
} else if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_INDOORS))
send_to_char(ch, "You are already indoors.\r\n");
@ -959,17 +954,17 @@ ACMD(do_follow)
} else { /* Not Charmed follow person */
if (leader == ch) {
if (!ch->master) {
send_to_char(ch, "You are already following yourself.\r\n");
return;
send_to_char(ch, "You are already following yourself.\r\n");
return;
}
stop_follower(ch);
} else {
if (circle_follow(ch, leader)) {
send_to_char(ch, "Sorry, but following in loops is not allowed.\r\n");
return;
send_to_char(ch, "Sorry, but following in loops is not allowed.\r\n");
return;
}
if (ch->master)
stop_follower(ch);
stop_follower(ch);
REMOVE_BIT_AR(AFF_FLAGS(ch), AFF_GROUP);
add_follower(ch, leader);
}

View file

@ -83,7 +83,7 @@ ACMD(do_hit)
act("$N is just such a good friend, you simply can't hit $M.", FALSE, ch, 0, vict, TO_CHAR);
else {
if (!CONFIG_PK_ALLOWED && !IS_NPC(vict) && !IS_NPC(ch))
check_killer(ch, vict);
check_killer(ch, vict);
if ((GET_POS(ch) == POS_STANDING) && (vict != FIGHTING(ch))) {
if (GET_DEX(ch) > GET_DEX(vict) || (GET_DEX(ch) == GET_DEX(vict) && rand_number(1, 2) == 1)) /* if faster */
@ -203,10 +203,10 @@ ACMD(do_order)
act("$n gives $N an order.", FALSE, ch, 0, vict, TO_ROOM);
if ((vict->master != ch) || !AFF_FLAGGED(vict, AFF_CHARM))
act("$n has an indifferent look.", FALSE, vict, 0, 0, TO_ROOM);
act("$n has an indifferent look.", FALSE, vict, 0, 0, TO_ROOM);
else {
send_to_char(ch, "%s", CONFIG_OK);
command_interpreter(vict, message);
send_to_char(ch, "%s", CONFIG_OK);
command_interpreter(vict, message);
}
} else { /* This is order "followers" */
char buf[MAX_STRING_LENGTH];
@ -215,16 +215,16 @@ ACMD(do_order)
act(buf, FALSE, ch, 0, 0, TO_ROOM);
for (k = ch->followers; k; k = k->next) {
if (IN_ROOM(ch) == IN_ROOM(k->follower))
if (AFF_FLAGGED(k->follower, AFF_CHARM)) {
found = TRUE;
command_interpreter(k->follower, message);
}
if (IN_ROOM(ch) == IN_ROOM(k->follower))
if (AFF_FLAGGED(k->follower, AFF_CHARM)) {
found = TRUE;
command_interpreter(k->follower, message);
}
}
if (found)
send_to_char(ch, "%s", CONFIG_OK);
send_to_char(ch, "%s", CONFIG_OK);
else
send_to_char(ch, "Nobody here is a loyal subject of yours!\r\n");
send_to_char(ch, "Nobody here is a loyal subject of yours!\r\n");
}
}
}

View file

@ -811,15 +811,15 @@ ACMD(do_gen_tog)
}
result = PRF_TOG_CHK(ch, PRF_BUILDWALK);
if (PRF_FLAGGED(ch, PRF_BUILDWALK)) {
one_argument(argument, arg);
for (i=0; *arg && *(sector_types[i]) != '\n'; i++)
if (is_abbrev(arg, sector_types[i]))
break;
if (*(sector_types[i]) == '\n')
i=0;
GET_BUILDWALK_SECTOR(ch) = i;
send_to_char(ch, "Default sector type is %s\r\n", sector_types[i]);
one_argument(argument, arg);
for (i=0; *arg && *(sector_types[i]) != '\n'; i++)
if (is_abbrev(arg, sector_types[i]))
break;
if (*(sector_types[i]) == '\n')
i=0;
GET_BUILDWALK_SECTOR(ch) = i;
send_to_char(ch, "Default sector type is %s\r\n", sector_types[i]);
mudlog(CMP, GET_LEVEL(ch), TRUE,
"OLC: %s turned buildwalk on. Allowed zone %d", GET_NAME(ch), GET_OLC_ZONE(ch));
} else

View file

@ -2719,7 +2719,7 @@ ACMD(do_show)
/* show thaco */
case 11:
len = strlcpy(buf, "LvL - Mu Cl Th Wa\r\n----------------\r\n", sizeof(buf));
for (j = 1; j < LVL_IMMORT; j++) {
nlen = snprintf(buf + len, sizeof(buf) - len, "%-3d - %-2d %-2d %-2d %-2d\r\n", j,
thaco(CLASS_MAGIC_USER, j),
@ -2728,43 +2728,43 @@ ACMD(do_show)
thaco(CLASS_WARRIOR, j));
if (len + nlen >= sizeof(buf))
break;
len += nlen;
}
page_string(ch->desc, buf, TRUE);
len += nlen;
}
page_string(ch->desc, buf, TRUE);
break;
/* show experience tables */
case 12:
len = strlcpy(buf, "LvL - Mu Cl Th Wa\r\n--------------------------\r\n", sizeof(buf));
for (i = 1; i < LVL_IMMORT; i++) {
nlen = snprintf(buf + len, sizeof(buf) - len, "%-3d - %-6d %-6d %-6d %-6d\r\n", i,
for (i = 1; i < LVL_IMMORT; i++) {
nlen = snprintf(buf + len, sizeof(buf) - len, "%-3d - %-6d %-6d %-6d %-6d\r\n", i,
level_exp(CLASS_MAGIC_USER, i) - level_exp(CLASS_MAGIC_USER, i - 1),
level_exp(CLASS_CLERIC, i) - level_exp(CLASS_CLERIC, i - 1),
level_exp(CLASS_THIEF, i) - level_exp(CLASS_THIEF, i - 1),
level_exp(CLASS_WARRIOR, i) - level_exp(CLASS_WARRIOR, i - 1));
if (len + nlen >= sizeof(buf))
break;
len += nlen;
if (len + nlen >= sizeof(buf))
break;
len += nlen;
}
page_string(ch->desc, buf, TRUE);
page_string(ch->desc, buf, TRUE);
break;
case 13:
len = strlcpy(buf, "Colours\r\n--------------------------\r\n", sizeof(buf));
k = 0;
k = 0;
for (r = 0; r < 6; r++)
for (g = 0; g < 6; g++)
for (b = 0; b < 6; b++) {
sprintf(colour, "F%d%d%d", r, g, b);
nlen = snprintf(buf + len, sizeof(buf) - len, "%s%s%s", ColourRGB(ch->desc, colour), colour, ++k % 6 == 0 ? "\tn\r\n" : " ");
if (len + nlen >= sizeof(buf))
break;
len += nlen;
}
page_string(ch->desc, buf, TRUE);
for (g = 0; g < 6; g++)
for (b = 0; b < 6; b++) {
sprintf(colour, "F%d%d%d", r, g, b);
nlen = snprintf(buf + len, sizeof(buf) - len, "%s%s%s", ColourRGB(ch->desc, colour), colour, ++k % 6 == 0 ? "\tn\r\n" : " ");
if (len + nlen >= sizeof(buf))
break;
len += nlen;
}
page_string(ch->desc, buf, TRUE);
break;
/* show what? */

View file

@ -86,7 +86,7 @@ int item_in_list(char *item, obj_data *list)
int count = 0;
if (!item || !*item)
return 0;
return 0;
if (*item == UID_CHAR) {
long id = atol(item + 1);
@ -218,7 +218,7 @@ int text_processed(char *field, char *subfield, struct trig_var_data *vd,
if (cindex > len || cindex < 1)
strcpy(str, "");
else
snprintf(str, slen, "%c", vd->value[cindex - 1]);
snprintf(str, slen, "%c", vd->value[cindex - 1]);
return TRUE;
} else if (!str_cmp(field, "mudcommand")) {
/* find the mud command returned from this text */
@ -658,13 +658,13 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
if (subfield && *subfield) {
int addition = atoi(subfield);
GET_DAMROLL(c) = MAX(1, GET_DAMROLL(c) + addition);
}
snprintf(str, slen, "%d", GET_DAMROLL(c));
} else if (!str_cmp(field, "dex")) {
if (subfield && *subfield) {
int addition = atoi(subfield);
}
snprintf(str, slen, "%d", GET_DAMROLL(c));
} else if (!str_cmp(field, "dex")) {
if (subfield && *subfield) {
int addition = atoi(subfield);
int max = (IS_NPC(c) || GET_LEVEL(c) >= LVL_GRGOD) ? 25 : 18;
GET_DEX(c) += addition;
GET_DEX(c) += addition;
if (GET_DEX(c) > max) GET_DEX(c) = max;
if (GET_DEX(c) < 3) GET_DEX(c) = 3;
}
@ -673,7 +673,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
else if (!str_cmp(field, "drunk")) {
if (subfield && *subfield) {
int addition = atoi(subfield);
GET_COND(c, DRUNK) = MAX(-1, MIN(addition, 24));
GET_COND(c, DRUNK) = MAX(-1, MIN(addition, 24));
}
snprintf(str, slen, "%d", GET_COND(c, DRUNK));
}
@ -760,12 +760,12 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
snprintf(str, slen, "%d", GET_HIT(c));
}
else if (!str_cmp(field, "hitroll")) {
if (subfield && *subfield) {
int addition = atoi(subfield);
GET_HITROLL(c) = MAX(1, GET_HITROLL(c) + addition);
}
snprintf(str, slen, "%d", GET_HITROLL(c));
}
if (subfield && *subfield) {
int addition = atoi(subfield);
GET_HITROLL(c) = MAX(1, GET_HITROLL(c) + addition);
}
snprintf(str, slen, "%d", GET_HITROLL(c));
}
else if (!str_cmp(field, "hunger")) {
if (subfield && *subfield) {
int addition = atoi(subfield);
@ -844,7 +844,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
GET_LEVEL(c) = MIN(MAX(lev, 0), LVL_IMMORT-1);
} else
snprintf(str, slen, "%d", GET_LEVEL(c));
}
}
break;
case 'm':
if (!str_cmp(field, "mana")) {
@ -1202,7 +1202,7 @@ o->contains));
snprintf(str, slen, "%s", (item_in_list(subfield,
o->contains) ? "1" : "0"));
else
strcpy(str, "0");
strcpy(str, "0");
}
else if (!str_cmp(field, "hasattached")) {
if (!(subfield && *subfield))

View file

@ -1235,18 +1235,18 @@ int enter_player_game (struct descriptor_data *d)
/* We have to place the character in a room before equipping them
* or equip_char() will gripe about the person in NOWHERE. */
if ((load_room = GET_LOADROOM(d->character)) != NOWHERE)
load_room = real_room(load_room);
load_room = real_room(load_room);
/* If char was saved with NOWHERE, or real_room above failed... */
if (load_room == NOWHERE) {
if (GET_LEVEL(d->character) >= LVL_IMMORT)
load_room = r_immort_start_room;
else
load_room = r_mortal_start_room;
if (GET_LEVEL(d->character) >= LVL_IMMORT)
load_room = r_immort_start_room;
else
load_room = r_mortal_start_room;
}
if (PLR_FLAGGED(d->character, PLR_FROZEN))
load_room = r_frozen_start_room;
load_room = r_frozen_start_room;
/* copyover */
GET_ID(d->character) = GET_IDNUM(d->character);
@ -1276,38 +1276,38 @@ int enter_player_game (struct descriptor_data *d)
EVENTFUNC(get_protocols)
{
struct descriptor_data *d;
struct mud_event_data *pMudEvent;
char buf[MAX_STRING_LENGTH];
int len;
if (event_obj == NULL)
return 0;
pMudEvent = (struct mud_event_data *) event_obj;
d = (struct descriptor_data *) pMudEvent->pStruct;
/* Clear extra white space from the "protocol scroll" */
write_to_output(d, "");
struct descriptor_data *d;
struct mud_event_data *pMudEvent;
char buf[MAX_STRING_LENGTH];
int len;
len = snprintf(buf, MAX_STRING_LENGTH, "\tO[\toClient\tO] \tw%s\tn | ", d->pProtocol->pVariables[eMSDP_CLIENT_ID]->pValueString);
if (d->pProtocol->pVariables[eMSDP_XTERM_256_COLORS]->ValueInt)
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toColors\tO] \tw256\tn | ");
else if (d->pProtocol->pVariables[eMSDP_ANSI_COLORS]->ValueInt)
if (event_obj == NULL)
return 0;
pMudEvent = (struct mud_event_data *) event_obj;
d = (struct descriptor_data *) pMudEvent->pStruct;
/* Clear extra white space from the "protocol scroll" */
write_to_output(d, "");
len = snprintf(buf, MAX_STRING_LENGTH, "\tO[\toClient\tO] \tw%s\tn | ", d->pProtocol->pVariables[eMSDP_CLIENT_ID]->pValueString);
if (d->pProtocol->pVariables[eMSDP_XTERM_256_COLORS]->ValueInt)
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toColors\tO] \tw256\tn | ");
else if (d->pProtocol->pVariables[eMSDP_ANSI_COLORS]->ValueInt)
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toColors\tO] \twAnsi\tn | ");
else
else
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "[Colors] No Color | ");
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toMXP\tO] \tw%s\tn | ", d->pProtocol->bMXP ? "Yes" : "No");
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toMSDP\tO] \tw%s\tn | ", d->pProtocol->bMSDP ? "Yes" : "No");
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toATCP\tO] \tw%s\tn\r\n\r\n", d->pProtocol->bATCP ? "Yes" : "No");
write_to_output(d, buf, 0);
write_to_output(d, GREETINGS, 0);
STATE(d) = CON_GET_NAME;
return 0;
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toMXP\tO] \tw%s\tn | ", d->pProtocol->bMXP ? "Yes" : "No");
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toMSDP\tO] \tw%s\tn | ", d->pProtocol->bMSDP ? "Yes" : "No");
len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toATCP\tO] \tw%s\tn\r\n\r\n", d->pProtocol->bATCP ? "Yes" : "No");
write_to_output(d, buf, 0);
write_to_output(d, GREETINGS, 0);
STATE(d) = CON_GET_NAME;
return 0;
}
/* deal with newcomers and other non-playing sockets */
@ -1348,9 +1348,9 @@ void nanny(struct descriptor_data *d, char *arg)
/* Not in OLC. */
switch (STATE(d)) {
case CON_GET_PROTOCOL:
write_to_output(d, "Collecting Protocol Information... Please Wait.\r\n");
return;
break;
write_to_output(d, "Collecting Protocol Information... Please Wait.\r\n");
return;
break;
case CON_GET_NAME: /* wait for input of name */
if (d->character == NULL) {
CREATE(d->character, struct char_data, 1);

View file

@ -33,19 +33,19 @@ struct list_data * create_list(void)
else
first_list = FALSE;
return (pNewList);
return (pNewList);
}
struct item_data * create_item(void)
{
struct item_data *pNewItem;
CREATE(pNewItem, struct item_data, 1);
pNewItem->pNextItem = NULL;
pNewItem->pPrevItem = NULL;
pNewItem->pContent = NULL;
return (pNewItem);
}
@ -76,15 +76,15 @@ void add_to_list(void * pContent, struct list_data * pList)
/* Allocate our memory */
pNewItem = create_item();
/* Place the contents in the item */
pNewItem->pContent = pContent;
pNewItem->pNextItem = NULL;
/* If we are the first entry in the list, mark us as such */
if (pList->pFirstItem == NULL)
pList->pFirstItem = pNewItem;
/* Grab our last item from the list and attach it to our new item */
if (pList->pLastItem) {
pLastItem = pList->pLastItem;
@ -94,39 +94,37 @@ void add_to_list(void * pContent, struct list_data * pList)
/* Make our new item our last item in the list */
pList->pLastItem = pNewItem;
pList->iSize++;
}
void remove_from_list(void * pContent, struct list_data * pList)
{
struct item_data *pRemovedItem;
if ((pRemovedItem = find_in_list(pContent, pList)) == NULL) {
mudlog(CMP, LVL_GOD, TRUE, "SYSERR: Attempting to remove contents that don't exist in list.");
return;
}
if (pRemovedItem == pList->pFirstItem)
pList->pFirstItem = pRemovedItem->pNextItem;
if (pRemovedItem == pList->pLastItem)
pList->pLastItem = pRemovedItem->pPrevItem;
if (pRemovedItem->pPrevItem)
pRemovedItem->pPrevItem->pNextItem = pRemovedItem->pNextItem;
if (pRemovedItem->pNextItem)
pRemovedItem->pNextItem->pPrevItem = pRemovedItem->pPrevItem;
pList->iSize--;
if (pList->iSize == 0) {
pList->pFirstItem = NULL;
pList->pLastItem = NULL;
}
free(pRemovedItem);
free(pRemovedItem);
}
/** Merges an iterator with a list
@ -136,7 +134,7 @@ void remove_from_list(void * pContent, struct list_data * pList)
void * merge_iterator(struct iterator_data * pIterator, struct list_data * pList)
{
void * pContent;
if (pList == NULL) {
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: Attempting to merge iterator to NULL list.");
pIterator->pList = NULL;
@ -149,13 +147,13 @@ void * merge_iterator(struct iterator_data * pIterator, struct list_data * pList
pIterator->pItem = NULL;
return NULL;
}
pList->iIterators++;
pIterator->pList = pList;
pIterator->pItem = pList->pFirstItem;
pContent = pIterator->pItem ? pIterator->pItem->pContent : NULL;
return (pContent);
}
@ -163,9 +161,9 @@ void remove_iterator(struct iterator_data * pIterator)
{
if (pIterator->pList == NULL) {
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: Attempting to remove iterator from NULL list.");
return;
return;
}
pIterator->pList->iIterators--;
pIterator->pList = NULL;
pIterator->pItem = NULL;
@ -179,19 +177,19 @@ void * next_in_list(struct iterator_data * pIterator)
{
void * pContent;
struct item_data * pTempItem;
if (pIterator->pList == NULL) {
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: Attempting to get content from iterator with NULL list.");
return NULL;
}
/* Cycle down the list */
pTempItem = pIterator->pItem->pNextItem;
pIterator->pItem = pTempItem;
/* Grab the content */
pContent = pIterator->pItem ? pIterator->pItem->pContent : NULL;
return (pContent);
}
@ -206,21 +204,21 @@ struct item_data * find_in_list(void * pContent, struct list_data * pList)
void * pFoundItem;
struct item_data *pItem = NULL;
bool found;
pFoundItem = merge_iterator(&Iterator, pList);
for (found = FALSE; pFoundItem != NULL; pFoundItem = next_in_list(&Iterator)) {
if (pFoundItem == pContent) {
found = TRUE;
break;
}
}
if (found)
pItem = Iterator.pItem;
remove_iterator(&Iterator);
if (found)
return (pItem);
else
@ -245,18 +243,18 @@ void * simple_list(struct list_data * pList)
static bool loop = FALSE;
static struct list_data *pLastList = NULL;
void * pContent;
/* Reset List */
if (pList == NULL) {
loop = FALSE;
pLastList = NULL;
return NULL;
}
/* Reset List */
if (pList == NULL) {
loop = FALSE;
pLastList = NULL;
return NULL;
}
if (!loop || pLastList != pList) {
if (loop && pLastList != pList)
mudlog(CMP, LVL_GRGOD, TRUE, "SYSERR: simple_list() forced to reset itself.");
pContent = merge_iterator(&Iterator, pList);
if (pContent != NULL) {
pLastList = pList;
@ -268,7 +266,7 @@ void * simple_list(struct list_data * pList)
if ((pContent = next_in_list(&Iterator)) != NULL)
return (pContent);
remove_iterator(&Iterator);
loop = FALSE;
return NULL;
@ -281,23 +279,23 @@ void * random_from_list(struct list_data * pList)
bool found;
int number;
int count = 1;
if (pList->iSize <= 0)
return NULL;
else
number = rand_number(1, pList->iSize);
pFoundItem = merge_iterator(&Iterator, pList);
for (found = FALSE; pFoundItem != NULL; pFoundItem = next_in_list(&Iterator), count++) {
if (count == number) {
found = TRUE;
break;
}
}
remove_iterator(&Iterator);
if (found)
return (pFoundItem);
else

View file

@ -54,17 +54,17 @@ 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;
@ -84,7 +84,7 @@ void attach_mud_event(struct mud_event_data *pMudEvent, long time)
struct char_data * ch;
pEvent = event_create(mud_event_index[pMudEvent->iId].func, pMudEvent, time);
pEvent->isMudEvent = TRUE;
pEvent->isMudEvent = TRUE;
pMudEvent->pEvent = pEvent;
switch (mud_event_index[pMudEvent->iId].iEvent_Type) {
@ -106,16 +106,16 @@ struct mud_event_data *new_mud_event(event_id iId, void *pStruct, char *sVariabl
{
struct mud_event_data *pMudEvent;
char *varString;
CREATE(pMudEvent, struct mud_event_data, 1);
varString = (sVariables != NULL) ? strdup(sVariables) : NULL;
varString = (sVariables != NULL) ? strdup(sVariables) : NULL;
pMudEvent->iId = iId;
pMudEvent->pStruct = pStruct;
pMudEvent->sVariables = varString;
pMudEvent->pEvent = NULL;
return (pMudEvent);
return (pMudEvent);
}
void free_mud_event(struct mud_event_data *pMudEvent)
@ -139,7 +139,7 @@ void free_mud_event(struct mud_event_data *pMudEvent)
if (pMudEvent->sVariables != NULL)
free(pMudEvent->sVariables);
pMudEvent->pEvent->event_obj = NULL;
free(pMudEvent);
}
@ -154,14 +154,14 @@ struct mud_event_data * char_has_mud_event(struct char_data * ch, event_id iId)
return NULL;
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;
if (!pEvent->isMudEvent)
continue;
pMudEvent = (struct mud_event_data * ) pEvent->event_obj;
if (pMudEvent->iId == iId) {
found = TRUE;
break;
}
}

View file

@ -78,18 +78,18 @@ static void prefedit_save_to_char(struct descriptor_data *d)
}
else
{
if (!vict) {
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: Unable to save toggles (no vict)");
send_to_char(d->character, "Unable to save toggles (no vict)");
} else if (!vict->desc) {
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: Unable to save toggles (no vict descriptor)");
send_to_char(d->character, "Unable to save toggles (no vict descriptor)");
} else if (!IS_PLAYING(vict->desc)) {
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: Unable to save toggles (vict not playing)");
send_to_char(d->character, "Unable to save toggles (vict not playing)");
} else {
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: Unable to save toggles (unknown reason)");
send_to_char(d->character, "Unable to save toggles (unknown reason)");
if (!vict) {
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: Unable to save toggles (no vict)");
send_to_char(d->character, "Unable to save toggles (no vict)");
} else if (!vict->desc) {
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: Unable to save toggles (no vict descriptor)");
send_to_char(d->character, "Unable to save toggles (no vict descriptor)");
} else if (!IS_PLAYING(vict->desc)) {
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: Unable to save toggles (vict not playing)");
send_to_char(d->character, "Unable to save toggles (vict not playing)");
} else {
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: Unable to save toggles (unknown reason)");
send_to_char(d->character, "Unable to save toggles (unknown reason)");
}
}
}

View file

@ -334,7 +334,7 @@ void ProtocolDestroy( protocol_t *apProtocol )
for ( i = eMSDP_NONE+1; i < eMSDP_MAX; ++i )
{
if (apProtocol->pVariables[i]->pValueString)
if (apProtocol->pVariables[i]->pValueString)
free(apProtocol->pVariables[i]->pValueString);
free(apProtocol->pVariables[i]);
}
@ -1402,7 +1402,7 @@ const char *ColourRGB( descriptor_t *apDescriptor, const char *apRGB )
bool charHasColor = TRUE;
if (apDescriptor->character && !clr(apDescriptor->character, C_CMP))
charHasColor = FALSE;
charHasColor = FALSE;
if ( pProtocol && pProtocol->pVariables[eMSDP_ANSI_COLORS]->ValueInt && charHasColor )
{