Commit ced996f4 authored by nanahira's avatar nanahira

Merge branch 'server' into fullview

parents 1151300c 4965a378
No preview for this file type
......@@ -132,7 +132,7 @@ void ClientField::Initial(int player, int deckc, int extrac) {
}
ClientCard* ClientField::GetCard(int controler, int location, int sequence, int sub_seq) {
std::vector<ClientCard*>* lst = 0;
bool is_xyz = (location & 0x80) != 0;
bool is_xyz = (location & LOCATION_OVERLAY) != 0;
location &= 0x7f;
switch(location) {
case LOCATION_DECK:
......
......@@ -579,7 +579,7 @@ void Game::DrawMisc() {
driver->draw2DImage(imageManager.tLPBar, Resize(986 - 290 * partialLP / maxLP, 12, 986, 28), recti(0, fgColorPos * 16, 16, (fgColorPos + 1) * 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);
else driver->draw2DImage(imageManager.tLPBar, Resize(986 - 290 * dInfo.lp[1] / maxLP, 12, 986, 28), recti(0, 0, 16, 16), 0, 0, true);
}
if(lpframe) {
dInfo.lp[lpplayer] -= lpd;
......
......@@ -2390,7 +2390,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
mainGame->WaitFrameSignal(5);
}
if (panel_confirm.size() && !auto_watch_mode) {
if (panel_confirm.size() && mainGame->dInfo.player_type != 7 && !auto_watch_mode) {
std::sort(panel_confirm.begin(), panel_confirm.end(), ClientCard::client_card_sort);
mainGame->gMutex.lock();
mainGame->dField.selectable_cards = panel_confirm;
......@@ -2775,7 +2775,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.RemoveCard(pc, pl, ps);
delete pcard;
} else {
if (!(pl & 0x80) && !(cl & 0x80)) {
if (!(pl & LOCATION_OVERLAY) && !(cl & LOCATION_OVERLAY)) {
ClientCard* pcard = mainGame->dField.GetCard(pc, pl, ps);
if (pcard->code != code && (code != 0 || cl == 0x40))
pcard->SetCode(code);
......@@ -2838,7 +2838,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->WaitFrameSignal(5);
}
}
} else if (!(pl & 0x80)) {
} else if (!(pl & LOCATION_OVERLAY)) {
ClientCard* pcard = mainGame->dField.GetCard(pc, pl, ps);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
......@@ -2858,7 +2858,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
olcard->overlayed.push_back(pcard);
mainGame->dField.overlay_cards.insert(pcard);
pcard->overlayTarget = olcard;
pcard->location = 0x80;
pcard->location = LOCATION_OVERLAY;
pcard->sequence = olcard->overlayed.size() - 1;
} else {
mainGame->gMutex.lock();
......@@ -2867,7 +2867,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.overlay_cards.insert(pcard);
mainGame->gMutex.unlock();
pcard->overlayTarget = olcard;
pcard->location = 0x80;
pcard->location = LOCATION_OVERLAY;
pcard->sequence = olcard->overlayed.size() - 1;
if (olcard->location & 0x0c) {
mainGame->gMutex.lock();
......@@ -2879,7 +2879,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->WaitFrameSignal(5);
}
}
} else if (!(cl & 0x80)) {
} else if (!(cl & LOCATION_OVERLAY)) {
ClientCard* olcard = mainGame->dField.GetCard(pc, pl & 0x7f, ps);
ClientCard* pcard = olcard->overlayed[pp];
if(mainGame->dInfo.isReplaySkiping) {
......@@ -2916,7 +2916,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
olcard1->overlayed.erase(olcard1->overlayed.begin() + pcard->sequence);
olcard2->overlayed.push_back(pcard);
pcard->sequence = olcard2->overlayed.size() - 1;
pcard->location = 0x80;
pcard->location = LOCATION_OVERLAY;
pcard->overlayTarget = olcard2;
for (size_t i = 0; i < olcard1->overlayed.size(); ++i) {
olcard1->overlayed[i]->sequence = i;
......@@ -2926,7 +2926,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
olcard1->overlayed.erase(olcard1->overlayed.begin() + pcard->sequence);
olcard2->overlayed.push_back(pcard);
pcard->sequence = olcard2->overlayed.size() - 1;
pcard->location = 0x80;
pcard->location = LOCATION_OVERLAY;
pcard->overlayTarget = olcard2;
for (size_t i = 0; i < olcard1->overlayed.size(); ++i) {
olcard1->overlayed[i]->sequence = i;
......@@ -3240,7 +3240,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf);
int ss = BufferIO::ReadInt8(pbuf);
if ((l & 0x80) > 0)
if ((l & LOCATION_OVERLAY) > 0)
pcards[i] = mainGame->dField.GetCard(c, l & 0x7f, s)->overlayed[ss];
else
pcards[i] = mainGame->dField.GetCard(c, l, s);
......@@ -4092,7 +4092,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
ccard->overlayed.push_back(xcard);
mainGame->dField.overlay_cards.insert(xcard);
xcard->overlayTarget = ccard;
xcard->location = 0x80;
xcard->location = LOCATION_OVERLAY;
xcard->sequence = ccard->overlayed.size() - 1;
xcard->owner = p;
xcard->controler = p;
......
......@@ -1683,6 +1683,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
myswprintf(formatBuffer, L"\n*%ls", dataManager.GetDesc(iter->first));
str.append(formatBuffer);
}
if(mainGame->dInfo.turn == 1) {
if(mplayer == 0 && mainGame->dInfo.isFirst || mplayer != 0 && !mainGame->dInfo.isFirst)
myswprintf(formatBuffer, L"\n*%ls", dataManager.GetSysString(100));
else
myswprintf(formatBuffer, L"\n*%ls", dataManager.GetSysString(101));
str.append(formatBuffer);
}
should_show_tip = true;
irr::core::dimension2d<unsigned int> dtip = mainGame->guiFont->getDimension(str.c_str()) + irr::core::dimension2d<unsigned int>(10, 10);
mainGame->stTip->setRelativePosition(recti(mousepos.X - 10 - dtip.Width, mousepos.Y + 10, mousepos.X - 10, mousepos.Y + 10 + dtip.Height));
......
......@@ -42,15 +42,15 @@ HostInfo game_info;
void Game::MainServerLoop() {
#ifdef SERVER_ZIP_SUPPORT
dataManager.FileSystem = new irr::io::CFileSystem();
#endif
#ifdef SERVER_PRO2_SUPPORT
dataManager.FileSystem->addFileArchive("data/script.zip");
#endif
initUtils();
deckManager.LoadLFList();
dataManager.LoadDB(L"cards.cdb");
LoadExpansions();
#ifdef SERVER_PRO2_SUPPORT
dataManager.FileSystem->addFileArchive("data/script.zip", true, false, EFAT_ZIP);
#endif
server_port = NetServer::StartServer(server_port);
NetServer::InitDuel();
printf("%u\n", server_port);
......@@ -229,7 +229,7 @@ bool Game::Initialize() {
SetWindowsIcon();
//main menu
wchar_t strbuf[256];
myswprintf(strbuf, L"KoishiPro %X.0%X.%X Paranoia", PRO_VERSION >> 12, (PRO_VERSION >> 4) & 0xff, PRO_VERSION & 0xf);
myswprintf(strbuf, L"KoishiPro %X.0%X.%X DaydreamCafe", PRO_VERSION >> 12, (PRO_VERSION >> 4) & 0xff, PRO_VERSION & 0xf);
wMainMenu = env->addWindow(rect<s32>(370, 200, 650, 415), false, strbuf);
wMainMenu->getCloseButton()->setVisible(false);
btnLanMode = env->addButton(rect<s32>(10, 30, 270, 60), wMainMenu, BUTTON_LAN_MODE, dataManager.GetSysString(1200));
......
......@@ -111,10 +111,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
case BUTTON_HOST_CONFIRM: {
bot_mode = false;
BufferIO::CopyWStr(mainGame->ebServerName->getText(), mainGame->gameConf.gamename, 20);
if(!NetServer::StartServer(mainGame->gameConf.serverport))
if(!NetServer::StartServer(mainGame->gameConf.serverport)) {
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402));
break;
}
if(!DuelClient::StartClient(0x7f000001, mainGame->gameConf.serverport)) {
NetServer::StopServer();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402));
break;
}
mainGame->btnHostConfirm->setEnabled(false);
......@@ -154,6 +159,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
case BUTTON_HP_READY: {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1406));
mainGame->gMutex.unlock();
break;
}
UpdateDeck();
......@@ -308,10 +317,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break;
bot_mode = true;
#ifdef _WIN32
if(!NetServer::StartServer(mainGame->gameConf.serverport))
if(!NetServer::StartServer(mainGame->gameConf.serverport)) {
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402));
break;
}
if(!DuelClient::StartClient(0x7f000001, mainGame->gameConf.serverport)) {
NetServer::StopServer();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402));
break;
}
STARTUPINFOW si;
......@@ -358,10 +372,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
execl("./bot", "bot", arg1, arg2, arg3, NULL);
exit(0);
} else {
if(!NetServer::StartServer(mainGame->gameConf.serverport))
if(!NetServer::StartServer(mainGame->gameConf.serverport)) {
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402));
break;
}
if(!DuelClient::StartClient(0x7f000001, mainGame->gameConf.serverport)) {
NetServer::StopServer();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402));
break;
}
}
......@@ -596,7 +615,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
mainGame->gMutex.lock();
static_cast<irr::gui::IGUICheckBox*>(caller)->setChecked(false);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1406));
mainGame->gMutex.unlock();
break;
}
UpdateDeck();
......
......@@ -20,6 +20,7 @@ namespace ygo {
#ifdef YGOPRO_SERVER_MODE
#define REPLAY_MODE_SAVE_IN_SERVER 0x1
#define REPLAY_MODE_WATCHER_NO_SEND 0x2
#define REPLAY_MODE_INCLUDE_CHAT 0x4
#endif // YGOPRO_SERVER_MODE
struct ReplayHeader {
......
......@@ -562,7 +562,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
/*int cp = pbuf[11];*/
pbuf += 16;
DuelClient::ClientAnalyze(offset, pbuf - offset);
if(cl && !(cl & 0x80) && (pl != cl || pc != cc))
if(cl && !(cl & LOCATION_OVERLAY) && (pl != cl || pc != cc))
ReplayRefreshSingle(cc, cl, cs);
else if(pl == cl && cl == LOCATION_DECK)
ReplayRefreshDeck(cc);
......
......@@ -38,6 +38,8 @@ void SingleDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
#ifdef YGOPRO_SERVER_MODE
if(cache_recorder)
NetServer::ReSendToPlayer(cache_recorder);
if(replay_recorder && replay_mode & REPLAY_MODE_INCLUDE_CHAT)
NetServer::ReSendToPlayer(replay_recorder);
#endif
}
void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
......@@ -1218,7 +1220,7 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
#ifdef YGOPRO_SERVER_MODE
NetServer::ReSendToPlayers(cache_recorder, replay_recorder);
#endif
if (cl != 0 && (cl & 0x80) == 0 && (cl != pl || pc != cc))
if (cl != 0 && (cl & LOCATION_OVERLAY) == 0 && (cl != pl || pc != cc))
RefreshSingle(cc, cl, cs);
break;
}
......
......@@ -452,7 +452,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
/*int cp = pbuf[11];*/
pbuf += 16;
DuelClient::ClientAnalyze(offset, pbuf - offset);
if(cl && !(cl & 0x80) && (pl != cl || pc != cc))
if(cl && !(cl & LOCATION_OVERLAY) && (pl != cl || pc != cc))
SinglePlayRefreshSingle(cc, cl, cs);
break;
}
......
......@@ -34,6 +34,8 @@ void TagDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
#ifdef YGOPRO_SERVER_MODE
if(cache_recorder)
NetServer::ReSendToPlayer(cache_recorder);
if(replay_recorder && replay_mode & REPLAY_MODE_INCLUDE_CHAT)
NetServer::ReSendToPlayer(replay_recorder);
#endif
}
void TagDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
......@@ -1198,7 +1200,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
#ifdef YGOPRO_SERVER_MODE
NetServer::ReSendToPlayers(cache_recorder, replay_recorder);
#endif
if (cl != 0 && (cl & 0x80) == 0 && (cl != pl || pc != cc))
if (cl != 0 && (cl & LOCATION_OVERLAY) == 0 && (cl != pl || pc != cc))
RefreshSingle(cc, cl, cs);
break;
}
......
This diff is collapsed.
Subproject commit f9cd0df0186dcf4ae75b37179e9c835f11061a16
Subproject commit 7c04707022bab65e5fb76f45637e7094476285bb
Subproject commit 861310196d509332bc25e20d12e492d48e4fa116
Subproject commit b1a22d4edbc3505340cb0bbb25dcb605ec9c5556
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