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
f4cc585a
Commit
f4cc585a
authored
Mar 07, 2024
by
wind2009
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into develop
parents
b4d009c8
0d23e593
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
31 deletions
+48
-31
card_data.h
card_data.h
+4
-1
field.h
field.h
+2
-0
interpreter.cpp
interpreter.cpp
+24
-23
libduel.cpp
libduel.cpp
+6
-0
playerop.cpp
playerop.cpp
+1
-1
processor.cpp
processor.cpp
+10
-6
scriptlib.h
scriptlib.h
+1
-0
No files found.
card_data.h
View file @
f4cc585a
...
...
@@ -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.h
View file @
f4cc585a
...
...
@@ -279,6 +279,8 @@ struct processor {
uint8
summon_cancelable
{
FALSE
};
card
*
attacker
{
nullptr
};
card
*
attack_target
{
nullptr
};
uint8
attacker_player
{
PLAYER_NONE
};
uint8
attack_target_player
{
PLAYER_NONE
};
uint32
limit_extra_summon_zone
{
0
};
uint32
limit_extra_summon_releasable
{
0
};
card
*
limit_tuner
{
nullptr
};
...
...
interpreter.cpp
View file @
f4cc585a
...
...
@@ -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
;
}
...
...
libduel.cpp
View file @
f4cc585a
...
...
@@ -4498,6 +4498,11 @@ int32 scriptlib::duel_is_player_can_additional_summon(lua_State * L) {
lua_pushboolean
(
L
,
0
);
return
1
;
}
int32
scriptlib
::
duel_is_chain_solving
(
lua_State
*
L
)
{
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
lua_pushboolean
(
L
,
pduel
->
game_field
->
core
.
chain_solving
);
return
1
;
}
int32
scriptlib
::
duel_is_chain_negatable
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
lua_pushboolean
(
L
,
1
);
...
...
@@ -4974,6 +4979,7 @@ static const struct luaL_Reg duellib[] = {
{
"IsPlayerCanSendtoGrave"
,
scriptlib
::
duel_is_player_can_send_to_grave
},
{
"IsPlayerCanSendtoDeck"
,
scriptlib
::
duel_is_player_can_send_to_deck
},
{
"IsPlayerCanAdditionalSummon"
,
scriptlib
::
duel_is_player_can_additional_summon
},
{
"IsChainSolving"
,
scriptlib
::
duel_is_chain_solving
},
{
"IsChainNegatable"
,
scriptlib
::
duel_is_chain_negatable
},
{
"IsChainDisablable"
,
scriptlib
::
duel_is_chain_disablable
},
{
"IsChainDisabled"
,
scriptlib
::
duel_is_chain_disabled
},
...
...
playerop.cpp
View file @
f4cc585a
...
...
@@ -972,7 +972,7 @@ static int32 is_declarable(card_data const& cd, const std::vector<uint32>& opcod
if
(
stack
.
size
()
!=
1
||
stack
.
top
()
==
0
)
return
FALSE
;
return
cd
.
code
==
CARD_MARINE_DOLPHIN
||
cd
.
code
==
CARD_TWINKLE_MOSS
||
(
!
cd
.
alias
&&
(
cd
.
type
&
(
TYPE_MONSTER
+
TYPE_TOKEN
))
!=
(
TYPE_MONSTER
+
TYPE_TOKEN
));
||
(
!
cd
.
alias
&&
(
cd
.
type
&
(
TYPE_MONSTER
|
TYPE_TOKEN
))
!=
(
TYPE_MONSTER
|
TYPE_TOKEN
));
}
int32
field
::
announce_card
(
int16
step
,
uint8
playerid
)
{
if
(
step
==
0
)
{
...
...
processor.cpp
View file @
f4cc585a
...
...
@@ -2928,6 +2928,8 @@ int32 field::process_battle_command(uint16 step) {
core
.
attacker
->
set_status
(
STATUS_OPPO_BATTLE
,
TRUE
);
core
.
attack_target
->
set_status
(
STATUS_OPPO_BATTLE
,
TRUE
);
}
core
.
attacker_player
=
pa
;
core
.
attack_target_player
=
pd
;
}
effect
*
damchange
=
nullptr
;
card
*
reason_card
=
nullptr
;
...
...
@@ -3164,16 +3166,16 @@ int32 field::process_battle_command(uint16 step) {
card_set
ing
;
card_set
ed
;
if
(
core
.
attacker
->
is_status
(
STATUS_BATTLE_DESTROYED
)
&&
(
core
.
attacker
->
current
.
reason
&
REASON_BATTLE
))
{
raise_single_event
(
core
.
attack_target
,
0
,
EVENT_BATTLE_DESTROYING
,
0
,
core
.
attacker
->
current
.
reason
,
core
.
attack_target
->
current
.
control
er
,
0
,
1
);
raise_single_event
(
core
.
attacker
,
0
,
EVENT_BATTLE_DESTROYED
,
0
,
core
.
attacker
->
current
.
reason
,
core
.
attack_target
->
current
.
control
er
,
0
,
0
);
raise_single_event
(
core
.
attacker
,
0
,
EVENT_DESTROYED
,
0
,
core
.
attacker
->
current
.
reason
,
core
.
attack_target
->
current
.
control
er
,
0
,
0
);
raise_single_event
(
core
.
attack_target
,
0
,
EVENT_BATTLE_DESTROYING
,
0
,
core
.
attacker
->
current
.
reason
,
core
.
attack_target
_play
er
,
0
,
1
);
raise_single_event
(
core
.
attacker
,
0
,
EVENT_BATTLE_DESTROYED
,
0
,
core
.
attacker
->
current
.
reason
,
core
.
attack_target
_play
er
,
0
,
0
);
raise_single_event
(
core
.
attacker
,
0
,
EVENT_DESTROYED
,
0
,
core
.
attacker
->
current
.
reason
,
core
.
attack_target
_play
er
,
0
,
0
);
ing
.
insert
(
core
.
attack_target
);
ed
.
insert
(
core
.
attacker
);
}
if
(
core
.
attack_target
&&
core
.
attack_target
->
is_status
(
STATUS_BATTLE_DESTROYED
)
&&
(
core
.
attack_target
->
current
.
reason
&
REASON_BATTLE
))
{
raise_single_event
(
core
.
attacker
,
0
,
EVENT_BATTLE_DESTROYING
,
0
,
core
.
attack_target
->
current
.
reason
,
core
.
attacker
->
current
.
control
er
,
0
,
0
);
raise_single_event
(
core
.
attack_target
,
0
,
EVENT_BATTLE_DESTROYED
,
0
,
core
.
attack_target
->
current
.
reason
,
core
.
attacker
->
current
.
control
er
,
0
,
1
);
raise_single_event
(
core
.
attack_target
,
0
,
EVENT_DESTROYED
,
0
,
core
.
attack_target
->
current
.
reason
,
core
.
attacker
->
current
.
control
er
,
0
,
1
);
raise_single_event
(
core
.
attacker
,
0
,
EVENT_BATTLE_DESTROYING
,
0
,
core
.
attack_target
->
current
.
reason
,
core
.
attacker
_play
er
,
0
,
0
);
raise_single_event
(
core
.
attack_target
,
0
,
EVENT_BATTLE_DESTROYED
,
0
,
core
.
attack_target
->
current
.
reason
,
core
.
attacker
_play
er
,
0
,
1
);
raise_single_event
(
core
.
attack_target
,
0
,
EVENT_DESTROYED
,
0
,
core
.
attack_target
->
current
.
reason
,
core
.
attacker
_play
er
,
0
,
1
);
ing
.
insert
(
core
.
attacker
);
ed
.
insert
(
core
.
attack_target
);
}
...
...
@@ -3212,6 +3214,8 @@ int32 field::process_battle_command(uint16 step) {
core
.
attacker
->
set_status
(
STATUS_OPPO_BATTLE
,
FALSE
);
if
(
core
.
attack_target
)
core
.
attack_target
->
set_status
(
STATUS_OPPO_BATTLE
,
FALSE
);
core
.
attacker_player
=
PLAYER_NONE
;
core
.
attack_target_player
=
PLAYER_NONE
;
core
.
units
.
begin
()
->
step
=
-
1
;
infos
.
phase
=
PHASE_BATTLE_STEP
;
pduel
->
write_buffer8
(
MSG_DAMAGE_STEP_END
);
...
...
scriptlib.h
View file @
f4cc585a
...
...
@@ -607,6 +607,7 @@ public:
static
int32
duel_is_player_can_send_to_grave
(
lua_State
*
L
);
static
int32
duel_is_player_can_send_to_deck
(
lua_State
*
L
);
static
int32
duel_is_player_can_additional_summon
(
lua_State
*
L
);
static
int32
duel_is_chain_solving
(
lua_State
*
L
);
static
int32
duel_is_chain_negatable
(
lua_State
*
L
);
static
int32
duel_is_chain_disablable
(
lua_State
*
L
);
static
int32
duel_is_chain_disabled
(
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