Merge branch 'master' into master

This commit is contained in:
Relaxing 2019-04-14 10:12:59 +02:00 committed by GitHub
commit 97fc80dd03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
278 changed files with 106637 additions and 32044 deletions

74
.github/CONTRIBUTING.md vendored Normal file
View File

@ -0,0 +1,74 @@
# Contributing to AMX Mod X
## Issue reports
Please consider the following guidelines when reporting an issue.
#### Not for general support
This is not the right place to get help with using or installing AMX Mod X, or for issues with specific, third-party AMX Mod X plugins or extensions.
For help with AMX Mod X, please consult the [AlliedModders forums](https://forums.alliedmods.net/forumdisplay.php?f=3). Similarly, for assistance with, or to report issues with, third-party AMX Mod X plugins or extensions, you should post in the existing thread for that plugin or extension on the [AlliedModders forums](https://forums.alliedmods.net/forumdisplay.php?f=3).
#### Details, details, details
Provide as much detail as possible when reporting an issue.
For bugs or other undesired behavior, answers to the following questions are a great start:
* What is the issue?
* What behavior are you expecting instead?
* On what operating system is the game server running?
* What game is the game server running?
* What exact versions (full x.y.z.a version number) of Metamod and AMX Mod X are installed on the game server?
* What is the specific, shortest path to reproducing this issue? If this issue can be reproduced with plugin code, please try to shorten it to the minimum required to trigger the problem.
If this is a feature request, the following are helpful. Generally, not all will apply, but whatever you can answer ahead of time will shorten back and forth conversation.
* What is your end goal, or what are you trying to accomplish?
* Why is this necessary, or what benefit do you see with it?
* Will this be useful to others?
#### Issues with security implications
Please report any security bugs to [security@alliedmods.net](mailto:security@alliedmods.net) rather than to this public issue tracker.
#### We're only human
Please keep in mind that we maintain this project in our spare time, at no cost. There is no SLA, and you are not owed a response or a fix.
#### Conduct
Please refer to the [AlliedModders forum rules.](https://forums.alliedmods.net/misc.php?do=showrules)
## Pull Requests
Firstly, thank you for considering contributing changes to the project!
However, if this is anything more than a small fix such as a gamedata update, a glaring code flaw, or a simple typo in a file like this one, please file an issue first so that it can be discussed, unless you have already spoken to multiple members of the development team about it on IRC or the AlliedModders forums.
We don't like to have to reject pull requests, so we want to avoid those scenarios. We wouldn't want you to feel like you wasted your time writing something only for us to shoot it down.
#### Rejection
*Copied from Phabricator's [Contributing Code guidelines](https://secure.phabricator.com/book/phabcontrib/article/contributing_code/#rejecting-patches), as we largely feel the same way about this.*
> If you send us a patch without coordinating it with us first, it will probably be immediately rejected, or sit in limbo for a long time and eventually be rejected. The reasons we do this vary from patch to patch, but some of the most common reasons are:
>
> **Unjustifiable Costs**: We support code in the upstream forever. Support is enormously expensive and takes up a huge amount of our time. The cost to support a change over its lifetime is often 10x or 100x or 1000x greater than the cost to write the first version of it. Many uncoordinated patches we receive are "white elephants", which would cost much more to maintain than the value they provide.
>
> As an author, it may look like you're giving us free work and we're rejecting it as too expensive, but this viewpoint doesn't align with the reality of a large project which is actively supported by a small, experienced team. Writing code is cheap; maintaining it is expensive.
>
> By coordinating with us first, you can make sure the patch is something we consider valuable enough to put long-term support resources behind, and that you're building it in a way that we're comfortable taking over.
>
> **Not a Good Fit**: Many patches aren't good fits for the upstream: they implement features we simply don't want. You can find more information in Contributing Feature Requests. Coordinating with us first helps make sure we're on the same page and interested in a feature.
>
> The most common type of patch along these lines is a patch which adds new configuration options. We consider additional configuration options to have an exceptionally high lifetime support cost and are very unlikely to accept them. Coordinate with us first.
>
> **Not a Priority**: If you send us a patch against something which isn't a priority, we probably won't have time to look at it. We don't give special treatment to low-priority issues just because there's code written: we'd still be spending time on something lower-priority when we could be spending it on something higher-priority instead.
>
> If you coordinate with us first, you can make sure your patch is in an area of the codebase that we can prioritize.
>
> **Overly Ambitious Patches**: Sometimes we'll get huge patches from new contributors. These can have a lot of fundamental problems and require a huge amount of our time to review and correct. If you're interested in contributing, you'll have more success if you start small and learn as you go.
>
> We can help you break a large change into smaller pieces and learn how the codebase works as you proceed through the implementation, but only if you coordinate with us first.
>
> **Generality**: We often receive several feature requests which ask for similar features, and can come up with a general approach which covers all of the use cases. If you send us a patch for your use case only, the approach may be too specific. When a cleaner and more general approach is available, we usually prefer to pursue it.
>
> By coordinating with us first, we can make you aware of similar use cases and opportunities to generalize an approach. These changes are often small, but can have a big impact on how useful a piece of code is.
>
> **Infrastructure and Sequencing**: Sometimes patches are written against a piece of infrastructure with major planned changes. We don't want to accept these because they'll make the infrastructure changes more difficult to implement.
>
> Coordinate with us first to make sure a change doesn't need to wait on other pieces of infrastructure. We can help you identify technical blockers and possibly guide you through resolving them if you're interested.

25
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,25 @@
# Help us help you
- [ ] I have checked that my issue [doesn't exist yet](https://github.com/alliedmodders/amxmodx/issues).
- [ ] I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
- [ ] I can always reproduce the issue with the provided description below.
# Environment
* Operating System version:
* Game/AppID (with version if applicable):
* Current AMX Mod X version:
* Current Metamod version:
- [ ] I have updated AMX Mod X to the [latest version](https://www.amxmodx.org/downloads.php) and it still happens.
- [ ] I have updated AMX Mod X to the [latest snapshot](https://www.amxmodx.org/snapshots.php) and it still happens.
- [ ] I have updated Metamod to the [latest version](https://www.amxmodx.org/downloads.php) and it still happens.
# Description
# Problematic Code (or Steps to Reproduce)
```PAWN
// TODO(you): code here to reproduce the problem
```
# Logs
* Please attach in separate files: game output, library logs, kernel logs, and any other supporting information.
* In case of a crash, please attach minidump or dump analyze output.

2
.gitignore vendored
View File

@ -84,3 +84,5 @@ Thumbs.db
# AMXX plugin build related files # AMXX plugin build related files
plugins/compile.dat plugins/compile.dat
plugins/compiled/ plugins/compiled/
build_deps/

View File

@ -8,6 +8,7 @@ addons:
- linux-libc-dev - linux-libc-dev
- gcc-multilib - gcc-multilib
- g++-multilib - g++-multilib
- nasm
sources: sources:
- llvm-toolchain-precise-3.7 - llvm-toolchain-precise-3.7
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test

View File

@ -20,6 +20,7 @@ class AMXXConfig(object):
self.utf8rewind = None self.utf8rewind = None
self.csx_app = None self.csx_app = None
self.stdcxx_path = None self.stdcxx_path = None
self.nasm_path = None
def use_auto_versioning(self): def use_auto_versioning(self):
if builder.backend != 'amb2': if builder.backend != 'amb2':
@ -105,6 +106,31 @@ class AMXXConfig(object):
if not self.mysql_path: if not self.mysql_path:
raise Exception('Could not find MySQL! Try passing --mysql to configure.py.') raise Exception('Could not find MySQL! Try passing --mysql to configure.py.')
def detectNASM(self):
import subprocess
nasm_paths = [
getattr(builder.options, 'nasm_path', 'nasm'),
]
if builder.target_platform == 'windows':
nasm_paths += [os.path.join(
builder.sourcePath,
'build_deps',
'nasm',
'nasm.exe')
]
for nasm_path in nasm_paths:
try:
subprocess.check_output([nasm_path, '-v'])
self.nasm_path = nasm_path
break
except:
pass
if self.nasm_path is None:
raise Exception('Could not find a suitable path for nasm')
# Returns list of lines of output from the compiler # Returns list of lines of output from the compiler
@staticmethod @staticmethod
def invokeCompiler(args): def invokeCompiler(args):
@ -265,6 +291,9 @@ class AMXXConfig(object):
'odbccp32.lib', 'odbccp32.lib',
] ]
if cxx.version >= 1900:
cxx.linkflags += ['legacy_stdio_definitions.lib', 'legacy_stdio_wide_specifiers.lib']
if builder.options.opt == '1': if builder.options.opt == '1':
cxx.cflags += ['/Ox'] cxx.cflags += ['/Ox']
cxx.linkflags += ['/OPT:ICF', '/OPT:REF'] cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
@ -369,11 +398,42 @@ class AMXXConfig(object):
binary = context.compiler.Program(name) binary = context.compiler.Program(name)
return self.AddVersioning(binary) return self.AddVersioning(binary)
def AddAssembly(self, context, binary, input_file, output_file, includes=[], extra_argv=[]):
if builder.target_platform == 'windows':
obj_type = 'win32'
elif builder.target_platform == 'linux':
obj_type = 'elf32'
elif builder.target_platform == 'mac':
obj_type = 'macho32'
input_path = os.path.join(context.currentSourcePath, input_file)
output_path = output_file
argv = [
self.nasm_path,
'-I{0}{1}'.format(context.currentSourcePath, os.sep),
input_path,
'-f', obj_type,
'-o', output_path,
] + extra_argv
extra_includes = []
for include_file in includes:
extra_includes.append(os.path.join(context.currentSourcePath, include_file))
cmd_node, output_nodes = context.AddCommand(
inputs = [input_path] + extra_includes,
argv = argv,
outputs = [output_path])
binary.compiler.linkflags += [output_nodes[0]]
AMXX = AMXXConfig() AMXX = AMXXConfig()
AMXX.detectProductVersion() AMXX.detectProductVersion()
AMXX.detectMetamod() AMXX.detectMetamod()
AMXX.detectHlsdk() AMXX.detectHlsdk()
AMXX.detectMysql() AMXX.detectMysql()
AMXX.detectNASM()
AMXX.configure() AMXX.configure()
if AMXX.use_auto_versioning(): if AMXX.use_auto_versioning():

View File

@ -1,18 +1,22 @@
AMX Mod X
=========
AMX Mod X - Half-Life 1 Scripting and Server Administration <p align="center">
<img src="https://github.com/alliedmodders/amxmodx/blob/master/editor/studio/AMXXLarge.bmp"/>
</p>
**AMX Mod X** is a [Metamod](https://github.com/jkivilin/metamod-p) plugin for [Half-Life 1](https://github.com/ValveSoftware/halflife). It provides comprehensive scripting for the game engine and its mods. Scripts can intercept network messages, log events, commands, client commands, set cvars, modify entities, and more. AMX Mod X also has a system for extending native scripting through modules, leading to outside support for things like MySQL and Sockets.
General General
------- -------
- [AMXX website](http://www.amxmodx.org/) - [AMXX website](https://amxmodx.org/)
- [Forum](https://forums.alliedmods.net/forumdisplay.php?f=3): Discussion forum including plugin/extension development - [Forum](https://forums.alliedmods.net/forumdisplay.php?f=3): Discussion forum including plugin/extension development
- [General documentation](https://wiki.alliedmods.net/Category:Documentation_%28AMX_Mod_X%29): Miscellaneous information about AMXX - [General documentation](https://wiki.alliedmods.net/Category:Documentation_%28AMX_Mod_X%29): Miscellaneous information about AMXX
- [Latest release](http://www.amxmodx.org/downloads.php): The latest stable AMXX release - [Latest release](https://amxmodx.org/downloads.php): The latest stable AMXX release
- [Build snapshots](http://www.amxmodx.org/snapshots.php): Builds of recent development versions - [Build snapshots](https://www.amxmodx.org/downloads-new.php): Builds of recent development versions
Development Development
----------- -----------
- [Issue tracker](https://bugs.alliedmods.net): Issues that require back and forth communication - [Issue tracker](https://github.com/alliedmodders/amxmodx/issues): Issues that require back and forth communication
- [Issue archive](https://bugs.alliedmods.net/describecomponents.cgi?product=AMX%20Mod%20X): Old issue tracker (read-only)
- [Building AMXX](https://wiki.alliedmods.net/Building_AMX_Mod_X): Instructions on how to build AMXX itself using [AMBuild](https://github.com/alliedmodders/ambuild) - [Building AMXX](https://wiki.alliedmods.net/Building_AMX_Mod_X): Instructions on how to build AMXX itself using [AMBuild](https://github.com/alliedmodders/ambuild)
- [AMX Mod X API](https://amxmodx.org/api/): AMX Mod X API reference generated from include files
- [AMXX scripting](https://wiki.alliedmods.net/Category:Scripting_(AMX_Mod_X)): Pawn examples and introduction to the language - [AMXX scripting](https://wiki.alliedmods.net/Category:Scripting_(AMX_Mod_X)): Pawn examples and introduction to the language

View File

@ -9,36 +9,25 @@ binary.compiler.defines += [
'HAVE_STDINT_H', 'HAVE_STDINT_H',
] ]
AMXX.AddAssembly(builder, binary, 'helpers-x86.asm', 'helpers-asm.obj')
AMXX.AddAssembly(builder, binary, 'natives-x86.asm', 'natives-asm.obj')
AMXX.AddAssembly(builder, binary, 'amxexecn.asm', 'amxexecn-asm.obj',
includes=['amxdefn.asm'])
AMXX.AddAssembly(builder, binary, 'amxjitsn.asm', 'amxjitsn-asm.obj',
includes=['amxdefn.asm'],
# Opcode sizes must be maximum width for patching to work.
extra_argv=['-O0'])
if builder.target_platform == 'mac': if builder.target_platform == 'mac':
jit_objects = [
binary.Dep('JIT/amxexecn-darwin.o'),
binary.Dep('JIT/amxjitsn-darwin.o'),
binary.Dep('JIT/natives-darwin-x86.o'),
binary.Dep('JIT/helpers-darwin-x86.o'),
]
binary.compiler.postlink += [ binary.compiler.postlink += [
'-Wl,-read_only_relocs,suppress' '-Wl,-read_only_relocs,suppress'
] ]
elif builder.target_platform == 'linux':
jit_objects = [
binary.Dep('JIT/amxexecn.o'),
binary.Dep('JIT/amxjitsn.o'),
binary.Dep('JIT/natives-x86.o'),
binary.Dep('JIT/helpers-x86.o'),
]
elif builder.target_platform == 'windows': elif builder.target_platform == 'windows':
jit_objects = [
binary.Dep('JIT/amxexecn.obj'),
binary.Dep('JIT/amxjitsn.obj'),
binary.Dep('JIT/helpers-x86.obj'),
binary.Dep('JIT/natives-x86.obj'),
]
binary.compiler.linkflags += [ binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1', '/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW', '/SECTION:.data,RW',
] ]
binary.compiler.linkflags += jit_objects
binary.compiler.linkflags += [AMXX.zlib.binary, AMXX.hashing.binary, AMXX.utf8rewind.binary] binary.compiler.linkflags += [AMXX.zlib.binary, AMXX.hashing.binary, AMXX.utf8rewind.binary]
binary.sources = [ binary.sources = [

View File

@ -325,16 +325,16 @@ SMCResult CGameConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key
} }
else if (!strcmp(key, "size")) else if (!strcmp(key, "size"))
{ {
TempType.fieldSize = ke::Max<int>(0, atoi(value)); TempType.fieldSize = ke::Max<int>(0, strtol(value, nullptr, 0));
} }
else if (!strcmp(key, "unsigned")) else if (!strcmp(key, "unsigned"))
{ {
TempType.fieldUnsigned = !!atoi(value); TempType.fieldUnsigned = !!strtol(value, nullptr, 0);
} }
else if (g_LibSys.IsPlatformCompatible(key, &m_MatchedPlatform)) else if (g_LibSys.IsPlatformCompatible(key, &m_MatchedPlatform))
{ {
m_FoundOffset = true; m_FoundOffset = true;
TempType.fieldOffset = atoi(value); TempType.fieldOffset = strtol(value, nullptr, 0);
} }
break; break;
} }
@ -397,7 +397,7 @@ SMCResult CGameConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key
if (m_AddressReadCount < limit) if (m_AddressReadCount < limit)
{ {
m_AddressRead[m_AddressReadCount] = atoi(value); m_AddressRead[m_AddressReadCount] = strtol(value, nullptr, 0);
m_AddressReadCount++; m_AddressReadCount++;
} }
else else

View File

@ -12,6 +12,7 @@
#include <IGameConfigs.h> #include <IGameConfigs.h>
#include "CLibrarySys.h" #include "CLibrarySys.h"
#include <amtl/am-autoptr.h>
#include <amtl/am-vector.h> #include <amtl/am-vector.h>
#include <amtl/am-string.h> #include <amtl/am-string.h>
#include <amtl/am-refcounting.h> #include <amtl/am-refcounting.h>
@ -166,6 +167,19 @@ class CGameConfigManager : public IGameConfigManager
StringHashMap<ITextListener_SMC*> m_customHandlers; StringHashMap<ITextListener_SMC*> m_customHandlers;
}; };
#define GET_OFFSET(classname, member) \
static int member = -1; \
if (member == -1) \
{ \
TypeDescription type; \
if (!CommonConfig->GetOffsetByClass(classname, #member, &type) || type.fieldOffset < 0)\
{ \
LogError(amx, AMX_ERR_NATIVE, "Invalid %s offset. Native %s is disabled", #member, __FUNCTION__);\
return 0; \
} \
member = type.fieldOffset; \
}
extern CGameConfigManager ConfigManager; extern CGameConfigManager ConfigManager;
extern IGameConfig *CommonConfig; extern IGameConfig *CommonConfig;

View File

@ -18,14 +18,14 @@
extern const char *no_function; extern const char *no_function;
CPluginMngr::CPlugin* CPluginMngr::loadPlugin(const char* path, const char* name, char* error, int debug) CPluginMngr::CPlugin* CPluginMngr::loadPlugin(const char* path, const char* name, char* error, size_t maxLength, int debug)
{ {
CPlugin** a = &head; CPlugin** a = &head;
while (*a) while (*a)
a = &(*a)->next; a = &(*a)->next;
*a = new CPlugin(pCounter++, path, name, error, debug); *a = new CPlugin(pCounter++, path, name, error, maxLength, debug);
return (*a); return (*a);
} }
@ -137,7 +137,7 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
continue; continue;
} }
CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, debugFlag); CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, sizeof(error), debugFlag);
if (plugin->getStatusCode() == ps_bad_load) if (plugin->getStatusCode() == ps_bad_load)
{ {
@ -267,7 +267,7 @@ const char* CPluginMngr::CPlugin::getStatus() const
return "error"; return "error";
} }
CPluginMngr::CPlugin::CPlugin(int i, const char* p, const char* n, char* e, int d) : name(n), title(n), m_pNullStringOfs(nullptr), m_pNullVectorOfs(nullptr) CPluginMngr::CPlugin::CPlugin(int i, const char* p, const char* n, char* e, size_t m, int d) : name(n), title(n), m_pNullStringOfs(nullptr), m_pNullVectorOfs(nullptr)
{ {
const char* unk = "unknown"; const char* unk = "unknown";
@ -280,7 +280,7 @@ CPluginMngr::CPlugin::CPlugin(int i, const char* p, const char* n, char* e, int
char* path = build_pathname_r(file, sizeof(file), "%s/%s", p, n); char* path = build_pathname_r(file, sizeof(file), "%s/%s", p, n);
code = 0; code = 0;
memset(&amx, 0, sizeof(AMX)); memset(&amx, 0, sizeof(AMX));
int err = load_amxscript(&amx, &code, path, e, d); int err = load_amxscript_ex(&amx, &code, path, e, m, d);
if (err == AMX_ERR_NONE) if (err == AMX_ERR_NONE)
{ {

View File

@ -15,6 +15,7 @@
#include "amxxfile.h" #include "amxxfile.h"
#include <amtl/am-string.h> #include <amtl/am-string.h>
#include <amtl/am-vector.h> #include <amtl/am-vector.h>
#include <amtl/am-autoptr.h>
// ***************************************************** // *****************************************************
// class CPluginMngr // class CPluginMngr
@ -65,7 +66,7 @@ public:
CPlugin* next; CPlugin* next;
int id; int id;
CPlugin(int i, const char* p, const char* n, char* e, int d); CPlugin(int i, const char* p, const char* n, char* e, size_t m, int d);
~CPlugin(); ~CPlugin();
bool m_Debug; bool m_Debug;
@ -121,7 +122,7 @@ public:
// Interface // Interface
CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug); CPlugin* loadPlugin(const char* path, const char* name, char* error, size_t maxLength, int debug);
void unloadPlugin(CPlugin** a); void unloadPlugin(CPlugin** a);
int loadPluginsFromFile(const char* filename, bool warn=true); int loadPluginsFromFile(const char* filename, bool warn=true);

View File

@ -53,7 +53,7 @@ void CoreConfig::ExecuteMainConfig()
char path[PLATFORM_MAX_PATH]; char path[PLATFORM_MAX_PATH];
char command[PLATFORM_MAX_PATH + sizeof(CommandFormat)]; char command[PLATFORM_MAX_PATH + sizeof(CommandFormat)];
ke::SafeSprintf(path, sizeof(path), "%s/%s/%s", g_mod_name.chars(), get_localinfo("amx_configdir", "addons/amxmodx/configs"), MainConfigFile); ke::SafeSprintf(path, sizeof(path), "%s/%s/%s", g_mod_name.chars(), get_localinfo("amxx_configsdir", "addons/amxmodx/configs"), MainConfigFile);
ke::SafeSprintf(command, sizeof(command), CommandFormat, path); ke::SafeSprintf(command, sizeof(command), CommandFormat, path);
SERVER_COMMAND(command); SERVER_COMMAND(command);
@ -80,7 +80,7 @@ bool CoreConfig::ExecuteAutoConfig(CPluginMngr::CPlugin *plugin, AutoConfig *con
{ {
bool will_create = false; bool will_create = false;
const char *configsDir = get_localinfo("amx_configdir", "addons/amxmodx/configs"); const char *configsDir = get_localinfo("amxx_configsdir", "addons/amxmodx/configs");
if (can_create && config->create) if (can_create && config->create)
{ {
@ -254,7 +254,7 @@ bool CoreConfig::ExecuteAutoConfig(CPluginMngr::CPlugin *plugin, AutoConfig *con
void CoreConfig::ExecuteMapConfig() void CoreConfig::ExecuteMapConfig()
{ {
const char *configsDir = get_localinfo("amx_configdir", "addons/amxmodx/configs"); const char *configsDir = get_localinfo("amxx_configsdir", "addons/amxmodx/configs");
char cfgPath[PLATFORM_MAX_PATH]; char cfgPath[PLATFORM_MAX_PATH];
char mapName[PLATFORM_MAX_PATH]; char mapName[PLATFORM_MAX_PATH];

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -214,7 +214,7 @@ static cell AMX_NATIVE_CALL console_print(AMX *amx, cell *params) /* 2 param */
{ {
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame) if (pPlayer->ingame && !pPlayer->IsBot())
{ {
if (len > 126) // Client console truncates after byte 127. (126 + \n = 127) if (len > 126) // Client console truncates after byte 127. (126 + \n = 127)
{ {
@ -247,7 +247,7 @@ static cell AMX_NATIVE_CALL client_print(AMX *amx, cell *params) /* 3 param */
{ {
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i); CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame) if (pPlayer->ingame && !pPlayer->IsBot())
{ {
g_langMngr.SetDefLang(i); g_langMngr.SetDefLang(i);
msg = format_amxstring(amx, params, 3, len); msg = format_amxstring(amx, params, 3, len);
@ -280,7 +280,7 @@ static cell AMX_NATIVE_CALL client_print(AMX *amx, cell *params) /* 3 param */
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame) if (pPlayer->ingame && !pPlayer->IsBot())
{ {
g_langMngr.SetDefLang(index); g_langMngr.SetDefLang(index);
@ -338,7 +338,7 @@ static cell AMX_NATIVE_CALL client_print_color(AMX *amx, cell *params) /* 3 para
g_langMngr.SetDefLang(i); g_langMngr.SetDefLang(i);
msg = format_amxstring(amx, params, 3, len); msg = format_amxstring(amx, params, 3, len);
if (*msg > 4) // Insert default color code at the start if not present, otherwise message will not be colored. if (static_cast<byte>(*msg) > 4) // Insert default color code at the start if not present, otherwise message will not be colored.
{ {
memmove(msg + 1, msg, ke::Min(len++, 191)); memmove(msg + 1, msg, ke::Min(len++, 191));
*msg = 1; *msg = 1;
@ -376,7 +376,7 @@ static cell AMX_NATIVE_CALL client_print_color(AMX *amx, cell *params) /* 3 para
msg = format_amxstring(amx, params, 3, len); msg = format_amxstring(amx, params, 3, len);
if (*msg > 4) // Insert default color code at the start if not present, otherwise message will not be colored. if (static_cast<byte>(*msg) > 4) // Insert default color code at the start if not present, otherwise message will not be colored.
{ {
memmove(msg + 1, msg, ke::Min(len++, 191)); memmove(msg + 1, msg, ke::Min(len++, 191));
*msg = 1; *msg = 1;
@ -427,7 +427,7 @@ static cell AMX_NATIVE_CALL show_motd(AMX *amx, cell *params) /* 3 param */
{ {
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame) if (pPlayer->ingame && !pPlayer->IsBot())
UTIL_ShowMOTD(pPlayer->pEdict, sToShow, ilen, szHead); UTIL_ShowMOTD(pPlayer->pEdict, sToShow, ilen, szHead);
} }
} else { } else {
@ -444,7 +444,7 @@ static cell AMX_NATIVE_CALL show_motd(AMX *amx, cell *params) /* 3 param */
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame) if (pPlayer->ingame && !pPlayer->IsBot())
UTIL_ShowMOTD(pPlayer->pEdict, sToShow, ilen, szHead); UTIL_ShowMOTD(pPlayer->pEdict, sToShow, ilen, szHead);
} }
@ -524,7 +524,7 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param *
{ {
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i); CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame) if (pPlayer->ingame && !pPlayer->IsBot())
{ {
g_langMngr.SetDefLang(i); g_langMngr.SetDefLang(i);
message = UTIL_SplitHudMessage(format_amxstring(amx, params, 2, len)); message = UTIL_SplitHudMessage(format_amxstring(amx, params, 2, len));
@ -551,7 +551,7 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param *
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame) if (pPlayer->ingame && !pPlayer->IsBot())
{ {
if (aut) if (aut)
{ {
@ -787,22 +787,27 @@ static cell AMX_NATIVE_CALL is_user_alive(AMX *amx, cell *params) /* 1 param */
if (index < 1 || index > gpGlobals->maxClients) if (index < 1 || index > gpGlobals->maxClients)
{ {
return 0; return FALSE;
} }
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (!pPlayer->ingame)
{
return FALSE;
}
if (g_bmod_tfc) if (g_bmod_tfc)
{ {
edict_t *e = pPlayer->pEdict; edict_t *e = pPlayer->pEdict;
if (e->v.flags & FL_SPECTATOR || if (e->v.flags & FL_SPECTATOR ||
(!e->v.team || !e->v.playerclass)) (!e->v.team || !e->v.playerclass))
{ {
return 0; return FALSE;
} }
} }
return ((pPlayer->ingame && pPlayer->IsAlive()) ? 1 : 0); return pPlayer->IsAlive() ? TRUE : FALSE;
} }
static cell AMX_NATIVE_CALL get_amxx_verstring(AMX *amx, cell *params) /* 2 params */ static cell AMX_NATIVE_CALL get_amxx_verstring(AMX *amx, cell *params) /* 2 params */
@ -1106,6 +1111,12 @@ static cell AMX_NATIVE_CALL user_has_weapon(AMX *amx, cell *params)
} }
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (!pPlayer->ingame)
{
return 0;
}
edict_t *pEntity = pPlayer->pEdict; edict_t *pEntity = pPlayer->pEdict;
if (params[3] == -1) if (params[3] == -1)
@ -1246,31 +1257,55 @@ static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params) /* 3 param */
static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
{ {
// If show_menu is called from within a newmenu callback upon receiving MENU_EXIT auto closeMenu = [amx](int index) -> int
// it is possible for this native to recurse. We need to close newmenus right away
// because the recursive call would otherwise modify/corrupt the static get_amxstring
// buffer mid execution. This will either display incorrect text or result in UTIL_ShowMenu
// running into an infinite loop.
int index = params[1];
if (index == 0)
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) auto pPlayer = GET_PLAYER_POINTER_I(index);
{
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame) if (!pPlayer->ingame)
{ {
return 1;
}
pPlayer->keys = 0; pPlayer->keys = 0;
pPlayer->menu = 0; pPlayer->menu = 0;
// Fire newmenu callback so closing it can be handled by the plugin // Fire newmenu callback so closing it can be handled by the plugin
if (!CloseNewMenus(pPlayer)) if (!CloseNewMenus(pPlayer))
{ {
LogError(amx, AMX_ERR_NATIVE, "Plugin called menu_display when item=MENU_EXIT"); return 2;
return 0;
} }
UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0); if (g_bmod_cstrike)
{
enum JoinState { Joined = 0 };
enum MenuState { Menu_OFF = 0, Menu_ChooseTeam = 1, Menu_ChooseAppearance = 3 };
GET_OFFSET("CBasePlayer", m_iJoiningState);
GET_OFFSET("CBasePlayer", m_iMenu);
if (get_pdata<int>(pPlayer->pEdict, m_iJoiningState) == Joined || (get_pdata<int>(pPlayer->pEdict, m_iMenu) != Menu_ChooseTeam && get_pdata<int>(pPlayer->pEdict, m_iMenu) != Menu_ChooseAppearance))
{
set_pdata<int>(pPlayer->pEdict, m_iMenu, Menu_OFF);
}
}
return 0;
};
int index = params[1];
// If show_menu is called from within a newmenu callback upon receiving MENU_EXIT
// it is possible for this native to recurse. We need to close newmenus right away
// because the recursive call would otherwise modify/corrupt the static get_amxstring
// buffer mid execution. This will either display incorrect text or result in UTIL_ShowMenu
// running into an infinite loop.
if (index == 0)
{
for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
if (closeMenu(i) == 2)
{
return 0;
} }
} }
} }
@ -1282,23 +1317,7 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
return 0; return 0;
} }
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); if (closeMenu(index) == 2)
if (pPlayer->ingame)
{
pPlayer->keys = 0;
pPlayer->menu = 0;
// Fire newmenu callback so closing it can be handled by the plugin
if (!CloseNewMenus(pPlayer))
{
LogError(amx, AMX_ERR_NATIVE, "Plugin called menu_display when item=MENU_EXIT");
return 0;
}
UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0);
}
else
{ {
return 0; return 0;
} }
@ -1343,6 +1362,8 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
} else { } else {
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
{
pPlayer->keys = keys; pPlayer->keys = keys;
pPlayer->menu = menuid; pPlayer->menu = menuid;
pPlayer->vgui = false; pPlayer->vgui = false;
@ -1355,6 +1376,7 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
pPlayer->page = 0; pPlayer->page = 0;
UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen); UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen);
} }
}
return 1; return 1;
} }
@ -2614,11 +2636,11 @@ static cell AMX_NATIVE_CALL change_task(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL engine_changelevel(AMX *amx, cell *params) static cell AMX_NATIVE_CALL engine_changelevel(AMX *amx, cell *params)
{ {
int length; int length;
const char* new_map = get_amxstring(amx, params[1], 0, length); ke::AString new_map(get_amxstring(amx, params[1], 0, length));
// Same as calling "changelevel" command but will trigger "server_changelevel" AMXX forward as well. // Same as calling "changelevel" command but will trigger "server_changelevel" AMXX forward as well.
// Filling second param will call "changelevel2" command, but this is not usable in multiplayer game. // Filling second param will call "changelevel2" command, but this is not usable in multiplayer game.
g_pEngTable->pfnChangeLevel(new_map, NULL); g_pEngTable->pfnChangeLevel(new_map.chars(), NULL);
return 1; return 1;
} }
@ -4700,6 +4722,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"precache_model", precache_model}, {"precache_model", precache_model},
{"precache_sound", precache_sound}, {"precache_sound", precache_sound},
{"precache_generic", precache_generic}, {"precache_generic", precache_generic},
{"precache_event", precache_event},
{"random_float", random_float}, {"random_float", random_float},
{"random_num", random_num}, {"random_num", random_num},
{"read_argc", read_argc}, {"read_argc", read_argc},

View File

@ -284,6 +284,7 @@ extern "C" size_t get_amxstring_r(AMX *amx, cell amx_addr, char *destination, in
int amxstring_len(cell* cstr); int amxstring_len(cell* cstr);
int load_amxscript(AMX* amx, void** program, const char* path, char error[64], int debug); int load_amxscript(AMX* amx, void** program, const char* path, char error[64], int debug);
int load_amxscript_ex(AMX* amx, void** program, const char* path, char *error, size_t maxLength, int debug);
int set_amxnatives(AMX* amx, char error[64]); int set_amxnatives(AMX* amx, char error[64]);
int set_amxstring(AMX *amx, cell amx_addr, const char *source, int max); int set_amxstring(AMX *amx, cell amx_addr, const char *source, int max);
int set_amxstring_simple(cell *dest, const char *source, int max); int set_amxstring_simple(cell *dest, const char *source, int max);

View File

@ -87,6 +87,7 @@ void Client_TeamInfo(void* mValue)
case 1: case 1:
if (index < 1 || index > gpGlobals->maxClients) break; if (index < 1 || index > gpGlobals->maxClients) break;
char* msg = (char*)mValue; char* msg = (char*)mValue;
if (!msg) break;
g_players[index].team = msg; g_players[index].team = msg;
g_teamsIds.registerTeam(msg, -1); g_teamsIds.registerTeam(msg, -1);
g_players[index].teamId = g_teamsIds.findTeamId(msg); g_players[index].teamId = g_teamsIds.findTeamId(msg);

View File

@ -657,10 +657,11 @@ void C_ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
pPlayer->Init(pEdictList + i, i); pPlayer->Init(pEdictList + i, i);
} }
CoreCfg.ExecuteMainConfig(); // Execute amxx.cfg
executeForwards(FF_PluginInit); executeForwards(FF_PluginInit);
executeForwards(FF_PluginCfg); executeForwards(FF_PluginCfg);
CoreCfg.ExecuteMainConfig(); // Execute amxx.cfg
CoreCfg.ExecuteAutoConfigs(); // Execute configs created with AutoExecConfig native. CoreCfg.ExecuteAutoConfigs(); // Execute configs created with AutoExecConfig native.
CoreCfg.SetMapConfigTimer(6.1); // Prepare per-map configs to be executed 6.1 seconds later. CoreCfg.SetMapConfigTimer(6.1); // Prepare per-map configs to be executed 6.1 seconds later.
// Original value which was used in admin.sma. // Original value which was used in admin.sma.
@ -1433,8 +1434,15 @@ int C_Cmd_Argc(void)
// Only here we may find out who is an owner. // Only here we may find out who is an owner.
void C_SetModel(edict_t *e, const char *m) void C_SetModel(edict_t *e, const char *m)
{ {
if (e->v.owner && m[7]=='w' && m[8]=='_' && m[9]=='h') if (!m || strcmp(m, "models/w_hegrenade.mdl") != 0)
g_grenades.put(e, 1.75, 4, GET_PLAYER_POINTER(e->v.owner)); {
RETURN_META(MRES_IGNORED);
}
if (e->v.owner)
{
g_grenades.put(e, 1.75f, 4, GET_PLAYER_POINTER(e->v.owner));
}
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }

View File

@ -108,7 +108,7 @@ static binlogfuncs_t logfuncs =
}; };
#endif #endif
int load_amxscript(AMX *amx, void **program, const char *filename, char error[64], int debug) int load_amxscript_internal(AMX *amx, void **program, const char *filename, char *error, size_t maxLength, int debug)
{ {
*error = 0; *error = 0;
size_t bufSize; size_t bufSize;
@ -127,7 +127,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
if (!*program) if (!*program)
{ {
strcpy(error, "Failed to allocate memory"); ke::SafeStrcpy(error, maxLength, "Failed to allocate memory");
return (amx->error = AMX_ERR_MEMORY); return (amx->error = AMX_ERR_MEMORY);
} }
@ -140,31 +140,31 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
case CAmxxReader::Err_None: case CAmxxReader::Err_None:
break; break;
case CAmxxReader::Err_FileOpen: case CAmxxReader::Err_FileOpen:
strcpy(error, "Plugin file open error"); ke::SafeStrcpy(error, maxLength, "Plugin file open error");
return (amx->error = AMX_ERR_NOTFOUND); return (amx->error = AMX_ERR_NOTFOUND);
case CAmxxReader::Err_FileRead: case CAmxxReader::Err_FileRead:
strcpy(error, "Plugin file read error"); ke::SafeStrcpy(error, maxLength, "Plugin file read error");
return (amx->error = AMX_ERR_NOTFOUND); return (amx->error = AMX_ERR_NOTFOUND);
case CAmxxReader::Err_InvalidParam: case CAmxxReader::Err_InvalidParam:
strcpy(error, "Internal error: Invalid parameter"); ke::SafeStrcpy(error, maxLength, "Internal error: Invalid parameter");
return (amx->error = AMX_ERR_NOTFOUND); return (amx->error = AMX_ERR_NOTFOUND);
case CAmxxReader::Err_FileInvalid: case CAmxxReader::Err_FileInvalid:
strcpy(error, "Invalid Plugin"); ke::SafeStrcpy(error, maxLength, "Invalid Plugin");
return (amx->error = AMX_ERR_FORMAT); return (amx->error = AMX_ERR_FORMAT);
case CAmxxReader::Err_SectionNotFound: case CAmxxReader::Err_SectionNotFound:
strcpy(error, "Searched section not found (.amxx)"); ke::SafeStrcpy(error, maxLength, "Searched section not found (.amxx)");
return (amx->error = AMX_ERR_NOTFOUND); return (amx->error = AMX_ERR_NOTFOUND);
case CAmxxReader::Err_DecompressorInit: case CAmxxReader::Err_DecompressorInit:
strcpy(error, "Decompressor initialization failed"); ke::SafeStrcpy(error, maxLength, "Decompressor initialization failed");
return (amx->error = AMX_ERR_INIT); return (amx->error = AMX_ERR_INIT);
case CAmxxReader::Err_Decompress: case CAmxxReader::Err_Decompress:
strcpy(error, "Internal error: Decompress"); ke::SafeStrcpy(error, maxLength, "Internal error: Decompress");
return (amx->error = AMX_ERR_NOTFOUND); return (amx->error = AMX_ERR_NOTFOUND);
case CAmxxReader::Err_OldFile: case CAmxxReader::Err_OldFile:
strcpy(error, "Plugin uses deprecated format. Update compiler"); ke::SafeStrcpy(error, maxLength, "Plugin uses deprecated format. Update compiler");
return (amx->error = AMX_ERR_FORMAT); return (amx->error = AMX_ERR_FORMAT);
default: default:
strcpy(error, "Unknown error"); ke::SafeStrcpy(error, maxLength, "Unknown error");
return (amx->error = AMX_ERR_NOTFOUND); return (amx->error = AMX_ERR_NOTFOUND);
} }
} else { } else {
@ -178,7 +178,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
if (magic != AMX_MAGIC) if (magic != AMX_MAGIC)
{ {
strcpy(error, "Invalid Plugin"); ke::SafeStrcpy(error, maxLength, "Invalid Plugin");
return (amx->error = AMX_ERR_FORMAT); return (amx->error = AMX_ERR_FORMAT);
} }
@ -191,7 +191,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
{ {
if ((hdr->file_version < CUR_FILE_VERSION)) if ((hdr->file_version < CUR_FILE_VERSION))
{ {
sprintf(error, "Plugin needs newer debug version info"); ke::SafeStrcpy(error, maxLength, "Plugin needs newer debug version info");
return (amx->error = AMX_ERR_VERSION); return (amx->error = AMX_ERR_VERSION);
} }
else if ((hdr->flags & AMX_FLAG_DEBUG) != 0) else if ((hdr->flags & AMX_FLAG_DEBUG) != 0)
@ -209,13 +209,13 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
{ {
dbg_FreeInfo(pDbg); dbg_FreeInfo(pDbg);
delete pDbg; delete pDbg;
sprintf(error, "Debug loading error %d", err); ke::SafeSprintf(error, maxLength, "Debug loading error %d", err);
return (amx->error = AMX_ERR_INIT); return (amx->error = AMX_ERR_INIT);
} }
amx->flags |= AMX_FLAG_DEBUG; amx->flags |= AMX_FLAG_DEBUG;
} else { } else {
sprintf(error, "Plugin not compiled with debug option"); ke::SafeStrcpy(error, maxLength, "Plugin not compiled with debug option");
return (amx->error = AMX_ERR_INIT); return (amx->error = AMX_ERR_INIT);
} }
} else { } else {
@ -238,7 +238,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
delete pDbg; delete pDbg;
} }
sprintf(error, "Load error %d (invalid file format or version)", err); ke::SafeSprintf(error, maxLength, "Load error %d (invalid file format or version)", err);
return (amx->error = AMX_ERR_INIT); return (amx->error = AMX_ERR_INIT);
} }
@ -276,7 +276,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
{ {
delete[] np; delete[] np;
delete[] rt; delete[] rt;
strcpy(error, "Failed to initialize JIT'd plugin"); ke::SafeStrcpy(error, maxLength, "Failed to initialize JIT'd plugin");
return (amx->error = AMX_ERR_INIT); return (amx->error = AMX_ERR_INIT);
} }
@ -307,14 +307,14 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
if (*program == 0) if (*program == 0)
{ {
strcpy(error, "Failed to allocate memory"); ke::SafeStrcpy(error, maxLength, "Failed to allocate memory");
return (amx->error = AMX_ERR_MEMORY); return (amx->error = AMX_ERR_MEMORY);
} }
} else { } else {
delete[] np; delete[] np;
delete[] rt; delete[] rt;
sprintf(error, "Failed to initialize plugin (%d)", err); ke::SafeSprintf(error, maxLength, "Failed to initialize plugin (%d)", err);
return (amx->error = AMX_ERR_INIT_JIT); return (amx->error = AMX_ERR_INIT_JIT);
} }
@ -325,7 +325,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
if (!script) if (!script)
{ {
ke::SafeSprintf(error, 64, "Failed to allocate memory for script"); ke::SafeStrcpy(error, maxLength, "Failed to allocate memory for script");
return (amx->error = AMX_ERR_MEMORY); return (amx->error = AMX_ERR_MEMORY);
} }
@ -341,7 +341,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
{ {
if (amx_Register(amx, core_Natives, -1) != AMX_ERR_NONE) if (amx_Register(amx, core_Natives, -1) != AMX_ERR_NONE)
{ {
sprintf(error, "Plugin uses an unknown function (name \"%s\") - check your modules.ini.", no_function); ke::SafeSprintf(error, maxLength, "Plugin uses an unknown function (name \"%s\") - check your modules.ini.", no_function);
return (amx->error = AMX_ERR_NOTFOUND); return (amx->error = AMX_ERR_NOTFOUND);
} }
} else { } else {
@ -352,6 +352,17 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
return (amx->error = AMX_ERR_NONE); return (amx->error = AMX_ERR_NONE);
} }
int load_amxscript_ex(AMX *amx, void **program, const char *filename, char *error, size_t maxLength, int debug)
{
return load_amxscript_internal(amx, program, filename, error, maxLength, debug);
}
// Deprecated. Use load_amxscript_ex() or MF_LoadAmxScriptEx() for modules. This function is kept to maintain backward compatibility.
int load_amxscript(AMX *amx, void **program, const char *filename, char error[64], int debug)
{
return load_amxscript_internal(amx, program, filename, error, 64 /* error max length */, debug);
}
const char *StrCaseStr(const char *as, const char *bs) const char *StrCaseStr(const char *as, const char *bs)
{ {
static char a[256]; static char a[256];
@ -1759,7 +1770,8 @@ void Module_CacheFunctions()
REGISTER_FUNC("GetAmxScriptName", MNF_GetAmxScriptName) REGISTER_FUNC("GetAmxScriptName", MNF_GetAmxScriptName)
REGISTER_FUNC("FindAmxScriptByName", MNF_FindAmxScriptByName) REGISTER_FUNC("FindAmxScriptByName", MNF_FindAmxScriptByName)
REGISTER_FUNC("FindAmxScriptByAmx", MNF_FindAmxScriptByAmx) REGISTER_FUNC("FindAmxScriptByAmx", MNF_FindAmxScriptByAmx)
REGISTER_FUNC("LoadAmxScript", load_amxscript) REGISTER_FUNC("LoadAmxScript", load_amxscript) // Deprecated. Please use LoadAmxScriptEx instead.
REGISTER_FUNC("LoadAmxScriptEx", load_amxscript_ex)
REGISTER_FUNC("UnloadAmxScript", unload_amxscript) REGISTER_FUNC("UnloadAmxScript", unload_amxscript)
// String / mem in amx scripts support // String / mem in amx scripts support

View File

@ -96,6 +96,14 @@
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes> <SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
<PreBuildEvent>
<Command>cd ..
md -p JIT 2&gt;NUL
%NASM_PATH%nasm.exe -f win32 helpers-x86.asm -o JIT/helpers-x86.obj
%NASM_PATH%nasm.exe -f win32 natives-x86.asm -o JIT/natives-x86.obj
%NASM_PATH%nasm.exe -f win32 amxexecn.asm -o JIT/amxexecn.obj
%NASM_PATH%nasm.exe -O0 -f win32 amxjitsn.asm -o JIT/amxjitsn.obj</Command>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='JITRelease|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='JITRelease|Win32'">
<Midl> <Midl>
@ -148,6 +156,14 @@
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes> <SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
<PreBuildEvent>
<Command>cd ..
md -p JIT 2&gt;NUL
%NASM_PATH%nasm.exe -f win32 helpers-x86.asm -o JIT/helpers-x86.obj
%NASM_PATH%nasm.exe -f win32 natives-x86.asm -o JIT/natives-x86.obj
%NASM_PATH%nasm.exe -f win32 amxexecn.asm -o JIT/amxexecn.obj
%NASM_PATH%nasm.exe -O0 -f win32 amxjitsn.asm -o JIT/amxjitsn.obj</Command>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\public\memtools\CDetour\asm\asm.c" /> <ClCompile Include="..\..\public\memtools\CDetour\asm\asm.c" />
@ -430,7 +446,10 @@
<ClInclude Include="..\..\public\sdk\moduleconfig.h" /> <ClInclude Include="..\..\public\sdk\moduleconfig.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\version.rc" /> <ResourceCompile Include="..\version.rc">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='JITDebug|Win32'">../../public;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='JITRelease|Win32'">../../public;</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\plugins\include\cellstack.inc" /> <None Include="..\..\plugins\include\cellstack.inc" />
@ -438,6 +457,7 @@
<None Include="..\..\plugins\include\cvars.inc" /> <None Include="..\..\plugins\include\cvars.inc" />
<None Include="..\..\plugins\include\datapack.inc" /> <None Include="..\..\plugins\include\datapack.inc" />
<None Include="..\..\plugins\include\gameconfig.inc" /> <None Include="..\..\plugins\include\gameconfig.inc" />
<None Include="..\..\plugins\include\newmenus.inc" />
<None Include="..\..\plugins\include\string_const.inc" /> <None Include="..\..\plugins\include\string_const.inc" />
<None Include="..\..\plugins\include\string_stocks.inc" /> <None Include="..\..\plugins\include\string_stocks.inc" />
<None Include="..\..\plugins\include\textparse_ini.inc" /> <None Include="..\..\plugins\include\textparse_ini.inc" />

View File

@ -693,6 +693,9 @@
<None Include="..\..\plugins\include\string_stocks.inc"> <None Include="..\..\plugins\include\string_stocks.inc">
<Filter>Pawn Includes</Filter> <Filter>Pawn Includes</Filter>
</None> </None>
<None Include="..\..\plugins\include\newmenus.inc">
<Filter>Pawn Includes</Filter>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Object Include="..\Jit\helpers-x86.obj"> <Object Include="..\Jit\helpers-x86.obj">

View File

@ -10,6 +10,7 @@
#include "amxmodx.h" #include "amxmodx.h"
#include "CMenu.h" #include "CMenu.h"
#include "newmenus.h" #include "newmenus.h"
#include "format.h"
ke::Vector<Menu *> g_NewMenus; ke::Vector<Menu *> g_NewMenus;
CStack<int> g_MenuFreeStack; CStack<int> g_MenuFreeStack;
@ -90,9 +91,9 @@ bool CloseNewMenus(CPlayer *pPlayer)
return true; return true;
} }
Menu::Menu(const char *title, AMX *amx, int fid) : m_Title(title), m_ItemColor("\\r"), Menu::Menu(const char *title, AMX *amx, int fid, bool use_ml) : m_Title(title), m_ItemColor("\\r"),
m_NeverExit(false), m_AutoColors(g_coloredmenus), thisId(0), func(fid), m_NeverExit(false), m_AutoColors(g_coloredmenus), thisId(0), func(fid),
isDestroying(false), pageCallback(-1), items_per_page(7) isDestroying(false), pageCallback(-1), showPageNumber(true), useMultilingual(use_ml), amx(amx), items_per_page(7)
{ {
CPluginMngr::CPlugin *pPlugin = g_plugins.findPluginFast(amx); CPluginMngr::CPlugin *pPlugin = g_plugins.findPluginFast(amx);
menuId = g_menucmds.registerMenuId(title, amx); menuId = g_menucmds.registerMenuId(title, amx);
@ -316,11 +317,6 @@ bool Menu::Display(int player, page_t page)
CPlayer *pPlayer = GET_PLAYER_POINTER_I(player); CPlayer *pPlayer = GET_PLAYER_POINTER_I(player);
pPlayer->keys = 0;
pPlayer->menu = 0;
UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0);
pPlayer->keys = keys; pPlayer->keys = keys;
pPlayer->menu = menuId; pPlayer->menu = menuId;
pPlayer->newmenu = thisId; pPlayer->newmenu = thisId;
@ -361,18 +357,32 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
m_Text = nullptr; m_Text = nullptr;
auto title = m_Title.chars();
if (this->useMultilingual)
{
const auto language = playerlang(player);
const auto definition = translate(this->amx, language, title);
if (definition)
{
title = definition;
}
}
char buffer[255]; char buffer[255];
if (items_per_page && (pages != 1)) if (showPageNumber && items_per_page && (pages != 1))
{ {
if (m_AutoColors) if (m_AutoColors)
ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s %d/%d\n\\w\n", m_Title.chars(), page + 1, pages); ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s %d/%d\n\\w\n", title, page + 1, pages);
else else
ke::SafeSprintf(buffer, sizeof(buffer), "%s %d/%d\n\n", m_Title.chars(), page + 1, pages); ke::SafeSprintf(buffer, sizeof(buffer), "%s %d/%d\n\n", title, page + 1, pages);
} else { } else {
if (m_AutoColors) if (m_AutoColors)
ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s\n\\w\n", m_Title.chars()); ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s\n\\w\n", title);
else else
ke::SafeSprintf(buffer, sizeof(buffer), "%s\n\n", m_Title.chars()); ke::SafeSprintf(buffer, sizeof(buffer), "%s\n\n", title);
} }
m_Text = m_Text + buffer; m_Text = m_Text + buffer;
@ -467,24 +477,37 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
option_display = 0; option_display = 0;
} }
auto itemName = pItem->name.chars();
if (this->useMultilingual)
{
const auto language = playerlang(player);
const auto definition = translate(this->amx, language, itemName);
if (definition)
{
itemName = definition;
}
}
if (pItem->isBlank) if (pItem->isBlank)
{ {
ke::SafeSprintf(buffer, sizeof(buffer), "%s\n", pItem->name.chars()); ke::SafeSprintf(buffer, sizeof(buffer), "%s\n", itemName);
} }
else if (enabled) else if (enabled)
{ {
if (m_AutoColors) if (m_AutoColors)
{ {
ke::SafeSprintf(buffer, sizeof(buffer), "%s%d.\\w %s\n", m_ItemColor.chars(),option_display, pItem->name.chars()); ke::SafeSprintf(buffer, sizeof(buffer), "%s%d.\\w %s\n", m_ItemColor.chars(),option_display, itemName);
} else { } else {
ke::SafeSprintf(buffer, sizeof(buffer), "%d. %s\n", option_display, pItem->name.chars()); ke::SafeSprintf(buffer, sizeof(buffer), "%d. %s\n", option_display, itemName);
} }
} else { } else {
if (m_AutoColors) if (m_AutoColors)
{ {
ke::SafeSprintf(buffer, sizeof(buffer), "\\d%d. %s\n\\w", option_display, pItem->name.chars()); ke::SafeSprintf(buffer, sizeof(buffer), "\\d%d. %s\n\\w", option_display, itemName);
} else { } else {
ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", pItem->name.chars()); ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", itemName);
} }
} }
slots++; slots++;
@ -625,38 +648,45 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
LogError(amx, AMX_ERR_NATIVE, "Invalid menu id %d(%d)", p, g_NewMenus.length()); \ LogError(amx, AMX_ERR_NATIVE, "Invalid menu id %d(%d)", p, g_NewMenus.length()); \
return 0; } return 0; }
//Makes a new menu handle (-1 for failure) // native menu_create(const title[], const handler[], bool:ml = false);
//native csdm_makemenu(title[]);
static cell AMX_NATIVE_CALL menu_create(AMX *amx, cell *params) static cell AMX_NATIVE_CALL menu_create(AMX *amx, cell *params)
{ {
int len; enum args { arg_count, arg_title, arg_handler, arg_ml };
char *title = get_amxstring(amx, params[1], 0, len);
validate_menu_text(title);
char *handler = get_amxstring(amx, params[2], 1, len);
int func = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_CELL, FP_DONE); int length;
const auto title = get_amxstring(amx, params[arg_title], 0, length);
const auto handler = get_amxstring(amx, params[arg_handler], 1, length);
const auto callback = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
if (func == -1) if (callback == -1)
{ {
LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler); LogError(amx, AMX_ERR_NOTFOUND, R"(Invalid function "%s")", handler);
return 0; return 0;
} }
Menu *pMenu = new Menu(title, amx, func); validate_menu_text(title);
auto pMenu = new Menu(title, amx, callback, params[arg_ml] != 0);
if (g_MenuFreeStack.empty()) if (g_MenuFreeStack.empty())
{ {
g_NewMenus.append(pMenu); g_NewMenus.append(pMenu);
pMenu->thisId = (int)g_NewMenus.length() - 1;
} else { pMenu->thisId = static_cast<int>(g_NewMenus.length()) - 1;
int pos = g_MenuFreeStack.front(); }
else
{
const auto position = g_MenuFreeStack.front();
g_MenuFreeStack.pop(); g_MenuFreeStack.pop();
g_NewMenus[pos] = pMenu; g_NewMenus[position] = pMenu;
pMenu->thisId = pos;
pMenu->thisId = position;
} }
return pMenu->thisId; return pMenu->thisId;
} }
static cell AMX_NATIVE_CALL menu_addblank(AMX *amx, cell *params) static cell AMX_NATIVE_CALL menu_addblank(AMX *amx, cell *params)
{ {
GETMENU(params[1]); GETMENU(params[1]);
@ -814,8 +844,21 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
int player = params[1]; int player = params[1];
int page = params[3]; int page = params[3];
if (player < 1 || player > gpGlobals->maxClients)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid player id %d.", player);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(player); CPlayer* pPlayer = GET_PLAYER_POINTER_I(player);
if (!pPlayer->ingame)
{
LogError(amx, AMX_ERR_NATIVE, "Player %d is not in game.", player);
return 0;
}
if (!CloseNewMenus(pPlayer)) if (!CloseNewMenus(pPlayer))
{ {
LogError(amx, AMX_ERR_NATIVE, "Plugin called menu_display when item=MENU_EXIT"); LogError(amx, AMX_ERR_NATIVE, "Plugin called menu_display when item=MENU_EXIT");
@ -828,6 +871,20 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
return 0; return 0;
} }
if (g_bmod_cstrike)
{
enum JoinState { Joined = 0 };
enum MenuState { Menu_OFF = 0, Menu_ChooseTeam = 1, Menu_ChooseAppearance = 3 };
GET_OFFSET("CBasePlayer", m_iJoiningState);
GET_OFFSET("CBasePlayer", m_iMenu);
if (get_pdata<int>(pPlayer->pEdict, m_iJoiningState) == Joined || (get_pdata<int>(pPlayer->pEdict, m_iMenu) != Menu_ChooseTeam && get_pdata<int>(pPlayer->pEdict, m_iMenu) != Menu_ChooseAppearance))
{
set_pdata<int>(pPlayer->pEdict, m_iMenu, Menu_OFF);
}
}
int time = -1; int time = -1;
if (params[0] / sizeof(cell) >= 4) if (params[0] / sizeof(cell) >= 4)
time = params[4]; time = params[4];
@ -982,6 +1039,11 @@ static cell AMX_NATIVE_CALL menu_setprop(AMX *amx, cell *params)
unregisterSPForward(pMenu->pageCallback); unregisterSPForward(pMenu->pageCallback);
pMenu->pageCallback = callback; pMenu->pageCallback = callback;
break;
}
case MPROP_SHOWPAGE:
{
pMenu->showPageNumber = (get_amxaddr(amx, params[3]) != 0);
break; break;
} }
case MPROP_SET_NUMBER_COLOR: case MPROP_SET_NUMBER_COLOR:

