Commit db9afc59 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro into develop

parents a1bfb45a c7b674da
......@@ -6,7 +6,6 @@
#include "image_manager.h"
#include "game.h"
#include "materials.h"
#include "../ocgcore/common.h"
namespace ygo {
......
......@@ -165,8 +165,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
}
}
bool DataManager::Error(sqlite3* pDB, sqlite3_stmt* pStmt) {
errmsg[0] = '\0';
std::strncat(errmsg, sqlite3_errmsg(pDB), sizeof errmsg - 1);
std::snprintf(errmsg, sizeof errmsg, "%s", sqlite3_errmsg(pDB));
if(pStmt)
sqlite3_finalize(pStmt);
return false;
......
......@@ -5,7 +5,6 @@
#include "deck_manager.h"
#include "sound_manager.h"
#include "duelclient.h"
#include "../ocgcore/common.h"
namespace ygo {
......
......@@ -891,8 +891,12 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_CHAT: {
if (len < 1 + sizeof(uint16_t) + sizeof(uint16_t) * 1)
return;
if (len > 1 + sizeof(uint16_t) + sizeof(uint16_t) * LEN_CHAT_MSG)
return;
const int chat_msg_size = len - 1 - sizeof(uint16_t);
if (!check_msg_size(chat_msg_size))
if (chat_msg_size % sizeof(uint16_t))
return;
uint16_t chat_player_type = buffer_read<uint16_t>(pdata);
uint16_t chat_msg[LEN_CHAT_MSG];
......
#include "event_handler.h"
#include "client_field.h"
#include "math.h"
#include "network.h"
#include "game.h"
#include "duelclient.h"
......@@ -11,7 +10,6 @@
#include "replay_mode.h"
#include "single_mode.h"
#include "materials.h"
#include "../ocgcore/common.h"
namespace ygo {
......
......@@ -206,7 +206,11 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
case CTOS_CHAT: {
if(!dp->game)
return;
if (len < 1 + (int)sizeof(unsigned char))
if (len < 1 + sizeof(uint16_t) * 1)
return;
if (len > 1 + sizeof(uint16_t) * LEN_CHAT_MSG)
return;
if ((len - 1) % sizeof(uint16_t))
return;
duel_mode->Chat(dp, pdata, len - 1);
break;
......@@ -360,8 +364,6 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
}
}
size_t NetServer::CreateChatPacket(unsigned char* src, int src_size, unsigned char* dst, uint16_t dst_player_type) {
if (!check_msg_size(src_size))
return 0;
uint16_t src_msg[LEN_CHAT_MSG];
std::memcpy(src_msg, src, src_size);
const int src_len = src_size / sizeof(uint16_t);
......
......@@ -196,17 +196,6 @@ struct DuelPlayer {
bufferevent* bev{};
};
inline bool check_msg_size(int size) {
// empty string is not allowed
if (size < 2 * sizeof(uint16_t))
return false;
if (size > LEN_CHAT_MSG * sizeof(uint16_t))
return false;
if (size % sizeof(uint16_t) != 0)
return false;
return true;
}
inline unsigned int GetPosition(unsigned char* qbuf, size_t offset) {
unsigned int info = 0;
std::memcpy(&info, qbuf + offset, sizeof info);
......
......@@ -68,6 +68,7 @@ void SoundManager::RefreshBGMList() {
#endif
}
void SoundManager::RefershBGMDir(std::wstring path, int scene) {
#ifdef YGOPRO_USE_AUDIO
std::wstring search = L"./sound/BGM/" + path;
FileSystem::TraversalDir(search.c_str(), [this, &path, scene](const wchar_t* name, bool isdir) {
if(!isdir && (
......@@ -81,6 +82,7 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) {
BGMList[scene].push_back(filename);
}
});
#endif // YGOPRO_USE_AUDIO
}
void SoundManager::PlaySound(wchar_t* sound) {
#ifdef YGOPRO_USE_AUDIO
......
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