예제 #1
0
// Parses weapon stat info for given ent
//	---> The given string must be space delimited and contain only integers
void G_parseStats(char *pszStatsInfo)
{
	gclient_t *cl;
	const char *tmp = pszStatsInfo;
	unsigned int i, dwWeaponMask, dwClientID = atoi(pszStatsInfo);

	if(dwClientID < 0 || dwClientID > MAX_CLIENTS) return;

	cl = &level.clients[dwClientID];

#define GETVAL(x) if((tmp = strchr(tmp, ' ')) == NULL) return; x = atoi(++tmp);

	GETVAL(cl->sess.rounds);
	GETVAL(dwWeaponMask);
	for(i=WS_KNIFE; i<WS_MAX; i++) {
		if(dwWeaponMask & (1 << i)) {
			GETVAL(cl->sess.aWeaponStats[i].hits);
			GETVAL(cl->sess.aWeaponStats[i].atts);
			GETVAL(cl->sess.aWeaponStats[i].kills);
			GETVAL(cl->sess.aWeaponStats[i].deaths);
			GETVAL(cl->sess.aWeaponStats[i].headshots);
		}
	}

	// CHRUKER: b015 - These only gets generated when there are some
	//          weaponstats. This is what the client expects.
	if (dwWeaponMask != 0) {
		GETVAL(cl->sess.damage_given);
		GETVAL(cl->sess.damage_received);
		// forty - #607 - Merge in Density's damage received display code
		GETVAL(cl->sess.team_damage_given);

	}
}
예제 #2
0
// Parses weapon stat info for given ent
//	---> The given string must be space delimited and contain only integers
void G_parseStats( char *pszStatsInfo ) {
	gclient_t *cl;
	const char *tmp = pszStatsInfo;
	unsigned int i, dwWeaponMask, dwClientID = atoi( pszStatsInfo );

	if ( dwClientID < 0 || dwClientID > MAX_CLIENTS ) {
		return;
	}

	cl = &level.clients[dwClientID];

#define GETVAL( x ) if ( ( tmp = strchr( tmp, ' ' ) ) == NULL ) {return;} x = atoi( ++tmp );

	GETVAL( cl->sess.rounds );
	GETVAL( dwWeaponMask );
	for ( i = WS_KNIFE; i < WS_MAX; i++ ) {
		if ( dwWeaponMask & ( 1 << i ) ) {
			GETVAL( cl->sess.aWeaponStats[i].hits );
			GETVAL( cl->sess.aWeaponStats[i].atts );
			GETVAL( cl->sess.aWeaponStats[i].kills );
			GETVAL( cl->sess.aWeaponStats[i].deaths );
			GETVAL( cl->sess.aWeaponStats[i].headshots );
		}
	}

	GETVAL( cl->sess.damage_given );
	GETVAL( cl->sess.damage_received );
	GETVAL( cl->sess.team_damage );
}
예제 #3
0
	void
	SVGCircleElement::asBezier(svgl::Context* svglContext, svgl::GLInfo* glinfo, agg::path_storage* ppath)
  {
    svg::SVGLength cxl = GETVAL(Cx);
    svg::SVGLength cyl = GETVAL(Cy);
    svg::SVGLength rl = GETVAL(R);
		
    double cx = svglContext->computeWidthLength(cxl);
    double cy = svglContext->computeHeightLength(cyl);
    double r = svglContext->computeHypotLength(rl);
		
		agg::ellipse e(cx,cy,r,r,1);
		e.approximation_scale(1);
		ppath->add_path(e);
  }		
예제 #4
0
  void
  SVGCircleElement::getBoundingBox(svgl::Context * svglContext, svgl::GLInfo* glinfo, float* bbx, float* bby, float* bbwidth, float* bbheight)
  {
    svg::SVGLength cxl = GETVAL(Cx);
    svg::SVGLength cyl = GETVAL(Cy);
    svg::SVGLength rl = GETVAL(R);

    float cx = svglContext->computeWidthLength(cxl);
    float cy = svglContext->computeHeightLength(cyl);
    float r = svglContext->computeHypotLength(rl);

    *bbx = cx-r;
    *bby = cy-r;
    *bbwidth = *bbheight = 2*r;
  }
