"...svn:/svn.code.sf.net/p/irrlicht/code/trunk@2521" did not exist on "7e5822ec2c7d246d82039789274a55274ba97b2b"
Commit 9453e29a authored by wind2009's avatar wind2009

Merge remote-tracking branch 'upstream/master' into 888

parents 5259a00a 60c3c4f0
Pipeline #42604 passed with stages
in 3 minutes and 45 seconds
...@@ -22,7 +22,7 @@ inline void buffer_write_block(unsigned char*& p, const void* src, size_t size) ...@@ -22,7 +22,7 @@ inline void buffer_write_block(unsigned char*& p, const void* src, size_t size)
p += size; p += size;
} }
template<typename T> template<typename T>
inline void buffer_write(unsigned char*& p, T value) { inline void buffer_write(unsigned char*& p, const T& value) {
std::memcpy(p, &value, sizeof(T)); std::memcpy(p, &value, sizeof(T));
p += sizeof(T); p += sizeof(T);
} }
...@@ -30,10 +30,10 @@ inline void buffer_write(unsigned char*& p, T value) { ...@@ -30,10 +30,10 @@ inline void buffer_write(unsigned char*& p, T value) {
inline void vector_write_block(std::vector<unsigned char>& buffer, const void* src, size_t size) { inline void vector_write_block(std::vector<unsigned char>& buffer, const void* src, size_t size) {
const auto len = buffer.size(); const auto len = buffer.size();
buffer.resize(len + size); buffer.resize(len + size);
std::memcpy(&buffer[len], src, size); std::memcpy(buffer.data() + len, src, size);
} }
template<typename T> template<typename T>
inline void vector_write(std::vector<unsigned char>& buffer, T value) { inline void vector_write(std::vector<unsigned char>& buffer, const T& value) {
vector_write_block(buffer, &value, sizeof(T)); vector_write_block(buffer, &value, sizeof(T));
} }
......
...@@ -44,7 +44,7 @@ int32_t scriptlib::get_effect_property(lua_State* L, effect_member type) { ...@@ -44,7 +44,7 @@ int32_t scriptlib::get_effect_property(lua_State* L, effect_member type) {
if (peffect) { if (peffect) {
switch (type) { switch (type) {
case MEMBER_CATEGORY: case MEMBER_CATEGORY:
value = peffect->category; value = (lua_Integer)peffect->category;
break; break;
case MEMBER_CODE: case MEMBER_CODE:
value = peffect->code; value = peffect->code;
...@@ -295,7 +295,7 @@ int32_t scriptlib::effect_set_category(lua_State *L) { ...@@ -295,7 +295,7 @@ int32_t scriptlib::effect_set_category(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32_t v = (uint32_t)lua_tointeger(L, 2); uint64_t v = (uint64_t)lua_tointeger(L, 2);
peffect->category = v; peffect->category = v;
return 0; return 0;
} }
......
...@@ -59,9 +59,9 @@ public: ...@@ -59,9 +59,9 @@ public:
return l + (int)(x % range); return l + (int)(x % range);
} }
#pragma warning(disable:4146)
// N % k = (N - k) % k = (-k) % k // N % k = (N - k) % k = (-k) % k
// discard (N % range) numbers from the left end so that it is a multiple of range // discard (N % range) numbers from the left end so that it is a multiple of range
#pragma warning(disable:4146)
int get_random_integer_v2(int l, int h) { int get_random_integer_v2(int l, int h) {
uint32_t range = (h - l + 1); uint32_t range = (h - l + 1);
uint32_t bound = -range % range; uint32_t bound = -range % range;
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
// Fisher-Yates shuffle [first, last) // Fisher-Yates shuffle [first, last)
template<typename T> template<typename T>
void shuffle_vector(std::vector<T>& v, int first = 0, int last = INT32_MAX, int version = 2) { void shuffle_vector(std::vector<T>& v, int first, int last, int version) {
if ((size_t)last > v.size()) if ((size_t)last > v.size())
last = (int)v.size(); last = (int)v.size();
auto distribution = &mtrandom::get_random_integer_v2; auto distribution = &mtrandom::get_random_integer_v2;
...@@ -87,6 +87,16 @@ public: ...@@ -87,6 +87,16 @@ public:
} }
} }
template<typename T>
void shuffle_vector(std::vector<T>& v) {
shuffle_vector(v, 0, (int)v.size(), 2);
}
template<typename T>
void shuffle_vector(std::vector<T>& v, int first, int last) {
shuffle_vector(v, first, last, 2);
}
private: private:
std::mt19937 rng; std::mt19937 rng;
}; };
......
...@@ -3658,7 +3658,7 @@ int32_t field::destroy(uint16_t step, group * targets, effect * reason_effect, u ...@@ -3658,7 +3658,7 @@ int32_t field::destroy(uint16_t step, group * targets, effect * reason_effect, u
core.hint_timing[pcard->current.controler] |= TIMING_DESTROY; core.hint_timing[pcard->current.controler] |= TIMING_DESTROY;
raise_single_event(pcard, 0, EVENT_DESTROY, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_DESTROY, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
} }
adjust_instant(); adjust_disable_check_list();
process_single_event(); process_single_event();
raise_event(targets->container, EVENT_DESTROY, reason_effect, reason, reason_player, 0, 0); raise_event(targets->container, EVENT_DESTROY, reason_effect, reason, reason_player, 0, 0);
process_instant_event(); process_instant_event();
...@@ -3693,6 +3693,7 @@ int32_t field::destroy(uint16_t step, group * targets, effect * reason_effect, u ...@@ -3693,6 +3693,7 @@ int32_t field::destroy(uint16_t step, group * targets, effect * reason_effect, u
} }
returns.ivalue[0] = (int32_t)core.operated_set.size(); returns.ivalue[0] = (int32_t)core.operated_set.size();
pduel->delete_group(targets); pduel->delete_group(targets);
adjust_self_destroy_set();
return TRUE; return TRUE;
} }
case 10: { case 10: {
......
...@@ -3933,6 +3933,9 @@ int32_t field::process_turn(uint16_t step, uint8_t turn_player) { ...@@ -3933,6 +3933,9 @@ int32_t field::process_turn(uint16_t step, uint8_t turn_player) {
} }
return FALSE; return FALSE;
} }
// ensure "entered 2nd Battle Phase" marker stored in `arg2` do not carry over into Main Phase 2.
core.units.begin()->arg2 = 0;
core.skip_m2 = FALSE; core.skip_m2 = FALSE;
if(returns.ivalue[0] == 3) { // End Phase if(returns.ivalue[0] == 3) { // End Phase
core.skip_m2 = TRUE; core.skip_m2 = TRUE;
......
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