Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-core
Commits
f53d0bab
Commit
f53d0bab
authored
Aug 12, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
2pick merge
parents
c34b37e9
fbaebd66
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
96 additions
and
79 deletions
+96
-79
card.cpp
card.cpp
+0
-1
card.h
card.h
+0
-1
duel.cpp
duel.cpp
+3
-3
effect.cpp
effect.cpp
+3
-1
effect.h
effect.h
+2
-2
field.cpp
field.cpp
+1
-1
group.cpp
group.cpp
+0
-3
group.h
group.h
+0
-1
interpreter.cpp
interpreter.cpp
+23
-32
interpreter.h
interpreter.h
+1
-0
libduel.cpp
libduel.cpp
+10
-0
libeffect.cpp
libeffect.cpp
+19
-12
scriptlib.cpp
scriptlib.cpp
+32
-22
scriptlib.h
scriptlib.h
+2
-0
No files found.
card.cpp
View file @
f53d0bab
...
@@ -109,7 +109,6 @@ void card_data::clear() {
...
@@ -109,7 +109,6 @@ void card_data::clear() {
std
::
memset
(
this
,
0
,
sizeof
(
card_data
));
std
::
memset
(
this
,
0
,
sizeof
(
card_data
));
}
}
card
::
card
(
duel
*
pd
)
{
card
::
card
(
duel
*
pd
)
{
scrtype
=
1
;
ref_handle
=
0
;
ref_handle
=
0
;
pduel
=
pd
;
pduel
=
pd
;
owner
=
PLAYER_NONE
;
owner
=
PLAYER_NONE
;
...
...
card.h
View file @
f53d0bab
...
@@ -131,7 +131,6 @@ public:
...
@@ -131,7 +131,6 @@ public:
uint8
location
;
uint8
location
;
uint8
sequence
;
uint8
sequence
;
};
};
int32
scrtype
;
int32
ref_handle
;
int32
ref_handle
;
duel
*
pduel
;
duel
*
pduel
;
card_data
data
;
card_data
data
;
...
...
duel.cpp
View file @
f53d0bab
...
@@ -120,17 +120,17 @@ void duel::restore_assumes() {
...
@@ -120,17 +120,17 @@ void duel::restore_assumes() {
assumes
.
clear
();
assumes
.
clear
();
}
}
void
duel
::
write_buffer32
(
uint32
value
)
{
void
duel
::
write_buffer32
(
uint32
value
)
{
*
((
uint32
*
)
bufferp
)
=
value
;
std
::
memcpy
(
bufferp
,
&
value
,
sizeof
(
value
))
;
bufferp
+=
4
;
bufferp
+=
4
;
bufferlen
+=
4
;
bufferlen
+=
4
;
}
}
void
duel
::
write_buffer16
(
uint16
value
)
{
void
duel
::
write_buffer16
(
uint16
value
)
{
*
((
uint16
*
)
bufferp
)
=
value
;
std
::
memcpy
(
bufferp
,
&
value
,
sizeof
(
value
))
;
bufferp
+=
2
;
bufferp
+=
2
;
bufferlen
+=
2
;
bufferlen
+=
2
;
}
}
void
duel
::
write_buffer8
(
uint8
value
)
{
void
duel
::
write_buffer8
(
uint8
value
)
{
*
((
uint8
*
)
bufferp
)
=
value
;
std
::
memcpy
(
bufferp
,
&
value
,
sizeof
(
value
))
;
bufferp
+=
1
;
bufferp
+=
1
;
bufferlen
+=
1
;
bufferlen
+=
1
;
}
}
...
...
effect.cpp
View file @
f53d0bab
...
@@ -15,7 +15,6 @@ bool effect_sort_id(const effect* e1, const effect* e2) {
...
@@ -15,7 +15,6 @@ bool effect_sort_id(const effect* e1, const effect* e2) {
return
e1
->
id
<
e2
->
id
;
return
e1
->
id
<
e2
->
id
;
};
};
effect
::
effect
(
duel
*
pd
)
{
effect
::
effect
(
duel
*
pd
)
{
scrtype
=
3
;
ref_handle
=
0
;
ref_handle
=
0
;
pduel
=
pd
;
pduel
=
pd
;
owner
=
0
;
owner
=
0
;
...
@@ -676,6 +675,9 @@ int32 effect::check_value_condition(uint32 extraargs) {
...
@@ -676,6 +675,9 @@ int32 effect::check_value_condition(uint32 extraargs) {
return
(
int32
)
value
;
return
(
int32
)
value
;
}
}
}
}
void
*
effect
::
get_label_object
()
{
return
pduel
->
lua
->
get_ref_object
(
label_object
);
}
int32
effect
::
get_speed
()
{
int32
effect
::
get_speed
()
{
if
(
!
(
type
&
EFFECT_TYPE_ACTIONS
))
if
(
!
(
type
&
EFFECT_TYPE_ACTIONS
))
return
0
;
return
0
;
...
...
effect.h
View file @
f53d0bab
...
@@ -27,7 +27,6 @@ enum effect_flag2 : uint32;
...
@@ -27,7 +27,6 @@ enum effect_flag2 : uint32;
class
effect
{
class
effect
{
public:
public:
int32
scrtype
;
int32
ref_handle
;
int32
ref_handle
;
duel
*
pduel
;
duel
*
pduel
;
card
*
owner
;
card
*
owner
;
...
@@ -56,7 +55,7 @@ public:
...
@@ -56,7 +55,7 @@ public:
card
*
active_handler
;
card
*
active_handler
;
uint16
status
;
uint16
status
;
uint32
label
;
uint32
label
;
void
*
label_object
;
int32
label_object
;
int32
condition
;
int32
condition
;
int32
cost
;
int32
cost
;
int32
target
;
int32
target
;
...
@@ -91,6 +90,7 @@ public:
...
@@ -91,6 +90,7 @@ public:
void
get_value
(
card
*
pcard
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
card
*
pcard
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
effect
*
peffect
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
effect
*
peffect
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
int32
check_value_condition
(
uint32
extraargs
=
0
);
int32
check_value_condition
(
uint32
extraargs
=
0
);
void
*
get_label_object
();
int32
get_speed
();
int32
get_speed
();
effect
*
clone
();
effect
*
clone
();
card
*
get_owner
()
const
;
card
*
get_owner
()
const
;
...
...
field.cpp
View file @
f53d0bab
...
@@ -2028,7 +2028,7 @@ int32 field::adjust_grant_effect() {
...
@@ -2028,7 +2028,7 @@ int32 field::adjust_grant_effect() {
}
}
for
(
auto
cit
=
add_set
.
begin
();
cit
!=
add_set
.
end
();
++
cit
)
{
for
(
auto
cit
=
add_set
.
begin
();
cit
!=
add_set
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
card
*
pcard
=
*
cit
;
effect
*
geffect
=
(
effect
*
)
peffect
->
label_object
;
effect
*
geffect
=
(
effect
*
)
peffect
->
get_label_object
()
;
effect
*
ceffect
=
geffect
->
clone
();
effect
*
ceffect
=
geffect
->
clone
();
ceffect
->
owner
=
pcard
;
ceffect
->
owner
=
pcard
;
pcard
->
add_effect
(
ceffect
);
pcard
->
add_effect
(
ceffect
);
...
...
group.cpp
View file @
f53d0bab
...
@@ -10,20 +10,17 @@
...
@@ -10,20 +10,17 @@
#include "duel.h"
#include "duel.h"
group
::
group
(
duel
*
pd
)
{
group
::
group
(
duel
*
pd
)
{
scrtype
=
2
;
ref_handle
=
0
;
ref_handle
=
0
;
pduel
=
pd
;
pduel
=
pd
;
is_readonly
=
FALSE
;
is_readonly
=
FALSE
;
}
}
group
::
group
(
duel
*
pd
,
card
*
pcard
)
{
group
::
group
(
duel
*
pd
,
card
*
pcard
)
{
container
.
insert
(
pcard
);
container
.
insert
(
pcard
);
scrtype
=
2
;
ref_handle
=
0
;
ref_handle
=
0
;
pduel
=
pd
;
pduel
=
pd
;
is_readonly
=
FALSE
;
is_readonly
=
FALSE
;
}
}
group
::
group
(
duel
*
pd
,
const
card_set
&
cset
)
:
container
(
cset
)
{
group
::
group
(
duel
*
pd
,
const
card_set
&
cset
)
:
container
(
cset
)
{
scrtype
=
2
;
ref_handle
=
0
;
ref_handle
=
0
;
pduel
=
pd
;
pduel
=
pd
;
is_readonly
=
FALSE
;
is_readonly
=
FALSE
;
...
...
group.h
View file @
f53d0bab
...
@@ -18,7 +18,6 @@ class duel;
...
@@ -18,7 +18,6 @@ class duel;
class
group
{
class
group
{
public:
public:
typedef
std
::
set
<
card
*
,
card_sort
>
card_set
;
typedef
std
::
set
<
card
*
,
card_sort
>
card_set
;
int32
scrtype
;
int32
ref_handle
;
int32
ref_handle
;
duel
*
pduel
;
duel
*
pduel
;
card_set
container
;
card_set
container
;
...
...
interpreter.cpp
View file @
f53d0bab
...
@@ -398,6 +398,7 @@ static const struct luaL_Reg duellib[] = {
...
@@ -398,6 +398,7 @@ static const struct luaL_Reg duellib[] = {
{
"MoveTurnCount"
,
scriptlib
::
duel_move_turn_count
},
{
"MoveTurnCount"
,
scriptlib
::
duel_move_turn_count
},
{
"GetCardsInZone"
,
scriptlib
::
duel_get_cards_in_zone
},
{
"GetCardsInZone"
,
scriptlib
::
duel_get_cards_in_zone
},
{
"XyzSummonByRose"
,
scriptlib
::
duel_xyz_summon_by_rose
},
{
"XyzSummonByRose"
,
scriptlib
::
duel_xyz_summon_by_rose
},
{
"LoadScript"
,
scriptlib
::
duel_load_script
},
{
"EnableGlobalFlag"
,
scriptlib
::
duel_enable_global_flag
},
{
"EnableGlobalFlag"
,
scriptlib
::
duel_enable_global_flag
},
{
"GetLP"
,
scriptlib
::
duel_get_lp
},
{
"GetLP"
,
scriptlib
::
duel_get_lp
},
...
@@ -669,7 +670,7 @@ interpreter::interpreter(duel* pd): coroutines(256) {
...
@@ -669,7 +670,7 @@ interpreter::interpreter(duel* pd): coroutines(256) {
//extra scripts
//extra scripts
load_script
((
char
*
)
"./script/constant.lua"
);
load_script
((
char
*
)
"./script/constant.lua"
);
load_script
((
char
*
)
"./script/utility.lua"
);
load_script
((
char
*
)
"./script/utility.lua"
);
load_script
((
char
*
)
"./s
pecials
/special.lua"
);
load_script
((
char
*
)
"./s
cript
/special.lua"
);
//load kpro constant
//load kpro constant
//card data constants
//card data constants
lua_pushinteger
(
lua_state
,
CARDDATA_CODE
);
lua_pushinteger
(
lua_state
,
CARDDATA_CODE
);
...
@@ -739,26 +740,18 @@ interpreter::interpreter(duel* pd): coroutines(256) {
...
@@ -739,26 +740,18 @@ interpreter::interpreter(duel* pd): coroutines(256) {
lua_setglobal
(
lua_state
,
"_WIN32"
);
lua_setglobal
(
lua_state
,
"_WIN32"
);
#endif
#endif
//load init.lua by MLD
//load init.lua by MLD
load_script
((
char
*
)
"./
expansions/
script/init.lua"
);
load_script
((
char
*
)
"./script/init.lua"
);
//nef
//nef
if
(
!
load_script
((
char
*
)
"./expansions/script/nef/afi.lua"
))
load_script
((
char
*
)
"./script/nef/afi.lua"
);
load_script
((
char
*
)
"./script/nef/afi.lua"
);
load_script
((
char
*
)
"./script/nef/cardList.lua"
);
if
(
!
load_script
((
char
*
)
"./expansions/script/nef/cardList.lua"
))
load_script
((
char
*
)
"./script/nef/nef.lua"
);
load_script
((
char
*
)
"./script/nef/cardList.lua"
);
load_script
((
char
*
)
"./script/nef/elf.lua"
);
if
(
!
load_script
((
char
*
)
"./expansions/script/nef/nef.lua"
))
load_script
((
char
*
)
"./script/nef/ets.lua"
);
load_script
((
char
*
)
"./script/nef/nef.lua"
);
load_script
((
char
*
)
"./script/nef/fus.lua"
);
if
(
!
load_script
((
char
*
)
"./expansions/script/nef/elf.lua"
))
load_script
((
char
*
)
"./script/nef/msc.lua"
);
load_script
((
char
*
)
"./script/nef/elf.lua"
);
load_script
((
char
*
)
"./script/nef/uds.lua"
);
if
(
!
load_script
((
char
*
)
"./expansions/script/nef/ets.lua"
))
load_script
((
char
*
)
"./script/nef/ets.lua"
);
if
(
!
load_script
((
char
*
)
"./expansions/script/nef/fus.lua"
))
load_script
((
char
*
)
"./script/nef/fus.lua"
);
if
(
!
load_script
((
char
*
)
"./expansions/script/nef/msc.lua"
))
load_script
((
char
*
)
"./script/nef/msc.lua"
);
if
(
!
load_script
((
char
*
)
"./expansions/script/nef/uds.lua"
))
load_script
((
char
*
)
"./script/nef/uds.lua"
);
//2pick rule
//2pick rule
load_script
((
char
*
)
"./
2pick
/pick.lua"
);
load_script
((
char
*
)
"./
script
/pick.lua"
);
}
}
interpreter
::~
interpreter
()
{
interpreter
::~
interpreter
()
{
lua_close
(
lua_state
);
lua_close
(
lua_state
);
...
@@ -871,19 +864,9 @@ int32 interpreter::load_card_script(uint32 code) {
...
@@ -871,19 +864,9 @@ int32 interpreter::load_card_script(uint32 code) {
lua_pushstring
(
current_state
,
"__index"
);
lua_pushstring
(
current_state
,
"__index"
);
lua_pushvalue
(
current_state
,
-
2
);
lua_pushvalue
(
current_state
,
-
2
);
lua_rawset
(
current_state
,
-
3
);
lua_rawset
(
current_state
,
-
3
);
//load special and extra scripts first
sprintf
(
script_name
,
"./script/c%d.lua"
,
code
);
sprintf
(
script_name
,
"./specials/c%d.lua"
,
code
);
if
(
!
load_script
(
script_name
))
{
if
(
!
load_script
(
script_name
))
{
return
OPERATION_FAIL
;
sprintf
(
script_name
,
"./beta/script/c%d.lua"
,
code
);
if
(
!
load_script
(
script_name
))
{
sprintf
(
script_name
,
"./expansions/script/c%d.lua"
,
code
);
if
(
!
load_script
(
script_name
))
{
sprintf
(
script_name
,
"./script/c%d.lua"
,
code
);
if
(
!
load_script
(
script_name
))
{
return
OPERATION_FAIL
;
}
}
}
}
}
}
}
return
OPERATION_SUCCESS
;
return
OPERATION_SUCCESS
;
...
@@ -1319,6 +1302,14 @@ int32 interpreter::clone_function_ref(int32 func_ref) {
...
@@ -1319,6 +1302,14 @@ int32 interpreter::clone_function_ref(int32 func_ref) {
int32
ref
=
luaL_ref
(
current_state
,
LUA_REGISTRYINDEX
);
int32
ref
=
luaL_ref
(
current_state
,
LUA_REGISTRYINDEX
);
return
ref
;
return
ref
;
}
}
void
*
interpreter
::
get_ref_object
(
int32
ref_handler
)
{
if
(
ref_handler
==
0
)
return
nullptr
;
lua_rawgeti
(
current_state
,
LUA_REGISTRYINDEX
,
ref_handler
);
void
*
p
=
*
(
void
**
)
lua_touserdata
(
current_state
,
-
1
);
lua_pop
(
current_state
,
1
);
return
p
;
}
//Convert a pointer to a lua value, +1 -0
//Convert a pointer to a lua value, +1 -0
void
interpreter
::
card2value
(
lua_State
*
L
,
card
*
pcard
)
{
void
interpreter
::
card2value
(
lua_State
*
L
,
card
*
pcard
)
{
if
(
!
pcard
||
pcard
->
ref_handle
==
0
)
if
(
!
pcard
||
pcard
->
ref_handle
==
0
)
...
...
interpreter.h
View file @
f53d0bab
...
@@ -70,6 +70,7 @@ public:
...
@@ -70,6 +70,7 @@ public:
int32
get_function_value
(
int32
f
,
uint32
param_count
,
std
::
vector
<
int32
>*
result
);
int32
get_function_value
(
int32
f
,
uint32
param_count
,
std
::
vector
<
int32
>*
result
);
int32
call_coroutine
(
int32
f
,
uint32
param_count
,
uint32
*
yield_value
,
uint16
step
);
int32
call_coroutine
(
int32
f
,
uint32
param_count
,
uint32
*
yield_value
,
uint16
step
);
int32
clone_function_ref
(
int32
func_ref
);
int32
clone_function_ref
(
int32
func_ref
);
void
*
get_ref_object
(
int32
ref_handler
);
static
void
card2value
(
lua_State
*
L
,
card
*
pcard
);
static
void
card2value
(
lua_State
*
L
,
card
*
pcard
);
static
void
group2value
(
lua_State
*
L
,
group
*
pgroup
);
static
void
group2value
(
lua_State
*
L
,
group
*
pgroup
);
...
...
libduel.cpp
View file @
f53d0bab
...
@@ -248,6 +248,16 @@ int32 scriptlib::duel_xyz_summon_by_rose(lua_State *L) {
...
@@ -248,6 +248,16 @@ int32 scriptlib::duel_xyz_summon_by_rose(lua_State *L) {
pduel
->
game_field
->
special_summon_rule
(
playerid
,
pcard
,
SUMMON_TYPE_XYZ
);
pduel
->
game_field
->
special_summon_rule
(
playerid
,
pcard
,
SUMMON_TYPE_XYZ
);
return
lua_yield
(
L
,
0
);
return
lua_yield
(
L
,
0
);
}
}
int32
scriptlib
::
duel_load_script
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_STRING
,
1
);
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
const
char
*
pstr
=
lua_tostring
(
L
,
1
);
char
filename
[
64
];
sprintf
(
filename
,
"./script/%s"
,
pstr
);
lua_pushboolean
(
L
,
pduel
->
lua
->
load_script
((
char
*
)
filename
));
return
1
;
}
int32
scriptlib
::
duel_enable_global_flag
(
lua_State
*
L
)
{
int32
scriptlib
::
duel_enable_global_flag
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param_count
(
L
,
1
);
...
...
libeffect.cpp
View file @
f53d0bab
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include "field.h"
#include "field.h"
#include "card.h"
#include "card.h"
#include "effect.h"
#include "effect.h"
#include "group.h"
int32
scriptlib
::
effect_set_owner
(
lua_State
*
L
)
{
int32
scriptlib
::
effect_set_owner
(
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
);
...
@@ -220,10 +221,17 @@ int32 scriptlib::effect_set_label_object(lua_State *L) {
...
@@ -220,10 +221,17 @@ int32 scriptlib::effect_set_label_object(lua_State *L) {
peffect
->
label_object
=
0
;
peffect
->
label_object
=
0
;
return
0
;
return
0
;
}
}
if
(
!
lua_isuserdata
(
L
,
2
))
if
(
check_param
(
L
,
PARAM_TYPE_CARD
,
2
,
TRUE
))
{
card
*
p
=
*
(
card
**
)
lua_touserdata
(
L
,
2
);
peffect
->
label_object
=
p
->
ref_handle
;
}
else
if
(
check_param
(
L
,
PARAM_TYPE_EFFECT
,
2
,
TRUE
))
{
effect
*
p
=
*
(
effect
**
)
lua_touserdata
(
L
,
2
);
peffect
->
label_object
=
p
->
ref_handle
;
}
else
if
(
check_param
(
L
,
PARAM_TYPE_GROUP
,
2
,
TRUE
))
{
group
*
p
=
*
(
group
**
)
lua_touserdata
(
L
,
2
);
peffect
->
label_object
=
p
->
ref_handle
;
}
else
luaL_error
(
L
,
"Parameter 2 should be
\"
Card
\"
or
\"
Effect
\"
or
\"
Group
\"
."
);
luaL_error
(
L
,
"Parameter 2 should be
\"
Card
\"
or
\"
Effect
\"
or
\"
Group
\"
."
);
void
*
p
=
*
(
void
**
)
lua_touserdata
(
L
,
2
);
peffect
->
label_object
=
p
;
return
0
;
return
0
;
}
}
int32
scriptlib
::
effect_set_category
(
lua_State
*
L
)
{
int32
scriptlib
::
effect_set_category
(
lua_State
*
L
)
{
...
@@ -376,15 +384,14 @@ int32 scriptlib::effect_get_label_object(lua_State *L) {
...
@@ -376,15 +384,14 @@ int32 scriptlib::effect_get_label_object(lua_State *L) {
lua_pushnil
(
L
);
lua_pushnil
(
L
);
return
1
;
return
1
;
}
}
int32
type
=
*
(
int32
*
)
peffect
->
label_object
;
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
peffect
->
label_object
);
if
(
type
==
1
)
if
(
lua_isuserdata
(
L
,
-
1
))
interpreter
::
card2value
(
L
,
(
card
*
)
peffect
->
label_object
);
return
1
;
else
if
(
type
==
2
)
else
{
interpreter
::
group2value
(
L
,
(
group
*
)
peffect
->
label_object
);
lua_pop
(
L
,
1
);
else
if
(
type
==
3
)
lua_pushnil
(
L
);
interpreter
::
effect2value
(
L
,
(
effect
*
)
peffect
->
label_object
);
return
1
;
else
lua_pushnil
(
L
);
}
return
1
;
}
}
int32
scriptlib
::
effect_get_category
(
lua_State
*
L
)
{
int32
scriptlib
::
effect_get_category
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param_count
(
L
,
1
);
...
...
scriptlib.cpp
View file @
f53d0bab
...
@@ -7,54 +7,64 @@
...
@@ -7,54 +7,64 @@
#include "scriptlib.h"
#include "scriptlib.h"
#include "duel.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
scriptlib
::
check_param
(
lua_State
*
L
,
int32
param_type
,
int32
index
,
int32
retfalse
)
{
int32
result
;
switch
(
param_type
)
{
switch
(
param_type
)
{
case
PARAM_TYPE_CARD
:
case
PARAM_TYPE_CARD
:
{
i
f
(
lua_isuserdata
(
L
,
index
))
{
i
nt32
result
=
FALSE
;
result
=
**
(
int32
**
)
lua_touserdata
(
L
,
index
);
if
(
lua_isuserdata
(
L
,
index
)
&&
lua_getmetatable
(
L
,
index
))
{
if
(
result
==
1
)
result
=
check_data_type
(
L
,
-
1
,
"Card"
);
return
TRUE
;
lua_pop
(
L
,
1
)
;
}
}
if
(
result
)
return
TRUE
;
if
(
retfalse
)
if
(
retfalse
)
return
FALSE
;
return
FALSE
;
luaL_error
(
L
,
"Parameter %d should be
\"
Card
\"
."
,
index
);
luaL_error
(
L
,
"Parameter %d should be
\"
Card
\"
."
,
index
);
break
;
break
;
case
PARAM_TYPE_GROUP
:
}
if
(
lua_isuserdata
(
L
,
index
))
{
case
PARAM_TYPE_GROUP
:
{
result
=
**
(
int32
**
)
lua_touserdata
(
L
,
index
);
if
(
lua_isuserdata
(
L
,
index
)
&&
check_data_type
(
L
,
index
,
"Group"
))
if
(
result
==
2
)
return
TRUE
;
return
TRUE
;
}
if
(
retfalse
)
if
(
retfalse
)
return
FALSE
;
return
FALSE
;
luaL_error
(
L
,
"Parameter %d should be
\"
Group
\"
."
,
index
);
luaL_error
(
L
,
"Parameter %d should be
\"
Group
\"
."
,
index
);
break
;
break
;
case
PARAM_TYPE_EFFECT
:
}
if
(
lua_isuserdata
(
L
,
index
))
{
case
PARAM_TYPE_EFFECT
:
{
result
=
**
(
int32
**
)
lua_touserdata
(
L
,
index
);
if
(
lua_isuserdata
(
L
,
index
)
&&
check_data_type
(
L
,
index
,
"Effect"
))
if
(
result
==
3
)
return
TRUE
;
return
TRUE
;
}
if
(
retfalse
)
if
(
retfalse
)
return
FALSE
;
return
FALSE
;
luaL_error
(
L
,
"Parameter %d should be
\"
Effect
\"
."
,
index
);
luaL_error
(
L
,
"Parameter %d should be
\"
Effect
\"
."
,
index
);
break
;
break
;
case
PARAM_TYPE_FUNCTION
:
}
if
(
lua_isfunction
(
L
,
index
))
case
PARAM_TYPE_FUNCTION
:
{
if
(
lua_isfunction
(
L
,
index
))
return
TRUE
;
return
TRUE
;
if
(
retfalse
)
if
(
retfalse
)
return
FALSE
;
return
FALSE
;
luaL_error
(
L
,
"Parameter %d should be
\"
Function
\"
."
,
index
);
luaL_error
(
L
,
"Parameter %d should be
\"
Function
\"
."
,
index
);
break
;
break
;
case
PARAM_TYPE_STRING
:
}
if
(
lua_isstring
(
L
,
index
))
case
PARAM_TYPE_STRING
:
{
if
(
lua_isstring
(
L
,
index
))
return
TRUE
;
return
TRUE
;
if
(
retfalse
)
if
(
retfalse
)
return
FALSE
;
return
FALSE
;
luaL_error
(
L
,
"Parameter %d should be
\"
String
\"
."
,
index
);
luaL_error
(
L
,
"Parameter %d should be
\"
String
\"
."
,
index
);
break
;
break
;
}
}
}
return
FALSE
;
return
FALSE
;
}
}
...
...
scriptlib.h
View file @
f53d0bab
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
class
scriptlib
{
class
scriptlib
{
public:
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
(
lua_State
*
L
,
int32
param_type
,
int32
index
,
BOOL
retfalse
=
FALSE
);
static
int32
check_param_count
(
lua_State
*
L
,
int32
count
);
static
int32
check_param_count
(
lua_State
*
L
,
int32
count
);
static
int32
check_action_permission
(
lua_State
*
L
);
static
int32
check_action_permission
(
lua_State
*
L
);
...
@@ -41,6 +42,7 @@ public:
...
@@ -41,6 +42,7 @@ public:
static
int32
duel_move_turn_count
(
lua_State
*
L
);
static
int32
duel_move_turn_count
(
lua_State
*
L
);
static
int32
duel_get_cards_in_zone
(
lua_State
*
L
);
static
int32
duel_get_cards_in_zone
(
lua_State
*
L
);
static
int32
duel_xyz_summon_by_rose
(
lua_State
*
L
);
static
int32
duel_xyz_summon_by_rose
(
lua_State
*
L
);
static
int32
duel_load_script
(
lua_State
*
L
);
//card lib
//card lib
static
int32
card_get_code
(
lua_State
*
L
);
static
int32
card_get_code
(
lua_State
*
L
);
static
int32
card_get_origin_code
(
lua_State
*
L
);
static
int32
card_get_origin_code
(
lua_State
*
L
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment