Clumsily cheating the type-check - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Clumsily cheating the type-check (
/showthread.php?tid=420389)
Clumsily cheating the type-check -
Misiur - 04.03.2013
I'm fooling around with typechecks during compile time, with some results:
pawn Код:
#include <a_samp>
#include <sscanf2>
main() {
new tmp[] = "Hello 15 1.5";
new str[] = "s[64]df";
new y[3][3];
new x[3][64];
new Float:f, s[64], d;
new j = 0, ss[64];
for(new i = 0; i < sizeof str; ++i) {
if(!('a' <= str[i] <= 'z')) continue;
new t;
#emit LOAD.S.pri ss
#emit STOR.S.pri t
switch(str[i]) {
case 's': {
strcat(y[j], "%s");
#emit LOAD.S.pri s
#emit STOR.S.pri t
}
case 'd': {
strcat(y[j], "%d");
#emit LOAD.S.pri d
#emit STOR.S.pri t
}
case 'f': {
strcat(y[j], "%f");
#emit LOAD.S.pri f
#emit STOR.S.pri t
}
}
strcat(x[j], ss);
++j;
}
sscanf(tmp, str, x[0], x[1], x[2]);
new ft[32];
format(ft, sizeof ft, "Hi %s %s %s", y[0], y[1], y[2]);
printf(ft, x[0], x[1], x[2]);
}
Returns "Hi Hello 15 1.5" - I was astonished that it worked in the end (so much pointer swaps). Anyway - is there some easier, cleaner way to do this type of experiment? Could someone show me how to pass to sscanf 3 variables with random types?
2. Is there way to smuggle array access into emit?
Extra characters in line
Re: Clumsily cheating the type-check -
Misiur - 05.03.2013
bump
Re: Clumsily cheating the type-check -
Misiur - 06.03.2013
bump again
Re: Clumsily cheating the type-check -
Stylock - 06.03.2013
No one knows wtf is #emit except ******, Slice, Zeex, Ryder, Nero3D and maybe a few other people. Ask them or
HERE.