more tweaks to binlogs

This commit is contained in:
Borja Ferrer 2006-08-21 03:46:20 +00:00
parent 44a17fe646
commit 45b67b6e2c
2 changed files with 14 additions and 59 deletions

View File

@ -202,21 +202,12 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
} }
case BinLog_NativeError: case BinLog_NativeError:
{ {
int file;
int err = va_arg(ap, int); int err = va_arg(ap, int);
const char *msg = va_arg(ap, const char *); const char *msg = va_arg(ap, const char *);
short len = (short)strlen(msg); short len = (short)strlen(msg);
fwrite(&err, sizeof(int), 1, fp); fwrite(&err, sizeof(int), 1, fp);
fwrite(&len, sizeof(short), 1, fp); fwrite(&len, sizeof(short), 1, fp);
fwrite(msg, sizeof(char), len+1, fp); fwrite(msg, sizeof(char), len+1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break; break;
} }
case BinLog_CallPubFunc: case BinLog_CallPubFunc:
@ -236,13 +227,21 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
} }
case BinLog_SetLine: case BinLog_SetLine:
{ {
int file;
int line = va_arg(ap, int); int line = va_arg(ap, int);
fwrite(&line, sizeof(int), 1, fp); fwrite(&line, sizeof(int), 1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break; break;
} }
case BinLog_FormatString: case BinLog_FormatString:
{ {
int file;
int param = va_arg(ap, int); int param = va_arg(ap, int);
int maxlen = va_arg(ap, int); int maxlen = va_arg(ap, int);
const char *str = va_arg(ap, const char *); const char *str = va_arg(ap, const char *);
@ -251,56 +250,29 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
fwrite(&maxlen, sizeof(int), 1, fp); fwrite(&maxlen, sizeof(int), 1, fp);
fwrite(&len, sizeof(short), 1, fp); fwrite(&len, sizeof(short), 1, fp);
fwrite(str, sizeof(char), len+1, fp); fwrite(str, sizeof(char), len+1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break; break;
} }
case BinLog_NativeParams: case BinLog_NativeParams:
{ {
int file;
cell *params = va_arg(ap, cell *); cell *params = va_arg(ap, cell *);
cell num = params[0] / sizeof(cell); cell num = params[0] / sizeof(cell);
fwrite(&num, sizeof(cell), 1, fp); fwrite(&num, sizeof(cell), 1, fp);
for (cell i=1; i<=num; i++) for (cell i=1; i<=num; i++)
fwrite(&(params[i]), sizeof(cell), 1, fp); fwrite(&(params[i]), sizeof(cell), 1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break; break;
} }
case BinLog_GetString: case BinLog_GetString:
{ {
int file;
cell addr = va_arg(ap, cell); cell addr = va_arg(ap, cell);
const char *str = va_arg(ap, const char *); const char *str = va_arg(ap, const char *);
short len = (short)strlen(str); short len = (short)strlen(str);
fwrite(&addr, sizeof(cell), 1, fp); fwrite(&addr, sizeof(cell), 1, fp);
fwrite(&len, sizeof(short), 1, fp); fwrite(&len, sizeof(short), 1, fp);
fwrite(str, sizeof(char), len+1, fp); fwrite(str, sizeof(char), len+1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break; break;
} }
case BinLog_SetString: case BinLog_SetString:
{ {
int file;
cell addr = va_arg(ap, cell); cell addr = va_arg(ap, cell);
int maxlen = va_arg(ap, int); int maxlen = va_arg(ap, int);
const char *str = va_arg(ap, const char *); const char *str = va_arg(ap, const char *);
@ -309,14 +281,6 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
fwrite(&maxlen, sizeof(int), 1, fp); fwrite(&maxlen, sizeof(int), 1, fp);
fwrite(&len, sizeof(short), 1, fp); fwrite(&len, sizeof(short), 1, fp);
fwrite(str, sizeof(char), len+1, fp); fwrite(str, sizeof(char), len+1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break; break;
} }
}; };

View File

@ -38,28 +38,19 @@
* float gametime * float gametime
* int32 plugin id * int32 plugin id
* <extra info> * <extra info>
* Following operation codes will have an extra int for filename
* If filename is 0 skip as plugin was not in debug mode, if -1 there was an error.
* NativeCall
* NativeRet
* NativeError
* CallPubFunc
* FormatString
* NativeParams
* GetString
* SetString
* ] * ]
* If filename id is 0 skip as plugin was not in debug mode, if -1 there was an error.
*/ */
enum BinLogOp enum BinLogOp
{ {
BinLog_Start=1, BinLog_Start=1,
BinLog_End, BinLog_End,
BinLog_NativeCall, //<int32 native id> <int32_t num_params> BinLog_NativeCall, //<int32 native id> <int32_t num_params> <int32_t filename id>
BinLog_NativeError, //<int32 errornum> <str[int16] string> BinLog_NativeError, //<int32 errornum> <str[int16] string>
BinLog_NativeRet, //<cell value> BinLog_NativeRet, //<cell value> <int32_t filename id>
BinLog_CallPubFunc, //<int32 public id> BinLog_CallPubFunc, //<int32 public id> <int32_t filename id>
BinLog_SetLine, //<int32 line no#> BinLog_SetLine, //<int32 line no#> <int32_t filename id>
BinLog_Registered, //<string title> <string version> BinLog_Registered, //<string title> <string version>
BinLog_FormatString, //<int32 param#> <int32 maxlen> <str[int16] string> BinLog_FormatString, //<int32 param#> <int32 maxlen> <str[int16] string>
BinLog_NativeParams, //<int32 num> <cell ...> BinLog_NativeParams, //<int32 num> <cell ...>