BOOLEAN LoadMapScreenMessagesFromSaveGameFile( HWFILE hFile ) { UINT32 uiNumBytesRead; UINT32 uiCount; UINT32 uiSizeOfString; StringSaveStruct StringSave; CHAR16 SavedString[ 512 ]; // clear tactical message queue ClearTacticalMessageQueue( ); gubEndOfMapScreenMessageList = 0; gubStartOfMapScreenMessageList = 0; gubCurrentMapMessageString = 0; // Read to the begining of the message list FileRead( hFile, &gubEndOfMapScreenMessageList, sizeof( UINT8 ), &uiNumBytesRead ); if( uiNumBytesRead != sizeof( UINT8 ) ) { return(FALSE); } // Read the current message string FileRead( hFile, &gubStartOfMapScreenMessageList, sizeof( UINT8 ), &uiNumBytesRead ); if( uiNumBytesRead != sizeof( UINT8 ) ) { return(FALSE); } // Read the current message string FileRead( hFile, &gubCurrentMapMessageString, sizeof( UINT8 ), &uiNumBytesRead ); if( uiNumBytesRead != sizeof( UINT8 ) ) { return(FALSE); } //Loopthrough all the messages for( uiCount=0; uiCount<256; uiCount++) { // Read to the file the size of the message FileRead( hFile, &uiSizeOfString, sizeof( UINT32 ), &uiNumBytesRead ); if( uiNumBytesRead != sizeof( UINT32 ) ) { return(FALSE); } //if there is a message if( uiSizeOfString ) { // Read the message from the file FileRead( hFile, SavedString, uiSizeOfString, &uiNumBytesRead ); if( uiNumBytesRead != uiSizeOfString ) { return(FALSE); } //if there is an existing string,delete it if( gMapScreenMessageList[ uiCount ] ) { if( gMapScreenMessageList[ uiCount ]->pString16 ) { MemFree( gMapScreenMessageList[ uiCount ]->pString16 ); gMapScreenMessageList[ uiCount ]->pString16 = NULL; } } else { // There is now message here, add one ScrollStringSt *sScroll; sScroll = MemAlloc( sizeof( ScrollStringSt ) ); if( sScroll == NULL ) return( FALSE ); memset( sScroll, 0, sizeof( ScrollStringSt ) ); gMapScreenMessageList[ uiCount ] = sScroll; } //allocate space for the new string gMapScreenMessageList[ uiCount ]->pString16 = MemAlloc( uiSizeOfString ); if( gMapScreenMessageList[ uiCount ]->pString16 == NULL ) return( FALSE ); memset( gMapScreenMessageList[ uiCount ]->pString16, 0, uiSizeOfString); //copy the string over wcscpy( gMapScreenMessageList[ uiCount ]->pString16, SavedString ); //Read the rest of the message information to the saved game file FileRead( hFile, &StringSave, sizeof( StringSaveStruct ), &uiNumBytesRead ); if( uiNumBytesRead != sizeof( StringSaveStruct ) ) { return(FALSE); } // Create the saved string struct gMapScreenMessageList[ uiCount ]->uiFont = StringSave.uiFont; gMapScreenMessageList[ uiCount ]->usColor = StringSave.usColor; gMapScreenMessageList[ uiCount ]->uiFlags = StringSave.uiFlags; gMapScreenMessageList[ uiCount ]->fBeginningOfNewString = StringSave.fBeginningOfNewString; gMapScreenMessageList[ uiCount ]->uiTimeOfLastUpdate = StringSave.uiTimeOfLastUpdate; } else gMapScreenMessageList[ uiCount ] = NULL; } // this will set a valid value for gubFirstMapscreenMessageIndex, which isn't being saved/restored MoveToEndOfMapScreenMessageList(); return( TRUE ); }
BOOLEAN InitNewGame( BOOLEAN fReset ) { INT32 iStartingCash; // static fScreenCount = 0; if( fReset ) { gubScreenCount = 0; return( TRUE ); } // reset meanwhile flags uiMeanWhileFlags = 0; // Reset the selected soldier gusSelectedSoldier = NOBODY; if( gubScreenCount == 0 ) { if( !LoadMercProfiles() ) return(FALSE); } //Initialize the Arms Dealers and Bobby Rays inventory if( gubScreenCount == 0 ) { //Init all the arms dealers inventory InitAllArmsDealers(); InitBobbyRayInventory(); } // clear tactical ClearTacticalMessageQueue( ); // clear mapscreen messages FreeGlobalMessageList(); #ifdef JA2DEMO // IF our first time, go into laptop! InitStrategicLayer(); // Hire demo mercs.... #if defined ( JA2TESTVERSION ) || defined ( JA2DEMO ) DemoHiringOfMercs( ); #endif // Setup initial money AddTransactionToPlayersBook( ANONYMOUS_DEPOSIT, 0, GetWorldTotalMin(), 20500 ); #ifdef GERMAN //The different mercs are slightly more expensive. This adds that difference. AddTransactionToPlayersBook( ANONYMOUS_DEPOSIT, 0, GetWorldTotalMin(), 1075 ); #endif if ( !SetCurrentWorldSector( 1, 16, 0 ) ) { } SetLaptopExitScreen( MAP_SCREEN ); FadeInGameScreen( ); EnterTacticalScreen( ); #else // IF our first time, go into laptop! if ( gubScreenCount == 0 ) { //Init the laptop here InitLaptopAndLaptopScreens(); InitStrategicLayer(); // Set new game flag SetLaptopNewGameFlag( ); // this is for the "mercs climbing down from a rope" animation, NOT Skyrider!! ResetHeliSeats( ); // Setup two new messages! AddPreReadEmail(OLD_ENRICO_1,OLD_ENRICO_1_LENGTH,MAIL_ENRICO, GetWorldTotalMin() ); AddPreReadEmail(OLD_ENRICO_2,OLD_ENRICO_2_LENGTH,MAIL_ENRICO, GetWorldTotalMin() ); AddPreReadEmail(RIS_REPORT,RIS_REPORT_LENGTH,RIS_EMAIL, GetWorldTotalMin() ); AddPreReadEmail(OLD_ENRICO_3,OLD_ENRICO_3_LENGTH,MAIL_ENRICO, GetWorldTotalMin() ); AddEmail(IMP_EMAIL_INTRO,IMP_EMAIL_INTRO_LENGTH,CHAR_PROFILE_SITE, GetWorldTotalMin() ); //AddEmail(ENRICO_CONGRATS,ENRICO_CONGRATS_LENGTH,MAIL_ENRICO, GetWorldTotalMin() ); // ATE: Set starting cash.... switch( gGameOptions.ubDifficultyLevel ) { case DIF_LEVEL_EASY: iStartingCash = 45000; break; case DIF_LEVEL_MEDIUM: iStartingCash = 35000; break; case DIF_LEVEL_HARD: iStartingCash = 30000; break; default: Assert(0); return( FALSE ); } // Setup initial money AddTransactionToPlayersBook( ANONYMOUS_DEPOSIT, 0, GetWorldTotalMin(), iStartingCash ); { UINT32 uiDaysTimeMercSiteAvailable = Random( 2 ) + 1; // schedule email for message from spec at 7am 3 days in the future AddFutureDayStrategicEvent( EVENT_DAY3_ADD_EMAIL_FROM_SPECK, 60*7, 0, uiDaysTimeMercSiteAvailable ); } #ifdef CRIPPLED_VERSION { UINT32 cnt; //loop through the first 20 AIM mercs and set them to be away for( cnt = 0; cnt < 20; cnt++) { gMercProfiles[ cnt ].bMercStatus = MERC_WORKING_ELSEWHERE; gMercProfiles[ cnt ].uiDayBecomesAvailable = 14; // 14 days should be ok considering crippled version only goes to day 7 } } //Add an event to check for the end of the crippled version AddEveryDayStrategicEvent( EVENT_CRIPPLED_VERSION_END_GAME_CHECK, 0, 0 ); #endif SetLaptopExitScreen( INIT_SCREEN ); SetPendingNewScreen(LAPTOP_SCREEN); gubScreenCount = 1; //Set the fact the game is in progress gTacticalStatus.fHasAGameBeenStarted = TRUE; return( TRUE ); } /* if( ( guiExitScreen == MAP_SCREEN ) && ( LaptopSaveInfo.gfNewGameLaptop ) ) { SetLaptopExitScreen( GAME_SCREEN ); return( TRUE ); } */ if ( gubScreenCount == 1 ) { // OK , FADE HERE //BeginFade( INIT_SCREEN, 35, FADE_OUT_REALFADE, 5 ); //BeginFade( INIT_SCREEN, 35, FADE_OUT_VERSION_FASTER, 25 ); //BeginFade( INIT_SCREEN, 35, FADE_OUT_VERSION_SIDE, 0 ); gubScreenCount = 2; return( TRUE ); } /* if ( gubScreenCount == 2 ) { if ( !SetCurrentWorldSector( 9, 1, 0 ) ) { } SetLaptopExitScreen( MAP_SCREEN ); FadeInGameScreen( ); EnterTacticalScreen( ); if( gfAtLeastOneMercWasHired == TRUE ) { gubScreenCount = 3; } else { } return( TRUE ); } */ #endif return( TRUE ); }