Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
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
List
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
nanahira
ygopro
Commits
11cad46b
Commit
11cad46b
authored
Dec 21, 2011
by
argon.sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua5.2
parent
dfcff86f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
69 deletions
+26
-69
ocgcore/interpreter.cpp
ocgcore/interpreter.cpp
+23
-30
ocgcore/libduel.cpp
ocgcore/libduel.cpp
+1
-1
ocgcore/scriptlib.cpp
ocgcore/scriptlib.cpp
+0
-30
ocgcore/scriptlib.h
ocgcore/scriptlib.h
+0
-6
script/c76573247.lua
script/c76573247.lua
+2
-2
No files found.
ocgcore/interpreter.cpp
View file @
11cad46b
...
...
@@ -15,15 +15,7 @@
#include "ocgapi.h"
#include "interpreter.h"
static
const
struct
luaL_reg
bitlib
[]
=
{
{
"band"
,
scriptlib
::
bit_and
},
{
"bor"
,
scriptlib
::
bit_or
},
{
"bxor"
,
scriptlib
::
bit_xor
},
{
"bls"
,
scriptlib
::
bit_ls
},
{
"brs"
,
scriptlib
::
bit_rs
},
{
NULL
,
NULL
}
};
static
const
struct
luaL_reg
cardlib
[]
=
{
static
const
struct
luaL_Reg
cardlib
[]
=
{
{
"GetCode"
,
scriptlib
::
card_get_code
},
{
"GetOriginalCode"
,
scriptlib
::
card_get_origin_code
},
{
"IsSetCard"
,
scriptlib
::
card_is_set_card
},
...
...
@@ -187,7 +179,7 @@ static const struct luaL_reg cardlib[] = {
{
NULL
,
NULL
}
};
static
const
struct
luaL_
r
eg
effectlib
[]
=
{
static
const
struct
luaL_
R
eg
effectlib
[]
=
{
{
"CreateEffect"
,
scriptlib
::
effect_new
},
{
"Clone"
,
scriptlib
::
effect_clone
},
{
"Reset"
,
scriptlib
::
effect_reset
},
...
...
@@ -232,7 +224,7 @@ static const struct luaL_reg effectlib[] = {
{
NULL
,
NULL
}
};
static
const
struct
luaL_
r
eg
grouplib
[]
=
{
static
const
struct
luaL_
R
eg
grouplib
[]
=
{
{
"CreateGroup"
,
scriptlib
::
group_new
},
{
"KeepAlive"
,
scriptlib
::
group_keep_alive
},
{
"DeleteGroup"
,
scriptlib
::
group_delete
},
...
...
@@ -461,26 +453,26 @@ interpreter::interpreter(duel* pd) {
lua_setglobal
(
lua_state
,
"io"
);
lua_pushnil
(
lua_state
);
lua_setglobal
(
lua_state
,
"os"
);
lua
L_openlib
(
lua_state
,
"bit"
,
bitlib
,
0
);
lua_
pop
(
lua_state
,
1
);
lua
_getglobal
(
lua_state
,
"bit32"
);
lua_
setglobal
(
lua_state
,
"bit"
);
//open all libs
luaL_
openlib
(
lua_state
,
"Card"
,
cardlib
,
0
);
luaL_
newlib
(
lua_state
,
cardlib
);
lua_pushstring
(
lua_state
,
"__index"
);
lua_pushvalue
(
lua_state
,
-
2
);
lua_rawset
(
lua_state
,
-
3
);
lua_
pop
(
lua_state
,
1
);
luaL_
openlib
(
lua_state
,
"Effect"
,
effectlib
,
0
);
lua_
setglobal
(
lua_state
,
"Card"
);
luaL_
newlib
(
lua_state
,
effectlib
);
lua_pushstring
(
lua_state
,
"__index"
);
lua_pushvalue
(
lua_state
,
-
2
);
lua_rawset
(
lua_state
,
-
3
);
lua_
pop
(
lua_state
,
1
);
luaL_
openlib
(
lua_state
,
"Group"
,
grouplib
,
0
);
lua_
setglobal
(
lua_state
,
"Effect"
);
luaL_
newlib
(
lua_state
,
grouplib
);
lua_pushstring
(
lua_state
,
"__index"
);
lua_pushvalue
(
lua_state
,
-
2
);
lua_rawset
(
lua_state
,
-
3
);
lua_
pop
(
lua_state
,
1
);
luaL_
openlib
(
lua_state
,
"Duel"
,
duellib
,
0
);
lua_
pop
(
lua_state
,
1
);
lua_
setglobal
(
lua_state
,
"Group"
);
luaL_
newlib
(
lua_state
,
duellib
);
lua_
setglobal
(
lua_state
,
"Duel"
);
//extra scripts
load_script
((
char
*
)
"constant.lua"
);
load_script
((
char
*
)
"utility.lua"
);
...
...
@@ -519,7 +511,7 @@ void interpreter::register_effect(effect *peffect) {
peffect
->
ref_handle
=
luaL_ref
(
lua_state
,
LUA_REGISTRYINDEX
);
//set metatable of pointer to base script
lua_rawgeti
(
lua_state
,
LUA_REGISTRYINDEX
,
peffect
->
ref_handle
);
lua_get
field
(
lua_state
,
LUA_GLOBALSINDEX
,
"Effect"
);
lua_get
global
(
lua_state
,
"Effect"
);
lua_setmetatable
(
lua_state
,
-
2
);
lua_pop
(
lua_state
,
1
);
}
...
...
@@ -548,7 +540,7 @@ void interpreter::register_group(group *pgroup) {
pgroup
->
ref_handle
=
luaL_ref
(
lua_state
,
LUA_REGISTRYINDEX
);
//set metatable of pointer to base script
lua_rawgeti
(
lua_state
,
LUA_REGISTRYINDEX
,
pgroup
->
ref_handle
);
lua_get
field
(
lua_state
,
LUA_GLOBALSINDEX
,
"Group"
);
lua_get
global
(
lua_state
,
"Group"
);
lua_setmetatable
(
lua_state
,
-
2
);
lua_pop
(
lua_state
,
1
);
}
...
...
@@ -580,15 +572,15 @@ int32 interpreter::load_card_script(uint32 code) {
char
class_name
[
20
];
char
script_name
[
20
];
sprintf
(
class_name
,
"c%d"
,
code
);
lua_get
field
(
current_state
,
LUA_GLOBALSINDEX
,
class_name
);
lua_get
global
(
current_state
,
class_name
);
//if script is not loaded, create and load it
if
(
lua_isnil
(
current_state
,
-
1
))
{
lua_pop
(
current_state
,
1
);
//create a table & set metatable
lua_createtable
(
current_state
,
0
,
0
);
lua_set
field
(
current_state
,
LUA_GLOBALSINDEX
,
class_name
);
lua_get
field
(
current_state
,
LUA_GLOBALSINDEX
,
class_name
);
lua_get
field
(
current_state
,
LUA_GLOBALSINDEX
,
"Card"
);
lua_set
global
(
current_state
,
class_name
);
lua_get
global
(
current_state
,
class_name
);
lua_get
global
(
current_state
,
"Card"
);
lua_setmetatable
(
current_state
,
-
2
);
lua_pushstring
(
current_state
,
"__index"
);
lua_pushvalue
(
current_state
,
-
2
);
...
...
@@ -923,7 +915,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
}
current_state
=
rthread
;
push_param
(
rthread
);
int32
result
=
lua_resume
(
rthread
,
param_count
);
int32
result
=
lua_resume
(
rthread
,
0
,
param_count
);
if
(
result
==
0
)
{
coroutines
.
erase
(
f
);
if
(
yield_value
)
...
...
@@ -979,10 +971,11 @@ int32 interpreter::get_function_handle(lua_State* L, int32 index) {
}
void
interpreter
::
set_duel_info
(
lua_State
*
L
,
duel
*
pduel
)
{
lua_pushinteger
(
L
,
(
ptr
)
pduel
);
lua_rawseti
(
L
,
LUA_GLOBALSINDEX
,
1
);
int32
ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
lua_setglobal
(
L
,
"__duel"
);
}
duel
*
interpreter
::
get_duel_info
(
lua_State
*
L
)
{
lua_
rawgeti
(
L
,
LUA_GLOBALSINDEX
,
1
);
lua_
getglobal
(
L
,
"__duel"
);
ptr
pduel
=
lua_tointeger
(
L
,
-
1
);
lua_pop
(
L
,
1
);
return
(
duel
*
)
pduel
;
...
...
ocgcore/libduel.cpp
View file @
11cad46b
...
...
@@ -57,7 +57,7 @@ int32 scriptlib::duel_get_draw_count(lua_State *L) {
}
int32
scriptlib
::
duel_debug_message
(
lua_State
*
L
)
{
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
lua_get
field
(
L
,
LUA_GLOBALSINDEX
,
"tostring"
);
lua_get
global
(
L
,
"tostring"
);
lua_pushvalue
(
L
,
-
2
);
lua_pcall
(
L
,
1
,
1
,
0
);
sprintf
(
pduel
->
strbuffer
,
"%s"
,
lua_tostring
(
L
,
-
1
));
...
...
ocgcore/scriptlib.cpp
View file @
11cad46b
...
...
@@ -69,33 +69,3 @@ int32 scriptlib::check_action_permission(lua_State* L) {
luaL_error
(
L
,
"Action is not allowed here."
);
return
TRUE
;
}
int32
scriptlib
::
bit_and
(
lua_State
*
L
)
{
int32
a
=
lua_tointeger
(
L
,
1
);
int32
b
=
lua_tointeger
(
L
,
2
);
lua_pushinteger
(
L
,
a
&
b
);
return
1
;
}
int32
scriptlib
::
bit_or
(
lua_State
*
L
)
{
int32
a
=
lua_tointeger
(
L
,
1
);
int32
b
=
lua_tointeger
(
L
,
2
);
lua_pushinteger
(
L
,
a
|
b
);
return
1
;
}
int32
scriptlib
::
bit_xor
(
lua_State
*
L
)
{
int32
a
=
lua_tointeger
(
L
,
1
);
int32
b
=
lua_tointeger
(
L
,
2
);
lua_pushinteger
(
L
,
a
^
b
);
return
1
;
}
int32
scriptlib
::
bit_ls
(
lua_State
*
L
)
{
int32
a
=
lua_tointeger
(
L
,
1
);
int32
b
=
lua_tointeger
(
L
,
2
);
lua_pushinteger
(
L
,
a
<<
b
);
return
1
;
}
int32
scriptlib
::
bit_rs
(
lua_State
*
L
)
{
int32
a
=
lua_tointeger
(
L
,
1
);
int32
b
=
lua_tointeger
(
L
,
2
);
lua_pushinteger
(
L
,
a
>>
b
);
return
1
;
}
ocgcore/scriptlib.h
View file @
11cad46b
...
...
@@ -16,12 +16,6 @@ public:
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
);
//bit
static
int32
bit_and
(
lua_State
*
L
);
static
int32
bit_or
(
lua_State
*
L
);
static
int32
bit_xor
(
lua_State
*
L
);
static
int32
bit_ls
(
lua_State
*
L
);
static
int32
bit_rs
(
lua_State
*
L
);
//card lib
static
int32
card_get_code
(
lua_State
*
L
);
...
...
script/c76573247.lua
View file @
11cad46b
...
...
@@ -26,8 +26,8 @@ function c76573247.seqop(e,tp,eg,ep,ev,re,r,rp)
if
(
seq
>
0
and
Duel
.
CheckLocation
(
tp
,
LOCATION_MZONE
,
seq
-
1
))
or
(
seq
<
4
and
Duel
.
CheckLocation
(
tp
,
LOCATION_MZONE
,
seq
+
1
))
then
local
flag
=
0
if
seq
>
0
and
Duel
.
CheckLocation
(
tp
,
LOCATION_MZONE
,
seq
-
1
)
then
flag
=
bit
.
bor
(
flag
,
bit
.
bls
(
0x1
,
seq
-
1
))
end
if
seq
<
4
and
Duel
.
CheckLocation
(
tp
,
LOCATION_MZONE
,
seq
+
1
)
then
flag
=
bit
.
bor
(
flag
,
bit
.
bls
(
0x1
,
seq
+
1
))
end
if
seq
>
0
and
Duel
.
CheckLocation
(
tp
,
LOCATION_MZONE
,
seq
-
1
)
then
flag
=
bit
.
bor
(
flag
,
bit
.
lshift
(
0x1
,
seq
-
1
))
end
if
seq
<
4
and
Duel
.
CheckLocation
(
tp
,
LOCATION_MZONE
,
seq
+
1
)
then
flag
=
bit
.
bor
(
flag
,
bit
.
lshift
(
0x1
,
seq
+
1
))
end
flag
=
bit
.
bxor
(
flag
,
0xff
)
local
s
=
Duel
.
SelectDisableField
(
tp
,
1
,
LOCATION_MZONE
,
0
,
flag
)
local
nseq
=
0
...
...
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