Commit 75bbf24b authored by Chen Bill's avatar Chen Bill

clear data while face-down

parent 1b54a189
...@@ -5,51 +5,7 @@ ...@@ -5,51 +5,7 @@
namespace ygo { namespace ygo {
ClientCard::ClientCard() { ClientCard::ClientCard() {}
curAlpha = 255;
dAlpha = 0;
aniFrame = 0;
is_moving = false;
is_fading = false;
is_hovered = false;
is_selectable = false;
is_selected = false;
is_showequip = false;
is_showtarget = false;
is_showchaintarget = false;
is_highlighting = false;
status = 0;
is_reversed = false;
cmdFlag = 0;
code = 0;
chain_code = 0;
location = 0;
type = 0;
alias = 0;
level = 0;
rank = 0;
link = 0;
race = 0;
attribute = 0;
attack = 0;
defense = 0;
base_attack = 0;
base_defense = 0;
lscale = 0;
rscale = 0;
link_marker = 0;
position = 0;
cHint = 0;
chValue = 0;
atkstring[0] = 0;
defstring[0] = 0;
lvstring[0] = 0;
linkstring[0] = 0;
rscstring[0] = 0;
lscstring[0] = 0;
overlayTarget = 0;
equipTarget = 0;
}
void ClientCard::SetCode(int code) { void ClientCard::SetCode(int code) {
if((location == LOCATION_HAND) && (this->code != (unsigned int)code)) { if((location == LOCATION_HAND) && (this->code != (unsigned int)code)) {
this->code = code; this->code = code;
...@@ -59,8 +15,10 @@ void ClientCard::SetCode(int code) { ...@@ -59,8 +15,10 @@ void ClientCard::SetCode(int code) {
} }
void ClientCard::UpdateInfo(unsigned char* buf) { void ClientCard::UpdateInfo(unsigned char* buf) {
int flag = BufferIO::ReadInt32(buf); int flag = BufferIO::ReadInt32(buf);
if(flag == 0) if (flag == 0) {
ClearData();
return; return;
}
int pdata; int pdata;
if(flag & QUERY_CODE) { if(flag & QUERY_CODE) {
pdata = BufferIO::ReadInt32(buf); pdata = BufferIO::ReadInt32(buf);
...@@ -133,8 +91,10 @@ void ClientCard::UpdateInfo(unsigned char* buf) { ...@@ -133,8 +91,10 @@ void ClientCard::UpdateInfo(unsigned char* buf) {
int s = BufferIO::ReadInt8(buf); int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf); BufferIO::ReadInt8(buf);
ClientCard* ecard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s); ClientCard* ecard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s);
equipTarget = ecard; if (ecard) {
ecard->equipped.insert(this); equipTarget = ecard;
ecard->equipped.insert(this);
}
} }
if(flag & QUERY_TARGET_CARD) { if(flag & QUERY_TARGET_CARD) {
int count = BufferIO::ReadInt32(buf); int count = BufferIO::ReadInt32(buf);
...@@ -144,8 +104,10 @@ void ClientCard::UpdateInfo(unsigned char* buf) { ...@@ -144,8 +104,10 @@ void ClientCard::UpdateInfo(unsigned char* buf) {
int s = BufferIO::ReadInt8(buf); int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf); BufferIO::ReadInt8(buf);
ClientCard* tcard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s); ClientCard* tcard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s);
cardTarget.insert(tcard); if (tcard) {
tcard->ownerTarget.insert(this); cardTarget.insert(tcard);
tcard->ownerTarget.insert(this);
}
} }
} }
if(flag & QUERY_OVERLAY_CARD) { if(flag & QUERY_OVERLAY_CARD) {
...@@ -198,6 +160,32 @@ void ClientCard::ClearTarget() { ...@@ -198,6 +160,32 @@ void ClientCard::ClearTarget() {
cardTarget.clear(); cardTarget.clear();
ownerTarget.clear(); ownerTarget.clear();
} }
void ClientCard::ClearData() {
alias = 0;
type = 0;
level = 0;
rank = 0;
race = 0;
attribute = 0;
attack = 0;
defense = 0;
base_attack = 0;
base_defense = 0;
lscale = 0;
rscale = 0;
link = 0;
link_marker = 0;
status = 0;
atkstring[0] = 0;
defstring[0] = 0;
lvstring[0] = 0;
linkstring[0] = 0;
rscstring[0] = 0;
lscstring[0] = 0;
counters.clear();
equipped.clear();
}
bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) { bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
if(c1->is_selected != c2->is_selected) if(c1->is_selected != c2->is_selected)
return c1->is_selected < c2->is_selected; return c1->is_selected < c2->is_selected;
......
...@@ -53,67 +53,69 @@ public: ...@@ -53,67 +53,69 @@ public:
irr::core::vector3df curRot; irr::core::vector3df curRot;
irr::core::vector3df dPos; irr::core::vector3df dPos;
irr::core::vector3df dRot; irr::core::vector3df dRot;
u32 curAlpha; u32 curAlpha{ 255 };
u32 dAlpha; u32 dAlpha{ 0 };
u32 aniFrame; u32 aniFrame{ 0 };
bool is_moving; bool is_moving{ false };
bool is_fading; bool is_fading{ false };
bool is_hovered; bool is_hovered{ false };
bool is_selectable; bool is_selectable{ false };
bool is_selected; bool is_selected{ false };
bool is_showequip; bool is_showequip{ false };
bool is_showtarget; bool is_showtarget{ false };
bool is_showchaintarget; bool is_showchaintarget{ false };
bool is_highlighting; bool is_highlighting{ false };
bool is_reversed; bool is_reversed{ false };
u32 code;
u32 chain_code; unsigned int code{ 0 };
u32 alias; unsigned int chain_code{ 0 };
u32 type; unsigned int alias{ 0 };
u32 level; unsigned int type{ 0 };
u32 rank; unsigned int level{ 0 };
u32 link; unsigned int rank{ 0 };
u32 attribute; unsigned int link{ 0 };
u32 race; unsigned int attribute{ 0 };
s32 attack; unsigned int race{ 0 };
s32 defense; int attack{ 0 };
s32 base_attack; int defense{ 0 };
s32 base_defense; int base_attack{ 0 };
u32 lscale; int base_defense{ 0 };
u32 rscale; unsigned int lscale{ 0 };
u32 link_marker; unsigned int rscale{ 0 };
u32 reason; unsigned int link_marker{ 0 };
u32 select_seq; unsigned int reason{ 0 };
u8 owner; unsigned int select_seq{ 0 };
u8 controler; unsigned char owner{ PLAYER_NONE };
u8 location; unsigned char controler{ PLAYER_NONE };
u8 sequence; unsigned char location{ 0 };
u8 position; unsigned char sequence{ 0 };
u32 status; unsigned char position{ 0 };
u8 cHint; unsigned int status{ 0 };
u32 chValue; unsigned char cHint{ 0 };
u32 opParam; unsigned int chValue{ 0 };
u32 symbol; unsigned int opParam{ 0 };
u32 cmdFlag; unsigned int symbol{ 0 };
ClientCard* overlayTarget; unsigned int cmdFlag{ 0 };
ClientCard* overlayTarget{ nullptr };
std::vector<ClientCard*> overlayed; std::vector<ClientCard*> overlayed;
ClientCard* equipTarget; ClientCard* equipTarget{ nullptr };
std::set<ClientCard*> equipped; std::set<ClientCard*> equipped;
std::set<ClientCard*> cardTarget; std::set<ClientCard*> cardTarget;
std::set<ClientCard*> ownerTarget; std::set<ClientCard*> ownerTarget;
std::map<int, int> counters; std::map<int, int> counters;
std::map<int, int> desc_hints; std::map<int, int> desc_hints;
wchar_t atkstring[16]; wchar_t atkstring[16]{ 0 };
wchar_t defstring[16]; wchar_t defstring[16]{ 0 };
wchar_t lvstring[16]; wchar_t lvstring[16]{ 0 };
wchar_t linkstring[16]; wchar_t linkstring[16]{ 0 };
wchar_t lscstring[16]; wchar_t lscstring[16]{ 0 };
wchar_t rscstring[16]; wchar_t rscstring[16]{ 0 };
ClientCard(); ClientCard();
void SetCode(int code); void SetCode(int code);
void UpdateInfo(unsigned char* buf); void UpdateInfo(unsigned char* buf);
void ClearTarget(); void ClearTarget();
void ClearData();
static bool client_card_sort(ClientCard* c1, ClientCard* c2); static bool client_card_sort(ClientCard* c1, ClientCard* c2);
static bool deck_sort_lv(code_pointer l1, code_pointer l2); static bool deck_sort_lv(code_pointer l1, code_pointer l2);
static bool deck_sort_atk(code_pointer l1, code_pointer l2); static bool deck_sort_atk(code_pointer l1, code_pointer l2);
......
...@@ -305,8 +305,9 @@ ClientCard* ClientField::RemoveCard(int controler, int location, int sequence) { ...@@ -305,8 +305,9 @@ ClientCard* ClientField::RemoveCard(int controler, int location, int sequence) {
} }
void ClientField::UpdateCard(int controler, int location, int sequence, unsigned char* data) { void ClientField::UpdateCard(int controler, int location, int sequence, unsigned char* data) {
ClientCard* pcard = GetCard(controler, location, sequence); ClientCard* pcard = GetCard(controler, location, sequence);
if(pcard) int len = BufferIO::ReadInt32(data);
pcard->UpdateInfo(data + 4); if (pcard && len > LEN_HEADER)
pcard->UpdateInfo(data);
} }
void ClientField::UpdateFieldCard(int controler, int location, unsigned char* data) { void ClientField::UpdateFieldCard(int controler, int location, unsigned char* data) {
std::vector<ClientCard*>* lst = 0; std::vector<ClientCard*>* lst = 0;
...@@ -338,7 +339,7 @@ void ClientField::UpdateFieldCard(int controler, int location, unsigned char* da ...@@ -338,7 +339,7 @@ void ClientField::UpdateFieldCard(int controler, int location, unsigned char* da
int len; int len;
for(auto cit = lst->begin(); cit != lst->end(); ++cit) { for(auto cit = lst->begin(); cit != lst->end(); ++cit) {
len = BufferIO::ReadInt32(data); len = BufferIO::ReadInt32(data);
if(len > 8) if(len > LEN_HEADER)
(*cit)->UpdateInfo(data); (*cit)->UpdateInfo(data);
data += len - 4; data += len - 4;
} }
......
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