mirror of
https://github.com/Patoke/4JLibs.git
synced 2026-07-14 20:28:58 +00:00
feat: finish 4J_Storage impl
fix: implement 4J_Input's CInput constructor
This commit is contained in:
@@ -1 +1,74 @@
|
||||
#pragma once
|
||||
#include "STO_Main.h"
|
||||
#include "4J_Storage.h"
|
||||
|
||||
CStorage InternalStorageManager;
|
||||
|
||||
CStorage::CStorage(void)
|
||||
{
|
||||
m_SaveGame = CSaveGame();
|
||||
m_DLC = CDLC();
|
||||
}
|
||||
|
||||
void CStorage::Init(int(*Func)(LPVOID, const C4JStorage::ESavingMessage, int), LPVOID lpParam, LPCSTR szGroupID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CStorage::Tick(void)
|
||||
{
|
||||
m_DLC.Tick();
|
||||
}
|
||||
|
||||
unsigned int CStorage::CRC(unsigned char* buf, int len)
|
||||
{
|
||||
return ~UpdateCRC(0xFFFFFFFF, buf, len);
|
||||
}
|
||||
|
||||
void CStorage::MakeCRCTable(void)
|
||||
{
|
||||
for (int c = 0; c < 256; ++c)
|
||||
{
|
||||
unsigned int k = c;
|
||||
for (int n = 0; n < 8; ++n)
|
||||
{
|
||||
if ((k & 1) != 0)
|
||||
{
|
||||
k = (k >> 1) ^ 0xEDB88320;
|
||||
}
|
||||
else
|
||||
{
|
||||
k >>= 1;
|
||||
}
|
||||
}
|
||||
m_CRCTable[c] = k;
|
||||
}
|
||||
m_bHasCRCTable = true;
|
||||
}
|
||||
|
||||
unsigned int CStorage::UpdateCRC(unsigned int crc, unsigned __int8* buf, int len)
|
||||
{
|
||||
if (!m_bHasCRCTable)
|
||||
{
|
||||
MakeCRCTable();
|
||||
}
|
||||
|
||||
for (int c = 0; c < len; ++c)
|
||||
{
|
||||
crc = (crc >> 8) ^ m_CRCTable[(unsigned __int8)(buf[c] ^ crc)];
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
void CStorage::DebugPrintf(const char* szFormat, ...)
|
||||
{
|
||||
char buf[1024]{};
|
||||
|
||||
va_list va;
|
||||
va_start(va, szFormat);
|
||||
|
||||
vsnprintf(buf, 1024, szFormat, va);
|
||||
|
||||
va_end(va);
|
||||
}
|
||||
Reference in New Issue
Block a user