Beispiel #1
0
void _cdecl wr_counter(dword ctr, int col, int row, int Fcolor, int Bcolor, int radix)
{
#if (DEVICE_CONSOLE_OUT)

   char  buffer[11];
   uint  i, j;

   ENTER_CLIB();
   _ultoa(ctr, buffer, radix);
   EXIT_CLIB();

   for(i = 0; buffer[i] && i < 6; i++) {}  /* find end of string */
   for(; i < 6; i++)                       /* right align */
   {
      for(j = i+1; j > 0; j--)
         buffer[j] = buffer[j-1];
      buffer[j] = '0';
   }

   wr_string(col,row,Fcolor,Bcolor,!BLINK,buffer);

#else
   /* Avoid compiler warning about unused pars. */
   (void) ctr;
   (void) col;
   (void) row;
   (void) Fcolor;
   (void) Bcolor;
   (void) radix;

#endif /* DEVICE_CONSOLE_OUT */
}
Beispiel #2
0
/*
 * Write the notes into the savefile. Every savefile has at least NOTES_MARK.
 */
static void wr_notes(void)
{
	char end_note[80];
	char tmpstr[100];
	char ch;
	bool done = FALSE;

	int i = 0;
	int j = 0;
	
	// Sil: I've had to re-do this with the removal of the notes file
	//      The code below is pretty verbose and surely there was a better way!
	while (!done)
	{
		j = 0;
		
		while (TRUE)
		{
			ch = notes_buffer[i];
			
			tmpstr[j] = ch;
			
			i++;
			j++;

			if (ch == '\n')
			{
				tmpstr[j-1] = '\0';
				
				wr_string(tmpstr);
				break;
			}
			
			if (ch == '\0')
			{
				done = TRUE;
				break;
			}
		}
	}
		
	// copy the special notes marker into a string
	my_strcpy(end_note, NOTES_MARK, sizeof(end_note));

  	/* Always write NOTES_MARK */
  	wr_string(end_note);
}
Beispiel #3
0
/*!
 * @brief ダミー情報スキップを書き込む / Hack -- Write the "ghost" info
 * @return なし
 */
static void wr_ghost(void)
{
	int i;

	/* Name */
	wr_string(_("不正なゴースト", "Broken Ghost"));

	/* Hack -- stupid data */
	for (i = 0; i < 60; i++) wr_byte(0);
}
Beispiel #4
0
/**
 * Hack -- Write the "ghost" info
 */
void wr_ghost(void)
{
    int i;
  
    /* Name */
    wr_string("Broken Ghost");
  
    /* Hack -- stupid data */
    for (i = 0; i < 60; i++) wr_byte(0);
}
Beispiel #5
0
/*
 * Write the "options"
 */
void wr_options(void)
{
	int i, k;

	u32b window_flag[ANGBAND_TERM_MAX];
	u32b window_mask[ANGBAND_TERM_MAX];


	/* Special Options */
	wr_byte(op_ptr->delay_factor);
	wr_byte(op_ptr->hitpoint_warn);
	wr_u16b(lazymove_delay);

	/* Normal options */
	for (i = 0; i < OPT_MAX; i++) {
		const char *name = option_name(i);
		if (!name)
			continue;

		wr_string(name);
		wr_byte(op_ptr->opt[i]);
   }

	/* Sentinel */
	wr_byte(0);

	/*** Window options ***/

	/* Reset */
	for (i = 0; i < ANGBAND_TERM_MAX; i++)
	{
		/* Flags */
		window_flag[i] = op_ptr->window_flag[i];

		/* Mask */
		window_mask[i] = 0L;

		/* Build the mask */
		for (k = 0; k < 32; k++)
		{
			/* Set mask */
			if (window_flag_desc[k])
			{
				window_mask[i] |= (1L << k);
			}
		}
	}

	/* Dump the flags */
	for (i = 0; i < ANGBAND_TERM_MAX; i++) wr_u32b(window_flag[i]);

	/* Dump the masks */
	for (i = 0; i < ANGBAND_TERM_MAX; i++) wr_u32b(window_mask[i]);
}
Beispiel #6
0
/*
 * Write a description of the character
 */
void wr_description(void)
{
	char buf[1024];

	if (p_ptr->is_dead)
		strnfmt(buf, sizeof buf, "%s, dead (%s)", op_ptr->full_name,
				p_ptr->died_from);
	else
		strnfmt(buf, sizeof buf, "%s, L%d %s %s",
				op_ptr->full_name, p_ptr->lev, rp_ptr->name, cp_ptr->name);

	wr_string(buf);
}
Beispiel #7
0
void wr_ghost(void)
{
	int i;

	if (p_ptr->is_dead)
		return;

	/* XXX */
	
	/* Name */
	wr_string("Broken Ghost");
	
	/* Hack -- stupid data */
	for (i = 0; i < 60; i++) wr_byte(0);
}
Beispiel #8
0
/*
 * Write a description of the character
 */
void wr_description(void)
{
	char buf[1024];

	if (p_ptr->is_dead)
		strnfmt(buf, sizeof buf, "%s, dead (%s)", op_ptr->full_name, p_ptr->died_from);
	else
		strnfmt(buf, sizeof buf, "%s, L%d %s %s, at DL%d",
				op_ptr->full_name,
				p_ptr->lev,
				p_ptr->race->name,
				p_ptr->class->name,
				p_ptr->depth);

	wr_string(buf);
}
Beispiel #9
0
void wr_history(void)
{
	size_t i;
	u32b tmp32u = history_get_num();

	wr_u32b(tmp32u);
	for (i = 0; i < tmp32u; i++)
	{
		wr_u16b(history_list[i].type);
		wr_s32b(history_list[i].turn);
		wr_s16b(history_list[i].dlev);
		wr_s16b(history_list[i].clev);
		wr_byte(history_list[i].a_idx);
		wr_string(history_list[i].event);
	}
}
Beispiel #10
0
void wr_messages(void)
{
	s16b i;
	u16b num;

	num = messages_num();
	if (num > 80) num = 80;
	wr_u16b(num);

	/* Dump the messages (oldest first!) */
	for (i = num - 1; i >= 0; i--)
	{
		wr_string(message_str(i));
		wr_u16b(message_type(i));
	}
}
Beispiel #11
0
/*
 * Dump the random artefacts
 */
static void wr_randarts(void)
{
	int i, begin;

	if (adult_rand_artefacts) begin = 0;
	else begin = z_info->art_norm_max;

	wr_u16b(begin);
	wr_u16b(z_info->art_max);
	wr_u16b(z_info->art_norm_max);


	for (i = begin; i < z_info->art_max; i++)
	{
		artefact_type *a_ptr = &a_info[i];

		wr_string(a_ptr->name);

		wr_byte(a_ptr->tval);
		wr_byte(a_ptr->sval);
		wr_s16b(a_ptr->pval);

		wr_s16b(a_ptr->att);
		wr_byte(a_ptr->dd);
		wr_byte(a_ptr->ds);
		wr_s16b(a_ptr->evn);
		wr_byte(a_ptr->pd);
		wr_byte(a_ptr->ps);

		wr_s16b(a_ptr->weight);
		wr_s32b(a_ptr->cost);

		wr_u32b(a_ptr->flags1);
		wr_u32b(a_ptr->flags2);
		wr_u32b(a_ptr->flags3);

		wr_byte(a_ptr->level);
		wr_byte(a_ptr->rarity);

		wr_byte(a_ptr->activation);
		wr_u16b(a_ptr->time);
		wr_u16b(a_ptr->randtime);
	}

}
Beispiel #12
0
void wr_squelch(void)
{
	size_t i, n;

	/* Write number of squelch bytes */
	wr_byte(squelch_size);
	for (i = 0; i < squelch_size; i++)
		wr_byte(squelch_level[i]);

	/* Write ego-item squelch bits */
	wr_u16b(z_info->e_max);
	for (i = 0; i < z_info->e_max; i++)
	{
		byte flags = 0;

		/* Figure out and write the everseen flag */
		if (e_info[i].everseen) flags |= 0x02;
		wr_byte(flags);
	}

	n = 0;
	for (i = 0; i < z_info->k_max; i++)
		if (k_info[i].note)
			n++;

	/* Write the current number of auto-inscriptions */
	wr_u16b(n);

	/* Write the autoinscriptions array */
	for (i = 0; i < z_info->k_max; i++) {
		if (!k_info[i].note)
			continue;
		wr_s16b(i);
		wr_string(quark_str(k_info[i].note));
	}

	return;
}
Beispiel #13
0
/**
 * Write autoinscribe & squelch item-quality submenu to the savefile
 */
void wr_squelch(void)
{
	int i, j;

	/* Write number of quality squelch bytes */
	wr_byte(Q_TV_MAX * SQUELCH_MAX);
	for (i = 0; i < Q_TV_MAX; i++)
		for (j = 0; j < SQUELCH_MAX; j++)
			wr_byte(squelch_profile[i][j]);

	/* Write ego-item squelch bits */
	wr_u16b(z_info->e_max);
	for (i = 0; i < z_info->e_max; i++) {
		byte flags = 0;

		/* Figure out and write the everseen flag */
		if (e_info[i].squelch)
			flags |= 0x01;
		if (e_info[i].everseen)
			flags |= 0x02;
		wr_byte(flags);

		/* Expansion */
		wr_u32b(0);
	}

	/* Write the current number of auto-inscriptions */
	wr_u16b(inscriptions_count);

	/* Write the autoinscriptions array */
	for (i = 0; i < inscriptions_count; i++) {
		wr_s16b(inscriptions[i].kind_idx);
		wr_string(quark_str(inscriptions[i].inscription_idx));
	}

	return;
}
Beispiel #14
0
/*!
 * @brief クイック・スタート情報を書き込む / Save quick start data
 * @return なし
 */
