mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Fixed a crash bug in FormatAmxString()
Added amx_FindNative to module API Changed LZO->GZ in .amxx format
This commit is contained in:
parent
94219ae71a
commit
9d3ea5513b
@ -47,6 +47,15 @@
|
|||||||
#define FFHL_VERSION 4
|
#define FFHL_VERSION 4
|
||||||
#define FFHL_MIN_VERSION 4
|
#define FFHL_MIN_VERSION 4
|
||||||
|
|
||||||
|
#define NEXT_PARAM() \
|
||||||
|
if (parm > paramCount) \
|
||||||
|
{ \
|
||||||
|
strcpy(outbuf, ""); \
|
||||||
|
len = 0; \
|
||||||
|
AMXXLOG_Log("[AMXX] Plugin did not format a string correctly (parameter %d (total %d), line %d, \"%s\")", parm, paramCount, amx->curline, g_plugins.findPluginFast(amx)); \
|
||||||
|
return outbuf; \
|
||||||
|
}
|
||||||
|
|
||||||
/*version history:
|
/*version history:
|
||||||
* 1 (BAILOPAN) - Simplest form possible, no reverse
|
* 1 (BAILOPAN) - Simplest form possible, no reverse
|
||||||
* 2 (BAILOPAN) - One language per file with full reverse
|
* 2 (BAILOPAN) - One language per file with full reverse
|
||||||
@ -627,8 +636,9 @@ const char *CLangMngr::Format(const char *src, ...)
|
|||||||
|
|
||||||
char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
||||||
{
|
{
|
||||||
cell *src = get_amxaddr(amx, params[parm++]);
|
int paramCount = *params / sizeof(cell);
|
||||||
static char outbuf[4096];
|
static char outbuf[4096];
|
||||||
|
cell *src = get_amxaddr(amx, params[parm++]);
|
||||||
char *outptr = outbuf;
|
char *outptr = outbuf;
|
||||||
enum State
|
enum State
|
||||||
{
|
{
|
||||||
@ -646,6 +656,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
if (*src=='L')
|
if (*src=='L')
|
||||||
{
|
{
|
||||||
cell langName = params[parm]; // "en" case (langName contains the address to the string)
|
cell langName = params[parm]; // "en" case (langName contains the address to the string)
|
||||||
|
NEXT_PARAM();
|
||||||
cell *pAmxLangName = get_amxaddr(amx, params[parm++]); // other cases
|
cell *pAmxLangName = get_amxaddr(amx, params[parm++]); // other cases
|
||||||
const char *cpLangName=NULL;
|
const char *cpLangName=NULL;
|
||||||
// Handle player ids (1-32) and server language
|
// Handle player ids (1-32) and server language
|
||||||
@ -673,6 +684,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
if (!cpLangName || strlen(cpLangName) < 1)
|
if (!cpLangName || strlen(cpLangName) < 1)
|
||||||
cpLangName = "en";
|
cpLangName = "en";
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
NEXT_PARAM();
|
||||||
char *key = get_amxstring(amx, params[parm++], 1, len);
|
char *key = get_amxstring(amx, params[parm++], 1, len);
|
||||||
const char *def = GetDef(cpLangName, key);
|
const char *def = GetDef(cpLangName, key);
|
||||||
if (def == NULL)
|
if (def == NULL)
|
||||||
@ -709,6 +721,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
{
|
{
|
||||||
char tmpString[256];
|
char tmpString[256];
|
||||||
char *tmpPtr = tmpString;
|
char *tmpPtr = tmpString;
|
||||||
|
NEXT_PARAM();
|
||||||
cell *tmpCell = get_amxaddr(amx, params[parm++]);
|
cell *tmpCell = get_amxaddr(amx, params[parm++]);
|
||||||
while (*tmpCell)
|
while (*tmpCell)
|
||||||
*tmpPtr++ = *tmpCell++;
|
*tmpPtr++ = *tmpCell++;
|
||||||
@ -719,15 +732,23 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
case 'g':
|
case 'g':
|
||||||
case 'f':
|
case 'f':
|
||||||
{
|
{
|
||||||
|
NEXT_PARAM();
|
||||||
sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++]));
|
sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'd':
|
case 'd':
|
||||||
{
|
{
|
||||||
|
NEXT_PARAM();
|
||||||
sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++]));
|
sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
*outptr++ = '%';
|
||||||
|
*outptr++ = *(ptr-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
outptr += strlen(outptr);
|
outptr += strlen(outptr);
|
||||||
}
|
}
|
||||||
@ -764,6 +785,8 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
char format[16];
|
char format[16];
|
||||||
format[0] = '%';
|
format[0] = '%';
|
||||||
char *ptr = format+1;
|
char *ptr = format+1;
|
||||||
|
if (*src != '%')
|
||||||
|
{
|
||||||
while (!isalpha(*ptr++ = *src++))
|
while (!isalpha(*ptr++ = *src++))
|
||||||
/*nothing*/;
|
/*nothing*/;
|
||||||
--src;
|
--src;
|
||||||
@ -772,6 +795,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
{
|
{
|
||||||
case 's':
|
case 's':
|
||||||
{
|
{
|
||||||
|
NEXT_PARAM();
|
||||||
cell *tmpCell = get_amxaddr(amx, params[parm++]);
|
cell *tmpCell = get_amxaddr(amx, params[parm++]);
|
||||||
while (*tmpCell)
|
while (*tmpCell)
|
||||||
*tmpPtr++ = *tmpCell++;
|
*tmpPtr++ = *tmpCell++;
|
||||||
@ -782,15 +806,28 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
case 'g':
|
case 'g':
|
||||||
case 'f':
|
case 'f':
|
||||||
{
|
{
|
||||||
|
NEXT_PARAM();
|
||||||
sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++]));
|
sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'd':
|
case 'd':
|
||||||
{
|
{
|
||||||
|
NEXT_PARAM();
|
||||||
sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++]));
|
sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
*outptr++ = '%';
|
||||||
|
*outptr++ = *(ptr-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*outptr++ = '%';
|
||||||
|
*outptr++ = '%';
|
||||||
|
src++;
|
||||||
}
|
}
|
||||||
outptr += strlen(outptr);
|
outptr += strlen(outptr);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,13 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if ( magic == 0x524C4542 ) {
|
||||||
|
//we have an invalid, old, RLEB file
|
||||||
|
m_Status = Err_OldFile;
|
||||||
|
fclose(m_pFile);
|
||||||
|
m_pFile = NULL;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
|
||||||
// try to find the section
|
// try to find the section
|
||||||
mint8_t numOfPlugins;
|
mint8_t numOfPlugins;
|
||||||
@ -165,6 +171,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
m_SectionLength = ftell(m_pFile) - (long)entry.offset;
|
m_SectionLength = ftell(m_pFile) - (long)entry.offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CAmxxReader::~CAmxxReader()
|
CAmxxReader::~CAmxxReader()
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,8 @@ public:
|
|||||||
Err_FileInvalid,
|
Err_FileInvalid,
|
||||||
Err_SectionNotFound,
|
Err_SectionNotFound,
|
||||||
Err_DecompressorInit,
|
Err_DecompressorInit,
|
||||||
Err_Decompress
|
Err_Decompress,
|
||||||
|
Err_OldFile,
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -132,6 +132,8 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
|||||||
case CAmxxReader::Err_Decompress:
|
case CAmxxReader::Err_Decompress:
|
||||||
strcpy(error, "Internal error: Decompress");
|
strcpy(error, "Internal error: Decompress");
|
||||||
return (amx->error = AMX_ERR_NOTFOUND);
|
return (amx->error = AMX_ERR_NOTFOUND);
|
||||||
|
case CAmxxReader::Err_OldFile:
|
||||||
|
strcpy(error, "Plugin uses deprecated format. Update compiler");
|
||||||
default:
|
default:
|
||||||
strcpy(error, "Unknown error");
|
strcpy(error, "Unknown error");
|
||||||
return (amx->error = AMX_ERR_NOTFOUND);
|
return (amx->error = AMX_ERR_NOTFOUND);
|
||||||
@ -894,6 +896,7 @@ void *Module_ReqFnptr(const char *funcName)
|
|||||||
REGISTER_FUNC("amx_Execv", amx_Execv)
|
REGISTER_FUNC("amx_Execv", amx_Execv)
|
||||||
REGISTER_FUNC("amx_Allot", amx_Allot)
|
REGISTER_FUNC("amx_Allot", amx_Allot)
|
||||||
REGISTER_FUNC("amx_FindPublic", amx_FindPublic)
|
REGISTER_FUNC("amx_FindPublic", amx_FindPublic)
|
||||||
|
REGISTER_FUNC("amx_FindNative", amx_FindNative)
|
||||||
|
|
||||||
// Natives / Forwards
|
// Natives / Forwards
|
||||||
REGISTER_FUNC("AddNatives", MNF_AddNatives)
|
REGISTER_FUNC("AddNatives", MNF_AddNatives)
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib"
|
AdditionalDependencies="odbc32.lib odbccp32.lib ..\zlib\zlib.lib"
|
||||||
OutputFile="debug/amxx_mm.dll"
|
OutputFile="debug/amxx_mm.dll"
|
||||||
Version="0.1"
|
Version="0.1"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
|
Loading…
Reference in New Issue
Block a user