Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rsKliPPy committed Feb 22, 2017
0 parents commit 97cf95b
Show file tree
Hide file tree
Showing 16 changed files with 7,855 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Binaries
*.dll
*.exe
*.so

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
build/
obj-*/

# Visual Studio 2015 cache/options directory
.vs/
.vscode/

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# Files generated by Mac OS X Finder
.DS_Store

# Files generated by Windows Explorer
Desktop.ini
Thumbs.db
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "amtl"]
path = public/amtl
url = https://github.com/alliedmodders/amtl
170 changes: 170 additions & 0 deletions AMBuildScript
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import os

#
# Detect Metamod and HLSDK
#

def detectMetamod():
metamod_path = builder.options.metamod_path
if not len(metamod_path):
metamod_path = os.getenv('METAMOD', '')

if len(metamod_path):
metamod_path = os.path.join(builder.originalCwd, metamod_path)
if not os.path.exists(os.path.join(metamod_path, 'metamod')):
raise Exception('Metamod path does not exist: {0}'.format(metamod_path))
else:
try_paths = [
os.path.join(builder.sourcePath, '..', 'metamod'),
os.path.join(builder.sourcePath, '..', 'metamod-am'),
os.path.join(builder.sourcePath, '..', 'metamod-hl1'),
]
for try_path in try_paths:
if os.path.exists(os.path.join(try_path, 'metamod')):
metamod_path = os.path.normpath(try_path)
break
if not metamod_path:
raise Exception('Could not find the source code to Metamod! Try passing --metamod to configure.py.')

return metamod_path

def detectHlsdk():
hlsdk_path = builder.options.hlsdk_path
if not len(hlsdk_path):
hlsdk_path = os.getenv('HLSDK', '')

if len(hlsdk_path):
hlsdk_path = os.path.join(builder.originalCwd, hlsdk_path)
if not os.path.exists(hlsdk_path):
raise Exception('Metamod path does not exist: {0}'.format(hlsdk_path))
else:
try_paths = [
os.path.join(builder.sourcePath, '..', 'hlsdk'),
]
for try_path in try_paths:
if os.path.exists(try_path):
hlsdk_path = os.path.normpath(try_path)
break
if not hlsdk_path:
raise Exception('Could not find the HLSDK! Try passing --hlsdk to configure.py.')

return hlsdk_path


metamod_path = detectMetamod()
hlsdk_path = detectHlsdk()

#
# Compiler settings
#
cxx = builder.DetectCompilers()

cxx.defines += [
'HAVE_STDINT_H'
]

if cxx.like('gcc'):
cxx.cflags += [
'-Wall',
'-Werror',
'-Wno-error=unused-result',
'-Wno-error=unused-variable',
'-Wno-unused-value',
'-fno-strict-aliasing',
'-fPIC',
'-m32'
]

cxx.cxxflags += [
'-std=c++11',
'-fno-exceptions',
'-fno-rtti'
]

cxx.linkflags += [
'-m32'
]

if builder.options.opt == '1':
cxx.cflags += ['-O2']

elif cxx.like('msvc'):
cxx.cflags += [
'/W3'
]

cxx.cxxflags += [
'/EHsc'
]

cxx.linkflags += [
'/MACHINE:X86',
'/SUBSYSTEM:WINDOWS',
'kernel32.lib',
'user32.lib',
'gdi32.lib',
'winspool.lib',
'comdlg32.lib',
'advapi32.lib',
'shell32.lib',
'ole32.lib',
'oleaut32.lib',
'uuid.lib',
'odbc32.lib',
'odbccp32.lib'
]

if builder.options.opt == '1':
cxx.cflags += ['/Ox']
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']

if builder.options.debug == '1':
cxx.cflags += ['/MTd', '/Od', '/RTC1']
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
else:
cxx.cflags += ['/MT']



# Optimization
if builder.options.opt == '1':
cxx.defines += ['NDEBUG']

# Debugging
if builder.options.debug == '1':
cxx.defines += ['DEBUG', '_DEBUG']


cxx.includes += [
os.path.join(metamod_path, 'metamod'),
os.path.join(hlsdk_path, 'common'),
os.path.join(hlsdk_path, 'public'),
os.path.join(hlsdk_path, 'engine'),
os.path.join(hlsdk_path, 'dlls'),
os.path.join(hlsdk_path, 'game_shared'),
os.path.join(hlsdk_path, 'pm_shared'),

os.path.join(builder.sourcePath, 'public'),
os.path.join(builder.sourcePath, 'public', 'amtl')
]


name = 'customentdata_amxx'
if builder.target_platform == 'linux':
name += '_i386'

binary = cxx.Library(name)
binary.sources += [
'source/amxx_api.cpp',
'source/module.cpp',
'source/natives.cpp',

'source/amxxsdk/amxxmodule.cpp'
]


#
# Run scripts, add binaries
#

builder.Add(binary)
24 changes: 24 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
API_VERSION = '2.1'

import sys
try:
from ambuild2 import run
if not run.HasAPI(API_VERSION):
raise Exception()
except:
sys.stderr.write('AMBuild {0} must be installed to build this project.\n'.format(API_VERSION))
sys.stderr.write('http://www.alliedmods.net/ambuild\n')
sys.exit(1)

prep = run.PrepareBuild(sourcePath=sys.path[0])
prep.default_build_folder = 'obj-' + prep.target_platform
prep.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
help='Enable debugging symbols')
prep.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
help='Enable optimization')
prep.options.add_option('--metamod', type='string', dest='metamod_path', default='',
help='Path to Metamod source code')
prep.options.add_option('--hlsdk', type='string', dest='hlsdk_path', default='',
help='Path to the HLSDK')

prep.Configure()
80 changes: 80 additions & 0 deletions plugins/include/customentdata.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#if defined _customentdata_included
#endinput
#endif
#define _customentdata_included


#pragma reqlib customentdata
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib customentdata
#endif


/**
* Sets custom entity data as cell
*
* @param entity Entity to set data for
* @param key Identifier for data
* @param data Data to be set
*
* @noreturn
*/
native CED_SetCell(entity, const key[], any:data);

/**
* Sets custom entity data as array
*
* @param entity Entity to set data for
* @param key Identifier for data
* @param data Data to be set
* @param size Size of the data array
*
* @noreturn
*/
native CED_SetArray(entity, const key[], const any:data[], size);

/**
* Sets custom entity data as string
*
* @param entity Entity to set data for
* @param key Identifier for data
* @param buffer Data to be set
*
* @noreturn
*/
native CED_SetString(entity, const key[], const buffer[]);

/**
* Gets custom entity data as cell
*
* @param entity Entity to get data for
* @param key Identifier for data
* @param data Variable to put data in
*
* @return true if data identified by |key| exists, false otherwise
*/
native bool:CED_GetCell(entity, const key[], &any:data);

/**
* Gets custom entity data as array
*
* @param entity Entity to get data for
* @param key Identifier for data
* @param data Array to fill with data
* @param size Maximum size of |data| array
*
* @return true if data identified by |key| exists, false otherwise
*/
native bool:CED_GetArray(entity, const key[], any:data[], size);

/**
* Gets custom entity data as string
*
* @param entity Entity to get data for
* @param key Identifier for data
* @param buffer Buffer to put string data in
* @param maxLength Maximum length of |buffer| buffer
*
* @return true if data identified by |key| existed, false otherwise
*/
native bool:CED_GetString(entity, const key[], buffer[], maxLength);
1 change: 1 addition & 0 deletions public/amtl
Submodule amtl added at b0550f
Loading

0 comments on commit 97cf95b

Please sign in to comment.