static void save_quick_start(void)
{
	int i;

	wr_byte(previous_char.psex);
	wr_byte(previous_char.prace);
	wr_byte(previous_char.pclass);
	wr_byte(previous_char.pseikaku);
	wr_byte(previous_char.realm1);
	wr_byte(previous_char.realm2);

	wr_s16b(previous_char.age);
	wr_s16b(previous_char.ht);
	wr_s16b(previous_char.wt);
	wr_s16b(previous_char.sc);
	wr_s32b(previous_char.au);

	for (i = 0; i < 6; i++) wr_s16b(previous_char.stat_max[i]);
	for (i = 0; i < 6; i++) wr_s16b(previous_char.stat_max_max[i]);

	for (i = 0; i < PY_MAX_LEVEL; i++) wr_s16b(previous_char.player_hp[i]);

	wr_s16b(previous_char.chaos_patron);

	for (i = 0; i < 8; i++) wr_s16b(previous_char.vir_types[i]);

	for (i = 0; i < 4; i++) wr_string(previous_char.history[i]);

	/* UNUSED : Was number of random quests */
	wr_byte(0);

	/* No quick start after using debug mode or cheat options */
	if (p_ptr->noscore) previous_char.quick_ok = FALSE;

	wr_byte((byte)previous_char.quick_ok);
}
Beispiel #15
0
/*
 * Write some "extra" info
 */
static void wr_extra(void)
{
	int i, j;

	wr_string(op_ptr->full_name);

	wr_string(p_ptr->died_from);

	wr_string(p_ptr->history);

	/* Race/House/Sex */
	wr_byte(p_ptr->prace);
	wr_byte(p_ptr->phouse);
	wr_byte(p_ptr->psex);
	
	wr_s16b(p_ptr->game_type);

	/* Age/Height/Weight */
	wr_s16b(p_ptr->age);
	wr_s16b(p_ptr->ht);
	wr_s16b(p_ptr->wt);

	/* Dump the stats (maximum and current) */
	for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_base[i]);
	for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_drain[i]);

	/* Dump the skill bases */
	for (i = 0; i < S_MAX; ++i) wr_s16b(p_ptr->skill_base[i]);

	for (i = 0; i < S_MAX; ++i) 
	{
		for (j = 0; j < ABILITIES_MAX; ++j) 
		{
			wr_byte(p_ptr->innate_ability[i][j]);
			wr_byte(p_ptr->active_ability[i][j]);
		}
	}

	wr_s16b(p_ptr->last_attack_m_idx);	
	wr_s16b(p_ptr->consecutive_attacks);
	wr_s16b(p_ptr->bane_type);
	
	for (i = 0; i < ACTION_MAX; ++i) 
	{
		wr_byte(p_ptr->previous_action[i]);
	}
	wr_byte(p_ptr->focused);
	
	wr_s32b(p_ptr->new_exp);
	wr_s32b(p_ptr->exp);
	
	wr_s32b(p_ptr->encounter_exp);
	wr_s32b(p_ptr->kill_exp);
	wr_s32b(p_ptr->descent_exp);
	wr_s32b(p_ptr->ident_exp);
	
	wr_s16b(p_ptr->mhp);
	wr_s16b(p_ptr->chp);
	wr_u16b(p_ptr->chp_frac);

	wr_s16b(p_ptr->msp);
	wr_s16b(p_ptr->csp);
	wr_u16b(p_ptr->csp_frac);

	/* Max Dungeon Level */
	wr_s16b(p_ptr->max_depth);
	
	wr_u16b(p_ptr->staircasiness);

	/* More info */
	wr_s16b(p_ptr->sc);

	wr_byte(p_ptr->song1);
	wr_byte(p_ptr->song2);
	wr_s16b(p_ptr->song_duration);
	wr_s16b(p_ptr->wrath); 
	wr_s16b(p_ptr->blind);
	wr_s16b(p_ptr->entranced);
	wr_s16b(p_ptr->confused);
	wr_s16b(p_ptr->food);
	wr_u16b(p_ptr->stairs_taken);
	wr_u16b(p_ptr->forge_drought);
	wr_u16b(p_ptr->forge_count);
	wr_s16b(p_ptr->energy);
	wr_s16b(p_ptr->fast);
	wr_s16b(p_ptr->slow);
	wr_s16b(p_ptr->afraid);
	wr_s16b(p_ptr->cut);
	wr_s16b(p_ptr->stun);
	wr_s16b(p_ptr->poisoned);
	wr_s16b(p_ptr->image);
	wr_s16b(p_ptr->rage);
	wr_s16b(p_ptr->tmp_str);
	wr_s16b(p_ptr->tmp_dex);
	wr_s16b(p_ptr->tmp_con);
	wr_s16b(p_ptr->tmp_gra);
	wr_s16b(p_ptr->tim_invis);
	wr_s16b(p_ptr->word_recall);
	wr_s16b(p_ptr->darkened);
	wr_s16b(p_ptr->oppose_fire);
	wr_s16b(p_ptr->oppose_cold);
	wr_s16b(p_ptr->oppose_pois);

	wr_byte(p_ptr->stealth_mode);
	wr_byte(p_ptr->self_made_arts);

	// 20 spare bytes
	wr_byte(0);
	wr_byte(0);
	wr_byte(0);
	wr_byte(0);
	wr_u32b(0L);
	wr_u32b(0L);
	
	wr_u32b((p_ptr->loglive.i)[0]); //mortality info
	wr_u32b((p_ptr->loglive.i)[1]);
		
	/* Save item-quality squelch sub-menu */
	for (i = 0; i < SQUELCH_BYTES; i++) wr_byte(squelch_level[i]);

	/* Store the name of the current greater vault */
	wr_string(g_vault_name);

	/* Save the current number of special item types */
	wr_u16b(z_info->e_max);

	/* Save special item squelch settings */
	for (i = 0; i < z_info->e_max; i++)
	{
		ego_item_type *e_ptr = &e_info[i];
		byte tmp8u = 0;

		if (e_ptr->squelch) tmp8u |= 0x01;
		if (e_ptr->everseen) tmp8u |= 0x02;
		if (e_ptr->aware) tmp8u |= 0x04;

		wr_byte(tmp8u);
	}

	/*Write the current number of auto-inscriptions*/
	wr_u16b(inscriptionsCount);

	/*Write the autoinscriptions array*/
	for(i = 0; i < inscriptionsCount; i++)
	{
		wr_s16b(inscriptions[i].kindIdx);
		wr_string(quark_str(inscriptions[i].inscriptionIdx));
	}

	// Greater vaults seen
	for (i = 0; i < MAX_GREATER_VAULTS; i++)
	{
		wr_s16b(p_ptr->greater_vaults[i]);
	}
	
	/* Random artefact version */
	wr_u32b(RANDART_VERSION);

	/* Random artefact seed */
	wr_u32b(seed_randart);

	/* Write the "object seeds" */
	wr_u32b(seed_flavor);

	/* Special stuff */
	wr_u16b(p_ptr->panic_save);
	wr_byte(p_ptr->truce);
	wr_byte(p_ptr->morgoth_hits);
	wr_byte(p_ptr->crown_hint);
	wr_byte(p_ptr->crown_shatter);
	wr_byte(p_ptr->cursed);
	wr_byte(p_ptr->on_the_run);
	wr_byte(p_ptr->morgoth_slain);
	wr_u16b(p_ptr->escaped);
	wr_u16b(p_ptr->noscore);
	wr_u16b(p_ptr->smithing_leftover);
	wr_byte(p_ptr->unique_forge_made);
	wr_byte(p_ptr->unique_forge_seen);

	/* Write death */
	wr_byte(p_ptr->is_dead);

	/* Write feeling */
	wr_byte(feeling);

	/* Turn of last "feeling" */
	wr_byte(do_feeling);

	/* Current turn */
	wr_s32b(turn);
	wr_s32b(playerturn);
}
Beispiel #16
0
/**
 * Write some player info
 */
