Thread: Compile error
View Single Post
Old 07-14-2002, 08:03 AM   #4
melker
New Member
 
Join Date: Jul 2002
Posts: 20
melker is on a distinguished road
Send a message via AIM to melker
[code]
void nanny( DESCRIPTOR_DATA *d, char *argument )
{
DESCRIPTOR_DATA *d_old, *d_next;
char buf[MAX_STRING_LENGTH];
char newbuf[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
char strsave[MAX_INPUT_LENGTH];
CHAR_DATA *ch;
char *pwdnew;
char *p;
int iClass,race,i,weapon;
int pos;
bool fOld;

while (isspace(*argument)) argument++;
ch = d->character;
switch (d->connected)
{
default;
bug( "Nanny; bad d->connected %d.", d->connected );
close_socket( d );
return;

case CON_GET_NAME;
if ( argument[0] == '\0')
{
close_socket( d );
return;
}

argument[0] = UPPER(argument[0]);
if ( !check_parse_name( argument ) )
{
write_to_buffer(d,"Illegal name, try another.\n\r",0);
write_to_buffer(d,"(If you've used this name here before, and are no\n\r",0);
write_to_buffer(d," longer able to, it may be because we've added a\n\r",0);
write_to_buffer(d," new mobile that uses the same name. Log in with\n\r",0);
write_to_buffer(d," a new name, and let an IMM know, and we will fix it.)\n\r",0);
write_to_buffer(d,"\n\rName; ",0);
return;
}
fOld = load_char_obj( d, argument );
ch = d->character;
if (IS_SET(ch->act, PLR_DENY))
{
sprintf( log_buf, "Denying access to %s@%s.", argument, d->host );
log_string( log_buf );
write_to_buffer( d, "You are denied access.\n\r", 0 );
close_socket( d );
return;
}
if (check_ban(d->host,BAN_PERMIT) && !IS_SET(ch->act,PLR_PERMIT))
{
write_to_buffer(d,"Your site has been banned from this mud.\n\r",0);
close_socket(d);
return;
}
if (IS_SET(ch->comm, COMM_WIPED ) )
{
write_to_buffer(d,"You have been wiped.\n\r",0);
close_socket( d );
return;
}
if (check_reconnect(d,argument,FALSE)) fOld = TRUE;
else
{
if ( wizlock && !IS_IMMORTAL(ch))
{
write_to_buffer( d, "The game is wizlocked.\n\r", 0 );
close_socket( d );
return;
}
}
if (fOld)
{
/* Old player */
write_to_buffer( d, "Password; ", 0 );
write_to_buffer( d, echo_off_str, 0 );
d->connected = CON_GET_OLD_PASSWORD;
return;
}
else
{
/* New player */
if (newlock)
{
write_to_buffer( d, "The game is newlocked.\n\r", 0 );
close_socket( d );
return;
}
if (check_ban(d->host,BAN_NEWBIES))
{
write_to_buffer(d,
"New players are not allowed from your site.\n\r",0);
close_socket(d);
return;
}
write_to_buffer(d,"Final Days is not a role-playing MUD, but overly\n\r",0);
write_to_buffer(d,"unreasonable character names will not be permitted.\n\r",0);
write_to_buffer(d,"The immortal staff has final decision regarding names.\n\r",0);
sprintf( buf, "Did I get that right, %s (Y/N)? ", argument );
write_to_buffer( d, buf, 0 );
d->connected = CON_CONFIRM_NEW_NAME;
return;
}
break;
case CON_GET_OLD_PASSWORD;
write_to_buffer( d, "\n\r", 2 );
if ( strcmp(argument, ch->pcdata->pwd ))
{
write_to_buffer( d, "Wrong password.\n\r", 0 );
close_socket( d );
return;
}
write_to_buffer( d, echo_on_str, 0 );
if (check_playing(d,ch->name)) return;
ch->pcdata->socket = str_dup(d->host);
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) );
ch->pcdata->socket = str_dup(d->host);
if (IS_SET(ch->act,PLR_REROLL))
{
int bplat, bgold, iq, aq, clan, clead, crank;

sprintf( strsave, "%s%s", PLAYER_DIR, capitalize( ch->name ) );
sprintf(newbuf, "%s", str_dup( ch->pcdata->pwd ));
sprintf( argument, "%s", capitalize( ch->name ) );
bplat = ch->platbank;
bgold = ch->goldbank;
iq = ch->qps;
aq = ch->questpoints;
clan = ch->clan;
clead = ch->clead;
crank = ch->pcdata->clanrank;
free_char( d->character );
d->character = NULL;
fOld = load_char_reroll( d, argument );
ch = d->character;
free_string( ch->pcdata->pwd );
ch->pcdata->pwd = str_dup( newbuf );
newbuf[0] = '\0';
ch->pcdata->tier = 1;
ch->pcdata->socket = str_dup( d->host );
ch->platbank = bplat;
ch->goldbank = bgold;
ch->qps = iq;
ch->questpoints = aq;
ch->clan = clan;
ch->clead = clead;
ch->pcdata->clanrank = crank;
write_to_buffer( d, echo_on_str, 0 );
send_to_desc("{8=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=[{xRaces{8]=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\r\n\r",d);
pos = 0;
for ( race = 1; race_table[race].name != NULL; race++ )
{
if (!race_table[race].pc_race) break;
sprintf(newbuf,"%6s{8<{C%2d{8> {x%-20s"," ",race,race_table[race].name);
send_to_desc(newbuf,d);
pos++;
if (pos >= 2) {
write_to_buffer(d,"\n\r",1);
pos = 0;
}
}
newbuf[0] = '\0';
write_to_buffer(d,"\n\r\n\r",0);
send_to_desc("Please select a race or type '{8help <race>{x' for more info; ",d);
d->connected = CON_GET_NEW_RACE;
break;
}
if ( IS_IMMORTAL(ch) )
{
do_help( ch, "imotd" );
d->connected = CON_READ_IMOTD;
}
else
{
do_help( ch, "motd" );
d->connected = CON_READ_MOTD;
}
break;

/* RT code for breaking link */
case CON_BREAK_CONNECT;
switch( *argument )
{
case 'y' ; case 'Y';
for ( d_old = descriptor_list; d_old != NULL; d_old = d_next )
{
d_next = d_old->next;
if (d_old == d || d_old->character == NULL)
continue;

if (str_cmp(ch->name,d_old->original ?
d_old->original->name ; d_old->character->name))
continue;

close_socket(d_old);
}
ch->pcdata->socket = str_dup( d->host );
if (check_reconnect(d,ch->name,TRUE))
return;
write_to_buffer(d,"Reconnect attempt failed.\n\rName; ",0);
if ( d->character != NULL )
{
free_char( d->character );
d->character = NULL;
}
d->connected = CON_GET_NAME;
break;

case 'n' ; case 'N';
write_to_buffer(d,"Name; ",0);
if ( d->character != NULL )
{
free_char( d->character );
d->character = NULL;
}
d->connected = CON_GET_NAME;
break;

default;
write_to_buffer(d,"Please type Y or N? ",0);
break;
}
break;

case CON_CONFIRM_NEW_NAME;
switch ( *argument )
{
case 'y'; case 'Y';
sprintf( buf, "New character.\n\rGive me a password for %s; %s",
ch->name, echo_off_str );
ch->pcdata->socket = str_dup( d->host );
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 );
free_char( d->character );
d->character = NULL;
d->connected = CON_GET_NAME;
break;

default;
write_to_buffer( d, "Please type Yes or No? ", 0 );
break;
}
break;