예제 #5
0
	SVGSecondTransform *SVGTransformable::getSecond(bool create) {
		const SVGTransformList &transforms = GETVAL(Transform);
		unsigned int numTransform = transforms.numberOfItems();
		SVGSecondTransform *second = 0;

		// place to insert the transform in the list if create is set
		unsigned int place = numTransform;

		// the transform #0 could be the one we are looking for
		if(numTransform > 0) {
			second = dynamic_cast< SVGSecondTransform * >(transforms.getItem(numTransform - 1));
			place -= 1;
		}
		// if it wasn't, it can be the #1 only if #0 is a SVGFirstTransform
		if((numTransform > 1) && (second == 0) &&
		   (dynamic_cast< SVGFirstTransform * >(transforms.getItem(numTransform - 1)) != 0)) {
			second = dynamic_cast< SVGSecondTransform * >(transforms.getItem(numTransform - 2));
		}
		
		// creating & inserting the transform if needed
		if((second == 0) && create) {
			second = new SVGSecondTransform();
			SVGTransformList &t = const_cast< SVGTransformList & >(transforms);
			t.insertItemBefore(second, place);
		}

		return second;
	}
예제 #6
0
  SVGFirstTransform *
  SVGTransformable::getFirst(bool create)
  {
    const SVGTransformList& transforms = GETVAL(Transform);
    unsigned int numTransform = transforms.numberOfItems();
    SVGFirstTransform * first = 0;
    if(!numTransform) {
      if(create) {
	first = new SVGFirstTransform;
	SVGTransformList& t = const_cast<SVGTransformList&>(transforms);
	t.appendItem(first);
      }
    }
    else {
      SVGTransform * transform = transforms.getItem(numTransform-1);
      first = dynamic_cast<SVGFirstTransform*>(transform);
      if(!first) {
	first = new SVGFirstTransform;
	SVGTransformList& t = const_cast<SVGTransformList&>(transforms);
	t.appendItem(first);
      }
    }
    //std::cerr << transforms << __FL__;
    return first;
  }
예제 #7
0
 void
 SVGFEBlendElement::glPostTraverse(svgl::Context * svglContext, svgl::GLInfo* glinfo, SVGElement * elem, svgl::FilterContext* filterContext)
 {
   const SVG_FEBLEND_MODE& mode_ = GETVAL(Mode);
   if(mode_!=SVG_FEBLEND_MODE_NORMAL)
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 }
예제 #8
0
  void
  SVGFEBlendElement::glPreTraverse(svgl::Context * svglContext, svgl::GLInfo* glinfo, SVGElement * elem, svgl::FilterContext* filterContext)
  {
    //const dom::string& in1_ = GET_BASE_VAL(In1);
    //const dom::string& in2_ = GET_BASE_VAL(In2);
    
    //std::cerr << in1_ << std::endl;
    //std::cerr << in2_ << std::endl;

    const SVG_FEBLEND_MODE& mode_ = GETVAL(Mode);
    switch (mode_) {
    case SVG_FEBLEND_MODE_NORMAL:
      break;
      
    case SVG_FEBLEND_MODE_MULTIPLY:
      glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
      std::cerr << "warning: 'multiply' mode for <feblend> not properly implemented " __FILE__":" << __LINE__ << std::endl;
      break;

    case SVG_FEBLEND_MODE_SCREEN:
      glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE);
      break;

    case SVG_FEBLEND_MODE_DARKEN:
    case SVG_FEBLEND_MODE_LIGHTEN:
    default:
      //std::cerr << "warning: '" << print_SVGFEBlendElement_SVG_FEBLEND_MODE(mode_) << "' mode for <feblend> not implemented " __FILE__":" << __LINE__ << std::endl;
      break;
    }
  }
