Commit ab260bc6 authored by nanahira's avatar nanahira

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

parents fb1a1fdb e65e5c61
......@@ -990,12 +990,46 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) {
if(last_successful_msg_length) {
char* p = last_successful_msg;
auto last_msg = BufferIO::ReadUInt8(p);
int err_desc = 1422;
int err_desc = 1421;
switch(last_msg) {
case MSG_ANNOUNCE_CARD:
case MSG_ANNOUNCE_CARD_FILTER:
err_desc = 1421;
//TODO: other cases
err_desc = 1422;
break;
case MSG_ANNOUNCE_ATTRIB:
err_desc = 1423;
break;
case MSG_ANNOUNCE_RACE:
err_desc = 1424;
break;
case MSG_ANNOUNCE_NUMBER:
err_desc = 1425;
break;
case MSG_SELECT_EFFECTYN:
case MSG_SELECT_YESNO:
case MSG_SELECT_OPTION:
err_desc = 1426;
break;
case MSG_SELECT_CARD:
case MSG_SELECT_UNSELECT_CARD:
case MSG_SELECT_TRIBUTE:
case MSG_SELECT_SUM:
case MSG_SORT_CARD:
err_desc = 1427;
break;
case MSG_SELECT_CHAIN:
err_desc = 1428;
break;
case MSG_SELECT_PLACE:
case MSG_SELECT_DISFIELD:
err_desc = 1429;
break;
case MSG_SELECT_POSITION:
err_desc = 1430;
break;
case MSG_SELECT_COUNTER:
err_desc = 1431;
break;
default:
break;
}
......@@ -4029,45 +4063,24 @@ void DuelClient::BeginRefreshHost() {
if(!host)
return;
SOCKET reply = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
sockaddr_in reply_addr;
memset(&reply_addr, 0, sizeof(reply_addr));
reply_addr.sin_family = AF_INET;
reply_addr.sin_port = htons(7921);
reply_addr.sin_addr.s_addr = 0;
if(bind(reply, (sockaddr*)&reply_addr, sizeof(reply_addr)) == SOCKET_ERROR) {
closesocket(reply);
return;
}
BOOL opt = TRUE;
setsockopt(reply, SOL_SOCKET, SO_BROADCAST, (const char*)&opt, sizeof(BOOL));
timeval timeout = {3, 0};
resp_event = event_new(broadev, reply, EV_TIMEOUT | EV_READ | EV_PERSIST, BroadcastReply, broadev);
event_add(resp_event, &timeout);
Thread::NewThread(RefreshThread, broadev);
//send request
SOCKADDR_IN local;
local.sin_family = AF_INET;
local.sin_port = htons(7922);
SOCKADDR_IN sockTo;
sockTo.sin_addr.s_addr = htonl(INADDR_BROADCAST);
SOCKADDR_IN sockTo = {};
sockTo.sin_family = AF_INET;
sockTo.sin_port = htons(7920);
sockTo.sin_port = htons(7911);
HostRequest hReq;
hReq.identifier = NETWORK_CLIENT_ID;
for(int i = 0; i < 8; ++i) {
if(host->h_addr_list[i] == 0)
break;
unsigned int local_addr = *(unsigned int*)host->h_addr_list[i];
local.sin_addr.s_addr = local_addr;
SOCKET sSend = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(sSend == INVALID_SOCKET)
break;
BOOL opt = TRUE;
setsockopt(sSend, SOL_SOCKET, SO_BROADCAST, (const char*)&opt, sizeof(BOOL));
if(bind(sSend, (sockaddr*)&local, sizeof(sockaddr)) == SOCKET_ERROR) {
closesocket(sSend);
break;
}
sendto(sSend, (const char*)&hReq, sizeof(HostRequest), 0, (sockaddr*)&sockTo, sizeof(sockaddr));
closesocket(sSend);
sockTo.sin_addr.s_addr = local_addr;
sendto(reply, (const char*)&hReq, sizeof(HostRequest), 0, (sockaddr*)&sockTo, sizeof(sockaddr));
}
}
int DuelClient::RefreshThread(void * arg) {
......
......@@ -40,13 +40,11 @@ bool NetServer::StartBroadcast() {
if(!net_evbase)
return false;
SOCKET udp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
BOOL opt = TRUE;
setsockopt(udp, SOL_SOCKET, SO_BROADCAST, (const char*)&opt, sizeof(BOOL));
sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(7920);
addr.sin_addr.s_addr = 0;
addr.sin_port = htons(7911);
addr.sin_addr.s_addr = htonl(INADDR_ANY);
if(bind(udp, (sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) {
closesocket(udp);
return false;
......@@ -85,17 +83,13 @@ void NetServer::BroadcastEvent(evutil_socket_t fd, short events, void* arg) {
return;
HostRequest* pHR = (HostRequest*)buf;
if(pHR->identifier == NETWORK_CLIENT_ID) {
SOCKADDR_IN sockTo;
sockTo.sin_addr.s_addr = bc_addr.sin_addr.s_addr;
sockTo.sin_family = AF_INET;
sockTo.sin_port = htons(7921);
HostPacket hp;
hp.identifier = NETWORK_SERVER_ID;
hp.port = server_port;
hp.version = PRO_VERSION;
hp.host = duel_mode->host_info;
BufferIO::CopyWStr(duel_mode->name, hp.name, 20);
sendto(fd, (const char*)&hp, sizeof(HostPacket), 0, (sockaddr*)&sockTo, sizeof(sockTo));
sendto(fd, (const char*)&hp, sizeof(HostPacket), 0, (sockaddr*)&bc_addr, sz);
}
}
void NetServer::ServerAccept(evconnlistener* listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx) {
......
......@@ -101,6 +101,8 @@ int ReplayMode::ReplayThread(void* param) {
if(is_restarting) {
mainGame->gMutex.Lock();
is_restarting = false;
mainGame->dInfo.isReplaySkiping = true;
Restart(false);
int step = current_step - 1;
if(step < 0)
step = 0;
......@@ -109,10 +111,13 @@ int ReplayMode::ReplayThread(void* param) {
skip_step = 0;
int len = get_message(pduel, (byte*)engineBuffer);
if (len > 0) {
mainGame->gMutex.Unlock();
is_continuing = ReplayAnalyze(engineBuffer, len);
mainGame->gMutex.Lock();
}
} else {
ReplayRefreshDeck(0);
ReplayRefreshDeck(1);
ReplayRefreshExtra(0);
ReplayRefreshExtra(1);
}
if(step == 0) {
Pause(true, false);
......@@ -175,14 +180,14 @@ bool ReplayMode::StartDuel() {
int extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(0, main, extra);
mainGame->dField.Initial(mainGame->LocalPlayer(0), main, extra);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(1, main, extra);
mainGame->dField.Initial(mainGame->LocalPlayer(1), main, extra);
} else {
int main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
......@@ -190,7 +195,7 @@ bool ReplayMode::StartDuel() {
int extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(0, main, extra);
mainGame->dField.Initial(mainGame->LocalPlayer(0), main, extra);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_tag_card(pduel, cur_replay.ReadInt32(), 0, LOCATION_DECK);
......@@ -203,7 +208,7 @@ bool ReplayMode::StartDuel() {
extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(1, main, extra);
mainGame->dField.Initial(mainGame->LocalPlayer(1), main, extra);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_tag_card(pduel, cur_replay.ReadInt32(), 1, LOCATION_DECK);
......@@ -271,13 +276,11 @@ void ReplayMode::Restart(bool refresh) {
//mainGame->dInfo.isReplay = true;
}
skip_turn = 0;
is_restarting = true;
}
void ReplayMode::Undo() {
if(skip_step > 0 || current_step == 0)
return;
mainGame->dInfo.isReplaySkiping = true;
Restart(false);
is_restarting = true;
Pause(false, false);
}
bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
......
......@@ -447,8 +447,17 @@
!system 1418 额外卡组数量应不超过15张,当前卡组数量为%d张。
!system 1419 副卡组数量应不超过15张,当前卡组数量为%d张。
!system 1420 有额外卡组卡片存在于主卡组,可能是额外卡组数量超过15张。
!system 1421 宣言的卡不符合条件,或无法被主机识别。
!system 1422 操作无效,请重试。
!system 1421 操作无效,请重试。
!system 1422 宣言的卡不符合条件,或无法被主机识别。
!system 1423 宣言的属性不符合条件。
!system 1424 宣言的种族不符合条件
!system 1425 宣言的数字不符合条件。
!system 1426 选择的选项不符合条件
!system 1427 选择的卡片不符合条件。
!system 1428 选择的连锁不符合条件。
!system 1429 选择的位置不符合条件。
!system 1430 选择的表示形式不符合条件。
!system 1431 选择的指示物不符合条件。
!system 1450 卡包展示
!system 1451 人机卡组
!system 1452 未分类卡组
......
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