/**
* For the .list command.
*
* @param crop_data *crop The thing to list.
* @param bool detail If TRUE, provide additional details
* @return char* The line to show (without a CRLF).
*/
char *list_one_crop(crop_data *crop, bool detail) {
	static char output[MAX_STRING_LENGTH];
	
	if (detail) {
		snprintf(output, sizeof(output), "[%5d] %s", GET_CROP_VNUM(crop), GET_CROP_NAME(crop));
	}
	else {
		snprintf(output, sizeof(output), "[%5d] %s", GET_CROP_VNUM(crop), GET_CROP_NAME(crop));
	}
	
	return output;
}
Пример #2
0
	// update crops
	HASH_ITER(hh, crop_table, crop, next_crop) {
		found = delete_mob_from_spawn_list(&GET_CROP_SPAWNS(crop), vnum);
		found |= delete_from_interaction_list(&GET_CROP_INTERACTIONS(crop), TYPE_MOB, vnum);
		if (found) {
			save_library_file_for_vnum(DB_BOOT_CROP, GET_CROP_VNUM(crop));
		}
	}
/**
* Creates a new crop entry.
* 
* @param crop_vnum vnum The number to create.
* @return crop_data* The new crop's prototype.
*/
crop_data* create_crop_table_entry(crop_vnum vnum) {
	void add_crop_to_table(crop_data *crop);
	
	crop_data *crop;
	
	// sanity
	if (crop_proto(vnum)) {
		log("SYSERR: Attempting to insert crop at existing vnum %d", vnum);
		return crop_proto(vnum);
	}
	
	CREATE(crop, crop_data, 1);
	init_crop(crop);
	GET_CROP_VNUM(crop) = vnum;
	add_crop_to_table(crop);

	// save index and crop file now
	save_index(DB_BOOT_CROP);
	save_library_file_for_vnum(DB_BOOT_CROP, vnum);

	return crop;
}
/**
* Checks for common crop problems and reports them to ch.
*
* @param crop_data *cp The item to audit.
* @param char_data *ch The person to report to.
* @return bool TRUE if any problems were reported; FALSE if all good.
*/
bool audit_crop(crop_data *cp, char_data *ch) {
	extern adv_data *get_adventure_for_vnum(rmt_vnum vnum);
	extern struct icon_data *get_icon_from_set(struct icon_data *set, int type);
	extern const char *icon_types[];
	
	struct interaction_item *inter;
	char temp[MAX_STRING_LENGTH];
	bool problem = FALSE;
	bool harv, forage;
	adv_data *adv;
	int iter;
	
	adv = get_adventure_for_vnum(GET_CROP_VNUM(cp));
	
	if (!GET_CROP_NAME(cp) || !*GET_CROP_NAME(cp) || !str_cmp(GET_CROP_NAME(cp), "Unnamed Crop")) {
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "No name set");
		problem = TRUE;
	}
	
	strcpy(temp, GET_CROP_NAME(cp));
	strtolower(temp);
	if (strcmp(GET_CROP_NAME(cp), temp)) {
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "Non-lowercase name");
		problem = TRUE;
	}
	
	if (!GET_CROP_TITLE(cp) || !*GET_CROP_TITLE(cp) || !str_cmp(GET_CROP_TITLE(cp), "An Unnamed Crop")) {
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "No title set");
		problem = TRUE;
	}
	
	if (adv && !CROP_FLAGGED(cp, CROPF_NOT_WILD)) {
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "Missing !WILD flag in adventure crop");
		problem = TRUE;
	}
	if (!adv && CROP_FLAGGED(cp, CROPF_NOT_WILD)) {
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "!WILD flag on non-adventure crop");
		problem = TRUE;
	}
	if (GET_CROP_MAPOUT(cp) == 0) {	// slightly magic-numbered
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "Mapout color not set");
		problem = TRUE;
	}
	for (iter = 0; iter < NUM_TILESETS; ++iter) {
		if (!get_icon_from_set(GET_CROP_ICONS(cp), iter)) {
			olc_audit_msg(ch, GET_CROP_VNUM(cp), "No icon for '%s' tileset", icon_types[iter]);
			problem = TRUE;
		}
	}
	if (GET_CROP_CLIMATE(cp) == CLIMATE_NONE) {
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "Climate not set");
		problem = TRUE;
	}
	if (!GET_CROP_SPAWNS(cp)) {
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "No spawns set");
		problem = TRUE;
	}
	
	harv = forage = FALSE;
	LL_FOREACH(GET_CROP_INTERACTIONS(cp), inter) {
		if (inter->type == INTERACT_HARVEST) {
			harv = TRUE;
		}
		else if (inter->type == INTERACT_FORAGE) {
			forage = TRUE;
		}
	}
	if (!harv) {
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "No HARVEST");
		problem = TRUE;
	}
	if (!forage) {
		olc_audit_msg(ch, GET_CROP_VNUM(cp), "No FORAGE");
		problem = TRUE;
	}
	
	return problem;
}