Commit eb429945 authored by nanahira's avatar nanahira

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

parents f05e22b2 d065fad9
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_BUTTON_H_INCLUDED__
#define __C_GUI_BUTTON_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIButton.h"
#include "IGUISpriteBank.h"
#include "SColor.h"
namespace irr
{
namespace gui
{
class CGUIButton : public IGUIButton
{
public:
//! constructor
CGUIButton(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool noclip=false);
//! destructor
virtual ~CGUIButton();
//! called if an event happened.
virtual bool OnEvent(const SEvent& event);
//! draws the element and its children
virtual void draw();
//! sets another skin independent font. if this is set to zero, the button uses the font of the skin.
virtual void setOverrideFont(IGUIFont* font=0);
//! Gets the override font (if any)
virtual IGUIFont* getOverrideFont() const;
//! Get the font which is used right now for drawing
virtual IGUIFont* getActiveFont() const;
//! Sets an image which should be displayed on the button when it is in normal state.
virtual void setImage(video::ITexture* image=0);
//! Sets an image which should be displayed on the button when it is in normal state.
virtual void setImage(video::ITexture* image, const core::rect<s32>& pos);
//! Sets an image which should be displayed on the button when it is in pressed state.
virtual void setPressedImage(video::ITexture* image=0);
//! Sets an image which should be displayed on the button when it is in pressed state.
virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos);
//! Sets the sprite bank used by the button
virtual void setSpriteBank(IGUISpriteBank* bank=0);
//! Sets the animated sprite for a specific button state
/** \param index: Number of the sprite within the sprite bank, use -1 for no sprite
\param state: State of the button to set the sprite for
\param index: The sprite number from the current sprite bank
\param color: The color of the sprite
*/
virtual void setSprite(EGUI_BUTTON_STATE state, s32 index,
video::SColor color=video::SColor(255,255,255,255), bool loop=false);
//! Sets if the button should behave like a push button. Which means it
//! can be in two states: Normal or Pressed. With a click on the button,
//! the user can change the state of the button.
virtual void setIsPushButton(bool isPushButton=true);
//! Checks whether the button is a push button
virtual bool isPushButton() const;
//! Sets the pressed state of the button if this is a pushbutton
virtual void setPressed(bool pressed=true);
//! Returns if the button is currently pressed
virtual bool isPressed() const;
//! Sets if the button should use the skin to draw its border
virtual void setDrawBorder(bool border=true);
//! Checks if the button face and border are being drawn
virtual bool isDrawingBorder() const;
//! Sets if the alpha channel should be used for drawing images on the button (default is false)
virtual void setUseAlphaChannel(bool useAlphaChannel=true);
//! Checks if the alpha channel should be used for drawing images on the button
virtual bool isAlphaChannelUsed() const;
//! Sets if the button should scale the button images to fit
virtual void setScaleImage(bool scaleImage=true);
//! Checks whether the button scales the used images
virtual bool isScalingImage() const;
//! Writes attributes of the element.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
//! Reads attributes of the element
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
protected:
struct ButtonSprite
{
s32 Index;
video::SColor Color;
bool Loop;
};
ButtonSprite ButtonSprites[EGBS_COUNT];
IGUISpriteBank* SpriteBank;
IGUIFont* OverrideFont;
video::ITexture* Image;
video::ITexture* PressedImage;
core::rect<s32> ImageRect;
core::rect<s32> PressedImageRect;
u32 ClickTime, HoverTime, FocusTime;
bool IsPushButton;
bool Pressed;
bool UseAlphaChannel;
bool DrawBorder;
bool ScaleImage;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_BUTTON_H_INCLUDED__
This diff is collapsed.
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef _C_GUI_IMAGE_BUTTON_H_ #ifndef _C_GUI_IMAGE_BUTTON_H_
#define _C_GUI_IMAGE_BUTTON_H_ #define _C_GUI_IMAGE_BUTTON_H_
#include <irrlicht.h> #include <IrrCompileConfig.h>
#include "CGUIButton.h" #ifdef _IRR_COMPILE_WITH_GUI_
#include <IGUIButton.h>
#include <SColor.h>
namespace irr { namespace irr {
namespace video {
class IVideoDriver;
class ITexture;
}
namespace gui { namespace gui {
class IGUISpriteBank;
void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect, void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> position, core::position2d<s32> rotationPoint, f32 rotation = 0.0f, core::position2d<s32> position, core::position2d<s32> rotationPoint, f32 rotation = 0.0f,
core::vector2df scale = core::vector2df(1.0, 1.0), bool useAlphaChannel = true, video::SColor color = 0xffffffff); core::vector2df scale = core::vector2df(1.0, 1.0), bool useAlphaChannel = true, video::SColor color = 0xffffffff);
void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect, void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> corner[4], bool useAlphaChannel = true, video::SColor color = 0xffffffff); core::position2d<s32> corner[4], bool useAlphaChannel = true, video::SColor color = 0xffffffff);
class CGUIImageButton : public CGUIButton {
class CGUIImageButton : public IGUIButton {
public: public:
CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle); static CGUIImageButton* addImageButton(IGUIEnvironment* env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id);
static CGUIImageButton* addImageButton(IGUIEnvironment *env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id);
virtual void draw(); //! constructor
virtual void setImage(video::ITexture* image = 0); CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent,
virtual void setDrawImage(bool b); s32 id, core::rect<s32> rectangle, bool noclip = false);
virtual void setImageRotation(f32 r);
virtual void setImageScale(core::vector2df s); //! destructor
virtual void setImageSize(core::dimension2di s); ~CGUIImageButton() override;
virtual IGUIFont* getOverrideFont(void) const;
virtual IGUIFont* getActiveFont() const; //! called if an event happened.
bool OnEvent(const SEvent& event) override;
private:
//! draws the element and its children
void draw() override;
//! sets another skin independent font. if this is set to zero, the button uses the font of the skin.
void setOverrideFont(IGUIFont* font = 0) override;
//! Gets the override font (if any)
IGUIFont* getOverrideFont() const override;
//! Get the font which is used right now for drawing
IGUIFont* getActiveFont() const override;
//! Sets an image which should be displayed on the button when it is in normal state.
void setImage(video::ITexture* image = 0) override;
//! Sets an image which should be displayed on the button when it is in normal state.
void setImage(video::ITexture* image, const core::rect<s32>& pos) override;
//! Sets an image which should be displayed on the button when it is in pressed state.
void setPressedImage(video::ITexture* image = 0) override;
//! Sets an image which should be displayed on the button when it is in pressed state.
void setPressedImage(video::ITexture* image, const core::rect<s32>& pos) override;
//! Sets the sprite bank used by the button
void setSpriteBank(IGUISpriteBank* bank = 0) override;
//! Sets the animated sprite for a specific button state
/** \param index: Number of the sprite within the sprite bank, use -1 for no sprite
\param state: State of the button to set the sprite for
\param index: The sprite number from the current sprite bank
\param color: The color of the sprite
*/
void setSprite(EGUI_BUTTON_STATE state, s32 index,
video::SColor color = video::SColor(255, 255, 255, 255), bool loop = false) override;
//! Sets if the button should behave like a push button. Which means it
//! can be in two states: Normal or Pressed. With a click on the button,
//! the user can change the state of the button.
void setIsPushButton(bool isPushButton = true) override;
//! Checks whether the button is a push button
bool isPushButton() const override;
//! Sets the pressed state of the button if this is a pushbutton
void setPressed(bool pressed = true) override;
//! Returns if the button is currently pressed
bool isPressed() const override;
//! Sets if the button should use the skin to draw its border
void setDrawBorder(bool border = true) override;
//! Checks if the button face and border are being drawn
bool isDrawingBorder() const override;
//! Sets if the alpha channel should be used for drawing images on the button (default is false)
void setUseAlphaChannel(bool useAlphaChannel = true) override;
//! Checks if the alpha channel should be used for drawing images on the button
bool isAlphaChannelUsed() const override;
//! Sets if the button should scale the button images to fit
void setScaleImage(bool scaleImage = true) override;
//! Checks whether the button scales the used images
bool isScalingImage() const override;
//! Writes attributes of the element.
void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const override;
//! Reads attributes of the element
void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) override;
// from ygopro
void setDrawImage(bool b);
void setImageRotation(f32 r);
void setImageScale(core::vector2df s);
void setImageSize(core::dimension2di s);
protected:
struct ButtonSprite
{
s32 Index;
video::SColor Color;
bool Loop;
};
ButtonSprite ButtonSprites[EGBS_COUNT];
IGUISpriteBank* SpriteBank;
IGUIFont* OverrideFont;
video::ITexture* Image;
video::ITexture* PressedImage;
core::rect<s32> ImageRect;
core::rect<s32> PressedImageRect;
bool IsPushButton;
bool Pressed;
bool UseAlphaChannel;
bool DrawBorder;
bool ScaleImage;
// from ygopro
bool isDrawImage; bool isDrawImage;
bool isFixedSize; bool isFixedSize;
f32 imageRotation; f32 imageRotation;
...@@ -36,4 +155,6 @@ private: ...@@ -36,4 +155,6 @@ private:
} }
} }
#endif // _IRR_COMPILE_WITH_GUI_
#endif //_C_GUI_IMAGE_BUTTON_H_ #endif //_C_GUI_IMAGE_BUTTON_H_
...@@ -50,7 +50,7 @@ inline int _wtoi(const wchar_t * str){ ...@@ -50,7 +50,7 @@ inline int _wtoi(const wchar_t * str){
} }
#endif #endif
#include <stdio.h> #include <cstdio>
#include <stdlib.h> #include <stdlib.h>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
...@@ -63,7 +63,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -63,7 +63,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return std::swprintf(buf, N, fmt, args...); return std::swprintf(buf, N, fmt, args...);
} }
inline FILE* myfopen(const wchar_t* filename, const char* mode) { inline FILE* mywfopen(const wchar_t* filename, const char* mode) {
FILE* fp{}; FILE* fp{};
#ifdef _WIN32 #ifdef _WIN32
wchar_t wmode[20]{}; wchar_t wmode[20]{};
...@@ -72,7 +72,7 @@ inline FILE* myfopen(const wchar_t* filename, const char* mode) { ...@@ -72,7 +72,7 @@ inline FILE* myfopen(const wchar_t* filename, const char* mode) {
#else #else
char fname[1024]{}; char fname[1024]{};
BufferIO::EncodeUTF8(filename, fname); BufferIO::EncodeUTF8(filename, fname);
fp = fopen(fname, mode); fp = std::fopen(fname, mode);
#endif #endif
return fp; return fp;
} }
......
#include "data_manager.h" #include "data_manager.h"
#include "game.h" #include "game.h"
#include <stdio.h>
#include "spmemvfs/spmemvfs.h" #include "spmemvfs/spmemvfs.h"
namespace ygo { namespace ygo {
...@@ -109,14 +108,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) { ...@@ -109,14 +108,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
return ret; return ret;
} }
bool DataManager::LoadStrings(const char* file) { bool DataManager::LoadStrings(const char* file) {
FILE* fp = fopen(file, "r"); FILE* fp = std::fopen(file, "r");
if(!fp) if(!fp)
return false; return false;
char linebuf[TEXT_LINE_SIZE]{}; char linebuf[TEXT_LINE_SIZE]{};
while(fgets(linebuf, sizeof linebuf, fp)) { while(std::fgets(linebuf, sizeof linebuf, fp)) {
ReadStringConfLine(linebuf); ReadStringConfLine(linebuf);
} }
fclose(fp); std::fclose(fp);
return true; return true;
} }
bool DataManager::LoadStrings(irr::io::IReadFile* reader) { bool DataManager::LoadStrings(irr::io::IReadFile* reader) {
...@@ -140,26 +139,26 @@ void DataManager::ReadStringConfLine(const char* linebuf) { ...@@ -140,26 +139,26 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
char strbuf[TEXT_LINE_SIZE]{}; char strbuf[TEXT_LINE_SIZE]{};
int value{}; int value{};
wchar_t strBuffer[4096]{}; wchar_t strBuffer[4096]{};
if (sscanf(linebuf, "!%63s", strbuf) != 1) if (std::sscanf(linebuf, "!%63s", strbuf) != 1)
return; return;
if(!std::strcmp(strbuf, "system")) { if(!std::strcmp(strbuf, "system")) {
if (sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf) != 2) if (std::sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf) != 2)
return; return;
BufferIO::DecodeUTF8(strbuf, strBuffer); BufferIO::DecodeUTF8(strbuf, strBuffer);
_sysStrings[value] = strBuffer; _sysStrings[value] = strBuffer;
} else if(!std::strcmp(strbuf, "victory")) { } else if(!std::strcmp(strbuf, "victory")) {
if (sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2) if (std::sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2)
return; return;
BufferIO::DecodeUTF8(strbuf, strBuffer); BufferIO::DecodeUTF8(strbuf, strBuffer);
_victoryStrings[value] = strBuffer; _victoryStrings[value] = strBuffer;
} else if(!std::strcmp(strbuf, "counter")) { } else if(!std::strcmp(strbuf, "counter")) {
if (sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2) if (std::sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2)
return; return;
BufferIO::DecodeUTF8(strbuf, strBuffer); BufferIO::DecodeUTF8(strbuf, strBuffer);
_counterStrings[value] = strBuffer; _counterStrings[value] = strBuffer;
} else if(!std::strcmp(strbuf, "setname")) { } else if(!std::strcmp(strbuf, "setname")) {
//using tab for comment //using tab for comment
if (sscanf(&linebuf[8], "%x %240[^\t\n]", &value, strbuf) != 2) if (std::sscanf(&linebuf[8], "%x %240[^\t\n]", &value, strbuf) != 2)
return; return;
BufferIO::DecodeUTF8(strbuf, strBuffer); BufferIO::DecodeUTF8(strbuf, strBuffer);
_setnameStrings[value] = strBuffer; _setnameStrings[value] = strBuffer;
...@@ -414,7 +413,7 @@ unsigned char* DataManager::ScriptReaderEx(const char* script_name, int* slen) { ...@@ -414,7 +413,7 @@ unsigned char* DataManager::ScriptReaderEx(const char* script_name, int* slen) {
} }
unsigned char* DataManager::ScriptReaderExSingle(const char* path, const char* script_name, int* slen, int pre_len, unsigned int use_irr) { unsigned char* DataManager::ScriptReaderExSingle(const char* path, const char* script_name, int* slen, int pre_len, unsigned int use_irr) {
char sname[256]; char sname[256];
snprintf(sname, sizeof sname, "%s%s", path, script_name + pre_len); //default script name: ./script/c%d.lua std::snprintf(sname, sizeof sname, "%s%s", path, script_name + pre_len); //default script name: ./script/c%d.lua
if (use_irr) { if (use_irr) {
return ReadScriptFromIrrFS(sname, slen); return ReadScriptFromIrrFS(sname, slen);
} }
...@@ -438,9 +437,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl ...@@ -438,9 +437,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
return scriptBuffer; return scriptBuffer;
} }
unsigned char* DataManager::ReadScriptFromFile(const char* script_name, int* slen) { unsigned char* DataManager::ReadScriptFromFile(const char* script_name, int* slen) {
wchar_t fname[256]{}; FILE* fp = std::fopen(script_name, "rb");
BufferIO::DecodeUTF8(script_name, fname);
FILE* fp = myfopen(fname, "rb");
if (!fp) if (!fp)
return nullptr; return nullptr;
size_t len = std::fread(scriptBuffer, 1, sizeof scriptBuffer, fp); size_t len = std::fread(scriptBuffer, 1, sizeof scriptBuffer, fp);
......
#include "deck_manager.h" #include "deck_manager.h"
#include "game.h"
#include "myfilesystem.h" #include "myfilesystem.h"
#include "network.h" #include "network.h"
#include "game.h"
#include "base64.h" #include "base64.h"
namespace ygo { namespace ygo {
...@@ -11,30 +11,27 @@ DeckManager deckManager; ...@@ -11,30 +11,27 @@ DeckManager deckManager;
void DeckManager::LoadLFListSingle(const char* path) { void DeckManager::LoadLFListSingle(const char* path) {
auto cur = _lfList.rend(); auto cur = _lfList.rend();
FILE* fp = fopen(path, "r"); FILE* fp = std::fopen(path, "r");
char linebuf[256]{}; char linebuf[256]{};
wchar_t strBuffer[256]{}; wchar_t strBuffer[256]{};
if(fp) { if(fp) {
while(fgets(linebuf, 256, fp)) { while(std::fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#') if(linebuf[0] == '#')
continue; continue;
if(linebuf[0] == '!') { if(linebuf[0] == '!') {
int sa = BufferIO::DecodeUTF8(&linebuf[1], strBuffer); auto len = std::strcspn(linebuf, "\r\n");
while(strBuffer[sa - 1] == L'\r' || strBuffer[sa - 1] == L'\n' ) linebuf[len] = 0;
sa--; BufferIO::DecodeUTF8(&linebuf[1], strBuffer);
strBuffer[sa] = 0;
LFList newlist; LFList newlist;
newlist.listName = strBuffer;
newlist.hash = 0x7dfcee6a;
_lfList.push_back(newlist); _lfList.push_back(newlist);
cur = _lfList.rbegin(); cur = _lfList.rbegin();
cur->listName = strBuffer;
cur->hash = 0x7dfcee6a;
continue; continue;
} }
if(linebuf[0] == 0)
continue;
int code = 0; int code = 0;
int count = -1; int count = -1;
if (sscanf(linebuf, "%d %d", &code, &count) != 2) if (std::sscanf(linebuf, "%d %d", &code, &count) != 2)
continue; continue;
if (code <= 0 || code > MAX_CARD_ID) if (code <= 0 || code > MAX_CARD_ID)
continue; continue;
...@@ -46,7 +43,7 @@ void DeckManager::LoadLFListSingle(const char* path) { ...@@ -46,7 +43,7 @@ void DeckManager::LoadLFListSingle(const char* path) {
cur->content[code] = count; cur->content[code] = count;
cur->hash = cur->hash ^ ((hcode << 18) | (hcode >> 14)) ^ ((hcode << (27 + count)) | (hcode >> (5 - count))); cur->hash = cur->hash ^ ((hcode << 18) | (hcode >> 14)) ^ ((hcode << (27 + count)) | (hcode >> (5 - count)));
} }
fclose(fp); std::fclose(fp);
} }
} }
void DeckManager::LoadLFList() { void DeckManager::LoadLFList() {
...@@ -273,16 +270,16 @@ void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory, ...@@ -273,16 +270,16 @@ void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory,
} }
} }
FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) { FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
FILE* fp = myfopen(file, mode); FILE* fp = mywfopen(file, mode);
return fp; return fp;
} }
IReadFile* DeckManager::OpenDeckReader(const wchar_t* file) { irr::io::IReadFile* DeckManager::OpenDeckReader(const wchar_t* file) {
#ifdef _WIN32 #ifdef _WIN32
IReadFile* reader = DataManager::FileSystem->createAndOpenFile(file); auto reader = DataManager::FileSystem->createAndOpenFile(file);
#else #else
char file2[256]; char file2[256];
BufferIO::EncodeUTF8(file, file2); BufferIO::EncodeUTF8(file, file2);
IReadFile* reader = DataManager::FileSystem->createAndOpenFile(file2); auto reader = DataManager::FileSystem->createAndOpenFile(file2);
#endif #endif
return reader; return reader;
} }
...@@ -326,16 +323,16 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) { ...@@ -326,16 +323,16 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
FILE* fp = OpenDeckFile(file, "w"); FILE* fp = OpenDeckFile(file, "w");
if(!fp) if(!fp)
return false; return false;
fprintf(fp, "#created by ...\n#main\n"); std::fprintf(fp, "#created by ...\n#main\n");
for(size_t i = 0; i < deck.main.size(); ++i) for(size_t i = 0; i < deck.main.size(); ++i)
fprintf(fp, "%d\n", deck.main[i]->first); std::fprintf(fp, "%d\n", deck.main[i]->first);
fprintf(fp, "#extra\n"); std::fprintf(fp, "#extra\n");
for(size_t i = 0; i < deck.extra.size(); ++i) for(size_t i = 0; i < deck.extra.size(); ++i)
fprintf(fp, "%d\n", deck.extra[i]->first); std::fprintf(fp, "%d\n", deck.extra[i]->first);
fprintf(fp, "!side\n"); std::fprintf(fp, "!side\n");
for(size_t i = 0; i < deck.side.size(); ++i) for(size_t i = 0; i < deck.side.size(); ++i)
fprintf(fp, "%d\n", deck.side[i]->first); std::fprintf(fp, "%d\n", deck.side[i]->first);
fclose(fp); std::fclose(fp);
return true; return true;
} }
bool DeckManager::DeleteDeck(const wchar_t* file) { bool DeckManager::DeleteDeck(const wchar_t* file) {
...@@ -419,26 +416,26 @@ bool DeckManager::SaveDeckBuffer(const int deckbuf[], const wchar_t* name) { ...@@ -419,26 +416,26 @@ bool DeckManager::SaveDeckBuffer(const int deckbuf[], const wchar_t* name) {
int it = 0; int it = 0;
const int mainc = deckbuf[it]; const int mainc = deckbuf[it];
++it; ++it;
fprintf(fp, "#created by ...\n#main\n"); std::fprintf(fp, "#created by ...\n#main\n");
for (int i = 0; i < mainc; ++i) { for (int i = 0; i < mainc; ++i) {
fprintf(fp, "%d\n", deckbuf[it]); std::fprintf(fp, "%d\n", deckbuf[it]);
++it; ++it;
} }
const int extrac = deckbuf[it]; const int extrac = deckbuf[it];
++it; ++it;
fprintf(fp, "#extra\n"); std::fprintf(fp, "#extra\n");
for (int i = 0; i < extrac; ++i) { for (int i = 0; i < extrac; ++i) {
fprintf(fp, "%d\n", deckbuf[it]); std::fprintf(fp, "%d\n", deckbuf[it]);
++it; ++it;
} }
const int sidec = deckbuf[it]; const int sidec = deckbuf[it];
++it; ++it;
fprintf(fp, "!side\n"); std::fprintf(fp, "!side\n");
for (int i = 0; i < sidec; ++i) { for (int i = 0; i < sidec; ++i) {
fprintf(fp, "%d\n", deckbuf[it]); std::fprintf(fp, "%d\n", deckbuf[it]);
++it; ++it;
} }
fclose(fp); std::fclose(fp);
return true; return true;
} }
} }
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text); void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text);
void GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck); void GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
FILE* OpenDeckFile(const wchar_t* file, const char* mode); FILE* OpenDeckFile(const wchar_t* file, const char* mode);
IReadFile* OpenDeckReader(const wchar_t* file); irr::io::IReadFile* OpenDeckReader(const wchar_t* file);
bool LoadCurrentDeck(const wchar_t* file, bool is_packlist = false); bool LoadCurrentDeck(const wchar_t* file, bool is_packlist = false);
bool LoadCurrentDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck); bool LoadCurrentDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
bool SaveDeck(Deck& deck, const wchar_t* file); bool SaveDeck(Deck& deck, const wchar_t* file);
......
This diff is collapsed.
...@@ -56,11 +56,11 @@ bool ImageManager::Initial() { ...@@ -56,11 +56,11 @@ bool ImageManager::Initial() {
tFieldTransparent[1] = driver->getTexture("textures/field-transparent3.png"); tFieldTransparent[1] = driver->getTexture("textures/field-transparent3.png");
char buff[100]; char buff[100];
for (int i = 0; i < 14; i++) { for (int i = 0; i < 14; i++) {
snprintf(buff, 100, "textures/pscale/rscale_%d.png", i); std::snprintf(buff, 100, "textures/pscale/rscale_%d.png", i);
tRScale[i] = driver->getTexture(buff); tRScale[i] = driver->getTexture(buff);
} }
for (int i = 0; i < 14; i++) { for (int i = 0; i < 14; i++) {
snprintf(buff, 100, "textures/pscale/lscale_%d.png", i); std::snprintf(buff, 100, "textures/pscale/lscale_%d.png", i);
tLScale[i] = driver->getTexture(buff); tLScale[i] = driver->getTexture(buff);
} }
tClock = driver->getTexture("textures/clock.png"); tClock = driver->getTexture("textures/clock.png");
...@@ -327,26 +327,26 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) { ...@@ -327,26 +327,26 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
auto tit = tMap[fit ? 1 : 0].find(code); auto tit = tMap[fit ? 1 : 0].find(code);
if(tit == tMap[fit ? 1 : 0].end()) { if(tit == tMap[fit ? 1 : 0].end()) {
char file[256]; char file[256];
snprintf(file, sizeof file, "expansions/pics/%d.png", code); std::snprintf(file, sizeof file, "expansions/pics/%d.png", code);
irr::video::ITexture* img = GetTextureFromFile(file, width, height); irr::video::ITexture* img = GetTextureFromFile(file, width, height);
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "expansions/pics/%d.jpg", code); std::snprintf(file, sizeof file, "expansions/pics/%d.jpg", code);
img = GetTextureFromFile(file, width, height); img = GetTextureFromFile(file, width, height);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/%d.png"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/%d.png"), code);
img = GetTextureFromFile(file, width, height); img = GetTextureFromFile(file, width, height);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/%d.jpg"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/%d.jpg"), code);
img = GetTextureFromFile(file, width, height); img = GetTextureFromFile(file, width, height);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/%d.png", code); std::snprintf(file, sizeof file, "pics/%d.png", code);
img = GetTextureFromFile(file, width, height); img = GetTextureFromFile(file, width, height);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/%d.jpg", code); std::snprintf(file, sizeof file, "pics/%d.jpg", code);
img = GetTextureFromFile(file, width, height); img = GetTextureFromFile(file, width, height);
} }
if(img == nullptr && !mainGame->gameConf.use_image_scale) { if(img == nullptr && !mainGame->gameConf.use_image_scale) {
...@@ -370,10 +370,10 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) { ...@@ -370,10 +370,10 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
} }
irr::video::ITexture* texture; irr::video::ITexture* texture;
char file[256]; char file[256];
snprintf(file, sizeof file, "expansions/pics/%d.jpg", code); std::snprintf(file, sizeof file, "expansions/pics/%d.jpg", code);
irr::video::IImage* srcimg = driver->createImageFromFile(file); irr::video::IImage* srcimg = driver->createImageFromFile(file);
if(srcimg == nullptr) { if(srcimg == nullptr) {
snprintf(file, sizeof file, "pics/%d.jpg", code); std::snprintf(file, sizeof file, "pics/%d.jpg", code);
srcimg = driver->createImageFromFile(file); srcimg = driver->createImageFromFile(file);
} }
if(srcimg == nullptr) { if(srcimg == nullptr) {
...@@ -399,49 +399,49 @@ int ImageManager::LoadThumbThread() { ...@@ -399,49 +399,49 @@ int ImageManager::LoadThumbThread() {
imageManager.tThumbLoadingCodes.pop(); imageManager.tThumbLoadingCodes.pop();
imageManager.tThumbLoadingMutex.unlock(); imageManager.tThumbLoadingMutex.unlock();
char file[256]; char file[256];
snprintf(file, sizeof file, "expansions/pics/thumbnail/%d.png", code); std::snprintf(file, sizeof file, "expansions/pics/thumbnail/%d.png", code);
irr::video::IImage* img = imageManager.driver->createImageFromFile(file); irr::video::IImage* img = imageManager.driver->createImageFromFile(file);
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "expansions/pics/thumbnail/%d.jpg", code); std::snprintf(file, sizeof file, "expansions/pics/thumbnail/%d.jpg", code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/thumbnail/%d.png"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/thumbnail/%d.png"), code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/thumbnail/%d.jpg"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/thumbnail/%d.jpg"), code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/thumbnail/%d.png", code); std::snprintf(file, sizeof file, "pics/thumbnail/%d.png", code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code); std::snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
if(img == nullptr && mainGame->gameConf.use_image_scale) { if(img == nullptr && mainGame->gameConf.use_image_scale) {
snprintf(file, sizeof file, "expansions/pics/%d.png", code); std::snprintf(file, sizeof file, "expansions/pics/%d.png", code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "expansions/pics/%d.jpg", code); std::snprintf(file, sizeof file, "expansions/pics/%d.jpg", code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/%d.png"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/%d.png"), code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/%d.jpg"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/%d.jpg"), code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/%d.png", code); std::snprintf(file, sizeof file, "pics/%d.png", code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/%d.jpg", code); std::snprintf(file, sizeof file, "pics/%d.jpg", code);
img = imageManager.driver->createImageFromFile(file); img = imageManager.driver->createImageFromFile(file);
} }
} }
...@@ -487,7 +487,7 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) { ...@@ -487,7 +487,7 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(lit != tThumbLoading.end()) { if(lit != tThumbLoading.end()) {
if(lit->second != nullptr) { if(lit->second != nullptr) {
char file[256]; char file[256];
snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code); std::snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code);
irr::video::ITexture* texture = driver->addTexture(file, lit->second); // textures must be added in the main thread due to OpenGL irr::video::ITexture* texture = driver->addTexture(file, lit->second); // textures must be added in the main thread due to OpenGL
lit->second->drop(); lit->second->drop();
tThumb[code] = texture; tThumb[code] = texture;
...@@ -517,26 +517,26 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) { ...@@ -517,26 +517,26 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
auto tit = tFields.find(code); auto tit = tFields.find(code);
if(tit == tFields.end()) { if(tit == tFields.end()) {
char file[256]; char file[256];
snprintf(file, sizeof file, "expansions/pics/field/%d.png", code); std::snprintf(file, sizeof file, "expansions/pics/field/%d.png", code);
irr::video::ITexture* img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); irr::video::ITexture* img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "expansions/pics/field/%d.jpg", code); std::snprintf(file, sizeof file, "expansions/pics/field/%d.jpg", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/field/%d.png"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/field/%d.png"), code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/field/%d.jpg"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/field/%d.jpg"), code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/field/%d.png", code); std::snprintf(file, sizeof file, "pics/field/%d.png", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/field/%d.jpg", code); std::snprintf(file, sizeof file, "pics/field/%d.jpg", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
if(img == nullptr) { if(img == nullptr) {
tFields[code] = nullptr; tFields[code] = nullptr;
...@@ -561,26 +561,26 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) { ...@@ -561,26 +561,26 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
auto tit = tFields.find(code); auto tit = tFields.find(code);
if(tit == tFields.end()) { if(tit == tFields.end()) {
char file[256]; char file[256];
snprintf(file, sizeof file, "expansions/pics/field/%d.png", code); std::snprintf(file, sizeof file, "expansions/pics/field/%d.png", code);
irr::video::ITexture* img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); irr::video::ITexture* img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "expansions/pics/field/%d.jpg", code); std::snprintf(file, sizeof file, "expansions/pics/field/%d.jpg", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/field/%d.png"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/field/%d.png"), code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/field/%d.jpg"), code); std::snprintf(file, sizeof file, mainGame->GetLocaleDir("pics/field/%d.jpg"), code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/field/%d.png", code); std::snprintf(file, sizeof file, "pics/field/%d.png", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
} }
if(img == nullptr) { if(img == nullptr) {
snprintf(file, sizeof file, "pics/field/%d.jpg", code); std::snprintf(file, sizeof file, "pics/field/%d.jpg", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale); img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
if(img == nullptr) { if(img == nullptr) {
tFields[code] = nullptr; tFields[code] = nullptr;
......
...@@ -382,9 +382,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -382,9 +382,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int flag = 0; int flag = 0;
flag += (mainGame->chkBotHand->isChecked() ? 0x1 : 0); flag += (mainGame->chkBotHand->isChecked() ? 0x1 : 0);
char arg2[8]; char arg2[8];
snprintf(arg2, sizeof arg2, "%d", flag); std::snprintf(arg2, sizeof arg2, "%d", flag);
char arg3[8]; char arg3[8];
snprintf(arg3, sizeof arg3, "%d", mainGame->gameConf.serverport); std::snprintf(arg3, sizeof arg3, "%d", mainGame->gameConf.serverport);
execl("./bot", "bot", arg1, arg2, arg3, nullptr); execl("./bot", "bot", arg1, arg2, arg3, nullptr);
exit(0); exit(0);
} else { } else {
...@@ -571,7 +571,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -571,7 +571,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
const wchar_t* name = mainGame->lstSinglePlayList->getListItem(sel); const wchar_t* name = mainGame->lstSinglePlayList->getListItem(sel);
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name); myswprintf(fname, L"./single/%ls", name);
FILE* fp = myfopen(fname, "rb"); FILE* fp = mywfopen(fname, "rb");
if(!fp) { if(!fp) {
mainGame->stSinglePlayInfo->setText(L""); mainGame->stSinglePlayInfo->setText(L"");
break; break;
...@@ -580,7 +580,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -580,7 +580,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t wlinebuf[1024]; wchar_t wlinebuf[1024];
std::wstring message = L""; std::wstring message = L"";
bool in_message = false; bool in_message = false;
while(fgets(linebuf, 1024, fp)) { while(std::fgets(linebuf, 1024, fp)) {
if(!std::strncmp(linebuf, "--[[message", 11)) { if(!std::strncmp(linebuf, "--[[message", 11)) {
size_t len = std::strlen(linebuf); size_t len = std::strlen(linebuf);
char* msgend = std::strrchr(linebuf, ']'); char* msgend = std::strrchr(linebuf, ']');
...@@ -603,7 +603,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -603,7 +603,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
message.append(wlinebuf); message.append(wlinebuf);
} }
} }
fclose(fp); std::fclose(fp);
mainGame->SetStaticText(mainGame->stSinglePlayInfo, 200, mainGame->guiFont, message.c_str()); mainGame->SetStaticText(mainGame->stSinglePlayInfo, 200, mainGame->guiFont, message.c_str());
break; break;
} }
......
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
if(fh == INVALID_HANDLE_VALUE) if(fh == INVALID_HANDLE_VALUE)
return; return;
do { do {
if(mywcsncasecmp(fdataw.cFileName, L".", 1) && mywcsncasecmp(fdataw.cFileName, L"..", 2)) if(std::wcscmp(fdataw.cFileName, L".") && std::wcscmp(fdataw.cFileName, L".."))
cb(fdataw.cFileName, (fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)); cb(fdataw.cFileName, (fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
} while(FindNextFileW(fh, &fdataw)); } while(FindNextFileW(fh, &fdataw));
FindClose(fh); FindClose(fh);
......
...@@ -23,8 +23,8 @@ void Replay::BeginRecord() { ...@@ -23,8 +23,8 @@ void Replay::BeginRecord() {
return; return;
#else #else
if(is_recording) if(is_recording)
fclose(fp); std::fclose(fp);
fp = fopen("./replay/_LastReplay.yrp", "wb"); fp = std::fopen("./replay/_LastReplay.yrp", "wb");
if(!fp) if(!fp)
return; return;
#endif #endif
...@@ -39,8 +39,8 @@ void Replay::WriteHeader(ReplayHeader& header) { ...@@ -39,8 +39,8 @@ void Replay::WriteHeader(ReplayHeader& header) {
DWORD size; DWORD size;
WriteFile(recording_fp, &header, sizeof(header), &size, nullptr); WriteFile(recording_fp, &header, sizeof(header), &size, nullptr);
#else #else
fwrite(&header, sizeof(header), 1, fp); std::fwrite(&header, sizeof(header), 1, fp);
fflush(fp); std::fflush(fp);
#endif #endif
} }
void Replay::WriteData(const void* data, size_t length, bool flush) { void Replay::WriteData(const void* data, size_t length, bool flush) {
...@@ -54,9 +54,9 @@ void Replay::WriteData(const void* data, size_t length, bool flush) { ...@@ -54,9 +54,9 @@ void Replay::WriteData(const void* data, size_t length, bool flush) {
DWORD size; DWORD size;
WriteFile(recording_fp, data, length, &size, nullptr); WriteFile(recording_fp, data, length, &size, nullptr);
#else #else
fwrite(data, length, 1, fp); std::fwrite(data, length, 1, fp);
if(flush) if(flush)
fflush(fp); std::fflush(fp);
#endif #endif
} }
void Replay::WriteInt32(int32_t data, bool flush) { void Replay::WriteInt32(int32_t data, bool flush) {
...@@ -67,7 +67,7 @@ void Replay::Flush() { ...@@ -67,7 +67,7 @@ void Replay::Flush() {
return; return;
#ifdef _WIN32 #ifdef _WIN32
#else #else
fflush(fp); std::fflush(fp);
#endif #endif
} }
void Replay::EndRecord() { void Replay::EndRecord() {
...@@ -76,7 +76,7 @@ void Replay::EndRecord() { ...@@ -76,7 +76,7 @@ void Replay::EndRecord() {
#ifdef _WIN32 #ifdef _WIN32
CloseHandle(recording_fp); CloseHandle(recording_fp);
#else #else
fclose(fp); std::fclose(fp);
#endif #endif
pheader.datasize = replay_size; pheader.datasize = replay_size;
pheader.flag |= REPLAY_COMPRESSED; pheader.flag |= REPLAY_COMPRESSED;
...@@ -94,19 +94,19 @@ void Replay::SaveReplay(const wchar_t* name) { ...@@ -94,19 +94,19 @@ void Replay::SaveReplay(const wchar_t* name) {
return; return;
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./replay/%ls.yrp", name); myswprintf(fname, L"./replay/%ls.yrp", name);
FILE* rfp = myfopen(fname, "wb"); FILE* rfp = mywfopen(fname, "wb");
if(!rfp) if(!rfp)
return; return;
fwrite(&pheader, sizeof pheader, 1, rfp); std::fwrite(&pheader, sizeof pheader, 1, rfp);
fwrite(comp_data, comp_size, 1, rfp); std::fwrite(comp_data, comp_size, 1, rfp);
fclose(rfp); std::fclose(rfp);
} }
bool Replay::OpenReplay(const wchar_t* name) { bool Replay::OpenReplay(const wchar_t* name) {
FILE* rfp = myfopen(name, "rb"); FILE* rfp = mywfopen(name, "rb");
if(!rfp) { if(!rfp) {
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./replay/%ls", name); myswprintf(fname, L"./replay/%ls", name);
rfp = myfopen(fname, "rb"); rfp = mywfopen(fname, "rb");
} }
if(!rfp) if(!rfp)
return false; return false;
...@@ -116,13 +116,13 @@ bool Replay::OpenReplay(const wchar_t* name) { ...@@ -116,13 +116,13 @@ bool Replay::OpenReplay(const wchar_t* name) {
is_replaying = false; is_replaying = false;
replay_size = 0; replay_size = 0;
comp_size = 0; comp_size = 0;
if(fread(&pheader, sizeof pheader, 1, rfp) < 1) { if(std::fread(&pheader, sizeof pheader, 1, rfp) < 1) {
fclose(rfp); std::fclose(rfp);
return false; return false;
} }
if(pheader.flag & REPLAY_COMPRESSED) { if(pheader.flag & REPLAY_COMPRESSED) {
comp_size = fread(comp_data, 1, MAX_COMP_SIZE, rfp); comp_size = std::fread(comp_data, 1, MAX_COMP_SIZE, rfp);
fclose(rfp); std::fclose(rfp);
if (pheader.datasize > MAX_REPLAY_SIZE) if (pheader.datasize > MAX_REPLAY_SIZE)
return false; return false;
replay_size = pheader.datasize; replay_size = pheader.datasize;
...@@ -133,8 +133,8 @@ bool Replay::OpenReplay(const wchar_t* name) { ...@@ -133,8 +133,8 @@ bool Replay::OpenReplay(const wchar_t* name) {
return false; return false;
} }
} else { } else {
replay_size = fread(replay_data, 1, MAX_REPLAY_SIZE, rfp); replay_size = std::fread(replay_data, 1, MAX_REPLAY_SIZE, rfp);
fclose(rfp); std::fclose(rfp);
comp_size = 0; comp_size = 0;
} }
is_replaying = true; is_replaying = true;
...@@ -143,12 +143,12 @@ bool Replay::OpenReplay(const wchar_t* name) { ...@@ -143,12 +143,12 @@ bool Replay::OpenReplay(const wchar_t* name) {
bool Replay::CheckReplay(const wchar_t* name) { bool Replay::CheckReplay(const wchar_t* name) {
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./replay/%ls", name); myswprintf(fname, L"./replay/%ls", name);
FILE* rfp = myfopen(fname, "rb"); FILE* rfp = mywfopen(fname, "rb");
if(!rfp) if(!rfp)
return false; return false;
ReplayHeader rheader; ReplayHeader rheader;
size_t count = fread(&rheader, sizeof rheader, 1, rfp); size_t count = std::fread(&rheader, sizeof rheader, 1, rfp);
fclose(rfp); std::fclose(rfp);
return count == 1 && rheader.id == 0x31707279 && rheader.version >= 0x12d0u && (rheader.version < 0x1353u || (rheader.flag & REPLAY_UNIFORM)); return count == 1 && rheader.id == 0x31707279 && rheader.version >= 0x12d0u && (rheader.version < 0x1353u || (rheader.flag & REPLAY_UNIFORM));
} }
bool Replay::DeleteReplay(const wchar_t* name) { bool Replay::DeleteReplay(const wchar_t* name) {
......
...@@ -176,7 +176,7 @@ void SoundManager::PlaySoundEffect(int sound) { ...@@ -176,7 +176,7 @@ void SoundManager::PlaySoundEffect(int sound) {
break; break;
} }
char soundPath[40]; char soundPath[40];
snprintf(soundPath, 40, "./sound/%s.wav", soundName); std::snprintf(soundPath, 40, "./sound/%s.wav", soundName);
#ifdef YGOPRO_USE_AUDIO #ifdef YGOPRO_USE_AUDIO
ma_engine_set_volume(&engineSound, mainGame->gameConf.sound_volume); ma_engine_set_volume(&engineSound, mainGame->gameConf.sound_volume);
auto res = ma_engine_play_sound(&engineSound, soundPath, nullptr); auto res = ma_engine_play_sound(&engineSound, soundPath, nullptr);
......
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