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
61479cf2
Commit
61479cf2
authored
Feb 05, 2020
by
DailyShana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove std::round
round decimals correctly in scripts close #264
parent
e6ac7e88
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
8 deletions
+7
-8
interpreter.cpp
interpreter.cpp
+3
-3
interpreter.h
interpreter.h
+0
-1
libduel.cpp
libduel.cpp
+3
-3
libeffect.cpp
libeffect.cpp
+1
-1
No files found.
interpreter.cpp
View file @
61479cf2
...
@@ -433,7 +433,7 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
...
@@ -433,7 +433,7 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
}
}
return
OPERATION_FAIL
;
return
OPERATION_FAIL
;
}
}
int32
result
=
lua_isinteger
(
current_state
,
-
1
)
?
lua_tointeger
(
current_state
,
-
1
)
:
std
::
round
(
lua_tonumber
(
current_state
,
-
1
)
);
int32
result
=
lua_isinteger
(
current_state
,
-
1
)
?
lua_tointeger
(
current_state
,
-
1
)
:
lua_tonumber
(
current_state
,
-
1
);
lua_pop
(
current_state
,
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
no_action
--
;
call_depth
--
;
call_depth
--
;
...
@@ -457,7 +457,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
...
@@ -457,7 +457,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
else
if
(
lua_isinteger
(
current_state
,
-
1
))
else
if
(
lua_isinteger
(
current_state
,
-
1
))
result
=
lua_tointeger
(
current_state
,
-
1
);
result
=
lua_tointeger
(
current_state
,
-
1
);
else
else
result
=
std
::
round
(
lua_tonumber
(
current_state
,
-
1
)
);
result
=
lua_tonumber
(
current_state
,
-
1
);
lua_pop
(
current_state
,
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
no_action
--
;
call_depth
--
;
call_depth
--
;
...
@@ -493,7 +493,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
...
@@ -493,7 +493,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
else
if
(
lua_isinteger
(
current_state
,
index
))
else
if
(
lua_isinteger
(
current_state
,
index
))
return_value
=
lua_tointeger
(
current_state
,
index
);
return_value
=
lua_tointeger
(
current_state
,
index
);
else
else
return_value
=
std
::
round
(
lua_tonumber
(
current_state
,
index
)
);
return_value
=
lua_tonumber
(
current_state
,
index
);
result
->
push_back
(
return_value
);
result
->
push_back
(
return_value
);
}
}
lua_settop
(
current_state
,
stack_top
);
lua_settop
(
current_state
,
stack_top
);
...
...
interpreter.h
View file @
61479cf2
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
#include <vector>
#include <vector>
#include <cstdio>
#include <cstdio>
#include <cstring>
#include <cstring>
#include <cmath>
class
card
;
class
card
;
class
effect
;
class
effect
;
...
...
libduel.cpp
View file @
61479cf2
...
@@ -33,7 +33,7 @@ int32 scriptlib::duel_get_lp(lua_State *L) {
...
@@ -33,7 +33,7 @@ int32 scriptlib::duel_get_lp(lua_State *L) {
int32
scriptlib
::
duel_set_lp
(
lua_State
*
L
)
{
int32
scriptlib
::
duel_set_lp
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
check_param_count
(
L
,
2
);
int32
p
=
lua_tointeger
(
L
,
1
);
int32
p
=
lua_tointeger
(
L
,
1
);
int32 lp =
std::round(lua_tonumber(L, 2)
);
int32
lp
=
lua_tonumber
(
L
,
2
);
if
(
lp
<
0
)
lp
=
0
;
if
(
lp
<
0
)
lp
=
0
;
if
(
p
!=
0
&&
p
!=
1
)
if
(
p
!=
0
&&
p
!=
1
)
return
0
;
return
0
;
...
@@ -1199,7 +1199,7 @@ int32 scriptlib::duel_damage(lua_State *L) {
...
@@ -1199,7 +1199,7 @@ int32 scriptlib::duel_damage(lua_State *L) {
uint32
playerid
=
lua_tointeger
(
L
,
1
);
uint32
playerid
=
lua_tointeger
(
L
,
1
);
if
(
playerid
!=
0
&&
playerid
!=
1
)
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
return
0
;
int32 amount =
std::round(lua_tonumber(L, 2)
);
int32
amount
=
lua_tonumber
(
L
,
2
);
if
(
amount
<
0
)
if
(
amount
<
0
)
amount
=
0
;
amount
=
0
;
uint32
reason
=
lua_tointeger
(
L
,
3
);
uint32
reason
=
lua_tointeger
(
L
,
3
);
...
@@ -1220,7 +1220,7 @@ int32 scriptlib::duel_recover(lua_State *L) {
...
@@ -1220,7 +1220,7 @@ int32 scriptlib::duel_recover(lua_State *L) {
uint32
playerid
=
lua_tointeger
(
L
,
1
);
uint32
playerid
=
lua_tointeger
(
L
,
1
);
if
(
playerid
!=
0
&&
playerid
!=
1
)
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
return
0
;
int32 amount =
std::round(lua_tonumber(L, 2)
);
int32
amount
=
lua_tonumber
(
L
,
2
);
if
(
amount
<
0
)
if
(
amount
<
0
)
amount
=
0
;
amount
=
0
;
uint32
reason
=
lua_tointeger
(
L
,
3
);
uint32
reason
=
lua_tointeger
(
L
,
3
);
...
...
libeffect.cpp
View file @
61479cf2
...
@@ -269,7 +269,7 @@ int32 scriptlib::effect_set_value(lua_State *L) {
...
@@ -269,7 +269,7 @@ int32 scriptlib::effect_set_value(lua_State *L) {
else
if
(
lua_isinteger
(
L
,
2
))
else
if
(
lua_isinteger
(
L
,
2
))
peffect
->
value
=
lua_tointeger
(
L
,
2
);
peffect
->
value
=
lua_tointeger
(
L
,
2
);
else
else
peffect
->
value
=
std
::
round
(
lua_tonumber
(
L
,
2
)
);
peffect
->
value
=
lua_tonumber
(
L
,
2
);
}
}
return
0
;
return
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