Decompile fn_09165 (BinkMovies::Get)
Batch #14154 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_09165 BinkMovies::Get: logic confirmed by peer review Peer-reviewed-by: KWDev, codeplay, StrawberrysherbetIX Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
parent
e920b7d67e
commit
f6c2437963
2 changed files with 33 additions and 12 deletions
|
|
@ -21,6 +21,31 @@ NamedBinkMovie::~NamedBinkMovie() {
|
|||
this->decoder.reset();
|
||||
}
|
||||
|
||||
// INLINED
|
||||
std::string NamedBinkMovie::Name() const {
|
||||
return this->name;
|
||||
}
|
||||
|
||||
// INLINED
|
||||
__forceinline bool NamedBinkMovie::Open(std::string fileName, int loop) {
|
||||
if (fileName.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->decoder.reset();
|
||||
this->decoder.reset(new (std::nothrow) BinkMovie);
|
||||
if (!this->decoder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->decoder->Open(("video\\" + fileName).c_str(), loop, true) != true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->name = fileName;
|
||||
return true;
|
||||
}
|
||||
|
||||
// OFFSET: 0x007AFB50
|
||||
// FUNCTION: fn_09161
|
||||
BinkMovies::BinkMovies() = default;
|
||||
|
|
@ -32,26 +57,20 @@ BinkMovies::~BinkMovies() = default;
|
|||
// OFFSET: 0x007B00F0
|
||||
// FUNCTION: fn_09165
|
||||
NamedBinkMovie* BinkMovies::Get(std::string name, int loop) {
|
||||
for (const auto& movie : this->m_movies) {
|
||||
if (movie->name == name) {
|
||||
return movie.get();
|
||||
}
|
||||
auto found = std::find_if(this->m_movies.begin(), this->m_movies.end(), [name](const std::unique_ptr<NamedBinkMovie>& movie) {
|
||||
return name.compare(movie->Name()) == 0;
|
||||
});
|
||||
if (found != this->m_movies.end()) {
|
||||
return found->get();
|
||||
}
|
||||
|
||||
std::unique_ptr<NamedBinkMovie> movie(new (std::nothrow) NamedBinkMovie);
|
||||
if (!movie || name.empty()) {
|
||||
if (!movie || !movie->Open(name, loop)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
movie->decoder.reset(new (std::nothrow) BinkMovie);
|
||||
if (!movie->decoder || !movie->decoder->Open((std::string("video\\") + name).c_str(), loop, true)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
movie->name = name;
|
||||
NamedBinkMovie* result = movie.get();
|
||||
this->m_movies.push_back(std::move(movie));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ struct MoviePosition {
|
|||
struct NamedBinkMovie {
|
||||
NamedBinkMovie();
|
||||
~NamedBinkMovie();
|
||||
std::string Name() const;
|
||||
bool Open(std::string fileName, int loop);
|
||||
/* 0000 */ std::string name;
|
||||
/* 0018 */ std::unique_ptr<BinkMovie> decoder;
|
||||
/* 001C */ float radius;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue