Commit 05b6c0a2 authored by mercury233's avatar mercury233

test

parent ae84948f
...@@ -12,7 +12,11 @@ bool DataManager::LoadDB(const char* file) { ...@@ -12,7 +12,11 @@ bool DataManager::LoadDB(const char* file) {
if(sqlite3_open_v2(file, &pDB, SQLITE_OPEN_READONLY, 0) != SQLITE_OK) if(sqlite3_open_v2(file, &pDB, SQLITE_OPEN_READONLY, 0) != SQLITE_OK)
return Error(pDB); return Error(pDB);
sqlite3_stmt* pStmt; sqlite3_stmt* pStmt;
#ifdef YGOPRO_SERVER_MODE
const char* sql = "select * from datas"; const char* sql = "select * from datas";
#else
const char* sql = "select * from datas,texts where datas.id=texts.id";
#endif //YGOPRO_SERVER_MODE
if(sqlite3_prepare_v2(pDB, sql, -1, &pStmt, 0) != SQLITE_OK) if(sqlite3_prepare_v2(pDB, sql, -1, &pStmt, 0) != SQLITE_OK)
return Error(pDB); return Error(pDB);
CardDataC cd; CardDataC cd;
...@@ -44,7 +48,7 @@ bool DataManager::LoadDB(const char* file) { ...@@ -44,7 +48,7 @@ bool DataManager::LoadDB(const char* file) {
cd.attribute = sqlite3_column_int(pStmt, 9); cd.attribute = sqlite3_column_int(pStmt, 9);
cd.category = sqlite3_column_int(pStmt, 10); cd.category = sqlite3_column_int(pStmt, 10);
_datas.insert(std::make_pair(cd.code, cd)); _datas.insert(std::make_pair(cd.code, cd));
/* #ifndef YGOPRO_SERVER_MODE
len = BufferIO::DecodeUTF8((const char*)sqlite3_column_text(pStmt, 12), strBuffer); len = BufferIO::DecodeUTF8((const char*)sqlite3_column_text(pStmt, 12), strBuffer);
if(len) { if(len) {
cs.name = new wchar_t[len + 1]; cs.name = new wchar_t[len + 1];
...@@ -66,7 +70,7 @@ bool DataManager::LoadDB(const char* file) { ...@@ -66,7 +70,7 @@ bool DataManager::LoadDB(const char* file) {
} else cs.desc[i - 14] = 0; } else cs.desc[i - 14] = 0;
} }
_strings.insert(std::make_pair(cd.code, cs)); _strings.insert(std::make_pair(cd.code, cs));
*/ #endif //YGOPRO_SERVER_MODE
} }
} while(step != SQLITE_DONE); } while(step != SQLITE_DONE);
sqlite3_finalize(pStmt); sqlite3_finalize(pStmt);
......
#include "config.h" #include "config.h"
#include "game.h" #include "game.h"
//#include "image_manager.h" #ifdef YGOPRO_SERVER_MODE
#include "data_manager.h" #include "data_manager.h"
#include "deck_manager.h" #include "deck_manager.h"
#include "replay.h" #include "replay.h"
//#include "materials.h"
//#include "duelclient.h"
#include "netserver.h" #include "netserver.h"
//#include "single_mode.h" #else
#include "image_manager.h"
#ifdef _WIN32 #include "data_manager.h"
#define strcasecmp _stricmp #include "deck_manager.h"
#include "dirent.h" #include "replay.h"
#endif // _WIN32 #include "materials.h"
#include "duelclient.h"
#include "netserver.h"
#include "single_mode.h"
#endif //YGOPRO_SERVER_MODE
#ifndef _WIN32 #ifndef _WIN32
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <dirent.h>
#include <unistd.h>
#endif #endif
const unsigned short PRO_VERSION = 0x233C; const unsigned short PRO_VERSION = 0x233C;
...@@ -42,23 +43,7 @@ unsigned char draw_count; ...@@ -42,23 +43,7 @@ unsigned char draw_count;
void Game::MainServerLoop(int bDuel_mode, int lflist) { void Game::MainServerLoop(int bDuel_mode, int lflist) {
deckManager.LoadLFList(); deckManager.LoadLFList();
//load expansions LoadExpansionDB()
DIR * dir;
struct dirent * dirp;
const char *foldername = "./expansions/";
if((dir = opendir(foldername)) != NULL) {
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0)
continue;
char *filepath = (char *)malloc(sizeof(char)*(len + strlen(foldername)));
strncpy(filepath, foldername, strlen(foldername)+1);
strncat(filepath, dirp->d_name, len);
dataManager.LoadDB(filepath);
free(filepath);
}
closedir(dir);
}
dataManager.LoadDB("cards.cdb"); dataManager.LoadDB("cards.cdb");
...@@ -74,7 +59,7 @@ void Game::MainServerLoop(int bDuel_mode, int lflist) { ...@@ -74,7 +59,7 @@ void Game::MainServerLoop(int bDuel_mode, int lflist) {
#endif #endif
} }
} }
/* #ifndef YGOPRO_SERVER_MODE
bool Game::Initialize() { bool Game::Initialize() {
srand(time(0)); srand(time(0));
LoadConfig(); LoadConfig();
...@@ -673,8 +658,8 @@ bool Game::Initialize() { ...@@ -673,8 +658,8 @@ bool Game::Initialize() {
hideChatTimer = 0; hideChatTimer = 0;
return true; return true;
} }
*/
/*
void Game::MainLoop() { void Game::MainLoop() {
wchar_t cap[256]; wchar_t cap[256];
camera = smgr->addCameraSceneNode(0); camera = smgr->addCameraSceneNode(0);
...@@ -764,8 +749,6 @@ void Game::MainLoop() { ...@@ -764,8 +749,6 @@ void Game::MainLoop() {
SaveConfig(); SaveConfig();
// device->drop(); // device->drop();
} }
*/
/*
void Game::BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar) { void Game::BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar) {
for(int i = 0; i < 16; ++i) for(int i = 0; i < 16; ++i)
mProjection[i] = 0; mProjection[i] = 0;
...@@ -821,6 +804,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu ...@@ -821,6 +804,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
dataManager.strBuffer[pbuffer] = 0; dataManager.strBuffer[pbuffer] = 0;
pControl->setText(dataManager.strBuffer); pControl->setText(dataManager.strBuffer);
} }
#endif //YGOPRO_SERVER_MODE
void Game::LoadExpansionDB() { void Game::LoadExpansionDB() {
#ifdef _WIN32 #ifdef _WIN32
char fpath[1000]; char fpath[1000];
...@@ -858,6 +842,7 @@ void Game::LoadExpansionDB() { ...@@ -858,6 +842,7 @@ void Game::LoadExpansionDB() {
} }
#endif #endif
} }
#ifndef YGOPRO_SERVER_MODE
void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) { void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) {
cbDeck->clear(); cbDeck->clear();
#ifdef _WIN32 #ifdef _WIN32
...@@ -1294,14 +1279,12 @@ void Game::CloseDuelWindow() { ...@@ -1294,14 +1279,12 @@ void Game::CloseDuelWindow() {
ClearTextures(); ClearTextures();
closeDoneSignal.Set(); closeDoneSignal.Set();
} }
*/
int Game::LocalPlayer(int player) { int Game::LocalPlayer(int player) {
return dInfo.isFirst ? player : 1 - player; return dInfo.isFirst ? player : 1 - player;
} }
const wchar_t* Game::LocalName(int local_player) { const wchar_t* Game::LocalName(int local_player) {
return local_player == 0 ? dInfo.hostname : dInfo.clientname; return local_player == 0 ? dInfo.hostname : dInfo.clientname;
} }
/*
void Game::SetWindowsIcon() { void Game::SetWindowsIcon() {
#ifdef _WIN32 #ifdef _WIN32
HINSTANCE hInstance = (HINSTANCE)GetModuleHandleW(NULL); HINSTANCE hInstance = (HINSTANCE)GetModuleHandleW(NULL);
...@@ -1322,6 +1305,6 @@ void Game::FlashWindow() { ...@@ -1322,6 +1305,6 @@ void Game::FlashWindow() {
FlashWindowEx(&fi); FlashWindowEx(&fi);
#endif #endif
} }
*/ #endif //YGOPRO_SERVER_MODE
} }
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
#define GAME_H #define GAME_H
#include "config.h" #include "config.h"
//#include "client_field.h" #ifndef YGOPRO_SERVER_MODE
//#include "deck_con.h" #include "client_field.h"
//#include "menu_handler.h" #include "deck_con.h"
#include "menu_handler.h"
#endif //YGOPRO_SERVER_MODE
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <list> #include <list>
...@@ -65,7 +67,7 @@ struct DuelInfo { ...@@ -65,7 +67,7 @@ struct DuelInfo {
unsigned short time_limit; unsigned short time_limit;
unsigned short time_left[2]; unsigned short time_left[2];
}; };
/* #ifndef YGOPRO_SERVER_MODE
struct FadingUnit { struct FadingUnit {
bool signalAction; bool signalAction;
bool isFadein; bool isFadein;
...@@ -77,14 +79,16 @@ struct FadingUnit { ...@@ -77,14 +79,16 @@ struct FadingUnit {
irr::core::vector2di fadingLR; irr::core::vector2di fadingLR;
irr::core::vector2di fadingDiff; irr::core::vector2di fadingDiff;
}; };
*/ #endif //YGOPRO_SERVER_MODE
class Game { class Game {
public: public:
bool Initialize(); bool Initialize();
//void MainLoop(); #ifdef YGOPRO_SERVER_MODE
void MainServerLoop(int bDuel_mode, int lflist); void MainServerLoop(int bDuel_mode, int lflist);
/* void LoadExpansionDB();
#else
void MainLoop();
void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar); void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar);
void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text); void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text);
void SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0); void SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0);
...@@ -116,19 +120,17 @@ public: ...@@ -116,19 +120,17 @@ public:
void AddDebugMsg(char* msgbuf); void AddDebugMsg(char* msgbuf);
void ClearTextures(); void ClearTextures();
void CloseDuelWindow(); void CloseDuelWindow();
*/
int LocalPlayer(int player); int LocalPlayer(int player);
const wchar_t* LocalName(int local_player); const wchar_t* LocalName(int local_player);
/*
bool HasFocus(EGUI_ELEMENT_TYPE type) const { bool HasFocus(EGUI_ELEMENT_TYPE type) const {
//irr::gui::IGUIElement* focus = env->getFocus(); irr::gui::IGUIElement* focus = env->getFocus();
return focus && focus->hasType(type); return focus && focus->hasType(type);
} }
void SetWindowsIcon(); void SetWindowsIcon();
void FlashWindow(); void FlashWindow();
*/
Mutex gMutex; Mutex gMutex;
Mutex gBuffer; Mutex gBuffer;
...@@ -138,10 +140,12 @@ public: ...@@ -138,10 +140,12 @@ public:
Signal singleSignal; Signal singleSignal;
Signal closeSignal; Signal closeSignal;
Signal closeDoneSignal; Signal closeDoneSignal;
#endif //YGOPRO_SERVER_MODE
Config gameConf; Config gameConf;
#ifndef YGOPRO_SERVER_MODE
DuelInfo dInfo; DuelInfo dInfo;
/*std::list<FadingUnit> fadingList; std::list<FadingUnit> fadingList;
std::vector<int> logParam; std::vector<int> logParam;
std::wstring chatMsg[8]; std::wstring chatMsg[8];
...@@ -174,8 +178,7 @@ public: ...@@ -174,8 +178,7 @@ public:
bool is_building; bool is_building;
bool is_siding; bool is_siding;
*/
/*
ClientField dField; ClientField dField;
DeckBuilder deckBuilder; DeckBuilder deckBuilder;
MenuHandler menuHandler; MenuHandler menuHandler;
...@@ -428,10 +431,11 @@ public: ...@@ -428,10 +431,11 @@ public:
irr::gui::IGUIButton* btnChainWhenAvail; irr::gui::IGUIButton* btnChainWhenAvail;
//cancel or finish //cancel or finish
irr::gui::IGUIButton* btnCancelOrFinish; irr::gui::IGUIButton* btnCancelOrFinish;
*/ #endif //YGOPRO_SERVER_MODE
}; };
extern Game* mainGame; extern Game* mainGame;
#ifdef YGOPRO_SERVER_MODE
extern unsigned short aServerPort; extern unsigned short aServerPort;
extern unsigned int lflist; extern unsigned int lflist;
extern unsigned char rule; extern unsigned char rule;
...@@ -444,6 +448,7 @@ extern unsigned short time_limit; ...@@ -444,6 +448,7 @@ extern unsigned short time_limit;
extern unsigned short replay_mode; extern unsigned short replay_mode;
extern unsigned char start_hand; extern unsigned char start_hand;
extern unsigned char draw_count; extern unsigned char draw_count;
#endif //YGOPRO_SERVER_MODE
} }
......
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