comparison mm7_2.cpp @ 1545:c4ab816fcc5e

assert, Abortf, AbortWithError -> Assert, Error refactors here and there
author Nomad
date Sat, 07 Sep 2013 20:05:20 +0200
parents 888157f45502
children 9a6567c6c76c
comparison
equal deleted inserted replaced
1544:499761153844 1545:c4ab816fcc5e
2 #define _CRT_SECURE_NO_WARNINGS 2 #define _CRT_SECURE_NO_WARNINGS
3 #endif 3 #endif
4 4
5 #include <io.h> 5 #include <io.h>
6 #include <direct.h> 6 #include <direct.h>
7 #include <assert.h> 7
8 #include <windows.h> 8 #include "OSAPI.h"
9
10 9
11 #include "Texture.h" 10 #include "Texture.h"
12 #include "mm7_data.h" 11 #include "mm7_data.h"
13 #include "VideoPlayer.h" 12 #include "VideoPlayer.h"
14 #include "Sprites.h" 13 #include "Sprites.h"
3086 for (uint i = 0; i < uNumLevelDecorations; ++i) 3085 for (uint i = 0; i < uNumLevelDecorations; ++i)
3087 if (pLevelDecorations[i].uDecorationDescID == id) 3086 if (pLevelDecorations[i].uDecorationDescID == id)
3088 event_triggers[num_event_triggers++] = i; 3087 event_triggers[num_event_triggers++] = i;
3089 } 3088 }
3090 3089
3091 OPENFILENAMEA ofn;
3092 //----- (0046271C) --------------------------------------------------------
3093 void CreateDefaultBLVLevel()
3094 {
3095 ofn.lStructSize = 0x4Cu;
3096 ofn.hwndOwner = hWnd;
3097 ofn.hInstance = 0;
3098 ofn.lpstrFilter = "Indoor BLV Files (*.blv)";
3099 ofn.lpstrCustomFilter = 0;
3100 ofn.nMaxCustFilter = 0;
3101 ofn.nFilterIndex = 0;
3102 ofn.lpstrFile = 0;
3103 ofn.nMaxFile = 260;
3104 ofn.nMaxFileTitle = 512;
3105 ofn.lpstrInitialDir = "levels";
3106 ofn.lpstrTitle = "Might and MagicŪ VII - Load Which Level?";
3107 ofn.Flags = 4;
3108 ofn.nFileOffset = 0;
3109 ofn.nFileExtension = 0;
3110 ofn.lpstrDefExt = "blv";
3111 ofn.lCustData = 0;
3112 ofn.lpfnHook = 0;
3113 ofn.lpTemplateName = 0;
3114 ofn.lpstrFileTitle = pTmpBuf.data();
3115 }
3116
3117 //----- (004627B7) -------------------------------------------------------- 3090 //----- (004627B7) --------------------------------------------------------
3118 void MainMenu_Loop() 3091 void MainMenu_Loop()
3119 { 3092 {
3120 GUIButton *pButton; // eax@27 3093 GUIButton *pButton; // eax@27
3121 unsigned int pControlParam; // ecx@35 3094 unsigned int pControlParam; // ecx@35
3696 HDC hDC = GetDC(hWnd); 3669 HDC hDC = GetDC(hWnd);
3697 int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL); 3670 int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL);
3698 int planes = GetDeviceCaps(hDC, PLANES); 3671 int planes = GetDeviceCaps(hDC, PLANES);
3699 ReleaseDC(hWnd, hDC); 3672 ReleaseDC(hWnd, hDC);
3700 if (bitsPerPixel != 16 || planes != 1) 3673 if (bitsPerPixel != 16 || planes != 1)
3701 Abortf(pGlobalTXT_LocalizationStrings[62]); 3674 Error(pGlobalTXT_LocalizationStrings[62]);
3702 } 3675 }
3703 BYTE1(dword_6BE364_game_settings_1) &= 0xFEu; 3676 BYTE1(dword_6BE364_game_settings_1) &= 0xFEu;
3704 3677
3705 if ( pArcomageGame->bGameInProgress ) 3678 if ( pArcomageGame->bGameInProgress )
3706 { 3679 {
5292 { 5265 {
5293 pMouse->Activate(0); 5266 pMouse->Activate(0);
5294 5267
5295 pParty->Reset(); 5268 pParty->Reset();
5296 pParty->CreateDefaultParty(1); 5269 pParty->CreateDefaultParty(1);
5297 5270
5298 extern void CreateDefaultBLVLevel(); 5271 __debugbreak();
5272 /*extern void CreateDefaultBLVLevel();
5299 CreateDefaultBLVLevel(); 5273 CreateDefaultBLVLevel();
5300 5274
5301 extern OPENFILENAMEA ofn; 5275 OPENFILENAMEA ofn;
5302 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) 5276 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
5303 { 5277 {
5304 pMouse->Activate(1); 5278 pMouse->Activate(1);
5305 break; 5279 break;
5306 } 5280 }
5307 _chdir("..\\"); 5281 _chdir("..\\");
5308 strcpy(pCurrentMapName, ofn.lpstrFileTitle); 5282 strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/
5309 pMouse->Activate(1); 5283 pMouse->Activate(1);
5310 pGame->Loop(); 5284 pGame->Loop();
5311 } 5285 }
5312 } 5286 }
5313 if ( uGameState == GAME_STATE_LOADING_GAME ) 5287 if ( uGameState == GAME_STATE_LOADING_GAME )
5535 viewparams->uSomeW = viewparams->uScreen_BttmR_Y; 5509 viewparams->uSomeW = viewparams->uScreen_BttmR_Y;
5536 5510
5537 pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y); 5511 pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y);
5538 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) 5512 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
5539 pOutdoorCamera->_485F64(); 5513 pOutdoorCamera->_485F64();
5540 }
5541
5542 //----- (00466B8C) --------------------------------------------------------
5543 int AbortWithError()
5544 {
5545 if ( !aborting_app )
5546 {
5547 ClipCursor(0);
5548 aborting_app = 1;
5549 if ( !pRenderer->bWindowMode )
5550 pRenderer->ChangeBetweenWinFullscreenModes();
5551 if ( MessageBoxA(0, pGlobalTXT_LocalizationStrings[176], pGlobalTXT_LocalizationStrings[59], 0x34u) == 6 )
5552 SaveGame(1, 0); // "Internal Error"
5553 // "Might and Magic VII has detected an internal error and will be forced to close. Would you like us to autosave your game before closing?"
5554 Game_DeinitializeAndTerminate(1);
5555 }
5556 return 0;
5557 }
5558 // 720018: using guessed type int aborting_app;
5559
5560 //----- (00466BE5) --------------------------------------------------------
5561 void Abortf(const char *Format, ...)
5562 {
5563 va_list va; // [sp+8h] [bp+8h]@1
5564
5565 va_start(va, Format);
5566 if ( !pRenderer->bWindowMode )
5567 pRenderer->ChangeBetweenWinFullscreenModes();
5568 vsprintf(pTmpBuf.data(), Format, va);
5569 if ( pMouse )
5570 pMouse->Activate(0);
5571 ClipCursor(0);
5572 MessageBoxA(0, pTmpBuf.data(), "Error", 0x30u);
5573 Game_DeinitializeAndTerminate(1);
5574 } 5514 }
5575 5515
5576 //----- (00466C40) -------------------------------------------------------- 5516 //----- (00466C40) --------------------------------------------------------
5577 const wchar_t *MENU_STATE_to_string(MENU_STATE m) 5517 const wchar_t *MENU_STATE_to_string(MENU_STATE m)
5578 { 5518 {