Commit graph

20 commits

Author SHA1 Message Date
Edoardo Lolletti
51d40c3a08 Add smart pointer backend to lua function references handling 2021-03-24 19:47:18 +01:00
edo9300
22e710a335 Major cleanups in interpreter.cpp
Update lua functions calling functions, moved most of their common code in inline helper functions, simplify some code flow logic, use raw string literals when formatting strings
2021-01-07 19:42:30 +01:00
edo9300
6ec6a6cc06 Improved callback calls from duel class, replace sprintf interpreter function with "format", usign a buffer internal to the interpreter class
handle_message and read_script are now wrappers on top of the callbacks, will pass the payload and other needed parameters accordingly
2021-01-07 13:39:12 +01:00
edo9300
bb01859d6b Add handling for onjects exposed to the lua api and still possibly referenced inside it
Currently the core just deallocated the internal object without doing nothing lua side, thus allowing the api to access invalid memory locations previously pointed by referenced objects. Added dummy `deleted` object that will take the place of any deleted lua/c object, raising errors when the api tries to read a lua_obj from the lua stack, so that the address pointed by the lua object will always be valid.
Also fixed possible crash when the label object passed to an EFFECT_TYPE_GRANT effect wasn't a valid effect.
2021-01-03 23:26:33 +01:00
edo9300
639a61fac7 Update lua functions related to strings
Remove global duel::strbuffer, this was a leftover from the old message handling, directly pass the string from lua to the callback function, and use local buffers when formatting is needed.
2020-11-06 22:40:01 +01:00
edo9300
d98ab684d7 Always use lua_get<duel*>() in library functions that have to access it 2020-10-30 17:05:28 +01:00
edo9300
83dbd1e6a7 Don't abort if passed parameter is not int, only log 2020-08-23 17:56:55 +02:00
edo9300
8268daf117 Treat boolean always valid, uinless it's a non valid index
To keep consistency with the language and the pre existing scripts
2020-07-23 23:49:06 +02:00
edo9300
368aa39b8c Update check_param to also return the checked lua object, simplify optional parameters checking 2020-07-21 15:03:03 +02:00
edo9300
7f8eaedc59 Update lua getters in libduel 2020-07-21 00:08:06 +02:00
edo9300
dad1f3f462 Missing const qualifier 2020-07-20 20:58:34 +02:00
edo9300
ded6eeb7ac Inherit group, card, effect form lua_object class, simplify userdata type handling
Have base class lua_obj also register the type of the parameter, so that we don't have to rely on calling lua functions, but the value of teh struct can be directly checked
2020-07-20 20:50:15 +02:00
edo9300
9e2a1ff5ba Make various select functions cancelable 2020-03-14 18:40:09 +01:00
edo9300
a891c23ecb Merge remote-tracking branch 'refs/remotes/Fluorohydride/master'
# Conflicts:
#	effect.cpp
#	field.cpp
#	libduel.cpp
#	libeffect.cpp
#	operations.cpp
#	premake4.lua
#	processor.cpp
#	scriptlib.h
2018-09-26 19:43:17 +02:00
DailyShana
49b33e46f3 make check_data_type only for internal usage 2018-09-11 18:39:26 +08:00
edo9300
a31bdd546a Merge remote-tracking branch 'refs/remotes/Fluorohydride/master' 2018-08-13 19:02:22 +02:00
DailyShana
c6f757aa26 Revert "Revert "update scriptlib::check_param""
This reverts commit 5a392f8b2d.
2018-08-12 11:37:00 +08:00
purerosefallen
5a392f8b2d Revert "update scriptlib::check_param"
This reverts commit 9a8ac816f7.
2018-08-12 08:53:04 +08:00
DailyShana
9a8ac816f7 update scriptlib::check_param 2018-08-11 14:37:55 +08:00
fluorohydride
e8420f0738 submodule first push 2015-09-25 21:07:16 +08:00