static void save_event(EVENT * e)
{
    MECH *mech = (MECH *) e->data;
    int data = (int) e->data2;
    int t;

    t = e->tick - event_tick;
    t = MAX(1, t);
    if (e->function == very_fake_func)
	t = 0 - t;
    CHESA(mech->mynum);
    CHESA(ev_type);
    CHESA(t);
    CHESA(data);
}
void saverepairs(FILE * f)
{
    int i;
    dbref d = -1;

    cheat_file = f;
    for (i = FIRST_TECH_EVENT; i <= LAST_TECH_EVENT; i++) {
	ev_type = i;
	event_gothru_type(i, save_event);
    }
    CHESA(d);
}
示例#3
0
文件: map.bits.c 项目: chazu/btmux
void map_save_bits(FILE * f, MAP * map, mapobj * obj)
{
	int tmp;
	int i, j, c, tc = 0;
	unsigned char **foo;
	int xs = map->map_width;
	int ys = map->map_height;
	unsigned char tmpb;

#define outbyte(a) tmpb=(a);fwrite(&tmpb, 1, 1, f);
	foo = (unsigned char **) ((void *) obj->datai);
	/* First, we clean up our act */
	for(i = 0; i < ys; i++) {
		c = 0;
		if(foo[i]) {
			for(j = 0; j < realnum(xs); j++)
				if(foo[i][j])
					c++;
			if(!c) {
				free((void *) foo[i]);
				foo[i] = NULL;
			} else
				tc += c;
		}
	}
	if(!tc) {
		/* We don't want to save worthless shit */
		/* On other hand, cleaning us out of memory would take too
		   much trouble compared to the worth. Therefore, during next
		   cleanup (reboot), this structure does a disappearance act. */
		return;
	}
	outbyte(TYPE_BITS + 1);
	CHESA(foo, sizeof(unsigned char *), ys, f);

	for(i = 0; i < ys; i++)
		if(foo[i])
			CHESA(foo[i], sizeof(unsigned char), realnum(xs), f);
}