void RepairCorvetteStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    RepairCorvetteStatics *corvstat = (statinfo->shiprace == R1) ? &RepairCorvetteStaticRace1 : &RepairCorvetteStaticRace2;

    memset(corvstat, 0, sizeof(RepairCorvetteStatics));
    scriptSetStruct(directory,filename,AttackSideStepParametersScriptTable,(ubyte *)&corvstat->sidestepParameters);
    scriptSetStruct(directory,filename,RepairCorvetteStaticScriptTable,(ubyte *)corvstat);

    statinfo->custstatinfo = corvstat;
}
void MinelayerCorvetteStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    MinelayerCorvetteStatics *corvstat = (statinfo->shiprace == R1) ? &MinelayerCorvetteStaticRace1 : &MinelayerCorvetteStaticRace2;

    memset(corvstat,sizeof(*corvstat),0);
    scriptSetStruct(directory,filename,AttackSideStepParametersScriptTable,(ubyte *)&corvstat->sidestepParameters);

    statinfo->custstatinfo = corvstat;

    scriptSetStruct(directory,filename,MinelayerCorvetteStaticScriptTable,(ubyte *)corvstat);
    corvstat->DropStopRadiusSqr = corvstat->MineDropDistance * corvstat->MineDropDistance;
    corvstat->NumMinesInSideSqr = corvstat->NumMinesInSide*corvstat->NumMinesInSide;
    corvstat->MineClearDistanceSQR = corvstat->MineClearDistance*corvstat->MineClearDistance;
}
void GenericDefenderStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    udword i;
    GenericDefenderStatics *defenderstat;

    switch (statinfo->shiptype)
    {
        case LightDefender:
           defenderstat = (statinfo->shiprace == R1) ? &LightDefenderStaticRace1 : &LightDefenderStaticRace2;
           break;
        case HeavyDefender:
           defenderstat = (statinfo->shiprace == R1) ? &HeavyDefenderStaticRace1 : &HeavyDefenderStaticRace2;
           break;
        default:
            dbgAssert(FALSE);
    }

    statinfo->custstatinfo = defenderstat;

    for(i=0;i<NUM_TACTICS_TYPES;i++)
    {
        defenderstat->gunRange[i] = statinfo->bulletRange[i];
        defenderstat->tooCloseRange[i] = statinfo->minBulletRange[i] * 0.9f;
    }

    defenderstat->CIRCLE_RIGHT_VELOCITY = 20.0f;
    defenderstat->CIRCLE_RIGHT_THRUST = 0.1f;

    scriptSetStruct(directory,filename,DefenderStaticScriptTable,(ubyte *)defenderstat);
}
void ResourceControllerStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    ResourceControllerStatics *resourcestat = (statinfo->shiprace == R1) ? &ResourceControllerStaticRace1 : &ResourceControllerStaticRace2;

    statinfo->custstatinfo = resourcestat;
    scriptSetStruct(directory,filename,RCStaticScriptTable,(ubyte *)resourcestat);
}
void DefenseFighterStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    DefenseFighterStatics *DefenseFighterstat = (statinfo->shiprace == R1) ? &DefenseFighterStaticRace1 : &DefenseFighterStaticRace2;

    statinfo->custstatinfo = DefenseFighterstat;
    scriptSetStruct(directory,filename,DefenseFighterStaticScriptTable,(ubyte *)DefenseFighterstat);
    //Calculate the Square of the radius for speeds sake
}
示例#6
0
void DDDFrigateStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    DDDFrigateStatics *dddstat = (statinfo->shiprace == R1) ? &DDDFrigateStaticRace1 : &DDDFrigateStaticRace2;

    statinfo->custstatinfo = dddstat;

    scriptSetStruct(directory,filename,DDDStaticScriptTable,(ubyte *)dddstat);
}
void P1StandardCorvetteStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    P1StandardCorvetteStatics *corvstat = &P1StandardCorvetteStatic;

    memset(corvstat, 0, sizeof(P1StandardCorvetteStatics));
    scriptSetStruct(directory,filename,AttackSideStepParametersScriptTable,(ubyte *)&corvstat->sidestepParameters);

    statinfo->custstatinfo = corvstat;
}
示例#8
0
void MultiGunCorvetteStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    MultiGunCorvetteStatics *corvstat = (statinfo->shiprace == R1) ? &MultiGunCorvetteStaticRace1 : &MultiGunCorvetteStaticRace2;

    memset(corvstat,sizeof(*corvstat),0);
    scriptSetStruct(directory,filename,AttackSideStepParametersScriptTable,(ubyte *)&corvstat->sidestepParameters);

    statinfo->custstatinfo = corvstat;
}
示例#9
0
void P1MissileCorvetteStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    udword i;
    P1MissileCorvetteStatics *corvstat = &P1MissileCorvetteStatic;

    memset(corvstat, 0, sizeof(P1MissileCorvetteStatics));

    scriptSetStruct(directory,filename,AttackSideStepParametersScriptTable,(ubyte *)&corvstat->sidestepParameters);
    scriptSetStruct(directory,filename,P1MissileCorvetteScriptTable,(ubyte *)corvstat);

    statinfo->custstatinfo = corvstat;

    for(i=0; i<NUM_TACTICS_TYPES; i++)
    {
        corvstat->missilecorvetteGunRange[i] = statinfo->bulletRange[i];
        corvstat->missilecorvetteTooCloseRange[i] = statinfo->minBulletRange[i] * 0.9f;
    }
}
示例#10
0
void CloakGeneratorStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    CloakGeneratorStatics *CloakGeneratorstat = (statinfo->shiprace == R1) ? &CloakGeneratorStaticRace1 : &CloakGeneratorStaticRace2;
    statinfo->custstatinfo = CloakGeneratorstat;

    scriptSetStruct(directory,filename,CloakGeneratorStaticScriptTable,(ubyte *)CloakGeneratorstat);
    CloakGeneratorstat->CloakingRadiusSqr = CloakGeneratorstat->CloakingRadius*CloakGeneratorstat->CloakingRadius;      //Calculate Square of Cloaking Radius
    CloakGeneratorstat->CloakingTime = 1 / CloakGeneratorstat->CloakingTime;
    CloakGeneratorstat->DeCloakingTime = 1 / CloakGeneratorstat->DeCloakingTime;
}
示例#11
0
void P2MultiBeamFrigateStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    udword i;
    P2MultiBeamFrigateStatics *frigstat = &P2MultiBeamFrigateStatic;

    statinfo->custstatinfo = frigstat;

    scriptSetStruct(directory, filename, P2MultiBeamFrigateScriptTable, (ubyte *)frigstat);

    for(i=0;i<NUM_TACTICS_TYPES;i++)
    {
        frigstat->MultiBeamRange[i] = frigstat->MBRstat * statinfo->bulletRange[i]; // multiply by gun range to get real beam range
    }
}
void AdvanceSupportFrigateStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    udword i;
    AdvanceSupportFrigateStatics *asfstat = (statinfo->shiprace == R1) ? &AdvanceSupportFrigateStaticRace1 : &AdvanceSupportFrigateStaticRace2;

    statinfo->custstatinfo = asfstat;

    for(i=0;i<NUM_TACTICS_TYPES;i++)
    {
        asfstat->asfGunRange[i] = statinfo->bulletRange[i];
        asfstat->asfTooCloseRange[i] = statinfo->minBulletRange[i] * 0.9f;
    }
    
    scriptSetStruct(directory,filename,ASFStaticScriptTable,(ubyte *)asfstat);
}
示例#13
0
void CarrierStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
    udword i;
    CarrierStatics *carrstat = (statinfo->shiprace == R1) ? &CarrierStaticRace1 : &CarrierStaticRace2;

    statinfo->custstatinfo = carrstat;

    for(i=0;i<NUM_TACTICS_TYPES;i++)
    {
        carrstat->carrierGunRange[i] = statinfo->bulletRange[i];
        carrstat->carrierTooCloseRange[i] = statinfo->minBulletRange[i] * 0.9f;
    }
    scriptSetStruct(directory,filename,CStaticScriptTable,(ubyte *)carrstat);

}
示例#14
0
lodinfo *lodTableReadScript(char *directory, char *fileName)
{
    lodinfo *info;
    sdword index;

    for (index = 0; index < LOD_NumberLevels; index++)
    {                                                       //initialize the lodmaxinfo structure
        lodMaxInfo.level[index].flags = LT_Invalid;
        lodMaxInfo.level[index].pData = NULL;
    }

    trBaseColorScalar = trStripeColorScalar = 0.0f;
    scriptSetStruct(directory, fileName, lodScriptTable, (ubyte *)&lodMaxInfo);//read the script file
    trBaseColorScalar = trStripeColorScalar = 0.0f;

    for (index = 0; index < LOD_NumberLevels; index++)
    {
        if ((lodMaxInfo.level[index].flags & LM_LODType) == LT_Invalid)
        {
            break;
        }
        if ((lodMaxInfo.level[index].flags & LM_LODType) == LT_Mesh)
        {                                                   //if it's a mesh
            lodMaxInfo.level[index].hBindings =                //create a bindings list
                meshBindingListCreate((meshdata *)lodMaxInfo.level[index].pData);
        }
        else
        {
            lodMaxInfo.level[index].hBindings = NULL;
        }
    }
    info = memAlloc(lodTableSize(index), "LOD Table", NonVolatile); //allocate the table
    memcpy(info, &lodMaxInfo, lodTableSize(index));            //and copy over the max table
    info->nLevels = index;                                  //store number of levels
#if LOD_AUTO_SAVE
    {
        char partialName[_MAX_PATH];
        char *fullName;
        sprintf(partialName, "%s%s", directory, fileName);
        fullName = filePathPrepend(partialName, 0);
        info->fileName = memStringDupe(fullName);           //store full path to file for saving
    }
#endif
    return(info);
}
示例#15
0
/*-----------------------------------------------------------------------------
    Name        : spNewItem
    Description : Called when a new item in the color picker list is selected.
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void spNewItem(void)
{
    char bitmapFile[_MAX_PATH];
    char descriptionFile[_MAX_PATH];
    char *chopBuffer;
    sdword scen;
    rectangle textureRect;
//    rectangle rect = spScenarioBitmapWindow->rect;
    color *bmpBuffer;
    filehandle handle;
    bmpheader header;
    featom *atom;

    scen = spScenarioListWindow->CurLineSelected->position;
    atom = feAtomFindInScreen(feStack[feStackIndex].screen, "CS_ScenarioBitmap");
    dbgAssert(atom != NULL);

    if (scenarioTexture != TR_InvalidInternalHandle)
    {                                                       //delete the old texture before creating a new one
        trRGBTextureDelete(scenarioTexture);
        scenarioTexture = TR_InvalidInternalHandle;
        if (spTextureData != NULL)
        {
            memFree(spTextureData);
            spTextureData = NULL;
        }
    }

    //free the previous text and set defaults
    spDescriptionDefaultsAndFreeText();

    spFindImage(bitmapFile, descriptionFile, spScenarios[scen].bitmapfileSpec);
    if (strlen(bitmapFile) > 0)
    {
        handle = bmpFileOpen(&header, bitmapFile);         //open the file
        if (handle != 0)
        {                                                   //if opened properly
            if (header.biWidth < SCP_PreviewWidthMin || header.biHeight > SCP_PreviewWidthMax)
            {
#if SCP_VERBOSE_LEVEL >= 1
                dbgMessagef("\n'%s': width of %d bad.", bitmapFile, header.biWidth);
#endif
                bmpClose(handle);
                return;
            }
            else if (header.biHeight < SCP_PreviewHeightMin || header.biHeight > SCP_PreviewHeightMax)
            {
#if SCP_VERBOSE_LEVEL >= 1
                dbgMessagef("\n'%s': height of %d bad.", bitmapFile, header.biHeight);
#endif
                bmpClose(handle);
                return;
            }
            //allocate the image buffer
            bmpBuffer = memAlloc(header.biWidth * header.biHeight * sizeof(color), "TempBMPbuffer", Pyrophoric);
            bmpBodyRead(bmpBuffer, handle, &header);        //read in the body of the file
            if (header.biWidth != SCP_PreviewWidth || header.biHeight != SCP_PreviewHeight)
            {                                               //if the image is the wrong size
                //rescale the image to the proper size
                bmpBuffer = trImageScale(bmpBuffer, header.biWidth, header.biHeight, SCP_PreviewWidth, SCP_PreviewHeight, TRUE);
                header.biWidth = SCP_PreviewWidth;           //make it think we're the right size
                header.biHeight = SCP_PreviewHeight;
            }
            scenarioTexture = trRGBTextureCreate(bmpBuffer, header.biWidth, header.biHeight, FALSE);
            spTextureWidth  = header.biWidth;
            spTextureHeight = header.biHeight;
            if (spTextureData != NULL)
            {
                memFree(spTextureData);
            }
            spTextureData = (ubyte*)memAlloc(4*spTextureWidth*spTextureHeight, "scenpick data", NonVolatile);
            memcpy(spTextureData, bmpBuffer, 4*spTextureWidth*spTextureHeight);
            memFree(bmpBuffer);                             //free the image
        }
        else
        {
            return;
        }
    }
    else
    {
#if SCP_VERBOSE_LEVEL >= 1
        dbgMessage("\nNo preview image found!");
#endif
        textureRect.x0 = atom->x + SCP_TEXTURE_INSET;
        textureRect.y0 = atom->y + SCP_TEXTURE_INSET;
        textureRect.x1 = atom->x + atom->width - SCP_TEXTURE_INSET;
        textureRect.y1 = atom->y + atom->height - SCP_TEXTURE_INSET;
        primRectSolid2(&textureRect, colBlack);
    }

    if (strlen(descriptionFile) > 0)
    {                                                       //if there is a description file
        // load in the proper description based on the language
        if (strCurLanguage==languageEnglish)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
        }
        else if (strCurLanguage==languageFrench)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaksFrench);//load in the description text
            if (spDescription==NULL)
            {
                // if french isn't found load in english
                scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
            }
        }
        else if (strCurLanguage==languageGerman)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaksGerman);//load in the description text
            if (spDescription==NULL)
            {
                // if german isn't found load in english
                scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
            }
        }
        else if (strCurLanguage==languageSpanish)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaksSpanish);//load in the description text
            if (spDescription==NULL)
            {
                // if german isn't found load in english
                scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
            }
        }
        else if (strCurLanguage==languageItalian)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaksItalian);//load in the description text
            if (spDescription==NULL)
            {
                // if german isn't found load in english
                scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
            }
        }

        if (spDescription != NULL)
        {                                                   //if there was real text in that file
            if (spDescriptionFont == FONT_InvalidFontHandle)
            {                                               //make sure we have a font
                spDescriptionFont = frFontRegister("default.hff");
            }
            textureRect.x0 = atom->x + SCP_TEXTURE_INSET;   //and a region to print into
            textureRect.y0 = atom->y + SCP_TEXTURE_INSET;
            textureRect.x1 = atom->x + atom->width - SCP_TEXTURE_INSET;
            textureRect.y1 = atom->y + atom->height - SCP_TEXTURE_INSET;

            spDescriptionLines = memAlloc(sizeof(char *) * (textureRect.y1 - textureRect.y0), "DescLines", NonVolatile);//allocate the chopping pointers
            chopBuffer = memAlloc(strlen(spDescription) + textureRect.y1 - textureRect.y0, "DescChopped", NonVolatile);//allocate chop buffer
            spNDescriptionLines = subStringsChop(&textureRect, spDescriptionFont, strlen(spDescription), spDescription, chopBuffer, spDescriptionLines);
            memFree(spDescription);                         //free unchopped description
            spDescription = chopBuffer;                     //keep pointer to chopped description
        }
        gameTypeFromDescription = memAlloc(sizeof(GameType), "DescGameType", 0);
        memset(gameTypeFromDescription, 0xff, sizeof(GameType));       //flag all members as unused
        gameTypeFromDescription->flag = gameTypeFromDescription->flagNeeded = 0;    //flag none of the flags needed

        scriptSetStruct(NULL, descriptionFile, StaticMGInfoScriptTable, (ubyte *)gameTypeFromDescription);
    }

    if (strlen(descriptionFile) > 0 || strlen(bitmapFile) > 0)
    {                                                       //if there is a description file or a bitmap
        if (spPickerStarted)
        {
            spScenarioBitmap(atom, (regionhandle)atom->region);//draw it/them
        }
    }
}