Commit 433f5c0a authored by salix5's avatar salix5

revert to fc4518b2

parent 334ba77e
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define CLIENT_CARD_H #define CLIENT_CARD_H
#include "config.h" #include "config.h"
#include "../ocgcore/card_data.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map> #include <map>
...@@ -9,20 +10,7 @@ ...@@ -9,20 +10,7 @@
namespace ygo { namespace ygo {
struct CardData { using CardData = card_data;
unsigned int code;
unsigned int alias;
unsigned long long setcode;
unsigned int type;
unsigned int level;
unsigned int attribute;
unsigned int race;
int attack;
int defense;
unsigned int lscale;
unsigned int rscale;
unsigned int link_marker;
};
struct CardDataC { struct CardDataC {
unsigned int code; unsigned int code;
unsigned int alias; unsigned int alias;
......
...@@ -13,13 +13,13 @@ class ClientCard; ...@@ -13,13 +13,13 @@ class ClientCard;
struct ChainInfo { struct ChainInfo {
irr::core::vector3df chain_pos; irr::core::vector3df chain_pos;
ClientCard* chain_card; ClientCard* chain_card{ nullptr };
int code; int code{ 0 };
int desc; int desc{ 0 };
int controler; int controler{ 0 };
int location; int location{ 0 };
int sequence; int sequence{ 0 };
bool solved; bool solved{ false };
std::set<ClientCard*> target; std::set<ClientCard*> target;
}; };
......
...@@ -147,12 +147,25 @@ bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt) { ...@@ -147,12 +147,25 @@ bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt) {
spmemvfs_env_fini(); spmemvfs_env_fini();
return false; return false;
} }
bool DataManager::GetData(int code, CardData* pData) { bool DataManager::GetData(unsigned int code, CardData* pData) {
auto cdit = _datas.find(code); auto cdit = _datas.find(code);
if(cdit == _datas.end()) if(cdit == _datas.end())
return false; return false;
if(pData) auto data = cdit->second;
*pData = *((CardData*)&cdit->second); if (pData) {
pData->code = data.code;
pData->alias = data.alias;
pData->setcode = data.setcode;
pData->type = data.type;
pData->level = data.level;
pData->attribute = data.attribute;
pData->race = data.race;
pData->attack = data.attack;
pData->defense = data.defense;
pData->lscale = data.lscale;
pData->rscale = data.rscale;
pData->link_marker = data.link_marker;
}
return true; return true;
} }
code_pointer DataManager::GetCodePointer(int code) { code_pointer DataManager::GetCodePointer(int code) {
...@@ -346,9 +359,9 @@ const wchar_t* DataManager::FormatLinkMarker(int link_marker) { ...@@ -346,9 +359,9 @@ const wchar_t* DataManager::FormatLinkMarker(int link_marker) {
BufferIO::CopyWStrRef(L"[\u2198]", p, 4); BufferIO::CopyWStrRef(L"[\u2198]", p, 4);
return lmBuffer; return lmBuffer;
} }
int DataManager::CardReader(int code, void* pData) { uint32 DataManager::CardReader(uint32 code, card_data* pData) {
if(!dataManager.GetData(code, (CardData*)pData)) if (!dataManager.GetData(code, pData))
memset(pData, 0, sizeof(CardData)); pData->clear();
return 0; return 0;
} }
byte* DataManager::ScriptReaderEx(const char* script_name, int* slen) { byte* DataManager::ScriptReaderEx(const char* script_name, int* slen) {
......
...@@ -11,13 +11,13 @@ namespace ygo { ...@@ -11,13 +11,13 @@ namespace ygo {
class DataManager { class DataManager {
public: public:
DataManager(): _datas(8192), _strings(8192) {} DataManager(): _datas(16384), _strings(16384) {}
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(IReadFile* reader);
void ReadStringConfLine(const char* linebuf); void ReadStringConfLine(const char* linebuf);
bool Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt = 0); bool Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt = 0);
bool GetData(int code, CardData* pData); bool GetData(unsigned int code, CardData* pData);
code_pointer GetCodePointer(int code); code_pointer GetCodePointer(int code);
bool GetString(int code, CardString* pStr); bool GetString(int code, CardString* pStr);
const wchar_t* GetName(int code); const wchar_t* GetName(int code);
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
static byte scriptBuffer[0x20000]; static byte scriptBuffer[0x20000];
static const wchar_t* unknown_string; static const wchar_t* unknown_string;
static int CardReader(int, void*); static uint32 CardReader(uint32, card_data*);
static byte* ScriptReaderEx(const char* script_name, int* slen); static byte* ScriptReaderEx(const char* script_name, int* slen);
static byte* ScriptReader(const char* script_name, int* slen); static byte* ScriptReader(const char* script_name, int* slen);
static IFileSystem* FileSystem; static IFileSystem* FileSystem;
......
...@@ -611,7 +611,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -611,7 +611,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
if(!mainGame->dInfo.isTag) { if(!mainGame->dInfo.isTag) {
if(selftype > 1) { if(selftype > 1) {
mainGame->dInfo.player_type = 7; mainGame->dInfo.player_type = NETPLAYER_TYPE_OBSERVER;
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1350)); mainGame->btnLeaveGame->setText(dataManager.GetSysString(1350));
mainGame->btnLeaveGame->setVisible(true); mainGame->btnLeaveGame->setVisible(true);
mainGame->btnSpectatorSwap->setVisible(true); mainGame->btnSpectatorSwap->setVisible(true);
......
...@@ -49,8 +49,9 @@ bool Game::Initialize() { ...@@ -49,8 +49,9 @@ bool Game::Initialize() {
is_building = false; is_building = false;
menuHandler.prev_operation = 0; menuHandler.prev_operation = 0;
menuHandler.prev_sel = -1; menuHandler.prev_sel = -1;
memset(&dInfo, 0, sizeof(DuelInfo)); for (auto i : chatTiming) {
memset(chatTiming, 0, sizeof(chatTiming)); i = 0;
}
deckManager.LoadLFList(); deckManager.LoadLFList();
driver = device->getVideoDriver(); driver = device->getVideoDriver();
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false); driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
...@@ -1541,8 +1542,7 @@ void Game::ShowCardInfo(int code, bool resize) { ...@@ -1541,8 +1542,7 @@ void Game::ShowCardInfo(int code, bool resize) {
return; return;
CardData cd; CardData cd;
wchar_t formatBuffer[256]; wchar_t formatBuffer[256];
if(!dataManager.GetData(code, &cd)) dataManager.GetData(code, &cd);
memset(&cd, 0, sizeof(CardData));
imgCard->setImage(imageManager.GetTexture(code, true)); imgCard->setImage(imageManager.GetTexture(code, true));
if(cd.alias != 0 && (cd.alias - code < CARD_ARTWORK_VERSIONS_OFFSET || code - cd.alias < CARD_ARTWORK_VERSIONS_OFFSET)) if(cd.alias != 0 && (cd.alias - code < CARD_ARTWORK_VERSIONS_OFFSET || code - cd.alias < CARD_ARTWORK_VERSIONS_OFFSET))
myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias); myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias);
......
...@@ -66,31 +66,31 @@ struct Config { ...@@ -66,31 +66,31 @@ struct Config {
}; };
struct DuelInfo { struct DuelInfo {
bool isStarted; bool isStarted{ false };
bool isFinished; bool isFinished{ false };
bool isReplay; bool isReplay{ false };
bool isReplaySkiping; bool isReplaySkiping{ false };
bool isFirst; bool isFirst{ false };
bool isTag; bool isTag{ false };
bool isSingleMode; bool isSingleMode{ false };
bool is_shuffling; bool is_shuffling{ false };
bool tag_player[2]; bool tag_player[2]{ false };
int lp[2]; bool isReplaySwapped{ false };
int start_lp; int lp[2]{ 0 };
int duel_rule; int start_lp{ 0 };
int turn; int duel_rule{ 0 };
short curMsg; int turn{ 0 };
wchar_t hostname[20]; short curMsg{ 0 };
wchar_t clientname[20]; wchar_t hostname[20]{ 0 };
wchar_t hostname_tag[20]; wchar_t clientname[20]{ 0 };
wchar_t clientname_tag[20]; wchar_t hostname_tag[20]{ 0 };
wchar_t strLP[2][16]; wchar_t clientname_tag[20]{ 0 };
wchar_t* vic_string; wchar_t strLP[2][16]{ 0 };
unsigned char player_type; wchar_t* vic_string{ 0 };
unsigned char time_player; unsigned char player_type{ 0 };
unsigned short time_limit; unsigned char time_player{ 0 };
unsigned short time_left[2]; unsigned short time_limit{ 0 };
bool isReplaySwapped; unsigned short time_left[2]{ 0 };
}; };
struct BotInfo { struct BotInfo {
...@@ -593,8 +593,6 @@ extern Game* mainGame; ...@@ -593,8 +593,6 @@ extern Game* mainGame;
} }
#define SIZE_QUERY_BUFFER 0x4000
#define CARD_IMG_WIDTH 177 #define CARD_IMG_WIDTH 177
#define CARD_IMG_HEIGHT 254 #define CARD_IMG_HEIGHT 254
#define CARD_THUMB_WIDTH 44 #define CARD_THUMB_WIDTH 44
......
...@@ -62,9 +62,9 @@ int ReplayMode::ReplayThread() { ...@@ -62,9 +62,9 @@ int ReplayMode::ReplayThread() {
mainGame->dInfo.isSingleMode = !!(rh.flag & REPLAY_SINGLE_MODE); mainGame->dInfo.isSingleMode = !!(rh.flag & REPLAY_SINGLE_MODE);
mainGame->dInfo.tag_player[0] = false; mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false; mainGame->dInfo.tag_player[1] = false;
set_script_reader((script_reader)DataManager::ScriptReaderEx); set_script_reader(DataManager::ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader(DataManager::CardReader);
set_message_handler((message_handler)MessageHandler); set_message_handler(ReplayMode::MessageHandler);
if(!StartDuel()) { if(!StartDuel()) {
EndDuel(); EndDuel();
return 0; return 0;
...@@ -929,7 +929,7 @@ void ReplayMode::ReplayReload() { ...@@ -929,7 +929,7 @@ void ReplayMode::ReplayReload() {
ReloadLocation(0, LOCATION_REMOVED, flag, queryBuffer); ReloadLocation(0, LOCATION_REMOVED, flag, queryBuffer);
ReloadLocation(1, LOCATION_REMOVED, flag, queryBuffer); ReloadLocation(1, LOCATION_REMOVED, flag, queryBuffer);
} }
int ReplayMode::MessageHandler(intptr_t fduel, int type) { uint32 ReplayMode::MessageHandler(intptr_t fduel, uint32 type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
char msgbuf[1024]; char msgbuf[1024];
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void ReplayReload(); static void ReplayReload();
static int MessageHandler(intptr_t fduel, int type); static uint32 MessageHandler(intptr_t fduel, uint32 type);
}; };
} }
......
...@@ -428,9 +428,9 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -428,9 +428,9 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit; time_limit[1] = host_info.time_limit;
set_script_reader((script_reader)DataManager::ScriptReaderEx); set_script_reader(DataManager::ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader(DataManager::CardReader);
set_message_handler((message_handler)SingleDuel::MessageHandler); set_message_handler(SingleDuel::MessageHandler);
pduel = create_duel(duel_seed); 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, 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); set_player_info(pduel, 1, host_info.start_lp, host_info.start_hand, host_info.draw_count);
...@@ -1577,7 +1577,7 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag) ...@@ -1577,7 +1577,7 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
NetServer::ReSendToPlayer(*pit); NetServer::ReSendToPlayer(*pit);
} }
} }
int SingleDuel::MessageHandler(intptr_t fduel, int type) { uint32 SingleDuel::MessageHandler(intptr_t fduel, uint32 type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
char msgbuf[1024]; char msgbuf[1024];
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(intptr_t fduel, int type); static uint32 MessageHandler(intptr_t fduel, uint32 type);
static void SingleTimer(evutil_socket_t fd, short events, void* arg); static void SingleTimer(evutil_socket_t fd, short events, void* arg);
private: private:
......
...@@ -36,9 +36,9 @@ int SingleMode::SinglePlayThread() { ...@@ -36,9 +36,9 @@ int SingleMode::SinglePlayThread() {
std::random_device rd; std::random_device rd;
unsigned int seed = rd(); unsigned int seed = rd();
mt19937 rnd((uint_fast32_t)seed); mt19937 rnd((uint_fast32_t)seed);
set_script_reader((script_reader)DataManager::ScriptReaderEx); set_script_reader(DataManager::ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader(DataManager::CardReader);
set_message_handler((message_handler)MessageHandler); set_message_handler(SingleMode::MessageHandler);
pduel = create_duel(rnd.rand()); pduel = create_duel(rnd.rand());
set_player_info(pduel, 0, start_lp, start_hand, draw_count); set_player_info(pduel, 0, start_lp, start_hand, draw_count);
set_player_info(pduel, 1, start_lp, start_hand, draw_count); set_player_info(pduel, 1, start_lp, start_hand, draw_count);
...@@ -830,7 +830,7 @@ void SingleMode::SinglePlayReload() { ...@@ -830,7 +830,7 @@ void SingleMode::SinglePlayReload() {
ReloadLocation(0, LOCATION_REMOVED, flag, queryBuffer); ReloadLocation(0, LOCATION_REMOVED, flag, queryBuffer);
ReloadLocation(1, LOCATION_REMOVED, flag, queryBuffer); ReloadLocation(1, LOCATION_REMOVED, flag, queryBuffer);
} }
int SingleMode::MessageHandler(intptr_t fduel, int type) { uint32 SingleMode::MessageHandler(intptr_t fduel, uint32 type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
char msgbuf[1024]; char msgbuf[1024];
......
...@@ -30,7 +30,7 @@ public: ...@@ -30,7 +30,7 @@ public:
static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void SinglePlayReload(); static void SinglePlayReload();
static int MessageHandler(intptr_t fduel, int type); static uint32 MessageHandler(intptr_t fduel, uint32 type);
protected: protected:
static Replay last_replay; static Replay last_replay;
......
...@@ -397,9 +397,9 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -397,9 +397,9 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit; time_limit[1] = host_info.time_limit;
set_script_reader((script_reader)DataManager::ScriptReaderEx); set_script_reader(DataManager::ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader(DataManager::CardReader);
set_message_handler((message_handler)TagDuel::MessageHandler); set_message_handler(TagDuel::MessageHandler);
pduel = create_duel(duel_seed); 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, 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); set_player_info(pduel, 1, host_info.start_lp, host_info.start_hand, host_info.draw_count);
...@@ -1690,7 +1690,7 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) { ...@@ -1690,7 +1690,7 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
} }
} }
} }
int TagDuel::MessageHandler(intptr_t fduel, int type) { uint32 TagDuel::MessageHandler(intptr_t fduel, uint32 type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
char msgbuf[1024]; char msgbuf[1024];
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(intptr_t fduel, int type); static uint32 MessageHandler(intptr_t fduel, uint32 type);
static void TagTimer(evutil_socket_t fd, short events, void* arg); static void TagTimer(evutil_socket_t fd, short events, void* arg);
private: private:
......
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