mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Fix bad include, missing static declaration, SRT path directory, and formatting
This commit is contained in:
@ -260,6 +260,7 @@ private:
|
||||
static hsBool fInit;
|
||||
static hsBool fActive;
|
||||
static hsBool fMuted;
|
||||
static bool fEnableSubtitles;
|
||||
static hsWindowHndl fWnd;
|
||||
static hsBool fUseHardware;
|
||||
static hsBool fDelayedActivate;
|
||||
|
@ -45,8 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsStream.h"
|
||||
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "../pnUtils/Private/pnUtPath.h"
|
||||
#include "../pnUtils/Private/pnUtStr.h"
|
||||
#include "../pnUtils/pnUtils.h"
|
||||
|
||||
#include <regex>
|
||||
|
||||
@ -55,8 +54,15 @@ static const std::regex timingsRegex("^(\\d{2}):(\\d{2}):(\\d{2}),(\\d{3}) --> (
|
||||
|
||||
bool plSrtFileReader::ReadFile()
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
|
||||
if (strchr(fAudioFileName, '\\') != nil)
|
||||
strcpy(path, fAudioFileName);
|
||||
else
|
||||
sprintf(path, "sfx\\%s", fAudioFileName);
|
||||
|
||||
wchar srtPathUnicode[MAX_PATH];
|
||||
StrToUnicode(srtPathUnicode, fAudioFileName, arrsize(srtPathUnicode));
|
||||
StrToUnicode(srtPathUnicode, path, arrsize(srtPathUnicode));
|
||||
PathSetExtension(srtPathUnicode, srtPathUnicode, L".sub", arrsize(srtPathUnicode));
|
||||
|
||||
if (PathDoesFileExist(srtPathUnicode)) {
|
||||
@ -70,7 +76,7 @@ bool plSrtFileReader::ReadFile()
|
||||
uint32_t subtitleNumber = 0;
|
||||
uint32_t subtitleStartTimeMs = 0;
|
||||
uint32_t subtitleEndTimeMs = 0;
|
||||
char* line;
|
||||
char line[4096];
|
||||
std::string speakerName;
|
||||
std::string subtitleText;
|
||||
std::cmatch matches;
|
||||
@ -78,8 +84,7 @@ bool plSrtFileReader::ReadFile()
|
||||
for (unsigned int lnCounter = 0; !srtFileStream.AtEnd(); lnCounter++) {
|
||||
if (lnCounter % 4 == 0 && srtFileStream.ReadLn(line)) {
|
||||
subtitleNumber = std::stoul(line);
|
||||
}
|
||||
else if (lnCounter % 4 == 1 && srtFileStream.ReadLn(line)) {
|
||||
} else if (lnCounter % 4 == 1 && srtFileStream.ReadLn(line)) {
|
||||
if (std::regex_match(line, matches, timingsRegex)) {
|
||||
if (matches.size() < 9) {
|
||||
// add error message and ensure this subtitle line won't be added to the entries
|
||||
@ -107,8 +112,7 @@ bool plSrtFileReader::ReadFile()
|
||||
subtitleEndTimeMs += std::stoul(matches[8].str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (lnCounter % 4 == 2 && srtFileStream.ReadLn(line)) {
|
||||
} else if (lnCounter % 4 == 2 && srtFileStream.ReadLn(line)) {
|
||||
if (std::regex_match(line, matches, speakerTextRegex)) {
|
||||
if (matches.size() < 5) {
|
||||
// add error message and ensure this subtitle line won't be added to the entries
|
||||
@ -124,8 +128,7 @@ bool plSrtFileReader::ReadFile()
|
||||
subtitleText = matches[5];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (lnCounter % 4 == 3 && subtitleNumber > 0 && subtitleStartTimeMs >= 0 && subtitleEndTimeMs >= 0 && !subtitleText.empty()) {
|
||||
} else if (lnCounter % 4 == 3 && subtitleNumber > 0 && subtitleStartTimeMs >= 0 && subtitleEndTimeMs >= 0 && !subtitleText.empty()) {
|
||||
// entry is complete, add to the queue and reset our temp variables
|
||||
if (!speakerName.empty())
|
||||
fEntries.emplace_back(plSrtEntry(subtitleNumber, subtitleStartTimeMs, subtitleEndTimeMs, std::move(subtitleText), std::move(speakerName)));
|
||||
|
Reference in New Issue
Block a user