(If no "===" comment, assume reverting code to previous patchlevel.) ACMD(do_levels) { char buf[MAX_STRING_LENGTH]; - size_t i, len = 0; - int nlen; + size_t i, len = 0, nlen; ---------------------------- @@ -66,8 +60,6 @@ void perform_put(struct char_data *ch, s { if (GET_OBJ_WEIGHT(cont) + GET_OBJ_WEIGHT(obj) > GET_OBJ_VAL(cont, 0)) act("$p won't fit in $P.", FALSE, ch, obj, cont, TO_CHAR); - else if (OBJ_FLAGGED(obj, ITEM_NODROP) && IN_ROOM(cont) != NOWHERE) - act("You can't get $p out of your hand.", FALSE, ch, obj, NULL, TO_CHAR); ------------------------------- /* If someone is quitting in their house, let them load back here. */ if (!PLR_FLAGGED(ch, PLR_LOADROOM) && ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOUSE)) - GET_LOADROOM(ch) = GET_ROOM_VNUM(IN_ROOM(ch)); + GET_LOADROOM(ch) = IN_ROOM(ch); ------------------------------ @@ -739,16 +734,9 @@ ACMD(do_display) skip_spaces(&argument); if (!*argument) { - send_to_char(ch, "Usage: prompt { { H | M | V } | all | auto | none }\r\n"); + send_to_char(ch, "Usage: prompt { { H | M | V } | all | none }\r\n"); return; } - - if (!str_cmp(argument, "auto")) { - TOGGLE_BIT(PRF_FLAGS(ch), PRF_DISPAUTO); - send_to_char(ch, "Auto prompt %sabled.\r\n", PRF_FLAGGED(ch, PRF_DISPAUTO) ? "en" : "dis"); - return; - } - @@ -768,13 +756,13 @@ ACMD(do_display) SET_BIT(PRF_FLAGS(ch), PRF_DISPMOVE); break; default: - send_to_char(ch, "Usage: prompt { { H | M | V } | all | auto | none }\r\n"); + send_to_char(ch, "Usage: prompt { { H | M | V } | all | none }\r\n"); return; ----------------------------- @@ -846,7 +834,7 @@ ACMD(do_gen_write) ACMD(do_gen_tog) { - long /* bitvector_t */ result; + long result; ----------------------------- @@ -482,8 +483,8 @@ void do_stat_object(struct char_data *ch sprintbit(GET_OBJ_EXTRA(j), extra_bits, buf, sizeof(buf)); send_to_char(ch, "Extra flags : %s\r\n", buf); - send_to_char(ch, "Weight: %d, Value: %d, Cost/day: %d, Timer: %d\r\n", - GET_OBJ_WEIGHT(j), GET_OBJ_COST(j), GET_OBJ_RENT(j), GET_OBJ_TIMER(j)); + sprintf(buf, "Weight: %d, Value: %d, Cost/day: %d, Timer: %d, Min Level: %d\r\n", + GET_OBJ_WEIGHT(j), GET_OBJ_COST(j), GET_OBJ_RENT(j), GET_OBJ_TIMER(j), GET_OBJ_LEVEL(j)); ----------------------------- @@ -1701,17 +1719,17 @@ ACMD(do_wiznet) (!PRF_FLAGGED(d->character, PRF_NOWIZ)) && (!PLR_FLAGGED(d->character, PLR_WRITING | PLR_MAILING)) && (d != ch->desc || !(PRF_FLAGGED(d->character, PRF_NOREPEAT)))) { - send_to_char(d->character, "%s", CCCYN(d->character, C_NRM)); + send_to_char(d->character, CCCYN(d->character, C_NRM)); if (CAN_SEE(d->character, ch)) - send_to_char(d->character, "%s", buf1); + send_to_char(d->character, buf1); else - send_to_char(d->character, "%s", buf2); - send_to_char(d->character, "%s", CCNRM(d->character, C_NRM)); + send_to_char(d->character, buf2); + send_to_char(d->character, CCNRM(d->character, C_NRM)); ----------------------------- @@ -1871,8 +1889,8 @@ size_t print_zone_to_buf(char *bufptr, s ACMD(do_show) { struct char_file_u vbuf; - int i, j, k, l, con, nlen; /* i, j, k to specifics? */ - size_t len; + int i, j, k, l, con; /* i, j, k to specifics? */ + size_t len, nlen; ----------------------------- diff -uNpr ../circle30bpl22.patch.using.this/src/boards.c ./src/boards.c --- ../circle30bpl22.patch.using.this/src/boards.c 2002-09-25 16:45:06.000000000 -0700 +++ ./src/boards.c 2002-12-06 21:58:57.000000000 -0800 @@ -416,11 +416,7 @@ int Board_remove_msg(int board_type, str MSG_SLOTNUM(board_type, ind) = MSG_SLOTNUM(board_type, ind + 1); MSG_LEVEL(board_type, ind) = MSG_LEVEL(board_type, ind + 1); } - MSG_HEADING(board_type, num_of_msgs[board_type] - 1) = NULL; - MSG_SLOTNUM(board_type, num_of_msgs[board_type] - 1) = 0; - MSG_LEVEL(board_type, num_of_msgs[board_type] - 1) = 0; num_of_msgs[board_type]--; - ----------------------------- + CREATE(OLC_CONFIG(d), struct config_data, 1); + + /****************************************************************************/ + /** Copy the current configuration from the config_info to this one. **/ + /****************************************************************************/ + CREATE(OLC_CONFIG(d)->play, struct game_data, 1); + CREATE(OLC_CONFIG(d)->csd, struct crash_save_data, 1); + CREATE(OLC_CONFIG(d)->room_nums, struct room_numbers, 1); + CREATE(OLC_CONFIG(d)->operation, struct game_operation, 1); + CREATE(OLC_CONFIG(d)->autowiz, struct autowiz_data, 1); === Why didn't you just embed the structures above into 'struct config_data' === like done for player_specials_saved? ----------------------------- +void cedit_disp_menu(struct descriptor_data *d) +{ + char buf[MAX_STRING_LENGTH]; + + get_char_colors(d->character); + clear_screen(d); + + /* + * Menu header + */ + sprintf(buf, + "OasisOLC MUD Configuration Editor\r\n" === Could be converted to variable argument write_to_output() ----------------------------- @@ -108,7 +102,6 @@ struct timeval null_time; /* zero-valued byte reread_wizlist; /* signal: SIGUSR1 */ byte emergency_unban; /* signal: SIGUSR2 */ FILE *logfile = NULL; /* Where to send the log messages. */ -const char *text_overflow = "**OVERFLOW**\r\n"; ----------------------------- @@ -756,19 +761,19 @@ void game_loop(socket_t mother_desc) for (d = descriptor_list; d; d = next_d) { next_d = d->next; if (*(d->output) && FD_ISSET(d->descriptor, &output_set)) { - /* Output for this player is ready. */ - - process_output(d); - if (d->bufptr == 0) /* All output sent. */ - d->has_prompt = TRUE; + /* Output for this player is ready */ + if (process_output(d) < 0) + close_socket(d); + else + d->has_prompt = 1; } } /* Print prompts for other descriptors who had no other output */ for (d = descriptor_list; d; d = d->next) { - if (!d->has_prompt && d->bufptr == 0) { + if (!d->has_prompt) { write_to_descriptor(d->descriptor, make_prompt(d)); - d->has_prompt = TRUE; + d->has_prompt = 1; } } ----------------------------- @@ -1128,26 +1125,12 @@ size_t vwrite_to_output(struct descripto int size; /* if we're in the overflow state already, ignore this new output */ - if (t->bufspace == 0) + if (t->bufptr < 0) return (0); wantsize = size = vsnprintf(txt, sizeof(txt), format, args); - /* If exceeding the size of the buffer, truncate it for the overflow message */ - if (size < 0 || wantsize >= sizeof(txt)) { + if (size < 0 || wantsize >= sizeof(txt)) size = sizeof(txt) - 1; - strcpy(txt + size - strlen(text_overflow), text_overflow); /* strcpy: OK */ - } - - /* - * If the text is too big to fit into even a large buffer, truncate - * the new text to make it fit. (This will switch to the overflow - * state automatically because t->bufspace will end up 0.) - */ - if (size + t->bufptr + 1 > LARGE_BUFSIZE) { - size = LARGE_BUFSIZE - t->bufptr - 1; - txt[size] = '\0'; - buf_overflows++; - } /* if we have enough space, just write to buffer and that's it! */ if (t->bufspace >= size) { @@ -1157,6 +1140,16 @@ size_t vwrite_to_output(struct descripto return (t->bufspace); } + /* + * If the text is too big to fit into even a large buffer, chuck the + * the new text, and switch to the overflow state. + */ + /* FIXME: This should write a partial string up to what fits! */ + if (size + t->bufptr > LARGE_BUFSIZE - 1) { + t->bufptr = -1; + buf_overflows++; + return (0); + } buf_switches++; /* if the pool has a buffer in it, grab it */ @@ -1391,6 +1385,8 @@ int new_descriptor(socket_t s) /* * Send all of the output that we've accumulated for a player out to * the player's descriptor. + * FIXME - This will be rewritten before 3.1, this code is dumb. + * FIXME: string nightmare * * 32 byte GARBAGE_SPACE in MAX_SOCK_BUF used for: * 2 bytes: prepended \r\n @@ -1400,22 +1396,22 @@ int new_descriptor(socket_t s) */ int process_output(struct descriptor_data *t) { - char i[MAX_SOCK_BUF], *osb = i + 2; + char i[MAX_SOCK_BUF]; int result; /* we may need this \r\n for later -- see below */ strcpy(i, "\r\n"); /* strcpy: OK (for 'MAX_SOCK_BUF >= 3') */ /* now, append the 'real' output */ - strcpy(osb, t->output); /* strcpy: OK (t->output:LARGE_BUFSIZE < osb:MAX_SOCK_BUF-2) */ + strcpy(i + 2, t->output); /* strcpy: OK (t->output:LARGE_BUFSIZE < i:MAX_SOCK_BUF-2) */ /* if we're in the overflow state, notify the user */ - if (t->bufspace == 0) - strcat(osb, "**OVERFLOW**\r\n"); /* strcpy: OK (osb:MAX_SOCK_BUF-2 reserves space) */ + if (t->bufptr < 0) + strcat(i, "**OVERFLOW**\r\n"); /* strcpy: OK (i:MAX_SOCK_BUF reserves space) */ /* add the extra CRLF if the person isn't in compact mode */ if (STATE(t) == CON_PLAYING && t->character && !IS_NPC(t->character) && !PRF_FLAGGED(t->character, PRF_COMPACT)) - strcat(osb, "\r\n"); /* strcpy: OK (osb:MAX_SOCK_BUF-2 reserves space) */ + strcat(i, "\r\n"); /* strcpy: OK (i:MAX_SOCK_BUF reserves space) */ /* add a prompt */ strcat(i, make_prompt(t)); /* strcpy: OK (i:MAX_SOCK_BUF reserves space) */ @@ -1424,60 +1420,29 @@ int process_output(struct descriptor_dat * now, send the output. If this is an 'interruption', use the prepended * CRLF, otherwise send the straight output sans CRLF. */ - if (t->has_prompt) { - t->has_prompt = FALSE; + if (t->has_prompt) /* && !t->connected) */ result = write_to_descriptor(t->descriptor, i); - if (result >= 2) - result -= 2; - } else - result = write_to_descriptor(t->descriptor, osb); - - if (result < 0) { /* Oops, fatal error. Bye! */ - close_socket(t); - return (-1); - } else if (result == 0) /* Socket buffer full. Try later. */ - return (0); + else + result = write_to_descriptor(t->descriptor, i + 2); - /* Handle snooping: prepend "% " and send to snooper. */ + /* handle snooping: prepend "% " and send to snooper */ if (t->snoop_by) - write_to_output(t->snoop_by, "%% %*s%%%%", result, t->output); - - /* The common case: all saved output was handed off to the kernel buffer. */ - if (result >= t->bufptr) { - /* - * if we were using a large buffer, put the large buffer on the buffer pool - * and switch back to the small one - */ - if (t->large_outbuf) { - t->large_outbuf->next = bufpool; - bufpool = t->large_outbuf; - t->large_outbuf = NULL; - t->output = t->small_outbuf; - } - /* reset total bufspace back to that of a small buffer */ - t->bufspace = SMALL_BUFSIZE - 1; - t->bufptr = 0; - *(t->output) = '\0'; - - /* - * If the overflow message or prompt were partially written, try to save - * them. There will be enough space for them if this is true. - */ - if (result < strlen(osb)) { - size_t savetextlen = strlen(osb + result); - - strcat(t->output, osb + result); - t->bufptr -= savetextlen; - t->bufspace += savetextlen; - } - - } else { - /* Not all data in buffer sent. result < output buffersize. */ + write_to_output(t->snoop_by, "%% %s%%%%", t->output); - strcpy(t->output, t->output + result); /* strcpy: OK (overlap) */ - t->bufptr -= result; - t->bufspace += result; - } + /* + * if we were using a large buffer, put the large buffer on the buffer pool + * and switch back to the small one + */ + if (t->large_outbuf) { + t->large_outbuf->next = bufpool; + bufpool = t->large_outbuf; + t->large_outbuf = NULL; + t->output = t->small_outbuf; + } + /* reset total bufspace back to that of a small buffer */ + t->bufspace = SMALL_BUFSIZE - 1; + t->bufptr = 0; + *(t->output) = '\0'; return (result); } @@ -1588,13 +1553,13 @@ ssize_t perform_socket_write(socket_t de * encountered. * * Returns: - * >=0 If all is well and good. - * -1 If an error was encountered, so that the player should be cut off. + * 0 If all is well and good, + * -1 If an error was encountered, so that the player should be cut off */ int write_to_descriptor(socket_t desc, const char *txt) { ssize_t bytes_written; - size_t total = strlen(txt), write_total = 0; + size_t total = strlen(txt); while (total > 0) { bytes_written = perform_socket_write(desc, txt, total); @@ -1604,16 +1569,20 @@ int write_to_descriptor(socket_t desc, c perror("SYSERR: Write to socket"); return (-1); } else if (bytes_written == 0) { - /* Temporary failure -- socket buffer full. */ - return (write_total); + /* + * Temporary failure -- socket buffer full. For now we'll just + * cut off the player, but eventually we'll stuff the unsent + * text into a buffer and retry the write later. JE 30 June 98. + */ + log("WARNING: write_to_descriptor: socket write would block, about to close"); + return (-1); } else { txt += bytes_written; total -= bytes_written; - write_total += bytes_written; } } - return (write_total); + return (0); } ----------------------------- diff -uNpr ../circle30bpl22.patch.using.this/src/conf.h ./src/conf.h --- ../circle30bpl22.patch.using.this/src/conf.h 1969-12-31 16:00:00.000000000 -0800 +++ ./src/conf.h 2002-12-06 21:58:57.000000000 -0800 === Shouldn't distribute a conf.h; you'll kill the one they already have. ----------------------------- +++ ./src/constants.c 2002-12-06 21:58:58.000000000 -0800 @@ -15,7 +15,8 @@ #include "interpreter.h" /* alias_data */ cpp_extern const char *circlemud_version = - "CircleMUD, version 3.00 beta patchlevel 22"; + "CircleMUD, version 3.00 beta patchlevel 22\r\n" + "OasisOLC v2.0.2 For CircleMUD v3.22\r\n"; === "3.0 bpl22" So people don't get confused when we do a "3.2" release. ----------------------------- @@ -47,6 +48,8 @@ struct zone_data *zone_table; /* zone ta zone_rnum top_of_zone_table = 0;/* top element of zone tab */ struct message_list fight_messages[MAX_MESSAGES]; /* fighting messages */ +struct config_data *config_info; /* Game configuration list. */ === Might as well be a static variable. (no-malloc) ----------------------------- +void load_config( void ) +{ + FILE *fl; + char line[MAX_STRING_LENGTH]; + char tag[MAX_INPUT_LENGTH]; + int num; + char buf2[128]; + + snprintf(buf2, strlen(buf2), "load_config()"); === A strcpy() is sufficient since you made it "128". ----------------------------- +/* + * NOTE: This clobbers some of the global variable strings. Do not + * save anything in them around calls to this function. + * + * buf1, buf2 + */ +int write_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd) === Those aren't global anymore, so no need for comment. ----------------------------- +/* ------------------------------------------------------------------------------------------------------------------------------ */ + +/* + * NOTE: This clobbers all of the global variable strings. Do not + * save anything in them around calls to this function. + * + * buf, buf1, buf2, arg + */ +int save_objects(zone_rnum zone_num) === Ditto. ----------------------------- +int genolc_checkstring(struct descriptor_data *d, const char *arg) +{ + char gcbuf[128]; + if (strchr(arg, STRING_TERMINATOR)) { + sprintf(gcbuf, "Sorry, you cannot use '%c' in your descriptions.\r\n", STRING_TERMINATOR); + write_to_output(d, gcbuf); + return FALSE; + } + return TRUE; +} === Variable argument write_to_output(). ----------------------------- diff -uNpr ../circle30bpl22.patch.using.this/src/i386 ./src/i386 --- ../circle30bpl22.patch.using.this/src/i386 1969-12-31 16:00:00.000000000 -0800 +++ ./src/i386 2002-12-06 21:58:58.000000000 -0800 @@ -0,0 +1,75 @@ + + === Delete this. ----------------------------- @@ -1179,13 +1198,7 @@ int perform_dupe_check(struct descriptor k->character->desc = NULL; k->character = NULL; k->original = NULL; - } else if (k->character && GET_IDNUM(k->character) == id && k->original) { - /* Character taking over their own body, while an immortal was switched to it. */ - - do_return(k->character, NULL, 0, 0); - } else if (k->character && GET_IDNUM(k->character) == id) { - /* Character taking over their own body. */ - + } else if (k->character && (GET_IDNUM(k->character) == id)) { ----------------------------- @@ -1238,7 +1251,7 @@ int perform_dupe_check(struct descriptor extract_char(ch); } - /* no target for switching into was found - allow login to continue */ + /* no target for swicthing into was found - allow login to continue */ ----------------------------- @@ -1146,7 +1164,10 @@ int _parse_name(char *arg, char *name) #define USURP 2 #define UNSWITCH 3 -/* This function seems a bit over-extended. */ +/* + * XXX: Make immortals 'return' instead of being disconnected when switched + * into person returns. This function seems a bit over-extended too. + */ int perform_dupe_check(struct descriptor_data *d) ----------------------------- @@ -1372,7 +1410,8 @@ void nanny(struct descriptor_data *d, ch STATE(d) = CON_NEWPASSWD; } else if (*arg == 'n' || *arg == 'N') { write_to_output(d, "Okay, what IS it, then? "); - free_char(d->character); + free(d->character->player.name); + d->character->player.name = NULL; ----------------------------- @@ -823,21 +823,15 @@ void mag_points(int level, struct char_d void mag_unaffects(int level, struct char_data *ch, struct char_data *victim, int spellnum, int type) { - int spell = 0, msg_not_affected = TRUE; + int spell = 0; const char *to_vict = NULL, *to_room = NULL; if (victim == NULL) return; switch (spellnum) { - case SPELL_HEAL: - /* - * Heal also restores health, so don't give the "no effect" message - * if the target isn't afflicted by the 'blindness' spell. - */ - msg_not_affected = FALSE; - /* fall-through */ case SPELL_CURE_BLIND: + case SPELL_HEAL: @@ -857,8 +851,8 @@ void mag_unaffects(int level, struct cha } if (!affected_by_spell(victim, spell)) { - if (msg_not_affected) - send_to_char(ch, "%s", NOEFFECT); + if (spellnum != SPELL_HEAL) /* 'cure blindness' message. */ + send_to_char(ch, "%s", config_info->play->NOEFFECT); return; } ----------------------------- medit.c +/* + * Local Variables +*/ +char buf[MAX_STRING_LENGTH]; +char buf1[MAX_STRING_LENGTH]; +char buf2[MAX_STRING_LENGTH]; === Ewww. I bet -Wshadow just loves you. ----------------------------- +ACMD(do_dig) +{ + struct room_data *room; + char sdir[10], sroom[10]; + int iroom = 0, rroom = 0, zone, dir = 0, counter; + struct descriptor_data *d = ch->desc; + char *room_name; + + /****************************************************************************/ + /** Grab the room's name (if available). **/ + /****************************************************************************/ + room_name = two_arguments(argument, sdir, sroom); === BAD BAD BAD. sdir[] and sroom[] must be MAX_INPUT_LENGTH big. ----------------------------- @@ -914,7 +915,7 @@ void shopping_list(char *arg, struct cha lindex++; if (!last_obj) /* we actually have nothing in our list for sale, period */ send_to_char(ch, "Currently, there is nothing for sale.\r\n"); - else if (*name && !found) /* nothing the char was looking for was found */ + else if (!found) /* nothing the char was looking for was found */ ----------------------------- @@ -1262,32 +1263,31 @@ void assign_the_shopkeepers(void) char *customer_string(int shop_nr, int detailed) { - int sindex = 0, flag = 1, nlen; + int sindex, cnt = 1, nlen; size_t len = 0; static char buf[256]; - while (*trade_letters[sindex] != '\n' && len + 1 < sizeof(buf)) { - if (detailed) { - if (!IS_SET(flag, SHOP_TRADE_WITH(shop_nr))) { - nlen = snprintf(buf + len, sizeof(buf) - len, ", %s", trade_letters[sindex]); - - if (len + nlen >= sizeof(buf) || nlen < 0) + for (sindex = 0; *trade_letters[sindex] != '\n' && len + 1 < sizeof(buf); sindex++, cnt <<= 1) + if (SHOP_TRADE_WITH(shop_nr) & cnt) { + if (!detailed) { + strlcpy(buf + len, "_", sizeof(buf) - len); + len++; + if (len >= sizeof(buf)) break; - - len += nlen; } } else { - buf[len++] = (IS_SET(flag, SHOP_TRADE_WITH(shop_nr)) ? '_' : *trade_letters[sindex]); - buf[len] = '\0'; - - if (len >= sizeof(buf)) + if (detailed) { + nlen = snprintf(buf + len, sizeof(buf) - len, "%s%s", len > 0 ? ", " : "", trade_letters[sindex]); + if (len + nlen >= sizeof(buf) || nlen < 0) + break; + len += nlen; + } else if (len + 2 <= sizeof(buf)) { + buf[len++] = *trade_letters[sindex]; + buf[len++] = '\0'; + } else break; } - sindex++; - flag <<= 1; - } - buf[sizeof(buf) - 1] = '\0'; return (buf); } @@ -1373,7 +1373,7 @@ void list_detailed_shop(struct char_data send_to_char(ch, "Rooms: None!"); send_to_char(ch, "\r\nShopkeeper: "); - if (SHOP_KEEPER(shop_nr) != NOBODY) { + if (SHOP_KEEPER(shop_nr) >= 0) { send_to_char(ch, "%s (#%d), Special Function: %s\r\n", GET_NAME(&mob_proto[SHOP_KEEPER(shop_nr)]), mob_index[SHOP_KEEPER(shop_nr)].vnum, ----------------------------- +++ ./src/spec_procs.c 2002-12-06 21:58:58.000000000 -0800 @@ -122,8 +122,8 @@ extern int prac_params[4][NUM_CLASSES]; void list_skills(struct char_data *ch) { const char *overflow = "\r\n**OVERFLOW**\r\n"; - int i, sortpos, nlen; - size_t len = 0; + int i, sortpos; + size_t len = 0, nlen; char buf2[MAX_STRING_LENGTH]; ----------------------------- +++ ./src/structs.h 2002-12-06 21:58:58.000000000 -0800 @@ -214,7 +214,7 @@ #define PRF_NOGOSS (1 << 19) /* Can't hear gossip channel */ #define PRF_NOGRATZ (1 << 20) /* Can't hear grats channel */ #define PRF_ROOMFLAGS (1 << 21) /* Can see room flags (ROOM_x) */ -#define PRF_DISPAUTO (1 << 22) /* Show prompt HP, MP, MV when < 30%. */ +#define PRF_CLS (1 << 22) /* Clear screen in OasisOLC */ ----------------------------- +++ ./src/sysdep.h 2002-12-06 21:58:58.000000000 -0800 @@ -485,7 +485,7 @@ struct in_addr { * but the prototype needed for FD_xxx macros on some machines. */ #ifdef NEED_BZERO_PROTO - void bzero(char *b, int length); + // void bzero(char *b, int length); #endif === Don't need this, that was fixed in a patchlevel. ----------------------------- @@ -297,8 +296,7 @@ void mudlog(int type, int level, int fil */ size_t sprintbit(bitvector_t bitvector, const char *names[], char *result, size_t reslen) { - size_t len = 0; - int nlen; + size_t len = 0, nlen; long nr; -----------------------------