make BB games deterministic for replays

This commit is contained in:
Martin Michelsen
2023-12-23 23:26:44 -08:00
parent 87440437fb
commit 84ed80365c
10 changed files with 22 additions and 23 deletions
+2 -4
View File
@@ -2,13 +2,11 @@
#include <string.h>
#include <phosg/Random.hh>
#include "SendCommands.hh"
using namespace std;
void player_use_item(shared_ptr<Client> c, size_t item_index) {
void player_use_item(shared_ptr<Client> c, size_t item_index, shared_ptr<PSOLFGEncryption> random_crypt) {
auto s = c->require_server_state();
// On PC (and presumably DC), the client sends a 6x29 after this to delete the
@@ -179,7 +177,7 @@ void player_use_item(shared_ptr<Client> c, size_t item_index) {
if (sum == 0) {
throw runtime_error("no unwrap results available for event");
}
size_t det = random_object<size_t>() % sum;
size_t det = random_crypt->next() % sum;
for (size_t z = 0; z < table.second; z++) {
const auto& entry = table.first[z];
if (det > entry.probability) {