コード例 #1
0
MAT_TYPE *new_mat()
{
	MAT_TYPE *mat;
	
	ALLOC_DATA(mat, MAT_TYPE, 1);

	mat->next = NULL;
	mat->name = NULL;
	mat->assignedValue = 0;

	return mat;
}
コード例 #2
0
void load_thread(char *name, NOTE_DATA **list, int type, time_t free_time)
{
	FILE *fp;
	NOTE_DATA *pnotelast;
 
	if ( ( fp = fopen( name, "r" ) ) == NULL )
	return;
	 
	pnotelast = NULL;
	for ( ; ; )
	{
	NOTE_DATA *pnote;
	char letter;
	 
	do
	{
		letter = getc( fp );
			if ( feof(fp) )
			{
				fclose( fp );
				return;
			}
		}
		while ( isspace(letter) );
		ungetc( letter, fp );
 
		ALLOC_DATA(pnote, NOTE_DATA, 1);
 
		if ( str_cmp( fread_word( fp ), "sender" ) )
			break;
		pnote->sender   = fread_string( fp );
 
		if ( str_cmp( fread_word( fp ), "date" ) )
			break;
		pnote->date     = fread_string( fp );
 
		if ( str_cmp( fread_word( fp ), "stamp" ) )
			break;
		pnote->date_stamp = fread_number(fp);
 
		if ( str_cmp( fread_word( fp ), "to" ) )
			break;
		pnote->to_list  = fread_string( fp );
 
		if ( str_cmp( fread_word( fp ), "subject" ) )
			break;
		pnote->subject  = fread_string( fp );
 
		if ( str_cmp( fread_word( fp ), "text" ) )
			break;
		pnote->text     = fread_string( fp );
 
		if (free_time && pnote->date_stamp < current_time - free_time)
		{
		free_note(pnote);
			continue;
		}

	pnote->type = type;
 
		if (*list == NULL)
			*list           = pnote;
		else
			pnotelast->next     = pnote;
 
		pnotelast       = pnote;
	}
 
	strcpy( strArea, NOTE_FILE );
	fpArea = fp;
	bug( "Load_notes: bad key word.", 0 );
	exit( 1 );
	return;
}
コード例 #3
0
/*
 * Snarf an obj section. new style
 */
