Пример #1
0
static void DS_Place(MECH * ds, MECH * mech, int frombay)
{
	int i;
	int nx, ny;
	MAP *mech_map;

	for(i = 0; i < NUM_BAYS; i++)
		if(AeroBay(ds, i) == frombay)
			break;
	if(i == NUM_BAYS || !(mech_map = getMap(mech->mapindex))) {
		/* i _should_ be set, otherwise things are deeply disturbing */
		mech_notify(mech, MECHALL, "Reality collapse imminent.");
		return;
	}
	i = Find_DS_Bay_Dir(ds, i);
	nx = dirs[(DSBearMod(ds) + i) % 6][0] + MechX(ds);
	ny = dirs[(DSBearMod(ds) + i) % 6][1] + MechY(ds) + KLUDGE(MechX(ds), nx);
	nx = BOUNDED(0, nx, mech_map->map_width - 1);
	ny = BOUNDED(0, ny, mech_map->map_height - 1);

	/* snippage from mech_Rsetxy */
	MechX(mech) = nx;
	MechLastX(mech) = nx;
	MechY(mech) = ny;
	MechLastY(mech) = ny;
	MechZ(mech) = MechZ(ds);
	MechElev(mech) = MechElev(ds);
	MapCoordToRealCoord(MechX(mech), MechY(mech), &MechFX(mech),
						&MechFY(mech));
	MechTerrain(mech) = GetTerrain(mech_map, MechX(mech), MechY(mech));
}
Пример #2
0
void Camera::strafe(float amount) {
	if(BOUNDED(lookAt[0])) {
		lookAt[0] += amount;
	}
	if(BOUNDED(location[0])) {
		location[0] += amount;
	}
}
Пример #3
0
void Camera::walk(float amount) {
	if(BOUNDED(lookAt[2])) {
		lookAt[2] += amount;
	}
	if(BOUNDED(location[2])) {
		location[2] += amount;
	}
}
Пример #4
0
bool IGraphicsLice::DrawVerticalLine(const IColor* pColor, int xi, int yLo, int yHi)
{
  int W = Width(), H = Height();
  xi = BOUNDED(xi, 0, W - 1);
  yLo = BOUNDED(yLo, 0, H - 1);
  yHi = BOUNDED(yHi, 0, H - 1);

  LICE_pixel px = LiceColor(pColor);
  LICE_pixel* pPx = mDrawBitmap->getBits() + yLo * W + xi;
  for (int i = yLo; i <= yHi; ++i, pPx += W) {
    *pPx = px;
  }
  return true;
}
Пример #5
0
bool IGraphicsLice::DrawHorizontalLine(const IColor* pColor, int yi, int xLo, int xHi)
{
  int W = Width(), H = Height();
  yi = BOUNDED(yi, 0, H - 1);
  xLo = BOUNDED(xLo, 0, W - 1);
  xHi = BOUNDED(xHi, 0, W - 1);
    
  LICE_pixel px = LiceColor(pColor);
  LICE_pixel* pPx = mDrawBitmap->getBits() + yi * W + xLo;
  for (int i = xLo; i <= xHi; ++i, ++pPx) {
    *pPx = px;
  }
  return true;
}
Пример #6
0
void IControl::SetDirty(bool pushParamToPlug)
{
	mValue = BOUNDED(mValue, mClampLo, mClampHi);
  mDirty = true;
	if (pushParamToPlug && mPlug && mParamIdx >= 0) {
		mPlug->SetParameterFromGUI(mParamIdx, mValue);
	}
}
Пример #7
0
bool IBitmapControl::Draw(IGraphics* pGraphics)
{
    int i = 1;
    if (mBitmap.N > 1) {
	    i = 1 + int(0.5 + mValue * (double) (mBitmap.N - 1));
	    i = BOUNDED(i, 1, mBitmap.N);
    }
    return pGraphics->DrawBitmap(&mBitmap, &mRECT, i, &mBlend);
}
Пример #8
0
void IMidiMsg::MakePitchWheelMsg(double value, int channel)
{
  Clear();
  mStatus = channel | (kPitchWheel << 4);
  int i = 8192 + (int) (value * 8192.0);
  i = BOUNDED(i, 0, 16383);
  mData2 = i>>7;
  mData1 = i&0x7F;
}
Пример #9
0
bool IRadioButtonsControl::Draw(IGraphics* pGraphics)
{
    int i, n = mRECTs.GetSize();
    int active = int(0.5 + mValue * (double) (n - 1));
    active = BOUNDED(active, 0, n - 1);
    for (i = 0; i < n; ++i) {
        if (i == active) {
            pGraphics->DrawBitmap(&mBitmap, &mRECTs.Get()[i], 2, &mBlend);
        }
        else {
            pGraphics->DrawBitmap(&mBitmap, &mRECTs.Get()[i], 1, &mBlend);
        }
    }
    return true;
}
Пример #10
0
int tech_roll(dbref player, MECH * mech, int diff)
{
	int s;
	int succ;
	int r =
		(HasBoolAdvantage(player, "tech_aptitude") ? char_rollsaving() :
		 Roll());

	s = FindTechSkill(player, mech);
	s += diff;
	succ = r >= s;
	if(Wizard(player)) {
		notify_printf(player, "Tech - BTH: %d(Base:%d, Mod:%d) Roll: %d",
					  s, s - diff, diff, r);
	} else {
		notify_printf(player, "BTH: %d Roll: %d", s, r);
	}
	if(succ && In_Character(mech->mynum))
		AccumulateTechXP(player, mech, BOUNDED(1, s - 7, MAX(2, 1 + diff)));
	return (r - s);
}
Пример #11
0
bool IGraphics::DrawHorizontalLine(const IColor* pColor, IRECT* pR, float y)
{
  y = BOUNDED(y, 0.0f, 1.0f);
  int yi = pR->B - int(y * (float) (pR->B - pR->T));
  return DrawHorizontalLine(pColor, yi, pR->L, pR->R);
}
Пример #12
0
bool IGraphics::DrawVerticalLine(const IColor* pColor, IRECT* pR, float x)
{
  x = BOUNDED(x, 0.0f, 1.0f);
  int xi = pR->L + int(x * (float) (pR->R - pR->L));
  return DrawVerticalLine(pColor, xi, pR->T, pR->B);
}
Пример #13
0
int	read_stimuli(char *filename)
{
	FILE	*id;
	int	n,i;
	int	here;
	int	inada;
	int	line=0;
	char	buf[BUF_LEN+1];
	pchar	err_msg;

	if (verbose) printf("Reading stimuli from \"%s\"...\n",filename);

	if ((id=fopen(filename,"r+")) == (FILE *) 0) {
		puts("File does not exist");
		return 0;
	}
	for (n=0;n<5;++n) {
		if (!fgets(buf,BUF_LEN,id)) 
			goto end_of_file;
		++line;
	}

	if (strlen(global_msg) != strlen(buf)) {
		err_msg=global_msg;
		goto invalid_file_format;
	}

	if (!fgets(buf,BUF_LEN,id))
		goto end_of_file;
	++line;

	if (sscanf(buf,global_str,&num_trials,&num_stimuli,&num_categories,
		&num_choices_per_category,&max_same_categories,
		&ms_btwn_stim,&ms_btwn_trials,&total_ms_on) != 8)
		goto unexpected_args;

	validate_args();
	if (!init_arrays()) {
		fclose(id);
		return 0;
	}

	for (n=0;n<2;++n) {
		if (!fgets(buf,BUF_LEN,id))
			goto end_of_file;
		++line;
	}
	if (strlen(color_msg) != strlen(buf)) {
		err_msg=color_msg;
		goto invalid_file_format;
	}
	if (!fgets(buf,BUF_LEN,id))
		goto end_of_file;
	++line;

	if (get_colors_from == COLORS_FROM_STM_FILE) {
		if (sscanf(buf,color_str,&_palette[0],&_palette[1],&_palette[2],
			&_palette[3],&_palette[4],&_palette[5],&_palette[6]) != 7)
			goto unexpected_args;
	}
	/* Else use the ones parsed in from .cfg file, if at all */

	for (n=0;n<2;++n) {
		if (!fgets(buf,BUF_LEN,id))
			goto end_of_file;
		++line;
	}
	if (strlen(stm_msg) != strlen(buf)) {
		err_msg=stm_msg;
		goto invalid_file_format;
	}

	for (n=0,here=0;n<num_trials;++n) {
		for (i=0;i<num_stimuli;++i,++here) {
			if (!fgets(buf,BUF_LEN,id))
				goto end_of_file;
			++line;
			if (sscanf(buf,stm_str,&inada,&inada,
				&_color[here],&_shape[here],
				&_num[here],&_size[here],&_filled[here],&_pattern[here],
				&_matches[here],&inada) != 10)
				goto unexpected_args;

			BOUNDED(_shape[here],0,num_choices_per_category-1);
			BOUNDED(_num[here],0,num_choices_per_category-1);
			BOUNDED(_size[here],0,num_choices_per_category-1);
			BOUNDED(_filled[here],0,num_choices_per_category-1);
			if(use_many_colors) {
				BOUNDED(_color[here],0,MAX_COLORS-1);
				BOUNDED(_pattern[here],0,MAX_PATTERNS-1);
			}
			else {
				BOUNDED(_color[here],0,num_choices_per_category-1);
				BOUNDED(_pattern[here],0,num_choices_per_category-1);
			}
			_Orig_stim[here] = item_val(here);	// for randomization purposes
		}
	}
	fclose(id);

	calc_matches();

	return 1;

unexpected_args:
	if (verbose) printf("Unexpected args on line %i\n", line);
	fclose(id);
	return 0;

end_of_file:
	puts("File ended too early");
	fclose(id);
	return 0;

invalid_file_format:
	printf("Invalid file format.  Expects as line %i:\n",line);
	puts(err_msg);
	fclose(id);
	return 0;
}
Пример #14
0
double IParam::GetNormalized(double nonNormalizedValue)
{
  nonNormalizedValue = BOUNDED(nonNormalizedValue, mMin, mMax);
  return ToNormalizedParam(nonNormalizedValue, mMin, mMax, mShape);
}
Пример #15
0
int	CBTparse(int index, int argc, char **argv)
{
	int	n;
	long	lcolor;

	switch(index) {
		case 0: verbose = atoi(argv[0]); break;
		case 1:
			for (n=0;n<argc && n < MAX_MULTI_EXP; ++n) 
				multi_exp[n] = (1 + CONFIGisentry(argv[n],sizeof(ExpType)/sizeof(char *),ExpType));
			break;
		case 2: num_stimuli = atoi(argv[0]); break;
		case 3: num_categories = atoi(argv[0]); break;
		case 4: num_choices_per_category = atoi(argv[0]); break;
		case 5: ms_btwn_stim = atoi(argv[0]); break;
		case 6: ms_btwn_trials = atoi(argv[0]); break;
		case 7: total_ms_on = atoi(argv[0]); break;
		case 8: mark_correct = atoi(argv[0]); break;
		case 9: use_absolute_size = atoi(argv[0]); break;
		case 10: use_ega = 0; break; // atoi(argv[0]); break;
		case 11: force_aspect_ratio = (float) atof(argv[0]); break;
		case 12: max_same_categories = atoi(argv[0]); break;
		case 13:
			input_type = CONFIGisentry(argv[0],sizeof(InputType)/sizeof(char *),InputType);
			if (input_type == -1)
				return 0;
			break;
		case 14:
			for (n=0;n<argc && n < MAX_MULTI_EXP; ++n) {
				randomize[n] = CONFIGisentry(argv[n],sizeof(RandType)/sizeof(char *),RandType);
				if (randomize[n] == -1)
					randomize[n] = 0;
			}
			break;
		case 15: datafile = Strdup(argv[0]); break;
		case 16:
			/** Parse color codes **/
			for (n=0;n<argc;++n) {
				if (n > 15)	// max of 16 colors
					break;
				if (sscanf(argv[n],"%8lxH",&lcolor) == 1) {
					_palette[n] = lcolor;
				}
			}
			break;
		case 17: num_trials = atoi(argv[0]); break;
		case 18: analysis_blocks = atoi(argv[0]); break;
		case 19: source_file = Strdup(argv[0]); break;
		case 20:
			for (n=0;n<argc && n < MAX_MULTI_EXP; ++n) 
				practice_rounds[n] = atoi(argv[n]);
			break;
		case 21: use_many_colors=atoi(argv[0]); break;
		case 22: ask_awareness_of_patterns = atoi(argv[0]); break;
		case 23: verbose_warmup = atoi(argv[0]); break;
		case 24: beep_on_error_key = atoi(argv[0]); break;
		case 25: get_colors_from = CONFIGisentry(argv[0],2,ColorFromType); break;
		case 26:
			all_immediate = 1;
			for (n=0;n<argc && n < MAX_MULTI_EXP; ++n) {
				immediate_start[n] = atoi(argv[n]);
				BOUNDED(immediate_start[n],0,1);
				all_immediate = (all_immediate && immediate_start[n]);
			}
			break;
		case 27: cleanup_delay = atoi(argv[0]); break;
		default: return 0;
	}
	return 1;
}