Exemplo n.º 1
0
static char *
incomplete_string(int n)
{
  struct entity_subloc *p;
  struct entity_build *b;

  p = rp_subloc(n);
  if (p == NULL)
    return "";

  b = get_build(n, BT_BUILD);

  if (b == NULL || b->effort_required == 0)
    return "";

  return sout(", %d%% completed", b->effort_given * 100 / b->effort_required);
}
Exemplo n.º 2
0
//------- Begin of function FirmRes::load_firm_info -------//
//
// Read in information of FIRM.DBF into memory array
//
void FirmRes::load_firm_info()
{
	FirmRec  	 *firmRec;
	FirmInfo 	 *firmInfo;
	FirmBuild	 *firmBuild;
	int      	 i;

	//---- read in firm count and initialize firm info array ----//

	Database *dbFirm;

	if (config.building_size == 1)
		dbFirm = game_set.open_db(FIRM_DB);	// only one database can be opened at a time, so we read FIRM.DBF first
	else
		dbFirm = game_set.open_db(FIRM_SMALL_DB);

	firm_count      = (short) dbFirm->rec_count();
	firm_info_array = (FirmInfo*) mem_add( sizeof(FirmInfo)*firm_count );

	memset( firm_info_array, 0, sizeof(FirmInfo) * firm_count );

	//---------- read in FIRM.DBF ---------//

	for( i=0 ; i<firm_count ; i++ )
	{
		firmRec  = (FirmRec*) dbFirm->read(i+1);
		firmInfo = firm_info_array+i;

		misc.rtrim_fld( firmInfo->name, firmRec->name, firmRec->NAME_LEN );
		misc.rtrim_fld( firmInfo->short_name, firmRec->short_name, firmRec->SHORT_NAME_LEN );

		misc.rtrim_fld( firmInfo->overseer_title, firmRec->overseer_title, firmRec->TITLE_LEN );
		misc.rtrim_fld( firmInfo->worker_title  , firmRec->worker_title  , firmRec->TITLE_LEN );
		translate.multi_to_win(firmInfo->name, firmInfo->NAME_LEN);
		translate.multi_to_win(firmInfo->short_name, firmInfo->SHORT_NAME_LEN);
		translate.multi_to_win(firmInfo->overseer_title, firmInfo->TITLE_LEN);
		translate.multi_to_win(firmInfo->worker_title, firmInfo->TITLE_LEN);

		firmInfo->firm_id     	 	  = i+1;
		firmInfo->tera_type   	 	  = firmRec->tera_type-'0';

		firmInfo->max_hit_points 	  = misc.atoi( firmRec->hit_points, firmRec->HIT_POINTS_LEN );

		firmInfo->first_build_id = misc.atoi( firmRec->first_build, firmRec->FIRST_BUILD_LEN );
		firmInfo->build_count	 = misc.atoi( firmRec->build_count, firmRec->BUILD_COUNT_LEN );

		firmInfo->first_group_id = misc.atoi( firmRec->first_group, firmRec->FIRST_GROUP_LEN );
		firmInfo->group_count	 = misc.atoi( firmRec->group_count, firmRec->GROUP_COUNT_LEN );

		firmInfo->need_overseer  = firmInfo->overseer_title[0] && firmInfo->overseer_title[0] != ' ';
		firmInfo->need_worker  	 = firmInfo->worker_title[0]   && firmInfo->worker_title[0]   != ' ';

//		if( firmInfo->firm_id == FIRM_LAIR )			// BUGHERE
//		{
//			firmInfo->need_overseer = 1;
//			firmInfo->need_worker  	= 1;
//		}

		firmInfo->setup_cost		 = misc.atoi( firmRec->setup_cost, firmRec->COST_LEN );
		firmInfo->year_cost		 = misc.atoi( firmRec->year_cost, firmRec->COST_LEN );
		firmInfo->setup_live_points_cost = misc.atoi( firmRec->setup_live_points_cost, firmRec->COST_LEN );
		firmInfo->year_live		 = misc.atoi( firmRec->year_live, firmRec->COST_LEN );

		firmInfo->is_linkable_to_town = firmRec->is_linkable_to_town=='1';
		
		firmInfo->live_in_town = firmRec->live_in_town=='1';

		firmInfo->is_military	 = firmRec->is_military == 'Y';

		firmInfo->buildable		 = firmInfo->setup_cost > 0;

		if( firmRec->all_know=='1' )
			memset( firmInfo->nation_tech_level_array, 1, sizeof(firmInfo->nation_tech_level_array) );
//		memset( firmInfo->nation_tech_level_array, 1, sizeof(firmInfo->nation_tech_level_array) );

		//------- set loc_width & loc_height in FirmInfo --------//

		firmBuild = firm_build_array+firmInfo->first_build_id-1;

		firmInfo->loc_width  = firmBuild->loc_width;
		firmInfo->loc_height = firmBuild->loc_height;

		// ------if FirmBuild::name is empty, take the name from firmInfo -----//

		if( firmInfo->first_build_id && firmInfo->build_count > 0 )
		{
			for( int j = firmInfo->first_build_id; j < firmInfo->first_build_id + firmInfo->build_count; ++j )
			{
				FirmBuild *firmBuild = get_build(j);

				firmBuild->firm_id = firmInfo->firm_id;

				if( firmBuild && firmBuild->name[0] == '\0' )		// empty string
					strcpy( firmBuild->name, firmInfo->name );
			}
		}

		if( firm_group_count )		// fill in firm_id of FirmGroup
		{
			for( int j = firmInfo->first_group_id; j < firmInfo->first_group_id + firmInfo->group_count; ++j )
			{
				get_group(j)->firm_id = firmInfo->firm_id;
			}
		}
		//----- set only_build_race_id -------//

		for( int j=1 ; j<=MAX_MONSTER_TYPE ; j++ )
		{
			if( firmInfo->get_build_id( monster_res[j]->firm_build_code ) )
			{
				if( !firmInfo->only_build_race_id )
					firmInfo->only_build_race_id = -j;
				else                                   // if more than one monster type can build this firm, reset only_build_race_id to zero
				{
					firmInfo->only_build_race_id = 0;
					break;
				}
			}
		}
	}

	//-- the size of camp and fort must be the same as camp can be upgraded to fort --//

	err_when( firm_res[FIRM_CAMP]->loc_width != firm_res[FIRM_FORT]->loc_width ||
				 firm_res[FIRM_CAMP]->loc_height != firm_res[FIRM_FORT]->loc_height );
}