summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--context.h4
-rw-r--r--include/pso/PSOV3Encryption.h4
-rw-r--r--src/pso/PSOV3Encryption.cpp9
3 files changed, 7 insertions, 10 deletions
diff --git a/context.h b/context.h
index 142e060..2fcdc7f 100644
--- a/context.h
+++ b/context.h
@@ -836,7 +836,7 @@ public:
PSOEncryption();
virtual void update_stream() = 0;
virtual ~PSOEncryption();
- virtual void encrypt(u32 seed) = 0;
+ virtual void init(u32 seed) = 0;
virtual u32 next() = 0;
};
@@ -845,7 +845,7 @@ public:
PSOV3Encryption();
virtual void update_stream() override;
virtual ~PSOV3Encryption();
- virtual void encrypt(u32 seed) override;
+ virtual void init(u32 seed) override;
virtual u32 next() override;
PRIVATE_MEMBER_ACCESSORS_ARRAY(u32, buffer, 522);
diff --git a/include/pso/PSOV3Encryption.h b/include/pso/PSOV3Encryption.h
index 5def0f2..0526cfb 100644
--- a/include/pso/PSOV3Encryption.h
+++ b/include/pso/PSOV3Encryption.h
@@ -11,7 +11,7 @@ public:
PSOEncryption();
virtual void update_stream() = 0;
virtual ~PSOEncryption();
- virtual void encrypt(u32 seed) = 0;
+ virtual void init(u32 seed) = 0;
virtual u32 next() = 0;
};
@@ -20,7 +20,7 @@ public:
PSOV3Encryption();
virtual void update_stream() override;
virtual ~PSOV3Encryption();
- virtual void encrypt(u32 seed) override;
+ virtual void init(u32 seed) override;
virtual u32 next() override;
PRIVATE_MEMBER_ACCESSORS_ARRAY(u32, buffer, 522);
diff --git a/src/pso/PSOV3Encryption.cpp b/src/pso/PSOV3Encryption.cpp
index 465249e..30c5586 100644
--- a/src/pso/PSOV3Encryption.cpp
+++ b/src/pso/PSOV3Encryption.cpp
@@ -26,12 +26,13 @@ void PSOV3Encryption::update_stream() {
for (u32 *p = ptr; p != m_buffer_end; *p++ ^= *start++);
}
-void PSOV3Encryption::encrypt(u32 seed) {
+void PSOV3Encryption::init(u32 seed) {
const size_t size = m_buffer.size();
u32 thing;
m_buffer_end = &m_buffer[size];
m_buffer_start = m_buffer.start();
u32 value = 0;
+
for (int i = 0; i <= 16; ++i, *m_buffer_start++ = value) {
for (int j = 32; j; --j) {
seed *= 0x5d588b65;
@@ -39,13 +40,9 @@ void PSOV3Encryption::encrypt(u32 seed) {
}
}
- //u32 *smth = &m_buffer[0];
- //u32 *smth2 = &m_buffer[1];
--m_buffer_start;
thing = m_buffer[0xf];
*m_buffer_start = (m_buffer[0] >> 9) ^ (*m_buffer_start << 23) ^ thing;
- //u32 *buf_val = &m_buffer[0];
- //u32 *next_buf_val = &m_buffer[1];
for (u32 *buf_val = &m_buffer[0], *next_buf_val = &m_buffer[1], *buf = m_buffer_start++; m_buffer_start != m_buffer_end;) {
*m_buffer_start++ = (*buf_val++ << 23) ^ (*next_buf_val++ >> 9) ^ *buf++;
@@ -64,7 +61,7 @@ PSOV3Encryption::~PSOV3Encryption() {
}
PSOV3Encryption::PSOV3Encryption() : PSOEncryption() {
- encrypt(0);
+ init(0);
}