Commit df5d87dd authored by nanahira's avatar nanahira

Merge branch 'master' into raw-video

parents e8e9f25a f52e8b19
...@@ -64,6 +64,7 @@ mat_linux: ...@@ -64,6 +64,7 @@ mat_linux:
stage: prepare stage: prepare
tags: tags:
- linux - linux
image: git-registry.mycard.moe/mycard/docker-runner-base:debian11
script: script:
- apt update; apt -y install git wget tar - apt update; apt -y install git wget tar
- git clone --depth=1 https://code.mycard.moe/mycard/irrlicht-new irrlicht - git clone --depth=1 https://code.mycard.moe/mycard/irrlicht-new irrlicht
...@@ -155,6 +156,7 @@ exec_linux: ...@@ -155,6 +156,7 @@ exec_linux:
extends: ._exec_build extends: ._exec_build
tags: tags:
- linux - linux
image: git-registry.mycard.moe/mycard/docker-runner-base:debian11
dependencies: dependencies:
- mat_common - mat_common
- mat_irrklang - mat_irrklang
......
No preview for this file type
...@@ -92,9 +92,9 @@ public: ...@@ -92,9 +92,9 @@ public:
case 4: case 4:
if (sizeof(wchar_t) == 2) { if (sizeof(wchar_t) == 2) {
cur = 0; cur = 0;
cur |= ((unsigned)*wsrc & 0x3ff) << 10; cur |= (*wsrc & 0x3ffU) << 10;
++wsrc; ++wsrc;
cur |= (unsigned)*wsrc & 0x3ff; cur |= *wsrc & 0x3ffU;
cur += 0x10000; cur += 0x10000;
} }
pstr[0] = ((cur >> 18) & 0x7) | 0xf0; pstr[0] = ((cur >> 18) & 0x7) | 0xf0;
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
const char* p = src; const char* p = src;
wchar_t* wp = wstr; wchar_t* wp = wstr;
while(*p != 0) { while(*p != 0) {
const unsigned cur = (unsigned)*p & 0xff; const unsigned cur = *p & 0xffU;
int codepoint_size = 0; int codepoint_size = 0;
if ((cur & 0xf8) == 0xf0) { if ((cur & 0xf8) == 0xf0) {
if (sizeof(wchar_t) == 2) if (sizeof(wchar_t) == 2)
...@@ -133,19 +133,19 @@ public: ...@@ -133,19 +133,19 @@ public:
*wp = *p; *wp = *p;
p++; p++;
} else if((cur & 0xe0) == 0xc0) { } else if((cur & 0xe0) == 0xc0) {
*wp = (((unsigned)p[0] & 0x1f) << 6) | ((unsigned)p[1] & 0x3f); *wp = ((p[0] & 0x1fU) << 6) | (p[1] & 0x3fU);
p += 2; p += 2;
} else if((cur & 0xf0) == 0xe0) { } else if((cur & 0xf0) == 0xe0) {
*wp = (((unsigned)p[0] & 0xf) << 12) | (((unsigned)p[1] & 0x3f) << 6) | ((unsigned)p[2] & 0x3f); *wp = ((p[0] & 0xfU) << 12) | ((p[1] & 0x3fU) << 6) | (p[2] & 0x3fU);
p += 3; p += 3;
} else if((cur & 0xf8) == 0xf0) { } else if((cur & 0xf8) == 0xf0) {
if (sizeof(wchar_t) == 2) { if (sizeof(wchar_t) == 2) {
unsigned unicode = (((unsigned)p[0] & 0x7) << 18) | (((unsigned)p[1] & 0x3f) << 12) | (((unsigned)p[2] & 0x3f) << 6) | ((unsigned)p[3] & 0x3f); unsigned unicode = ((p[0] & 0x7U) << 18) | ((p[1] & 0x3fU) << 12) | ((p[2] & 0x3fU) << 6) | (p[3] & 0x3fU);
unicode -= 0x10000; unicode -= 0x10000;
*wp++ = (unicode >> 10) | 0xd800; *wp++ = (unicode >> 10) | 0xd800;
*wp = (unicode & 0x3ff) | 0xdc00; *wp = (unicode & 0x3ff) | 0xdc00;
} else { } else {
*wp = (((unsigned)p[0] & 0x7) << 18) | (((unsigned)p[1] & 0x3f) << 12) | (((unsigned)p[2] & 0x3f) << 6) | ((unsigned)p[3] & 0x3f); *wp = ((p[0] & 0x7U) << 18) | ((p[1] & 0x3fU) << 12) | ((p[2] & 0x3fU) << 6) | (p[3] & 0x3fU);
} }
p += 4; p += 4;
} else } else
...@@ -163,6 +163,10 @@ public: ...@@ -163,6 +163,10 @@ public:
static int DecodeUTF8(const char* src, wchar_t(&dst)[N]) { static int DecodeUTF8(const char* src, wchar_t(&dst)[N]) {
return DecodeUTF8String(src, dst, N); return DecodeUTF8String(src, dst, N);
} }
template<size_t N, typename T>
static void NullTerminate(T(&str)[N]) {
str[N - 1] = 0;
}
static int GetVal(const wchar_t* pstr) { static int GetVal(const wchar_t* pstr) {
unsigned int ret = 0; unsigned int ret = 0;
while(*pstr >= L'0' && *pstr <= L'9') { while(*pstr >= L'0' && *pstr <= L'9') {
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h> #include <unistd.h>
#include <locale.h>
#define SD_BOTH 2 #define SD_BOTH 2
#define SOCKET int #define SOCKET int
......
...@@ -1803,7 +1803,7 @@ bool DeckBuilder::push_main(code_pointer pointer, int seq) { ...@@ -1803,7 +1803,7 @@ bool DeckBuilder::push_main(code_pointer pointer, int seq) {
if(pointer->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) if(pointer->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK))
return false; return false;
auto& container = deckManager.current_deck.main; auto& container = deckManager.current_deck.main;
int maxc = mainGame->is_siding ? DECK_MAX_SIZE + 4 : DECK_MAX_SIZE; int maxc = mainGame->is_siding ? DECK_MAX_SIZE + 5 : DECK_MAX_SIZE;
if((int)container.size() >= maxc) if((int)container.size() >= maxc)
return false; return false;
if(seq >= 0 && seq < (int)container.size()) if(seq >= 0 && seq < (int)container.size())
......
...@@ -176,7 +176,7 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p ...@@ -176,7 +176,7 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p
} }
if(cd.type & TYPE_TOKEN) if(cd.type & TYPE_TOKEN)
continue; continue;
if(deck.side.size() < YGOPRO_MAX_SIDE) if(deck.side.size() < SIDE_MAX_SIZE)
deck.side.push_back(dataManager.GetCodePointer(code)); deck.side.push_back(dataManager.GetCodePointer(code));
} }
return errorcode; return errorcode;
...@@ -249,6 +249,8 @@ bool DeckManager::LoadDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUICom ...@@ -249,6 +249,8 @@ bool DeckManager::LoadDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUICom
bool res = LoadDeck(filepath, is_packlist); bool res = LoadDeck(filepath, is_packlist);
if(res && mainGame->is_building) if(res && mainGame->is_building)
mainGame->deckBuilder.RefreshPackListScroll(); mainGame->deckBuilder.RefreshPackListScroll();
if (!res)
current_deck.clear();
return res; return res;
} }
FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) { FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
...@@ -287,8 +289,8 @@ bool DeckManager::LoadDeck(const wchar_t* file, bool is_packlist) { ...@@ -287,8 +289,8 @@ bool DeckManager::LoadDeck(const wchar_t* file, bool is_packlist) {
} }
if(!reader) if(!reader)
return false; return false;
size_t size = reader->getSize(); auto size = reader->getSize();
if(size >= 0x20000) { if(size >= (int)sizeof deckBuffer) {
reader->drop(); reader->drop();
return false; return false;
} }
...@@ -303,7 +305,7 @@ bool DeckManager::LoadDeck(std::istringstream* deckStream, bool is_packlist) { ...@@ -303,7 +305,7 @@ bool DeckManager::LoadDeck(std::istringstream* deckStream, bool is_packlist) {
int cardlist[300]; int cardlist[300];
bool is_side = false; bool is_side = false;
std::string linebuf; std::string linebuf;
while(std::getline(*deckStream, linebuf) && ct < 300) { while(std::getline(*deckStream, linebuf, '\n') && ct < 300) {
if(linebuf[0] == '!') { if(linebuf[0] == '!') {
is_side = true; is_side = true;
continue; continue;
......
...@@ -22,8 +22,6 @@ unsigned char DuelClient::selftype = 0; ...@@ -22,8 +22,6 @@ unsigned char DuelClient::selftype = 0;
bool DuelClient::is_host = false; bool DuelClient::is_host = false;
event_base* DuelClient::client_base = 0; event_base* DuelClient::client_base = 0;
bufferevent* DuelClient::client_bev = 0; bufferevent* DuelClient::client_bev = 0;
unsigned char DuelClient::duel_client_read[SIZE_NETWORK_BUFFER];
int DuelClient::read_len = 0;
unsigned char DuelClient::duel_client_write[SIZE_NETWORK_BUFFER]; unsigned char DuelClient::duel_client_write[SIZE_NETWORK_BUFFER];
bool DuelClient::is_closing = false; bool DuelClient::is_closing = false;
bool DuelClient::is_swapping = false; bool DuelClient::is_swapping = false;
...@@ -59,6 +57,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g ...@@ -59,6 +57,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
sin.sin_addr.s_addr = htonl(ip); sin.sin_addr.s_addr = htonl(ip);
sin.sin_port = htons(port); sin.sin_port = htons(port);
client_bev = bufferevent_socket_new(client_base, -1, BEV_OPT_CLOSE_ON_FREE); client_bev = bufferevent_socket_new(client_base, -1, BEV_OPT_CLOSE_ON_FREE);
bufferevent_setwatermark(client_bev, EV_READ, 3, 0);
bufferevent_setcb(client_bev, ClientRead, NULL, ClientEvent, (void*)create_game); bufferevent_setcb(client_bev, ClientRead, NULL, ClientEvent, (void*)create_game);
temp_ip = ip; temp_ip = ip;
temp_port = port; temp_port = port;
...@@ -113,24 +112,23 @@ void DuelClient::StopClient(bool is_exiting) { ...@@ -113,24 +112,23 @@ void DuelClient::StopClient(bool is_exiting) {
void DuelClient::ClientRead(bufferevent* bev, void* ctx) { void DuelClient::ClientRead(bufferevent* bev, void* ctx) {
evbuffer* input = bufferevent_get_input(bev); evbuffer* input = bufferevent_get_input(bev);
int len = evbuffer_get_length(input); int len = evbuffer_get_length(input);
unsigned short packet_len = 0; unsigned char* duel_client_read = new unsigned char[std::min(len, SIZE_NETWORK_BUFFER)];
while(true) { unsigned short packet_len;
if(len < 2) while (len >= 2) {
return; evbuffer_copyout(input, &packet_len, sizeof packet_len);
evbuffer_copyout(input, &packet_len, 2);
if (packet_len + 2 > SIZE_NETWORK_BUFFER) { if (packet_len + 2 > SIZE_NETWORK_BUFFER) {
delete[] duel_client_read;
ClientEvent(bev, BEV_EVENT_ERROR, 0); ClientEvent(bev, BEV_EVENT_ERROR, 0);
return; return;
} }
if(len < packet_len + 2) if (len < packet_len + 2)
return; break;
if (packet_len < 1) int read_len = evbuffer_remove(input, duel_client_read, packet_len + 2);
return;
read_len = evbuffer_remove(input, duel_client_read, packet_len + 2);
if (read_len >= 3) if (read_len >= 3)
HandleSTOCPacketLan(&duel_client_read[2], read_len - 2); HandleSTOCPacketLan(&duel_client_read[2], read_len - 2);
len -= packet_len + 2; len -= packet_len + 2;
} }
delete[] duel_client_read;
} }
void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
if (events & BEV_EVENT_CONNECTED) { if (events & BEV_EVENT_CONNECTED) {
...@@ -959,10 +957,11 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) { ...@@ -959,10 +957,11 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER); soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER);
STOC_HS_PlayerEnter packet; STOC_HS_PlayerEnter packet;
std::memcpy(&packet, pdata, STOC_HS_PlayerEnter_size); std::memcpy(&packet, pdata, STOC_HS_PlayerEnter_size);
const auto* pkt = &packet; auto pkt = &packet;
if(pkt->pos > 3) if(pkt->pos > 3)
break; break;
wchar_t name[20]; wchar_t name[20];
BufferIO::NullTerminate(pkt->name);
BufferIO::CopyWStr(pkt->name, name, 20); BufferIO::CopyWStr(pkt->name, name, 20);
if(mainGame->dInfo.isTag) { if(mainGame->dInfo.isTag) {
if(pkt->pos == 0) if(pkt->pos == 0)
...@@ -1705,7 +1704,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -1705,7 +1704,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
wchar_t ynbuf[256]; wchar_t ynbuf[256];
myswprintf(ynbuf, dataManager.GetSysString(221), dataManager.FormatLocation(l, s), dataManager.GetName(code)); myswprintf(ynbuf, dataManager.GetSysString(221), dataManager.FormatLocation(l, s), dataManager.GetName(code));
myswprintf(textBuffer, L"%ls\n%ls\n%ls", event_string, ynbuf, dataManager.GetSysString(223)); myswprintf(textBuffer, L"%ls\n%ls\n%ls", event_string, ynbuf, dataManager.GetSysString(223));
} else if(desc < 2048) { } else if(desc <= MAX_STRING_ID) {
myswprintf(textBuffer, dataManager.GetSysString(desc), dataManager.GetName(code)); myswprintf(textBuffer, dataManager.GetSysString(desc), dataManager.GetName(code));
} else { } else {
myswprintf(textBuffer, dataManager.GetDesc(desc), dataManager.GetName(code)); myswprintf(textBuffer, dataManager.GetDesc(desc), dataManager.GetName(code));
......
...@@ -60,8 +60,6 @@ private: ...@@ -60,8 +60,6 @@ private:
static bool is_host; static bool is_host;
static event_base* client_base; static event_base* client_base;
static bufferevent* client_bev; static bufferevent* client_bev;
static unsigned char duel_client_read[SIZE_NETWORK_BUFFER];
static int read_len;
static unsigned char duel_client_write[SIZE_NETWORK_BUFFER]; static unsigned char duel_client_write[SIZE_NETWORK_BUFFER];
static bool is_closing; static bool is_closing;
static bool is_swapping; static bool is_swapping;
...@@ -106,16 +104,15 @@ public: ...@@ -106,16 +104,15 @@ public:
template<typename ST> template<typename ST>
static void SendPacketToServer(unsigned char proto, ST& st) { static void SendPacketToServer(unsigned char proto, ST& st) {
auto p = duel_client_write; auto p = duel_client_write;
int blen = sizeof(ST); if ((int)sizeof(ST) > MAX_DATA_SIZE)
if (blen > MAX_DATA_SIZE)
return; return;
BufferIO::WriteInt16(p, (short)(1 + blen)); BufferIO::WriteInt16(p, (short)(1 + sizeof(ST)));
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
std::memcpy(p, &st, blen); std::memcpy(p, &st, sizeof(ST));
#ifdef YGOPRO_MESSAGE_DEBUG #ifdef YGOPRO_MESSAGE_DEBUG
printf("CTOS: %d Length: %ld\n", proto, sizeof(ST)); printf("CTOS: %d Length: %ld\n", proto, sizeof(ST));
#endif #endif
bufferevent_write(client_bev, duel_client_write, blen + 3); bufferevent_write(client_bev, duel_client_write, sizeof(ST) + 3);
} }
static void SendBufferToServer(unsigned char proto, void* buffer, size_t len) { static void SendBufferToServer(unsigned char proto, void* buffer, size_t len) {
auto p = duel_client_write; auto p = duel_client_write;
......
This diff is collapsed.
...@@ -302,6 +302,7 @@ public: ...@@ -302,6 +302,7 @@ public:
HWND hWnd; HWND hWnd;
#endif #endif
std::vector<irr::gui::IGUIEditBox* > editbox_list;
//GUI //GUI
irr::gui::IGUIEnvironment* env; irr::gui::IGUIEnvironment* env;
irr::gui::CGUITTFont* guiFont; irr::gui::CGUITTFont* guiFont;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "game.h" #include "game.h"
#include "data_manager.h" #include "data_manager.h"
#include <event2/thread.h> #include <event2/thread.h>
#include <locale.h>
#include <memory> #include <memory>
#ifdef __APPLE__ #ifdef __APPLE__
#import <CoreFoundation/CoreFoundation.h> #import <CoreFoundation/CoreFoundation.h>
......
...@@ -9,8 +9,6 @@ event_base* NetServer::net_evbase = 0; ...@@ -9,8 +9,6 @@ event_base* NetServer::net_evbase = 0;
event* NetServer::broadcast_ev = 0; event* NetServer::broadcast_ev = 0;
evconnlistener* NetServer::listener = 0; evconnlistener* NetServer::listener = 0;
DuelMode* NetServer::duel_mode = 0; DuelMode* NetServer::duel_mode = 0;
unsigned char NetServer::net_server_read[SIZE_NETWORK_BUFFER];
int NetServer::read_len = 0;
unsigned char NetServer::net_server_write[SIZE_NETWORK_BUFFER]; unsigned char NetServer::net_server_write[SIZE_NETWORK_BUFFER];
unsigned short NetServer::last_sent = 0; unsigned short NetServer::last_sent = 0;
...@@ -109,6 +107,7 @@ void NetServer::ServerAccept(evconnlistener* listener, evutil_socket_t fd, socka ...@@ -109,6 +107,7 @@ void NetServer::ServerAccept(evconnlistener* listener, evutil_socket_t fd, socka
dp.type = 0xff; dp.type = 0xff;
dp.bev = bev; dp.bev = bev;
users[bev] = dp; users[bev] = dp;
bufferevent_setwatermark(bev, EV_READ, 3, 0);
bufferevent_setcb(bev, ServerEchoRead, NULL, ServerEchoEvent, NULL); bufferevent_setcb(bev, ServerEchoRead, NULL, ServerEchoEvent, NULL);
bufferevent_enable(bev, EV_READ); bufferevent_enable(bev, EV_READ);
} }
...@@ -123,24 +122,23 @@ void NetServer::ServerAcceptError(evconnlistener* listener, void* ctx) { ...@@ -123,24 +122,23 @@ void NetServer::ServerAcceptError(evconnlistener* listener, void* ctx) {
void NetServer::ServerEchoRead(bufferevent *bev, void *ctx) { void NetServer::ServerEchoRead(bufferevent *bev, void *ctx) {
evbuffer* input = bufferevent_get_input(bev); evbuffer* input = bufferevent_get_input(bev);
int len = evbuffer_get_length(input); int len = evbuffer_get_length(input);
unsigned short packet_len = 0; unsigned char* net_server_read = new unsigned char[std::min(len, SIZE_NETWORK_BUFFER)];
while(true) { unsigned short packet_len;
if(len < 2) while (len >= 2) {
return; evbuffer_copyout(input, &packet_len, sizeof packet_len);
evbuffer_copyout(input, &packet_len, 2);
if (packet_len + 2 > SIZE_NETWORK_BUFFER) { if (packet_len + 2 > SIZE_NETWORK_BUFFER) {
delete[] net_server_read;
ServerEchoEvent(bev, BEV_EVENT_ERROR, 0); ServerEchoEvent(bev, BEV_EVENT_ERROR, 0);
return; return;
} }
if (len < packet_len + 2) if (len < packet_len + 2)
return; break;
if (packet_len < 1) int read_len = evbuffer_remove(input, net_server_read, packet_len + 2);
return;
read_len = evbuffer_remove(input, net_server_read, packet_len + 2);
if (read_len >= 3) if (read_len >= 3)
HandleCTOSPacket(&users[bev], &net_server_read[2], read_len - 2); HandleCTOSPacket(&users[bev], &net_server_read[2], read_len - 2);
len -= packet_len + 2; len -= packet_len + 2;
} }
delete[] net_server_read;
} }
void NetServer::ServerEchoEvent(bufferevent* bev, short events, void* ctx) { void NetServer::ServerEchoEvent(bufferevent* bev, short events, void* ctx) {
if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) { if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) {
...@@ -249,7 +247,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) { ...@@ -249,7 +247,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
return; return;
CTOS_PlayerInfo packet; CTOS_PlayerInfo packet;
std::memcpy(&packet, pdata, sizeof packet); std::memcpy(&packet, pdata, sizeof packet);
const auto* pkt = &packet; auto pkt = &packet;
BufferIO::NullTerminate(pkt->name);
BufferIO::CopyWStr(pkt->name, dp->name, 20); BufferIO::CopyWStr(pkt->name, dp->name, 20);
break; break;
} }
...@@ -271,10 +270,10 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) { ...@@ -271,10 +270,10 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
duel_mode = new TagDuel(); duel_mode = new TagDuel();
duel_mode->etimer = event_new(net_evbase, 0, EV_TIMEOUT | EV_PERSIST, TagDuel::TagTimer, duel_mode); duel_mode->etimer = event_new(net_evbase, 0, EV_TIMEOUT | EV_PERSIST, TagDuel::TagTimer, duel_mode);
} }
if(pkt->info.rule > 5) if(pkt->info.rule > CURRENT_RULE)
pkt->info.rule = 5; pkt->info.rule = CURRENT_RULE;
if(pkt->info.mode > 2) if(pkt->info.mode > MODE_TAG)
pkt->info.mode = 0; pkt->info.mode = MODE_SINGLE;
unsigned int hash = 1; unsigned int hash = 1;
for(auto lfit = deckManager._lfList.begin(); lfit != deckManager._lfList.end(); ++lfit) { for(auto lfit = deckManager._lfList.begin(); lfit != deckManager._lfList.end(); ++lfit) {
if(pkt->info.lflist == lfit->hash) { if(pkt->info.lflist == lfit->hash) {
...@@ -284,8 +283,9 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) { ...@@ -284,8 +283,9 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
} }
if(hash == 1) if(hash == 1)
pkt->info.lflist = deckManager._lfList[0].hash; pkt->info.lflist = deckManager._lfList[0].hash;
std::memcpy(pdata, &packet, sizeof packet);
duel_mode->host_info = pkt->info; duel_mode->host_info = pkt->info;
BufferIO::NullTerminate(pkt->name);
BufferIO::NullTerminate(pkt->pass);
BufferIO::CopyWStr(pkt->name, duel_mode->name, 20); BufferIO::CopyWStr(pkt->name, duel_mode->name, 20);
BufferIO::CopyWStr(pkt->pass, duel_mode->pass, 20); BufferIO::CopyWStr(pkt->pass, duel_mode->pass, 20);
duel_mode->JoinGame(dp, 0, true); duel_mode->JoinGame(dp, 0, true);
......
...@@ -18,8 +18,6 @@ private: ...@@ -18,8 +18,6 @@ private:
static event* broadcast_ev; static event* broadcast_ev;
static evconnlistener* listener; static evconnlistener* listener;
static DuelMode* duel_mode; static DuelMode* duel_mode;
static unsigned char net_server_read[SIZE_NETWORK_BUFFER];
static int read_len;
static unsigned char net_server_write[SIZE_NETWORK_BUFFER]; static unsigned char net_server_write[SIZE_NETWORK_BUFFER];
static unsigned short last_sent; static unsigned short last_sent;
...@@ -50,15 +48,14 @@ public: ...@@ -50,15 +48,14 @@ public:
template<typename ST> template<typename ST>
static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto, ST& st) { static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto, ST& st) {
auto p = net_server_write; auto p = net_server_write;
int blen = sizeof(ST); if ((int)sizeof(ST) > MAX_DATA_SIZE)
if (blen > MAX_DATA_SIZE)
return; return;
BufferIO::WriteInt16(p, (short)(1 + blen)); BufferIO::WriteInt16(p, (short)(1 + sizeof(ST)));
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
std::memcpy(p, &st, blen); std::memcpy(p, &st, sizeof(ST));
last_sent = blen + 3; last_sent = sizeof(ST) + 3;
if (dp) if (dp)
bufferevent_write(dp->bev, net_server_write, blen + 3); bufferevent_write(dp->bev, net_server_write, sizeof(ST) + 3);
} }
static void SendBufferToPlayer(DuelPlayer* dp, unsigned char proto, void* buffer, size_t len) { static void SendBufferToPlayer(DuelPlayer* dp, unsigned char proto, void* buffer, size_t len) {
auto p = net_server_write; auto p = net_server_write;
......
...@@ -34,7 +34,7 @@ void SingleDuel::JoinGame(DuelPlayer* dp, unsigned char* pdata, bool is_creater) ...@@ -34,7 +34,7 @@ void SingleDuel::JoinGame(DuelPlayer* dp, unsigned char* pdata, bool is_creater)
} }
CTOS_JoinGame packet; CTOS_JoinGame packet;
std::memcpy(&packet, pdata, sizeof packet); std::memcpy(&packet, pdata, sizeof packet);
const auto* pkt = &packet; auto* pkt = &packet;
/* disabled version check /* disabled version check
if(pkt->version != PRO_VERSION) { if(pkt->version != PRO_VERSION) {
STOC_ErrorMsg scem; STOC_ErrorMsg scem;
...@@ -46,6 +46,7 @@ void SingleDuel::JoinGame(DuelPlayer* dp, unsigned char* pdata, bool is_creater) ...@@ -46,6 +46,7 @@ void SingleDuel::JoinGame(DuelPlayer* dp, unsigned char* pdata, bool is_creater)
} }
*/ */
wchar_t jpass[20]; wchar_t jpass[20];
BufferIO::NullTerminate(pkt->pass);
BufferIO::CopyWStr(pkt->pass, jpass, 20); BufferIO::CopyWStr(pkt->pass, jpass, 20);
if(wcscmp(jpass, pass)) { if(wcscmp(jpass, pass)) {
STOC_ErrorMsg scem; STOC_ErrorMsg scem;
...@@ -1436,7 +1437,7 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) { ...@@ -1436,7 +1437,7 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
return 0; return 0;
} }
void SingleDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int len) { void SingleDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int len) {
byte resb[SIZE_RETURN_VALUE]; byte resb[SIZE_RETURN_VALUE]{};
if (len > SIZE_RETURN_VALUE) if (len > SIZE_RETURN_VALUE)
len = SIZE_RETURN_VALUE; len = SIZE_RETURN_VALUE;
std::memcpy(resb, pdata, len); std::memcpy(resb, pdata, len);
......
...@@ -38,7 +38,7 @@ void TagDuel::JoinGame(DuelPlayer* dp, unsigned char* pdata, bool is_creater) { ...@@ -38,7 +38,7 @@ void TagDuel::JoinGame(DuelPlayer* dp, unsigned char* pdata, bool is_creater) {
} }
CTOS_JoinGame packet; CTOS_JoinGame packet;
std::memcpy(&packet, pdata, sizeof packet); std::memcpy(&packet, pdata, sizeof packet);
const auto* pkt = &packet; auto* pkt = &packet;
/* disabled version check /* disabled version check
if(pkt->version != PRO_VERSION) { if(pkt->version != PRO_VERSION) {
STOC_ErrorMsg scem; STOC_ErrorMsg scem;
...@@ -50,6 +50,7 @@ void TagDuel::JoinGame(DuelPlayer* dp, unsigned char* pdata, bool is_creater) { ...@@ -50,6 +50,7 @@ void TagDuel::JoinGame(DuelPlayer* dp, unsigned char* pdata, bool is_creater) {
} }
*/ */
wchar_t jpass[20]; wchar_t jpass[20];
BufferIO::NullTerminate(pkt->pass);
BufferIO::CopyWStr(pkt->pass, jpass, 20); BufferIO::CopyWStr(pkt->pass, jpass, 20);
if(wcscmp(jpass, pass)) { if(wcscmp(jpass, pass)) {
STOC_ErrorMsg scem; STOC_ErrorMsg scem;
...@@ -1553,7 +1554,7 @@ int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) { ...@@ -1553,7 +1554,7 @@ int TagDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
return 0; return 0;
} }
void TagDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int len) { void TagDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int len) {
byte resb[SIZE_RETURN_VALUE]; byte resb[SIZE_RETURN_VALUE]{};
if (len > SIZE_RETURN_VALUE) if (len > SIZE_RETURN_VALUE)
len = SIZE_RETURN_VALUE; len = SIZE_RETURN_VALUE;
std::memcpy(resb, pdata, len); std::memcpy(resb, pdata, len);
......
This diff is collapsed.
Subproject commit d4430f0ae3f415b322bd58de7b3c3fdec849feb3 Subproject commit 3e88ee9f65ec8dc8181c0105bf720e9671956504
1 ICON "ygopro.ico" 1 ICON "ygopro.ico"
1 VERSIONINFO 1 VERSIONINFO
FILEVERSION 1, 0, 36, 1 FILEVERSION 1, 0, 36, 1
PRODUCTVERSION 1, 0, 36, 1 PRODUCTVERSION 1, 0, 36, 1
FILEOS 0x4 FILEOS 0x4
FILETYPE 0x1 FILETYPE 0x1
BEGIN BEGIN
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
BEGIN BEGIN
BLOCK "080404b0" BLOCK "080404b0"
BEGIN BEGIN
VALUE "FileDescription", "KoishiPro" VALUE "FileDescription", "KoishiPro"
VALUE "InternalName", "KoishiPro" VALUE "InternalName", "KoishiPro"
VALUE "LegalCopyright", "Copyright (C) 2023 Nanahira" VALUE "LegalCopyright", "Copyright (C) 2023 Nanahira"
VALUE "OriginalFilename", "ygopro.exe" VALUE "OriginalFilename", "ygopro.exe"
VALUE "ProductName", "KoishiPro" VALUE "ProductName", "KoishiPro"
VALUE "FileVersion", "GIGALODOON" VALUE "FileVersion", "Euphoria"
VALUE "ProductVersion", "GIGALODOON" VALUE "ProductVersion", "Euphoria"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
BEGIN BEGIN
VALUE "Translation", 0x804, 1200 VALUE "Translation", 0x804, 1200
END END
END END
Subproject commit 6aff241a80b38289696a1fc52b7fcc754f6eb4b5 Subproject commit ca695a4fc929a1a45d795236e71fd6fd49a34bf2
...@@ -139,6 +139,7 @@ ...@@ -139,6 +139,7 @@
!system 572 请选择要放置指示物的卡 !system 572 请选择要放置指示物的卡
!system 573 请选择要无效的卡 !system 573 请选择要无效的卡
!system 574 请选择要操作的卡 !system 574 请选择要操作的卡
!system 575 请选择场上的卡(按取消可选择其他区域的卡)
!system 1000 卡组 !system 1000 卡组
!system 1001 手卡 !system 1001 手卡
!system 1002 怪兽区 !system 1002 怪兽区
...@@ -564,6 +565,7 @@ ...@@ -564,6 +565,7 @@
!victory 0x20 「真艾克佐迪亚」特殊胜利 !victory 0x20 「真艾克佐迪亚」特殊胜利
!victory 0x21 「混沌虚数No.1000 梦幻虚光神 原数天灵·原数天地」特殊胜利 !victory 0x21 「混沌虚数No.1000 梦幻虚光神 原数天灵·原数天地」特殊胜利
!victory 0x22 「席取-六双丸」特殊胜利 !victory 0x22 「席取-六双丸」特殊胜利
!victory 0x23 「火器的祝台」特殊胜利
!victory 0xffff 由于「%ls」获得比赛胜利 !victory 0xffff 由于「%ls」获得比赛胜利
#counters #counters
!counter 0x1 魔力指示物 !counter 0x1 魔力指示物
...@@ -668,6 +670,7 @@ ...@@ -668,6 +670,7 @@
!counter 0x6a 响鸣指示物 !counter 0x6a 响鸣指示物
!counter 0x6b 狂乱指示物 !counter 0x6b 狂乱指示物
!counter 0x6c 访问指示物 !counter 0x6c 访问指示物
!counter 0x6d 祝台指示物
#setnames, using tab for comment #setnames, using tab for comment
!setname 0x1 正义盟军 AOJ !setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス !setname 0x2 次世代 ジェネクス
...@@ -1229,3 +1232,15 @@ ...@@ -1229,3 +1232,15 @@
!setname 0x1b1 白森林 白き森 !setname 0x1b1 白森林 白き森
!setname 0x1b2 欢聚友伴 マルチャミー !setname 0x1b2 欢聚友伴 マルチャミー
!setname 0x1b3 徽记 エンブレーマ !setname 0x1b3 徽记 エンブレーマ
!setname 0x1b4 时空 タキオン
!setname 0x1b5 蓝泪 青い涙
!setname 0x1b6 石版
!setname 0x1b7 拟箱掳尸 Mimighoul
!setname 0x1b8 鲨 シャーク
!setname 0x11b8 鲨龙兽 シャーク・ドレイク
!setname 0x1b9 原石
!setname 0x1ba 六武式
!setname 0x1bb 金属化 メタル化
!setname 0x1bc 魔瞳
!setname 0x1bd 蓟花 アザミナ
!setname 0x1be 祝台
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