The server tree of https://code.moenext.com/nanahira/ygopro.git, branch server, commit 52c868ce071ea0f2fcb0cf39bf2fb4151d12b90c, stock: gframe/, premake5.lua, .ci/, LICENSE, and gframe/ygopro.rc + .ico (upstream keeps them in resource/ and copies them in before building). No game assets, no scripts, no ocgcore submodule: the core is ../core. The third-party sources upstream's Windows CI downloads are vendored here at the positions its premake expects, each with its premake fragment from upstream's premake/ folder inside it: lua 5.4.8, sqlite 3.53.3, libevent 2.1.13-stable (tests, samples and autotools helpers left out; the files its Windows prebuild copies into include/ left out), zlib 1.3.2 (contrib and examples left out), xz 5.8.3 (src/liblzma + src/common only), and irrlicht 1.9 from mycard at 20f86d25: include/ plus the source/Irrlicht headers and the 11 .cpp files the server's zip reader project compiles. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
136 lines
4.0 KiB
C++
136 lines
4.0 KiB
C++
#ifndef DECKMANAGER_H
|
|
#define DECKMANAGER_H
|
|
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <sstream>
|
|
#include <functional>
|
|
#include "deck.h"
|
|
#include "bufferio.h"
|
|
|
|
#ifndef YGOPRO_MAX_DECK
|
|
#define YGOPRO_MAX_DECK 60
|
|
#endif
|
|
|
|
#ifndef YGOPRO_MIN_DECK
|
|
#define YGOPRO_MIN_DECK 40
|
|
#endif
|
|
|
|
#ifndef YGOPRO_MAX_EXTRA
|
|
#define YGOPRO_MAX_EXTRA 15
|
|
#endif
|
|
|
|
#ifndef YGOPRO_MAX_SIDE
|
|
#define YGOPRO_MAX_SIDE 15
|
|
#endif
|
|
|
|
namespace irr {
|
|
namespace io {
|
|
class IReadFile;
|
|
}
|
|
}
|
|
|
|
namespace ygo {
|
|
|
|
constexpr int DECK_MAX_SIZE = YGOPRO_MAX_DECK;
|
|
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;
|
|
|
|
constexpr int MAINC_MAX = 250; // the limit of card_state
|
|
constexpr int SIDEC_MAX = MAINC_MAX;
|
|
|
|
constexpr int DECK_CATEGORY_PACK = 0;
|
|
constexpr int DECK_CATEGORY_BOT = 1;
|
|
constexpr int DECK_CATEGORY_NONE = 2;
|
|
constexpr int DECK_CATEGORY_SEPARATOR = 3;
|
|
constexpr int DECK_CATEGORY_CUSTOM = 4;
|
|
|
|
struct LFList {
|
|
unsigned int hash{};
|
|
std::wstring listName;
|
|
std::unordered_map<uint32_t, int> content;
|
|
std::unordered_map<std::wstring, uint32_t> credit_limits;
|
|
std::unordered_map<uint32_t, std::unordered_map<std::wstring, uint32_t>> credits;
|
|
};
|
|
|
|
class DeckManager {
|
|
public:
|
|
#ifndef YGOPRO_SERVER_MODE
|
|
Deck current_deck;
|
|
#endif
|
|
std::vector<LFList> _lfList;
|
|
|
|
#ifndef YGOPRO_SERVER_MODE
|
|
static constexpr int MAX_YDK_SIZE = 0x10000;
|
|
#endif
|
|
|
|
void LoadLFListSingle(const char* path, bool insert = false);
|
|
void LoadLFListSingle(const wchar_t* path, bool insert = false);
|
|
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
|
|
void LoadLFListSingle(irr::io::IReadFile* reader, bool insert = false);
|
|
#endif
|
|
void LoadLFList();
|
|
#ifndef YGOPRO_SERVER_MODE
|
|
const wchar_t* GetLFListName(unsigned int lfhash);
|
|
#endif
|
|
const LFList* GetLFList(unsigned int lfhash);
|
|
uint32_t CheckDeck(const Deck& deck, unsigned int lfhash, size_t rule);
|
|
#ifndef YGOPRO_SERVER_MODE
|
|
bool LoadCurrentDeck(const wchar_t* file, bool is_packlist = false);
|
|
bool LoadCurrentDeck(int category_index, const wchar_t* category_name, const wchar_t* deckname);
|
|
bool LoadCurrentDeck(std::istringstream& deckStream, bool is_packlist = false);
|
|
wchar_t DeckFormatBuffer[128];
|
|
int TypeCount(std::vector<const CardDataC*> list, unsigned int ctype);
|
|
bool LoadDeckFromCode(Deck& deck, const unsigned char *code, int len);
|
|
int SaveDeckToCode(Deck &deck, unsigned char *code);
|
|
#endif //YGOPRO_SERVER_MODE
|
|
|
|
static uint32_t LoadDeck(Deck& deck, uint32_t dbuf[], uint32_t mainc, uint32_t sidec, bool is_packlist = false);
|
|
static bool LoadSide(Deck& deck, uint32_t dbuf[], uint32_t mainc, uint32_t sidec);
|
|
#ifndef YGOPRO_SERVER_MODE
|
|
static uint32_t LoadDeckFromStream(Deck& deck, std::istringstream& deckStream, bool is_packlist = false);
|
|
static void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text);
|
|
static void GetDeckFile(wchar_t* ret, int category_index, const wchar_t* category_name, const wchar_t* deckname);
|
|
static FILE* OpenDeckFile(const wchar_t* file, const char* mode);
|
|
static irr::io::IReadFile* OpenDeckReader(const wchar_t* file);
|
|
static bool SaveDeck(const Deck& deck, const wchar_t* file);
|
|
static void SaveDeck(const Deck& deck, std::stringstream& deckStream);
|
|
static bool DeleteDeck(const wchar_t* file);
|
|
static bool CreateCategory(const wchar_t* name);
|
|
static bool RenameCategory(const wchar_t* oldname, const wchar_t* newname);
|
|
static bool DeleteCategory(const wchar_t* name);
|
|
static bool SaveDeckArray(const DeckArray& deck, const wchar_t* name);
|
|
#endif //YGOPRO_SERVER_MODE
|
|
|
|
private:
|
|
void LoadLFListFromLineProvider(const std::function<bool(char*, size_t)>& getLine, bool insert = false);
|
|
};
|
|
|
|
extern DeckManager deckManager;
|
|
|
|
}
|
|
|
|
#ifdef YGOPRO_SERVER_MODE
|
|
|
|
#ifndef DECKCOUNT_MAIN_MIN
|
|
#define DECKCOUNT_MAIN_MIN 40
|
|
#endif
|
|
|
|
#ifndef DECKCOUNT_MAIN_MAX
|
|
#define DECKCOUNT_MAIN_MAX 60
|
|
#endif
|
|
|
|
#ifndef DECKCOUNT_SIDE
|
|
#define DECKCOUNT_SIDE 15
|
|
#endif
|
|
|
|
#ifndef DECKCOUNT_EXTRA
|
|
#define DECKCOUNT_EXTRA 15
|
|
#endif
|
|
|
|
#endif //YGOPRO_SERVER_MODE
|
|
|
|
#endif //DECKMANAGER_H
|