case CON_GET_NEW_PASSWORD;
write_to_buffer( d, "\n\r", 2 );
if ( strlen(argument) < 5 )
{
write_to_buffer( d,
"Password must be at least five characters long.\n\rPassword; ", 0 );
return;
}

pwdnew = argument;
for ( p = pwdnew; *p != '\0'; p++ )
{
if ( *p == '~' )
{
write_to_buffer( d,
"New password not acceptable, try again.\n\rPassword; ", 0 );
return;
}
}

free_string( ch->pcdata->pwd );
ch->pcdata->pwd = str_dup( pwdnew );
write_to_buffer( d, "Please retype password; ", 0 );
d->connected = CON_CONFIRM_NEW_PASSWORD;
break;

case CON_CONFIRM_NEW_PASSWORD;
write_to_buffer( d, "\n\r", 2 );
if ( strcmp( argument, ch->pcdata->pwd ) )
{
write_to_buffer( d, "Passwords don't match.\n\rRetype password; ", 0 );
d->connected = CON_GET_NEW_PASSWORD;
return;
}
write_to_buffer(d,"\n\r", 2 );
write_to_buffer(d,"You may be good, neutral, or evil.\n\r",0);
write_to_buffer(d,"Which alignment (G/N/E)? ",0);
d->connected = CON_GET_ALIGNMENT;
break;
case CON_GET_ALIGNMENT;
switch( argument[0])
{
case 'g' ; case 'G' ; ch->alignment = 750;
break;
case 'n' ; case 'N' ; ch->alignment = 0;
break;
case 'e' ; case 'E' ; ch->alignment = -750;
break;
default;
write_to_buffer(d,"That's not a valid alignment.\n\r",0);
write_to_buffer(d,"Which alignment (G/N/E)? ",0);
return;
}
write_to_buffer(d,"\n\r",0);
for ( race = 0; race < MAX_PC_RACE; race++ )
{
do_help( ch, "NANNY_RACES" );
if (IS_GOOD(ch))
{
do_help(ch,"GOOD_RACES");
write_to_buffer(d,"\n\r\n\r",1);
send_to_char( "Enter the name of your desired race; ", ch );
d->connected = CON_GET_NEW_RACE;
break;
}
if (IS_NEUTRAL(ch))
{
do_help(ch,"NEUTRAL_RACES");
write_to_buffer(d,"\n\r\n\r",1);
send_to_char( "Enter the name of your desired race; ", ch );

d->connected = CON_GET_NEW_RACE;
break;
}
if (IS_EVIL(ch))
{
do_help(ch,"EVIL_RACES");
write_to_buffer(d,"\n\r\n\r",1);
send_to_char( "Enter the name of your desired race; ", ch );
d->connected = CON_GET_NEW_RACE;
break;
}
}
break;
case CON_GET_NEW_RACE;
one_argument(argument,arg);


