Commit 9ca984d3 authored by fallenstardust's avatar fallenstardust

sync

parent 6e3291e0
...@@ -3675,7 +3675,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3675,7 +3675,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_MZONE, seq); mainGame->dField.AddCard(ccard, p, LOCATION_MZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf); ccard->position = BufferIO::ReadInt8(pbuf);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
if(val) { if(val) {
for(int xyz = 0; xyz < val; ++xyz) { for(int xyz = 0; xyz < val; ++xyz) {
...@@ -3685,7 +3684,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3685,7 +3684,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
xcard->overlayTarget = ccard; xcard->overlayTarget = ccard;
xcard->location = 0x80; xcard->location = 0x80;
xcard->sequence = ccard->overlayed.size() - 1; xcard->sequence = ccard->overlayed.size() - 1;
mainGame->dField.GetCardLocation(xcard, &xcard->curPos, &xcard->curRot, true); xcard->owner = p;
xcard->controler = p;
} }
} }
} }
...@@ -3696,49 +3696,39 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3696,49 +3696,39 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_SZONE, seq); mainGame->dField.AddCard(ccard, p, LOCATION_SZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf); ccard->position = BufferIO::ReadInt8(pbuf);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_DECK, seq); mainGame->dField.AddCard(ccard, p, LOCATION_DECK, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_HAND, seq); mainGame->dField.AddCard(ccard, p, LOCATION_HAND, seq);
} }
// Use another loop to refresh the hand locations to prevent incorrect positioning
for (int seq = 0; seq < val; ++seq) {
ClientCard* ccard = mainGame->dField.hand[p][seq];
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
}
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_GRAVE, seq); mainGame->dField.AddCard(ccard, p, LOCATION_GRAVE, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_REMOVED, seq); mainGame->dField.AddCard(ccard, p, LOCATION_REMOVED, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_EXTRA, seq); mainGame->dField.AddCard(ccard, p, LOCATION_EXTRA, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
mainGame->dField.extra_p_count[p] = val; mainGame->dField.extra_p_count[p] = val;
} }
val = BufferIO::ReadInt8(pbuf); //chains mainGame->dField.RefreshAllCards();
val = BufferIO::ReadInt8(pbuf); //chains, always 0 in single mode
if(!mainGame->dInfo.isSingleMode) {
for(int i = 0; i < val; ++i) { for(int i = 0; i < val; ++i) {
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf); unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
int pcc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int pcc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
...@@ -3760,11 +3750,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3760,11 +3750,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.current_chain.solved = false; mainGame->dField.current_chain.solved = false;
int chc = 0; int chc = 0;
for(auto chit = mainGame->dField.chains.begin(); chit != mainGame->dField.chains.end(); ++chit) { for(auto chit = mainGame->dField.chains.begin(); chit != mainGame->dField.chains.end(); ++chit) {
if (cl == 0x10 || cl == 0x20) { if(cl == 0x10 || cl == 0x20) {
if (chit->controler == cc && chit->location == cl) if(chit->controler == cc && chit->location == cl)
chc++; chc++;
} else { } else {
if (chit->controler == cc && chit->location == cl && chit->sequence == cs) if(chit->controler == cc && chit->location == cl && chit->sequence == cs)
chc++; chc++;
} }
} }
...@@ -3778,6 +3768,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3778,6 +3768,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code)); myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code));
mainGame->dField.last_chain = true; mainGame->dField.last_chain = true;
} }
}
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
} }
......
...@@ -719,72 +719,25 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -719,72 +719,25 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
break; break;
} }
case MSG_RELOAD_FIELD: { case MSG_RELOAD_FIELD: {
mainGame->gMutex.Lock(); pbuf++;
mainGame->dField.Clear();
mainGame->dInfo.duel_rule = BufferIO::ReadInt8(pbuf);
int val = 0;
for(int p = 0; p < 2; ++p) { for(int p = 0; p < 2; ++p) {
mainGame->dInfo.lp[p] = BufferIO::ReadInt32(pbuf); pbuf += 4;
myswprintf(mainGame->dInfo.strLP[p], L"%d", mainGame->dInfo.lp[p]);
for(int seq = 0; seq < 7; ++seq) { for(int seq = 0; seq < 7; ++seq) {
val = BufferIO::ReadInt8(pbuf); int val = BufferIO::ReadInt8(pbuf);
if(val) { if(val)
ClientCard* ccard = new ClientCard; pbuf += 2;
mainGame->dField.AddCard(ccard, p, LOCATION_MZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf);
val = BufferIO::ReadInt8(pbuf);
if(val) {
for(int xyz = 0; xyz < val; ++xyz) {
ClientCard* xcard = new ClientCard;
ccard->overlayed.push_back(xcard);
mainGame->dField.overlay_cards.insert(xcard);
xcard->overlayTarget = ccard;
xcard->location = 0x80;
xcard->sequence = ccard->overlayed.size() - 1;
xcard->owner = p;
xcard->controler = p;
}
} }
for(int seq = 0; seq < 8; ++seq) {
int val = BufferIO::ReadInt8(pbuf);
if(val)
pbuf++;
} }
pbuf += 6;
} }
for(int seq = 0; seq < 8; ++seq) { pbuf++;
val = BufferIO::ReadInt8(pbuf); DuelClient::ClientAnalyze(offset, pbuf - offset);
if(val) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_SZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf);
}
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_DECK, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_HAND, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_GRAVE, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_REMOVED, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_EXTRA, seq);
}
val = BufferIO::ReadInt8(pbuf);
mainGame->dField.extra_p_count[p] = val;
}
BufferIO::ReadInt8(pbuf); //chain count, always 0
SinglePlayReload(); SinglePlayReload();
mainGame->gMutex.Lock();
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
......
...@@ -1234,6 +1234,8 @@ void field::remove_oath_effect(effect* reason_effect) { ...@@ -1234,6 +1234,8 @@ void field::remove_oath_effect(effect* reason_effect) {
void field::reset_phase(uint32 phase) { void field::reset_phase(uint32 phase) {
for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) { for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) {
auto rm = eit++; auto rm = eit++;
if((*rm)->code == EFFECT_SET_CONTROL)
continue;
if((*rm)->reset(phase, RESET_PHASE)) { if((*rm)->reset(phase, RESET_PHASE)) {
if((*rm)->is_flag(EFFECT_FLAG_FIELD_ONLY)) if((*rm)->is_flag(EFFECT_FLAG_FIELD_ONLY))
remove_effect((*rm)); remove_effect((*rm));
......
...@@ -4013,8 +4013,6 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -4013,8 +4013,6 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
tag_swap(turn_player); 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_STANDBY);
reset_phase(PHASE_END); reset_phase(PHASE_END);
adjust_all(); adjust_all();
return FALSE; return FALSE;
......
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