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

clear data while face-down

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