Commit a1621ee4 authored by argon.sun's avatar argon.sun

fix

parent 2b1b5e62
...@@ -2574,25 +2574,23 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -2574,25 +2574,23 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int ecount = BufferIO::ReadInt8(pbuf); int ecount = BufferIO::ReadInt8(pbuf);
int hcount = BufferIO::ReadInt8(pbuf); int hcount = BufferIO::ReadInt8(pbuf);
int topcode = BufferIO::ReadInt32(pbuf); int topcode = BufferIO::ReadInt32(pbuf);
for (int i = 0; i < mainGame->dField.deck[player].size(); ++i)
mainGame->dField.deck[player][i]->code = 0;
for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) { for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) {
if(player == 0) (*cit)->dPos.Y = 1.0f; if(player == 0) (*cit)->dPos.Y = 0.4f;
else (*cit)->dPos.Y = -1.0f; else (*cit)->dPos.Y = -0.4f;
(*cit)->dRot = irr::core::vector3df(0, 0, 0); (*cit)->dRot = irr::core::vector3df(0, 0, 0);
(*cit)->is_moving = true; (*cit)->is_moving = true;
(*cit)->aniFrame = 5; (*cit)->aniFrame = 5;
} }
for (auto cit = mainGame->dField.hand[player].begin(); cit != mainGame->dField.hand[player].end(); ++cit) { for (auto cit = mainGame->dField.hand[player].begin(); cit != mainGame->dField.hand[player].end(); ++cit) {
if(player == 0) (*cit)->dPos.Y = 1.0f; if(player == 0) (*cit)->dPos.Y = 0.4f;
else (*cit)->dPos.Y = -1.0f; else (*cit)->dPos.Y = -0.4f;
(*cit)->dRot = irr::core::vector3df(0, 0, 0); (*cit)->dRot = irr::core::vector3df(0, 0, 0);
(*cit)->is_moving = true; (*cit)->is_moving = true;
(*cit)->aniFrame = 5; (*cit)->aniFrame = 5;
} }
for (auto cit = mainGame->dField.extra[player].begin(); cit != mainGame->dField.extra[player].end(); ++cit) { for (auto cit = mainGame->dField.extra[player].begin(); cit != mainGame->dField.extra[player].end(); ++cit) {
if(player == 0) (*cit)->dPos.Y = 1.0f; if(player == 0) (*cit)->dPos.Y = 0.4f;
else (*cit)->dPos.Y = -1.0f; else (*cit)->dPos.Y = -0.4f;
(*cit)->dRot = irr::core::vector3df(0, 0, 0); (*cit)->dRot = irr::core::vector3df(0, 0, 0);
(*cit)->is_moving = true; (*cit)->is_moving = true;
(*cit)->aniFrame = 5; (*cit)->aniFrame = 5;
...@@ -2615,14 +2613,14 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -2615,14 +2613,14 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->dField.deck[player].push_back(ccard); mainGame->dField.deck[player].push_back(ccard);
} }
} }
if(mainGame->dField.hand[player].size() > mcount) { if(mainGame->dField.hand[player].size() > hcount) {
for(int i = 0; i < mainGame->dField.hand[player].size() - mcount; ++i) { for(int i = 0; i < mainGame->dField.hand[player].size() - hcount; ++i) {
ClientCard* ccard = *mainGame->dField.hand[player].rbegin(); ClientCard* ccard = *mainGame->dField.hand[player].rbegin();
mainGame->dField.hand[player].pop_back(); mainGame->dField.hand[player].pop_back();
delete ccard; delete ccard;
} }
} else { } else {
for(int i = 0; i < mcount - mainGame->dField.hand[player].size(); ++i) { for(int i = 0; i < hcount - mainGame->dField.hand[player].size(); ++i) {
ClientCard* ccard = new ClientCard(); ClientCard* ccard = new ClientCard();
ccard->controler = player; ccard->controler = player;
ccard->location = LOCATION_HAND; ccard->location = LOCATION_HAND;
...@@ -2630,14 +2628,14 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -2630,14 +2628,14 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->dField.hand[player].push_back(ccard); mainGame->dField.hand[player].push_back(ccard);
} }
} }
if(mainGame->dField.extra[player].size() > mcount) { if(mainGame->dField.extra[player].size() > ecount) {
for(int i = 0; i < mainGame->dField.extra[player].size() - mcount; ++i) { for(int i = 0; i < mainGame->dField.extra[player].size() - ecount; ++i) {
ClientCard* ccard = *mainGame->dField.extra[player].rbegin(); ClientCard* ccard = *mainGame->dField.extra[player].rbegin();
mainGame->dField.extra[player].pop_back(); mainGame->dField.extra[player].pop_back();
delete ccard; delete ccard;
} }
} else { } else {
for(int i = 0; i < mcount - mainGame->dField.extra[player].size(); ++i) { for(int i = 0; i < ecount - mainGame->dField.extra[player].size(); ++i) {
ClientCard* ccard = new ClientCard(); ClientCard* ccard = new ClientCard();
ccard->controler = player; ccard->controler = player;
ccard->location = LOCATION_EXTRA; ccard->location = LOCATION_EXTRA;
...@@ -2650,22 +2648,25 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -2650,22 +2648,25 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) { for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) {
ClientCard* pcard = *cit; ClientCard* pcard = *cit;
mainGame->dField.GetCardLocation(pcard, &pcard->curPos, &pcard->curRot); mainGame->dField.GetCardLocation(pcard, &pcard->curPos, &pcard->curRot);
if(player == 0) pcard->curPos.Y += 5.0f; if(player == 0) pcard->curPos.Y += 2.0f;
else pcard->curPos.Y -= 5.0f; else pcard->curPos.Y -= 2.0f;
mainGame->dField.MoveCard(*cit, 5); mainGame->dField.MoveCard(*cit, 5);
} }
if(mainGame->dField.deck[player].size())
(*mainGame->dField.deck[player].rbegin())->code = topcode;
for (auto cit = mainGame->dField.hand[player].begin(); cit != mainGame->dField.hand[player].end(); ++cit) { for (auto cit = mainGame->dField.hand[player].begin(); cit != mainGame->dField.hand[player].end(); ++cit) {
ClientCard* pcard = *cit; ClientCard* pcard = *cit;
pcard->code = BufferIO::ReadInt32(pbuf);
mainGame->dField.GetCardLocation(pcard, &pcard->curPos, &pcard->curRot); mainGame->dField.GetCardLocation(pcard, &pcard->curPos, &pcard->curRot);
if(player == 0) pcard->curPos.Y += 5.0f; if(player == 0) pcard->curPos.Y +=2.0f;
else pcard->curPos.Y -= 5.0f; else pcard->curPos.Y -= 2.0f;
mainGame->dField.MoveCard(*cit, 5); mainGame->dField.MoveCard(*cit, 5);
} }
for (auto cit = mainGame->dField.extra[player].begin(); cit != mainGame->dField.extra[player].end(); ++cit) { for (auto cit = mainGame->dField.extra[player].begin(); cit != mainGame->dField.extra[player].end(); ++cit) {
ClientCard* pcard = *cit; ClientCard* pcard = *cit;
mainGame->dField.GetCardLocation(pcard, &pcard->curPos, &pcard->curRot); mainGame->dField.GetCardLocation(pcard, &pcard->curPos, &pcard->curRot);
if(player == 0) pcard->curPos.Y += 5.0f; if(player == 0) pcard->curPos.Y += 2.0f;
else pcard->curPos.Y -= 5.0f; else pcard->curPos.Y -= 2.0f;
mainGame->dField.MoveCard(*cit, 5); mainGame->dField.MoveCard(*cit, 5);
} }
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
......
...@@ -596,7 +596,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -596,7 +596,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
break; break;
} }
case MSG_TAG_SWAP: { case MSG_TAG_SWAP: {
pbuf += pbuf[4] * 4 + 8; pbuf += pbuf[3] * 4 + 8;
DuelClient::ClientAnalyze(offset, pbuf - offset); DuelClient::ClientAnalyze(offset, pbuf - offset);
break; break;
} }
......
...@@ -380,15 +380,11 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -380,15 +380,11 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
if(!host_info.no_shuffle_deck) { if(!host_info.no_shuffle_deck) {
for(int i = 0; i < pdeck[0].main.size(); ++i) { for(int i = 0; i < pdeck[0].main.size(); ++i) {
int swap = rnd.real() * pdeck[0].main.size(); int swap = rnd.real() * pdeck[0].main.size();
auto tmp = pdeck[0].main[i]; std::swap(pdeck[0].main[i], pdeck[0].main[swap]);
pdeck[0].main[i] = pdeck[0].main[swap];
pdeck[0].main[swap] = tmp;
} }
for(int i = 0; i < pdeck[1].main.size(); ++i) { for(int i = 0; i < pdeck[1].main.size(); ++i) {
int swap = rnd.real() * pdeck[1].main.size(); int swap = rnd.real() * pdeck[1].main.size();
auto tmp = pdeck[1].main[i]; std::swap(pdeck[1].main[i], pdeck[1].main[swap]);
pdeck[1].main[i] = pdeck[1].main[swap];
pdeck[1].main[swap] = tmp;
} }
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
...@@ -1082,7 +1078,7 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -1082,7 +1078,7 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
pbuf += count * 4; pbuf += count * 4;
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset); NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
if(!(pbufw[i] & 0x80000000)) if(!(pbufw[3] & 0x80))
BufferIO::WriteInt32(pbufw, 0); BufferIO::WriteInt32(pbufw, 0);
else else
pbufw += 4; pbufw += 4;
......
...@@ -99,11 +99,11 @@ void TagDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) { ...@@ -99,11 +99,11 @@ void TagDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
if(players[i]) { if(players[i]) {
STOC_HS_PlayerEnter scpe; STOC_HS_PlayerEnter scpe;
BufferIO::CopyWStr(players[i]->name, scpe.name, 20); BufferIO::CopyWStr(players[i]->name, scpe.name, 20);
scpe.pos = 0; scpe.pos = i;
NetServer::SendPacketToPlayer(dp, STOC_HS_PLAYER_ENTER, scpe); NetServer::SendPacketToPlayer(dp, STOC_HS_PLAYER_ENTER, scpe);
if(ready[i]) { if(ready[i]) {
STOC_HS_PlayerChange scpc; STOC_HS_PlayerChange scpc;
scpc.status = PLAYERCHANGE_READY; scpc.status = (i << 4) | PLAYERCHANGE_READY;
NetServer::SendPacketToPlayer(dp, STOC_HS_PLAYER_CHANGE, scpc); NetServer::SendPacketToPlayer(dp, STOC_HS_PLAYER_CHANGE, scpc);
} }
} }
...@@ -182,7 +182,7 @@ void TagDuel::ToDuelist(DuelPlayer* dp) { ...@@ -182,7 +182,7 @@ void TagDuel::ToDuelist(DuelPlayer* dp) {
return; return;
uint8 dptype = (dp->type + 1) % 4; uint8 dptype = (dp->type + 1) % 4;
while(players[dptype]) while(players[dptype])
dptype = (dp->type + 1) % 4; dptype = (dptype + 1) % 4;
STOC_HS_PlayerChange scpc; STOC_HS_PlayerChange scpc;
scpc.status = (dp->type << 4) | dptype; scpc.status = (dp->type << 4) | dptype;
for(int i = 0; i < 4; ++i) for(int i = 0; i < 4; ++i)
...@@ -304,14 +304,12 @@ void TagDuel::HandResult(DuelPlayer* dp, unsigned char res) { ...@@ -304,14 +304,12 @@ void TagDuel::HandResult(DuelPlayer* dp, unsigned char res) {
|| (hand_result[0] == 2 && hand_result[1] == 3) || (hand_result[0] == 2 && hand_result[1] == 3)
|| (hand_result[0] == 3 && hand_result[1] == 1)) { || (hand_result[0] == 3 && hand_result[1] == 1)) {
NetServer::SendPacketToPlayer(players[2], CTOS_TP_RESULT); NetServer::SendPacketToPlayer(players[2], CTOS_TP_RESULT);
tp_player = 1;
players[0]->state = 0xff; players[0]->state = 0xff;
players[2]->state = CTOS_TP_RESULT; players[2]->state = CTOS_TP_RESULT;
} else { } else {
NetServer::SendPacketToPlayer(players[0], CTOS_TP_RESULT); NetServer::SendPacketToPlayer(players[0], CTOS_TP_RESULT);
players[2]->state = 0xff; players[2]->state = 0xff;
players[0]->state = CTOS_TP_RESULT; players[0]->state = CTOS_TP_RESULT;
tp_player = 0;
} }
} }
} }
...@@ -335,8 +333,8 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -335,8 +333,8 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
std::swap(pdeck[1], pdeck[3]); std::swap(pdeck[1], pdeck[3]);
swapped = true; swapped = true;
} }
tp_player = 0; turn_count = 0;
cur_player[0] = players[1]; cur_player[0] = players[0];
cur_player[1] = players[3]; cur_player[1] = players[3];
dp->state = CTOS_RESPONSE; dp->state = CTOS_RESPONSE;
ReplayHeader rh; ReplayHeader rh;
...@@ -353,15 +351,19 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -353,15 +351,19 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
if(!host_info.no_shuffle_deck) { if(!host_info.no_shuffle_deck) {
for(int i = 0; i < pdeck[0].main.size(); ++i) { for(int i = 0; i < pdeck[0].main.size(); ++i) {
int swap = rnd.real() * pdeck[0].main.size(); int swap = rnd.real() * pdeck[0].main.size();
auto tmp = pdeck[0].main[i]; std::swap(pdeck[0].main[i], pdeck[0].main[swap]);
pdeck[0].main[i] = pdeck[0].main[swap];
pdeck[0].main[swap] = tmp;
} }
for(int i = 0; i < pdeck[1].main.size(); ++i) { for(int i = 0; i < pdeck[1].main.size(); ++i) {
int swap = rnd.real() * pdeck[1].main.size(); int swap = rnd.real() * pdeck[1].main.size();
auto tmp = pdeck[1].main[i]; std::swap(pdeck[1].main[i], pdeck[1].main[swap]);
pdeck[1].main[i] = pdeck[1].main[swap]; }
pdeck[1].main[swap] = tmp; for(int i = 0; i < pdeck[2].main.size(); ++i) {
int swap = rnd.real() * pdeck[2].main.size();
std::swap(pdeck[2].main[i], pdeck[2].main[swap]);
}
for(int i = 0; i < pdeck[3].main.size(); ++i) {
int swap = rnd.real() * pdeck[3].main.size();
std::swap(pdeck[3].main[i], pdeck[3].main[swap]);
} }
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
...@@ -406,27 +408,27 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -406,27 +408,27 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay.WriteInt32(pdeck[1].extra[i]->first, false); last_replay.WriteInt32(pdeck[1].extra[i]->first, false);
} }
// //
last_replay.WriteInt32(pdeck[2].main.size(), false);
for(int i = pdeck[2].main.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[2].main[i]->first, 1, 1, LOCATION_DECK, 0, 0);
last_replay.WriteInt32(pdeck[2].main[i]->first, false);
}
last_replay.WriteInt32(pdeck[2].extra.size(), false);
for(int i = pdeck[2].extra.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[2].extra[i]->first, 1, 1, LOCATION_EXTRA, 0, 0);
last_replay.WriteInt32(pdeck[2].extra[i]->first, false);
}
//
last_replay.WriteInt32(pdeck[3].main.size(), false); last_replay.WriteInt32(pdeck[3].main.size(), false);
for(int i = pdeck[3].main.size() - 1; i >= 0; --i) { for(int i = pdeck[3].main.size() - 1; i >= 0; --i) {
new_tag_card(pduel, pdeck[3].main[i]->first, 0, LOCATION_DECK); new_card(pduel, pdeck[3].main[i]->first, 1, 1, LOCATION_DECK, 0, 0);
last_replay.WriteInt32(pdeck[3].main[i]->first, false); last_replay.WriteInt32(pdeck[3].main[i]->first, false);
} }
last_replay.WriteInt32(pdeck[3].extra.size(), false); last_replay.WriteInt32(pdeck[3].extra.size(), false);
for(int i = pdeck[3].extra.size() - 1; i >= 0; --i) { for(int i = pdeck[3].extra.size() - 1; i >= 0; --i) {
new_tag_card(pduel, pdeck[3].extra[i]->first, 0, LOCATION_EXTRA); new_card(pduel, pdeck[3].extra[i]->first, 1, 1, LOCATION_EXTRA, 0, 0);
last_replay.WriteInt32(pdeck[3].extra[i]->first, false); last_replay.WriteInt32(pdeck[3].extra[i]->first, false);
} }
//
last_replay.WriteInt32(pdeck[2].main.size(), false);
for(int i = pdeck[2].main.size() - 1; i >= 0; --i) {
new_tag_card(pduel, pdeck[2].main[i]->first, 1, LOCATION_DECK);
last_replay.WriteInt32(pdeck[2].main[i]->first, false);
}
last_replay.WriteInt32(pdeck[2].extra.size(), false);
for(int i = pdeck[2].extra.size() - 1; i >= 0; --i) {
new_tag_card(pduel, pdeck[2].extra[i]->first, 1, LOCATION_EXTRA);
last_replay.WriteInt32(pdeck[2].extra[i]->first, false);
}
last_replay.Flush(); last_replay.Flush();
char startbuf[32], *pbuf = startbuf; char startbuf[32], *pbuf = startbuf;
BufferIO::WriteInt8(pbuf, MSG_START); BufferIO::WriteInt8(pbuf, MSG_START);
...@@ -773,12 +775,6 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -773,12 +775,6 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
break; break;
} }
case MSG_NEW_TURN: { case MSG_NEW_TURN: {
RefreshMzone(0);
RefreshMzone(1);
RefreshSzone(0);
RefreshSzone(1);
RefreshHand(0);
RefreshHand(1);
pbuf++; pbuf++;
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit; time_limit[1] = host_info.time_limit;
...@@ -788,18 +784,26 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -788,18 +784,26 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::ReSendToPlayer(players[3]); NetServer::ReSendToPlayer(players[3]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit) for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
if(tp_player == 0) { if(turn_count > 0) {
if(cur_player[0] == players[0]) if(turn_count % 2 == 0) {
cur_player[0] = players[1]; if(cur_player[0] == players[0])
else cur_player[0] = players[1];
cur_player[0] = players[0]; else
} else { cur_player[0] = players[0];
if(cur_player[1] == players[2]) } else {
cur_player[1] = players[3]; if(cur_player[1] == players[2])
else cur_player[1] = players[3];
cur_player[1] = players[2]; else
cur_player[1] = players[2];
}
} }
tp_player = 1 - tp_player; turn_count++;
RefreshMzone(0);
RefreshMzone(1);
RefreshSzone(0);
RefreshSzone(1);
RefreshHand(0);
RefreshHand(1);
break; break;
} }
case MSG_NEW_PHASE: { case MSG_NEW_PHASE: {
...@@ -1092,7 +1096,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -1092,7 +1096,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
pbuf += count * 4; pbuf += count * 4;
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset); NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
if(!(pbufw[i] & 0x80000000)) if(!(pbufw[3] & 0x80))
BufferIO::WriteInt32(pbufw, 0); BufferIO::WriteInt32(pbufw, 0);
else else
pbufw += 4; pbufw += 4;
...@@ -1332,7 +1336,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -1332,7 +1336,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
pbuf += hcount * 4 + 4; pbuf += hcount * 4 + 4;
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset); NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
for (int i = 0; i < hcount; ++i) { for (int i = 0; i < hcount; ++i) {
if(!(pbufw[i] & 0x80000000)) if(!(pbufw[3] & 0x80))
BufferIO::WriteInt32(pbufw, 0); BufferIO::WriteInt32(pbufw, 0);
else else
pbufw += 4; pbufw += 4;
...@@ -1403,7 +1407,7 @@ void TagDuel::WaitforResponse(int playerid) { ...@@ -1403,7 +1407,7 @@ void TagDuel::WaitforResponse(int playerid) {
void TagDuel::TimeConfirm(DuelPlayer* dp) { void TagDuel::TimeConfirm(DuelPlayer* dp) {
if(host_info.time_limit == 0) if(host_info.time_limit == 0)
return; return;
if(dp->type != last_response) if(dp != cur_player[last_response])
return; return;
cur_player[last_response]->state = CTOS_RESPONSE; cur_player[last_response]->state = CTOS_RESPONSE;
time_elapsed = 0; time_elapsed = 0;
......
...@@ -51,7 +51,7 @@ protected: ...@@ -51,7 +51,7 @@ protected:
unsigned char hand_result[2]; unsigned char hand_result[2];
unsigned char last_response; unsigned char last_response;
Replay last_replay; Replay last_replay;
unsigned char tp_player; unsigned char turn_count;
unsigned short time_limit[2]; unsigned short time_limit[2];
unsigned short time_elapsed; unsigned short time_elapsed;
}; };
......
...@@ -552,9 +552,7 @@ void field::tag_swap(uint8 playerid) { ...@@ -552,9 +552,7 @@ void field::tag_swap(uint8 playerid) {
(*clit)->enable_field_effect(false); (*clit)->enable_field_effect(false);
(*clit)->cancel_field_effect(); (*clit)->cancel_field_effect();
} }
card_vector cl = player[playerid].list_grave; std::swap(player[playerid].list_main, player[playerid].tag_list_main);
player[playerid].list_main = player[playerid].tag_list_main;
player[playerid].list_main = cl;
for(clit = player[playerid].list_main.begin(); clit != player[playerid].list_main.end(); ++clit) { for(clit = player[playerid].list_main.begin(); clit != player[playerid].list_main.end(); ++clit) {
(*clit)->apply_field_effect(); (*clit)->apply_field_effect();
(*clit)->enable_field_effect(true); (*clit)->enable_field_effect(true);
...@@ -564,9 +562,7 @@ void field::tag_swap(uint8 playerid) { ...@@ -564,9 +562,7 @@ void field::tag_swap(uint8 playerid) {
(*clit)->enable_field_effect(false); (*clit)->enable_field_effect(false);
(*clit)->cancel_field_effect(); (*clit)->cancel_field_effect();
} }
cl = player[playerid].list_grave; std::swap(player[playerid].list_hand, player[playerid].tag_list_hand);
player[playerid].list_hand = player[playerid].tag_list_hand;
player[playerid].list_hand = cl;
for(clit = player[playerid].list_hand.begin(); clit != player[playerid].list_hand.end(); ++clit) { for(clit = player[playerid].list_hand.begin(); clit != player[playerid].list_hand.end(); ++clit) {
(*clit)->apply_field_effect(); (*clit)->apply_field_effect();
(*clit)->enable_field_effect(true); (*clit)->enable_field_effect(true);
...@@ -576,9 +572,7 @@ void field::tag_swap(uint8 playerid) { ...@@ -576,9 +572,7 @@ void field::tag_swap(uint8 playerid) {
(*clit)->enable_field_effect(false); (*clit)->enable_field_effect(false);
(*clit)->cancel_field_effect(); (*clit)->cancel_field_effect();
} }
cl = player[playerid].list_grave; std::swap(player[playerid].list_extra, player[playerid].tag_list_extra);
player[playerid].list_extra = player[playerid].tag_list_extra;
player[playerid].list_extra = cl;
for(clit = player[playerid].list_extra.begin(); clit != player[playerid].list_extra.end(); ++clit) { for(clit = player[playerid].list_extra.begin(); clit != player[playerid].list_extra.end(); ++clit) {
(*clit)->apply_field_effect(); (*clit)->apply_field_effect();
(*clit)->enable_field_effect(true); (*clit)->enable_field_effect(true);
...@@ -588,7 +582,7 @@ void field::tag_swap(uint8 playerid) { ...@@ -588,7 +582,7 @@ void field::tag_swap(uint8 playerid) {
pduel->write_buffer8(player[playerid].list_main.size()); pduel->write_buffer8(player[playerid].list_main.size());
pduel->write_buffer8(player[playerid].list_extra.size()); pduel->write_buffer8(player[playerid].list_extra.size());
pduel->write_buffer8(player[playerid].list_hand.size()); pduel->write_buffer8(player[playerid].list_hand.size());
if(core.deck_reversed) if(core.deck_reversed && player[playerid].list_main.size())
pduel->write_buffer32((*player[playerid].list_main.rbegin())->data.code); pduel->write_buffer32((*player[playerid].list_main.rbegin())->data.code);
else else
pduel->write_buffer32(0); pduel->write_buffer32(0);
......
...@@ -77,6 +77,24 @@ extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int options) { ...@@ -77,6 +77,24 @@ extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int options) {
pd->game_field->draw(0, REASON_RULE, PLAYER_NONE, 0, pd->game_field->player[0].start_count); pd->game_field->draw(0, REASON_RULE, PLAYER_NONE, 0, pd->game_field->player[0].start_count);
if(pd->game_field->player[1].start_count > 0) if(pd->game_field->player[1].start_count > 0)
pd->game_field->draw(0, REASON_RULE, PLAYER_NONE, 1, pd->game_field->player[1].start_count); pd->game_field->draw(0, REASON_RULE, PLAYER_NONE, 1, pd->game_field->player[1].start_count);
if(options & DUEL_TAG_MODE) {
for(int i = 0; i < pd->game_field->player[0].start_count && pd->game_field->player[0].tag_list_main.size(); ++i) {
card* pcard = *pd->game_field->player[0].tag_list_main.rbegin();
pd->game_field->player[0].tag_list_main.pop_back();
pd->game_field->player[0].tag_list_hand.push_back(pcard);
pcard->current.controler = 0;
pcard->current.location = LOCATION_HAND;
pcard->current.sequence = pd->game_field->player[0].tag_list_hand.size() - 1;
}
for(int i = 0; i < pd->game_field->player[1].start_count && pd->game_field->player[1].tag_list_main.size(); ++i) {
card* pcard = *pd->game_field->player[1].tag_list_main.rbegin();
pd->game_field->player[1].tag_list_main.pop_back();
pd->game_field->player[1].tag_list_hand.push_back(pcard);
pcard->current.controler = 1;
pcard->current.location = LOCATION_HAND;
pcard->current.sequence = pd->game_field->player[1].tag_list_hand.size() - 1;
}
}
pd->game_field->add_process(PROCESSOR_TURN, 0, 0, 0, 0, 0); pd->game_field->add_process(PROCESSOR_TURN, 0, 0, 0, 0, 0);
} }
extern "C" DECL_DLLEXPORT void end_duel(ptr pduel) { extern "C" DECL_DLLEXPORT void end_duel(ptr pduel) {
...@@ -135,9 +153,15 @@ extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner, ...@@ -135,9 +153,15 @@ extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner,
switch(location) { switch(location) {
case LOCATION_DECK: case LOCATION_DECK:
ptduel->game_field->player[owner].tag_list_main.push_back(pcard); ptduel->game_field->player[owner].tag_list_main.push_back(pcard);
pcard->current.controler = owner;
pcard->current.location = LOCATION_DECK;
pcard->current.sequence = ptduel->game_field->player[owner].tag_list_main.size() - 1;
break; break;
case LOCATION_EXTRA: case LOCATION_EXTRA:
ptduel->game_field->player[owner].tag_list_extra.push_back(pcard); ptduel->game_field->player[owner].tag_list_extra.push_back(pcard);
pcard->current.controler = owner;
pcard->current.location = LOCATION_EXTRA;
pcard->current.sequence = ptduel->game_field->player[owner].tag_list_extra.size() - 1;
break; break;
} }
} }
......
...@@ -3519,10 +3519,10 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -3519,10 +3519,10 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
(*rit)->recharge(); (*rit)->recharge();
infos.turn_id++; infos.turn_id++;
infos.turn_player = turn_player; infos.turn_player = turn_player;
if(core.duel_options & DUEL_TAG_MODE)
tag_swap(turn_player);
pduel->write_buffer8(MSG_NEW_TURN); pduel->write_buffer8(MSG_NEW_TURN);
pduel->write_buffer8(turn_player); pduel->write_buffer8(turn_player);
if((core.duel_options & DUEL_TAG_MODE) && infos.turn_id != 1)
tag_swap(turn_player);
if(is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_TURN)) { if(is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_TURN)) {
core.units.begin()->step = 17; core.units.begin()->step = 17;
reset_phase(PHASE_DRAW); reset_phase(PHASE_DRAW);
......
...@@ -86,7 +86,7 @@ end ...@@ -86,7 +86,7 @@ end
function c31768112.spop(e,tp,eg,ep,ev,re,r,rp) function c31768112.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
if c:IsRelateToEffect(e) then if c:IsRelateToEffect(e) then
Duel.SpecialSummon(c,0,tp,tp,true,false,POS_FACEUP) Duel.SpecialSummon(c,0,tp,tp,true,false,POS_FACEUP_ATTACK)
end end
end end
function c31768112.drcon(e,tp,eg,ep,ev,re,r,rp) function c31768112.drcon(e,tp,eg,ep,ev,re,r,rp)
......
...@@ -55,7 +55,7 @@ function c32391631.recop(e,tp,eg,ep,ev,re,r,rp) ...@@ -55,7 +55,7 @@ function c32391631.recop(e,tp,eg,ep,ev,re,r,rp)
Duel.Recover(p,d,REASON_EFFECT) Duel.Recover(p,d,REASON_EFFECT)
end end
function c32391631.becon(e) function c32391631.becon(e)
return Duel.IsExistingMatchingCard(Card.IsAttackPosable,Duel.GetTurnPlayer(),LOCATION_MZONE,0,1,nil) return Duel.IsExistingMatchingCard(Card.IsAttackable,Duel.GetTurnPlayer(),LOCATION_MZONE,0,1,nil)
end end
function c32391631.desfilter(c) function c32391631.desfilter(c)
return c:IsPosition(POS_FACEUP_ATTACK) and c:GetAttackedCount()==0 and c:IsDestructable() return c:IsPosition(POS_FACEUP_ATTACK) and c:GetAttackedCount()==0 and c:IsDestructable()
......
...@@ -35,6 +35,7 @@ function c39695323.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -35,6 +35,7 @@ function c39695323.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
local tc=Duel.GetFirstTarget() local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENCE)~=0 then if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENCE)~=0 then
Duel.BreakEffect()
if c:IsRelateToEffect(e) and c:IsFaceup() then if c:IsRelateToEffect(e) and c:IsFaceup() then
Duel.ChangePosition(e:GetHandler(),POS_FACEUP_DEFENCE) Duel.ChangePosition(e:GetHandler(),POS_FACEUP_DEFENCE)
end end
......
...@@ -24,7 +24,8 @@ function c48686504.filter(c,e,tp) ...@@ -24,7 +24,8 @@ function c48686504.filter(c,e,tp)
return c:IsRace(RACE_PLANT) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) return c:IsRace(RACE_PLANT) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end end
function c48686504.target(e,tp,eg,ep,ev,re,r,rp,chk) function c48686504.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c48686504.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1
and Duel.IsExistingMatchingCard(c48686504.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,LOCATION_DECK) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,LOCATION_DECK)
end end
function c48686504.operation(e,tp,eg,ep,ev,re,r,rp) function c48686504.operation(e,tp,eg,ep,ev,re,r,rp)
......
...@@ -15,7 +15,7 @@ end ...@@ -15,7 +15,7 @@ end
function c4906301.condition(e,tp,eg,ep,ev,re,r,rp) function c4906301.condition(e,tp,eg,ep,ev,re,r,rp)
local ph=Duel.GetCurrentPhase() local ph=Duel.GetCurrentPhase()
return Duel.GetTurnPlayer()~=tp and ph~=PHASE_MAIN2 and ph~=PHASE_END return Duel.GetTurnPlayer()~=tp and ph~=PHASE_MAIN2 and ph~=PHASE_END
and Duel.IsExistingMatchingCard(Card.IsAttackPosable,tp,0,LOCATION_MZONE,1,nil) and Duel.IsExistingMatchingCard(Card.IsAttackable,tp,0,LOCATION_MZONE,1,nil)
end end
function c4906301.cost(e,tp,eg,ep,ev,re,r,rp,chk) function c4906301.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
......
...@@ -5,7 +5,7 @@ function c55501446.initial_effect(c) ...@@ -5,7 +5,7 @@ function c55501446.initial_effect(c)
e1:SetDescription(aux.Stringid(55501446,0)) e1:SetDescription(aux.Stringid(55501446,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EVENT_TO_GRAVE) e1:SetCode(EVENT_TO_GRAVE)
e1:SetCondition(c55501446.spcon) e1:SetCondition(c55501446.spcon)
e1:SetTarget(c55501446.sptg) e1:SetTarget(c55501446.sptg)
......
...@@ -23,7 +23,7 @@ function c73417207.target(e,syncard,f,minc,maxc) ...@@ -23,7 +23,7 @@ function c73417207.target(e,syncard,f,minc,maxc)
end end
function c73417207.operation(e,tp,eg,ep,ev,re,r,rp,syncard,f,minc,maxc) function c73417207.operation(e,tp,eg,ep,ev,re,r,rp,syncard,f,minc,maxc)
local lv=syncard:GetLevel()-e:GetHandler():GetLevel() local lv=syncard:GetLevel()-e:GetHandler():GetLevel()
local g=Duel.GetMatchingGroup(c73417207.synfilter,syncard:GetControler(),LOCATION_HAND,LOCATION_HAND,c,syncard,f) local g=Duel.GetMatchingGroup(c73417207.synfilter,syncard:GetControler(),LOCATION_HAND,0,c,syncard,f)
local sg=g:SelectWithSumEqual(tp,Card.GetSynchroLevel,lv,2,2,syncard) local sg=g:SelectWithSumEqual(tp,Card.GetSynchroLevel,lv,2,2,syncard)
Duel.SetSynchroMaterial(sg) Duel.SetSynchroMaterial(sg)
end end
...@@ -54,7 +54,7 @@ function c79229522.sprop(e,tp,eg,ep,ev,re,r,rp,c) ...@@ -54,7 +54,7 @@ function c79229522.sprop(e,tp,eg,ep,ev,re,r,rp,c)
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE) e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_BASE_ATTACK) e1:SetCode(EFFECT_SET_BASE_ATTACK)
e1:SetReset(RESET_EVENT+0xfe0000) e1:SetReset(RESET_EVENT+0xff0000)
e1:SetValue(g1:GetCount()*1000) e1:SetValue(g1:GetCount()*1000)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
...@@ -32,7 +32,7 @@ function c93542102.cfilter(c) ...@@ -32,7 +32,7 @@ function c93542102.cfilter(c)
return c:IsLevelBelow(4) and c:IsSetCard(0x26) and c:IsType(TYPE_MONSTER) return c:IsLevelBelow(4) and c:IsSetCard(0x26) and c:IsType(TYPE_MONSTER)
end end
function c93542102.tg(e,tp,eg,ep,ev,re,r,rp,chk) function c93542102.tg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>0 if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>0
and Duel.IsExistingMatchingCard(c93542102.cfilter,tp,LOCATION_DECK,0,1,nil) end and Duel.IsExistingMatchingCard(c93542102.cfilter,tp,LOCATION_DECK,0,1,nil) end
end end
function c93542102.filter(c,e,tp) function c93542102.filter(c,e,tp)
......
...@@ -24,10 +24,10 @@ function c93717133.initial_effect(c) ...@@ -24,10 +24,10 @@ function c93717133.initial_effect(c)
end end
function c93717133.spcon(e,c) function c93717133.spcon(e,c)
if c==nil then return true end if c==nil then return true end
return Duel.CheckReleaseGroup(c:GetControler(),Card.IsAttackPosAbove,2,nil,2000) return Duel.CheckReleaseGroup(c:GetControler(),Card.IsAttackAbove,2,nil,2000)
end end
function c93717133.spop(e,tp,eg,ep,ev,re,r,rp,c) function c93717133.spop(e,tp,eg,ep,ev,re,r,rp,c)
local g=Duel.SelectReleaseGroup(c:GetControler(),Card.IsAttackPosAbove,2,2,nil,2000) local g=Duel.SelectReleaseGroup(c:GetControler(),Card.IsAttackAbove,2,2,nil,2000)
Duel.Release(g,REASON_COST) Duel.Release(g,REASON_COST)
end end
function c93717133.rmcon(e,tp,eg,ep,ev,re,r,rp) function c93717133.rmcon(e,tp,eg,ep,ev,re,r,rp)
......
...@@ -9,5 +9,5 @@ lastdeck = T1 ...@@ -9,5 +9,5 @@ lastdeck = T1
textfont = c:/windows/fonts/simsun.ttc 14 textfont = c:/windows/fonts/simsun.ttc 14
numfont = c:/windows/fonts/arialbd.ttf numfont = c:/windows/fonts/arialbd.ttf
serverport = 7911 serverport = 7911
lastip = 192.168.1.100 lastip = 192.168.3.235
lastport = 7911 lastport = 7911
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