mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added: Regex filtering for pbo index.
Changed: Logging cleanup, default files and paths. Changed: initialization order of plugin (PRE-Init for vehicle registration).
This commit is contained in:
parent
d4a354d5b8
commit
91bd1e7c7b
@ -3,5 +3,4 @@
|
||||
// Handle damage to local vehicles
|
||||
[QGVAR(hp), FUNC(dispatchHitPart)] call EFUNC(common,addEventHandler);
|
||||
|
||||
[] call FUNC(initializeExtension);
|
||||
[FUNC(monitorResultsPFH), 0, []] call CBA_fnc_addPerFrameHandler;
|
@ -30,4 +30,6 @@ FUNC(_textVector) = {
|
||||
_str
|
||||
};
|
||||
|
||||
[] call FUNC(initializeExtension);
|
||||
|
||||
ADDON = true;
|
||||
|
@ -784,12 +784,12 @@ namespace el {
|
||||
#else
|
||||
# if ELPP_OS_UNIX
|
||||
# if ELPP_OS_ANDROID
|
||||
static const char* kDefaultLogFile = "logs/myeasylog.log";
|
||||
static const char* kDefaultLogFile = "logs/ace.log";
|
||||
# else
|
||||
static const char* kDefaultLogFile = "logs/myeasylog.log";
|
||||
static const char* kDefaultLogFile = "logs/ace.log";
|
||||
# endif // ELPP_OS_ANDROID
|
||||
# elif ELPP_OS_WINDOWS
|
||||
static const char* kDefaultLogFile = "logs\\myeasylog.log";
|
||||
static const char* kDefaultLogFile = "logs\\ace.log";
|
||||
# endif // ELPP_OS_UNIX
|
||||
#endif // defined(ELPP_DEFAULT_LOG_FILE)
|
||||
#if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <sstream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <regex>
|
||||
|
||||
#define NT_SUCCESS(x) ((x) >= 0)
|
||||
#define STATUS_INFO_LENGTH_MISMATCH 0xc0000004
|
||||
@ -103,7 +104,12 @@ namespace ace {
|
||||
namespace pbo {
|
||||
|
||||
bool search::index_files() {
|
||||
return index_files(".*");
|
||||
}
|
||||
|
||||
bool search::index_files(const std::string &filter) {
|
||||
std::ifstream pbo_stream;
|
||||
std::regex txt_regex(filter);
|
||||
|
||||
if (_active_pbo_list.size() < 1)
|
||||
return false;
|
||||
@ -118,10 +124,12 @@ namespace ace {
|
||||
ace::pbo::archive _archive(pbo_stream);
|
||||
for (ace::pbo::entry_p & entry : _archive.entries) {
|
||||
if (entry->filename != "") {
|
||||
std::string full_virtual_path = _archive.info->data + "\\" + entry->filename;
|
||||
std::transform(full_virtual_path.begin(), full_virtual_path.end(), full_virtual_path.begin(), ::tolower);
|
||||
_file_pbo_index[full_virtual_path] = pbo_file_path;
|
||||
//LOG(DEBUG) << full_virtual_path << " = " << pbo_file_path;
|
||||
if (std::regex_match(entry->filename, txt_regex)) {
|
||||
std::string full_virtual_path = _archive.info->data + "\\" + entry->filename;
|
||||
std::transform(full_virtual_path.begin(), full_virtual_path.end(), full_virtual_path.begin(), ::tolower);
|
||||
_file_pbo_index[full_virtual_path] = pbo_file_path;
|
||||
//LOG(DEBUG) << full_virtual_path << " = " << pbo_file_path;
|
||||
}
|
||||
}
|
||||
}
|
||||
pbo_stream.close();
|
||||
@ -130,6 +138,11 @@ namespace ace {
|
||||
return true;
|
||||
}
|
||||
|
||||
search::search(const std::string & filter) {
|
||||
generate_pbo_list();
|
||||
index_files(filter);
|
||||
}
|
||||
|
||||
search::search() {
|
||||
generate_pbo_list();
|
||||
index_files();
|
||||
|
@ -8,11 +8,13 @@ namespace ace {
|
||||
class search {
|
||||
public:
|
||||
search();
|
||||
search(const std::string &);
|
||||
|
||||
const std::unordered_map<std::string, std::string> & file_index() { return _file_pbo_index; }
|
||||
const std::vector<std::string> & active_pbo_list() { return _active_pbo_list; }
|
||||
protected:
|
||||
bool index_files();
|
||||
bool index_files(const std::string &);
|
||||
bool generate_pbo_list();
|
||||
|
||||
std::unordered_map<std::string, std::string> _file_pbo_index;
|
||||
|
@ -7,7 +7,7 @@ namespace ace {
|
||||
bool model_collection::init(void) {
|
||||
if (_initialized) return true;
|
||||
|
||||
_pbo_searcher = std::make_shared<ace::pbo::search>();
|
||||
_pbo_searcher = std::make_shared<ace::pbo::search>(".*\.p3d");
|
||||
|
||||
_initialized = true;
|
||||
_ready = true;
|
||||
|
@ -28,6 +28,7 @@ namespace ace {
|
||||
|
||||
bool initialized(void) const { return _initialized; }
|
||||
bool ready(void) const { return _ready; }
|
||||
|
||||
protected:
|
||||
bool _load_model(const std::string &, const std::string &);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user