if (!strcmp(arg,"help"))
{
argument = one_argument(argument,arg);
if (argument[0] == '\0')
do_help(ch,"race help");
else
do_help(ch,argument);
write_to_buffer(d, "What is your race (help for more information)? ",0);
break;
}

race = race_lookup(argument);


if ((race == 0)
|| (!race_table[race].pc_race)
|| (IS_GOOD(ch) && !race_table[race].good)
|| (IS_NEUTRAL(ch) && !race_table[race].neutral)
|| (IS_EVIL(ch) && !race_table[race].evil))
{
send_to_char( "Invalid selection.\n\rEnter race name; ", ch );
return;
}
ch->race = race;
/* initialize stats */
for (i = 0; i < MAX_STATS; i++)
ch->perm_stat[i] = pc_race_table[race].stats[i];
ch->affected_by = ch->affected_by|race_table[race].aff;
ch->shielded_by = ch->shielded_by|race_table[race].shd;
ch->imm_flags = ch->imm_flags|race_table[race].imm;
ch->res_flags = ch->res_flags|race_table[race].res;
ch->vuln_flags = ch->vuln_flags|race_table[race].vuln;
ch->form = race_table[race].form;
ch->parts = race_table[race].parts;

/* add skills */
for (i = 0; i < 5; i++)
{
if (pc_race_table[race].skills[i] == NULL)
break;
group_add(ch,pc_race_table[race].skills[i],FALSE);
}
/* add cost */
ch->pcdata->points = pc_race_table[race].points;
ch->size = pc_race_table[race].size;

write_to_buffer( d, "What is your sex (M/F/N)? ", 0 );
d->connected = CON_GET_NEW_SEX;
break;


case CON_GET_NEW_SEX;
switch ( argument[0] )
{
case 'm'; case 'M'; ch->sex = SEX_MALE;
ch->pcdata->true_sex = SEX_MALE;
break;
case 'f'; case 'F'; ch->sex = SEX_FEMALE;
ch->pcdata->true_sex = SEX_FEMALE;
break;
case 'n'; case 'N'; ch->sex = SEX_NEUTRAL;
ch->pcdata->true_sex = SEX_NEUTRAL;
break;
default;
write_to_buffer( d, "That's not a sex.\n\rWhat IS your sex? ", 0 );
return;
}

write_to_buffer( d, echo_on_str, 0 );
write_to_buffer(d,"The following classes are available;\n\r\n\r",0);
if (ch->pcdata->tier != 1) {
ch->pcdata->tier = 0;
for ( iClass = 0; iClass < MAX_CLASS/2; iClass++ )
{
write_to_buffer(d," ",0);
write_to_buffer(d,class_table[iClass].name,0);
write_to_buffer(d,"\n\r",1);
}
} else {
for ( iClass = MAX_CLASS/2; iClass < MAX_CLASS; iClass++ )
{
write_to_buffer(d," ",0);
write_to_buffer(d,class_table[iClass].name,0);
write_to_buffer(d,"\n\r",1);
}
}
write_to_buffer(d,"\n\r\n\r",0);
write_to_buffer(d,"What is your class ? ",0);
d->connected = CON_GET_NEW_CLASS;
break;

