Skip to content
Permalink
Browse files

Add new public var with mapname and new constant (#687)

* Add new public var with current map name

* Add a constant to define max map's name length

* Reducing the maximum buffer size to store a map's name

* The PLATFORM_MAX_PATH constant replaced to MAX_MAPNAME_LENGTH
  • Loading branch information...
KaidoRen authored and Arkshine committed Apr 26, 2019
1 parent 6bed09d commit 1cc7786a4c260ca9ad55fa9fd1c8c415115ead89
Showing with 18 additions and 1 deletion.
  1. +6 −0 amxmodx/CPlugin.cpp
  2. +1 −1 amxmodx/amxmodx.cpp
  3. +10 −0 plugins/include/amxconst.inc
  4. +1 −0 public/engine_strucs.h
@@ -15,6 +15,7 @@
#include "debugger.h"
#include "libraries.h"
#include <amxmodx_version.h>
#include "engine_strucs.h"

extern const char *no_function;

@@ -154,6 +155,11 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
*get_amxaddr(plugin->getAMX(), addr) = gpGlobals->maxClients;
}

if (amx_FindPubVar(plugin->getAMX(), "MapName", &addr) != AMX_ERR_NOTFOUND)
{
set_amxstring(plugin->getAMX(), addr, STRING(gpGlobals->mapname), MAX_MAPNAME_LENGTH - 1);
}

if (amx_FindPubVar(plugin->getAMX(), "NULL_STRING", &addr) != AMX_ERR_NOTFOUND)
{
plugin->m_pNullStringOfs = get_amxaddr(plugin->getAMX(), addr);
@@ -29,7 +29,7 @@ static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params)
char* sName = get_amxstring(amx, params[1], 0, len);
cell ptr;

if (!strcmp(sName, "MaxClients") || !strcmp(sName, "NULL_STRING") || !strcmp(sName, "NULL_VECTOR"))
if (!strcmp(sName, "MaxClients") || !strcmp(sName, "MapName") || !strcmp(sName, "NULL_STRING") || !strcmp(sName, "NULL_VECTOR"))
{
return -1;
}
@@ -29,6 +29,11 @@
*/
#define MAX_STRING_LENGTH 16384

/**
* The maximum buffer size required to store a map's name.
*/
#define MAX_MAPNAME_LENGTH 64

/**
* Defines and constants related to the maximum number of clients.
*
@@ -44,6 +49,11 @@
*/
public stock const MaxClients;

/**
* Current map name
*/
public stock const MapName[MAX_MAPNAME_LENGTH];

/**
* Pass this into certain functions to act as a C++ NULL
*/
@@ -22,6 +22,7 @@
#define MAX_LIGHTSTYLES 64
#define MAX_PACKET_ENTITIES 256
#define MAX_PATH_LENGTH 260
#define MAX_MAPNAME_LENGTH 64

#define MAX_LATENT 32
#define FRAGMENT_SIZE 1400

0 comments on commit 1cc7786

Please sign in to comment.
You can’t perform that action at this time.