Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: mapchange crash, and latest amtl/amxmodx support. #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if cxx.like('gcc'):
]

cxx.cxxflags += [
'-std=c++11',
'-std=gnu++14',
'-fno-exceptions',
'-fno-rtti'
]
Expand All @@ -100,7 +100,7 @@ elif cxx.like('msvc'):
cxx.linkflags += [
'/MACHINE:X86',
'/SUBSYSTEM:WINDOWS',

'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'kernel32.lib'
]

Expand Down Expand Up @@ -156,4 +156,5 @@ binary.sources += [
# Run scripts, add binaries
#

builder.Add(binary)
builder.Add(binary)

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Amxx-Module-CustomEntityData
API for saving custom entity data easily through AMXX plugins

# Linux
Since libgcc_s.so.1 and libstdc++.so.6 bundled with HLDS for Linux are too old, install the latest GCC and place symbolic links to the respective libraries.

1. install gcc over than 11.3.1
2. command execute.

+ cd /[your hlds directory]/

+ mv libgcc_s.so.1 libgcc_s.so.1.bk
+ mv libstdc++.so.6 libstdc++.so.6.bk

+ ln -s /usr/lib/libgcc_s.so.1 libgcc_s.so.1
+ ln -s /usr/lib/libstdc++.so.6 libstdc++.so.6
182 changes: 182 additions & 0 deletions public/IGameConfigs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/

#ifndef _INCLUDE_IGAMECONFIG_H_
#define _INCLUDE_IGAMECONFIG_H_

#include <ITextParsers.h>

enum class FieldType
{
FIELD_NONE,
FIELD_FLOAT, // Floating point value
FIELD_STRINGINT, // String ID (return from ALLOC_STRING)
FIELD_STRINGPTR, // String, pointer-to-char
FIELD_STRING, // String, fixed size
FIELD_CLASSPTR, // Classes pointer derived of CBaseEntity
FIELD_CLASS, // Arbitrary classes, direct
FIELD_STRUCTURE, // Arbitrary structures, direct
FIELD_EHANDLE, // Entity handle
FIELD_ENTVARS, // entvars_t*
FIELD_EDICT, // edict_t*
FIELD_VECTOR, // Vector
FIELD_POINTER, // Arbitrary data pointer
FIELD_INTEGER, // Integer or enum
FIELD_FUNCTION, // Class function pointer (Think, Use, etc)
FIELD_BOOLEAN, // Boolean
FIELD_SHORT, // 2 bytes integer
FIELD_CHARACTER, // 1 byte
};

struct TypeDescription
{
TypeDescription()
{
reset();
}

void reset()
{
fieldType = FieldType::FIELD_NONE;
fieldOffset = 0;
fieldSize = 0;
fieldUnsigned = false;
}

FieldType fieldType;
int fieldOffset;
int fieldSize;
bool fieldUnsigned;
};

/**
* @brief Describes a game private data config file
*/
class IGameConfig
{
public:
/**
* @brief Returns an offset value.
*
* @param key Key to retrieve from the offset section.
* @param value Pointer to store the TypeDescription reference in.
* @return True if found, false otherwise.
*/
virtual bool GetOffset(const char *key, TypeDescription *value) = 0;

/**
* @brief Returns an offset value from given class.
*
* @param classname class name to match from the offset section.
* @param key Key to retrieve from the offset section.
* @param value Pointer to store the TypeDescription reference in.
* @return True if found, false otherwise.
*/
virtual bool GetOffsetByClass(const char *classname, const char *key, TypeDescription *value) = 0;

/**
* @brief Returns the value of a key from the "Keys" section.
*
* @param key Key to retrieve from the Keys section.
* @return String containing the value, or NULL if not found.
*/
virtual const char *GetKeyValue(const char *key) = 0;

/**
* @brief Retrieves a cached memory signature.
*
* @param key Name of the signature.
* @param addr Pointer to store the memory address in.
* (NULL is copied if signature is not found in binary).
* @return True if the section exists and key for current
* platform was found, false otherwise.
*/
virtual bool GetMemSig(const char *key, void **addr) = 0;

/**
* @brief Retrieves the value of an address from the "Address" section.
*
* @param key Key to retrieve from the Address section.
* @param addr Pointer to store the memory address.
* @return True on success, false on failure.
*/
virtual bool GetAddress(const char *key, void **addr) = 0;
};

/**
* @brief Manages game config files
*/
class IGameConfigManager
{
public:
/**
* @brief Loads or finds an already loaded game config file.
*
* @param file File to load. The path must be relative to the
* 'gamedata' folder and the extension should be
* omitted.
* @param pConfig Pointer to store the game config pointer. Pointer
* will be valid even on failure.
* @param error Optional error message buffer.
* @param maxlength Maximum length of the error buffer.
* @return True on success, false if the file failed.
*/
virtual bool LoadGameConfigFile(const char *file, IGameConfig **pConfig, char *error, size_t maxlength) = 0;

/**
* @brief Closes an IGameConfig pointer. Since a file can be loaded
* more than once, the file will not actually be removed from memory
* until it is closed once for each call to LoadGameConfigfile().
*
* @param cfg Pointer to the IGameConfig to close.
*/
virtual void CloseGameConfigFile(IGameConfig *cfg) = 0;

/**
* @brief Adds a custom gamedata section hook.
*
* @param sectionname Section name to hook.
* @param listener Listener callback.
* @noreturn
*/
virtual void AddUserConfigHook(const char *sectionname, ITextListener_SMC *listener) = 0;

/**
* @brief Removes a custom gamedata section hook.
*
* @param sectionname Section name to unhook.
* @param listener Listener callback.
* @noreturn
*/
virtual void RemoveUserConfigHook(const char *sectionname, ITextListener_SMC *listener) = 0;
};

#endif //_INCLUDE_IGAMECONFIG_H_
Loading