case CON_GET_NEW_CLASS;
iClass = class_lookup(argument);

if ( iClass == -1 )
{
write_to_buffer( d,
"That's not a class.\n\rWhat IS your class? ", 0 );
return;
}
if (ch->pcdata->tier != 1) {
if (iClass >= (MAX_CLASS/2)) {
write_to_buffer( d,
"That's not a first tier class.\n\rWhat IS your class? ", 0 );
return;
}
} else {
if (iClass < (MAX_CLASS/2)) {
write_to_buffer( d,
"That's not a second tier class.\n\rWhat IS your class? ", 0 );
return;
}
}
ch->class = iClass;

sprintf( log_buf, "%s@%s new player.", ch->name, d->host );
log_string( log_buf );
wiznet("Newbie alert! $N sighted.",ch,NULL,WIZ_NEWBIE,0,0);
wiznet(log_buf,NULL,NULL,WIZ_SITES,0,get_trust(ch) );

write_to_buffer(d,"\n\r",0);
group_add(ch,"rom basics",FALSE);
group_add(ch,class_table[ch->class].base_group,FALSE);
ch->pcdata->learned[gsn_recall] = 50;
write_to_buffer(d,"Do you wish to customize this character?\n\r",0);
write_to_buffer(d,"Customization takes time, but allows a wider range of skills and abilities.\n\r",0);
write_to_buffer(d,"Customize (Y/N)? ",0);
d->connected = CON_DEFAULT_CHOICE;
break;

case CON_DEFAULT_CHOICE;
write_to_buffer(d,"\n\r",2);
switch ( argument[0] )
{
case 'y'; case 'Y';
ch->gen_data = new_gen_data();
ch->gen_data->points_chosen = ch->pcdata->points;
do_help(ch,"group header");
list_group_costs(ch);
write_to_buffer(d,"You already have the following skills;\n\r",0);
do_skills(ch,"");
do_help(ch,"menu choice");
d->connected = CON_GEN_GROUPS;
break;
case 'n'; case 'N';
group_add(ch,class_table[ch->class].default_group,TRUE);
write_to_buffer( d, "\n\r", 2 );
write_to_buffer(d,
"Please pick a weapon from the following choices;\n\r",0);
buf[0] = '\0';
for ( i = 0; weapon_table[i].name != NULL; i++)
if (ch->pcdata->learned[*weapon_table[i].gsn] > 0)
{
strcat(buf,weapon_table[i].name);
strcat(buf," ");
}
strcat(buf,"\n\rYour choice? ");
write_to_buffer(d,buf,0);
d->connected = CON_PICK_WEAPON;
break;
default;
write_to_buffer( d, "Please answer (Y/N)? ", 0 );
return;
}
break;

case CON_PICK_WEAPON;
write_to_buffer(d,"\n\r",2);
weapon = weapon_lookup(argument);
if (weapon == -1 || ch->pcdata->learned[*weapon_table[weapon].gsn] <= 0)
{
write_to_buffer(d,
"That's not a valid selection. Choices are;\n\r",0);
buf[0] = '\0';
for ( i = 0; weapon_table[i].name != NULL; i++)
if (ch->pcdata->learned[*weapon_table[i].gsn] > 0)
{
strcat(buf,weapon_table[i].name);
strcat(buf," ");
}
strcat(buf,"\n\rYour choice? ");
write_to_buffer(d,buf,0);
return;
}
ch->pcdata->learned[*weapon_table[weapon].gsn] = 40;
write_to_buffer(d,"\n\r",2);
do_help(ch,"motd");
d->connected = CON_READ_MOTD;
break;
case CON_GEN_GROUPS;
send_to_char("\n\r",ch);
if (!str_cmp(argument,"done"))
{
sprintf(buf,"Creation points; %d\n\r",ch->pcdata->points);
send_to_char(buf,ch);
sprintf(buf,"Experience per level; %ld\n\r",
(long)exp_per_level(ch,ch->gen_data->points_chosen));
if (ch->pcdata->points < 40)
ch->train = (40 - ch->pcdata->points + 1) / 2;
free_gen_data(ch->gen_data);
ch->gen_data = NULL;
send_to_char(buf,ch);
write_to_buffer( d, "\n\r", 2 );
write_to_buffer(d,
"Please pick a weapon from the following choices;\n\r",0);
buf[0] = '\0';
for ( i = 0; weapon_table[i].name != NULL; i++)
if (ch->pcdata->learned[*weapon_table[i].gsn] > 0)
{
strcat(buf,weapon_table[i].name);
strcat(buf," ");
}
strcat(buf,"\n\rYour choice? ");
write_to_buffer(d,buf,0);
d->connected = CON_PICK_WEAPON;
break;
}
if (!parse_gen_groups(ch,argument))
send_to_char(
"Choices are; list,learned,premise,add,drop,info,help, and done.\n\r"
,ch);
do_help(ch,"menu choice");
break;
case CON_READ_IMOTD;
write_to_buffer(d,"\n\r",2);
do_help( ch, "motd" );
d->connected = CON_READ_MOTD;
break;
case CON_READ_MOTD;
if ( ch->pcdata == NULL || ch->pcdata->pwd[0] == '\0')
{
write_to_buffer( d, "Warning! Null password!\n\r",0 );
write_to_buffer( d, "Please report old password with bug.\n\r",0);
write_to_buffer( d,
"Type 'password null <new password>' to fix.\n\r",0);
}

