RPCS3 / rpcs3

PS3 emulator/debugger
https://rpcs3.net/
GNU General Public License v2.0
15.28k stars 1.9k forks source link

Adding date/time of unlocking trophies #3777

Closed TotalCaesar659 closed 1 year ago

TotalCaesar659 commented 6 years ago

Hello, could you add date/time of unlocking to Trophy Manager?

Megamouse commented 5 years ago

I think timestamps are only added while connected to psn on real hardware

Vahkiti commented 3 years ago

I think timestamps are only added while connected to psn on real hardware

Well if that's the case they should still be logged to a separate file or something just for user convenience. As mentioned in the above apparent duplicate issue, some people may want to manually copy that data to original hardware which IS possible to do with timestamps via PS3TrophyIsGood. Another person also noted that the times ARE in fact being set already in the code, but for some reason default to 0.

jhonathanc commented 3 years ago

As @MSuih suggested, there is already some code to write timestamps to trophies, but it's always filling it with "0".

https://github.com/RPCS3/rpcs3/issues/10254#issuecomment-835179669

About it, is there anyway to set internal RTC clock of RPCS3 (if it exists) to use the system clock? If so, RPCS3 could use that to fill the correct timestamps.

Vahkiti commented 3 years ago

It's just a shame that between this and the missing header, it's so close, but otherwise generates a partially invalid file. I've also found that IMPORTING a real trophy list will actually be read initially, but entirely wiped the moment an in-game trophy trigger is hit. Not sure if it's related to this or the header, but it's still an issue.

marcoluc97 commented 1 year ago

@RipleyTom do you think RPCN can help here? Or is it something else as said in: https://github.com/RPCS3/rpcs3/issues/10254#issuecomment-835179669

RipleyTom commented 1 year ago

Technically trophies are stored on PSN but it's not a functionality I plan to implement.

marcoluc97 commented 1 year ago

Thanks for the reply. @Megamouse do you think is possible to "fix" it locally (in the TODO left) or is still needed XMB?

RobbedColek commented 1 year ago

What I've done is to modify sceNpTrophy.cpp - it's an ugly hack but it's working for me - definitely better than storing zeroes as these values.

Calculate timestamp like that: auto now = std::chrono::system_clock::now(); u64 timestamp = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch() + std::chrono::hours(24 * 719162)).count();

Trophy timestamps are in microseconds since 0001-01-01 AD - hence the calculation.

Then pass that to UnlockTrophy in same file where it's used instead of 0 as timestamp1 and timestamp2.

I could confirm in hex editor that these timestamps are now correct, but of course, this will not make them show up in RPCS3's trophy window - this would require further changes.

Megamouse commented 1 year ago

@RobbedColek can you compare the output of #13867 with your reference data?

RobbedColek commented 1 year ago

@Megamouse - Sorry for late response, I rarely get on Github.

Took a brief look - the timestamp has to be also set for the first parameter timestamp1 for it to be 'properly' written to file.

So instead of: ctxt->tropusr->UnlockTrophy(trophyId, 0, tick->tick)

You'll need: ctxt->tropusr->UnlockTrophy(trophyId, tick->tick, tick->tick)

With that change, I've tested it quickly and everything seems to be working fine!

Megamouse commented 1 year ago

@RobbedColek it should be fine now in the PR. I only wondered if the values written to file match the values that you'd expect (microseconds since ...).

RobbedColek commented 1 year ago

@Megamouse looks all fine to me, thank you for working on this!