04.06.2012, 14:40
Quote:
Is there any way to use your formatex and the va_format from y_va together?
Cause I use SendClientMessageEx with va_format and I want to use your custom format in SCMEx. |
pawn Код:
stock va_formatex(output[], size = sizeof(output), const fmat[], va_:STATIC_ARGS) {
new
num_args,
arg_start,
arg_end;
// Get the pointer to the number of arguments to the last function.
#emit LOAD.S.pri 0
#emit ADD.C 8
#emit MOVE.alt
// Get the number of arguments.
#emit LOAD.I
#emit STOR.S.pri num_args
// Get the variable arguments (end).
#emit ADD
#emit STOR.S.pri arg_end
// Get the variable arguments (start).
#emit LOAD.S.pri STATIC_ARGS
#emit SMUL.C 4
#emit ADD
#emit STOR.S.pri arg_start
// Using an assembly loop here screwed the code up as the labels added some
// odd stack/frame manipulation code...
while (arg_end != arg_start)
{
#emit MOVE.pri
#emit LOAD.I
#emit PUSH.pri
#emit CONST.pri 4
#emit SUB.alt
#emit STOR.S.pri arg_end
}
// Push the additional parameters.
#emit PUSH.S fmat
#emit PUSH.S size
#emit PUSH.S output
// Push the argument count.
#emit LOAD.S.pri num_args
#emit ADD.C 12
#emit LOAD.S.alt STATIC_ARGS
#emit XCHG
#emit SMUL.C 4
#emit SUB.alt
#emit PUSH.pri
#emit MOVE.alt
// Push the return address.
#emit LCTRL 6
#emit ADD.C 28
#emit PUSH.pri
// Call formatex
#emit CONST.pri formatex
#emit SCTRL 6
}
pawn Код:
static stock
gs_Buffer[256]
;
stock SendClientMessagef(playerid, color, fmat[], va_args<>) {
va_formatex(gs_Buffer, _, fmat, va_start<3>);
SendClientMessage(playerid, color, gs_Buffer);
}
stock SendClientMessageToAllf(color, fmat[], va_args<>) {
va_formatex(gs_Buffer, _, fmat, va_start<2>);
SendClientMessageToAll(color, gs_Buffer);
}
pawn Код:
color = 0xFFFFFFFF;
SendClientMessageToAllf(color, "* %P%C just joined the server.", playerid, color);