diff -NaurBdw QuickMUD/src/Makefile rom/src/Makefile --- QuickMUD/src/Makefile Fri Feb 1 04:53:38 2002 +++ rom/src/Makefile Mon Apr 8 01:19:42 2002 @@ -14,7 +14,7 @@ # Uncomment these two lines to use plaintext passwords. # This is how you fix the 'crypt' linking errors! -C_FLAGS = -Wall $(PROF) -DNOCRYPT -DQMFIXES +C_FLAGS = -Wall $(PROF) -DQMFIXES L_FLAGS = $(PROF) # Source Files @@ -26,11 +26,11 @@ rom: $(OBJ_FILES) $(RM) -f $(EXE) - $(CC) $(L_FLAGS) -o $(EXE) $(OBJ_FILES) + $(CC) $(L_FLAGS) -o $(EXE) $(OBJ_FILES) -lcrypt $(OBJ_DIR)/%.o: %.c $(CC) $(C_FLAGS) -c -o $@ $< clean: - $(RM) -f $(OBJ_FILES) $(EXE) *~ *.bak *.orig *.rej + $(RM) -f $(OBJ_FILES) $(EXE) *~ *.bak *.orig *.rej *.~c *.~h *.c~ *.h~ diff -NaurBdw QuickMUD/src/account.c rom/src/account.c --- QuickMUD/src/account.c Wed Dec 31 16:00:00 1969 +++ rom/src/account.c Mon Apr 8 20:29:40 2002 @@ -0,0 +1,518 @@ +/*************************************************************************** + * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, * + * Michael Seifert, Hans Henrik Strfeldt, Tom Madsen, and Katja Nyboe. * + * * + * Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael * + * Chastain, Michael Quan, and Mitchell Tse. * + * * + * In order to use any part of this Merc Diku Mud, you must comply with * + * both the original Diku license in 'license.doc' as well the Merc * + * license in 'license.txt'. In particular, you may not remove either of * + * these copyright notices. * + * * + * Much time and thought has gone into this software and you are * + * benefitting. We hope that you share your changes too. What goes * + * around, comes around. * + **************************************************************************/ + +/*************************************************************************** + * ROM 2.4 is copyright 1993-1998 Russ Taylor * + * ROM has been brought to you by the ROM consortium * + * Russ Taylor (rtaylor@hypercube.org) * + * Gabrielle Taylor (gtaylor@hypercube.org) * + * Brian Moore (zump@rom.org) * + * By using this code, you have agreed to follow the terms of the * + * ROM license, in the file Rom24/doc/rom.license * + **************************************************************************/ + +/* + * Most account stuff wrote by Jobo from Dystopia MUD. + * Changed and ported by Daurven + */ + +#if defined(macintosh) +#include <types.h> +#else +#include <sys/types.h> +#include <sys/time.h> +#endif +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <time.h> +#include "merc.h" +#include "interp.h" + +ACCOUNT_DATA * account_free = NULL; + +ACCOUNT_DATA *load_account(char *name) +{ + ACCOUNT_DATA *account = NULL; + FILE *fp; + char pfile[256]; + char *word; + bool done = FALSE, found; + + /* open the account so we can read from it */ + sprintf(pfile, "../accounts/%s/account.dat", capitalize(name)); + if ((fp = fopen(pfile, "r")) == NULL) + return NULL; + + /* create new account data */ + account = alloc_account(); + + /* load data */ + word = fread_word(fp); + while (!done) + { + found = FALSE; + switch (word[0]) + { + case 'D': + IREAD( "Denied", account->denied ); + break; + case 'E': + if (!str_cmp(word, "EOF")) {done = TRUE; found = TRUE; break;} + break; + case 'L': + IREAD( "Level", account->level ); + break; + case 'O': + SREAD( "Owner", account->owner ); + break; + case 'P': + SREAD( "Password", account->password ); + IREAD( "PCount", account->p_count ); + SREAD( "Players", account->players ); + break; + } + + if (!found) + { + char buf[MAX_STRING_LENGTH]; + + sprintf(buf, "Load_account: unexpected '%s' in /%s/account.dat.", word, name); + bug(buf, 0); + close_account(account); + return NULL; + } + + /* read one more */ + if (!done) word = fread_word(fp); + } + fclose(fp); + return account; +} + +void save_account(ACCOUNT_DATA *account) +{ + FILE *fp; + char pfile[256]; + + /* open the account file so we can write to it */ + sprintf(pfile, "../accounts/%s/account.dat", account->owner); + if ((fp = fopen(pfile, "w")) == NULL) + { + char buf[MAX_STRING_LENGTH]; + + sprintf(buf, "Unable to write to %s's account file", account->owner); + bug(buf, 0); + return; + } + + /* save the account data */ + fprintf(fp, "Denied %ld\n", account->denied ); + fprintf(fp, "Level %d\n", account->level ); + fprintf(fp, "Owner %s~\n", account->owner ); + fprintf(fp, "Password %s~\n", account->password ); + fprintf(fp, "PCount %d\n", account->p_count ); + fprintf(fp, "Players %s~\n", account->players ); + + /* terminate the file */ + fprintf(fp, "EOF\n"); + fclose(fp); +} + +ACCOUNT_DATA *alloc_account() +{ + static ACCOUNT_DATA clear_account; + ACCOUNT_DATA *account; + + if (account_free) + { + account = account_free; + account_free = account_free->next; + } + else + { + if ((account = alloc_perm(sizeof(*account))) == NULL) + { + bug("Alloc_account: Cannot allocate memory.", 0); + abort(); + } + } + *account = clear_account; + account->owner = str_dup(""); + account->password = str_dup(""); + account->new_password = str_dup(""); + account->players = str_dup(""); + account->level = PLAYER_ACCOUNT; + account->denied = (time_t) 0; + account->p_count = 0; + + return account; +} + +void close_account(ACCOUNT_DATA *account) +{ + /* free the memory */ + free_string(account->players); + free_string(account->password); + free_string(account->owner); + free_string(account->new_password); + + /* attach to free list */ + account->next = account_free; + account_free = account; +} +/* + + _ _ + ,/ \, + _________{( })_________ + /.-------./\\ //\.-------.\ + //@@@@@@@//@@\\ ) ( //@@\\@@@@@@@\\ + //@@@@@@@//@@@@>>/ \<<@@@@\\@@@@@@@\\ + //O@O@O@O//@O@O// \\O@O@\\O@O@O@O\\ + //OOOOOOOO//OOOO|| \ / ||OOOO\\OOOOOOOO\\ + //O%O%O%O%//O%O%O%\\ ))(( //%O%O%O\\%O%O%O%O\\ +||%%%%%%%%//' `%%%%\\ // \\ //%%%%' `\\%%%%%%%|| +((%%%%%%%(( %%%%%\\ (( )) //%%%%% ))%%%%%%)) + \:::' `::\\ `:::::\\ \)~~(/ //:::::' //::' `:::/ + )' `;)' (` ` \\ `<@ @>' / / ' ') `(;' `( + ( \`\ )^^( / / ) + _ ) \\oo/ ( + (@) \ `' / _ + |-|\__________________\__^__<________oOo__________ (@) + | | VVV \|-| + |-| |-| + |_|\_____________________________________________ | | + (@) / ,/ \_____/ \\ ~\/~ `\|-| + ~ ___//^~ \____/\\ (@) + <<< \ __ <____/|| ~ + < \ <___/|| + || <___// + \ \/__// + ~----~ + + + , \ -.__...--.__ _ / / + _|\_ .' ) ,~~ / +_ ("} - : '. _ <=) _/_ +Y_.-@-._ _ \ .' _ /I\.="==.{> +B--, .-`~ ( ) \I/-\T/-' +I /==\ (_ / /_\ +I | \ (___, _..__) _ // \\_ +I /____\ -' '--' _I / + + + + _ _ ______________________ + _____________ __ _ \../ _ __ ____ -=(_)____________________)=- _ +| // \_=>OO<=_ / \\ / _/ | +| ______ /X\ \ \oo/\ / /\\ /~ / | +|| | \\\\ \ `'\^\/ /\ \\ (~ ( | +|| ===' \\\\ \ /^/ /\ \ \\ \ ------------------~\ | +|| | \XX\_\/^.\/\/\/\/\\ \ \ | +|| | _-~^^^^/)\v\__ \_ ======== \ | +|| | /^^^^^^_// \__ \ \ \ | +| ~~~~~~ \^^___/ \ /// \_ ======== ~\ | +| |^^/\/\ (// ) ) | +| |^| ^ \ ( /~ _/ | +| \^\_ ^ __/ _/____________________/ | +|________________ \^^-----_/ ________ -=(_)____________________)=- _| + ~----~~ + + +o--====---------------------------------------------------------===--o + ___ ___ __________________ ___ ___ + ____/ _ \__/ _ \_____ (------------------) _____/ _ \__/ _ \____ + ( _| / \/ \/ \ |_ ) \ / ( _| / \/ \/ \ |_ ) + \( \| ) ( |/ ) (___) __________ (___) ( \| ) ( |/ )/ + ` ` \`'/ ' (_________) (_________) ` \`'/ ' ' + || || + `' `' + + + + Does not tell you how many Door = 0 files to modify in each file. Not detailed enough. + Forgot to add rev_dir and its based on your door #'s. If your set up north, east, south, + west, up, down, northeast, southeast, southwest, northwest then your rev_dir should look + like this: +2, 3, 0, 1, 5, 4, 6, 7, 8, 9 if it is not and you create a room your exit names will be +messed up. +There is some other information not included. + +*/ +void show_options(DESCRIPTOR_DATA *dsock) +{ + char buf[MAX_STRING_LENGTH]; + extern char *help_menu_1; + + send_to_desc("\x1B[H\x1B[J",dsock); + if (help_menu_1[0] == '.') + send_to_desc (help_menu_1 + 1, dsock); + else + send_to_desc (help_menu_1, dsock); + sprintf(buf, "\n\rWelcome %s, whats your choice today.", dsock->account->owner); + send_to_desc(buf, dsock); +} + +struct plist *parse_player_list(char *list) +{ + CHAR_DATA *dMob; + struct plist *p_list; + char tempbuf[MAX_STRING_LENGTH]; + bool first = TRUE; + int total_time = 0; + + if ((p_list = malloc(sizeof(*p_list))) == NULL) + { + bug("Parse_player_list: Cannot allocate memory", 0); + abort(); + } + p_list->count = 0; + + while (*list != '\0') + { + char name[20]; + char race[20]; + char *ptr1, *ptr2; + int played = 0; + bool in_game = FALSE; + + name[0] = '\0'; ptr1 = name; + race[0] = '\0'; ptr2 = race; + + /* get the name */ + while (*list != ' ') + *ptr1++ = *list++; + *ptr1 = '\0'; list++; + + /* is that player already logged on ?? */ + for (dMob = char_list; dMob; dMob = dMob->next) + { + if (IS_NPC(dMob)) continue; + if (!str_cmp(dMob->name, name)) + in_game = TRUE; + } + + /* get the race */ + while (*list != ' ') + *ptr2++ = *list++; + *ptr2 = '\0'; list++; + + /* get the hours */ + while (*list != ' ' && *list != '\0') + { + played *= 10; + played += *list++ - '0'; + } + if (*list == ' ') list++; + + p_list->count++; + sprintf(tempbuf, " [%d] %-12s %-12s %5d hour%s%s\n\r", + p_list->count, name, race, played, (played == 1) ? "" : "s", + (in_game) ? " (active)" : ""); + + /* add up */ + total_time += played; + + if (first) + { + first = FALSE; + sprintf(p_list->text, "%s", tempbuf); + } + else strcat(p_list->text, tempbuf); + } + + /* should we add a line with the total time ? */ + if (!first) + { + sprintf(tempbuf, "%34s %5d hour%s total\n\r", " ", total_time, (total_time == 1) ? "" : "s"); + strcat(p_list->text, tempbuf); + } + + return p_list; +} + +char *get_option_login(char *list, int option) +{ + static char buf[MAX_STRING_LENGTH]; + int current = 1, i = 0; + + buf[0] = '\0'; + + /* saves some time */ + if (option < 1) return NULL; + + while (*list != '\0') + { + /* get the name */ + while (*list != ' ') + { + if (current == option) buf[i++] = *list; + list++; + } + if (current == option) + { + buf[i] = '\0'; + return buf; + } + list++; + + /* scan past race */ + while (*list++ != ' ') ; + + /* scan past hours */ + while (*list != '\0' && *list++ != ' ') ; + + current++; + } + + if (buf[0] == '\0') + return NULL; + else + return buf; +} + +/* + * check reconnect is called before this procedure, + * so we don't have to worry about this being the + * same char as the one trying to logon. + */ +bool already_logged(char *name) +{ + CHAR_DATA *dMob; + + for (dMob = char_list; dMob; dMob = dMob->next) + { + if (IS_NPC(dMob)) continue; + if (!str_cmp(dMob->pcdata->account, name)) + return TRUE; + } + return FALSE; +} + +void account_update(ACCOUNT_DATA *account, CHAR_DATA *dMob) +{ + char buf[MAX_STRING_LENGTH], name[MAX_STRING_LENGTH]; + char *ptr, *list; + int i = 0, j = 0; + + buf[0] = '\0'; + ptr = buf; + list = account->players; + + /* first we error check */ + if (!is_full_name(dMob->name, account->players)) + { + sprintf(buf, "Account_update: %s not in %s's playerlist", dMob->name, account->owner); + bug(buf, 0); + return; + } + + /* then we parse */ + while (1) + { + one_argument(list + i, name); + if (!str_cmp(name, dMob->name)) + { + /* scan past name */ + while ((buf[i + j] = *(list+i)) != ' ') + i++; + i++; + + /* scan past race */ + while ((buf[i + j] = *(list+i)) != ' ') + i++; + i++; + + /* parse correct time */ + { + char tempbuf[MAX_STRING_LENGTH]; + int count = 0; + + sprintf(tempbuf, "%d", + (dMob->played + (int) (current_time - dMob->logon))/3600); + while ((buf[i + j] = tempbuf[count++]) != '\0') + j++; + + /* change that to a space */ + buf[i + j] = ' '; + + /* skip past the old time entry */ + while (*(list+i) != '\0' && *(list+i) != ' ') + i++, j--; + + if (*(list + (i++)) == '\0') + { + buf[i + j - 1] = '\0'; + break; + } + } + } + else // scan forward one entry + { + /* scan past name */ + while ((buf[i + j] = *(list+i)) != ' ') + i++; + i++; + + /* scan past race */ + while ((buf[i + j] = *(list+i)) != ' ') + i++; + i++; + + /* scan past hours */ + while ((buf[i + j] = *(list+i)) != '\0' && *(list+i) != ' ') + i++; + + /* found the end */ + if (*(list + (i++)) == '\0') + break; + } + } + + /* then we copy */ + free_string(account->players); + account->players = str_dup(buf); + + /* and finally we save */ + save_account(account); +} + +void account_new_player(ACCOUNT_DATA *account, CHAR_DATA *dMob) +{ + char buf[MAX_STRING_LENGTH]; + + sprintf(buf, "%s%s%s %d", + account->players, (account->players[0] == '\0') ? "" : " ", + dMob->name, dMob->played/3600); + free_string(account->players); + account->players = str_dup(buf); + save_account(account); +} + +void create_new_account(ACCOUNT_DATA *account) +{ + char buf[MAX_STRING_LENGTH]; + + /* create the directory */ + sprintf(buf, "mkdir ../accounts/%s", account->owner); + system(buf); + + /* save the account */ + save_account(account); +} diff -NaurBdw QuickMUD/src/act_comm.c rom/src/act_comm.c --- QuickMUD/src/act_comm.c Mon Apr 16 12:43:12 2001 +++ rom/src/act_comm.c Tue Apr 9 13:23:24 2002 @@ -36,12 +36,12 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <ctype.h> /* for isalpha() and isspace() -- JR */ #include <time.h> #include "merc.h" #include "interp.h" #include "recycle.h" #include "tables.h" -#include <ctype.h> /* for isalpha() and isspace() -- JR */ /* RT code to delete yourself */ @@ -68,7 +68,9 @@ } else { - sprintf (strsave, "%s%s", PLAYER_DIR, capitalize (ch->name)); + sprintf ( strsave, "%s%s/%s", PLAYER_DIR, ch->pcdata->account, + capitalize( ch->name ) ); + ch->desc->account->p_count--; wiznet ("$N turns $Mself into line noise.", ch, NULL, 0, 0, 0); stop_fighting (ch, TRUE); do_function (ch, &do_quit, ""); @@ -1197,7 +1199,7 @@ * All the posing stuff. */ struct pose_table_type { - char *message[2 * MAX_CLASS]; + char *message[2 * MAX_PC_RACE]; }; const struct pose_table_type pose_table[] = { @@ -1420,9 +1422,9 @@ UMIN (ch->level, sizeof (pose_table) / sizeof (pose_table[0]) - 1); pose = number_range (0, level); - act (pose_table[pose].message[2 * ch->class + 0], ch, NULL, NULL, + act (pose_table[pose].message[2 * ch->race + 0], ch, NULL, NULL, TO_CHAR); - act (pose_table[pose].message[2 * ch->class + 1], ch, NULL, NULL, + act (pose_table[pose].message[2 * ch->race + 1], ch, NULL, NULL, TO_ROOM); return; @@ -1791,8 +1793,8 @@ sprintf (buf, "[%2d %s] %-16s %4d/%4d hp %4d/%4d mana %4d/%4d mv %5d xp\n\r", gch->level, - IS_NPC (gch) ? "Mob" : class_table[gch-> - class].who_name, + IS_NPC (gch) ? "Mob" : race_table[gch-> + race].name, capitalize (PERS (gch, ch)), gch->hit, gch->max_hit, gch->mana, gch->max_mana, gch->move, gch->max_move, gch->exp); diff -NaurBdw QuickMUD/src/act_info.c rom/src/act_info.c --- QuickMUD/src/act_info.c Fri Dec 1 03:48:32 2000 +++ rom/src/act_info.c Tue Apr 9 13:28:50 2002 @@ -1493,10 +1491,9 @@ send_to_char (buf, ch); } - sprintf (buf, "Race: %s Sex: %s Class: %s\n\r", + sprintf (buf, "Race: %s Sex: %s\n\r", race_table[ch->race].name, - ch->sex == 0 ? "sexless" : ch->sex == 1 ? "male" : "female", - IS_NPC (ch) ? "mobile" : class_table[ch->class].name); + ch->sex == 0 ? "sexless" : ch->sex == 1 ? "male" : "female"); send_to_char (buf, ch); diff -NaurBdw QuickMUD/src/act_move.c rom/src/act_move.c --- QuickMUD/src/act_move.c Fri Dec 1 03:48:32 2000 +++ rom/src/act_move.c Mon Apr 8 02:38:26 2002 @@ -39,15 +39,25 @@ #include "merc.h" #include "interp.h" -char *const dir_name[] = { - "north", "east", "south", "west", "up", "down" +char *const dir_name[] = +{ + "north", "east", "south", "west", "up", "down", + "northwest", "northeast", "southwest", "southeast" }; -const sh_int rev_dir[] = { - 2, 3, 0, 1, 5, 4 +char * const dir_rev [] = +{ + "the south", "the west", "the north", "the east", "below", "above", + "the southeast", "the southwest", "the northeast", "the northwest" }; -const sh_int movement_loss[SECT_MAX] = { +const sh_int rev_dir[] = +{ + 2, 3, 0, 1, 5, 4, 6, 7, 8, 9 +}; + +const sh_int movement_loss[SECT_MAX] = +{ 1, 2, 2, 3, 4, 6, 4, 1, 6, 10, 6 }; diff -NaurBdw QuickMUD/src/act_wiz.c rom/src/act_wiz.c --- QuickMUD/src/act_wiz.c Fri Feb 1 04:01:18 2002 +++ rom/src/act_wiz.c Sat Apr 6 13:49:56 2002 @@ -512,9 +512,93 @@ return; } +void do_deny(CHAR_DATA *ch, char *argument) +{ + CHAR_DATA *victim; + char target[MAX_STRING_LENGTH]; + int days; + argument = one_argument(argument, target); -void do_deny (CHAR_DATA * ch, char *argument) + if ( target[0] == '\0' || !is_number( argument ) ) + { + send_to_char("Syntax: Deny <player> <days>\n\r", ch); + return; + } + + if ( ( days = atoi( argument ) ) < 1 || days > 30 ) + { + send_to_char("Between 1 and 30 days, please.\n\r", ch); + return; + } + + if ( ( victim = get_char_world( ch, target ) ) == NULL ) + { + send_to_char("That player is not online.\n\r", ch); + return; + } + + if (IS_NPC (victim)) + { + send_to_char ("Not on NPC's.\n\r", ch); + return; + } + + if ( victim->desc == NULL ) + { + send_to_char("That player does not have a live connection.\n\r", ch); + return; + } + + if ( victim->trust >= ch->trust ) + { + send_to_char("You failed.\n\r", ch); + return; + } + + victim->desc->account->denied = current_time + ( days * 24L * 3600L ); + sprintf( target, "You have been denied for %d days.\n\r", days ); + write_to_buffer( victim->desc, target, 0 ); + save_char_obj( victim ); + stop_fighting( victim, TRUE ); + do_function( victim, &do_quit, "" ); + + send_to_char("They have been denied.\n\r", ch); +} + +void do_undeny(CHAR_DATA *ch, char *argument) +{ + ACCOUNT_DATA *account; + char arg[MAX_STRING_LENGTH]; + + one_argument(argument, arg); + + if ( arg[0] == '\0' ) + { + send_to_char("Undeny whom?\n\r", ch); + return; + } + + if ( ( account = load_account( arg ) ) == NULL ) + { + send_to_char("There is no account by that name.\n\r", ch); + return; + } + + if ( account->denied <= current_time ) + { + send_to_char("That account is not denied.\n\r", ch); + close_account( account ); + return; + } + + account->denied = current_time; + save_account( account ); + close_account( account ); + send_to_char("Account undenied.\n\r", ch); +} + +void do_deny_player (CHAR_DATA * ch, char *argument) { char arg[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH]; CHAR_DATA *victim; @@ -2734,6 +2818,15 @@ victim->exp = exp_per_level (victim, victim->pcdata->points) * UMAX (1, victim->level); victim->trust = 0; + if ( IS_IMMORTAL( victim ) ) { + if (victim->desc) + victim->desc->account->level = ADMIN_ACCOUNT; + } + else + { + if (victim->desc) + victim->desc->account->level = PLAYER_ACCOUNT; + } save_char_obj (victim); return; } @@ -4532,20 +4622,9 @@ } else { - fprintf (fp, "%d %s %s\n", d->descriptor, och->name, d->host); - -#if 0 /* This is not necessary for ROM */ - if (och->level == 1) - { - write_to_descriptor (d->descriptor, - "Since you are level one, and level one characters do not save, you gain a free level!\n\r", - 0); - advance_level (och); - och->level++; /* Advance_level doesn't do that */ - } -#endif + fprintf(fp, "%d %s %s %s\n", d->descriptor, och->name, + och->pcdata->account, d->host); save_char_obj (och); - write_to_descriptor (d->descriptor, buf, 0); } } @@ -4576,9 +4652,10 @@ void copyover_recover () { DESCRIPTOR_DATA *d; + ACCOUNT_DATA *acc; FILE *fp; char name[100]; - char host[MSL]; + char host[MSL], account[100]; int desc; bool fOld; @@ -4597,7 +4674,7 @@ for (;;) { - fscanf (fp, "%d %s %s\n", &desc, name, host); + fscanf (fp, "%d %s %s %s\n", &desc, name, account, host); if (desc == -1) break; @@ -4612,6 +4689,12 @@ d = new_descriptor (); d->descriptor = desc; + acc = load_account(account); + d->account = acc; + /* + d = new_descriptor (); + d->descriptor = desc; + */ d->host = str_dup (host); d->next = descriptor_list; descriptor_list = d; diff -NaurBdw QuickMUD/src/comm.c rom/src/comm.c --- QuickMUD/src/comm.c Fri Feb 1 03:49:48 2002 +++ rom/src/comm.c Mon Apr 8 02:23:26 2002 @@ -540,7 +540,7 @@ */ dcon.descriptor = 0; if (!mud_ansiprompt) - dcon.connected = CON_GET_NAME; + dcon.connected = CON_ACCOUNT_NAME; else dcon.connected = CON_ANSI; dcon.ansi = mud_ansicolor; @@ -953,9 +953,10 @@ dnew->descriptor = desc; if (!mud_ansiprompt) - dnew->connected = CON_GET_NAME; + dnew->connected = CON_ACCOUNT_NAME; else dnew->connected = CON_ANSI; + dnew->account = NULL; dnew->ansi = mud_ansicolor; dnew->showstr_head = NULL; dnew->showstr_point = NULL; @@ -1080,6 +1081,9 @@ if (d_next == dclose) d_next = d_next->next; + if (dclose->account) + close_account(dclose->account); + if (dclose == descriptor_list) { descriptor_list = descriptor_list->next; @@ -1462,7 +1466,7 @@ } } if (!found) - strcat (buf, "none"); + strcat (doors, "none"); sprintf (buf2, "%s", doors); i = buf2; break; @@ -1874,7 +1878,7 @@ { if (dold != d && dold->character != NULL - && dold->connected != CON_GET_NAME + && dold->connected != CON_ACCOUNT_NAME && dold->connected != CON_GET_OLD_PASSWORD && !str_cmp (name, dold->original ? dold->original->name : dold->character->name)) diff -NaurBdw QuickMUD/src/db.c rom/src/db.c --- QuickMUD/src/db.c Thu Jan 31 20:44:00 2002 +++ rom/src/db.c Mon Apr 8 06:41:18 2002 @@ -89,6 +89,7 @@ char bug_buf[2 * MAX_INPUT_LENGTH]; CHAR_DATA *char_list; char *help_greeting; +char *help_menu_1; char log_buf[2 * MAX_INPUT_LENGTH]; KILL_DATA kill_table[MAX_LEVEL]; OBJ_DATA *object_list; @@ -646,6 +647,9 @@ if (!str_cmp (pHelp->keyword, "greeting")) help_greeting = pHelp->text; + if (!str_cmp (pHelp->keyword, "menu_1")) + help_menu_1 = pHelp->text; + if (help_first == NULL) help_first = pHelp; if (help_last != NULL) diff -NaurBdw QuickMUD/src/merc.h rom/src/merc.h --- QuickMUD/src/merc.h Thu Jan 31 20:44:56 2002 +++ rom/src/merc.h Sat Apr 6 14:17:56 2002 @@ -79,6 +79,7 @@ /* * Structure types. */ +typedef struct account_data ACCOUNT_DATA; typedef struct affect_data AFFECT_DATA; typedef struct area_data AREA_DATA; typedef struct ban_data BAN_DATA; @@ -203,6 +204,25 @@ #define NORMAL 0 /* Bright/Normal colours */ #define BRIGHT 1 +#define IREAD(sKey, sPtr) \ +{ \ + if (!str_cmp(sKey, word)) \ + { \ + sPtr = fread_number(fp); \ + found = TRUE; \ + break; \ + } \ +} +#define SREAD(sKey, sPtr) \ +{ \ + if (!str_cmp(sKey, word)) \ + { \ + sPtr = fread_string(fp); \ + found = TRUE; \ + break; \ + } \ +} + #define ALTER_COLOUR( type ) if( !str_prefix( argument, "red" ) ) \ { \ ch->pcdata->type[0] = NORMAL; \ @@ -382,9 +402,14 @@ /* * Connected state for a channel. */ -#define CON_GET_NAME -14 +#define CON_ACCOUNT_NAME -19 +#define CON_CONFIRM_ACCOUNT -18 +#define CON_PICK_PLAYER -17 +#define CON_DELETE_PLAYER -16 +#define CON_CONFIRM_DEL_PLAYER -15 +#define CON_NEW_PLAYER -14 #define CON_GET_OLD_PASSWORD -13 -#define CON_CONFIRM_NEW_NAME -12 +#define CON_CONFIRM_PLAYER -12 #define CON_GET_NEW_PASSWORD -11 #define CON_CONFIRM_NEW_PASSWORD -10 #define CON_ANSI -9 @@ -407,6 +432,28 @@ #define CON_NOTE_TEXT 8 #define CON_NOTE_FINISH 9 +/* + * account levels + */ +#define PLAYER_ACCOUNT 1 +#define ADMIN_ACCOUNT 2 +#define OWNER_ACCOUNT 3 + +/* + * account data + */ +struct account_data +{ + ACCOUNT_DATA * next; /* next active account */ + char * owner; /* the accounts owner (login name) */ + char * password; /* the accounts password (crypt) */ + char * new_password; /* used when changing password */ + char * players; /* the list of players owned */ + time_t denied; /* how long is this account denied */ + sh_int level; /* the trust-level of this account */ + sh_int p_count; /* amount of created characters */ + bool ansi; +}; /* * Descriptor (channel) structure. @@ -417,6 +464,7 @@ DESCRIPTOR_DATA * snoop_by; CHAR_DATA * character; CHAR_DATA * original; + ACCOUNT_DATA * account; bool valid; bool ansi; char * host; @@ -471,6 +519,11 @@ sh_int shock; }; +struct plist +{ + char text[MAX_STRING_LENGTH]; /* the list of players */ + int count; /* the amount of players */ +}; /* @@ -1645,6 +1698,7 @@ char * bamfin; char * bamfout; char * title; + char * account; sh_int perm_hit; sh_int perm_mana; sh_int perm_move; @@ -2206,6 +2260,7 @@ extern NOTE_DATA * note_free; extern OBJ_DATA * obj_free; extern bool MOBtrigger; +extern ACCOUNT_DATA * account_free; /* * OS-dependent declarations. @@ -2319,7 +2374,7 @@ #endif #if defined(unix) -#define PLAYER_DIR "../player/" /* Player files */ +#define PLAYER_DIR "../accounts/" /* Player files */ #define GOD_DIR "../gods/" /* list of gods */ #define TEMP_FILE "../player/romtmp" #define NULL_FILE "/dev/null" /* To reserve one stream */ @@ -2348,6 +2403,23 @@ #define AD AFFECT_DATA #define MPC MPROG_CODE +/********************************************************************** + * Contains functions and variables for use with file account.c * + * The file is for the account system. * + **********************************************************************/ +ACCOUNT_DATA *load_account args( ( char *name ) ); +void save_account args( ( ACCOUNT_DATA *account ) ); +void create_new_account args( ( ACCOUNT_DATA *account ) ); +void account_new_player args( ( ACCOUNT_DATA *account, CHAR_DATA *dMob ) ); +void account_update args( ( ACCOUNT_DATA *account, CHAR_DATA *dMob ) ); +bool already_logged args( ( char *name ) ); +char *get_option_login args( ( char *list, int option ) ); +void show_options args( ( DESCRIPTOR_DATA *dsock ) ); +struct plist *parse_player_list args( ( char *list ) ); +void close_account args( ( ACCOUNT_DATA *account ) ); +ACCOUNT_DATA *alloc_account args( ( void ) ); + + /* act_comm.c */ void check_sex args( ( CHAR_DATA *ch) ); void add_follower args( ( CHAR_DATA *ch, CHAR_DATA *master ) ); diff -NaurBdw QuickMUD/src/nanny.c rom/src/nanny.c --- QuickMUD/src/nanny.c Thu May 3 11:54:54 2001 +++ rom/src/nanny.c Mon Apr 8 20:31:26 2002 @@ -115,13 +115,14 @@ void nanny (DESCRIPTOR_DATA * d, char *argument) { DESCRIPTOR_DATA *d_old, *d_next; + ACCOUNT_DATA *account; char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; CHAR_DATA *ch; - char *pwdnew; + char *pwdnew, *option; char *p; - int iClass, race, i, weapon; bool fOld; + int iClass, race, i, weapon; extern int mud_telnetga, mud_ansicolor; /* Delete leading spaces UNLESS character is writing a note */ @@ -145,7 +146,7 @@ { d->ansi = TRUE; send_to_desc ("{RAnsi enabled!{x\n\r", d); - d->connected = CON_GET_NAME; + d->connected = CON_ACCOUNT_NAME; { extern char *help_greeting; if (help_greeting[0] == '.') @@ -160,7 +161,7 @@ { d->ansi = FALSE; send_to_desc ("Ansi disabled!\n\r", d); - d->connected = CON_GET_NAME; + d->connected = CON_ACCOUNT_NAME; { extern char *help_greeting; if (help_greeting[0] == '.') @@ -177,67 +178,111 @@ } - case CON_GET_NAME: + case CON_ACCOUNT_NAME: if (argument[0] == '\0') { close_socket (d); return; } - argument[0] = UPPER (argument[0]); - if (!check_parse_name (argument)) + if ( check_ban( d->host, BAN_ALL) ) { - send_to_desc ("Illegal name, try another.\n\rName: ", d); + write_to_buffer(d, "Your site has been banned from this mud\n\r", 0); + close_socket(d); return; } - fOld = load_char_obj (d, argument); - ch = d->character; - - if (IS_SET (ch->act, PLR_DENY)) + argument = capitalize(argument); + if (!check_parse_name(argument)) { - sprintf (log_buf, "Denying access to %s@%s.", argument, - d->host); - log_string (log_buf); - send_to_desc ("You are denied access.\n\r", d); - close_socket (d); + write_to_buffer( d, "Illegal account name, try another.\n\r" + "What is your account name? ", 0 ); return; } - if (check_ban (d->host, BAN_PERMIT) - && !IS_SET (ch->act, PLR_PERMIT)) + if (strlen(argument) < 3 + || (account = load_account(argument)) == NULL) { - send_to_desc ("Your site has been banned from this mud.\n\r", - d); + /* wizlock */ + if (wizlock) + { + write_to_buffer(d, "Currently wizlocked.\n\r", 0); close_socket (d); return; } - if (check_reconnect (d, argument, FALSE)) - { - fOld = TRUE; + account = alloc_account(); + account->owner = str_dup(argument); + d->account = account; + d->connected = CON_CONFIRM_ACCOUNT; + sprintf(buf, "Do you wish to create a new account" + " called '%s' (yes|no)? ", argument); + write_to_buffer(d, buf, 0); + return; } - else + + d->account = account; + if (account->denied > current_time) { - if (wizlock && !IS_IMMORTAL (ch)) + sprintf(log_buf, "Denying access to %s@%s.", + account->owner, d->host); + log_string(log_buf); + write_to_buffer(d, "You are denied access.\n\r", 0); + close_socket(d); + return; + } + + /* wizlock */ + if (wizlock && account->level < ADMIN_ACCOUNT) { - send_to_desc ("The game is wizlocked.\n\r", d); + write_to_buffer(d, "Currenly wizlocked.\n\r", 0); close_socket (d); return; } + + /* ask for password */ + write_to_buffer(d, "Please enter password: ", 0); + write_to_buffer(d, echo_off_str, 0); + d->connected = CON_GET_OLD_PASSWORD; + break; + + case CON_NEW_PLAYER: + argument[0] = UPPER (argument[0]); + if (!check_parse_name (argument)) + { + send_to_desc ("Illegal name, try another.\n\rName: ", d); + return; } + fOld = load_char_obj( d, argument ); + ch = d->character; + if (fOld) { - /* Old player */ - send_to_desc ("Password: ", d); - write_to_buffer (d, echo_off_str, 0); - d->connected = CON_GET_OLD_PASSWORD; + if (check_playing (d, ch->name)) + return; + + if (check_reconnect (d, ch->name, TRUE)) return; + + sprintf (log_buf, "Account %s, Player %s@%s has connected.", + d->account->owner, ch->name, d->host); + log_string (log_buf); + wiznet (log_buf, NULL, NULL, WIZ_SITES, 0, get_trust (ch)); + + if (IS_IMMORTAL (ch)) + { + do_function (ch, &do_help, "imotd"); + d->connected = CON_READ_IMOTD; + } + else + { + do_function (ch, &do_help, "motd"); + d->connected = CON_READ_MOTD; + } } else { - /* New player */ if (newlock) { send_to_desc ("The game is newlocked.\n\r", d); @@ -256,7 +301,8 @@ sprintf (buf, "Did I get that right, %s (Y/N)? ", argument); send_to_desc (buf, d); - d->connected = CON_CONFIRM_NEW_NAME; + load_char_obj(d, argument); + d->connected = CON_CONFIRM_PLAYER; return; } break; @@ -266,7 +312,8 @@ write_to_buffer (d, "\n\r", 2); #endif - if (strcmp (crypt (argument, ch->pcdata->pwd), ch->pcdata->pwd)) + if ( str_cmp( crypt( argument, d->account->password ), + d->account->password ) ) { send_to_desc ("Wrong password.\n\r", d); close_socket (d); @@ -274,31 +321,29 @@ } write_to_buffer (d, echo_on_str, 0); + show_options(d); + d->connected = CON_PICK_PLAYER; + break; - if (check_playing (d, ch->name)) - return; - - if (check_reconnect (d, ch->name, TRUE)) - return; - - sprintf (log_buf, "%s@%s has connected.", ch->name, d->host); - log_string (log_buf); - wiznet (log_buf, NULL, NULL, WIZ_SITES, 0, get_trust (ch)); - - if (ch->desc->ansi) - SET_BIT (ch->act, PLR_COLOUR); - else - REMOVE_BIT (ch->act, PLR_COLOUR); - - if (IS_IMMORTAL (ch)) - { - do_function (ch, &do_help, "imotd"); - d->connected = CON_READ_IMOTD; - } - else + case CON_CONFIRM_ACCOUNT: + switch ( *argument ) { - do_function (ch, &do_help, "motd"); - d->connected = CON_READ_MOTD; + case 'y': case 'Y': + sprintf(buf, "New account created.\n\r" + "Give me a password for %s: %s", + d->account->owner, echo_off_str ); + write_to_buffer(d, buf, 0); + d->connected = CON_GET_NEW_PASSWORD; + break; + case 'n': case 'N': + write_to_buffer(d, "Ok, what IS it, then? ", 0); + close_account(d->account); + d->account = NULL; + d->connected = CON_ACCOUNT_NAME; + break; + default: + write_to_buffer(d, "Please type Yes or No? ", 0); + break; } break; @@ -331,7 +375,7 @@ free_char (d->character); d->character = NULL; } - d->connected = CON_GET_NAME; + d->connected = CON_ACCOUNT_NAME; break; case 'n': @@ -342,7 +386,7 @@ free_char (d->character); d->character = NULL; } - d->connected = CON_GET_NAME; + d->connected = CON_ACCOUNT_NAME; break; default: @@ -351,16 +395,24 @@ } break; - case CON_CONFIRM_NEW_NAME: + case CON_CONFIRM_PLAYER: switch (*argument) { case 'y': case 'Y': - sprintf (buf, - "New character.\n\rGive me a password for %s: %s", - ch->name, echo_off_str); - send_to_desc (buf, d); - d->connected = CON_GET_NEW_PASSWORD; + ch->desc->account->p_count++; + send_to_desc ("The following races are available:\n\r ", d); + for (race = 1; race_table[race].name != NULL; race++) + { + if (!race_table[race].pc_race) + break; + + write_to_buffer (d, race_table[race].name, 0); + write_to_buffer (d, " ", 1); + } + write_to_buffer (d, "\n\r", 0); + send_to_desc ("What is your race (help for more information)? ",d); + d->connected = CON_GET_NEW_RACE; if (ch->desc->ansi) SET_BIT (ch->act, PLR_COLOUR); break; @@ -370,7 +422,7 @@ send_to_desc ("Ok, what IS it, then? ", d); free_char (d->character); d->character = NULL; - d->connected = CON_GET_NAME; + d->connected = CON_NEW_PLAYER; break; default: @@ -392,7 +444,7 @@ return; } - pwdnew = crypt (argument, ch->name); + pwdnew = crypt (argument, d->account->owner); for (p = pwdnew; *p != '\0'; p++) { if (*p == '~') @@ -404,18 +456,23 @@ } } - free_string (ch->pcdata->pwd); - ch->pcdata->pwd = str_dup (pwdnew); - send_to_desc ("Please retype password: ", d); + free_string(d->account->new_password); + d->account->new_password = str_dup(pwdnew); + write_to_buffer( d, "Please retype password: ", 0 ); d->connected = CON_CONFIRM_NEW_PASSWORD; break; - + /* + free_string (ch->pcdata->pwd); + ch->pcdata->pwd = str_dup (pwdnew); +*/ case CON_CONFIRM_NEW_PASSWORD: #if defined(unix) write_to_buffer (d, "\n\r", 2); #endif - if (strcmp (crypt (argument, ch->pcdata->pwd), ch->pcdata->pwd)) + if ( strcmp( crypt( argument, d->account->owner ), + d->account->new_password ) ) + //if (strcmp (crypt (argument, ch->pcdata->pwd), ch->pcdata->pwd)) { send_to_desc ("Passwords don't match.\n\rRetype password: ", d); @@ -423,19 +480,184 @@ return; } + free_string(d->account->password); + d->account->password = str_dup(d->account->new_password); write_to_buffer (d, echo_on_str, 0); - send_to_desc ("The following races are available:\n\r ", d); - for (race = 1; race_table[race].name != NULL; race++) + show_options(d); + create_new_account(d->account); + d->connected = CON_PICK_PLAYER; + break; + + case CON_DELETE_PLAYER: + if (!load_char_obj(d, argument)) { - if (!race_table[race].pc_race) + write_to_buffer(d, "There is no character with that name.\n\r", 0); + show_options(d); + d->connected = CON_PICK_PLAYER; + return; + } + + ch = d->character; + if (str_cmp(ch->pcdata->account, d->account->owner)) + { + free_char(ch); + d->character = NULL; + write_to_buffer(d, "That is not your character.\n\r", 0); + show_options(d); + d->connected = CON_PICK_PLAYER; + return; + } + + /* delete this character */ + sprintf(buf, "%s %d", ch->name, ch->played/3600); + free_string(d->account->new_password); + d->account->new_password = str_dup(buf); + sprintf(buf, "Are you sure you wish to delete %s [Y/N]? ", ch->name); + write_to_buffer(d, buf, 0); + free_char(ch); + d->character = NULL; + d->connected = CON_CONFIRM_DEL_PLAYER; break; - write_to_buffer (d, race_table[race].name, 0); - write_to_buffer (d, " ", 1); + + case CON_CONFIRM_DEL_PLAYER: + switch(argument[0]) + { + default: + write_to_buffer(d, "Please answer Yes or No.\n\rAre you sure? ", 0); + break; + case 'y': case'Y': + { + char strsave[MAX_STRING_LENGTH]; + char *ptr; + int len = strlen(d->account->new_password), i; + + /* rip out the substring (string parsing) */ + strcpy(buf, d->account->players); + d->account->p_count--; + if ((ptr = strstr(buf, d->account->new_password)) == NULL) + { + sprintf(buf, "Unable to delete '%s' from account '%s'", + d->account->new_password, d->account->owner); + bug(buf, 0); + write_to_buffer(d, "\n\rDeletion FAILED!\n\r", 0); + show_options(d); + d->connected = CON_PICK_PLAYER; + return; + } + + if (((i = strlen(buf)) - len) == 0) + { + free_string(d->account->players); + d->account->players = str_dup(""); + } + else + { + i -= strlen(ptr); + if (i > 0 && buf[i-1] == ' ') + buf[i-1] = '\0'; + else + buf[i++] = '\0'; + strcat(buf, &d->account->players[i + len]); + free_string(d->account->players); + d->account->players = str_dup(buf); + } + + /* unlink all relevant files and save account */ + one_argument(d->account->new_password, buf); + buf[0] = toupper(buf[0]); + for (i = 1; buf[i] != '\0'; i++) + buf[i] = tolower(buf[i]); + + sprintf(strsave, "../accounts/%s/%s", d->account->owner, buf); + unlink(strsave); + + save_account(d->account); + + write_to_buffer(d, "\n\rCharacter deleted.\n\r", 0); + show_options(d); + d->connected = CON_PICK_PLAYER; + break; + } + + case 'n': case 'N': + show_options(d); + d->connected = CON_PICK_PLAYER; + break; + } + break; + + case CON_PICK_PLAYER: + if (toupper(argument[0]) == 'C') + { + write_to_buffer(d, "What shall you be known as? ", 0); + d->connected = CON_NEW_PLAYER; + } + else if (toupper(argument[0]) == 'D') + { + write_to_buffer(d, "Which player do you wish to delete? ", 0); + d->connected = CON_DELETE_PLAYER; + } + else if (toupper(argument[0]) == 'E') + { + write_to_buffer(d, "What is your name?? ", 0); + d->connected = CON_NEW_PLAYER; + } + else if (toupper(argument[0]) == 'P') + { + write_to_buffer(d, echo_off_str, 0); + write_to_buffer(d, "Please pick a new password: ", 0); + d->connected = CON_GET_NEW_PASSWORD; + } + else if (toupper(argument[0]) == 'Q') + { + write_to_buffer(d, "Come back soon.\n\r", 0); + close_socket(d); + } + else + { + if ( ( option = get_option_login( d->account->players, + atoi( argument ) ) ) == NULL ) + { + write_to_buffer(d, "That is not an option!\n\r" + "What will it be? ", 0); + return; + } + + if ( check_reconnect( d, option, TRUE ) ) + return; + + else if ( already_logged( d->account->owner ) ) + { + write_to_buffer(d, "You already have a different character" + " in the game.\n\r", 0); + close_socket(d); + return; + } + else if (!load_char_obj(d, option)) + { + write_to_buffer(d, "ERROR: Your pfile is missing!\n\r", 0); + close_socket(d); + return; + } + else + { + if (ch->desc->ansi) + SET_BIT (ch->act, PLR_COLOUR); + else + REMOVE_BIT (ch->act, PLR_COLOUR); + + if (IS_IMMORTAL (ch)) + { + do_function (ch, &do_help, "imotd"); + d->connected = CON_READ_IMOTD; + } + else + { + do_function (ch, &do_help, "motd"); + d->connected = CON_READ_MOTD; + } + } } - write_to_buffer (d, "\n\r", 0); - send_to_desc ("What is your race (help for more information)? ", - d); - d->connected = CON_GET_NEW_RACE; break; case CON_GET_NEW_RACE: @@ -453,6 +675,7 @@ break; } + ch = d->character; race = race_lookup (argument); if (race == 0 || !race_table[race].pc_race) diff -NaurBdw QuickMUD/src/recycle.c rom/src/recycle.c --- QuickMUD/src/recycle.c Thu Nov 23 17:30:00 2000 +++ rom/src/recycle.c Sat Apr 6 14:01:12 2002 @@ -92,7 +92,7 @@ *d = d_zero; VALIDATE (d); - d->connected = CON_GET_NAME; + d->connected = CON_ACCOUNT_NAME; d->showstr_head = NULL; d->showstr_point = NULL; d->outsize = 2000; diff -NaurBdw QuickMUD/src/save.c rom/src/save.c --- QuickMUD/src/save.c Thu Jan 31 20:46:38 2002 +++ rom/src/save.c Sat Apr 6 15:17:54 2002 @@ -122,6 +122,10 @@ return; } + /* update account information */ + if (ch->desc) + account_update(ch->desc->account, ch); + if (ch->desc != NULL && ch->desc->original != NULL) ch = ch->desc->original; @@ -145,7 +149,10 @@ #endif fclose (fpReserve); - sprintf (strsave, "%s%s", PLAYER_DIR, capitalize (ch->name)); + sprintf (strsave, "%s%s/%s", PLAYER_DIR, + ch->pcdata->account, capitalize( ch->name ) ); + /* Commented out for account system + sprintf (strsave, "%s%s", PLAYER_DIR, capitalize (ch->name));*/ if ((fp = fopen (TEMP_FILE, "w")) == NULL) { bug ("Save_char_obj: fopen", 0); @@ -671,6 +678,7 @@ ch->comm = COMM_COMBINE | COMM_PROMPT; ch->prompt = str_dup ("<%hhp %mm %vmv> "); ch->pcdata->confirm_delete = FALSE; + ch->pcdata->account = str_dup(d->account->owner); ch->pcdata->board = &boards[DEFAULT_BOARD]; ch->pcdata->pwd = str_dup (""); ch->pcdata->bamfin = str_dup (""); @@ -803,7 +811,10 @@ } #endif - sprintf (strsave, "%s%s", PLAYER_DIR, capitalize (name)); + sprintf (strsave, "%s%s/%s", PLAYER_DIR, + d->account->owner, capitalize( name ) ); + /* commented out for account stuff + sprintf (strsave, "%s%s", PLAYER_DIR, capitalize (name)); */ if ((fp = fopen (strsave, "r")) != NULL) { int iNest;