write_to_buffer(d,"\n\rWelcome to Final Days! Kill or be killed.\n\r",0);
ch->next = char_list;
char_list = ch;
d->connected = CON_PLAYING;
reset_char(ch);
if ( ch->level == 0 )
{
ch->perm_stat[class_table[ch->class].attr_prime] += 3;
/* add this while initializing all the racial stuff for new characters */
ch->level = 1;
ch->exp = exp_per_level(ch,ch->pcdata->points);
ch->hit = ch->max_hit;
ch->mana = ch->max_mana;
ch->move = ch->max_move;
ch->train = 40;
ch->practice = 25;
set_title(ch,"the adventurer.");
//do_pack(ch,"self");
//obj_to_char(create_object(get_obj_index(OBJ_VNUM_M AP),0),ch);
//obj_to_char(create_object(get_obj_index(OBJ_VNUM_W MAP),0),ch);
//obj_to_char(create_object(get_obj_index(OBJ_VNUM_E MAP),0),ch);
char_to_room( ch, get_room_index( ROOM_VNUM_SCHOOL ) );
send_to_char("\n\r",ch);
}
else if ( ch->in_room != NULL )
{
char_to_room( ch, ch->in_room );
}
else if ( IS_IMMORTAL(ch) )
{
char_to_room( ch, get_room_index( ROOM_VNUM_CHAT ) );
}
else
{
if ( ch->alignment < 0 )
char_to_room( ch, get_room_index( ROOM_VNUM_TEMPLEB ) );
else
char_to_room( ch, get_room_index( ROOM_VNUM_TEMPLE ) );
}

act( "$n has entered Final Days.", ch, NULL, NULL, TO_ROOM );
if (IS_IMMORTAL(ch) )
{
wiznet("$N has entered Final Days.",ch,NULL,
WIZ_LOGINS,WIZ_SITES,get_trust(ch));
do_look( ch, "auto" );
}
else
{
sprintf(buf,"%s has entered Final Days.",ch->name);
do_announce(ch,buf);
do_look( ch, "auto" );
wiznet("$N has entered Final Days.",ch,NULL,
WIZ_LOGINS,WIZ_SITES,get_trust(ch));
}
if (IS_SET(ch->act,PLR_QUESTOR)) REMOVE_BIT(ch->act,PLR_QUESTOR);
if (ch->pet != NULL)
{
char_to_room(ch->pet,ch->in_room);
act("$n has entered Final Days.",ch->pet,NULL,NULL,TO_ROOM);
}

if (ch->mount != NULL)
{
char_to_room(ch->mount,ch->in_room);
act("$n has entered the game.",ch->mount,NULL,NULL,TO_ROOM);
add_follower(ch->mount, ch);
do_mount( ch, ch->mount->name);
}

do_unread(ch,"");
break;
case CON_CHAR_REROLL;
write_to_buffer(d,"The following races are available;\n\r\n\r",0);
pos = 0;
for ( race = 1; race_table[race].name != NULL; race++ )
{
if (!race_table[race].pc_race) break;
sprintf(newbuf, "%6s%-24s", " ", race_table[race].name);
write_to_buffer(d,newbuf,0);
pos++;
if (pos >= 2) {
write_to_buffer(d,"\n\r",1);
pos = 0;
}
}
newbuf[0] = '\0';
write_to_buffer(d,"\n\r\n\r",0);
write_to_buffer(d,"What is your race (help for more information)? ",0);
d->connected = CON_GET_NEW_RACE;
break;
}
return;
}


[/quote]

Sorry didnt read the entire reply before. (I'm tired) heheh
melker is offline   Reply With Quote