Commit 414bc299 authored by argon.sun's avatar argon.sun

vs build

parent 078fd70d
...@@ -429,22 +429,23 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -429,22 +429,23 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
} }
case WM_IME_CHAR: { case WM_IME_CHAR: {
setlocale(LC_ALL, ""); /* setlocale(LC_ALL, "");*/
event.EventType = irr::EET_KEY_INPUT_EVENT; event.EventType = irr::EET_KEY_INPUT_EVENT;
event.KeyInput.PressedDown = true; event.KeyInput.PressedDown = true;
dev = getDeviceFromHWnd(hWnd); dev = getDeviceFromHWnd(hWnd);
unsigned char mbc[3]; // unsigned char mbc[3];
wchar_t wc[2]; // wchar_t wc[2];
if(wParam > 255) { // if(wParam > 255) {
mbc[0] = wParam >> 8; // mbc[0] = wParam >> 8;
mbc[1] = wParam & 0xff; // mbc[1] = wParam & 0xff;
mbc[2] = 0; // mbc[2] = 0;
} else { // } else {
mbc[0] = wParam; // mbc[0] = wParam;
mbc[1] = mbc[2] = 0; // mbc[1] = mbc[2] = 0;
} // }
mbstowcs(wc, (char *)&mbc, MB_CUR_MAX ); // mbstowcs(wc, (char *)&mbc, MB_CUR_MAX );
event.KeyInput.Char = wc[0]; // event.KeyInput.Char = wc[0];
event.KeyInput.Char = wParam;
event.KeyInput.Key = irr::KEY_ACCEPT; event.KeyInput.Key = irr::KEY_ACCEPT;
event.KeyInput.Shift = 0; event.KeyInput.Shift = 0;
event.KeyInput.Control = 0; event.KeyInput.Control = 0;
......
...@@ -39,7 +39,7 @@ struct CardString { ...@@ -39,7 +39,7 @@ struct CardString {
}; };
typedef std::unordered_map<unsigned int, CardDataC>::iterator code_pointer; typedef std::unordered_map<unsigned int, CardDataC>::iterator code_pointer;
struct ClientCard { class ClientCard {
public: public:
irr::video::ITexture* curTexture; irr::video::ITexture* curTexture;
irr::core::matrix4 mTransform; irr::core::matrix4 mTransform;
......
...@@ -9,9 +9,14 @@ ...@@ -9,9 +9,14 @@
#include <WinSock2.h> #include <WinSock2.h>
#include <windows.h> #include <windows.h>
#define myswprintf swprintf
#ifdef _MSC_VER
#define myswprintf _swprintf
#else #else
#define myswprintf swprintf
#endif
#else //_WIN32
#include <errno.h> #include <errno.h>
#include <netinet/in.h> #include <netinet/in.h>
......
...@@ -10,6 +10,7 @@ namespace ygo { ...@@ -10,6 +10,7 @@ namespace ygo {
class DataManager { class DataManager {
public: public:
DataManager(): _datas(8192), _strings(8192) {}
bool LoadDates(const char* file); bool LoadDates(const char* file);
bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = 0); bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = 0);
bool GetData(int code, CardData* pData); bool GetData(int code, CardData* pData);
......
...@@ -8,21 +8,29 @@ ...@@ -8,21 +8,29 @@
namespace ygo { namespace ygo {
void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv) { void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv) {
float origin[4] = {1.0f, 1.0f, 1.0f, 1.0f}; if(!gameConf.use_d3d) {
glLineWidth(width); float origin[4] = {1.0f, 1.0f, 1.0f, 1.0f};
glLineStipple(1, linePattern); glLineWidth(width);
if(strip) glLineStipple(1, linePattern);
glEnable(GL_LINE_STIPPLE); if(strip)
glDisable(GL_TEXTURE_2D); glEnable(GL_LINE_STIPPLE);
glMaterialfv(GL_FRONT, GL_AMBIENT, cv); glDisable(GL_TEXTURE_2D);
glBegin(GL_LINE_LOOP); glMaterialfv(GL_FRONT, GL_AMBIENT, cv);
glVertex3fv((float*)&vec[0].Pos); glBegin(GL_LINE_LOOP);
glVertex3fv((float*)&vec[1].Pos); glVertex3fv((float*)&vec[0].Pos);
glVertex3fv((float*)&vec[3].Pos); glVertex3fv((float*)&vec[1].Pos);
glVertex3fv((float*)&vec[2].Pos); glVertex3fv((float*)&vec[3].Pos);
glEnd(); glVertex3fv((float*)&vec[2].Pos);
glMaterialfv(GL_FRONT, GL_AMBIENT, origin); glEnd();
glDisable(GL_LINE_STIPPLE); glMaterialfv(GL_FRONT, GL_AMBIENT, origin);
glDisable(GL_LINE_STIPPLE);
} else {
int indexlist[4] = {0, 1, 3, 2};
driver->draw3DLine(vec[0].Pos,vec[1].Pos);
driver->draw3DLine(vec[1].Pos,vec[3].Pos);
driver->draw3DLine(vec[3].Pos,vec[2].Pos);
driver->draw3DLine(vec[2].Pos,vec[0].Pos);
}
} }
void Game::DrawBackGround() { void Game::DrawBackGround() {
static int selFieldAlpha = 255; static int selFieldAlpha = 255;
...@@ -383,10 +391,13 @@ void Game::DrawMisc() { ...@@ -383,10 +391,13 @@ void Game::DrawMisc() {
numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(386, 321, 445, 341), 0xffffff00, true, false, 0); numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(386, 321, 445, 341), 0xffffff00, true, false, 0);
} }
for(int i = 0; i < 5; ++i) { for(int i = 0; i < 5; ++i) {
static unsigned int chatColor[10] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040};
if(chatTiming[i]) { if(chatTiming[i]) {
chatTiming[i]--; chatTiming[i]--;
int w = textFont->getDimension(chatMsg[i].c_str()).Width;
driver->draw2DRectangle(recti(305, 596 - 20 * i, 307 + w, 616 - 20 * i), 0xa0000000, 0xa0000000, 0xa0000000, 0xa0000000);
textFont->draw(chatMsg[i].c_str(), rect<s32>(305, 595 - 20 * i, 1020, 615 - 20 * i), 0xff000000, false, false); textFont->draw(chatMsg[i].c_str(), rect<s32>(305, 595 - 20 * i, 1020, 615 - 20 * i), 0xff000000, false, false);
textFont->draw(chatMsg[i].c_str(), rect<s32>(306, 596 - 20 * i, 1021, 616 - 20 * i), 0xffffffff, false, false); textFont->draw(chatMsg[i].c_str(), rect<s32>(306, 596 - 20 * i, 1021, 616 - 20 * i), chatColor[chatType[i]], false, false);
} }
} }
} }
...@@ -812,7 +823,7 @@ void Game::DrawDeckBd() { ...@@ -812,7 +823,7 @@ void Game::DrawDeckBd() {
myswprintf(textBuffer, L"%ls", dataManager.GetName(ptr->first)); myswprintf(textBuffer, L"%ls", dataManager.GetName(ptr->first));
textFont->draw(textBuffer, recti(859, 164 + i * 66, 955, 185 + i * 66), 0xff000000, false, false); textFont->draw(textBuffer, recti(859, 164 + i * 66, 955, 185 + i * 66), 0xff000000, false, false);
textFont->draw(textBuffer, recti(860, 165 + i * 66, 955, 185 + i * 66), 0xffffffff, false, false); textFont->draw(textBuffer, recti(860, 165 + i * 66, 955, 185 + i * 66), 0xffffffff, false, false);
myswprintf(textBuffer, L"%ls/%ls %d", dataManager.FormatAttribute(ptr->second.attribute), dataManager.FormatRace(ptr->second.race), ptr->second.level); myswprintf(textBuffer, L"%ls/%ls \x2605%d", dataManager.FormatAttribute(ptr->second.attribute), dataManager.FormatRace(ptr->second.race), ptr->second.level);
textFont->draw(textBuffer, recti(859, 186 + i * 66, 955, 207 + i * 66), 0xff000000, false, false); textFont->draw(textBuffer, recti(859, 186 + i * 66, 955, 207 + i * 66), 0xff000000, false, false);
textFont->draw(textBuffer, recti(860, 187 + i * 66, 955, 207 + i * 66), 0xffffffff, false, false); textFont->draw(textBuffer, recti(860, 187 + i * 66, 955, 207 + i * 66), 0xffffffff, false, false);
if(ptr->second.attack < 0 && ptr->second.defence < 0) if(ptr->second.attack < 0 && ptr->second.defence < 0)
......
...@@ -1284,7 +1284,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -1284,7 +1284,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
case MSG_CONFIRM_DECKTOP: { case MSG_CONFIRM_DECKTOP: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf); int count = BufferIO::ReadInt8(pbuf);
int code, c, l, s; int code;
ClientCard* pcard; ClientCard* pcard;
myswprintf(textBuffer, dataManager.GetSysString(207), count); myswprintf(textBuffer, dataManager.GetSysString(207), count);
mainGame->lstLog->addItem(textBuffer); mainGame->lstLog->addItem(textBuffer);
......
...@@ -1261,11 +1261,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1261,11 +1261,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
myswprintf(formatBuffer, L"\n%ls/%ls", mcard->atkstring, mcard->defstring); myswprintf(formatBuffer, L"\n%ls/%ls", mcard->atkstring, mcard->defstring);
str.append(formatBuffer); str.append(formatBuffer);
myswprintf(formatBuffer, L"\n%d %ls/%ls", (mcard->level ? mcard->level : mcard->rank), dataManager.FormatRace(mcard->race), dataManager.FormatAttribute(mcard->attribute)); myswprintf(formatBuffer, L"\n\x2605%d %ls/%ls", (mcard->level ? mcard->level : mcard->rank), dataManager.FormatRace(mcard->race), dataManager.FormatAttribute(mcard->attribute));
str.append(formatBuffer); str.append(formatBuffer);
if(mcard->counters.size()) { if(mcard->counters.size()) {
for(std::map<int, int>::iterator ctit = mcard->counters.begin(); ctit != mcard->counters.end(); ++ctit) { for(std::map<int, int>::iterator ctit = mcard->counters.begin(); ctit != mcard->counters.end(); ++ctit) {
myswprintf(formatBuffer, L"\n[%ls]%d", dataManager.GetCounterName(ctit->first), ctit->second); myswprintf(formatBuffer, L"\n[%ls]: %d", dataManager.GetCounterName(ctit->first), ctit->second);
str.append(formatBuffer); str.append(formatBuffer);
} }
} }
...@@ -1293,7 +1293,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1293,7 +1293,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
if(mcard->counters.size()) { if(mcard->counters.size()) {
for(std::map<int, int>::iterator ctit = mcard->counters.begin(); ctit != mcard->counters.end(); ++ctit) { for(std::map<int, int>::iterator ctit = mcard->counters.begin(); ctit != mcard->counters.end(); ++ctit) {
myswprintf(formatBuffer, L"\n[%ls]%d", dataManager.GetCounterName(ctit->first), ctit->second); myswprintf(formatBuffer, L"\n[%ls]: %d", dataManager.GetCounterName(ctit->first), ctit->second);
str.append(formatBuffer); str.append(formatBuffer);
} }
} }
...@@ -1337,7 +1337,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1337,7 +1337,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
} }
break; break;
} }
case irr::EMIE_MOUSE_WHEEL: { case irr::EMIE_MOUSE_WHEEL: {
break; break;
} }
......
...@@ -23,7 +23,10 @@ bool Game::Initialize() { ...@@ -23,7 +23,10 @@ bool Game::Initialize() {
LoadConfig(); LoadConfig();
irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters(); irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters();
params.AntiAlias = gameConf.antialias; params.AntiAlias = gameConf.antialias;
params.DriverType = irr::video::EDT_OPENGL; if(gameConf.use_d3d)
params.DriverType = irr::video::EDT_DIRECT3D9;
else
params.DriverType = irr::video::EDT_OPENGL;
params.WindowSize = irr::core::dimension2d<u32>(1024, 640); params.WindowSize = irr::core::dimension2d<u32>(1024, 640);
device = irr::createDeviceEx(params); device = irr::createDeviceEx(params);
if(!device) if(!device)
...@@ -39,6 +42,7 @@ bool Game::Initialize() { ...@@ -39,6 +42,7 @@ bool Game::Initialize() {
ignore_chain = false; ignore_chain = false;
is_building = false; is_building = false;
memset(&dInfo, 0, sizeof(DuelInfo)); memset(&dInfo, 0, sizeof(DuelInfo));
memset(chatTiming, 0, sizeof(chatTiming));
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);
...@@ -164,23 +168,23 @@ bool Game::Initialize() { ...@@ -164,23 +168,23 @@ bool Game::Initialize() {
//phase //phase
wPhase = env->addStaticText(L"", rect<s32>(475, 310, 850, 330)); wPhase = env->addStaticText(L"", rect<s32>(475, 310, 850, 330));
wPhase->setVisible(false); wPhase->setVisible(false);
btnDP = env->addButton(rect<s32>(0, 0, 50, 20), wPhase, -1, L"DP"); btnDP = env->addButton(rect<s32>(0, 0, 50, 20), wPhase, -1, L"\xff24\xff30");
btnDP->setEnabled(false); btnDP->setEnabled(false);
btnDP->setPressed(true); btnDP->setPressed(true);
btnDP->setVisible(false); btnDP->setVisible(false);
btnSP = env->addButton(rect<s32>(65, 0, 115, 20), wPhase, -1, L"SP"); btnSP = env->addButton(rect<s32>(65, 0, 115, 20), wPhase, -1, L"\xff33\xff30");
btnSP->setEnabled(false); btnSP->setEnabled(false);
btnSP->setPressed(true); btnSP->setPressed(true);
btnSP->setVisible(false); btnSP->setVisible(false);
btnM1 = env->addButton(rect<s32>(130, 0, 180, 20), wPhase, -1, L"M1"); btnM1 = env->addButton(rect<s32>(130, 0, 180, 20), wPhase, -1, L"\xff2d\xff11");
btnM1->setEnabled(false); btnM1->setEnabled(false);
btnM1->setPressed(true); btnM1->setPressed(true);
btnM1->setVisible(false); btnM1->setVisible(false);
btnBP = env->addButton(rect<s32>(195, 0, 245, 20), wPhase, BUTTON_BP, L"BP"); btnBP = env->addButton(rect<s32>(195, 0, 245, 20), wPhase, BUTTON_BP, L"\xff22\xff30");
btnBP->setVisible(false); btnBP->setVisible(false);
btnM2 = env->addButton(rect<s32>(260, 0, 310, 20), wPhase, BUTTON_M2, L"M2"); btnM2 = env->addButton(rect<s32>(260, 0, 310, 20), wPhase, BUTTON_M2, L"\xff2d\xff12");
btnM2->setVisible(false); btnM2->setVisible(false);
btnEP = env->addButton(rect<s32>(325, 0, 375, 20), wPhase, BUTTON_EP, L"EP"); btnEP = env->addButton(rect<s32>(325, 0, 375, 20), wPhase, BUTTON_EP, L"\xff25\xff30");
btnEP->setVisible(false); btnEP->setVisible(false);
//tab //tab
wInfos = env->addTabControl(rect<s32>(1, 275, 301, 639), 0, true); wInfos = env->addTabControl(rect<s32>(1, 275, 301, 639), 0, true);
...@@ -538,7 +542,7 @@ void Game::MainLoop() { ...@@ -538,7 +542,7 @@ void Game::MainLoop() {
usleep(500000); usleep(500000);
#endif #endif
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)
...@@ -663,6 +667,10 @@ void Game::LoadConfig() { ...@@ -663,6 +667,10 @@ void Game::LoadConfig() {
sscanf(linebuf, "%s = %s", strbuf, valbuf); sscanf(linebuf, "%s = %s", strbuf, valbuf);
if(!strcmp(strbuf, "antialias")) { if(!strcmp(strbuf, "antialias")) {
gameConf.antialias = atoi(valbuf); gameConf.antialias = atoi(valbuf);
} else if(!strcmp(strbuf, "use_d3d")) {
gameConf.use_d3d = atoi(valbuf);
} else if(!strcmp(strbuf, "errorlog")) {
enable_log = atoi(valbuf);
} else if(!strcmp(strbuf, "nickname")) { } else if(!strcmp(strbuf, "nickname")) {
BufferIO::DecodeUTF8(valbuf, wstr); BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.nickname, 20); BufferIO::CopyWStr(wstr, gameConf.nickname, 20);
...@@ -698,7 +706,9 @@ void Game::SaveConfig() { ...@@ -698,7 +706,9 @@ void Game::SaveConfig() {
FILE* fp = fopen("system.conf", "w"); FILE* fp = fopen("system.conf", "w");
fprintf(fp, "#config file\n#nickname & gamename should be less than 20 characters\n"); fprintf(fp, "#config file\n#nickname & gamename should be less than 20 characters\n");
char linebuf[256]; char linebuf[256];
fprintf(fp, "use_d3d = %d\n", gameConf.use_d3d ? 1 : 0);
fprintf(fp, "antialias = %d\n", gameConf.antialias); fprintf(fp, "antialias = %d\n", gameConf.antialias);
fprintf(fp, "errorlog = %d\n", enable_log ? 1 : 0);
BufferIO::CopyWStr(ebNickName->getText(), gameConf.nickname, 20); BufferIO::CopyWStr(ebNickName->getText(), gameConf.nickname, 20);
BufferIO::EncodeUTF8(gameConf.nickname, linebuf); BufferIO::EncodeUTF8(gameConf.nickname, linebuf);
fprintf(fp, "nickname = %s\n", linebuf); fprintf(fp, "nickname = %s\n", linebuf);
...@@ -757,9 +767,11 @@ void Game::AddChatMsg(wchar_t* msg, int player) { ...@@ -757,9 +767,11 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
for(int i = 4; i > 0; --i) { for(int i = 4; i > 0; --i) {
chatMsg[i] = chatMsg[i - 1]; chatMsg[i] = chatMsg[i - 1];
chatTiming[i] = chatTiming[i - 1]; chatTiming[i] = chatTiming[i - 1];
chatType[i] = chatType[i - 1];
} }
chatMsg[0].clear(); chatMsg[0].clear();
chatTiming[0] = 600; chatTiming[0] = 600;
chatType[0] = player;
switch(player) { switch(player) {
case 0: //from host case 0: //from host
chatMsg[0].append(dInfo.hostname); chatMsg[0].append(dInfo.hostname);
...@@ -770,6 +782,10 @@ void Game::AddChatMsg(wchar_t* msg, int player) { ...@@ -770,6 +782,10 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 8: //system custom message, no prefix. case 8: //system custom message, no prefix.
chatMsg[0].append(L"[System]: ");
break;
case 9: //error message
chatMsg[0].append(L"[Script error:] ");
break; break;
default: //from watcher or unknown default: //from watcher or unknown
chatMsg[0].append(L"[***]: "); chatMsg[0].append(L"[***]: ");
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
namespace ygo { namespace ygo {
struct Config { struct Config {
bool use_d3d;
unsigned short antialias; unsigned short antialias;
unsigned short serverport; unsigned short serverport;
unsigned char textfontsize; unsigned char textfontsize;
...@@ -100,6 +101,7 @@ public: ...@@ -100,6 +101,7 @@ public:
std::vector<int> logParam; std::vector<int> logParam;
std::wstring chatMsg[5]; std::wstring chatMsg[5];
int chatTiming[5]; int chatTiming[5];
int chatType[5];
unsigned short linePattern; unsigned short linePattern;
int waitFrame; int waitFrame;
int signalFrame; int signalFrame;
......
...@@ -20,15 +20,12 @@ int main(int argc, char* argv[]) { ...@@ -20,15 +20,12 @@ int main(int argc, char* argv[]) {
if(!ygo::mainGame->Initialize()) if(!ygo::mainGame->Initialize())
return 0; return 0;
if(argc >= 2) if(argc >= 2) {
if(!strcmp(argv[1], "-debug"))
enable_log = true;
/*command line args: /*command line args:
* -j: join host (host info from system.conf) * -j: join host (host info from system.conf)
* -d: deck edit * -d: deck edit
* -r: replay */ * -r: replay */
else if(!strcmp(argv[1], "-j") || !strcmp(argv[1], "-d") || !strcmp(argv[1], "-r")) { if(!strcmp(argv[1], "-j") || !strcmp(argv[1], "-d") || !strcmp(argv[1], "-r")) {
exit_on_return = true; exit_on_return = true;
irr::SEvent event; irr::SEvent event;
event.EventType = irr::EET_GUI_EVENT; event.EventType = irr::EET_GUI_EVENT;
...@@ -50,6 +47,7 @@ int main(int argc, char* argv[]) { ...@@ -50,6 +47,7 @@ int main(int argc, char* argv[]) {
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
} }
} }
}
ygo::mainGame->MainLoop(); ygo::mainGame->MainLoop();
#ifdef _WIN32 #ifdef _WIN32
WSACleanup(); WSACleanup();
......
...@@ -54,15 +54,11 @@ irr::video::ITexture* ImageManager::GetTexture(int code) { ...@@ -54,15 +54,11 @@ irr::video::ITexture* ImageManager::GetTexture(int code) {
auto tit = tMap.find(code); auto tit = tMap.find(code);
if(tit == tMap.end()) { if(tit == tMap.end()) {
char file[256]; char file[256];
sprintf(file, "pics/%d.jpg", code); //suggest that define the path in game.h sprintf(file, "pics/%d.jpg", code);
irr::video::ITexture* img = driver->getTexture(file); irr::video::ITexture* img = driver->getTexture(file);
if(img == NULL) {
sprintf(file, "pics/thumbnail/%d.jpg", code);
img = driver->getTexture(file);
}
if(img == NULL) { if(img == NULL) {
tMap[code] = NULL; tMap[code] = NULL;
return tUnknown; return GetTextureThumb(code);
} else { } else {
tMap[code] = img; tMap[code] = img;
return img; return img;
...@@ -71,20 +67,16 @@ irr::video::ITexture* ImageManager::GetTexture(int code) { ...@@ -71,20 +67,16 @@ irr::video::ITexture* ImageManager::GetTexture(int code) {
if(tit->second) if(tit->second)
return tit->second; return tit->second;
else else
return tUnknown; return GetTextureThumb(code);
} }
irr::video::ITexture* ImageManager::GetTextureThumb(int code) { irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(code == 0) if(code == 0)
return tUnknown; return tUnknown;
auto tit = tThumb.find(code); auto tit = tThumb.find(code);
if(tit == tThumb.end()) { if(tit == tThumb.end()) {
char file[32]; char file[256];
sprintf(file, "pics/thumbnail/%d.jpg", code); sprintf(file, "pics/thumbnail/%d.jpg", code);
irr::video::ITexture* img = driver->getTexture(file); irr::video::ITexture* img = driver->getTexture(file);
if(img == NULL) {
sprintf(file, "pics/%d.jpg", code);
img = driver->getTexture(file);
}
if(img == NULL) { if(img == NULL) {
tThumb[code] = NULL; tThumb[code] = NULL;
return tUnknown; return tUnknown;
......
...@@ -220,7 +220,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -220,7 +220,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
wchar_t infobuf[256]; wchar_t infobuf[256];
std::wstring repinfo; std::wstring repinfo;
tm* st = localtime((time_t*)(&ReplayMode::cur_replay.pheader.seed)); time_t curtime = ReplayMode::cur_replay.pheader.seed;
tm* st = localtime(&curtime);
myswprintf(infobuf, L"%d/%d/%d %02d:%02d:%02d\n", st->tm_year + 1900, st->tm_mon + 1, st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec); myswprintf(infobuf, L"%d/%d/%d %02d:%02d:%02d\n", st->tm_year + 1900, st->tm_mon + 1, st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec);
repinfo.append(infobuf); repinfo.append(infobuf);
myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", (wchar_t*)ReplayMode::cur_replay.replay_data, (wchar_t*)(&ReplayMode::cur_replay.replay_data[40])); myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", (wchar_t*)ReplayMode::cur_replay.replay_data, (wchar_t*)(&ReplayMode::cur_replay.replay_data[40]));
......
...@@ -52,6 +52,7 @@ bool NetServer::StartBroadcast() { ...@@ -52,6 +52,7 @@ bool NetServer::StartBroadcast() {
} }
broadcast_ev = event_new(net_evbase, udp, EV_READ | EV_PERSIST, BroadcastEvent, NULL); broadcast_ev = event_new(net_evbase, udp, EV_READ | EV_PERSIST, BroadcastEvent, NULL);
event_add(broadcast_ev, NULL); event_add(broadcast_ev, NULL);
return true;
} }
void NetServer::StopServer() { void NetServer::StopServer() {
if(!net_evbase) if(!net_evbase)
......
...@@ -58,7 +58,7 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -58,7 +58,7 @@ int ReplayMode::ReplayThread(void* param) {
cur_replay.ReadData(mainGame->dInfo.hostname, 40); cur_replay.ReadData(mainGame->dInfo.hostname, 40);
cur_replay.ReadData(mainGame->dInfo.clientname, 40); cur_replay.ReadData(mainGame->dInfo.clientname, 40);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
//set_message_handler((message_handler)DuelClient::MessageHandler); set_message_handler((message_handler)MessageHandler);
pduel = create_duel(rnd.rand()); pduel = create_duel(rnd.rand());
int start_lp = cur_replay.ReadInt32(); int start_lp = cur_replay.ReadInt32();
int start_hand = cur_replay.ReadInt32(); int start_hand = cur_replay.ReadInt32();
...@@ -119,7 +119,7 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -119,7 +119,7 @@ int ReplayMode::ReplayThread(void* param) {
} }
bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
char* offset, *pbufw, *pbuf = msg; char* offset, *pbufw, *pbuf = msg;
int player, count, type; int player, count;
bool pauseable; bool pauseable;
while (pbuf - msg < len) { while (pbuf - msg < len) {
if(is_closing) if(is_closing)
...@@ -605,5 +605,15 @@ void ReplayMode::ReplayRefreshSingle(int player, int location, int sequence, int ...@@ -605,5 +605,15 @@ void ReplayMode::ReplayRefreshSingle(int player, int location, int sequence, int
int len = query_card(pduel, player, location, sequence, flag, queryBuffer, 0); int len = query_card(pduel, player, location, sequence, flag, queryBuffer, 0);
mainGame->dField.UpdateCard(mainGame->LocalPlayer(player), location, sequence, (char*)queryBuffer); mainGame->dField.UpdateCard(mainGame->LocalPlayer(player), location, sequence, (char*)queryBuffer);
} }
int ReplayMode::MessageHandler(long fduel, int type) {
if(!enable_log)
return 0;
char msgbuf[1024];
wchar_t wbuf[1024];
get_log_message(fduel, (byte*)msgbuf);
BufferIO::DecodeUTF8(msgbuf, wbuf);
mainGame->AddChatMsg(wbuf, 9);
return 0;
}
} }
...@@ -35,6 +35,8 @@ public: ...@@ -35,6 +35,8 @@ public:
static void ReplayRefreshHand(int player, int flag = 0x181fff); static void ReplayRefreshHand(int player, int flag = 0x181fff);
static void ReplayRefreshGrave(int player, int flag = 0x181fff); static void ReplayRefreshGrave(int player, int flag = 0x181fff);
static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0x181fff); static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0x181fff);
static int MessageHandler(long fduel, int type);
}; };
} }
......
#include "single_duel.h" #include "single_duel.h"
#include "netserver.h" #include "netserver.h"
#include "game.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/card.h"
#include "../ocgcore/duel.h" #include "../ocgcore/duel.h"
...@@ -1430,13 +1431,10 @@ int SingleDuel::MessageHandler(long fduel, int type) { ...@@ -1430,13 +1431,10 @@ int SingleDuel::MessageHandler(long fduel, int type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
char msgbuf[1024]; char msgbuf[1024];
wchar_t wbuf[1024];
get_log_message(fduel, (byte*)msgbuf); get_log_message(fduel, (byte*)msgbuf);
FILE* fp = fopen("error.log", "at+"); BufferIO::DecodeUTF8(msgbuf, wbuf);
if(!fp) mainGame->AddChatMsg(wbuf, 9);
return 0;
msgbuf[1023] = 0;
fprintf(fp, "[Script error:] %s\n", msgbuf);
fclose(fp);
return 0; return 0;
} }
void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) { void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
......
...@@ -816,7 +816,7 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) { ...@@ -816,7 +816,7 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) {
pduel->release_script_group(); pduel->release_script_group();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
int32 interpreter::check_matching(card* pcard, int32 findex, uint32 extraargs) { int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
int32 result; int32 result;
if(!findex || lua_isnil(current_state, findex)) if(!findex || lua_isnil(current_state, findex))
return TRUE; return TRUE;
...@@ -844,7 +844,7 @@ int32 interpreter::check_matching(card* pcard, int32 findex, uint32 extraargs) { ...@@ -844,7 +844,7 @@ int32 interpreter::check_matching(card* pcard, int32 findex, uint32 extraargs) {
pduel->release_script_group(); pduel->release_script_group();
return result; return result;
} }
int32 interpreter::get_operation_value(card* pcard, int32 findex, uint32 extraargs) { int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraargs) {
int32 result; int32 result;
if(!findex || lua_isnil(current_state, findex)) if(!findex || lua_isnil(current_state, findex))
return 0; return 0;
......
...@@ -60,8 +60,8 @@ public: ...@@ -60,8 +60,8 @@ public:
int32 call_card_function(card *pcard, char *f, uint32 param_count, uint32 ret_count); int32 call_card_function(card *pcard, char *f, uint32 param_count, uint32 ret_count);
int32 call_code_function(uint32 code, char *f, uint32 param_count, uint32 ret_count); int32 call_code_function(uint32 code, char *f, uint32 param_count, uint32 ret_count);
int32 check_condition(int32 f, uint32 param_count); int32 check_condition(int32 f, uint32 param_count);
int32 check_matching(card* pcard, int32 findex, uint32 extraargs); int32 check_matching(card* pcard, int32 findex, int32 extraargs);
int32 get_operation_value(card* pcard, int32 findex, uint32 extraargs); int32 get_operation_value(card* pcard, int32 findex, int32 extraargs);
int32 get_function_value(int32 f, uint32 param_count); int32 get_function_value(int32 f, uint32 param_count);
int32 call_coroutine(int32 f, uint32 param_count, uint32* yield_value, uint16 step); int32 call_coroutine(int32 f, uint32 param_count, uint32* yield_value, uint16 step);
......
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
return y; return y;
} }
double real() { double real() {
return (double) rand() / -1UL; return (double) rand() / 0xffffffffUL;
} }
double res53() { double res53() {
unsigned int a = rand() >> 5, b = rand() >> 6; unsigned int a = rand() >> 5, b = rand() >> 6;
......
...@@ -417,7 +417,7 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin ...@@ -417,7 +417,7 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin
pduel->write_buffer8(MSG_SELECT_COUNTER); pduel->write_buffer8(MSG_SELECT_COUNTER);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
pduel->write_buffer16(countertype); pduel->write_buffer16(countertype);
pduel->write_buffer8(count); pduel->write_buffer8((uint8)count);
pduel->write_buffer8(core.select_cards.size()); pduel->write_buffer8(core.select_cards.size());
card* pcard; card* pcard;
std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort); std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort);
...@@ -510,7 +510,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 ...@@ -510,7 +510,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
return TRUE; return TRUE;
} else { } else {
uint8 m = core.select_cards.size(), v = 0; uint8 m = core.select_cards.size(), v = 0;
int32 op, o1, o2, sum = 0, mx = 0, mn; int32 op, o1, o2, sum = 0, mx = 0, mn = 0x7fffffff;
int16 ms[16]; int16 ms[16];
for(int32 i = 0; i < returns.bvalue[0]; ++i) { for(int32 i = 0; i < returns.bvalue[0]; ++i) {
v = returns.bvalue[i + 1]; v = returns.bvalue[i + 1];
......
...@@ -1824,7 +1824,13 @@ int32 field::process_quick_effect(int16 step, int32 special, uint8 priority) { ...@@ -1824,7 +1824,13 @@ int32 field::process_quick_effect(int16 step, int32 special, uint8 priority) {
case 1: { case 1: {
if(core.tpchain.size() == 0 && core.ntpchain.size() == 0) { if(core.tpchain.size() == 0 && core.ntpchain.size() == 0) {
chain newchain; chain newchain;
for(evit = core.point_event.begin(); evit != core.instant_event.end();) { evit = core.point_event.begin();
bool pev = true;
if(evit == core.point_event.end()) {
evit = core.instant_event.begin();
pev = false;
}
while(pev || (evit != core.instant_event.end())) {
pr = effects.activate_effect.equal_range(evit->event_code); pr = effects.activate_effect.equal_range(evit->event_code);
for(; pr.first != pr.second; ++pr.first) { for(; pr.first != pr.second; ++pr.first) {
peffect = pr.first->second; peffect = pr.first->second;
...@@ -1855,9 +1861,11 @@ int32 field::process_quick_effect(int16 step, int32 special, uint8 priority) { ...@@ -1855,9 +1861,11 @@ int32 field::process_quick_effect(int16 step, int32 special, uint8 priority) {
core.select_chains.push_back(newchain); core.select_chains.push_back(newchain);
} }
} }
++evit; evit++;
if(evit == core.point_event.end()) if(pev && evit == core.point_event.end()) {
evit = core.instant_event.begin(); evit = core.instant_event.begin();
pev = false;
}
} }
core.spe_effect[priority] = core.select_chains.size(); core.spe_effect[priority] = core.select_chains.size();
if(!special) { if(!special) {
......
...@@ -4,12 +4,12 @@ function c66947414.initial_effect(c) ...@@ -4,12 +4,12 @@ function c66947414.initial_effect(c)
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN) e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(c66947414.accon) e1:SetCondition(c66947414.condition)
c:RegisterEffect(e1) c:RegisterEffect(e1)
--cannot normal summon or set --cannot normal summon
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD) e2:SetType(EFFECT_TYPE_FIELD)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetRange(LOCATION_SZONE) e2:SetRange(LOCATION_SZONE)
e2:SetTargetRange(1,0) e2:SetTargetRange(1,0)
e2:SetCode(EFFECT_CANNOT_SUMMON) e2:SetCode(EFFECT_CANNOT_SUMMON)
...@@ -19,52 +19,36 @@ function c66947414.initial_effect(c) ...@@ -19,52 +19,36 @@ function c66947414.initial_effect(c)
c:RegisterEffect(e3) c:RegisterEffect(e3)
--special summon --special summon
local e4=Effect.CreateEffect(c) local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(66947414,0)) e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_PHASE+PHASE_END)
e4:SetRange(LOCATION_SZONE) e4:SetRange(LOCATION_SZONE)
e4:SetProperty(EFFECT_FLAG_REPEAT) e4:SetCode(EVENT_TO_GRAVE)
e4:SetCountLimit(1) e4:SetOperation(c66947414.checkop)
e4:SetCondition(c66947414.spcon) c:RegisterEffect(e4,0)
e4:SetTarget(c66947414.sptg) local e5=Effect.CreateEffect(c)
e4:SetOperation(c66947414.spop) e5:SetDescription(aux.Stringid(66947414,0))
c:RegisterEffect(e4) e5:SetCategory(CATEGORY_SPECIAL_SUMMON)
if not c66947414.global_check then e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
c66947414.global_check=true e5:SetCode(EVENT_PHASE+PHASE_END)
c66947414[0]=false e5:SetRange(LOCATION_SZONE)
c66947414[1]=false e5:SetCountLimit(1)
local ge1=Effect.CreateEffect(c) e5:SetCondition(c66947414.spcon)
ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e5:SetTarget(c66947414.sptg)
ge1:SetCode(EVENT_TO_GRAVE) e5:SetOperation(c66947414.spop)
ge1:SetOperation(c66947414.checkop) c:RegisterEffect(e5)
Duel.RegisterEffect(ge1,0)
local ge2=Effect.CreateEffect(c)
ge2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge2:SetCode(EVENT_PHASE_START+PHASE_DRAW)
ge2:SetOperation(c66947414.clear)
Duel.RegisterEffect(ge2,0)
end
end end
function c66947414.checkop(e,tp,eg,ep,ev,re,r,rp) function c66947414.condition(e,tp,eg,ep,ev,re,r,rp)
local tc=eg:GetFirst() return not Duel.CheckNormalSummonActivity(tp)
while tc do
if tc:IsSetCard(0x15) and tc:IsReason(REASON_DESTROY)
and tc:IsPreviousLocation(LOCATION_MZONE) and tc:IsPreviousPosition(POS_FACEUP) then
c66947414[tc:GetControler()]=true
end
tc=eg:GetNext()
end
end end
function c66947414.clear(e,tp,eg,ep,ev,re,r,rp) function c66947414.chkfilter(c,tp)
c66947414[0]=false return c:IsSetCard(0x15) and c:IsReason(REASON_DESTROY) and c:GetPreviousControler()==tp and c:IsPreviousLocation(LOCATION_MZONE)
c66947414[1]=false
end end
function c66947414.accon(e,tp,eg,ep,ev,re,r,rp) function c66947414.checkop(e,tp,eg,ep,ev,re,r,rp)
return not Duel.CheckNormalSummonActivity(tp) if eg:IsExists(c66947414.chkfilter,1,nil,tp) then
e:GetHandler():RegisterFlagEffect(66947414,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
end
end end
function c66947414.spcon(e,tp,eg,ep,ev,re,r,rp) function c66947414.spcon(e,tp,eg,ep,ev,re,r,rp)
return c66947414[tp] return e:GetHandler():GetFlagEffect(66947414)~=0
end end
function c66947414.filter(c,e,tp) function c66947414.filter(c,e,tp)
return c:IsSetCard(0x15) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) return c:IsSetCard(0x15) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
......
#config file #config file
#nickname & gamename should be less than 20 characters #nickname & gamename should be less than 20 characters
use_d3d = 0
antialias = 2 antialias = 2
errorlog = 1
nickname = Player nickname = Player
gamename = Game gamename = Game
lastdeck = test lastdeck = test
......
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