예제 #9
0
  void
  SVGTextPathElement::buildBezier(svgl::Context * svglContext, svgl::GLInfo* glinfo, svgl::TextInfo* textinfo)
  {

    if(!_bezier) {
      unicode::String* ref = GETVAL(Href);
      SVGPathElement* path=0;
    
      if (ref) {
	dom::Element* de = svglContext->externalEntityManager->get(ref, getOwnerDocument());
	path = dynamic_cast<SVGPathElement*>(de);
      }
      if(!path)
	//std::cerr << "textPath " << ref << " " __FILE__ ":" << __LINE__ << std::endl;
	return;

      const SVGPathSegList& pl = path->GET_SIMPLE_VAL(PathSegList);
      if (pl.numberOfItems()<2)
	return;

      _bezier = new BezierPath;
      
      for(unsigned int i=0; i<pl.numberOfItems(); ++i) {
	const SVGPathSeg* p = pl.getItem(i);
	p->updateBezier(*_bezier);
      }
    }

    svg::SVGLength startOffsetl = GETVAL(StartOffset);

    float startOffset_ = 0;
    {
      float sav = svglContext->viewport_width;
      svglContext->viewport_width = svgl::length(*_bezier);
      startOffset_ = svglContext->computeWidthLength(startOffsetl);
      //std::cerr << DBGVAR(startOffsetl.getValueInSpecifiedUnits().getValue()) << DBGVAR(svglContext->viewport_width) << __FL__;
      svglContext->viewport_width = sav;
    }
    //std::cerr << DBGVAR(startOffset_) << __FL__;
    textinfo->distanceIterator= new svgl::BezierPathDistanceIterator(*_bezier);
    textinfo->distanceIterator->advance(startOffset_);
    textinfo->x = textinfo->distanceIterator->x /*+ textinfo->distanceIterator->dx*/;
    textinfo->y = textinfo->distanceIterator->y /*+ textinfo->distanceIterator->dy*/;

    //std::cerr << DBGVAR(startOffset_) << DBGVAR(textinfo->distanceIterator->x) << DBGVAR(textinfo->distanceIterator->y) << DBGVAR(textinfo->distanceIterator->dx) << DBGVAR(textinfo->distanceIterator->dy) << __FL__;
  }
예제 #10
0
 void
 SVGTransformable::glTraverse(svgl::Context * svglContext, svgl::GLInfo* glinfo) const
 {
   const SVGTransformList& transforms = GETVAL(Transform);
   for(unsigned int i=0; i<transforms.numberOfItems(); ++i) {
     transforms.getItem(i)->glTraverse(svglContext, glinfo);
   }
   
   //  std::cerr << "SVGTransformable::glTraverse() const" << std::endl;
   
 }
예제 #11
0
  SVGThirdTransform*
  SVGTransformable::getThird(bool create)
  {
    const SVGTransformList& transforms = GETVAL(Transform);
    unsigned int numTransform = transforms.numberOfItems();
    SVGThirdTransform * third = 0;
    if(!numTransform) {
      if(create) {
	third = new SVGThirdTransform;
	SVGTransformList& t = const_cast<SVGTransformList&>(transforms);
	t.appendItem(third);
      }
    }
    else {
      int i=numTransform-1;
      SVGTransform * transform = transforms.getItem(i);
      third = dynamic_cast<SVGThirdTransform*>(transform);
      if(!third) {
	SVGFirstTransform * first = dynamic_cast<SVGFirstTransform*>(transform);
	if(first) {
	  if ((i-1)>=0) {
	    --i;
	    SVGTransform * transform = transforms.getItem(i);
	    SVGSecondTransform * second = dynamic_cast<SVGSecondTransform*>(transform);
	    if(second) {
	      if ((i-1)>=0) {
		--i;
		SVGTransform * transform = transforms.getItem(i);
		third = dynamic_cast<SVGThirdTransform*>(transform);
	      }
	    } else {
	      ++i;
	    }
	  }
	}
	else {
	  ++i;
	}
      }
      if(!third) {
	if(create) {
	  third = new SVGThirdTransform;
	  SVGTransformList& t = const_cast<SVGTransformList&>(transforms);
	  t.insertItemBefore(third,i);
	}
      }
    }
    //std::cerr << transforms << __FL__;
    return third;
  }
예제 #12
0
  SVGFirstTransform *SVGTransformable::getFirst(bool create) {
		const SVGTransformList &transforms = GETVAL(Transform);
		unsigned int numTransform = transforms.numberOfItems();
		SVGFirstTransform *first = 0;
		
		// place to insert the transform in the list if create is set
		unsigned int place = numTransform;

		// if the transform list is not empty, the only possible place for the
		// first transform is #0 (starting from the end)
		if(numTransform > 0) {
			first = dynamic_cast< SVGFirstTransform * >(transforms.getItem(numTransform - 1));
		}

		// creating & inserting the transform if needed
		if((first == 0) && create) {
			first = new SVGFirstTransform();
			SVGTransformList &t = const_cast< SVGTransformList & >(transforms);
			t.insertItemBefore(first, place);
		}

		return first;
	}
