![]() |
|
[Pawn] [Help] Convert code written on YSI 4.x to 5.x(y_inline and y_malloc) - Printable Version +- open.mp forum (https://forum.open.mp) +-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) +--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) +--- Thread: [Pawn] [Help] Convert code written on YSI 4.x to 5.x(y_inline and y_malloc) (/showthread.php?tid=398) |
[Help] Convert code written on YSI 4.x to 5.x(y_inline and y_malloc) - MattHudson - 2019-04-20 Hi guys, i'm trying to convert this code: Code: ? ?new
? ? ? ?cb_data[E_CALLBACK_DATA]
? ?;
? ?cb_data[E_CALLBACK_DATA_ALLOC] ? ? ?= ResolvedAlloc: address;
? ?cb_data[E_CALLBACK_DATA_POINTER] ? ?= Function: pointer;
? ?cb_data[E_CALLBACK_DATA_OFFSET] ? ? = offset;
? ?cb_data[E_CALLBACK_DATA_FORMAT][0] ?= data1;
? ?cb_data[E_CALLBACK_DATA_FORMAT][1] ?= data2;To YSI 5.x Inline, but i really don't know what to do or how to start... I read?y_inline_impl2.inc documentation and note "How to convert from old y_inline to new y_inline:", but i didn't understand it. Thanks for reading! RE: [Help] Convert old y_inline code to newer one - Y_Less - 2019-04-20 That doesn't look like y_inline code, that looks like you are directly manipulating internal data structures. That's not documented at all. What are you trying to do with that? Why are you modifying E_CALLBACK_DATA? RE: [Help] Convert old y_inline code to newer one - #Fede - 2019-04-20 (2019-04-20, 11:07 AM)Y_Less Wrote: That doesn't look like y_inline code, that looks like you are directly manipulating internal data structures. That's not documented at all. What are you trying to do with that? Why are you modifying E_CALLBACK_DATA? He is trying to do?this include?work with YSI 5.x RE: [Help] Convert old y_inline code to newer one - MattHudson - 2019-04-20 (2019-04-20, 11:07 AM)Y_Less Wrote: That doesn't look like y_inline code, that looks like you are directly manipulating internal data structures. That's not documented at all. What are you trying to do with that? Why are you modifying E_CALLBACK_DATA? Well... basically i'm trying to upgrade?this library?because i'm using YSI 5.x on my code. I re-write most of it based on?this?documentation of converting old to new?but i stopped on the lines i said up... Thanks for answer! [Edit] So sorry,i didn't see #Fede's answer. RE: [Help] Convert code written on YSI 4.x to 5.x(y_inline and y_malloc) - Y_Less - 2019-04-21 The documentation covers standard uses. This is a completely non-standard use, and exploits internal details. Those details have never been guaranteed to be stable and change a lot. Fortunately, rewriting that isn't too hard because the timer doesn't accept any additional parameters (i.e. it is a `SetTimer` wrapper, not a `SetTimerEx` wrapper). Something like this: PHP Code: #if defined _inline_timers_included
#endinput
#endif
#define _inline_timers_included
#include <YSI_Coding\y_inline>
forward InlineTimersHandler(Func:cb<>, bool:repeat);
public InlineTimersHandler(Func:cb<>, bool:repeat)
{
@.cb();
if (!repeat)
{
Indirect_Release(cb);
}
}
stock SetInlineTimer(Func:cb<>, delay, bool:repeat)
{
new timer = SetTimerEx("InlineTimersHandler", delay, _:repeat, "ii", _:cb, _:repeat);
if (timer)
{
Indirect_SetMeta(cb, timer);
Indirect_Claim(cb);
return _:cb;
}
return 0;
}
stock KillInlineTimer(cb)
{
KillTimer(Indirect_GetMeta(cb));
Indirect_Release(cb);
}
|