void free_all_quest( void ) { while ( last_quest ) free_quest( last_quest ); }
/* This procedure frees up the strings and/or the structures attatched to a * descriptor, sets all flags back to how they should be. */ void cleanup_olc(struct descriptor_data *d, byte cleanup_type) { /* Clean up WHAT? */ if (d->olc == NULL) return; /* Check for a room. free_room doesn't perform sanity checks, we must be * careful here. */ if (OLC_ROOM(d)) { switch (cleanup_type) { case CLEANUP_ALL: /* free(OLC_SCRIPT(d)) equivalent */ free_proto_script(OLC_ROOM(d), WLD_TRIGGER); free_room(OLC_ROOM(d)); break; case CLEANUP_STRUCTS: free(OLC_ROOM(d)); break; case CLEANUP_CONFIG: free_config(OLC_CONFIG(d)); break; default: /* The caller has screwed up. */ log("SYSERR: cleanup_olc: Unknown type!"); break; } } /* Check for an existing object in the OLC. The strings aren't part of the * prototype any longer. They get added with strdup(). */ if (OLC_OBJ(d)) { free_object_strings(OLC_OBJ(d)); free(OLC_OBJ(d)); } /* Check for a mob. free_mobile() makes sure strings are not in the * prototype. */ if (OLC_MOB(d)) free_mobile(OLC_MOB(d)); /* Check for a zone. cleanup_type is irrelevant here, free() everything. */ if (OLC_ZONE(d)) { if (OLC_ZONE(d)->builders) free(OLC_ZONE(d)->builders); if (OLC_ZONE(d)->name) free(OLC_ZONE(d)->name); if (OLC_ZONE(d)->cmd) free(OLC_ZONE(d)->cmd); free(OLC_ZONE(d)); } /* Check for a shop. free_shop doesn't perform sanity checks, we must be * careful here. OLC_SHOP(d) is a _copy_ - no pointers to the original. Just * go ahead and free it all. */ if (OLC_SHOP(d)) free_shop(OLC_SHOP(d)); /* Check for a quest. */ if (OLC_QUEST(d)) { switch (cleanup_type) { case CLEANUP_ALL: free_quest(OLC_QUEST(d)); break; case CLEANUP_STRUCTS: free(OLC_QUEST(d)); break; default: break; } } /*. Check for aedit stuff -- M. Scott */ if (OLC_ACTION(d)) { switch(cleanup_type) { case CLEANUP_ALL: free_action(OLC_ACTION(d)); break; case CLEANUP_STRUCTS: free(OLC_ACTION(d)); break; default: /* Caller has screwed up */ break; } } /* Used for cleanup of Hedit */ if (OLC_HELP(d)) { switch(cleanup_type) { case CLEANUP_ALL: free_help(OLC_HELP(d)); break; case CLEANUP_STRUCTS: free(OLC_HELP(d)); break; default: break; } } if (OLC_IBT(d)) { free_olc_ibt(OLC_IBT(d)); OLC_IBT(d) = NULL; } if (OLC_MSG_LIST(d)) { free_message_list(OLC_MSG_LIST(d)); OLC_MSG_LIST(d) = NULL; OLC_MSG(d) = NULL; } /* Free storage if allocated (tedit, aedit, and trigedit). This is the command * list - it's been copied to disk already, so just free it -Welcor. */ if (OLC_STORAGE(d)) { free(OLC_STORAGE(d)); OLC_STORAGE(d) = NULL; } /* Free this one regardless. If we've left olc, we've either made a fresh * copy of it in the trig index, or we lost connection. Either way, we need * to get rid of this. */ if (OLC_TRIG(d)) { free_trigger(OLC_TRIG(d)); OLC_TRIG(d) = NULL; } /* Free this one regardless. If we've left olc, we've either copied the * * preferences to the player, or we lost connection. Either way, we need * * to get rid of this. */ if(OLC_PREFS(d)) { /*. There is nothing else really to free, except this... .*/ free(OLC_PREFS(d)); OLC_PREFS(d) = NULL; } /* OLC_SCRIPT is always set as trig_proto of OLC_OBJ/MOB/ROOM. Therefore it * should not be free'd here. */ /* Restore descriptor playing status. */ if (d->character) { REMOVE_BIT_AR(PLR_FLAGS(d->character), PLR_WRITING); act("$n stops using OLC.", TRUE, d->character, NULL, NULL, TO_ROOM); if (cleanup_type == CLEANUP_CONFIG) mudlog(BRF, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing the game configuration", GET_NAME(d->character)); else if (STATE(d) == CON_TEDIT) mudlog(BRF, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing text files.", GET_NAME(d->character)); else if (STATE(d) == CON_HEDIT) mudlog(CMP, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing help files.", GET_NAME(d->character)); else mudlog(CMP, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing zone %d allowed zone %d", GET_NAME(d->character), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(d->character)); STATE(d) = CON_PLAYING; } free(d->olc); d->olc = NULL; }
void do_setquest( CHAR_DATA *ch, char *argument ) { char arg1[MIL], arg2[MIL], arg3[MIL], arg4[MIL]; QUEST_DATA *quest; int x; set_char_color( AT_PLAIN, ch ); if ( IS_NPC( ch ) ) { error( ch ); return; } if ( !IS_IMMORTAL( ch ) ) { error( ch ); return; } if ( !ch->desc ) { bug( "%s", "do_setquest (desc): no descriptor" ); return; } switch ( ch->substate ) { default: break; case SUB_QUEST_DESC: if ( !ch->dest_buf || !( quest = ( QUEST_DATA * ) ch->dest_buf ) ) { bug( "%s: sub_quest_desc: NULL ch->dest_buf", __FUNCTION__ ); ch->substate = SUB_NONE; return; } ch->dest_buf = NULL; if ( VLD_STR( quest->desc ) ) STRFREE( quest->desc ); quest->desc = copy_buffer( ch ); stop_editing( ch ); write_quest_list( ); ch->substate = SUB_NONE; return; } argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if ( arg1[0] == '\0' ) { send_to_char( "&cUsage: setquest save all\r\n", ch ); send_to_char( " setquest <&Cqname&c> create\r\n", ch ); send_to_char( " setquest <&Cqname&c> delete\r\n", ch ); send_to_char( " setquest <&Cqname&c> chapter <#> delete\r\n", ch ); send_to_char( " setquest <&Cqname&c> desc\r\n", ch ); send_to_char( " setquest <&Cqname&c> <&Cfield&c>\r\n", ch ); send_to_char( " setquest <&Cquest&c> remove <&Cplayer&c>\r\n", ch ); send_to_char( " showquest <&Cqname&c>\r\n", ch ); send_to_char( " Field being one of:\r\n", ch ); send_to_char( "level svnum stype chapters chapter timelimit skipchapters glory\r\n", ch ); send_to_char( "\r\nchapter <n> <field2>\r\n", ch ); send_to_char( " Field2 being one of:\r\n", ch ); send_to_char( "create delete svnum stype\r\n", ch ); send_to_char( "name timelimit level kamount\r\n", ch ); send_to_char( "Note: 3600 = 1 hour timelimit\r\n", ch ); return; } if ( ( !str_cmp( arg1, "tutorial" ) && ch->level < 108 ) || ( !str_cmp( arg1, "etutorial" ) && ch->level < 108 ) || ( !str_cmp( arg1, "dtutorial" ) && ch->level < 108 ) ) { send_to_char( "You need Vladaar's permission to change anything with tutorials.\r\n", ch ); return; } if ( !str_cmp( arg1, "save" ) ) { if ( !str_cmp( arg2, "all" ) ) { write_quest_list( ); send_to_char( "All quests saved.\r\n", ch ); return; } } quest = get_quest_from_name( arg1 ); if ( !str_cmp( arg2, "create" ) ) { if ( quest && VLD_STR( quest->name ) && !str_cmp( quest->name, arg1 ) ) { ch_printf( ch, "(%s): quest already exists!\r\n", quest->name ); return; } CREATE( quest, QUEST_DATA, 1 ); quest->name = STRALLOC( arg1 ); quest->number = -1; add_new_quest( ch, quest ); write_quest_list( ); return; } if ( !quest ) { send_to_char( "No quest by that name.\r\n", ch ); return; } if ( !str_cmp( arg2, "desc" ) ) { if ( !ch->desc ) { bug( "%s", "do_setquest (desc): no descriptor" ); return; } ch->substate = SUB_QUEST_DESC; ch->dest_buf = quest; start_editing( ch, quest->desc ); return; } if ( !str_cmp( arg2, "delete" ) ) { free_quest( quest ); send_to_char( "Deleted.\r\n", ch ); return; } if ( !str_cmp( arg2, "skipchapters" ) ) { quest->skipchapters = !quest->skipchapters; ch_printf( ch, "That quest will %s allow chapters to be skipped.\r\n", quest->skipchapters ? "now" : "no longer" ); return; } if ( !str_cmp( arg2, "chapters" ) ) { x = atoi( argument ); if ( x < 0 || x > 30 ) { send_to_char( "Chapters must be between 0 and 30.\r\n", ch ); return; } quest->chapters = x; send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "svnum" ) ) { quest->svnum = atoi( argument ); ch_printf( ch, "That quest's svnum (starting vnum) is set to %d.\r\n", quest->svnum ); return; } if ( !str_cmp( arg2, "stype" ) ) { x = atoi( argument ); if ( x < 0 || x > 2 ) { send_to_char ( "Can only set stype (starting type) to 0 for Mobiles, 1 for Objects, 2 for Rooms.\r\n", ch ); return; } quest->stype = x; ch_printf( ch, "That quest's stype (starting type) is set to %d[%s].\r\n", quest->stype, ( quest->stype == 0 ) ? "Mobile" : ( quest->stype == 1 ) ? "Object" : ( quest->stype == 2 ) ? "Room" : "Unknown" ); return; } if ( !str_cmp( arg2, "glory" ) ) { x = atoi( argument ); if ( x < 0 || x > 1 ) { send_to_char( "Can only set 0 for no glory, or 1 for glory.\r\n", ch ); return; } quest->glory = x; return; } if ( !str_cmp( arg2, "chapter" ) ) { CHAP_DATA *chap = NULL; argument = one_argument( argument, arg3 ); argument = one_argument( argument, arg4 ); int chapno = atoi( arg3 ); if ( chapno < 1 || chapno > MAX_CHAPTERS ) { ch_printf( ch, "Chapter range is 1 to %d.\r\n", MAX_CHAPTERS ); return; } if ( !str_cmp( arg4, "create" ) ) { if ( get_chap_from_quest( chapno, quest ) ) { send_to_char( "That chapter already exists!\r\n", ch ); return; } if ( !get_chap_from_quest( ( chapno - 1 ), quest ) && chapno > 1 ) { ch_printf( ch, "How can you create chapter %d before chapter %d even exists?\r\n", chapno, chapno - 1 ); return; } if ( chapno > quest->chapters ) { ch_printf( ch, "How can you create chapter %d when there are only %d chapters?\r\n", chapno, quest->chapters ); send_to_char( "Set more - 'setquest (questname) chapters (number)'.\r\n", ch ); return; } CREATE( chap, CHAP_DATA, 1 ); chap->number = chapno; add_chapter( quest, chap ); send_to_char( "New chapter added.\r\n", ch ); write_quest_list( ); return; } chap = get_chap_from_quest( chapno, quest ); if ( !chap ) { send_to_char( "No such chapter.\r\n", ch ); return; } if ( !str_cmp( arg4, "delete" ) ) { free_chapter( quest, chap ); send_to_char( "Chapter Deleted.\r\n", ch ); return; } if ( !str_cmp( arg4, "name" ) ) { if ( VLD_STR( chap->desc ) ) STRFREE( chap->desc ); if ( VLD_STR( argument ) ) { if ( strlen( argument ) > 50 ) argument[50] = '\0'; chap->desc = STRALLOC( argument ); } write_quest_list( ); send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg4, "timelimit" ) ) { x = atoi( argument ); if ( x < 0 || x > 3600 ) { send_to_char( "Time limit is between 0 and 3600 (one hour).\r\n", ch ); return; } chap->timelimit = x; send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg4, "kamount" ) ) { int kamount = atoi( argument ); if ( kamount < 0 ) { send_to_char( "You have to set kamount to 0 or higher.\r\n", ch ); return; } chap->kamount = kamount; send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg4, "level" ) ) { int level = atoi( argument ); if ( level < 0 || level > MAX_LEVEL ) { ch_printf( ch, "Level range is between 0 and %d.\r\n", MAX_LEVEL ); return; } chap->level = level; send_to_char( "Done.\r\n", ch ); return; } do_setquest( ch, ( char * ) "" ); return; } if ( !str_cmp( arg2, "level" ) ) { x = atoi( argument ); if ( x < 1 || x > MAX_LEVEL ) { send_to_char( "Quest level must be between 1 and max.\r\n", ch ); return; } quest->level = x; send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "timelimit" ) ) { x = atoi( argument ); if ( x < 0 || x > 3600 ) { send_to_char ( "Quest time limit must be between 0 (no timer) and 3600 seconds (1 hour).\r\n", ch ); return; } quest->timelimit = x; send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "remove" ) ) { CHAR_DATA *victim; CHQUEST_DATA *chquest; if ( ( victim = get_char_world( ch, argument ) ) != NULL && !IS_NPC( victim ) ) { x = get_number_from_quest( quest ); for ( chquest = victim->pcdata->first_quest; chquest; chquest = chquest->next ) { if ( chquest->questnum != quest->number ) continue; UNLINK( chquest, victim->pcdata->first_quest, victim->pcdata->last_quest, next, prev ); DISPOSE( chquest ); ch_printf( ch, "You remove quest %s from %s.\r\n", quest->name, victim->name ); ch_printf( victim, "Quest %s has been removed from your journal.\r\n", quest->name ); return; } send_to_char( "That player isn't currently on that quest.\r\n", ch ); return; } else send_to_char( "That player isn't currently online.\r\n", ch ); return; } do_setquest( ch, ( char * ) "" ); return; }