Merge branch 'master' into feature/unittesting

# Conflicts:
#	.gitignore
#	src/Makefile.in
This commit is contained in:
Thomas Arp 2025-07-02 22:49:38 +02:00
commit b76945f1ff
45 changed files with 1933 additions and 619 deletions

View file

@ -20,8 +20,8 @@ CFLAGS = @CFLAGS@ $(MYFLAGS) $(PROFILE)
LIBS = @LIBS@ @CRYPTLIB@ @NETLIB@
SRCFILES := act.comm.c act.informative.c act.item.c act.movement.c act.offensive.c act.other.c act.social.c act.wizard.c aedit.c asciimap.c ban.c boards.c bsd-snprintf.c castle.c cedit.c class.c comm.c config.c constants.c db.c dg_comm.c dg_db_scripts.c dg_event.c dg_handler.c dg_misc.c dg_mobcmd.c dg_objcmd.c dg_olc.c dg_scripts.c dg_triggers.c dg_variables.c dg_wldcmd.c fight.c genmob.c genobj.c genolc.c genqst.c genshp.c genwld.c genzon.c graph.c handler.c hedit.c house.c ibt.c improved-edit.c interpreter.c limits.c lists.c magic.c mail.c main.c medit.c mobact.c modify.c msgedit.c mud_event.c oasis.c oasis_copy.c oasis_delete.c oasis_list.c objsave.c oedit.c players.c prefedit.c protocol.c qedit.c quest.c random.c redit.c sedit.c shop.c spec_assign.c spec_procs.c spell_parser.c spells.c tedit.c utils.c weather.c zedit.c zmalloc.c
OBJFILES := act.comm.o act.informative.o act.item.o act.movement.o act.offensive.o act.other.o act.social.o act.wizard.o aedit.o asciimap.o ban.o boards.o bsd-snprintf.o castle.o cedit.o class.o comm.o config.o constants.o db.o dg_comm.o dg_db_scripts.o dg_event.o dg_handler.o dg_misc.o dg_mobcmd.o dg_objcmd.o dg_olc.o dg_scripts.o dg_triggers.o dg_variables.o dg_wldcmd.o fight.o genmob.o genobj.o genolc.o genqst.o genshp.o genwld.o genzon.o graph.o handler.o hedit.o house.o ibt.o improved-edit.o interpreter.o limits.o lists.o magic.o mail.o main.o medit.o mobact.o modify.o msgedit.o mud_event.o oasis.o oasis_copy.o oasis_delete.o oasis_list.o objsave.o oedit.o players.o prefedit.o protocol.o qedit.o quest.o random.o redit.o sedit.o shop.o spec_assign.o spec_procs.o spell_parser.o spells.o tedit.o utils.o weather.o zedit.o zmalloc.o
SRCFILES := $(shell ls *.c | sort)
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
default: all
@ -32,10 +32,6 @@ all: .accepted
.accepted:
@./licheck @MORE@
.PHONY: test
test:
(cd test; $(MAKE) all)
utils: .accepted
(cd util; $(MAKE) all)
@ -50,7 +46,6 @@ $%.o: %.c
clean:
rm -f *.o depend
(cd test; $(MAKE) clean)
# Dependencies for the object files (automagically generated with
# gcc -MM)

56
src/Makefile.macOS Normal file
View file

@ -0,0 +1,56 @@
# tbaMUD Makefile.in - Makefile template used by 'configure'
# Clean-up provided by seqwith.
# C compiler to use
CC = gcc
# Any special flags you want to pass to the compiler
MYFLAGS = -Wall -Wno-char-subscripts -Wno-invalid-source-encoding -DMEMORY_DEBUG
#flags for profiling (see hacker.doc for more information)
PROFILE =
##############################################################################
# Do Not Modify Anything Below This Line (unless you know what you're doing) #
##############################################################################
BINDIR = ../bin
CFLAGS = -g -O0 $(MYFLAGS) $(PROFILE)
LIBS =
SRCFILES := $(shell ls *.c | sort)
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
default: all
all: .accepted
$(MAKE) $(BINDIR)/circle
$(MAKE) utils
.accepted:
@./licheck less
utils: .accepted
(cd util; $(MAKE) all)
circle:
$(MAKE) $(BINDIR)/circle
$(BINDIR)/circle : $(OBJFILES)
$(CC) -o $(BINDIR)/circle $(PROFILE) $(OBJFILES) $(LIBS)
$%.o: %.c
$(CC) $< $(CFLAGS) -c -o $@
clean:
rm -f *.o depend
# Dependencies for the object files (automagically generated with
# gcc -MM)
depend:
$(CC) -MM *.c > depend
-include depend

View file