void wr_player(void)
{
	int i;

	wr_string(op_ptr->full_name);

	wr_string(p_ptr->died_from);

	wr_string(p_ptr->history);

	/* Race/Class/Gender/Spells */
	wr_byte(p_ptr->prace);
	wr_byte(p_ptr->pclass);
	wr_byte(p_ptr->psex);
	wr_byte(op_ptr->name_suffix);

	wr_byte(p_ptr->hitdie);
	wr_byte(0);

	wr_s16b(p_ptr->age);
	wr_s16b(p_ptr->ht);
	wr_s16b(p_ptr->wt);


	/* Dump the stats (maximum and current) */
	for (i = 0; i < A_MAX; ++i)
		wr_s16b(p_ptr->stat_max[i]);
	for (i = 0; i < A_MAX; ++i)
		wr_s16b(p_ptr->stat_cur[i]);
	for (i = 0; i < A_MAX; ++i)
		wr_s16b(p_ptr->stat_birth[i]);

	wr_s16b(p_ptr->ht_birth);
	wr_s16b(p_ptr->wt_birth);
	wr_s16b(p_ptr->sc_birth);
	wr_u32b(p_ptr->au_birth);

	/* Druid damage */
	for (i = 0; i < 12; ++i)
		wr_u16b(p_ptr->barehand_dam[i]);

	wr_u32b(p_ptr->au);

	wr_u32b(p_ptr->max_exp);
	wr_u32b(p_ptr->exp);
	wr_u16b(p_ptr->exp_frac);
	wr_s16b(p_ptr->lev);
	wr_s16b(p_ptr->home);

	wr_s16b(p_ptr->mhp);
	wr_s16b(p_ptr->chp);
	wr_u16b(p_ptr->chp_frac);

	wr_s16b(p_ptr->msp);
	wr_s16b(p_ptr->csp);
	wr_u16b(p_ptr->csp_frac);

	/* Max Player and Dungeon Levels */
	wr_s16b(p_ptr->max_lev);
	wr_byte(MAX_RECALL_PTS);
	for (i = 0; i < MAX_RECALL_PTS; i++)
		wr_s16b(p_ptr->recall[i]);
	wr_s16b(p_ptr->recall_pt);

	/* Game map and modes */
	wr_byte(p_ptr->map);
	wr_byte(GAME_MODE_MAX);
	for (i = 0; i < GAME_MODE_MAX; i++)
		wr_byte(p_ptr->game_mode[i]);

	/* More info */
	wr_s16b(p_ptr->speed_boost);	/* Specialty Fury */
	wr_s16b(p_ptr->heighten_power);	/* Specialty Heighten Magic */
	wr_s16b(p_ptr->sc);

	wr_s16b(p_ptr->food);
	wr_s16b(p_ptr->energy);
	wr_s16b(p_ptr->word_recall);
	wr_s16b(p_ptr->state.see_infra);

	/* Find the number of timed effects */
	wr_byte(TMD_MAX);

	/* Read all the effects, in a loop */
	for (i = 0; i < TMD_MAX; i++)
		wr_s16b(p_ptr->timed[i]);


	wr_u32b(p_ptr->special_attack);	/* Attack modifier flags. */
	wr_byte(0);					/* oops */
	wr_byte(0);					/* oops */
	wr_byte(p_ptr->black_breath);	/* Now used to store Black Breath. */
	wr_byte(p_ptr->searching);
	wr_byte(0);					/* formerly maximize */
	wr_byte(0);					/* formerly preserve */
	wr_byte(p_ptr->schange);	/* Now used to store shapechange. */

	/* Store the bones file selector, if the player is not dead. -LM- */
	if (!(p_ptr->is_dead))
		wr_byte(bones_selector);
	else
		wr_byte(0);

	/* Store the number of thefts on the level. -LM- */
	wr_byte(number_of_thefts_on_level);

	/* Store number of monster traps on this level. -LM- */
	wr_byte(num_trap_on_level);

	/* Store number of runes on this level, mana reserve for rune of mana. */
	wr_byte(RUNE_TAIL);
	for (i = 0; i < RUNE_TAIL; i++)
		wr_byte(num_runes_on_level[i]);
	wr_byte((byte) mana_reserve);

	wr_byte(p_ptr->themed_level);	/* Stores the current themed level. -LM- */

	/* Stores what themed levels have already appeared. -LM- */
	wr_u32b(p_ptr->themed_level_appeared);

	/* Specialty abilties */
	wr_byte(MAX_SPECIALTIES);
	for (i = 0; i < MAX_SPECIALTIES; i++)
		wr_byte(p_ptr->specialty_order[i]);

	/* Ignore some flags */
	wr_s16b(0L);				/* oops */

	/* Expansion */
	wr_u32b(0);
	wr_u32b(0);
}
Beispiel #17
0
/*!
 * @brief セーブデータの書き込み /
 * Actually write a save-file
 * @return 成功すればtrue
 */
static bool wr_savefile_new(void)
{
	int        i, j;

	u32b              now;

	byte            tmp8u;
	u16b            tmp16u;


	/* Compact the objects */
	compact_objects(0);
	/* Compact the monsters */
	compact_monsters(0);

	/* Guess at the current time */
	now = time((time_t *)0);


	/* Note the operating system */
	sf_system = 0L;

	/* Note when the file was saved */
	sf_when = now;

	/* Note the number of saves */
	sf_saves++;


	/*** Actually write the file ***/

	/* Dump the file header */
	xor_byte = 0;
	wr_byte(FAKE_VER_MAJOR);
	xor_byte = 0;
	wr_byte(FAKE_VER_MINOR);
	xor_byte = 0;
	wr_byte(FAKE_VER_PATCH);
	xor_byte = 0;

	/* Initial value of xor_byte */
	tmp8u = (byte)Rand_external(256);
	wr_byte(tmp8u);


	/* Reset the checksum */
	v_stamp = 0L;
	x_stamp = 0L;

	/* Write the savefile version for Hengband 1.1.1 and later */
	wr_byte(H_VER_EXTRA);
	wr_byte(H_VER_PATCH);
	wr_byte(H_VER_MINOR);
	wr_byte(H_VER_MAJOR);

	/* Operating system */
	wr_u32b(sf_system);


	/* Time file last saved */
	wr_u32b(sf_when);

	/* Number of past lives */
	wr_u16b(sf_lives);

	/* Number of times saved */
	wr_u16b(sf_saves);


	/* Space */
	wr_u32b(0L);
	wr_u16b(0);
	wr_byte(0);

#ifdef JP
# ifdef EUC
	/* EUC kanji code */
	wr_byte(2);
# endif
# ifdef SJIS
	/* SJIS kanji code */
	wr_byte(3);
# endif
#else
	/* ASCII */
	wr_byte(1);
#endif

	/* Write the RNG state */
	wr_randomizer();


	/* Write the boolean "options" */
	wr_options();


	/* Dump the number of "messages" */
	tmp16u = message_num();
	if (compress_savefile && (tmp16u > 40)) tmp16u = 40;
	wr_u16b(tmp16u);

	/* Dump the messages (oldest first!) */
	for (i = tmp16u - 1; i >= 0; i--)
	{
		wr_string(message_str((s16b)i));
	}


	/* Dump the monster lore */
	tmp16u = max_r_idx;
	wr_u16b(tmp16u);
	for (i = 0; i < tmp16u; i++) wr_lore(i);


	/* Dump the object memory */
	tmp16u = max_k_idx;
	wr_u16b(tmp16u);
	for (i = 0; i < tmp16u; i++) wr_xtra(i);

	/* Dump the towns */
	tmp16u = max_towns;
	wr_u16b(tmp16u);

	/* Dump the quests */
	tmp16u = max_quests;
	wr_u16b(tmp16u);

	/* Dump the quests */
	tmp8u = MAX_RANDOM_QUEST-MIN_RANDOM_QUEST;
	wr_byte(tmp8u);

	for (i = 0; i < max_quests; i++)
	{
		quest_type* const q_ptr = &quest[i];

		/* Save status for every quest */
		wr_s16b(q_ptr->status);

		/* And the dungeon level too */
		/* (prevents problems with multi-level quests) */
		wr_s16b(q_ptr->level);

		wr_byte(q_ptr->complev);
		wr_u32b(q_ptr->comptime);

		/* Save quest status if quest is running */
		if (q_ptr->status == QUEST_STATUS_TAKEN || q_ptr->status == QUEST_STATUS_COMPLETED || !is_fixed_quest_idx(i))
		{
			wr_s16b(q_ptr->cur_num);
			wr_s16b(q_ptr->max_num);
			wr_s16b(q_ptr->type);
			wr_s16b(q_ptr->r_idx);
			wr_s16b(q_ptr->k_idx);
			wr_byte(q_ptr->flags);
			wr_byte(q_ptr->dungeon);
		}
	}

	/* Dump the position in the wilderness */
	wr_s32b(p_ptr->wilderness_x);
	wr_s32b(p_ptr->wilderness_y);

	wr_byte(p_ptr->wild_mode);
	wr_byte(ambush_flag);

	wr_s32b(max_wild_x);
	wr_s32b(max_wild_y);

	/* Dump the wilderness seeds */
	for (i = 0; i < max_wild_x; i++)
	{
		for (j = 0; j < max_wild_y; j++)
		{
			wr_u32b(wilderness[j][i].seed);
		}
	}

	/* Hack -- Dump the artifacts */
	tmp16u = max_a_idx;
	wr_u16b(tmp16u);
	for (i = 0; i < tmp16u; i++)
	{
		artifact_type *a_ptr = &a_info[i];
		wr_byte(a_ptr->cur_num);
		wr_s16b(a_ptr->floor_id);
	}



	/* Write the "extra" information */
	wr_extra();

	/* Dump the "player hp" entries */
	tmp16u = PY_MAX_LEVEL;
	wr_u16b(tmp16u);
	for (i = 0; i < tmp16u; i++)
	{
		wr_s16b(p_ptr->player_hp[i]);
	}


	/* Write spell data */
	wr_u32b(p_ptr->spell_learned1);
	wr_u32b(p_ptr->spell_learned2);
	wr_u32b(p_ptr->spell_worked1);
	wr_u32b(p_ptr->spell_worked2);
	wr_u32b(p_ptr->spell_forgotten1);
	wr_u32b(p_ptr->spell_forgotten2);

	wr_s16b(p_ptr->learned_spells);
	wr_s16b(p_ptr->add_spells);

	/* Dump the ordered spells */
	for (i = 0; i < 64; i++)
	{
		wr_byte(p_ptr->spell_order[i]);
	}


	/* Write the inventory */
	for (i = 0; i < INVEN_TOTAL; i++)
	{
		object_type *o_ptr = &inventory[i];

		/* Skip non-objects */
		if (!o_ptr->k_idx) continue;

		/* Dump index */
		wr_u16b((u16b)i);

		/* Dump object */
		wr_item(o_ptr);
	}

	/* Add a sentinel */
	wr_u16b(0xFFFF);

	/* Note the towns */
	tmp16u = max_towns;
	wr_u16b(tmp16u);

	/* Note the stores */
	tmp16u = MAX_STORES;
	wr_u16b(tmp16u);

	/* Dump the stores of all towns */
	for (i = 1; i < max_towns; i++)
	{
		for (j = 0; j < MAX_STORES; j++)
		{
			wr_store(&town[i].store[j]);
		}
	}

	/* Write the pet command settings */
	wr_s16b(p_ptr->pet_follow_distance);
	wr_s16b(p_ptr->pet_extra_flags);

	/* Write screen dump for sending score */
	if (screen_dump && (p_ptr->wait_report_score || !p_ptr->is_dead))
	{
		wr_string(screen_dump);
	}
	else
	{
		wr_string("");
	}

	/* Player is not dead, write the dungeon */
	if (!p_ptr->is_dead)
	{
		/* Dump the dungeon */
		if (!wr_dungeon()) return FALSE;

		/* Dump the ghost */
		wr_ghost();

		/* No scripts */
		wr_s32b(0);
	}


	/* Write the "value check-sum" */
	wr_u32b(v_stamp);

	/* Write the "encoded checksum" */
	wr_u32b(x_stamp);


	/* Error in save */
	if (ferror(fff) || (fflush(fff) == EOF)) return FALSE;

	/* Successful save */
	return TRUE;
}
Beispiel #18
0
/*
 * Write an "item" record
 */
