Commit 1ee0c651 authored by VanillaSalt's avatar VanillaSalt

update

parent 2a5b5bba
......@@ -1244,4 +1244,38 @@ bool ClientField::check_sum(std::set<ClientCard*>::const_iterator index, std::se
|| (l2 > 0 && acc > l2 && check_sum(index, end, acc - l2, count + 1))
|| check_sum(index, end, acc, count);
}
template <class T>
static bool is_declarable(T const& cd, int declarable_type) {
if(!(cd.type & declarable_type))
return false;
return cd.code == CARD_MARINE_DOLPHIN || cd.code == CARD_TWINKLE_MOSS
|| (!cd.alias && (cd.type & (TYPE_MONSTER + TYPE_TOKEN)) != (TYPE_MONSTER + TYPE_TOKEN));
}
void ClientField::UpdateDeclarableCode() {
const wchar_t* pname = mainGame->ebANCard->getText();
int trycode = BufferIO::GetVal(pname);
CardString cstr;
CardData cd;
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, declarable_type)) {
mainGame->lstANCard->clear();
ancard.clear();
mainGame->lstANCard->addItem(cstr.name);
ancard.push_back(trycode);
return;
}
if(pname[0] == 0 || pname[1] == 0)
return;
mainGame->lstANCard->clear();
ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if(wcsstr(cit->second.name, pname) != 0) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias
if(is_declarable(cp->second, declarable_type)) {
mainGame->lstANCard->addItem(cit->second.name);
ancard.push_back(cit->first);
}
}
}
}
}
......@@ -56,6 +56,7 @@ public:
int select_mode;
bool select_ready;
int announce_count;
int declarable_type;
int select_counter_count;
int select_counter_type;
std::vector<ClientCard*> selectable_cards;
......@@ -101,6 +102,8 @@ public:
void check_sel_sum_t(const std::set<ClientCard*>& left, int acc);
bool check_sum(std::set<ClientCard*>::const_iterator index, std::set<ClientCard*>::const_iterator end, int acc, int count);
void UpdateDeclarableCode();
irr::gui::IGUIElement* panel;
std::vector<int> ancard;
int hovered_controler;
......@@ -124,4 +127,8 @@ public:
}
//special cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#endif //CLIENT_FIELD_H
......@@ -2872,6 +2872,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case MSG_ANNOUNCE_CARD: {
/*int player = */mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
mainGame->dField.declarable_type = BufferIO::ReadInt32(pbuf);
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, dataManager.GetSysString(564));
......
......@@ -799,34 +799,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::gui::EGET_EDITBOX_CHANGED: {
switch(id) {
case EDITBOX_ANCARD: {
const wchar_t* pname = mainGame->ebANCard->getText();
int trycode = BufferIO::GetVal(pname);
CardString cstr;
CardData cd;
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd)
&& (cd.code == CARD_MARINE_DOLPHIN || cd.code == CARD_TWINKLE_MOSS
|| !cd.alias && !((cd.type & (TYPE_MONSTER + TYPE_TOKEN)) == (TYPE_MONSTER + TYPE_TOKEN)))) {
mainGame->lstANCard->clear();
ancard.clear();
mainGame->lstANCard->addItem(cstr.name);
ancard.push_back(trycode);
break;
}
if(pname[0] == 0 || pname[1] == 0)
break;
mainGame->lstANCard->clear();
ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if(wcsstr(cit->second.name, pname) != 0) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias
if(cp->second.code == CARD_MARINE_DOLPHIN || cp->second.code == CARD_TWINKLE_MOSS
|| !cp->second.alias && !((cp->second.type & (TYPE_MONSTER + TYPE_TOKEN)) == (TYPE_MONSTER + TYPE_TOKEN))) {
mainGame->lstANCard->addItem(cit->second.name);
ancard.push_back(cit->first);
}
}
}
UpdateDeclarableCode();
break;
}
}
......@@ -835,34 +808,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::gui::EGET_EDITBOX_ENTER: {
switch(id) {
case EDITBOX_ANCARD: {
const wchar_t* pname = mainGame->ebANCard->getText();
int trycode = BufferIO::GetVal(pname);
CardString cstr;
CardData cd;
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd)
&& (cd.code == CARD_MARINE_DOLPHIN || cd.code == CARD_TWINKLE_MOSS
|| !cd.alias && !((cd.type & (TYPE_MONSTER + TYPE_TOKEN)) == (TYPE_MONSTER + TYPE_TOKEN)))) {
mainGame->lstANCard->clear();
ancard.clear();
mainGame->lstANCard->addItem(cstr.name);
ancard.push_back(trycode);
break;
}
if(pname[0] == 0)
break;
mainGame->lstANCard->clear();
ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if(wcsstr(cit->second.name, pname) != 0) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias
if(cp->second.code == CARD_MARINE_DOLPHIN || cp->second.code == CARD_TWINKLE_MOSS
|| !cp->second.alias && !((cp->second.type & (TYPE_MONSTER + TYPE_TOKEN)) == (TYPE_MONSTER + TYPE_TOKEN))) {
mainGame->lstANCard->addItem(cit->second.name);
ancard.push_back(cit->first);
}
}
}
UpdateDeclarableCode();
break;
}
case EDITBOX_CHAT: {
......
#ifndef EVENT_HANDLER_H
#define EVENT_HANDLER_H
//special cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#include "config.h"
#include "game.h"
#include "client_card.h"
......
......@@ -636,6 +636,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
}
case MSG_ANNOUNCE_CARD: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 4;
return ReadReplayResponse();
}
case MSG_ANNOUNCE_NUMBER: {
......
......@@ -1258,6 +1258,7 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
case MSG_ANNOUNCE_CARD: {
player = BufferIO::ReadInt8(pbuf);
WaitforResponse(player);
pbuf += 4;
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
}
......
......@@ -578,6 +578,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
}
case MSG_ANNOUNCE_CARD: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 4;
if(!DuelClient::ClientAnalyze(offset, pbuf - offset)) {
mainGame->singleSignal.Reset();
mainGame->singleSignal.Wait();
......
......@@ -1296,6 +1296,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
}
case MSG_ANNOUNCE_CARD: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 4;
WaitforResponse(player);
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
......
Subproject commit e92e8c0b75f7fc3ba01f3c266667c5000baf168a
Subproject commit ea2ad25d577e98a7915389298f190ba6bac5079b
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