/*----------------------------------------------------------------------------- Name : taskShutdown Description : Close the task manager by clearing all tasks. Inputs : void Outputs : Clears all task structures to unused and frees stack memory (if any) Return : void ----------------------------------------------------------------------------*/ void taskShutdown(void) { sdword index; #if TASK_VERBOSE_LEVEL >= 1 dbgMessage("taskClose: closing task module"); #endif if (!taskModuleInit) { return; } for (index = 0; index < taskMaxTask; index++) { if (taskData[index] != NULL) { if (taskData[index]->context != NULL) free(taskData[index]->context); //free structure and stack associated with this task memFree(taskData[index]); taskData[index] = NULL; } } taskModuleInit = FALSE; }
void captaincyLog(bool echotoscreen,char *format, ...) { char buffer[200]; va_list argList; va_start(argList, format); //get first arg vsprintf(buffer, format, argList); //prepare output string va_end(argList); dbgMessage("\n"); dbgMessage(buffer); if (echotoscreen) clCommandMessage(buffer); if (logEnable) { SYSTEMTIME systime; char buffer2[200]; GetSystemTime(&systime); sprintf(buffer2,"\n%2d:%2d:%2d %s",systime.wHour,systime.wMinute,systime.wSecond,buffer); logfileLog(CAPTAINCYLOGFILE,buffer2); } }
bool gpQuickLoad(void) { char* path; char filename[128]; path = gpQuickSetup(); if (path == NULL) { dbgMessage("gpQuickLoad couldn't find a dir"); return FALSE; } strcpy(filename, path); strcat(filename, QuickSaveName); gpLoadGivenGame(filename); return TRUE; }
/*----------------------------------------------------------------------------- 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 } } }
void gpStopPlayback(char *name, featom *atom) { dbgMessage("Stop playback."); }