Commit 925d2528 authored by DailyShana's avatar DailyShana

verify parameters of Duel.AnnounceCard

parent fefb0c47
...@@ -3634,6 +3634,34 @@ int32 scriptlib::duel_announce_card(lua_State * L) { ...@@ -3634,6 +3634,34 @@ int32 scriptlib::duel_announce_card(lua_State * L) {
for(int32 i = 2; i <= lua_gettop(L); ++i) for(int32 i = 2; i <= lua_gettop(L); ++i)
pduel->game_field->core.select_options.push_back((uint32)lua_tointeger(L, i)); pduel->game_field->core.select_options.push_back((uint32)lua_tointeger(L, i));
} }
int32 stack_size = 0;
for(auto& it : pduel->game_field->core.select_options) {
switch(it) {
case OPCODE_ADD:
case OPCODE_SUB:
case OPCODE_MUL:
case OPCODE_DIV:
case OPCODE_AND:
case OPCODE_OR:
stack_size -= 1;
break;
case OPCODE_NEG:
case OPCODE_NOT:
case OPCODE_ISCODE:
case OPCODE_ISSETCARD:
case OPCODE_ISTYPE:
case OPCODE_ISRACE:
case OPCODE_ISATTRIBUTE:
break;
default:
stack_size += 1;
break;
}
if(stack_size <= 0)
break;
}
if(stack_size != 1)
return luaL_error(L, "Parameters are invalid.");
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_CARD, 0, 0, 0, playerid, 0); pduel->game_field->add_process(PROCESSOR_ANNOUNCE_CARD, 0, 0, 0, playerid, 0);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) { return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx; duel* pduel = (duel*)ctx;
......
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