Exemple #1
0
void C_THISCLASS::load_config(unsigned char *data, int len)
{
	int pos=0;
  if (data[pos] == 1)
  {
    pos++;
    load_string(effect_exp[0],data,pos,len);
    load_string(effect_exp[1],data,pos,len);
    load_string(effect_exp[2],data,pos,len);
  }
  else
  {
    char buf[769];
    if (len-pos >= 768)
    {
      memcpy(buf,data+pos,768);
      pos+=768;
      buf[768]=0;
      effect_exp[2].assign(buf+512);
      buf[512]=0;
      effect_exp[1].assign(buf+256);
      buf[256]=0;
      effect_exp[0].assign(buf);
    }
  }
	if (len-pos >= 4) { blend=GET_INT(); pos+=4; }
	if (len-pos >= 4) { subpixel=GET_INT(); pos+=4; }

}
Exemple #2
0
CELL func_substring(CELL frame)
{
	CELL string = FV0;
	CELL start = FV1;
	CELL end = FV2;
	if (!STRINGP(string)) {
		return make_exception("expects a string");
	}
	if (!INTP(start)) {
		return make_exception("expects a non-negative start index");
	}
	if (!INTP(end)) {
		return make_exception("expects a non-negative end index");
	}

	size_t len = GET_STRING(string)->len;
	size_t starti = GET_INT(start);
	size_t endi = GET_INT(end);
	if (starti < 0 || starti > len) {
		return make_exception("start index %d out of range [0,%d]", starti, len);
	}
	if (endi < starti || endi > len) {
		return make_exception("end index %d out of range [%d,%d]", endi, starti, len);
	}

	gc_root_1("func_substring", string);
	CELL result = make_string_raw(endi - starti);
	gc_unroot();
	memcpy(GET_STRING(result)->data, GET_STRING(string)->data + starti, endi - starti);
	return result;
}
Exemple #3
0
/* code for skill improvement through use */
void improve_skill(struct char_data *ch, int skill, int chance)
{
  int percent = GET_SKILL(ch, skill);
  int newpercent, max;
  char skillbuf[MAX_STRING_LENGTH];
  char mybuf[256];

  max = max_lvl_skill[1][spells[find_skill_num_def(skill)].difficulty][(int) GET_LEVEL(ch)];
  if (percent >= max || IS_NPC(ch))
    return;
  if (number(1, (chance * 50)) > (GET_WIS(ch) + GET_INT(ch)))
    return;
  newpercent = 1;
  if (number(1, 120) <= GET_WIS(ch))
    newpercent++;
  if (number(1, 120) <= GET_INT(ch))
    newpercent++;
  percent += newpercent;
  percent = MIN(percent, max);
  SET_SKILL(ch, skill, percent);
  if (newpercent) {
    sprintf(mybuf, "SKILLIMPROVE: %s improved skill %s, int = %d, wis = %d, improved by = %d, now = %d", GET_NAME(ch), spells[find_skill_num_def(skill)].command, GET_INT(ch), GET_WIS(ch), newpercent, percent);
    mudlog(mybuf, 'D', COM_IMMORT, TRUE);
    sprintf(skillbuf, "{RYou feel your skill in {W%s {Rimproving.{x\r\n", spells[find_skill_num_def(skill)].command);
    send_to_char(skillbuf, ch);
  }
}
Exemple #4
0
CAMLprim value LFUN(sqr_nrm2_stub)(
  value vSTABLE, value vN, value vOFSX, value vINCX, value vX)
{
  CAMLparam1(vX);

  integer GET_INT(N), GET_INT(INCX);
  REAL res;

  VEC_PARAMS(X);

  caml_enter_blocking_section();  /* Allow other threads */
  if (Bool_val(vSTABLE)) {
#ifndef LACAML_DOUBLE
  res = scnrm2_(&N, X_data, &INCX);
#else
  res = dznrm2_(&N, X_data, &INCX);
#endif
  res *= res;
  } else {
    COMPLEX cres = FUN(dotc)(&N, X_data, &INCX, X_data, &INCX);
    res = cres.r;
  }
  caml_leave_blocking_section();  /* Disallow other threads */

  CAMLreturn(caml_copy_double(res));
}
// process a player kick packet
void process_player_kick_packet(ubyte *data, header *hinfo)
{
	int player_num,from_player,ban,reason;	
	short player_id;
	int offset = HEADER_LENGTH;
	
	// get the address of the guy who is to be kicked
	GET_SHORT(player_id);
	GET_INT(ban);
	GET_INT(reason);
	player_num = find_player_id(player_id);
	PACKET_SET_SIZE();

	// only the server should ever receive a request to kick a guy
	Assert(Net_player->flags & NETINFO_FLAG_AM_MASTER);
	
	// determine who sent the packet	
	from_player = find_player_id(hinfo->id);

	// check to see if this guy is allowed to make such a request
	if((from_player == -1) || !multi_kick_can_kick(&Net_players[from_player]) ){
		nprintf(("Network","Received a kick request from an invalid player!!\n"));
	} 
	// otherwise, process the request fully
	else {
		// make sure we have a valid player to kick
		if(player_num == -1){
			nprintf(("Network","Received request to kick an unknown player!\n"));
		} else {
			// will handle all the rest of the details
			multi_kick_player(player_num,ban,reason);
		}
	}
}
Exemple #6
0
void glDrawArrays.@precall()
{
    int maxIndex = first + count - 1, i;
    int maxTextureUnit = GET_INT(TRS_CTX_CTEXUNIT_MAX);
    void* origUnit = GET(TRS_CTX_CTEXUNIT);
    
    /* Save all the enabled arrays that are not bound to any buffers */
    SAVE_ARRAY(GET_BOOL(TRS_CTX_VERTEX_ENABLED)      && GET(TRS_CTX_VERTEX_BINDING) == 0,      GET(TRS_CTX_VERTEX_POINTER),      GET_INT(TRS_CTX_VERTEX_STRIDE),      GET_INT(TRS_CTX_VERTEX_TYPE),      GET_INT(TRS_CTX_VERTEX_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_NORMAL_ENABLED)      && GET(TRS_CTX_NORMAL_BINDING) == 0,      GET(TRS_CTX_NORMAL_POINTER),      GET_INT(TRS_CTX_NORMAL_STRIDE),      GET_INT(TRS_CTX_NORMAL_TYPE),      3);
    SAVE_ARRAY(GET_BOOL(TRS_CTX_COLOR_ENABLED)       && GET(TRS_CTX_COLOR_BINDING) == 0,       GET(TRS_CTX_COLOR_POINTER),       GET_INT(TRS_CTX_COLOR_STRIDE),       GET_INT(TRS_CTX_COLOR_TYPE),       GET_INT(TRS_CTX_COLOR_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_POINTSIZE_ENABLED)   && GET(TRS_CTX_POINTSIZE_BINDING) == 0,   GET(TRS_CTX_POINTSIZE_POINTER),   GET_INT(TRS_CTX_POINTSIZE_STRIDE),   GET_INT(TRS_CTX_POINTSIZE_TYPE),   1);
    SAVE_ARRAY(GET_BOOL(TRS_CTX_MATRIXINDEX_ENABLED) && GET(TRS_CTX_MATRIXINDEX_BINDING) == 0, GET(TRS_CTX_MATRIXINDEX_POINTER), GET_INT(TRS_CTX_MATRIXINDEX_STRIDE), GET_INT(TRS_CTX_MATRIXINDEX_TYPE), GET_INT(TRS_CTX_MATRIXINDEX_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_WEIGHT_ENABLED)      && GET(TRS_CTX_WEIGHT_BINDING) == 0,      GET(TRS_CTX_WEIGHT_POINTER),      GET_INT(TRS_CTX_WEIGHT_STRIDE),      GET_INT(TRS_CTX_WEIGHT_TYPE),      GET_INT(TRS_CTX_WEIGHT_SIZE));

    maxTextureUnit = TR_MAX(GL_TEXTURE0, maxTextureUnit);
    for (i = GL_TEXTURE0; i < maxTextureUnit + 1; i++)
    {
        SET(TRS_CTX_CTEXUNIT, i);
        SAVE_ARRAY(GET_BOOL(TRS_CTX_CTEXUNIT_TEXCOORD_ENABLED) && GET(TRS_CTX_CTEXUNIT_TEXCOORD_BINDING) == 0,
                   GET(TRS_CTX_CTEXUNIT_TEXCOORD_POINTER),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_STRIDE),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_TYPE),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_SIZE));
    }
    SET(TRS_CTX_CTEXUNIT, origUnit);
}
Exemple #7
0
int write_mobile_espec(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{
  if (GET_ATTACK(mob) != 0)
    fprintf(fd, "BareHandAttack: %d\n", GET_ATTACK(mob));
  if (GET_STR(mob) != 0)
    fprintf(fd, "Str: %d\n", GET_STR(mob));
  if (GET_ADD(mob) != 0)
    fprintf(fd, "StrAdd: %d\n", GET_ADD(mob));
  if (GET_DEX(mob) != 0)
    fprintf(fd, "Dex: %d\n", GET_DEX(mob));
  if (GET_INT(mob) != 0)
    fprintf(fd, "Int: %d\n", GET_INT(mob));
  if (GET_WIS(mob) != 0)
    fprintf(fd, "Wis: %d\n", GET_WIS(mob));
  if (GET_CON(mob) != 0)
    fprintf(fd, "Con: %d\n", GET_CON(mob));
  if (GET_CHA(mob) != 0)
    fprintf(fd, "Cha: %d\n", GET_CHA(mob));
  if(GET_CLASS(mob) != CLASS_NPC_OTHER)
    fprintf(fd, "Class: %d\n", GET_CLASS(mob));
  if(GET_RACE(mob) != RACE_NPC_OTHER)
    fprintf(fd, "Race: %d\n", GET_RACE(mob));
  if(GET_MOB_WEIGHT(mob))
    fprintf(fd, "Weight: %d\n", GET_MOB_WEIGHT(mob));

  fprintf(fd, "Size: %d\n", GET_MOB_SIZE(mob));

  fputs("E\n", fd);
  return TRUE;
}
Exemple #8
0
// HandleSortBy():
void HandleSortBy( LWControl *con, void *data ) {
  int state, index;
  GET_INT( rint->sort_by_popup, state );
  GET_INT( rint->list, index );

  // Store the item
  ReplaceObjects_SwapObject *swap = NULL;
  if( index != -1 ) {
    swap = rint->swaps[ index ];
    assert( swap != NULL );
  }

  // Sort the list
  if( state == 0 )
    rint->swaps.QSort( SortSwapObjects_Alpha );
  else
    rint->swaps.QSort( SortSwapObjects_Weight );

  // Reselect the item
  if( swap != NULL ) {
    unsigned long new_index = rint->swaps.FindIndexOf( swap );
    SET_IVEC( rint->list, new_index, 1, 0 );
  }

  REDRAW_CON( rint->list );
}
Exemple #9
0
CELL func_integer_to_char(CELL frame)
{
	if (!(INTP(FV0) && GET_INT(FV0) >= 0 && GET_INT(FV0) <= 255)) {
		return make_exception("expects an <integer> in [0,255]");
	}
	return make_char(GET_INT(FV0));
}
Exemple #10
0
CAMLprim value LFUN(mat_axpy_stub)(
  value vALPHA,
  value vM, value vN,
  value vXR, value vXC, value vX,
  value vYR, value vYC, value vY)
{
  CAMLparam2(vX, vY);
  integer GET_INT(M), GET_INT(N);
  if (M > 0 && N > 0) {
    CREATE_NUMBER(ALPHA);
    MAT_PARAMS(X);
    MAT_PARAMS(Y);
    INIT_NUMBER(ALPHA);
    caml_enter_blocking_section();
      if (rows_X == M && rows_Y == M) {
        integer MN = M * N;
        FUN(axpy)(&MN, &ALPHA, X_data, &integer_one, Y_data, &integer_one);
      } else {
        NUMBER *X_last = X_data + rows_X * N;
        do {
          FUN(axpy)(&M, &ALPHA, X_data, &integer_one, Y_data, &integer_one);
          X_data += rows_X;
          Y_data += rows_Y;
        } while (X_data != X_last);
      }
    caml_leave_blocking_section();
  }

  CAMLreturn(Val_unit);
}
Exemple #11
0
CAMLprim value LFUN(scal_mat_stub)(
  value vM, value vN,
  value vALPHA,
  value vAR, value vAC, value vA)
{
  CAMLparam1(vA);
  integer GET_INT(M), GET_INT(N);

  if ( M > 0 && N > 0) {
    CREATE_NUMBER(ALPHA);
    MAT_PARAMS(A);
    INIT_NUMBER(ALPHA);
    caml_enter_blocking_section();
      if (rows_A == M) {
        integer MN = M * N;
        FUN(scal)(&MN, &ALPHA, A_data, &integer_one);
      } else {
        NUMBER *A_last = A_data + rows_A * N;
        do {
          FUN(scal)(&M, &ALPHA, A_data, &integer_one);
          A_data += rows_A;
        } while (A_data != A_last);
      }
    caml_leave_blocking_section();
  }

  CAMLreturn(Val_unit);
}
static jboolean android_view_GraphicBuffer_lockCanvas(JNIEnv* env, jobject,
        jlong wrapperHandle, jobject canvas, jobject dirtyRect) {

    GraphicBufferWrapper* wrapper =
                reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle);
    if (!wrapper) {
        return JNI_FALSE;
    }

    sp<GraphicBuffer> buffer(wrapper->buffer);

    Rect rect;
    if (dirtyRect) {
        rect.left = GET_INT(dirtyRect, gRectClassInfo.left);
        rect.top = GET_INT(dirtyRect, gRectClassInfo.top);
        rect.right = GET_INT(dirtyRect, gRectClassInfo.right);
        rect.bottom = GET_INT(dirtyRect, gRectClassInfo.bottom);
    } else {
        rect.set(Rect(buffer->getWidth(), buffer->getHeight()));
    }

    void* bits = NULL;
    status_t status = buffer->lock(LOCK_CANVAS_USAGE, rect, &bits);

    if (status) return JNI_FALSE;
    if (!bits) {
        buffer->unlock();
        return JNI_FALSE;
    }

    ssize_t bytesCount = buffer->getStride() * bytesPerPixel(buffer->getPixelFormat());

    SkBitmap bitmap;
    bitmap.setInfo(SkImageInfo::Make(buffer->getWidth(), buffer->getHeight(),
                                     convertPixelFormat(buffer->getPixelFormat()),
                                     kPremul_SkAlphaType),
                   bytesCount);

    if (buffer->getWidth() > 0 && buffer->getHeight() > 0) {
        bitmap.setPixels(bits);
    } else {
        bitmap.setPixels(NULL);
    }

    SET_INT(canvas, gCanvasClassInfo.mSurfaceFormat, buffer->getPixelFormat());
    INVOKEV(canvas, gCanvasClassInfo.setNativeBitmap, reinterpret_cast<jlong>(&bitmap));

    SkRect clipRect;
    clipRect.set(rect.left, rect.top, rect.right, rect.bottom);
    SkCanvas* nativeCanvas = GraphicsJNI::getNativeCanvas(env, canvas);
    nativeCanvas->clipRect(clipRect);

    if (dirtyRect) {
        INVOKEV(dirtyRect, gRectClassInfo.set,
                int(rect.left), int(rect.top), int(rect.right), int(rect.bottom));
    }

    return JNI_TRUE;
}
Exemple #13
0
void glDrawElements.@precall()
{
    int maxIndex = 0, i;
    const void *indexData = indices;
    int maxTextureUnit = GET_INT(TRS_CTX_CTEXUNIT_MAX);
    void* origUnit = GET(TRS_CTX_CTEXUNIT);
    void* origBuffer = GET(TRS_CTX_BUFFER);
        
    /* See if an element array buffer is bound */
    SET(TRS_CTX_BUFFER, GL_ELEMENT_ARRAY_BUFFER);
    if (GET(TRS_CTX_BUFFER_HANDLE))
    {
        const TRbyte* pointer = (const TRbyte*)GET(TRS_CTX_BUFFER_HANDLE_DATA);
        TRuint offset = (TRuint)indexData;
        indexData = (void*)(pointer + offset);
    }
    SET(TRS_CTX_BUFFER, origBuffer);
    
    /* Find out the minimum and maximum indices for this draw call */
    if (indexData)
    {
        if (type == GL_UNSIGNED_BYTE)
        {
            const unsigned char* d = (const unsigned char*)indexData;
            for (i = 0; i < count; i++)
            {
                if (d[i] > maxIndex) maxIndex = d[i];
            }
        }
        else if (type == GL_UNSIGNED_SHORT)
        {
            const unsigned short* d = (const unsigned short*)indexData;
            for (i = 0; i < count; i++)
            {
                if (d[i] > maxIndex) maxIndex = d[i];
            }
        }
    }

    /* Save all the enabled arrays */
    SAVE_ARRAY(GET_BOOL(TRS_CTX_VERTEX_ENABLED)      && GET(TRS_CTX_VERTEX_BINDING) == 0,      GET(TRS_CTX_VERTEX_POINTER),      GET_INT(TRS_CTX_VERTEX_STRIDE),      GET_INT(TRS_CTX_VERTEX_TYPE),      GET_INT(TRS_CTX_VERTEX_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_NORMAL_ENABLED)      && GET(TRS_CTX_NORMAL_BINDING) == 0,      GET(TRS_CTX_NORMAL_POINTER),      GET_INT(TRS_CTX_NORMAL_STRIDE),      GET_INT(TRS_CTX_NORMAL_TYPE),      3);
    SAVE_ARRAY(GET_BOOL(TRS_CTX_COLOR_ENABLED)       && GET(TRS_CTX_COLOR_BINDING) == 0,       GET(TRS_CTX_COLOR_POINTER),       GET_INT(TRS_CTX_COLOR_STRIDE),       GET_INT(TRS_CTX_COLOR_TYPE),       GET_INT(TRS_CTX_COLOR_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_POINTSIZE_ENABLED)   && GET(TRS_CTX_POINTSIZE_BINDING) == 0,   GET(TRS_CTX_POINTSIZE_POINTER),   GET_INT(TRS_CTX_POINTSIZE_STRIDE),   GET_INT(TRS_CTX_POINTSIZE_TYPE),   1);
    SAVE_ARRAY(GET_BOOL(TRS_CTX_MATRIXINDEX_ENABLED) && GET(TRS_CTX_MATRIXINDEX_BINDING) == 0, GET(TRS_CTX_MATRIXINDEX_POINTER), GET_INT(TRS_CTX_MATRIXINDEX_STRIDE), GET_INT(TRS_CTX_MATRIXINDEX_TYPE), GET_INT(TRS_CTX_MATRIXINDEX_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_WEIGHT_ENABLED)      && GET(TRS_CTX_WEIGHT_BINDING) == 0,      GET(TRS_CTX_WEIGHT_POINTER),      GET_INT(TRS_CTX_WEIGHT_STRIDE),      GET_INT(TRS_CTX_WEIGHT_TYPE),      GET_INT(TRS_CTX_WEIGHT_SIZE));

    maxTextureUnit = TR_MAX(GL_TEXTURE0, maxTextureUnit);
    for (i = GL_TEXTURE0; i < maxTextureUnit + 1; i++)
    {
        SET(TRS_CTX_CTEXUNIT, i);
        SAVE_ARRAY(GET_BOOL(TRS_CTX_CTEXUNIT_TEXCOORD_ENABLED) && GET(TRS_CTX_CTEXUNIT_TEXCOORD_BINDING) == 0,
                   GET(TRS_CTX_CTEXUNIT_TEXCOORD_POINTER),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_STRIDE),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_TYPE),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_SIZE));
    }
    SET(TRS_CTX_CTEXUNIT, origUnit);
}
Exemple #14
0
/* walk even though they could fly at will.                             */
void affect_total(struct char_data *ch)
{
  struct affected_type *af;
  int i,j;
  char buff[200];

  for(i=0; i<MAX_WEAR; i++) {
    if (ch->equipment[i])
      for(j=0; j<MAX_OBJ_AFFECT; j++)
	affect_modify(ch, ch->equipment[i]->affected[j].location,
		      (int)ch->equipment[i]->affected[j].modifier,
		      ch->equipment[i]->obj_flags.bitvector, FALSE);
  }
  
  for(af = ch->affected; af; af=af->next)
    if(af->type != SPELL_FLY)
      affect_modify(ch, af->location, (int) af->modifier, af->bitvector, 
		    FALSE);

  ch->tmpabilities = ch->abilities; 
  
  for(i=0; i<MAX_WEAR; i++) {
    if (ch->equipment[i])
      for(j=0; j<MAX_OBJ_AFFECT; j++)
	affect_modify(ch, ch->equipment[i]->affected[j].location,
		      (int) ch->equipment[i]->affected[j].modifier,
		      ch->equipment[i]->obj_flags.bitvector, TRUE);
  }
  
  
  for(af = ch->affected; af; af=af->next)
    if(af->type != SPELL_FLY)
      affect_modify(ch, af->location, (int)af->modifier, 
		    af->bitvector, TRUE);
  
  /* Make certain values are between 0..25, not < 0 and not > 25! */
  
  i = ((!IS_PC(ch)) ? 25 :18);	/* f**k polies */
 
  GET_DEX(ch) = MAX(3,MIN(GET_DEX(ch), i));
  GET_INT(ch) = MAX(3,MIN(GET_INT(ch), i));
  GET_WIS(ch) = MAX(3,MIN(GET_WIS(ch), i));
  GET_CON(ch) = MAX(3,MIN(GET_CON(ch), i));
  GET_STR(ch) = MAX(3,GET_STR(ch));
  
  if (!IS_PC(ch)) {
    GET_STR(ch) = MIN(GET_STR(ch), i);
  } else if(GET_RACE(ch) != RACE_OGRE) {
    if (GET_STR(ch) > 18) {
      GET_ADD(ch) = 100;
      GET_STR(ch) = 18;
    }
  } else {			
    /* warning: I am counting on ChangeStrength() */
    /* to be working for this to be safe :) */
    GET_STR(ch) = MIN(22,GET_STR(ch));
  }
}
Exemple #15
0
void MainWindow::readSettings()
{
	QVariant v;
	QSettings s;

	s.beginGroup("Units");
	if (s.value("unit_system").toString() == "metric") {
		prefs.unit_system = METRIC;
		prefs.units = SI_units;
	} else if (s.value("unit_system").toString() == "imperial") {
		prefs.unit_system = IMPERIAL;
		prefs.units = IMPERIAL_units;
	} else {
		prefs.unit_system = PERSONALIZE;
		GET_UNIT("length", length, units::FEET, units::METERS);
		GET_UNIT("pressure", pressure, units::PSI, units::BAR);
		GET_UNIT("volume", volume, units::CUFT, units::LITER);
		GET_UNIT("temperature", temperature, units::FAHRENHEIT, units::CELSIUS);
		GET_UNIT("weight", weight, units::LBS, units::KG);
	}
	s.endGroup();
	s.beginGroup("DisplayListColumns");
	GET_BOOL("CYLINDER", visible_cols.cylinder);
	GET_BOOL("TEMPERATURE", visible_cols.temperature);
	GET_BOOL("TOTALWEIGHT", visible_cols.totalweight);
	GET_BOOL("SUIT", visible_cols.suit);
	GET_BOOL("NITROX", visible_cols.nitrox);
	GET_BOOL("OTU", visible_cols.otu);
	GET_BOOL("MAXCNS", visible_cols.maxcns);
	GET_BOOL("SAC", visible_cols.sac);
	s.endGroup();
	s.beginGroup("TecDetails");
	GET_BOOL("po2graph", pp_graphs.po2);
	GET_BOOL("pn2graph", pp_graphs.pn2);
	GET_BOOL("phegraph", pp_graphs.phe);
	GET_DOUBLE("po2threshold", pp_graphs.po2_threshold);
	GET_DOUBLE("pn2threshold", pp_graphs.pn2_threshold);
	GET_DOUBLE("phethreshold", pp_graphs.phe_threshold);
	GET_BOOL("mod", mod);
	GET_DOUBLE("modppO2", mod_ppO2);
	GET_BOOL("ead", ead);
	GET_BOOL("redceiling", profile_red_ceiling);
	GET_BOOL("dcceiling", profile_dc_ceiling);
	GET_BOOL("calcceiling", profile_calc_ceiling);
	GET_BOOL("calcceiling3m", calc_ceiling_3m_incr);
	GET_BOOL("calcalltissues", calc_all_tissues);
	GET_INT("gflow", gflow);
	GET_INT("gfhigh", gfhigh);
	set_gf(prefs.gflow, prefs.gfhigh);
	s.endGroup();

	s.beginGroup("Display");
	v = s.value(QString("divelist_font"));
	if (v.isValid())
		prefs.divelist_font = strdup(v.toString().toUtf8().data());
}
Exemple #16
0
CELL func_make_string(CELL frame)
{
	if (!(INTP(FV0) && GET_INT(FV0) >= 0)) {
		return make_exception("1st argument expects non-negative integer");
	}
	if (FC == 2 && !CHARP(FV1)) {
		return make_exception("2nd argument expects character");
	}
	return make_string_filled(GET_INT(FV0), (FC == 2) ? GET_CHAR(FV1) : -1);
}
Exemple #17
0
CAMLprim value LFUN(gemm_diag_stub)(
  value vTRANSA,
  value vTRANSB,
  value vN, value vK,
  value vAR, value vAC, value vA,
  value vBR, value vBC, value vB,
  value vOFSY,
  value vY,
  value vALPHA,
  value vBETA
  )
{
  CAMLparam3(vA, vB, vY);

  integer GET_INT(N), GET_INT(K);
  char GET_INT(TRANSA), GET_INT(TRANSB);

  CREATE_NUMBER(ALPHA);
  CREATE_NUMBER(BETA);

  MAT_PARAMS(A);
  MAT_PARAMS(B);
  VEC_PARAMS(Y);

  unsigned long iter_incr_A, iter_incr_B;
  integer dot_incr_A, dot_incr_B;
  NUMBER *last_Y = Y_data + N;

  if (TRANSB == 'N') {
    iter_incr_B = rows_B;
    dot_incr_B = 1;
  } else {
    iter_incr_B = 1;
    dot_incr_B = rows_B;
  }

  INIT_NUMBER(ALPHA);
  INIT_NUMBER(BETA);

  caml_enter_blocking_section();  /* Allow other threads */

  if (TRANSA == 'N') {
    iter_incr_A = 1;
    dot_incr_A = rows_A;
  } else {
    iter_incr_A = rows_A;
    dot_incr_A = 1;
  }

  COMMON_DIAG_LOOP(GEMM)

  caml_leave_blocking_section();  /* Disallow other threads */

  CAMLreturn(Val_unit);
}
Exemple #18
0
FUNC_STATUS WORD pnm_getActualTraits (
    IP_XFORM_HANDLE  hXform,         /* in:  handle for xform */
    DWORD            dwInputAvail,   /* in:  # avail bytes in input buf */
    PBYTE            pbInputBuf,     /* in:  ptr to input buffer */
    PDWORD           pdwInputUsed,   /* out: # bytes used from input buf */
    PDWORD           pdwInputNextPos,/* out: file-pos to read from next */
    PIP_IMAGE_TRAITS pInTraits,      /* out: input image traits */
    PIP_IMAGE_TRAITS pOutTraits)     /* out: output image traits */
{
    PPNM_INST g;

    HANDLE_TO_PTR (hXform, g);

    /* If there is no header, we'll report no usage of input */
    *pdwInputUsed = 0;

    /* Parse the header for decode operations. */
    if (!g->fIsEncode) {
        unsigned char c;
        unsigned int maxval;

        GET_CHAR(&c);
        if (c!='P') {
            return IP_INPUT_ERROR;
        }
        GET_CHAR(&c);
        if (c=='4') {
            /* PBM */
            g->traits.iComponentsPerPixel=1;
            g->traits.iBitsPerPixel=1;

        } else if (c=='5') {
            /* PGM */
            g->traits.iComponentsPerPixel=1;
            g->traits.iBitsPerPixel=0;

        } else if (c=='6') {
            /* PPM */
            g->traits.iComponentsPerPixel=3;
            g->traits.iBitsPerPixel=0;

        } else {
            /* "Plain" (all-ASCII) formats (1-3) not (yet) supported. */
            return IP_INPUT_ERROR;
        }

        GET_INT(&g->traits.iPixelsPerRow);
        GET_INT(&g->traits.lNumRows);
        if (!g->traits.iBitsPerPixel) {
            GET_INT(&maxval);
            while (maxval) {
                g->traits.iBitsPerPixel++;
                maxval>>=1;
            }
        }
Exemple #19
0
void C_THISCLASS::load_config(unsigned char *data, int len)
{
	int pos=0;
  int x=0;
	if (len-pos >= 4) { effect=GET_INT(); pos+=4; }
	if (len-pos >= 4) { num_colors=GET_INT(); pos+=4; }
	if (num_colors <= 16) while (len-pos >= 4 && x < num_colors) { colors[x++]=GET_INT(); pos+=4; }
  else num_colors=1;
  if (len-pos >= 4) { size=GET_INT(); pos+=4; }
  if (len-pos >= 4) { rot=GET_INT(); pos+=4; }
}
static jboolean android_view_TextureView_lockCanvas(JNIEnv* env, jobject,
        jlong nativeWindow, jobject canvas, jobject dirtyRect) {

    if (!nativeWindow) {
        return JNI_FALSE;
    }

    ANativeWindow_Buffer buffer;

    Rect rect;
    if (dirtyRect) {
        rect.left = GET_INT(dirtyRect, gRectClassInfo.left);
        rect.top = GET_INT(dirtyRect, gRectClassInfo.top);
        rect.right = GET_INT(dirtyRect, gRectClassInfo.right);
        rect.bottom = GET_INT(dirtyRect, gRectClassInfo.bottom);
    } else {
        rect.set(Rect(0x3FFF, 0x3FFF));
    }

    sp<ANativeWindow> window((ANativeWindow*) nativeWindow);
    int32_t status = native_window_lock(window.get(), &buffer, &rect);
    if (status) return JNI_FALSE;

    ssize_t bytesCount = buffer.stride * bytesPerPixel(buffer.format);

    SkBitmap bitmap;
    bitmap.setConfig(convertPixelFormat(buffer.format), buffer.width, buffer.height, bytesCount);

    if (buffer.format == WINDOW_FORMAT_RGBX_8888) {
        bitmap.setIsOpaque(true);
    }

    if (buffer.width > 0 && buffer.height > 0) {
        bitmap.setPixels(buffer.bits);
    } else {
        bitmap.setPixels(NULL);
    }

    SET_INT(canvas, gCanvasClassInfo.mSurfaceFormat, buffer.format);

    SkCanvas* nativeCanvas = SkNEW_ARGS(SkCanvas, (bitmap));
    swapCanvasPtr(env, canvas, nativeCanvas);

    SkRect clipRect;
    clipRect.set(rect.left, rect.top, rect.right, rect.bottom);
    nativeCanvas->clipRect(clipRect);

    if (dirtyRect) {
        INVOKEV(dirtyRect, gRectClassInfo.set,
                int(rect.left), int(rect.top), int(rect.right), int(rect.bottom));
    }

    return JNI_TRUE;
}
Exemple #21
0
void C_THISCLASS::load_config(unsigned char *data, int len)
{
	int pos=0;
	if (len-pos >= 4) { dir=GET_INT(); pos+=4; }
	if (len-pos >= 4) { which=GET_INT(); pos+=4; }
	if (len-pos >= 4) { blend=GET_INT(); pos+=4; }
	if (len-pos >= 4) { adjblend_val=GET_INT(); pos+=4; }
  
  if (which < 0) which=0;
  if (which >= NBUF) which=NBUF-1;
}
Exemple #22
0
// TODO: Requires GL >= 3.2 or extension GL_ARB_sync
bool vogl_sync_state::snapshot(const vogl_context_info &context_info, vogl_handle_remapper &remapper, GLuint64 handle, GLenum target)
{
    VOGL_FUNC_TRACER

    VOGL_NOTE_UNUSED(context_info);
    VOGL_NOTE_UNUSED(target);
    VOGL_NOTE_UNUSED(remapper);

    VOGL_CHECK_GL_ERROR;

    clear();

    m_snapshot_handle = handle;

    GLsync sync = vogl_handle_to_sync(handle);

    bool any_gl_errors = false;

#define GET_INT(pname)                                                    \
    do                                                                    \
    {                                                                     \
        GLint val = 0;                                                    \
        GLsizei len = 0;                                                  \
        GL_ENTRYPOINT(glGetSynciv)(sync, pname, sizeof(val), &len, &val); \
        if (vogl_check_gl_error())                                         \
            any_gl_errors = true;                                         \
        m_params.insert(pname, 0, &val, sizeof(val));                     \
    } while (0)

    GET_INT(GL_OBJECT_TYPE);
    GET_INT(GL_SYNC_STATUS);
    GET_INT(GL_SYNC_CONDITION);
    GET_INT(GL_SYNC_FLAGS);

#undef GET_INT

    if (any_gl_errors)
    {
        clear();

        vogl_error_printf("%s: GL error while enumerating sync %" PRIu64 "'s' params\n", VOGL_METHOD_NAME, (uint64_t)handle);
        return false;
    }

    VOGL_ASSERT(m_params.get_value<GLenum>(GL_OBJECT_TYPE) == GL_SYNC_FENCE);
    VOGL_ASSERT(m_params.get_value<GLenum>(GL_SYNC_CONDITION) == GL_SYNC_GPU_COMMANDS_COMPLETE);
    VOGL_ASSERT(m_params.get_value<uint>(GL_SYNC_FLAGS) == 0);

    m_is_valid = true;

    return true;
}
Exemple #23
0
void MainWindow::readSettings()
{
	QVariant v;
	QSettings s;

	s.beginGroup("Units");
	if (s.value("unit_system").toString() == "metric") {
		prefs.unit_system = METRIC;
		prefs.units = SI_units;
	} else if (s.value("unit_system").toString() == "imperial") {
		prefs.unit_system = IMPERIAL;
		prefs.units = IMPERIAL_units;
	} else {
		prefs.unit_system = PERSONALIZE;
		GET_UNIT("length", length, units::FEET, units::METERS);
		GET_UNIT("pressure", pressure, units::PSI, units::BAR);
		GET_UNIT("volume", volume, units::CUFT, units::LITER);
		GET_UNIT("temperature", temperature, units::FAHRENHEIT, units::CELSIUS);
		GET_UNIT("weight", weight, units::LBS, units::KG);
	}
	GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS);
	s.endGroup();
	s.beginGroup("TecDetails");
	GET_BOOL("po2graph", pp_graphs.po2);
	GET_BOOL("pn2graph", pp_graphs.pn2);
	GET_BOOL("phegraph", pp_graphs.phe);
	GET_DOUBLE("po2threshold", pp_graphs.po2_threshold);
	GET_DOUBLE("pn2threshold", pp_graphs.pn2_threshold);
	GET_DOUBLE("phethreshold", pp_graphs.phe_threshold);
	GET_BOOL("mod", mod);
	GET_DOUBLE("modppO2", mod_ppO2);
	GET_BOOL("ead", ead);
	GET_BOOL("redceiling", profile_red_ceiling);
	GET_BOOL("dcceiling", profile_dc_ceiling);
	GET_BOOL("calcceiling", profile_calc_ceiling);
	GET_BOOL("calcceiling3m", calc_ceiling_3m_incr);
	GET_BOOL("calcalltissues", calc_all_tissues);
	GET_INT("gflow", gflow);
	GET_INT("gfhigh", gfhigh);
	set_gf(prefs.gflow, prefs.gfhigh);
	GET_BOOL("show_time", show_time);
	GET_BOOL("show_sac", show_sac);
	s.endGroup();

	s.beginGroup("Display");
	v = s.value(QString("divelist_font"));
	if (v.isValid())
		prefs.divelist_font = strdup(v.toString().toUtf8().data());
}
Exemple #24
0
/* This updates a character by subtracting everything he is affected by
 * restoring original abilities, and then affecting all again. */
void affect_total(struct char_data *ch)
{
  struct affected_type *af;
  int i, j;

  for (i = 0; i < NUM_WEARS; i++) {
    if (GET_EQ(ch, i))
      for (j = 0; j < MAX_OBJ_AFFECT; j++)
	affect_modify_ar(ch, GET_EQ(ch, i)->affected[j].location,
		      GET_EQ(ch, i)->affected[j].modifier,
		      GET_OBJ_AFFECT(GET_EQ(ch, i)), FALSE);
  }

  for (af = ch->affected; af; af = af->next)
    affect_modify_ar(ch, af->location, af->modifier, af->bitvector, FALSE);

  ch->aff_abils = ch->real_abils;

  for (i = 0; i < NUM_WEARS; i++) {
    if (GET_EQ(ch, i))
      for (j = 0; j < MAX_OBJ_AFFECT; j++)
	affect_modify_ar(ch, GET_EQ(ch, i)->affected[j].location,
		      GET_EQ(ch, i)->affected[j].modifier,
		      GET_OBJ_AFFECT(GET_EQ(ch, i)), TRUE);
  }

  for (af = ch->affected; af; af = af->next)
    affect_modify_ar(ch, af->location, af->modifier, af->bitvector, TRUE);

  /* Make certain values are between 0..25, not < 0 and not > 25! */
  i = (IS_NPC(ch) || GET_LEVEL(ch) >= LVL_GRGOD) ? 25 : 18;

  GET_DEX(ch) = MAX(0, MIN(GET_DEX(ch), i));
  GET_INT(ch) = MAX(0, MIN(GET_INT(ch), i));
  GET_WIS(ch) = MAX(0, MIN(GET_WIS(ch), i));
  GET_CON(ch) = MAX(0, MIN(GET_CON(ch), i));
  GET_CHA(ch) = MAX(0, MIN(GET_CHA(ch), i));
  GET_STR(ch) = MAX(0, GET_STR(ch));

  if (IS_NPC(ch)) {
    GET_STR(ch) = MIN(GET_STR(ch), i);
  } else {
    if (GET_STR(ch) > 18) {
      i = GET_ADD(ch) + ((GET_STR(ch) - 18) * 10);
      GET_ADD(ch) = MIN(i, 100);
      GET_STR(ch) = 18;
    }
  }
}
// process incoming squadmate messaging info 
void multi_msg_process_squadmsg_packet(unsigned char *data, header *hinfo)
{	
	int command;
	ushort net_sig;
	short source_id;
	int source_index;
	char s_val;
	int offset = HEADER_LENGTH;

	// get all packet data
	GET_INT(command);
	GET_SHORT(source_id);
	GET_USHORT(net_sig);
	GET_DATA(s_val);
	PACKET_SET_SIZE();

	// determine who the order is from
	source_index = find_player_id(source_id);
	if(source_index == -1){
		nprintf(("Network","Received squadmsg order packet from unknown player!!\n"));
		return;
	}

	// display the squadmessage somehow
	multi_msg_show_squadmsg(&Net_players[source_index],command,net_sig,(int)s_val);
}
Exemple #26
0
CAMLprim value LFUN(linspace_stub)(value vY, value va, value vb, value vN)
{
  CAMLparam1(vY);
  integer i, GET_INT(N);
  REAL ar = Double_field(va, 0),
       ai = Double_field(va, 1),
       N1 = N - 1.,
       hr = (Double_field(vb, 0) - ar) / N1,
       hi = (Double_field(vb, 1) - ai) / N1,
       xr = ar,
       xi = ai;
  VEC_PARAMS1(Y);

  caml_enter_blocking_section();  /* Allow other threads */

  for (i = 1; i <= N; i++) {
    Y_data->r = xr;
    Y_data->i = xi;
    Y_data++;
    xr = ar + i * hr;
    xi = ai + i * hi;
  }

  caml_leave_blocking_section();  /* Disallow other threads */

  CAMLreturn(Val_unit);
}
Exemple #27
0
/* An aggressive mobile wants to attack something.  If they're under the 
 * influence of mind altering PC, then see if their master can talk them out 
 * of it, eye them down, or otherwise intimidate the slave. */
static bool aggressive_mob_on_a_leash(struct char_data *slave, struct char_data *master, struct char_data *attack)
{
  static int snarl_cmd;
  int dieroll;

  if (!master || !AFF_FLAGGED(slave, AFF_CHARM))
    return (FALSE);

  if (!snarl_cmd)
    snarl_cmd = find_command("snarl");

  /* Sit. Down boy! HEEEEeeeel! */
  dieroll = rand_number(1, 20);
  if (dieroll != 1 && (dieroll == 20 || dieroll > 10 - GET_CHA(master) + GET_INT(slave))) {
    if (snarl_cmd > 0 && attack && !rand_number(0, 3)) {
      char victbuf[MAX_NAME_LENGTH + 1];

      strncpy(victbuf, GET_NAME(attack), sizeof(victbuf));	/* strncpy: OK */
      victbuf[sizeof(victbuf) - 1] = '\0';

      do_action(slave, victbuf, snarl_cmd, 0);
    }

    /* Success! But for how long? Hehe. */
    return (TRUE);
  }

  /* So sorry, now you're a player killer... Tsk tsk. */
  return (FALSE);
}
Exemple #28
0
static void sevent( LWControl *ctl, void *data )
{
   LWPanelFuncs *panf;
   const LWDisplayMetrics *dmet;
   LWPanelID panel;
   LWValue
      ival = { LWT_INTEGER },
      ivecval = { LWT_VINT };
   int x, y, w, h, m;
   char a[ 32 ];


   /* panel, panf, dmet */

   panel = ( LWPanelID ) CON_PAN( ctl );
   panf = ( LWPanelFuncs * ) CON_PANFUN( ctl );
   dmet = panf->drawFuncs->dispMetrics();

   /* control dimensions */

   x = CON_HOTX( ctl );
   y = CON_HOTY( ctl );
   w = CON_HOTW( ctl );
   h = CON_HOTH( ctl );
   x += w;
   y += ( h - dmet->textHeight ) / 2;

   /* mouse drag coordinates */

   GET_INT( ctl, m );
   sprintf( a, "%d", m );
   panf->drawFuncs->drawBox( panel, COLOR_LT_YELLOW, x + 10, y, 40,
      dmet->textHeight );
   panf->drawFuncs->drawText( panel, a, COLOR_BLACK, x + 12, y );
}
Exemple #29
0
// OnToolOptionsTabs()
//  Handles changing which tool tab has been selected
void OnToolOptionsTabs(LWControl *ctl, FreeKeyInterface *panel) {
  int tab;
  GET_INT( fk_int->tool_options_tabs, tab );

  fk->SetToolOptionsTab( (fk_tool_option_tab_ids) tab );
  fk_int->ShowToolOptionsTab( fk->GetToolOptionsTab() );
}
Exemple #30
0
// SpaceBall_Event():
double SpaceBall_Event( LWInstance _inst, const LWMasterAccess *access ) {
  if( access->eventCode == LWEVNT_COMMAND ) {
    if( strncmp( (const char *)access->eventData, "RenderFrame", 11 ) == 0 )
      is_safe = false;
    else if( strncmp( (const char *)access->eventData, "RenderScene", 11 ) == 0 )
      is_safe = false;
    else if( strncmp( (const char *)access->eventData, "RenderObject", 12 ) == 0 )
      is_safe = false;

    if( sb_int != NULL ) {
      if( sb_int->IsOpen() ) {
        int do_capture;
        GET_INT( sb_int->capture, do_capture );

        if( do_capture ) {
          if( (sb_int->current_function >= 0) && (sb_int->current_function < num_functions) ) {
            StringTools::strdup2( function_map[ sb_int->current_function ], (const char *)access->eventData );
            REDRAW_CON( sb_int->list );
            HandleList( sb_int->list, NULL );
          }
        }
      }
    }

  } else if ( access->eventCode == LWEVNT_RENDER_DONE ) {
    is_safe = true;
  }

  return 0.0;
}