예제 #13
0
PIFIMETRICS
APIENTRY
BmfdQueryFont(
    IN DHPDEV dhpdev,
    IN ULONG_PTR iFile,
    IN ULONG iFace,
    IN ULONG_PTR *pid)
{
    PBMFD_FILE pfile = (PBMFD_FILE)iFile;
    PBMFD_FACE pface;
    PFONTINFO16 pFontInfo;
    PIFIMETRICS pifi;
    PBMFD_IFIMETRICS pifiX;
    PANOSE panose = {0};

    DbgPrint("BmfdQueryFont()\n");
//    __debugbreak();

    /* Validate parameters */
    if (iFace > pfile->cNumFaces || !pid)
    {
        return NULL;
    }

    pface = &pfile->aface[iFace - 1];
    pFontInfo = pface->pFontInfo;

    /* Allocate the structure */
    pifiX = EngAllocMem(FL_ZERO_MEMORY, sizeof(BMFD_IFIMETRICS), TAG_IFIMETRICS);
    if (!pifiX)
    {
        return NULL;
    }

    /* Return a pointer to free it later */
    *pid = (ULONG_PTR)pifiX;

    /* Fill IFIMETRICS */
    pifi = &pifiX->ifim;
    pifi->cjThis = sizeof(BMFD_IFIMETRICS);
    pifi->cjIfiExtra = 0;
    pifi->dpwszFamilyName = FIELD_OFFSET(BMFD_IFIMETRICS, wszFamilyName);
    pifi->dpwszStyleName = FIELD_OFFSET(BMFD_IFIMETRICS, wszFamilyName);
    pifi->dpwszFaceName = FIELD_OFFSET(BMFD_IFIMETRICS, wszFaceName);
    pifi->dpwszUniqueName = FIELD_OFFSET(BMFD_IFIMETRICS, wszFaceName);
    pifi->dpFontSim = 0;
    pifi->lEmbedId = 0;
    pifi->lItalicAngle = 0;
    pifi->lCharBias = 0;
    pifi->dpCharSets = 0;
    pifi->jWinCharSet = pFontInfo->dfCharSet;
    pifi->jWinPitchAndFamily = pFontInfo->dfPitchAndFamily;
    pifi->usWinWeight = GETVAL(pFontInfo->dfWeight);
    pifi->flInfo = pface->flInfo;
    pifi->fsSelection = 0;
    pifi->fsType = 0;
    pifi->fwdUnitsPerEm = GETVAL(pFontInfo->dfPixHeight);
    pifi->fwdLowestPPEm = 0;
    pifi->fwdWinAscender = GETVAL(pFontInfo->dfAscent);
    pifi->fwdWinDescender = pifi->fwdUnitsPerEm - pifi->fwdWinAscender;
    pifi->fwdMacAscender = pifi->fwdWinAscender;
    pifi->fwdMacDescender = - pifi->fwdWinDescender;
    pifi->fwdMacLineGap = 0;
    pifi->fwdTypoAscender = pifi->fwdWinAscender;
    pifi->fwdTypoDescender = - pifi->fwdWinDescender;
    pifi->fwdTypoLineGap = 0;
    pifi->fwdAveCharWidth = GETVAL(pFontInfo->dfAvgWidth);
    pifi->fwdMaxCharInc =  GETVAL(pFontInfo->dfMaxWidth);
    pifi->fwdCapHeight = pifi->fwdUnitsPerEm / 2;
    pifi->fwdXHeight = pifi->fwdUnitsPerEm / 4;
    pifi->fwdSubscriptXSize = 0;
    pifi->fwdSubscriptYSize = 0;
    pifi->fwdSubscriptXOffset = 0;
    pifi->fwdSubscriptYOffset = 0;
    pifi->fwdSuperscriptXSize = 0;
    pifi->fwdSuperscriptYSize = 0;
    pifi->fwdSuperscriptXOffset = 0;
    pifi->fwdSuperscriptYOffset = 0;
    pifi->fwdUnderscoreSize = 01;
    pifi->fwdUnderscorePosition = -1;
    pifi->fwdStrikeoutSize = 1;
    pifi->fwdStrikeoutPosition = pifi->fwdXHeight + 1;
    pifi->chFirstChar = pFontInfo->dfFirstChar;
    pifi->chLastChar = pFontInfo->dfLastChar;
    pifi->chDefaultChar = pFontInfo->dfFirstChar + pFontInfo->dfDefaultChar;
    pifi->chBreakChar = pFontInfo->dfFirstChar + pFontInfo->dfBreakChar;
    pifi->wcFirstChar = pface->wcFirstChar;
    pifi->wcLastChar = pface->wcLastChar;
    pifi->wcDefaultChar = pface->wcDefaultChar;
    pifi->wcBreakChar = pface->wcBreakChar;
    pifi->ptlBaseline.x = 1;
    pifi->ptlBaseline.y = 0;
    pifi->ptlAspect.x = pFontInfo->dfVertRes; // CHECKME
    pifi->ptlAspect.y = pFontInfo->dfHorizRes;
    pifi->ptlCaret.x = 0;
    pifi->ptlCaret.y = 1;
    pifi->rclFontBox.left = 0;
    pifi->rclFontBox.right = pifi->fwdAveCharWidth;
    pifi->rclFontBox.top = pifi->fwdWinAscender;
    pifi->rclFontBox.bottom = - pifi->fwdWinDescender;
    *(DWORD*)&pifi->achVendId = 0x30303030; // FIXME
    pifi->cKerningPairs = 0;
    pifi->ulPanoseCulture = FM_PANOSE_CULTURE_LATIN;
    pifi->panose = panose;

    /* Set char sets */
    pifiX->ajCharSet[0] = pifi->jWinCharSet;
    pifiX->ajCharSet[1] = DEFAULT_CHARSET;

    if (pface->flInfo & FM_INFO_CONSTANT_WIDTH)
        pifi->jWinPitchAndFamily |= FIXED_PITCH;

#if 0
    EngMultiByteToUnicodeN(pifiX->wszFaceName,
                           LF_FACESIZE * sizeof(WCHAR),
                           NULL,
                           pFontInfo->,
                           strnlen(pDesc, LF_FACESIZE));
#endif
    wcscpy(pifiX->wszFaceName, L"Courier-X");
    wcscpy(pifiX->wszFamilyName, L"Courier-X");

    /* Initialize font weight style flags and string */
    if (pifi->usWinWeight == FW_REGULAR)
    {
   //     pifi->fsSelection |= FM_SEL_REGULAR;
    }
    else if (pifi->usWinWeight > FW_SEMIBOLD)
    {
        pifi->fsSelection |= FM_SEL_BOLD;
        wcscat(pifiX->wszStyleName, L"Bold ");
    }
    else if (pifi->usWinWeight <= FW_LIGHT)
    {
        wcscat(pifiX->wszStyleName, L"Light ");
    }

    if (pFontInfo->dfItalic)
    {
        pifi->fsSelection |= FM_SEL_ITALIC;
        wcscat(pifiX->wszStyleName, L"Italic ");
    }

    if (pFontInfo->dfUnderline)
    {
        pifi->fsSelection |= FM_SEL_UNDERSCORE;
        wcscat(pifiX->wszStyleName, L"Underscore ");
    }

    if (pFontInfo->dfStrikeOut)
    {
        pifi->fsSelection |= FM_SEL_STRIKEOUT;
        wcscat(pifiX->wszStyleName, L"Strikeout ");
    }

    return pifi;
}
 unicode::String *
 SVGFESpecularLightingElement::getOptionalResult()
 {
   return GETVAL(Result);
 }
