Commit 6c545feb authored by salix5's avatar salix5

remove memset

parent 8657c2f2
...@@ -19,6 +19,20 @@ bool card_sort::operator()(void* const & p1, void* const & p2) const { ...@@ -19,6 +19,20 @@ bool card_sort::operator()(void* const & p1, void* const & p2) const {
card* c2 = (card*)p2; card* c2 = (card*)p2;
return c1->cardid < c2->cardid; return c1->cardid < c2->cardid;
} }
void card_data::clear() {
code = 0;
alias = 0;
setcode = 0;
type = 0;
level = 0;
attribute = 0;
race = 0;
attack = 0;
defense = 0;
lscale = 0;
rscale = 0;
link_marker = 0;
}
bool card_state::is_location(int32 loc) const { bool card_state::is_location(int32 loc) const {
if((loc & LOCATION_FZONE) && location == LOCATION_SZONE && sequence == 5) if((loc & LOCATION_FZONE) && location == LOCATION_SZONE && sequence == 5)
return true; return true;
...@@ -50,6 +64,25 @@ void card_state::init_state() { ...@@ -50,6 +64,25 @@ void card_state::init_state() {
reason = 0xffffffff; reason = 0xffffffff;
reason_player = 0xff; reason_player = 0xff;
} }
void query_cache::clear_cache() {
info_location = UINT32_MAX;
current_code = UINT32_MAX;
type = UINT32_MAX;
level = UINT32_MAX;
rank = UINT32_MAX;
link = UINT32_MAX;
attribute = UINT32_MAX;
race = UINT32_MAX;
attack = -1;
defense = -1;
base_attack = -1;
base_defense = -1;
reason = UINT32_MAX;
status = UINT32_MAX;
lscale = UINT32_MAX;
rscale = UINT32_MAX;
link_marker = UINT32_MAX;
}
bool card::card_operation_sort(card* c1, card* c2) { bool card::card_operation_sort(card* c1, card* c2) {
duel* pduel = c1->pduel; duel* pduel = c1->pduel;
int32 cp1 = c1->overlay_target ? c1->overlay_target->current.controler : c1->current.controler; int32 cp1 = c1->overlay_target ? c1->overlay_target->current.controler : c1->current.controler;
...@@ -89,9 +122,6 @@ uint32 card::attacker_map::findcard(card* pcard) { ...@@ -89,9 +122,6 @@ uint32 card::attacker_map::findcard(card* pcard) {
else else
return it->second.second; return it->second.second;
} }
void card_data::clear() {
std::memset(this, 0, sizeof(card_data));
}
card::card(duel* pd) { card::card(duel* pd) {
ref_handle = 0; ref_handle = 0;
pduel = pd; pduel = pd;
...@@ -105,7 +135,6 @@ card::card(duel* pd) { ...@@ -105,7 +135,6 @@ card::card(duel* pd) {
direct_attackable = 0; direct_attackable = 0;
summon_info = 0; summon_info = 0;
status = 0; status = 0;
std::memset(&q_cache, 0xff, sizeof(query_cache));
equiping_target = 0; equiping_target = 0;
pre_equip_target = 0; pre_equip_target = 0;
overlay_target = 0; overlay_target = 0;
...@@ -152,7 +181,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) { ...@@ -152,7 +181,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
*p = tdata; *p = tdata;
++p; ++p;
if (q_cache.info_location != tdata) { if (q_cache.info_location != tdata) {
std::memset(&q_cache, 0xff, sizeof(query_cache)); q_cache.clear_cache();
q_cache.info_location = tdata; q_cache.info_location = tdata;
use_cache = 0; use_cache = 0;
} }
......
...@@ -76,23 +76,25 @@ struct card_state { ...@@ -76,23 +76,25 @@ struct card_state {
}; };
struct query_cache { struct query_cache {
uint32 info_location; uint32 info_location{ UINT32_MAX };
uint32 current_code; uint32 current_code{ UINT32_MAX };
uint32 type; uint32 type{ UINT32_MAX };
uint32 level; uint32 level{ UINT32_MAX };
uint32 rank; uint32 rank{ UINT32_MAX };
uint32 link; uint32 link{ UINT32_MAX };
uint32 attribute; uint32 attribute{ UINT32_MAX };
uint32 race; uint32 race{ UINT32_MAX };
int32 attack; int32 attack{ -1 };
int32 defense; int32 defense{ -1 };
int32 base_attack; int32 base_attack{ -1 };
int32 base_defense; int32 base_defense{ -1 };
uint32 reason; uint32 reason{ UINT32_MAX };
int32 status; uint32 status{ UINT32_MAX };
uint32 lscale; uint32 lscale{ UINT32_MAX };
uint32 rscale; uint32 rscale{ UINT32_MAX };
uint32 link_marker; uint32 link_marker{ UINT32_MAX };
void clear_cache();
}; };
struct material_info { struct material_info {
......
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