Пример #1
0
static void add_name_decoration(enum decoration_type type, const char *name, struct object *obj)
{
	int nlen = strlen(name);
	struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + nlen);
	memcpy(res->name, name, nlen + 1);
	res->type = type;
	res->next = add_decoration(&name_decoration, obj, res);
}
Пример #2
0
static void add_object_buffer(struct object *object, char *buffer, unsigned long size)
{
	struct obj_buffer *obj;
	obj = xcalloc(1, sizeof(struct obj_buffer));
	obj->buffer = buffer;
	obj->size = size;
	if (add_decoration(&obj_decorate, object, obj))
		die("object %s tried to add buffer twice!", sha1_to_hex(object->sha1));
}
Пример #3
0
static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
{
	int plen = strlen(prefix);
	int nlen = strlen(name);
	struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + plen + nlen);
	memcpy(res->name, prefix, plen);
	memcpy(res->name + plen, name, nlen + 1);
	res->next = add_decoration(&name_decoration, obj, res);
}
Пример #4
0
static struct merge_simplify_state *locate_simplify_state(struct rev_info *revs, struct commit *commit)
{
	struct merge_simplify_state *st;

	st = lookup_decoration(&revs->merge_simplification, &commit->object);
	if (!st) {
		st = xcalloc(1, sizeof(*st));
		add_decoration(&revs->merge_simplification, &commit->object, st);
	}
	return st;
}
Пример #5
0
static void put_object_name(struct fsck_options *options, struct object *obj,
	const char *fmt, ...)
{
	va_list ap;
	struct strbuf buf = STRBUF_INIT;
	char *existing;

	if (!options->object_names)
		return;
	existing = lookup_decoration(options->object_names, obj);
	if (existing)
		return;
	va_start(ap, fmt);
	strbuf_vaddf(&buf, fmt, ap);
	add_decoration(options->object_names, obj, strbuf_detach(&buf, NULL));
	va_end(ap);
}
Пример #6
0
void Room::set_wall_decoration(Sprites *sprites, boolean give_priority, boolean subpicture) {
   initialize_wall_decoration();
   if (sprites == NULL) {
      wall_decoration->set_visible(FALSE);
   } else {
//      wall_decoration->set_visible(TRUE);
      Sprites *remaining = sprites;
      while (remaining != NULL) {
         add_decoration(remaining->first(),give_priority,subpicture);
//         wall_decoration->add_follower(sprite,TRUE,FALSE);  // is completely inside but want insertion by priority
//         sprite->recursively_activate_pictures();
         remaining->set_first(NULL); // since about to destroy list
         remaining = remaining->rest();
      };
      delete sprites; // just the list not the contents
   };
};
Пример #7
0
static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
	timestamp_t timestamp)
{
	struct object *obj;

	if (!is_null_oid(oid)) {
		obj = lookup_object(oid->hash);
		if (obj && (obj->flags & HAS_OBJ)) {
			if (timestamp && name_objects)
				add_decoration(fsck_walk_options.object_names,
					obj,
					xstrfmt("%s@{%"PRItime"}", refname, timestamp));
			obj->flags |= USED;
			mark_object_reachable(obj);
		} else if (!is_promisor_object(oid)) {
			error("%s: invalid reflog entry %s", refname, oid_to_hex(oid));
			errors_found |= ERROR_REACHABLE;
		}
	}
}
Пример #8
0
void meltSnowAndIce(MAP * map, int x, int y, int depth, int emit,
    int makeSteam)
{
    int data = 0;
    int layers = 0, oldLayers = 0;
    int snowDone = 0;
    int steamLength = 0;

    if (!map)
	return;

    if (depth <= 0)
	return;

    oldLayers = GetHexLayers(map, x, y);
    layers = oldLayers;
    data = GetHexLayerData(map, x, y);

    if ((layers & HEXLAYER_SNOW) || (layers & HEXLAYER_DEEP_SNOW)) {
	data = MAX(0, data - depth);
	steamLength = abs(data - GetHexLayerData(map, x, y));

	if (data == 0)
	    layers &= ~(HEXLAYER_SNOW | HEXLAYER_DEEP_SNOW);
	else if (data <= 1000) {
	    layers |= HEXLAYER_SNOW;
	    layers &= ~HEXLAYER_DEEP_SNOW;
	} else {
	    layers |= HEXLAYER_DEEP_SNOW;
	    layers &= ~HEXLAYER_SNOW;
	}

	SetHexLayers(map, x, y, layers);
	SetHexLayerData(map, x, y, data);

	if (emit) {
	    if (layers & HEXLAYER_DEEP_SNOW)
		snowDone = 1;

	    if (!snowDone && !((layers & HEXLAYER_SNOW) ||
		    (layers & HEXLAYER_DEEP_SNOW))) {
		HexLOSBroadcast(map, x, y,
		    "%ch%cgThe snow in $h melts to nothingness!%cn");
		snowDone = 1;
	    }

	    if (!snowDone && ((oldLayers & HEXLAYER_DEEP_SNOW) &&
		    (!(layers & HEXLAYER_DEEP_SNOW)))) {
		HexLOSBroadcast(map, x, y,
		    "%ch%cgThe snow in $h visibly melts!%cn");
		snowDone = 1;
	    }
	}
    }

    if (IsIceHex(map, x, y)) {
	if (depth >= (Elevation(map, x, y) * 200)) {
	    if (emit)
		HexLOSBroadcast(map, x, y, "The ice at $h breaks apart!");

	    breakIceAndSplashUnits(map, NULL, x, y,
		"goes swimming as ice breaks!");
	    steamLength = (Elevation(map, x, y) * 200);
	}
    }

    if ((steamLength > 0) && makeSteam) {
	if (steamLength > 90)
	    steamLength = 90 + Number(0, steamLength / 20);

	add_decoration(map, x, y, TYPE_SMOKE, SMOKE, steamLength);
    }
}
Пример #9
0
static inline void mark_object(struct object *object, uint32_t mark)
{
	add_decoration(&idnums, object, mark_to_ptr(mark));
}
Пример #10
0
int cmd_fsck(int argc, const char **argv, const char *prefix)
{
	int i;
	struct alternate_object_database *alt;

	/* fsck knows how to handle missing promisor objects */
	fetch_if_missing = 0;

	errors_found = 0;
	check_replace_refs = 0;

	argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0);

	fsck_walk_options.walk = mark_object;
	fsck_obj_options.walk = mark_used;
	fsck_obj_options.error_func = fsck_error_func;
	if (check_strict)
		fsck_obj_options.strict = 1;

	if (show_progress == -1)
		show_progress = isatty(2);
	if (verbose)
		show_progress = 0;

	if (write_lost_and_found) {
		check_full = 1;
		include_reflogs = 0;
	}

	if (name_objects)
		fsck_walk_options.object_names =
			xcalloc(1, sizeof(struct decoration));

	git_config(fsck_config, NULL);

	fsck_head_link();
	if (connectivity_only) {
		for_each_loose_object(mark_loose_for_connectivity, NULL, 0);
		for_each_packed_object(mark_packed_for_connectivity, NULL, 0);
	} else {
		struct alternate_object_database *alt_odb_list;

		fsck_object_dir(get_object_directory());

		prepare_alt_odb(the_repository);
		alt_odb_list = the_repository->objects->alt_odb_list;
		for (alt = alt_odb_list; alt; alt = alt->next)
			fsck_object_dir(alt->path);

		if (check_full) {
			struct packed_git *p;
			uint32_t total = 0, count = 0;
			struct progress *progress = NULL;

			if (show_progress) {
				for (p = get_packed_git(the_repository); p;
				     p = p->next) {
					if (open_pack_index(p))
						continue;
					total += p->num_objects;
				}

				progress = start_progress(_("Checking objects"), total);
			}
			for (p = get_packed_git(the_repository); p;
			     p = p->next) {
				/* verify gives error messages itself */
				if (verify_pack(p, fsck_obj_buffer,
						progress, count))
					errors_found |= ERROR_PACK;
				count += p->num_objects;
			}
			stop_progress(&progress);
		}
	}

	for (i = 0; i < argc; i++) {
		const char *arg = argv[i];
		struct object_id oid;
		if (!get_oid(arg, &oid)) {
			struct object *obj = lookup_object(oid.hash);

			if (!obj || !(obj->flags & HAS_OBJ)) {
				if (is_promisor_object(&oid))
					continue;
				error("%s: object missing", oid_to_hex(&oid));
				errors_found |= ERROR_OBJECT;
				continue;
			}

			obj->flags |= USED;
			if (name_objects)
				add_decoration(fsck_walk_options.object_names,
					obj, xstrdup(arg));
			mark_object_reachable(obj);
			continue;
		}
		error("invalid parameter: expected sha1, got '%s'", arg);
		errors_found |= ERROR_OBJECT;
	}

	/*
	 * If we've not been given any explicit head information, do the
	 * default ones from .git/refs. We also consider the index file
	 * in this case (ie this implies --cache).
	 */
	if (!argc) {
		get_default_heads();
		keep_cache_objects = 1;
	}

	if (keep_cache_objects) {
		verify_index_checksum = 1;
		verify_ce_order = 1;
		read_cache();
		for (i = 0; i < active_nr; i++) {
			unsigned int mode;
			struct blob *blob;
			struct object *obj;

			mode = active_cache[i]->ce_mode;
			if (S_ISGITLINK(mode))
				continue;
			blob = lookup_blob(&active_cache[i]->oid);
			if (!blob)
				continue;
			obj = &blob->object;
			obj->flags |= USED;
			if (name_objects)
				add_decoration(fsck_walk_options.object_names,
					obj,
					xstrfmt(":%s", active_cache[i]->name));
			mark_object_reachable(obj);
		}
		if (active_cache_tree)
			fsck_cache_tree(active_cache_tree);
	}

	check_connectivity();
	return errors_found;
}