Commit e1d52185 authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/Fluorohydride/ygopro

parents 0433b3a7 1cfa1a1c
......@@ -11,7 +11,6 @@ DataManager dataManager;
bool DataManager::LoadDB(const wchar_t* wfile) {
char file[256];
wchar_t strBuffer[4096];
BufferIO::EncodeUTF8(wfile, file);
#ifdef _WIN32
IReadFile* reader = FileSystem->createAndOpenFile(wfile);
......@@ -37,6 +36,7 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
return Error(&db);
CardDataC cd;
CardString cs;
wchar_t strBuffer[4096];
int step = 0;
do {
step = sqlite3_step(pStmt);
......
......@@ -118,6 +118,7 @@ void DeckBuilder::Terminate() {
mainGame->showingcode = 0;
mainGame->scrFilter->setVisible(false);
mainGame->scrPackCards->setVisible(false);
mainGame->scrPackCards->setPos(0);
int catesel = mainGame->cbDBCategory->getSelected();
if(catesel >= 0)
BufferIO::CopyWStr(mainGame->cbDBCategory->getItem(catesel), mainGame->gameConf.lastcategory, 64);
......@@ -1637,6 +1638,7 @@ void DeckBuilder::RefreshPackListScroll() {
}
} else {
mainGame->scrPackCards->setVisible(false);
mainGame->scrPackCards->setPos(0);
}
}
void DeckBuilder::ChangeCategory(int catesel) {
......
......@@ -517,12 +517,14 @@ void Game::DrawMisc() {
}
driver->draw2DImage(imageManager.tLPFrame, Resize(330, 10, 629, 30), recti(0, 0, 200, 20), 0, 0, true);
driver->draw2DImage(imageManager.tLPFrame, Resize(691, 10, 990, 30), recti(0, 0, 200, 20), 0, 0, true);
if(dInfo.lp[0] >= 8000)
driver->draw2DImage(imageManager.tLPBar, Resize(335, 12, 625, 28), recti(0, 0, 16, 16), 0, 0, true);
else driver->draw2DImage(imageManager.tLPBar, Resize(335, 12, 335 + 290 * dInfo.lp[0] / 8000, 28), recti(0, 0, 16, 16), 0, 0, true);
if(dInfo.lp[1] >= 8000)
driver->draw2DImage(imageManager.tLPBar, Resize(696, 12, 986, 28), recti(0, 0, 16, 16), 0, 0, true);
else driver->draw2DImage(imageManager.tLPBar, Resize(986 - 290 * dInfo.lp[1] / 8000, 12, 986, 28), recti(0, 0, 16, 16), 0, 0, true);
if(dInfo.start_lp) {
if(dInfo.lp[0] >= dInfo.start_lp)
driver->draw2DImage(imageManager.tLPBar, Resize(335, 12, 625, 28), recti(0, 0, 16, 16), 0, 0, true);
else driver->draw2DImage(imageManager.tLPBar, Resize(335, 12, 335 + 290 * dInfo.lp[0] / dInfo.start_lp, 28), recti(0, 0, 16, 16), 0, 0, true);
if(dInfo.lp[1] >= dInfo.start_lp)
driver->draw2DImage(imageManager.tLPBar, Resize(696, 12, 986, 28), recti(0, 0, 16, 16), 0, 0, true);
else driver->draw2DImage(imageManager.tLPBar, Resize(986 - 290 * dInfo.lp[1] / dInfo.start_lp, 12, 986, 28), recti(0, 0, 16, 16), 0, 0, true);
}
if(lpframe) {
dInfo.lp[lpplayer] -= lpd;
myswprintf(dInfo.strLP[lpplayer], L"%d", dInfo.lp[lpplayer]);
......@@ -685,10 +687,10 @@ void Game::DrawStatus(ClientCard* pcard, int x1, int y1, int x2, int y2) {
}
}
void Game::DrawGUI() {
if(imageLoading.size()) {
for(auto mit = imageLoading.begin(); mit != imageLoading.end(); ++mit)
mit->first->setImage(imageManager.GetTexture(mit->second));
imageLoading.clear();
while (imageLoading.size()) {
auto mit = imageLoading.cbegin();
mit->first->setImage(imageManager.GetTexture(mit->second));
imageLoading.erase(mit);
}
for(auto fit = fadingList.begin(); fit != fadingList.end();) {
auto fthis = fit++;
......
......@@ -495,6 +495,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->wChat->setVisible(true);
mainGame->gMutex.unlock();
mainGame->dInfo.duel_rule = pkt->info.duel_rule;
mainGame->dInfo.start_lp = pkt->info.start_lp;
watching = 0;
connect_state |= 0x4;
break;
......
......@@ -75,6 +75,7 @@ struct DuelInfo {
bool is_shuffling;
bool tag_player[2];
int lp[2];
int start_lp;
int duel_rule;
int turn;
short curMsg;
......
......@@ -141,7 +141,7 @@ public:
DuelPlayer* host_player;
HostInfo host_info;
int duel_stage;
unsigned long pduel;
intptr_t pduel;
wchar_t name[20];
wchar_t pass[20];
};
......
......@@ -7,7 +7,7 @@
namespace ygo {
long ReplayMode::pduel = 0;
intptr_t ReplayMode::pduel = 0;
Replay ReplayMode::cur_replay;
bool ReplayMode::is_continuing = true;
bool ReplayMode::is_closing = false;
......@@ -175,6 +175,7 @@ bool ReplayMode::StartDuel() {
set_player_info(pduel, 1, start_lp, start_hand, draw_count);
mainGame->dInfo.lp[0] = start_lp;
mainGame->dInfo.lp[1] = start_lp;
mainGame->dInfo.start_lp = start_lp;
myswprintf(mainGame->dInfo.strLP[0], L"%d", mainGame->dInfo.lp[0]);
myswprintf(mainGame->dInfo.strLP[1], L"%d", mainGame->dInfo.lp[1]);
mainGame->dInfo.turn = 0;
......@@ -943,7 +944,7 @@ void ReplayMode::ReplayReload() {
/*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
}
int ReplayMode::MessageHandler(long fduel, int type) {
int ReplayMode::MessageHandler(intptr_t fduel, int type) {
if(!enable_log)
return 0;
char msgbuf[1024];
......
......@@ -11,7 +11,7 @@ namespace ygo {
class ReplayMode {
private:
static long pduel;
static intptr_t pduel;
static bool is_continuing;
static bool is_closing;
static bool is_pausing;
......@@ -47,7 +47,7 @@ public:
static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void ReplayReload();
static int MessageHandler(long fduel, int type);
static int MessageHandler(intptr_t fduel, int type);
};
}
......
......@@ -484,6 +484,11 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
RefreshExtra(0);
RefreshExtra(1);
start_duel(pduel, opt);
if(host_info.time_limit) {
time_elapsed = 0;
timeval timeout = { 1, 0 };
event_add(etimer, &timeout);
}
Process();
}
void SingleDuel::Process() {
......@@ -1410,7 +1415,7 @@ void SingleDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {
if(time_limit[dp->type] >= time_elapsed)
time_limit[dp->type] -= time_elapsed;
else time_limit[dp->type] = 0;
event_del(etimer);
time_elapsed = 0;
}
Process();
}
......@@ -1427,6 +1432,7 @@ void SingleDuel::EndDuel() {
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
end_duel(pduel);
event_del(etimer);
pduel = 0;
}
void SingleDuel::WaitforResponse(int playerid) {
......@@ -1449,9 +1455,8 @@ void SingleDuel::TimeConfirm(DuelPlayer* dp) {
if(dp->type != last_response)
return;
players[last_response]->state = CTOS_RESPONSE;
time_elapsed = 0;
timeval timeout = {1, 0};
event_add(etimer, &timeout);
if(time_elapsed < 10)
time_elapsed = 0;
}
void SingleDuel::RefreshMzone(int player, int flag, int use_cache) {
char query_buffer[0x2000];
......@@ -1560,7 +1565,7 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
NetServer::ReSendToPlayer(*pit);
}
}
int SingleDuel::MessageHandler(long fduel, int type) {
int SingleDuel::MessageHandler(intptr_t fduel, int type) {
if(!enable_log)
return 0;
char msgbuf[1024];
......@@ -1571,7 +1576,7 @@ int SingleDuel::MessageHandler(long fduel, int type) {
void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
SingleDuel* sd = static_cast<SingleDuel*>(arg);
sd->time_elapsed++;
if(sd->time_elapsed >= sd->time_limit[sd->last_response]) {
if(sd->time_elapsed >= sd->time_limit[sd->last_response] || sd->time_limit[sd->last_response] <= 0) {
unsigned char wbuf[3];
uint32 player = sd->last_response;
wbuf[0] = MSG_WIN;
......@@ -1591,7 +1596,10 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
sd->EndDuel();
sd->DuelEndProc();
event_del(sd->etimer);
return;
}
timeval timeout = { 1, 0 };
event_add(sd->etimer, &timeout);
}
}
......@@ -38,7 +38,7 @@ public:
void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(long fduel, int type);
static int MessageHandler(intptr_t fduel, int type);
static void SingleTimer(evutil_socket_t fd, short events, void* arg);
protected:
......@@ -56,8 +56,8 @@ protected:
unsigned char duel_count;
unsigned char tp_player;
unsigned char match_result[3];
unsigned short time_limit[2];
unsigned short time_elapsed;
short time_limit[2];
short time_elapsed;
};
}
......
......@@ -6,7 +6,7 @@
namespace ygo {
long SingleMode::pduel = 0;
intptr_t SingleMode::pduel = 0;
bool SingleMode::is_closing = false;
bool SingleMode::is_continuing = false;
Replay SingleMode::last_replay;
......@@ -44,6 +44,7 @@ int SingleMode::SinglePlayThread() {
set_player_info(pduel, 1, start_lp, start_hand, draw_count);
mainGame->dInfo.lp[0] = start_lp;
mainGame->dInfo.lp[1] = start_lp;
mainGame->dInfo.start_lp = start_lp;
myswprintf(mainGame->dInfo.strLP[0], L"%d", mainGame->dInfo.lp[0]);
myswprintf(mainGame->dInfo.strLP[1], L"%d", mainGame->dInfo.lp[1]);
BufferIO::CopyWStr(mainGame->ebNickName->getText(), mainGame->dInfo.hostname, 20);
......@@ -843,7 +844,7 @@ void SingleMode::SinglePlayReload() {
/*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
}
int SingleMode::MessageHandler(long fduel, int type) {
int SingleMode::MessageHandler(intptr_t fduel, int type) {
if(!enable_log)
return 0;
char msgbuf[1024];
......
......@@ -7,7 +7,7 @@ namespace ygo {
class SingleMode {
private:
static long pduel;
static intptr_t pduel;
static bool is_closing;
static bool is_continuing;
......@@ -26,7 +26,7 @@ public:
static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void SinglePlayReload();
static int MessageHandler(long fduel, int type);
static int MessageHandler(intptr_t fduel, int type);
protected:
static Replay last_replay;
......
......@@ -480,6 +480,11 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
RefreshExtra(0);
RefreshExtra(1);
start_duel(pduel, opt);
if(host_info.time_limit) {
time_elapsed = 0;
timeval timeout = { 1, 0 };
event_add(etimer, &timeout);
}
Process();
}
void TagDuel::Process() {
......@@ -1491,7 +1496,7 @@ void TagDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {
if(time_limit[resp_type] >= time_elapsed)
time_limit[resp_type] -= time_elapsed;
else time_limit[resp_type] = 0;
event_del(etimer);
time_elapsed = 0;
}
Process();
}
......@@ -1510,6 +1515,7 @@ void TagDuel::EndDuel() {
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
end_duel(pduel);
event_del(etimer);
pduel = 0;
}
void TagDuel::WaitforResponse(int playerid) {
......@@ -1536,9 +1542,8 @@ void TagDuel::TimeConfirm(DuelPlayer* dp) {
if(dp != cur_player[last_response])
return;
cur_player[last_response]->state = CTOS_RESPONSE;
time_elapsed = 0;
timeval timeout = {1, 0};
event_add(etimer, &timeout);
if(time_elapsed < 10)
time_elapsed = 0;
}
void TagDuel::RefreshMzone(int player, int flag, int use_cache) {
char query_buffer[0x4000];
......@@ -1676,7 +1681,7 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
}
}
}
int TagDuel::MessageHandler(long fduel, int type) {
int TagDuel::MessageHandler(intptr_t fduel, int type) {
if(!enable_log)
return 0;
char msgbuf[1024];
......@@ -1687,7 +1692,7 @@ int TagDuel::MessageHandler(long fduel, int type) {
void TagDuel::TagTimer(evutil_socket_t fd, short events, void* arg) {
TagDuel* sd = static_cast<TagDuel*>(arg);
sd->time_elapsed++;
if(sd->time_elapsed >= sd->time_limit[sd->last_response]) {
if(sd->time_elapsed >= sd->time_limit[sd->last_response] || sd->time_limit[sd->last_response] <= 0) {
unsigned char wbuf[3];
uint32 player = sd->last_response;
wbuf[0] = MSG_WIN;
......@@ -1700,7 +1705,10 @@ void TagDuel::TagTimer(evutil_socket_t fd, short events, void* arg) {
sd->EndDuel();
sd->DuelEndProc();
event_del(sd->etimer);
return;
}
timeval timeout = { 1, 0 };
event_add(sd->etimer, &timeout);
}
}
......@@ -38,7 +38,7 @@ public:
void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(long fduel, int type);
static int MessageHandler(intptr_t fduel, int type);
static void TagTimer(evutil_socket_t fd, short events, void* arg);
protected:
......@@ -53,8 +53,8 @@ protected:
unsigned char last_response;
Replay last_replay;
unsigned char turn_count;
unsigned short time_limit[2];
unsigned short time_elapsed;
short time_limit[2];
short time_elapsed;
};
}
......
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