예제 #15
0
/*
==================
G_InitWorldSession
==================
*/
void G_InitWorldSession(void)
{
    char s[MAX_STRING_CHARS];
    int  gt;
    int  i, j;

    trap_Cvar_VariableStringBuffer("session", s, sizeof(s));
    gt = atoi(s);

    // if the gametype changed since the last session, don't use any
    // client sessions
    if (g_gametype.integer != gt)
    {
        level.fResetStats = qtrue;
        G_Printf("Gametype changed, clearing session data.\n");

	}
    else
    {
        char     *tmp = s;
        qboolean test = (g_altStopwatchMode.integer != 0 || g_currentRound.integer == 1);


#define GETVAL(x) if ((tmp = strchr(tmp, ' ')) == NULL) { return; \
} x = atoi(++tmp);

        // Get team lock stuff
        GETVAL(gt);
        teamInfo[TEAM_AXIS].spec_lock = (gt & TEAM_AXIS) ? qtrue : qfalse;
        teamInfo[TEAM_ALLIES].spec_lock = (gt & TEAM_ALLIES) ? qtrue : qfalse;

        // See if we need to clear player stats
        // FIXME: deal with the multi-map missions
        if (g_gametype.integer != GT_WOLF_CAMPAIGN)
        {
            if ((tmp = strchr(va("%s", tmp), ' ')) != NULL)
            {
                tmp++;
                trap_GetServerinfo(s, sizeof(s));
                if (Q_stricmp(tmp, Info_ValueForKey(s, "mapname")))
                {
                    level.fResetStats = qtrue;
                    G_Printf("Map changed, clearing player stats.\n");
				}
			}
		}

        // have to make sure spec locks follow the right teams
        if (g_gametype.integer == GT_WOLF_STOPWATCH && g_gamestate.integer != GS_PLAYING && test)
        {
            G_swapTeamLocks();
		}

        if (g_swapteams.integer)
        {
            G_swapTeamLocks();
		}
	}

    for (i = 0; i < MAX_FIRETEAMS; i++)
    {
        char *p, *c;

        trap_Cvar_VariableStringBuffer(va("fireteam%i", i), s, sizeof(s));

/*		p = Info_ValueForKey( s, "n" );

        if(p && *p) {
            Q_strncpyz( level.fireTeams[i].name, p, 32 );
            level.fireTeams[i].inuse = qtrue;
        } else {
            *level.fireTeams[i].name = '\0';
            level.fireTeams[i].inuse = qfalse;
        }*/

        p = Info_ValueForKey(s, "id");
        j = atoi(p);
        if (!*p || j == -1)
        {
            level.fireTeams[i].inuse = qfalse;
		}
        else
        {
            level.fireTeams[i].inuse = qtrue;
		}
        level.fireTeams[i].ident = j + 1;

        p = Info_ValueForKey(s, "p");
        level.fireTeams[i].priv = !atoi(p) ? qfalse : qtrue;

        p = Info_ValueForKey(s, "i");

        j = 0;
        if (p && *p)
        {
            c = p;
            for (c = strchr(c, ' ') + 1; c && *c; )
            {
                char str[8];
                char *l = strchr(c, ' ');

                if (!l)
                {
                    break;
				}
                Q_strncpyz(str, c, l - c + 1);
                str[l - c] = '\0';
                level.fireTeams[i].joinOrder[j++] = atoi(str);
                c = l + 1;
			}
		}

        for ( ; j < MAX_CLIENTS; j++)
        {
            level.fireTeams[i].joinOrder[j] = -1;
		}
        G_UpdateFireteamConfigString(&level.fireTeams[i]);
	}
}
예제 #16
0
 unicode::String *
 SVGFEBlendElement::getOptionalResult()
 {
   return GETVAL(Result);
 }