View File

@ -31,6 +31,7 @@
#define MPROP_PADMENU 9 #define MPROP_PADMENU 9
#define MPROP_SET_NUMBER_COLOR 10 #define MPROP_SET_NUMBER_COLOR 10
#define MPROP_PAGE_CALLBACK 11 #define MPROP_PAGE_CALLBACK 11
#define MPROP_SHOWPAGE 12
typedef int (*MENUITEM_CALLBACK)(int, int, int); typedef int (*MENUITEM_CALLBACK)(int, int, int);
@ -94,7 +95,7 @@ typedef unsigned int page_t;
class Menu class Menu
{ {
public: public:
Menu(const char *title, AMX *amx, int fid); Menu(const char *title, AMX *amx, int fid, bool use_ml);
~Menu(); ~Menu();
menuitem *GetMenuItem(item_t item); menuitem *GetMenuItem(item_t item);
@ -125,6 +126,9 @@ public:
int func; int func;
bool isDestroying; bool isDestroying;
int pageCallback; int pageCallback;
bool showPageNumber;
bool useMultilingual;
AMX *amx;
public: public:
unsigned int items_per_page; unsigned int items_per_page;
}; };

View File

@ -1,4 +1,4 @@
// vim: set ts=4 sw=4 tw=99 noet: // vim: set ts=4 sw=4 tw=99 noet:
// //
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). // AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team. // Copyright (C) The AMX Mod X Development Team.
@ -210,6 +210,16 @@ void copy_amxmemory(cell* dest, cell* src, int len)
*dest++=*src++; *dest++=*src++;
} }
bool utf8isspace(const char* string)
{
return utf8iscategory(string, 1, UTF8_CATEGORY_ISSPACE) != 0;
}
size_t utf8getspaces(const char* string)
{
return utf8iscategory(string, SIZE_MAX, UTF8_CATEGORY_ISSPACE);
}
char* parse_arg(char** line, int& state) char* parse_arg(char** line, int& state)
{ {
static char arg[3072]; static char arg[3072];
@ -218,7 +228,7 @@ char* parse_arg(char** line, int& state)
while (**line) while (**line)
{ {
if (isspace(**line)) if (utf8isspace(*line))
{ {
if (state == 1) if (state == 1)
break; break;
@ -919,6 +929,7 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
int right_pos = 0; int right_pos = 0;
unsigned int i = 0; unsigned int i = 0;
bool done_flag = false; bool done_flag = false;
size_t spaces;
int len = 0; int len = 0;
//string[] //string[]
@ -938,9 +949,9 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
{ {
if (trim && !done_flag) if (trim && !done_flag)
{ {
if (isspace(string[i])) if ((spaces = utf8getspaces(string + i) > 0))
{ {
while (isspace(string[++i])); i += spaces;
done_flag = true; done_flag = true;
} }
} }
@ -974,6 +985,7 @@ static cell AMX_NATIVE_CALL amx_strtok2(AMX *amx, cell *params)
{ {
int left_pos = 0, right_pos = 0, len, pos = -1; int left_pos = 0, right_pos = 0, len, pos = -1;
unsigned int i = 0; unsigned int i = 0;
size_t spaces;
char *string = get_amxstring(amx, params[1], 0, len); char *string = get_amxstring(amx, params[1], 0, len);
char *left = new char[len + 1], *right = new char[len + 1]; char *left = new char[len + 1], *right = new char[len + 1];
@ -989,9 +1001,9 @@ static cell AMX_NATIVE_CALL amx_strtok2(AMX *amx, cell *params)
int trim = params[7]; int trim = params[7];
// ltrim left // ltrim left
if (trim & 1 && isspace(string[i])) if (trim & 1 && (spaces = utf8getspaces(string)) > 0)
{ {
while (isspace(string[++i])); i += spaces;
} }
for (; i < (unsigned int) len; ++i) for (; i < (unsigned int) len; ++i)
@ -1007,17 +1019,17 @@ static cell AMX_NATIVE_CALL amx_strtok2(AMX *amx, cell *params)
} }
// rtrim left // rtrim left
if (trim & 2 && left_pos && isspace(left[left_pos - 1])) if (trim & 2 && left_pos && utf8isspace(&left[left_pos - 1]))
{ {
while (--left_pos >= 0 && isspace(left[left_pos])); while (--left_pos >= 0 && utf8isspace(&left[left_pos]));
++left_pos; ++left_pos;
} }
// ltrim right // ltrim right
if (trim & 4 && isspace(string[i])) if (trim & 4 && (spaces = utf8getspaces(string + i)) > 0)
{ {
while (isspace(string[++i])); i += spaces;
} }
for (; i < (unsigned int) len; ++i) for (; i < (unsigned int) len; ++i)
@ -1026,9 +1038,9 @@ static cell AMX_NATIVE_CALL amx_strtok2(AMX *amx, cell *params)
} }
// rtrim right // rtrim right
if (trim & 8 && right_pos && isspace(right[right_pos - 1])) if (trim & 8 && right_pos && utf8isspace(&right[right_pos - 1]))
{ {
while (--right_pos >= 0 && isspace(right[right_pos])); while (--right_pos >= 0 && utf8isspace(&right[right_pos]));
++right_pos; ++right_pos;
} }
@ -1058,8 +1070,12 @@ static cell AMX_NATIVE_CALL argparse(AMX *amx, cell *params)
// Strip all left-hand whitespace. // Strip all left-hand whitespace.
size_t i = start_pos; size_t i = start_pos;
while (i < input_len && isspace(input[i])) size_t spaces;
i++;
if ((spaces = utf8getspaces(input + i)) > 0)
{
i += spaces;
}
if (i >= input_len) { if (i >= input_len) {
*buffer = '\0'; *buffer = '\0';
@ -1078,7 +1094,7 @@ static cell AMX_NATIVE_CALL argparse(AMX *amx, cell *params)
} }
// If not in quotes, and we see a space, stop. // If not in quotes, and we see a space, stop.
if (isspace(input[i]) && !in_quote) if (utf8isspace(input + i) && !in_quote)
break; break;
if (size_t(bufpos - buffer) < buflen) if (size_t(bufpos - buffer) < buflen)
@ -1106,9 +1122,13 @@ static cell AMX_NATIVE_CALL strbreak(AMX *amx, cell *params) /* 5 param */
int RightMax = params[5]; int RightMax = params[5];
size_t len = (size_t)_len; size_t len = (size_t)_len;
size_t spaces;
if ((spaces = utf8getspaces(string)) > 0)
{
i += spaces;
}
while (isspace(string[i]) && i<len)
i++;
beg = i; beg = i;
for (; i<len; i++) for (; i<len; i++)
{ {
@ -1120,12 +1140,12 @@ static cell AMX_NATIVE_CALL strbreak(AMX *amx, cell *params) /* 5 param */
if (i == len-1) if (i == len-1)
goto do_copy; goto do_copy;
} else { } else {
if (isspace(string[i]) && !in_quote) if (!in_quote && (spaces = utf8getspaces(string + i)) > 0)
{ {
do_copy: do_copy:
size_t pos = i; size_t pos = i;
while (isspace(string[i])) i += spaces;
i++;
const char *start = had_quotes ? &(string[beg+1]) : &(string[beg]); const char *start = had_quotes ? &(string[beg+1]) : &(string[beg]);
size_t _end = had_quotes ? (i==len-1 ? 1 : 2) : 0; size_t _end = had_quotes ? (i==len-1 ? 1 : 2) : 0;
size_t end = (pos - _end > (size_t)LeftMax) ? (size_t)LeftMax : pos - _end; size_t end = (pos - _end > (size_t)LeftMax) ? (size_t)LeftMax : pos - _end;
@ -1367,18 +1387,27 @@ static cell AMX_NATIVE_CALL amx_strlen(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
{ {
int len, newlen; int length;
char *str = get_amxstring(amx, params[1], 0, len); auto string = get_amxstring(amx, params[1], 0, length);
UTIL_TrimLeft(str); auto leftSpaces = utf8getspaces(string);
UTIL_TrimRight(str); auto rightSpaces = 0u;
newlen = strlen(str); auto originalLength = length;
len -= newlen;
set_amxstring(amx, params[1], str, newlen); if (leftSpaces < size_t(length))
{
while (--length >= 0 && utf8isspace(string + length))
{
++rightSpaces;
}
}
return len; auto totalSpaces = leftSpaces + rightSpaces;
set_amxstring(amx, params[1], string + leftSpaces, originalLength - totalSpaces);
return totalSpaces;
} }
static cell AMX_NATIVE_CALL n_strcat(AMX *amx, cell *params) static cell AMX_NATIVE_CALL n_strcat(AMX *amx, cell *params)

View File

@ -44,7 +44,12 @@ cell destroyParser(cell *handle)
// native SMCParser:SMC_CreateParser(); // native SMCParser:SMC_CreateParser();
static cell AMX_NATIVE_CALL SMC_CreateParser(AMX *amx, cell *params) static cell AMX_NATIVE_CALL SMC_CreateParser(AMX *amx, cell *params)
{ {
return createParser(); const auto handle = createParser();
const auto parseInfo = TextParsersHandles.lookup(handle);
parseInfo->handle = handle;
return handle;
} }
// native SMC_SetParseStart(SMCParser:handle, const func[]); // native SMC_SetParseStart(SMCParser:handle, const func[]);
@ -224,7 +229,12 @@ static cell AMX_NATIVE_CALL SMC_DestroyParser(AMX *amx, cell *params)
// native INIParser:INI_CreateParser(); // native INIParser:INI_CreateParser();
static cell AMX_NATIVE_CALL INI_CreateParser(AMX *amx, cell *params) static cell AMX_NATIVE_CALL INI_CreateParser(AMX *amx, cell *params)
{ {
return createParser(); const auto handle = createParser();
const auto parseInfo = TextParsersHandles.lookup(handle);
parseInfo->handle = handle;
return handle;
} }
// native bool:INI_ParseFile(INIParser:handle, const file[], &line = 0, &col = 0, any:data = 0); // native bool:INI_ParseFile(INIParser:handle, const file[], &line = 0, &col = 0, any:data = 0);

View File

@ -373,8 +373,8 @@ void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1,
{ {
if ((*aa).matchCommandLine(cmd, arg1) && (*aa).getPlugin()->isExecutable((*aa).getFunction())) if ((*aa).matchCommandLine(cmd, arg1) && (*aa).getPlugin()->isExecutable((*aa).getFunction()))
{ {
if (executeForwards((*aa).getFunction(), static_cast<cell>(GET_PLAYER_POINTER(pEdict)->index)), if (executeForwards((*aa).getFunction(), static_cast<cell>(GET_PLAYER_POINTER(pEdict)->index),
static_cast<cell>((*aa).getFlags()), static_cast<cell>((*aa).getId()) > 0) static_cast<cell>((*aa).getFlags()), static_cast<cell>((*aa).getId())) > 0)
{ {
g_fakecmd.notify = false; g_fakecmd.notify = false;
return; return;

View File

@ -6,13 +6,7 @@
// Generated from the TEXTINCLUDE 2 resource. // Generated from the TEXTINCLUDE 2 resource.
// //
#include <winresrc.h> #include <winresrc.h>
#if defined AMBUILD #include <amxmodx_version.h>
# include <amxmodx_version.h>
#else
# define SVN_VERSION_DWORD 1, 8, 3, 0
# define SVN_VERSION_STRING "dev-local"
# define SVN_VERSION SVN_VERSION_STRING
#endif
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS #undef APSTUDIO_READONLY_SYMBOLS
@ -32,8 +26,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION SVN_VERSION_DWORD FILEVERSION AMXX_VERSION_FILE
PRODUCTVERSION SVN_VERSION_DWORD PRODUCTVERSION AMXX_VERSION_FILE
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -50,12 +44,12 @@ BEGIN
BEGIN BEGIN
VALUE "Comments", "AMX Mod X" VALUE "Comments", "AMX Mod X"
VALUE "FileDescription", "AMX Mod X" VALUE "FileDescription", "AMX Mod X"
VALUE "FileVersion", SVN_VERSION_STRING VALUE "FileVersion", AMXX_VERSION_STRING
VALUE "InternalName", "amxmodx" VALUE "InternalName", "amxmodx"
VALUE "LegalCopyright", "Copyright (c) 2004-2015, AMX Mod X Dev Team" VALUE "LegalCopyright", "Copyright (c) 2004-2015, AMX Mod X Dev Team"
VALUE "OriginalFilename", "amxmodx_mm.dll" VALUE "OriginalFilename", "amxmodx_mm.dll"
VALUE "ProductName", "AMX Mod X" VALUE "ProductName", "AMX Mod X"
VALUE "ProductVersion", SVN_VERSION VALUE "ProductVersion", AMXX_VERSION_STRING
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -3,14 +3,20 @@ clone_folder: c:\projects\amxmodx
install: install:
- git submodule update --init --recursive - git submodule update --init --recursive
- 'c:' - 'c:'
- mkdir c:\nasm
- set PATH=c:\nasm\nasm-2.13.03;%PATH%
- curl -L -o "c:\nasm\nasm.zip" https://www.nasm.us/pub/nasm/releasebuilds/2.13.03/win32/nasm-2.13.03-win32.zip
- chdir c:\nasm
- 7z x nasm.zip
- chdir c:\projects - chdir c:\projects
- git clone https://github.com/alliedmodders/ambuild - git clone https://github.com/alliedmodders/ambuild
- git clone https://github.com/alliedmodders/metamod-hl1 - git clone https://github.com/alliedmodders/metamod-hl1
- git clone https://github.com/alliedmodders/hlsdk - git clone https://github.com/alliedmodders/hlsdk
- ps: Start-FileDownload 'http://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.54-win32.zip' - ps: Start-FileDownload 'https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.1-win32.zip'
- 7z x mysql-5.5.54-win32.zip -o"mysql" - 7z x mysql-connector-c-6.1.1-win32.zip -o"mysql"
- cd mysql - cd mysql
- ren mysql-5.5.54-win32 mysql-5.5 - dir
- ren mysql-connector-c-6.1.1-win32 mysql-5.5
- move /Y mysql-5.5 ..\ - move /Y mysql-5.5 ..\
- cd ..\ambuild - cd ..\ambuild
- c:\python27\python setup.py install - c:\python27\python setup.py install
@ -19,8 +25,8 @@ cache:
- c:\projects\*.zip -> appveyor.yml - c:\projects\*.zip -> appveyor.yml
- c:\projects\mysql-5.5 -> appveyor.yml - c:\projects\mysql-5.5 -> appveyor.yml
build_script: build_script:
- '"%VS120COMNTOOLS%\vsvars32.bat"' - '"%VS140COMNTOOLS%\vsvars32.bat"'
- mkdir build - mkdir build
- cd build - cd build
- c:\python27\python ../configure.py --enable-optimize - c:\python27\python ../configure.py --enable-optimize --nasm="C:\nasm\nasm-2.13.03\nasm.exe"
- c:\python27\scripts\ambuild - c:\python27\scripts\ambuild

View File

@ -65,7 +65,7 @@ int main(int argc, char **argv)
# else # else
printf("compiler failed to instantiate: %d\n", GetLastError()); printf("compiler failed to instantiate: %d\n", GetLastError());
# endif # endif
exit(0); exit(EXIT_FAILURE);
} }
COMPILER sc32 = (COMPILER)dlsym(lib, "Compile32"); COMPILER sc32 = (COMPILER)dlsym(lib, "Compile32");
@ -79,7 +79,7 @@ int main(int argc, char **argv)
#else #else
printf("compiler failed to link: %d.\n", GetLastError()); printf("compiler failed to link: %d.\n", GetLastError());
#endif #endif
exit(0); exit(EXIT_FAILURE);
} }
pc_printf("AMX Mod X Compiler %s\n", AMXX_VERSION); pc_printf("AMX Mod X Compiler %s\n", AMXX_VERSION);
@ -91,7 +91,7 @@ int main(int argc, char **argv)
pc_printf("Usage: <file.sma> [options]\n"); pc_printf("Usage: <file.sma> [options]\n");
pc_printf("Use -? or --help to see full options\n\n"); pc_printf("Use -? or --help to see full options\n\n");
getchar(); getchar();
exit(0); exit(EXIT_FAILURE);
} }
if (!strcmp(argv[1], "-?") || !strcmp(argv[1], "--help")) if (!strcmp(argv[1], "-?") || !strcmp(argv[1], "--help"))
@ -99,7 +99,7 @@ int main(int argc, char **argv)
show_help(); show_help();
pc_printf("Press any key to continue.\n"); pc_printf("Press any key to continue.\n");
getchar(); getchar();
exit(0); exit(EXIT_SUCCESS);
} }
sc32(argc, argv); sc32(argc, argv);
@ -109,16 +109,16 @@ int main(int argc, char **argv)
if (file == NULL) if (file == NULL)
{ {
pc_printf("Could not locate the output file.\n"); pc_printf("Could not locate the output file.\n");
exit(0); exit(EXIT_FAILURE);
} else if (strstr(file, ".asm")) { } else if (strstr(file, ".asm")) {
pc_printf("Assembler output succeeded.\n"); pc_printf("Assembler output succeeded.\n");
exit(0); exit(EXIT_SUCCESS);
} else { } else {
FILE *fp = fopen(file, "rb"); FILE *fp = fopen(file, "rb");
if (fp == NULL) if (fp == NULL)
{ {
pc_printf("Could not locate output file %s (compile failed).\n", file); pc_printf("Could not locate output file %s (compile failed).\n", file);
exit(0); exit(EXIT_FAILURE);
} }
ReadFileIntoPl(&pl32, fp); ReadFileIntoPl(&pl32, fp);
pl32.cellsize = 4; pl32.cellsize = 4;
@ -142,7 +142,7 @@ int main(int argc, char **argv)
if (!fp) if (!fp)
{ {
pc_printf("Error trying to write file %s.\n", newfile); pc_printf("Error trying to write file %s.\n", newfile);
exit(0); exit(EXIT_FAILURE);
} }
BinPlugin bh32; BinPlugin bh32;
@ -179,7 +179,7 @@ int main(int argc, char **argv)
#if !defined EMSCRIPTEN #if !defined EMSCRIPTEN
dlclose(lib); dlclose(lib);
#endif #endif
exit(0); exit(EXIT_FAILURE);
} }
fclose(fp); fclose(fp);
@ -195,7 +195,7 @@ int main(int argc, char **argv)
dlclose(lib); dlclose(lib);
#endif #endif
exit(0); exit(EXIT_SUCCESS);
} }
void WriteBh(BinaryWriter *bw, BinPlugin *bh) void WriteBh(BinaryWriter *bw, BinPlugin *bh)
@ -228,7 +228,7 @@ bool CompressPl(abl *pl)
if (err != Z_OK) if (err != Z_OK)
{ {
pc_printf("internal error - compression failed on first pass: %d\n", err); pc_printf("internal error - compression failed on first pass: %d\n", err);
exit(0); exit(EXIT_FAILURE);
} }
return true; return true;

View File

@ -55,29 +55,28 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE; AMX_ANSIONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_MBCS;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE; AMX_ANSIONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild> <MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo> <RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader> <PrecompiledHeader>
</PrecompiledHeader> </PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>..\..\public;..\..\third_party;..\..\third_party\zlib;..\..\amxmodx\;C:\Program Files (x86)\Visual Leak Detector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\public;..\..\third_party;..\..\third_party\zlib;..\..\amxmodx\;C:\Program Files (x86)\Visual Leak Detector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)amxxpc.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE; AMX_ANSIONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_MBCS;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE; AMX_ANSIONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StructMemberAlignment>Default</StructMemberAlignment> <StructMemberAlignment>Default</StructMemberAlignment>
<RuntimeTypeInfo>false</RuntimeTypeInfo> <RuntimeTypeInfo>false</RuntimeTypeInfo>

View File

@ -54,7 +54,7 @@
#define CTRL_CHAR '^' /* default control character */ #define CTRL_CHAR '^' /* default control character */
#define sCHARBITS 8 /* size of a packed character */ #define sCHARBITS 8 /* size of a packed character */
#define sDIMEN_MAX 3 /* maximum number of array dimensions */ #define sDIMEN_MAX 4 /* maximum number of array dimensions */
#define sLINEMAX 4095 /* input line length (in characters) */ #define sLINEMAX 4095 /* input line length (in characters) */
#define sCOMP_STACK 32 /* maximum nesting of #if .. #endif sections */ #define sCOMP_STACK 32 /* maximum nesting of #if .. #endif sections */
#define sDEF_LITMAX 500 /* initial size of the literal pool, in "cells" */ #define sDEF_LITMAX 500 /* initial size of the literal pool, in "cells" */
@ -280,6 +280,12 @@ typedef struct s_stringpair {
char *documentation; char *documentation;
} stringpair; } stringpair;
typedef struct s_valuepair {
struct s_valuepair *next;
long first;
long second;
} valuepair;
/* macros for code generation */ /* macros for code generation */
#define opcodes(n) ((n)*sizeof(cell)) /* opcode size */ #define opcodes(n) ((n)*sizeof(cell)) /* opcode size */
#define opargs(n) ((n)*sizeof(cell)) /* size of typical argument */ #define opargs(n) ((n)*sizeof(cell)) /* size of typical argument */
@ -521,6 +527,10 @@ SC_FUNC symbol *add_constant(char *name,cell val,int vclass,int tag);
SC_FUNC void exporttag(int tag); SC_FUNC void exporttag(int tag);
SC_FUNC void sc_attachdocumentation(symbol *sym); SC_FUNC void sc_attachdocumentation(symbol *sym);
SC_FUNC int get_actual_compound(symbol *sym); SC_FUNC int get_actual_compound(symbol *sym);
#if !defined NO_DEFINE
SC_FUNC void inst_file_name(char* filename, int strip_path);
#endif
/* function prototypes in SC2.C */ /* function prototypes in SC2.C */
#define PUSHSTK_P(v) { stkitem s_; s_.pv=(v); pushstk(s_); } #define PUSHSTK_P(v) { stkitem s_; s_.pv=(v); pushstk(s_); }
@ -696,6 +706,9 @@ SC_FUNC void delete_docstringtable(void);
SC_FUNC stringlist *insert_autolist(char *string); SC_FUNC stringlist *insert_autolist(char *string);
SC_FUNC char *get_autolist(int index); SC_FUNC char *get_autolist(int index);
SC_FUNC void delete_autolisttable(void); SC_FUNC void delete_autolisttable(void);
SC_FUNC valuepair *push_heaplist(long first, long second);
SC_FUNC int popfront_heaplist(long *first, long *second);
SC_FUNC void delete_heaplisttable(void);
SC_FUNC stringlist *insert_dbgfile(const char *filename); SC_FUNC stringlist *insert_dbgfile(const char *filename);
SC_FUNC stringlist *insert_dbgline(int linenr); SC_FUNC stringlist *insert_dbgline(int linenr);
SC_FUNC stringlist *insert_dbgsymbol(symbol *sym); SC_FUNC stringlist *insert_dbgsymbol(symbol *sym);
@ -722,8 +735,6 @@ int mfputs(MEMFILE *mf,char *string);
SC_FUNC int cp_path(const char *root,const char *directory); SC_FUNC int cp_path(const char *root,const char *directory);
SC_FUNC int cp_set(const char *name); SC_FUNC int cp_set(const char *name);
SC_FUNC cell cp_translate(const unsigned char *string,const unsigned char **endptr); SC_FUNC cell cp_translate(const unsigned char *string,const unsigned char **endptr);
SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **endptr);
SC_FUNC int scan_utf8(FILE *fp,const char *filename);
/* function prototypes in SCSTATE.C */ /* function prototypes in SCSTATE.C */
SC_FUNC constvalue *automaton_add(const char *name); SC_FUNC constvalue *automaton_add(const char *name);
@ -799,7 +810,6 @@ SC_VDECL int sc_status; /* read/write status */
SC_VDECL int sc_rationaltag; /* tag for rational numbers */ SC_VDECL int sc_rationaltag; /* tag for rational numbers */
SC_VDECL int rational_digits; /* number of fractional digits */ SC_VDECL int rational_digits; /* number of fractional digits */
SC_VDECL int sc_allowproccall;/* allow/detect tagnames in lex() */ SC_VDECL int sc_allowproccall;/* allow/detect tagnames in lex() */
SC_VDECL short sc_is_utf8; /* is this source file in UTF-8 encoding */
SC_VDECL char *pc_deprecate; /* if non-NULL, mark next declaration as deprecated */ SC_VDECL char *pc_deprecate; /* if non-NULL, mark next declaration as deprecated */
SC_VDECL int sc_warnings_are_errors; SC_VDECL int sc_warnings_are_errors;

View File

@ -408,11 +408,47 @@ void inst_datetime_defines()
insert_subst("__TIME__", ltime, 8); insert_subst("__TIME__", ltime, 8);
} }
void inst_file_name(char *file, int strip_path)
{
char newname[_MAX_PATH];
char *fileptr;
fileptr = NULL;
if (strip_path) {
size_t i, len;
int slashchar;
len = strlen(file);
for (i = len - 1; i < len; i--)
{
slashchar = file[i] == '/';
#if defined WIN32 || defined _WIN32
slashchar = slashchar || file[i] == '\\';
#endif
if (slashchar)
{
fileptr = &file[i + 1];
break;
}
}
}
if (fileptr == NULL) {
fileptr = file;
}
snprintf(newname, sizeof(newname), "\"%s\"", fileptr);
insert_subst("__FILE__", newname, 8);
}
static void inst_binary_name(char *binfname) static void inst_binary_name(char *binfname)
{ {
size_t i, len; size_t i, len;
char *binptr; char *binptr;
char newpath[512], newname[512]; char newname[_MAX_PATH];
int slashchar; int slashchar;
binptr = NULL; binptr = NULL;
@ -435,11 +471,9 @@ static void inst_binary_name(char *binfname)
binptr = binfname; binptr = binfname;
} }
snprintf(newpath, sizeof(newpath), "\"%s\"", binfname);
snprintf(newname, sizeof(newname), "\"%s\"", binptr); snprintf(newname, sizeof(newname), "\"%s\"", binptr);
insert_subst("__BINARY_PATH__", newpath, 15); insert_subst("__BINARY__", newname, 10);
insert_subst("__BINARY_NAME__", newname, 15);
} }
/* "main" of the compiler /* "main" of the compiler
@ -594,10 +628,12 @@ int pc_compile(int argc, char *argv[])
/* reset "defined" flag of all functions and global variables */ /* reset "defined" flag of all functions and global variables */
reduce_referrers(&glbtab); reduce_referrers(&glbtab);
delete_symbols(&glbtab,0,TRUE,FALSE); delete_symbols(&glbtab,0,TRUE,FALSE);
delete_heaplisttable();
#if !defined NO_DEFINE #if !defined NO_DEFINE
delete_substtable(); delete_substtable();
inst_datetime_defines(); inst_datetime_defines();
inst_binary_name(binfname); inst_binary_name(binfname);
inst_file_name(inpfname, TRUE);
#endif #endif
resetglobals(); resetglobals();
sc_ctrlchar=sc_ctrlchar_org; sc_ctrlchar=sc_ctrlchar_org;
@ -663,6 +699,7 @@ int pc_compile(int argc, char *argv[])
delete_substtable(); delete_substtable();
inst_datetime_defines(); inst_datetime_defines();
inst_binary_name(binfname); inst_binary_name(binfname);
inst_file_name(inpfname, TRUE);
#endif #endif
resetglobals(); resetglobals();
sc_ctrlchar=sc_ctrlchar_org; sc_ctrlchar=sc_ctrlchar_org;
@ -769,6 +806,7 @@ cleanup:
free(sc_documentation); free(sc_documentation);
#endif #endif
delete_autolisttable(); delete_autolisttable();
delete_heaplisttable();
if (errnum!=0) { if (errnum!=0) {
if (strlen(errfname)==0) if (strlen(errfname)==0)
pc_printf("\n%d Error%s.\n",errnum,(errnum>1) ? "s" : ""); pc_printf("\n%d Error%s.\n",errnum,(errnum>1) ? "s" : "");
@ -2134,26 +2172,24 @@ static cell calc_arraysize(int dim[],int numdim,int cur)
return dim[cur]+(dim[cur]*calc_arraysize(dim,numdim,cur+1)); return dim[cur]+(dim[cur]*calc_arraysize(dim,numdim,cur+1));
} }
static cell adjust_indirectiontables(int dim[],int numdim,int cur,cell increment, static void adjust_indirectiontables(int dim[],int numdim,int startlit,
int startlit,constvalue *lastdim,int *skipdim) constvalue *lastdim,int *skipdim)
{ {
static int base; static int base;
int d; int cur;
int i,d;
cell accum; cell accum;
cell size;
assert(cur>=0 && cur<numdim); assert(startlit==-1 || startlit>=0 && startlit<=litidx);
assert(increment>=0);
assert(cur>0 && startlit==-1 || startlit>=0 && startlit<=litidx);
if (cur==0)
base=startlit; base=startlit;
if (cur==numdim-1) size=1;
return 0; for (cur=0; cur<numdim-1; cur++) {
/* 2 or more dimensions left, fill in an indirection vector */ /* 2 or more dimensions left, fill in an indirection vector */
assert(dim[cur]>0);
if (dim[cur+1]>0) { if (dim[cur+1]>0) {
for (i=0; i<size; i++)
for (d=0; d<dim[cur]; d++) for (d=0; d<dim[cur]; d++)
litq[base++]=(dim[cur]+d*(dim[cur+1]-1)+increment) * sizeof(cell); litq[base++]=(size*dim[cur]+(dim[cur+1]-1)*(dim[cur]*i+d)) * sizeof(cell);
accum=dim[cur]*(dim[cur+1]-1);
} else { } else {
/* final dimension is variable length */ /* final dimension is variable length */
constvalue *ld; constvalue *ld;
@ -2161,6 +2197,7 @@ static int base;
assert(lastdim!=NULL); assert(lastdim!=NULL);
assert(skipdim!=NULL); assert(skipdim!=NULL);
accum=0; accum=0;
for (i=0; i<size; i++) {
/* skip the final dimension sizes for all earlier major dimensions */ /* skip the final dimension sizes for all earlier major dimensions */
for (d=0,ld=lastdim->next; d<*skipdim; d++,ld=ld->next) { for (d=0,ld=lastdim->next; d<*skipdim; d++,ld=ld->next) {
assert(ld!=NULL); assert(ld!=NULL);
@ -2168,19 +2205,15 @@ static int base;
for (d=0; d<dim[cur]; d++) { for (d=0; d<dim[cur]; d++) {
assert(ld!=NULL); assert(ld!=NULL);
assert(strtol(ld->name,NULL,16)==d); assert(strtol(ld->name,NULL,16)==d);
litq[base++]=(dim[cur]+accum+increment) * sizeof(cell); litq[base++]=(size*dim[cur]+accum) * sizeof(cell);
accum+=ld->value-1; accum+=ld->value-1;
*skipdim+=1; *skipdim+=1;
ld=ld->next; ld=ld->next;
} /* for */ } /* for */
} /* for */
} /* if */ } /* if */
/* create the indirection tables for the lower level */ size*=dim[cur];
if (cur+2<numdim) { /* are there at least 2 dimensions below this one? */ } /* for */
increment+=(dim[cur]-1)*dim[cur+1]; /* this many indirection tables follow */
for (d=0; d<dim[cur]; d++)
increment+=adjust_indirectiontables(dim,numdim,cur+1,increment,-1,lastdim,skipdim);
} /* if */
return accum;
} }
/* initials /* initials
@ -2238,7 +2271,7 @@ static void initials2(int ident,int tag,cell *size,int dim[],int numdim,
for (tablesize=calc_arraysize(dim,numdim-1,0); tablesize>0; tablesize--) for (tablesize=calc_arraysize(dim,numdim-1,0); tablesize>0; tablesize--)
litadd(0); litadd(0);
if (dim[numdim-1]!=0) /* error 9 has already been given */ if (dim[numdim-1]!=0) /* error 9 has already been given */
adjust_indirectiontables(dim,numdim,0,0,curlit,NULL,NULL); adjust_indirectiontables(dim,numdim,curlit,NULL,NULL);
} /* if */ } /* if */
return; return;
} /* if */ } /* if */
@ -2304,7 +2337,7 @@ static void initials2(int ident,int tag,cell *size,int dim[],int numdim,
* of the array and we can properly adjust the indirection vectors * of the array and we can properly adjust the indirection vectors
*/ */
if (err==0) if (err==0)
adjust_indirectiontables(dim,numdim,0,0,curlit,&lastdim,&skipdim); adjust_indirectiontables(dim,numdim,curlit,&lastdim,&skipdim);
delete_consttable(&lastdim); /* clear list of minor dimension sizes */ delete_consttable(&lastdim); /* clear list of minor dimension sizes */
} /* if */ } /* if */
} /* if */ } /* if */
@ -5419,6 +5452,16 @@ static void doreturn(void)
/* nothing */; /* nothing */;
sub=addvariable(curfunc->name,(argcount+3)*sizeof(cell),iREFARRAY,sGLOBAL,curfunc->tag,dim,numdim,idxtag); sub=addvariable(curfunc->name,(argcount+3)*sizeof(cell),iREFARRAY,sGLOBAL,curfunc->tag,dim,numdim,idxtag);
sub->parent=curfunc; sub->parent=curfunc;
/* Function that returns array can be used before it is defined, so at
* the call point (if it is before definition) we may not know if this
* function returns array and what is its size (for example inside the
* conditional operator), so we don't know how many cells on the heap
* we need. Calculating heap consumption is required for the fix of
* incorrect heap deallocation on conditional operator. That's why we
* need an additional pass.
*/
if ((curfunc->usage & uREAD)!=0)
sc_reparse=TRUE;
} /* if */ } /* if */
/* get the hidden parameter, copy the array (the array is on the heap; /* get the hidden parameter, copy the array (the array is on the heap;
* it stays on the heap for the moment, and it is removed -usually- at * it stays on the heap for the moment, and it is removed -usually- at

View File

@ -152,7 +152,6 @@ static char *extensions[] = { ".inc", ".p", ".pawn" };
PUSHSTK_I(iflevel); PUSHSTK_I(iflevel);
assert(!SKIPPING); assert(!SKIPPING);
assert(skiplevel==iflevel); /* these two are always the same when "parsing" */ assert(skiplevel==iflevel); /* these two are always the same when "parsing" */
PUSHSTK_I(sc_is_utf8);
PUSHSTK_I(icomment); PUSHSTK_I(icomment);
PUSHSTK_I(fcurrent); PUSHSTK_I(fcurrent);
PUSHSTK_I(fline); PUSHSTK_I(fline);
@ -169,7 +168,6 @@ static char *extensions[] = { ".inc", ".p", ".pawn" };
assert(sc_status == statFIRST || strcmp(get_inputfile(fcurrent), inpfname) == 0); assert(sc_status == statFIRST || strcmp(get_inputfile(fcurrent), inpfname) == 0);
setfiledirect(inpfname); /* (optionally) set in the list file */ setfiledirect(inpfname); /* (optionally) set in the list file */
listline=-1; /* force a #line directive when changing the file */ listline=-1; /* force a #line directive when changing the file */
sc_is_utf8=(short)scan_utf8(inpf,name);
return TRUE; return TRUE;
} }
@ -270,6 +268,11 @@ static void doinclude(int silent)
result=plungefile(name,(c!='>'),TRUE); result=plungefile(name,(c!='>'),TRUE);
if (!result && !silent) if (!result && !silent)
error(100,name); /* cannot read from ... (fatal error) */ error(100,name); /* cannot read from ... (fatal error) */
#if !defined NO_DEFINE
if (result) {
inst_file_name(name, FALSE);
}
#endif
} }
/* readline /* readline
@ -314,7 +317,6 @@ static void readline(unsigned char *line)
fline=i; fline=i;
fcurrent=(short)POPSTK_I(); fcurrent=(short)POPSTK_I();
icomment=(short)POPSTK_I(); icomment=(short)POPSTK_I();
sc_is_utf8=(short)POPSTK_I();
iflevel=(short)POPSTK_I(); iflevel=(short)POPSTK_I();
skiplevel=iflevel; /* this condition held before including the file */ skiplevel=iflevel; /* this condition held before including the file */
assert(!SKIPPING); /* idem ditto */ assert(!SKIPPING); /* idem ditto */
@ -324,6 +326,9 @@ static void readline(unsigned char *line)
inpf=(FILE *)POPSTK_P(); inpf=(FILE *)POPSTK_P();
insert_dbgfile(inpfname); insert_dbgfile(inpfname);
setfiledirect(inpfname); setfiledirect(inpfname);
#if !defined NO_DEFINE
inst_file_name(inpfname, TRUE);
#endif
assert(sc_status==statFIRST || strcmp(get_inputfile(fcurrent),inpfname)==0); assert(sc_status==statFIRST || strcmp(get_inputfile(fcurrent),inpfname)==0);
listline=-1; /* force a #line directive when changing the file */ listline=-1; /* force a #line directive when changing the file */
} /* if */ } /* if */
@ -595,13 +600,6 @@ static int htoi(cell *val,const unsigned char *curptr)
return (int)(ptr-curptr); return (int)(ptr-curptr);
} }
#if defined __APPLE__
static double pow10(double d)
{
return pow(10, d);
}
#endif
/* ftoi /* ftoi
* *
* Attempts to interpret a numeric symbol as a rational number, either as * Attempts to interpret a numeric symbol as a rational number, either as
@ -677,11 +675,7 @@ static int ftoi(cell *val,const unsigned char *curptr)
exp=(exp*10)+(*ptr-'0'); exp=(exp*10)+(*ptr-'0');
ptr++; ptr++;
} /* while */ } /* while */
#if defined __GNUC__
fmult=pow10(exp*sign);
#else
fmult=pow(10,exp*sign); fmult=pow(10,exp*sign);
#endif
fnum *= fmult; fnum *= fmult;
dnum *= (unsigned long)(fmult+0.5); dnum *= (unsigned long)(fmult+0.5);
} /* if */ } /* if */
@ -972,8 +966,14 @@ static int command(void)
if (strlen(pathname)>0) { if (strlen(pathname)>0) {
free(inpfname); free(inpfname);
inpfname=duplicatestring(pathname); inpfname=duplicatestring(pathname);
if (inpfname==NULL) if (inpfname==NULL) {
error(103); /* insufficient memory */ error(103); /* insufficient memory */
}
#if !defined NO_DEFINE
else {
inst_file_name(inpfname, TRUE);
}
#endif
} /* if */ } /* if */
} /* if */ } /* if */
check_empty(lptr); check_empty(lptr);
@ -2381,21 +2381,12 @@ static cell litchar(const unsigned char **lptr,int flags)
cptr=*lptr; cptr=*lptr;
if ((flags & RAWMODE)!=0 || *cptr!=sc_ctrlchar) { /* no escape character */ if ((flags & RAWMODE)!=0 || *cptr!=sc_ctrlchar) { /* no escape character */
#if !defined NO_UTF8
if (sc_is_utf8 && (flags & UTF8MODE)!=0) {
c=get_utf8_char(cptr,&cptr);
assert(c>=0); /* file was already scanned for conformance to UTF-8 */
} else {
#endif
#if !defined NO_CODEPAGE #if !defined NO_CODEPAGE
c=cp_translate(cptr,&cptr); c=cp_translate(cptr,&cptr);
#else #else
c=*cptr; c=*cptr;
cptr+=1; cptr+=1;
#endif #endif
#if !defined NO_UTF8
} /* if */
#endif
} else { } else {
cptr+=1; cptr+=1;
if (*cptr==sc_ctrlchar) { if (*cptr==sc_ctrlchar) {

63
compiler/libpc300/sc3.c Executable file → Normal file
View File

@ -1010,38 +1010,60 @@ static int hier13(value *lval)
{ {
int lvalue=plnge1(hier12,lval); int lvalue=plnge1(hier12,lval);
if (matchtoken('?')) { if (matchtoken('?')) {
int locheap=decl_heap; /* save current heap delta */
long heap1,heap2; /* max. heap delta either branch */
valuepair *heaplist_node;
int flab1=getlabel(); int flab1=getlabel();
int flab2=getlabel(); int flab2=getlabel();
value lval2 = {0}; value lval2 = {0};
int array1,array2; int array1,array2;
int orig_heap=decl_heap;
int diff1=0,diff2=0;
if (lvalue) { if (lvalue) {
rvalue(lval); rvalue(lval);
} else if (lval->ident==iCONSTEXPR) { } else if (lval->ident==iCONSTEXPR) {
ldconst(lval->constval,sPRI); ldconst(lval->constval,sPRI);
error(lval->constval ? 206 : 205); /* redundant test */ error(lval->constval ? 206 : 205); /* redundant test */
} /* if */ } /* if */
if (sc_status==statFIRST) {
/* We should push a new node right now otherwise we will pop it in the
* wrong order on the write stage.
*/
heaplist_node=push_heaplist(0,0); /* save the pointer to write the actual data later */
} else if (sc_status==statWRITE || sc_status==statSKIP) {
#if !defined NDEBUG
int result=
#endif
popfront_heaplist(&heap1,&heap2);
assert(result); /* pop off equally many items than were pushed */
} /* if */
jmp_eq0(flab1); /* go to second expression if primary register==0 */ jmp_eq0(flab1); /* go to second expression if primary register==0 */
PUSHSTK_I(sc_allowtags); PUSHSTK_I(sc_allowtags);
sc_allowtags=FALSE; /* do not allow tagnames here (colon is a special token) */ sc_allowtags=FALSE; /* do not allow tagnames here (colon is a special token) */
if (sc_status==statWRITE) {
modheap(heap1*sizeof(cell));
decl_heap+=heap1; /* equilibrate the heap (see comment below) */
} /* if */
if (hier13(lval)) if (hier13(lval))
rvalue(lval); rvalue(lval);
if (lval->ident==iCONSTEXPR) /* load constant here */ if (lval->ident==iCONSTEXPR) /* load constant here */
ldconst(lval->constval,sPRI); ldconst(lval->constval,sPRI);
sc_allowtags=(short)POPSTK_I(); /* restore */ sc_allowtags=(short)POPSTK_I(); /* restore */
heap1=decl_heap-locheap; /* save heap space used in "true" branch */
assert(heap1>=0);
decl_heap=locheap; /* restore heap delta */
jumplabel(flab2); jumplabel(flab2);
setlabel(flab1); setlabel(flab1);
if (orig_heap!=decl_heap) {
diff1=abs(decl_heap-orig_heap);
decl_heap=orig_heap;
}
needtoken(':'); needtoken(':');
if (sc_status==statWRITE) {
modheap(heap2*sizeof(cell));
decl_heap+=heap2; /* equilibrate the heap (see comment below) */
} /* if */
if (hier13(&lval2)) if (hier13(&lval2))
rvalue(&lval2); rvalue(&lval2);
if (lval2.ident==iCONSTEXPR) /* load constant here */ if (lval2.ident==iCONSTEXPR) /* load constant here */
ldconst(lval2.constval,sPRI); ldconst(lval2.constval,sPRI);
heap2=decl_heap-locheap; /* save heap space used in "false" branch */
assert(heap2>=0);
array1= (lval->ident==iARRAY || lval->ident==iREFARRAY); array1= (lval->ident==iARRAY || lval->ident==iREFARRAY);
array2= (lval2.ident==iARRAY || lval2.ident==iREFARRAY); array2= (lval2.ident==iARRAY || lval2.ident==iREFARRAY);
if (array1 && !array2) { if (array1 && !array2) {
@ -1055,19 +1077,26 @@ static int hier13(value *lval)
if (!matchtag(lval->tag,lval2.tag,FALSE)) if (!matchtag(lval->tag,lval2.tag,FALSE))
error(213); /* tagname mismatch ('true' and 'false' expressions) */ error(213); /* tagname mismatch ('true' and 'false' expressions) */
setlabel(flab2); setlabel(flab2);
if (sc_status==statFIRST) {
/* Calculate the max. heap space used by either branch and save values of
* max - heap1 and max - heap2. On the second pass, we use these values
* to equilibrate the heap space used by either branch. This is needed
* because we don't know (at compile time) which branch will be taken,
* but the heap cannot be restored inside each branch because the result
* on the heap may needed by the remaining expression.
*/
int max=(heap1>heap2) ? heap1 : heap2;
heaplist_node->first=max-heap1;
heaplist_node->second=max-heap2;
decl_heap=locheap+max; /* otherwise it will contain locheap+heap2 and the
* max. heap usage will be wrong for the upper
* expression */
} /* if */
assert(sc_status!=statWRITE || heap1==heap2);
if (lval->ident==iARRAY) if (lval->ident==iARRAY)
lval->ident=iREFARRAY; /* iARRAY becomes iREFARRAY */ lval->ident=iREFARRAY; /* iARRAY becomes iREFARRAY */
else if (lval->ident!=iREFARRAY) else if (lval->ident!=iREFARRAY)
lval->ident=iEXPRESSION; /* iREFARRAY stays iREFARRAY, rest becomes iEXPRESSION */ lval->ident=iEXPRESSION; /* iREFARRAY stays iREFARRAY, rest becomes iEXPRESSION */
if (orig_heap!=decl_heap) {
diff2=abs(decl_heap-orig_heap);
decl_heap=orig_heap;
}
if (diff1==diff2) {
decl_heap+=(diff1/2);
} else {
decl_heap+=(diff1+diff2);
}
return FALSE; /* conditional expression is no lvalue */ return FALSE; /* conditional expression is no lvalue */
} else { } else {
return lvalue; return lvalue;
@ -2058,7 +2087,8 @@ static int nesting=0;
error(35,argidx+1); /* argument type mismatch */ error(35,argidx+1); /* argument type mismatch */
/* Verify that the dimensions match with those in arg[argidx]. /* Verify that the dimensions match with those in arg[argidx].
* A literal array always has a single dimension. * A literal array always has a single dimension.
* An iARRAYCELL parameter is also assumed to have a single dimension. * An iARRAYCELL parameter is also assumed to have a single dimension,
* but its size may be >1 in case of an enumeration pseudo-array.
*/ */
if (lval.sym==NULL || lval.ident==iARRAYCELL) { if (lval.sym==NULL || lval.ident==iARRAYCELL) {
if (arg[argidx].numdim!=1) { if (arg[argidx].numdim!=1) {
@ -2066,6 +2096,7 @@ static int nesting=0;
} else if (arg[argidx].dim[0]!=0) { } else if (arg[argidx].dim[0]!=0) {
assert(arg[argidx].dim[0]>0); assert(arg[argidx].dim[0]>0);
if (lval.ident==iARRAYCELL) { if (lval.ident==iARRAYCELL) {
if (lval.constval==0 || arg[argidx].dim[0]!=lval.constval)
error(47); /* array sizes must match */ error(47); /* array sizes must match */
} else { } else {
assert(lval.constval!=0); /* literal array must have a size */ assert(lval.constval!=0); /* literal array must have a size */

View File

@ -309,120 +309,3 @@ SC_FUNC cell cp_translate(const unsigned char *string,const unsigned char **endp
} }
#endif /* NO_CODEPAGE */ #endif /* NO_CODEPAGE */
#if !defined NO_UTF8
SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **endptr)
{
int follow=0;
long lowmark=0;
unsigned char ch;
cell result=0;
if (endptr!=NULL)
*endptr=string;
for ( ;; ) {
ch=*string++;
if (follow>0 && (ch & 0xc0)==0x80) {
/* leader code is active, combine with earlier code */
result=(result << 6) | (ch & 0x3f);
if (--follow==0) {
/* encoding a character in more bytes than is strictly needed,
* is not really valid UTF-8; we are strict here to increase
* the chance of heuristic dectection of non-UTF-8 text
* (JAVA writes zero bytes as a 2-byte code UTF-8, which is invalid)
*/
if (result<lowmark)
return -1;
/* the code positions 0xd800--0xdfff and 0xfffe & 0xffff do not
* exist in UCS-4 (and hence, they do not exist in Unicode)
*/
if ((result>=0xd800 && result<=0xdfff) || result==0xfffe || result==0xffff)
return -1;
} /* if */
break;
} else if (follow==0 && (ch & 0x80)==0x80) {
/* UTF-8 leader code */
if ((ch & 0xe0)==0xc0) {
/* 110xxxxx 10xxxxxx */
follow=1;
lowmark=0x80L;
result=ch & 0x1f;
} else if ((ch & 0xf0)==0xe0) {
/* 1110xxxx 10xxxxxx 10xxxxxx (16 bits, BMP plane) */
follow=2;
lowmark=0x800L;
result=ch & 0x0f;
} else if ((ch & 0xf8)==0xf0) {
/* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
follow=3;
lowmark=0x10000L;
result=ch & 0x07;
} else if ((ch & 0xfc)==0xf8) {
/* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
follow=4;
lowmark=0x200000L;
result=ch & 0x03;
} else if ((ch & 0xfe)==0xfc) {
/* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx (32 bits) */
follow=5;
lowmark=0x4000000L;
result=ch & 0x01;
} else {
/* this is invalid UTF-8 */
return -1;
} /* if */
} else if (follow==0 && (ch & 0x80)==0x00) {
/* 0xxxxxxx (US-ASCII) */
result=ch;
break;
} else {
/* this is invalid UTF-8 */
return -1;
} /* if */
} /* for */
if (endptr!=NULL)
*endptr=string;
return result;
}
#endif
SC_FUNC int scan_utf8(FILE *fp,const char *filename)
{
#if defined NO_UTF8
return 0;
#else
static void *resetpos=NULL;
int utf8=TRUE;
int firstchar=TRUE,bom_found=FALSE;
const unsigned char *ptr;
resetpos=pc_getpossrc(fp);
while (utf8 && pc_readsrc(fp,pline,sLINEMAX)!=NULL) {
ptr=pline;
if (firstchar) {
/* check whether the very first character on the very first line
* starts with a BYTE order mark
*/
cell c=get_utf8_char(ptr,&ptr);
bom_found= (c==0xfeff);
utf8= (c>=0);
firstchar=FALSE;
} /* if */
while (utf8 && *ptr!='\0')
utf8= (get_utf8_char(ptr,&ptr)>=0);
} /* while */
pc_resetsrc(fp,resetpos);
if (bom_found) {
unsigned char bom[3];
if (!utf8)
error(77,filename); /* malformed UTF-8 encoding */
pc_readsrc(fp,bom,3);
assert(bom[0]==0xef && bom[1]==0xbb && bom[2]==0xbf);
} /* if */
return utf8;
#endif /* NO_UTF8 */
}

View File

@ -443,6 +443,52 @@ SC_FUNC void delete_autolisttable(void)
} }
/* ----- value pair list ----------------------------------------- */
static valuepair heaplist = {NULL, 0, 0};
SC_FUNC valuepair *push_heaplist(long first, long second)
{
valuepair *cur, *last;
if ((cur=malloc(sizeof(valuepair)))==NULL)
error(103); /* insufficient memory (fatal error) */
cur->first=first;
cur->second=second;
cur->next=NULL;
for (last=&heaplist; last->next!=NULL; last=last->next)
/* nothing */;
last->next=cur;
return cur;
}
SC_FUNC int popfront_heaplist(long *first, long *second)
{
valuepair *front=heaplist.next;
if (front==NULL)
return 0;
/* copy fields */
*first=front->first;
*second=front->second;
/* unlink and free */
heaplist.next=front->next;
free(front);
return 1;
}
SC_FUNC void delete_heaplisttable(void)
{
valuepair *cur;
while (heaplist.next!=NULL) {
cur=heaplist.next;
heaplist.next=cur->next;
free(cur);
} /* while */
}
/* ----- debug information --------------------------------------- */ /* ----- debug information --------------------------------------- */
static stringlist dbgstrings = {NULL, NULL}; static stringlist dbgstrings = {NULL, NULL};

View File

@ -84,7 +84,6 @@ SC_VDEFINE int sc_status; /* read/write status */
SC_VDEFINE int sc_rationaltag=0; /* tag for rational numbers */ SC_VDEFINE int sc_rationaltag=0; /* tag for rational numbers */
SC_VDEFINE int rational_digits=0; /* number of fractional digits */ SC_VDEFINE int rational_digits=0; /* number of fractional digits */
SC_VDEFINE int sc_allowproccall=0; /* allow/detect tagnames in lex() */ SC_VDEFINE int sc_allowproccall=0; /* allow/detect tagnames in lex() */
SC_VDEFINE short sc_is_utf8=FALSE; /* is this source file in UTF-8 encoding */
SC_VDEFINE char *pc_deprecate = NULL;/* if non-null, mark next declaration as deprecated */ SC_VDEFINE char *pc_deprecate = NULL;/* if non-null, mark next declaration as deprecated */
SC_VDEFINE int sc_showincludes=0; /* show include files */ SC_VDEFINE int sc_showincludes=0; /* show include files */
SC_VDEFINE int sc_warnings_are_errors=0; SC_VDEFINE int sc_warnings_are_errors=0;

File diff suppressed because it is too large Load Diff

View File

@ -30,4 +30,6 @@ run.options.add_option('--mysql', type='string', dest='mysql_path', default='',
help='Path to MySQL') help='Path to MySQL')
run.options.add_option('--disable-auto-versioning', action='store_true', dest='disable_auto_versioning', run.options.add_option('--disable-auto-versioning', action='store_true', dest='disable_auto_versioning',
default=False, help='Disable the auto versioning script') default=False, help='Disable the auto versioning script')
run.options.add_option('--nasm', type='string', dest='nasm_path',
default='nasm', help='Path to NASM')
run.Configure() run.Configure()

View File

@ -4105,4 +4105,67 @@
"game" "valve" "game" "valve"
} }
//
// Virtual Functions
//
"virtual.games/ag/offsets-common.txt"
{
"game" "ag"
}
"virtual.games/cstrike/offsets-common.txt"
{
"game" "cstrike"
"game" "czero"
}
"virtual.games/dod/offsets-common.txt"
{
"game" "dod"
}
"virtual.games/esf/offsets-common.txt"
{
"game" "esf"
}
"virtual.games/esf_openbeta/offsets-common.txt"
{
"game" "esf_openbeta"
}
"virtual.games/gearbox/offsets-common.txt"
{
"game" "gearbox"
}
"virtual.games/ns/offsets-common.txt"
{
"game" "ns"
"game" "nsp"
}
"virtual.games/svencoop/offsets-common.txt"
{
"game" "svencoop"
}
"virtual.games/tfc/offsets-common.txt"
{
"game" "tfc"
}
"virtual.games/ts/offsets-common.txt"
{
"game" "ts"
}
"virtual.games/valve/offsets-common.txt"
{
"game" "valve"
"game" "dmc"
}
} }

View File

@ -0,0 +1,938 @@
/**
* Do not edit this file. Any changes will be overwritten by the gamedata
* updater or by upgrading your AMX Mod X install.
*
* To override data in this file, create a subdirectory named "custom" and
* place your own gamedata file(s) inside of it. Such files will be parsed
* after AMXX's own.
*
* For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X)
*/
"Games"
{
"#default"
{
"Offsets"
{
"pev"
{
"windows" "4"
"linux" "0"
}
"base"
{
"windows" "0x0"
"linux" "0x60"
}
"spawn"
{
"windows" "0"
"linux" "2"
}
"precache"
{
"windows" "1"
"linux" "3"
}
"keyvalue"
{
"windows" "2"
"linux" "4"
}
"objectcaps"
{
"windows" "5"
"linux" "7"
}
"activate"
{
"windows" "6"
"linux" "8"
}
"setobjectcollisionbox"
{
"windows" "7"
"linux" "9"
}
"classify"
{
"windows" "8"
"linux" "10"
}
"deathnotice"
{
"windows" "9"
"linux" "11"
}
"traceattack"
{
"windows" "10"
"linux" "12"
}
"takedamage"
{
"windows" "11"
"linux" "13"
}
"takehealth"
{
"windows" "12"
"linux" "14"
}
"killed"
{
"windows" "13"
"linux" "15"
}
"bloodcolor"
{
"windows" "14"
"linux" "16"
}
"tracebleed"
{
"windows" "15"
"linux" "17"
}
"istriggered"
{
"windows" "16"
"linux" "18"
}
"mymonsterpointer"
{
"windows" "17"
"linux" "19"
}
"mysquadmonsterpointer"
{
"windows" "18"
"linux" "20"
}
"gettogglestate"
{
"windows" "19"
"linux" "21"
}
"addpoints"
{
"windows" "20"
"linux" "22"
}
"addpointstoteam"
{
"windows" "21"
"linux" "23"
}
"addplayeritem"
{
"windows" "22"
"linux" "24"
}
"removeplayeritem"
{
"windows" "23"
"linux" "25"
}
"giveammo"
{
"windows" "24"
"linux" "26"
}
"getdelay"
{
"windows" "25"
"linux" "27"
}
"ismoving"
{
"windows" "26"
"linux" "28"
}
"overridereset"
{
"windows" "27"
"linux" "29"
}
"damagedecal"
{
"windows" "28"
"linux" "30"
}
"settogglestate"
{
"windows" "29"
"linux" "31"
}
"startsneaking"
{
"windows" "30"
"linux" "32"
}
"stopsneaking"
{
"windows" "31"
"linux" "33"
}
"oncontrols"
{
"windows" "32"
"linux" "34"
}
"issneaking"
{
"windows" "33"
"linux" "35"
}
"isalive"
{
"windows" "34"
"linux" "36"
}
"isbspmodel"
{
"windows" "35"
"linux" "37"
}
"reflectgauss"
{
"windows" "36"
"linux" "38"
}
"hastarget"
{
"windows" "37"
"linux" "39"
}
"isinworld"
{
"windows" "38"
"linux" "40"
}
"isplayer"
{
"windows" "39"
"linux" "41"
}
"isnetclient"
{
"windows" "40"
"linux" "42"
}
"teamid"
{
"windows" "41"
"linux" "43"
}
"getnexttarget"
{
"windows" "42"
"linux" "44"
}
"think"
{
"windows" "43"
"linux" "45"
}
"touch"
{
"windows" "44"
"linux" "46"
}
"use"
{
"windows" "45"
"linux" "47"
}
"blocked"
{
"windows" "46"
"linux" "48"
}
"respawn"
{
"windows" "48"
"linux" "50"
}
"updateowner"
{
"windows" "49"
"linux" "51"
}
"fbecomeprone"
{
"windows" "50"
"linux" "52"
}
"center"
{
"windows" "51"
"linux" "53"
}
"eyeposition"
{
"windows" "52"
"linux" "54"
}
"earposition"
{
"windows" "53"
"linux" "55"
}
"bodytarget"
{
"windows" "54"
"linux" "56"
}
"illumination"
{
"windows" "55"
"linux" "57"
}
"fvisible"
{
"windows" "56"
"linux" "58"
}
"fvecvisible"
{
"windows" "57"
"linux" "59"
}
"look"
{
"windows" "60"
"linux" "62"
}
"changeyaw"
{
"windows" "63"
"linux" "65"
}
"irelationship"
{
"windows" "65"
"linux" "67"
}
"monsterinitdead"
{
"windows" "67"
"linux" "69"
}
"becomedead"
{
"windows" "68"
"linux" "70"
}
"bestvisibleenemy"
{
"windows" "70"
"linux" "72"
}
"finviewcone"
{
"windows" "71"
"linux" "73"
}
"fvecinviewcone"
{
"windows" "72"
"linux" "74"
}
"runai"
{
"windows" "61"
"linux" "63"
}
"monsterthink"
{
"windows" "64"
"linux" "66"
}
"monsterinit"
{
"windows" "66"
"linux" "68"
}
"checklocalmove"
{
"windows" "73"
"linux" "75"
}
"move"
{
"windows" "74"
"linux" "76"
}
"moveexecute"
{
"windows" "75"
"linux" "77"
}
"shouldadvanceroute"
{
"windows" "76"
"linux" "78"
}
"getstoppedactivity"
{
"windows" "77"
"linux" "79"
}
"stop"
{
"windows" "78"
"linux" "80"
}
"checkrangeattack1"
{
"windows" "79"
"linux" "81"
}
"checkrangeattack2"
{
"windows" "80"
"linux" "82"
}
"checkmeleeattack1"
{
"windows" "81"
"linux" "83"
}
"checkmeleeattack2"
{
"windows" "82"
"linux" "84"
}
"schedulechange"
{
"windows" "88"
"linux" "90"
}
"canplaysequence"
{
"windows" "89"
"linux" "91"
}
"canplaysentence"
{
"windows" "90"
"linux" "92"
}
"playsentence"
{
"windows" "91"
"linux" "93"
}
"playscriptedsentence"
{
"windows" "92"
"linux" "94"
}
"sentencestop"
{
"windows" "93"
"linux" "95"
}
"getidealstate"
{
"windows" "94"
"linux" "96"
}
"setactivity"
{
"windows" "95"
"linux" "97"
}
"reportaistate"
{
"windows" "96"
"linux" "98"
}
"checkenemy"
{
"windows" "97"
"linux" "99"
}
"ftriangulate"
{
"windows" "98"
"linux" "100"
}
"setyawspeed"
{
"windows" "99"
"linux" "101"
}
"buildnearestroute"
{
"windows" "100"
"linux" "102"
}
"findcover"
{
"windows" "101"
"linux" "103"
}
"coverradius"
{
"windows" "103"
"linux" "105"
}
"fcancheckattacks"
{
"windows" "104"
"linux" "106"
}
"checkammo"
{
"windows" "105"
"linux" "107"
}
"ignoreconditions"
{
"windows" "106"
"linux" "108"
}
"fvalidatehinttype"
{
"windows" "107"
"linux" "109"
}
"fcanactiveidle"
{
"windows" "108"
"linux" "110"
}
"isoundmask"
{
"windows" "109"
"linux" "111"
}
"hearingsensitivity"
{
"windows" "112"
"linux" "114"
}
"barnaclevictimbitten"
{
"windows" "113"
"linux" "115"
}
"barnaclevictimreleased"
{
"windows" "114"
"linux" "116"
}
"preschedulethink"
{
"windows" "115"
"linux" "117"
}
"getdeathactivity"
{
"windows" "116"
"linux" "118"
}
"gibmonster"
{
"windows" "117"
"linux" "119"
}
"hashumangibs"
{
"windows" "118"
"linux" "120"
}
"hasaliengibs"
{
"windows" "119"
"linux" "121"
}
"fademonster"
{
"windows" "120"
"linux" "122"
}
"deathsound"
{
"windows" "122"
"linux" "124"
}
"alertsound"
{
"windows" "123"
"linux" "125"
}
"idlesound"
{
"windows" "124"
"linux" "126"
}
"painsound"
{
"windows" "125"
"linux" "127"
}
"stopfollowing"
{
"windows" "126"
"linux" "128"
}
"player_jump"
{
"windows" "127"
"linux" "129"
}
"player_duck"
{
"windows" "128"
"linux" "130"
}
"player_prethink"
{
"windows" "129"
"linux" "131"
}
"player_postthink"
{
"windows" "130"
"linux" "132"
}
"player_getgunposition"
{
"windows" "121"
"linux" "123"
}
"player_shouldfadeondeath"
{
"windows" "62"
"linux" "64"
}
"player_impulsecommands"
{
"windows" "132"
"linux" "134"
}
"player_updateclientdata"
{
"windows" "131"
"linux" "133"
}
"item_addtoplayer"
{
"windows" "59"
"linux" "61"
}
"item_addduplicate"
{
"windows" "60"
"linux" "62"
}
"item_getiteminfo"
{
"windows" "61"
"linux" "63"
}
"item_candeploy"
{
"windows" "62"
"linux" "64"
}
"item_deploy"
{
"windows" "63"
"linux" "65"
}
"item_canholster"
{
"windows" "64"
"linux" "66"
}
"item_holster"
{
"windows" "65"
"linux" "67"
}
"item_updateiteminfo"
{
"windows" "66"
"linux" "68"
}
"item_preframe"
{
"windows" "67"
"linux" "69"
}
"item_postframe"
{
"windows" "68"
"linux" "70"
}
"item_drop"
{
"windows" "69"
"linux" "71"
}
"item_kill"
{
"windows" "70"
"linux" "72"
}
"item_attachtoplayer"
{
"windows" "71"
"linux" "73"
}
"item_primaryammoindex"
{
"windows" "72"
"linux" "74"
}
"item_secondaryammoindex"
{
"windows" "73"
"linux" "75"
}
"item_updateclientdata"
{
"windows" "74"
"linux" "76"
}
"item_getweaponptr"
{
"windows" "75"
"linux" "77"
}
"item_itemslot"
{
"windows" "76"
"linux" "78"
}
"weapon_extractammo"
{
"windows" "77"
"linux" "79"
}
"weapon_extractclipammo"
{
"windows" "78"
"linux" "80"
}
"weapon_addweapon"
{
"windows" "79"
"linux" "81"
}
"weapon_playemptysound"
{
"windows" "80"
"linux" "82"
}
"weapon_resetemptysound"
{
"windows" "81"
"linux" "83"
}
"weapon_sendweaponanim"
{
"windows" "82"
"linux" "84"
}
"weapon_isusable"
{
"windows" "83"
"linux" "85"
}
"weapon_primaryattack"
{
"windows" "84"
"linux" "86"
}
"weapon_secondaryattack"
{
"windows" "85"
"linux" "87"
}
"weapon_reload"
{
"windows" "86"
"linux" "88"
}
"weapon_weaponidle"
{
"windows" "87"
"linux" "89"
}
"weapon_retireweapon"
{
"windows" "88"
"linux" "90"
}
"weapon_shouldweaponidle"
{
"windows" "89"
"linux" "91"
}
"weapon_usedecrement"
{
"windows" "90"
"linux" "92"
}
}
}
}

View File

@ -0,0 +1,874 @@
/**
* Do not edit this file. Any changes will be overwritten by the gamedata
* updater or by upgrading your AMX Mod X install.
*
* To override data in this file, create a subdirectory named "custom" and
* place your own gamedata file(s) inside of it. Such files will be parsed
* after AMXX's own.
*
* For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X)
*/
"Games"
{
"#default"
{
"Offsets"
{
"pev"
{
"windows" "4"
"linux" "4"
"mac" "4"
}
"base"
{
"windows" "0x0"
"linux" "0x0"
"mac" "0x0"
}
"spawn"
{
"windows" "0"
"linux" "0"
"mac" "0"
}
"precache"
{
"windows" "1"
"linux" "1"
"mac" "1"
}
"keyvalue"
{
"windows" "3"
"linux" "3"
"mac" "3"
}
"objectcaps"
{
"windows" "6"
"linux" "6"
"mac" "6"
}
"activate"
{
"windows" "7"
"linux" "7"
"mac" "7"
}
"setobjectcollisionbox"
{
"windows" "8"
"linux" "8"
"mac" "8"
}
"classify"
{
"windows" "9"
"linux" "9"
"mac" "9"
}
"deathnotice"
{
"windows" "10"
"linux" "10"
"mac" "10"
}
"traceattack"
{
"windows" "11"
"linux" "11"
"mac" "11"
}
"takedamage"
{
"windows" "12"
"linux" "12"
"mac" "12"
}
"takehealth"
{
"windows" "13"
"linux" "13"
"mac" "13"
}
"killed"
{
"windows" "14"
"linux" "14"
"mac" "14"
}
"bloodcolor"
{
"windows" "15"
"linux" "15"
"mac" "15"
}
"tracebleed"
{
"windows" "16"
"linux" "16"
"mac" "16"
}
"istriggered"
{
"windows" "17"
"linux" "17"
"mac" "17"
}
"mymonsterpointer"
{
"windows" "18"
"linux" "18"
"mac" "18"
}
"mysquadmonsterpointer"
{
"windows" "19"
"linux" "19"
"mac" "19"
}
"gettogglestate"
{
"windows" "20"
"linux" "20"
"mac" "20"
}
"addpoints"
{
"windows" "21"
"linux" "21"
"mac" "21"
}
"addpointstoteam"
{
"windows" "22"
"linux" "22"
"mac" "22"
}
"addplayeritem"
{
"windows" "23"
"linux" "23"
"mac" "23"
}
"removeplayeritem"
{
"windows" "24"
"linux" "24"
"mac" "24"
}
"giveammo"
{
"windows" "25"
"linux" "25"
"mac" "25"
}
"getdelay"
{
"windows" "26"
"linux" "26"
"mac" "26"
}
"ismoving"
{
"windows" "27"
"linux" "27"
"mac" "27"
}
"overridereset"
{
"windows" "28"
"linux" "28"
"mac" "28"
}
"damagedecal"
{
"windows" "29"
"linux" "29"
"mac" "29"
}
"settogglestate"
{
"windows" "30"
"linux" "30"
"mac" "30"
}
"startsneaking"
{
"windows" "31"
"linux" "31"
"mac" "31"
}
"stopsneaking"
{
"windows" "32"
"linux" "32"
"mac" "32"
}
"oncontrols"
{
"windows" "33"
"linux" "33"
"mac" "33"
}
"issneaking"
{
"windows" "34"
"linux" "34"
"mac" "34"
}
"isalive"
{
"windows" "35"
"linux" "35"
"mac" "35"
}
"isbspmodel"
{
"windows" "36"
"linux" "36"
"mac" "36"
}
"reflectgauss"
{
"windows" "37"
"linux" "37"
"mac" "37"
}
"hastarget"
{
"windows" "38"
"linux" "38"
"mac" "38"
}
"isinworld"
{
"windows" "39"
"linux" "39"
"mac" "39"
}
"isplayer"
{
"windows" "40"
"linux" "40"
"mac" "40"
}
"isnetclient"
{
"windows" "41"
"linux" "41"
"mac" "41"
}
"teamid"
{
"windows" "42"
"linux" "42"
"mac" "42"
}
"getnexttarget"
{
"windows" "43"
"linux" "43"
"mac" "43"
}
"think"
{
"windows" "44"
"linux" "44"
"mac" "44"
}
"touch"
{
"windows" "45"
"linux" "45"
"mac" "45"
}
"use"
{
"windows" "46"
"linux" "46"
"mac" "46"
}
"blocked"
{
"windows" "47"
"linux" "47"
"mac" "47"
}
"respawn"
{
"windows" "48"
"linux" "48"
"mac" "48"
}
"updateowner"
{
"windows" "49"
"linux" "49"
"mac" "49"
}
"fbecomeprone"
{
"windows" "50"
"linux" "50"
"mac" "50"
}
"center"
{
"windows" "51"
"linux" "51"
"mac" "51"
}
"eyeposition"
{
"windows" "52"
"linux" "52"
"mac" "52"
}
"earposition"
{
"windows" "53"
"linux" "53"
"mac" "53"
}
"bodytarget"
{
"windows" "54"
"linux" "54"
"mac" "54"
}
"illumination"
{
"windows" "55"
"linux" "55"
"mac" "55"
}
"fvisible"
{
"windows" "56"
"linux" "56"
"mac" "56"
}
"fvecvisible"
{
"windows" "57"
"linux" "57"
"mac" "57"
}
"changeyaw"
{
"windows" "59"
"linux" "59"
"mac" "59"
}
"hashumangibs"
{
"windows" "60"
"linux" "60"
"mac" "60"
}
"hasaliengibs"
{
"windows" "61"
"linux" "61"
"mac" "61"
}
"fademonster"
{
"windows" "62"
"linux" "62"
"mac" "62"
}
"gibmonster"
{
"windows" "63"
"linux" "63"
"mac" "63"
}
"getdeathactivity"
{
"windows" "64"
"linux" "64"
"mac" "64"
}
"becomedead"
{
"windows" "65"
"linux" "65"
"mac" "65"
}
"irelationship"
{
"windows" "67"
"linux" "67"
"mac" "67"
}
"painsound"
{
"windows" "68"
"linux" "68"
"mac" "68"
}
"reportaistate"
{
"windows" "70"
"linux" "70"
"mac" "70"
}
"monsterinitdead"
{
"windows" "71"
"linux" "71"
"mac" "71"
}
"look"
{
"windows" "72"
"linux" "72"
"mac" "72"
}
"bestvisibleenemy"
{
"windows" "73"
"linux" "73"
"mac" "73"
}
"finviewcone"
{
"windows" "75"
"linux" "74"
"mac" "74"
}
"fvecinviewcone"
{
"windows" "74"
"linux" "75"
"mac" "75"
}
"player_jump"
{
"windows" "76"
"linux" "76"
"mac" "76"
}
"player_duck"
{
"windows" "77"
"linux" "77"
"mac" "77"
}
"player_prethink"
{
"windows" "78"
"linux" "78"
"mac" "78"
}
"player_postthink"
{
"windows" "79"
"linux" "79"
"mac" "79"
}
"player_getgunposition"
{
"windows" "80"
"linux" "80"
"mac" "80"
}
"player_shouldfadeondeath"
{
"windows" "66"
"linux" "66"
"mac" "66"
}
"player_impulsecommands"
{
"windows" "83"
"linux" "83"
"mac" "83"
}
"player_updateclientdata"
{
"windows" "82"
"linux" "82"
"mac" "82"
}
"item_addtoplayer"
{
"windows" "59"
"linux" "59"
"mac" "59"
}
"item_addduplicate"
{
"windows" "60"
"linux" "60"
"mac" "60"
}
"item_getiteminfo"
{
"windows" "61"
"linux" "61"
"mac" "61"
}
"item_candeploy"
{
"windows" "62"
"linux" "62"
"mac" "62"
}
"item_deploy"
{
"windows" "64"
"linux" "64"
"mac" "64"
}
"item_canholster"
{
"windows" "66"
"linux" "66"
"mac" "66"
}
"item_holster"
{
"windows" "67"
"linux" "67"
"mac" "67"
}
"item_updateiteminfo"
{
"windows" "68"
"linux" "68"
"mac" "68"
}
"item_preframe"
{
"windows" "69"
"linux" "69"
"mac" "69"
}
"item_postframe"
{
"windows" "70"
"linux" "70"
"mac" "70"
}
"item_drop"
{
"windows" "71"
"linux" "71"
"mac" "71"
}
"item_kill"
{
"windows" "72"
"linux" "72"
"mac" "72"
}
"item_attachtoplayer"
{
"windows" "73"
"linux" "73"
"mac" "73"
}
"item_primaryammoindex"
{
"windows" "74"
"linux" "74"
"mac" "74"
}
"item_secondaryammoindex"
{
"windows" "75"
"linux" "75"
"mac" "75"
}
"item_updateclientdata"
{
"windows" "76"
"linux" "76"
"mac" "76"
}
"item_getweaponptr"
{
"windows" "77"
"linux" "77"
"mac" "77"
}
"item_itemslot"
{
"windows" "79"
"linux" "79"
"mac" "79"
}
"weapon_extractammo"
{
"windows" "80"
"linux" "80"
"mac" "80"
}
"weapon_extractclipammo"
{
"windows" "81"
"linux" "81"
"mac" "81"
}
"weapon_addweapon"
{
"windows" "82"
"linux" "82"
"mac" "82"
}
"weapon_playemptysound"
{
"windows" "83"
"linux" "83"
"mac" "83"
}
"weapon_resetemptysound"
{
"windows" "84"
"linux" "84"
"mac" "84"
}
"weapon_isusable"
{
"windows" "86"
"linux" "86"
"mac" "86"
}
"weapon_primaryattack"
{
"windows" "87"
"linux" "87"
"mac" "87"
}
"weapon_secondaryattack"
{
"windows" "88"
"linux" "88"
"mac" "88"
}
"weapon_reload"
{
"windows" "89"
"linux" "89"
"mac" "89"
}
"weapon_weaponidle"
{
"windows" "90"
"linux" "90"
"mac" "90"
}
"weapon_retireweapon"
{
"windows" "91"
"linux" "91"
"mac" "91"
}
"weapon_shouldweaponidle"
{
"windows" "92"
"linux" "92"
"mac" "92"
}
"weapon_usedecrement"
{
"windows" "93"
"linux" "93"
"mac" "93"
}
"cstrike_restart"
{
"windows" "2"
"linux" "2"
"mac" "2"
}
"cstrike_roundrespawn"
{
"windows" "84"
"linux" "84"
"mac" "84"
}
"cstrike_item_candrop"
{
"windows" "63"
"linux" "63"
"mac" "63"
}
"cstrike_item_isweapon"
{
"windows" "65"
"linux" "65"
"mac" "65"
}
"cstrike_item_getmaxspeed"
{
"windows" "78"
"linux" "78"
"mac" "78"
}
"cstrike_weapon_sendweaponanim"
{
"windows" "85"
"linux" "85"
"mac" "85"
}
"cstrike_player_resetmaxspeed"
{
"windows" "69"
"linux" "69"
"mac" "69"
}
"cstrike_player_isbot"
{
"windows" "81"
"linux" "81"
"mac" "81"
}
"cstrike_player_getautoaimvector"
{
"windows" "85"
"linux" "85"
"mac" "85"
}
"cstrike_player_blind"
{
"windows" "86"
"linux" "86"
"mac" "86"
}
"cstrike_player_ontouchingweapon"
{
"windows" "87"
"linux" "87"
"mac" "87"
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,902 @@
/**
* Do not edit this file. Any changes will be overwritten by the gamedata
* updater or by upgrading your AMX Mod X install.
*
* To override data in this file, create a subdirectory named "custom" and
* place your own gamedata file(s) inside of it. Such files will be parsed
* after AMXX's own.
*
* For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X)
*/
"Games"
{
"#default"
{
"Offsets"
{
"pev"
{
"windows" "4"
"linux" "0"
}
"base"
{
"windows" "0x0"
"linux" "0x60"
}
"spawn"
{
"windows" "0"
"linux" "2"
}
"precache"
{
"windows" "1"
"linux" "3"
}
"keyvalue"
{
"windows" "2"
"linux" "4"
}
"objectcaps"
{
"windows" "5"
"linux" "7"
}
"activate"
{
"windows" "6"
"linux" "8"
}
"setobjectcollisionbox"
{
"windows" "7"
"linux" "9"
}
"classify"
{
"windows" "8"
"linux" "10"
}
"deathnotice"
{
"windows" "9"
"linux" "11"
}
"traceattack"
{
"windows" "10"
"linux" "12"
}
"takedamage"
{
"windows" "11"
"linux" "13"
}
"takehealth"
{
"windows" "12"
"linux" "14"
}
"killed"
{
"windows" "13"
"linux" "15"
}
"bloodcolor"
{
"windows" "14"
"linux" "16"
}
"tracebleed"
{
"windows" "15"
"linux" "17"
}
"istriggered"
{
"windows" "16"
"linux" "18"
}
"mymonsterpointer"
{
"windows" "17"
"linux" "19"
}
"mysquadmonsterpointer"
{
"windows" "18"
"linux" "20"
}
"gettogglestate"
{
"windows" "19"
"linux" "21"
}
"addpoints"
{
"windows" "20"
"linux" "22"
}
"addpointstoteam"
{
"windows" "21"
"linux" "23"
}
"addplayeritem"
{
"windows" "22"
"linux" "24"
}
"removeplayeritem"
{
"windows" "23"
"linux" "25"
}
"getdelay"
{
"windows" "24"
"linux" "26"
}
"ismoving"
{
"windows" "25"
"linux" "27"
}
"overridereset"
{
"windows" "26"
"linux" "28"
}
"damagedecal"
{
"windows" "27"
"linux" "29"
}
"settogglestate"
{
"windows" "28"
"linux" "30"
}
"startsneaking"
{
"windows" "29"
"linux" "31"
}
"stopsneaking"
{
"windows" "30"
"linux" "32"
}
"oncontrols"
{
"windows" "31"
"linux" "33"
}
"issneaking"
{
"windows" "32"
"linux" "34"
}
"isalive"
{
"windows" "33"
"linux" "35"
}
"isbspmodel"
{
"windows" "34"
"linux" "36"
}
"reflectgauss"
{
"windows" "35"
"linux" "37"
}
"hastarget"
{
"windows" "36"
"linux" "38"
}
"isinworld"
{
"windows" "37"
"linux" "39"
}
"isplayer"
{
"windows" "38"
"linux" "40"
}
"isnetclient"
{
"windows" "39"
"linux" "41"
}
"teamid"
{
"windows" "40"
"linux" "42"
}
"getnexttarget"
{
"windows" "41"
"linux" "43"
}
"think"
{
"windows" "42"
"linux" "44"
}
"touch"
{
"windows" "43"
"linux" "45"
}
"use"
{
"windows" "44"
"linux" "46"
}
"blocked"
{
"windows" "45"
"linux" "47"
}
"respawn"
{
"windows" "46"
"linux" "48"
}
"updateowner"
{
"windows" "47"
"linux" "49"
}
"fbecomeprone"
{
"windows" "48"
"linux" "50"
}
"center"
{
"windows" "49"
"linux" "51"
}
"eyeposition"
{
"windows" "50"
"linux" "52"
}
"earposition"
{
"windows" "51"
"linux" "53"
}
"bodytarget"
{
"windows" "52"
"linux" "54"
}
"illumination"
{
"windows" "53"
"linux" "55"
}
"fvisible"
{
"windows" "54"
"linux" "56"
}
"fvecvisible"
{
"windows" "55"
"linux" "57"
}
"look"
{
"windows" "57"
"linux" "59"
}
"changeyaw"
{
"windows" "60"
"linux" "62"
}
"irelationship"
{
"windows" "62"
"linux" "64"
}
"monsterinitdead"
{
"windows" "64"
"linux" "66"
}
"becomedead"
{
"windows" "65"
"linux" "67"
}
"bestvisibleenemy"
{
"windows" "67"
"linux" "69"
}
"finviewcone"
{
"windows" "68"
"linux" "70"
}
"fvecinviewcone"
{
"windows" "69"
"linux" "71"
}
"runai"
{
"windows" "58"
"linux" "60"
}
"monsterthink"
{
"windows" "61"
"linux" "63"
}
"monsterinit"
{
"windows" "63"
"linux" "65"
}
"checklocalmove"
{
"windows" "70"
"linux" "72"
}
"move"
{
"windows" "71"
"linux" "73"
}
"moveexecute"
{
"windows" "72"
"linux" "74"
}
"shouldadvanceroute"
{
"windows" "73"
"linux" "75"
}
"getstoppedactivity"
{
"windows" "74"
"linux" "76"
}
"stop"
{
"windows" "75"
"linux" "77"
}
"checkrangeattack1"
{
"windows" "76"
"linux" "78"
}
"checkrangeattack2"
{
"windows" "77"
"linux" "79"
}
"checkmeleeattack1"
{
"windows" "78"
"linux" "80"
}
"checkmeleeattack2"
{
"windows" "79"
"linux" "81"
}
"schedulechange"
{
"windows" "85"
"linux" "87"
}
"canplaysequence"
{
"windows" "86"
"linux" "88"
}
"canplaysentence"
{
"windows" "87"
"linux" "89"
}
"playsentence"
{
"windows" "88"
"linux" "90"
}
"playscriptedsentence"
{
"windows" "89"
"linux" "91"
}
"sentencestop"
{
"windows" "90"
"linux" "92"
}
"getidealstate"
{
"windows" "91"
"linux" "93"
}
"setactivity"
{
"windows" "92"
"linux" "94"
}
"reportaistate"
{
"windows" "93"
"linux" "95"
}
"checkenemy"
{
"windows" "94"
"linux" "96"
}
"ftriangulate"
{
"windows" "95"
"linux" "97"
}
"setyawspeed"
{
"windows" "96"
"linux" "98"
}
"buildnearestroute"
{
"windows" "97"
"linux" "99"
}
"findcover"
{
"windows" "98"
"linux" "100"
}
"coverradius"
{
"windows" "100"
"linux" "102"
}
"fcancheckattacks"
{
"windows" "101"
"linux" "103"
}
"checkammo"
{
"windows" "102"
"linux" "104"
}
"ignoreconditions"
{
"windows" "103"
"linux" "105"
}
"fvalidatehinttype"
{
"windows" "104"
"linux" "106"
}
"fcanactiveidle"
{
"windows" "105"
"linux" "107"
}
"isoundmask"
{
"windows" "106"
"linux" "108"
}
"hearingsensitivity"
{
"windows" "109"
"linux" "111"
}
"barnaclevictimbitten"
{
"windows" "110"
"linux" "112"
}
"barnaclevictimreleased"
{
"windows" "111"
"linux" "113"
}
"preschedulethink"
{
"windows" "112"
"linux" "114"
}
"getdeathactivity"
{
"windows" "113"
"linux" "115"
}
"gibmonster"
{
"windows" "114"
"linux" "116"
}
"hashumangibs"
{
"windows" "115"
"linux" "117"
}
"hasaliengibs"
{
"windows" "116"
"linux" "118"
}
"fademonster"
{
"windows" "117"
"linux" "119"
}
"deathsound"
{
"windows" "119"
"linux" "121"
}
"alertsound"
{
"windows" "120"
"linux" "122"
}
"idlesound"
{
"windows" "121"
"linux" "123"
}
"painsound"
{
"windows" "122"
"linux" "124"
}
"stopfollowing"
{
"windows" "123"
"linux" "125"
}
"player_jump"
{
"windows" "124"
"linux" "126"
}
"player_prethink"
{
"windows" "125"
"linux" "127"
}
"player_postthink"
{
"windows" "126"
"linux" "128"
}
"player_getgunposition"
{
"windows" "118"
"linux" "120"
}
"player_shouldfadeondeath"
{
"windows" "59"
"linux" "61"
}
"player_impulsecommands"
{
"windows" "128"
"linux" "130"
}
"player_updateclientdata"
{
"windows" "127"
"linux" "129"
}
"item_addtoplayer"
{
"windows" "57"
"linux" "59"
}
"item_addduplicate"
{
"windows" "58"
"linux" "60"
}
"item_getiteminfo"
{
"windows" "59"
"linux" "61"
}
"item_candeploy"
{
"windows" "60"
"linux" "62"
}
"item_deploy"
{
"windows" "61"
"linux" "63"
}
"item_canholster"
{
"windows" "62"
"linux" "64"
}
"item_holster"
{
"windows" "63"
"linux" "65"
}
"item_updateiteminfo"
{
"windows" "64"
"linux" "66"
}
"item_preframe"
{
"windows" "65"
"linux" "67"
}
"item_postframe"
{
"windows" "66"
"linux" "68"
}
"item_drop"
{
"windows" "67"
"linux" "69"
}
"item_kill"
{
"windows" "68"
"linux" "70"
}
"item_attachtoplayer"
{
"windows" "69"
"linux" "71"
}
"item_primaryammoindex"
{
"windows" "70"
"linux" "72"
}
"item_secondaryammoindex"
{
"windows" "71"
"linux" "73"
}
"item_updateclientdata"
{
"windows" "72"
"linux" "74"
}
"item_getweaponptr"
{
"windows" "73"
"linux" "75"
}
"item_itemslot"
{
"windows" "74"
"linux" "76"
}
"weapon_playemptysound"
{
"windows" "75"
"linux" "77"
}
"weapon_resetemptysound"
{
"windows" "76"
"linux" "78"
}
"weapon_sendweaponanim"
{
"windows" "77"
"linux" "79"
}
"weapon_primaryattack"
{
"windows" "78"
"linux" "80"
}
"weapon_secondaryattack"
{
"windows" "79"
"linux" "81"
}
"weapon_weaponidle"
{
"windows" "80"
"linux" "82"
}
"weapon_retireweapon"
{
"windows" "81"
"linux" "83"
}
"weapon_shouldweaponidle"
{
"windows" "82"
"linux" "84"
}
"weapon_usedecrement"
{
"windows" "83"
"linux" "85"
}
"esf_weapon_holsterwhenmeleed"
{
"windows" "84"
"linux" "86"
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,878 @@
/**
* Do not edit this file. Any changes will be overwritten by the gamedata
* updater or by upgrading your AMX Mod X install.
*
* To override data in this file, create a subdirectory named "custom" and
* place your own gamedata file(s) inside of it. Such files will be parsed
* after AMXX's own.
*
* For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X)
*/
"Games"
{
"#default"
{
"Offsets"
{
"pev"
{
"windows" "4"
"linux" "4"
}
"base"
{
"windows" "0x0"
"linux" "0x0"
}
"spawn"
{
"windows" "0"
"linux" "0"
}
"precache"
{
"windows" "1"
"linux" "1"
}
"keyvalue"
{
"windows" "2"
"linux" "2"
}
"objectcaps"
{
"windows" "5"
"linux" "5"
}
"activate"
{
"windows" "6"
"linux" "6"
}
"setobjectcollisionbox"
{
"windows" "7"
"linux" "7"
}
"classify"
{
"windows" "8"
"linux" "8"
}
"deathnotice"
{
"windows" "9"
"linux" "9"
}
"traceattack"
{
"windows" "10"
"linux" "10"
}
"takedamage"
{
"windows" "11"
"linux" "11"
}
"takehealth"
{
"windows" "12"
"linux" "12"
}
"killed"
{
"windows" "14"
"linux" "14"
}
"bloodcolor"
{
"windows" "16"
"linux" "16"
}
"tracebleed"
{
"windows" "17"
"linux" "17"
}
"istriggered"
{
"windows" "18"
"linux" "18"
}
"mymonsterpointer"
{
"windows" "19"
"linux" "19"
}
"mysquadmonsterpointer"
{
"windows" "20"
"linux" "20"
}
"gettogglestate"
{
"windows" "21"
"linux" "21"
}
"addpoints"
{
"windows" "22"
"linux" "22"
}
"addpointstoteam"
{
"windows" "23"
"linux" "23"
}
"addplayeritem"
{
"windows" "24"
"linux" "24"
}
"removeplayeritem"
{
"windows" "25"
"linux" "25"
}
"giveammo"
{
"windows" "26"
"linux" "26"
}
"getdelay"
{
"windows" "27"
"linux" "27"
}
"ismoving"
{
"windows" "28"
"linux" "28"
}
"overridereset"
{
"windows" "29"
"linux" "29"
}
"damagedecal"
{
"windows" "30"
"linux" "30"
}
"settogglestate"
{
"windows" "31"
"linux" "31"
}
"startsneaking"
{
"windows" "32"
"linux" "32"
}
"stopsneaking"
{
"windows" "33"
"linux" "33"
}
"oncontrols"
{
"windows" "34"
"linux" "34"
}
"issneaking"
{
"windows" "35"
"linux" "35"
}
"isalive"
{
"windows" "36"
"linux" "36"
}
"isbspmodel"
{
"windows" "37"
"linux" "37"
}
"reflectgauss"
{
"windows" "38"
"linux" "38"
}
"hastarget"
{
"windows" "39"
"linux" "39"
}
"isinworld"
{
"windows" "40"
"linux" "40"
}
"isplayer"
{
"windows" "41"
"linux" "41"
}
"isnetclient"
{
"windows" "42"
"linux" "42"
}
"teamid"
{
"windows" "43"
"linux" "43"
}
"getnexttarget"
{
"windows" "46"
"linux" "46"
}
"think"
{
"windows" "47"
"linux" "47"
}
"touch"
{
"windows" "48"
"linux" "48"
}
"use"
{
"windows" "49"
"linux" "49"
}
"blocked"
{
"windows" "50"
"linux" "50"
}
"respawn"
{
"windows" "52"
"linux" "52"
}
"updateowner"
{
"windows" "53"
"linux" "53"
}
"fbecomeprone"
{
"windows" "54"
"linux" "54"
}
"center"
{
"windows" "55"
"linux" "55"
}
"eyeposition"
{
"windows" "56"
"linux" "56"
}
"earposition"
{
"windows" "57"
"linux" "57"
}
"bodytarget"
{
"windows" "58"
"linux" "58"
}
"illumination"
{
"windows" "59"
"linux" "59"
}
"fvisible"
{
"windows" "60"
"linux" "60"
}
"fvecvisible"
{
"windows" "61"
"linux" "61"
}
"changeyaw"
{
"windows" "65"
"linux" "65"
}
"hashumangibs"
{
"windows" "66"
"linux" "66"
}
"hasaliengibs"
{
"windows" "67"
"linux" "67"
}
"fademonster"
{
"windows" "68"
"linux" "68"
}
"gibmonster"
{
"windows" "69"
"linux" "69"
}
"getdeathactivity"
{
"windows" "70"
"linux" "70"
}
"becomedead"
{
"windows" "71"
"linux" "71"
}
"irelationship"
{
"windows" "73"
"linux" "73"
}
"painsound"
{
"windows" "74"
"linux" "74"
}
"reportaistate"
{
"windows" "75"
"linux" "75"
}
"monsterinitdead"
{
"windows" "76"
"linux" "76"
}
"look"
{
"windows" "77"
"linux" "77"
}
"bestvisibleenemy"
{
"windows" "78"
"linux" "78"
}
"finviewcone"
{
"windows" "80"
"linux" "80"
}
"fvecinviewcone"
{
"windows" "81"
"linux" "81"
}
"player_jump"
{
"windows" "83"
"linux" "83"
}
"player_duck"
{
"windows" "84"
"linux" "84"
}
"player_prethink"
{
"windows" "85"
"linux" "85"
}
"player_postthink"
{
"windows" "86"
"linux" "86"
}
"player_getgunposition"
{
"windows" "87"
"linux" "87"
}
"player_shouldfadeondeath"
{
"windows" "72"
"linux" "72"
}
"player_impulsecommands"
{
"windows" "101"
"linux" "101"
}
"player_updateclientdata"
{
"windows" "99"
"linux" "99"
}
"item_addtoplayer"
{
"windows" "64"
"linux" "64"
}
"item_addduplicate"
{
"windows" "65"
"linux" "65"
}
"item_getiteminfo"
{
"windows" "68"
"linux" "68"
}
"item_candeploy"
{
"windows" "69"
"linux" "69"
}
"item_deploy"
{
"windows" "70"
"linux" "70"
}
"item_canholster"
{
"windows" "71"
"linux" "71"
}
"item_holster"
{
"windows" "72"
"linux" "72"
}
"item_updateiteminfo"
{
"windows" "74"
"linux" "74"
}
"item_preframe"
{
"windows" "75"
"linux" "75"
}
"item_postframe"
{
"windows" "76"
"linux" "76"
}
"item_drop"
{
"windows" "77"
"linux" "77"
}
"item_kill"
{
"windows" "78"
"linux" "78"
}
"item_attachtoplayer"
{
"windows" "79"
"linux" "79"
}
"item_primaryammoindex"
{
"windows" "80"
"linux" "80"
}
"item_secondaryammoindex"
{
"windows" "81"
"linux" "81"
}
"item_updateclientdata"
{
"windows" "82"
"linux" "82"
}
"item_getweaponptr"
{
"windows" "83"
"linux" "83"
}
"item_itemslot"
{
"windows" "84"
"linux" "84"
}
"weapon_extractammo"
{
"windows" "85"
"linux" "85"
}
"weapon_extractclipammo"
{
"windows" "86"
"linux" "86"
}
"weapon_addweapon"
{
"windows" "87"
"linux" "87"
}
"weapon_playemptysound"
{
"windows" "88"
"linux" "88"
}
"weapon_resetemptysound"
{
"windows" "89"
"linux" "89"
}
"weapon_sendweaponanim"
{
"windows" "94"
"linux" "94"
}
"weapon_isusable"
{
"windows" "73"
"linux" "73"
}
"weapon_primaryattack"
{
"windows" "98"
"linux" "98"
}
"weapon_secondaryattack"
{
"windows" "99"
"linux" "99"
}
"weapon_reload"
{
"windows" "100"
"linux" "100"
}
"weapon_weaponidle"
{
"windows" "101"
"linux" "101"
}
"weapon_retireweapon"
{
"windows" "102"
"linux" "102"
}
"weapon_shouldweaponidle"
{
"windows" "103"
"linux" "103"
}
"weapon_usedecrement"
{
"windows" "104"
"linux" "104"
}
"ns_getpointvalue"
{
"windows" "13"
"linux" "13"
}
"ns_awardkill"
{
"windows" "15"
"linux" "15"
}
"ns_resetentity"
{
"windows" "45"
"linux" "45"
}
"ns_updateonremove"
{
"windows" "51"
"linux" "51"
}
"ns_setbonecontroller"
{
"windows" "63"
"linux" "63"
}
"ns_savedataforreset"
{
"windows" "64"
"linux" "64"
}
"ns_gethull"
{
"windows" "79"
"linux" "79"
}
"ns_getmaxwalkspeed"
{
"windows" "88"
"linux" "88"
}
"ns_setteamid"
{
"windows" "90"
"linux" "90"
}
"ns_geteffectiveplayerclass"
{
"windows" "91"
"linux" "91"
}
"ns_getauthenticationmask"
{
"windows" "92"
"linux" "92"
}
"ns_effectiveplayerclasschanged"
{
"windows" "93"
"linux" "93"
}
"ns_needsteamupdate"
{
"windows" "94"
"linux" "94"
}
"ns_sendteamupdate"
{
"windows" "95"
"linux" "95"
}
"ns_sendweaponupdate"
{
"windows" "96"
"linux" "96"
}
"ns_initplayerfromspawn"
{
"windows" "97"
"linux" "97"
}
"ns_packdeadplayeritems"
{
"windows" "98"
"linux" "98"
}
"ns_getanimationforactivity"
{
"windows" "100"
"linux" "100"
}
"ns_startobserver"
{
"windows" "102"
"linux" "102"
}
"ns_stopobserver"
{
"windows" "103"
"linux" "103"
}
"ns_getadrenalinefactor"
{
"windows" "104"
"linux" "104"
}
"ns_givenameditem"
{
"windows" "106"
"linux" "106"
}
"ns_suicide"
{
"windows" "107"
"linux" "107"
}
"ns_getcanuseweapon"
{
"windows" "108"
"linux" "108"
}
"ns_weapon_getweaponprimetime"
{
"windows" "90"
"linux" "90"
}
"ns_weapon_primeweapon"
{
"windows" "91"
"linux" "91"
}
"ns_weapon_getisweaponprimed"
{
"windows" "92"
"linux" "92"
}
"ns_weapon_getisweaponpriming"
{
"windows" "93"
"linux" "93"
}
"ns_weapon_defaultdeploy"
{
"windows" "95"
"linux" "95"
}
"ns_weapon_defaultreload"
{
"windows" "96"
"linux" "96"
}
"ns_weapon_getdeploytime"
{
"windows" "97"
"linux" "97"
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,746 @@
/**
* Do not edit this file. Any changes will be overwritten by the gamedata
* updater or by upgrading your AMX Mod X install.
*
* To override data in this file, create a subdirectory named "custom" and
* place your own gamedata file(s) inside of it. Such files will be parsed
* after AMXX's own.
*
* For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X)
*/
"Games"
{
"#default"
{
"Offsets"
{
"pev"
{
"windows" "4"
"linux" "0"
}
"base"
{
"windows" "0x0"
"linux" "0x60"
}
"spawn"
{
"windows" "7"
"linux" "9"
}
"precache"
{
"windows" "8"
"linux" "10"
}
"keyvalue"
{
"windows" "9"
"linux" "11"
}
"objectcaps"
{
"windows" "12"
"linux" "14"
}
"activate"
{
"windows" "13"
"linux" "15"
}
"setobjectcollisionbox"
{
"windows" "16"
"linux" "18"
}
"classify"
{
"windows" "17"
"linux" "19"
}
"deathnotice"
{
"windows" "18"
"linux" "20"
}
"traceattack"
{
"windows" "19"
"linux" "21"
}
"takedamage"
{
"windows" "20"
"linux" "22"
}
"takehealth"
{
"windows" "21"
"linux" "23"
}
"killed"
{
"windows" "22"
"linux" "24"
}
"bloodcolor"
{
"windows" "23"
"linux" "25"
}
"tracebleed"
{
"windows" "24"
"linux" "26"
}
"istriggered"
{
"windows" "25"
"linux" "27"
}
"mymonsterpointer"
{
"windows" "26"
"linux" "28"
}
"mysquadmonsterpointer"
{
"windows" "27"
"linux" "29"
}
"gettogglestate"
{
"windows" "28"
"linux" "30"
}
"addpoints"
{
"windows" "29"
"linux" "31"
}
"addpointstoteam"
{
"windows" "30"
"linux" "32"
}
"addplayeritem"
{
"windows" "31"
"linux" "33"
}
"removeplayeritem"
{
"windows" "32"
"linux" "34"
}
"giveammo"
{
"windows" "33"
"linux" "35"
}
"getdelay"
{
"windows" "34"
"linux" "36"
}
"ismoving"
{
"windows" "35"
"linux" "37"
}
"overridereset"
{
"windows" "36"
"linux" "38"
}
"damagedecal"
{
"windows" "37"
"linux" "39"
}
"settogglestate"
{
"windows" "38"
"linux" "40"
}
"startsneaking"
{
"windows" "39"
"linux" "41"
}
"stopsneaking"
{
"windows" "40"
"linux" "42"
}
"oncontrols"
{
"windows" "41"
"linux" "43"
}
"issneaking"
{
"windows" "42"
"linux" "44"
}
"isalive"
{
"windows" "43"
"linux" "45"
}
"isbspmodel"
{
"windows" "44"
"linux" "46"
}
"reflectgauss"
{
"windows" "45"
"linux" "47"
}
"hastarget"
{
"windows" "46"
"linux" "48"
}
"isinworld"
{
"windows" "47"
"linux" "49"
}
"isplayer"
{
"windows" "48"
"linux" "50"
}
"isnetclient"
{
"windows" "49"
"linux" "51"
}
"teamid"
{
"windows" "50"
"linux" "52"
}
"getnexttarget"
{
"windows" "51"
"linux" "53"
}
"think"
{
"windows" "52"
"linux" "54"
}
"touch"
{
"windows" "53"
"linux" "55"
}
"use"
{
"windows" "54"
"linux" "56"
}
"blocked"
{
"windows" "55"
"linux" "57"
}
"respawn"
{
"windows" "57"
"linux" "59"
}
"updateowner"
{
"windows" "58"
"linux" "60"
}
"fbecomeprone"
{
"windows" "59"
"linux" "61"
}
"center"
{
"windows" "60"
"linux" "62"
}
"eyeposition"
{
"windows" "61"
"linux" "63"
}
"earposition"
{
"windows" "62"
"linux" "64"
}
"bodytarget"
{
"windows" "63"
"linux" "65"
}
"illumination"
{
"windows" "64"
"linux" "66"
}
"fvisible"
{
"windows" "65"
"linux" "67"
}
"fvecvisible"
{
"windows" "66"
"linux" "68"
}
"changeyaw"
{
"windows" "68"
"linux" "70"
}
"hashumangibs"
{
"windows" "69"
"linux" "71"
}
"hasaliengibs"
{
"windows" "70"
"linux" "72"
}
"fademonster"
{
"windows" "71"
"linux" "73"
}
"gibmonster"
{
"windows" "72"
"linux" "74"
}
"getdeathactivity"
{
"windows" "73"
"linux" "75"
}
"becomedead"
{
"windows" "74"
"linux" "76"
}
"irelationship"
{
"windows" "76"
"linux" "78"
}
"painsound"
{
"windows" "77"
"linux" "79"
}
"reportaistate"
{
"windows" "78"
"linux" "80"
}
"monsterinitdead"
{
"windows" "79"
"linux" "81"
}
"look"
{
"windows" "80"
"linux" "82"
}
"bestvisibleenemy"
{
"windows" "81"
"linux" "83"
}
"finviewcone"
{
"windows" "82"
"linux" "84"
}
"fvecinviewcone"
{
"windows" "83"
"linux" "85"
}
"player_jump"
{
"windows" "84"
"linux" "86"
}
"player_duck"
{
"windows" "85"
"linux" "87"
}
"player_prethink"
{
"windows" "86"
"linux" "88"
}
"player_postthink"
{
"windows" "87"
"linux" "89"
}
"player_getgunposition"
{
"windows" "88"
"linux" "90"
}
"player_shouldfadeondeath"
{
"windows" "75"
"linux" "77"
}
"player_impulsecommands"
{
"windows" "90"
"linux" "92"
}
"player_updateclientdata"
{
"windows" "89"
"linux" "91"
}
"item_addtoplayer"
{
"windows" "68"
"linux" "70"
}
"item_addduplicate"
{
"windows" "69"
"linux" "71"
}
"item_candeploy"
{
"windows" "71"
"linux" "73"
}
"item_deploy"
{
"windows" "72"
"linux" "74"
}
"item_canholster"
{
"windows" "73"
"linux" "75"
}
"item_holster"
{
"windows" "74"
"linux" "76"
}
"item_updateiteminfo"
{
"windows" "75"
"linux" "77"
}
"item_preframe"
{
"windows" "76"
"linux" "78"
}
"item_postframe"
{
"windows" "77"
"linux" "79"
}
"item_drop"
{
"windows" "78"
"linux" "80"
}
"item_kill"
{
"windows" "79"
"linux" "81"
}
"item_attachtoplayer"
{
"windows" "80"
"linux" "82"
}
"item_primaryammoindex"
{
"windows" "81"
"linux" "83"
}
"item_secondaryammoindex"
{
"windows" "82"
"linux" "84"
}
"item_updateclientdata"
{
"windows" "83"
"linux" "85"
}
"item_getweaponptr"
{
"windows" "84"
"linux" "86"
}
"item_itemslot"
{
"windows" "85"
"linux" "87"
}
"weapon_extractammo"
{
"windows" "86"
"linux" "88"
}
"weapon_extractclipammo"
{
"windows" "87"
"linux" "89"
}
"weapon_addweapon"
{
"windows" "88"
"linux" "90"
}
"weapon_playemptysound"
{
"windows" "89"
"linux" "91"
}
"weapon_resetemptysound"
{
"windows" "90"
"linux" "92"
}
"weapon_sendweaponanim"
{
"windows" "91"
"linux" "93"
}
"weapon_isusable"
{
"windows" "92"
"linux" "94"
}
"weapon_primaryattack"
{
"windows" "93"
"linux" "95"
}
"weapon_secondaryattack"
{
"windows" "94"
"linux" "96"
}
"weapon_reload"
{
"windows" "96"
"linux" "98"
}
"weapon_weaponidle"
{
"windows" "97"
"linux" "99"
}
"weapon_retireweapon"
{
"windows" "98"
"linux" "100"
}
"weapon_shouldweaponidle"
{
"windows" "99"
"linux" "101"
}
"weapon_usedecrement"
{
"windows" "100"
"linux" "102"
}
"ts_breakablerespawn"
{
"windows" "0"
"linux" "2"
}
"ts_canusedthroughwalls"
{
"windows" "1"
"linux" "3"
}
"ts_giveslowmul"
{
"windows" "2"
"linux" "4"
}
"ts_goslow"
{
"windows" "3"
"linux" "5"
}
"ts_inslow"
{
"windows" "4"
"linux" "6"
}
"ts_isobjective"
{
"windows" "5"
"linux" "7"
}
"ts_enableobjective"
{
"windows" "6"
"linux" "8"
}
"ts_onfreeentprivatedata"
{
"windows" "10"
"linux" "12"
}
"ts_shouldcollide"
{
"windows" "11"
"linux" "13"
}
"ts_weapon_alternateattack"
{
"windows" "95"
"linux" "97"
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -110,7 +110,6 @@ Section "MainSection" SEC01
File "installer\files\base\addons\amxmodx\configs\core.ini" File "installer\files\base\addons\amxmodx\configs\core.ini"
File "installer\files\base\addons\amxmodx\configs\custommenuitems.cfg" File "installer\files\base\addons\amxmodx\configs\custommenuitems.cfg"
File "installer\files\base\addons\amxmodx\configs\cvars.ini" File "installer\files\base\addons\amxmodx\configs\cvars.ini"
File "installer\files\base\addons\amxmodx\configs\hamdata.ini"
File "installer\files\base\addons\amxmodx\configs\maps.ini" File "installer\files\base\addons\amxmodx\configs\maps.ini"
File "installer\files\base\addons\amxmodx\configs\modules.ini" File "installer\files\base\addons\amxmodx\configs\modules.ini"
File "installer\files\base\addons\amxmodx\configs\plugins.ini" File "installer\files\base\addons\amxmodx\configs\plugins.ini"

View File

@ -721,9 +721,9 @@ void InitFuncsAddresses()
MF_Log("UTIL_FindEntByString is not available - native cs_find_ent_by_class() has been disabled"); MF_Log("UTIL_FindEntByString is not available - native cs_find_ent_by_class() has been disabled");
} }
if (!AddEntityHashValue || !AddEntityHashValue) if (!AddEntityHashValue || !RemoveEntityHashValue)
{ {
MF_Log("AddEntityHashValue or AddEntityHashValue is not available - native cs_set_ent_class() has been disabled"); MF_Log("AddEntityHashValue or RemoveEntityHashValue is not available - native cs_set_ent_class() has been disabled");
} }
if (!HasReGameDll && !GetWeaponInfo) if (!HasReGameDll && !GetWeaponInfo)

View File

@ -17,7 +17,7 @@
#include <resdk/mod_regamedll_api.h> #include <resdk/mod_regamedll_api.h>
CsItemInfo ItemsManager; CsItemInfo ItemsManager;
ItemInfo WeaponsList[MAX_WEAPONS]; ItemInfos WeaponsList[MAX_WEAPONS];
#define PSTATE_ALIASES_TYPE 0 #define PSTATE_ALIASES_TYPE 0
#define PSTATE_ALIASES_ALIAS 1 #define PSTATE_ALIASES_ALIAS 1

View File

@ -20,12 +20,12 @@
#include <amtl/am-string.h> #include <amtl/am-string.h>
#include <sm_stringhashmap.h> #include <sm_stringhashmap.h>
struct ItemInfo struct ItemInfos
{ {
ItemInfo() : name("Empty"), ammoIndex1(-1), maxAmmo1(0), ammoIndex2(-1), maxAmmo2(0), slot(0), position(0), id(0), flags(0) ItemInfos() : name("Empty"), ammoIndex1(-1), maxAmmo1(0), ammoIndex2(-1), maxAmmo2(0), slot(0), position(0), id(0), flags(0)
{} {}
ItemInfo &operator = (ItemInfo &other) ItemInfos &operator = (ItemInfos &other)
{ {
name = other.name; name = other.name;
ammoIndex1 = other.ammoIndex1; ammoIndex1 = other.ammoIndex1;
@ -133,7 +133,7 @@ class CsItemInfo : public ITextListener_SMC
int m_EquipmentsPrice[static_cast<size_t>(Equipments::Count)]; int m_EquipmentsPrice[static_cast<size_t>(Equipments::Count)];
}; };
extern ItemInfo WeaponsList[MAX_WEAPONS]; extern ItemInfos WeaponsList[MAX_WEAPONS];
extern CsItemInfo ItemsManager; extern CsItemInfo ItemsManager;
#endif // _CSTRIKE_WEAPONS_INFOS_H_ #endif // _CSTRIKE_WEAPONS_INFOS_H_

View File

@ -882,7 +882,7 @@ static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params)
GET_OFFSET("CBasePlayer", m_modelIndexPlayer); GET_OFFSET("CBasePlayer", m_modelIndexPlayer);
char modelpath[260]; char modelpath[PLATFORM_MAX_PATH];
ke::SafeSprintf(modelpath, sizeof(modelpath), "models/player/%s/%s.mdl", newModel, newModel); ke::SafeSprintf(modelpath, sizeof(modelpath), "models/player/%s/%s.mdl", newModel, newModel);
auto modelIndex = 0; auto modelIndex = 0;
@ -1998,6 +1998,34 @@ static cell AMX_NATIVE_CALL cs_get_user_weapon(AMX *amx, cell *params)
return 0; return 0;
} }
// native cs_get_weaponbox_item(weaponboxIndex);
static cell AMX_NATIVE_CALL cs_get_weaponbox_item(AMX *amx, cell *params)
{
GET_OFFSET("CWeaponBox", m_rgpPlayerItems);
int weaponboxIndex = params[1];
CHECK_NONPLAYER(weaponboxIndex);
edict_t *pWeaponBox = TypeConversion.id_to_edict(weaponboxIndex);
if (strcmp(STRING(pWeaponBox->v.classname), "weaponbox") != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Not a weaponbox entity! (%d)", weaponboxIndex);
return 0;
}
edict_t *pWeapon;
for (int i = 1; i < MAX_ITEM_TYPES; i++)
{
pWeapon = TypeConversion.cbase_to_edict(get_pdata<void *>(pWeaponBox, m_rgpPlayerItems, i));
if (!FNullEnt(pWeapon))
{
return TypeConversion.edict_to_id(pWeapon);
}
}
return 0;
}
AMX_NATIVE_INFO CstrikeNatives[] = AMX_NATIVE_INFO CstrikeNatives[] =
{ {
{"cs_set_user_money", cs_set_user_money}, {"cs_set_user_money", cs_set_user_money},
@ -2070,5 +2098,6 @@ AMX_NATIVE_INFO CstrikeNatives[] =
{"cs_get_weapon_info", cs_get_weapon_info}, {"cs_get_weapon_info", cs_get_weapon_info},
{"cs_get_user_weapon_entity", cs_get_user_weapon_entity}, {"cs_get_user_weapon_entity", cs_get_user_weapon_entity},
{"cs_get_user_weapon", cs_get_user_weapon}, {"cs_get_user_weapon", cs_get_user_weapon},
{"cs_get_weaponbox_item", cs_get_weaponbox_item},
{nullptr, nullptr} {nullptr, nullptr}
}; };

View File

@ -22,7 +22,7 @@ bool ShouldBlock;
bool ShouldBlockHLTV; bool ShouldBlockHLTV;
bool ShouldDisableHooks; bool ShouldDisableHooks;
bool RetrieveWeaponList; bool RetrieveWeaponList;
ItemInfo CurrentWeaponList; ItemInfos CurrentWeaponList;
int ArgPosition; int ArgPosition;
int MessageIdArmorType; int MessageIdArmorType;

View File

@ -13,12 +13,13 @@
#include "amxxmodule.h" #include "amxxmodule.h"
#include <amtl/am-algorithm.h> #include <amtl/am-algorithm.h>
#include <amtl/am-string.h>
extern int MessageIdTextMsg; extern int MessageIdTextMsg;
bool UTIL_IsPlayer(edict_t *pPlayer) bool UTIL_IsPlayer(edict_t *pPlayer)
{ {
return strcmp(STRING(pPlayer->v.classname), "player") == 0; return pPlayer && strcmp(STRING(pPlayer->v.classname), "player") == 0;
} }
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message) void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message)
@ -36,7 +37,7 @@ bool UTIL_CheckForPublic(const char *publicname)
int i = 0; int i = 0;
char blah[64]; char blah[64];
strncpy(blah, publicname, sizeof(blah) - 1); ke::SafeStrcpy(blah, sizeof(blah), publicname);
while ((amx = MF_GetScriptAmx(i++))) while ((amx = MF_GetScriptAmx(i++)))
{ {

View File

@ -49,6 +49,10 @@ void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \ return 0; \
} \ } \
else if (!MF_GetPlayerEdict(x)->pvPrivateData) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (no private data)", x); \
return 0; \
} \
} else { \ } else { \
if (x != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \ if (x != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
@ -62,8 +66,12 @@ void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength);
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \ return 0; \
} else { \ } else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \ if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
else if (!MF_GetPlayerEdict(x)->pvPrivateData) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (no private data)", x); \
return 0; \ return 0; \
} \ } \
} }

View File

@ -165,9 +165,18 @@
<ClInclude Include="..\..\..\..\public\memtools\CDetour\detours.h" /> <ClInclude Include="..\..\..\..\public\memtools\CDetour\detours.h" />
<ClInclude Include="..\..\..\..\public\memtools\MemoryUtils.h" /> <ClInclude Include="..\..\..\..\public\memtools\MemoryUtils.h" />
<ClInclude Include="..\..\..\..\public\resdk\common\hookchains.h" /> <ClInclude Include="..\..\..\..\public\resdk\common\hookchains.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSEntity.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSInterfaces.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSPlayer.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSPlayerItem.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSPlayerWeapon.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_api.h" /> <ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_api.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_const.h" /> <ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_const.h" />
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_interfaces.h" /> <ClInclude Include="..\..\..\..\public\resdk\engine\cmd_rehlds.h" />
<ClInclude Include="..\..\..\..\public\resdk\engine\FlightRecorder.h" />
<ClInclude Include="..\..\..\..\public\resdk\engine\IObjectContainer.h" />
<ClInclude Include="..\..\..\..\public\resdk\engine\ObjectList.h" />
<ClInclude Include="..\..\..\..\public\resdk\engine\pr_dlls.h" />
<ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_api.h" /> <ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_api.h" />
<ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_interfaces.h" /> <ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_interfaces.h" />
<ClInclude Include="..\..\..\..\public\resdk\mod_regamedll_api.h" /> <ClInclude Include="..\..\..\..\public\resdk\mod_regamedll_api.h" />
@ -185,6 +194,12 @@
<None Include="..\..\..\..\plugins\include\cstrike.inc" /> <None Include="..\..\..\..\plugins\include\cstrike.inc" />
<None Include="..\..\..\..\plugins\include\cstrike_const.inc" /> <None Include="..\..\..\..\plugins\include\cstrike_const.inc" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../../public;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../../public;</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -39,6 +39,12 @@
<Filter Include="ReSDK\cstrike"> <Filter Include="ReSDK\cstrike">
<UniqueIdentifier>{ba0b72ba-25d8-48c3-af84-c1d4d7436636}</UniqueIdentifier> <UniqueIdentifier>{ba0b72ba-25d8-48c3-af84-c1d4d7436636}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="ReSDK\cstrike\API">
<UniqueIdentifier>{67de85cb-b8e7-4cd6-b8cf-2ff7ed540c2b}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{1b196636-b242-45a8-ad14-3fb21eb799f7}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\CstrikeHacks.cpp"> <ClCompile Include="..\CstrikeHacks.cpp">
@ -127,9 +133,6 @@
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_const.h"> <ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_const.h">
<Filter>ReSDK\cstrike</Filter> <Filter>ReSDK\cstrike</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\cstrike\regamedll_interfaces.h">
<Filter>ReSDK\cstrike</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_api.h"> <ClInclude Include="..\..\..\..\public\resdk\engine\rehlds_api.h">
<Filter>ReSDK\engine</Filter> <Filter>ReSDK\engine</Filter>
</ClInclude> </ClInclude>
@ -142,6 +145,36 @@
<ClInclude Include="..\..\..\..\public\resdk\mod_rehlds_api.h"> <ClInclude Include="..\..\..\..\public\resdk\mod_rehlds_api.h">
<Filter>ReSDK</Filter> <Filter>ReSDK</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSEntity.h">
<Filter>ReSDK\cstrike\API</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSInterfaces.h">
<Filter>ReSDK\cstrike\API</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSPlayer.h">
<Filter>ReSDK\cstrike\API</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSPlayerItem.h">
<Filter>ReSDK\cstrike\API</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\cstrike\API\CSPlayerWeapon.h">
<Filter>ReSDK\cstrike\API</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\engine\cmd_rehlds.h">
<Filter>ReSDK\engine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\engine\FlightRecorder.h">
<Filter>ReSDK\engine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\engine\IObjectContainer.h">
<Filter>ReSDK\engine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\engine\ObjectList.h">
<Filter>ReSDK\engine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\public\resdk\engine\pr_dlls.h">
<Filter>ReSDK\engine</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\..\..\plugins\include\cstrike.inc"> <None Include="..\..\..\..\plugins\include\cstrike.inc">
@ -151,4 +184,9 @@
<Filter>Pawn Includes</Filter> <Filter>Pawn Includes</Filter>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>

View File

@ -139,9 +139,9 @@ void RankSystem::clear(){
bool RankSystem::loadCalc(const char* filename, char* error) bool RankSystem::loadCalc(const char* filename, char* error, size_t maxLength)
{ {
if ((MF_LoadAmxScript(&calc.amx,&calc.code,filename,error,0)!=AMX_ERR_NONE)|| if ((MF_LoadAmxScriptEx(&calc.amx,&calc.code,filename, error, maxLength, 0)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 11 , &calc.amxAddr1, &calc.physAddr1)!=AMX_ERR_NONE)|| (MF_AmxAllot(&calc.amx, 11 , &calc.amxAddr1, &calc.physAddr1)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr2, &calc.physAddr2)!=AMX_ERR_NONE)|| (MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr2, &calc.physAddr2)!=AMX_ERR_NONE)||
(MF_AmxFindPublic(&calc.amx,"get_score",&calc.func)!=AMX_ERR_NONE)){ (MF_AmxFindPublic(&calc.amx,"get_score",&calc.func)!=AMX_ERR_NONE)){

View File

@ -110,7 +110,7 @@ public:
void saveRank( const char* filename ); void saveRank( const char* filename );
void loadRank( const char* filename ); void loadRank( const char* filename );
RankStats* findEntryInRank(const char* unique, const char* name, bool isip=false); RankStats* findEntryInRank(const char* unique, const char* name, bool isip=false);
bool loadCalc(const char* filename, char* error); bool loadCalc(const char* filename, char* error, size_t maxLength);
inline int getRankNum( ) const { return rankNum; } inline int getRankNum( ) const { return rankNum; }
void clear(); void clear();
void unloadCalc(); void unloadCalc();

View File

@ -178,14 +178,18 @@ void PlayerPreThink_Post( edict_t *pEntity ) {
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void ServerDeactivate() { void ServerDeactivate()
{
int i; int i;
for( i = 1;i<=gpGlobals->maxClients; ++i){
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i); for( i = 1; i <= gpGlobals->maxClients; ++i)
if (pPlayer->rank) pPlayer->Disconnect(); {
GET_PLAYER_POINTER_I(i)->Disconnect();
} }
if ( (g_rank.getRankNum() >= (int)csstats_maxsize->value) || ((int)csstats_reset->value == 1 ) ) {
CVAR_SET_FLOAT("csstats_reset",0.0); if (static_cast<int>(csstats_maxsize->value) <= 0 || g_rank.getRankNum() >= static_cast<int>(csstats_maxsize->value) || static_cast<int>(csstats_reset->value) != 0)
{
CVAR_SET_FLOAT("csstats_reset", 0.0f);
g_rank.clear(); // clear before save to file g_rank.clear(); // clear before save to file
} }
g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("csstats")) ); g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("csstats")) );
@ -197,27 +201,26 @@ void ServerDeactivate() {
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ){ BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128])
{
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if (pPlayer->pEdict == NULL)
{
pPlayer->Init(ENTINDEX(pEntity), pEntity);
}
pPlayer->Connect(pszAddress); pPlayer->Connect(pszAddress);
RETURN_META_VALUE(MRES_IGNORED, TRUE); RETURN_META_VALUE(MRES_IGNORED, TRUE);
} }
void ClientDisconnect( edict_t *pEntity ) { void ClientDisconnect( edict_t *pEntity )
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); {
if (pPlayer->rank) pPlayer->Disconnect(); GET_PLAYER_POINTER(pEntity)->Disconnect();
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void ClientPutInServer_Post( edict_t *pEntity ) { void ClientPutInServer_Post( edict_t *pEntity )
{
GET_PLAYER_POINTER(pEntity)->PutInServer(); GET_PLAYER_POINTER(pEntity)->PutInServer();
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
@ -418,7 +421,7 @@ void OnAmxxAttach(){
if ( path && *path ) if ( path && *path )
{ {
char error[128]; char error[128];
g_rank.loadCalc( MF_BuildPathname("%s",path) , error ); g_rank.loadCalc( MF_BuildPathname("%s",path) , error, sizeof(error));
} }
if ( !g_rank.begin() ) if ( !g_rank.begin() )

View File

@ -160,8 +160,15 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\..\plugins\include\csstats.inc" /> <None Include="..\..\..\plugins\include\csstats.inc" />
<None Include="..\..\..\plugins\include\csstats_const.inc" />
<None Include="..\..\..\plugins\include\csx.inc" /> <None Include="..\..\..\plugins\include\csx.inc" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../../public;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../../public;</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -18,6 +18,9 @@
<Filter Include="Pawn Includes"> <Filter Include="Pawn Includes">
<UniqueIdentifier>{3f559917-fcbd-4cd3-8136-8a7a769af465}</UniqueIdentifier> <UniqueIdentifier>{3f559917-fcbd-4cd3-8136-8a7a769af465}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{95e872b8-d195-4d02-8a88-aed2894c54fe}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\CMisc.cpp"> <ClCompile Include="..\CMisc.cpp">
@ -60,8 +63,16 @@
<None Include="..\..\..\plugins\include\csstats.inc"> <None Include="..\..\..\plugins\include\csstats.inc">
<Filter>Pawn Includes</Filter> <Filter>Pawn Includes</Filter>
</None> </None>
<None Include="..\..\..\plugins\include\csstats_const.inc">
<Filter>Pawn Includes</Filter>
</None>
<None Include="..\..\..\plugins\include\csx.inc"> <None Include="..\..\..\plugins\include\csx.inc">
<Filter>Pawn Includes</Filter> <Filter>Pawn Includes</Filter>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>

View File

@ -161,6 +161,12 @@
<None Include="..\..\..\..\plugins\include\dodconst.inc" /> <None Include="..\..\..\..\plugins\include\dodconst.inc" />
<None Include="..\..\..\..\plugins\include\dodfun.inc" /> <None Include="..\..\..\..\plugins\include\dodfun.inc" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../../public;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../../public;</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -18,6 +18,9 @@
<Filter Include="Pawn Includes"> <Filter Include="Pawn Includes">
<UniqueIdentifier>{2deb0e1f-fb04-4734-ae4a-39fa3d4eab86}</UniqueIdentifier> <UniqueIdentifier>{2deb0e1f-fb04-4734-ae4a-39fa3d4eab86}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{1441a5c1-9b0c-4dc7-b898-7236588e5f98}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\CMisc.cpp"> <ClCompile Include="..\CMisc.cpp">
@ -64,4 +67,9 @@
<Filter>Pawn Includes</Filter> <Filter>Pawn Includes</Filter>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>

View File

@ -128,9 +128,9 @@ void RankSystem::clear(){
} }
} }
bool RankSystem::loadCalc(const char* filename, char* error) bool RankSystem::loadCalc(const char* filename, char* error, size_t maxLength)
{ {
if ((MF_LoadAmxScript(&calc.amx,&calc.code,filename,error,0)!=AMX_ERR_NONE)|| if ((MF_LoadAmxScriptEx(&calc.amx,&calc.code,filename, error, maxLength, 0)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr1, &calc.physAddr1)!=AMX_ERR_NONE)|| (MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr1, &calc.physAddr1)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr2, &calc.physAddr2)!=AMX_ERR_NONE)|| (MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr2, &calc.physAddr2)!=AMX_ERR_NONE)||
(MF_AmxFindPublic(&calc.amx,"get_score",&calc.func)!=AMX_ERR_NONE)){ (MF_AmxFindPublic(&calc.amx,"get_score",&calc.func)!=AMX_ERR_NONE)){

View File

@ -104,7 +104,7 @@ public:
void saveRank( const char* filename ); void saveRank( const char* filename );
void loadRank( const char* filename ); void loadRank( const char* filename );
RankStats* findEntryInRank(const char* unique, const char* name , bool isip = false); RankStats* findEntryInRank(const char* unique, const char* name , bool isip = false);
bool loadCalc(const char* filename, char* error); bool loadCalc(const char* filename, char* error, size_t maxLength);
inline int getRankNum( ) const { return rankNum; } inline int getRankNum( ) const { return rankNum; }
void clear(); void clear();
void unloadCalc(); void unloadCalc();

View File

@ -471,7 +471,7 @@ void OnAmxxAttach()
if ( path && *path ) if ( path && *path )
{ {
char error[128]; char error[128];
g_rank.loadCalc( MF_BuildPathname("%s",path) , error ); g_rank.loadCalc( MF_BuildPathname("%s",path) , error, sizeof(error));
} }
if ( !g_rank.begin() ) if ( !g_rank.begin() )

View File

@ -164,6 +164,12 @@
<None Include="..\..\..\..\plugins\include\dodstats.inc" /> <None Include="..\..\..\..\plugins\include\dodstats.inc" />
<None Include="..\..\..\..\plugins\include\dodx.inc" /> <None Include="..\..\..\..\plugins\include\dodx.inc" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../../public;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../../public;</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -18,6 +18,9 @@
<Filter Include="Pawn Includes"> <Filter Include="Pawn Includes">
<UniqueIdentifier>{d13b95f6-bd1e-4c68-a7f1-57e4f39ffde3}</UniqueIdentifier> <UniqueIdentifier>{d13b95f6-bd1e-4c68-a7f1-57e4f39ffde3}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{0f02323b-c637-4625-aa3c-03f1424de34c}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\CMisc.cpp"> <ClCompile Include="..\CMisc.cpp">
@ -73,4 +76,9 @@
<Filter>Pawn Includes</Filter> <Filter>Pawn Includes</Filter>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>

View File

@ -456,6 +456,13 @@ static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) {
plinfo[iIndex].iViewType = CAMERA_3RDPERSON; plinfo[iIndex].iViewType = CAMERA_3RDPERSON;
pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
if (!pNewCamera)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Could not create camera entity.");
return 0;
}
pNewCamera->v.classname = MAKE_STRING("VexdCam"); pNewCamera->v.classname = MAKE_STRING("VexdCam");
SET_MODEL(pNewCamera, "models/rpgrocket.mdl"); SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
@ -486,6 +493,13 @@ static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) {
plinfo[iIndex].iViewType = CAMERA_UPLEFT; plinfo[iIndex].iViewType = CAMERA_UPLEFT;
pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
if (!pNewCamera)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Could not create camera entity.");
return 0;
}
pNewCamera->v.classname = MAKE_STRING("VexdCam"); pNewCamera->v.classname = MAKE_STRING("VexdCam");
SET_MODEL(pNewCamera, "models/rpgrocket.mdl"); SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
@ -516,6 +530,13 @@ static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) {
plinfo[iIndex].iViewType = CAMERA_TOPDOWN; plinfo[iIndex].iViewType = CAMERA_TOPDOWN;
pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
if (!pNewCamera)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Could not create camera entity.");
return 0;
}
pNewCamera->v.classname = MAKE_STRING("VexdCam"); pNewCamera->v.classname = MAKE_STRING("VexdCam");
SET_MODEL(pNewCamera, "models/rpgrocket.mdl"); SET_MODEL(pNewCamera, "models/rpgrocket.mdl");

View File

@ -130,6 +130,12 @@
<None Include="..\..\..\plugins\include\engine_stocks.inc" /> <None Include="..\..\..\plugins\include\engine_stocks.inc" />
<None Include="..\..\..\plugins\include\hlsdk_const.inc" /> <None Include="..\..\..\plugins\include\hlsdk_const.inc" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../public;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../public;</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -27,6 +27,9 @@
<Filter Include="Memtools\CDetour\asm"> <Filter Include="Memtools\CDetour\asm">
<UniqueIdentifier>{6c2c3c74-4dc3-45bf-b3a5-6224971eee69}</UniqueIdentifier> <UniqueIdentifier>{6c2c3c74-4dc3-45bf-b3a5-6224971eee69}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{766da9da-a13a-4f01-a886-570fc28772a6}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\amxxapi.cpp"> <ClCompile Include="..\amxxapi.cpp">
@ -103,4 +106,9 @@
<Filter>Pawn Includes</Filter> <Filter>Pawn Includes</Filter>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>

View File

@ -12,9 +12,12 @@
// //
#include "fakemeta_amxx.h" #include "fakemeta_amxx.h"
#include <engine_strucs.h>
TraceResult g_tr; TraceResult g_tr;
ke::AString LightStyleBuffers[MAX_LIGHTSTYLES];
//by mahnsawce from his NS module //by mahnsawce from his NS module
static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params) static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
{ {
@ -595,8 +598,13 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
case EngFunc_LightStyle: // void ) (int style, const char* val); case EngFunc_LightStyle: // void ) (int style, const char* val);
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
iparam1=cRet[0]; iparam1=cRet[0];
temp = MF_GetAmxString(amx,params[3],0,&len); if (iparam1 < 0 || iparam1 >= ARRAYSIZE(LightStyleBuffers))
(*g_engfuncs.pfnLightStyle)(iparam1,temp); {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid style %d", iparam1);
return 0;
}
LightStyleBuffers[iparam1] = MF_GetAmxString(amx, params[3], 0, &len);
(*g_engfuncs.pfnLightStyle)(iparam1, LightStyleBuffers[iparam1].chars());
return 1; return 1;

View File

@ -50,6 +50,16 @@
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(TypeConversion.id_to_edict(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity"); return 0; } #define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(TypeConversion.id_to_edict(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity"); return 0; }
#define CHECK_OFFSET(x) if (x < 0) { MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset"); return 0; } #define CHECK_OFFSET(x) if (x < 0) { MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset"); return 0; }
#define CHECK_ENTITY_PDATA(x) \
if (FNullEnt(TypeConversion.id_to_edict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
else if (!TypeConversion.id_to_edict(x)->pvPrivateData) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d (no private data)", x); \
return 0; \
}
extern AMX_NATIVE_INFO engfunc_natives[]; extern AMX_NATIVE_INFO engfunc_natives[];
extern AMX_NATIVE_INFO dllfunc_natives[]; extern AMX_NATIVE_INFO dllfunc_natives[];

View File

@ -27,7 +27,6 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
} }
cell *ptr = MF_GetAmxAddr(amx, params[2]); cell *ptr = MF_GetAmxAddr(amx, params[2]);
edict_t *e;
switch (type) switch (type)
{ {
@ -85,12 +84,13 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
} }
case TR_pHit: case TR_pHit:
{ {
e = TypeConversion.id_to_edict(*ptr); const auto pEdict = TypeConversion.id_to_edict(*ptr);
if (!e || FNullEnt(e)) if (pEdict == nullptr)
return 0; //TODO: return error {
gfm_tr->pHit = e; return 0;
}
gfm_tr->pHit = pEdict;
return 1; return 1;
break;
} }
case TR_iHitgroup: case TR_iHitgroup:
{ {
@ -167,7 +167,7 @@ static cell AMX_NATIVE_CALL get_tr(AMX *amx, cell *params)
} }
case TR_pHit: case TR_pHit:
{ {
if (gfm_tr->pHit == NULL || FNullEnt(gfm_tr->pHit)) if (FNullEnt(gfm_tr->pHit))
return -1; return -1;
return ENTINDEX(gfm_tr->pHit); return ENTINDEX(gfm_tr->pHit);
break; break;

View File

@ -98,12 +98,13 @@ static cell AMX_NATIVE_CALL set_tr2(AMX *amx, cell *params)
} }
case TR_pHit: case TR_pHit:
{ {
edict_t *e = TypeConversion.id_to_edict(*ptr); const auto pEdict = TypeConversion.id_to_edict(*ptr);
if (!e || FNullEnt(e)) if (pEdict == nullptr)
return 0; //TODO: return error {
tr->pHit = e; return 0;
}
tr->pHit = pEdict;
return 1; return 1;
break;
} }
case TR_iHitgroup: case TR_iHitgroup:
{ {
@ -187,7 +188,7 @@ static cell AMX_NATIVE_CALL get_tr2(AMX *amx, cell *params)
} }
case TR_pHit: case TR_pHit:
{ {
if (tr->pHit == NULL || FNullEnt(tr->pHit)) if (FNullEnt(tr->pHit))
return -1; return -1;
return ENTINDEX(tr->pHit); return ENTINDEX(tr->pHit);
break; break;

View File

@ -18,7 +18,7 @@ static cell AMX_NATIVE_CALL copy_infokey_buffer(AMX *amx, cell *params)
{ {
char *infobuffer = reinterpret_cast<char *>(params[1]); char *infobuffer = reinterpret_cast<char *>(params[1]);
return MF_SetAmxString(amx, params[2], infobuffer, params[3]); return MF_SetAmxString(amx, params[2], infobuffer ? infobuffer : "", params[3]);
} }
// lookup_sequence(entid, "sequence name", &Float:framerate = 0.0, &bool:loops = false, &Float:groundspeed = 0.0); // lookup_sequence(entid, "sequence name", &Float:framerate = 0.0, &bool:loops = false, &Float:groundspeed = 0.0);
@ -149,42 +149,6 @@ enum
Model_CurrentSequence = -1, Model_CurrentSequence = -1,
}; };
// GetModelCollisionBox( index, Float:mins[3], Float:maxs[3] );
static cell AMX_NATIVE_CALL GetModelCollisionBox(AMX *amx, cell *params)
{
int entityIndex = params[1];
CHECK_ENTITY(entityIndex);
edict_t *pEdict = TypeConversion.id_to_edict(entityIndex);
if (!FNullEnt(pEdict))
{
studiohdr_t *pStudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(pEdict));
if (!pStudiohdr)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Could not find the model pointer for the entity.");
return 0;
}
cell *cmins = MF_GetAmxAddr(amx, params[2]);
cell *cmaxs = MF_GetAmxAddr(amx, params[3]);
cmins[0] = amx_ftoc(pStudiohdr->bbmin.x);
cmins[1] = amx_ftoc(pStudiohdr->bbmin.y);
cmins[2] = amx_ftoc(pStudiohdr->bbmin.z);
cmaxs[0] = amx_ftoc(pStudiohdr->bbmax.x);
cmaxs[1] = amx_ftoc(pStudiohdr->bbmax.y);
cmaxs[2] = amx_ftoc(pStudiohdr->bbmax.z);
return 1;
}
return 0;
};
// GetModelBoundingBox( index, Float:mins[3], Float:maxs[3], sequence = Model_DefaultSize ); // GetModelBoundingBox( index, Float:mins[3], Float:maxs[3], sequence = Model_DefaultSize );
static cell AMX_NATIVE_CALL GetModelBoundingBox(AMX *amx, cell *params) static cell AMX_NATIVE_CALL GetModelBoundingBox(AMX *amx, cell *params)
{ {
@ -242,82 +206,11 @@ static cell AMX_NATIVE_CALL GetModelBoundingBox(AMX *amx, cell *params)
return 0; return 0;
}; };
// SetModelCollisionBox( index );
static cell AMX_NATIVE_CALL SetModelCollisionBox(AMX *amx, cell *params)
{
int entityIndex = params[1];
CHECK_ENTITY(entityIndex);
edict_t *pentModel = TypeConversion.id_to_edict(entityIndex);
if (!FNullEnt(pentModel))
{
studiohdr_t *pStudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(pentModel));
if (!pStudiohdr)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Could not find the model pointer for the entity.");
return 0;
}
SET_SIZE(pentModel, pStudiohdr->bbmin, pStudiohdr->bbmax);
return 1;
}
return 0;
};
// SetModelBoudingBox( index, sequence = Model_DefaultSize );
static cell AMX_NATIVE_CALL SetModelBoundingBox(AMX *amx, cell *params)
{
int entityIndex = params[1];
CHECK_ENTITY(entityIndex);
edict_t *pentModel = TypeConversion.id_to_edict(entityIndex);
if (!FNullEnt(pentModel))
{
studiohdr_t *pStudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(pentModel));
if (!pStudiohdr)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Could not find the model pointer for the entity.");
return 0;
}
int sequence = params[2];
if (sequence <= Model_DefaultSize)
{
SET_SIZE(pentModel, pStudiohdr->min, pStudiohdr->max);
}
else
{
if (sequence <= Model_CurrentSequence || sequence >= pStudiohdr->numseq)
sequence = pentModel->v.sequence;
mstudioseqdesc_t *pSeqdesc;
pSeqdesc = (mstudioseqdesc_t*)((byte*)pStudiohdr + pStudiohdr->seqindex);
SET_SIZE(pentModel, pSeqdesc[sequence].bbmin, pSeqdesc[sequence].bbmax);
return 1;
}
}
return 0;
}
AMX_NATIVE_INFO misc_natives[] = { AMX_NATIVE_INFO misc_natives[] = {
{ "copy_infokey_buffer", copy_infokey_buffer }, { "copy_infokey_buffer", copy_infokey_buffer },
{ "lookup_sequence", lookup_sequence }, { "lookup_sequence", lookup_sequence },
{ "set_controller", set_controller }, { "set_controller", set_controller },
{ "GetModelCollisionBox", GetModelCollisionBox },
{ "SetModelCollisionBox", SetModelCollisionBox },
{ "GetModelBoundingBox", GetModelBoundingBox }, { "GetModelBoundingBox", GetModelBoundingBox },
{ "SetModelBoundingBox", SetModelBoundingBox },
{NULL, NULL}, {NULL, NULL},
}; };

View File

@ -120,11 +120,14 @@
<ClInclude Include="..\..\..\public\HLTypeConversion.h" /> <ClInclude Include="..\..\..\public\HLTypeConversion.h" />
<ClInclude Include="..\..\..\public\memtools\MemoryUtils.h" /> <ClInclude Include="..\..\..\public\memtools\MemoryUtils.h" />
<ClInclude Include="..\..\..\public\resdk\common\hookchains.h" /> <ClInclude Include="..\..\..\public\resdk\common\hookchains.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\API\CSEntity.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\API\CSInterfaces.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\API\CSPlayer.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\API\CSPlayerItem.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\API\CSPlayerWeapon.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_api.h" /> <ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_api.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_const.h" /> <ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_const.h" />
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_interfaces.h" />
<ClInclude Include="..\..\..\public\resdk\mod_regamedll_api.h" /> <ClInclude Include="..\..\..\public\resdk\mod_regamedll_api.h" />
<ClInclude Include="..\..\..\public\resdk\mod_rehlds_api.h" />
<ClInclude Include="..\fakemeta_amxx.h" /> <ClInclude Include="..\fakemeta_amxx.h" />
<ClInclude Include="..\fm_tr.h" /> <ClInclude Include="..\fm_tr.h" />
<ClInclude Include="..\dllfunc.h" /> <ClInclude Include="..\dllfunc.h" />
@ -145,6 +148,12 @@
<None Include="..\..\..\plugins\include\fakemeta_stocks.inc" /> <None Include="..\..\..\plugins\include\fakemeta_stocks.inc" />
<None Include="..\..\..\plugins\include\hlsdk_const.inc" /> <None Include="..\..\..\plugins\include\hlsdk_const.inc" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../public;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../public;</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -45,6 +45,12 @@
<Filter Include="ReSDK\cstrike"> <Filter Include="ReSDK\cstrike">
<UniqueIdentifier>{0d1c5025-071d-43aa-b19a-2eee0d34a906}</UniqueIdentifier> <UniqueIdentifier>{0d1c5025-071d-43aa-b19a-2eee0d34a906}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="ReSDK\cstrike\API">
<UniqueIdentifier>{2800175e-06bf-42bf-b3c1-f86561471531}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{c5065ec5-3262-49dd-825b-2cf3956e79ac}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\fakemeta_amxx.cpp"> <ClCompile Include="..\fakemeta_amxx.cpp">
@ -145,14 +151,23 @@
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_const.h"> <ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_const.h">
<Filter>ReSDK\cstrike</Filter> <Filter>ReSDK\cstrike</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\public\resdk\cstrike\regamedll_interfaces.h">
<Filter>ReSDK\cstrike</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\mod_regamedll_api.h"> <ClInclude Include="..\..\..\public\resdk\mod_regamedll_api.h">
<Filter>ReSDK</Filter> <Filter>ReSDK</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\public\resdk\mod_rehlds_api.h"> <ClInclude Include="..\..\..\public\resdk\cstrike\API\CSEntity.h">
<Filter>ReSDK</Filter> <Filter>ReSDK\cstrike\API</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\cstrike\API\CSInterfaces.h">
<Filter>ReSDK\cstrike\API</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\cstrike\API\CSPlayer.h">
<Filter>ReSDK\cstrike\API</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\cstrike\API\CSPlayerItem.h">
<Filter>ReSDK\cstrike\API</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\resdk\cstrike\API\CSPlayerWeapon.h">
<Filter>ReSDK\cstrike\API</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -174,4 +189,9 @@
<Filter>PEV</Filter> <Filter>PEV</Filter>
</CustomBuildStep> </CustomBuildStep>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>

View File

@ -32,18 +32,18 @@
//implement these with setjmp later. //implement these with setjmp later.
bool IsBadReadPtr(void *l, size_t size) bool IsBadReadPtr(void *l, size_t size)
{ {
return false; return l ? false : true;
} }
bool IsBadWritePtr(void *l, size_t size) bool IsBadWritePtr(void *l, size_t size)
{ {
return false; return l ? false : true;
} }
#endif #endif
static cell AMX_NATIVE_CALL set_pdata_int(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_int(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int iOffset=params[2]; int iOffset=params[2];
CHECK_OFFSET(iOffset); CHECK_OFFSET(iOffset);
@ -65,7 +65,7 @@ static cell AMX_NATIVE_CALL set_pdata_int(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_pdata_int(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_int(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int iOffset=params[2]; int iOffset=params[2];
CHECK_OFFSET(iOffset); CHECK_OFFSET(iOffset);
@ -87,7 +87,7 @@ static cell AMX_NATIVE_CALL get_pdata_int(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_pdata_float(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_float(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int iOffset=params[2]; int iOffset=params[2];
CHECK_OFFSET(iOffset); CHECK_OFFSET(iOffset);
@ -109,7 +109,7 @@ static cell AMX_NATIVE_CALL set_pdata_float(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_pdata_float(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_float(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int iOffset=params[2]; int iOffset=params[2];
CHECK_OFFSET(iOffset); CHECK_OFFSET(iOffset);
@ -130,7 +130,7 @@ static cell AMX_NATIVE_CALL get_pdata_float(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_pdata_string(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_string(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int iOffset=params[2]; int iOffset=params[2];
CHECK_OFFSET(iOffset); CHECK_OFFSET(iOffset);
@ -167,7 +167,7 @@ static cell AMX_NATIVE_CALL get_pdata_string(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_pdata_string(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_string(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int iOffset=params[2]; int iOffset=params[2];
CHECK_OFFSET(iOffset); CHECK_OFFSET(iOffset);
@ -192,22 +192,27 @@ static cell AMX_NATIVE_CALL set_pdata_string(AMX *amx, cell *params)
szData = get_pdata_direct<char*>(pEdict, iOffset); szData = get_pdata_direct<char*>(pEdict, iOffset);
if (IsBadWritePtr(szData, 1)) if (IsBadWritePtr(szData, 1))
return 0; return 0;
strcpy(szData, data);
} else { } else {
szData = get_pdata<char*>(pEdict, iOffset); szData = get_pdata<char*>(pEdict, iOffset);
if (IsBadWritePtr(szData, 1)) if (IsBadWritePtr(szData, 1))
return 0; return 0;
if (len > static_cast<int>(strlen(szData)))
{
if (params[4] == 1) if (params[4] == 1)
{ {
free(szData); free(szData);
szData = (char *)malloc(len + 1); szData = (char *)malloc(len + 1);
} else if (params[4] == 2) { }
delete [] szData; else if (params[4] == 2) {
delete[] szData;
szData = new char[len + 1]; szData = new char[len + 1];
} }
strcpy(szData, data);
set_pdata<char*>(pEdict, iOffset, szData); set_pdata<char*>(pEdict, iOffset, szData);
} }
}
strncopy(szData, data, len + 1);
return 1; return 1;
} }
@ -215,7 +220,7 @@ static cell AMX_NATIVE_CALL set_pdata_string(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_pdata_ent(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_ent(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int iOffset=params[2]; int iOffset=params[2];
CHECK_OFFSET(iOffset); CHECK_OFFSET(iOffset);
@ -256,7 +261,7 @@ static cell AMX_NATIVE_CALL get_pdata_ent(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_pdata_ent(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_ent(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -282,7 +287,7 @@ static cell AMX_NATIVE_CALL set_pdata_ent(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_pdata_bool(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_bool(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -303,7 +308,7 @@ static cell AMX_NATIVE_CALL get_pdata_bool(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_pdata_bool(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_bool(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -328,7 +333,7 @@ static cell AMX_NATIVE_CALL set_pdata_bool(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_pdata_byte(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_byte(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -349,7 +354,7 @@ static cell AMX_NATIVE_CALL get_pdata_byte(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_pdata_byte(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_byte(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -374,7 +379,7 @@ static cell AMX_NATIVE_CALL set_pdata_byte(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_pdata_short(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_short(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -395,7 +400,7 @@ static cell AMX_NATIVE_CALL get_pdata_short(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_pdata_short(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_short(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -420,7 +425,7 @@ static cell AMX_NATIVE_CALL set_pdata_short(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_pdata_vector(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_vector(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -449,7 +454,7 @@ static cell AMX_NATIVE_CALL get_pdata_vector(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_pdata_vector(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_vector(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -476,7 +481,7 @@ static cell AMX_NATIVE_CALL set_pdata_vector(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_pdata_ehandle(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_ehandle(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);
@ -524,7 +529,7 @@ static cell AMX_NATIVE_CALL get_pdata_ehandle(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_pdata_ehandle(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_ehandle(AMX *amx, cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY_PDATA(index);
int offset = params[2]; int offset = params[2];
CHECK_OFFSET(offset); CHECK_OFFSET(offset);

View File

@ -18,7 +18,7 @@
static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params)
{ {
int entity = params[1]; int entity = params[1];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
TypeDescription data; TypeDescription data;
GET_TYPE_DESCRIPTION(2, data, CommonConfig); GET_TYPE_DESCRIPTION(2, data, CommonConfig);
@ -33,7 +33,7 @@ static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_ent_data(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_ent_data(AMX *amx, cell *params)
{ {
int entity = params[1]; int entity = params[1];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
TypeDescription data; TypeDescription data;
GET_TYPE_DESCRIPTION(2, data, CommonConfig); GET_TYPE_DESCRIPTION(2, data, CommonConfig);
@ -57,7 +57,7 @@ static cell AMX_NATIVE_CALL set_ent_data(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_ent_data_float(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_ent_data_float(AMX *amx, cell *params)
{ {
int entity = params[1]; int entity = params[1];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
TypeDescription data; TypeDescription data;
GET_TYPE_DESCRIPTION(2, data, CommonConfig); GET_TYPE_DESCRIPTION(2, data, CommonConfig);
@ -72,7 +72,7 @@ static cell AMX_NATIVE_CALL get_ent_data_float(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_ent_data_float(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_ent_data_float(AMX *amx, cell *params)
{ {
int entity = params[1]; int entity = params[1];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
TypeDescription data; TypeDescription data;
GET_TYPE_DESCRIPTION(2, data, CommonConfig); GET_TYPE_DESCRIPTION(2, data, CommonConfig);
@ -90,7 +90,7 @@ static cell AMX_NATIVE_CALL set_ent_data_float(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_ent_data_vector(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_ent_data_vector(AMX *amx, cell *params)
{ {
int entity = params[1]; int entity = params[1];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
TypeDescription data; TypeDescription data;
GET_TYPE_DESCRIPTION(2, data, CommonConfig); GET_TYPE_DESCRIPTION(2, data, CommonConfig);
@ -107,7 +107,7 @@ static cell AMX_NATIVE_CALL get_ent_data_vector(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_ent_data_vector(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_ent_data_vector(AMX *amx, cell *params)
{ {
int entity = params[1]; int entity = params[1];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
TypeDescription data; TypeDescription data;
GET_TYPE_DESCRIPTION(2, data, CommonConfig); GET_TYPE_DESCRIPTION(2, data, CommonConfig);
@ -125,7 +125,7 @@ static cell AMX_NATIVE_CALL set_ent_data_vector(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_ent_data_entity(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_ent_data_entity(AMX *amx, cell *params)
{ {
int entity = params[1]; int entity = params[1];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
TypeDescription data; TypeDescription data;
GET_TYPE_DESCRIPTION(2, data, CommonConfig); GET_TYPE_DESCRIPTION(2, data, CommonConfig);
@ -142,7 +142,7 @@ static cell AMX_NATIVE_CALL set_ent_data_entity(AMX *amx, cell *params)
int entity = params[1]; int entity = params[1];
int value = params[4]; int value = params[4];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
if (value != -1) if (value != -1)
{ {
@ -165,7 +165,7 @@ static cell AMX_NATIVE_CALL set_ent_data_entity(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_ent_data_string(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_ent_data_string(AMX *amx, cell *params)
{ {
int entity = params[1]; int entity = params[1];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
TypeDescription data; TypeDescription data;
GET_TYPE_DESCRIPTION(2, data, CommonConfig); GET_TYPE_DESCRIPTION(2, data, CommonConfig);
@ -190,7 +190,7 @@ static cell AMX_NATIVE_CALL get_ent_data_string(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params)
{ {
int entity = params[1]; int entity = params[1];
CHECK_ENTITY(entity); CHECK_ENTITY_PDATA(entity);
TypeDescription data; TypeDescription data;
GET_TYPE_DESCRIPTION(2, data, CommonConfig); GET_TYPE_DESCRIPTION(2, data, CommonConfig);

View File

@ -11,562 +11,461 @@
// Fun Module // Fun Module
// //
#include <string.h>
#include "fun.h" #include "fun.h"
#include <HLTypeConversion.h> #include <HLTypeConversion.h>
/*
JGHG says:
Ok this is what I use below, it may probably not be right with all natives etc but I try to maintain this style to natives.
Note that this is still very much subject to change, regarding return values etc!
(Ok I haven't checked all natives that they comply with this yet, this is just a model I'm working on and which I might implement soon.)
static cell AMX_NATIVE_CALL nativename(AMX *amx, cell *params) // nativename(argument1, argument2); = 2 params
{
// Description what this native does. <--- Description what this native does
// params[1] = argument1 <--- Description of each argument, so we don't have to allocate new variables and can
// params[2] = argument2 <--- use the ones in params[n] directly, to save some time.
// Check receiver and sender validity. <--- Check ents, maybe need to do this better and more proper later?
CHECK_PLAYER(params[1])
CHECK_PLAYER(params[2])
// Get * pointer.
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); <--- Players require a different function than INDEXENT because of an HLSDK bug
return 1 <--- If native succeeded, return 1, if the native isn't supposed to return a specific value.
Note: Should be able to do: if (thenative()) and it should return false when it fails, and true when succeeds... is -1 treated as false, or is 0 a must?
}
*/
char g_bodyhits[33][33]; // where can the guy in the first dimension hit the people in the 2nd dimension? :-)
bool g_silent[33]; // used for set_user_footsteps()
HLTypeConversion TypeConversion; HLTypeConversion TypeConversion;
CPlayers Players;
// ######## Utils: // native get_client_listen(receiver, sender)
void FUNUTIL_ResetPlayer(int index) static cell AMX_NATIVE_CALL get_client_listening(AMX *amx, cell *params)
{ {
//MF_PrintSrvConsole("Resetting player index %d! maxclients: %d\n", index, gpGlobals->maxClients); enum args { arg_count, arg_receiver, arg_sender };
for (int i = 1; i <= gpGlobals->maxClients; i++) {
g_bodyhits[index][i] = (char)((1<<HITGROUP_GENERIC) | CHECK_PLAYER(params[arg_receiver]);
(1<<HITGROUP_HEAD) | CHECK_PLAYER(params[arg_sender]);
(1<<HITGROUP_CHEST) |
(1<<HITGROUP_STOMACH) | return GETCLIENTLISTENING(params[arg_receiver], params[arg_sender]);
(1<<HITGROUP_LEFTARM) |
(1<<HITGROUP_RIGHTARM)|
(1<<HITGROUP_LEFTLEG) |
(1<<HITGROUP_RIGHTLEG));
}
// Reset silent slippers
g_silent[index] = false;
} }
// ######## Natives: // native set_client_listen(receiver, sender, listen)
static cell AMX_NATIVE_CALL get_client_listening(AMX *amx, cell *params) // get_client_listening(receiver, sender); = 2 params static cell AMX_NATIVE_CALL set_client_listening(AMX *amx, cell *params)
{ {
// Gets who can listen to who. enum args { arg_count, arg_receiver, arg_sender, arg_listen };
// params[1] = receiver
// params[2] = sender
// Check receiver and sender validity. CHECK_PLAYER(params[arg_receiver]);
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[arg_sender]);
CHECK_PLAYER(params[2]);
// GET- AND SETCLIENTLISTENING returns "qboolean", an int, probably 0 or 1... return SETCLIENTLISTENING(params[arg_receiver], params[arg_sender], params[arg_listen]);
return GETCLIENTLISTENING(params[1], params[2]);
} }
static cell AMX_NATIVE_CALL set_client_listening(AMX *amx, cell *params) // set_client_listening(receiver, sender, listen); = 3 params // native set_user_godmode(index, godmode = 0)
static cell AMX_NATIVE_CALL set_user_godmode(AMX *amx, cell *params)
{ {
// Sets who can listen to who. enum args { arg_count, arg_user, arg_godmode };
// params[1] = receiver
// params[2] = sender
// params[3] = listen
// Check receiver and sender validity. CHECK_PLAYER(params[arg_user]);
CHECK_PLAYER(params[1]);
CHECK_PLAYER(params[2]);
// Make a check on params[3] here later, and call run time error when it's wrong. const auto pPlayer = TypeConversion.id_to_edict(params[arg_user]);
// To do: find out the possible values to set (0, 1?)
// GET- AND SETCLIENTLISTENING returns "qboolean", an int, probably 0 or 1... pPlayer->v.takedamage = params[arg_godmode] != 0 ? DAMAGE_NO : DAMAGE_AIM;
return SETCLIENTLISTENING(params[1], params[2], params[3]);
}
static cell AMX_NATIVE_CALL set_user_godmode(AMX *amx, cell *params) // set_user_godmode(index, godmode = 0); = 2 params
{
/* Sets player godmode. If you want to disable godmode set only first parameter. */
// params[1] = index
// params[2] = godmode = 0
// Check index.
CHECK_PLAYER(params[1]);
// Get player pointer.
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
if (params[2] == 1) {
// Enable godmode
pPlayer->v.takedamage = 0.0; // 0.0, the player doesn't seem to be able to get hurt.
}
else {
// Disable godmode
pPlayer->v.takedamage = 2.0; // 2.0 seems to be standard value?
}
return 1; return 1;
} }
static cell AMX_NATIVE_CALL get_user_godmode(AMX *amx, cell *params) // get_user_godmode(index); = 1 param // native get_user_godmode(index)
static cell AMX_NATIVE_CALL get_user_godmode(AMX *amx, cell *params)
{ {
/* Returns 1 if godmode is set. */ enum args { arg_count, arg_user };
// params[1] = index
// Check index. CHECK_PLAYER(params[arg_user]);
CHECK_PLAYER(params[1]);
// Get player pointer. const auto pPlayer = TypeConversion.id_to_edict(params[arg_user]);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
int godmode = 0; return pPlayer->v.takedamage == DAMAGE_NO;
if (pPlayer->v.takedamage == 0.0) {
// God mode is enabled
godmode = 1;
}
return godmode;
} }
static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params) // native give_item(index, const item[]); = 2 params // native give_item(index, const item[])
static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params)
{ {
/* Gives item to player, name of item can start enum args { arg_count, arg_index, arg_item };
* with weapon_, ammo_ and item_. This event
* is announced with proper message to all players. */
// params[1] = index
// params[2] = item...
// Check index. CHECK_PLAYER(params[arg_index]);
CHECK_PLAYER(params[1]);
// Get player pointer. auto itemLength = 0;
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]); const auto item = MF_GetAmxString(amx, params[arg_item], 1, &itemLength);
// Create item entity pointer if (!itemLength
edict_t *pItemEntity; ||(strncmp(item, "weapon_", 7) != 0
&& strncmp(item, "ammo_", 5) != 0
// Make an "intstring" out of 2nd parameter && strncmp(item, "item_", 5) != 0
int length; && strncmp(item, "tf_weapon_", 10) != 0))
const char *szItem = MF_GetAmxString(amx, params[2], 1, &length); {
//check for valid item
if (strncmp(szItem, "weapon_", 7) &&
strncmp(szItem, "ammo_", 5) &&
strncmp(szItem, "item_", 5) &&
strncmp(szItem, "tf_weapon_", 10)
) {
return 0; return 0;
} }
//string_t item = MAKE_STRING(szItem); auto pEntity = CREATE_NAMED_ENTITY(ALLOC_STRING(item));
string_t item = ALLOC_STRING(szItem); // Using MAKE_STRING makes "item" contents get lost when we leave this scope! ALLOC_STRING seems to allocate properly...
// Create the entity, returns to pointer
pItemEntity = CREATE_NAMED_ENTITY(item);
if (FNullEnt(pItemEntity)) { if (FNullEnt(pEntity))
MF_LogError(amx, AMX_ERR_NATIVE, "Item \"%s\" failed to create", szItem); {
MF_LogError(amx, AMX_ERR_NATIVE, "Item \"%s\" failed to create", item);
return 0; return 0;
} }
//VARS(pItemEntity)->origin = VARS(pPlayer)->origin; // nice to do VARS(ent)->origin instead of ent->v.origin? :-I const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
//I'm not sure, normally I use macros too =P
pItemEntity->v.origin = pPlayer->v.origin;
pItemEntity->v.spawnflags |= SF_NORESPAWN; //SF_NORESPAWN;
MDLL_Spawn(pItemEntity); pEntity->v.origin = pPlayer->v.origin;
pEntity->v.spawnflags |= SF_NORESPAWN;
int save = pItemEntity->v.solid; MDLL_Spawn(pEntity);
MDLL_Touch(pItemEntity, ENT(pPlayer)); const auto oldSolid = pEntity->v.solid;
//The problem with the original give_item was the MDLL_Touch(pEntity, pPlayer);
// item was not removed. I had tried this but it
// did not work. OLO's implementation is better.
/*
int iEnt = ENTINDEX(pItemEntity->v.owner);
if (iEnt > 32 || iEnt <1 ) {
MDLL_Think(pItemEntity);
}*/
if (pItemEntity->v.solid == save) { if (pEntity->v.solid == oldSolid)
REMOVE_ENTITY(pItemEntity); {
//the function did not fail - we're just deleting the item REMOVE_ENTITY(pEntity); // The function did not fail - we're just deleting the item
return -1; return -1;
} }
return ENTINDEX(pItemEntity); return TypeConversion.edict_to_id(pEntity);
} }
static cell AMX_NATIVE_CALL spawn(AMX *amx, cell *params) // spawn(id) = 1 param // native spawn(index)
static cell AMX_NATIVE_CALL spawn(AMX *amx, cell *params)
{ {
// Spawns an entity, this can be a user/player -> spawns at spawnpoints, or created entities seems to need this as a final "kick" into the game? :-) enum args { arg_count, arg_index };
// params[1] = entity to spawn
CHECK_ENTITY(params[1]); CHECK_ENTITY(params[arg_index]);
edict_t *pEnt = TypeConversion.id_to_edict(params[1]); const auto pEntity = TypeConversion.id_to_edict(params[arg_index]);
MDLL_Spawn(pEnt); MDLL_Spawn(pEntity);
return 1; return 1;
} }
static cell AMX_NATIVE_CALL set_user_health(AMX *amx, cell *params) // set_user_health(index, health); = 2 arguments // native set_user_health(index, health)
static cell AMX_NATIVE_CALL set_user_health(AMX *amx, cell *params)
{ {
// Sets user health. If health is 0 and below, also kill... enum args { arg_count, arg_index, arg_health };
// params[1] = index
// params[2] = health
// Check index CHECK_PLAYER(params[arg_index]);
CHECK_PLAYER(params[1]);
// Fetch player pointer const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]); const auto health = float(params[arg_health]);
// Kill if health too low. if (health > 0.0f)
if (params[2] > 0) {
pPlayer->v.health = float(params[2]); pPlayer->v.health = health;
}
else else
{
MDLL_ClientKill(pPlayer); MDLL_ClientKill(pPlayer);
}
return 1; return 1;
} }
static cell AMX_NATIVE_CALL set_user_frags(AMX *amx, cell *params) // set_user_frags(index, frags); = 2 arguments // native set_user_frags(index, frags)
static cell AMX_NATIVE_CALL set_user_frags(AMX *amx, cell *params)
{ {
// Sets user frags. enum args { arg_count, arg_index, arg_frags };
// params[1] = index
// params[2] = frags
// Check index CHECK_PLAYER(params[arg_index]);
CHECK_PLAYER(params[1]);
// Fetch player pointer const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
pPlayer->v.frags = params[2]; pPlayer->v.frags = float(params[arg_frags]);
return 1; return 1;
} }
static cell AMX_NATIVE_CALL set_user_armor(AMX *amx, cell *params) // set_user_armor(index, armor); = 2 arguments // native set_user_armor(index, armor)
static cell AMX_NATIVE_CALL set_user_armor(AMX *amx, cell *params)
{ {
// Sets user armor. enum args { arg_count, arg_index, arg_armor };
// params[1] = index
// params[2] = armor
// Check index CHECK_PLAYER(params[arg_index]);
CHECK_PLAYER(params[1]);
// Fetch player pointer const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
pPlayer->v.armorvalue = params[2]; pPlayer->v.armorvalue = float(params[arg_armor]);
return 1; return 1;
} }
static cell AMX_NATIVE_CALL set_user_origin(AMX *amx, cell *params) // set_user_origin(index, origin[3]); = 2 arguments // native set_user_origin(index, const origin[3])
static cell AMX_NATIVE_CALL set_user_origin(AMX *amx, cell *params)
{ {
// Sets user origin. enum args { arg_count, arg_index, arg_origin };
// params[1] = index
// params[2] = origin
// Check index CHECK_PLAYER(params[arg_index]);
CHECK_PLAYER(params[1]);
// Fetch player pointer auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]); const auto pVector = MF_GetAmxAddr(amx, params[arg_origin]);
cell *newVectorCell = MF_GetAmxAddr(amx, params[2]);
SET_SIZE(pPlayer, pPlayer->v.mins, pPlayer->v.maxs); SET_SIZE(pPlayer, pPlayer->v.mins, pPlayer->v.maxs);
SET_ORIGIN(pPlayer, Vector((float)newVectorCell[0], (float)newVectorCell[1], (float)newVectorCell[2])); SET_ORIGIN(pPlayer, Vector(float(pVector[0]), float(pVector[1]), float(pVector[2])));
return 1; return 1;
} }
static cell AMX_NATIVE_CALL set_user_rendering(AMX *amx, cell *params) // set_user_rendering(index, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16); = 7 arguments // native set_user_rendering(index, fx = kRenderFxNone, r = 0, g = 0, b = 0, render = kRenderNormal, amount = 0)
static cell AMX_NATIVE_CALL set_user_rendering(AMX *amx, cell *params)
{ {
// Sets user rendering. enum args { arg_count, arg_index, arg_fx, arg_red, arg_green, arg_blue, arg_render, arg_amount };
// params[1] = index
// params[2] = fx
// params[3] = r
// params[4] = g
// params[5] = b
// params[6] = render
// params[7] = amount
// Check index CHECK_PLAYER(params[arg_index]);
CHECK_PLAYER(params[1]);
// Fetch player pointer auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
pPlayer->v.renderfx = params[2]; pPlayer->v.renderfx = params[arg_fx];
Vector newVector = Vector(float(params[3]), float(params[4]), float(params[5])); pPlayer->v.rendercolor = Vector(float(params[arg_red]), float(params[arg_green]), float(params[arg_blue]));
pPlayer->v.rendercolor = newVector; pPlayer->v.rendermode = params[arg_render];
pPlayer->v.rendermode = params[6]; pPlayer->v.renderamt = float(params[arg_amount]);
pPlayer->v.renderamt = params[7];
return 1; return 1;
} }
// get_user_rendering(index, &fx = kRenderFxNone, &r = 0, &g = 0, &b = 0, &render = kRenderNormal, &amount = 0);
static cell AMX_NATIVE_CALL set_user_maxspeed(AMX *amx, cell *params) // set_user_maxspeed(index, Float:speed = -1.0) = 2 arguments static cell AMX_NATIVE_CALL get_user_rendering(AMX *amx, cell *params)
{ {
// Sets user maxspeed. enum args { arg_count, arg_index, arg_fx, arg_red, arg_green, arg_blue, arg_render, arg_amount };
// params[1] = index
// params[2] = speed (should be -1.0 if not specified) (JGHG: unspecified parameters seems to always be -1.0!)
REAL fNewSpeed = amx_ctof(params[2]); CHECK_PLAYER(params[arg_index]);
// Check index auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
CHECK_PLAYER(params[1]);
// Fetch player pointer *MF_GetAmxAddr(amx, params[arg_fx]) = pPlayer->v.renderfx;
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]); *MF_GetAmxAddr(amx, params[arg_red]) = pPlayer->v.rendercolor[0];
*MF_GetAmxAddr(amx, params[arg_green]) = pPlayer->v.rendercolor[1];
SETCLIENTMAXSPEED(pPlayer, fNewSpeed); *MF_GetAmxAddr(amx, params[arg_blue]) = pPlayer->v.rendercolor[2];
pPlayer->v.maxspeed = fNewSpeed; *MF_GetAmxAddr(amx, params[arg_render]) = pPlayer->v.rendermode;
*MF_GetAmxAddr(amx, params[arg_amount]) = pPlayer->v.renderamt;
return 1; return 1;
} }
static cell AMX_NATIVE_CALL get_user_maxspeed(AMX *amx, cell *params) // Float:get_user_maxspeed(index) = 1 argument // native set_user_maxspeed(index, Float:speed = -1.0)
static cell AMX_NATIVE_CALL set_user_maxspeed(AMX *amx, cell *params)
{ {
// Gets user maxspeed. enum args { arg_count, arg_index, arg_speed };
// params[1] = index
// Check index CHECK_PLAYER(params[arg_index]);
CHECK_PLAYER(params[1]);
// Fetch player pointer const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]); const auto newSpeed = amx_ctof(params[arg_speed]);
SETCLIENTMAXSPEED(pPlayer, newSpeed);
pPlayer->v.maxspeed = newSpeed;
return 1;
}
// native Float:get_user_maxspeed(index)
static cell AMX_NATIVE_CALL get_user_maxspeed(AMX *amx, cell *params)
{
enum args { arg_count, arg_index };
CHECK_PLAYER(params[arg_index]);
const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
return amx_ftoc(pPlayer->v.maxspeed); return amx_ftoc(pPlayer->v.maxspeed);
} }
static cell AMX_NATIVE_CALL set_user_gravity(AMX *amx, cell *params) // set_user_gravity(index, Float:gravity = 1.0) = 2 arguments // native set_user_gravity(index, Float:gravity = 1.0)
static cell AMX_NATIVE_CALL set_user_gravity(AMX *amx, cell *params)
{ {
// Sets user gravity. enum args { arg_count, arg_index, arg_gravity };
// params[1] = index
// params[2] = gravity (=-1.0)
// Check index
CHECK_PLAYER(params[1]);
// Fetch player pointer CHECK_PLAYER(params[arg_index]);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
pPlayer->v.gravity = amx_ctof(params[2]); const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
pPlayer->v.gravity = amx_ctof(params[arg_gravity]);
return 1; return 1;
} }
static cell AMX_NATIVE_CALL get_user_gravity(AMX *amx, cell *params) // Float:get_user_gravity(index) = 1 argument // native Float:get_user_gravity(index)
static cell AMX_NATIVE_CALL get_user_gravity(AMX *amx, cell *params)
{ {
// Gets user gravity. enum args { arg_count, arg_index };
// params[1] = index
// Check index CHECK_PLAYER(params[arg_index]);
CHECK_PLAYER(params[1]);
// Fetch player pointer const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
return amx_ftoc(pPlayer->v.gravity); return amx_ftoc(pPlayer->v.gravity);
} }
static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params) // set_user_hitzones(index = 0, target = 0, body = 255); = 3 arguments // native set_user_hitzones(index = 0, target = 0, body = HITZONES_DEFAULT)
static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params)
{ {
// Sets user hitzones. enum args { arg_count, arg_attacker, arg_target, arg_hitzones };
// params[1] = the one(s) who shoot(s), shooter
int shooter = params[1];
// params[2] = the one getting hit const int attacker = params[arg_attacker];
int gettingHit = params[2]; const int target = params[arg_target];
const int hitzones = params[arg_hitzones];
// params[3] = specified hit zones if (attacker == 0 && target == 0)
int hitzones = params[3]; {
Players.SetEveryoneBodyHits(hitzones);
//set_user_hitzones(id, 0, 0) // Makes ID not able to shoot EVERYONE - id can shoot on 0 (all) at 0
//set_user_hitzones(0, id, 0) // Makes EVERYONE not able to shoot ID - 0 (all) can shoot id at 0
if (shooter == 0 && gettingHit == 0) {
for (int i = 1; i <= gpGlobals->maxClients; i++) {
for (int j = 1; j <= gpGlobals->maxClients; j++) {
g_bodyhits[i][j] = hitzones;
} }
//g_zones_toHit[i] = hitzones; else if (attacker == 0 && target != 0)
//g_zones_getHit[i] = hitzones; {
}
}
else if (shooter == 0 && gettingHit != 0) {
// "All" shooters, target (gettingHit) should be existing player id
CHECK_PLAYER(gettingHit);
// Where can all hit gettingHit?
for (int i = 1; i <= gpGlobals->maxClients; i++)
g_bodyhits[i][gettingHit] = hitzones;
}
else if (shooter != 0 && gettingHit == 0) {
// Shooter can hit all in bodyparts.
CHECK_PLAYER(shooter);
for (int i = 1; i <= gpGlobals->maxClients; i++)
g_bodyhits[shooter][i] = hitzones;
}
else {
// Specified, where can player A hit player B?
CHECK_PLAYER(shooter);
CHECK_PLAYER(gettingHit);
g_bodyhits[shooter][gettingHit] = hitzones;
}
return 1;
}
static cell AMX_NATIVE_CALL get_user_hitzones(AMX *amx, cell *params) // get_user_hitzones(index, target); = 2 arguments
{
int shooter = params[1];
CHECK_PLAYER(shooter);
int target = params[2];
CHECK_PLAYER(target); CHECK_PLAYER(target);
return g_bodyhits[shooter][target];
}
static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params) // set_user_noclip(index, noclip = 0); = 2 arguments Players.SetAttackersBodyHits(target, hitzones);
{ }
// Sets user to no clipping mode. else if (attacker != 0 && target == 0)
// params[1] = index {
// params[2] = no clip or not... CHECK_PLAYER(attacker);
// Check index Players.SetTargetsBodyHits(attacker, hitzones);
CHECK_PLAYER(params[1]); }
// Fetch player pointer
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
if (params[2] == 1)
pPlayer->v.movetype = MOVETYPE_NOCLIP;
else else
pPlayer->v.movetype = MOVETYPE_WALK; {
CHECK_PLAYER(attacker);
CHECK_PLAYER(target);
Players.SetBodyHits(attacker, target, hitzones);
}
return 1; return 1;
} }
static cell AMX_NATIVE_CALL get_user_noclip(AMX *amx, cell *params) // get_user_noclip(index); = 1 argument // native get_user_hitzones(index, target)
static cell AMX_NATIVE_CALL get_user_hitzones(AMX *amx, cell *params)
{ {
// Gets user noclip. enum args { arg_count, arg_attacker, arg_target };
// params[1] = index
// Check index const auto attacker = params[arg_attacker];
CHECK_PLAYER(params[1]);
// Fetch player pointer CHECK_PLAYER(attacker);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
const auto target = params[arg_target];
CHECK_PLAYER(target);
return Players[attacker].GetBodyHits(target);
}
// native set_user_noclip(index, noclip = 0)
static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params)
{
enum args { arg_count, arg_index, arg_noclip };
CHECK_PLAYER(params[arg_index]);
const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
pPlayer->v.movetype = params[arg_noclip] != 0 ? MOVETYPE_NOCLIP : MOVETYPE_WALK;
return 1;
}
// native get_user_noclip(index)
static cell AMX_NATIVE_CALL get_user_noclip(AMX *amx, cell *params)
{
enum args { arg_count, arg_index };
CHECK_PLAYER(params[arg_index]);
const auto pPlayer = TypeConversion.id_to_edict(params[arg_index]);
return pPlayer->v.movetype == MOVETYPE_NOCLIP; return pPlayer->v.movetype == MOVETYPE_NOCLIP;
} }
// JustinHoMi made this one originally // native set_user_footsteps(id, set = 1)
static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params) // set_user_footsteps(id, set = 1); = 2 params static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params)
{ {
// Gives player silent footsteps. enum args { arg_count, arg_index, arg_footsteps };
// if set=0 it will return footsteps to normal
// params[1] = index of player
// params[2] = 0 = normal footstep sound, 1 = silent slippers
// Check index const auto index = params[arg_index];
CHECK_PLAYER(params[1]);
// Fetch player pointer CHECK_PLAYER(index);
edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
if (params[2]) { const auto pPlayer = TypeConversion.id_to_edict(index);
if (params[arg_footsteps] != 0)
{
pPlayer->v.flTimeStepSound = 999; pPlayer->v.flTimeStepSound = 999;
g_silent[params[1]] = true; Players[index].SetSilentFootsteps(true);
g_pFunctionTable->pfnPlayerPreThink = PlayerPreThink;
} }
else { else
{
pPlayer->v.flTimeStepSound = STANDARDTIMESTEPSOUND; pPlayer->v.flTimeStepSound = STANDARDTIMESTEPSOUND;
g_silent[params[1]] = false; Players[index].SetSilentFootsteps(false);
if (g_pFunctionTable->pfnPlayerPreThink && !Players.HaveSilentFootsteps())
{
g_pFunctionTable->pfnPlayerPreThink = nullptr;
}
} }
return 1; return 1;
} }
// native get_user_footsteps(index)
static cell AMX_NATIVE_CALL get_user_footsteps(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_user_footsteps(AMX *amx, cell *params)
{ {
CHECK_PLAYER(params[1]); enum args { arg_count, arg_index };
return g_silent[params[1]]; const auto index = params[arg_index];
CHECK_PLAYER(index);
return Players[index].HasSilentFootsteps();
} }
// SidLuke // native strip_user_weapons(index)
static cell AMX_NATIVE_CALL strip_user_weapons(AMX *amx, cell *params) // index static cell AMX_NATIVE_CALL strip_user_weapons(AMX *amx, cell *params)
{ {
CHECK_PLAYER(params[1]); enum args { arg_count, arg_index };
edict_t* pPlayer = TypeConversion.id_to_edict(params[1]); const auto index = params[arg_index];
string_t item = MAKE_STRING("player_weaponstrip"); CHECK_PLAYER(index);
edict_t *pent = CREATE_NAMED_ENTITY(item);
if (FNullEnt(pent)) const auto pPlayer = TypeConversion.id_to_edict(index);
const auto pEntity = CREATE_NAMED_ENTITY(MAKE_STRING("player_weaponstrip"));
if (FNullEnt(pEntity))
{ {
return 0; return 0;
} }
MDLL_Spawn(pent); MDLL_Spawn(pEntity);
MDLL_Use(pent, pPlayer); MDLL_Use(pEntity, pPlayer);
REMOVE_ENTITY(pent); REMOVE_ENTITY(pEntity);
*reinterpret_cast<int *>(MF_PlayerPropAddr(params[1], Player_CurrentWeapon)) = 0; *reinterpret_cast<int *>(MF_PlayerPropAddr(index, Player_CurrentWeapon)) = 0;
return 1; return 1;
} }
AMX_NATIVE_INFO fun_Exports[] = {
{"get_client_listen", get_client_listening}, AMX_NATIVE_INFO fun_Exports[] =
{"set_client_listen", set_client_listening}, {
{"set_user_godmode", set_user_godmode}, { "get_client_listen" , get_client_listening },
{"get_user_godmode", get_user_godmode}, { "set_client_listen" , set_client_listening },
{"set_user_health", set_user_health}, { "set_user_godmode" , set_user_godmode },
{"give_item", give_item}, { "get_user_godmode" , get_user_godmode },
{"spawn", spawn}, { "set_user_health" , set_user_health },
{"set_user_frags", set_user_frags}, { "give_item" , give_item },
{"set_user_armor", set_user_armor}, { "spawn" , spawn },
{"set_user_origin", set_user_origin}, { "set_user_frags" , set_user_frags },
{"set_user_rendering", set_user_rendering}, { "set_user_armor" , set_user_armor },
{"set_user_maxspeed", set_user_maxspeed}, { "set_user_origin" , set_user_origin },
{"get_user_maxspeed", get_user_maxspeed}, { "set_user_rendering", set_user_rendering },
{"set_user_gravity", set_user_gravity}, { "get_user_rendering", get_user_rendering },
{"get_user_gravity", get_user_gravity}, { "set_user_maxspeed" , set_user_maxspeed },
{"get_user_footsteps", get_user_footsteps}, { "get_user_maxspeed" , get_user_maxspeed },
{"set_user_hitzones", set_user_hitzones}, { "set_user_gravity" , set_user_gravity },
{"get_user_hitzones", get_user_hitzones}, { "get_user_gravity" , get_user_gravity },
{"set_user_noclip", set_user_noclip}, { "get_user_footsteps", get_user_footsteps },
{"get_user_noclip", get_user_noclip}, { "set_user_hitzones" , set_user_hitzones },
{"set_user_footsteps", set_user_footsteps}, { "get_user_hitzones" , get_user_hitzones },
{"strip_user_weapons", strip_user_weapons}, { "set_user_noclip" , set_user_noclip },
/////////////////// <--- 19 chars max in current small version { "get_user_noclip" , get_user_noclip },
{NULL, NULL} { "set_user_footsteps", set_user_footsteps },
{ "strip_user_weapons", strip_user_weapons },
{ nullptr , nullptr }
}; };
/******************************************************************************************/
void PlayerPreThink(edict_t *pEntity) void PlayerPreThink(edict_t *pEntity)
{ {
if (g_silent[ENTINDEX(pEntity)]) { const auto index = TypeConversion.edict_to_id(pEntity);
if (Players[index].HasSilentFootsteps())
{
pEntity->v.flTimeStepSound = 999; pEntity->v.flTimeStepSound = 999;
RETURN_META(MRES_HANDLED); RETURN_META(MRES_HANDLED);
} }
@ -576,76 +475,52 @@ void PlayerPreThink(edict_t *pEntity)
int ClientConnect(edict_t *pPlayer, const char *pszName, const char *pszAddress, char szRejectReason[128]) int ClientConnect(edict_t *pPlayer, const char *pszName, const char *pszAddress, char szRejectReason[128])
{ {
// Reset stuff: const auto index = TypeConversion.edict_to_id(pPlayer);
FUNUTIL_ResetPlayer(ENTINDEX(pPlayer));
Players[index].Clear();
RETURN_META_VALUE(MRES_IGNORED, 0); RETURN_META_VALUE(MRES_IGNORED, 0);
} }
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *shooter, TraceResult *ptr) { void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *shooter, TraceResult *ptr)
{
TRACE_LINE(v1, v2, fNoMonsters, shooter, ptr); TRACE_LINE(v1, v2, fNoMonsters, shooter, ptr);
if ( ptr->pHit && (ptr->pHit->v.flags& (FL_CLIENT | FL_FAKECLIENT))
&& shooter && (shooter->v.flags & (FL_CLIENT | FL_FAKECLIENT)) ) { if (ptr->pHit && (ptr->pHit->v.flags & (FL_CLIENT | FL_FAKECLIENT))
int shooterIndex = ENTINDEX(shooter); && shooter && (shooter->v.flags & (FL_CLIENT | FL_FAKECLIENT)) )
if ( !(g_bodyhits[shooterIndex][ENTINDEX(ptr->pHit)] & (1<<ptr->iHitgroup)) ) {
const auto shooterIndex = TypeConversion.edict_to_id(shooter);
const auto targetIndex = TypeConversion.edict_to_id(ptr->pHit);
if (!(Players[shooterIndex].GetBodyHits(targetIndex) & (1 << ptr->iHitgroup)))
{
ptr->flFraction = 1.0; ptr->flFraction = 1.0;
} }
}
RETURN_META(MRES_SUPERCEDE); RETURN_META(MRES_SUPERCEDE);
} }
//int g_hitIndex, g_canTargetGetHit, g_canShooterHitThere;
//void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *shooter, TraceResult *ptr) {
// if (!pentToSkip || (pentToSkip->v.flags & (FL_CLIENT | FL_FAKECLIENT)) == false || pentToSkip->v.deadflag != DEAD_NO)
// RETURN_META(MRES_IGNORED);
//
// TRACE_LINE(v1, v2, fNoMonsters, shooter, ptr); // Filter shooter
//
// if (!ptr->pHit || (ptr->pHit->v.flags & (FL_CLIENT | FL_FAKECLIENT)) == false )
// RETURN_META(MRES_SUPERCEDE);
//
// g_hitIndex = ENTINDEX(ptr->pHit);
// //bool blocked = false;
// g_canTargetGetHit = g_zones_getHit[g_hitIndex] & (1 << ptr->iHitgroup);
// g_canShooterHitThere = g_zones_toHit[ENTINDEX(shooter)] & (1 << ptr->iHitgroup);
//
// if (!g_canTargetGetHit || !g_canShooterHitThere) {
// ptr->flFraction = 1.0; // set to not hit anything (1.0 = shot doesn't hit anything)
// //blocked = true;
// }
// /*
// if (blocked) {
// MF_PrintSrvConsole("%s was blocked from hitting %s: %d and %d\n", MF_GetPlayerName(ENTINDEX(pentToSkip)), MF_GetPlayerName(hitIndex), canTargetGetHit, canShooterHitThere);
// }
// else {
// MF_PrintSrvConsole("%s was NOT blocked from hitting %s: %d and %d\n", MF_GetPlayerName(ENTINDEX(pentToSkip)), MF_GetPlayerName(hitIndex), canTargetGetHit, canShooterHitThere);
// }
// */
//
// RETURN_META(MRES_SUPERCEDE);
//}
void OnAmxxAttach() void OnAmxxAttach()
{ {
MF_AddNatives(fun_Exports); MF_AddNatives(fun_Exports);
} }
// The content of OnPluginsLoaded() was moved from OnAmxxAttach with AMXx 1.5 because for some reason gpGlobals->maxClients wasn't void OnPluginsLoaded()
// initialized to its proper value until some time after OnAmxxAttach(). In OnAmxxAttach() it always showed 0. /JGHG {
void OnPluginsLoaded() { Players.Clear();
// Reset stuff - hopefully this should
for (int i = 1; i <= gpGlobals->maxClients; i++) {
// Reset all hitzones
FUNUTIL_ResetPlayer(i);
}
TypeConversion.init(); TypeConversion.init();
g_pFunctionTable->pfnPlayerPreThink = nullptr;
g_pengfuncsTable_Post->pfnTraceLine = nullptr;
} }
/*
void ClientConnectFakeBot(int index) void ServerDeactivate()
{ {
FUNUTIL_ResetPlayer(index); g_pFunctionTable->pfnPlayerPreThink = nullptr;
//MF_Log("A bot connects, forwarded to fun! The bot is %d!", index); g_pengfuncsTable_Post->pfnTraceLine = nullptr;
//CPlayer* player;
RETURN_META(MRES_IGNORED);
} }
*/

View File

@ -11,7 +11,9 @@
// Fun Module // Fun Module
// //
#include "amxxmodule.h" #pragma once
#include <amxxmodule.h>
// Fun-specific defines below // Fun-specific defines below
#define GETCLIENTLISTENING (*g_engfuncs.pfnVoice_GetClientListening) #define GETCLIENTLISTENING (*g_engfuncs.pfnVoice_GetClientListening)
@ -29,19 +31,181 @@
#define HITGROUP_RIGHTARM 5 // 32 #define HITGROUP_RIGHTARM 5 // 32
#define HITGROUP_LEFTLEG 6 // 64 #define HITGROUP_LEFTLEG 6 // 64
#define HITGROUP_RIGHTLEG 7 // 128 #define HITGROUP_RIGHTLEG 7 // 128
#define HITGROUP_MAX 8
extern DLL_FUNCTIONS *g_pFunctionTable;
extern enginefuncs_t *g_pengfuncsTable_Post;
void PlayerPreThink(edict_t *pEntity);
void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *shooter, TraceResult *ptr);
static const auto kHitGroupsBits = (1 << HITGROUP_MAX) - 1;
static const auto kMaxClients = 32u;
class CPlayer
{
public:
CPlayer()
{
Clear();
}
public:
bool HasBodyHits() const
{
for (auto i = 1; i <= gpGlobals->maxClients; ++i)
{
if (GetBodyHits(i) != kHitGroupsBits)
{
return true;
}
}
return false;
}
int GetBodyHits(const int other) const
{
return bodyHits_[other];
}
void SetBodyHits(const int other, const int flags)
{
bodyHits_[other] = flags;
}
void SetBodyHits(const int flags)
{
memset(bodyHits_, flags, sizeof bodyHits_);
}
public:
bool HasSilentFootsteps() const
{
return silentFootsteps_;
}
void SetSilentFootsteps(const bool state)
{
silentFootsteps_ = state;
}
public:
void Clear()
{
SetBodyHits(kHitGroupsBits);
SetSilentFootsteps(false);
}
private:
int bodyHits_[kMaxClients + 1];
bool silentFootsteps_ {};
};
class CPlayers
{
using Internal = CPlayer;
public:
bool HaveBodyHits() const
{
for (auto i = 1; i <= gpGlobals->maxClients; ++i)
{
if (players_[i].HasBodyHits())
{
return true;
}
}
return false;
}
void SetBodyHits(const int attacker, const int target, const int flags)
{
players_[attacker].SetBodyHits(target, flags);
}
void SetTargetsBodyHits(const int attacker, const int flags)
{
players_[attacker].SetBodyHits(flags);
}
void SetAttackersBodyHits(const int target, const int flags)
{
for (auto i = 1; i <= gpGlobals->maxClients; ++i)
{
players_[i].SetBodyHits(target, flags);
}
}
void SetEveryoneBodyHits(const int flags)
{
for (auto i = 1; i <= gpGlobals->maxClients; ++i)
{
players_[i].SetBodyHits(flags);
}
}
public:
bool HaveSilentFootsteps() const
{
for (auto i = 1; i <= gpGlobals->maxClients; ++i)
{
if (players_[i].HasSilentFootsteps())
{
return true;
}
}
return false;
}
public:
void Clear()
{
for (auto i = 1; i <= gpGlobals->maxClients; ++i)
{
players_[i].Clear();
}
}
public:
Internal& operator [](const size_t index)
{
return players_[index];
}
const Internal& operator [](const size_t index) const
{
return players_[index];
}
private:
Internal players_[kMaxClients + 1];
};
#define CHECK_ENTITY(x) \ #define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \ if ((x) < 0 || (x) > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \ return 0; \
} else { \ } else { \
if (x <= gpGlobals->maxClients) { \ if ((x) <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \ if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \ return 0; \
} \ } \
} else { \ } else { \
if (x != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \ if ((x) != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \ return 0; \
} \ } \
@ -49,7 +213,7 @@
} }
#define CHECK_PLAYER(x) \ #define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \ if ((x) < 1 || (x) > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \ return 0; \
} else { \ } else { \

View File

@ -119,8 +119,8 @@
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */ // #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */ // #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */ // #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
// #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */ #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
#define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */ // #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */ // #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
// #define FN_StartFrame StartFrame /* pfnStartFrame() */ // #define FN_StartFrame StartFrame /* pfnStartFrame() */
// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */ // #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */

Some files were not shown because too many files have changed in this diff Show More