Ejemplo n.º 1
0
void liBlendScreen(color *buffer, color *layer, real32 opacity, sdword nPixels)
{
    real32 redSource, greenSource, blueSource, alpha;
    real32 redDest, greenDest, blueDest;//, alphaDest;
    real32 oneMinusAlpha;

    while (nPixels > 0)
    {
        alpha = colUbyteToReal(colAlpha(*layer)) * opacity;
        oneMinusAlpha = 1.0f - alpha;
        redSource = colUbyteToReal(colRed(*layer));    //read pixel to floating point
        greenSource = colUbyteToReal(colGreen(*layer));
        blueSource = colUbyteToReal(colBlue(*layer));
        redDest = colUbyteToReal(colRed(*buffer));
        greenDest = colUbyteToReal(colGreen(*buffer));
        blueDest = colUbyteToReal(colBlue(*buffer));

        redDest = (1.0f - (1.0f - redDest) * (1.0f - redSource)) * alpha + redDest * oneMinusAlpha;
        greenDest = (1.0f - (1.0f - greenDest) * (1.0f - greenSource)) * alpha + greenDest * oneMinusAlpha;
        blueDest = (1.0f - (1.0f - blueDest) * (1.0f - blueSource)) * alpha + blueDest * oneMinusAlpha;
        redDest = min(redDest, 1.0f);
        greenDest = min(greenDest, 1.0f);
        blueDest = min(blueDest, 1.0f);
        *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest),
                         colRealToUbyte(blueDest));
        buffer++;
        layer++;
        nPixels--;
    }
}
Ejemplo n.º 2
0
/*-----------------------------------------------------------------------------
    Name        : teColorAdjust
    Description : Adjust a color according to a HLS colorizing table.
    Inputs      : baseColor - origional color
                  colorize - HLS parameters to adjust by.
    Outputs     :
    Return      : newly adjusted color
----------------------------------------------------------------------------*/
color teColorAdjust(color baseColor, trhlscolorize *colorize)
{
    real32 red, green, blue, hue, lum, sat;
    colRGBToHLS(&hue, &lum, &sat, colUbyteToReal(colRed(baseColor)),
                colUbyteToReal(colGreen(baseColor)),
                colUbyteToReal(colBlue(baseColor)));
    hue += colorize->hue;
    if (hue < 0)
    {
        hue += 1.0f;
    }
    if (hue > 1.0f)
    {
        hue -= 1.0f;
    }
    lum *= colorize->lum;
    sat *= colorize->sat;
    if (lum > 1.0f)
    {
        lum = 1.0f;
    }
    if (sat > 1.0f)
    {
        sat = 1.0f;
    }
    colHLSToRGB(&red, &green, &blue, hue, lum, sat);
    return(colRGB(colRealToUbyte(red), colRealToUbyte(green), colRealToUbyte(blue)));
}
Ejemplo n.º 3
0
/*-----------------------------------------------------------------------------
    Name        : tmNumberRUsDraw
    Description : Callback to draw number of RU's available
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void tmNumberRUsDraw(featom *atom, regionhandle region)
{
    sdword width;
    fonthandle oldfont;
    rectangle rect = region->rect;
    tmNumberRUsRegion = region;

    oldfont = fontMakeCurrent(tmTechListFont);
    width = fontWidthf("%d", universe.curPlayerPtr->resourceUnits);//width of number

    primModeSet2();
    primRectSolid2(&rect, colRGB(0, 0, 0));

    glEnable(GL_SCISSOR_TEST);
    glScissor(rect.x0, MAIN_WindowHeight - rect.y1, rect.x1 - rect.x0, rect.y1 - rect.y0);
    glClear(GL_DEPTH_BUFFER_BIT);
    glDisable(GL_SCISSOR_TEST);

    feStaticRectangleDraw(region);                          //draw regular rectangle as backdrop
    fontPrintf(region->rect.x1 - width - TM_RUMarginRight,
               (region->rect.y1 - region->rect.y0 - fontHeight(NULL)) / 2 + region->rect.y0,
               atom->borderColor, "%d", universe.curPlayerPtr->resourceUnits);

    fontMakeCurrent(oldfont);
}
Ejemplo n.º 4
0
void hrDrawChatBox(featom *atom, regionhandle region)
{
    fonthandle currentfont;
    sdword     x,y,i;
    char       name[128];

    hrChatBoxRegion = region;

    currentfont = fontMakeCurrent(playernamefont);

    primRectSolid2(&region->rect,colRGB(0,0,0));
    feStaticRectangleDraw(region);

    x = region->rect.x0+10;
    y = region->rect.y0;

    for (i=0;i<NUM_CHAT_LINES;i++)
    {
        if (chathistory[i].message[0]!=0)
        {
            x = region->rect.x0;
            sprintf(name,"%s >",tpGameCreated.playerInfo[chathistory[i].packetheader.frame].PersonalName);
            fontPrintf(x,y,tpGameCreated.playerInfo[chathistory[i].packetheader.frame].baseColor,"%s",name);
            x+=fontWidth(name)+10;
            //fontShadowSet(FS_E | FS_SE | FS_S);
            fontPrintf(x,y,hrChatTextColor,"%s",chathistory[i].message);
            //fontShadowSet(FS_NONE);
            y+= fontHeight(" ");
        }
    }

    fontMakeCurrent(currentfont);
}
Ejemplo n.º 5
0
void liBlendOverlay(color *buffer, color *layer, real32 opacity, sdword nPixels)
{
    real32 redSource, greenSource, blueSource, alpha;
    real32 redDest, greenDest, blueDest;//, alphaDest;
    real32 oneMinusAlpha;
    real32 redTemp, greenTemp, blueTemp;

    while (nPixels > 0)
    {
        alpha = colUbyteToReal(colAlpha(*layer)) * opacity;
        oneMinusAlpha = 1.0f - alpha;
        redSource = colUbyteToReal(colRed(*layer));    //read pixel to floating point
        greenSource = colUbyteToReal(colGreen(*layer));
        blueSource = colUbyteToReal(colBlue(*layer));
        redDest = colUbyteToReal(colRed(*buffer));
        greenDest = colUbyteToReal(colGreen(*buffer));
        blueDest = colUbyteToReal(colBlue(*buffer));
        if (redDest < 0.5f)
        {
            redTemp = (2.0f * redSource * 2.0f * redDest) / 2.0f;
        }
        else
        {
            redTemp = 1.0f - ((2.0f * (1.0f - redSource)) * (2.0f * (1.0f - redDest)) / 2.0f);
        }
        if (greenDest < 0.5f)
        {
            greenTemp = (2.0f * greenSource * 2.0f * greenDest) / 2.0f;
        }
        else
        {
            greenTemp = 1.0f - ((2.0f * (1.0f - greenSource)) * (2.0f * (1.0f - greenDest)) / 2.0f);
        }
        if (blueDest < 0.5f)
        {
            blueTemp = (2.0f * blueSource * 2.0f * blueDest) / 2.0f;
        }
        else
        {
            blueTemp = 1.0f - ((2.0f * (1.0f - blueSource)) * (2.0f * (1.0f - blueDest)) / 2.0f);
        }
        redDest = redTemp * alpha + redDest * oneMinusAlpha;
        greenDest = greenTemp * alpha + greenDest * oneMinusAlpha;
        blueDest = blueTemp * alpha + blueDest * oneMinusAlpha;
        redDest = min(redDest, 1.0f);
        greenDest = min(greenDest, 1.0f);
        blueDest = min(blueDest, 1.0f);
        *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest),
                         colRealToUbyte(blueDest));
        buffer++;
        layer++;
        nPixels--;
    }
}
Ejemplo n.º 6
0
/*=============================================================================
    Script-parsing functions:
=============================================================================*/
void teTrailColorSet(char *directory,char *field,void *dataToFillIn)
{
    sdword iPlayer, iPoint, red, green, blue, nScanned;

    nScanned = sscanf(field, "%d,%d,%d,%d,%d", &iPlayer, &iPoint, &red, &green, &blue);
    dbgAssert(nScanned == 5);
    dbgAssert(iPlayer >= 0 && iPlayer < TE_NumberPlayers);
    dbgAssert(iPoint >= 0 && iPoint < TE_NumberTrailColors);
    dbgAssert(red >= 0 && red < 256);
    dbgAssert(green >= 0 && green < 256);
    dbgAssert(blue >= 0 && blue < 256);
    teColorSchemes[iPlayer].trailColors[iPoint] = colRGB(red, green, blue);
}
Ejemplo n.º 7
0
/*-----------------------------------------------------------------------------
    Name        : teColorSet
    Description : Set a color for a particular color scheme structure.
    Inputs      : script callback
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void teColorSet(char *directory,char *field,void *dataToFillIn)
{
    sdword iPlayer, red, green, blue, nScanned;
    color *dest;

    nScanned = sscanf(field, "%d,%d,%d,%d", &iPlayer, &red, &green, &blue);
    dbgAssert(nScanned == 4);
    dbgAssert(iPlayer >= 0 && iPlayer < TE_NumberPlayers);
    dbgAssert(red >= 0 && red < 256);
    dbgAssert(green >= 0 && green < 256);
    dbgAssert(blue >= 0 && blue < 256);
    dest = (color *)(((ubyte*)(&teColorSchemes[iPlayer])) +
                      (udword)dataToFillIn - (udword)(&teColorSchemes));
//    teColorSchemes[iPlayer].tacticalColor = colRGB(red, green, blue);
    *dest = colRGB(red, green, blue);
}
Ejemplo n.º 8
0
void teTeamColorsSet(sdword iTeam, color baseColor, color stripeColor)
{
    sdword index;
    real32 red, green, blue, hue, sat, val;

    dbgAssert(iTeam >= 0 && iTeam < TE_NumberPlayers);

    if (multiPlayerGame)
    {                                                       //if somebody in a multiplayer game
        red = colUbyteToReal(colRed(baseColor));
        green = colUbyteToReal(colGreen(baseColor));
        blue = colUbyteToReal(colBlue(baseColor));
        colRGBToHSV(&hue, &sat, &val, red, green, blue);
        if (colRealToUbyte(val) < cpDarkestColor0 * TE_DarkColorGraceFactor)
        {                                                   //is trying to set his ships to black
            baseColor = TE_DorkyCheaterBaseColor;
            stripeColor = TE_DorkyCheaterStripeColor;
        }
    }
    teColorSchemes[iTeam].textureColor.base = baseColor;
    teColorSchemes[iTeam].textureColor.detail = stripeColor;

#if !TO_STANDARD_COLORS
    teColorSchemes[iTeam].tacticalColor =
        teColorAdjust(baseColor, &teTacticalColorize);
#endif
    for (index = 0; index < TE_NumberTrailColors; index++)
    {
        teColorSchemes[iTeam].trailColors[index] =
            teColorAdjust(baseColor, &teTrailColorize[index]);
    }
    for (iTeam = 0; iTeam < TE_NumberPlayers; iTeam++)
    {
        teColorSchemes[iTeam].ambient = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536));
        teColorSchemes[iTeam].diffuse = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536));
        teColorSchemes[iTeam].specular = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536));
        teColorSchemes[iTeam].stripeAmbient = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536));
        teColorSchemes[iTeam].stripeDiffuse = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536));
        teColorSchemes[iTeam].stripeSpecular = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536));
    }
}
Ejemplo n.º 9
0
void GUILevelPathing::Render(float elapsedTime, const RenderInfo& info)
{
    //Overlay a color onto each room based on its proximity to each team.
    for (unsigned int i = 0; i < editor.LevelData.Rooms.size(); ++i)
    {
        const LevelInfo::RoomData& room = editor.LevelData.Rooms[i];

        Vector2f worldCenter = ToV2f(room.MinCornerPos) + (ToV2f(room.Walls.GetDimensions()) * 0.5f);
        SetBounds(Box2D(editor.WorldPosToScreen(worldCenter),
                        editor.WorldSizeToScreen(ToV2f(room.Walls.GetDimensions()))));

        Vector3f colRGB((COLOR_Team1 * (1.0f - powf(roomNormalizedDistsToTeamBases[i][0], COLOR_Exponent))) +
                        (COLOR_Team2 * (1.0f - powf(roomNormalizedDistsToTeamBases[i][1], COLOR_Exponent))));
        SetColor(Vector4f(colRGB, ALPHA_Team));

        GUITexture::Render(elapsedTime, info);
    }
}
Ejemplo n.º 10
0
//This one not a perfect copy, but pretty close
void liBlendColor(color *buffer, color *layer, real32 opacity, sdword nPixels)
{
    real32 redSource, greenSource, blueSource, alpha;
    real32 redDest, greenDest, blueDest;//, alphaDest;
    real32 oneMinusAlpha;
    real32 hueS, satS, hueD, satD, lumS, lumD;
    real32 clumD, clumS;
    real32 redTemp, greenTemp, blueTemp;

#if LI_VERBOSE_LEVEL >= 2
    dbgMessagef("\nColor: Blending mode not implemented perfectly.");
#endif

    while (nPixels > 0)
    {
        alpha = colUbyteToReal(colAlpha(*layer)) * opacity;
        oneMinusAlpha = 1.0f - alpha;
        redSource = colUbyteToReal(colRed(*layer));    //read pixel to floating point
        greenSource = colUbyteToReal(colGreen(*layer));
        blueSource = colUbyteToReal(colBlue(*layer));
        redDest = colUbyteToReal(colRed(*buffer));
        greenDest = colUbyteToReal(colGreen(*buffer));
        blueDest = colUbyteToReal(colBlue(*buffer));
        clumS = (redSource * LI_RedGamma + greenSource * LI_GreenGamma + blueSource * LI_BlueGamma) / LI_TotalGamma;
        clumD = (redDest * LI_RedGamma + greenDest * LI_GreenGamma + blueDest * LI_BlueGamma) / LI_TotalGamma;

        colRGBToHLS(&hueS, &lumS, &satS, redSource, greenSource, blueSource);
        colRGBToHLS(&hueD, &lumD, &satD, redDest, greenDest, blueDest);
        colHLSToRGB(&redTemp, &greenTemp, &blueTemp, hueS, clumD, satS);

        redDest = redTemp * alpha + redDest * oneMinusAlpha;
        greenDest = greenTemp * alpha + greenDest * oneMinusAlpha;
        blueDest = blueTemp * alpha + blueDest * oneMinusAlpha;
        redDest = min(redDest, 1.0f);
        greenDest = min(greenDest, 1.0f);
        blueDest = min(blueDest, 1.0f);

        *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest),
                         colRealToUbyte(blueDest));
        buffer++;
        layer++;
        nPixels--;
    }
}
Ejemplo n.º 11
0
/*-----------------------------------------------------------------------------
    Name        : colMultiplyClamped
    Description : multiply a color by a floating-point factor clamping to prevent overflow
    Inputs      :
    Outputs     :
    Return      : multiplied color
----------------------------------------------------------------------------*/
color colMultiplyClamped(color c, real32 factor)
{
    udword red, green, blue;
    udword intFactor;

    if (factor < 0.0f)
    {
        intFactor = 0;
    }
    else if (factor > 1.0f)
    {
        intFactor = 255;
    }
    else
    {
        intFactor = (udword)(factor * 255.0f);
    }
    red = (colRed(c) * intFactor) >> 8;
    green = (colGreen(c) * intFactor) >> 8;
    blue = (colBlue(c) * intFactor) >> 8;
    return(colRGB(red, green, blue));
}
Ejemplo n.º 12
0
/*-----------------------------------------------------------------------------
    Name        : Make3dStar
    Description : Makes a 3d-star with random position, color, and brightness
    Inputs      : innerlimit, outerlimit (distances from origin)
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void Make3dStar(Star3d *star,real32 innerlimit,real32 outerlimit)
{
    real32 distance = frandyrandombetween(0,innerlimit,outerlimit);
    real32 rotaboutx = frandyrandom(0,2*PI);
    real32 rotabouty = frandyrandom(0,2*PI);
    real32 rotaboutz = frandyrandom(0,2*PI);
    matrix rotxmat;
    matrix rotymat;
    matrix rotzmat;
    vector position1 = { 0.0f,0.0f,0.0f };
    vector position2;
    udword colorComponent, red, green, blue;

    position1.z = distance;

    matMakeRotAboutX(&rotxmat,(real32)cos(rotaboutx),(real32)sin(rotaboutx));
    matMakeRotAboutY(&rotymat,(real32)cos(rotabouty),(real32)sin(rotabouty));
    matMakeRotAboutZ(&rotzmat,(real32)cos(rotaboutz),(real32)sin(rotaboutz));

    matMultiplyMatByVec(&position2,&rotxmat,&position1);
    matMultiplyMatByVec(&position1,&rotymat,&position2);
    matMultiplyMatByVec(&star->position,&rotzmat,&position1);

    star->brightness = frandyrandom(0,1.0f);

    //compute star color with an random intensity and random variance
    colorComponent = randyrandom(0,starMaxColor - starMinColor) + starMinColor;
    red = colorComponent + randyrandom(0,starRedVariance * 2) - starRedVariance;
    red = min(255, max(0, red));
    green = colorComponent + randyrandom(0,starGreenVariance * 2) - starGreenVariance;
    green = min(255, max(0, green));
    blue = colorComponent + randyrandom(0,starBlueVariance * 2) - starBlueVariance;
    blue = min(255, max(0, blue));
    star->c = colRGB(red, green, blue);
    star->r = (ubyte)red;
    star->g = (ubyte)green;
    star->b = (ubyte)blue;
}
Ejemplo n.º 13
0
/*-----------------------------------------------------------------------------
    Name        : RenderNAVLights
    Description : TODO: render sorted by projected depth value so alpha sorts correctly
    Inputs      : ship - the ship whose navlights we are to render
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void RenderNAVLights(Ship *ship)
{
   sdword i;
   NAVLight *navLight;
   NAVLightInfo *navLightInfo;
   ShipStaticInfo *shipStaticInfo;
   NAVLightStatic *navLightStatic;
   vector origin = {0.0f, 0.0f, 0.0f};
   NAVLightStaticInfo *navLightStaticInfo;
   real32 fade;
   bool lightOn;
   extern bool bFade;
   extern real32 meshFadeAlpha;

   fade = bFade ? meshFadeAlpha : 1.0f;

   shipStaticInfo = (ShipStaticInfo *)ship->staticinfo;

    navLightInfo = ship->navLightInfo;
   if(shipStaticInfo->navlightStaticInfo && navLightInfo != NULL)
   {
      glDepthMask(GL_FALSE);
      rndAdditiveBlends(TRUE);
      lightOn = rndLightingEnable(FALSE);

      navLightStaticInfo = shipStaticInfo->navlightStaticInfo;
      navLightStatic = navLightStaticInfo->navlightstatics;
      navLight = navLightInfo->navLights;

      for( i=0 ; i<navLightStaticInfo->numNAVLights ; i++, navLight ++, navLightStatic ++)
      {
			// Account for the startdelay.
			if(navLight->lastTimeFlashed == navLightStatic->startdelay)
			{
				navLight->lastTimeFlashed = universe.totaltimeelapsed + navLightStatic->startdelay;
			}
			
			if(universe.totaltimeelapsed > navLight->lastTimeFlashed)
			{
				if(navLight->lightstate == 1)
				{
					navLight->lastTimeFlashed = universe.totaltimeelapsed + navLightStatic->flashrateoff;
				}
				else
				{
					navLight->lastTimeFlashed = universe.totaltimeelapsed + navLightStatic->flashrateon;
				}
				
				navLight->lightstate = 1 - navLight->lightstate;
			}

			if(navLight->lightstate)
			{
				if (ship->currentLOD <= (sdword)navLightStatic->minLOD)
				{
					navLightBillboardEnable(ship, navLightStatic);

					if(navLightStatic->texturehandle == TR_InvalidHandle)
					{
						primCircleSolid3Fade(&origin, navLightStatic->size, 10, navLightStatic->color, fade);
					}
					else
					{
						primSolidTexture3Fade(&origin, navLightStatic->size, navLightStatic->color, navLightStatic->texturehandle, fade);
					}

					navLightBillboardDisable();
				}
				else
				{
					color tempColor;

                    tempColor = colRGB(colRed(navLightStatic->color) * 2 / 3,
					                   colGreen(navLightStatic->color) * 2 / 3,
									   colBlue(navLightStatic->color) * 2 / 3);

                    rndTextureEnable(FALSE);
                    if (RGL)
                    {
                        if (glCapFastFeature(GL_BLEND))
                        {
                            rndAdditiveBlends(TRUE);
                            primPointSize3(&navLightStatic->position, 2.0f, tempColor);
                        }
                        else
                        {
                            primPointSize3(&navLightStatic->position, 1.0f, tempColor);
                        }
                    }
                    else
                    {
                        rndAdditiveBlends(TRUE);
                        glEnable(GL_POINT_SMOOTH);
                        primPointSize3Fade(&navLightStatic->position, 2.0f, tempColor, fade);
                        glDisable(GL_POINT_SMOOTH);
                    }
				}
			}
      }

      rndLightingEnable(lightOn);
      rndAdditiveBlends(FALSE);
      glDepthMask(GL_TRUE);
    }
}
Ejemplo n.º 14
0
/*=============================================================================
    defines:
=============================================================================*/

