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
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-core
Commits
5ec509c2
Commit
5ec509c2
authored
Feb 27, 2024
by
salix5
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into next
parents
7dba7a68
2a7e3dfe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
24 deletions
+29
-24
card_data.h
card_data.h
+4
-1
field.cpp
field.cpp
+1
-0
interpreter.cpp
interpreter.cpp
+24
-23
No files found.
card_data.h
View file @
5ec509c2
...
...
@@ -3,8 +3,9 @@
#include "common.h"
constexpr
int
CARD_ARTWORK_VERSIONS_OFFSET
=
1
0
;
constexpr
int
CARD_ARTWORK_VERSIONS_OFFSET
=
2
0
;
constexpr
int
SIZE_SETCODE
=
16
;
constexpr
int
CARD_BLACK_LUSTER_SOLDIER2
=
5405695
;
struct
card_data
{
uint32
code
{};
...
...
@@ -49,6 +50,8 @@ struct card_data {
}
bool
is_alternative
()
const
{
if
(
code
==
CARD_BLACK_LUSTER_SOLDIER2
)
return
false
;
return
alias
&&
(
alias
<
code
+
CARD_ARTWORK_VERSIONS_OFFSET
)
&&
(
code
<
alias
+
CARD_ARTWORK_VERSIONS_OFFSET
);
}
...
...
field.cpp
View file @
5ec509c2
...
...
@@ -11,6 +11,7 @@
#include "group.h"
#include "effect.h"
#include "interpreter.h"
#include <cstring>
int32
field
::
field_used_count
[
32
]
=
{
0
,
1
,
1
,
2
,
1
,
2
,
2
,
3
,
1
,
2
,
2
,
3
,
2
,
3
,
3
,
4
,
1
,
2
,
2
,
3
,
2
,
3
,
3
,
4
,
2
,
3
,
3
,
4
,
3
,
4
,
4
,
5
};
...
...
interpreter.cpp
View file @
5ec509c2
...
...
@@ -50,19 +50,20 @@ int32 interpreter::register_card(card *pcard) {
//create a card in by userdata
luaL_checkstack
(
lua_state
,
1
,
nullptr
);
luaL_checkstack
(
current_state
,
1
,
nullptr
);
card
**
ppcard
=
(
card
**
)
lua_newuserdata
(
lua_state
,
sizeof
(
card
*
));
card
**
ppcard
=
(
card
**
)
lua_newuserdata
(
lua_state
,
sizeof
(
card
*
));
//+1 userdata
*
ppcard
=
pcard
;
pcard
->
ref_handle
=
luaL_ref
(
lua_state
,
LUA_REGISTRYINDEX
);
pcard
->
ref_handle
=
luaL_ref
(
lua_state
,
LUA_REGISTRYINDEX
);
//-1
//some userdata may be created in script like token so use current_state
lua_rawgeti
(
current_state
,
LUA_REGISTRYINDEX
,
pcard
->
ref_handle
);
lua_rawgeti
(
current_state
,
LUA_REGISTRYINDEX
,
pcard
->
ref_handle
);
//+1 userdata
//load script
if
(
pcard
->
data
.
is_alternative
())
load_card_script
(
pcard
->
data
.
alias
);
else
load_card_script
(
pcard
->
data
.
code
);
//stack: table cxxx, userdata
//set metatable of pointer to base script
lua_setmetatable
(
current_state
,
-
2
);
lua_pop
(
current_state
,
1
);
lua_setmetatable
(
current_state
,
-
2
);
//-1
lua_pop
(
current_state
,
1
);
//-1
//Initial
if
(
pcard
->
data
.
code
&&
(
!
(
pcard
->
data
.
type
&
TYPE_NORMAL
)
||
(
pcard
->
data
.
type
&
TYPE_PENDULUM
)))
{
pcard
->
set_status
(
STATUS_INITIALIZING
,
TRUE
);
...
...
@@ -144,31 +145,31 @@ int32 interpreter::load_card_script(uint32 code) {
char
class_name
[
20
];
sprintf
(
class_name
,
"c%d"
,
code
);
luaL_checkstack
(
current_state
,
1
,
nullptr
);
lua_getglobal
(
current_state
,
class_name
);
lua_getglobal
(
current_state
,
class_name
);
//+1 table cxxx
//if script is not loaded, create and load it
if
(
lua_isnil
(
current_state
,
-
1
))
{
luaL_checkstack
(
current_state
,
5
,
nullptr
);
lua_pop
(
current_state
,
1
);
lua_pop
(
current_state
,
1
);
//-1
//create a table & set metatable
lua_createtable
(
current_state
,
0
,
0
);
lua_setglobal
(
current_state
,
class_name
);
lua_getglobal
(
current_state
,
class_name
);
lua_getglobal
(
current_state
,
"Card"
);
lua_setmetatable
(
current_state
,
-
2
);
lua_pushstring
(
current_state
,
"__index"
);
lua_pushvalue
(
current_state
,
-
2
);
lua_rawset
(
current_state
,
-
3
);
lua_getglobal
(
current_state
,
class_name
);
lua_setglobal
(
current_state
,
"self_table"
);
lua_pushinteger
(
current_state
,
code
);
lua_setglobal
(
current_state
,
"self_code"
);
lua_createtable
(
current_state
,
0
,
0
);
//+1, {}
lua_setglobal
(
current_state
,
class_name
);
//-1
lua_getglobal
(
current_state
,
class_name
);
//+1 table cxxx
lua_getglobal
(
current_state
,
"Card"
);
//+1 Card, table cxxx
lua_setmetatable
(
current_state
,
-
2
);
//-1 table cxxx
lua_pushstring
(
current_state
,
"__index"
);
//+1 "__index", table cxxx
lua_pushvalue
(
current_state
,
-
2
);
//+1 table cxxx, "__index", table cxxx
lua_rawset
(
current_state
,
-
3
);
//-2 table cxxx
lua_getglobal
(
current_state
,
class_name
);
//+1
lua_setglobal
(
current_state
,
"self_table"
);
//-1
lua_pushinteger
(
current_state
,
code
);
//+1
lua_setglobal
(
current_state
,
"self_code"
);
//-1
char
script_name
[
64
];
sprintf
(
script_name
,
"./script/c%d.lua"
,
code
);
int32
res
=
load_script
(
script_name
);
lua_pushnil
(
current_state
);
lua_setglobal
(
current_state
,
"self_table"
);
lua_pushnil
(
current_state
);
lua_setglobal
(
current_state
,
"self_code"
);
lua_pushnil
(
current_state
);
//+1
lua_setglobal
(
current_state
,
"self_table"
);
//-1
lua_pushnil
(
current_state
);
//+1
lua_setglobal
(
current_state
,
"self_code"
);
//-1 table cxxx {__index: cxxx }
if
(
!
res
)
{
return
OPERATION_FAIL
;
}
...
...
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