Mercurial > mm7
annotate VideoPlayer.cpp @ 2369:bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
author | Grumpy7 |
---|---|
date | Mon, 12 May 2014 01:50:32 +0200 |
parents | 63ad4e3606f4 |
children | bbf8a522dcec |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2223
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
0 | 2 |
2336 | 3 #include "mm7_unsorted_subs.h" |
0 | 4 #include "Bink_Smacker.h" |
5 | |
1262 | 6 #include "mm7_data.h" |
1016 | 7 #include "CShow.h" |
8 #include "Mouse.h" | |
9 | |
0 | 10 #include "VideoPlayer.h" |
2345 | 11 #include "MediaPlayer.h" |
0 | 12 #include "AudioPlayer.h" |
13 #include "Game.h" | |
14 #include "Render.h" | |
15 #include "Party.h" | |
16 #include "GUIWindow.h" | |
2044 | 17 #include "Timer.h" |
0 | 18 #include "Log.h" |
1253 | 19 #include "texts.h" |
1299 | 20 #include "UI\UIHouses.h" |
0 | 21 |
22 VideoPlayer *pVideoPlayer = nullptr; | |
23 | |
2347 | 24 #pragma comment(lib, "Version.lib") |
0 | 25 bool GetDllVersion(const wchar_t *pDllName, uint *pMajor, uint *pMinor) |
26 { | |
27 uint uVersionSize = GetFileVersionInfoSizeW(pDllName, nullptr); | |
28 void *pVersionData = HeapAlloc(GetProcessHeap(), 0, uVersionSize); | |
29 { | |
30 GetFileVersionInfoW(pDllName, 0, uVersionSize, pVersionData); | |
31 | |
32 VS_FIXEDFILEINFO *pInfo = nullptr; | |
33 UINT uInfoSize = 0; | |
34 VerQueryValueW(pVersionData, L"\\", (void **)&pInfo, &uInfoSize); | |
35 | |
36 if (!pMajor || !pMinor) | |
37 { | |
38 HeapFree(GetProcessHeap(), 0, pVersionData); | |
39 return false; | |
40 } | |
41 *pMajor = pInfo->dwFileVersionMS; | |
42 *pMinor = pInfo->dwFileVersionLS; | |
43 } | |
44 HeapFree(GetProcessHeap(), 0, pVersionData); | |
45 return true; | |
46 } | |
47 | |
48 //----- (004BF794) -------------------------------------------------------- | |
2290 | 49 void ShowMM7IntroVideo_and_LoadingScreen() |
0 | 50 { |
51 RGBTexture tex; // [sp+Ch] [bp-30h]@1 | |
2290 | 52 unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8 |
53 unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8 | |
0 | 54 |
55 pVideoPlayer->bStopBeforeSchedule = false; | |
165 | 56 pVideoPlayer->pResetflag = 0; |
2290 | 57 bGameoverLoop = true; |
256 | 58 if (!bNoVideo) |
0 | 59 { |
60 pRenderer->PresentBlackScreen(); | |
61 if ( !pVideoPlayer->bStopBeforeSchedule ) | |
2290 | 62 PlayFullscreenMovie(MOVIE_Intro, true); |
0 | 63 } |
2334 | 64 // char pContainerName[64]; |
2278 | 65 |
2290 | 66 tex.Load("mm6title.pcx", 2); |
0 | 67 pRenderer->BeginScene(); |
68 pRenderer->DrawTextureRGB(0, 0, &tex); | |
69 free(tex.pPixels); | |
70 tex.pPixels = 0; | |
762 | 71 |
2290 | 72 //LoadFonts_and_DrawCopyrightWindow(); |
73 DrawMM7CopyrightWindow(); | |
762 | 74 |
0 | 75 pRenderer->EndScene(); |
76 pRenderer->Present(); | |
1004 | 77 |
78 #ifndef _DEBUG | |
79 Sleep(1500); // let the copyright window stay for a while | |
80 #endif | |
81 | |
2290 | 82 if (!bNoSound && pAudioPlayer->hAILRedbook ) |
0 | 83 { |
84 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); | |
85 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
2218 | 86 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS); |
0 | 87 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); |
2290 | 88 } |
89 bGameoverLoop = false; | |
0 | 90 } |
91 | |
92 //----- (004BE70E) -------------------------------------------------------- | |
1802 | 93 void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) |
0 | 94 { |
95 int v4; // ebp@1 | |
96 MSG Msg; // [sp+Ch] [bp-1Ch]@12 | |
2218 | 97 |
0 | 98 v4 = a2; |
2061 | 99 if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) ) |
0 | 100 { |
101 if ( a2 == 2 ) | |
102 v4 = 0; | |
2347 | 103 ShowCursor(0);//Убрать курсор |
104 OpenGlobalMovie(pMovieName, 0, ScreenSizeFlag); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
105 bPlayingMovie = 1; |
2218 | 106 field_44 = v4; |
2347 | 107 pRenderer->ClearTarget(0); |
151 | 108 pCurrentScreen = SCREEN_VIDEO; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
109 |
2218 | 110 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
111 RECT rc_client; | |
112 GetClientRect(hwnd, &rc_client); | |
113 int client_width = rc_client.right - rc_client.left, | |
114 client_height = rc_client.bottom - rc_client.top; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
115 |
2218 | 116 HDC dc = GetDC(hwnd); |
117 HDC back_dc = CreateCompatibleDC(dc); | |
118 HBITMAP back_bmp; | |
119 SelectObject(back_dc, back_bmp = CreateCompatibleBitmap(dc, client_width, client_height)); | |
2347 | 120 |
121 DWORD t = GetTickCount();//текущее время от запуска ОС | |
122 | |
123 end_current_file = false;//установить флаг конца видеоролика | |
124 | |
125 while (true) //Цикл воспроизведения видеоролика | |
2218 | 126 { |
127 if ( pVideoPlayer->bStopBeforeSchedule ) | |
128 break; | |
129 while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE)) | |
130 { | |
131 if (Msg.message == 18) | |
132 Game_DeinitializeAndTerminate(0); | |
133 if (Msg.message == 15) | |
134 break; | |
135 TranslateMessage(&Msg); | |
136 DispatchMessageA(&Msg); | |
137 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
138 |
2347 | 139 double dt = (GetTickCount() - t) / 1000.0; //изменение времени |
2345 | 140 //dt = 1.0/15.0; |
141 t = GetTickCount(); | |
142 | |
143 //log("dt=%.5f\n", dt); | |
144 | |
145 auto image = new char[client_width * client_height * 4]; | |
146 | |
2347 | 147 pMovie->GetNextFrame(dt, image); //получить следующий кадр |
148 | |
149 if (end_current_file)//достигнут ли конец видео? | |
2218 | 150 break; |
2347 | 151 |
2218 | 152 if (image) |
153 { | |
154 // draw to hwnd | |
155 BITMAPINFO bmi; | |
156 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
157 bmi.bmiHeader.biWidth = client_width; | |
158 bmi.bmiHeader.biHeight = -client_height; | |
159 bmi.bmiHeader.biPlanes = 1; | |
160 bmi.bmiHeader.biBitCount = 32; | |
161 bmi.bmiHeader.biCompression = BI_RGB; | |
162 bmi.bmiHeader.biSizeImage = 0; | |
163 bmi.bmiHeader.biXPelsPerMeter = 0; | |
164 bmi.bmiHeader.biYPelsPerMeter = 0; | |
165 bmi.bmiHeader.biClrUsed = 0; | |
166 bmi.bmiHeader.biClrImportant = 0; | |
167 GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS); | |
168 SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS); | |
169 BitBlt(dc, 0, 0, client_width, client_height, back_dc, 0, 0, SRCCOPY); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
170 |
2347 | 171 delete[] image;//удалить кадр |
2218 | 172 } |
2347 | 173 |
174 GUI_MainMenuMessageProc(); //после отрисовки, т.к. иначе вылетает dt = 0.03, image - ??? | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
175 |
2347 | 176 if (pVideoPlayer->bStopBeforeSchedule == 1)//остановка видео |
177 Sleep(1000); //пауза после видеоролика | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
178 } |
2347 | 179 |
180 pVideoPlayer->Unload(); | |
181 | |
227 | 182 if (a4 == 1) |
151 | 183 pCurrentScreen = SCREEN_GAME; |
2347 | 184 |
0 | 185 pVideoPlayer->bPlayingMovie = 0; |
2347 | 186 |
187 ShowCursor(1);//вернуть курсор | |
188 | |
151 | 189 if ( pCurrentScreen == SCREEN_VIDEO ) |
190 pCurrentScreen = SCREEN_GAME; | |
0 | 191 } |
192 } | |
193 | |
194 //----- (004BE9D8) -------------------------------------------------------- | |
1802 | 195 void VideoPlayer::Initialize(OSWindow *target_window) |
0 | 196 { |
197 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9 | |
198 | |
1802 | 199 window = target_window; |
200 | |
0 | 201 uint uBinkVersionMajor = -1, |
202 uBinkVersionMinor = -1; | |
203 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor); | |
204 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor; | |
205 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
206 strcpy(pTmpBuf.data(), "anims\\might7.vid"); |
2218 | 207 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 208 if ( hMightVid == INVALID_HANDLE_VALUE ) |
209 { | |
1217 | 210 sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data()); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
211 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 212 return; |
213 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
214 strcpy(pTmpBuf.data(), "anims\\magic7.vid"); |
2218 | 215 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 216 if ( hMagicVid == INVALID_HANDLE_VALUE ) |
217 { | |
218 if ( !bCanLoadFromCD ) | |
2218 | 219 { |
1217 | 220 sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data()); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
221 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 222 return; |
2218 | 223 } |
1217 | 224 sprintf(pTmpBuf2.data(), "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf.data()); |
2218 | 225 hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 226 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE ) |
227 { | |
2218 | 228 sprintf(pTmpBuf2.data(), "Can't open file - %s", pTmpBuf.data()); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
229 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 230 return; |
231 } | |
232 } | |
233 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0); | |
234 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); | |
1583 | 235 pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2); |
236 pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2); | |
0 | 237 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); |
238 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0); | |
239 } | |
240 | |
241 //----- (004BEBD7) -------------------------------------------------------- | |
242 void VideoPlayer::Unload() | |
243 { | |
1802 | 244 if ( pSmackMovieBlit ) |
0 | 245 { |
1802 | 246 SmackBlitClose(pSmackMovieBlit); |
247 pSmackMovieBlit = 0; | |
0 | 248 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
249 bBufferLoaded = 0; |
1802 | 250 uMovieFormat = 0; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
251 uMovieFormatSwapped = 0; |
1802 | 252 memset(pCurrentMovieName, 0, 0x40); |
0 | 253 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) |
254 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | |
255 pEventTimer->Resume(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
256 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
257 if (pMovie) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
258 { |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
259 delete pMovie; |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
260 pMovie = nullptr; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
261 } |
0 | 262 } |
263 | |
1802 | 264 void VideoPlayer::_inlined_in_463149() |
265 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
266 if (pMovie) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
267 { |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
268 pRenderer->BeginScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
269 pMouse->DrawCursorToTarget(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
270 UpdatePalette(); |
2216 | 271 pMouse->ReadCursorWithItem(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
272 pRenderer->EndScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
273 } |
1802 | 274 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
275 |
2356 | 276 void VideoPlayer::UpdatePalette() //UpdateVideo |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
277 { |
2218 | 278 Log::Warning(L"smacker"); |
2360 | 279 loop_current_file = true;//зацикленный ролик |
2218 | 280 pRenderer->BeginScene(); |
2360 | 281 if (end_current_file)//видео завершено/перезагрузка |
2218 | 282 { |
2222 | 283 int width = game_viewport_width; |
284 int height = game_viewport_height; | |
2360 | 285 MovieRelease(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
286 |
2218 | 287 SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN); |
2360 | 288 pMovie = nullptr; |
289 pMovie = pMediaPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height); | |
290 end_current_file = false; | |
2218 | 291 } |
2360 | 292 //else |
293 //{ | |
2345 | 294 double dt = (GetTickCount() - time_video_begin) / 1000.0; |
295 //dt = 1.0/15.0; | |
296 time_video_begin = GetTickCount(); | |
297 | |
298 //log("dt=%.5f\n", dt); | |
299 | |
300 auto image = new char[current_movie_width * current_movie_height * 4]; | |
301 | |
302 pMovie->GetNextFrame(dt, image); | |
303 | |
2222 | 304 int image_array[460 * 344];//game_viewport_width * game_viewport_height |
2218 | 305 if (image) |
306 { | |
2222 | 307 memcpy(image_array, image, sizeof (image_array)); |
2223 | 308 for (unsigned int y = 8; y < 8 + game_viewport_height; ++y)//координаты местоположения видеоролика |
2221 | 309 { |
310 for (unsigned int x = 8; x < 8 + game_viewport_width; ++x) | |
311 { | |
2222 | 312 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + x + y * pRenderer->uTargetSurfacePitch; |
313 *p = image_array[((x - 8) + ((y - 8)*game_viewport_width))]; | |
2221 | 314 } |
315 } | |
2218 | 316 delete[] image; |
317 } | |
2360 | 318 //} |
2218 | 319 pRenderer->EndScene(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
320 } |
0 | 321 |
322 //----- (004BF28F) -------------------------------------------------------- | |
898 | 323 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
0 | 324 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
325 if (!this->bBufferLoaded) |
0 | 326 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
327 //Prepare(); |
2218 | 328 pEventTimer->Pause(); |
329 if (pAudioPlayer->hAILRedbook) | |
330 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
331 |
2218 | 332 bStopBeforeSchedule = false; |
333 bBufferLoaded = 1; | |
334 bPlayingMovie = false; | |
335 bFirstFrame = false; | |
336 bUsingSmackerMMX = SmackUseMMX(1); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
337 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
338 this->bLoopPlaying = a3_1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
339 if ( LOBYTE(this->field_104) == 1 ) |
0 | 340 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
341 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
0 | 342 return; |
343 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
344 |
2218 | 345 LoadMovie(pMovieName); |
2345 | 346 time_video_begin = GetTickCount(); |
0 | 347 } |
348 } | |
349 | |
350 //----- (004BF3F9) -------------------------------------------------------- | |
351 bool VideoPlayer::AnyMovieLoaded() | |
352 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
353 return pMovie;// pSmackerMovie || pBinkMovie; |
0 | 354 } |
355 | |
356 //----- (004BF411) -------------------------------------------------------- | |
898 | 357 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
0 | 358 { |
2334 | 359 // unsigned int v10; // eax@11 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
360 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
361 if (!this->bBufferLoaded) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
362 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
363 pEventTimer->Pause(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
364 if (pAudioPlayer->hAILRedbook) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
365 AIL_redbook_pause(pAudioPlayer->hAILRedbook); |
0 | 366 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
367 bStopBeforeSchedule = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
368 bBufferLoaded = 1; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
369 bPlayingMovie = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
370 bFirstFrame = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
371 bUsingSmackerMMX = SmackUseMMX(1); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
372 this->bLoopPlaying = bLoop; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
373 LoadMovie(pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
374 return; |
0 | 375 } |
376 } | |
377 | |
2347 | 378 //----- (004BF5B2) -------------------------------------------------------- |
0 | 379 void VideoPlayer::_4BF5B2() |
380 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
381 //__debugbreak(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
382 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
383 /*if ( this->uMovieFormat == 2 ) |
0 | 384 { |
385 BinkGoto(pBinkMovie, 1, 0); | |
386 BinkDoFrame(pBinkMovie); | |
387 BinkNextFrame(pBinkMovie); | |
388 } | |
389 else | |
390 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
391 if ( this->uMovieFormat != 1 ) |
0 | 392 return; |
393 SmackGoto(pSmackerMovie, 1); | |
394 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
395 { | |
396 SmackDoFrame(pSmackerMovie); | |
397 SmackNextFrame(pSmackerMovie); | |
398 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
399 }*/ |
0 | 400 pMouse->_469E24(); |
2356 | 401 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !pMovie)//!this->pSmackerMovie ) |
0 | 402 { |
2218 | 403 bGameoverLoop = true; |
1919 | 404 HouseDialogPressCloseBtn(); |
336 | 405 window_SpeakInHouse->Release(); |
2218 | 406 pParty->uFlags &= 0xFFFFFFFD; |
481 | 407 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) |
0 | 408 { |
388 | 409 pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2154
diff
changeset
|
410 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); |
2218 | 411 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, 0x31, "", 0); |
412 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, 0x32, "", 0); | |
413 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, 0x33, "", 0); | |
414 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, 0x34, "", 0); | |
0 | 415 } |
416 bGameoverLoop = 0; | |
417 } | |
418 } | |
419 | |
420 //----- (004BF73A) -------------------------------------------------------- | |
898 | 421 void VideoPlayer::SelectMovieType() |
0 | 422 { |
423 char Source[32]; // [sp+Ch] [bp-40h]@1 | |
424 | |
425 strcpy(Source, this->pCurrentMovieName); | |
426 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
427 if ( this->uMovieFormatSwapped == 1 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
428 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
429 else if ( this->uMovieFormatSwapped == 2 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
430 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
0 | 431 else |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
432 __debugbreak(); |
0 | 433 } |
434 | |
435 //----- (004BF8F6) -------------------------------------------------------- | |
436 void VideoPlayer::PlayDeathMovie() | |
437 { | |
438 bStopBeforeSchedule = 0; | |
165 | 439 pResetflag = 0; |
1397 | 440 PlayFullscreenMovie(MOVIE_Death, true); |
441 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); | |
1262 | 442 } |
443 | |
444 //----- (004BE6F5) -------------------------------------------------------- | |
445 VideoPlayer::VideoPlayer() : | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
446 bBufferLoaded(0), |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
447 //pBinkMovie(nullptr), pBinkBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
448 //pSmackerMovie(nullptr), pSmackerBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
449 pSmackMovieBlit(nullptr) |
1262 | 450 { |
451 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); | |
452 bStopBeforeSchedule = false; | |
453 pResetflag = 0; | |
2356 | 454 pMediaPlayer = new Media::MPlayer;//создаётся плеер |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
455 pMovie = nullptr; |
1262 | 456 //pBinkMovie = nullptr; |
457 } | |
2134 | 458 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
459 int VideoPlayer::readFunction(void* opaque, uint8_t* buf, int buf_size) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
460 { |
2218 | 461 HANDLE stream = (HANDLE)opaque; |
462 //int numBytes = stream->read((char*)buf, buf_size); | |
463 int numBytes; | |
464 ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL); | |
465 return numBytes; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
466 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
467 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
468 int64_t VideoPlayer::seekFunction(void* opaque, int64_t offset, int whence) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
469 { |
2218 | 470 if (whence == AVSEEK_SIZE) |
471 return pVideoPlayer->uSize; | |
472 HANDLE h = (HANDLE)opaque; | |
473 LARGE_INTEGER li; | |
474 li.QuadPart = offset; | |
475 | |
476 if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN)) | |
477 return -1; | |
478 return li.QuadPart; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
479 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
480 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
481 void VideoPlayer::LoadMovie(const char * pFilename) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
482 { |
2218 | 483 char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2 |
484 char pVideoNameSmk[120]; // [sp+Ch] [bp-28h]@2 | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
485 |
2218 | 486 sprintf(pVideoNameBik, "%s.bik", pFilename); |
487 sprintf(pVideoNameSmk, "%s.smk", pFilename); | |
488 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
489 { | |
490 if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName)) | |
491 { | |
492 hVidFile = hMightVid; | |
493 uOffset = pMightVideoHeaders[i].uFileOffset; | |
494 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
495 this->uMovieFormat = 1; | |
496 this->uMovieFormatSwapped = 2; | |
497 } | |
498 } | |
499 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
500 { | |
501 if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName)) | |
502 { | |
503 hVidFile = hMagicVid; | |
504 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
505 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
506 this->uMovieFormat = 2; | |
507 this->uMovieFormatSwapped = 1; | |
508 } | |
509 if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName)) | |
510 { | |
511 hVidFile = hMagicVid; | |
512 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
513 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
514 this->uMovieFormat = 1; | |
515 this->uMovieFormatSwapped = 2; | |
516 } | |
517 } | |
518 if (!hVidFile) | |
519 { | |
520 Unload(); | |
521 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0); | |
522 return; | |
523 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
524 |
2218 | 525 SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN); |
526 strcpy(this->pCurrentMovieName, pFilename); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
527 |
2218 | 528 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
529 RECT rc_client; | |
530 GetClientRect(hwnd, &rc_client); | |
531 int client_width = rc_client.right - rc_client.left, | |
532 client_height = rc_client.bottom - rc_client.top; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
533 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
534 |
2356 | 535 pMovie = pMediaPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, client_width, client_height); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
536 |
2345 | 537 } |