Skip to content

Commit 06b5b6d

Browse files
committed
Dungeon Stomp DirectX12
1 parent 4dd72b4 commit 06b5b6d

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎bin/DungeonStomp.exe‎

-5 KB
Binary file not shown.

‎src/World.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,10 +1001,11 @@ void DrawIndexedItems(int fakel, int vert_index) {
10011001
}
10021002
}
10031003

1004-
wchar_t *charToWChar(const char *text) {
1004+
std::wstring charToWChar(const char *text) {
10051005
const size_t size = strlen(text) + 1;
1006-
wchar_t *wText = new wchar_t[size];
1006+
std::wstring wText(size, L'\0');
10071007
size_t outSize;
1008-
mbstowcs_s(&outSize, wText, size, text, size);
1008+
mbstowcs_s(&outSize, &wText[0], size, text, size);
1009+
wText.resize(outSize > 0 ? outSize - 1 : 0);
10091010
return wText;
10101011
}

‎src/XAudio2BasicSound.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ void MakeWave(char *file, std::unique_ptr<uint8_t[]> waveFile) {
389389
HRESULT hr;
390390

391391
DirectX::WAVData waveData;
392-
hr = DirectX::LoadWAVAudioFromFileEx(charToWChar(file), waveFile, waveData);
392+
hr = DirectX::LoadWAVAudioFromFileEx(charToWChar(file).c_str(), waveFile, waveData);
393393
//{
394394
// wprintf(L"Failed reading WAV file: %#X (%s)\n", hr, strFilePath);
395395
// return;
@@ -461,7 +461,7 @@ BOOL LoadSoundFiles(char *filename) {
461461
GetCurrentDirectory(100, NPath);
462462

463463
// DirectX::WAVData waveData;
464-
hr = DirectX::LoadWAVAudioFromFileEx(charToWChar(file), sound_buffer[numsounds].waveFile, sound_buffer[numsounds].waveData);
464+
hr = DirectX::LoadWAVAudioFromFileEx(charToWChar(file).c_str(), sound_buffer[numsounds].waveFile, sound_buffer[numsounds].waveData);
465465
hr = pXAudio2->CreateSourceVoice(&sound_list[numsounds].pSourceVoice, sound_buffer[numsounds].waveData.wfx);
466466
strcpy_s(sound_buffer[numsounds].name, name);
467467
sound_list[numsounds].soundbufferid = numsounds;

‎src/world.hpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <windows.h>
66
#include <windowsx.h>
7+
#include <string>
78
#include "d3dtypes.h"
89
#include "GlobalSettings.hpp"
910
#include <DirectXMath.h>
@@ -535,7 +536,7 @@ int SoundID(char *name);
535536
int FreeSlave();
536537
void CheckMidiMusic();
537538
int MakeDice();
538-
wchar_t *charToWChar(const char *text);
539+
std::wstring charToWChar(const char *text);
539540
int GetNextFramePlayer();
540541

541542
#endif // __WORLD_H__

0 commit comments

Comments
 (0)