static void wr_item(const object_type *o_ptr)
{
	size_t i, j;

	wr_u16b(0xffff);
	wr_byte(ITEM_VERSION);

	wr_s16b(0);

	/* Location */
	wr_byte(o_ptr->iy);
	wr_byte(o_ptr->ix);

	wr_byte(o_ptr->tval);
	wr_byte(o_ptr->sval);

        for (i = 0; i < MAX_PVALS; i++) {
		wr_s16b(o_ptr->pval[i]);
        }
        wr_byte(o_ptr->num_pvals);

	wr_byte(0);

	wr_byte(o_ptr->number);
	wr_s16b(o_ptr->weight);

	if (o_ptr->artifact) wr_byte(o_ptr->artifact->aidx);
	else wr_byte(0);

	if (o_ptr->ego) wr_byte(o_ptr->ego->eidx);
	else wr_byte(0);

	wr_s16b(o_ptr->timeout);

	wr_s16b(o_ptr->to_h);
	wr_s16b(o_ptr->to_d);
	wr_s16b(o_ptr->to_a);
	wr_s16b(o_ptr->ac);
	wr_byte(o_ptr->dd);
	wr_byte(o_ptr->ds);

	wr_u16b(o_ptr->ident);

	wr_byte(o_ptr->marked);

	wr_byte(o_ptr->origin);
	wr_byte(o_ptr->origin_depth);
	wr_u16b(o_ptr->origin_xtra);
	wr_byte(o_ptr->ignore);

	for (i = 0; i < OF_SIZE; i++)
		wr_byte(o_ptr->flags[i]);

	for (i = 0; i < OF_SIZE; i++)
		wr_byte(o_ptr->known_flags[i]);

	for (j = 0; j < MAX_PVALS; j++) {
		for (i = 0; i < OF_SIZE; i++)
			wr_byte(o_ptr->pval_flags[j][i]);
	}

	/* Held by monster index */
	wr_s16b(o_ptr->held_m_idx);
	
	wr_s16b(o_ptr->mimicking_m_idx);

	/* Save the inscription (if any) */
	if (o_ptr->note)
	{
		wr_string(quark_str(o_ptr->note));
	}
	else
	{
		wr_string("");
	}
}
Beispiel #19
0
/*
 * Write an "item" record
 */
static void wr_item(const object_type *o_ptr)
{
	int i;
	
	wr_s16b(o_ptr->k_idx);

	wr_s16b(o_ptr->image_k_idx);

	/* Location */
	wr_byte(o_ptr->iy);
	wr_byte(o_ptr->ix);

	wr_byte(o_ptr->tval);
	wr_byte(o_ptr->sval);
	wr_s16b(o_ptr->pval);

	wr_byte(o_ptr->discount);

	wr_byte(o_ptr->number);
	wr_s16b(o_ptr->weight);

	wr_byte(o_ptr->name1);
	wr_byte(o_ptr->name2);

	wr_s16b(o_ptr->timeout);

	wr_s16b(o_ptr->att);
	wr_byte(o_ptr->dd);
	wr_byte(o_ptr->ds);
	wr_s16b(o_ptr->evn);	
	wr_byte(o_ptr->pd);		
	wr_byte(o_ptr->ps);		
	wr_byte(o_ptr->pickup);	

	wr_u32b(o_ptr->ident);

	wr_byte(o_ptr->marked);

	/* Held by monster index */
	wr_s16b(o_ptr->held_m_idx);

	/* Extra information */
	wr_byte(o_ptr->xtra1);

	// granted abilities
	wr_byte(o_ptr->abilities);
	for (i = 0; i < 8; i++)
	{
		wr_byte(o_ptr->skilltype[i]);
		wr_byte(o_ptr->abilitynum[i]);
	}
	
	// 8 spare bytes
	wr_u32b(0L);
	wr_u32b(0L);
		
	/* Save the inscription (if any) */
	if (o_ptr->obj_note)
	{
		wr_string(quark_str(o_ptr->obj_note));
	}
	else
	{
		wr_string("");
	}
}
Beispiel #20
0
/*!
 * @brief その他の情報を書き込む / Write some "extra" info
 * @return なし
 */
