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

fix

parent 0ed2cbaf
......@@ -411,16 +411,6 @@ void Game::DrawMisc() {
numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(386, 320, 443, 340), 0xff000000, true, false, 0);
numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(386, 321, 445, 341), 0xffffff00, true, false, 0);
}
for(int i = 0; i < 5; ++i) {
static unsigned int chatColor[10] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040};
if(chatTiming[i]) {
chatTiming[i]--;
int w = textFont->getDimension(chatMsg[i].c_str()).Width;
driver->draw2DRectangle(recti(305, 596 - 20 * i, 307 + w, 616 - 20 * i), 0xa0000000, 0xa0000000, 0xa0000000, 0xa0000000);
textFont->draw(chatMsg[i].c_str(), rect<s32>(305, 595 - 20 * i, 1020, 615 - 20 * i), 0xff000000, false, false);
textFont->draw(chatMsg[i].c_str(), rect<s32>(306, 596 - 20 * i, 1021, 616 - 20 * i), chatColor[chatType[i]], false, false);
}
}
}
void Game::DrawGUI() {
if(imageLoading.size()) {
......@@ -670,6 +660,16 @@ void Game::DrawSpec() {
if (attack_sv > 28)
attack_sv = 0;
}
for(int i = 0; i < 5; ++i) {
static unsigned int chatColor[10] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040};
if(chatTiming[i]) {
chatTiming[i]--;
int w = textFont->getDimension(chatMsg[i].c_str()).Width;
driver->draw2DRectangle(recti(305, 596 - 20 * i, 307 + w, 616 - 20 * i), 0xa0000000, 0xa0000000, 0xa0000000, 0xa0000000);
textFont->draw(chatMsg[i].c_str(), rect<s32>(305, 595 - 20 * i, 1020, 615 - 20 * i), 0xff000000, false, false);
textFont->draw(chatMsg[i].c_str(), rect<s32>(306, 596 - 20 * i, 1021, 616 - 20 * i), chatColor[chatType[i]], false, false);
}
}
}
void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
FadingUnit fu;
......
......@@ -361,6 +361,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
else if (mainGame->wLanWindow->isVisible())
mainGame->HideElement(mainGame->wLanWindow);
mainGame->ShowElement(mainGame->wHostPrepare);
mainGame->wChat->setVisible(true);
mainGame->gMutex.Unlock();
break;
}
......@@ -542,18 +543,23 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
BufferIO::CopyWStr(pkt->msg, msg, 256);
msg[(len - 3) / 2] = 0;
mainGame->gMutex.Lock();
if(!mainGame->dInfo.is_tag)
mainGame->AddChatMsg(msg, mainGame->LocalPlayer(pkt->player));
else {
if(mainGame->dInfo.isFirst) {
if(!mainGame->dInfo.is_tag) {
if(mainGame->dInfo.isStarted)
mainGame->AddChatMsg(msg, mainGame->LocalPlayer(pkt->player));
else
mainGame->AddChatMsg(msg, pkt->player);
} else {
if(mainGame->dInfo.isFirst || !mainGame->dInfo.isStarted) {
if(pkt->player == 0)
mainGame->AddChatMsg(msg, 0);
else if(pkt->player == 1)
mainGame->AddChatMsg(msg, 2);
else if(pkt->player == 2)
mainGame->AddChatMsg(msg, 1);
else
else if(pkt->player == 3)
mainGame->AddChatMsg(msg, 3);
else
mainGame->AddChatMsg(msg, 10);
} else {
if(pkt->player == 0)
mainGame->AddChatMsg(msg, 1);
......@@ -561,8 +567,10 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->AddChatMsg(msg, 3);
else if(pkt->player == 2)
mainGame->AddChatMsg(msg, 0);
else
else if(pkt->player == 3)
mainGame->AddChatMsg(msg, 2);
else
mainGame->AddChatMsg(msg, 10);
}
}
mainGame->gMutex.Unlock();
......@@ -591,6 +599,21 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break;
wchar_t name[20];
BufferIO::CopyWStr(pkt->name, name, 20);
if(mainGame->dInfo.is_tag) {
if(pkt->pos == 0)
BufferIO::CopyWStr(pkt->name, mainGame->dInfo.hostname, 20);
else if(pkt->pos == 1)
BufferIO::CopyWStr(pkt->name, mainGame->dInfo.hostname_tag, 20);
else if(pkt->pos == 2)
BufferIO::CopyWStr(pkt->name, mainGame->dInfo.clientname, 20);
else if(pkt->pos == 3)
BufferIO::CopyWStr(pkt->name, mainGame->dInfo.clientname_tag, 20);
} else {
if(pkt->pos == 0)
BufferIO::CopyWStr(pkt->name, mainGame->dInfo.hostname, 20);
else if(pkt->pos == 1)
BufferIO::CopyWStr(pkt->name, mainGame->dInfo.clientname, 20);
}
mainGame->gMutex.Lock();
mainGame->stHostPrepDuelist[pkt->pos]->setText(name);
mainGame->gMutex.Unlock();
......@@ -604,9 +627,18 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break;
mainGame->gMutex.Lock();
if(state < 8) {
mainGame->stHostPrepDuelist[state]->setText(mainGame->stHostPrepDuelist[pos]->getText());
wchar_t* prename = (wchar_t*)mainGame->stHostPrepDuelist[pos]->getText();
mainGame->stHostPrepDuelist[state]->setText(prename);
mainGame->stHostPrepDuelist[pos]->setText(L"");
mainGame->chkHostPrepReady[pos]->setChecked(false);
if(pos == 0)
BufferIO::CopyWStr(prename, mainGame->dInfo.hostname, 20);
else if(pos == 1)
BufferIO::CopyWStr(prename, mainGame->dInfo.hostname_tag, 20);
else if(pos == 2)
BufferIO::CopyWStr(prename, mainGame->dInfo.clientname, 20);
else if(pos == 3)
BufferIO::CopyWStr(prename, mainGame->dInfo.clientname_tag, 20);
} else if(state == PLAYERCHANGE_READY) {
mainGame->chkHostPrepReady[pos]->setChecked(true);
} else if(state == PLAYERCHANGE_NOTREADY) {
......@@ -637,7 +669,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
}
}
int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
char* pbuf = msg;
wchar_t textBuffer[256];
mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf);
......@@ -2692,7 +2724,7 @@ void DuelClient::SetResponseI(int respI) {
*((int*)response_buf) = respI;
response_len = 4;
}
void DuelClient::SetResponseB(unsigned char* respB, unsigned char len) {
void DuelClient::SetResponseB(unsigned char * respB, unsigned char len) {
memcpy(response_buf, respB, len);
response_len = len;
}
......@@ -2793,7 +2825,7 @@ void DuelClient::BeginRefreshHost() {
closesocket(sSend);
}
}
int DuelClient::RefreshThread(void* arg) {
int DuelClient::RefreshThread(void * arg) {
event_base* broadev = (event_base*)arg;
event_base_dispatch(broadev);
evutil_socket_t fd;
......@@ -2804,7 +2836,7 @@ int DuelClient::RefreshThread(void* arg) {
is_refreshing = false;
return 0;
}
void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void* arg) {
void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
if(events & EV_TIMEOUT) {
evutil_closesocket(fd);
event_base_loopbreak((event_base*)arg);
......
......@@ -774,12 +774,16 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
if(mainGame->dInfo.player_type < 7) {
if(mainGame->dInfo.is_tag && (mainGame->dInfo.player_type % 2))
mainGame->AddChatMsg((wchar_t*)input, 2);
else
mainGame->AddChatMsg((wchar_t*)input, 0);
} else mainGame->AddChatMsg((wchar_t*)input, 10);
if(mainGame->dInfo.isStarted) {
if(mainGame->dInfo.player_type < 7) {
if(mainGame->dInfo.is_tag && (mainGame->dInfo.player_type % 2))
mainGame->AddChatMsg((wchar_t*)input, 2);
else
mainGame->AddChatMsg((wchar_t*)input, 0);
} else
mainGame->AddChatMsg((wchar_t*)input, 10);
} else
mainGame->AddChatMsg((wchar_t*)input, 7);
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
......
......@@ -776,7 +776,7 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
chatType[i] = chatType[i - 1];
}
chatMsg[0].clear();
chatTiming[0] = 600;
chatTiming[0] = 1200;
chatType[0] = player;
switch(player) {
case 0: //from host
......@@ -795,6 +795,10 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
chatMsg[0].append(dInfo.clientname_tag);
chatMsg[0].append(L": ");
break;
case 7: //local name
chatMsg[0].append(mainGame->ebNickName->getText());
chatMsg[0].append(L": ");
break;
case 8: //system custom message, no prefix.
chatMsg[0].append(L"[System]: ");
break;
......@@ -804,7 +808,6 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
default: //from watcher or unknown
chatMsg[0].append(L"[---]: ");
}
chatMsg[0].append(msg);
}
void Game::ClearTextures() {
......
......@@ -113,6 +113,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->btnJoinCancel->setEnabled(true);
mainGame->HideElement(mainGame->wHostPrepare);
mainGame->ShowElement(mainGame->wLanWindow);
mainGame->wChat->setVisible(false);
if(exit_on_return)
mainGame->device->closeDevice();
break;
......@@ -270,6 +271,33 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
break;
}
case irr::gui::EGET_EDITBOX_ENTER: {
switch(id) {
case EDITBOX_CHAT: {
if(mainGame->dInfo.isReplay)
break;
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
if(mainGame->dInfo.isStarted) {
if(mainGame->dInfo.player_type < 7) {
if(mainGame->dInfo.is_tag && (mainGame->dInfo.player_type % 2))
mainGame->AddChatMsg((wchar_t*)input, 2);
else
mainGame->AddChatMsg((wchar_t*)input, 0);
} else
mainGame->AddChatMsg((wchar_t*)input, 10);
} else
mainGame->AddChatMsg((wchar_t*)input, 7);
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
}
break;
}
}
break;
}
break;
}
break;
......
......@@ -21,7 +21,7 @@ private:
static char net_server_read[0x2000];
static char net_server_write[0x2000];
static unsigned short last_sent;
public:
static bool StartServer(unsigned short port);
static bool StartBroadcast();
......@@ -41,6 +41,8 @@ public:
BufferIO::WriteInt16(p, 1);
BufferIO::WriteInt8(p, proto);
last_sent = 3;
if(!dp)
return;
bufferevent_write(dp->bev, net_server_write, last_sent);
}
template<typename ST>
......@@ -50,7 +52,8 @@ public:
BufferIO::WriteInt8(p, proto);
memcpy(p, &st, sizeof(ST));
last_sent = sizeof(ST) + 3;
bufferevent_write(dp->bev, net_server_write, last_sent);
if(dp)
bufferevent_write(dp->bev, net_server_write, last_sent);
}
static void SendBufferToPlayer(DuelPlayer* dp, unsigned char proto, void* buffer, size_t len) {
char* p = net_server_write;
......@@ -58,10 +61,12 @@ public:
BufferIO::WriteInt8(p, proto);
memcpy(p, buffer, len);
last_sent = len + 3;
bufferevent_write(dp->bev, net_server_write, last_sent);
if(dp)
bufferevent_write(dp->bev, net_server_write, last_sent);
}
static void ReSendToPlayer(DuelPlayer* dp) {
bufferevent_write(dp->bev, net_server_write, last_sent);
if(dp)
bufferevent_write(dp->bev, net_server_write, last_sent);
}
};
......
......@@ -110,7 +110,7 @@ static const struct luaL_Reg cardlib[] = {
{ "CreateRelation", scriptlib::card_create_relation },
{ "ReleaseRelation", scriptlib::card_release_relation },
{ "CreateEffectRelation", scriptlib::card_create_effect_relation },
{ "ClearEffectRelation", scriptlib::card_clear_effect_relation },
{ "ReleaseEffectRelation", scriptlib::card_release_effect_relation },
{ "IsRelateToEffect", scriptlib::card_is_relate_to_effect },
{ "IsRelateToCard", scriptlib::card_is_relate_to_card },
{ "IsRelateToBattle", scriptlib::card_is_relate_to_battle },
......
......@@ -861,11 +861,13 @@ int32 scriptlib::card_create_effect_relation(lua_State *L) {
pcard->create_relation(peffect);
return 0;
}
int32 scriptlib::card_clear_effect_relation(lua_State *L) {
check_param_count(L, 1);
int32 scriptlib::card_release_effect_relation(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_EFFECT, 2);
card* pcard = *(card**) lua_touserdata(L, 1);
pcard->relate_effect.clear();
effect* peffect = *(effect**) lua_touserdata(L, 2);
pcard->relate_effect.erase(peffect);
return 0;
}
int32 scriptlib::card_is_relate_to_effect(lua_State *L) {
......@@ -1717,7 +1719,15 @@ int32 scriptlib::card_cancel_to_grave(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
pcard->set_status(STATUS_LEAVE_CONFIRMED, FALSE);
bool cancel = true;
if(lua_gettop(L) > 1)
cancel = lua_toboolean(L, 2);
if(cancel)
pcard->set_status(STATUS_LEAVE_CONFIRMED, FALSE);
else {
pcard->pduel->game_field->core.leave_confirmed.insert(pcard);
pcard->set_status(STATUS_LEAVE_CONFIRMED, TRUE);
}
return 0;
}
int32 scriptlib::card_get_tribute_requirement(lua_State *L) {
......
......@@ -4126,8 +4126,8 @@ int32 field::solve_chain(uint16 step, uint32 skip_new) {
return FALSE;
}
case 13: {
raise_event((card*)0, EVENT_CHAIN_END, 0, 0, 0, 0, 0);
if(!skip_new) {
raise_event((card*)0, EVENT_CHAIN_END, 0, 0, 0, 0, 0);
process_instant_event();
core.hint_timing[0] |= TIMING_CHAIN_END;
core.hint_timing[1] |= TIMING_CHAIN_END;
......
......@@ -112,7 +112,7 @@ public:
static int32 card_create_relation(lua_State *L);
static int32 card_release_relation(lua_State *L);
static int32 card_create_effect_relation(lua_State *L);
static int32 card_clear_effect_relation(lua_State *L);
static int32 card_release_effect_relation(lua_State *L);
static int32 card_is_relate_to_effect(lua_State *L);
static int32 card_is_relate_to_card(lua_State *L);
static int32 card_is_relate_to_battle(lua_State *L);
......
......@@ -20,10 +20,10 @@ end
function c19733961.atkval(e,c)
local g=Duel.GetMatchingGroup(c19733961.filter,c:GetControler(),LOCATION_MZONE,0,nil)
if g:IsExists(Card.IsDefencePos,1,nil) then return 0 end
return g:GetCount()*500
return 500
end
function c19733961.defval(e,c)
local g=Duel.GetMatchingGroup(c19733961.filter,c:GetControler(),LOCATION_MZONE,0,nil)
if g:IsExists(Card.IsAttackPos,1,nil) then return 0 end
return g:GetCount()*500
return 500
end
......@@ -24,22 +24,24 @@ function c28890974.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=g:GetFirst()
if tc then
local atk=tc:GetAttack()
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK)
e1:SetValue(atk/2)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1,true)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EVENT_PHASE+PHASE_END)
e2:SetOperation(c28890974.desop)
e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e2:SetCountLimit(1)
tc:RegisterEffect(e2,true)
if Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK)
e1:SetValue(atk/2)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1,true)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EVENT_PHASE+PHASE_END)
e2:SetOperation(c28890974.desop)
e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e2:SetCountLimit(1)
tc:RegisterEffect(e2,true)
Duel.SpecialSummonComplete()
end
end
end
function c28890974.desop(e,tp,eg,ep,ev,re,r,rp)
......
--おとり人形
function c7165085.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c7165085.target)
e1:SetOperation(c7165085.activate)
c:RegisterEffect(e1)
end
function c7165085.filter(c)
return c:IsFacedown() and c:GetSequence()~=5
end
function c7165085.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_SZONE) and c7165085.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c7165085.filter,tp,LOCATION_SZONE,LOCATION_SZONE,1,e:GetHandler()) end
e:SetProperty(EFFECT_FLAG_CARD_TARGET)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEDOWN)
Duel.SelectTarget(tp,c7165085.filter,tp,LOCATION_SZONE,LOCATION_SZONE,1,1,e:GetHandler())
end
function c7165085.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if not tc:IsRelateToEffect(e) or tc:IsFaceup() then return end
Duel.ConfirmCards(tp,tc)
if tc:IsType(TYPE_TRAP) then
local te=tc:GetActivateEffect()
local tep=tc:GetControler()
if not te then
Duel.Destroy(tc,REASON_EFFECT)
else
local condition=te:GetCondition()
local cost=te:GetCost()
local target=te:GetTarget()
local operation=te:GetOperation()
if te:GetCode()==EVENT_FREE_CHAIN
and (not condition or condition(te,tep,eg,ep,ev,re,r,rp))
and (not cost or cost(te,tep,eg,ep,ev,re,r,rp,0))
and (not target or target(te,tep,eg,ep,ev,re,r,rp,0)) then
Duel.ClearTargetCard()
e:SetProperty(te:GetProperty())
Duel.Hint(HINT_CARD,0,tc:GetOriginalCode())
Duel.Hint(HINT_CARD,1,tc:GetOriginalCode())
Duel.ChangePosition(tc,POS_FACEUP)
tc:CancelToGrave(false)
tc:CreateEffectRelation(te)
cost(te,tep,eg,ep,ev,re,r,rp,1)
target(te,tep,eg,ep,ev,re,r,rp,1)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local tg=g:GetFirst()
while tg do
tg:CreateEffectRelation(te)
tg=g:GetNext()
end
operation(te,tep,eg,ep,ev,re,r,rp)
tc:ReleaseEffectRelation(te)
tg=g:GetFirst()
while tg do
tg:ReleaseEffectRelation(te)
tg=g:GetNext()
end
else
Duel.Destroy(tc,REASON_EFFECT)
end
end
end
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
c:CancelToGrave()
Duel.SendtoDeck(c,nil,2,REASON_EFFECT)
end
end
......@@ -40,7 +40,7 @@ function c91349449.rmcost(e,tp,eg,ep,ev,re,r,rp,chk)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_OATH)
e1:SetCode(EFFECT_CANNOT_ATTACK)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e:GetHandler():RegisterEffect(e1,true)
end
function c91349449.filter1(c)
......
......@@ -3,7 +3,7 @@
use_d3d = 0
antialias = 2
errorlog = 1
nickname = Player
nickname = Player1
gamename = Game
lastdeck = test
textfont = c:/windows/fonts/simsun.ttc 14
......
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