Commit cf3e824f authored by VanillaSalt's avatar VanillaSalt

fix

parent 0ac58aca
......@@ -1012,9 +1012,11 @@ void card::create_relation(card* target, uint32 reset) {
relations[target] = reset;
}
void card::create_relation(effect* peffect) {
if (relate_effect.find(peffect) != relate_effect.end())
return;
relate_effect.insert(peffect);
auto it = relate_effect.find(peffect);
if (it != relate_effect.end())
++it->second;
else
relate_effect[peffect] = 1;
}
int32 card::is_has_relation(card* target) {
if (relations.find(target) != relations.end())
......@@ -1032,9 +1034,9 @@ void card::release_relation(card* target) {
relations.erase(target);
}
void card::release_relation(effect* peffect) {
if (relate_effect.find(peffect) == relate_effect.end())
return;
relate_effect.erase(peffect);
auto it = relate_effect.find(peffect);
if (it != relate_effect.end() && --it->second == 0)
relate_effect.erase(it);
}
int32 card::leave_field_redirect(uint32 reason) {
effect_set es;
......
......@@ -73,7 +73,7 @@ public:
typedef std::multimap<uint32, effect*> effect_container;
typedef std::set<card*, card_sort> card_set;
typedef std::map<effect*, effect_container::iterator> effect_indexer;
typedef std::set<effect*> effect_relation;
typedef std::map<effect*, uint32> effect_relation;
typedef std::map<card*, uint32> relation_map;
typedef std::map<uint16, uint16> counter_map;
typedef std::map<uint16, card*> attacker_map;
......
......@@ -912,7 +912,7 @@ int32 scriptlib::card_release_effect_relation(lua_State *L) {
check_param(L, PARAM_TYPE_EFFECT, 2);
card* pcard = *(card**) lua_touserdata(L, 1);
effect* peffect = *(effect**) lua_touserdata(L, 2);
pcard->relate_effect.erase(peffect);
pcard->release_relation(peffect);
return 0;
}
int32 scriptlib::card_clear_effect_relation(lua_State *L) {
......
......@@ -2855,10 +2855,10 @@ int32 scriptlib::duel_check_chain_uniqueness(lua_State *L) {
lua_pushboolean(L, 1);
return 1;
}
card::effect_relation er;
std::set<uint32> er;
field::chain_array::iterator cait;
for(cait = pduel->game_field->core.current_chain.begin(); cait != pduel->game_field->core.current_chain.end(); ++cait)
er.insert((effect*)(size_t)(cait->triggering_effect->handler->get_code()));
er.insert(cait->triggering_effect->handler->get_code());
if(er.size() == pduel->game_field->core.current_chain.size())
lua_pushboolean(L, 1);
else
......
......@@ -453,10 +453,10 @@ int32 scriptlib::group_get_class_count(lua_State *L) {
group* pgroup = *(group**) lua_touserdata(L, 1);
duel* pduel = pgroup->pduel;
int32 extraargs = lua_gettop(L) - 2;
card::effect_relation er;
std::set<uint32> er;
field::card_set::iterator cit = pgroup->container.begin();
for(; cit != pgroup->container.end(); ++cit) {
er.insert((effect*)(size_t)pduel->lua->get_operation_value(*cit, 2, extraargs));
er.insert(pduel->lua->get_operation_value(*cit, 2, extraargs));
}
lua_pushinteger(L, er.size());
return 1;
......
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