Skip to content

Commit

Permalink
32-bit fix for REALS
Browse files Browse the repository at this point in the history
  • Loading branch information
Fjara-h committed Apr 8, 2024
1 parent 83b7920 commit d8487b7
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 25 deletions.
Binary file modified component/foo_skipcount-v2.0.4.fb2k-component
Binary file not shown.
Binary file modified component/foo_skipcount.dll
Binary file not shown.
Binary file modified component/x64/foo_skipcount.dll
Binary file not shown.
Binary file modified pdbs/foo_skipcount.pdb
Binary file not shown.
Binary file modified pdbs/x64/foo_skipcount.pdb
Binary file not shown.
4 changes: 2 additions & 2 deletions src/contextmenu.cpp
Expand Up @@ -528,7 +528,7 @@ namespace foo_skipcount {
}
}
if(writeMsg) {
pfc::stringLite skipTimes = getSkipTimesStr(recordWrite.skipTimes, false, true, ", ", false).c_str();
pfc::stringLite skipTimes = getSkipTimesStr(recordWrite.skipTimes, false, true, false).c_str();
if(skipTimes.get_length() > MAX_DISPLAY_LENGTH) {
skipTimes.truncate(MAX_DISPLAY_LENGTH);
skipTimes += "...";
Expand Down Expand Up @@ -655,7 +655,7 @@ namespace foo_skipcount {
info[i].meta_set(tagMetaFieldString.at("current").c_str(), std::to_string(getLocalTimestamp(filetimestamp_from_system_timer(), false)).c_str());
}
if(tagAllTimestampsRaw) {
info[i].meta_set(tagMetaFieldString.at("times").c_str(), getSkipTimesStr(record.skipTimes, false, false, tagTimestampDelimiters[tagDelimiter], false).c_str());
info[i].meta_set(tagMetaFieldString.at("times").c_str(), getSkipTimesStr(record.skipTimes, false, false, false, tagTimestampDelimiters[tagDelimiter]).c_str());
}
tmp += hash;
}
Expand Down
16 changes: 8 additions & 8 deletions src/fields.cpp
Expand Up @@ -71,7 +71,7 @@ namespace foo_skipcount {
out->write(titleformat_inputtypes::meta, "[]");
}
else {
out->write(titleformat_inputtypes::meta, getSkipTimesStr(record.skipTimes, (index == FIELD_SKIP_TIMES_JS), (index == FIELD_SKIP_TIMES), ", ", (index == FIELD_SKIP_TIMES_JS)).c_str());
out->write(titleformat_inputtypes::meta, getSkipTimesStr(record.skipTimes, (index == FIELD_SKIP_TIMES_JS), (index == FIELD_SKIP_TIMES)).c_str());
}
break;
}
Expand All @@ -96,7 +96,7 @@ namespace foo_skipcount {

t_uint skipCount = 0, nextCount = 0, randomCount = 0, previousCount = 0, doubleClickCount = 0;
pfc::stringLite skipTimesStr = "", skipTimesRawStr = "", skipTimesJSStr = "", latestSkipStr = "", oldestSkipStr = "";
t_filetimestamp latestSkip = filetimestamp_invalid, oldestSkip = UINTPTR_MAX;
t_filetimestamp latestSkip = filetimestamp_invalid, oldestSkip = filetimestamp_invalid;

record_t firstRecord;
for(metadb_index_hash hash : hashes) {
Expand All @@ -111,35 +111,35 @@ namespace foo_skipcount {
previousCount += record.skipCountPrevious;
doubleClickCount += record.skipCountDoubleClick;
if(!record.skipTimes.empty()) {
if(oldestSkip > record.skipTimes.front()) {
if(oldestSkip > record.skipTimes.front() || oldestSkip == filetimestamp_invalid) {
oldestSkip = record.skipTimes.front();
}
if(latestSkip < record.skipTimes.back()) {
if(latestSkip < record.skipTimes.back() || latestSkip == filetimestamp_invalid) {
latestSkip = record.skipTimes.back();
}
}
}

if(hashes.get_count() == 1 && !firstRecord.skipTimes.empty()) {
skipTimesStr = getSkipTimesStr(firstRecord.skipTimes, false, true, ", ", true).c_str();
skipTimesStr = getSkipTimesStr(firstRecord.skipTimes, false, true).c_str();
#define MAX_PROPERTY_LENGTH 500
if(skipTimesStr.get_length() > MAX_PROPERTY_LENGTH) {
skipTimesStr.truncate(MAX_PROPERTY_LENGTH);
skipTimesStr += "...";
}
skipTimesRawStr = getSkipTimesStr(firstRecord.skipTimes, false, false, ", ", true).c_str();
skipTimesRawStr = getSkipTimesStr(firstRecord.skipTimes, false, false).c_str();
if(skipTimesRawStr.get_length() > MAX_PROPERTY_LENGTH) {
skipTimesRawStr.truncate(MAX_PROPERTY_LENGTH);
skipTimesRawStr += "...";
}
skipTimesJSStr = getSkipTimesStr(firstRecord.skipTimes, true, false, ", ", true).c_str();
skipTimesJSStr = getSkipTimesStr(firstRecord.skipTimes, true, false).c_str();
if(skipTimesJSStr.get_length() > MAX_PROPERTY_LENGTH) {
skipTimesJSStr.truncate(MAX_PROPERTY_LENGTH);
skipTimesJSStr += "...";
}
}

oldestSkipStr = (oldestSkip == UINTPTR_MAX) ? "Never" : foobar2000_io::format_filetimestamp(oldestSkip);
oldestSkipStr = (oldestSkip == filetimestamp_invalid) ? "Never" : foobar2000_io::format_filetimestamp(oldestSkip);
latestSkipStr = (latestSkip == filetimestamp_invalid) ? "Never" : foobar2000_io::format_filetimestamp(latestSkip);

p_out.set_property(strPropertiesGroup, priorityBase + 1, PFC_string_formatter() << "Skip count", PFC_string_formatter() << skipCount << " times");
Expand Down
20 changes: 5 additions & 15 deletions src/record.h
Expand Up @@ -28,33 +28,23 @@ namespace foo_skipcount {
}

inline static t_filetimestamp getLatestSkip(record_t record) {
if((record.version > 1 && !record.skipTimes.empty())) {
return (record.skipTimes.size() == 1) ? record.skipTimes[0] : record.skipTimes.back();
}
else {
return 0;
}
return record.skipTimes.empty() ? 0 : record.skipTimes.back();
}

inline static t_filetimestamp getOldestSkip(record_t record) {
if((record.version > 1 && !record.skipTimes.empty())) {
return (record.skipTimes.size() == 1) ? record.skipTimes[0] : record.skipTimes.front();
}
else {
return 0;
}
return record.skipTimes.empty() ? 0 : record.skipTimes.front();
}

static std::string getSkipTimesStr(std::vector<t_filetimestamp> skipTimes, bool JS, bool dateTime, std::string delimiter = ", ", bool useArrayChars = false) {
static std::string getSkipTimesStr(std::vector<t_filetimestamp> skipTimes, bool JS, bool dateTime, bool useArrayChars = true, std::string delimiter = ", ") {
if(skipTimes.empty()) {
return useArrayChars ? "[]" : "";
}
std::string str = useArrayChars ? "[" : "";
for(t_filetimestamp& time : skipTimes) {
if(dateTime) {
str.append(useArrayChars ? "" : "\"");
str.append(useArrayChars ? "\"" : "");
str.append(foobar2000_io::format_filetimestamp(time));
str.append(useArrayChars ? "" : "\"");
str.append(useArrayChars ? "\"" : "");
}
else {
str.append(std::to_string(getLocalTimestamp(time, JS)));
Expand Down

0 comments on commit d8487b7

Please sign in to comment.