static void wr_extra(void)
{
	int i,j;
	byte tmp8u;

	wr_string(player_name);

	wr_string(p_ptr->died_from);

	wr_string(p_ptr->last_message ? p_ptr->last_message : "");

	save_quick_start();

	for (i = 0; i < 4; i++)
	{
		wr_string(p_ptr->history[i]);
	}

	/* Race/Class/Gender/Spells */
	wr_byte(p_ptr->prace);
	wr_byte(p_ptr->pclass);
	wr_byte(p_ptr->pseikaku);
	wr_byte(p_ptr->psex);
	wr_byte(p_ptr->realm1);
	wr_byte(p_ptr->realm2);
	wr_byte(0);	/* oops */

	wr_byte(p_ptr->hitdie);
	wr_u16b(p_ptr->expfact);

	wr_s16b(p_ptr->age);
	wr_s16b(p_ptr->ht);
	wr_s16b(p_ptr->wt);

	/* Dump the stats (maximum and current) */
	for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_max[i]);
	for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_max_max[i]);
	for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_cur[i]);

	/* Ignore the transient stats */
	for (i = 0; i < 12; ++i) wr_s16b(0);

	wr_u32b(p_ptr->au);

	wr_u32b(p_ptr->max_exp);
	wr_u32b(p_ptr->max_max_exp);
	wr_u32b(p_ptr->exp);
	wr_u32b(p_ptr->exp_frac);
	wr_s16b(p_ptr->lev);

	for (i = 0; i < 64; i++) wr_s16b(p_ptr->spell_exp[i]);
	for (i = 0; i < 5; i++) for (j = 0; j < 64; j++) wr_s16b(p_ptr->weapon_exp[i][j]);
	for (i = 0; i < 10; i++) wr_s16b(p_ptr->skill_exp[i]);
	for (i = 0; i < 108; i++) wr_s32b(p_ptr->magic_num1[i]);
	for (i = 0; i < 108; i++) wr_byte(p_ptr->magic_num2[i]);

	wr_byte(p_ptr->start_race);
	wr_s32b(p_ptr->old_race1);
	wr_s32b(p_ptr->old_race2);
	wr_s16b(p_ptr->old_realm);

	for (i = 0; i < MAX_MANE; i++)
	{
		wr_s16b(p_ptr->mane_spell[i]);
		wr_s16b(p_ptr->mane_dam[i]);
	}
	wr_s16b(p_ptr->mane_num);

	for (i = 0; i < MAX_KUBI; i++)
	{
		wr_s16b(kubi_r_idx[i]);
	}

	for (i = 0; i < 4; i++)
	{
		wr_s16b(battle_mon[i]);
		wr_u32b(mon_odds[i]);
	}

	wr_s16b(p_ptr->town_num); /* -KMW- */

	/* Write arena and rewards information -KMW- */
	wr_s16b(p_ptr->arena_number);
	wr_s16b(p_ptr->inside_arena);
	wr_s16b(p_ptr->inside_quest);
	wr_s16b(p_ptr->inside_battle);
	wr_byte(p_ptr->exit_bldg);
	wr_byte(0); /* Unused */

	wr_s16b(p_ptr->oldpx);
	wr_s16b(p_ptr->oldpy);

	/* Was number of p_ptr->rewards[] */
	wr_s16b(0);

	wr_s32b(p_ptr->mhp);
	wr_s32b(p_ptr->chp);
	wr_u32b(p_ptr->chp_frac);

	wr_s32b(p_ptr->msp);
	wr_s32b(p_ptr->csp);
	wr_u32b(p_ptr->csp_frac);

	/* Max Player and Dungeon Levels */
	wr_s16b(p_ptr->max_plv);
	tmp8u = (byte)max_d_idx;
	wr_byte(tmp8u);
	for (i = 0; i < tmp8u; i++)
		wr_s16b(max_dlv[i]);

	/* More info */
	wr_s16b(0);     /* oops */
	wr_s16b(0);     /* oops */
	wr_s16b(0);     /* oops */
	wr_s16b(0);     /* oops */
	wr_s16b(p_ptr->sc);
	wr_s16b(p_ptr->concent);

	wr_s16b(0);             /* old "rest" */
	wr_s16b(p_ptr->blind);
	wr_s16b(p_ptr->paralyzed);
	wr_s16b(p_ptr->confused);
	wr_s16b(p_ptr->food);
	wr_s16b(0);     /* old "food_digested" */
	wr_s16b(0);     /* old "protection" */
	wr_s16b(p_ptr->energy_need);
	wr_s16b(p_ptr->enchant_energy_need);
	wr_s16b(p_ptr->fast);
	wr_s16b(p_ptr->slow);
	wr_s16b(p_ptr->afraid);
	wr_s16b(p_ptr->cut);
	wr_s16b(p_ptr->stun);
	wr_s16b(p_ptr->poisoned);
	wr_s16b(p_ptr->image);
	wr_s16b(p_ptr->protevil);
	wr_s16b(p_ptr->invuln);
	wr_s16b(p_ptr->ult_res);
	wr_s16b(p_ptr->hero);
	wr_s16b(p_ptr->shero);
	wr_s16b(p_ptr->shield);
	wr_s16b(p_ptr->blessed);
	wr_s16b(p_ptr->tim_invis);
	wr_s16b(p_ptr->word_recall);
	wr_s16b(p_ptr->recall_dungeon);
	wr_s16b(p_ptr->alter_reality);
	wr_s16b(p_ptr->see_infra);
	wr_s16b(p_ptr->tim_infra);
	wr_s16b(p_ptr->oppose_fire);
	wr_s16b(p_ptr->oppose_cold);
	wr_s16b(p_ptr->oppose_acid);
	wr_s16b(p_ptr->oppose_elec);
	wr_s16b(p_ptr->oppose_pois);
	wr_s16b(p_ptr->tsuyoshi);
	wr_s16b(p_ptr->tim_esp);
	wr_s16b(p_ptr->wraith_form);
	wr_s16b(p_ptr->resist_magic);
	wr_s16b(p_ptr->tim_regen);
	wr_s16b(p_ptr->kabenuke);
	wr_s16b(p_ptr->tim_stealth);
	wr_s16b(p_ptr->tim_levitation);
	wr_s16b(p_ptr->tim_sh_touki);
	wr_s16b(p_ptr->lightspeed);
	wr_s16b(p_ptr->tsubureru);
	wr_s16b(p_ptr->magicdef);
	wr_s16b(p_ptr->tim_res_nether);
	wr_s16b(p_ptr->tim_res_time);
	wr_byte(p_ptr->mimic_form);
	wr_s16b(p_ptr->tim_mimic);
	wr_s16b(p_ptr->tim_sh_fire);
	wr_s16b(p_ptr->tim_sh_holy);
	wr_s16b(p_ptr->tim_eyeeye);

	/* by henkma */
	wr_s16b(p_ptr->tim_reflect);
	wr_s16b(p_ptr->multishadow);
	wr_s16b(p_ptr->dustrobe);

	wr_s16b(p_ptr->chaos_patron);
	wr_u32b(p_ptr->muta1);
	wr_u32b(p_ptr->muta2);
	wr_u32b(p_ptr->muta3);

	for (i = 0; i<8; i++)
		wr_s16b(p_ptr->virtues[i]);
	for (i = 0; i<8; i++)
		wr_s16b(p_ptr->vir_types[i]);

	wr_s16b(p_ptr->ele_attack);
	wr_u32b(p_ptr->special_attack);
	wr_s16b(p_ptr->ele_immune);
	wr_u32b(p_ptr->special_defense);
	wr_byte(p_ptr->knowledge);
	wr_byte(p_ptr->autopick_autoregister);
	wr_byte(0);     /* oops */
	wr_byte(p_ptr->action);
	wr_byte(0);
	wr_byte(preserve_mode);
	wr_byte(p_ptr->wait_report_score);

	/* Future use */
	for (i = 0; i < 12; i++) wr_u32b(0L);

	/* Ignore some flags */
	wr_u32b(0L);    /* oops */
	wr_u32b(0L);    /* oops */
	wr_u32b(0L);    /* oops */


	/* Write the "object seeds" */
	wr_u32b(seed_flavor);
	wr_u32b(seed_town);


	/* Special stuff */
	wr_u16b(p_ptr->panic_save);
	wr_u16b(p_ptr->total_winner);
	wr_u16b(p_ptr->noscore);


	/* Write death */
	wr_byte(p_ptr->is_dead);

	/* Write feeling */
	wr_byte(p_ptr->feeling);

	/* Turn when level began */
	wr_s32b(old_turn);

	/* Turn of last "feeling" */
	wr_s32b(p_ptr->feeling_turn);

	/* Current turn */
	wr_s32b(turn);

	wr_s32b(dungeon_turn);

	wr_s32b(old_battle);

	wr_s16b(today_mon);
	wr_s16b(p_ptr->today_mon);
	wr_s16b(p_ptr->riding);

	/* Current floor_id */
	wr_s16b(p_ptr->floor_id);

	/* Save temporary preserved pets (obsolated) */
	wr_s16b(0);

	wr_u32b(playtime);

	wr_s32b(p_ptr->visit);

	wr_u32b(p_ptr->count);
}
Beispiel #21
0
static int 
write_header(FILE *file, imageparams *ip)
{
    unsigned char buffer[300];            /* Be careful with the size ! */
    unsigned char *p = buffer;
    int headersize;
    int bounding_x;
    int bounding_y;
    int i;

    /* Calculate the bounding box from the resolutions    */
    bounding_x = ((int) (1200 * ((double) (ip->width) / ip->h_res)));
    bounding_y = ((int) (1200 * ((double) (ip->height) / ip->v_res)));

    /* This is gross. The entire DDIF grammar is constructed by   */
    /* hand. The indentation is meant to indicate DDIF document structure */

    tag(&p,PRIVATE,CONS,16383); ind(&p);      /* DDIF Document */
    tag(&p,CONTEXT,CONS, 0); ind(&p);        /* Document Descriptor */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,1);  /* Major Version */
    tag(&p,CONTEXT,PRIM, 1); wr_int(&p,3);  /* Minor Version */
    tag(&p,CONTEXT,PRIM, 2); wr_string(&p,"PBM+"); /* Product Indentifier */
    tag(&p,CONTEXT,CONS, 3); ind(&p);       /* Product Name */
    tag(&p,PRIVATE,PRIM, 9); emit_isolatin1(&p,"PBMPLUS Writer V1.0");
    eoc(&p);
    eoc(&p);                 /* Document Descriptor */
    tag(&p,CONTEXT,CONS, 1); ind(&p);        /* Document Header     */
    tag(&p,CONTEXT,CONS, 3); ind(&p);       /* Version */
    tag(&p,PRIVATE,PRIM, 9); emit_isolatin1(&p,"1.0");
    eoc(&p);
    eoc(&p);                 /* Document Header */
    tag(&p,CONTEXT,CONS, 2); ind(&p);        /* Document Content    */
    tag(&p,APPLICATION,CONS,2); ind(&p);    /* Segment Primitive    */
    eoc(&p);
    tag(&p,APPLICATION,CONS,2); ind(&p);    /* Segment  */
    tag(&p,CONTEXT,CONS, 3); ind(&p);      /* Segment Specific Attributes */
    tag(&p,CONTEXT,PRIM, 2); wr_string(&p,"$I");  /* Category */
    tag(&p,CONTEXT,CONS,22); ind(&p);     /* Image Attributes */
    tag(&p,CONTEXT,CONS, 0); ind(&p);    /* Image Presentation Attributes */
    tag(&p,CONTEXT,PRIM, 1); wr_int(&p,0);  /* Pixel Path */
    tag(&p,CONTEXT,PRIM, 2); wr_int(&p,270); /* Line Progression */
    tag(&p,CONTEXT,CONS, 3); ind(&p);   /* Pixel Aspect Ratio */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,1); /* PP Pixel Dist */
    tag(&p,CONTEXT,PRIM, 1); wr_int(&p,1); /* LP Pixel Dist */
    eoc(&p);                /* Pixel Aspect Ratio */
    tag(&p,CONTEXT,PRIM, 4); wr_int(&p,ip->polarity);  
        /* Brightness Polarity */
    tag(&p,CONTEXT,PRIM, 5); wr_int(&p,1);  /* Grid Type    */
    tag(&p,CONTEXT,PRIM, 7); wr_int(&p,ip->spectral);  /* Spectral Mapping */
    tag(&p,CONTEXT,CONS,10); ind(&p);   /* Pixel Group Info */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,1); /* Pixel Group Size */
    tag(&p,CONTEXT,PRIM, 1); wr_int(&p,1); /* Pixel Group Order */
    eoc(&p);                /* Pixel Group Info */
    eoc(&p);                     /* Image Presentation Attributes */
    tag(&p,CONTEXT,CONS, 1); ind(&p);    /* Component Space Attributes */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,1);  /* Component Space Organization */
    tag(&p,CONTEXT,PRIM, 1); wr_int(&p,1);  /* Planes per Pixel */
    tag(&p,CONTEXT,PRIM, 2); wr_int(&p,1);  /* Plane Significance   */
    tag(&p,CONTEXT,PRIM, 3); wr_int(&p,ip->components);  
        /* Number of Components    */
    tag(&p,CONTEXT,CONS, 4); ind(&p);   /* Bits per Component   */
    for (i = 0; i < ip->components; i++) {
        tag(&p,UNIVERSAL,PRIM,2); wr_int(&p,ip->bits_per_component);
    }
    eoc(&p);                /* Bits per Component   */
    tag(&p,CONTEXT,CONS, 5); ind(&p);   /* Component Quantization Levels */
    for (i = 0; i < ip->components; i++) {
        tag(&p,UNIVERSAL,PRIM,2); wr_int(&p,1 << ip->bits_per_component);
    }
    eoc(&p);                /* Component Quantization Levels */
    eoc(&p);                 /* Component Space Attributes */
    eoc(&p);                  /* Image Attributes */
    tag(&p,CONTEXT,CONS,23); ind(&p);     /* Frame Parameters */
    tag(&p,CONTEXT,CONS, 1); ind(&p);    /* Bounding Box */
    tag(&p,CONTEXT,CONS, 0); ind(&p);   /* lower-left   */
    tag(&p,CONTEXT,CONS, 0); ind(&p);  /* XCoordinate  */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,0);
    eoc(&p);                           /* XCoordinate  */
    tag(&p,CONTEXT,CONS, 1); ind(&p);  /* YCoordinate  */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,0);
    eoc(&p);                               /* YCoordinate  */
    eoc(&p);                /* lower left */
    tag(&p,CONTEXT,CONS, 1); ind(&p);       /* upper right */
    tag(&p,CONTEXT,CONS, 0); ind(&p);      /* XCoordinate  */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,bounding_x);
    eoc(&p);               /* XCoordinate  */
    tag(&p,CONTEXT,CONS, 1); ind(&p);      /* YCoordinate  */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,bounding_y);
    eoc(&p);                   /* YCoordinate  */
    eoc(&p);                            /* upper right */
    eoc(&p);                 /* Bounding Box */
    tag(&p,CONTEXT,CONS, 4); ind(&p);    /* Frame Position */
    tag(&p,CONTEXT,CONS, 0); ind(&p);   /* XCoordinate  */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,0);
    eoc(&p);                /* XCoordinate  */
    tag(&p,CONTEXT,CONS, 1); ind(&p);   /* YCoordinate  */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,0);
    eoc(&p);                    /* YCoordinate  */
    eoc(&p);                 /* Frame Position */
    eoc(&p);                  /* Frame Parameters */
    eoc(&p);                        /* Segment Specific Attributes */
    eoc(&p);                    /* Segment */
    tag(&p,APPLICATION,CONS,17); ind(&p);   /* Image Data Descriptor */
    tag(&p,UNIVERSAL,CONS,16); ind(&p);    /* Sequence */
    tag(&p,CONTEXT,CONS, 0); ind(&p);     /* Image Coding Attributes */
    tag(&p,CONTEXT,PRIM, 1); wr_int(&p,ip->width); /* Pixels per Line    */
    tag(&p,CONTEXT,PRIM, 2); wr_int(&p,ip->height);  /* Number of Lines  */
    tag(&p,CONTEXT,PRIM, 3); wr_int(&p,2);   /* Compression Type */
    tag(&p,CONTEXT,PRIM, 5); wr_int(&p,0);   /* Data Offset  */
    tag(&p,CONTEXT,PRIM, 6); wr_int(&p,ip->bits_per_pixel);  /* Pixel Stride */
    tag(&p,CONTEXT,PRIM, 7); wr_int(&p,ip->bytes_per_line * 8);
        /* Scanline Stride    */
    tag(&p,CONTEXT,PRIM, 8); wr_int(&p,1);   /* Bit Order        */
    tag(&p,CONTEXT,PRIM, 9); wr_int(&p,ip->bits_per_pixel);  
        /* Planebits per Pixel */
    tag(&p,CONTEXT,CONS,10); ind(&p);    /* Byteorder Info   */
    tag(&p,CONTEXT,PRIM, 0); wr_int(&p,1);  /* Byte Unit        */
    tag(&p,CONTEXT,PRIM, 1); wr_int(&p,1);  /* Byte Order   */
    eoc(&p);                 /* Byteorder Info   */
    tag(&p,CONTEXT,PRIM,11); wr_int(&p,3);   /* Data Type        */
    eoc(&p);                              /* Image Coding Attributes */
    tag(&p,CONTEXT,PRIM, 1); wr_length(&p,ip->bytes_per_line*ip->height);  
        /* Component Plane Data */
    /* End of DDIF document Indentation */
    headersize = p - buffer;
    if (headersize >= 300)  {
        fprintf(stderr,"Overran buffer area %d >= 300\n",headersize);
        exit(1);
    }

    return (fwrite(buffer, 1, headersize, file) == headersize);
}
Beispiel #22
0
/*!
 * @brief モンスター情報を書き込む / Write a "monster" record
 * @param m_ptr モンスター情報保存元ポインタ
 * @return なし
 */