예제 #17
0
 unicode::String *
 SVGFEBlendElement::getOptionalIn2()
 {
   return GETVAL(In2);
 }
예제 #18
0
/* Note that AC power sources also include a laptop battery it is charging. */
static void
checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery,
        SDL_bool * charging, int *seconds, int *percent)
{
    CFStringRef strval;         /* don't CFRelease() this. */
    CFBooleanRef bval;
    CFNumberRef numval;
    SDL_bool charge = SDL_FALSE;
    SDL_bool choose = SDL_FALSE;
    SDL_bool is_ac = SDL_FALSE;
    int secs = -1;
    int maxpct = -1;
    int pct = -1;

    if ((GETVAL(kIOPSIsPresentKey, &bval)) && (bval == kCFBooleanFalse)) {
        return;                 /* nothing to see here. */
    }

    if (!GETVAL(kIOPSPowerSourceStateKey, &strval)) {
        return;
    }

    if (STRMATCH(strval, CFSTR(kIOPSACPowerValue))) {
        is_ac = *have_ac = SDL_TRUE;
    } else if (!STRMATCH(strval, CFSTR(kIOPSBatteryPowerValue))) {
        return;                 /* not a battery? */
    }

    if ((GETVAL(kIOPSIsChargingKey, &bval)) && (bval == kCFBooleanTrue)) {
        charge = SDL_TRUE;
    }

    if (GETVAL(kIOPSMaxCapacityKey, &numval)) {
        SInt32 val = -1;
        CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
        if (val > 0) {
            *have_battery = SDL_TRUE;
            maxpct = (int) val;
        }
    }

    if (GETVAL(kIOPSMaxCapacityKey, &numval)) {
        SInt32 val = -1;
        CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
        if (val > 0) {
            *have_battery = SDL_TRUE;
            maxpct = (int) val;
        }
    }

    if (GETVAL(kIOPSTimeToEmptyKey, &numval)) {
        SInt32 val = -1;
        CFNumberGetValue(numval, kCFNumberSInt32Type, &val);

        /* Mac OS X reports 0 minutes until empty if you're plugged in. :( */
        if ((val == 0) && (is_ac)) {
            val = -1;           /* !!! FIXME: calc from timeToFull and capacity? */
        }

        secs = (int) val;
        if (secs > 0) {
            secs *= 60;         /* value is in minutes, so convert to seconds. */
        }
    }

    if (GETVAL(kIOPSCurrentCapacityKey, &numval)) {
        SInt32 val = -1;
        CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
        pct = (int) val;
    }

    if ((pct > 0) && (maxpct > 0)) {
        pct = (int) ((((double) pct) / ((double) maxpct)) * 100.0);
    }

    if (pct > 100) {
        pct = 100;
    }

    /*
     * We pick the battery that claims to have the most minutes left.
     *  (failing a report of minutes, we'll take the highest percent.)
     */
    if ((secs < 0) && (*seconds < 0)) {
        if ((pct < 0) && (*percent < 0)) {
            choose = SDL_TRUE;  /* at least we know there's a battery. */
        }
        if (pct > *percent) {
            choose = SDL_TRUE;
        }
    } else if (secs > *seconds) {
        choose = SDL_TRUE;
    }

    if (choose) {
        *seconds = secs;
        *percent = pct;
        *charging = charge;
    }
}
예제 #19
0
static
PVOID
ParseFonFile(
    PVOID pvView,
    ULONG cjView)
{
    PIMAGE_DOS_HEADER pDosHeader = pvView;
    PIMAGE_OS2_HEADER pOs2Header;
    PNE_RESTABLE pResTable;
    PNE_TYPEINFO pTInfo;
    PFONTINFO16 pFontInfo;
    PCHAR pStart, pEnd;
    PBMFD_FILE pfile = NULL;
    WORD wShift;
    ULONG i, cjOffset, cjLength;
    ULONG type_id, count;

    /* Initial margins for valid pointers */
    pStart = pvView;
    pEnd = pStart + cjView;

    /* Check for image dos header */
    if (GETVAL(pDosHeader->e_magic) != IMAGE_DOS_MAGIC)
    {
        return NULL;
    }

    /* Get pointer to OS2 header and veryfy it is valid */
    pOs2Header = (PVOID)((PCHAR)pDosHeader + GETVAL(pDosHeader->e_lfanew));
    pStart += sizeof(IMAGE_DOS_HEADER);
    if (!IsValidPtr(pOs2Header, sizeof(IMAGE_OS2_HEADER), pStart, pEnd, 4))
    {
        DbgPrint("e_lfanew is invalid: 0x%lx\n", pDosHeader->e_lfanew);
        return NULL;
    }

    /* Get pointer to resource table and verify it is valid */
    pResTable = (PVOID)((PCHAR)pOs2Header + GETVAL(pOs2Header->ne_rsrctab));
    pStart = (PCHAR)pOs2Header;
    if (!IsValidPtr(pResTable, sizeof(NE_RESTABLE), pStart, pEnd, 1))
    {
        DbgPrint("pTInfo is invalid: 0x%p\n", pResTable);
        return NULL;
    }

    wShift = GETVAL(pResTable->size_shift);
    pTInfo = pResTable->typeinfo;
    type_id = GETVAL(pTInfo->type_id);

    /* Loop the resource table to find a font resource */
    while (type_id)
    {
        /* Get number of nameinfo entries */
        count = GETVAL(pTInfo->count);

        /* Look for a font resource */
        if (type_id == NE_RSCTYPE_FONT && count > 0)
        {
            DbgPrint("Found NE_RSCTYPE_FONT\n");

            /* Allocate an info structure for this font and all faces */
            cjLength = sizeof(BMFD_FILE) + (count-1) * sizeof(BMFD_FACE);
            pfile = EngAllocMem(0, cjLength, TAG_FONTINFO);
            if (!pfile)
            {
                DbgPrint("Not enough memory: %ld\n", cjLength);
                return NULL;
            }

            pfile->cNumFaces = count;

            /* Fill all face info structures */
            for (i = 0; i < count; i++)
            {
                cjOffset = GETVAL(pTInfo->nameinfo[i].offset) << wShift;
                cjLength = GETVAL(pTInfo->nameinfo[i].length) << wShift;
                pFontInfo = (PVOID)((PCHAR)pDosHeader + cjOffset);

                if (!IsValidPtr(pFontInfo, cjLength, pStart, pEnd, 1))
                {
                    DbgPrint("pFontInfo is invalid: 0x%p\n", pFontInfo);
                    EngFreeMem(pfile);
                    return NULL;
                }

                /* Validate FONTINFO and fill face info */
                if (!FillFaceInfo(&pfile->aface[i], pFontInfo))
                {
                    DbgPrint("pFontInfo is invalid: 0x%p\n", pFontInfo);
                    EngFreeMem(pfile);
                    return NULL;
                }
            }

            /* Break out of the loop */
            break;
        }

        /* Following pointers must be bigger than this */
        pStart = (PCHAR)pTInfo;

        /* Goto next entry in resource table */
        pTInfo = (PVOID)&pTInfo->nameinfo[count];

        /* Verify that the new pTInfo pointer is valid */
        if (!IsValidPtr(pTInfo, sizeof(NE_TYPEINFO), pStart, pEnd, 1))
        {
            DbgPrint("pTInfo is invalid: 0x%p\n", pTInfo);
            return NULL;
        }

        type_id = GETVAL(pTInfo->type_id);
    }

    return pfile;
}
예제 #20
0
static
BOOL
FillFaceInfo(
    PBMFD_FACE pface,
    PFONTINFO16 pFontInfo)
{
    CHAR ansi[4];
    WCHAR unicode[4];
    ULONG written;
    DWORD dfFlags;

    pface->pFontInfo = pFontInfo;
    pface->ulVersion = GETVAL(pFontInfo->dfVersion);
    pface->cGlyphs = pFontInfo->dfLastChar - pFontInfo->dfFirstChar + 1;

    /* Convert chars to unicode */
    ansi[0] = pFontInfo->dfFirstChar;
    ansi[1] = pFontInfo->dfLastChar;
    ansi[2] = pFontInfo->dfFirstChar + pFontInfo->dfDefaultChar;
    ansi[3] = pFontInfo->dfFirstChar + pFontInfo->dfBreakChar;
    EngMultiByteToUnicodeN(unicode, 4 * sizeof(WCHAR), &written, ansi, 4);
    pface->wcFirstChar = unicode[0];
    pface->wcLastChar = unicode[1];
    pface->wcDefaultChar = unicode[2];
    pface->wcBreakChar = unicode[3];

    /* Copy some values */
    pface->wPixHeight = GETVAL(pFontInfo->dfPixHeight);
    pface->wPixWidth = GETVAL(pFontInfo->dfPixWidth);
    pface->wWidthBytes = GETVAL(pFontInfo->dfWidthBytes);
    pface->wAscent = GETVAL(pFontInfo->dfAscent);
    pface->wDescent = pface->wPixHeight - pface->wAscent;

    /* Some version specific members */
    if (pface->ulVersion >= 0x300)
    {
        dfFlags = GETVAL(pFontInfo->dfFlags);
        pface->wA = GETVAL(pFontInfo->dfAspace);
        pface->wB = GETVAL(pFontInfo->dfBspace);
        pface->wC = GETVAL(pFontInfo->dfCspace);
        pface->pCharTable = pface->pFontInfo->dfCharTable;
        pface->cjEntrySize = sizeof(GLYPHENTRY30);
    }
    else
    {
        dfFlags = DFF_1COLOR;
        pface->wA = 0;
        pface->wB = 0;
        pface->wC = 0;
        pface->pCharTable = &pface->pFontInfo->dfReserved + 1;
        pface->cjEntrySize = sizeof(GLYPHENTRY20);
    }

    pface->flInfo = FM_INFO_MASK;

    /* If dfWidth is non-null, we have a fixed width font */
    if (dfFlags & DFF_FIXED || pface->wPixWidth)
        pface->flInfo |= FM_INFO_CONSTANT_WIDTH;

    /* Initialize color depth flags */
    if (dfFlags & DFF_1COLOR)
        pface->flInfo |= FM_INFO_1BPP;
    else if (dfFlags & DFF_16COLOR)
        pface->flInfo |= FM_INFO_4BPP;
    else if (dfFlags & DFF_256COLOR)
        pface->flInfo |= FM_INFO_8BPP;
    else if (dfFlags & DFF_RGBCOLOR)
        pface->flInfo |= FM_INFO_24BPP;

    // TODO: walk through all glyphs and veryfy them and calculate max values

    // FIXME: After this point, the whole font data should be verified!

    return TRUE;
}
 unicode::String *
 SVGFESpecularLightingElement::getOptionalIn1()
 {
   unicode::String * in1 = GETVAL(In1);
   return in1;
 }