Commit 2961cbb1 authored by Chen Bill's avatar Chen Bill

move struct CardDataC to data_manager.h

parent 8b622643
#include "client_card.h" #include "client_card.h"
#include "client_field.h" #include "client_field.h"
#include "data_manager.h"
#include "game.h" #include "game.h"
namespace ygo { namespace ygo {
......
...@@ -2,35 +2,13 @@ ...@@ -2,35 +2,13 @@
#define CLIENT_CARD_H #define CLIENT_CARD_H
#include "config.h" #include "config.h"
#include "../ocgcore/card_data.h" #include "data_manager.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map> #include <map>
#include <unordered_map>
namespace ygo { namespace ygo {
using CardData = card_data;
struct CardDataC : card_data {
unsigned int ot{};
unsigned int category{};
bool is_setcodes(std::vector <uint32_t> values) const {
for (auto& value : values) {
if (is_setcode(value))
return true;
}
return false;
}
};
struct CardString {
std::wstring name;
std::wstring text;
std::wstring desc[16];
};
typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer;
typedef std::unordered_map<unsigned int, CardString>::const_iterator string_pointer;
class ClientCard { class ClientCard {
public: public:
irr::core::matrix4 mTransform; irr::core::matrix4 mTransform;
......
...@@ -7,7 +7,7 @@ namespace ygo { ...@@ -7,7 +7,7 @@ namespace ygo {
const wchar_t* DataManager::unknown_string = L"???"; const wchar_t* DataManager::unknown_string = L"???";
unsigned char DataManager::scriptBuffer[0x100000] = {}; unsigned char DataManager::scriptBuffer[0x100000] = {};
IFileSystem* DataManager::FileSystem = nullptr; irr::io::IFileSystem* DataManager::FileSystem = nullptr;
DataManager dataManager; DataManager dataManager;
DataManager::DataManager() : _datas(32768), _strings(32768) { DataManager::DataManager() : _datas(32768), _strings(32768) {
...@@ -119,7 +119,7 @@ bool DataManager::LoadStrings(const char* file) { ...@@ -119,7 +119,7 @@ bool DataManager::LoadStrings(const char* file) {
fclose(fp); fclose(fp);
return true; return true;
} }
bool DataManager::LoadStrings(IReadFile* reader) { bool DataManager::LoadStrings(irr::io::IReadFile* reader) {
char ch{}; char ch{};
std::string linebuf; std::string linebuf;
while (reader->read(&ch, 1)) { while (reader->read(&ch, 1)) {
......
#ifndef DATAMANAGER_H #ifndef DATAMANAGER_H
#define DATAMANAGER_H #define DATAMANAGER_H
#include "config.h"
#include <unordered_map> #include <unordered_map>
#include <vector>
#include <string>
#include <sqlite3.h> #include <sqlite3.h>
#include "client_card.h" #include "../ocgcore/card_data.h"
namespace irr {
namespace io {
class IReadFile;
class IFileSystem;
}
}
namespace ygo { namespace ygo {
constexpr int MAX_STRING_ID = 0x7ff; constexpr int MAX_STRING_ID = 0x7ff;
constexpr unsigned int MIN_CARD_ID = (unsigned int)(MAX_STRING_ID + 1) >> 4; constexpr unsigned int MIN_CARD_ID = (unsigned int)(MAX_STRING_ID + 1) >> 4;
using CardData = card_data;
struct CardDataC : card_data {
unsigned int ot{};
unsigned int category{};
bool is_setcodes(std::vector <uint32_t> values) const {
for (auto& value : values) {
if (is_setcode(value))
return true;
}
return false;
}
};
struct CardString {
std::wstring name;
std::wstring text;
std::wstring desc[16];
};
typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer;
typedef std::unordered_map<unsigned int, CardString>::const_iterator string_pointer;
class DataManager { class DataManager {
public: public:
...@@ -16,7 +45,7 @@ public: ...@@ -16,7 +45,7 @@ public:
bool ReadDB(sqlite3* pDB); bool ReadDB(sqlite3* pDB);
bool LoadDB(const wchar_t* wfile); bool LoadDB(const wchar_t* wfile);
bool LoadStrings(const char* file); bool LoadStrings(const char* file);
bool LoadStrings(IReadFile* reader); bool LoadStrings(irr::io::IReadFile* reader);
void ReadStringConfLine(const char* linebuf); void ReadStringConfLine(const char* linebuf);
bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = nullptr); bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = nullptr);
...@@ -60,7 +89,7 @@ public: ...@@ -60,7 +89,7 @@ public:
//read by fread //read by fread
static unsigned char* DefaultScriptReader(const char* script_name, int* slen); static unsigned char* DefaultScriptReader(const char* script_name, int* slen);
static IFileSystem* FileSystem; static irr::io::IFileSystem* FileSystem;
private: private:
std::unordered_map<unsigned int, CardDataC> _datas; std::unordered_map<unsigned int, CardDataC> _datas;
......
#include "deck_manager.h" #include "deck_manager.h"
#include "myfilesystem.h" #include "myfilesystem.h"
#include "data_manager.h"
#include "network.h" #include "network.h"
#include "game.h" #include "game.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define DECKMANAGER_H #define DECKMANAGER_H
#include "config.h" #include "config.h"
#include "client_card.h" #include "data_manager.h"
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <sstream> #include <sstream>
......
#ifndef SINGLE_DUEL_H #ifndef SINGLE_DUEL_H
#define SINGLE_DUEL_H #define SINGLE_DUEL_H
#include <set>
#include "network.h" #include "network.h"
#include "deck_manager.h" #include "deck_manager.h"
#include "replay.h" #include "replay.h"
......
#ifndef TAG_DUEL_H #ifndef TAG_DUEL_H
#define TAG_DUEL_H #define TAG_DUEL_H
#include <set>
#include "network.h" #include "network.h"
#include "deck_manager.h" #include "deck_manager.h"
#include "replay.h" #include "replay.h"
......
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