#ifdef _MACOSX
    #define HR_SCALE_MISSION_LOADING_SCREENS  TRUE
#else
    #define HR_SCALE_MISSION_LOADING_SCREENS  FALSE
#endif

#define HR_PlayerNameFont   "Arial_12.hff"
#define MAX_CHAT_TEXT       64
#define NUM_CHAT_LINES      10

real32 HorseRacePlayerDropoutTime = 10.0f;     // tweakable
color HorseRaceDropoutColor = colRGB(75,75,75);

/*=============================================================================
    data:
=============================================================================*/

/*extern HDC hGLDeviceContext;*/

static rectangle hrSinglePlayerPos;
static color hrSinglePlayerLoadingBarColor = colRGB(255,63,63);  // pastel red

static sdword JustInit;
static sdword localbar;

// Pixels and info about the background image chosen
static bool hrBackgroundInitFrame = 0;
Ejemplo n.º 15
0
/*-----------------------------------------------------------------------------
    Name        : btgLoad
    Description : load a btg scene into our structures
    Inputs      : filename - the name of the btg file to load
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void btgLoad(char* filename)
{
    ubyte* btgData       = NULL;
    ubyte* btgDataOffset = NULL;
    ubyte* instarp       = NULL;
    udword headSize;
    udword vertSize;
    udword vertSizeFile;
    udword starSize, fileStarSize;
    udword polySize;
    real32 thetaSave, phiSave;
    udword i;
#if FIX_ENDIAN
    Uint64 *swap;
#endif

#if BTG_VERBOSE_LEVEL >= 2
    dbgMessagef("filename= %s", filename);
#endif


    fileLoadAlloc(filename, (void**)&btgData, 0);
    btgDataOffset=btgData;

    memStrncpy(btgLastBackground, filename, 127);

    //reset / free any previous structures
    thetaSave = btgThetaOffset;
    phiSave = btgPhiOffset;
    btgReset();
    btgThetaOffset = thetaSave;
    btgPhiOffset = phiSave;

    //header.  trivial copy
    headSize = sizeof(btgHeader);
    btgHead = (btgHeader*)memAlloc(headSize, "btg header", 0);

#if BTG_VERBOSE_LEVEL >=3
 dbgMessagef("btgData= %x", btgData);
 dbgMessagef("btgHead= %x", btgHead);
#endif


// Hard coding sizeof values. 
// This is because they may change later on in the world but static in the file.
// This allows us to align variables. It replaces 
//  memcpy(btgHead, btgData, headSize);

    memset(btgHead,0,sizeof(btgHead));

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,btgFileVersion), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,numVerts      ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,numStars      ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,numPolys      ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,xScroll       ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,yScroll       ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,zoomVal       ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,pageWidth     ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,pageHeight    ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,mRed          ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,mGreen        ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,mBlue         ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,mBGRed        ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,mBGGreen      ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,mBGBlue       ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,bVerts        ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,bPolys        ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,bStars        ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,bOutlines     ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,bBlends       ), btgDataOffset, 4 );
    btgDataOffset += 4;

    memcpy( (ubyte*)btgHead+offsetof(btgHeader,renderMode    ), btgDataOffset, 4 );
    btgDataOffset += 4;
        
//    memcpy(btgHead, btgData, headSize);  //See above.

#if FIX_ENDIAN
	btgHead->btgFileVersion = FIX_ENDIAN_INT_32( btgHead->btgFileVersion );
	btgHead->numVerts       = FIX_ENDIAN_INT_32( btgHead->numVerts );
	btgHead->numStars       = FIX_ENDIAN_INT_32( btgHead->numStars );
	btgHead->numPolys       = FIX_ENDIAN_INT_32( btgHead->numPolys );
	btgHead->xScroll        = FIX_ENDIAN_INT_32( btgHead->xScroll );
	btgHead->yScroll        = FIX_ENDIAN_INT_32( btgHead->yScroll );
	btgHead->zoomVal        = FIX_ENDIAN_INT_32( btgHead->zoomVal );
	btgHead->pageWidth      = FIX_ENDIAN_INT_32( btgHead->pageWidth );
	btgHead->pageHeight     = FIX_ENDIAN_INT_32( btgHead->pageHeight );
	btgHead->mRed           = FIX_ENDIAN_INT_32( btgHead->mRed );
	btgHead->mGreen         = FIX_ENDIAN_INT_32( btgHead->mGreen );
	btgHead->mBlue          = FIX_ENDIAN_INT_32( btgHead->mBlue );
	btgHead->mBGRed         = FIX_ENDIAN_INT_32( btgHead->mBGRed );
	btgHead->mBGGreen       = FIX_ENDIAN_INT_32( btgHead->mBGGreen );
	btgHead->mBGBlue        = FIX_ENDIAN_INT_32( btgHead->mBGBlue );
	btgHead->bVerts         = FIX_ENDIAN_INT_32( btgHead->bVerts );
	btgHead->bPolys         = FIX_ENDIAN_INT_32( btgHead->bPolys );
	btgHead->bStars         = FIX_ENDIAN_INT_32( btgHead->bStars );
	btgHead->bOutlines      = FIX_ENDIAN_INT_32( btgHead->bOutlines );
	btgHead->bBlends        = FIX_ENDIAN_INT_32( btgHead->bBlends );
	btgHead->renderMode     = FIX_ENDIAN_INT_32( btgHead->renderMode );
#endif

    //set background colour
    universe.backgroundColor = colRGB(btgHead->mBGRed, btgHead->mBGGreen, btgHead->mBGBlue);

    //version check
    dbgAssertOrIgnore(btgHead->btgFileVersion == BTG_FILE_VERSION);

    vertSize = btgHead->numVerts * sizeof(btgVertex);  //Machine Specific size

    vertSizeFile = btgHead->numVerts * (4 + (2* 8) + (5*4));  //Actual size from file. (No Alignment)

    if (vertSize)
    {

        btgVerts = (btgVertex*)memAlloc(vertSize, "btg verts", 0);

        for( i=0; i<btgHead->numVerts; i++ )
        {
            memcpy( (ubyte*)btgVerts+ ( i * sizeof(btgVertex)) +offsetof(btgVertex,flags     ), btgDataOffset, 4 );
            btgDataOffset += 4;

            memcpy( (ubyte*)btgVerts+( i * sizeof(btgVertex)) +offsetof(btgVertex,x          ), btgDataOffset, 8 );
            btgDataOffset += 8;

            memcpy( (ubyte*)btgVerts+( i * sizeof(btgVertex)) +offsetof(btgVertex,y          ), btgDataOffset, 8 );
            btgDataOffset += 8;

            memcpy( (ubyte*)btgVerts+( i * sizeof(btgVertex)) +offsetof(btgVertex,red        ), btgDataOffset, 4 );
            btgDataOffset += 4;

            memcpy( (ubyte*)btgVerts+( i * sizeof(btgVertex)) +offsetof(btgVertex,green      ), btgDataOffset, 4 );
            btgDataOffset += 4;

            memcpy( (ubyte*)btgVerts+( i * sizeof(btgVertex)) +offsetof(btgVertex,blue       ), btgDataOffset, 4 );
            btgDataOffset += 4;

            memcpy( (ubyte*)btgVerts+( i * sizeof(btgVertex)) +offsetof(btgVertex,alpha      ), btgDataOffset, 4 );
            btgDataOffset += 4;

            memcpy( (ubyte*)btgVerts+( i * sizeof(btgVertex)) +offsetof(btgVertex,brightness ), btgDataOffset, 4 );
            btgDataOffset += 4;
        }

//        memcpy(btgVerts, btgData + headSize, vertSize);  //Replaced by above.

#if FIX_ENDIAN
        for( i=0; i<btgHead->numVerts; i++ )
        {
            btgVerts[i].flags = FIX_ENDIAN_INT_32( btgVerts[i].flags );
            
            swap  = ( Uint64 *)&btgVerts[i].x;
            *swap = SDL_SwapLE64( *swap );
            
            swap  = ( Uint64 *)&btgVerts[i].y;
            *swap = SDL_SwapLE64( *swap );
            
            btgVerts[i].red        = FIX_ENDIAN_INT_32( btgVerts[i].red );
            btgVerts[i].green      = FIX_ENDIAN_INT_32( btgVerts[i].green );
            btgVerts[i].blue       = FIX_ENDIAN_INT_32( btgVerts[i].blue );
            btgVerts[i].alpha      = FIX_ENDIAN_INT_32( btgVerts[i].alpha );
            btgVerts[i].brightness = FIX_ENDIAN_INT_32( btgVerts[i].brightness );
        }
#endif
    }

#if BTG_VERBOSE_LEVEL >= 2
 dbgMessagef("numStars= %d", btgHead->numStars);
#endif

    //stars.  non-trivial munging around
    starSize = btgHead->numStars * sizeof(btgStar);
    fileStarSize = 0;
    if (starSize != 0)
    {
        btgStar* outstarp;
        btgStar* inp;
        udword*  udp;
        sdword   j, tempSize, count, length;
        char     filename[48];

        btgStars = (btgStar*)memAlloc(starSize, "btg stars", 0);
        instarp  = btgDataOffset;
#if BTG_VERBOSE_LEVEL >= 3
 dbgMessagef("instarp= %x",instarp);
 dbgMessagef("Offset= %x",instarp - btgData);
#endif
        outstarp = btgStars;
        inp = ( btgStar *)instarp;

        for (i = 0; i < btgHead->numStars; i++, outstarp++)
        {
            //extract constant-sized header
//            tempSize = sizeof(udword) + 2*sizeof(real64) + 4*sizeof(sdword);
            tempSize = 4 + 2*8 + 4*4;
            memcpy( (ubyte*)outstarp+offsetof(btgStar,flags), instarp, 4);
            instarp += 4;

            memcpy( (ubyte*)outstarp+offsetof(btgStar,x),     instarp, 8);
            instarp += 8;

            memcpy( (ubyte*)outstarp+offsetof(btgStar,y),     instarp, 8);
            instarp += 8;

            memcpy( (ubyte*)outstarp+offsetof(btgStar,red),   instarp, 4);
            instarp += 4;

            memcpy( (ubyte*)outstarp+offsetof(btgStar,green), instarp, 4);
            instarp += 4;

            memcpy( (ubyte*)outstarp+offsetof(btgStar,blue),  instarp, 4);
            instarp += 4;

            memcpy( (ubyte*)outstarp+offsetof(btgStar,alpha), instarp, 4);
            instarp += 4;

//            memcpy(outstarp, instarp, tempSize); //Replaced by Above.
#if BTG_VERBOSE_LEVEL >= 3
 dbgMessagef("tempSize= %x", tempSize);
 dbgMessagef("instarp= %x", instarp);
#endif
            fileStarSize += tempSize;

#if FIX_ENDIAN
            swap = ( Uint64 *)&outstarp->x;
            *swap = SDL_SwapLE64( *swap );
            swap = ( Uint64 *)&outstarp->y;
            *swap = SDL_SwapLE64( *swap );
            outstarp->flags = FIX_ENDIAN_INT_32( outstarp->flags );
            outstarp->red   = FIX_ENDIAN_INT_32( outstarp->red );
            outstarp->green = FIX_ENDIAN_INT_32( outstarp->green );
            outstarp->blue  = FIX_ENDIAN_INT_32( outstarp->blue );
            outstarp->alpha = FIX_ENDIAN_INT_32( outstarp->alpha );
#endif

            //extract variable-sized filename
            count = 0;
            memset(filename, 0, 48);
            udp = (udword*)instarp;

#if FIX_ENDIAN
            length = FIX_ENDIAN_INT_32( (sdword)*udp );
#else
            length = (sdword)*udp;
#endif

#if BTG_VERBOSE_LEVEL >=4
 dbgMessagef("instarp= %x", instarp);
 dbgMessagef("udp= %x", udp);
 dbgMessagef("length= %d", length);
 dbgMessagef("filename= %s", filename);
#endif

            instarp += 4;
            fileStarSize += 4;
            for (j = 0; j < length; j++)
            {
                filename[count++] = *instarp++;
                fileStarSize++;
            }
            memcpy(outstarp->filename, filename, 48);

            //create a GL texture object
            if (!btgTexInList(filename))
            {
                btgGetTexture(filename, &outstarp->glhandle, &outstarp->width, &outstarp->height);
                btgAddTexToList(filename, outstarp->glhandle, outstarp->width, outstarp->height);
            }
            else
            {
                btgFindTexture(filename, outstarp);
            }
        }
    }

    //reset the game's current texture, which now differs from the GL's
    trClearCurrent();

    btgPolygon* polyOut;

    //polys.  trivial copy
    polySize = btgHead->numPolys * sizeof(btgPolygon);
    if (polySize != 0)
    {
        btgPolys = (btgPolygon*)memAlloc(polySize, "btg polys", 0);

        polyOut= btgPolys;
// HERE FIX IT HERE
//        memcpy(btgPolys, btgData + headSize + vertSize + fileStarSize, polySize);

	for( i=0; i<btgHead->numPolys; i++, polyOut++ )
	{
            memcpy((ubyte*)polyOut+offsetof(btgPolygon,flags), instarp, 4);
            instarp += 4;

            memcpy((ubyte*)polyOut+offsetof(btgPolygon,v0), instarp, 4);
            instarp += 4;

            memcpy((ubyte*)polyOut+offsetof(btgPolygon,v1), instarp, 4);
            instarp += 4;

            memcpy((ubyte*)polyOut+offsetof(btgPolygon,v2), instarp, 4);
            instarp += 4;

	}
		
#if FIX_ENDIAN
		for( i=0; i<btgHead->numPolys; i++ )
		{
			btgPolys[i].flags = FIX_ENDIAN_INT_32( btgPolys[i].flags );
			btgPolys[i].v0    = FIX_ENDIAN_INT_32( btgPolys[i].v0 );
			btgPolys[i].v1    = FIX_ENDIAN_INT_32( btgPolys[i].v1 );
			btgPolys[i].v2    = FIX_ENDIAN_INT_32( btgPolys[i].v2 );
		}
#endif
    }

    memFree(btgData);

    btgIndices = (uword*)memAlloc(3 * btgHead->numPolys * sizeof(uword), "btg indices", NonVolatile);
    if (useVBO) glGenBuffers(1, &vboIndices);

#ifndef _WIN32_FIXME
    //spherically project things, blend colours, &c
    btgConvertVerts();
#endif
}
Ejemplo n.º 16
0
unsigned long AD_PORT = 2501;

char PATCHNAME[50] = "HomeworldPatch.exe";

char ROUTING_SERVER_NAME[30] = "routingserv";

real32 LAN_ADVERTISE_USER_TIME = 1.0f;
real32 LAN_ADVERTISE_USER_TIMEOUT = 5.0f;
real32 LAN_ADVERTISE_GAME_TIME = 1.0f;
real32 LAN_ADVERTISE_GAME_TIMEOUT = 5.0f;

real32 KEEPALIVE_SEND_IAMALIVE_TIME = 10.0f;
real32 KEEPALIVE_IAMALIVE_TIMEOUT = 25.0f;
real32 KEEPALIVE_SEND_ALIVESTATUS_TIME = 30.0f;

color PATCHBARCOLOR = colRGB(255, 0, 0);
color PATCHBAROUTLINECOLOR = colWhite;

udword PRINTLAG_IFGREATERTHAN =        10;
udword PRINTLAG_MINFRAMES =            20;

udword ROOM_MIN_THRESHOLD = 1;
udword ROOM_MAX_THRESHOLD = 50;

unsigned long WAIT_SHUTDOWN_MS = 1000;

void scriptSetIPStrings(char *directory,char *field,void *dataToFillIn);
void scriptSetPortNumbers(char *directory,char *field,void *dataToFillIn);

extern sdword TimedOutWaitingForPauseAcksGiveUpAfterNumTimes;
Ejemplo n.º 17
0
/*-----------------------------------------------------------------------------
    Name        : pingListDraw
    Description : Draw all pings from farthest to nearest.
    Inputs      : camera - the camera we're rendering from
                  modelView, projection - current matrices
                  viewPort - rectangle we're rending in, for the TO legend
    Outputs     :
    Return      :
    Note        : The renderer should be in 2D mode at this point.
----------------------------------------------------------------------------*/
void pingListDraw(Camera *camera, hmatrix *modelView, hmatrix *projection, rectangle *viewPort)
{
    real32 pingAge, pingCycle, pingMod, pingSize;
    real32 x, y, radius;
    Node *thisNode, *nextNode;
    ping *thisPing;
    vector distSquared;
    sdword nSegments, index, rowHeight, xScreen, yScreen;
    oval o;
    udword TOFlags = 0;
    fonthandle fhSave;
    toicon *icon;
    color col;
    real32 realMargin;
    ShipClass shipClass;
    static real32 lastProximityPing = REALlyBig;
    static real32 lastAnomolyPing = REALlyBig;
    static real32 lastBattlePing = REALlyBig;
    static real32 lastHyperspacePing = REALlyBig;
    static real32 lastNewshipPing = REALlyBig;
    bool pingset;

    //start by sorting the ping list from farthest to nearest
    thisNode = pingList.head;

    while (thisNode != NULL)
    {                                                       //scan all pings
        nextNode = thisNode->next;
        thisPing = listGetStructOfNode(thisNode);

        if (thisPing->owner != NULL)
        {
            thisPing->centre = thisPing->owner->posinfo.position;
        }
        vecSub(distSquared, camera->eyeposition, thisPing->centre);
        thisPing->cameraDistanceSquared = vecMagnitudeSquared(distSquared);
        TOFlags |= thisPing->TOMask;

        thisNode = nextNode;
    }
    listMergeSortGeneral(&pingList, pingListSortCallback);

    //now the list is sorted; proceed to draw all the pings
    thisNode = pingList.head;

    pingset = FALSE;

    while (thisNode != NULL)
    {                                                       //scan all pings
        nextNode = thisNode->next;
        thisPing = listGetStructOfNode(thisNode);

        pingCycle = thisPing->pingDuration + thisPing->interPingPause;
        pingAge = universe.totaltimeelapsed - thisPing->creationTime;
        pingMod = (real32)fmod((double)pingAge, (double)pingCycle);
        if (pingMod <= thisPing->pingDuration)
        {
            pingSize = (thisPing->size - thisPing->minSize) * pingMod / thisPing->pingDuration + thisPing->minSize;
            selCircleComputeGeneral(modelView, projection, &thisPing->centre, max(thisPing->size,thisPing->minSize), &x, &y, &radius);
            if (radius > 0.0f)
            {
                radius = max(radius, thisPing->minScreenSize);
                radius *= pingSize / max(thisPing->size,thisPing->minSize);
                o.centreX = primGLToScreenX(x);
                o.centreY = primGLToScreenY(y);
                o.radiusX = o.radiusY = primGLToScreenScaleX(radius);
                nSegments = pieCircleSegmentsCompute(radius);
                primOvalArcOutline2(&o, 0.0f, 2*PI, 1, nSegments, thisPing->c);

                /* starting to draw a new ping so play the sound */
                if (!smZoomingIn && !smZoomingOut && !pingset)
                {
                    switch (thisPing->TOMask)
                    {
                        case PTOM_Anomaly:
                            if (pingSize <=lastAnomolyPing)
                            {
                                soundEvent(NULL, UI_SensorsPing);
                                pingset = TRUE;
                                lastAnomolyPing = pingSize;
                            }
                            break;
                        case PTOM_Battle:
                            if (pingSize <= lastBattlePing)
                            {
                                soundEvent(NULL, UI_PingBattle);
                                pingset = TRUE;
                                lastBattlePing = pingSize;
                            }
                            break;
                        case PTOM_Hyperspace:
                            if (pingSize <=  lastHyperspacePing)
                            {
                                soundEvent(NULL, UI_PingHyperspace);
                                pingset = TRUE;
                                lastHyperspacePing = pingSize;
                            }
                            break;
                        case PTOM_Proximity:
                            if (pingSize <= lastProximityPing)
                            {
                                soundEvent(NULL, UI_PingProximity);
                                pingset = TRUE;
                                lastProximityPing = pingSize;
                            }
                            break;
                        case PTOM_NewShips:
                            if (pingSize <= lastNewshipPing)
                            {
                                soundEvent(NULL, UI_PingNewShips);
                                pingset = TRUE;
                                lastNewshipPing = pingSize;
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
        }

        thisNode = nextNode;
    }

    //draw the blip TO
    if (smTacticalOverlay)
    {
        realMargin = primScreenToGLScaleX(viewPort->x0);
        fhSave = fontCurrentGet();                          //save the current font
        fontMakeCurrent(selGroupFont2);                     // use a common, fairly small font
        rowHeight = fontHeight("M");                        // used to space the legend
        yScreen = viewPort->y0 + rowHeight;                 //leave some space at the top to start
        radius = primScreenToGLScaleX(rowHeight)/2;
        xScreen = viewPort->x0 + (sdword)(rowHeight * 2.5);

        for (index = 0; index < PTO_NumberTOs; index++)
        {
            if ((TOFlags & pingTOList[index].bitMask))
            {
    //            fontPrint(xScreen, yScreen, *pingTOList[index].c, "O");
                pingTOList[index].lastTimeDrawn = universe.totaltimeelapsed;
            }
            if (universe.totaltimeelapsed - pingTOList[index].lastTimeDrawn <= pingTOLingerTime)
            {
                o.centreX = viewPort->x0 + rowHeight * 3 / 2;
                o.centreY = yScreen + rowHeight / 2;
                o.radiusX = o.radiusY = rowHeight / 2;
                primOvalArcOutline2(&o, 0.0f, TWOPI, 1, pingTONSegments, *pingTOList[index].c);
                fontPrint(xScreen, yScreen, TO_TextColor, strGetString(pingTOList[index].stringEnum));
                yScreen += rowHeight + 1;
            }
        }
        for (shipClass = 0; shipClass < NUM_CLASSES; shipClass++)
        {
            if (!toClassUsed[shipClass][0])
            {
                continue;
            }
            icon = toClassIcon[shipClass];
            fontPrint(xScreen, yScreen + (rowHeight>>2), TO_TextColor, ShipClassToNiceStr(shipClass));
#if TO_STANDARD_COLORS
            col = teFriendlyColor;
#else
            col = teColorSchemes[universe.curPlayerIndex].tacticalColor;
#endif
            col = colRGB(colRed(col)/TO_IconColorFade, colGreen(col)/TO_IconColorFade, colBlue(col)/TO_IconColorFade);
            primLineLoopStart2(1, col);

            for (index = icon->nPoints - 1; index >= 0; index--)
            {
               primLineLoopPoint3F(realMargin + primScreenToGLX(rowHeight*1.5) + icon->loc[index].x * radius,
                                          primScreenToGLY(yScreen + rowHeight/2) + icon->loc[index].y * radius);
            }
            primLineLoopEnd2();
            yScreen += rowHeight + 1;
        }

        fontMakeCurrent(fhSave);
    }
}
Ejemplo n.º 18
0
sdword          MessageToAllies;
bool            ViewingBuffer=FALSE;

//bool            reset=FALSE;

fonthandle      chathistoryfont=0;
char            chathistoryfontname[64]="default.hff";

LinkedList      chathistorylist;
Node           *curPosition=NULL;
chathistory     threadtransfer[40];
sdword          numnewchat=0;

// tweakable variables for color

color           gcGamePrivateChatColor=colRGB(255,0,0);
color           gcGameWhisperedColor=colRGB(0,255,0);
color           gcGameNormalChatColor=colRGB(200,200,200);

void           *chatmutex=NULL;

BabyCallBack   *ScrollDownAutoBaby=NULL;
real32          GC_SCROLL_TIME=2.5f;
sdword          maxlines=3;
uword           RUTransferToPlayer;

sdword          chatwidth;

/*=============================================================================
    function prototypes:
=============================================================================*/
Ejemplo n.º 19
0
void liBlendColorDodge(color *buffer, color *layer, real32 opacity, sdword nPixels)
{
    real32 redSource, greenSource, blueSource, alpha;
    real32 redDest, greenDest, blueDest;//, alphaDest;
    real32 oneMinusAlpha;

    while (nPixels > 0)
    {
        alpha = colUbyteToReal(colAlpha(*layer)) * opacity;
        oneMinusAlpha = 1.0f - alpha;
        redSource = colUbyteToReal(colRed(*layer));    //read pixel to floating point
        greenSource = colUbyteToReal(colGreen(*layer));
        blueSource = colUbyteToReal(colBlue(*layer));
        redDest = colUbyteToReal(colRed(*buffer));
        greenDest = colUbyteToReal(colGreen(*buffer));
        blueDest = colUbyteToReal(colBlue(*buffer));
        redDest = (redDest + redSource * redSource * redDest) * alpha + redDest * oneMinusAlpha;
        greenDest = (greenDest + greenSource * greenSource * greenDest) * alpha + greenDest * oneMinusAlpha;
        blueDest = (blueDest + blueSource * blueSource * blueDest) * alpha + blueDest * oneMinusAlpha;
        redDest = min(redDest, 1.0f);
        greenDest = min(greenDest, 1.0f);
        blueDest = min(blueDest, 1.0f);
        *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest),
                         colRealToUbyte(blueDest));
        buffer++;
        layer++;
        nPixels--;
    }
/*
    real32 redSource, greenSource, blueSource, alpha;
    real32 redDest, greenDest, blueDest;//, alphaDest;
    real32 oneMinusAlpha;
    real32 hueS, satS, valS, hueD, satD, valD;
//    real32 cvalD, cvalS;

    while (nPixels > 0)
    {
        alpha = colUbyteToReal(colAlpha(*layer)) * opacity;
        oneMinusAlpha = 1.0f - alpha;
        redSource = colUbyteToReal(colRed(*layer));    //read pixel to floating point
        greenSource = colUbyteToReal(colGreen(*layer));
        blueSource = colUbyteToReal(colBlue(*layer));
        redDest = colUbyteToReal(colRed(*buffer));
        greenDest = colUbyteToReal(colGreen(*buffer));
        blueDest = colUbyteToReal(colBlue(*buffer));
//        redDest = (redDest + redSource * redSource * redDest) * alpha + redDest * oneMinusAlpha;
//        greenDest = (greenDest + greenSource * greenSource * greenDest) * alpha + greenDest * oneMinusAlpha;
//        blueDest = (blueDest + blueSource * blueSource * blueDest) * alpha + blueDest * oneMinusAlpha;
        colRGBToHSV(&hueS, &satS, &valS, redSource * alpha, greenSource * alpha, blueSource * alpha);
        colRGBToHSV(&hueD, &satD, &valD, redDest, greenDest, blueDest);
        valD += valS;
        valD = min(valD, 1.0f);
        colHSVToRGB(&redDest, &greenDest, &blueDest, hueD, satD, valD);

        *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest),
                         colRealToUbyte(blueDest));
        buffer++;
        layer++;
        nPixels--;
    }
*/
}
Ejemplo n.º 20
0
void tutExecute(regionhandle reg)
{
    fonthandle currentfont;
    sdword texty, bitmap;

    rectangle rect;                         // used for translucent boxes behind text
    rectangle *buttonrect = &reg->rect;     // used for "next" button
    bool modeset = FALSE;
    sdword bitmap_x, bitmap_vel;

	if(tutorial == 3)
		return;

    if(tutRegion->previous)
        regSiblingMoveToFront(tutRegion);

    if(tutTransition == 0 && tutLesson != TUT_LESSON_ENTER_BUILD_MANAGER && tutLesson != TUT_LESSON_BUILD_SHIP) // don't draw button on build manager lessons
    {
        if(mouseInRect(buttonrect))
        {
            if(mouseLeftButton())
            {
                tutSkip = TRUE;
                trRGBTextureMakeCurrent(tutButtonTexture[NEXT_ON]);
            }
            else
                trRGBTextureMakeCurrent(tutButtonTexture[NEXT_MOUSE]);
        }
        else
            trRGBTextureMakeCurrent(tutButtonTexture[NEXT_OFF]);
        rndPerspectiveCorrection(FALSE);
//      glEnable(GL_BLEND);         // needs to be enabled once Keith fixes alpha blending intel compiler optimization bug
        primRectSolidTextured2(buttonrect);
//      glDisable(GL_BLEND);        // needs to be enabled once Keith fixes alpha blending intel compiler optimization bug
    }

    if(tutTransition == 0)
    {
        switch(PassedTutorial(tutLesson))
        {
        case 0:     // Didn't pass
            break;

        case 1:     // Perform transition
            tutTransition = 1;
            break;

        case -1:    // No Transition
            tutLesson++;
            InitTutorial(tutLesson);
            break;
        }
    }
    else if(tutTransition == 1)
    {
        tutTransitionCount++;
        if(tutTransitionCount == TUT_TransitionFramesOut)
        {
            tutTransition = 2;
            tutTransitionCount = TUT_TransitionFramesIn;
            tutLesson++;
            InitTutorial(tutLesson);
            if((tutLesson >= TUT_ADVANCED_INTRO && tutorial == 1) || (tutLesson >= TUT_TOTAL_LESSONS && tutorial == 2))
            {
                tutorialdone = TRUE;
                return;
            }
        }
    }
    else if(tutTransition == 2)
    {
        tutTransitionCount--;
        if(tutTransitionCount == 0)
            tutTransition = 0;
    }

    if(tutBitmapList[tutLesson][2] != -1)
    {
        bitmap_x = TUT_BITMAP_X;
        bitmap_vel = 210;
    }
    else if(tutBitmapList[tutLesson][1] != -1)
    {
        bitmap_x = TUT_BITMAP_X + (TUT_BITMAP_WIDTH + 8);
        bitmap_vel = 150;
    }
    else
    {
        bitmap_x = TUT_BITMAP_X + ((2 * TUT_BITMAP_WIDTH) + 8);
        bitmap_vel = 90;
    }

    if(tutTransition == 0)
        bitmap_vel = 0;
    else if(tutTransition == 1)
        bitmap_vel = (long) (((float)bitmap_vel/(float)TUT_TransitionFramesOut) * (float)tutTransitionCount);
    else if(tutTransition == 2)
        bitmap_vel = (long) (((float)bitmap_vel/(float)TUT_TransitionFramesIn) * (float)tutTransitionCount);

//  glEnable(GL_BLEND);
    for(bitmap = 0; bitmap < 3; bitmap++)
    {
        if(tutBitmapList[tutLesson][bitmap] != -1)
        {
            trRGBTextureMakeCurrent(tutButtonTexture[tutBitmapList[tutLesson][bitmap]]);
            rndPerspectiveCorrection(FALSE);
            rect.x0 = bitmap_x + ((TUT_BITMAP_WIDTH + 8) * bitmap) + bitmap_vel;
            rect.y0 = TUT_BITMAP_Y;
            rect.x1 = bitmap_x + ((TUT_BITMAP_WIDTH + 8) * bitmap) + TUT_BITMAP_WIDTH + bitmap_vel;
            rect.y1 = TUT_BITMAP_Y + TUT_BITMAP_HEIGHT;
            primRectSolidTextured2(&rect);
        }
    }
//  glDisable(GL_BLEND);

    if (!primModeEnabled)   // draw translucent polys before text
    {
        primModeSet2();
        modeset = TRUE;
    }

    if(tutLesson != TUT_LESSON_BUILD_SHIP)      // default behaviour for lessons
    {
    long    TitlePos = (long)(TUT_TitleTransMult[tutTransition] * (float)tutTransitionCount);
    long    TextPos = (long)(TUT_TextTransMult[tutTransition] * (float)tutTransitionCount);

        rect.x0 = 0;
        rect.y0 = TUT_Title_Y - TitlePos - 7;
        rect.x1 = 640;
        rect.y1 = TUT_Title_Y - TitlePos + 22;
        primRectTranslucent2(&rect, colRGBA(0, 0, 0, 128));

        rect.x0 = TUT_Main_X - TextPos - 12;
        rect.y0 = TUT_Main_Y - 6;
        rect.x1 = TUT_Main_X - TextPos + TUT_MainTextWidth + 4;
        rect.y1 = tutLastMainY;
        primRectTranslucent2(&rect, colRGBA(0, 0, 0, 128));

        currentfont = fontMakeCurrent(tutTitleFont);    // draw text
        fontPrintf(TUT_Title_X, TUT_Title_Y - TitlePos, TUT_TitleColor, "%s", strGetString(strTutorial00Title + (tutLesson * 7)));
        currentfont = fontMakeCurrent(tutMainFont);
        texty = DrawTextBlock(strGetString(strTutorial00Line01 + (tutLesson * 7)), TUT_Main_X - TextPos, TUT_Main_Y, TUT_MainTextWidth, TUT_MainTextHeight, TUT_MainColor);
        texty = DrawTextBlock(strGetString(strTutorial00Line02 + (tutLesson * 7)), TUT_Main_X - TextPos, texty, TUT_MainTextWidth, TUT_MainTextHeight, TUT_MainColor);
        texty = DrawTextBlock(strGetString(strTutorial00Line03 + (tutLesson * 7)), TUT_Main_X - TextPos, texty, TUT_MainTextWidth, TUT_MainTextHeight, TUT_MainColor);
        texty = DrawTextBlock(strGetString(strTutorial00Line04 + (tutLesson * 7)), TUT_Main_X - TextPos, texty, TUT_MainTextWidth, TUT_MainTextHeight, TUT_MainColor);
        tutLastMainY = DrawTextBlock(strGetString(strTutorial00Line05 + (tutLesson * 7)), TUT_Main_X - TextPos, texty, TUT_MainTextWidth, TUT_MainTextHeight, TUT_MainColor);
        fontMakeCurrent(currentfont);
    }
    else                                    // special case for build ship lesson
    {
        currentfont = fontMakeCurrent(tutMainFont);
        texty = DrawTextBlock(strGetString(strTutorial17Line01 + tutVar.count), TUT_Build_X, TUT_Build_Y, TUT_BuildTextWidth, TUT_BuildTextHeight, TUT_BuildColor);
        fontMakeCurrent(currentfont);

        rect.x0 = TUT_Build_X - 8;          // draw outline box around text
        rect.y0 = TUT_Build_Y - 6;
        rect.x1 = TUT_Build_X + TUT_BuildTextWidth + 8;
        rect.y1 = texty;
        primRectOutline2(&rect, 2, colRGB(tutPulseValue, tutPulseValue, tutPulseValue));

        if(tutVar.count == 0)               // point to appropriate place on screen
            tutDrawLinePulse(TUT_Build_X - 8, texty, 160, 100, tutPulseValue, 8);
        else if(tutVar.count == 1)
            tutDrawLinePulse(TUT_Build_X - 8, texty, 180, 410, tutPulseValue, 8);
        else if(tutVar.count == 2)
            tutDrawLinePulse(TUT_Build_X - 8, texty, 550, 410, tutPulseValue, 8);

        tutPulseValue -= 8;
    }

    if(!FirstWordNULL(strGetString(strTutorial00Tip + (tutLesson * 7))))
    {
    long    TipPos = (long)(TUT_TipTransMult[tutTransition] * (float)tutTransitionCount);
    long    TextPos = (long)(TUT_TextTransMult[tutTransition] * (float)tutTransitionCount);

        if (!primModeEnabled)   // draw translucent polys before tip text
        {
            primModeSet2();
            modeset = TRUE;
        }

        rect.x0 = TUT_TipTitle_X - 8;
        rect.y0 = TUT_TipTitle_Y - TipPos - 6;
        rect.x1 = TUT_Tip_X - 8;
        rect.y1 = TUT_TipTitle_Y - TipPos + 18;
        primRectTranslucent2(&rect, colRGBA(0, 0, 0, 128));

        rect.x0 = TUT_Tip_X + TextPos - 8;
        rect.y0 = TUT_Tip_Y - 6;
        rect.x1 = TUT_Tip_X + TextPos + TUT_TipTextWidth + 8;
        rect.y1 = tutLastTipY;
        primRectTranslucent2(&rect, colRGBA(0, 0, 0, 128));

        if(modeset)
            primModeClear2();

        currentfont = fontMakeCurrent(tutTipTitleFont);
        fontPrintf(TUT_TipTitle_X, TUT_TipTitle_Y - TipPos, TUT_TipTitleColor, "%s", strGetString(strTutorialTip));
        currentfont = fontMakeCurrent(tutTipFont);
        tutLastTipY = DrawTextBlock(strGetString(strTutorial00Tip + (tutLesson * 7)), TUT_Tip_X + TextPos, TUT_Tip_Y, TUT_TipTextWidth, TUT_TipTextHeight, TUT_TipColor);
    }

    fontMakeCurrent(currentfont);
}
Ejemplo n.º 21
0
#include "Alliance.h"
#include "gamechat.h"
#include "chatting.h"
#include "utility.h"
#include "universe.h"
#include "commandnetwork.h"
#include "commandlayer.h"
#include "commandwrap.h"
#include "strings.h"
#include "soundevent.h"

/*=============================================================================
    Data:
=============================================================================*/

color allianceMessageColor = colRGB(255,255,255);

/*=============================================================================
    Function prototypes for some private functions:
=============================================================================*/

//void alliancePrintNamesNice(char *dest, uword alliance);
void allianceRemovePlayerShipsFromAttackList(SelectAnyCommand *list,uword playerindex,CommandToDo *todo);
void allianceCancelAttackOrders(uword playerone, uword playertwo);

/*=============================================================================
    Function logic for Alliances:
=============================================================================*/


/*-----------------------------------------------------------------------------