static void wr_monster(monster_type *m_ptr)
{
	u32b flags = 0x00000000;
	byte tmp8u;

	if (!is_original_ap(m_ptr)) flags |= SAVE_MON_AP_R_IDX;
	if (m_ptr->sub_align) flags |= SAVE_MON_SUB_ALIGN;
	if (MON_CSLEEP(m_ptr)) flags |= SAVE_MON_CSLEEP;
	if (MON_FAST(m_ptr)) flags |= SAVE_MON_FAST;
	if (MON_SLOW(m_ptr)) flags |= SAVE_MON_SLOW;
	if (MON_STUNNED(m_ptr)) flags |= SAVE_MON_STUNNED;
	if (MON_CONFUSED(m_ptr)) flags |= SAVE_MON_CONFUSED;
	if (MON_MONFEAR(m_ptr)) flags |= SAVE_MON_MONFEAR;
	if (m_ptr->target_y) flags |= SAVE_MON_TARGET_Y;
	if (m_ptr->target_x) flags |= SAVE_MON_TARGET_X;
	if (MON_INVULNER(m_ptr)) flags |= SAVE_MON_INVULNER;
	if (m_ptr->smart) flags |= SAVE_MON_SMART;
	if (m_ptr->exp) flags |= SAVE_MON_EXP;
	if (m_ptr->mflag2) flags |= SAVE_MON_MFLAG2;
	if (m_ptr->nickname) flags |= SAVE_MON_NICKNAME;
	if (m_ptr->parent_m_idx) flags |= SAVE_MON_PARENT;

	/*** Monster save flags ***/
	wr_u32b(flags);

	/*** Write only un-obvious elements ***/
	wr_s16b(m_ptr->r_idx);
	wr_byte(m_ptr->fy);
	wr_byte(m_ptr->fx);
	wr_s16b(m_ptr->hp);
	wr_s16b(m_ptr->maxhp);
	wr_s16b(m_ptr->max_maxhp);
	wr_u32b(m_ptr->dealt_damage);
	

	/* Monster race index of its appearance */
	if (flags & SAVE_MON_AP_R_IDX) wr_s16b(m_ptr->ap_r_idx);

	if (flags & SAVE_MON_SUB_ALIGN) wr_byte(m_ptr->sub_align);
	if (flags & SAVE_MON_CSLEEP) wr_s16b(m_ptr->mtimed[MTIMED_CSLEEP]);

	wr_byte(m_ptr->mspeed);
	wr_s16b(m_ptr->energy_need);

	if (flags & SAVE_MON_FAST)
	{
		tmp8u = (byte)m_ptr->mtimed[MTIMED_FAST];
		wr_byte(tmp8u);
	}
	if (flags & SAVE_MON_SLOW)
	{
		tmp8u = (byte)m_ptr->mtimed[MTIMED_SLOW];
		wr_byte(tmp8u);
	}
	if (flags & SAVE_MON_STUNNED)
	{
		tmp8u = (byte)m_ptr->mtimed[MTIMED_STUNNED];
		wr_byte(tmp8u);
	}
	if (flags & SAVE_MON_CONFUSED)
	{
		tmp8u = (byte)m_ptr->mtimed[MTIMED_CONFUSED];
		wr_byte(tmp8u);
	}
	if (flags & SAVE_MON_MONFEAR)
	{
		tmp8u = (byte)m_ptr->mtimed[MTIMED_MONFEAR];
		wr_byte(tmp8u);
	}
	if (flags & SAVE_MON_TARGET_Y) wr_s16b(m_ptr->target_y);
	if (flags & SAVE_MON_TARGET_X) wr_s16b(m_ptr->target_x);
	if (flags & SAVE_MON_INVULNER)
	{
		tmp8u = (byte)m_ptr->mtimed[MTIMED_INVULNER];
		wr_byte(tmp8u);
	}
	if (flags & SAVE_MON_SMART) wr_u32b(m_ptr->smart);
	if (flags & SAVE_MON_EXP) wr_u32b(m_ptr->exp);
	if (flags & SAVE_MON_MFLAG2) wr_byte(m_ptr->mflag2);
	if (flags & SAVE_MON_NICKNAME) wr_string(quark_str(m_ptr->nickname));
	if (flags & SAVE_MON_PARENT) wr_s16b(m_ptr->parent_m_idx);
}
Beispiel #23
0
void wr_player(void)
{
	int i;

	wr_string(op_ptr->full_name);

	wr_string(p_ptr->died_from);

	wr_string(p_ptr->history);

	/* Race/Class/Gender/Spells */
	wr_byte(p_ptr->race->ridx);
	wr_byte(p_ptr->class->cidx);
	wr_byte(p_ptr->psex);
	wr_byte(op_ptr->name_suffix);

	wr_byte(p_ptr->hitdie);
	wr_byte(p_ptr->expfact);

	wr_s16b(p_ptr->age);
	wr_s16b(p_ptr->ht);
	wr_s16b(p_ptr->wt);

	/* Dump the stats (maximum and current and birth) */
	wr_byte(A_MAX);
	for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_max[i]);
	for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_cur[i]);
	for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_birth[i]);

	wr_s16b(p_ptr->ht_birth);
	wr_s16b(p_ptr->wt_birth);
	wr_s16b(0);
	wr_u32b(p_ptr->au_birth);

	/* Padding */
	wr_u32b(0);

	wr_u32b(p_ptr->au);


	wr_u32b(p_ptr->max_exp);
	wr_u32b(p_ptr->exp);
	wr_u16b(p_ptr->exp_frac);
	wr_s16b(p_ptr->lev);

	wr_s16b(p_ptr->mhp);
	wr_s16b(p_ptr->chp);
	wr_u16b(p_ptr->chp_frac);

	wr_s16b(p_ptr->msp);
	wr_s16b(p_ptr->csp);
	wr_u16b(p_ptr->csp_frac);

	/* Max Player and Dungeon Levels */
	wr_s16b(p_ptr->max_lev);
	wr_s16b(p_ptr->max_depth);

	/* More info */
	wr_s16b(0);	/* oops */
	wr_s16b(0);	/* oops */
	wr_s16b(0);	/* oops */
	wr_s16b(0);	/* oops */
	wr_byte(0);
	wr_byte(p_ptr->unignoring);
	wr_s16b(p_ptr->deep_descent);

	wr_s16b(p_ptr->food);
	wr_s16b(p_ptr->energy);
	wr_s16b(p_ptr->word_recall);
	wr_s16b(p_ptr->state.see_infra);
	wr_byte(p_ptr->confusing);
	wr_byte(p_ptr->searching);

	/* Find the number of timed effects */
	wr_byte(TMD_MAX);

	/* Read all the effects, in a loop */
	for (i = 0; i < TMD_MAX; i++)
		wr_s16b(p_ptr->timed[i]);

	/* Total energy used so far */
	wr_u32b(p_ptr->total_energy);
	/* # of turns spent resting */
	wr_u32b(p_ptr->resting_turn);

	/* Future use */
	for (i = 0; i < 8; i++) wr_u32b(0L);
}
Beispiel #24
0
void wr_artifacts(void)
{
	size_t i;
	u16b tmp16u;

	/* Record the total number of artifacts. */
	tmp16u = z_info->a_max;
	wr_u16b(tmp16u);

	/* Record the first random artifact index. */
	tmp16u = ART_MIN_RANDOM;
	wr_u16b(tmp16u);


	/* Write the artifact info. */
	for (i = 0; i < ART_MIN_RANDOM; i++) {
		artifact_type *a_ptr = &a_info[i];

		wr_byte(a_ptr->created);
		wr_byte(a_ptr->seen);
		/* Store set completion info */
		wr_byte(a_ptr->set_bonus ? 1 : 0);

		/* Expansion */
		wr_u32b(0);
	}

	/* Random artifacts are specific to each player. */
	for (i = ART_MIN_RANDOM; i < z_info->a_max; i++) {
		artifact_type *a_ptr = &a_info[i];
		size_t j;

		wr_string(format("%s", a_ptr->name));

		wr_byte(a_ptr->tval);
		wr_byte(a_ptr->sval);
		wr_u16b(a_ptr->pval);

		wr_u16b(a_ptr->to_h);
		wr_u16b(a_ptr->to_d);
		wr_u16b(a_ptr->to_a);

		wr_byte(a_ptr->dd);
		wr_byte(a_ptr->ds);

		wr_u16b(a_ptr->ac);
		wr_u16b(a_ptr->weight);

		wr_u32b(a_ptr->cost);

		for (j = 0; j < OF_SIZE; j++)
			wr_byte(a_ptr->flags_obj[j]);
		for (j = 0; j < CF_SIZE; j++)
			wr_byte(a_ptr->flags_curse[j]);

		wr_byte(a_ptr->level);
		wr_byte(a_ptr->rarity);

		wr_byte(a_ptr->created);
		wr_byte(a_ptr->seen);
		wr_byte(a_ptr->effect);
		wr_u16b(a_ptr->time.base);
		wr_u16b(a_ptr->time.dice);
		wr_u16b(a_ptr->time.sides);
		wr_u16b(a_ptr->charge.base);
		wr_u16b(a_ptr->charge.dice);
		wr_u16b(a_ptr->charge.sides);

		/* Resists, bonuses, multiples -NRM- */
		for (j = 0; j < MAX_P_RES; j++)
			wr_byte(a_ptr->percent_res[j]);
		for (j = 0; j < A_MAX; j++)
			wr_byte(a_ptr->bonus_stat[j]);
		for (j = 0; j < MAX_P_BONUS; j++)
			wr_byte(a_ptr->bonus_other[j]);
		for (j = 0; j < MAX_P_SLAY; j++)
			wr_byte(a_ptr->multiple_slay[j]);
		for (j = 0; j < MAX_P_BRAND; j++)
			wr_byte(a_ptr->multiple_brand[j]);

		/* Add some filler space for later expansion. */
		wr_u32b(0);
	}
}
Beispiel #25
0
/**
 * Write an "item" record
 */
