Commit f728e520 authored by nanahira's avatar nanahira

Merge branch 'develop' into server-develop

parents ca17e4fd ec9c71bf
#ifndef BUFFERIO_H
#define BUFFERIO_H
#include <cstdint>
#include "../ocgcore/buffer.h"
class BufferIO {
public:
inline static int ReadInt32(unsigned char*& p) {
int ret = *(int*)p;
p += 4;
return ret;
return buffer_read<int32_t>(p);
}
inline static unsigned int ReadUInt32(unsigned char*& p) {
unsigned int ret = *(unsigned int*)p;
......@@ -15,9 +15,7 @@ public:
return ret;
}
inline static short ReadInt16(unsigned char*& p) {
short ret = *(short*)p;
p += 2;
return ret;
return buffer_read<int16_t>(p);
}
inline static unsigned short ReadUInt16(unsigned char*& p) {
unsigned short ret = *(unsigned short*)p;
......@@ -25,26 +23,19 @@ public:
return ret;
}
inline static char ReadInt8(unsigned char*& p) {
char ret = *(char*)p;
p++;
return ret;
return buffer_read<char>(p);
}
inline static unsigned char ReadUInt8(unsigned char*& p) {
unsigned char ret = *(unsigned char*)p;
p++;
return ret;
return buffer_read<unsigned char>(p);
}
inline static void WriteInt32(unsigned char*& p, int val) {
(*(int*)p) = val;
p += 4;
buffer_write<int32_t>(p, val);
}
inline static void WriteInt16(unsigned char*& p, short val) {
(*(short*)p) = val;
p += 2;
buffer_write<int16_t>(p, val);
}
inline static void WriteInt8(unsigned char*& p, char val) {
*p = val;
p++;
buffer_write<char>(p, val);
}
template<typename T1, typename T2>
inline static int CopyWStr(T1* src, T2* pstr, int bufsize) {
......
#include "replay.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
#include "lzma/LzmaLib.h"
namespace ygo {
......@@ -87,7 +85,7 @@ void Replay::WriteData(const void* data, int length, bool flush) {
return;
if (length < 0 || (pdata - replay_data) + length > MAX_REPLAY_SIZE)
return;
memcpy(pdata, data, length);
std::memcpy(pdata, data, length);
pdata += length;
#ifdef YGOPRO_SERVER_MODE
if(!(replay_mode & REPLAY_MODE_SAVE_IN_SERVER)) return;
......@@ -106,8 +104,7 @@ void Replay::WriteInt32(int data, bool flush) {
return;
if ((pdata - replay_data) + 4 > MAX_REPLAY_SIZE)
return;
*((int*)(pdata)) = data;
pdata += 4;
BufferIO::WriteInt32(pdata, data);
#ifdef YGOPRO_SERVER_MODE
if(!(replay_mode & REPLAY_MODE_SAVE_IN_SERVER)) return;
#endif
......@@ -125,8 +122,7 @@ void Replay::WriteInt16(short data, bool flush) {
return;
if ((pdata - replay_data) + 2 > MAX_REPLAY_SIZE)
return;
*((short*)(pdata)) = data;
pdata += 2;
BufferIO::WriteInt16(pdata, data);
#ifdef YGOPRO_SERVER_MODE
if(!(replay_mode & REPLAY_MODE_SAVE_IN_SERVER)) return;
#endif
......@@ -144,8 +140,7 @@ void Replay::WriteInt8(char data, bool flush) {
return;
if ((pdata - replay_data) + 1 > MAX_REPLAY_SIZE)
return;
*pdata = data;
pdata++;
BufferIO::WriteInt8(pdata, data);
#ifdef YGOPRO_SERVER_MODE
if(!(replay_mode & REPLAY_MODE_SAVE_IN_SERVER)) return;
#endif
......@@ -320,7 +315,7 @@ bool Replay::ReadNextResponse(unsigned char resp[]) {
int len = *pdata++;
if(len > SIZE_RETURN_VALUE)
return false;
memcpy(resp, pdata, len);
std::memcpy(resp, pdata, len);
pdata += len;
return true;
}
......@@ -334,27 +329,26 @@ void Replay::ReadName(wchar_t* data) {
void Replay::ReadData(void* data, int length) {
if(!is_replaying)
return;
memcpy(data, pdata, length);
std::memcpy(data, pdata, length);
pdata += length;
}
int Replay::ReadInt32() {
if(!is_replaying)
return -1;
int ret = *((int*)pdata);
pdata += 4;
int ret = BufferIO::ReadInt32(pdata);
return ret;
}
short Replay::ReadInt16() {
if(!is_replaying)
return -1;
short ret = *((short*)pdata);
pdata += 2;
short ret = BufferIO::ReadInt16(pdata);
return ret;
}
char Replay::ReadInt8() {
if(!is_replaying)
return -1;
return *pdata++;
char ret= BufferIO::ReadInt8(pdata);
return ret;
}
void Replay::Rewind() {
pdata = replay_data;
......
This diff is collapsed.
Subproject commit ec05a8189956908db31ed1ff8dbf8b421dcb402f
Subproject commit 6235c3e2477ae9a26840c5996682f4bd0d5b8cb2
Subproject commit 395507c470422d81202c2181aac2ab762573bbb5
Subproject commit 0afd8128c0eaa79157305d64d8d6d5d6d0ce2c86
......@@ -672,7 +672,7 @@
!setname 0x2 次世代 ジェネクス
!setname 0x1002 真次世代 レアル·ジェネクス
#!setname 0x2002 盟军·次世代 A・ジェネクス
#setname 0x3 N/A
!setname 0x3 魅惑的女王 魅惑の女王
!setname 0x4 亚马逊 アマゾネス
!setname 0x5 秘仪之力 アルカナフォース
!setname 0x6 暗黑界 暗黒界
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment