Commit 63ad4fbc authored by wind2009's avatar wind2009

Merge remote-tracking branch 'upstream/master' into server-develop

parents f56aea7a 12259071
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#define mystrncasecmp strncasecmp #define mystrncasecmp strncasecmp
#endif #endif
#include <string> #include <wchar.h>
template<size_t N, typename... TR> template<size_t N, typename... TR>
inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return swprintf(buf, N, fmt, args...); return swprintf(buf, N, fmt, args...);
...@@ -51,9 +51,9 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -51,9 +51,9 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <wchar.h>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <string>
#include "bufferio.h" #include "bufferio.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h" #include "../ocgcore/common.h"
......
...@@ -314,7 +314,7 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) { ...@@ -314,7 +314,7 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
reader->drop(); reader->drop();
return false; return false;
} }
memset(deckBuffer, 0, sizeof(deckBuffer)); std::memset(deckBuffer, 0, sizeof deckBuffer);
reader->read(deckBuffer, size); reader->read(deckBuffer, size);
reader->drop(); reader->drop();
std::istringstream deckStream(deckBuffer); std::istringstream deckStream(deckBuffer);
......
...@@ -44,7 +44,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g ...@@ -44,7 +44,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
client_base = event_base_new(); client_base = event_base_new();
if(!client_base) if(!client_base)
return false; return false;
memset(&sin, 0, sizeof(sin)); std::memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(ip); sin.sin_addr.s_addr = htonl(ip);
sin.sin_port = htons(port); sin.sin_port = htons(port);
...@@ -4062,7 +4062,7 @@ void DuelClient::BeginRefreshHost() { ...@@ -4062,7 +4062,7 @@ void DuelClient::BeginRefreshHost() {
return; return;
SOCKET reply = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); SOCKET reply = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
sockaddr_in reply_addr; sockaddr_in reply_addr;
memset(&reply_addr, 0, sizeof(reply_addr)); std::memset(&reply_addr, 0, sizeof reply_addr);
reply_addr.sin_family = AF_INET; reply_addr.sin_family = AF_INET;
reply_addr.sin_port = htons(7921); reply_addr.sin_port = htons(7921);
reply_addr.sin_addr.s_addr = 0; reply_addr.sin_addr.s_addr = 0;
......
...@@ -78,7 +78,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -78,7 +78,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
BufferIO::CopyWStr(mainGame->ebJoinPort->getText(), port, 6); BufferIO::CopyWStr(mainGame->ebJoinPort->getText(), port, 6);
struct evutil_addrinfo hints; struct evutil_addrinfo hints;
struct evutil_addrinfo *answer = NULL; struct evutil_addrinfo *answer = NULL;
memset(&hints, 0, sizeof(hints)); std::memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP; hints.ai_protocol = IPPROTO_TCP;
......
...@@ -86,7 +86,7 @@ bool NetServer::StartServer(unsigned short port) { ...@@ -86,7 +86,7 @@ bool NetServer::StartServer(unsigned short port) {
if(!net_evbase) if(!net_evbase)
return false; return false;
sockaddr_in sin; sockaddr_in sin;
memset(&sin, 0, sizeof(sin)); std::memset(&sin, 0, sizeof sin);
server_port = port; server_port = port;
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
#ifdef SERVER_PRO2_SUPPORT #ifdef SERVER_PRO2_SUPPORT
...@@ -122,7 +122,7 @@ bool NetServer::StartBroadcast() { ...@@ -122,7 +122,7 @@ bool NetServer::StartBroadcast() {
setsockopt(udp, SOL_SOCKET, SO_BROADCAST, (const char*)&opt, sizeof opt); setsockopt(udp, SOL_SOCKET, SO_BROADCAST, (const char*)&opt, sizeof opt);
setsockopt(udp, SOL_SOCKET, SO_REUSEADDR, (const char*)&opt, sizeof opt); setsockopt(udp, SOL_SOCKET, SO_REUSEADDR, (const char*)&opt, sizeof opt);
sockaddr_in addr; sockaddr_in addr;
memset(&addr, 0, sizeof(addr)); std::memset(&addr, 0, sizeof addr);
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(7920); addr.sin_port = htons(7920);
addr.sin_addr.s_addr = 0; addr.sin_addr.s_addr = 0;
......
...@@ -1965,7 +1965,7 @@ if(!dp || dp == players[player]) ...@@ -1965,7 +1965,7 @@ if(!dp || dp == players[player])
continue; continue;
auto position = GetPosition(qbuf, 8); auto position = GetPosition(qbuf, 8);
if (position & POS_FACEDOWN) if (position & POS_FACEDOWN)
memset(qbuf, 0, clen - 4); std::memset(qbuf, 0, clen - 4);
qbuf += clen - 4; qbuf += clen - 4;
} }
#ifdef YGOPRO_SERVER_MODE #ifdef YGOPRO_SERVER_MODE
...@@ -2008,7 +2008,7 @@ if(!dp || dp == players[player]) ...@@ -2008,7 +2008,7 @@ if(!dp || dp == players[player])
continue; continue;
auto position = GetPosition(qbuf, 8); auto position = GetPosition(qbuf, 8);
if (position & POS_FACEDOWN) if (position & POS_FACEDOWN)
memset(qbuf, 0, clen - 4); std::memset(qbuf, 0, clen - 4);
qbuf += clen - 4; qbuf += clen - 4;
} }
#ifdef YGOPRO_SERVER_MODE #ifdef YGOPRO_SERVER_MODE
...@@ -2051,7 +2051,7 @@ if(!dp || dp == players[player]) ...@@ -2051,7 +2051,7 @@ if(!dp || dp == players[player])
continue; continue;
auto position = GetPosition(qbuf, 8); auto position = GetPosition(qbuf, 8);
if(!(position & POS_FACEUP)) if(!(position & POS_FACEUP))
memset(qbuf, 0, slen - 4); std::memset(qbuf, 0, slen - 4);
qbuf += slen - 4; qbuf += slen - 4;
} }
#ifdef YGOPRO_SERVER_MODE #ifdef YGOPRO_SERVER_MODE
...@@ -2180,7 +2180,7 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag) ...@@ -2180,7 +2180,7 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
if (position & POS_FACEDOWN) { if (position & POS_FACEDOWN) {
BufferIO::WriteInt32(qbuf, QUERY_CODE); BufferIO::WriteInt32(qbuf, QUERY_CODE);
BufferIO::WriteInt32(qbuf, 0); BufferIO::WriteInt32(qbuf, 0);
memset(qbuf, 0, clen - 12); std::memset(qbuf, 0, clen - 12);
} }
NetServer::SendBufferToPlayer(players[1 - player], STOC_GAME_MSG, query_buffer, len + 4); NetServer::SendBufferToPlayer(players[1 - player], STOC_GAME_MSG, query_buffer, len + 4);
for (auto pit = observers.begin(); pit != observers.end(); ++pit) for (auto pit = observers.begin(); pit != observers.end(); ++pit)
......
...@@ -2080,7 +2080,7 @@ if(!dp || dp == players[pid]) ...@@ -2080,7 +2080,7 @@ if(!dp || dp == players[pid])
continue; continue;
auto position = GetPosition(qbuf, 8); auto position = GetPosition(qbuf, 8);
if (position & POS_FACEDOWN) if (position & POS_FACEDOWN)
memset(qbuf, 0, clen - 4); std::memset(qbuf, 0, clen - 4);
qbuf += clen - 4; qbuf += clen - 4;
} }
pid = 2 - pid; pid = 2 - pid;
...@@ -2133,7 +2133,7 @@ if(!dp || dp == players[pid]) ...@@ -2133,7 +2133,7 @@ if(!dp || dp == players[pid])
continue; continue;
auto position = GetPosition(qbuf, 8); auto position = GetPosition(qbuf, 8);
if (position & POS_FACEDOWN) if (position & POS_FACEDOWN)
memset(qbuf, 0, clen - 4); std::memset(qbuf, 0, clen - 4);
qbuf += clen - 4; qbuf += clen - 4;
} }
pid = 2 - pid; pid = 2 - pid;
...@@ -2181,7 +2181,7 @@ if(!dp || dp == cur_player[player]) ...@@ -2181,7 +2181,7 @@ if(!dp || dp == cur_player[player])
continue; continue;
auto position = GetPosition(qbuf, 8); auto position = GetPosition(qbuf, 8);
if(!(position & POS_FACEUP)) if(!(position & POS_FACEUP))
memset(qbuf, 0, slen - 4); std::memset(qbuf, 0, slen - 4);
qbuf += slen - 4; qbuf += slen - 4;
} }
for(int i = 0; i < 4; ++i) for(int i = 0; i < 4; ++i)
......
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