static void wr_item(object_type * o_ptr)
{
	size_t i;

	wr_s16b(o_ptr->k_idx);

	/* Location */
	wr_byte(o_ptr->iy);
	wr_byte(o_ptr->ix);

	wr_byte(o_ptr->tval);
	wr_byte(o_ptr->sval);
	wr_s16b(o_ptr->pval);

	wr_byte(o_ptr->discount);
	wr_byte(o_ptr->number);
	wr_s16b(o_ptr->weight);

	wr_byte(o_ptr->name1);
	wr_byte(o_ptr->name2);
	wr_s16b(o_ptr->timeout);

	wr_s16b(o_ptr->to_h);
	wr_s16b(o_ptr->to_d);
	wr_s16b(o_ptr->to_a);
	wr_s16b(o_ptr->ac);
	wr_byte(o_ptr->dd);
	wr_byte(o_ptr->ds);

	wr_byte(o_ptr->ident);

	wr_byte(o_ptr->marked);

	wr_byte(o_ptr->origin);
	wr_byte(o_ptr->origin_stage);
	wr_u16b(o_ptr->origin_xtra);

	/* Flags */
	for (i = 0; i < OF_SIZE; i++)
		wr_byte(o_ptr->flags_obj[i]);
	for (i = 0; i < CF_SIZE; i++)
		wr_byte(o_ptr->flags_curse[i]);
	for (i = 0; i < CF_SIZE; i++)
		wr_byte(o_ptr->id_curse[i]);
	for (i = 0; i < OF_SIZE; i++)
		wr_byte(o_ptr->id_obj[i]);
	for (i = 0; i < IF_SIZE; i++)
		wr_byte(o_ptr->id_other[i]);

	/* Resists, bonuses, multiples -NRM- */
	for (i = 0; i < MAX_P_RES; i++)
		wr_byte(o_ptr->percent_res[i]);
	for (i = 0; i < A_MAX; i++)
		wr_byte(o_ptr->bonus_stat[i]);
	for (i = 0; i < MAX_P_BONUS; i++)
		wr_byte(o_ptr->bonus_other[i]);
	for (i = 0; i < MAX_P_SLAY; i++)
		wr_byte(o_ptr->multiple_slay[i]);
	for (i = 0; i < MAX_P_BRAND; i++)
		wr_byte(o_ptr->multiple_brand[i]);

	/* Held by monster index */
	wr_s16b(o_ptr->held_m_idx);

	/* Activation */
	wr_u16b(o_ptr->effect);
	wr_u16b(o_ptr->time.base);
	wr_u16b(o_ptr->time.dice);
	wr_u16b(o_ptr->time.sides);

	/* Feeling */
	wr_byte(o_ptr->feel);

	/* Save the inscription (if any) */
	if (o_ptr->note) {
		wr_string(quark_str(o_ptr->note));
	} else {
		wr_string("");
	}

	/* Expansion */
	wr_u32b(0);
}
Beispiel #26
0
/**
 * Write the "options"
 */
void wr_options(void)
{
	int i, k;

	u32b flag[8];
	u32b mask[8];


	/*** Timed Autosave (inspired by Zangband) ***/
	wr_byte(autosave);
	wr_s16b(autosave_freq);


	/*** Special Options ***/

	/* Write "delay_factor" */
	wr_byte((byte) op_ptr->delay_factor);

	/* Write "hitpoint_warn" */
	wr_byte((byte) op_ptr->hitpoint_warn);

	/* Write "panel_change" */
	wr_byte((byte) op_ptr->panel_change);

	/* Write lazymove delay */
	wr_u16b(lazymove_delay);


	/*** Normal options ***/

	for (i = 0; i < OPT_MAX; i++) {
		const char *name = option_name(i);
		if (!name)
			continue;

		wr_string(name);
		wr_byte(op_ptr->opt[i]);
	}

	/* Sentinel */
	wr_byte(0);

	/*** Window options ***/

	/* Reset */
	for (i = 0; i < 8; i++) {
		/* Flags */
		flag[i] = op_ptr->window_flag[i];

		/* Mask */
		mask[i] = 0L;

		/* Build the mask */
		for (k = 0; k < 32; k++) {
			/* Set mask */
			if (window_flag_desc[k]) {
				mask[i] |= (1L << k);
			}
		}
	}

	/* Dump the flags */
	for (i = 0; i < 8; i++)
		wr_u32b(flag[i]);

	/* Dump the masks */
	for (i = 0; i < 8; i++)
		wr_u32b(mask[i]);
}
Beispiel #27
0
/*!
 * @brief アイテムオブジェクトを書き込む / Write an "item" record
 * @param o_ptr アイテムオブジェクト保存元ポインタ
 * @return なし
 */
