Commit 05b6c0a2 authored by mercury233's avatar mercury233

test

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