void load_objects ( FILE *fp )
{
	ItemData *pObjIndex;

	if ( !area_last ) { /* OLC */
		log_hd ( LOG_ERROR, "Load_objects: no #AREA seen yet." );
		exit ( 1 );
	}

	while ( true ) {
		int vnum;
		char letter;
		int iHash;

		letter                          = fread_letter ( fp );
		if ( letter != '#' ) {
			log_hd ( LOG_ERROR, "Load_objects: # not found." );
			exit ( 1 );
		}

		vnum                            = fread_number ( fp );
		if ( vnum == 0 )
		{ break; }

		fBootDb = FALSE;
		if ( get_obj_index ( vnum ) != NULL ) {
			log_hd ( LOG_ERROR, Format ( "Load_objects: vnum %d duplicated.", vnum ) );
			exit ( 1 );
		}
		fBootDb = TRUE;

		ALLOC_DATA ( pObjIndex, ItemData, 1 );

		pObjIndex->vnum                 = vnum;
		pObjIndex->area                 = area_last;            /* OLC */
		pObjIndex->new_format           = TRUE;
		pObjIndex->reset_num		= 0;
		newobjs++;
		pObjIndex->name                 = fread_string ( fp );
		pObjIndex->short_descr          = fread_string ( fp );
		pObjIndex->description          = fread_string ( fp );

		CHECK_POS ( pObjIndex->item_type, item_lookup ( fread_word ( fp ) ), "item_type" );
		pObjIndex->extra_flags          = fread_flag ( fp );
		pObjIndex->wear_flags           = fread_flag ( fp );
		pObjIndex->material_flags       = fread_flag ( fp );
		switch ( pObjIndex->item_type ) {
			case ITEM_WEAPON:
				pObjIndex->value[0]		= weapon_type ( fread_word ( fp ) );
				pObjIndex->value[1]		= fread_number ( fp );
				pObjIndex->value[2]		= fread_number ( fp );
				pObjIndex->value[3]		= attack_lookup ( fread_word ( fp ) );
				pObjIndex->value[4]		= fread_flag ( fp );
				break;
			case ITEM_CONTAINER:
				pObjIndex->value[0]		= fread_number ( fp );
				pObjIndex->value[1]		= fread_flag ( fp );
				pObjIndex->value[2]		= fread_number ( fp );
				pObjIndex->value[3]		= fread_number ( fp );
				pObjIndex->value[4]		= fread_number ( fp );
				break;
			case ITEM_DRINK_CON:
			case ITEM_FOUNTAIN:
				pObjIndex->value[0]         = fread_number ( fp );
				pObjIndex->value[1]         = fread_number ( fp );
				CHECK_POS ( pObjIndex->value[2], liq_lookup ( fread_word ( fp ) ), "liq_lookup" );
				pObjIndex->value[3]         = fread_number ( fp );
				pObjIndex->value[4]         = fread_number ( fp );
				break;
			case ITEM_WAND:
			case ITEM_STAFF:
				pObjIndex->value[0]		= fread_number ( fp );
				pObjIndex->value[1]		= fread_number ( fp );
				pObjIndex->value[2]		= fread_number ( fp );
				pObjIndex->value[3]		= skill_lookup ( fread_word ( fp ) );
				pObjIndex->value[4]		= fread_number ( fp );
				break;
			case ITEM_POTION:
			case ITEM_PILL:
			case ITEM_SCROLL:
				pObjIndex->value[0]		= fread_number ( fp );
				pObjIndex->value[1]		= skill_lookup ( fread_word ( fp ) );
				pObjIndex->value[2]		= skill_lookup ( fread_word ( fp ) );
				pObjIndex->value[3]		= skill_lookup ( fread_word ( fp ) );
				pObjIndex->value[4]		= skill_lookup ( fread_word ( fp ) );
				break;
			default:
				pObjIndex->value[0]             = fread_flag ( fp );
				pObjIndex->value[1]             = fread_flag ( fp );
				pObjIndex->value[2]             = fread_flag ( fp );
				pObjIndex->value[3]             = fread_flag ( fp );
				pObjIndex->value[4]		    = fread_flag ( fp );
				break;
		}
		pObjIndex->level		= fread_number ( fp );
		pObjIndex->weight               = fread_number ( fp );
		pObjIndex->cost                 = fread_number ( fp );

		/* condition */
		letter 				= fread_letter ( fp );
		switch ( letter ) {
			case ( 'P' ) :
				pObjIndex->condition = 100;
				break;
			case ( 'G' ) :
				pObjIndex->condition =  90;
				break;
			case ( 'A' ) :
				pObjIndex->condition =  75;
				break;
			case ( 'W' ) :
				pObjIndex->condition =  50;
				break;
			case ( 'D' ) :
				pObjIndex->condition =  25;
				break;
			case ( 'B' ) :
				pObjIndex->condition =  10;
				break;
			case ( 'R' ) :
				pObjIndex->condition =   0;
				break;
			default:
				pObjIndex->condition = 100;
				break;
		}

		while ( true ) {
			char letter;

			letter = fread_letter ( fp );

			if ( letter == 'A' ) {
				Affect *paf;

				ALLOC_DATA ( paf, Affect, 1 );

				paf->where		= TO_OBJECT;
				paf->type               = -1;
				paf->level              = pObjIndex->level;
				paf->duration           = -1;
				paf->location           = fread_number ( fp );
				paf->modifier           = fread_number ( fp );
				paf->bitvector          = 0;
				paf->next               = pObjIndex->affected;
				pObjIndex->affected     = paf;
				top_affect++;
			}

			else if ( letter == 'F' ) {
				Affect *paf;

				ALLOC_DATA ( paf, Affect, 1 );

				letter 			= fread_letter ( fp );
				switch ( letter ) {
					case 'A':
						paf->where          = TO_AFFECTS;
						break;
					case 'I':
						paf->where		= TO_IMMUNE;
						break;
					case 'R':
						paf->where		= TO_RESIST;
						break;
					case 'V':
						paf->where		= TO_VULN;
						break;
					default:
						log_hd ( LOG_ERROR, "Load_objects: Bad where on flag set." );
						exit ( 1 );
				}
				paf->type               = -1;
				paf->level              = pObjIndex->level;
				paf->duration           = -1;
				paf->location           = fread_number ( fp );
				paf->modifier           = fread_number ( fp );
				paf->bitvector          = fread_flag ( fp );
				paf->next               = pObjIndex->affected;
				pObjIndex->affected     = paf;
				top_affect++;
			}

			else if ( letter == 'E' ) {
				DescriptionData *ed;

				ALLOC_DATA ( ed, DescriptionData, 1 );

				ed->keyword             = fread_string ( fp );
				ed->description         = fread_string ( fp );
				ed->next                = pObjIndex->extra_descr;
				pObjIndex->extra_descr  = ed;
				top_ed++;
			} else if ( letter == 'R' ) {
				pObjIndex->requirements[SIZ_REQ]	= fread_number ( fp );
				pObjIndex->requirements[STR_REQ]	= fread_number ( fp );
				pObjIndex->requirements[DEX_REQ]	= fread_number ( fp );
				pObjIndex->requirements[CON_REQ]	= fread_number ( fp );
				pObjIndex->requirements[INT_REQ]	= fread_number ( fp );
				pObjIndex->requirements[WIS_REQ]	= fread_number ( fp );
			} else if ( letter == 'L' ) {
				pObjIndex->repop_percent = fread_number ( fp );
			} else {
				ungetc ( letter, fp );
				break;
			}
		}

		iHash                   = vnum % MAX_KEY_HASH;
		pObjIndex->next         = obj_index_hash[iHash];
		obj_index_hash[iHash]   = pObjIndex;
		top_obj_index++;
		top_vnum_obj = top_vnum_obj < vnum ? vnum : top_vnum_obj;   /* OLC */
		assign_area_vnum ( vnum );                                  /* OLC */
	}

	return;
}
コード例 #4
0
/*
 * Snarf a mob section.  new style
 */