static void wr_item(object_type *o_ptr)
{
	u32b flags = 0x00000000;

	if (o_ptr->pval) flags |= SAVE_ITEM_PVAL;
	if (o_ptr->discount) flags |= SAVE_ITEM_DISCOUNT;
	if (o_ptr->number != 1) flags |= SAVE_ITEM_NUMBER;
	if (o_ptr->name1) flags |= SAVE_ITEM_NAME1;
	if (o_ptr->name2) flags |= SAVE_ITEM_NAME2;
	if (o_ptr->timeout) flags |= SAVE_ITEM_TIMEOUT;
	if (o_ptr->to_h) flags |= SAVE_ITEM_TO_H;
	if (o_ptr->to_d) flags |= SAVE_ITEM_TO_D;
	if (o_ptr->to_a) flags |= SAVE_ITEM_TO_A;
	if (o_ptr->ac) flags |= SAVE_ITEM_AC;
	if (o_ptr->dd) flags |= SAVE_ITEM_DD;
	if (o_ptr->ds) flags |= SAVE_ITEM_DS;
	if (o_ptr->ident) flags |= SAVE_ITEM_IDENT;
	if (o_ptr->marked) flags |= SAVE_ITEM_MARKED;
	if (o_ptr->art_flags[0]) flags |= SAVE_ITEM_ART_FLAGS0;
	if (o_ptr->art_flags[1]) flags |= SAVE_ITEM_ART_FLAGS1;
	if (o_ptr->art_flags[2]) flags |= SAVE_ITEM_ART_FLAGS2;
	if (o_ptr->art_flags[3]) flags |= SAVE_ITEM_ART_FLAGS3;
	if (o_ptr->art_flags[4]) flags |= SAVE_ITEM_ART_FLAGS4;
	if (o_ptr->curse_flags) flags |= SAVE_ITEM_CURSE_FLAGS;
	if (o_ptr->held_m_idx) flags |= SAVE_ITEM_HELD_M_IDX;
	if (o_ptr->xtra1) flags |= SAVE_ITEM_XTRA1;
	if (o_ptr->xtra2) flags |= SAVE_ITEM_XTRA2;
	if (o_ptr->xtra3) flags |= SAVE_ITEM_XTRA3;
	if (o_ptr->xtra4) flags |= SAVE_ITEM_XTRA4;
	if (o_ptr->xtra5) flags |= SAVE_ITEM_XTRA5;
	if (o_ptr->feeling) flags |= SAVE_ITEM_FEELING;
	if (o_ptr->inscription) flags |= SAVE_ITEM_INSCRIPTION;
	if (o_ptr->art_name) flags |= SAVE_ITEM_ART_NAME;

	/*** Item save flags ***/
	wr_u32b(flags);

	/*** Write only un-obvious elements ***/
	wr_s16b(o_ptr->k_idx);

	/* Location */
	wr_byte(o_ptr->iy);
	wr_byte(o_ptr->ix);

	if (flags & SAVE_ITEM_PVAL) wr_s16b(o_ptr->pval);

	if (flags & SAVE_ITEM_DISCOUNT) wr_byte(o_ptr->discount);
	if (flags & SAVE_ITEM_NUMBER) wr_byte(o_ptr->number);

	wr_s16b(o_ptr->weight);

	if (flags & SAVE_ITEM_NAME1) wr_byte(o_ptr->name1);
	if (flags & SAVE_ITEM_NAME2) wr_byte(o_ptr->name2);
	if (flags & SAVE_ITEM_TIMEOUT) wr_s16b(o_ptr->timeout);

	if (flags & SAVE_ITEM_TO_H) wr_s16b(o_ptr->to_h);
	if (flags & SAVE_ITEM_TO_D) wr_s16b(o_ptr->to_d);
	if (flags & SAVE_ITEM_TO_A) wr_s16b(o_ptr->to_a);
	if (flags & SAVE_ITEM_AC) wr_s16b(o_ptr->ac);
	if (flags & SAVE_ITEM_DD) wr_byte(o_ptr->dd);
	if (flags & SAVE_ITEM_DS) wr_byte(o_ptr->ds);

	if (flags & SAVE_ITEM_IDENT) wr_byte(o_ptr->ident);

	if (flags & SAVE_ITEM_MARKED) wr_byte(o_ptr->marked);

	if (flags & SAVE_ITEM_ART_FLAGS0) wr_u32b(o_ptr->art_flags[0]);
	if (flags & SAVE_ITEM_ART_FLAGS1) wr_u32b(o_ptr->art_flags[1]);
	if (flags & SAVE_ITEM_ART_FLAGS2) wr_u32b(o_ptr->art_flags[2]);
	if (flags & SAVE_ITEM_ART_FLAGS3) wr_u32b(o_ptr->art_flags[3]);
	if (flags & SAVE_ITEM_ART_FLAGS4) wr_u32b(o_ptr->art_flags[4]);

	if (flags & SAVE_ITEM_CURSE_FLAGS) wr_u32b(o_ptr->curse_flags);

	/* Held by monster index */
	if (flags & SAVE_ITEM_HELD_M_IDX) wr_s16b(o_ptr->held_m_idx);

	/* Extra information */
	if (flags & SAVE_ITEM_XTRA1) wr_byte(o_ptr->xtra1);
	if (flags & SAVE_ITEM_XTRA2) wr_byte(o_ptr->xtra2);
	if (flags & SAVE_ITEM_XTRA3) wr_byte(o_ptr->xtra3);
	if (flags & SAVE_ITEM_XTRA4) wr_s16b(o_ptr->xtra4);
	if (flags & SAVE_ITEM_XTRA5) wr_s16b(o_ptr->xtra5);

	/* Feelings */
	if (flags & SAVE_ITEM_FEELING) wr_byte(o_ptr->feeling);

	if (flags & SAVE_ITEM_INSCRIPTION) wr_string(quark_str(o_ptr->inscription));
	if (flags & SAVE_ITEM_ART_NAME) wr_string(quark_str(o_ptr->art_name));
}
Beispiel #28
0
/*
 * This procedure stores the current state of the lists (lwps, processes,
 * users and project) into the file defined by 'file'.
 * param file - the file name to be used
 * return 0, or -1 on error and store the error message in
 *		the global buffer 'errmsg'.
 */
int
list_store(char *file)
{
	int	storefd;
	time_t  tv;
	char 	*tstr;
	int 	ret = -1;

	if ((storefd = open(file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR))
			== -1) {
		format_err("can't open list db: %s\n", file);
		(void) fprintf(stderr, errmsg);
		return (-1);
	}
	log_msg("writing persistence file: %s\n", file);

	/*
	 * the next do {..} while (false); statement is a replacement
	 * of goto;
	 */
	do {
		if (open_prot(storefd, "w") == -1) {
			format_err("can't open list db: %s\n", file);
			(void) fprintf(stderr, errmsg);
			break;
		}
		(void) time(&tv);
		tstr = ctime(&tv);
		if (wr_string("# RDS data base file generated on: ") == -1)
			break;
		if (wr_string(tstr) == -1)
			break;
		if (wr_value(LTDB_VERSION_KEY, LTDB_VERSION) == -1)
			break;
		if (wr_value(LTDB_TIMESTAMP, tv) == -1)
			break;
		/* we will write 4 lists */
		if (wr_lshead(4) != 0) {
			format_err("can't write into list db: %s\n",
					"./listdb");
			break;
		}
		if (list_write(L_LWP, 0) == -1)
			break;
		if (list_write(L_PRC_SI, 0) == -1)
			break;
		if (list_write(L_USR_SI, 0) == -1)
			break;
		if (list_write(L_PRJ_SI, 0) == -1)
			break;
		ret = 0;
	} while (ret);

	if (ret == 0) {
		struct stat stat_buf;
		(void) fstat(storefd, &stat_buf);
		log_msg("wrote: %ld bytes\n", stat_buf.st_size);
	}

	/* close_prot(); */
	(void) close(storefd);

	return (ret);
}
Beispiel #29
0
/*
 * Actually write a save-file
 */
static bool wr_savefile(void)
{
	int i;

	u32b now;

	u16b tmp16u;


	/* Guess at the current time */
	now = time((time_t *)0);


	/* Note the operating system */
	sf_xtra = 0L;

	/* Note when the file was saved */
	sf_when = now;

	/* Note the number of saves */
	sf_saves++;


	/*** Actually write the file ***/

	/* Dump the file header */
	xor_byte = 0;
	wr_byte(VERSION_MAJOR);
	xor_byte = 0;
	wr_byte(VERSION_MINOR);
	xor_byte = 0;
	wr_byte(VERSION_PATCH);
	xor_byte = 0;
	wr_byte(VERSION_EXTRA);


	/* Reset the checksum */
	v_stamp = 0L;
	x_stamp = 0L;


	/* Operating system */
	wr_u32b(sf_xtra);

	/* Time file last saved */
	wr_u32b(sf_when);

	/* Number of past lives */
	wr_u16b(sf_lives);

	/* Number of times saved */
	wr_u16b(sf_saves);

	// 8 spare bytes
	wr_u32b(0L);
	wr_u32b(0L);

	/* Write the RNG state */
	wr_randomizer();

	/* Write the boolean "options" */
	wr_options();

	/* Dump the number of "messages" */
	tmp16u = message_num();
	wr_u16b(tmp16u);

	/* Dump the messages (oldest first!) */
	for (i = tmp16u - 1; i >= 0; i--)
	{
		wr_string(message_str((s16b)i));
		wr_u16b(message_type((s16b)i));
	}


	/* Dump the monster lore */
	tmp16u = z_info->r_max;
	wr_u16b(tmp16u);
	for (i = 0; i < tmp16u; i++) wr_lore(i);

	/* Dump the object memory */
	tmp16u = z_info->k_max;
	wr_u16b(tmp16u);
	for (i = 0; i < tmp16u; i++) wr_xtra(i);

	/* Hack -- Dump the artefacts */
	tmp16u = z_info->art_max;
	wr_u16b(tmp16u);
	for (i = 0; i < tmp16u; i++)
	{
		artefact_type *a_ptr = &a_info[i];
		wr_byte(a_ptr->cur_num);
		wr_byte(a_ptr->found_num);
	}

	/* Write the "extra" information */
	wr_extra();

	/*Write the randarts*/
	wr_randarts();

	/*Copy the notes file into the savefile*/
	wr_notes();

	// Write the smithing item
	wr_item(smith_o_ptr);
	
	/* Write the inventory */
	for (i = 0; i < INVEN_TOTAL; i++)
	{
		object_type *o_ptr = &inventory[i];

		/* Skip non-objects */
		if (!o_ptr->k_idx) continue;

		/* Dump index */
		wr_u16b((u16b)i);

		/* Dump object */
		wr_item(o_ptr);
	}

	/* Add a sentinel */
	wr_u16b(0xFFFF);

	/* Player is not dead, write the dungeon */
	if (!p_ptr->is_dead)
	{
		/* Dump the dungeon */
		wr_dungeon();
	}


	/* Write the "value check-sum" */
	wr_u32b(v_stamp);

	/* Write the "encoded checksum" */
	wr_u32b(x_stamp);


	/* Error in save */
	if (ferror(fff) || (fflush(fff) == EOF)) return FALSE;

	/* Successful save */
	return TRUE;
}