Commit 7305659c authored by nanahira's avatar nanahira

Merge branch 'develop'

parents 9f3d0376 78812871
......@@ -116,7 +116,7 @@ mat_windows:
- wget -O - https://cdn01.moecube.com/ygopro-build-materials/libevent-2.0.22-stable.tar.gz | tar zfx -
- mv libevent-2.0.22-stable event
# irrlicht
- git clone --depth=1 https://code.mycard.moe/mycard/irrlicht-new irrlicht
- git clone --depth=1 -b develop https://code.mycard.moe/mycard/irrlicht-new irrlicht
artifacts:
paths:
- premake5.exe
......
......@@ -269,7 +269,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
// Log.
if (logger)
logger->log(L"CGUITTFont", core::stringw(core::stringw(L"Creating new font: ") + core::ustring(filename).toWCHAR_s() + L" " + core::stringc(size) + L"pt " + (antialias ? L"+antialias " : L"-antialias ") + (transparency ? L"+transparency" : L"-transparency")).c_str(), irr::ELL_INFORMATION);
logger->log(L"CGUITTFont", core::stringw(core::stringw(L"Creating new font: ") + core::stringc(filename) + L" " + core::stringc(size) + L"pt " + (antialias ? L"+antialias " : L"-antialias ") + (transparency ? L"+transparency" : L"-transparency")).c_str(), irr::ELL_INFORMATION);
// Grab the face.
SGUITTFace* face = 0;
......@@ -304,15 +304,12 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
return false;
}
} else {
core::ustring converter(filename);
if (FT_New_Face(c_library, reinterpret_cast<const char*>(converter.toUTF8_s().c_str()), 0, &face->face)) {
if (logger) logger->log(L"CGUITTFont", L"FT_New_Face failed.", irr::ELL_INFORMATION);
if (logger) logger->log(L"CGUITTFont", L"FT_New_Face failed.", irr::ELL_INFORMATION);
c_faces.remove(filename);
delete face;
face = 0;
return false;
}
c_faces.remove(filename);
delete face;
face = 0;
return false;
}
} else {
// Using another instance of this face.
......@@ -491,6 +488,12 @@ void CGUITTFont::setFontHinting(const bool enable, const bool enable_auto_hintin
}
void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position, video::SColor color, bool hcenter, bool vcenter, const core::rect<s32>* clip) {
if (!Driver)
return;
drawUstring(text, position, color, hcenter, vcenter, clip);
}
void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&position, video::SColor color, bool hcenter, bool vcenter, const core::rect<s32>*clip) {
if (!Driver)
return;
......@@ -506,7 +509,7 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position
// Determine offset positions.
if (hcenter || vcenter) {
textDimension = getDimension(text.c_str());
textDimension = getDimension(utext);
if (hcenter)
offset.X = ((position.getWidth() - textDimension.Width) >> 1) + offset.X;
......@@ -515,9 +518,6 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position
offset.Y = ((position.getHeight() - textDimension.Height) >> 1) + offset.Y;
}
// Convert to a unicode string.
core::ustring utext(text);
// Set up our render map.
core::map<u32, CGUITTGlyphPage*> Render_Map;
......
......@@ -54,7 +54,7 @@ public:
//! Structure representing a single TrueType glyph.
struct SGUITTGlyph {
//! Constructor.
SGUITTGlyph() : isLoaded(false), glyph_page(0), surface(0), parent(0) {}
SGUITTGlyph() : isLoaded(false), glyph_page(0), advance({}), surface(0), parent(0) {}
//! Destructor.
~SGUITTGlyph() {
......@@ -207,93 +207,96 @@ public:
static CGUITTFont* create(IrrlichtDevice *device, const io::path& filename, const u32 size, const bool antialias = true, const bool transparency = true);
//! Destructor
virtual ~CGUITTFont();
~CGUITTFont() override;
//! Sets the amount of glyphs to batch load.
virtual void setBatchLoadSize(u32 batch_size) {
void setBatchLoadSize(u32 batch_size) {
batch_load_size = batch_size;
}
//! Sets the maximum texture size for a page of glyphs.
virtual void setMaxPageTextureSize(const core::dimension2du& texture_size) {
void setMaxPageTextureSize(const core::dimension2du& texture_size) {
max_page_texture_size = texture_size;
}
//! Get the font size.
virtual u32 getFontSize() const {
u32 getFontSize() const {
return size;
}
//! Check the font's transparency.
virtual bool isTransparent() const {
bool isTransparent() const {
return use_transparency;
}
//! Check if the font auto-hinting is enabled.
//! Auto-hinting is FreeType's built-in font hinting engine.
virtual bool useAutoHinting() const {
bool useAutoHinting() const {
return use_auto_hinting;
}
//! Check if the font hinting is enabled.
virtual bool useHinting() const {
bool useHinting() const {
return use_hinting;
}
//! Check if the font is being loaded as a monochrome font.
//! The font can either be a 256 color grayscale font, or a 2 color monochrome font.
virtual bool useMonochrome() const {
bool useMonochrome() const {
return use_monochrome;
}
//! Tells the font to allow transparency when rendering.
//! Default: true.
//! \param flag If true, the font draws using transparency.
virtual void setTransparency(const bool flag);
void setTransparency(const bool flag);
//! Tells the font to use monochrome rendering.
//! Default: false.
//! \param flag If true, the font draws using a monochrome image. If false, the font uses a grayscale image.
virtual void setMonochrome(const bool flag);
void setMonochrome(const bool flag);
//! Enables or disables font hinting.
//! Default: Hinting and auto-hinting true.
//! \param enable If false, font hinting is turned off. If true, font hinting is turned on.
//! \param enable_auto_hinting If true, FreeType uses its own auto-hinting algorithm. If false, it tries to use the algorithm specified by the font.
virtual void setFontHinting(const bool enable, const bool enable_auto_hinting = true);
void setFontHinting(const bool enable, const bool enable_auto_hinting = true);
//! Draws some text and clips it to the specified rectangle if wanted.
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
void draw(const core::stringw& text, const core::rect<s32>& position,
video::SColor color, bool hcenter = false, bool vcenter = false,
const core::rect<s32>* clip = 0);
const core::rect<s32>* clip = 0) override;
void drawUstring(const core::ustring& text, const core::rect<s32>& position,
video::SColor color, bool hcenter = false, bool vcenter = false,
const core::rect<s32>* clip = 0);
//! Returns the dimension of a character produced by this font.
virtual core::dimension2d<u32> getCharDimension(const wchar_t ch) const;
core::dimension2d<u32> getCharDimension(const wchar_t ch) const;
//! Returns the dimension of a text string.
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const;
virtual core::dimension2d<u32> getDimension(const core::ustring& text) const;
core::dimension2d<u32> getDimension(const wchar_t* text) const override;
core::dimension2d<u32> getDimension(const core::ustring& text) const;
//! Calculates the index of the character in the text which is on a specific position.
virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const;
virtual s32 getCharacterFromPos(const core::ustring& text, s32 pixel_x) const;
s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const override;
s32 getCharacterFromPos(const core::ustring& text, s32 pixel_x) const;
//! Sets global kerning width for the font.
virtual void setKerningWidth(s32 kerning);
void setKerningWidth(s32 kerning) override;
//! Sets global kerning height for the font.
virtual void setKerningHeight(s32 kerning);
void setKerningHeight(s32 kerning) override;
//! Gets kerning values (distance between letters) for the font. If no parameters are provided,
virtual s32 getKerningWidth(const wchar_t* thisLetter = 0, const wchar_t* previousLetter = 0) const;
virtual s32 getKerningWidth(const uchar32_t thisLetter = 0, const uchar32_t previousLetter = 0) const;
s32 getKerningWidth(const wchar_t* thisLetter = 0, const wchar_t* previousLetter = 0) const override;
s32 getKerningWidth(const uchar32_t thisLetter = 0, const uchar32_t previousLetter = 0) const;
//! Returns the distance between letters
virtual s32 getKerningHeight() const;
s32 getKerningHeight() const override;
//! Define which characters should not be drawn by the font.
virtual void setInvisibleCharacters(const wchar_t *s);
virtual void setInvisibleCharacters(const core::ustring& s);
void setInvisibleCharacters(const wchar_t *s) override;
void setInvisibleCharacters(const core::ustring& s);
//! Get the last glyph page if there's still available slots.
//! If not, it will return zero.
......@@ -312,14 +315,14 @@ public:
//! Create corresponding character's software image copy from the font,
//! so you can use this data just like any ordinary video::IImage.
//! \param ch The character you need
virtual video::IImage* createTextureFromChar(const uchar32_t& ch);
video::IImage* createTextureFromChar(const uchar32_t& ch);
//! This function is for debugging mostly. If the page doesn't exist it returns zero.
//! \param page_index Simply return the texture handle of a given page index.
virtual video::ITexture* getPageTextureByIndex(const u32& page_index) const;
video::ITexture* getPageTextureByIndex(const u32& page_index) const;
//! Add a list of scene nodes generated by putting font textures on the 3D planes.
virtual core::array<scene::ISceneNode*> addTextSceneNode
core::array<scene::ISceneNode*> addTextSceneNode
(const wchar_t* text, scene::ISceneManager* smgr, scene::ISceneNode* parent = 0,
const video::SColor& color = video::SColor(255, 0, 0, 0), bool center = false );
......@@ -340,7 +343,7 @@ private:
static scene::IMesh* shared_plane_ptr_;
static scene::SMesh shared_plane_;
CGUITTFont(IGUIEnvironment *env);
explicit CGUITTFont(IGUIEnvironment *env);
bool load(const io::path& filename, const u32 size, const bool antialias, const bool transparency);
void reset_images();
void update_glyph_pages() const;
......
......@@ -2,6 +2,7 @@
#define BUFFERIO_H
#include <cstdint>
#include <cwchar>
#include "../ocgcore/buffer.h"
class BufferIO {
......@@ -55,6 +56,16 @@ public:
*pstr = 0;
return l;
}
template<size_t N>
static void CopyString(const char* src, wchar_t(&dst)[N]) {
dst[0] = 0;
std::strncat(dst, src, N - 1);
}
template<size_t N>
static void CopyWideString(const wchar_t* src, wchar_t(&dst)[N]) {
dst[0] = 0;
std::wcsncat(dst, src, N - 1);
}
template<typename T>
static bool CheckUTF8Byte(const T* str, int len) {
for (int i = 1; i < len; ++i) {
......
......@@ -1572,10 +1572,10 @@ void ClientField::UpdateDeclarableList() {
if(ancard.size())
return;
}
for(auto cit = dataManager.strings_begin; cit != dataManager.strings_end; ++cit) {
for(auto cit = dataManager.strings_begin(); cit != dataManager.strings_end(); ++cit) {
if(cit->second.name.find(pname) != std::wstring::npos) {
auto cp = dataManager.GetCodePointer(cit->first);
if (cp == dataManager.datas_end)
if (cp == dataManager.datas_end())
continue;
//datas.alias can be double card names or alias
if(is_declarable(cp->second, declare_opcodes)) {
......
This diff is collapsed.
......@@ -2,10 +2,9 @@
#define DATAMANAGER_H
#include "config.h"
#include "sqlite3.h"
#include "spmemvfs/spmemvfs.h"
#include "client_card.h"
#include <unordered_map>
#include <sqlite3.h>
#include "client_card.h"
namespace ygo {
constexpr int MAX_STRING_ID = 0x7ff;
......@@ -14,47 +13,42 @@ namespace ygo {
class DataManager {
public:
DataManager();
bool ReadDB(sqlite3* pDB);
bool LoadDB(const wchar_t* wfile);
bool LoadStrings(const char* file);
bool LoadStrings(IReadFile* reader);
void ReadStringConfLine(const char* linebuf);
bool Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt = 0);
bool GetData(unsigned int code, CardData* pData);
bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = nullptr);
code_pointer GetCodePointer(unsigned int code) const;
string_pointer GetStringPointer(unsigned int code) const;
bool GetString(unsigned int code, CardString* pStr);
const wchar_t* GetName(unsigned int code);
const wchar_t* GetText(unsigned int code);
const wchar_t* GetDesc(unsigned int strCode);
const wchar_t* GetSysString(int code);
const wchar_t* GetVictoryString(int code);
const wchar_t* GetCounterName(int code);
const wchar_t* GetSetName(int code);
std::vector<unsigned int> GetSetCodes(std::wstring setname);
const wchar_t* GetNumString(int num, bool bracket = false);
const wchar_t* FormatLocation(int location, int sequence);
const wchar_t* FormatAttribute(int attribute);
const wchar_t* FormatRace(int race);
const wchar_t* FormatType(int type);
const wchar_t* FormatSetName(const uint16_t setcode[]);
const wchar_t* FormatLinkMarker(int link_marker);
code_pointer datas_begin();
code_pointer datas_end();
string_pointer strings_begin();
string_pointer strings_end();
bool GetData(unsigned int code, CardData* pData) const;
bool GetString(unsigned int code, CardString* pStr) const;
const wchar_t* GetName(unsigned int code) const;
const wchar_t* GetText(unsigned int code) const;
const wchar_t* GetDesc(unsigned int strCode) const;
const wchar_t* GetSysString(int code) const;
const wchar_t* GetVictoryString(int code) const;
const wchar_t* GetCounterName(int code) const;
const wchar_t* GetSetName(int code) const;
std::vector<unsigned int> GetSetCodes(std::wstring setname) const;
std::wstring GetNumString(int num, bool bracket = false) const;
const wchar_t* FormatLocation(int location, int sequence) const;
std::wstring FormatAttribute(unsigned int attribute) const;
std::wstring FormatRace(unsigned int race) const;
std::wstring FormatType(unsigned int type) const;
std::wstring FormatSetName(const uint16_t setcode[]) const;
std::wstring FormatLinkMarker(unsigned int link_marker) const;
std::unordered_map<unsigned int, std::wstring> _counterStrings;
std::unordered_map<unsigned int, std::wstring> _victoryStrings;
std::unordered_map<unsigned int, std::wstring> _setnameStrings;
std::unordered_map<unsigned int, std::wstring> _sysStrings;
code_pointer datas_begin;
code_pointer datas_end;
string_pointer strings_begin;
string_pointer strings_end;
wchar_t numStrings[301][4]{};
wchar_t numBuffer[6]{};
wchar_t attBuffer[128]{};
wchar_t racBuffer[128]{};
wchar_t tpBuffer[128]{};
wchar_t scBuffer[128]{};
wchar_t lmBuffer[32]{};
char errmsg[512]{};
static byte scriptBuffer[0x20000];
static const wchar_t* unknown_string;
......
......@@ -105,11 +105,11 @@ void DeckBuilder::Terminate() {
mainGame->scrPackCards->setVisible(false);
mainGame->scrPackCards->setPos(0);
int catesel = mainGame->cbDBCategory->getSelected();
if(catesel >= 0)
BufferIO::CopyWStr(mainGame->cbDBCategory->getItem(catesel), mainGame->gameConf.lastcategory, 64);
if (catesel >= 0)
BufferIO::CopyWideString(mainGame->cbDBCategory->getItem(catesel), mainGame->gameConf.lastcategory);
int decksel = mainGame->cbDBDecks->getSelected();
if(decksel >= 0)
BufferIO::CopyWStr(mainGame->cbDBDecks->getItem(decksel), mainGame->gameConf.lastdeck, 64);
if (decksel >= 0)
BufferIO::CopyWideString(mainGame->cbDBDecks->getItem(decksel), mainGame->gameConf.lastdeck);
if(exit_on_return)
mainGame->device->closeDevice();
}
......@@ -583,7 +583,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
const wchar_t* newcatename = mainGame->cbDMCategory->getText();
const wchar_t* olddeckname = mainGame->lstDecks->getListItem(decksel);
wchar_t deckname[256];
BufferIO::CopyWStr(olddeckname, deckname, 256);
BufferIO::CopyWideString(olddeckname, deckname);
wchar_t oldfilepath[256];
deckManager.GetDeckFile(oldfilepath, mainGame->cbDBCategory, mainGame->cbDBDecks);
wchar_t newfilepath[256];
......@@ -623,7 +623,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
const wchar_t* newcatename = mainGame->cbDMCategory->getText();
const wchar_t* olddeckname = mainGame->lstDecks->getListItem(decksel);
wchar_t deckname[256];
BufferIO::CopyWStr(olddeckname, deckname, 256);
BufferIO::CopyWideString(olddeckname, deckname);
wchar_t newfilepath[256];
if(oldcatesel != 2 && newcatesel == 0) {
myswprintf(newfilepath, L"./deck/%ls.ydk", deckname);
......@@ -1058,7 +1058,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
dragx = event.MouseInput.X;
dragy = event.MouseInput.Y;
draging_pointer = dataManager.GetCodePointer(hovered_code);
if(draging_pointer == dataManager.datas_end)
if(draging_pointer == dataManager.datas_end())
break;
if(hovered_pos == 4) {
if(!check_limit(draging_pointer))
......@@ -1112,7 +1112,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if(hovered_pos == 0 || hovered_seq == -1)
break;
auto pointer = dataManager.GetCodePointer(hovered_code);
if(pointer == dataManager.datas_end)
if(pointer == dataManager.datas_end())
break;
soundManager.PlaySoundEffect(SOUND_CARD_DROP);
if(hovered_pos == 1) {
......@@ -1147,7 +1147,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
pop_side(hovered_seq);
} else {
auto pointer = dataManager.GetCodePointer(hovered_code);
if(pointer == dataManager.datas_end)
if(pointer == dataManager.datas_end())
break;
if(!check_limit(pointer))
break;
......@@ -1182,7 +1182,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if (is_draging)
break;
auto pointer = dataManager.GetCodePointer(hovered_code);
if (pointer == dataManager.datas_end)
if (pointer == dataManager.datas_end())
break;
if(!check_limit(pointer))
break;
......@@ -1452,10 +1452,10 @@ void DeckBuilder::FilterCards() {
query_elements.push_back(element);
}
}
for(code_pointer ptr = dataManager.datas_begin; ptr != dataManager.datas_end; ++ptr) {
for(code_pointer ptr = dataManager.datas_begin(); ptr != dataManager.datas_end(); ++ptr) {
const CardDataC& data = ptr->second;
auto strpointer = dataManager.GetStringPointer(ptr->first);
if (strpointer == dataManager.strings_end)
if (strpointer == dataManager.strings_end())
continue;
const CardString& text = strpointer->second;
if(data.type & TYPE_TOKEN)
......
......@@ -189,7 +189,7 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p
}
int DeckManager::LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_packlist) {
int ct = 0, mainc = 0, sidec = 0, code = 0;
int cardlist[300]{};
int cardlist[PACK_MAX_SIZE]{};
bool is_side = false;
std::string linebuf;
while (std::getline(deckStream, linebuf, '\n') && ct < (int)(sizeof cardlist / sizeof cardlist[0])) {
......@@ -244,7 +244,7 @@ void DeckManager::GetCategoryPath(wchar_t* ret, int index, const wchar_t* text)
myswprintf(catepath, L"./pack");
break;
case 1:
myswprintf(catepath, mainGame->gameConf.bot_deck_path);
BufferIO::CopyWideString(mainGame->gameConf.bot_deck_path, catepath);
break;
case -1:
case 2:
......
......@@ -28,6 +28,7 @@ namespace ygo {
constexpr int DECK_MIN_SIZE = YGOPRO_MIN_DECK;
constexpr int EXTRA_MAX_SIZE = YGOPRO_MAX_EXTRA;
constexpr int SIDE_MAX_SIZE = YGOPRO_MAX_SIDE;
constexpr int PACK_MAX_SIZE = 1000;
struct LFList {
unsigned int hash{};
......
This diff is collapsed.
......@@ -1228,7 +1228,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
break;
}
case HINT_RACE: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatRace(data));
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatRace(data).c_str());
mainGame->AddLog(textBuffer);
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
......@@ -1238,7 +1238,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
break;
}
case HINT_ATTRIB: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatAttribute(data));
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatAttribute(data).c_str());
mainGame->AddLog(textBuffer);
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
......@@ -1370,7 +1370,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
int type = BufferIO::ReadUInt8(pbuf);
mainGame->showcarddif = 110;
mainGame->showcardp = 0;
mainGame->dInfo.vic_string = 0;
mainGame->dInfo.vic_string = L"";
wchar_t vic_buf[256];
if(player == 2)
mainGame->showcardcode = 3;
......@@ -1396,7 +1396,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
}
mainGame->showcard = 101;
mainGame->WaitFrameSignal(120);
mainGame->dInfo.vic_string = 0;
mainGame->dInfo.vic_string = L"";
mainGame->showcard = 0;
break;
}
......@@ -3437,7 +3437,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0;
mainGame->lpcstring = L"";
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
......@@ -3466,7 +3466,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0;
mainGame->lpcstring = L"";
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
......@@ -3618,7 +3618,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0;
mainGame->lpcstring = L"";
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
......
......@@ -1618,7 +1618,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
myswprintf(formatBuffer, L"\nLINK-%d", mcard->link);
str.append(formatBuffer);
}
myswprintf(formatBuffer, L" %ls/%ls", dataManager.FormatRace(mcard->race), dataManager.FormatAttribute(mcard->attribute));
myswprintf(formatBuffer, L" %ls/%ls", dataManager.FormatRace(mcard->race).c_str(), dataManager.FormatAttribute(mcard->attribute).c_str());
str.append(formatBuffer);
if(mcard->location == LOCATION_HAND && (mcard->type & TYPE_PENDULUM)) {
myswprintf(formatBuffer, L"\n%d/%d", mcard->lscale, mcard->rscale);
......@@ -1644,9 +1644,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
else if(mcard->cHint == CHINT_CARD)
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(212), dataManager.GetName(mcard->chValue));
else if(mcard->cHint == CHINT_RACE)
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(213), dataManager.FormatRace(mcard->chValue));
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(213), dataManager.FormatRace(mcard->chValue).c_str());
else if(mcard->cHint == CHINT_ATTRIBUTE)
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(214), dataManager.FormatAttribute(mcard->chValue));
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(214), dataManager.FormatAttribute(mcard->chValue).c_str());
else if(mcard->cHint == CHINT_NUMBER)
myswprintf(formatBuffer, L"\n%ls%d", dataManager.GetSysString(215), mcard->chValue);
str.append(formatBuffer);
......@@ -2586,11 +2586,14 @@ void ClientField::ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* e
}
}
void ClientField::SetResponseSelectedCards() const {
unsigned char respbuf[SIZE_RETURN_VALUE];
respbuf[0] = selected_cards.size();
for (size_t i = 0; i < selected_cards.size(); ++i)
unsigned char respbuf[SIZE_RETURN_VALUE]{};
int len = (int)selected_cards.size();
if (len > UINT8_MAX)
len = UINT8_MAX;
respbuf[0] = (unsigned char)len;
for (int i = 0; i < len; ++i)
respbuf[i + 1] = selected_cards[i]->select_seq;
DuelClient::SetResponseB(respbuf, selected_cards.size() + 1);
DuelClient::SetResponseB(respbuf, len + 1);
}
void ClientField::SetResponseSelectedOption() const {
if(mainGame->dInfo.curMsg == MSG_SELECT_OPTION) {
......
This diff is collapsed.
......@@ -26,9 +26,12 @@
#ifndef YGOPRO_DEFAULT_DUEL_RULE
#define YGOPRO_DEFAULT_DUEL_RULE 5
#endif
constexpr int CONFIG_LINE_SIZE = 1024;
namespace ygo {
bool IsExtension(const wchar_t* filename, const wchar_t* extension);
struct Config {
bool use_d3d{ false };
bool use_image_scale{ true };
......@@ -36,15 +39,16 @@ struct Config {
unsigned short serverport{ 7911 };
unsigned char textfontsize{ 14 };
wchar_t lasthost[100]{};
int lastport{ 0 };
wchar_t lastport[10]{};
wchar_t nickname[20]{};
wchar_t gamename[20]{};
wchar_t lastcategory[64]{};
wchar_t lastdeck[64]{};
wchar_t roompass[20]{};
//path
wchar_t lastcategory[256]{};
wchar_t lastdeck[256]{};
wchar_t textfont[256]{};
wchar_t numfont[256]{};
wchar_t roompass[20]{};
wchar_t bot_deck_path[64]{};
wchar_t bot_deck_path[256]{};
wchar_t locale[64];
//settings
int chkMAutoPos{ 0 };
......@@ -113,7 +117,7 @@ struct DuelInfo {
wchar_t hostname_tag[20]{};
wchar_t clientname_tag[20]{};
wchar_t strLP[2][16]{};
wchar_t* vic_string{ nullptr };
std::wstring vic_string;
unsigned char player_type{ 0 };
unsigned char time_player{ 0 };
unsigned short time_limit{ 0 };
......@@ -176,7 +180,6 @@ public:
void CheckMutual(ClientCard* pcard, int mark);
void DrawCards();
void DrawCard(ClientCard* pcard);
void DrawShadowText(irr::gui::CGUITTFont* font, const core::stringw& text, const core::rect<s32>& position, const core::rect<s32>& padding, video::SColor color = 0xffffffff, video::SColor shadowcolor = 0xff000000, bool hcenter = false, bool vcenter = false, const core::rect<s32>* clip = 0);
void DrawMisc();
void DrawStatus(ClientCard* pcard, int x1, int y1, int x2, int y2);
void DrawGUI();
......@@ -283,7 +286,7 @@ public:
int lpd;
int lpplayer;
int lpccolor;
wchar_t* lpcstring;
std::wstring lpcstring;
bool always_chain;
bool ignore_chain;
bool chain_when_avail;
......
......@@ -132,14 +132,14 @@ int main(int argc, char* argv[]) {
++i;
if(i < wargc) {
deckCategorySpecified = true;
wcscpy(ygo::mainGame->gameConf.lastcategory, wargv[i]);
BufferIO::CopyWideString(wargv[i], ygo::mainGame->gameConf.lastcategory);
}
} else if(!wcscmp(wargv[i], L"-d")) { // Deck
++i;
if(!deckCategorySpecified)
ygo::mainGame->gameConf.lastcategory[0] = 0;
if(i + 1 < wargc) { // select deck
wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]);
BufferIO::CopyWideString(wargv[i], ygo::mainGame->gameConf.lastdeck);
continue;
} else { // open deck
exit_on_return = !keep_on_return;
......@@ -152,7 +152,7 @@ int main(int argc, char* argv[]) {
myswprintf(open_file_name, L"%ls/%ls", ygo::mainGame->gameConf.lastcategory, wargv[i]);
#endif
} else {
wcscpy(open_file_name, wargv[i]);
BufferIO::CopyWideString(wargv[i], open_file_name);
}
}
ClickButton(ygo::mainGame->btnDeckEdit);
......@@ -173,7 +173,7 @@ int main(int argc, char* argv[]) {
++i;
if(i < wargc) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
BufferIO::CopyWideString(wargv[i], open_file_name);
}
ClickButton(ygo::mainGame->btnReplayMode);
if(open_file)
......@@ -184,7 +184,7 @@ int main(int argc, char* argv[]) {
++i;
if(i < wargc) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
BufferIO::CopyWideString(wargv[i], open_file_name);
}
ClickButton(ygo::mainGame->btnSingleMode);
if(open_file)
......@@ -194,14 +194,14 @@ int main(int argc, char* argv[]) {
wchar_t* pstrext = wargv[1] + wcslen(wargv[1]) - 4;
if(!mywcsncasecmp(pstrext, L".ydk", 4)) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
BufferIO::CopyWideString(wargv[i], open_file_name);
exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnDeckEdit);
break;
}
if(!mywcsncasecmp(pstrext, L".yrp", 4)) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
BufferIO::CopyWideString(wargv[i], open_file_name);
exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnReplayMode);
ClickButton(ygo::mainGame->btnLoadReplay);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -442,8 +442,8 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
pduel = create_duel(duel_seed);
set_player_info(pduel, 0, host_info.start_lp, host_info.start_hand, host_info.draw_count);
set_player_info(pduel, 1, host_info.start_lp, host_info.start_hand, host_info.draw_count);
preload_script(pduel, "./script/special.lua", 0);
preload_script(pduel, "./script/init.lua", 0);
preload_script(pduel, "./script/special.lua");
preload_script(pduel, "./script/init.lua");
unsigned int opt = (unsigned int)host_info.duel_rule << 16;
if(host_info.no_shuffle_deck)
opt |= DUEL_PSEUDO_SHUFFLE;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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