Commit 5a392f8b authored by nanahira's avatar nanahira

Revert "update scriptlib::check_param"

This reverts commit 9a8ac816.
parent 2ca88956
......@@ -64,6 +64,7 @@ void card_data::clear() {
std::memset(this, 0, sizeof(card_data));
}
card::card(duel* pd) {
scrtype = 1;
ref_handle = 0;
pduel = pd;
owner = PLAYER_NONE;
......
......@@ -124,6 +124,7 @@ public:
uint8 location;
uint8 sequence;
};
int32 scrtype;
int32 ref_handle;
duel* pduel;
card_data data;
......
......@@ -15,6 +15,7 @@ bool effect_sort_id(const effect* e1, const effect* e2) {
return e1->id < e2->id;
};
effect::effect(duel* pd) {
scrtype = 3;
ref_handle = 0;
pduel = pd;
owner = 0;
......
......@@ -27,6 +27,7 @@ enum effect_flag2 : uint32;
class effect {
public:
int32 scrtype;
int32 ref_handle;
duel* pduel;
card* owner;
......
......@@ -10,17 +10,20 @@
#include "duel.h"
group::group(duel* pd) {
scrtype = 2;
ref_handle = 0;
pduel = pd;
is_readonly = FALSE;
}
group::group(duel* pd, card* pcard) {
container.insert(pcard);
scrtype = 2;
ref_handle = 0;
pduel = pd;
is_readonly = FALSE;
}
group::group(duel* pd, const card_set& cset): container(cset) {
scrtype = 2;
ref_handle = 0;
pduel = pd;
is_readonly = FALSE;
......
......@@ -18,6 +18,7 @@ class duel;
class group {
public:
typedef std::set<card*, card_sort> card_set;
int32 scrtype;
int32 ref_handle;
duel* pduel;
card_set container;
......
......@@ -7,64 +7,54 @@
#include "scriptlib.h"
#include "duel.h"
int32 scriptlib::check_data_type(lua_State* L, int32 index, const char* tname) {
int32 result = FALSE;
if(lua_getmetatable(L, index)) {
lua_getglobal(L, tname);
if(lua_rawequal(L, -1, -2))
result = TRUE;
lua_pop(L, 2);
}
return result;
}
int32 scriptlib::check_param(lua_State* L, int32 param_type, int32 index, int32 retfalse) {
int32 result;
switch (param_type) {
case PARAM_TYPE_CARD: {
int32 result = FALSE;
if(lua_isuserdata(L, index) && lua_getmetatable(L, index)) {
result = check_data_type(L, -1, "Card");
lua_pop(L, 1);
case PARAM_TYPE_CARD:
if (lua_isuserdata(L, index)) {
result = **(int32**)lua_touserdata(L, index);
if(result == 1)
return TRUE;
}
if(result)
return TRUE;
if(retfalse)
return FALSE;
luaL_error(L, "Parameter %d should be \"Card\".", index);
break;
}
case PARAM_TYPE_GROUP: {
if(lua_isuserdata(L, index) && check_data_type(L, index, "Group"))
return TRUE;
case PARAM_TYPE_GROUP:
if (lua_isuserdata(L, index)) {
result = **(int32**)lua_touserdata(L, index);
if(result == 2)
return TRUE;
}
if(retfalse)
return FALSE;
luaL_error(L, "Parameter %d should be \"Group\".", index);
break;
}
case PARAM_TYPE_EFFECT: {
if(lua_isuserdata(L, index) && check_data_type(L, index, "Effect"))
return TRUE;
case PARAM_TYPE_EFFECT:
if (lua_isuserdata(L, index)) {
result = **(int32**)lua_touserdata(L, index);
if(result == 3)
return TRUE;
}
if(retfalse)
return FALSE;
luaL_error(L, "Parameter %d should be \"Effect\".", index);
break;
}
case PARAM_TYPE_FUNCTION: {
if(lua_isfunction(L, index))
case PARAM_TYPE_FUNCTION:
if (lua_isfunction(L, index))
return TRUE;
if(retfalse)
return FALSE;
luaL_error(L, "Parameter %d should be \"Function\".", index);
break;
}
case PARAM_TYPE_STRING: {
if(lua_isstring(L, index))
case PARAM_TYPE_STRING:
if (lua_isstring(L, index))
return TRUE;
if(retfalse)
return FALSE;
luaL_error(L, "Parameter %d should be \"String\".", index);
break;
}
}
return FALSE;
}
......
......@@ -13,7 +13,6 @@
class scriptlib {
public:
static int32 check_data_type(lua_State* L, int32 index, const char* tname);
static int32 check_param(lua_State* L, int32 param_type, int32 index, BOOL retfalse = FALSE);
static int32 check_param_count(lua_State* L, int32 count);
static int32 check_action_permission(lua_State* L);
......
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