@ -150,39 +150,7 @@ ACMD(do_tell)
if (!*buf || !*buf2)
send_to_char(ch, "Who do you wish to tell what??\r\n");
else if (!strcmp(buf, "m-w")) {
#ifdef CIRCLE_WINDOWS
/* getpid() is not portable */
send_to_char(ch, "Sorry, that is not available in the windows port.\r\n");
#else /* all other configurations */
char word[MAX_INPUT_LENGTH], *p, *q;
if (last_webster_teller != -1L) {
if (GET_IDNUM(ch) == last_webster_teller) {
send_to_char(ch, "You are still waiting for a response.\r\n");
return;
} else {
send_to_char(ch, "Hold on, m-w is busy. Try again in a couple of seconds.\r\n");
return;
}
}
/* Only a-z and +/- allowed. */
for (p = buf2, q = word; *p ; p++)
if ((LOWER(*p) <= 'z' && LOWER(*p) >= 'a') || (*p == '+') || (*p == '-'))
*q++ = *p;
*q = '\0';
if (!*word) {
send_to_char(ch, "Sorry, only letters and +/- are allowed characters.\r\n");
return;
}
snprintf(buf, sizeof(buf), "../bin/webster %s %d &", word, (int) getpid());
last_webster_teller = GET_IDNUM(ch);
send_to_char(ch, "You look up '%s' in Merriam-Webster.\r\n", word);
#endif /* platform specific part */
} else if (GET_LEVEL(ch) < LVL_IMMORT && !(vict = get_player_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
else if (GET_LEVEL(ch) < LVL_IMMORT && !(vict = get_player_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (GET_LEVEL(ch) >= LVL_IMMORT && !(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
send_to_char(ch, "%s", CONFIG_NOPERSON);

View file

@ -46,10 +46,10 @@ static void list_obj_to_char(struct obj_data *list, struct char_data *ch, int mo
static void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode);
static void show_obj_modifiers(struct obj_data *obj, struct char_data *ch);
/* do_where utility functions */
static void perform_immort_where(struct char_data *ch, char *arg);
static void perform_immort_where(char_data *ch, const char *arg);
static void perform_mortal_where(struct char_data *ch, char *arg);
static void print_object_location(int num, struct obj_data *obj, struct char_data *ch, int recur);
static size_t print_object_location(int num, const obj_data *obj, const char_data *ch,
char *buf, size_t len, size_t buf_size, int recur);
/* Subcommands */
/* For show_obj_to_char 'mode'. /-- arbitrary */
#define SHOW_OBJ_LONG 0
@ -1603,41 +1603,71 @@ static void perform_mortal_where(struct char_data *ch, char *arg)
}
}
static void print_object_location(int num, struct obj_data *obj, struct char_data *ch,
int recur)
static size_t print_object_location(const int num, const obj_data *obj, const char_data *ch, // NOLINT(*-no-recursion)
char *buf, size_t len, const size_t buf_size, const int recur)
{
size_t nlen = 0;
if (num > 0)
send_to_char(ch, "O%3d. %-25s%s - ", num, obj->short_description, QNRM);
nlen = snprintf(buf + len, buf_size - len, "O%4d. %-25s%s - ", num, obj->short_description, QNRM);
else
send_to_char(ch, "%33s", " - ");
nlen = snprintf(buf + len, buf_size - len, "%37s", " - ");
len += nlen;
nlen = 0;
if (len > buf_size)
return len; // let the caller know we overflowed
if (SCRIPT(obj)) {
if (!TRIGGERS(SCRIPT(obj))->next)
send_to_char(ch, "[T%d] ", GET_TRIG_VNUM(TRIGGERS(SCRIPT(obj))));
nlen = snprintf(buf + len, buf_size - len, "[T%d] ", GET_TRIG_VNUM(TRIGGERS(SCRIPT(obj))));
else
send_to_char(ch, "[TRIGS] ");
nlen = snprintf(buf + len, buf_size - len, "[TRIGS] ");
}
len += nlen;
if (len > buf_size)
return len; // let the caller know we overflowed
if (IN_ROOM(obj) != NOWHERE)
send_to_char(ch, "[%5d] %s%s\r\n", GET_ROOM_VNUM(IN_ROOM(obj)), world[IN_ROOM(obj)].name, QNRM);
else if (obj->carried_by)
send_to_char(ch, "carried by %s%s\r\n", PERS(obj->carried_by, ch), QNRM);
else if (obj->worn_by)
send_to_char(ch, "worn by %s%s\r\n", PERS(obj->worn_by, ch), QNRM);
else if (obj->in_obj) {
send_to_char(ch, "inside %s%s%s\r\n", obj->in_obj->short_description, QNRM, (recur ? ", which is" : " "));
if (recur)
print_object_location(0, obj->in_obj, ch, recur);
nlen = snprintf(buf + len, buf_size - len, "[%5d] %s%s\r\n", GET_ROOM_VNUM(IN_ROOM(obj)), world[IN_ROOM(obj)].name, QNRM);
else if (obj->carried_by) {
if (PRF_FLAGGED(ch, PRF_SHOWVNUMS))
nlen = snprintf(buf + len, buf_size - len, "carried by [%5d] %s%s\r\n", GET_MOB_VNUM(obj->carried_by), PERS(obj->carried_by, ch), QNRM);
else
nlen = snprintf(buf + len, buf_size - len, "carried by %s%s\r\n", PERS(obj->carried_by, ch), QNRM);
if (PRF_FLAGGED(ch, PRF_VERBOSE) && IN_ROOM(obj->carried_by) != NOWHERE && len + nlen < buf_size)
nlen += snprintf(buf + len + nlen, buf_size - len - nlen, "%37sin [%5d] %s%s\r\n", " - ", GET_ROOM_VNUM(IN_ROOM(obj->carried_by)), world[IN_ROOM(obj->carried_by)].name, QNRM);
} else if (obj->worn_by) {
if (PRF_FLAGGED(ch, PRF_SHOWVNUMS))
nlen = snprintf(buf + len, buf_size - len, "worn by [%5d] %s%s\r\n", GET_MOB_VNUM(obj->worn_by), PERS(obj->worn_by, ch), QNRM);
else
nlen = snprintf(buf + len, buf_size - len, "worn by %s%s\r\n", PERS(obj->worn_by, ch), QNRM);
if (PRF_FLAGGED(ch, PRF_VERBOSE) && IN_ROOM(obj->worn_by) != NOWHERE && len + nlen < buf_size)
nlen += snprintf(buf + len + nlen, buf_size - len - nlen, "%37sin [%5d] %s%s\r\n", " - ", GET_ROOM_VNUM(IN_ROOM(obj->worn_by)), world[IN_ROOM(obj->worn_by)].name, QNRM);
} else if (obj->in_obj) {
nlen = snprintf(buf + len, buf_size - len, "inside %s%s%s\r\n", obj->in_obj->short_description, QNRM, (recur ? ", which is" : " "));
if (recur && nlen + len < buf_size) {
len += nlen;
nlen = 0;
len = print_object_location(0, obj->in_obj, ch, buf, len, buf_size, recur);
}
} else
send_to_char(ch, "in an unknown location\r\n");
nlen = snprintf(buf + len, buf_size - len, "in an unknown location\r\n");
len += nlen;
return len;
}
static void perform_immort_where(struct char_data *ch, char *arg)
static void perform_immort_where(char_data *ch, const char *arg)
{
struct char_data *i;
struct obj_data *k;
char_data *i;
obj_data *k;
struct descriptor_data *d;
int num = 0, found = 0;
int num = 0, found = FALSE; // "num" here needs to match the lookup in do_stat, so "stat 4.sword" finds the right one
const char *error_message = "\r\n***OVERFLOW***\r\n";
char buf[MAX_STRING_LENGTH];
size_t len = 0, nlen = 0;
const size_t buf_size = sizeof(buf) - strlen(error_message) - 1;
if (!*arg) {
send_to_char(ch, "Players Room Location Zone\r\n");
@ -1658,26 +1688,64 @@ static void perform_immort_where(struct char_data *ch, char *arg)
}
}
} else {
if (PRF_FLAGGED(ch, PRF_VERBOSE))
len = snprintf(buf, buf_size, " ### Mob name - Room # Room name\r\n");
for (i = character_list; i; i = i->next)
if (CAN_SEE(ch, i) && IN_ROOM(i) != NOWHERE && isname(arg, i->player.name)) {
found = 1;
send_to_char(ch, "M%3d. %-25s%s - [%5d] %-25s%s", ++num, GET_NAME(i), QNRM,
nlen = snprintf(buf + len, buf_size - len, "M%4d. %-25s%s - [%5d] %-25s%s", ++num, GET_NAME(i), QNRM,
GET_ROOM_VNUM(IN_ROOM(i)), world[IN_ROOM(i)].name, QNRM);
if (len + nlen >= buf_size) {
len += snprintf(buf + len, buf_size - len, "%s", error_message);
break;
}
len += nlen;
if (SCRIPT(i) && TRIGGERS(SCRIPT(i))) {
if (!TRIGGERS(SCRIPT(i))->next)
send_to_char(ch, "[T%d] ", GET_TRIG_VNUM(TRIGGERS(SCRIPT(i))));
nlen = snprintf(buf + len, buf_size - len, "[T%d]", GET_TRIG_VNUM(TRIGGERS(SCRIPT(i))));
else
send_to_char(ch, "[TRIGS] ");
nlen = snprintf(buf + len, buf_size - len, "[TRIGS]");
if (len + nlen >= buf_size) {
snprintf(buf + len, buf_size - len, "%s", error_message);
break;
}
len += nlen;
}
send_to_char(ch, "%s\r\n", QNRM);
nlen = snprintf(buf + len, buf_size - len, "%s\r\n", QNRM);
if (len + nlen >= buf_size) {
snprintf(buf + len, buf_size - len, "%s", error_message);
break;
}
len += nlen;
}
for (num = 0, k = object_list; k; k = k->next)
if (CAN_SEE_OBJ(ch, k) && isname(arg, k->name)) {
found = 1;
print_object_location(++num, k, ch, TRUE);
if (PRF_FLAGGED(ch, PRF_VERBOSE) && len < buf_size) {
nlen = snprintf(buf + len, buf_size - len, " ### Object name Location\r\n");
if (len + nlen >= buf_size) {
snprintf(buf + len, buf_size - len, "%s", error_message);
}
len += nlen;
}
if (len < buf_size) {
for (k = object_list; k; k = k->next) {
if (CAN_SEE_OBJ(ch, k) && isname(arg, k->name)) {
found = 1;
len = print_object_location(++num, k, ch, buf, len, buf_size, TRUE);
if (len >= buf_size) {
snprintf(buf + buf_size, sizeof(buf) - buf_size, "%s", error_message);
break;
}
}
}
}
if (!found)
send_to_char(ch, "Couldn't find any such thing.\r\n");
else
page_string(ch->desc, buf, TRUE);
}
}
@ -1937,6 +2005,9 @@ ACMD(do_toggle)
{"pagelength", 0, 0, "\n", "\n"},
{"screenwidth", 0, 0, "\n", "\n"},
{"color", 0, 0, "\n", "\n"},
{"verbose", PRF_VERBOSE, LVL_IMMORT,
"You will no longer see verbose output in listings.\n",
"You will now see verbose listings.\n"},
{"\n", 0, -1, "\n", "\n"} /* must be last */
};
@ -1950,7 +2021,8 @@ ACMD(do_toggle)
if (!GET_WIMP_LEV(ch))
strcpy(buf2, "OFF"); /* strcpy: OK */
else
sprintf(buf2, "%-3.3d", GET_WIMP_LEV(ch)); /* sprintf: OK */
snprintf(buf2, sizeof(buf2), "%-3.3d", GET_WIMP_LEV(ch)); /* thanks to Ironfist for the fix for the buffer overrun here */
if (GET_LEVEL(ch) == LVL_IMPL) {
send_to_char(ch,
@ -1970,7 +2042,8 @@ ACMD(do_toggle)
" NoHassle: %-3s "
" Holylight: %-3s "
" ShowVnums: %-3s\r\n"
" Syslog: %-3s%s ",
" Syslog: %-3s "
" Verbose: %-3s%s ",
ONOFF(PRF_FLAGGED(ch, PRF_BUILDWALK)),
ONOFF(PRF_FLAGGED(ch, PRF_NOWIZ)),
@ -1979,6 +2052,7 @@ ACMD(do_toggle)
ONOFF(PRF_FLAGGED(ch, PRF_HOLYLIGHT)),
ONOFF(PRF_FLAGGED(ch, PRF_SHOWVNUMS)),
types[(PRF_FLAGGED(ch, PRF_LOG1) ? 1 : 0) + (PRF_FLAGGED(ch, PRF_LOG2) ? 2 : 0)],
ONOFF(PRF_FLAGGED(ch, PRF_VERBOSE)),
GET_LEVEL(ch) == LVL_IMPL ? "" : "\r\n");
}
if (GET_LEVEL(ch) >= LVL_IMPL) {

View file

@ -785,6 +785,9 @@ void name_from_drinkcon(struct obj_data *obj)
if (!obj || (GET_OBJ_TYPE(obj) != ITEM_DRINKCON && GET_OBJ_TYPE(obj) != ITEM_FOUNTAIN))
return;
if (obj->name == obj_proto[GET_OBJ_RNUM(obj)].name)
obj->name = strdup(obj_proto[GET_OBJ_RNUM(obj)].name);
liqname = drinknames[GET_OBJ_VAL(obj, 2)];
remove_from_string(obj->name, liqname);

View file

@ -557,7 +557,7 @@ void aedit_parse(struct descriptor_data * d, char *arg) {
}
if (OLC_ACTION(d)->command)
free(OLC_ACTION(d)->command);
OLC_ACTION(d)->command = strdup(arg);
OLC_ACTION(d)->command = strdup(arg);
break;
@ -566,10 +566,10 @@ void aedit_parse(struct descriptor_data * d, char *arg) {
aedit_disp_menu(d);
return;
}
if (OLC_ACTION(d)->sort_as) {
if (OLC_ACTION(d)->sort_as)
free(OLC_ACTION(d)->sort_as);
OLC_ACTION(d)->sort_as = strdup(arg);
}
OLC_ACTION(d)->sort_as = strdup(arg);
break;
case AEDIT_MIN_CHAR_POS:

View file

@ -104,8 +104,7 @@ unsigned long pulse = 0; /* number of pulses since game start */
ush_int port;
socket_t mother_desc;
int next_tick = SECS_PER_MUD_HOUR; /* Tick countdown */
/* used with do_tell and handle_webster_file utility */
long last_webster_teller = -1L;
/* static local global variable declarations (current file scope only) */
static struct txt_block *bufpool = 0; /* pool of large output buffers */
@ -113,14 +112,11 @@ static int max_players = 0; /* max descriptors available */
static int tics_passed = 0; /* for extern checkpointing */
static struct timeval null_time; /* zero-valued time structure */
static byte reread_wizlist; /* signal: SIGUSR1 */
/* normally signal SIGUSR2, currently orphaned in favor of Webster dictionary
* lookup
static byte emergency_unban;
*/
static byte emergency_unban; /* signal: SIGUSR2 */
static int dg_act_check; /* toggle for act_trigger */
static bool fCopyOver; /* Are we booting in copyover mode? */
static char *last_act_message = NULL;
static byte webster_file_ready = FALSE;/* signal: SIGUSR2 */
/* static local function prototypes (current file scope only) */
static RETSIGTYPE reread_wizlists(int sig);
@ -160,9 +156,6 @@ static int open_logfile(const char *filename, FILE *stderr_fp);
#if defined(POSIX)
static sigfunc *my_signal(int signo, sigfunc *func);
#endif
/* Webster Dictionary Lookup functions */
static RETSIGTYPE websterlink(int sig);
static void handle_webster_file(void);
static void msdp_update(void); /* KaVir plugin*/
@ -959,7 +952,7 @@ void game_loop(socket_t local_mother_desc)
mudlog(CMP, LVL_IMMORT, TRUE, "Signal received - rereading wizlists.");
reboot_wizlists();
}
/* Orphaned right now as signal trapping is used for Webster lookup
if (emergency_unban) {
emergency_unban = FALSE;
mudlog(BRF, LVL_IMMORT, TRUE, "Received SIGUSR2 - completely unrestricting game (emergent)");
@ -967,11 +960,7 @@ void game_loop(socket_t local_mother_desc)
circle_restrict = 0;
num_invalid = 0;
}
*/
if (webster_file_ready) {
webster_file_ready = FALSE;
handle_webster_file();
}
#ifdef CIRCLE_UNIX
/* Update tics_passed for deadlock protection (UNIX only) */
@ -1597,7 +1586,7 @@ static int process_output(struct descriptor_data *t)
result = write_to_descriptor(t->descriptor, osb);
if (result < 0) { /* Oops, fatal error. Bye! */
close_socket(t);
// close_socket(t); // close_socket is called after return of negative result
return (-1);
} else if (result == 0) /* Socket buffer full. Try later. */
return (0);
@ -2233,18 +2222,10 @@ static RETSIGTYPE reread_wizlists(int sig)
reread_wizlist = TRUE;
}
/* Orphaned right now in place of Webster ...
static RETSIGTYPE unrestrict_game(int sig)
{
emergency_unban = TRUE;
}
*/
static RETSIGTYPE websterlink(int sig)
{
webster_file_ready = TRUE;
}
#ifdef CIRCLE_UNIX
@ -2319,7 +2300,7 @@ static void signal_setup(void)
/* user signal 2: unrestrict game. Used for emergencies if you lock
* yourself out of the MUD somehow. */
my_signal(SIGUSR2, websterlink);
my_signal(SIGUSR2, unrestrict_game);
/* set up the deadlock-protection so that the MUD aborts itself if it gets
* caught in an infinite loop for more than 3 minutes. */
@ -2781,45 +2762,6 @@ static void circle_sleep(struct timeval *timeout)
#endif /* CIRCLE_WINDOWS */
static void handle_webster_file(void) {
FILE *fl;
struct char_data *ch = find_char(last_webster_teller);
char retval[MAX_STRING_LENGTH], line[READ_SIZE];
size_t len = 0, nlen = 0;
last_webster_teller = -1L;
if (!ch) /* they quit ? */
return;
fl = fopen("websterinfo", "r");
if (!fl) {
send_to_char(ch, "It seems the dictionary is offline..\r\n");
return;
}
unlink("websterinfo");
get_line(fl, line);
while (!feof(fl)) {
nlen = snprintf(retval + len, sizeof(retval) - len, "%s\r\n", line);
if (len + nlen >= sizeof(retval))
break;
len += nlen;
get_line(fl, line);
}
if (len >= sizeof(retval)) {
const char *overflow = "\r\n**OVERFLOW**\r\n";
strcpy(retval + sizeof(retval) - strlen(overflow) - 1, overflow); /* strcpy: OK */
}
fclose(fl);
send_to_char(ch, "You get this feedback from Merriam-Webster:\r\n");
page_string(ch->desc, retval, 1);
}
/* KaVir's plugin*/
static void msdp_update( void )
{

View file

@ -61,9 +61,6 @@ void game_loop(socket_t mother_desc);
void heartbeat(int heart_pulse);
void copyover_recover(void);
/** webster dictionary lookup */
extern long last_webster_teller;
extern struct descriptor_data *descriptor_list;
extern int buf_largecount;
extern int buf_overflows;

337
src/conf.h.cmake.in Normal file
View file

@ -0,0 +1,337 @@
/* src/conf.h.cmake.in. Used as basis for conf.h when building with cmake */
#ifndef _CONF_H_
#define _CONF_H_
/* Define to empty if the keyword does not work. */
#define const @CONST_KEYWORD@
/* Define if you don't have vprintf but do have _doprnt. */
#cmakedefine HAVE_DOPRNT
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#cmakedefine HAVE_SYS_WAIT_H
/* Define if you have the vprintf function. */
#cmakedefine HAVE_VPRINTF
/* Define to `int' if <sys/types.h> doesn't define. */
#cmakedefine pid_t @pid_t@
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE @RETSIGTYPE@
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#cmakedefine size_t @size_t@
/* Define if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#cmakedefine TIME_WITH_SYS_TIME
/* Define if we're compiling CircleMUD under any type of UNIX system. */
#cmakedefine CIRCLE_UNIX
/* Define if the system is capable of using crypt() to encrypt. */
#cmakedefine CIRCLE_CRYPT
/* Define if we don't have proper support for the system's crypt(). */
#cmakedefine HAVE_UNSAFE_CRYPT
/* Define is the system has struct in_addr. */
#cmakedefine HAVE_STRUCT_IN_ADDR
/* Define to `int' if <sys/socket.h> doesn't define. */
#cmakedefine socklen_t @socklen_t@
/* Define to `int' if <sys/types.h> doesn't define. */
#cmakedefine ssize_t @ssize_t@
/* Define if you have the gettimeofday function. */
#cmakedefine HAVE_GETTIMEOFDAY
/* Define if you have the inet_addr function. */
#cmakedefine HAVE_INET_ADDR
/* Define if you have the inet_aton function. */
#cmakedefine HAVE_INET_ATON
/* Define if you have the select function. */
#cmakedefine HAVE_SELECT
/* Define if you have the snprintf function. */
#cmakedefine HAVE_SNPRINTF
/* Define if you have the strcasecmp function. */
#cmakedefine HAVE_STRCASECMP
/* Define if you have the strdup function. */
#cmakedefine HAVE_STRDUP
/* Define if you have the strerror function. */
#cmakedefine HAVE_STRERROR
/* Define if you have the stricmp function. */
#cmakedefine HAVE_STRICMP
/* Define if you have the strlcpy function. */
#cmakedefine HAVE_STRLCPY
/* Define if you have the strncasecmp function. */
#cmakedefine HAVE_STRNCASECMP
/* Define if you have the strnicmp function. */
#cmakedefine HAVE_STRNICMP
/* Define if you have the strstr function. */
#cmakedefine HAVE_STRSTR
/* Define if you have the vsnprintf function. */
#cmakedefine HAVE_VSNPRINTF
/* Define if you have the <arpa/inet.h> header file. */
#cmakedefine HAVE_ARPA_INET_H
/* Define if you have the <arpa/telnet.h> header file. */
#cmakedefine HAVE_ARPA_TELNET_H
/* Define if you have the <assert.h> header file. */
#cmakedefine HAVE_ASSERT_H
/* Define if you have the <crypt.h> header file. */
#cmakedefine HAVE_CRYPT_H
/* Define if you have the <errno.h> header file. */
#cmakedefine HAVE_ERRNO_H
/* Define if you have the <fcntl.h> header file. */
#cmakedefine HAVE_FCNTL_H
/* Define if you have the <limits.h> header file. */
#cmakedefine HAVE_LIMITS_H
/* Define if you have the <mcheck.h> header file. */
#cmakedefine HAVE_MCHECK_H
/* Define if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H
/* Define if you have the <net/errno.h> header file. */
#cmakedefine HAVE_NET_ERRNO_H
/* Define if you have the <netdb.h> header file. */
#cmakedefine HAVE_NETDB_H
/* Define if you have the <netinet/in.h> header file. */
#cmakedefine HAVE_NETINET_IN_H
/* Define if you have the <signal.h> header file. */
#cmakedefine HAVE_SIGNAL_H
/* Define if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H
/* Define if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H
/* Define if you have the <sys/fcntl.h> header file. */
#cmakedefine HAVE_SYS_FCNTL_H
/* Define if you have the <sys/resource.h> header file. */
#cmakedefine HAVE_SYS_RESOURCE_H
/* Define if you have the <sys/select.h> header file. */
#cmakedefine HAVE_SYS_SELECT_H
/* Define if you have the <sys/socket.h> header file. */
#cmakedefine HAVE_SYS_SOCKET_H
/* Define if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H
/* Define if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H
/* Define if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H
/* Define if you have the <sys/uio.h> header file. */
#cmakedefine HAVE_SYS_UIO_H
/* Define if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H
/* Define if you have the malloc library (-lmalloc). */
#cmakedefine HAVE_LIBMALLOC
/* Check for a prototype to accept. */
#cmakedefine NEED_ACCEPT_PROTO
/* Check for a prototype to atoi. */
#cmakedefine NEED_ATOI_PROTO
/* Check for a prototype to atol. */
#cmakedefine NEED_ATOL_PROTO
/* Check for a prototype to bind. */
#cmakedefine NEED_BIND_PROTO
/* Check for a prototype to bzero. */
#cmakedefine NEED_BZERO_PROTO
/* Check for a prototype to chdir. */
#cmakedefine NEED_CHDIR_PROTO
/* Check for a prototype to close. */
#cmakedefine NEED_CLOSE_PROTO
/* Check for a prototype to crypt. */
#cmakedefine NEED_CRYPT_PROTO
/* Check for a prototype to fclose. */
#cmakedefine NEED_FCLOSE_PROTO
/* Check for a prototype to fcntl. */
#cmakedefine NEED_FCNTL_PROTO
/* Check for a prototype to fflush. */
#cmakedefine NEED_FFLUSH_PROTO
/* Check for a prototype to fprintf. */
#cmakedefine NEED_FPRINTF_PROTO
/* Check for a prototype to fputc. */
#cmakedefine NEED_FPUTC_PROTO
/* Check for a prototype to fputs. */
#cmakedefine NEED_FPUTS_PROTO
/* Check for a prototype to fread. */
#cmakedefine NEED_FREAD_PROTO
/* Check for a prototype to fscanf. */
#cmakedefine NEED_FSCANF_PROTO
/* Check for a prototype to fseek. */
#cmakedefine NEED_FSEEK_PROTO
/* Check for a prototype to fwrite. */
#cmakedefine NEED_FWRITE_PROTO
/* Check for a prototype to getpeername. */
#cmakedefine NEED_GETPEERNAME_PROTO
/* Check for a prototype to getpid. */
#cmakedefine NEED_GETPID_PROTO
/* Check for a prototype to getrlimit. */
#cmakedefine NEED_GETRLIMIT_PROTO
/* Check for a prototype to getsockname. */
#cmakedefine NEED_GETSOCKNAME_PROTO
/* Check for a prototype to gettimeofday. */
#cmakedefine NEED_GETTIMEOFDAY_PROTO
/* Check for a prototype to htonl. */
#cmakedefine NEED_HTONL_PROTO
/* Check for a prototype to htons. */
#cmakedefine NEED_HTONS_PROTO
/* Check for a prototype to inet_addr. */
#cmakedefine NEED_INET_ADDR_PROTO
/* Check for a prototype to inet_aton. */
#cmakedefine NEED_INET_ATON_PROTO
/* Check for a prototype to inet_ntoa. */
#cmakedefine NEED_INET_NTOA_PROTO
/* Check for a prototype to listen. */
#cmakedefine NEED_LISTEN_PROTO
/* Check for a prototype to ntohl. */
#cmakedefine NEED_NTOHL_PROTO
/* Check for a prototype to perror. */
#cmakedefine NEED_PERROR_PROTO
/* Check for a prototype to printf. */
#cmakedefine NEED_PRINTF_PROTO
/* Check for a prototype to qsort. */
#cmakedefine NEED_QSORT_PROTO
/* Check for a prototype to read. */
#cmakedefine NEED_READ_PROTO
/* Check for a prototype to remove. */
#cmakedefine NEED_REMOVE_PROTO
/* Check for a prototype to rewind. */
#cmakedefine NEED_REWIND_PROTO
/* Check for a prototype to select. */
#cmakedefine NEED_SELECT_PROTO
/* Check for a prototype to setitimer. */
#cmakedefine NEED_SETITIMER_PROTO
/* Check for a prototype to setrlimit. */
#cmakedefine NEED_SETRLIMIT_PROTO
/* Check for a prototype to setsockopt. */
#cmakedefine NEED_SETSOCKOPT_PROTO
/* Check for a prototype to snprintf. */
#cmakedefine NEED_SNPRINTF_PROTO
/* Check for a prototype to socket. */
#cmakedefine NEED_SOCKET_PROTO
/* Check for a prototype to sprintf. */
#cmakedefine NEED_SPRINTF_PROTO
/* Check for a prototype to sscanf. */
#cmakedefine NEED_SSCANF_PROTO
/* Check for a prototype to strcasecmp. */
#cmakedefine NEED_STRCASECMP_PROTO
/* Check for a prototype to strdup. */
#cmakedefine NEED_STRDUP_PROTO
/* Check for a prototype to strerror. */
#cmakedefine NEED_STRERROR_PROTO
/* Check for a prototype to stricmp. */
#cmakedefine NEED_STRICMP_PROTO
/* Check for a prototype to strlcpy. */
#cmakedefine NEED_STRLCPY_PROTO
/* Check for a prototype to strncasecmp. */
#cmakedefine NEED_STRNCASECMP_PROTO
/* Check for a prototype to strnicmp. */
#cmakedefine NEED_STRNICMP_PROTO
/* Check for a prototype to system. */
#cmakedefine NEED_SYSTEM_PROTO
/* Check for a prototype to time. */
#cmakedefine NEED_TIME_PROTO
/* Check for a prototype to unlink. */
#cmakedefine NEED_UNLINK_PROTO
/* Check for a prototype to vsnprintf. */
#cmakedefine NEED_VSNPRINTF_PROTO
/* Check for a prototype to write. */
#cmakedefine NEED_WRITE_PROTO
#endif /* _CONF_H_ */

367
src/conf.h.macOS Normal file
View file

@ -0,0 +1,367 @@
#ifndef _CONF_H_
#define _CONF_H_
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if you don't have vprintf but do have _doprnt. */
/* #undef HAVE_DOPRNT */
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#define HAVE_SYS_WAIT_H 1
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF 1
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef pid_t */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
/* #undef STDC_HEADERS */
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if we're compiling CircleMUD under any type of UNIX system. */
#define CIRCLE_UNIX 1
/* Machine-specific dependencies for running on modern macOS systems 10.13+ (High Sierra)
* Updated by Victor Augusto Borges Dias de Almeida (aka Stoneheart), 26 June 2024.
*
* Tested on:
* - macOS 10.13: High Sierra - September 25, 2017 (Latest: 10.13.6)
* - macOS 10.14: Mojave - September 24, 2018 (Latest: 10.14.6)
* - macOS 10.15: Catalina - October 7, 2019 (Latest: 10.15.7)
* - macOS 11: Big Sur - November 12, 2020 (Latest: 11.7.10)
* - macOS 12: Monterey - October 25, 2021 (Latest: 12.7)
* - macOS 13: Ventura - November 7, 2022 (Latest: 13.7)
* - macOS 14: Sonoma - November 7, 2023 (Latest: 14.3)
*
* This file works on Apple Silicon Chips (M1, M2, M3) without futher configurations. */
#if defined(__APPLE__) && defined(__MACH__)
#define CIRCLE_MAC_OS 1
#endif
/* Define if the system is capable of using crypt() to encrypt. */
#define CIRCLE_CRYPT 1
/* Define if we don't have proper support for the system's crypt(). */
/* #undef HAVE_UNSAFE_CRYPT */
/* Define is the system has struct in_addr. */
#define HAVE_STRUCT_IN_ADDR 1
/* Define to `int' if <sys/socket.h> doesn't define. */
/* #undef socklen_t */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef ssize_t */
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the inet_addr function. */
#define HAVE_INET_ADDR 1
/* Define if you have the inet_aton function. */
#define HAVE_INET_ATON 1
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the snprintf function. */
#define HAVE_SNPRINTF 1
/* Define if you have the strcasecmp function. */
#define HAVE_STRCASECMP 1
/* Define if you have the strdup function. */
#define HAVE_STRDUP 1
/* Define if you have the strerror function. */
#define HAVE_STRERROR 1
/* Define if you have the stricmp function. */
/* #undef HAVE_STRICMP */
/* Define if you have the strlcpy function. */
#ifndef CIRCLE_MAC_OS
#define HAVE_STRLCPY 1
#else
#define HAVE_STRLCPY 0
#endif
/* Define if you have the strncasecmp function. */
#define HAVE_STRNCASECMP 1
/* Define if you have the strnicmp function. */
/* #undef HAVE_STRNICMP */
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the vsnprintf function. */
#define HAVE_VSNPRINTF 1
/* Define if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
/* Define if you have the <arpa/telnet.h> header file. */
#define HAVE_ARPA_TELNET_H 1
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define if you have the <crypt.h> header file. */
/* #undef HAVE_CRYPT_H */
#ifdef CIRCLE_MAC_OS
#define HAVE_CRYPT_H 1
#endif
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <mcheck.h> header file. */
/* #undef HAVE_MCHECK_H */
#ifdef CIRCLE_MAC_OS
#define HAVE_MCHECK_H 1
#endif
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if you have the <net/errno.h> header file. */
/* #undef HAVE_NET_ERRNO_H */
/* Define if you have the <netdb.h> header file. */
#define HAVE_NETDB_H 1
/* Define if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Define if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define if you have the <sys/fcntl.h> header file. */
#define HAVE_SYS_FCNTL_H 1
/* Define if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <sys/uio.h> header file. */
#define HAVE_SYS_UIO_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the malloc library (-lmalloc). */
/* #undef HAVE_LIBMALLOC */
/* Check for a prototype to accept. */
/* #undef NEED_ACCEPT_PROTO */
#ifndef CIRCLE_MAC_OS
/* Check for a prototype to atoi. */
#define NEED_ATOI_PROTO
/* Check for a prototype to atol. */
#define NEED_ATOL_PROTO
#endif
/* Check for a prototype to bind. */
/* #undef NEED_BIND_PROTO */
/* Check for a prototype to bzero. */
/* #undef NEED_BZERO_PROTO */
/* Check for a prototype to chdir. */
/* #undef NEED_CHDIR_PROTO */
/* Check for a prototype to close. */
/* #undef NEED_CLOSE_PROTO */
/* Check for a prototype to crypt. */
/* #undef NEED_CRYPT_PROTO */
/* Check for a prototype to fclose. */
/* #undef NEED_FCLOSE_PROTO */
/* Check for a prototype to fcntl. */
/* #undef NEED_FCNTL_PROTO */
/* Check for a prototype to fflush. */
/* #undef NEED_FFLUSH_PROTO */
/* Check for a prototype to fprintf. */
/* #undef NEED_FPRINTF_PROTO */
/* Check for a prototype to fputc. */
/* #undef NEED_FPUTC_PROTO */
/* Check for a prototype to fputs. */
/* #undef NEED_FPUTS_PROTO */
/* Check for a prototype to fread. */
/* #undef NEED_FREAD_PROTO */
/* Check for a prototype to fscanf. */
/* #undef NEED_FSCANF_PROTO */
/* Check for a prototype to fseek. */
/* #undef NEED_FSEEK_PROTO */
/* Check for a prototype to fwrite. */
/* #undef NEED_FWRITE_PROTO */
/* Check for a prototype to getpeername. */
/* #undef NEED_GETPEERNAME_PROTO */
/* Check for a prototype to getpid. */
/* #undef NEED_GETPID_PROTO */
/* Check for a prototype to getrlimit. */
/* #undef NEED_GETRLIMIT_PROTO */
/* Check for a prototype to getsockname. */
/* #undef NEED_GETSOCKNAME_PROTO */
/* Check for a prototype to gettimeofday. */
/* #undef NEED_GETTIMEOFDAY_PROTO */
/* Check for a prototype to htonl. */
/* #undef NEED_HTONL_PROTO */
/* Check for a prototype to htons. */
/* #undef NEED_HTONS_PROTO */
/* Check for a prototype to inet_addr. */
/* #undef NEED_INET_ADDR_PROTO */
/* Check for a prototype to inet_aton. */
/* #undef NEED_INET_ATON_PROTO */
/* Check for a prototype to inet_ntoa. */
/* #undef NEED_INET_NTOA_PROTO */
/* Check for a prototype to listen. */
/* #undef NEED_LISTEN_PROTO */
/* Check for a prototype to ntohl. */
/* #undef NEED_NTOHL_PROTO */
/* Check for a prototype to perror. */
/* #undef NEED_PERROR_PROTO */
/* Check for a prototype to printf. */
/* #undef NEED_PRINTF_PROTO */
/* Check for a prototype to qsort. */
#ifndef CIRCLE_MAC_OS
#define NEED_QSORT_PROTO
#endif
/* Check for a prototype to read. */
/* #undef NEED_READ_PROTO */
/* Check for a prototype to remove. */
/* #undef NEED_REMOVE_PROTO */
/* Check for a prototype to rewind. */
/* #undef NEED_REWIND_PROTO */
/* Check for a prototype to select. */
/* #undef NEED_SELECT_PROTO */
/* Check for a prototype to setitimer. */
/* #undef NEED_SETITIMER_PROTO */
/* Check for a prototype to setrlimit. */
/* #undef NEED_SETRLIMIT_PROTO */
/* Check for a prototype to setsockopt. */
/* #undef NEED_SETSOCKOPT_PROTO */
/* Check for a prototype to snprintf. */
/* #undef NEED_SNPRINTF_PROTO */
/* Check for a prototype to socket. */
/* #undef NEED_SOCKET_PROTO */
/* Check for a prototype to sprintf. */
/* #undef NEED_SPRINTF_PROTO */
/* Check for a prototype to sscanf. */
/* #undef NEED_SSCANF_PROTO */
/* Check for a prototype to strcasecmp. */
/* #undef NEED_STRCASECMP_PROTO */
/* Check for a prototype to strdup. */
/* #undef NEED_STRDUP_PROTO */
/* Check for a prototype to strerror. */
/* #undef NEED_STRERROR_PROTO */
/* Check for a prototype to stricmp. */
#define NEED_STRICMP_PROTO
/* Check for a prototype to strlcpy. */
/* #undef NEED_STRLCPY_PROTO */
/* Check for a prototype to strncasecmp. */
/* #undef NEED_STRNCASECMP_PROTO */
/* Check for a prototype to strnicmp. */
#define NEED_STRNICMP_PROTO
/* Check for a prototype to system. */
#ifndef CIRCLE_MAC_OS
#define NEED_SYSTEM_PROTO
#endif
/* Check for a prototype to time. */
/* #undef NEED_TIME_PROTO */
/* Check for a prototype to unlink. */
/* #undef NEED_UNLINK_PROTO */
/* Check for a prototype to vsnprintf. */
/* #undef NEED_VSNPRINTF_PROTO */
/* Check for a prototype to write. */
/* #undef NEED_WRITE_PROTO */
#endif /* _CONF_H_ */

View file

@ -24,7 +24,7 @@
* @todo cpp_extern isn't needed here (or anywhere) as the extern reserved word
* works correctly with C compilers (at least in my Experience)
* Jeremy Osborne 1/28/2008 */
cpp_extern const char *tbamud_version = "tbaMUD 2023";
cpp_extern const char *tbamud_version = "tbaMUD 2025";
/* strings corresponding to ordinals/bitvectors in structs.h */
/* (Note: strings for class definitions in class.c instead of here) */
@ -877,6 +877,7 @@ const char *trig_types[] = {
"Door",
"UNUSED",
"Time",
"Damage",
"\n"
};

View file

@ -1091,70 +1091,85 @@ int format_script(struct descriptor_data *d)
char nsc[MAX_CMD_LENGTH], *t, line[READ_SIZE];
char *sc;
size_t len = 0, nlen = 0, llen = 0;
int indent = 0, indent_next = FALSE, found_case = FALSE, i, line_num = 0, ret;
int indent = 0, indent_next = FALSE, line_num = 0, ret, i; // Declare i here
int block_stack[READ_SIZE]; // Stack to track block types
int stack_top = -1; // Initialize stack as empty
int switch_indent[READ_SIZE]; // Array to track switch indent levels
int switch_top = -1; // Index for switch_indent array
int case_indent = 0; // Track indent for case blocks
int in_switch = 0; // Flag to indicate if we're inside a switch block
if (!d->str || !*d->str)
return FALSE;
sc = strdup(*d->str); /* we work on a copy, because of strtok() */
sc = strdup(*d->str); // Work on a copy
t = strtok(sc, "\n\r");
*nsc = '\0';
while (t) {
line_num++;
skip_spaces(&t);
if (!strn_cmp(t, "if ", 3) ||
!strn_cmp(t, "switch ", 7)) {
if (!strn_cmp(t, "switch ", 7)) {
indent_next = TRUE;
} else if (!strn_cmp(t, "while ", 6)) {
found_case = TRUE; /* so you can 'break' a loop without complains */
stack_top++;
block_stack[stack_top] = 's'; // 's' for switch
switch_top++;
switch_indent[switch_top] = indent; // Save current indent level for switch
in_switch++; // We're entering a switch block
} else if (!strn_cmp(t, "case", 4) || !strn_cmp(t, "default", 7)) {
if (in_switch > 0) { // If we're inside a switch
indent = switch_indent[switch_top] + 1; // Indent cases one level under switch
indent_next = TRUE; // Indent the next line after case
case_indent = indent; // Save indent for case block
}
} else if (!strn_cmp(t, "if ", 3) || !strn_cmp(t, "while ", 6)) {
indent_next = TRUE;
} else if (!strn_cmp(t, "end", 3) ||
!strn_cmp(t, "done", 4)) {
if (!indent) {
stack_top++;
block_stack[stack_top] = 'l'; // 'l' for loop or conditional
} else if (!strn_cmp(t, "end", 3) || !strn_cmp(t, "done", 4)) {
if (stack_top < 0) {
write_to_output(d, "Unmatched 'end' or 'done' (line %d)!\r\n", line_num);
free(sc);
return FALSE;
}
indent--;
indent_next = FALSE;
if (block_stack[stack_top] == 's') {
indent = switch_indent[switch_top]; // Reset to the exact indent level where switch was declared
switch_top--; // Decrease switch stack if ending a switch
case_indent = 0; // Reset case indent since we're leaving the switch
in_switch--; // We're leaving a switch block
} else {
indent--; // For other blocks like while
}
stack_top--;
indent_next = FALSE; // Reset for next line
} else if (!strn_cmp(t, "else", 4)) {
if (!indent) {
if (stack_top < 0 || block_stack[stack_top] != 'l') {
write_to_output(d, "Unmatched 'else' (line %d)!\r\n", line_num);
free(sc);
return FALSE;
}
indent--;
indent--; // Reduce indent for else, then increment for next statement
indent_next = TRUE;
} else if (!strn_cmp(t, "case", 4) ||
!strn_cmp(t, "default", 7)) {
if (!indent) {
write_to_output(d, "Case/default outside switch (line %d)!\r\n", line_num);
free(sc);
return FALSE;
}
if (!found_case) /* so we don't indent multiple case statements without a break */
indent_next = TRUE;
found_case = TRUE;
} else if (!strn_cmp(t, "break", 5)) {
if (!found_case || !indent ) {
write_to_output(d, "Break not in case (line %d)!\r\n", line_num);
if (stack_top < 0 || (block_stack[stack_top] != 's' && block_stack[stack_top] != 'l')) {
write_to_output(d, "Break not in case or loop (line %d)!\r\n", line_num);
free(sc);
return FALSE;
}
found_case = FALSE;
indent--;
indent = case_indent + 1; // Indent break one level deeper than case
indent_next = FALSE; // Ensure no automatic increase for next line after break
}
*line = '\0';
for (nlen = 0, i = 0;i<indent;i++) {
for (nlen = 0, i = 0; i < indent; i++) {
strncat(line, " ", sizeof(line) - strlen(line) - 1);
nlen += 2;
}
ret = snprintf(line + nlen, sizeof(line) - nlen, "%s\r\n", t);
llen = (size_t)ret;
if (ret < 0 || llen + nlen + len > d->max_str - 1 ) {
if (ret < 0 || llen + nlen + len > d->max_str - 1) {
write_to_output(d, "String too long, formatting aborted\r\n");
free(sc);
return FALSE;
@ -1169,8 +1184,8 @@ int format_script(struct descriptor_data *d)
t = strtok(NULL, "\n\r");
}
if (indent)
write_to_output(d, "Unmatched if, while or switch ignored.\r\n");
if (stack_top >= 0)
write_to_output(d, "Unmatched block statements ignored.\r\n");
free(*d->str);
*d->str = strdup(nsc);

View file

@ -16,7 +16,7 @@
#include "dg_scripts.h"
#define NUM_TRIG_TYPE_FLAGS 20
#define NUM_TRIG_TYPE_FLAGS 21
/* Submodes of TRIGEDIT connectedness. */
#define TRIGEDIT_MAIN_MENU 0

View file

@ -2486,7 +2486,6 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode)
char cmd[MAX_INPUT_LENGTH], *p;
struct script_data *sc = 0;
struct cmdlist_element *temp;
unsigned long loops = 0;
void *go = NULL;
void obj_command_interpreter(obj_data *obj, char *argument);
@ -2578,8 +2577,8 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode)
if (process_if(p + 6, go, sc, trig, type)) {
temp->original = cl;
} else {
cl->loops = 0;
cl = temp;
loops = 0;
}
} else if (!strn_cmp("switch ", p, 7)) {
cl = find_case(trig, cl, go, sc, type, p + 7);
@ -2599,9 +2598,10 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode)
if (cl->original && process_if(orig_cmd + 6, go, sc, trig,
type)) {
cl = cl->original;
loops++;
cl->loops++;
GET_TRIG_LOOPS(trig)++;
if (loops == 30) {
if (cl->loops == 30) {
cl->loops = 0;
process_wait(go, trig, type, "wait 1", cl);
depth--;
return ret_val;

View file

@ -71,6 +71,7 @@
#define MTRIG_DOOR (1 << 17) /* door manipulated in room */
#define MTRIG_TIME (1 << 19) /* trigger based on game hour */
#define MTRIG_DAMAGE (1 << 20) /* trigger whenever mob is damaged */
/* obj trigger types */
#define OTRIG_GLOBAL (1 << 0) /* unused */
@ -135,6 +136,7 @@ struct cmdlist_element {
char *cmd; /* one line of a trigger */
struct cmdlist_element *original;
struct cmdlist_element *next;
int loops; /* for counting number of runs in a while loop */
};
struct trig_var_data {
@ -263,6 +265,7 @@ void time_wtrigger(room_data *room);
int login_wtrigger(struct room_data *room, char_data *actor);
int damage_mtrigger(char_data *ch, char_data *victim, int dam, int attacktype);
/* function prototypes from dg_scripts.c */
ACMD(do_attach) ;
ACMD(do_detach);

View file

@ -554,6 +554,33 @@ int cast_mtrigger(char_data *actor, char_data *ch, int spellnum)
return 1;
}
int damage_mtrigger(char_data *actor, char_data *victim, int dam, int attacktype)
{
trig_data *t;
char buf[MAX_INPUT_LENGTH];
if (victim == NULL)
return dam;
if (!SCRIPT_CHECK(victim, MTRIG_DAMAGE) || AFF_FLAGGED(victim, AFF_CHARM))
return dam;
for (t = TRIGGERS(SCRIPT(victim)); t; t = t->next) {
if (TRIGGER_CHECK(t, MTRIG_DAMAGE) &&
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
ADD_UID_VAR(buf, t, char_script_id(actor), "actor", 0);
ADD_UID_VAR(buf, t, char_script_id(victim), "victim", 0);
sprintf(buf, "%d", dam);
add_var(&GET_TRIG_VARS(t), "damage", buf, 0);
add_var(&GET_TRIG_VARS(t), "attacktype", skill_name(attacktype), 0);
return script_driver(&victim, t, MOB_TRIGGER, TRIG_NEW);
}
}
return dam;
}
int leave_mtrigger(char_data *actor, int dir)
{
trig_data *t;

View file

@ -620,6 +620,11 @@ int damage(struct char_data *ch, struct char_data *victim, int dam, int attackty
if (!IS_NPC(victim) && ((GET_LEVEL(victim) >= LVL_IMMORT) && PRF_FLAGGED(victim, PRF_NOHASSLE)))
dam = 0;
dam = damage_mtrigger(ch, victim, dam, attacktype);
if (dam == -1) {
return (0);
}
if (victim != ch) {
/* Start the attacker fighting the victim */
if (GET_POS(ch) > POS_STUNNED && (FIGHTING(ch) == NULL))

View file

@ -146,7 +146,8 @@ static void prefedit_disp_main_menu(struct descriptor_data *d)
"%sImmortal Preferences\r\n"
"%s1%s) Syslog Level %s[%s%8s%s] %s4%s) ClsOLC %s[%s%3s%s]\r\n"
"%s2%s) Show Flags %s[%s%3s%s] %s5%s) No WizNet %s[%s%3s%s]\r\n"
"%s3%s) No Hassle %s[%s%3s%s] %s6%s) Holylight %s[%s%3s%s]\r\n",
"%s3%s) No Hassle %s[%s%3s%s] %s6%s) Holylight %s[%s%3s%s]\r\n"
"%s7%s) Verbose %s[%s%3s%s] ",
CBWHT(d->character, C_NRM),
/* Line 1 - syslog and clsolc */
CBYEL(d->character, C_NRM), CCNRM(d->character, C_NRM), CCCYN(d->character, C_NRM), CCYEL(d->character, C_NRM),
@ -159,12 +160,17 @@ static void prefedit_disp_main_menu(struct descriptor_data *d)
/* Line 3 - nohassle and holylight */
CBYEL(d->character, C_NRM), CCNRM(d->character, C_NRM), CCCYN(d->character, C_NRM), CCYEL(d->character, C_NRM),
ONOFF(PREFEDIT_FLAGGED(PRF_NOHASSLE)), CCCYN(d->character, C_NRM), CBYEL(d->character, C_NRM), CCNRM(d->character, C_NRM),
CCCYN(d->character, C_NRM), CCYEL(d->character, C_NRM), ONOFF(PREFEDIT_FLAGGED(PRF_HOLYLIGHT)), CCCYN(d->character, C_NRM)
CCCYN(d->character, C_NRM), CCYEL(d->character, C_NRM), ONOFF(PREFEDIT_FLAGGED(PRF_HOLYLIGHT)), CCCYN(d->character, C_NRM),
/* Line 4 - Verbose */
CBYEL(d->character, C_NRM), CCNRM(d->character, C_NRM), CCCYN(d->character, C_NRM), CCYEL(d->character, C_NRM),
ONOFF(PREFEDIT_FLAGGED(PRF_VERBOSE)), CCCYN(d->character, C_NRM)
);
if (GET_LEVEL(PREFEDIT_GET_CHAR) == LVL_IMPL)
send_to_char(d->character, "%s7%s) Zone Resets %s[%s%3s%s]\r\n",
send_to_char(d->character, "%s8%s) Zone Resets %s[%s%3s%s]\r\n",
CBYEL(d->character, C_NRM), CCNRM(d->character, C_NRM), CCCYN(d->character, C_NRM), CCYEL(d->character, C_NRM),
ONOFF(PREFEDIT_FLAGGED(PRF_ZONERESETS)), CCCYN(d->character, C_NRM));
else
send_to_char(d->character, "\r\n");
}
/* Finishing Off */
@ -505,7 +511,19 @@ void prefedit_parse(struct descriptor_data * d, char *arg)
}
break;
case '7':
case '7':
if (GET_LEVEL(PREFEDIT_GET_CHAR) < LVL_IMMORT)
{
send_to_char(d->character, "%sInvalid choice!%s\r\n", CBRED(d->character, C_NRM), CCNRM(d->character, C_NRM));
prefedit_disp_main_menu(d);
}
else
{
TOGGLE_BIT_AR(PREFEDIT_GET_FLAGS, PRF_VERBOSE);
}
break;
case '8':
if (GET_LEVEL(PREFEDIT_GET_CHAR) < LVL_IMPL)
{
send_to_char(d->character, "%sInvalid choice!%s\r\n", CBRED(d->character, C_NRM), CCNRM(d->character, C_NRM));
@ -901,6 +919,10 @@ void prefedit_Restore_Defaults(struct descriptor_data *d)
if (PREFEDIT_FLAGGED(PRF_AUTODOOR))
SET_BIT_AR(PREFEDIT_GET_FLAGS, PRF_AUTODOOR);
/* PRF_VERBOSE - On */
if (PREFEDIT_FLAGGED(PRF_VERBOSE))
SET_BIT_AR(PREFEDIT_GET_FLAGS, PRF_VERBOSE);
/* Other (non-toggle) options */
PREFEDIT_GET_WIMP_LEV = 0; /* Wimpy off by default */
PREFEDIT_GET_PAGELENGTH = 22; /* Default telnet screen is 22 lines */

View file

@ -1768,7 +1768,26 @@ static void PerformSubnegotiation( descriptor_t *apDescriptor, char aCmd, char *
Write(apDescriptor, RequestTTYPE);
}
if ( PrefixString("Mudlet", pClientName) )
if ( PrefixString("MTTS ", pClientName) )
{
pProtocol->pVariables[eMSDP_CLIENT_VERSION]->ValueInt = atoi(pClientName+5);
if (pProtocol->pVariables[eMSDP_CLIENT_VERSION]->ValueInt & 1)
{
pProtocol->pVariables[eMSDP_ANSI_COLORS]->ValueInt = 1;
}
if (pProtocol->pVariables[eMSDP_CLIENT_VERSION]->ValueInt & 4)
{
pProtocol->pVariables[eMSDP_UTF_8]->ValueInt = 1;
}
if (pProtocol->pVariables[eMSDP_CLIENT_VERSION]->ValueInt & 8)
{
pProtocol->pVariables[eMSDP_XTERM_256_COLORS]->ValueInt = 1;
pProtocol->b256Support = eYES;
}
}
else if ( PrefixString("Mudlet", pClientName) )
{
/* Mudlet beta 15 and later supports 256 colours, but we can't
* identify it from the mud - everything prior to 1.1 claims

View file

@ -262,9 +262,10 @@
#define PRF_AUTOMAP 31 /**< Show map at the side of room descs */
#define PRF_AUTOKEY 32 /**< Automatically unlock locked doors when opening */
#define PRF_AUTODOOR 33 /**< Use the next available door */
#define PRF_ZONERESETS 34
#define PRF_ZONERESETS 34 /**< Show when zones reset */
#define PRF_VERBOSE 35 /**< Listings like where are more verbose */
/** Total number of available PRF flags */
#define NUM_PRF_FLAGS 35
#define NUM_PRF_FLAGS 36
/* Affect bits: used in char_data.char_specials.saved.affected_by */
/* WARNING: In the world files, NEVER set the bits marked "R" ("Reserved") */

View file

@ -63,6 +63,24 @@
/* Do not change anything below this line. */
#if defined(__APPLE__) && defined(__MACH__)
/* Machine-specific dependencies for running on modern macOS systems 10.13+ (High Sierra)
* Updated by Victor Augusto Borges Dias de Almeida (aka Stoneheart), 26 June 2024.
*
* Tested on:
* - macOS 10.13: High Sierra (Lobo) - September 25, 2017 (Latest: 10.13.6)
* - macOS 10.14: Mojave (Liberty) - September 24, 2018 (Latest: 10.14.6)
* - macOS 10.15: Catalina (Jazz) - October 7, 2019 (Latest: 10.15.7)
* - macOS 11: Big Sur (GoldenGate) - November 12, 2020 (Latest: 11.7.10)
* - macOS 12: Monterey (Star) - October 25, 2021 (Latest: 12.7)
* - macOS 13: Ventura (Rome) - November 7, 2022 (Latest: 13.7)
* - macOS 14: Sonoma (Sunburst) - November 7, 2023 (Latest: 14.3)
*
* This file works on Apple Silicon Chips (M1, M2, M3) without futher configurations.
*/
#define CIRCLE_MAC_OS 1
#endif
/* Set up various machine-specific things based on the values determined from
* configure and conf.h. */
@ -78,7 +96,7 @@
#include <strings.h>
#endif
#if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
#if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) || defined(CIRCLE_MAC_OS))
#include <stdlib.h>
#else /* No standard headers. */
@ -88,9 +106,8 @@
#endif
extern char *malloc(), *calloc(), *realloc();
extern void free ();
extern void abort (), exit ();
extern void free();
extern void abort(), exit();
#endif /* Standard headers. */
@ -150,9 +167,11 @@ extern void abort (), exit ();
#include <sys/errno.h>
#endif
#ifndef CIRCLE_MAC_OS
#ifdef HAVE_CRYPT_H
#include <crypt.h>
#endif
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
@ -434,9 +453,11 @@ struct in_addr {
char *strerror(int errnum);
#endif
#ifndef CIRCLE_MAC_OS
#ifdef NEED_STRLCPY_PROTO
size_t strlcpy(char *dest, const char *src, size_t copylen);
#endif
#endif
#ifdef NEED_SYSTEM_PROTO
int system(const char *string);

46
src/util/CMakeLists.txt Normal file
View file

@ -0,0 +1,46 @@
set(TOOLS
asciipasswd
autowiz
plrtoascii
rebuildIndex
rebuildMailIndex
shopconv
sign
split
wld2html
webster
)
# common includes and flags
include_directories(${CMAKE_SOURCE_DIR}/src)
add_definitions(-DCIRCLE_UTIL)
find_library(CRYPT_LIBRARY crypt)
find_library(NETLIB_LIBRARY nsl socket) # for sign.c, hvis nødvendig
foreach(tool ${TOOLS})
if(${tool} STREQUAL "rebuildIndex")
add_executable(rebuildIndex rebuildAsciiIndex.c)
else()
add_executable(${tool} ${tool}.c)
endif()
# Set output location
set_target_properties(${tool} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin
)
# Link to libcrypt for asciipasswd
if(${tool} STREQUAL "asciipasswd" AND CRYPT_LIBRARY)
target_link_libraries(${tool} ${CRYPT_LIBRARY})
endif()
# Link to netlib for sign
if(${tool} STREQUAL "sign" AND NETLIB_LIBRARY)
target_link_libraries(${tool} ${NETLIB_LIBRARY})
endif()
endforeach()
add_custom_target(utils DEPENDS ${TOOLS})

View file

@ -23,7 +23,7 @@ CFLAGS = @CFLAGS@ $(MYFLAGS) $(PROFILE) -I$(INCDIR)
default: all
all: $(BINDIR)/asciipasswd $(BINDIR)/autowiz $(BINDIR)/plrtoascii $(BINDIR)/rebuildIndex $(BINDIR)/rebuildMailIndex $(BINDIR)/shopconv $(BINDIR)/sign $(BINDIR)/split $(BINDIR)/wld2html $(BINDIR)/webster
all: $(BINDIR)/asciipasswd $(BINDIR)/autowiz $(BINDIR)/plrtoascii $(BINDIR)/rebuildIndex $(BINDIR)/rebuildMailIndex $(BINDIR)/shopconv $(BINDIR)/sign $(BINDIR)/split $(BINDIR)/wld2html
asciipasswd: $(BINDIR)/asciipasswd
@ -43,8 +43,6 @@ split: $(BINDIR)/split
wld2html: $(BINDIR)/wld2html
webster: $(BINDIR)/webster
$(BINDIR)/asciipasswd: asciipasswd.c
$(CC) $(CFLAGS) -o $(BINDIR)/asciipasswd asciipasswd.c @CRYPTLIB@
@ -72,9 +70,6 @@ $(BINDIR)/split: split.c
$(BINDIR)/wld2html: wld2html.c
$(CC) $(CFLAGS) -o $(BINDIR)/wld2html wld2html.c
$(BINDIR)/webster: webster.c
$(CC) $(CFLAGS) -o $(BINDIR)/webster webster.c
# Dependencies for the object files (automagically generated with
# gcc -MM)

View file

@ -85,7 +85,7 @@ void read_file(void)
while (get_line(fl, line))
if (*line != '~')
recs++;
rewind(fl);
rewind(fl);
for (i = 0; i < recs; i++) {
get_line(fl, line);

View file

@ -155,7 +155,7 @@ static int boot_the_shops_conv(FILE * shop_f, FILE * newshop_f, char *filename)
int main(int argc, char *argv[])
{
FILE *sfp, *nsfp;
char fn[256], part[256];
char fn[120], part[256];
int result, index, i;
if (argc < 2) {
@ -173,20 +173,20 @@ int main(int argc, char *argv[])
perror(fn);
} else {
if ((nsfp = fopen(fn, "w")) == NULL) {
printf("Error writing to %s.\n", fn);
continue;
printf("Error writing to %s.\n", fn);
continue;
}
printf("%s:\n", fn);
result = boot_the_shops_conv(sfp, nsfp, fn);
fclose(nsfp);
fclose(sfp);
if (result) {
sprintf(part, "mv %s.tmp %s", fn, fn);
i = system(part);
sprintf(part, "mv %s.tmp %s", fn, fn);
i = system(part);
} else {
sprintf(part, "mv %s.tmp %s.bak", fn, fn);
i = system(part);
printf("Done!\n");
sprintf(part, "mv %s.tmp %s.bak", fn, fn);
i = system(part);
printf("Done!\n");
}
}
}

View file

@ -1,175 +0,0 @@
/* ************************************************************************
* File: webster.c Part of tbaMUD *
* Usage: Use an online dictionary via tell m-w <word>. *
* *
* Based on the Circle 3.0 syntax checker and wld2html programs. *
************************************************************************ */
#define log(msg) fprintf(stderr, "%s\n", msg)
#include "conf.h"
#include "sysdep.h"
#define MEM_USE 10000
char buf[MEM_USE];
int get_line(FILE * fl, char *buf);
void skip_spaces(char **string);
void parse_webster_html(char *arg);
int main(int argc, char **argv)
{
int pid = 0;
if (argc != 3) {
return 0; /* no word/pid given */
}
pid = atoi(argv[2]);
snprintf(buf, sizeof(buf),
"lynx -accept_all_cookies -source http://www.thefreedictionary.com/%s"
" >webster.html", argv[1]);
system(buf);
parse_webster_html(argv[1]);
if (pid)
kill(pid, SIGUSR2);
return (0);
}
void parse_webster_html(char *arg) {
FILE *infile, *outfile;
char scanbuf[MEM_USE], outline[MEM_USE], *p, *q;
outfile = fopen("websterinfo", "w");
if (!outfile)
exit(1);
infile = fopen("webster.html", "r");
if (!infile) {
fprintf(outfile, "A bug has occured in webster. (no webster.html) Please notify Welcor.");
fclose(outfile);
return;
}
unlink("webster.html"); /* We can still read */
for ( ; get_line(infile, buf)!=0; ) {
if (strncmp(buf, "<script>write_ads(AdsNum, 0, 1)</script>", 40) != 0)
continue; // read until we hit the line with results in it.
p = buf+40;
if (strncmp(p, "<br>", 4) == 0)
{
fprintf(outfile, "That word could not be found.\n");
goto end;
}
else if (strncmp(p, "<div ", 5) == 0) // definition is here, all in one line.
{
while (strncmp(p, "ds-list", 7)) //seek to the definition
p++;
strncpy(scanbuf, p, sizeof(scanbuf)); // strtok on a copy.
p = strtok(scanbuf, ">"); // chop the line at the end of tags: <br><b>word</b> becomes "<br" "<b" "word</b"
p = strtok(NULL, ">"); // skip the rest of this tag.
fprintf(outfile, "Info on: %s\n\n", arg);
while (1)
{
q = outline;
while (*p != '<')
{
assert(p < scanbuf+sizeof(scanbuf));
*q++ = *p++;
}
if (!strncmp(p, "<br", 3) || !strncmp(p, "<p", 2) || !strncmp(p, "<div class=\"ds-list\"", 23) || !strncmp(p, "<div class=\"sds-list\"", 24))
*q++ = '\n';
// if it's not a <br> tag or a <div class="sds-list"> or <div class="ds-list"> tag, ignore it.
*q++='\0';
fprintf(outfile, "%s", outline);
if (!strncmp(p, "</table", 7))
goto end;
p = strtok(NULL, ">");
}
}
else if (strncmp(p, "<div>", 5) == 0) // not found, but suggestions are ample:
{
strncpy(scanbuf, p, sizeof(scanbuf)); // strtok on a copy.
p = strtok(scanbuf, ">"); // chop the line at the end of tags: <br><b>word</b> becomes "<br>" "<b>" "word</b>"
p = strtok(NULL, ">"); // skip the rest of this tag.
while (1)
{
q = outline;
while (*p != '<')
*q++ = *p++;
if (!strncmp(p, "<td ", 4))
*q++ = '\n';
// if it's not a <td> tag, ignore it.
*q++='\0';
fprintf(outfile, "%s", outline);
if (!strncmp(p, "</table", 7))
goto end;
p = strtok(NULL, ">");
}
}
else
{
// weird.. one of the above should be correct.
fprintf(outfile, "It would appear that the free online dictionary has changed their format.\n"
"Sorry, but you might need a webrowser instead.\n\n"
"See http://www.thefreedictionary.com/%s", arg);
goto end;
}
}
end:
fclose(infile);
fprintf(outfile, "~");
fclose(outfile);
}
/* get_line reads the next non-blank line off of the input stream.
* The newline character is removed from the input.
*/
int get_line(FILE * fl, char *buf)
{
char temp[MEM_USE];
do {
fgets(temp, MEM_USE, fl);
if (*temp)
temp[strlen(temp) - 1] = '\0';
} while (!feof(fl) && !*temp);
if (feof(fl))
return (0);
else {
strcpy(buf, temp);
return (1);
}
}
/*
* Function to skip over the leading spaces of a string.
*/
void skip_spaces(char **string)
{
for (; **string && isspace(**string); (*string)++);
}