void load_mobiles ( FILE *fp )
{
	NPCData *pMobIndex;

	if ( !area_last ) { /* OLC */
		log_hd ( LOG_ERROR, "Load_mobiles: no #AREA seen yet." );
		exit ( 1 );
	}

	for ( ; ; ) {
		int vnum;
		char letter;
		int iHash;

		letter                          = fread_letter ( fp );
		if ( letter != '#' ) {
			log_hd ( LOG_ERROR, "Load_mobiles: # not found." );
			exit ( 1 );
		}

		vnum                            = fread_number ( fp );
		if ( vnum == 0 )
		{ break; }

		fBootDb = FALSE;
		if ( get_mob_index ( vnum ) != NULL ) {
			log_hd ( LOG_ERROR, Format ( "Load_mobiles: vnum %d duplicated.", vnum ) );
			exit ( 1 );
		}
		fBootDb = TRUE;

		ALLOC_DATA ( pMobIndex, NPCData, 1 );

		pMobIndex->vnum                 = vnum;
		pMobIndex->area                 = area_last;               /* OLC */
		pMobIndex->new_format		= TRUE;
		newmobs++;
		pMobIndex->player_name          = fread_string ( fp );
		pMobIndex->short_descr          = fread_string ( fp );
		pMobIndex->long_descr           = fread_string ( fp );
		pMobIndex->description          = fread_string ( fp );
		pMobIndex->race		 	= race_lookup ( fread_string ( fp ) );

		pMobIndex->long_descr[0]        = UPPER ( pMobIndex->long_descr[0] );
		pMobIndex->description[0]       = UPPER ( pMobIndex->description[0] );

		pMobIndex->material_flags				= fread_flag ( fp );
		pMobIndex->random								= fread_flag ( fp );
		pMobIndex->act                  = fread_flag ( fp ) | ACT_IS_NPC
										  | race_table[pMobIndex->race].act;
		pMobIndex->affected_by          = fread_flag ( fp )
										  | race_table[pMobIndex->race].aff;
		pMobIndex->pShop                = NULL;
		pMobIndex->alignment            = fread_number ( fp );
		pMobIndex->group                = fread_number ( fp );

		pMobIndex->level                = fread_number ( fp );
		pMobIndex->hitroll              = fread_number ( fp );

		/* read hit Math::instance().dice */
		pMobIndex->hit[DICE_NUMBER]     = fread_number ( fp );
		/* 'd'          */                fread_letter ( fp );
		pMobIndex->hit[DICE_TYPE]   	= fread_number ( fp );
		/* '+'          */                fread_letter ( fp );
		pMobIndex->hit[DICE_BONUS]      = fread_number ( fp );

		/* read mana Math::instance().dice */
		pMobIndex->mana[DICE_NUMBER]	= fread_number ( fp );
		fread_letter ( fp );
		pMobIndex->mana[DICE_TYPE]	= fread_number ( fp );
		fread_letter ( fp );
		pMobIndex->mana[DICE_BONUS]	= fread_number ( fp );

		/* read damage Math::instance().dice */
		pMobIndex->damage[DICE_NUMBER]	= fread_number ( fp );
		fread_letter ( fp );
		pMobIndex->damage[DICE_TYPE]	= fread_number ( fp );
		fread_letter ( fp );
		pMobIndex->damage[DICE_BONUS]	= fread_number ( fp );
		pMobIndex->dam_type		= attack_lookup ( fread_word ( fp ) );

		/* read armor archetype */
		pMobIndex->ac[AC_PIERCE]	= fread_number ( fp ) * 10;
		pMobIndex->ac[AC_BASH]		= fread_number ( fp ) * 10;
		pMobIndex->ac[AC_SLASH]		= fread_number ( fp ) * 10;
		pMobIndex->ac[AC_EXOTIC]	= fread_number ( fp ) * 10;

		/* read flags and add in data from the race table */
		pMobIndex->off_flags		= fread_flag ( fp )
									  | race_table[pMobIndex->race].off;
		pMobIndex->imm_flags		= fread_flag ( fp )
									  | race_table[pMobIndex->race].imm;
		pMobIndex->res_flags		= fread_flag ( fp )
									  | race_table[pMobIndex->race].res;
		pMobIndex->vuln_flags		= fread_flag ( fp )
									  | race_table[pMobIndex->race].vuln;

		/* vital statistics */
		pMobIndex->start_pos		= position_lookup ( fread_word ( fp ) );
		pMobIndex->default_pos		= position_lookup ( fread_word ( fp ) );
		pMobIndex->sex			= sex_lookup ( fread_word ( fp ) );

		pMobIndex->wealth		= fread_number ( fp );

		pMobIndex->form			= fread_flag ( fp )
								  | race_table[pMobIndex->race].form;
		pMobIndex->parts		= fread_flag ( fp )
								  | race_table[pMobIndex->race].parts;
		/* size */
		CHECK_POS ( pMobIndex->size, size_lookup ( fread_word ( fp ) ), "size" );
		/*	pMobIndex->size			= size_lookup(fread_word(fp)); */

		while ( true ) {
			letter = fread_letter ( fp );

			if ( letter == 'F' ) {
				char *word;
				long vector;

				word                    = fread_word ( fp );
				vector			= fread_flag ( fp );

				if ( !str_prefix ( word, "act" ) )
				{ REMOVE_BIT ( pMobIndex->act, vector ); }
				else if ( !str_prefix ( word, "aff" ) )
				{ REMOVE_BIT ( pMobIndex->affected_by, vector ); }
				else if ( !str_prefix ( word, "off" ) )
				{ REMOVE_BIT ( pMobIndex->off_flags, vector ); }
				else if ( !str_prefix ( word, "imm" ) )
				{ REMOVE_BIT ( pMobIndex->imm_flags, vector ); }
				else if ( !str_prefix ( word, "res" ) )
				{ REMOVE_BIT ( pMobIndex->res_flags, vector ); }
				else if ( !str_prefix ( word, "vul" ) )
				{ REMOVE_BIT ( pMobIndex->vuln_flags, vector ); }
				else if ( !str_prefix ( word, "for" ) )
				{ REMOVE_BIT ( pMobIndex->form, vector ); }
				else if ( !str_prefix ( word, "par" ) )
				{ REMOVE_BIT ( pMobIndex->parts, vector ); }
				else {
					log_hd ( LOG_ERROR, "Flag remove: flag not found." );
					exit ( 1 );
				}
			} else if ( letter == 'M' ) {
				MPROG_LIST *pMprog;
				char *word;
				int trigger = 0;

				ALLOC_DATA ( pMprog, MPROG_LIST, 1 );

				word   		    = fread_word ( fp );
				if ( ( trigger = flag_lookup ( word, mprog_flags ) ) == NO_FLAG ) {
					log_hd ( LOG_ERROR, "MOBprogs: invalid trigger." );
					exit ( 1 );
				}
				SET_BIT ( pMobIndex->mprog_flags, trigger );
				pMprog->trig_type   = trigger;
				pMprog->vnum        = fread_number ( fp );
				pMprog->trig_phrase = fread_string ( fp );
				pMprog->next        = pMobIndex->mprogs;
				pMobIndex->mprogs   = pMprog;
			} else if ( letter == 'L' ) {
				pMobIndex->repop_percent = fread_number ( fp );
			} else {
				ungetc ( letter, fp );
				break;
			}
		}

		iHash                   = vnum % MAX_KEY_HASH;
		pMobIndex->next         = mob_index_hash[iHash];
		mob_index_hash[iHash]   = pMobIndex;
		top_mob_index++;
		top_vnum_mob = top_vnum_mob < vnum ? vnum : top_vnum_mob;  /* OLC */
		assign_area_vnum ( vnum );                                 /* OLC */
		kill_table[URANGE ( 0, pMobIndex->level, MAX_LEVEL - 1 )].number++;
	}

	return;
}